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__HttpStatus__HpcCourse.ae...

366 lines
933 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[170,6,7],{"+NIl":function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){"use strict";oe.defineMode("stex",function($,D){"use strict";function Z(L,A){L.cmdState.push(A)}function F(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function M(L){var A=L.cmdState.pop();A&&A.closeBracket()}function z(L){for(var A=L.cmdState,C=A.length-1;C>=0;C--){var u=A[C];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function H(L,A,C){return function(){this.name=L,this.bracketNo=0,this.style=A,this.styles=C,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var N={};N.importmodule=H("importmodule","tag",["string","builtin"]),N.documentclass=H("documentclass","tag",["","atom"]),N.usepackage=H("usepackage","tag",["atom"]),N.begin=H("begin","tag",["atom"]),N.end=H("end","tag",["atom"]),N.label=H("label","tag",["atom"]),N.ref=H("ref","tag",["atom"]),N.eqref=H("eqref","tag",["atom"]),N.cite=H("cite","tag",["atom"]),N.bibitem=H("bibitem","tag",["atom"]),N.Bibitem=H("Bibitem","tag",["atom"]),N.RBibitem=H("RBibitem","tag",["atom"]),N.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function R(L,A){L.f=A}function v(L,A){var C;if(L.match(/^\\[a-zA-Z@]+/)){var u=L.current().slice(1);return C=N.hasOwnProperty(u)?N[u]:N.DEFAULT,C=new C,Z(A,C),R(A,O),C.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return R(A,function(l,h){return T(l,h,"\\]")}),"keyword";if(L.match("\\("))return R(A,function(l,h){return T(l,h,"\\)")}),"keyword";if(L.match("$$"))return R(A,function(l,h){return T(l,h,"$$")}),"keyword";if(L.match("$"))return R(A,function(l,h){return T(l,h,"$")}),"keyword";var o=L.next();if(o=="%")return L.skipToEnd(),"comment";if(o=="}"||o=="]"){if(C=F(A),C)C.closeBracket(o),R(A,O);else return"error";return"bracket"}else return o=="{"||o=="["?(C=N.DEFAULT,C=new C,Z(A,C),"bracket"):/\d/.test(o)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),C=z(A),C.name=="begin"&&(C.argument=L.current()),C.styleIdentifier())}function T(L,A,C){if(L.eatSpace())return null;if(C&&L.match(C))return R(A,v),"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 O(L,A){var C=L.peek(),u;return C=="{"||C=="["?(u=F(A),u.openBracket(C),L.eat(C),R(A,v),"bracket"):/[ \t\r]/.test(C)?(L.eat(C),null):(R(A,v),M(A),v(L,A))}return{startState:function(){var L=D.inMathMode?function(A,C){return T(A,C)}:v;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,A){return A.f(L,A)},blankLine:function(L){L.f=v,L.cmdState.length=0},lineComment:"%"}}),oe.defineMIME("text/x-stex","stex"),oe.defineMIME("text/x-latex","stex")})},"19Vz":function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){oe.defineOption("placeholder","",function(H,N,R){var v=R&&R!=oe.Init;if(N&&!v)H.on("blur",F),H.on("change",M),H.on("swapDoc",M),oe.on(H.getInputField(),"compositionupdate",H.state.placeholderCompose=function(){Z(H)}),M(H);else if(!N&&v){H.off("blur",F),H.off("change",M),H.off("swapDoc",M),oe.off(H.getInputField(),"compositionupdate",H.state.placeholderCompose),$(H);var T=H.getWrapperElement();T.className=T.className.replace(" CodeMirror-empty","")}N&&!H.hasFocus()&&F(H)});function $(H){H.state.placeholder&&(H.state.placeholder.parentNode.removeChild(H.state.placeholder),H.state.placeholder=null)}function D(H){$(H);var N=H.state.placeholder=document.createElement("pre");N.style.cssText="height: 0; overflow: visible",N.style.direction=H.getOption("direction"),N.className="CodeMirror-placeholder CodeMirror-line-like";var R=H.getOption("placeholder");typeof R=="string"&&(R=document.createTextNode(R)),N.appendChild(R),H.display.lineSpace.insertBefore(N,H.display.lineSpace.firstChild)}function Z(H){setTimeout(function(){var N=!1,R=H.getInputField();R.nodeName=="TEXTAREA"?N=!R.value:H.lineCount()==1&&(N=!/[^\u200b]/.test(R.querySelector(".CodeMirror-line").textContent)),N?D(H):$(H)},20)}function F(H){z(H)&&D(H)}function M(H){var N=H.getWrapperElement(),R=z(H);N.className=N.className.replace(" CodeMirror-empty","")+(R?" CodeMirror-empty":""),R?D(H):$(H)}function z(H){return H.lineCount()===1&&H.getLine(0)===""}})},"1eCo":function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){"use strict";var $={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};oe.defineMode("xml",function(Z,F){var M=Z.indentUnit,z={},H=F.htmlMode?$:D;for(var N in H)z[N]=H[N];for(var N in F)z[N]=F[N];var R,v;function T(a,b){function m(U){return b.tokenize=U,U(a,b)}var E=a.next();if(E=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?m(A("atom","]]>")):null:a.match("--")?m(A("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),m(C(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=A("meta","?>"),"meta"):(R=a.eat("/")?"closeTag":"openTag",b.tokenize=O,"tag bracket");if(E=="&"){var B;return a.eat("#")?a.eat("x")?B=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):B=a.eatWhile(/[\d]/)&&a.eat(";"):B=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),B?"atom":"error"}else return a.eatWhile(/[^&<]/),null}T.isInText=!0;function O(a,b){var m=a.next();if(m==">"||m=="/"&&a.eat(">"))return b.tokenize=T,R=m==">"?"endTag":"selfcloseTag","tag bracket";if(m=="=")return R="equals",null;if(m=="<"){b.tokenize=T,b.state=h,b.tagName=b.tagStart=null;var E=b.tokenize(a,b);return E?E+" tag error":"tag error"}else return/[\'\"]/.test(m)?(b.tokenize=L(m),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(a){var b=function(m,E){for(;!m.eol();)if(m.next()==a){E.tokenize=O;break}return"string"};return b.isInAttribute=!0,b}function A(a,b){return function(m,E){for(;!m.eol();){if(m.match(b)){E.tokenize=T;break}m.next()}return a}}function C(a){return function(b,m){for(var E;(E=b.next())!=null;){if(E=="<")return m.tokenize=C(a+1),m.tokenize(b,m);if(E==">")if(a==1){m.tokenize=T;break}else return m.tokenize=C(a-1),m.tokenize(b,m)}return"meta"}}function u(a,b,m){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=m,(z.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,b){for(var m;;){if(!a.context)return;if(m=a.context.tagName,!z.contextGrabbers.hasOwnProperty(m)||!z.contextGrabbers[m].hasOwnProperty(b))return;o(a)}}function h(a,b,m){return a=="openTag"?(m.tagStart=b.column(),w):a=="closeTag"?y:h}function w(a,b,m){return a=="word"?(m.tagName=b.current(),v="tag",x):z.allowMissingTagName&&a=="endTag"?(v="tag bracket",x(a,b,m)):(v="error",w)}function y(a,b,m){if(a=="word"){var E=b.current();return m.context&&m.context.tagName!=E&&z.implicitlyClosed.hasOwnProperty(m.context.tagName)&&o(m),m.context&&m.context.tagName==E||z.matchClosing===!1?(v="tag",g):(v="tag error",k)}else return z.allowMissingTagName&&a=="endTag"?(v="tag bracket",g(a,b,m)):(v="error",k)}function g(a,b,m){return a!="endTag"?(v="error",g):(o(m),h)}function k(a,b,m){return v="error",g(a,b,m)}function x(a,b,m){if(a=="word")return v="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var E=m.tagName,B=m.tagStart;return m.tagName=m.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(E)?l(m,E):(l(m,E),m.context=new u(m,E,B==m.indented)),h}return v="error",x}function f(a,b,m){return a=="equals"?p:(z.allowMissing||(v="error"),x(a,b,m))}function p(a,b,m){return a=="string"?d:a=="word"&&z.allowUnquoted?(v="string",x):(v="error",x(a,b,m))}function d(a,b,m){return a=="string"?d:x(a,b,m)}return{startState:function(a){var b={tokenize:T,state:h,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;R=null;var m=b.tokenize(a,b);return(m||R)&&m!="comment"&&(v=null,b.state=b.state(R||m,a,b),v&&(m=v=="error"?m+" error":v)),m},indent:function(a,b,m){var E=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+M;if(E&&E.noIndent)return oe.Pass;if(a.tokenize!=O&&a.tokenize!=T)return m?m.match(/^(\s*)/)[0].length:0;if(a.tagName)return z.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+M*(z.multilineTagIndentFactor||1);if(z.alignCDATA&&/<!\[CDATA\[/.test(b))return 0;var B=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);if(B&&B[1])for(;E;)if(E.tagName==B[2]){E=E.prev;break}else if(z.implicitlyClosed.hasOwnProperty(E.tagName))E=E.prev;else break;else if(B)for(;E;){var U=z.contextGrabbers[E.tagName];if(U&&U.hasOwnProperty(B[2]))E=E.prev;else break}for(;E&&E.prev&&!E.startOfLine;)E=E.prev;return E?E.indent+M:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==p&&(a.state=x)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],m=a.context;m;m=m.prev)m.tagName&&b.push(m.tagName);return b.reverse()}}}),oe.defineMIME("text/xml","xml"),oe.defineMIME("application/xml","xml"),oe.mimeModes.hasOwnProperty("text/html")||oe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"7Cbv":function(Tt,ut,he){"use strict";var oe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),$=new Uint8Array(16);function D(){if(!oe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oe($)}var Z=/^(?:[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 F(O){return typeof O=="string"&&Z.test(O)}for(var M=F,z=[],H=0;H<256;++H)z.push((H+256).toString(16).substr(1));function N(O){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(z[O[L+0]]+z[O[L+1]]+z[O[L+2]]+z[O[L+3]]+"-"+z[O[L+4]]+z[O[L+5]]+"-"+z[O[L+6]]+z[O[L+7]]+"-"+z[O[L+8]]+z[O[L+9]]+"-"+z[O[L+10]]+z[O[L+11]]+z[O[L+12]]+z[O[L+13]]+z[O[L+14]]+z[O[L+15]]).toLowerCase();if(!M(A))throw TypeError("Stringified UUID is invalid");return A}var R=N;function v(O,L,A){O=O||{};var C=O.random||(O.rng||D)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,L){A=A||0;for(var u=0;u<16;++u)L[A+u]=C[u];return L}return R(C)}var T=ut.a=v},"7ahc":function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return w});var oe=he("k1fw"),$=he("0Owb"),D=he("+L6B"),Z=he("2/Rp"),F=he("y8nQ"),M=he("Vl3Y"),z=he("tJVT"),H=he("OaEy"),N=he("2fM7"),R=he("q1tI"),v=he.n(R),T=he("VrN/"),O=he.n(T),L=he("p77/"),A=he.n(L),C=he("c5Ni"),u=he.n(C),o=N.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"]};ut.b=function(y){var g=y.callback,k=y.onCancel,x=Object(R.useState)("python"),f=Object(z.a)(x,2),p=f[0],d=f[1];function a(m){d(h[m][1])}function b(m){g(m)}return v.a.createElement(M.a,Object($.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),v.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(N.a,{onChange:a},Object.keys(h).map(function(m){return v.a.createElement(o,{key:m,value:m},h[m][0])}))),v.a.createElement(M.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(w,{mode:p})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(Z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement(Z.a,{type:"ghost",onClick:k},"\u53D6\u6D88")))};function w(y){var g=y.value,k=y.onChange,x=y.mode,f=y.options,p=f===void 0?{}:f,d=Object(R.useRef)(),a=Object(R.useState)(),b=Object(z.a)(a,2),m=b[0],E=b[1];return Object(R.useEffect)(function(){if(m){function B(U){var K=U.getValue();k&&k(K)}return m.on("change",B),function(){m.off("change",B)}}},[m,k]),Object(R.useEffect)(function(){m&&m.setOption("mode",x)},[m,x]),Object(R.useEffect)(function(){m&&((g!==m.getValue()||g==="")&&setTimeout(function(){m.setValue(g||" ")},300))},[m,g]),Object(R.useEffect)(function(){if(d.current&&!m){var B=O.a.fromTextArea(d.current,Object(oe.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));E(B)}},[d.current,m]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:d}))}},"7ixt":function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return D});var oe={adjustX:1,adjustY:1},$=[0,0],D={left:{points:["cr","cl"],overflow:oe,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:oe,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:oe,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:oe,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:oe,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:oe,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:oe,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:oe,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:oe,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:oe,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:oe,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:oe,offset:[-4,0],targetOffset:$}},Z=D},"8EBN":function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){"use strict";oe.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var $=0;$<oe.modeInfo.length;$++){var D=oe.modeInfo[$];D.mimes&&(D.mime=D.mimes[0])}oe.findModeByMIME=function(Z){Z=Z.toLowerCase();for(var F=0;F<oe.modeInfo.length;F++){var M=oe.modeInfo[F];if(M.mime==Z)return M;if(M.mimes){for(var z=0;z<M.mimes.length;z++)if(M.mimes[z]==Z)return M}}if(/\+xml$/.test(Z))return oe.findModeByMIME("application/xml");if(/\+json$/.test(Z))return oe.findModeByMIME("application/json")},oe.findModeByExtension=function(Z){Z=Z.toLowerCase();for(var F=0;F<oe.modeInfo.length;F++){var M=oe.modeInfo[F];if(M.ext){for(var z=0;z<M.ext.length;z++)if(M.ext[z]==Z)return M}}},oe.findModeByFileName=function(Z){for(var F=0;F<oe.modeInfo.length;F++){var M=oe.modeInfo[F];if(M.file&&M.file.test(Z))return M}var z=Z.lastIndexOf("."),H=z>-1&&Z.substring(z+1,Z.length);if(H)return oe.findModeByExtension(H)},oe.findModeByName=function(Z){Z=Z.toLowerCase();for(var F=0;F<oe.modeInfo.length;F++){var M=oe.modeInfo[F];if(M.name.toLowerCase()==Z)return M;if(M.alias){for(var z=0;z<M.alias.length;z++)if(M.alias[z].toLowerCase()==Z)return M}}}})},"8hTe":function(Tt,ut,he){Tt.exports={button:"button___1wy9m"}},"9Bee":function(Tt,ut,he){"use strict";var oe=he("DYRE"),$=he("zeV3"),D=he("+L6B"),Z=he("2/Rp"),F=he("k1fw"),M=he("9og8"),z=he("tJVT"),H=he("WmNS"),N=he.n(H),R=he("q1tI"),v=he.n(R),T=he("vg9a"),O=he("DlQD"),L=he.n(O),A=he("rUJ1");function C(G,s){var c=G.match(/^(\s+)(?:```)/);if(c===null)return s;var I=c[1];return s.split(`
`).map(function(Q){var W=Q.match(/^\s+/);if(W===null)return Q;var ge=Object(z.a)(W,1),je=ge[0];return je.length>=I.length?Q.slice(I.length):Q}).join(`
`)}var u=[],o=["<ul>"],l=new L.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function w(){u.length=0,o=["<ul>"]}var y={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function g(G,s,c,I){if(s>=G.length||G[s].level<=c)return s;var Q=G[s];I.push("<li><a href='#"+Q.anchor+"'>"+Q.text+"</a>"),s++;var W=[];return s=g(G,s,Q.level,W),W.length>0&&(I.push("<ul>"),W.forEach(function(ge){I.push(ge)}),I.push("</ul>")),I.push("</li>"),s=g(G,s,c,I),s}function k(){return g(u,0,0,o),o.push("</ul>"),o.join("")}var x={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 I=c[0],Q=C(I,c[3]||""),W=c[2]?c[2].trim():c[2];if(["latex","katex","math"].indexOf(W)>=0){var ge=d(),je=Q;Q=ge,a[ge]={type:"block",expression:je}}return{type:"code",raw:I,lang:W,text:Q}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,d=function(){return"__special_katext_id_".concat(p++,"__")},a={};function b(){return a}function m(){p=0,a={}}function E(G){return G=G.replace(f,function(s,c){var I=d();return a[I]={type:"inline",expression:c},I}),G}var B=l.listitem;l.listitem=function(G){return B(E(G))};var U=l.paragraph;l.paragraph=function(G){return U(E(G))};var K=l.tablecell;l.tablecell=function(G,s){return K(E(G),s)},l.code=function(G,s,c){var I=(s||"").match(/\S*/)[0];return I?["latex","katex","math"].indexOf(I)>=0?"<p class='editormd-tex'>".concat(G,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?G:Object(A.escape)(G,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(c?G:Object(A.escape)(G,!0))+"</code></pre>"},l.heading=function(G,s,c){var I=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:I,level:s,text:G}),"<h"+s+' id="'+I+'">'+G+"</h"+s+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:x,renderer:l});var V=L.a,P=he("SJMd"),_=he("ulZh"),Y=he.n(_),ee=he("m3rI"),ae=he("Oy/b"),ce=he("p5ED"),De=he("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 Se=function(G,s){return(Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,I){c.__proto__=I}||function(c,I){for(var Q in I)Object.prototype.hasOwnProperty.call(I,Q)&&(c[Q]=I[Q])})(G,s)};function Ce(G,s){function c(){this.constructor=G}Se(G,s),G.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Ae(G,s,c,I){return new(c||(c=Promise))(function(Q,W){function ge(pt){try{Je(I.next(pt))}catch(He){W(He)}}function je(pt){try{Je(I.throw(pt))}catch(He){W(He)}}function Je(pt){var He;pt.done?Q(pt.value):(He=pt.value,He instanceof c?He:new c(function(vt){vt(He)})).then(ge,je)}Je((I=I.apply(G,s||[])).next())})}function Te(G,s){var c,I,Q,W,ge={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return W={next:je(0),throw:je(1),return:je(2)},typeof Symbol=="function"&&(W[Symbol.iterator]=function(){return this}),W;function je(Je){return function(pt){return function(He){if(c)throw new TypeError("Generator is already executing.");for(;ge;)try{if(c=1,I&&(Q=2&He[0]?I.return:He[0]?I.throw||((Q=I.return)&&Q.call(I),0):I.next)&&!(Q=Q.call(I,He[1])).done)return Q;switch(I=0,Q&&(He=[2&He[0],Q.value]),He[0]){case 0:case 1:Q=He;break;case 4:return ge.label++,{value:He[1],done:!1};case 5:ge.label++,I=He[1],He=[0];continue;case 7:He=ge.ops.pop(),ge.trys.pop();continue;default:if(!(Q=ge.trys,(Q=Q.length>0&&Q[Q.length-1])||He[0]!==6&&He[0]!==2)){ge=0;continue}if(He[0]===3&&(!Q||He[1]>Q[0]&&He[1]<Q[3])){ge.label=He[1];break}if(He[0]===6&&ge.label<Q[1]){ge.label=Q[1],Q=He;break}if(Q&&ge.label<Q[2]){ge.label=Q[2],ge.ops.push(He);break}Q[2]&&ge.ops.pop(),ge.trys.pop();continue}He=s.call(G,ge)}catch(vt){He=[6,vt],I=0}finally{c=Q=0}if(5&He[0])throw He[1];return{value:He[0]?He[1]:void 0,done:!0}}([Je,pt])}}}function ve(){for(var G=0,s=0,c=arguments.length;s<c;s++)G+=arguments[s].length;var I=Array(G),Q=0;for(s=0;s<c;s++)for(var W=arguments[s],ge=0,je=W.length;ge<je;ge++,Q++)I[Q]=W[ge];return I}var le=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,c){for(var I=0,Q=c;I<Q.length;I++){var W=Q[I],ge=W[0],je=W[1];s.setAttribute(ge,je)}},G.createRect=function(s,c,I){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",c.toString()),I&&G.setAttributes(Q,I),Q},G.createLine=function(s,c,I,Q,W){var ge=document.createElementNS("http://www.w3.org/2000/svg","line");return ge.setAttribute("x1",s.toString()),ge.setAttribute("y1",c.toString()),ge.setAttribute("x2",I.toString()),ge.setAttribute("y2",Q.toString()),W&&G.setAttributes(ge,W),ge},G.createPolygon=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","polygon");return I.setAttribute("points",s),c&&G.setAttributes(I,c),I},G.createCircle=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","circle");return I.setAttribute("cx",(s/2).toString()),I.setAttribute("cy",(s/2).toString()),I.setAttribute("r",s.toString()),c&&G.setAttributes(I,c),I},G.createEllipse=function(s,c,I){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(c/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(c/2).toString()),I&&G.setAttributes(Q,I),Q},G.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(c,s),c},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,c,I,Q,W,ge,je){var Je=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Je,[["id",s],["orient",c],["markerWidth",I.toString()],["markerHeight",Q.toString()],["refX",W.toString()],["refY",ge.toString()]]),Je.appendChild(je),Je},G.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&G.setAttributes(c,s),c},G.createTSpan=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","tspan");return I.textContent=s,c&&G.setAttributes(I,c),I},G.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(c,s),c},G.createPoint=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return I.x=s,I.y=c,I},G.createPath=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","path");return I.setAttribute("d",s),c&&G.setAttributes(I,c),I},G}(),te=function(){function G(){}return G.addKey=function(s){G.key=s},Object.defineProperty(G,"isLicensed",{get:function(){return!!G.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(G.key)},enumerable:!1,configurable:!0}),G}(),de=function(){function G(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return G.prototype.rasterize=function(s,c,I){var Q=this;return new Promise(function(W){var ge=I!==void 0?I:document.createElement("canvas");s===null&&(Q.markersOnly=!0,Q.naturalSize=!1);var je=document.createElementNS("http://www.w3.org/2000/svg","svg");je.setAttribute("xmlns","http://www.w3.org/2000/svg"),je.setAttribute("width",c.width.baseVal.valueAsString),je.setAttribute("height",c.height.baseVal.valueAsString),je.setAttribute("viewBox","0 0 "+c.viewBox.baseVal.width.toString()+" "+c.viewBox.baseVal.height.toString()),je.innerHTML=c.innerHTML,Q.naturalSize===!0?(je.width.baseVal.value=s.naturalWidth,je.height.baseVal.value=s.naturalHeight):Q.width!==void 0&&Q.height!==void 0&&(je.width.baseVal.value=Q.width,je.height.baseVal.value=Q.height),ge.width=je.width.baseVal.value,ge.height=je.height.baseVal.value;var Je=je.outerHTML,pt=ge.getContext("2d");Q.markersOnly!==!0&&pt.drawImage(s,0,0,ge.width,ge.height);var He=window.URL,vt=new Image(ge.width,ge.height);vt.setAttribute("crossOrigin","anonymous");var Ft=new Blob([Je],{type:"image/svg+xml"}),Xt=He.createObjectURL(Ft);vt.onload=function(){pt.drawImage(vt,0,0),He.revokeObjectURL(Xt);var _r=ge.toDataURL(Q.imageType,Q.imageQuality);W(_r)},vt.src=Xt})},G}(),ne=function(){},ke=function(){function G(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(G.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),G.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},G.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)},G.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 Oe("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Oe("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Oe("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new Ee("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new Ee("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},G.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},G}(),Oe=function(G,s){this.selector=G,this.style=s},Ee=function(G,s){this.localName=G,this.style=s},Re=function(){function G(s,c,I,Q,W){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=c,this.markerItems=I,this.uiStyleSettings=Q,this.styles=W,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return G.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 I=document.createElement("div");I.className=this.toolbarBlockStyleClass.name,I.style.whiteSpace="nowrap",this.uiContainer.appendChild(I),this.addActionButton(I,'<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(I,'<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(I,'<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(I,'<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(I,'<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(I,'<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(I,'<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(I,'<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(W){var ge=document.createElement("div");ge.className=""+c.toolbarButtonStyleClass.name,ge.setAttribute("data-type-name",W.typeName),ge.innerHTML=W.icon,ge.addEventListener("click",function(){c.markerToolbarButtonClicked(ge,W)}),c.buttons.push(ge),c.markerButtons.push(ge)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var Q=document.createElement("div");Q.className=this.toolbarBlockStyleClass.name,Q.style.whiteSpace="nowrap",Q.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(Q),this.addActionButton(Q,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(Q,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},G.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},G.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},G.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},G.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]))}},G.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")},G.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)})},G.prototype.addActionButton=function(s,c,I){var Q=this,W=document.createElement("div");switch(W.className=""+this.toolbarButtonStyleClass.name,W.innerHTML=c,W.setAttribute("data-action",I),W.addEventListener("click",function(){Q.actionToolbarButtonClicked(W,I)}),I){case"select":W.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":W.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":W.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":W.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":W.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(W),this.buttons.push(W)},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Ee("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ee("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 Ee("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ee("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Oe("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Oe("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},G.prototype.markerToolbarButtonClicked=function(s,c){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(I){return I("marker",c)}),this.markerButtonOverflowBlock.style.display="none"},G.prototype.actionToolbarButtonClicked=function(s,c){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(I){return I("action",c)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},G.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)},G.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(I){return I.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},G.prototype.setCurrentMarker=function(s){var c=this;this.currentMarker=s,this.buttons.filter(function(I){return/delete|notes/.test(I.getAttribute("data-action"))}).forEach(function(I){c.currentMarker===void 0?(I.style.fillOpacity="0.4",I.style.pointerEvents="none"):(I.style.fillOpacity="1",I.style.pointerEvents="all")})},G}(),Be=function(){function G(s,c,I,Q){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=c,this.uiStyleSettings=I,this.styles=Q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return G.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new Ee("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 Ee("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var c=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Ee("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Ee("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Ee("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 Ee("toolbox-panel-row_colors",`
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Ee("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 Ee("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Ee("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Oe("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Oe("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},G.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)},G.prototype.setPanelButtons=function(s){var c,I,Q=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+" "+((I=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&I!==void 0?I:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(W){var ge;W.uiStyleSettings=Q.uiStyleSettings;var je=document.createElement("div");je.className=Q.toolboxButtonStyleClass.name+" "+((ge=Q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ge!==void 0?ge:Q.toolboxButtonStyleColorsClass.name),je.innerHTML=W.icon,je.title=W.title,je.addEventListener("click",function(){Q.panelButtonClick(W)}),Q.panelButtons.push(je),Q.buttonRow.appendChild(je)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},G.prototype.panelButtonClick=function(s){var c=this,I=-1;if(s!==this.activePanel){I=this.panels.indexOf(s),this.panelRow.innerHTML="";var Q=s.getUi();Q.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(Q),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){c.displayMode==="inline"?c.panelRow.style.display="none":c.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(W,ge){var je,Je;W.className=c.toolboxButtonStyleClass.name+" "+(ge===I?""+((je=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&je!==void 0?je:c.toolboxActiveButtonStyleColorsClass.name):""+((Je=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Je!==void 0?Je:c.toolboxButtonStyleColorsClass.name))})},G}(),ze=function(G,s){this.title=G,this.icon=s},Fe=function(G){function s(c,I,Q,W){var ge=G.call(this,c,W||'<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 ge.colors=[],ge.addTransparent=!1,ge.colorBoxes=[],ge.colors=I,ge.currentColor=Q,ge.setCurrentColor=ge.setCurrentColor.bind(ge),ge.getColorBox=ge.getColorBox.bind(ge),ge}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");return I.style.overflow="hidden",I.style.whiteSpace="nowrap",this.colors.forEach(function(Q){var W=c.getColorBox(Q);I.appendChild(W),c.colorBoxes.push(W)}),I},s.prototype.getColorBox=function(c){var I=this,Q=this.uiStyleSettings.toolbarHeight/4,W=this.uiStyleSettings.toolbarHeight-Q,ge=document.createElement("div");ge.style.display="inline-block",ge.style.boxSizing="content-box",ge.style.width=W-2+"px",ge.style.height=W-2+"px",ge.style.padding="1px",ge.style.marginRight="2px",ge.style.marginBottom="2px",ge.style.borderWidth="2px",ge.style.borderStyle="solid",ge.style.borderRadius=(W+2)/2+"px",ge.style.borderColor=c===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ge.addEventListener("click",function(){I.setCurrentColor(c,ge)});var je=document.createElement("div");return je.style.display="inline-block",je.style.width=W-2+"px",je.style.height=W-2+"px",je.style.backgroundColor=c,je.style.borderRadius=W/2+"px",c==="transparent"&&(je.style.fill=this.uiStyleSettings.toolboxAccentColor,je.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>`),ge.appendChild(je),ge},s.prototype.setCurrentColor=function(c,I){var Q=this;this.currentColor=c,this.colorBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(c)},s}(ze),Ue=function(){function G(s,c,I){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=c,this.globalSettings=I,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(G.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),G.prototype.ownsTarget=function(s){return!1},Object.defineProperty(G.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),G.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},G.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},G.prototype.pointerDown=function(s,c){},G.prototype.dblClick=function(s,c){},G.prototype.manipulate=function(s){},G.prototype.pointerUp=function(s){this.stateChanged()},G.prototype.dispose=function(){},G.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},G.prototype.getState=function(){return{typeName:G.typeName,state:this.state,notes:this.notes}},G.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},G.prototype.scale=function(s,c){},G.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},G.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},G.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)}},G.typeName="MarkerBase",G}(),Ie=function(){function G(){this.findGripByVisual=this.findGripByVisual.bind(this)}return G.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},G}(),it=function(){function G(){this.GRIP_SIZE=10,this.visual=le.createGroup(),this.visual.appendChild(le.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(le.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return G.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},G}(),Ye=function(){function G(){}return G.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},G.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},G}(),Qe=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.left=0,W.top=0,W.width=0,W.height=0,W.defaultSize={x:50,y:20},W.offsetX=0,W.offsetY=0,W.rotationAngle=0,W.CB_DISTANCE=10,W._suppressMarkerCreateEvent=!1,W.container.transform.baseVal.appendItem(le.createTransform()),W.setupControlBox(),W}return Ce(s,G),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 I=le.createTransform();this._visual.transform.baseVal.appendItem(I)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!!G.prototype.ownsTarget.call(this,c)||!!(this.controlGrips.findGripByVisual(c)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(c))},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),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 Q=this.unrotatePoint(c);if(this.manipulationStartX=Q.x,this.manipulationStartY=Q.y,this.offsetX=Q.x-this.left,this.offsetY=Q.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(I),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(I)){this.activeGrip=this.rotatorGrip;var W=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=W.x-this.width/2,this.top=W.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ge=this.container.transform.baseVal.getItem(0);ge.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ge,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(c){var I=this.state;G.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",I==="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 I=this.unrotatePoint(c);this.state==="creating"?this.resize(c):this.state==="move"?(this.left=this.manipulationStartLeft+(I.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(I.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(I):this.state==="rotate"&&this.rotate(c)},s.prototype.resize=function(c){var I=this.manipulationStartLeft,Q=this.manipulationStartWidth,W=this.manipulationStartTop,ge=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:I=this.manipulationStartLeft+c.x-this.manipulationStartX,Q=this.manipulationStartWidth+this.manipulationStartLeft-I;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Q=this.manipulationStartWidth+c.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:W=this.manipulationStartTop+c.y-this.manipulationStartY,ge=this.manipulationStartHeight+this.manipulationStartTop-W;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ge=this.manipulationStartHeight+c.y-this.manipulationStartY}Q>=0?(this.left=I,this.width=Q):(this.left=I+Q,this.width=-Q),ge>=0?(this.top=W,this.height=ge):(this.top=W+ge,this.height=-ge),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 I=Math.sign(c.x-this.centerX);this.rotationAngle=180*Math.atan((c.y-this.centerY)/(c.x-this.centerX))/Math.PI+90*I,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 I=this.container.getCTM(),Q=le.createPoint(c.x,c.y);return{x:(Q=Q.matrixTransform(I)).x,y:Q.y}},s.prototype.unrotatePoint=function(c){if(this.rotationAngle===0)return c;var I=this.container.getCTM();I=I.inverse();var Q=le.createPoint(c.x,c.y);return{x:(Q=Q.matrixTransform(I)).x,y:Q.y}},s.prototype.select=function(){G.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){G.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.createGroup();var c=le.createTransform();c.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(c),this.container.appendChild(this.controlBox),this.controlRect=le.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=le.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Ie,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var 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 it;return c.visual.transform.baseVal.appendItem(le.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.controlGrips.topLeft.GRIP_SIZE,I=-c/2,Q=I,W=(this.width+this.CB_DISTANCE)/2-c/2,ge=(this.height+this.CB_DISTANCE)/2-c/2,je=this.height+this.CB_DISTANCE-c/2,Je=this.width+this.CB_DISTANCE-c/2;this.positionGrip(this.controlGrips.topLeft.visual,I,Q),this.positionGrip(this.controlGrips.topCenter.visual,W,Q),this.positionGrip(this.controlGrips.topRight.visual,Je,Q),this.positionGrip(this.controlGrips.centerLeft.visual,I,ge),this.positionGrip(this.controlGrips.centerRight.visual,Je,ge),this.positionGrip(this.controlGrips.bottomLeft.visual,I,je),this.positionGrip(this.controlGrips.bottomCenter.visual,W,je),this.positionGrip(this.controlGrips.bottomRight.visual,Je,je),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,W,Q-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(c,I,Q){var W=c.transform.baseVal.getItem(0);W.setTranslate(I,Q),c.transform.baseVal.replaceItem(W,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:Ye.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Ye.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},G.prototype.getState.call(this))},s.prototype.restoreState=function(c){G.prototype.restoreState.call(this,c);var I=c;this.left=I.left,this.top=I.top,this.width=I.width,this.height=I.height,this.rotationAngle=I.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Ye.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,I.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Ye.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,I.containerTransformMatrix))},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I);var Q=this.rotatePoint({x:this.left,y:this.top}),W=this.unrotatePoint({x:Q.x*c,y:Q.y*I});this.left=W.x,this.top=W.y,this.width=this.width*c,this.height=this.height*I,this.adjustControlBox()},s}(Ue),qe=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.fillColor="transparent",W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.opacity=1,W.setStrokeColor=W.setStrokeColor.bind(W),W.setFillColor=W.setFillColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.createVisual=W.createVisual.bind(W),W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=le.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){G.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){G.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){G.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&le.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},G.prototype.getState.call(this))},s.prototype.restoreState=function(c){var I=c;this.fillColor=I.fillColor,this.strokeColor=I.strokeColor,this.strokeWidth=I.strokeWidth,this.strokeDasharray=I.strokeDasharray,this.opacity=I.opacity,this.createVisual(),G.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),this.setSize()},s.title="Rectangle marker",s}(Qe),ct=function(G){function s(c,I,Q,W){var ge=G.call(this,c,W||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ge.widths=[],ge.widthBoxes=[],ge.widths=I,ge.currentWidth=Q,ge.setCurrentWidth=ge.setCurrentWidth.bind(ge),ge}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");return I.style.display="flex",I.style.overflow="hidden",I.style.flexGrow="2",this.widths.forEach(function(Q){var W=document.createElement("div");W.style.display="flex",W.style.flexGrow="2",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.borderColor=Q===c.currentWidth?c.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){c.setCurrentWidth(Q,W)}),I.appendChild(W);var ge=document.createElement("div");ge.innerText=Q.toString(),ge.style.marginRight="5px",W.appendChild(ge);var je=document.createElement("div");je.style.minHeight="20px",je.style.flexGrow="2",je.style.display="flex",je.style.alignItems="center";var Je=document.createElement("hr");Je.style.minWidth="20px",Je.style.border="0px",Je.style.borderTop=Q+"px solid "+c.uiStyleSettings.toolboxColor,Je.style.flexGrow="2",je.appendChild(Je),W.appendChild(je),c.widthBoxes.push(W)}),I},s.prototype.setCurrentWidth=function(c,I){var Q=this;this.currentWidth=c,this.widthBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(ze),et=function(G){function s(c,I,Q,W){var ge=G.call(this,c,W||'<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 ge.styles=[],ge.styleBoxes=[],ge.styles=I,ge.currentStyle=Q,ge.setCurrentStyle=ge.setCurrentStyle.bind(ge),ge}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");return I.style.display="flex",I.style.overflow="hidden",I.style.flexGrow="2",this.styles.forEach(function(Q){var W=document.createElement("div");W.style.display="flex",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.overflow="hidden",W.style.maxWidth=100/c.styles.length-5+"%",W.style.borderColor=Q===c.currentStyle?c.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){c.setCurrentStyle(Q,W)}),I.appendChild(W);var ge=document.createElement("div");ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.overflow="hidden";var je=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+c.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Q!==""?'stroke-dasharray="'+Q+'"':"")+` />
</svg>`;ge.innerHTML=je,W.appendChild(ge),c.styleBoxes.push(W)}),I},s.prototype.setCurrentStyle=function(c,I){var Q=this;this.currentStyle=c,this.styleBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(ze),nt=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.strokeColor=Q.defaultColor,W.strokeWidth=Q.defaultStrokeWidth,W.strokeDasharray=Q.defaultStrokeDasharray,W.strokePanel=new Fe("Line color",Q.defaultColorSet,Q.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new ct("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return Ce(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=G.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}(qe),Pe=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},dt=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.x1=0,W.y1=0,W.x2=0,W.y2=0,W.defaultLength=50,W.manipulationStartX=0,W.manipulationStartY=0,W.manipulationStartX1=0,W.manipulationStartY1=0,W.manipulationStartX2=0,W.manipulationStartY2=0,W.setupControlBox(),W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!!G.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),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(I)?this.activeGrip=this.grip1:this.grip2.ownsTarget(I)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(c){var I=this.state;G.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",I==="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(){G.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){G.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=le.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var c=new it;return c.visual.transform.baseVal.appendItem(le.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,I,Q){var W=c.transform.baseVal.getItem(0);W.setTranslate(I,Q),c.transform.baseVal.replaceItem(W,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},G.prototype.getState.call(this))},s.prototype.restoreState=function(c){G.prototype.restoreState.call(this,c);var I=c;this.x1=I.x1,this.y1=I.y1,this.x2=I.x2,this.y2=I.y2},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),this.x1=this.x1*c,this.y1=this.y1*I,this.x2=this.x2*c,this.y2=this.y2*I,this.adjustVisual(),this.adjustControlBox()},s}(Ue),at=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.setStrokeColor=W.setStrokeColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.strokeColor=Q.defaultColor,W.strokeWidth=Q.defaultStrokeWidth,W.strokeDasharray=Q.defaultStrokeDasharray,W.strokePanel=new Fe("Line color",Q.defaultColorSet,Q.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new ct("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorLine&&c!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.selectorLine=le.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=le.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),le.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(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},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){G.prototype.restoreState.call(this,c);var I=c;this.strokeColor=I.strokeColor,this.strokeWidth=I.strokeWidth,this.strokeDasharray=I.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}(dt),Me=function(G){function s(c,I,Q,W){var ge=G.call(this,c,W||'<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 ge.fonts=[],ge.fontBoxes=[],ge.fonts=I,ge.currentFont=Q,ge.setCurrentFont=ge.setCurrentFont.bind(ge),ge}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");return I.style.overflow="hidden",I.style.flexGrow="2",this.fonts.forEach(function(Q){var W=document.createElement("div");W.style.display="inline-block",W.style.alignItems="center",W.style.justifyContent="space-between",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.overflow="hidden",W.style.maxWidth=100/c.fonts.length-5+"%",W.style.borderColor=Q===c.currentFont?c.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){c.setCurrentFont(Q,W)}),I.appendChild(W);var ge=document.createElement("div");ge.style.display="flex",ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.fontFamily=Q,ge.style.overflow="hidden";var je=document.createElement("div");je.style.whiteSpace="nowrap",je.style.overflow="hidden",je.style.textOverflow="ellipsis",je.innerHTML="The quick brown fox jumps over the lazy dog",ge.appendChild(je),W.appendChild(ge),c.fontBoxes.push(W)}),I},s.prototype.setCurrentFont=function(c,I){var Q=this;this.currentFont=c,this.fontBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(ze),Ge=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.color="transparent",W.padding=5,W.DEFAULT_TEXT="your text here",W.text=W.DEFAULT_TEXT,W.isMoved=!1,W.color=Q.defaultColor,W.fontFamily=Q.defaultFontFamily,W.defaultSize={x:100,y:30},W.setColor=W.setColor.bind(W),W.setFont=W.setFont.bind(W),W.renderText=W.renderText.bind(W),W.sizeText=W.sizeText.bind(W),W.textEditDivClicked=W.textEditDivClicked.bind(W),W.showTextEditor=W.showTextEditor.bind(W),W.setSize=W.setSize.bind(W),W.positionTextEditor=W.positionTextEditor.bind(W),W.colorPanel=new Fe("Color",Q.defaultColorSet,Q.defaultColor),W.colorPanel.onColorChanged=W.setColor,W.fontFamilyPanel=new Me("Font",Q.defaultFontFamilies,Q.defaultFontFamily),W.fontFamilyPanel.onFontChanged=W.setFont,W}return Ce(s,G),s.prototype.ownsTarget=function(c){if(G.prototype.ownsTarget.call(this,c)||c===this.visual||c===this.textElement||c===this.bgRectangle)return!0;var I=!1;return this.textElement.childNodes.forEach(function(Q){Q===c&&(I=!0)}),I},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.bgRectangle=le.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=le.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.textElement.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),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(I){c.textElement.appendChild(le.createTSpan(I.trim()===""?" ":I.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var c=this.textElement.getBBox(),I=1;if(c.width>0&&c.height>0){var Q=(1*this.width-this.width*this.padding*2/100)/c.width,W=(1*this.height-this.height*this.padding*2/100)/c.height;I=Math.min(Q,W)}return I},s.prototype.getTextPosition=function(c){var I=this.textElement.getBBox(),Q=0,W=0;return I.width>0&&I.height>0&&(Q=(this.width-I.width*c)/2,W=this.height/2-I.height*c/2),{x:Q,y:W}},s.prototype.sizeText=function(){var c=this.textElement.getBBox(),I=this.getTextScale(),Q=this.getTextPosition(I);Q.y-=c.y*I,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Q.x+"px, "+Q.y+"px) scale("+I+", "+I+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Q.x,Q.y),this.textElement.transform.baseVal.getItem(1).setScale(I,I))},s.prototype.manipulate=function(c){G.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){G.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){G.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(c){var I=this.state;I==="creating"&&(this._suppressMarkerCreateEvent=!0),G.prototype.pointerUp.call(this,c),this.setSize(),(I==="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(I){I.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var I=Number.parseFloat(c.textEditor.style.fontSize);c.textEditor.clientWidth>=Number.parseInt(c.textEditor.style.maxWidth)&&I>.9;)I-=.1,c.textEditor.style.fontSize=Math.max(I,.9)+"em"}),this.textEditor.addEventListener("keyup",function(I){I.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(I){if(I.clipboardData){var Q=I.clipboardData.getData("text"),W=window.getSelection();if(!W.rangeCount)return!1;W.deleteFromDocument(),W.getRangeAt(0).insertNode(document.createTextNode(Q)),I.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(),I=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Q=this.textElement.getBBox(),W={x:Q.width*c,y:Q.height*c};I.x-=W.x/2,I.y-=W.y/2,this.textEditor.style.top=I.y+"px",this.textEditor.style.left=I.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-I.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(){G.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),G.prototype.deselect.call(this)},s.prototype.dblClick=function(c,I){G.prototype.dblClick.call(this,c,I),this.showTextEditor()},s.prototype.setColor=function(c){this.textElement&&le.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&&le.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},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var I=c;this.color=I.color,this.fontFamily=I.fontFamily,this.padding=I.padding,this.text=I.text,this.createVisual(),G.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),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),xe=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.color="transparent",W.lineWidth=3,W.drawing=!1,W.pixelRatio=1,W.color=Q.defaultColor,W.lineWidth=Q.defaultStrokeWidth,W.pixelRatio=Q.freehandPixelRatio,W.setColor=W.setColor.bind(W),W.addCanvas=W.addCanvas.bind(W),W.finishCreation=W.finishCreation.bind(W),W.setLineWidth=W.setLineWidth.bind(W),W.colorPanel=new Fe("Color",Q.defaultColorSet,Q.defaultColor),W.colorPanel.onColorChanged=W.setColor,W.lineWidthPanel=new ct("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),W.lineWidthPanel.onWidthChanged=W.setLineWidth,W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=le.createGroup(),this.drawingImage=le.createImage(),this.visual.appendChild(this.drawingImage);var c=le.createTransform();this.visual.transform.baseVal.appendItem(c),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,I){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):G.prototype.pointerDown.call(this,c,I)},s.prototype.manipulate=function(c){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(c.x,c.y),this.canvasContext.stroke()):G.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){G.prototype.resize.call(this,c),le.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):G.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(),G.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),G.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var c=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),I=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Q=I[0],W=I[1],ge=I[2],je=I[3],Je=!1,pt=0;pt<this.canvasElement.height;pt++)for(var He=0;He<this.canvasElement.width;He++)c.data[pt*this.canvasElement.width*4+4*He+3]>0&&(Je=!0,pt<W&&(W=pt),He<Q&&(Q=He),pt>je&&(je=pt),He>ge&&(ge=He));if(Je){this.left=Q/this.pixelRatio,this.top=W/this.pixelRatio,this.width=(ge-Q)/this.pixelRatio,this.height=(je-W)/this.pixelRatio;var vt=document.createElement("canvas");vt.width=ge-Q,vt.height=je-W,vt.getContext("2d").putImageData(this.canvasContext.getImageData(Q,W,ge-Q,je-W),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(){le.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),le.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(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},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),G.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),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),me=function(G){function s(c,I,Q){var W=G.call(this,c,Q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return W.typeBoxes=[],W.currentType=I,W.setCurrentType=W.setCurrentType.bind(W),W}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");I.style.display="flex",I.style.overflow="hidden",I.style.flexGrow="2";for(var Q=function(je){var Je="both";switch(je){case 0:Je="both";break;case 1:Je="start";break;case 2:Je="end";break;case 3:Je="none"}var pt=document.createElement("div");if(pt.style.display="flex",pt.style.flexGrow="2",pt.style.alignItems="center",pt.style.justifyContent="space-between",pt.style.padding="5px",pt.style.borderWidth="2px",pt.style.borderStyle="solid",pt.style.borderColor=Je===W.currentType?W.uiStyleSettings.toolboxAccentColor:"transparent",pt.addEventListener("click",function(){c.setCurrentType(Je,pt)}),I.appendChild(pt),Je==="both"||Je==="start"){var He=document.createElement("div");He.style.display="flex",He.style.alignItems="center",He.style.minHeight="20px",He.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="`+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,He.style.marginLeft="5px",pt.appendChild(He)}var vt=document.createElement("div");vt.style.display="flex",vt.style.alignItems="center",vt.style.minHeight="20px",vt.style.flexGrow="2";var Ft=document.createElement("hr");if(Ft.style.minWidth="20px",Ft.style.border="0px",Ft.style.borderTop="3px solid "+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee"),Ft.style.flexGrow="2",vt.appendChild(Ft),pt.appendChild(vt),Je==="both"||Je==="end"){var Xt=document.createElement("div");Xt.style.display="flex",Xt.style.alignItems="center",Xt.style.minHeight="20px",Xt.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="`+(W.uiStyleSettings!==void 0?W.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Xt.style.marginRight="5px",pt.appendChild(Xt)}W.typeBoxes.push(pt)},W=this,ge=0;ge<4;ge++)Q(ge);return I},s.prototype.setCurrentType=function(c,I){var Q=this;this.currentType=c,this.typeBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings!==void 0?Q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(ze),ye=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.arrowType="end",W.arrowBaseHeight=10,W.arrowBaseWidth=10,W.getArrowPoints=W.getArrowPoints.bind(W),W.setArrowType=W.setArrowType.bind(W),W.arrowTypePanel=new me("Arrow type","end"),W.arrowTypePanel.onArrowTypeChanged=W.setArrowType,W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.arrow1&&c!==this.arrow2)},s.prototype.getArrowPoints=function(c,I){var Q=this.arrowBaseWidth+2*this.strokeWidth,W=this.arrowBaseHeight+2*this.strokeWidth;return c-Q/2+","+(I+W/2)+" "+c+","+(I-W/2)+" "+(c+Q/2)+","+(I+W/2)},s.prototype.createTips=function(){this.arrow1=le.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=le.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(G.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",le.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),le.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),I=this.arrow1.transform.baseVal.getItem(0);I.setRotate(c,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(I,0);var Q=this.arrow2.transform.baseVal.getItem(0);Q.setRotate(c+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Q,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},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){G.prototype.restoreState.call(this,c);var I=c;this.arrowType=I.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(at),re=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.fillColor=Q.defaultFillColor,W.strokeWidth=0,W.fillPanel=new Fe("Color",Q.defaultColorSet,Q.defaultFillColor),W.fillPanel.onColorChanged=W.setFillColor,W}return Ce(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=G.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}(qe),ie=function(G){function s(c,I,Q,W){var ge=G.call(this,c,W||'<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 ge.opacities=[],ge.opacityBoxes=[],ge.opacities=I,ge.currentOpacity=Q,ge.setCurrentOpacity=ge.setCurrentOpacity.bind(ge),ge}return Ce(s,G),s.prototype.getUi=function(){var c=this,I=document.createElement("div");return I.style.display="flex",I.style.overflow="hidden",I.style.flexGrow="2",I.style.justifyContent="space-between",this.opacities.forEach(function(Q){var W=document.createElement("div");W.style.display="flex",W.style.alignItems="center",W.style.justifyContent="center",W.style.padding="5px",W.style.borderWidth="2px",W.style.borderStyle="solid",W.style.borderColor=Q===c.currentOpacity?c.uiStyleSettings.toolboxAccentColor:"transparent",W.addEventListener("click",function(){c.setCurrentOpacity(Q,W)}),I.appendChild(W);var ge=document.createElement("div");ge.innerText=100*Q+"%",W.appendChild(ge),c.opacityBoxes.push(W)}),I},s.prototype.setCurrentOpacity=function(c,I){var Q=this;this.currentOpacity=c,this.opacityBoxes.forEach(function(W){W.style.borderColor=W===I?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(ze),se=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.setOpacity=W.setOpacity.bind(W),W.fillColor=Q.defaultHighlightColor,W.strokeWidth=0,W.opacity=Q.defaultHighlightOpacity,W.fillPanel=new Fe("Color",Q.defaultColorSet,W.fillColor),W.fillPanel.onColorChanged=W.setFillColor,W.opacityPanel=new ie("Opacity",Q.defaultOpacitySteps,W.opacity),W.opacityPanel.onOpacityChanged=W.setOpacity,W}return Ce(s,G),s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&le.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=G.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}(re),pe='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',be=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.bgColor="transparent",W.tipPosition={x:0,y:0},W.tipBase1Position={x:0,y:0},W.tipBase2Position={x:0,y:0},W.tipMoving=!1,W.color=Q.defaultStrokeColor,W.bgColor=Q.defaultFillColor,W.fontFamily=Q.defaultFontFamily,W.defaultSize={x:100,y:30},W.setBgColor=W.setBgColor.bind(W),W.getTipPoints=W.getTipPoints.bind(W),W.positionTip=W.positionTip.bind(W),W.setTipPoints=W.setTipPoints.bind(W),W.colorPanel=new Fe("Text color",Q.defaultColorSet,W.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>'),W.colorPanel.onColorChanged=W.setColor,W.bgColorPanel=new Fe("Fill color",Q.defaultColorSet,W.bgColor,pe),W.bgColorPanel.onColorChanged=W.setBgColor,W.fontFamilyPanel=new Me("Font",Q.defaultFontFamilies,Q.defaultFontFamily),W.fontFamilyPanel.onFontChanged=W.setFont,W.tipGrip=new it,W.tipGrip.visual.transform.baseVal.appendItem(le.createTransform()),W.controlBox.appendChild(W.tipGrip.visual),W}return Ce(s,G),s.prototype.ownsTarget=function(c){return G.prototype.ownsTarget.call(this,c)||this.tipGrip.ownsTarget(c)||this.tip===c},s.prototype.createTip=function(){le.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=le.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(c,I){this.state==="new"&&G.prototype.pointerDown.call(this,c,I),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(I)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):G.prototype.pointerDown.call(this,c,I)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,G.prototype.pointerUp.call(this,c);else{var I=this.state==="creating";G.prototype.pointerUp.call(this,c),this.setTipPoints(I),this.positionTip()}},s.prototype.manipulate=function(c){if(this.tipMoving){var I=this.unrotatePoint(c);this.tipPosition={x:I.x-this.manipulationStartLeft,y:I.y-this.manipulationStartTop},this.positionTip()}else G.prototype.manipulate.call(this,c)},s.prototype.setBgColor=function(c){this.bgRectangle&&this.tip&&(le.setAttributes(this.bgRectangle,[["fill",c]]),le.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 I=Math.min(this.height/2,15),Q=this.height/5;c&&(this.tipPosition={x:I+Q/2,y:this.height+20});var W=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?W<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,I=Math.min(this.width/2,15),this.tipBase1Position={x:I,y:0},this.tipBase2Position={x:I+Q,y:0}):(this.tipBase1Position={x:0,y:I},this.tipBase2Position={x:0,y:I+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?W<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,I=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-I-Q,y:0},this.tipBase2Position={x:this.width-I,y:0}):(this.tipBase1Position={x:this.width,y:I},this.tipBase2Position={x:this.width,y:I+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?W<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,I=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-I-Q,y:this.height},this.tipBase2Position={x:this.width-I,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-I-Q},this.tipBase2Position={x:this.width,y:this.height-I}):W<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,I=Math.min(this.width/2,15),this.tipBase1Position={x:I,y:this.height},this.tipBase2Position={x:I+Q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-I},this.tipBase2Position={x:0,y:this.height-I-Q})},s.prototype.resize=function(c){G.prototype.resize.call(this,c),this.positionTip()},s.prototype.positionTip=function(){le.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(),G.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var I=c;this.bgColor=I.bgColor,this.tipPosition=I.tipPosition,G.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),this.tipPosition={x:this.tipPosition.x*c,y:this.tipPosition.y*I},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}(Ge),_e=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.fillColor="transparent",W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.opacity=1,W.strokeColor=Q.defaultColor,W.strokeWidth=Q.defaultStrokeWidth,W.strokeDasharray=Q.defaultStrokeDasharray,W.fillColor=Q.defaultFillColor,W.setStrokeColor=W.setStrokeColor.bind(W),W.setFillColor=W.setFillColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.setOpacity=W.setOpacity.bind(W),W.createVisual=W.createVisual.bind(W),W.strokePanel=new Fe("Line color",ve(Q.defaultColorSet,["transparent"]),Q.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.fillPanel=new Fe("Fill color",ve(Q.defaultColorSet,["transparent"]),W.fillColor,pe),W.fillPanel.onColorChanged=W.setFillColor,W.strokeWidthPanel=new ct("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W.opacityPanel=new ie("Opacity",Q.defaultOpacitySteps,W.opacity),W.opacityPanel.onOpacityChanged=W.setOpacity,W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=le.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){G.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){G.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),le.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(c){G.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&le.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&le.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(c),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&le.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&le.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&le.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var I=c;this.fillColor=I.fillColor,this.strokeColor=I.strokeColor,this.strokeWidth=I.strokeWidth,this.strokeDasharray=I.strokeDasharray,this.opacity=I.opacity,this.createVisual(),G.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,I){G.prototype.scale.call(this,c,I),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),We=function(G){function s(c,I,Q){return G.call(this,c,I,Q)||this}return Ce(s,G),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!G.prototype.ownsTarget.call(this,c)&&c!==this.tip1&&c!==this.tip2)},s.prototype.createTips=function(){this.tip1=le.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.tip1),this.tip2=le.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(le.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(G.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(le.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),I=this.tip1.transform.baseVal.getItem(0);I.setRotate(c,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(I,0);var Q=this.tip2.transform.baseVal.getItem(0);Q.setRotate(c+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Q,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=G.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){G.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}(at),$e=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.strokePanel.colors=Q.defaultColorSet,W.fillColor="transparent",W}return Ce(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=G.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}(_e),st=function(){function G(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(G.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),G.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))},G.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},G.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},G.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}},G.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},G}(),Ze=function(G){function s(c,I,Q){var W=G.call(this,c,I,Q)||this;return W.strokeColor="transparent",W.strokeWidth=0,W.strokeDasharray="",W.curveX=0,W.curveY=0,W.manipulationStartCurveX=0,W.manipulationStartCurveY=0,W.setStrokeColor=W.setStrokeColor.bind(W),W.setStrokeWidth=W.setStrokeWidth.bind(W),W.setStrokeDasharray=W.setStrokeDasharray.bind(W),W.positionGrips=W.positionGrips.bind(W),W.addControlGrips=W.addControlGrips.bind(W),W.adjustVisual=W.adjustVisual.bind(W),W.setupControlBox=W.setupControlBox.bind(W),W.resize=W.resize.bind(W),W.strokeColor=Q.defaultColor,W.strokeWidth=Q.defaultStrokeWidth,W.strokeDasharray=Q.defaultStrokeDasharray,W.strokePanel=new Fe("Line color",Q.defaultColorSet,Q.defaultColor),W.strokePanel.onColorChanged=W.setStrokeColor,W.strokeWidthPanel=new ct("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),W.strokeWidthPanel.onWidthChanged=W.setStrokeWidth,W.strokeStylePanel=new et("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),W.strokeStylePanel.onStyleChanged=W.setStrokeDasharray,W}return Ce(s,G),s.prototype.ownsTarget=function(c){return!(!G.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=le.createGroup(),this.selectorCurve=le.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=le.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,I){G.prototype.pointerDown.call(this,c,I),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(I)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),le.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),le.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),le.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){G.prototype.setupControlBox.call(this),this.curveControlLine1=le.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=le.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,G.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){G.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),G.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),G.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,I){this.curveX=this.curveX*c,this.curveY=this.curveY*I,G.prototype.scale.call(this,c,I)},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},G.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){G.prototype.restoreState.call(this,c);var I=c;this.strokeColor=I.strokeColor,this.strokeWidth=I.strokeWidth,this.strokeDasharray=I.strokeDasharray,this.curveX=I.curveX,this.curveY=I.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}(dt),St=function(){function G(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(G.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),G.prototype.preventDefault=function(){this._defaultPrevented=!0},G}(),Et=function(G){function s(c,I,Q){var W=G.call(this,c,!1)||this;return W.dataUrl=I,W.state=Q,W}return Ce(s,G),s}(St),lt=function(G){function s(c,I,Q){Q===void 0&&(Q=!1);var W=G.call(this,c,Q)||this;return W.marker=I,W}return Ce(s,G),s}(St),Pt=function(){function G(){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 G.prototype.addEventListener=function(s,c){this[s].push(c)},G.prototype.removeEventListener=function(s,c){var I=this[s].indexOf(c);I>-1&&this[s].splice(I,1)},G}(),_t=function(){function G(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 Pe,this._isOpen=!1,this.undoRedoManager=new st,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new Pt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=G.instanceCounter++,this.styles=new ke(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(G.prototype,"ALL_MARKER_TYPES",{get:function(){return[nt,xe,ye,Ge,$e,_e,se,be,We,re,at,Ze]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[nt,xe,ye,Ge,_e,se,be]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"BASIC_MARKER_TYPES",{get:function(){return[nt,xe,ye,Ge,se]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var c=this;this._availableMarkerTypes.splice(0),s.forEach(function(I){if(typeof I=="string"){var Q=c.ALL_MARKER_TYPES.find(function(W){return W.typeName===I});Q!==void 0&&c._availableMarkerTypes.push(Q)}else c._availableMarkerTypes.push(I)})},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),G.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),te.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},G.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&ne.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=ne.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(c){return c(new St(s))})},G.prototype.render=function(){return Ae(this,void 0,void 0,function(){var s;return Te(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new de).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()]}})})},G.prototype.close=function(s){var c=this;if(s===void 0&&(s=!1),this.isOpen){var I=!1;s||this.eventListeners.beforeclose.forEach(function(Q){var W=new St(c,!0);Q(W),W.defaultPrevented&&(I=!0)}),I||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(Q){return Q(new St(c))}),this.detachEvents(),this._isOpen=!1)}},G.prototype.addMarkersToToolbar=function(){for(var s,c=[],I=0;I<arguments.length;I++)c[I]=arguments[I];(s=this._availableMarkerTypes).push.apply(s,c)},G.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},G.prototype.removeRenderEventListener=function(s){},G.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},G.prototype.removeCloseEventListener=function(s){},G.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))},G.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,I=c<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(c,I)},G.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},G.prototype.resize=function(s,c){this._isResizing=!0;var I=s/this.imageWidth,Q=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(I,Q),this._isResizing=!1},G.prototype.scaleMarkers=function(s,c){var I,Q=this;this._currentMarker&&this._currentMarker instanceof Ge?this._currentMarker.scale(s,c):(I=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(W){W!==Q._currentMarker&&W.scale(s,c)}),I!==void 0&&this.setCurrentMarker(I)},G.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"},G.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.top},G.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)},G.prototype.addDefs=function(){for(var s,c=[],I=0;I<arguments.length;I++)c[I]=arguments[I];this.defs=le.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,c)},G.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},G.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)},G.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},G.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},G.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)},G.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},G.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)},G.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()},G.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")},G.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"},G.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},G.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 Re(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 Be(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},G.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},G.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},G.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())},G.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()}},G.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Q){var W=new lt(s,s._currentMarker,!0);Q(W),W.defaultPrevented&&(c=!0)}),!c){var I=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(Q){return Q(new lt(s,I))})}}},G.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ge){var je=new lt(s,void 0,!0);ge(je),je.defaultPrevented&&(c=!0)}),!c)){this.setCurrentMarker();for(var I=function(ge){var je=Q.markers[ge];Q.setCurrentMarker(Q.markers[ge]),Q._currentMarker.dispose(),Q.markerImage.removeChild(Q._currentMarker.container),Q.markers.splice(Q.markers.indexOf(Q._currentMarker),1),Q.eventListeners.markerdelete.forEach(function(Je){return Je(new lt(s,je))})},Q=this,W=this.markers.length-1;W>=0;W--)I(W);this.addUndoStep()}},Object.defineProperty(G.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),G.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))},G.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)},G.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},G.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var c=this.getState(),I=this.undoRedoManager.getLastUndoStep();if(!I||I.width===c.width&&I.height===c.height){var Q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(c),Q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(W){return W(new St(s))})}else this.undoRedoManager.replaceLastUndoStep(c),this.eventListeners.statechange.forEach(function(W){return W(new St(s))})}},G.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},G.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(I){return I(new St(s))}))},G.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},G.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(I){return I(new St(s))}))},G.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},G.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},G.prototype.startRenderAndClose=function(){return Ae(this,void 0,void 0,function(){var s,c,I=this;return Te(this,function(Q){switch(Q.label){case 0:return[4,this.render()];case 1:return s=Q.sent(),c=this.getState(),this.eventListeners.render.forEach(function(W){return W(new Et(I,s,c))}),this.close(!0),[2]}})})},G.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var c={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(I){return c.markers.push(I.getState())}),c},G.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(I){var Q=c._availableMarkerTypes.find(function(ge){return ge.typeName===I.typeName});if(Q!==void 0){var W=c.addNewMarker(Q);W.restoreState(I),c.markers.push(W)}}),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(I){return I(new St(c))})},G.prototype.addNewMarker=function(s){var c=le.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},G.prototype.createNewMarker=function(s){var c,I=this;(c=typeof s=="string"?this._availableMarkerTypes.find(function(Q){return Q.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(Q){return Q(new lt(I,I._currentMarker))}))},G.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof xe&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(xe):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(I){return I(new lt(c,c._currentMarker))})},G.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},G.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},G.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(I){return I(new lt(c,s))})},G.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(I){return I(new lt(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(I){return I(new lt(c,c._currentMarker))}))},G.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(I){return I.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))},G.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var c=this.markers.find(function(I){return I.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()}},G.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}))},G.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()},G.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},G.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},G.prototype.clientToLocalCoordinates=function(s,c){var I=this.markerImage.getBoundingClientRect();return{x:(s-I.left)/this.zoomLevel,y:(c-I.top)/this.zoomLevel}},G.prototype.onWindowResize=function(){this.positionUI()},G.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()},G.prototype.addLicenseKey=function(s){te.addKey(s)},G.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},G.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},G.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(G.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),G.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 St(s))}))},G.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 St(s))}))},G.instanceCounter=0,G}();/* **********************************
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 Mt=function(G,s){return(Mt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,I){c.__proto__=I}||function(c,I){for(var Q in I)Object.prototype.hasOwnProperty.call(I,Q)&&(c[Q]=I[Q])})(G,s)};function jt(G,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=G}Mt(G,s),G.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Lt(G,s,c,I){return new(c||(c=Promise))(function(Q,W){function ge(pt){try{Je(I.next(pt))}catch(He){W(He)}}function je(pt){try{Je(I.throw(pt))}catch(He){W(He)}}function Je(pt){var He;pt.done?Q(pt.value):(He=pt.value,He instanceof c?He:new c(function(vt){vt(He)})).then(ge,je)}Je((I=I.apply(G,s||[])).next())})}function pr(G,s){var c,I,Q,W,ge={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return W={next:je(0),throw:je(1),return:je(2)},typeof Symbol=="function"&&(W[Symbol.iterator]=function(){return this}),W;function je(Je){return function(pt){return function(He){if(c)throw new TypeError("Generator is already executing.");for(;ge;)try{if(c=1,I&&(Q=2&He[0]?I.return:He[0]?I.throw||((Q=I.return)&&Q.call(I),0):I.next)&&!(Q=Q.call(I,He[1])).done)return Q;switch(I=0,Q&&(He=[2&He[0],Q.value]),He[0]){case 0:case 1:Q=He;break;case 4:return ge.label++,{value:He[1],done:!1};case 5:ge.label++,I=He[1],He=[0];continue;case 7:He=ge.ops.pop(),ge.trys.pop();continue;default:if(!(Q=ge.trys,(Q=Q.length>0&&Q[Q.length-1])||He[0]!==6&&He[0]!==2)){ge=0;continue}if(He[0]===3&&(!Q||He[1]>Q[0]&&He[1]<Q[3])){ge.label=He[1];break}if(He[0]===6&&ge.label<Q[1]){ge.label=Q[1],Q=He;break}if(Q&&ge.label<Q[2]){ge.label=Q[2],ge.ops.push(He);break}Q[2]&&ge.ops.pop(),ge.trys.pop();continue}He=s.call(G,ge)}catch(vt){He=[6,vt],I=0}finally{c=Q=0}if(5&He[0])throw He[1];return{value:He[0]?He[1]:void 0,done:!0}}([Je,pt])}}}var Kr=function(){function G(){}return G.addKey=function(s){G.key=s},Object.defineProperty(G,"isLicensed",{get:function(){return!!G.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(G.key)},enumerable:!1,configurable:!0}),G}(),bt=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,c){for(var I=0,Q=c;I<Q.length;I++){var W=Q[I],ge=W[0],je=W[1];s.setAttribute(ge,je)}},G.createRect=function(s,c,I){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",c.toString()),I&&G.setAttributes(Q,I),Q},G.createLine=function(s,c,I,Q,W){var ge=document.createElementNS("http://www.w3.org/2000/svg","line");return ge.setAttribute("x1",s.toString()),ge.setAttribute("y1",c.toString()),ge.setAttribute("x2",I.toString()),ge.setAttribute("y2",Q.toString()),W&&G.setAttributes(ge,W),ge},G.createPolygon=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","polygon");return I.setAttribute("points",s),c&&G.setAttributes(I,c),I},G.createCircle=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","circle");return I.setAttribute("cx",(s/2).toString()),I.setAttribute("cy",(s/2).toString()),I.setAttribute("r",s.toString()),c&&G.setAttributes(I,c),I},G.createEllipse=function(s,c,I){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(c/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(c/2).toString()),I&&G.setAttributes(Q,I),Q},G.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(c,s),c},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,c,I,Q,W,ge,je){var Je=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Je,[["id",s],["orient",c],["markerWidth",I.toString()],["markerHeight",Q.toString()],["refX",W.toString()],["refY",ge.toString()]]),Je.appendChild(je),Je},G.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&G.setAttributes(c,s),c},G.createTSpan=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","tspan");return I.textContent=s,c&&G.setAttributes(I,c),I},G.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(c,s),c},G.createPoint=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return I.x=s,I.y=c,I},G.createPath=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg","path");return I.setAttribute("d",s),c&&G.setAttributes(I,c),I},G.createElement=function(s,c){var I=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&G.setAttributes(I,c),I},G.getHollowRectanglePath=function(s,c,I,Q,W,ge,je,Je){return"M"+s+","+c+"V"+(c+Q)+"H"+(s+I)+"V"+c+"H"+W+"V"+ge+"H"+(W+je)+"V"+(ge+Je)+"H"+W+"V"+c+"Z"},G}(),Nr=function(){function G(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(G.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),G.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},G.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)},G.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 mr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new mr("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},G.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},G}(),hr=function(G,s){this.selector=G,this.style=s},mr=function(G,s){this.localName=G,this.style=s},Br=function(){function G(){this.blocks=[],this.display=""}return G.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},G.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},G.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},G}(),ci=function(){function G(){}return G.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},G}(),qr=function(G){function s(){var c=G!==null&&G.apply(this,arguments)||this;return c.buttons=[],c}return jt(s,G),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=G.prototype.getUI.call(this);return this.buttons.forEach(function(I){return c.appendChild(I.getUI())}),c},s}(ci),Bt=function(){function G(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(G.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),G.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},G.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,"")))},G.prototype.hide=function(){this._isHidden=!0},G}(),ft=function(G){function s(){var c=G!==null&&G.apply(this,arguments)||this;return c.elements=[],c}return jt(s,G),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=G.prototype.getUI.call(this);return this.elements.forEach(function(I){return c.appendChild(I)}),c},s}(ci),Hr=function(){function G(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(G.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),G.prototype.getVerticalLength=function(s){return s/this.ratio},G.prototype.getHorizontalLength=function(s){return s*this.ratio},G}(),ei=function(){function G(){}return G.getIcon=function(s,c){if(s>0&&c>0){var I=new Hr(s,c),Q=I.ratio>=1?20:I.getHorizontalLength(20),W=I.ratio<1?20:I.getVerticalLength(20),ge=document.createElementNS("http://www.w3.org/2000/svg","svg");ge.setAttribute("xmlns","http://www.w3.org/2000/svg"),ge.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ge);var je=bt.createDefs();ge.appendChild(je);var Je=bt.createElement("clipPath",[["id","text-bg-clip"]]);je.appendChild(Je);var pt=bt.createPath(bt.getHollowRectanglePath((24-Q)/2,(24-W)/2,Q,W,(24-Q)/2+2,(24-W)/2+2,Q-4,W-4));ge.appendChild(pt);var He=bt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);He.appendChild(bt.createTSpan(s+":"+c)),ge.appendChild(He);var vt=He.getBBox();bt.setAttributes(He,[["x",((24-vt.width)/2).toString()],["y",((24-vt.height)/2-vt.y).toString()]]);var Ft=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 Je.appendChild(Ft),bt.setAttributes(pt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ge),ge.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>'},G}(),gr=function(G){function s(c,I,Q){var W=G.call(this,c,I)||this;return W.isDropdownOpen=!1,W.onClick=W.dropdownButtonClicked,W.dropdownButtons=Q,W}return jt(s,G),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(I){I.className=c.className,I.colorsClassName=c.colorsClassName,c.dropdownBlock.appendChild(I.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}(Bt),Dt=function(){function G(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 G.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},G.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(I){return bt.setAttributes(I,[["cx",s.toString()],["cy",c.toString()]])})},G}(),Fr=function(){function G(s,c,I,Q){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=c,this.margin=I,this.container=Q,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(G.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(G.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(G.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),G.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(I){return s.gridContainer.appendChild(I)}),this.verticalGridLines.forEach(function(I){return s.gridContainer.appendChild(I)}),this.cropRectElement=bt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Dt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},G.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 I=c.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(W,ge){var je=c.y+I*(ge+1);bt.setAttributes(W,[["x1",""+c.x],["y1",""+je],["x2",""+(c.x+c.width)],["y2",""+je]])});var Q=c.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(W,ge){var je=c.x+Q*(ge+1);bt.setAttributes(W,[["x1",""+je],["y1",""+c.y],["x2",""+je],["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},G.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)},G.prototype.clientToLocalCoordinates=function(s,c){var I=this.container.getBoundingClientRect();return{x:s-I.left+this.margin,y:c-I.top+this.margin}},G.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)},G.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()},G.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},G.prototype.move=function(s){var c=s.x-this.previousPoint.x,I=s.y-this.previousPoint.y;this.zoomFactor!==1&&(c=-c/this.zoomFactor,I=-I/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+I),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},G.prototype.resize=function(s){var c=Object.assign({},this.cropRect),I=s.x-this.previousPoint.x,Q=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:c.x+I<this.margin&&(I=this.margin-c.x),c.x+=I,c.width=this.cropRect.x+this.cropRect.width-c.x;break;case this.bottomRightGrip:case this.topRightGrip:c.width+I>this.canvasWidth*this.zoomFactor&&(I=this.canvasWidth*this.zoomFactor-c.width),c.width+=I}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(I),c.height=this.aspectRatio.getVerticalLength(c.width)):(c.y+=Q,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+=Q}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))},G.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,I=this.aspectRatio.getHorizontalLength(this.cropRect.height),Q=this.aspectRatio.getVerticalLength(this.cropRect.width);I/this.canvasWidth<Q/this.canvasHeight?this.cropRect.width=I:this.cropRect.height=Q,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=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)}},G.prototype.getRescaledRect=function(s,c,I,Q,W,ge){var je=I/s,Je=Q/c;return{x:(W.x-ge)*je+ge,y:(W.y-ge)*Je+ge,width:W.width*je,height:W.height*Je}},G.prototype.scaleCanvas=function(s,c){var I=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,c,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=c,this.onCropChange&&this.onCropChange(I),this.setCropRectangle(I)},G}(),Vr=function(){function G(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(G.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),G.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},G.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},G.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},G.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},G.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()]])}},G.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)}},G.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,I=1;I<=this.width/5+10;I++){var Q=I%5==0?this.height/3:this.height/6;c+="h4v"+-Q+"h1v"+Q}c+="v1H0Z",this.scaleShape=bt.createPath(c);var W=bt.createTransform();this.scaleShape.transform.baseVal.appendItem(W),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 ge=bt.createTSpan("");return ge.innerHTML="&deg;",this.angleLabelElement.appendChild(ge),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},G}(),fi=function(){function G(){this.naturalSize=!1,this.imageType="image/png"}return G.prototype.rasterize=function(s,c,I,Q,W,ge,je){var Je=this;return new Promise(function(pt){var He=document.createElement("canvas");He.width=s.width.baseVal.value-2*Q,He.height=s.height.baseVal.value-2*Q;var vt=1,Ft=1;Je.naturalSize===!0?(vt=c.naturalWidth/(s.width.baseVal.value-2*Q)/ge,Ft=c.naturalHeight/(s.height.baseVal.value-2*Q)/je,He.width=c.naturalWidth/ge,He.height=c.naturalHeight/je):Je.width!==void 0&&Je.height!==void 0&&(vt=Je.width/I.width,Ft=Je.height/I.height,He.width*=vt,He.height*=Ft);var Xt=He.getContext("2d");Xt.translate(He.width/2,He.height/2),Xt.rotate(W*Math.PI/180),Xt.scale(ge,je),Xt.translate(-He.width/2,-He.height/2),Xt.drawImage(c,0,0,He.width,He.height);var _r=document.createElement("canvas");_r.width=I.width*vt,_r.height=I.height*Ft,_r.getContext("2d").putImageData(Xt.getImageData((I.x-Q)*vt,(I.y-Q)*Ft,I.width*vt,I.height*Ft),0,0),pt(_r.toDataURL(Je.imageType,Je.imageQuality))})},G}(),Ve=function(){function G(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=G.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(G.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(G.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(G.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(G.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(G.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(G.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}),G.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},G.prototype.show=function(){this.showUI(),this.open()},G.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)},G.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},G.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},G.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},G.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},G.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))},G.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,I=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,I)}},G.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},G.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"},G.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()},G.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()},G.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},G.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)},G.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},G.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()},G.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)}},G.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)},G.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},G.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},G.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"},G.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},G.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},G.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},G.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 I=[];this.aspectRatios.forEach(function(Ft){var Xt=new Bt(ei.getIcon(Ft.horizontal,Ft.vertical),Ft.horizontal===0&&Ft.vertical===0?"FREE":Ft.horizontal+":"+Ft.vertical);Xt.onClick=function(){return s.ratioButtonClicked(Ft)},I.push(Xt)}),this.aspectRatioButton=new gr(ei.getIcon(0,0),"Aspect ratio",I),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 Q=new Bt('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");Q.isActive=this.isGridVisible,Q.onClick=function(){s.isGridVisible=!s.isGridVisible,Q.isActive=s.isGridVisible},c.addButton(Q);var W=new Bt('<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(W.isActive=this.zoomToCropEnabled,W.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,W.isActive=s.zoomToCropEnabled},c.addButton(W),!Kr.isLicensed){var ge=new ft;this.topToolbar.addElementBlock(ge);var je=document.createElement("div");je.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Je=document.createElement("a");Je.style.color="currentColor",Je.href="https://markerjs.com/products/cropro",Je.target="_blank",Je.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>',je.appendChild(Je),ge.addElement(je)}var pt=new qr;pt.minWidth=3*this.toolbarHeight+"px",pt.contentAlign="end",this.topToolbar.addButtonBlock(pt);var He=new Bt('<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");He.onClick=this.startRenderAndClose,pt.addButton(He),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(He.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var vt=new Bt('<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,pt.addButton(vt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(vt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},G.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 I=new Bt('<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");I.onClick=this.rotateLeftButtonClicked,c.addButton(I);var Q=new Bt('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");Q.onClick=this.rotateRightButtonClicked,c.addButton(Q);var W=new ft;W.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(W),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(pt){s.rotateBy(pt),s.straightener.angle=s.rotationAngle},W.addElement(this.straightener.getUI());var ge=new qr;ge.minWidth=2*this.toolbarHeight+"px",ge.contentAlign="end",this.bottomToolbar.addButtonBlock(ge);var je=new Bt('<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");je.onClick=this.flipHorizontallyButtonClicked,ge.addButton(je);var Je=new Bt('<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");Je.onClick=this.flipVerticallyButtonClicked,ge.addButton(Je)},G.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},G.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},G.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)},G.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},G.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},G.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()}},G.prototype.clientToLocalCoordinates=function(s,c){var I=this.cropImage.getBoundingClientRect();return{x:s-I.left,y:c-I.top}},G.prototype.onWindowResize=function(){this.positionUI()},G.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()},G.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)},G.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)},G.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},G.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},G.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 I=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/I.width,this.imageHeight/I.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},G.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},G.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},G.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},G.prototype.startRenderAndClose=function(){return Lt(this,void 0,void 0,function(){var s,c;return pr(this,function(I){switch(I.label){case 0:return[4,this.render()];case 1:return s=I.sent(),c=this.getState(),this.renderEventListeners.forEach(function(Q){return Q(s,c)}),this.close(!0),[2]}})})},G.prototype.render=function(){return Lt(this,void 0,void 0,function(){var s;return pr(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()]}})})},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new mr("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 mr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new mr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new mr("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 mr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new mr("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 mr("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 mr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new mr("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 mr("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 mr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},G.instanceCounter=0,G}(),Ct=he("8hTe"),pi=he.n(Ct),mi=/<pre[^>]*>/g;function gi(G){var s=document.createElement("div");return s.innerHTML=G,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=ut.a=function(G){var s=G.value,c=s===void 0?"":s,I=G.edit,Q=I===void 0?!1:I,W=G.className,ge=G.showTextOnly,je=G.showLines,Je=G.replaces,pt=G.zoomImg,He=G.hasMask,vt=G.style,Ft=vt===void 0?{}:vt,Xt=G.stylesPrev,_r=Xt===void 0?{}:Xt,vr=String(c),yr=Object(R.useRef)(),Xr=Object(R.useRef)(),Oi=Object(R.useState)(""),nr=Object(z.a)(Oi,2),Ur=nr[0],oi=nr[1],si=Object(R.useState)("office"),Pr=Object(z.a)(si,2),_i=Pr[0],yi=Pr[1],zi=function(){var Ut=new Ve(Xr.current);Ut.displayMode="popup",Ut.addRenderEventListener(function(){var dr=Object(M.a)(N.a.mark(function Rt(qt){var Gt;return N.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return yr.current.style.display="none",ar.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:Gt=ar.sent,Gt!=null&&Gt.id&&Je(Xr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 5:case"end":return ar.stop()}},Rt)}));return function(Rt){return dr.apply(this,arguments)}}()),Ut.show()},Ki=function(){var Ut=new _t(Xr.current);Ut.settings.displayMode="popup",Ut.addEventListener("render",function(){var dr=Object(M.a)(N.a.mark(function Rt(qt){var Gt;return N.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:if(yr.current.style.display="none",!Xr.current){ar.next=6;break}return ar.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:Gt=ar.sent,Gt!=null&&Gt.id&&Je(Xr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Gt==null?void 0:Gt.id,"?type=").concat(Gt.content_type));case 6:case"end":return ar.stop()}},Rt)}));return function(Rt){return dr.apply(this,arguments)}}()),Ut.show(),window.markerArea=Ut},Yr=Object(R.useMemo)(function(){yr.current&&(yr.current.style.zIndex=-1);try{var Jt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Ut=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;vr=vr.replace(Jt,"("+ee.a.API_SERVER+"/api/attachments/").replace(Ut,'"'+ee.a.API_SERVER+"/api/attachments/").replace(dr,'"'+ee.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 Rt=V(vr),qt=b();if(vr.match(/\[TOC\]/)&&(Rt=Rt.replace("<p>[TOC]</p>",k()),w()),Rt=Rt.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var Sr=qt[ar],Vi=Sr.type,Ei=Sr.expression;return Object(ae.renderToString)(gi(Ei)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Rt=Rt.replace(/▁/g,"\u2581\u2581\u2581"),m(),ge){var Gt=document.createElement("div");return Gt.innerHTML=Rt,Gt.innerText}return setTimeout(function(){return dn()},500),Rt},[vr]),Gr=Object(R.useRef)();y.WebkitLineClamp=je,je&&(Ft=Object(F.a)(Object(F.a)({},Ft),y));function bi(Jt){var Ut=Jt.target;if(Ut.tagName.toUpperCase()==="IMG"){if(pt){var dr=Ut.getAttribute("src");oi(dr),yi("image")}}else if(Ut.tagName.toUpperCase()==="A"){var Rt=Ut.getAttribute("href");if(Rt.indexOf("office")>-1)Jt.preventDefault(),oi(Rt),yi("office");else if(Rt.indexOf("application/pdf")>-1)Jt.preventDefault(),oi(Rt),yi("pdf");else if(Rt.indexOf("text/html")>-1)Jt.preventDefault(),oi(Rt),yi("html");else if(Rt.startsWith("#")){Jt.preventDefault();var qt=document.getElementById(Rt.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var dn=function(){var Ut,dr=(Ut=Gr.current)===null||Ut===void 0?void 0:Ut.querySelectorAll("video");dr==null||dr.forEach(function(Rt){if(Rt.oncontextmenu=function(){return!1},Rt.src.indexOf(".m3u8")>-1&&!Rt.canPlayType("application/vnd.apple.mpegurl")){if(Y.a.isSupported()){var qt=new Y.a;qt.loadSource(Rt.src),qt.attachMedia(Rt)}}})};Object(R.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),m(),w()}},[Yr,Gr.current,bi]);var xi=function(Ut){if(!Q)return;Ut.target.nodeName==="IMG"?(yr.current.style.zIndex=1,yr.current.style.display="flex",yr.current.style.width=Ut.target.clientWidth+"px",yr.current.style.height=Ut.target.clientHeight+"px",yr.current.style.top=Ut.target.offsetTop+"px",yr.current.style.left=Ut.target.offsetLeft+"px",Xr.current.src=Ut.target.getAttribute("src")):yr.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:Gr,style:Object(F.a)({},Ft),className:"".concat(W||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:xi,dangerouslySetInnerHTML:{__html:Yr}}),v.a.createElement("div",{ref:yr,className:pi.a.button},v.a.createElement($.a,null,v.a.createElement(Z.a,{onClick:function(){return zi()}},"\u88C1\u526A"),v.a.createElement(Z.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.a.createElement(ce.a,{close:!0,data:Ur,type:Ur!=null&&Ur.length?_i:"",style:Object(F.a)({},_r),onClose:function(){return oi("")}}))}},"9VGf":function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return D});var oe=he("q1tI"),$=he.n(oe);function D(Z,F){var M=Object(oe.useRef)();Object(oe.useEffect)(function(){M.current=Z}),Object(oe.useEffect)(function(){function z(){M.current()}if(F!==null){var H=setInterval(z,F);return function(){return clearInterval(H)}}},[F])}},"9ivq":function(Tt,ut,he){},Bd2K:function(Tt,ut,he){(function(oe){oe(he("VrN/"),he("osHv"))})(function(oe){oe.defineOption("autoCloseTags",!1,function(N,R,v){if(v!=oe.Init&&v&&N.removeKeyMap("autoCloseTags"),!R)return;var T={name:"autoCloseTags"};(typeof R!="object"||R.whenClosing!==!1)&&(T["'/'"]=function(O){return M(O)}),(typeof R!="object"||R.whenOpening!==!1)&&(T["'>'"]=function(O){return Z(O)}),N.addKeyMap(T)});var $=["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 Z(N){if(N.getOption("disableInput"))return oe.Pass;for(var R=N.listSelections(),v=[],T=N.getOption("autoCloseTags"),O=0;O<R.length;O++){if(!R[O].empty())return oe.Pass;var L=R[O].head,A=N.getTokenAt(L),C=oe.innerMode(N.getMode(),A.state),u=C.state,o=C.mode.xmlCurrentTag&&C.mode.xmlCurrentTag(u),l=o&&o.name;if(!l)return oe.Pass;var h=C.mode.configuration=="html",w=typeof T=="object"&&T.dontCloseTags||h&&$,y=typeof T=="object"&&T.indentTags||h&&D;A.end>L.ch&&(l=l.slice(0,l.length-A.end+L.ch));var g=l.toLowerCase();if(!l||A.type=="string"&&(A.end!=L.ch||!/[\"\']/.test(A.string.charAt(A.string.length-1))||A.string.length==1)||A.type=="tag"&&o.close||A.string.indexOf("/")==L.ch-A.start-1||w&&z(w,g)>-1||H(N,C.mode.xmlCurrentContext&&C.mode.xmlCurrentContext(u)||[],l,L,!0))return oe.Pass;var k=typeof T=="object"&&T.emptyTags;if(k&&z(k,l)>-1){v[O]={text:"/>",newPos:oe.Pos(L.line,L.ch+2)};continue}var x=y&&z(y,g)>-1;v[O]={indent:x,text:">"+(x?`
`:"")+"</"+l+">",newPos:x?oe.Pos(L.line+1,0):oe.Pos(L.line,L.ch+1)}}for(var f=typeof T=="object"&&T.dontIndentOnAutoClose,O=R.length-1;O>=0;O--){var p=v[O];N.replaceRange(p.text,R[O].head,R[O].anchor,"+insert");var d=N.listSelections().slice(0);d[O]={head:p.newPos,anchor:p.newPos},N.setSelections(d),!f&&p.indent&&(N.indentLine(p.newPos.line,null,!0),N.indentLine(p.newPos.line+1,null,!0))}}function F(N,R){for(var v=N.listSelections(),T=[],O=R?"/":"</",L=N.getOption("autoCloseTags"),A=typeof L=="object"&&L.dontIndentOnSlash,C=0;C<v.length;C++){if(!v[C].empty())return oe.Pass;var u=v[C].head,o=N.getTokenAt(u),l=oe.innerMode(N.getMode(),o.state),h=l.state;if(R&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=u.ch-1))return oe.Pass;var w,y=l.mode.name!="xml"&&N.getMode().name=="htmlmixed";if(y&&l.mode.name=="javascript")w=O+"script";else if(y&&l.mode.name=="css")w=O+"style";else{var g=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!g||g.length&&H(N,g,g[g.length-1],u))return oe.Pass;w=O+g[g.length-1]}N.getLine(u.line).charAt(o.end)!=">"&&(w+=">"),T[C]=w}if(N.replaceSelections(T),v=N.listSelections(),!A)for(var C=0;C<v.length;C++)(C==v.length-1||v[C].head.line<v[C+1].head.line)&&N.indentLine(v[C].head.line)}function M(N){return N.getOption("disableInput")?oe.Pass:F(N,!0)}oe.commands.closeTag=function(N){return F(N)};function z(N,R){if(N.indexOf)return N.indexOf(R);for(var v=0,T=N.length;v<T;++v)if(N[v]==R)return v;return-1}function H(N,R,v,T,O){if(!oe.scanForClosingTag)return!1;var L=Math.min(N.lastLine()+1,T.line+500),A=oe.scanForClosingTag(N,T,null,L);if(!A||A.tag!=v)return!1;for(var C=O?1:0,u=R.length-1;u>=0&&R[u]==v;u--)++C;T=A.to;for(var u=1;u<C;u++){var o=oe.scanForClosingTag(N,T,null,L);if(!o||o.tag!=v)return!1;T=o.to}return!0}})},BjJ7:function(Tt,ut,he){"use strict";he.d(ut,"d",function(){return $}),he.d(ut,"c",function(){return D}),he.d(ut,"e",function(){return Z}),he.d(ut,"b",function(){return F}),he.d(ut,"a",function(){return z});var oe=he("m3rI");function $(H){var N=!0;if(H.length>0){for(var R=0;R<H.length;R++)if(H[R].compile_success==0||!H[R].compile_success){N=!1;break}}else N=!1;return N}function D(H){for(var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",R=[],v=0;v<H.length;v++){var T=H[v],O=N?"".concat(N,"/").concat(T.name):"".concat(T.name);R.push({title:T.name,isLeaf:!(T.type==="tree"),key:O})}return R}function Z(H,N,R){for(var v=0;v<H.length;v++){var T=H[v];if(T.key===N){T.children=R;break}T.children&&Z(T.children,N,R)}return H}function F(H,N,R){var v;return function(){var T=this,O=arguments,L=function(){v=null,R||H.apply(T,O)},A=R&&!v;clearTimeout(v),v=setTimeout(L,N),A&&H.apply(T,O)}}var M=!0,z=oe.a.API_SERVER},"C+DQ":function(Tt,ut,he){},DlQD:function(Tt,ut,he){(function(oe,$){Tt.exports=$()})(this,function(){"use strict";function oe(xe,me){for(var ye=0;ye<me.length;ye++){var re=me[ye];re.enumerable=re.enumerable||!1,re.configurable=!0,"value"in re&&(re.writable=!0),Object.defineProperty(xe,re.key,re)}}function $(xe,me,ye){return me&&oe(xe.prototype,me),ye&&oe(xe,ye),xe}function D(xe,me){if(!xe)return;if(typeof xe=="string")return Z(xe,me);var ye=Object.prototype.toString.call(xe).slice(8,-1);if(ye==="Object"&&xe.constructor&&(ye=xe.constructor.name),ye==="Map"||ye==="Set")return Array.from(xe);if(ye==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ye))return Z(xe,me)}function Z(xe,me){(me==null||me>xe.length)&&(me=xe.length);for(var ye=0,re=new Array(me);ye<me;ye++)re[ye]=xe[ye];return re}function F(xe,me){var ye;if(typeof Symbol=="undefined"||xe[Symbol.iterator]==null){if(Array.isArray(xe)||(ye=D(xe))||me&&xe&&typeof xe.length=="number"){ye&&(xe=ye);var re=0;return function(){return re>=xe.length?{done:!0}:{done:!1,value:xe[re++]}}}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 ye=xe[Symbol.iterator](),ye.next.bind(ye)}function M(xe,me){return me={exports:{}},xe(me,me.exports),me.exports}var z=M(function(xe){function me(){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 ye(re){xe.exports.defaults=re}xe.exports={defaults:me(),getDefaults:me,changeDefaults:ye}}),H=z.defaults,N=z.getDefaults,R=z.changeDefaults,v=/[&<>"']/,T=/[&<>"']/g,O=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,A={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},C=function(me){return A[me]};function u(xe,me){if(me){if(v.test(xe))return xe.replace(T,C)}else if(O.test(xe))return xe.replace(L,C);return xe}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(xe){return xe.replace(o,function(me,ye){return ye=ye.toLowerCase(),ye==="colon"?":":ye.charAt(0)==="#"?ye.charAt(1)==="x"?String.fromCharCode(parseInt(ye.substring(2),16)):String.fromCharCode(+ye.substring(1)):""})}var h=/(^|[^\[])\^/g;function w(xe,me){xe=xe.source||xe,me=me||"";var ye={replace:function(ie,se){return se=se.source||se,se=se.replace(h,"$1"),xe=xe.replace(ie,se),ye},getRegex:function(){return new RegExp(xe,me)}};return ye}var y=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(xe,me,ye){if(xe){var re;try{re=decodeURIComponent(l(ye)).replace(y,"").toLowerCase()}catch(ie){return null}if(re.indexOf("javascript:")===0||re.indexOf("vbscript:")===0||re.indexOf("data:")===0)return null}me&&!g.test(ye)&&(ye=a(me,ye));try{ye=encodeURI(ye).replace(/%25/g,"%")}catch(ie){return null}return ye}var x={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(xe,me){x[" "+xe]||(f.test(xe)?x[" "+xe]=xe+"/":x[" "+xe]=B(xe,"/",!0)),xe=x[" "+xe];var ye=xe.indexOf(":")===-1;return me.substring(0,2)==="//"?ye?me:xe.replace(p,"$1")+me:me.charAt(0)==="/"?ye?me:xe.replace(d,"$1")+me:xe+me}var b={exec:function(){}};function m(xe){for(var me=1,ye,re;me<arguments.length;me++){ye=arguments[me];for(re in ye)Object.prototype.hasOwnProperty.call(ye,re)&&(xe[re]=ye[re])}return xe}function E(xe,me){var ye=xe.replace(/\|/g,function(se,pe,be){for(var _e=!1,We=pe;--We>=0&&be[We]==="\\";)_e=!_e;return _e?"|":" |"}),re=ye.split(/ \|/),ie=0;if(re.length>me)re.splice(me);else for(;re.length<me;)re.push("");for(;ie<re.length;ie++)re[ie]=re[ie].trim().replace(/\\\|/g,"|");return re}function B(xe,me,ye){var re=xe.length;if(re===0)return"";for(var ie=0;ie<re;){var se=xe.charAt(re-ie-1);if(se===me&&!ye)ie++;else if(se!==me&&ye)ie++;else break}return xe.substr(0,re-ie)}function U(xe,me){if(xe.indexOf(me[1])===-1)return-1;for(var ye=xe.length,re=0,ie=0;ie<ye;ie++)if(xe[ie]==="\\")ie++;else if(xe[ie]===me[0])re++;else if(xe[ie]===me[1]&&(re--,re<0))return ie;return-1}function K(xe){xe&&xe.sanitize&&!xe.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 V={escape:u,unescape:l,edit:w,cleanUrl:k,resolveUrl:a,noopTest:b,merge:m,splitCells:E,rtrim:B,findClosingBracket:U,checkSanitizeDeprecation:K},P=z.defaults,_=V.rtrim,Y=V.splitCells,ee=V.escape,ae=V.findClosingBracket;function ce(xe,me,ye){var re=me.href,ie=me.title?ee(me.title):null,se=xe[1].replace(/\\([\[\]])/g,"$1");return xe[0].charAt(0)!=="!"?{type:"link",raw:ye,href:re,title:ie,text:se}:{type:"image",raw:ye,href:re,title:ie,text:ee(se)}}function De(xe,me){var ye=xe.match(/^(\s+)(?:```)/);if(ye===null)return me;var re=ye[1];return me.split(`
`).map(function(ie){var se=ie.match(/^\s+/);if(se===null)return ie;var pe=se[0];return pe.length>=re.length?ie.slice(re.length):ie}).join(`
`)}var Se=function(){function xe(ye){this.options=ye||P}var me=xe.prototype;return me.space=function(re){var ie=this.rules.block.newline.exec(re);if(ie)return ie[0].length>1?{type:"space",raw:ie[0]}:{raw:`
`}},me.code=function(re,ie){var se=this.rules.block.code.exec(re);if(se){var pe=ie[ie.length-1];if(pe&&pe.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var be=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?be:_(be,`
`)}}},me.fences=function(re){var ie=this.rules.block.fences.exec(re);if(ie){var se=ie[0],pe=De(se,ie[3]||"");return{type:"code",raw:se,lang:ie[2]?ie[2].trim():ie[2],text:pe}}},me.heading=function(re){var ie=this.rules.block.heading.exec(re);if(ie)return{type:"heading",raw:ie[0],depth:ie[1].length,text:ie[2]}},me.nptable=function(re){var ie=this.rules.block.nptable.exec(re);if(ie){var se={type:"table",header:Y(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[],raw:ie[0]};if(se.header.length===se.align.length){var pe=se.align.length,be;for(be=0;be<pe;be++)/^ *-+: *$/.test(se.align[be])?se.align[be]="right":/^ *:-+: *$/.test(se.align[be])?se.align[be]="center":/^ *:-+ *$/.test(se.align[be])?se.align[be]="left":se.align[be]=null;for(pe=se.cells.length,be=0;be<pe;be++)se.cells[be]=Y(se.cells[be],se.header.length);return se}}},me.hr=function(re){var ie=this.rules.block.hr.exec(re);if(ie)return{type:"hr",raw:ie[0]}},me.blockquote=function(re){var ie=this.rules.block.blockquote.exec(re);if(ie){var se=ie[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:ie[0],text:se}}},me.list=function(re){var ie=this.rules.block.list.exec(re);if(ie){for(var se=ie[0],pe=ie[2],be=pe.length>1,_e=pe[pe.length-1]===")",We={type:"list",raw:se,ordered:be,start:be?+pe.slice(0,-1):"",loose:!1,items:[]},$e=ie[0].match(this.rules.block.item),st=!1,Ze,St,Et,lt,Pt,_t,Mt,jt=$e.length,Lt=0;Lt<jt;Lt++)Ze=$e[Lt],se=Ze,St=Ze.length,Ze=Ze.replace(/^ *([*+-]|\d+[.)]) */,""),~Ze.indexOf(`
`)&&(St-=Ze.length,Ze=this.options.pedantic?Ze.replace(/^ {1,4}/gm,""):Ze.replace(new RegExp("^ {1,"+St+"}","gm"),"")),Lt!==jt-1&&(Et=this.rules.block.bullet.exec($e[Lt+1])[0],(be?Et.length===1||!_e&&Et[Et.length-1]===")":Et.length>1||this.options.smartLists&&Et!==pe)&&(lt=$e.slice(Lt+1).join(`
`),We.raw=We.raw.substring(0,We.raw.length-lt.length),Lt=jt-1)),Pt=st||/\n\n(?!\s*$)/.test(Ze),Lt!==jt-1&&(st=Ze.charAt(Ze.length-1)===`
`,Pt||(Pt=st)),Pt&&(We.loose=!0),_t=/^\[[ xX]\] /.test(Ze),Mt=void 0,_t&&(Mt=Ze[1]!==" ",Ze=Ze.replace(/^\[[ xX]\] +/,"")),We.items.push({type:"list_item",raw:se,task:_t,checked:Mt,loose:Pt,text:Ze});return We}},me.html=function(re){var ie=this.rules.block.html.exec(re);if(ie)return{type:this.options.sanitize?"paragraph":"html",raw:ie[0],pre:!this.options.sanitizer&&(ie[1]==="pre"||ie[1]==="script"||ie[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ie[0]):ee(ie[0]):ie[0]}},me.def=function(re){var ie=this.rules.block.def.exec(re);if(ie){ie[3]&&(ie[3]=ie[3].substring(1,ie[3].length-1));var se=ie[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:ie[0],href:ie[2],title:ie[3]}}},me.table=function(re){var ie=this.rules.block.table.exec(re);if(ie){var se={type:"table",header:Y(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[]};if(se.header.length===se.align.length){se.raw=ie[0];var pe=se.align.length,be;for(be=0;be<pe;be++)/^ *-+: *$/.test(se.align[be])?se.align[be]="right":/^ *:-+: *$/.test(se.align[be])?se.align[be]="center":/^ *:-+ *$/.test(se.align[be])?se.align[be]="left":se.align[be]=null;for(pe=se.cells.length,be=0;be<pe;be++)se.cells[be]=Y(se.cells[be].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},me.lheading=function(re){var ie=this.rules.block.lheading.exec(re);if(ie)return{type:"heading",raw:ie[0],depth:ie[2].charAt(0)==="="?1:2,text:ie[1]}},me.paragraph=function(re){var ie=this.rules.block.paragraph.exec(re);if(ie)return{type:"paragraph",raw:ie[0],text:ie[1].charAt(ie[1].length-1)===`
`?ie[1].slice(0,-1):ie[1]}},me.text=function(re,ie){var se=this.rules.block.text.exec(re);if(se){var pe=ie[ie.length-1];return pe&&pe.type==="text"?{raw:se[0],text:se[0]}:{type:"text",raw:se[0],text:se[0]}}},me.escape=function(re){var ie=this.rules.inline.escape.exec(re);if(ie)return{type:"escape",raw:ie[0],text:ee(ie[1])}},me.tag=function(re,ie,se){var pe=this.rules.inline.tag.exec(re);if(pe)return!ie&&/^<a /i.test(pe[0])?ie=!0:ie&&/^<\/a>/i.test(pe[0])&&(ie=!1),!se&&/^<(pre|code|kbd|script)(\s|>)/i.test(pe[0])?se=!0:se&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(pe[0])&&(se=!1),{type:this.options.sanitize?"text":"html",raw:pe[0],inLink:ie,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(pe[0]):ee(pe[0]):pe[0]}},me.link=function(re){var ie=this.rules.inline.link.exec(re);if(ie){var se=ae(ie[2],"()");if(se>-1){var pe=ie[0].indexOf("!")===0?5:4,be=pe+ie[1].length+se;ie[2]=ie[2].substring(0,se),ie[0]=ie[0].substring(0,be).trim(),ie[3]=""}var _e=ie[2],We="";if(this.options.pedantic){var $e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(_e);$e?(_e=$e[1],We=$e[3]):We=""}else We=ie[3]?ie[3].slice(1,-1):"";_e=_e.trim().replace(/^<([\s\S]*)>$/,"$1");var st=ce(ie,{href:_e&&_e.replace(this.rules.inline._escapes,"$1"),title:We&&We.replace(this.rules.inline._escapes,"$1")},ie[0]);return st}},me.reflink=function(re,ie){var se;if((se=this.rules.inline.reflink.exec(re))||(se=this.rules.inline.nolink.exec(re))){var pe=(se[2]||se[1]).replace(/\s+/g," ");if(pe=ie[pe.toLowerCase()],!pe||!pe.href){var be=se[0].charAt(0);return{type:"text",raw:be,text:be}}var _e=ce(se,pe,se[0]);return _e}},me.strong=function(re,ie,se){se===void 0&&(se="");var pe=this.rules.inline.strong.start.exec(re);if(pe&&(!pe[1]||pe[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){ie=ie.slice(-1*re.length);var be=pe[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;be.lastIndex=0;for(var _e;(pe=be.exec(ie))!=null;)if(_e=this.rules.inline.strong.middle.exec(ie.slice(0,pe.index+3)),_e)return{type:"strong",raw:re.slice(0,_e[0].length),text:re.slice(2,_e[0].length-2)}}},me.em=function(re,ie,se){se===void 0&&(se="");var pe=this.rules.inline.em.start.exec(re);if(pe&&(!pe[1]||pe[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){ie=ie.slice(-1*re.length);var be=pe[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;be.lastIndex=0;for(var _e;(pe=be.exec(ie))!=null;)if(_e=this.rules.inline.em.middle.exec(ie.slice(0,pe.index+2)),_e)return{type:"em",raw:re.slice(0,_e[0].length),text:re.slice(1,_e[0].length-1)}}},me.codespan=function(re){var ie=this.rules.inline.code.exec(re);if(ie){var se=ie[2].replace(/\n/g," "),pe=/[^ ]/.test(se),be=se.startsWith(" ")&&se.endsWith(" ");return pe&&be&&(se=se.substring(1,se.length-1)),se=ee(se,!0),{type:"codespan",raw:ie[0],text:se}}},me.br=function(re){var ie=this.rules.inline.br.exec(re);if(ie)return{type:"br",raw:ie[0]}},me.del=function(re){var ie=this.rules.inline.del.exec(re);if(ie)return{type:"del",raw:ie[0],text:ie[1]}},me.autolink=function(re,ie){var se=this.rules.inline.autolink.exec(re);if(se){var pe,be;return se[2]==="@"?(pe=ee(this.options.mangle?ie(se[1]):se[1]),be="mailto:"+pe):(pe=ee(se[1]),be=pe),{type:"link",raw:se[0],text:pe,href:be,tokens:[{type:"text",raw:pe,text:pe}]}}},me.url=function(re,ie){var se;if(se=this.rules.inline.url.exec(re)){var pe,be;if(se[2]==="@")pe=ee(this.options.mangle?ie(se[0]):se[0]),be="mailto:"+pe;else{var _e;do _e=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(_e!==se[0]);pe=ee(se[0]),se[1]==="www."?be="http://"+pe:be=pe}return{type:"link",raw:se[0],text:pe,href:be,tokens:[{type:"text",raw:pe,text:pe}]}}},me.inlineText=function(re,ie,se){var pe=this.rules.inline.text.exec(re);if(pe){var be;return ie?be=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(pe[0]):ee(pe[0]):pe[0]:be=ee(this.options.smartypants?se(pe[0]):pe[0]),{type:"text",raw:pe[0],text:be}}},xe}(),Ce=V.noopTest,Ae=V.edit,Te=V.merge,ve={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=Ae(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ve.item=Ae(ve.item,"gm").replace(/bull/g,ve.bullet).getRegex(),ve.list=Ae(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?-->/,ve.html=Ae(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=Ae(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=Ae(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal=Te({},ve),ve.gfm=Te({},ve.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ve.gfm.nptable=Ae(ve.gfm.nptable).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.table=Ae(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic=Te({},ve.normal,{html:Ae(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Ce,paragraph:Ae(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var le={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ce,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ce,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};le._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",le.punctuation=Ae(le.punctuation).replace(/punctuation/g,le._punctuation).getRegex(),le._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",le._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",le.em.start=Ae(le.em.start).replace(/punctuation/g,le._punctuation).getRegex(),le.em.middle=Ae(le.em.middle).replace(/punctuation/g,le._punctuation).replace(/overlapSkip/g,le._overlapSkip).getRegex(),le.em.endAst=Ae(le.em.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.em.endUnd=Ae(le.em.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.start=Ae(le.strong.start).replace(/punctuation/g,le._punctuation).getRegex(),le.strong.middle=Ae(le.strong.middle).replace(/punctuation/g,le._punctuation).replace(/blockSkip/g,le._blockSkip).getRegex(),le.strong.endAst=Ae(le.strong.endAst,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.strong.endUnd=Ae(le.strong.endUnd,"g").replace(/punctuation/g,le._punctuation).getRegex(),le.blockSkip=Ae(le._blockSkip,"g").getRegex(),le.overlapSkip=Ae(le._overlapSkip,"g").getRegex(),le._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,le._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,le._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,le.autolink=Ae(le.autolink).replace("scheme",le._scheme).replace("email",le._email).getRegex(),le._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,le.tag=Ae(le.tag).replace("comment",ve._comment).replace("attribute",le._attribute).getRegex(),le._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,le._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,le._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,le.link=Ae(le.link).replace("label",le._label).replace("href",le._href).replace("title",le._title).getRegex(),le.reflink=Ae(le.reflink).replace("label",le._label).getRegex(),le.reflinkSearch=Ae(le.reflinkSearch,"g").replace("reflink",le.reflink).replace("nolink",le.nolink).getRegex(),le.normal=Te({},le),le.pedantic=Te({},le.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ae(/^!?\[(label)\]\((.*?)\)/).replace("label",le._label).getRegex(),reflink:Ae(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",le._label).getRegex()}),le.gfm=Te({},le.normal,{escape:Ae(le.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),le.gfm.url=Ae(le.gfm.url,"i").replace("email",le.gfm._extended_email).getRegex(),le.breaks=Te({},le.gfm,{br:Ae(le.br).replace("{2,}","*").getRegex(),text:Ae(le.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var te={block:ve,inline:le},de=z.defaults,ne=te.block,ke=te.inline;function Oe(xe){return xe.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 Ee(xe){var me="",ye,re,ie=xe.length;for(ye=0;ye<ie;ye++)re=xe.charCodeAt(ye),Math.random()>.5&&(re="x"+re.toString(16)),me+="&#"+re+";";return me}var Re=function(){function xe(ye){this.tokens=[],this.tokens.links=Object.create(null),this.options=ye||de,this.options.tokenizer=this.options.tokenizer||new Se,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var re={block:ne.normal,inline:ke.normal};this.options.pedantic?(re.block=ne.pedantic,re.inline=ke.pedantic):this.options.gfm&&(re.block=ne.gfm,this.options.breaks?re.inline=ke.breaks:re.inline=ke.gfm),this.tokenizer.rules=re}xe.lex=function(re,ie){var se=new xe(ie);return se.lex(re)};var me=xe.prototype;return me.lex=function(re){return re=re.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(re,this.tokens,!0),this.inline(this.tokens),this.tokens},me.blockTokens=function(re,ie,se){ie===void 0&&(ie=[]),se===void 0&&(se=!0),re=re.replace(/^ +$/gm,"");for(var pe,be,_e,We;re;){if(pe=this.tokenizer.space(re)){re=re.substring(pe.raw.length),pe.type&&ie.push(pe);continue}if(pe=this.tokenizer.code(re,ie)){re=re.substring(pe.raw.length),pe.type?ie.push(pe):(We=ie[ie.length-1],We.raw+=`
`+pe.raw,We.text+=`
`+pe.text);continue}if(pe=this.tokenizer.fences(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.heading(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.nptable(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.hr(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.blockquote(re)){re=re.substring(pe.raw.length),pe.tokens=this.blockTokens(pe.text,[],se),ie.push(pe);continue}if(pe=this.tokenizer.list(re)){for(re=re.substring(pe.raw.length),_e=pe.items.length,be=0;be<_e;be++)pe.items[be].tokens=this.blockTokens(pe.items[be].text,[],!1);ie.push(pe);continue}if(pe=this.tokenizer.html(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(se&&(pe=this.tokenizer.def(re))){re=re.substring(pe.raw.length),this.tokens.links[pe.tag]||(this.tokens.links[pe.tag]={href:pe.href,title:pe.title});continue}if(pe=this.tokenizer.table(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.lheading(re)){re=re.substring(pe.raw.length),ie.push(pe);continue}if(se&&(pe=this.tokenizer.paragraph(re))){re=re.substring(pe.raw.length),ie.push(pe);continue}if(pe=this.tokenizer.text(re,ie)){re=re.substring(pe.raw.length),pe.type?ie.push(pe):(We=ie[ie.length-1],We.raw+=`
`+pe.raw,We.text+=`
`+pe.text);continue}if(re){var $e="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error($e);break}else throw new Error($e)}}return ie},me.inline=function(re){var ie,se,pe,be,_e,We,$e=re.length;for(ie=0;ie<$e;ie++){We=re[ie];switch(We.type){case"paragraph":case"text":case"heading":{We.tokens=[],this.inlineTokens(We.text,We.tokens);break}case"table":{for(We.tokens={header:[],cells:[]},be=We.header.length,se=0;se<be;se++)We.tokens.header[se]=[],this.inlineTokens(We.header[se],We.tokens.header[se]);for(be=We.cells.length,se=0;se<be;se++)for(_e=We.cells[se],We.tokens.cells[se]=[],pe=0;pe<_e.length;pe++)We.tokens.cells[se][pe]=[],this.inlineTokens(_e[pe],We.tokens.cells[se][pe]);break}case"blockquote":{this.inline(We.tokens);break}case"list":{for(be=We.items.length,se=0;se<be;se++)this.inline(We.items[se].tokens);break}}}return re},me.inlineTokens=function(re,ie,se,pe,be){ie===void 0&&(ie=[]),se===void 0&&(se=!1),pe===void 0&&(pe=!1),be===void 0&&(be="");var _e,We=re,$e;if(this.tokens.links){var st=Object.keys(this.tokens.links);if(st.length>0)for(;($e=this.tokenizer.rules.inline.reflinkSearch.exec(We))!=null;)st.includes($e[0].slice($e[0].lastIndexOf("[")+1,-1))&&(We=We.slice(0,$e.index)+"["+"a".repeat($e[0].length-2)+"]"+We.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;($e=this.tokenizer.rules.inline.blockSkip.exec(We))!=null;)We=We.slice(0,$e.index)+"["+"a".repeat($e[0].length-2)+"]"+We.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;re;){if(_e=this.tokenizer.escape(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.tag(re,se,pe)){re=re.substring(_e.raw.length),se=_e.inLink,pe=_e.inRawBlock,ie.push(_e);continue}if(_e=this.tokenizer.link(re)){re=re.substring(_e.raw.length),_e.type==="link"&&(_e.tokens=this.inlineTokens(_e.text,[],!0,pe)),ie.push(_e);continue}if(_e=this.tokenizer.reflink(re,this.tokens.links)){re=re.substring(_e.raw.length),_e.type==="link"&&(_e.tokens=this.inlineTokens(_e.text,[],!0,pe)),ie.push(_e);continue}if(_e=this.tokenizer.strong(re,We,be)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],se,pe),ie.push(_e);continue}if(_e=this.tokenizer.em(re,We,be)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],se,pe),ie.push(_e);continue}if(_e=this.tokenizer.codespan(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.br(re)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.del(re)){re=re.substring(_e.raw.length),_e.tokens=this.inlineTokens(_e.text,[],se,pe),ie.push(_e);continue}if(_e=this.tokenizer.autolink(re,Ee)){re=re.substring(_e.raw.length),ie.push(_e);continue}if(!se&&(_e=this.tokenizer.url(re,Ee))){re=re.substring(_e.raw.length),ie.push(_e);continue}if(_e=this.tokenizer.inlineText(re,pe,Oe)){re=re.substring(_e.raw.length),be=_e.raw.slice(-1),ie.push(_e);continue}if(re){var Ze="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error(Ze);break}else throw new Error(Ze)}}return ie},$(xe,null,[{key:"rules",get:function(){return{block:ne,inline:ke}}}]),xe}(),Be=z.defaults,ze=V.cleanUrl,Fe=V.escape,Ue=function(){function xe(ye){this.options=ye||Be}var me=xe.prototype;return me.code=function(re,ie,se){var pe=(ie||"").match(/\S*/)[0];if(this.options.highlight){var be=this.options.highlight(re,pe);be!=null&&be!==re&&(se=!0,re=be)}return pe?'<pre><code class="'+this.options.langPrefix+Fe(pe,!0)+'">'+(se?re:Fe(re,!0))+`</code></pre>
`:"<pre><code>"+(se?re:Fe(re,!0))+`</code></pre>
`},me.blockquote=function(re){return`<blockquote>
`+re+`</blockquote>
`},me.html=function(re){return re},me.heading=function(re,ie,se,pe){return this.options.headerIds?"<h"+ie+' id="'+this.options.headerPrefix+pe.slug(se)+'">'+re+"</h"+ie+`>
`:"<h"+ie+">"+re+"</h"+ie+`>
`},me.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},me.list=function(re,ie,se){var pe=ie?"ol":"ul",be=ie&&se!==1?' start="'+se+'"':"";return"<"+pe+be+`>
`+re+"</"+pe+`>
`},me.listitem=function(re){return"<li>"+re+`</li>
`},me.checkbox=function(re){return"<input "+(re?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},me.paragraph=function(re){return"<p>"+re+`</p>
`},me.table=function(re,ie){return ie&&(ie="<tbody>"+ie+"</tbody>"),`<table>
<thead>
`+re+`</thead>
`+ie+`</table>
`},me.tablerow=function(re){return`<tr>
`+re+`</tr>
`},me.tablecell=function(re,ie){var se=ie.header?"th":"td",pe=ie.align?"<"+se+' align="'+ie.align+'">':"<"+se+">";return pe+re+"</"+se+`>
`},me.strong=function(re){return"<strong>"+re+"</strong>"},me.em=function(re){return"<em>"+re+"</em>"},me.codespan=function(re){return"<code>"+re+"</code>"},me.br=function(){return this.options.xhtml?"<br/>":"<br>"},me.del=function(re){return"<del>"+re+"</del>"},me.link=function(re,ie,se){if(re=ze(this.options.sanitize,this.options.baseUrl,re),re===null)return se;var pe='<a href="'+Fe(re)+'"';return ie&&(pe+=' title="'+ie+'"'),pe+=">"+se+"</a>",pe},me.image=function(re,ie,se){if(re=ze(this.options.sanitize,this.options.baseUrl,re),re===null)return se;var pe='<img src="'+re+'" alt="'+se+'"';return ie&&(pe+=' title="'+ie+'"'),pe+=this.options.xhtml?"/>":">",pe},me.text=function(re){return re},xe}(),Ie=function(){function xe(){}var me=xe.prototype;return me.strong=function(re){return re},me.em=function(re){return re},me.codespan=function(re){return re},me.del=function(re){return re},me.html=function(re){return re},me.text=function(re){return re},me.link=function(re,ie,se){return""+se},me.image=function(re,ie,se){return""+se},me.br=function(){return""},xe}(),it=function(){function xe(){this.seen={}}var me=xe.prototype;return me.slug=function(re){var ie=re.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(ie)){var se=ie;do this.seen[se]++,ie=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(ie))}return this.seen[ie]=0,ie},xe}(),Ye=z.defaults,Qe=V.unescape,qe=function(){function xe(ye){this.options=ye||Ye,this.options.renderer=this.options.renderer||new Ue,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ie,this.slugger=new it}xe.parse=function(re,ie){var se=new xe(ie);return se.parse(re)};var me=xe.prototype;return me.parse=function(re,ie){ie===void 0&&(ie=!0);var se="",pe,be,_e,We,$e,st,Ze,St,Et,lt,Pt,_t,Mt,jt,Lt,pr,Kr,bt,Nr=re.length;for(pe=0;pe<Nr;pe++){lt=re[pe];switch(lt.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline(lt.tokens),lt.depth,Qe(this.parseInline(lt.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code(lt.text,lt.lang,lt.escaped);continue}case"table":{for(St="",Ze="",We=lt.header.length,be=0;be<We;be++)Ze+=this.renderer.tablecell(this.parseInline(lt.tokens.header[be]),{header:!0,align:lt.align[be]});for(St+=this.renderer.tablerow(Ze),Et="",We=lt.cells.length,be=0;be<We;be++){for(st=lt.tokens.cells[be],Ze="",$e=st.length,_e=0;_e<$e;_e++)Ze+=this.renderer.tablecell(this.parseInline(st[_e]),{header:!1,align:lt.align[_e]});Et+=this.renderer.tablerow(Ze)}se+=this.renderer.table(St,Et);continue}case"blockquote":{Et=this.parse(lt.tokens),se+=this.renderer.blockquote(Et);continue}case"list":{for(Pt=lt.ordered,_t=lt.start,Mt=lt.loose,We=lt.items.length,Et="",be=0;be<We;be++)Lt=lt.items[be],pr=Lt.checked,Kr=Lt.task,jt="",Lt.task&&(bt=this.renderer.checkbox(pr),Mt?Lt.tokens.length>0&&Lt.tokens[0].type==="text"?(Lt.tokens[0].text=bt+" "+Lt.tokens[0].text,Lt.tokens[0].tokens&&Lt.tokens[0].tokens.length>0&&Lt.tokens[0].tokens[0].type==="text"&&(Lt.tokens[0].tokens[0].text=bt+" "+Lt.tokens[0].tokens[0].text)):Lt.tokens.unshift({type:"text",text:bt}):jt+=bt),jt+=this.parse(Lt.tokens,Mt),Et+=this.renderer.listitem(jt,Kr,pr);se+=this.renderer.list(Et,Pt,_t);continue}case"html":{se+=this.renderer.html(lt.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline(lt.tokens));continue}case"text":{for(Et=lt.tokens?this.parseInline(lt.tokens):lt.text;pe+1<Nr&&re[pe+1].type==="text";)lt=re[++pe],Et+=`
`+(lt.tokens?this.parseInline(lt.tokens):lt.text);se+=ie?this.renderer.paragraph(Et):Et;continue}default:{var hr='Token with "'+lt.type+'" type was not found.';if(this.options.silent){console.error(hr);return}else throw new Error(hr)}}}return se},me.parseInline=function(re,ie){ie=ie||this.renderer;var se="",pe,be,_e=re.length;for(pe=0;pe<_e;pe++){be=re[pe];switch(be.type){case"escape":{se+=ie.text(be.text);break}case"html":{se+=ie.html(be.text);break}case"link":{se+=ie.link(be.href,be.title,this.parseInline(be.tokens,ie));break}case"image":{se+=ie.image(be.href,be.title,be.text);break}case"strong":{se+=ie.strong(this.parseInline(be.tokens,ie));break}case"em":{se+=ie.em(this.parseInline(be.tokens,ie));break}case"codespan":{se+=ie.codespan(be.text);break}case"br":{se+=ie.br();break}case"del":{se+=ie.del(this.parseInline(be.tokens,ie));break}case"text":{se+=ie.text(be.text);break}default:{var We='Token with "'+be.type+'" type was not found.';if(this.options.silent){console.error(We);return}else throw new Error(We)}}}return se},xe}(),ct=V.merge,et=V.checkSanitizeDeprecation,nt=V.escape,Pe=z.getDefaults,dt=z.changeDefaults,at=z.defaults;function Me(xe,me,ye){if(typeof xe=="undefined"||xe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof xe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(xe)+", string expected");if(typeof me=="function"&&(ye=me,me=null),me=ct({},Me.defaults,me||{}),et(me),ye){var re=me.highlight,ie;try{ie=Re.lex(xe,me)}catch(_e){return ye(_e)}var se=function(We){var $e;if(!We)try{$e=qe.parse(ie,me)}catch(st){We=st}return me.highlight=re,We?ye(We):ye(null,$e)};if(!re||re.length<3)return se();if(delete me.highlight,!ie.length)return se();var pe=0;Me.walkTokens(ie,function(_e){_e.type==="code"&&(pe++,setTimeout(function(){re(_e.text,_e.lang,function(We,$e){if(We)return se(We);$e!=null&&$e!==_e.text&&(_e.text=$e,_e.escaped=!0),pe--,pe===0&&se()})},0))}),pe===0&&se();return}try{var be=Re.lex(xe,me);return me.walkTokens&&Me.walkTokens(be,me.walkTokens),qe.parse(be,me)}catch(_e){if(_e.message+=`
Please report this to https://github.com/markedjs/marked.`,me.silent)return"<p>An error occurred:</p><pre>"+nt(_e.message+"",!0)+"</pre>";throw _e}}Me.options=Me.setOptions=function(xe){return ct(Me.defaults,xe),dt(Me.defaults),Me},Me.getDefaults=Pe,Me.defaults=at,Me.use=function(xe){var me=ct({},xe);if(xe.renderer&&function(){var re=Me.defaults.renderer||new Ue,ie=function(be){var _e=re[be];re[be]=function(){for(var We=arguments.length,$e=new Array(We),st=0;st<We;st++)$e[st]=arguments[st];var Ze=xe.renderer[be].apply(re,$e);return Ze===!1&&(Ze=_e.apply(re,$e)),Ze}};for(var se in xe.renderer)ie(se);me.renderer=re}(),xe.tokenizer&&function(){var re=Me.defaults.tokenizer||new Se,ie=function(be){var _e=re[be];re[be]=function(){for(var We=arguments.length,$e=new Array(We),st=0;st<We;st++)$e[st]=arguments[st];var Ze=xe.tokenizer[be].apply(re,$e);return Ze===!1&&(Ze=_e.apply(re,$e)),Ze}};for(var se in xe.tokenizer)ie(se);me.tokenizer=re}(),xe.walkTokens){var ye=Me.defaults.walkTokens;me.walkTokens=function(re){xe.walkTokens(re),ye&&ye(re)}}Me.setOptions(me)},Me.walkTokens=function(xe,me){for(var ye=F(xe),re;!(re=ye()).done;){var ie=re.value;me(ie);switch(ie.type){case"table":{for(var se=F(ie.tokens.header),pe;!(pe=se()).done;){var be=pe.value;Me.walkTokens(be,me)}for(var _e=F(ie.tokens.cells),We;!(We=_e()).done;)for(var $e=We.value,st=F($e),Ze;!(Ze=st()).done;){var St=Ze.value;Me.walkTokens(St,me)}break}case"list":{Me.walkTokens(ie.items,me);break}default:ie.tokens&&Me.walkTokens(ie.tokens,me)}}},Me.Parser=qe,Me.parser=qe.parse,Me.Renderer=Ue,Me.TextRenderer=Ie,Me.Lexer=Re,Me.lexer=Re.lex,Me.Tokenizer=Se,Me.Slugger=it,Me.parse=Me;var Ge=Me;return Ge})},ELLl:function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=oe.Pos;oe.defineOption("autoCloseBrackets",!1,function(A,C,u){u&&u!=oe.Init&&(A.removeKeyMap(F),A.state.closeBrackets=null),C&&(M(Z(C,"pairs")),A.state.closeBrackets=C,A.addKeyMap(F))});function Z(A,C){return C=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[C]!=null?A[C]:$[C]}var F={Backspace:N,Enter:R};function M(A){for(var C=0;C<A.length;C++){var u=A.charAt(C),o="'"+u+"'";F[o]||(F[o]=z(u))}}M($.pairs+"`");function z(A){return function(C){return T(C,A)}}function H(A){var C=A.state.closeBrackets;if(!C||C.override)return C;var u=A.getModeAt(A.getCursor());return u.closeBrackets||C}function N(A){var C=H(A);if(!C||A.getOption("disableInput"))return oe.Pass;for(var u=Z(C,"pairs"),o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var h=O(A,o[l].head);if(!h||u.indexOf(h)%2!=0)return oe.Pass}for(var l=o.length-1;l>=0;l--){var w=o[l].head;A.replaceRange("",D(w.line,w.ch-1),D(w.line,w.ch+1),"+delete")}}function R(A){var C=H(A),u=C&&Z(C,"explode");if(!u||A.getOption("disableInput"))return oe.Pass;for(var o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return oe.Pass;var h=O(A,o[l].head);if(!h||u.indexOf(h)%2!=0)return oe.Pass}A.operation(function(){var w=A.lineSeparator()||`
`;A.replaceSelection(w+w,null),A.execCommand("goCharLeft"),o=A.listSelections();for(var y=0;y<o.length;y++){var g=o[y].head.line;A.indentLine(g,null,!0),A.indentLine(g+1,null,!0)}})}function v(A){var C=oe.cmpPos(A.anchor,A.head)>0;return{anchor:new D(A.anchor.line,A.anchor.ch+(C?-1:1)),head:new D(A.head.line,A.head.ch+(C?1:-1))}}function T(A,C){var u=H(A);if(!u||A.getOption("disableInput"))return oe.Pass;var o=Z(u,"pairs"),l=o.indexOf(C);if(l==-1)return oe.Pass;for(var h=Z(u,"closeBefore"),w=Z(u,"triples"),y=o.charAt(l+1)==C,g=A.listSelections(),k=l%2==0,x,f=0;f<g.length;f++){var p=g[f],d=p.head,a,b=A.getRange(d,D(d.line,d.ch+1));if(k&&!p.empty())a="surround";else if((y||!k)&&b==C)y&&L(A,d)?a="both":w.indexOf(C)>=0&&A.getRange(d,D(d.line,d.ch+3))==C+C+C?a="skipThree":a="skip";else if(y&&d.ch>1&&w.indexOf(C)>=0&&A.getRange(D(d.line,d.ch-2),d)==C+C){if(d.ch>2&&/\bstring/.test(A.getTokenTypeAt(D(d.line,d.ch-2))))return oe.Pass;a="addFour"}else if(y){var m=d.ch==0?" ":A.getRange(D(d.line,d.ch-1),d);if(!oe.isWordChar(b)&&m!=C&&!oe.isWordChar(m))a="both";else return oe.Pass}else if(k&&(b.length===0||/\s/.test(b)||h.indexOf(b)>-1))a="both";else return oe.Pass;if(!x)x=a;else if(x!=a)return oe.Pass}var E=l%2?o.charAt(l-1):C,B=l%2?C:o.charAt(l+1);A.operation(function(){if(x=="skip")A.execCommand("goCharRight");else if(x=="skipThree")for(var U=0;U<3;U++)A.execCommand("goCharRight");else if(x=="surround"){for(var K=A.getSelections(),U=0;U<K.length;U++)K[U]=E+K[U]+B;A.replaceSelections(K,"around"),K=A.listSelections().slice();for(var U=0;U<K.length;U++)K[U]=v(K[U]);A.setSelections(K)}else x=="both"?(A.replaceSelection(E+B,null),A.triggerElectric(E+B),A.execCommand("goCharLeft")):x=="addFour"&&(A.replaceSelection(E+E+E+E,"before"),A.execCommand("goCharRight"))})}function O(A,C){var u=A.getRange(D(C.line,C.ch-1),D(C.line,C.ch+1));return u.length==2?u:null}function L(A,C){var u=A.getTokenAt(D(C.line,C.ch+1));return/\bstring/.test(u.type)&&u.start==C.ch&&(C.ch==0||!/\bstring/.test(A.getTokenTypeAt(C)))}})},GfqC:function(Tt,ut,he){"use strict";var oe=he("q1tI"),$=he.n(oe),D=he("TSYQ"),Z=he.n(D);function F(V,P){var _="cannot "+V.method+" "+V.action+" "+P.status+"'",Y=new Error(_);return Y.status=P.status,Y.method=V.method,Y.url=V.action,Y}function M(V){var P=V.responseText||V.response;if(!P)return P;try{return JSON.parse(P)}catch(_){return P}}function z(V){var P=new XMLHttpRequest;V.onProgress&&P.upload&&(P.upload.onprogress=function(ae){ae.total>0&&(ae.percent=ae.loaded/ae.total*100),V.onProgress(ae)});var _=new FormData;V.data&&Object.keys(V.data).forEach(function(ee){var ae=V.data[ee];if(Array.isArray(ae)){ae.forEach(function(ce){_.append(ee+"[]",ce)});return}_.append(ee,V.data[ee])}),V.file instanceof Blob?_.append(V.filename,V.file,V.file.name):_.append(V.filename,V.file),P.onerror=function(ae){V.onError(ae)},P.onload=function(){return P.status<200||P.status>=300?V.onError(F(V,P),M(P)):V.onSuccess(M(P),P)},P.open(V.method,V.action,!0),V.withCredentials&&"withCredentials"in P&&(P.withCredentials=!0);var Y=V.headers||{};return Y["X-Requested-With"]!==null&&P.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(Y).forEach(function(ee){Y[ee]!==null&&P.setRequestHeader(ee,Y[ee])}),P.send(_),{abort:function(){P.abort()}}}var H=+new Date,N=0;function R(){return"rc-upload-"+H+"-"+ ++N}function v(V,P){return V.indexOf(P,V.length-P.length)!==-1}var T=function(V,P){if(V&&P){var _=Array.isArray(P)?P:P.split(","),Y=V.name||"",ee=V.type||"",ae=ee.replace(/\/.*$/,"");return _.some(function(ce){var De=ce.trim();return De.charAt(0)==="."?v(Y.toLowerCase(),De.toLowerCase()):/\/\*$/.test(De)?ae===De.replace(/\/.*$/,""):ee===De})}return!0};function O(V,P){var _=V.createReader(),Y=[];function ee(){_.readEntries(function(ae){var ce=Array.prototype.slice.apply(ae);Y=Y.concat(ce);var De=!ce.length;De?P(Y):ee()})}ee()}var L=function(P,_,Y){var ee=function ae(ce,De){De=De||"",ce.isFile?ce.file(function(Se){Y(Se)&&(ce.fullPath&&!Se.webkitRelativePath&&(Object.defineProperties(Se,{webkitRelativePath:{writable:!0}}),Se.webkitRelativePath=ce.fullPath.replace(/^\//,""),Object.defineProperties(Se,{webkitRelativePath:{writable:!1}})),_([Se]))}):ce.isDirectory&&O(ce,function(Se){Se.forEach(function(Ce){ae(Ce,""+De+ce.name+"/")})})};P.forEach(function(ae){ee(ae.webkitGetAsEntry())})},A=L,C=Object.assign||function(V){for(var P=1;P<arguments.length;P++){var _=arguments[P];for(var Y in _)Object.prototype.hasOwnProperty.call(_,Y)&&(V[Y]=_[Y])}return V},u=function(){function V(P,_){var Y=[],ee=!0,ae=!1,ce=void 0;try{for(var De=P[Symbol.iterator](),Se;!(ee=(Se=De.next()).done)&&!(Y.push(Se.value),_&&Y.length===_);ee=!0);}catch(Ce){ae=!0,ce=Ce}finally{try{!ee&&De.return&&De.return()}finally{if(ae)throw ce}}return Y}return function(P,_){if(Array.isArray(P))return P;if(Symbol.iterator in Object(P))return V(P,_);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function V(P,_){for(var Y=0;Y<_.length;Y++){var ee=_[Y];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(P,ee.key,ee)}}return function(P,_,Y){return _&&V(P.prototype,_),Y&&V(P,Y),P}}();function l(V,P,_){return P in V?Object.defineProperty(V,P,{value:_,enumerable:!0,configurable:!0,writable:!0}):V[P]=_,V}function h(V,P){var _={};for(var Y in V){if(P.indexOf(Y)>=0)continue;if(!Object.prototype.hasOwnProperty.call(V,Y))continue;_[Y]=V[Y]}return _}function w(V,P){if(!(V instanceof P))throw new TypeError("Cannot call a class as a function")}function y(V,P){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:V}function g(V,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);V.prototype=Object.create(P&&P.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(V,P):V.__proto__=P)}var k=function(P){return Object.keys(P).reduce(function(_,Y){return(Y.substr(0,5)==="data-"||Y.substr(0,5)==="aria-"||Y==="role")&&(_[Y]=P[Y]),_},{})},x=function(V){g(P,V);function P(){var _,Y,ee,ae;w(this,P);for(var ce=arguments.length,De=Array(ce),Se=0;Se<ce;Se++)De[Se]=arguments[Se];return ae=(Y=(ee=y(this,(_=P.__proto__||Object.getPrototypeOf(P)).call.apply(_,[this].concat(De))),ee),ee.state={uid:R()},ee.reqs={},ee.onChange=function(Ce){var Ae=Ce.target.files;ee.uploadFiles(Ae),ee.reset()},ee.onClick=function(Ce){var Ae=ee.fileInput;if(!Ae)return;var Te=ee.props,ve=Te.children,le=Te.onClick;ve&&ve.type==="button"&&(Ae.parentNode.focus(),Ae.parentNode.querySelector("button").blur()),Ae.click(),le&&le(Ce)},ee.onKeyDown=function(Ce){Ce.key==="Enter"&&ee.onClick()},ee.onFileDrop=function(Ce){var Ae=ee.props.multiple;if(Ce.preventDefault(),Ce.type==="dragover")return;if(ee.props.directory)A(Array.prototype.slice.call(Ce.dataTransfer.items),ee.uploadFiles,function(ve){return T(ve,ee.props.accept)});else{var Te=Array.prototype.slice.call(Ce.dataTransfer.files).filter(function(ve){return T(ve,ee.props.accept)});Ae===!1&&(Te=Te.slice(0,1)),ee.uploadFiles(Te)}},ee.uploadFiles=function(Ce){var Ae=Array.prototype.slice.call(Ce);Ae.map(function(Te){return Te.uid=R(),Te}).forEach(function(Te){ee.upload(Te,Ae)})},ee.saveFileInput=function(Ce){ee.fileInput=Ce},Y),y(ee,ae)}return o(P,[{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.abort()}},{key:"upload",value:function(Y,ee){var ae=this,ce=this.props;if(!ce.beforeUpload)return setTimeout(function(){return ae.post(Y)},0);var De=ce.beforeUpload(Y,ee);De&&De.then?De.then(function(Se){var Ce=Object.prototype.toString.call(Se);return Ce==="[object File]"||Ce==="[object Blob]"?ae.post(Se):ae.post(Y)}).catch(function(Se){console.log(Se)}):De!==!1&&setTimeout(function(){return ae.post(Y)},0);return}},{key:"post",value:function(Y){var ee=this;if(!this._isMounted)return;var ae=this.props,ce=ae.onStart,De=ae.onProgress,Se=ae.transformFile,Ce=Se===void 0?function(Ae){return Ae}:Se;new Promise(function(Ae){var Te=ae.action;return typeof Te=="function"&&(Te=Te(Y)),Ae(Te)}).then(function(Ae){var Te=Y.uid,ve=ae.customRequest||z,le=Promise.resolve(Ce(Y)).then(function(te){var de=ae.data;return typeof de=="function"&&(de=de(te)),Promise.all([te,de])}).catch(function(te){console.error(te)});le.then(function(te){var de=u(te,2),ne=de[0],ke=de[1],Oe={action:Ae,filename:ae.name,data:ke,file:ne,headers:ae.headers,withCredentials:ae.withCredentials,method:ae.method||"post",onProgress:De?function(Ee){De(Ee,Y)}:null,onSuccess:function(Re,Be){delete ee.reqs[Te],ae.onSuccess(Re,Y,Be)},onError:function(Re,Be){delete ee.reqs[Te],ae.onError(Re,Be,Y)}};ce(Y),ee.reqs[Te]=ve(Oe)})})}},{key:"reset",value:function(){this.setState({uid:R()})}},{key:"abort",value:function(Y){var ee=this.reqs;if(Y){var ae=Y;Y&&Y.uid&&(ae=Y.uid),ee[ae]&&ee[ae].abort&&ee[ae].abort(),delete ee[ae]}else Object.keys(ee).forEach(function(ce){ee[ce]&&ee[ce].abort&&ee[ce].abort(),delete ee[ce]})}},{key:"render",value:function(){var Y,ee=this.props,ae=ee.component,ce=ee.prefixCls,De=ee.className,Se=ee.disabled,Ce=ee.id,Ae=ee.style,Te=ee.multiple,ve=ee.accept,le=ee.children,te=ee.directory,de=ee.openFileDialogOnClick,ne=ee.onMouseEnter,ke=ee.onMouseLeave,Oe=h(ee,["component","prefixCls","className","disabled","id","style","multiple","accept","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"]),Ee=Z()((Y={},l(Y,ce,!0),l(Y,ce+"-disabled",Se),l(Y,De,De),Y)),Re=Se?{}:{onClick:de?this.onClick:function(){},onKeyDown:de?this.onKeyDown:function(){},onMouseEnter:ne,onMouseLeave:ke,onDrop:this.onFileDrop,onDragOver:this.onFileDrop,tabIndex:"0"};return $.a.createElement(ae,C({},Re,{className:Ee,role:"button",style:Ae}),$.a.createElement("input",C({},k(Oe),{id:Ce,type:"file",ref:this.saveFileInput,onClick:function(ze){return ze.stopPropagation()},key:this.state.uid,style:{display:"none"},accept:ve,directory:te?"directory":null,webkitdirectory:te?"webkitdirectory":null,multiple:Te,onChange:this.onChange})),le)}}]),P}(oe.Component),f=x,p=Object.assign||function(V){for(var P=1;P<arguments.length;P++){var _=arguments[P];for(var Y in _)Object.prototype.hasOwnProperty.call(_,Y)&&(V[Y]=_[Y])}return V},d=function(){function V(P,_){for(var Y=0;Y<_.length;Y++){var ee=_[Y];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(P,ee.key,ee)}}return function(P,_,Y){return _&&V(P.prototype,_),Y&&V(P,Y),P}}();function a(V,P){if(!(V instanceof P))throw new TypeError("Cannot call a class as a function")}function b(V,P){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:V}function m(V,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);V.prototype=Object.create(P&&P.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(V,P):V.__proto__=P)}function E(){}var B=function(V){m(P,V);function P(){var _,Y,ee,ae;a(this,P);for(var ce=arguments.length,De=Array(ce),Se=0;Se<ce;Se++)De[Se]=arguments[Se];return ae=(Y=(ee=b(this,(_=P.__proto__||Object.getPrototypeOf(P)).call.apply(_,[this].concat(De))),ee),ee.saveUploader=function(Ce){ee.uploader=Ce},Y),b(ee,ae)}return d(P,[{key:"abort",value:function(Y){this.uploader.abort(Y)}},{key:"render",value:function(){return $.a.createElement(f,p({},this.props,{ref:this.saveUploader}))}}]),P}(oe.Component);B.defaultProps={component:"span",prefixCls:"rc-upload",data:{},headers:{},name:"file",multipart:!1,onStart:E,onError:E,onSuccess:E,multiple:!1,beforeUpload:null,customRequest:null,withCredentials:!1,openFileDialogOnClick:!0};var U=B,K=ut.a=U},Gytx:function(Tt,ut){Tt.exports=function(oe,$,D,Z){var F=D?D.call(Z,oe,$):void 0;if(F!==void 0)return!!F;if(oe===$)return!0;if(typeof oe!="object"||!oe||typeof $!="object"||!$)return!1;var M=Object.keys(oe),z=Object.keys($);if(M.length!==z.length)return!1;for(var H=Object.prototype.hasOwnProperty.bind($),N=0;N<M.length;N++){var R=M[N];if(!H(R))return!1;var v=oe[R],T=$[R];if(F=D?D.call(Z,v,T,R):void 0,F===!1||F===void 0&&v!==T)return!1}return!0}},HmJG:function(Tt,ut,he){},LdHM:function(Tt,ut,he){"use strict";he.d(ut,"b",function(){return h}),he.d(ut,"a",function(){return y});var oe=he("1OyB"),$=he("vuIU"),D=he("Ji7U"),Z=he("LK+K"),F=he("q1tI"),M=he("rePB"),z=he("Ff2n"),H=he("ODXe"),N=he("4IlW"),R=he("bX4T"),v=he("YrtM"),T=he("TSYQ"),O=he.n(T),L=he("+nKL"),A=he("8OUc"),C=function(Y,ee){var ae=Y.prefixCls,ce=Y.id,De=Y.flattenOptions,Se=Y.childrenAsData,Ce=Y.values,Ae=Y.searchValue,Te=Y.multiple,ve=Y.defaultActiveFirstOption,le=Y.height,te=Y.itemHeight,de=Y.notFoundContent,ne=Y.open,ke=Y.menuItemSelectedIcon,Oe=Y.virtual,Ee=Y.onSelect,Re=Y.onToggleOpen,Be=Y.onActiveValue,ze=Y.onScroll,Fe=Y.onMouseEnter,Ue="".concat(ae,"-item"),Ie=Object(v.a)(function(){return De},[ne,De],function(Ge,xe){return xe[0]&&Ge[1]!==xe[1]}),it=F.useRef(null),Ye=function(xe){xe.preventDefault()},Qe=function(xe){it.current&&it.current.scrollTo({index:xe})},qe=function(xe){for(var me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ye=Ie.length,re=0;re<ye;re+=1){var ie=(xe+re*me+ye)%ye,se=Ie[ie],pe=se.group,be=se.data;if(!pe&&!be.disabled)return ie}return-1},ct=F.useState(function(){return qe(0)}),et=Object(H.a)(ct,2),nt=et[0],Pe=et[1],dt=function(xe){Pe(xe);var me=Ie[xe];if(!me){Be(null,-1);return}Be(me.data.value,xe)};F.useEffect(function(){dt(ve!==!1?qe(0):-1)},[Ie.length,Ae]),F.useEffect(function(){var Ge=setTimeout(function(){if(!Te&&ne&&Ce.size===1){var xe=Array.from(Ce)[0],me=Ie.findIndex(function(ye){var re=ye.data;return re.value===xe});dt(me),Qe(me)}});return function(){return clearTimeout(Ge)}},[ne]);var at=function(xe){xe!==void 0&&Ee(xe,{selected:!Ce.has(xe)}),Te||Re(!1)};if(F.useImperativeHandle(ee,function(){return{onKeyDown:function(xe){var me=xe.which;switch(me){case N.a.UP:case N.a.DOWN:{var ye=0;if(me===N.a.UP?ye=-1:me===N.a.DOWN&&(ye=1),ye!==0){var re=qe(nt+ye,ye);Qe(re),dt(re)}break}case N.a.ENTER:{var ie=Ie[nt];ie&&!ie.data.disabled?at(ie.data.value):at(void 0),ne&&xe.preventDefault();break}case N.a.ESC:Re(!1)}},onKeyUp:function(){},scrollTo:function(xe){Qe(xe)}}}),Ie.length===0)return F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),className:"".concat(Ue,"-empty"),onMouseDown:Ye},de);function Me(Ge){var xe=Ie[Ge];if(!xe)return null;var me=xe.data||{},ye=me.value,re=me.label,ie=me.children,se=Object(R.a)(me,!0),pe=Se?ie:re;return xe?F.createElement("div",Object.assign({"aria-label":typeof pe=="string"?pe:null},se,{key:Ge,role:"option",id:"".concat(ce,"_list_").concat(Ge),"aria-selected":Ce.has(ye)}),ye):null}return F.createElement(F.Fragment,null,F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),style:{height:0,width:0,overflow:"hidden"}},Me(nt-1),Me(nt),Me(nt+1)),F.createElement(L.a,{itemKey:"key",ref:it,data:Ie,height:le,itemHeight:te,fullHeight:!1,onMouseDown:Ye,onScroll:ze,virtual:Oe,onMouseEnter:Fe},function(Ge,xe){var me,ye=Ge.group,re=Ge.groupOption,ie=Ge.data,se=ie.label,pe=ie.key;if(ye)return F.createElement("div",{className:O()(Ue,"".concat(Ue,"-group"))},se!==void 0?se:pe);var be=ie.disabled,_e=ie.value,We=ie.title,$e=ie.children,st=ie.style,Ze=ie.className,St=Object(z.a)(ie,["disabled","value","title","children","style","className"]),Et=Ce.has(_e),lt="".concat(Ue,"-option"),Pt=O()(Ue,lt,Ze,(me={},Object(M.a)(me,"".concat(lt,"-grouped"),re),Object(M.a)(me,"".concat(lt,"-active"),nt===xe&&!be),Object(M.a)(me,"".concat(lt,"-disabled"),be),Object(M.a)(me,"".concat(lt,"-selected"),Et),me)),_t=Se?$e:se,Mt=!ke||typeof ke=="function"||Et;return F.createElement("div",Object.assign({},St,{"aria-selected":Et,className:Pt,title:We,onMouseMove:function(){if(nt===xe||be)return;dt(xe)},onClick:function(){be||at(_e)},style:st}),F.createElement("div",{className:"".concat(lt,"-content")},_t||_e),F.isValidElement(ke)||Et,Mt&&F.createElement(A.a,{className:"".concat(Ue,"-option-state"),customizeIcon:ke,customizeIconProps:{isSelected:Et}},Et?"\u2713":null))}))},u=F.forwardRef(C);u.displayName="OptionList";var o=u,l=function(){return null};l.isSelectOption=!0;var h=l,w=function(){return null};w.isSelectOptGroup=!0;var y=w,g=he("VTBJ"),k=he("Zm9Q");function x(_){var Y=_.key,ee=_.props,ae=ee.children,ce=ee.value,De=Object(z.a)(ee,["children","value"]);return Object(g.a)({key:Y,value:ce!==void 0?ce:Y,children:ae},De)}function f(_){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(k.a)(_).map(function(ee,ae){if(!F.isValidElement(ee)||!ee.type)return null;var ce=ee.type.isSelectOptGroup,De=ee.key,Se=ee.props,Ce=Se.children,Ae=Object(z.a)(Se,["children"]);return Y||!ce?x(ee):Object(g.a)(Object(g.a)({key:"__RC_SELECT_GRP__".concat(De===null?ae:De,"__"),label:De},Ae),{},{options:f(Ce)})}).filter(function(ee){return ee})}var p=he("2Qr1"),d=he("qNPg"),a=he("U8pU"),b=he("Kwbf"),m=he("WKfj");function E(_){var Y=_.mode,ee=_.options,ae=_.children,ce=_.backfill,De=_.allowClear,Se=_.placeholder,Ce=_.getInputElement,Ae=_.showSearch,Te=_.onSearch,ve=_.defaultOpen,le=_.autoFocus,te=_.labelInValue,de=_.value,ne=_.inputValue,ke=_.optionLabelProp,Oe=Y==="multiple"||Y==="tags",Ee=Ae!==void 0?Ae:Oe||Y==="combobox",Re=ee||f(ae);if(Object(b.a)(Y!=="tags"||Re.every(function(Ue){return!Ue.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),Y==="tags"||Y==="combobox"){var Be=Re.some(function(Ue){return Ue.options?Ue.options.some(function(Ie){return typeof("value"in Ie?Ie.value:Ie.key)=="number"}):typeof("value"in Ue?Ue.value:Ue.key)=="number"});Object(b.a)(!Be,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(Y!=="combobox"||!ke,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(Y==="combobox"||!ce,"`backfill` only works with `combobox` mode."),Object(b.a)(Y==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(b.b)(Y!=="combobox"||!Ce||!De||!Se,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Te&&!Ee&&Y!=="combobox"&&Y!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!ve||le,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),de!=null){var ze=Object(m.d)(de);Object(b.a)(!te||ze.every(function(Ue){return Object(a.a)(Ue)==="object"&&("key"in Ue||"value"in Ue)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Oe||Array.isArray(de),"`value` should be array when `mode` is `multiple` or `tags`")}if(ae){var Fe=null;Object(k.a)(ae).some(function(Ue){if(!F.isValidElement(Ue)||!Ue.type)return!1;var Ie=Ue.type;if(Ie.isSelectOption)return!1;if(Ie.isSelectOptGroup){var it=Object(k.a)(Ue.props.children).every(function(Ye){return!F.isValidElement(Ye)||!Ue.type||Ye.type.isSelectOption?!0:(Fe=Ye.type,!1)});return!it}return Fe=Ie,!0}),Fe&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Fe.displayName||Fe.name||Fe,"`.")),Object(b.a)(ne===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var B=E,U=Object(d.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:B,fillOptionsWithMissingValue:p.a}),K=function(_){Object(D.a)(ee,_);var Y=Object(Z.a)(ee);function ee(){var ae;return Object(oe.a)(this,ee),ae=Y.apply(this,arguments),ae.selectRef=F.createRef(),ae.focus=function(){ae.selectRef.current.focus()},ae.blur=function(){ae.selectRef.current.blur()},ae}return Object($.a)(ee,[{key:"render",value:function(){return F.createElement(U,Object.assign({ref:this.selectRef},this.props))}}]),ee}(F.Component);K.Option=h,K.OptGroup=y;var V=K,P=ut.c=V},M8RZ:function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return N});var oe=he("fWQN"),$=he("mtLc"),D=he("yKVA"),Z=he("879j"),F=he("q1tI"),M=he.n(F),z=he("i8i4"),H=he.n(z),N=function(R){Object(D.a)(T,R);var v=Object(Z.a)(T);function T(O){var L;Object(oe.a)(this,T),L=v.call(this,O);var A=window.document;return L.node=A.createElement("div"),A.body.appendChild(L.node),L}return Object($.a)(T,[{key:"render",value:function(){var L=this.props.children;return Object(z.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),T}(M.a.Component)},OLES:function(Tt,ut,he){"use strict";var oe=he("U8pU"),$=he("VTBJ"),D=he("Ff2n"),Z=he("q1tI"),F=he("uciX"),M=he("7ixt"),z=function(O){var L=O.overlay,A=O.prefixCls,C=O.id,u=O.overlayInnerStyle;return Z.createElement("div",{className:"".concat(A,"-inner"),id:C,role:"tooltip",style:u},typeof L=="function"?L():L)},H=z,N=function(O,L){var A=O.overlayClassName,C=O.trigger,u=C===void 0?["hover"]:C,o=O.mouseEnterDelay,l=o===void 0?0:o,h=O.mouseLeaveDelay,w=h===void 0?.1:h,y=O.overlayStyle,g=O.prefixCls,k=g===void 0?"rc-tooltip":g,x=O.children,f=O.onVisibleChange,p=O.afterVisibleChange,d=O.transitionName,a=O.animation,b=O.placement,m=b===void 0?"right":b,E=O.align,B=E===void 0?{}:E,U=O.destroyTooltipOnHide,K=U===void 0?!1:U,V=O.defaultVisible,P=O.getTooltipContainer,_=O.overlayInnerStyle,Y=Object(D.a)(O,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),ee=Object(Z.useRef)(null);Object(Z.useImperativeHandle)(L,function(){return ee.current});var ae=Object($.a)({},Y);"visible"in O&&(ae.popupVisible=O.visible);var ce=function(){var Te=O.arrowContent,ve=Te===void 0?null:Te,le=O.overlay,te=O.id;return[Z.createElement("div",{className:"".concat(k,"-arrow"),key:"arrow"},ve),Z.createElement(H,{key:"content",prefixCls:k,id:te,overlay:le,overlayInnerStyle:_})]},De=!1,Se=!1;if(typeof K=="boolean")De=K;else if(K&&Object(oe.a)(K)==="object"){var Ce=K.keepParent;De=Ce===!0,Se=Ce===!1}return Z.createElement(F.a,Object.assign({popupClassName:A,prefixCls:k,popup:ce,action:u,builtinPlacements:M.a,popupPlacement:m,ref:ee,popupAlign:B,getPopupContainer:P,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:d,popupAnimation:a,defaultPopupVisible:V,destroyPopupOnHide:De,autoDestroy:Se,mouseLeaveDelay:w,popupStyle:y,mouseEnterDelay:l},ae),x)},R=Object(Z.forwardRef)(N),v=ut.a=R},Ot1p:function(Tt,ut,he){"use strict";var oe=he("2qtc"),$=he("kLXV"),D=he("rAM+"),Z=he("miYZ"),F=he("tsqr"),M=he("9og8"),z=he("tJVT"),H=he("jrin"),N=he("WmNS"),R=he.n(N),v=he("q1tI"),T=he.n(v),O=he("VrN/"),L=he.n(O),A=he("bdgK"),C=he("p77/"),u=he("Bd2K"),o=he("ELLl"),l=he("19Vz"),h=he("lZu9"),w=he("+NIl"),y=he("kSUc"),g=he("9Bee"),k=function(be){var _e=be.value,We=_e===void 0?"":_e,$e=be.className,st=be.showTextOnly,Ze=be.showLines,St=be.style,Et=St===void 0?{}:St,lt=Object(v.useMemo)(function(){return""},[We]);return T.a.createElement(T.a.Fragment,null,T.a.createElement("div",{dangerouslySetInnerHTML:{__html:lt}}))},x=he("0Owb"),f=he("dejd"),p=he("C+DQ"),d=he("1vsH"),a=he("m3rI"),b=[{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 m(be){var _e=be.onActionCallback,We=be.title,$e=be.icon,st=be.actionName,Ze=be.className,St=Ze===void 0?"":Ze,Et=be.children;function lt(){_e(st)}return T.a.createElement("a",{title:We,className:St,onClick:lt},T.a.createElement("i",{className:"md-iconfont ".concat($e)}),Et)}var E=function(be){var _e=be.watch,We=be.showNullButton,$e=be.onActionCallback,st=be.fullScreen,Ze=be.insertTemp,St=be.hidetoolBar,Et=be.uuid,lt=be.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(Et,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Pt=[].concat(b,[{title:"".concat(_e?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(_e?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return T.a.createElement("ul",{className:"markdown-toolbar-container"},!St&&Pt.map(function(_t,Mt){return T.a.createElement("li",{key:Mt},_t.actionName?T.a.createElement(m,Object(x.a)({},_t,{onActionCallback:$e})):T.a.createElement("span",{className:"v-line"}))}),We?T.a.createElement("li",null,T.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:$e},T.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,Ze&&T.a.createElement("li",null,T.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(Ze),onActionCallback:$e},T.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),T.a.createElement("li",{className:"btn-full-screen"},T.a.createElement(m,{icon:"".concat(st?"icon-shrink":"icon-enlarge"),title:st?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:$e})))},B=he("M8RZ"),U=he("+L6B"),K=he("2/Rp"),V=he("y8nQ"),P=he("Vl3Y"),_=he("5NDa"),Y=he("5rEg"),ee={labelCol:{span:4},wrapperCol:{span:20}},ae=function(be){var _e=be.callback,We=be.onCancel;function $e(st){_e(st)}return T.a.createElement(P.a,Object(x.a)({},ee,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:$e}),T.a.createElement(P.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},T.a.createElement(Y.a,null)),T.a.createElement(P.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},T.a.createElement(Y.a,null)),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(K.a,{type:"ghost",onClick:We},"\u53D6\u6D88")))},ce=he("7ahc"),De=he("HmJG"),Se=he("BjJ7"),Ce=P.a.useForm,Ae={width:280,marginRight:10},Te={labelCol:{span:5},wrapperCol:{span:19}},ve=function(be){var _e=be.callback,We=be.onCancel,$e=Ce(),st=Object(z.a)($e,1),Ze=st[0];function St(Pt){_e(Pt)}function Et(Pt,_t){if(Pt.status===-1){F.b.error(Pt.message);return}Ze.setFieldsValue({src:"/api/attachments/".concat(Pt.id),type:_t.type})}function lt(Pt){var _t=Pt.target.files[0];te(_t,Et)}return T.a.createElement(P.a,Object(x.a)({form:Ze},Te,{className:"upload-image-panel",onFinish:St}),T.a.createElement(P.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},T.a.createElement("div",{className:"flex-container"},T.a.createElement(P.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},T.a.createElement(Y.a,{style:Ae})),T.a.createElement(le,{onFileChange:lt}))),T.a.createElement(P.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},T.a.createElement(Y.a,{style:{width:264}})),T.a.createElement(P.a.Item,{style:{textAlign:"right"}},T.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(K.a,{type:"ghost",onClick:We},"\u53D6\u6D88")))};function le(be){var _e=be.onFileChange;return T.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",T.a.createElement("input",{type:"file",onChange:_e}))}function te(be,_e){if(!be)throw new String("\u6CA1\u6709\u6587\u4EF6");var We=new FormData;We.append("editormd-image-file",be),We.append("file_param_name","editormd-image-file"),We.append("byxhr","true");var $e=new window.XMLHttpRequest;$e.withCredentials=!0,$e.addEventListener("load",function(st){_e(JSON.parse(st.target.responseText),be)},!1),$e.addEventListener("error",function(st){console.error(st)},!1),$e.open("POST","".concat(Se.a,"/api/attachments.json")),$e.send(We)}var de=he("giR+"),ne=he("fyUT"),ke=he("7Kak"),Oe=he("9yH6"),Ee=Oe.a.Group,Re={margin:"0 8px"},Be=function(be){var _e=be.callback,We=be.onCancel;function $e(st){_e(st)}return T.a.createElement(P.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:$e},T.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},T.a.createElement("span",{style:Re},"\u5355\u5143\u683C\u6570\uFF1A"),T.a.createElement("span",{style:Re},"\u884C\u6570"),T.a.createElement(P.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},T.a.createElement(ne.a,null)),T.a.createElement("span",{style:Re},"\u5217\u6570"),T.a.createElement(P.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},T.a.createElement(ne.a,null))),T.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},T.a.createElement("span",{style:Re},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),T.a.createElement(P.a.Item,{name:"align"},T.a.createElement(Ee,null,T.a.createElement(Oe.a,{value:"default"},T.a.createElement("i",{className:"fa fa-align-justify"})),T.a.createElement(Oe.a,{value:"left"},T.a.createElement("i",{className:"fa fa-align-left"})),T.a.createElement(Oe.a,{value:"center"},T.a.createElement("i",{className:"fa fa-align-center"})),T.a.createElement(Oe.a,{value:"right"},T.a.createElement("i",{className:"fa fa-align-right"}))))),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(K.a,{type:"ghost",onClick:We},"\u53D6\u6D88")))},ze=he("ErOA"),Fe=he("7Cbv"),Ue="link",Ie="upload-image",it="code-block",Ye="add-table",Qe="------------",qe={default:Qe,left:":".concat(Qe),center:":".concat(Qe,":"),right:"".concat(Qe,":")},ct=he("9VGf"),et,nt;function Pe(){}var dt=0,at=1e4,Me="\u2581",Ge=`
**\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 xe(be){return/^\d+$/.test(be)?"".concat(be,"px"):be}var me=navigator.platform.toUpperCase().indexOf("MAC")>=0,ye=me?"Cmd":"Ctrl",re=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],ie=(et={},Object(H.a)(et,ye+"-B","bold"),Object(H.a)(et,ye+"-I","italic"),et),se=(nt={},Object(H.a)(nt,Ue,"\u6DFB\u52A0\u94FE\u63A5"),Object(H.a)(nt,it,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(H.a)(nt,Ie,"\u6DFB\u52A0\u6587\u4EF6"),Object(H.a)(nt,Ye,"\u6DFB\u52A0\u8868\u683C"),nt),pe=ut.a=function(be){var _e=be.defaultValue,We=_e===void 0?"":_e,$e=be.onChange,st=be.width,Ze=st===void 0?"100%":st,St=be.height,Et=St===void 0?400:St,lt=be.miniToolbar,Pt=lt===void 0?!1:lt,_t=be.isFocus,Mt=_t===void 0?!1:_t,jt=be.watch,Lt=be.insertTemp,pr=be.mode,Kr=pr===void 0?"markdown":pr,bt=be.id,Nr=bt===void 0?"markdown-editor-id":bt,hr=be.showResizeBar,mr=hr===void 0?!1:hr,Br=be.noStorage,ci=Br===void 0?!1:Br,qr=be.showNullButton,Bt=qr===void 0?!1:qr,ft=be.hidetoolBar,Hr=ft===void 0?!1:ft,ei=be.fullScreen,gr=ei===void 0?!1:ei,Dt=be.onBlur,Fr=be.onCMBeforeChange,Vr=be.onFullScreen,fi=be.className,Ve=fi===void 0?"":fi,Ct=be.disablePaste,pi=Ct===void 0?!1:Ct,mi=be.placeholder,gi=mi===void 0?"":mi,vi=be.values,G=vi===void 0?"":vi,s=Object(v.useState)(null),c=Object(z.a)(s,2),I=c[0],Q=c[1],W=Object(v.useState)(We),ge=Object(z.a)(W,2),je=ge[0],Je=ge[1],pt=Object(v.useState)(jt),He=Object(z.a)(pt,2),vt=He[0],Ft=He[1],Xt=Object(v.useState)(gr),_r=Object(z.a)(Xt,2),vr=_r[0],yr=_r[1],Xr=Object(v.useState)(""),Oi=Object(z.a)(Xr,2),nr=Oi[0],Ur=Oi[1],oi=Object(v.useState)(0),si=Object(z.a)(oi,2),Pr=si[0],_i=si[1],yi=Object(v.useState)(Et),zi=Object(z.a)(yi,2),Ki=zi[0],Yr=zi[1],Gr=Object(v.useState)(!1),bi=Object(z.a)(Gr,2),dn=bi[0],xi=bi[1],Jt=Object(v.useRef)(Object(Fe.a)()),Ut=Object(v.useRef)(!1),dr=Object(v.useRef)(),Rt=Object(v.useRef)(),qt=Object(v.useRef)(),Gt=Object(v.useRef)(),ti=Object(v.useRef)(),ar=function(){var mt=Object(M.a)(R.a.mark(function wt(){var yt,kt;return R.a.wrap(function(Kt){for(;;)switch(Kt.prev=Kt.next){case 0:return Kt.next=2,Object(ze.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:kt=Kt.sent,kt!=null&&(yt=kt.attachments)!==null&&yt!==void 0&&yt.length&&(console.log("cm:",I,Rt),kt.attachments.map(function(It){It.content_type.indexOf("image")>-1?I.replaceSelection("![,](/api/attachments/".concat(It.id,"?type=").concat(It.content_type,")")):It.content_type.indexOf("video")>-1?I.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):It.content_type.indexOf("pdf")>-1?I.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):I.replaceSelection("[".concat(It.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(It.id,"?type=").concat(It.content_type,")"))}));case 4:case"end":return Kt.stop()}},wt)}));return function(){return mt.apply(this,arguments)}}();Object(v.useEffect)(function(){Je(G),I==null||I.setValue(G)},[G]),Object(v.useEffect)(function(){Vr==null||Vr(vr)},[vr]),Object(v.useEffect)(function(){if(Rt.current){var mt=L.a.fromTextArea(Rt.current,{mode:Kr,lineNumbers:!Pt,lineWrapping:!0,value:We,autoCloseTags:!0,autoCloseBrackets:!0});Mt&&mt.focus();function wt(yt,kt){if(pi){kt.preventDefault();return}var Nt=kt.clipboardData;if(Nt){var Kt=Nt.types.toString(),It=Nt.items;if(Kt==="Files"||Nt.types.indexOf("Files")>-1){if(kt.preventDefault(),Kr=="stex")return;try{var rr,wr=It[1];((rr=It[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(wr=It[0]);var Ot=wr.getAsFile(),li=Ot.name.split(".").pop();te(Ot,function(Wt){if(Wt.id){var Ar,br,zr;(Ot==null||((Ar=Ot.type)===null||Ar===void 0)?void 0:Ar.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Wt.id,"?type=").concat(Wt.content_type,")")):(Ot==null||((br=Ot.type)===null||br===void 0)?void 0:br.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Ot==null||((zr=Ot.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Ot.type,'&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):re.includes(li)?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):mt.replaceSelection("[".concat(Ot.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})}catch(Wt){F.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return mt.on("paste",wt),mt.on("dragleave",function(yt,kt){qt.current.classList.remove("mouse-hover-md")}),mt.on("dragover",function(yt,kt){qt.current.classList.add("mouse-hover-md")}),mt.on("drop",function(yt,kt){qt.current.classList.add("mouse-hover-md");var Nt;if(Nt=kt.dataTransfer.files,Nt.length>0){kt.preventDefault(),kt.stopPropagation();for(var Kt=function(wr){var Ot=Nt[wr],li=Ot.name.split(".").pop();te(Ot,function(Wt){if(Wt.id){var Ar,br,zr;(Ot==null||((Ar=Ot.type)===null||Ar===void 0)?void 0:Ar.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Wt.id,"?type=").concat(Wt.content_type,")")):(Ot==null||((br=Ot.type)===null||br===void 0)?void 0:br.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'"></video>')):(Ot==null||((zr=Ot.type)===null||zr===void 0)?void 0:zr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Ot.type,'&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):re.includes(li)?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,'?type=office&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):mt.replaceSelection("[".concat(Ot.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Wt.id,"?type=").concat(Wt.content_type,")"))}else(Wt==null?void 0:Wt.status)===401&&(document.location.href="/user/login")})},It=0;It<Nt.length;It++)Kt(It)}}),Q(mt),function(){mt.off("paste",wt)}}},[]);var Sr=Object(v.useCallback)(function(){if(qt.current)try{}catch(mt){console.log(mt,"---- to set md editor body height")}},[Ki,qt,vr]);Object(v.useEffect)(function(){function mt(){var yt=new A.default(function(kt){var Nt=Object(D.a)(kt),Kt;try{for(Nt.s();!(Kt=Nt.n()).done;){var It=Kt.value;(It.target.offsetHeight>0||It.target.offsetWidth>0)&&(Sr(),I.setSize("100%","100%"),I.refresh())}}catch(rr){Nt.e(rr)}finally{Nt.f()}});return yt.observe(Rt.current.parentElement),yt}if(I){var wt=mt();return function(){wt.unobserve(Rt.current.parentElement)}}},[I,Sr]),Object(v.useEffect)(function(){if(I){for(var mt=[],wt=function(){var It=kt[yt];Nt=Object(z.a)(It,2);var rr=Nt[0],wr=Nt[1],Ot=Object(H.a)({},rr,function(){Vi(wr)});mt.push(Ot),I.addKeyMap(Ot)},yt=0,kt=Object.entries(ie);yt<kt.length;yt++){var Nt;wt()}return dr.current=setInterval(function(){Ut.current&&ar()},4e3),function(){clearInterval(dr.current);var Kt=Object(D.a)(mt),It;try{for(Kt.s();!(It=Kt.n()).done;){var rr=It.value;I.removeKeyMap(rr)}}catch(wr){Kt.e(wr)}finally{Kt.f()}}}},[I]),Object(v.useEffect)(function(){gr!==vr&&yr(gr)},[gr]),Object(ct.a)(function(){if(!ci&&Pr>0){var mt=new Date().getTime(),wt=window.sessionStorage.getItem(Nr);mt>=Pr+at&&(!wt||wt!==je)&&(window.sessionStorage.setItem(Nr,je),xi(!0))}},at),Object(v.useEffect)(function(){Ft(jt)},[I,jt]),Object(v.useEffect)(function(){I&&(Mt&&I.focus())},[I,Mt]),Object(v.useEffect)(function(){if(vt&&I){var mt=I.getScrollerElement();function wt(yt){var kt=yt.target;if(ti.current){var Nt=kt.scrollTop/kt.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Nt}}return mt.addEventListener("scroll",wt),function(){mt.removeEventListener("scroll",wt)}}},[I,vt]),Object(v.useEffect)(function(){if(I&&Fr){function mt(wt,yt){Fr(wt,yt)}return I.on("beforeChange",mt),function(){I.off("beforeChange",mt)}}},[I,Fr]),Object(v.useEffect)(function(){if(I&&Dt){function mt(){Dt(I.getValue())}return I.on("blur",mt),function(){I.off("blur",mt)}}},[I,Dt]),Object(v.useEffect)(function(){if(I){function mt(wt){var yt=wt.getValue();Je(yt),_i(new Date().getTime()),wt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),$e&&$e(yt)}return I.on("change",mt),function(){I.off("change",mt)}}},[I,$e]),Object(v.useEffect)(function(){I&&(We==null?(I.setValue(""),Je("")):We!==I.getValue()&&(I.setValue(We),Je(We),I.setCursor(I.lineCount(),0)))},[I,We]);var Vi=Object(v.useCallback)(function(mt){var wt=I.getCursor(),yt=I.getSelection(),kt=yt.split(`
`);switch(mt){case"bold":return I.replaceSelection("**"+yt+"**"),yt===""&&I.setCursor(wt.line,wt.ch+2),I.focus();case"italic":return I.replaceSelection("*"+yt+"*"),yt===""&&I.setCursor(wt.line,wt.ch+1),I.focus();case"code":return I.replaceSelection("`"+yt+"`"),yt===""&&I.setCursor(wt.line,wt.ch+1),I.focus();case"inline-latex":return I.replaceSelection("`$$"+yt+"$$`"),yt===""&&I.setCursor(wt.line,wt.ch+3),I.focus();case"latex":return I.replaceSelection("```latex\n"+yt+"\n```"),I.setCursor(wt.line+1,yt.length+1),I.focus();case"line-break":return I.replaceSelection(`<br/>
`),I.focus();case"list-ul":return yt===""?I.replaceSelection("- "+yt):I.replaceSelection(kt.map(function(Nt){return Nt===""?"":"- ".concat(Nt)}).join(`
`)),I.focus();case"list-ol":return yt===""?I.replaceSelection("1. "+yt):I.replaceSelection(kt.map(function(Nt,Kt){return Nt===""?"":"".concat(Kt+1,". ").concat(Nt)}).join(`
`)),I.focus();case"add-null-ch":return yt===""&&I.setCursor(wt.line,wt.ch+1),I.replaceSelection(Me),I.focus();case"inster-template-1":return yt===""&&I.setCursor(wt.line,wt.ch),I.replaceSelection(Ge),I.focus();case"eraser":return I.setValue(""),I.focus();case"trigger-watch":return Ft(!vt),I.focus();case"trigger-full-screen":return yr(!vr),I.focus();case Ue:Ur(Ue);return;case it:Ur(it);return;case Ie:Ur(Ie);return;case Ye:Ur(Ye);return;default:throw new Error}},[I,vt,vr]),Ei=Object(v.useCallback)(function(mt){Ur("");switch(nr){case Ue:var wt=mt.title,yt=mt.link;return I.replaceSelection("[".concat(wt,"](").concat(yt,")")),I.focus();case it:var kt=mt.language,Nt=mt.content;return I.replaceSelection(["```"+kt,Nt,"```"].join(`
`)),I.focus();case Ie:var Kt=mt.src,It=mt.alt;return It?I.replaceSelection("![ ".concat(It," ]( ").concat(Kt,' "').concat(It,'" )')):I.replaceSelection("![,](".concat(Kt,")")),I.focus();case Ye:for(var rr=mt.row,wr=mt.col,Ot=mt.align,li=`
`,Wt=0;Wt<rr;Wt++){for(var Ar=[],br=[],zr=0;zr<wr;zr++)Wt===1&&br.push(qe[Ot]),Ar.push(" ");Wt===1&&(li+="| ".concat(br.join(" | "),` |
`)),li+="| ".concat(Ar.join(wr===1?"":" | "),` |
`)}return I.replaceSelection(li+`
`),I.focus();default:throw new Error}},[I,nr]),cn=Object(v.useMemo)(function(){switch(nr){case Ue:return T.a.createElement(ae,{callback:Ei,onCancel:Si});case it:return T.a.createElement(ce.b,{callback:Ei,onCancel:Si});case Ie:return T.a.createElement(ve,{callback:Ei,onCancel:Si});case Ye:return T.a.createElement(Be,{callback:Ei,onCancel:Si});default:return null}},[nr]);function Si(){Ur("")}Object(v.useEffect)(function(){if(Gt.current){var mt=Gt.current,wt=!1,yt=0;function kt(It){wt=!0,yt=It.pageY}function Nt(){wt=!1}function Kt(It){if(wt){var rr=It.pageY-yt;rr<0&&(rr=0),rr>300&&(rr=300);var wr=Et+rr+"px";Yr(wr)}}return mt.addEventListener("mousedown",kt),document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",Nt),function(){mt.removeEventListener("mousedown",kt),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",Nt)}}},[I,Gt]),Object(v.useEffect)(function(){Yr(Et)},[Et]);var ri=xe(Ze),fn=xe(Ki),$r={width:ri,height:fn},pn=Object(v.useMemo)(function(){if(Pr){var mt=new Date(Pr),wt=mt.getHours(),yt=mt.getMinutes(),kt=mt.getSeconds();return wt=wt<10?"0"+wt:wt,yt=yt<10?"0"+yt:yt,kt=kt<10?"0"+kt:kt,"".concat(wt,":").concat(yt,":").concat(kt)}return 0},[Pr]);function jn(){window.sessionStorage.removeItem(Nr),xi(!1),_i(0)}function Pi(){xi(!1),_i(0),I.setValue(window.sessionStorage.getItem(Nr))}function ua(mt,wt){var yt=I.getValue();yt=yt.replace(mt,wt),Je(yt),I==null||I.setValue(yt)}return T.a.createElement(v.Fragment,null,T.a.createElement("div",{className:"markdown-editor-wrapper",ref:qt},T.a.createElement("div",{className:"markdown-editor-container ".concat(Ve," ").concat(vt?"on-preview":""," ").concat(Pt?"mini":""," ").concat(vr?"full-screen":""),style:$r},T.a.createElement(E,{insertTemp:Lt,watch:vt,fullScreen:vr,showNullButton:Bt,onActionCallback:Vi,hidetoolBar:Hr,uuid:Jt.current,setOpenPhones:function(){Ut.current=!0}}),T.a.createElement("div",{className:"markdown-editor-body"},T.a.createElement("div",{className:"codemirror-container"},T.a.createElement("textarea",{ref:Rt,placeholder:gi})),vt?T.a.createElement("div",{ref:ti,className:"preview-container"},Kr==="stex"&&T.a.createElement(k,{value:je}),Kr!=="stex"&&T.a.createElement(g.a,{edit:!0,value:je,replaces:ua})):null))),mr?T.a.createElement("a",{ref:Gt,className:"editor-resize"}):null,T.a.createElement(B.a,null,se[nr]?T.a.createElement($.a,{centered:!0,title:se[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(Tt,ut){/**
* @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 he,oe,$,D=!1,Z,F;window.PR_SHOULD_USE_CONTINUATION=!0;var M,z;(function(){var H=window,N=["break,continue,do,else,for,if,return,while"],R=[N,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],v=[R,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],T=[v,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],O=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[v,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],A="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",C=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[N,"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=[N,"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=[N,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],w=[T,L,O,C,u,o,l,h],y=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,g="str",k="kwd",x="com",f="typ",p="lit",d="pun",a="pln",b="tag",m="dec",E="src",B="atn",U="atv",K="nocode",V="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function P(Ee){for(var Re=0,Be=!1,ze=!1,Fe=0,Ue=Ee.length;Fe<Ue;++Fe){var Ie=Ee[Fe];if(Ie.ignoreCase)ze=!0;else if(/[a-z]/i.test(Ie.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Be=!0,ze=!1;break}}var it={b:8,t:9,n:10,v:11,f:12,r:13};function Ye(nt){var Pe=nt.charCodeAt(0);if(Pe!==92)return Pe;var dt=nt.charAt(1);return Pe=it[dt],Pe||("0"<=dt&&dt<="7"?parseInt(nt.substring(1),8):dt==="u"||dt==="x"?parseInt(nt.substring(2),16):nt.charCodeAt(1))}function Qe(nt){if(nt<32)return(nt<16?"\\x0":"\\x")+nt.toString(16);var Pe=String.fromCharCode(nt);return Pe==="\\"||Pe==="-"||Pe==="]"||Pe==="^"?"\\"+Pe:Pe}function qe(nt){var Pe=nt.substring(1,nt.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")),dt=[],at=Pe[0]==="^",Me=["["];at&&Me.push("^");for(var Ge=at?1:0,xe=Pe.length;Ge<xe;++Ge){var me=Pe[Ge];if(/\\[bdsw]/i.test(me))Me.push(me);else{var ye=Ye(me),re;Ge+2<xe&&Pe[Ge+1]==="-"?(re=Ye(Pe[Ge+2]),Ge+=2):re=ye,dt.push([ye,re]),re<65||ye>122||(re<65||ye>90||dt.push([Math.max(65,ye)|32,Math.min(re,90)|32]),re<97||ye>122||dt.push([Math.max(97,ye)&~32,Math.min(re,122)&~32]))}}dt.sort(function(be,_e){return be[0]-_e[0]||_e[1]-be[1]});for(var ie=[],se=[],Ge=0;Ge<dt.length;++Ge){var pe=dt[Ge];pe[0]<=se[1]+1?se[1]=Math.max(se[1],pe[1]):ie.push(se=pe)}for(var Ge=0;Ge<ie.length;++Ge){var pe=ie[Ge];Me.push(Qe(pe[0])),pe[1]>pe[0]&&(pe[1]+1>pe[0]&&Me.push("-"),Me.push(Qe(pe[1])))}return Me.push("]"),Me.join("")}function ct(nt){for(var Pe=nt.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")),dt=Pe.length,at=[],Me=0,Ge=0;Me<dt;++Me){var xe=Pe[Me];if(xe==="(")++Ge;else if(xe.charAt(0)==="\\"){var me=+xe.substring(1);me&&(me<=Ge?at[me]=-1:Pe[Me]=Qe(me))}}for(var Me=1;Me<at.length;++Me)at[Me]===-1&&(at[Me]=++Re);for(var Me=0,Ge=0;Me<dt;++Me){var xe=Pe[Me];if(xe==="(")++Ge,at[Ge]||(Pe[Me]="(?:");else if(xe.charAt(0)==="\\"){var me=+xe.substring(1);me&&me<=Ge&&(Pe[Me]="\\"+at[me])}}for(var Me=0;Me<dt;++Me)Pe[Me]==="^"&&Pe[Me+1]!=="^"&&(Pe[Me]="");if(nt.ignoreCase&&Be)for(var Me=0;Me<dt;++Me){var xe=Pe[Me],ye=xe.charAt(0);xe.length>=2&&ye==="["?Pe[Me]=qe(xe):ye!=="\\"&&(Pe[Me]=xe.replace(/[a-zA-Z]/g,function(se){var pe=se.charCodeAt(0);return"["+String.fromCharCode(pe&~32,pe|32)+"]"}))}return Pe.join("")}for(var et=[],Fe=0,Ue=Ee.length;Fe<Ue;++Fe){var Ie=Ee[Fe];if(Ie.global||Ie.multiline)throw new Error(""+Ie);et.push("(?:"+ct(Ie)+")")}return new RegExp(et.join("|"),ze?"gi":"g")}function _(Ee,Re){var Be=/(?:^|\s)nocode(?:\s|$)/,ze=[],Fe=0,Ue=[],Ie=0;function it(Ye){var Qe=Ye.nodeType;if(Qe==1){if(Be.test(Ye.className))return;for(var qe=Ye.firstChild;qe;qe=qe.nextSibling)it(qe);var ct=Ye.nodeName.toLowerCase();(ct==="br"||ct==="li")&&(ze[Ie]=`
`,Ue[Ie<<1]=Fe++,Ue[Ie++<<1|1]=Ye)}else if(Qe==3||Qe==4){var et=Ye.nodeValue;et.length&&(Re?et=et.replace(/\r\n?/g,`
`):et=et.replace(/[ \t\r\n]+/g," "),ze[Ie]=et,Ue[Ie<<1]=Fe,Fe+=et.length,Ue[Ie++<<1|1]=Ye)}}return it(Ee),{sourceCode:ze.join("").replace(/\n$/,""),spans:Ue}}function Y(Ee,Re,Be,ze,Fe){if(!Be)return;var Ue={sourceNode:Ee,pre:1,langExtension:null,numberLines:null,sourceCode:Be,spans:null,basePos:Re,decorations:null};ze(Ue),Fe.push.apply(Fe,Ue.decorations)}var ee=/\S/;function ae(Ee){for(var Re=void 0,Be=Ee.firstChild;Be;Be=Be.nextSibling){var ze=Be.nodeType;Re=ze===1?Re?Ee:Be:ze===3&&ee.test(Be.nodeValue)?Ee:Re}return Re===Ee?void 0:Re}function ce(Ee,Re){var Be={},ze;(function(){for(var Ie=Ee.concat(Re),it=[],Ye={},Qe=0,qe=Ie.length;Qe<qe;++Qe){var ct=Ie[Qe],et=ct[3];if(et)for(var nt=et.length;--nt>=0;)Be[et.charAt(nt)]=ct;var Pe=ct[1],dt=""+Pe;Ye.hasOwnProperty(dt)||(it.push(Pe),Ye[dt]=null)}it.push(/[\0-\uffff]/),ze=P(it)})();var Fe=Re.length,Ue=function(Ie){for(var it=Ie.sourceCode,Ye=Ie.basePos,Qe=Ie.sourceNode,qe=[Ye,a],ct=0,et=it.match(ze)||[],nt={},Pe=0,dt=et.length;Pe<dt;++Pe){var at=et[Pe],Me=nt[at],Ge=void 0,xe;if(typeof Me=="string")xe=!1;else{var me=Be[at.charAt(0)];if(me)Ge=at.match(me[1]),Me=me[0];else{for(var ye=0;ye<Fe;++ye)if(me=Re[ye],Ge=at.match(me[1]),Ge){Me=me[0];break}Ge||(Me=a)}xe=Me.length>=5&&Me.substring(0,5)==="lang-",xe&&!(Ge&&typeof Ge[1]=="string")&&(xe=!1,Me=E),xe||(nt[at]=Me)}var re=ct;if(ct+=at.length,!xe)qe.push(Ye+re,Me);else{var ie=Ge[1],se=at.indexOf(ie),pe=se+ie.length;Ge[2]&&(pe=at.length-Ge[2].length,se=pe-ie.length);var be=Me.substring(5);Y(Qe,Ye+re,at.substring(0,se),Ue,qe),Y(Qe,Ye+re+se,ie,le(be,ie),qe),Y(Qe,Ye+re+pe,at.substring(pe),Ue,qe)}}Ie.decorations=qe};return Ue}function De(Ee){var Re=[],Be=[];Ee.tripleQuotedStrings?Re.push([g,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Ee.multiLineStrings?Re.push([g,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Re.push([g,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Ee.verbatimStrings&&Be.push([g,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var ze=Ee.hashComments;ze&&(Ee.cStyleComments?(ze>1?Re.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Re.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Be.push([g,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Re.push([x,/^#[^\r\n]*/,null,"#"])),Ee.cStyleComments&&(Be.push([x,/^\/\/[^\r\n]*/,null]),Be.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Fe=Ee.regexLiterals;if(Fe){var Ue=Fe>1?"":`
\r`,Ie=Ue?".":"[\\S\\s]",it="/(?=[^/*"+Ue+"])(?:[^/\\x5B\\x5C"+Ue+"]|\\x5C"+Ie+"|\\x5B(?:[^\\x5C\\x5D"+Ue+"]|\\x5C"+Ie+")*(?:\\x5D|$))+/";Be.push(["lang-regex",RegExp("^"+V+"("+it+")")])}var Ye=Ee.types;Ye&&Be.push([f,Ye]);var Qe=(""+Ee.keywords).replace(/^ | $/g,"");Qe.length&&Be.push([k,new RegExp("^(?:"+Qe.replace(/[\s,]+/g,"|")+")\\b"),null]),Re.push([a,/^\s+/,null,` \r
\xA0`]);var qe="^.[^\\s\\w.$@'\"`/\\\\]*";return Ee.regexLiterals&&(qe+="(?!s*/)"),Be.push([p,/^@[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],[p,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(qe),null]),ce(Re,Be)}var Se=De({keywords:w,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(Ee,Re,Be){for(var ze=/(?:^|\s)nocode(?:\s|$)/,Fe=/\r\n?|\n/,Ue=Ee.ownerDocument,Ie=Ue.createElement("li");Ee.firstChild;)Ie.appendChild(Ee.firstChild);var it=[Ie];function Ye(Pe){var dt=Pe.nodeType;if(dt==1&&!ze.test(Pe.className))if(Pe.nodeName==="br")Qe(Pe),Pe.parentNode&&Pe.parentNode.removeChild(Pe);else for(var at=Pe.firstChild;at;at=at.nextSibling)Ye(at);else if((dt==3||dt==4)&&Be){var Me=Pe.nodeValue,Ge=Me.match(Fe);if(Ge){var xe=Me.substring(0,Ge.index);Pe.nodeValue=xe;var me=Me.substring(Ge.index+Ge[0].length);if(me){var ye=Pe.parentNode;ye.insertBefore(Ue.createTextNode(me),Pe.nextSibling)}Qe(Pe),xe||Pe.parentNode.removeChild(Pe)}}}function Qe(Pe){for(;!Pe.nextSibling;)if(Pe=Pe.parentNode,!Pe)return;function dt(Ge,xe){var me=xe?Ge.cloneNode(!1):Ge,ye=Ge.parentNode;if(ye){var re=dt(ye,1),ie=Ge.nextSibling;re.appendChild(me);for(var se=ie;se;se=ie)ie=se.nextSibling,re.appendChild(se)}return me}for(var at=dt(Pe.nextSibling,0),Me;(Me=at.parentNode)&&Me.nodeType===1;)at=Me;it.push(at)}for(var qe=0;qe<it.length;++qe)Ye(it[qe]);Re===(Re|0)&&it[0].setAttribute("value",Re);var ct=Ue.createElement("ol");ct.className="linenums";for(var et=Math.max(0,Re-1|0)||0,qe=0,nt=it.length;qe<nt;++qe)Ie=it[qe],Ie.className="L"+(qe+et)%10,Ie.firstChild||Ie.appendChild(Ue.createTextNode("\xA0")),ct.appendChild(Ie);Ee.appendChild(ct)}function Ae(Ee){var Re=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Re=Re&&+Re[1]<=8;var Be=/\n/g,ze=Ee.sourceCode,Fe=ze.length,Ue=0,Ie=Ee.spans,it=Ie.length,Ye=0,Qe=Ee.decorations,qe=Qe.length,ct=0;Qe[qe]=Fe;var et,nt;for(nt=et=0;nt<qe;)Qe[nt]!==Qe[nt+2]?(Qe[et++]=Qe[nt++],Qe[et++]=Qe[nt++]):nt+=2;for(qe=et,nt=et=0;nt<qe;){for(var Pe=Qe[nt],dt=Qe[nt+1],at=nt+2;at+2<=qe&&Qe[at+1]===dt;)at+=2;Qe[et++]=Pe,Qe[et++]=dt,nt=at}qe=Qe.length=et;var Me=Ee.sourceNode,Ge="";Me&&(Ge=Me.style.display,Me.style.display="none");try{for(var xe=null;Ye<it;){var me=Ie[Ye],ye=Ie[Ye+2]||Fe,re=Qe[ct+2]||Fe,at=Math.min(ye,re),ie=Ie[Ye+1],se;if(ie.nodeType!==1&&(se=ze.substring(Ue,at))){Re&&(se=se.replace(Be,"\r")),ie.nodeValue=se;var pe=ie.ownerDocument,be=pe.createElement("span");be.className=Qe[ct+1];var _e=ie.parentNode;_e.replaceChild(be,ie),be.appendChild(ie),Ue<ye&&(Ie[Ye+1]=ie=pe.createTextNode(ze.substring(at,ye)),_e.insertBefore(ie,be.nextSibling))}Ue=at,Ue>=ye&&(Ye+=2),Ue>=re&&(ct+=2)}}finally{Me&&(Me.style.display=Ge)}}var Te={};function ve(Ee,Re){for(var Be=Re.length;--Be>=0;){var ze=Re[Be];Te.hasOwnProperty(ze)?H.console&&console.warn("cannot override language handler %s",ze):Te[ze]=Ee}}function le(Ee,Re){return Ee&&Te.hasOwnProperty(Ee)||(Ee=/^\s*</.test(Re)?"default-markup":"default-code"),Te[Ee]}ve(Se,["default-code"]),ve(ce([],[[a,/^[^<?]+/],[m,/^<!\w[^>]*(?:>|$)/],[x,/^<\!--[\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"]),ve(ce([[a,/^[\s]+/,null,` \r
`],[U,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[B,/^(?!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"]),ve(ce([],[[U,/^[\s\S]+/]]),["uq.val"]),ve(De({keywords:T,hashComments:!0,cStyleComments:!0,types:y}),["c","cc","cpp","cxx","cyc","m"]),ve(De({keywords:"null,true,false"}),["json"]),ve(De({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:y}),["cs"]),ve(De({keywords:O,cStyleComments:!0}),["java"]),ve(De({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(De({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(De({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(De({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(De({keywords:C,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(De({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(ce([],[[g,/^[\s\S]+/]]),["regex"]);function te(Ee){var Re=Ee.langExtension;try{var Be=_(Ee.sourceNode,Ee.pre),ze=Be.sourceCode;Ee.sourceCode=ze,Ee.spans=Be.spans,Ee.basePos=0,le(Re,ze)(Ee),Ae(Ee)}catch(Fe){H.console&&console.log(Fe&&Fe.stack||Fe)}}function de(Ee,Re,Be){var ze=Be||!1,Fe=Re||null,Ue=document.createElement("div");Ue.innerHTML="<pre>"+Ee+"</pre>",Ue=Ue.firstChild,ze&&Ce(Ue,ze,!0);var Ie={langExtension:Fe,numberLines:ze,sourceNode:Ue,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return te(Ie),Ue.innerHTML}function ne(Ee,Re){var Be=Re||document.body,ze=Be.ownerDocument||document;function Fe(me){return Be.getElementsByTagName(me)}for(var Ue=[Fe("pre"),Fe("code"),Fe("xmp")],Ie=[],it=0;it<Ue.length;++it)for(var Ye=0,Qe=Ue[it].length;Ye<Qe;++Ye)Ie.push(Ue[it][Ye]);Ue=null;var qe=Date;qe.now||(qe={now:function(){return+new Date}});var ct=0,et=/\blang(?:uage)?-([\w.]+)(?!\S)/,nt=/\bprettyprint\b/,Pe=/\bprettyprinted\b/,dt=/pre|xmp/i,at=/^code$/i,Me=/^(?:pre|code|xmp)$/i,Ge={};function xe(){for(var me=H.PR_SHOULD_USE_CONTINUATION?qe.now()+250:Infinity;ct<Ie.length&&qe.now()<me;ct++){for(var ye=Ie[ct],re=Ge,ie=ye;ie=ie.previousSibling;){var se=ie.nodeType,pe=(se===7||se===8)&&ie.nodeValue;if(pe?!/^\??prettify\b/.test(pe):se!==3||/\S/.test(ie.nodeValue))break;if(pe){re={},pe.replace(/\b(\w+)=([\w:.%+-]+)/g,function(jt,Lt,pr){re[Lt]=pr});break}}var be=ye.className;if((re!==Ge||nt.test(be))&&!Pe.test(be)){for(var _e=!1,We=ye.parentNode;We;We=We.parentNode){var $e=We.tagName;if(Me.test($e)&&We.className&&nt.test(We.className)){_e=!0;break}}if(!_e){ye.className+=" prettyprinted";var st=re.lang;if(!st){st=be.match(et);var Ze;!st&&(Ze=ae(ye))&&at.test(Ze.tagName)&&(st=Ze.className.match(et)),st&&(st=st[1])}var St;if(dt.test(ye.tagName))St=1;else{var Et=ye.currentStyle,lt=ze.defaultView,Pt=Et?Et.whiteSpace:lt&&lt.getComputedStyle?lt.getComputedStyle(ye,null).getPropertyValue("white-space"):0;St=Pt&&Pt.substring(0,3)==="pre"}var _t=re.linenums;(_t=_t==="true"||+_t)||(_t=be.match(/\blinenums\b(?::(\d+))?/),_t=_t?_t[1]&&_t[1].length?+_t[1]:!0:!1),_t&&Ce(ye,_t,St);var Mt={langExtension:st,sourceNode:ye,numberLines:_t,pre:St,sourceCode:null,basePos:null,spans:null,decorations:null};te(Mt)}}}ct<Ie.length?H.setTimeout(xe,250):typeof Ee=="function"&&Ee()}xe()}var ke=H.PR={createSimpleLexer:ce,registerLangHandler:ve,sourceDecorator:De,PR_ATTRIB_NAME:B,PR_ATTRIB_VALUE:U,PR_COMMENT:x,PR_DECLARATION:m,PR_KEYWORD:k,PR_LITERAL:p,PR_NOCODE:K,PR_PLAIN:a,PR_PUNCTUATION:d,PR_SOURCE:E,PR_STRING:g,PR_TAG:b,PR_TYPE:f,prettyPrintOne:D?H.prettyPrintOne=de:M=de,prettyPrint:z=D?H.prettyPrint=ne:z=ne},Oe=H.define;typeof Oe=="function"&&Oe.amd&&Oe("google-code-prettify",[],function(){return ke})})()},"VrN/":function(Tt,ut,he){(function(oe,$){Tt.exports=$()})(this,function(){"use strict";var oe=navigator.userAgent,$=navigator.platform,D=/gecko\/\d/i.test(oe),Z=/MSIE \d/.test(oe),F=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oe),M=/Edge\/(\d+)/.exec(oe),z=Z||F||M,H=z&&(Z?document.documentMode||6:+(M||F)[1]),N=!M&&/WebKit\//.test(oe),R=N&&/Qt\/\d+\.\d+/.test(oe),v=!M&&/Chrome\//.test(oe),T=/Opera\//.test(oe),O=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(oe),A=/PhantomJS/.test(oe),C=!M&&/AppleWebKit/.test(oe)&&/Mobile\/\w+/.test(oe),u=/Android/.test(oe),o=C||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(oe),l=C||/Mac/.test($),h=/\bCrOS\b/.test(oe),w=/win/i.test($),y=T&&oe.match(/Version\/(\d*\.\d*)/);y&&(y=Number(y[1])),y&&y>=15&&(T=!1,N=!0);var g=l&&(R||T&&(y==null||y<12.11)),k=D||z&&H>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var i=e.className,r=x(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return p(e).appendChild(t)}function 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 b(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var m;document.createRange?m=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:m=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 E(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 B(){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 U(e,t){var i=e.className;x(t).test(i)||(e.className+=(i?" ":"")+t)}function K(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!x(i[r]).test(t)&&(t+=" "+i[r]);return t}var V=function(e){e.select()};C?V=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:z&&(V=function(e){try{e.select()}catch(t){}});function P(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function _(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 Y(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var S=r||0,j=n||0;;){var X=e.indexOf(" ",S);if(X<0||X>=t)return j+(t-S);j+=X-S,j+=i-j%i,S=X+1}}var ee=function(){this.id=null,this.f=null,this.time=0,this.handler=P(this.onTimeout,this)};ee.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ee.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 ae(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ce=50,De={toString:function(){return"CodeMirror.Pass"}},Se={scroll:!1},Ce={origin:"*mouse"},Ae={origin:"+move"};function Te(e,t,i){for(var r=0,n=0;;){var S=e.indexOf(" ",r);S==-1&&(S=e.length);var j=S-r;if(S==e.length||n+j>=t)return r+Math.min(j,t-n);if(n+=S-r,n+=i-n%i,r=S+1,n>=t)return r}}var ve=[""];function le(e){for(;ve.length<=e;)ve.push(te(ve)+" ");return ve[e]}function te(e){return e[e.length-1]}function de(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function ne(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function ke(){}function Oe(e,t){var i;return Object.create?i=Object.create(e):(ke.prototype=e,i=new ke),t&&_(t,i),i}var Ee=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Re(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ee.test(e))}function Be(e,t){return t?t.source.indexOf("\\w")>-1&&Re(e)?!0:t.test(e):Re(e)}function ze(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Fe=/[\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 Ue(e){return e.charCodeAt(0)>=768&&Fe.test(e)}function Ie(e,t,i){for(;(i<0?t>0:t<e.length)&&Ue(e.charAt(t));)t+=i;return t}function it(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 Ye(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,S=0;S<e.length;++S){var j=e[S];(j.from<i&&j.to>t||t==i&&j.to==t)&&(r(Math.max(j.from,t),Math.min(j.to,i),j.level==1?"rtl":"ltr",S),n=!0)}n||r(t,i,"ltr")}var Qe=null;function qe(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(q){return q<=247?e.charAt(q):1424<=q&&q<=1524?"R":1536<=q&&q<=1785?t.charAt(q-1536):1774<=q&&q<=2220?"r":8192<=q&&q<=8203?"w":q==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,S=/[LRr]/,j=/[Lb1n]/,X=/[1n]/;function J(q,ue,fe){this.level=q,this.from=ue,this.to=fe}return function(q,ue){var fe=ue=="ltr"?"L":"R";if(q.length==0||ue=="ltr"&&!r.test(q))return!1;for(var Le=q.length,we=[],Ne=0;Ne<Le;++Ne)we.push(i(q.charCodeAt(Ne)));for(var Ke=0,Xe=fe;Ke<Le;++Ke){var tt=we[Ke];tt=="m"?we[Ke]=Xe:Xe=tt}for(var ot=0,rt=fe;ot<Le;++ot){var ht=we[ot];ht=="1"&&rt=="r"?we[ot]="n":S.test(ht)&&(rt=ht,ht=="r"&&(we[ot]="R"))}for(var xt=1,gt=we[0];xt<Le-1;++xt){var At=we[xt];At=="+"&&gt=="1"&&we[xt+1]=="1"?we[xt]="1":At==","&&gt==we[xt+1]&&(gt=="1"||gt=="n")&&(we[xt]=gt),gt=At}for(var Vt=0;Vt<Le;++Vt){var lr=we[Vt];if(lr==",")we[Vt]="N";else if(lr=="%"){var $t=void 0;for($t=Vt+1;$t<Le&&we[$t]=="%";++$t);for(var Ir=Vt&&we[Vt-1]=="!"||$t<Le&&we[$t]=="1"?"1":"N",Dr=Vt;Dr<$t;++Dr)we[Dr]=Ir;Vt=$t-1}}for(var er=0,Rr=fe;er<Le;++er){var fr=we[er];Rr=="L"&&fr=="1"?we[er]="L":S.test(fr)&&(Rr=fr)}for(var ir=0;ir<Le;++ir)if(n.test(we[ir])){var tr=void 0;for(tr=ir+1;tr<Le&&n.test(we[tr]);++tr);for(var Zt=(ir?we[ir-1]:fe)=="L",Or=(tr<Le?we[tr]:fe)=="L",un=Zt==Or?Zt?"L":"R":fe,Ri=ir;Ri<tr;++Ri)we[Ri]=un;ir=tr-1}for(var Er=[],ai,ur=0;ur<Le;)if(j.test(we[ur])){var Va=ur;for(++ur;ur<Le&&j.test(we[ur]);++ur);Er.push(new J(0,Va,ur))}else{var di=ur,Hi=Er.length,Gi=ue=="rtl"?1:0;for(++ur;ur<Le&&we[ur]!="L";++ur);for(var Cr=di;Cr<ur;)if(X.test(we[Cr])){di<Cr&&(Er.splice(Hi,0,new J(1,di,Cr)),Hi+=Gi);var hn=Cr;for(++Cr;Cr<ur&&X.test(we[Cr]);++Cr);Er.splice(Hi,0,new J(2,hn,Cr)),Hi+=Gi,di=Cr}else++Cr;di<ur&&Er.splice(Hi,0,new J(1,di,ur))}return ue=="ltr"&&(Er[0].level==1&&(ai=q.match(/^\s+/))&&(Er[0].from=ai[0].length,Er.unshift(new J(0,0,ai[0].length))),te(Er).level==1&&(ai=q.match(/\s+$/))&&(te(Er).to-=ai[0].length,Er.push(new J(0,Le-ai[0].length,Le)))),ue=="rtl"?Er.reverse():Er}}();function et(e,t){var i=e.order;return i==null&&(i=e.order=ct(e.text,t)),i}var nt=[],Pe=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]||nt).concat(i)}};function dt(e,t){return e._handlers&&e._handlers[t]||nt}function at(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var S=ae(n,i);S>-1&&(r[t]=n.slice(0,S).concat(n.slice(S+1)))}}}function Me(e,t){var i=dt(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 Ge(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Me(e,i||t.type,e,t),se(t)||t.codemirrorIgnore}function xe(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)ae(i,t[r])==-1&&i.push(t[r])}function me(e,t){return dt(e,t).length>0}function ye(e){e.prototype.on=function(t,i){Pe(this,t,i)},e.prototype.off=function(t,i){at(this,t,i)}}function re(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function ie(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function pe(e){re(e),ie(e)}function be(e){return e.target||e.srcElement}function _e(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 We=function(){if(z&&H<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),$e;function st(e){if($e==null){var t=a("span","\u200B");d(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&($e=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&H<8))}var i=$e?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Ze;function St(e){if(Ze!=null)return Ze;var t=d(e,document.createTextNode("A\u062EA")),i=m(t,0,1).getBoundingClientRect(),r=m(t,1,2).getBoundingClientRect();return p(e),!i||i.left==i.right?!1:Ze=r.right-i.right<3}var Et=`
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),j=S.indexOf("\r");j!=-1?(i.push(S.slice(0,j)),t+=j+1):(i.push(S),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},lt=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},Pt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),_t=null;function Mt(e){if(_t!=null)return _t;var t=d(e,a("span","x")),i=t.getBoundingClientRect(),r=m(t,0,1).getBoundingClientRect();return _t=Math.abs(i.left-r.left)>1}var jt={},Lt={};function pr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),jt[e]=t}function Kr(e,t){Lt[e]=t}function bt(e){if(typeof e=="string"&&Lt.hasOwnProperty(e))e=Lt[e];else if(e&&typeof e.name=="string"&&Lt.hasOwnProperty(e.name)){var t=Lt[e.name];typeof t=="string"&&(t={name:t}),e=Oe(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=jt[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 j in t.modeProps)r[j]=t.modeProps[j];return r}var hr={};function mr(e,t){var i=hr.hasOwnProperty(e)?hr[e]:hr[e]={};_(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 Bt=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};Bt.prototype.eol=function(){return this.pos>=this.string.length},Bt.prototype.sol=function(){return this.pos==this.lineStart},Bt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Bt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Bt.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},Bt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Bt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Bt.prototype.skipToEnd=function(){this.pos=this.string.length},Bt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Bt.prototype.backUp=function(e){this.pos-=e},Bt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Y(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},Bt.prototype.indentation=function(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},Bt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(j){return i?j.toLowerCase():j},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)}},Bt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Bt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Bt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Bt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ft(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 j=S.text;n==i.line&&(j=j.slice(0,i.ch)),n==t.line&&(j=j.slice(t.ch)),r.push(j),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function gr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Dt(e){if(e.parent==null)return null;for(var t=e.parent,i=ae(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 j=0;j<e.lines.length;++j){var X=e.lines[j],J=X.height;if(t<J)break;t-=J}return i+j}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 Ve(e,t,i){if(i===void 0&&(i=null),!(this instanceof Ve))return new Ve(e,t,i);this.line=e,this.ch=t,this.sticky=i}function Ct(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&Ct(e,t)==0}function mi(e){return Ve(e.line,e.ch)}function gi(e,t){return Ct(e,t)<0?t:e}function vi(e,t){return Ct(e,t)<0?e:t}function G(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 Ve(e.first,0);var i=e.first+e.size-1;return t.line>i?Ve(i,ft(e,i).text.length):c(t,ft(e,t.line).text.length)}function c(e,t){var i=e.ch;return i==null||i>t?Ve(e.line,t):i<0?Ve(e.line,0):e}function I(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Q=function(e,t){this.state=e,this.lookAhead=t},W=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};W.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},W.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}},W.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},W.fromSaved=function(e,t,i){return t instanceof Q?new W(e,Br(e.mode,t.state),i,t.lookAhead):new W(e,Br(e.mode,t),i)},W.prototype.save=function(e){var t=e!==!1?Br(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Q(t,this.maxLookAhead):t};function ge(e,t,i,r){var n=[e.state.modeGen],S={};vr(e,t.text,e.doc.mode,i,function(q,ue){return n.push(q,ue)},S,r);for(var j=i.state,X=function(q){i.baseTokens=n;var ue=e.state.overlays[q],fe=1,Le=0;i.state=!0,vr(e,t.text,ue.mode,i,function(we,Ne){for(var Ke=fe;Le<we;){var Xe=n[fe];Xe>we&&n.splice(fe,1,we,n[fe+1],Xe),fe+=2,Le=Math.min(we,Xe)}if(!Ne)return;if(ue.opaque)n.splice(Ke,fe-Ke,we,"overlay "+Ne),fe=Ke+2;else for(;Ke<fe;Ke+=2){var tt=n[Ke+1];n[Ke+1]=(tt?tt+" ":"")+"overlay "+Ne}},S),i.state=j,i.baseTokens=null,i.baseTokenPos=1},J=0;J<e.state.overlays.length;++J)X(J);return{styles:n,classes:S.bgClass||S.textClass?S:null}}function je(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Je(e,Dt(t)),n=t.text.length>e.options.maxHighlightLength&&Br(e.doc.mode,r.state),S=ge(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 Je(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new W(r,!0,t);var S=yr(e,t,i),j=S>r.first&&ft(r,S-1).stateAfter,X=j?W.fromSaved(r,j,S):new W(r,qr(r.mode),S);return r.iter(S,t,function(J){pt(e,J.text,X);var q=X.line;J.stateAfter=q==t-1||q%5==0||q>=n.viewFrom&&q<n.viewTo?X.save():null,X.nextLine()}),i&&(r.modeFrontier=X.line),X}function pt(e,t,i,r){var n=e.doc.mode,S=new Bt(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&He(n,i.state);!S.eol();)vt(n,S,i.state),S.start=S.pos}function He(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 Ft=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Xt(e,t,i,r){var n=e.doc,S=n.mode,j;t=s(n,t);var X=ft(n,t.line),J=Je(e,t.line,i),q=new Bt(X.text,e.options.tabSize,J),ue;for(r&&(ue=[]);(r||q.pos<t.ch)&&!q.eol();)q.start=q.pos,j=vt(S,q,J.state),r&&ue.push(new Ft(q,j,Br(n.mode,J.state)));return r?ue:new Ft(q,j,J.state)}function _r(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 vr(e,t,i,r,n,S,j){var X=i.flattenSpans;X==null&&(X=e.options.flattenSpans);var J=0,q=null,ue=new Bt(t,e.options.tabSize,r),fe,Le=e.options.addModeClass&&[null];for(t==""&&_r(He(i,r.state),S);!ue.eol();){if(ue.pos>e.options.maxHighlightLength?(X=!1,j&&pt(e,t,r,ue.pos),ue.pos=t.length,fe=null):fe=_r(vt(i,ue,r.state,Le),S),Le){var we=Le[0].name;we&&(fe="m-"+(fe?we+" "+fe:we))}if(!X||q!=fe){for(;J<ue.start;)J=Math.min(ue.start,J+5e3),n(J,q);q=fe}ue.start=ue.pos}for(;J<ue.pos;){var Ne=Math.min(ue.pos,J+5e3);n(Ne,q),J=Ne}}function yr(e,t,i){for(var r,n,S=e.doc,j=i?-1:t-(e.doc.mode.innerMode?1e3:100),X=t;X>j;--X){if(X<=S.first)return S.first;var J=ft(S,X-1),q=J.stateAfter;if(q&&(!i||X+(q instanceof Q?q.lookAhead:0)<=S.modeFrontier))return X;var ue=Y(J.text,null,e.options.tabSize);(n==null||r>ue)&&(n=X-1,r=ue)}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=ft(e,r).stateAfter;if(n&&(!(n instanceof Q)||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 Pr(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],j=S.marker,X=S.from==null||(j.inclusiveLeft?S.from<=t:S.from<t);if(X||S.from==t&&j.type=="bookmark"&&(!i||!S.marker.insertLeft)){var J=S.to==null||(j.inclusiveRight?S.to>=t:S.to>t);(r||(r=[])).push(new si(j,S.from,J?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],j=S.marker,X=S.to==null||(j.inclusiveRight?S.to>=t:S.to>t);if(X||S.from==t&&j.type=="bookmark"&&(!i||S.marker.insertLeft)){var J=S.from==null||(j.inclusiveLeft?S.from<=t:S.from<t);(r||(r=[])).push(new si(j,J?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)&&ft(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&ft(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,S=t.to.ch,j=Ct(t.from,t.to)==0,X=zi(i,n,j),J=Ki(r,S,j),q=t.text.length==1,ue=te(t.text).length+(q?n:0);if(X)for(var fe=0;fe<X.length;++fe){var Le=X[fe];if(Le.to==null){var we=Pr(J,Le.marker);we?q&&(Le.to=we.to==null?null:we.to+ue):Le.to=n}}if(J)for(var Ne=0;Ne<J.length;++Ne){var Ke=J[Ne];if(Ke.to!=null&&(Ke.to+=ue),Ke.from==null){var Xe=Pr(X,Ke.marker);Xe||(Ke.from=ue,q&&(X||(X=[])).push(Ke))}else Ke.from+=ue,q&&(X||(X=[])).push(Ke)}X&&(X=Gr(X)),J&&J!=X&&(J=Gr(J));var tt=[X];if(!q){var ot=t.text.length-2,rt;if(ot>0&&X)for(var ht=0;ht<X.length;++ht)X[ht].to==null&&(rt||(rt=[])).push(new si(X[ht].marker,null,null));for(var xt=0;xt<ot;++xt)tt.push(rt);tt.push(J)}return tt}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(we){if(we.markedSpans)for(var Ne=0;Ne<we.markedSpans.length;++Ne){var Ke=we.markedSpans[Ne].marker;Ke.readOnly&&(!r||ae(r,Ke)==-1)&&(r||(r=[])).push(Ke)}}),!r)return null;for(var n=[{from:t,to:i}],S=0;S<r.length;++S)for(var j=r[S],X=j.find(0),J=0;J<n.length;++J){var q=n[J];if(Ct(q.to,X.from)<0||Ct(q.from,X.to)>0)continue;var ue=[J,1],fe=Ct(q.from,X.from),Le=Ct(q.to,X.to);(fe<0||!j.inclusiveLeft&&!fe)&&ue.push({from:q.from,to:X.from}),(Le>0||!j.inclusiveRight&&!Le)&&ue.push({from:X.to,to:q.to}),n.splice.apply(n,ue),J+=ue.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 Ut(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=Ct(r.from,n.from)||Jt(e)-Jt(t);if(S)return-S;var j=Ct(r.to,n.to)||Ut(e)-Ut(t);return j||t.id-e.id}function Rt(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 Rt(e,!0)}function Gt(e){return Rt(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=ft(e,t),j=nr&&S.markedSpans;if(j)for(var X=0;X<j.length;++X){var J=j[X];if(!J.marker.collapsed)continue;var q=J.marker.find(0),ue=Ct(q.from,i)||Jt(J.marker)-Jt(n),fe=Ct(q.to,r)||Ut(J.marker)-Ut(n);if(ue>=0&&fe<=0||ue<=0&&fe>=0)continue;if(ue<=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?Ct(q.to,i)>=0:Ct(q.to,i)>0)||ue>=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?Ct(q.from,r)<=0:Ct(q.from,r)<0))return!0}}function Sr(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Gt(e);)e=t.find(1,!0).line;return e}function Ei(e){for(var t,i;t=Gt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=ft(e,t),r=Sr(i);return i==r?t:Dt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=ft(e,t),r;if(!ri(e,i))return t;for(;r=Gt(i);)i=r.find(1,!0).line;return Dt(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,Pr(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=Sr(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 j=0;j<S.children.length;++j){var X=S.children[j];if(X==i)break;t+=X.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=Gt(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=ft(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 Pi=function(e,t,i){this.text=e,xi(this,t),this.height=i?i(this):1};Pi.prototype.lineNo=function(){return Dt(this)},ye(Pi);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&&gr(e,n)}function mt(e){e.parent=null,dn(e)}var wt={},yt={};function kt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?yt:wt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Nt(e,t){var i=b("span",null,null,N?"padding-right: .1px":null),r={pre:b("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,j=void 0;r.pos=0,r.addToken=It,St(e.display.measure)&&(j=et(S,e.doc.direction))&&(r.addToken=wr(r.addToken,j)),r.map=[];var X=t!=e.display.externalMeasured&&Dt(S);li(S,r,je(e,S,X)),S.styleClasses&&(S.styleClasses.bgClass&&(r.bgClass=K(S.styleClasses.bgClass,r.bgClass||"")),S.styleClasses.textClass&&(r.textClass=K(S.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(st(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(N){var J=r.content.lastChild;(/\bcm-tab\b/.test(J.className)||J.querySelector&&J.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Me(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=K(r.pre.className,r.textClass||"")),r}function Kt(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 It(e,t,i,r,n,S,j){if(!t)return;var X=e.splitSpaces?rr(t,e.trailingSpace):t,J=e.cm.state.specialChars,q=!1,ue;if(!J.test(t))e.col+=t.length,ue=document.createTextNode(X),e.map.push(e.pos,e.pos+t.length,ue),z&&H<9&&(q=!0),e.pos+=t.length;else{ue=document.createDocumentFragment();for(var fe=0;;){J.lastIndex=fe;var Le=J.exec(t),we=Le?Le.index-fe:t.length-fe;if(we){var Ne=document.createTextNode(X.slice(fe,fe+we));z&&H<9?ue.appendChild(a("span",[Ne])):ue.appendChild(Ne),e.map.push(e.pos,e.pos+we,Ne),e.col+=we,e.pos+=we}if(!Le)break;fe+=we+1;var Ke=void 0;if(Le[0]==" "){var Xe=e.cm.options.tabSize,tt=Xe-e.col%Xe;Ke=ue.appendChild(a("span",le(tt),"cm-tab")),Ke.setAttribute("role","presentation"),Ke.setAttribute("cm-text"," "),e.col+=tt}else Le[0]=="\r"||Le[0]==`
`?(Ke=ue.appendChild(a("span",Le[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ke.setAttribute("cm-text",Le[0]),e.col+=1):(Ke=e.cm.options.specialCharPlaceholder(Le[0]),Ke.setAttribute("cm-text",Le[0]),z&&H<9?ue.appendChild(a("span",[Ke])):ue.appendChild(Ke),e.col+=1);e.map.push(e.pos,e.pos+1,Ke),e.pos++}}if(e.trailingSpace=X.charCodeAt(t.length-1)==32,i||r||n||q||S||j){var ot=i||"";r&&(ot+=r),n&&(ot+=n);var rt=a("span",[ue],ot,S);if(j)for(var ht in j)j.hasOwnProperty(ht)&&ht!="style"&&ht!="class"&&rt.setAttribute(ht,j[ht]);return e.content.appendChild(rt)}e.content.appendChild(ue)}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 wr(e,t){return function(i,r,n,S,j,X,J){n=n?n+" cm-force-border":"cm-force-border";for(var q=i.pos,ue=q+r.length;;){for(var fe=void 0,Le=0;Le<t.length&&!(fe=t[Le],fe.to>q&&fe.from<=q);Le++);if(fe.to>=ue)return e(i,r,n,S,j,X,J);e(i,r.slice(0,fe.to-q),n,S,null,X,J),S=null,r=r.slice(fe.to-q),q=fe.to}}}function Ot(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 j=1;j<i.length;j+=2)t.addToken(t,n.slice(S,S=i[j]),kt(i[j+1],t.cm.options));return}for(var X=n.length,J=0,q=1,ue="",fe,Le,we=0,Ne,Ke,Xe,tt,ot;;){if(we==J){Ne=Ke=Xe=Le="",ot=null,tt=null,we=Infinity;for(var rt=[],ht=void 0,xt=0;xt<r.length;++xt){var gt=r[xt],At=gt.marker;if(At.type=="bookmark"&&gt.from==J&&At.widgetNode)rt.push(At);else if(gt.from<=J&&(gt.to==null||gt.to>J||At.collapsed&&gt.to==J&&gt.from==J)){if(gt.to!=null&&gt.to!=J&&we>gt.to&&(we=gt.to,Ke=""),At.className&&(Ne+=" "+At.className),At.css&&(Le=(Le?Le+";":"")+At.css),At.startStyle&&gt.from==J&&(Xe+=" "+At.startStyle),At.endStyle&&gt.to==we&&(ht||(ht=[])).push(At.endStyle,gt.to),At.title&&((ot||(ot={})).title=At.title),At.attributes)for(var Vt in At.attributes)(ot||(ot={}))[Vt]=At.attributes[Vt];At.collapsed&&(!tt||dr(tt.marker,At)<0)&&(tt=gt)}else gt.from>J&&we>gt.from&&(we=gt.from)}if(ht)for(var lr=0;lr<ht.length;lr+=2)ht[lr+1]==we&&(Ke+=" "+ht[lr]);if(!tt||tt.from==J)for(var $t=0;$t<rt.length;++$t)Ot(t,0,rt[$t]);if(tt&&(tt.from||0)==J){if(Ot(t,(tt.to==null?X+1:tt.to)-J,tt.marker,tt.from==null),tt.to==null)return;tt.to==J&&(tt=!1)}}if(J>=X)break;for(var Ir=Math.min(X,we);;){if(ue){var Dr=J+ue.length;if(!tt){var er=Dr>Ir?ue.slice(0,Ir-J):ue;t.addToken(t,er,fe?fe+Ne:Ne,Xe,J+er.length==we?Ke:"",Le,ot)}if(Dr>=Ir){ue=ue.slice(Ir-J),J=Ir;break}J=Dr,Xe=""}ue=n.slice(S,S=i[q++]),fe=kt(i[q++],t.cm.options)}}}function Wt(e,t,i){this.line=t,this.rest=Ei(t),this.size=this.rest?Dt(te(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function Ar(e,t,i){for(var r=[],n,S=t;S<i;S=n){var j=new Wt(e.doc,ft(e.doc,S),S);n=S+j.size,r.push(j)}return r}var br=null;function zr(e){br?br.ops.push(e):e.ownsGroup=br={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{br=null,t(i)}}var mn=null;function cr(e,t){var i=dt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;br?n=br.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(_s,0));for(var S=function(X){n.push(function(){return i[X].apply(null,r)})},j=0;j<i.length;++j)S(j)}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"?Ms(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),z&&H<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=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):Nt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(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 j=gn(t),X=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(X),j.insertBefore(X,t.text),t.line.gutterClass&&(X.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=X.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 J=0;J<e.display.gutterSpecs.length;++J){var q=e.display.gutterSpecs[J].className,ue=S.hasOwnProperty(q)&&S[q];ue&&X.appendChild(a("div",[ue],"CodeMirror-gutter-elt","left: "+r.gutterLeft[q]+"px; width: "+r.gutterWidth[q]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=x("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),j=0,X=t.widgets;j<X.length;++j){var J=X[j],q=a("div",[J.node],"CodeMirror-linewidget"+(J.className?" "+J.className:""));J.handleMouseEvents||q.setAttribute("cm-ignore-events","true"),Bs(J,q,i,r),e.display.input.setUneditable(q),n&&J.above?S.insertBefore(q,i.gutter||i.text):S.appendChild(q),cr(J,"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(!E(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=be(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function 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 ce-e.display.nativeBarWidth}function Mi(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&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var S=t.measure.heights=[];if(r){t.measure.width=n;for(var j=t.text.firstChild.getClientRects(),X=0;X<j.length-1;X++){var J=j[X],q=j[X+1];Math.abs(J.bottom-q.bottom)>2&&S.push((J.bottom+q.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(Dt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=Sr(t);var i=Dt(t),r=e.display.externalMeasured=new Wt(e.doc,t,i);r.lineN=i;var n=r.built=Nt(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=Dt(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||""),j;return t.cache.hasOwnProperty(S)?j=t.cache[S]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),j=Ws(e,t,i,r),j.bogus||(t.cache[S]=j)),{left:j.left,right:j.right,top:n?j.rtop:j.top,bottom:n?j.rbottom:j.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,S,j,X,J,q=0;q<e.length;q+=3)if(X=e[q],J=e[q+1],t<X?(n=0,S=1,j="left"):t<J?(n=t-X,S=n+1):(q==e.length-3||t==J&&e[q+3]>t)&&(S=J-X,n=S-1,t>=J&&(j="right")),n!=null){if(r=e[q+2],X==J&&i==(r.insertLeft?"left":"right")&&(j=i),i=="left"&&n==0)for(;q&&e[q-2]==e[q-3]&&e[q-1].insertLeft;)r=e[(q-=3)+2],j="left";if(i=="right"&&n==J-X)for(;q<e.length-3&&e[q+3]==e[q+4]&&!e[q+5].insertLeft;)r=e[(q+=3)+2],j="right";break}return{node:r,start:n,end:S,collapse:j,coverStart:X,coverEnd:J}}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,j=n.start,X=n.end,J=n.collapse,q;if(S.nodeType==3){for(var ue=0;ue<4;ue++){for(;j&&Ue(t.line.text.charAt(n.coverStart+j));)--j;for(;n.coverStart+X<n.coverEnd&&Ue(t.line.text.charAt(n.coverStart+X));)++X;if(z&&H<9&&j==0&&X==n.coverEnd-n.coverStart?q=S.parentNode.getBoundingClientRect():q=js(m(S,j,X).getClientRects(),r),q.left||q.right||j==0)break;X=j,j=j-1,J="right"}z&&H<11&&(q=Hs(e.display.measure,q))}else{j>0&&(J=r="right");var fe;e.options.lineWrapping&&(fe=S.getClientRects()).length>1?q=fe[r=="right"?fe.length-1:0]:q=S.getBoundingClientRect()}if(z&&H<9&&!j&&(!q||!q.left&&!q.right)){var Le=S.parentNode.getClientRects()[0];Le?q={left:Le.left,right:Le.left+$i(e.display),top:Le.top,bottom:Le.bottom}:q=ro}for(var we=q.top-t.rect.top,Ne=q.bottom-t.rect.top,Ke=(we+Ne)/2,Xe=t.view.measure.heights,tt=0;tt<Xe.length-1&&!(Ke<Xe[tt]);tt++);var ot=tt?Xe[tt-1]:0,rt=Xe[tt],ht={left:(J=="right"?q.right:q.left)-t.rect.left,right:(J=="left"?q.left:q.right)-t.rect.left,top:ot,bottom:rt};return!q.left&&!q.right&&(ht.bogus=!0),e.options.singleCursorHeightPerLine||(ht.rtop=we,ht.rbottom=Ne),ht}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Mt(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,p(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 v&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return v&&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 j=$r(t);if(r=="local"?j+=Wn(e.display):j-=e.display.viewOffset,r=="page"||r=="window"){var X=e.display.lineSpace.getBoundingClientRect();j+=X.top+(r=="window"?0:so());var J=X.left+(r=="window"?0:oo());i.left+=J,i.right+=J}return i.top+=j,i.bottom+=j,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 j=e.display.lineSpace.getBoundingClientRect();return{left:r-j.left,top:n-j.top}}function ma(e,t,i,r,n){return r||(r=ft(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,S){r=r||ft(e.doc,t.line),n||(n=Xi(e,r));function j(Ne,Ke){var Xe=ni(e,n,Ne,Ke?"right":"left",S);return Ke?Xe.left=Xe.right:Xe.right=Xe.left,Hn(e,r,Xe,i)}var X=et(r,e.doc.direction),J=t.ch,q=t.sticky;if(J>=r.text.length?(J=r.text.length,q="before"):J<=0&&(J=0,q="after"),!X)return j(q=="before"?J-1:J,q=="before");function ue(Ne,Ke,Xe){var tt=X[Ke],ot=tt.level==1;return j(Xe?Ne-1:Ne,ot!=Xe)}var fe=qe(X,J,q),Le=Qe,we=ue(J,fe,q=="before");return Le!=null&&(we.other=ue(J,Le,q!="before")),we}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=ft(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=Ve(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,ft(r,S).text.length,null,1,1);t<0&&(t=0);for(var j=ft(r,n);;){var X=Gs(e,j,n,t,i),J=ti(j,X.ch+(X.xRel>0||X.outside>0?1:0));if(!J)return X;var q=J.find(1);if(q.line==n)return q;j=ft(r,n=q.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,S=it(function(j){return ni(e,i,j-1).bottom<=r},n,0);return n=it(function(j){return ni(e,i,j).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),j=pa(t),X=0,J=t.text.length,q=!0,ue=et(t,e.doc.direction);if(ue){var fe=(e.options.lineWrapping?Ks:zs)(e,t,i,S,ue,r,n);q=fe.level!=1,X=q?fe.from:fe.to-1,J=q?fe.to:fe.from-1}var Le=null,we=null,Ne=it(function(xt){var gt=ni(e,S,xt);return gt.top+=j,gt.bottom+=j,ya(gt,r,n,!1)?(gt.top<=n&&gt.left<=r&&(Le=xt,we=gt),!0):!1},X,J),Ke,Xe,tt=!1;if(we){var ot=r-we.left<we.right-r,rt=ot==q;Ne=Le+(rt?0:1),Xe=rt?"after":"before",Ke=ot?we.left:we.right}else{!q&&(Ne==J||Ne==X)&&Ne++,Xe=Ne==0?"after":Ne==t.text.length?"before":ni(e,S,Ne-(q?1:0)).bottom+j<=n==q?"after":"before";var ht=Zr(e,Ve(i,Ne,Xe),"line",t,S);Ke=ht.left,tt=n<ht.top?-1:n>=ht.bottom?1:0}return Ne=Ie(t.text,Ne,1),ga(i,Ne,Xe,tt,r-Ke)}function zs(e,t,i,r,n,S,j){var X=it(function(fe){var Le=n[fe],we=Le.level!=1;return ya(Zr(e,Ve(i,we?Le.to:Le.from,we?"before":"after"),"line",t,r),S,j,!0)},0,n.length-1),J=n[X];if(X>0){var q=J.level!=1,ue=Zr(e,Ve(i,q?J.from:J.to,q?"after":"before"),"line",t,r);ya(ue,S,j,!0)&&ue.top>j&&(J=n[X-1])}return J}function Ks(e,t,i,r,n,S,j){var X=ho(e,t,r,j),J=X.begin,q=X.end;/\s/.test(t.text.charAt(q-1))&&q--;for(var ue=null,fe=null,Le=0;Le<n.length;Le++){var we=n[Le];if(we.from>=q||we.to<=J)continue;var Ne=we.level!=1,Ke=ni(e,r,Ne?Math.min(q,we.to)-1:Math.max(J,we.from)).right,Xe=Ke<S?S-Ke+1e9:Ke-S;(!ue||fe>Xe)&&(ue=we,fe=Xe)}return ue||(ue=n[n.length-1]),ue.from<J&&(ue={from:J,to:ue.to,level:ue.level}),ue.to>q&&(ue={from:ue.from,to:q,level:ue.level}),ue}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),p(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,j=0;S;S=S.nextSibling,++j){var X=e.display.gutterSpecs[j].className;i[X]=S.offsetLeft+S.clientLeft+n,r[X]=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 j=0;j<n.widgets.length;j++)n.widgets[j].height&&(S+=n.widgets[j].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&&gr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&be(t).getAttribute("cm-not-content")=="true")return null;var S,j,X=n.lineSpace.getBoundingClientRect();try{S=t.clientX-X.left,j=t.clientY-X.top}catch(fe){return null}var J=va(e,S,j),q;if(r&&J.xRel>0&&(q=ft(e.doc,J.line).text).length==J.ch){var ue=Y(q,q.length,e.options.tabSize)-q.length;J=Ve(J.line,Math.max(0,Math.round((S-qa(e.display).left)/$i(e.display))-ue))}return J}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 Lr(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 j=Gn(e,t,t,-1);j?(n.view=n.view.slice(0,j.index),n.viewTo=j.lineN):Ci(e)}else{var X=Gn(e,t,t,-1),J=Gn(e,i,i+r,1);X&&J?(n.view=n.view.slice(0,X.index).concat(Ar(e,X.lineN,J.lineN)).concat(n.view.slice(J.index)),n.viewTo+=r):Ci(e)}var q=n.externalMeasured;q&&(i<q.lineN?q.lineN+=r:t<q.lineN+q.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 j=S.changes||(S.changes=[]);ae(j,i)==-1&&j.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,j=e.display.view;if(!nr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var X=e.display.viewFrom,J=0;J<n;J++)X+=j[J].size;if(X!=t){if(r>0){if(n==j.length-1)return null;S=X+j[n].size-t,n++}else S=X-t;t+=S,i+=S}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:j.length-1))return null;i+=r*j[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=Ar(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Ar(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(Ar(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(),j=0;j<i.sel.ranges.length;j++){if(!t&&j==i.sel.primIndex)continue;var X=i.sel.ranges[j];if(X.from().line>=e.display.viewTo||X.to().line<e.display.viewFrom)continue;var J=X.empty();(J||e.options.showCursorWhenSelecting)&&go(e,X.head,n),J||Xs(e,X,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(),j=qa(e.display),X=j.left,J=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-j.right,q=n.direction=="ltr";function ue(rt,ht,xt,gt){ht<0&&(ht=0),ht=Math.round(ht),gt=Math.round(gt),S.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+rt+`px;
top: `+ht+"px; width: "+(xt==null?J-rt:xt)+`px;
height: `+(gt-ht)+"px"))}function fe(rt,ht,xt){var gt=ft(n,rt),At=gt.text.length,Vt,lr;function $t(er,Rr){return ma(e,Ve(rt,er),"div",gt,Rr)}function Ir(er,Rr,fr){var ir=co(e,gt,null,er),tr=Rr=="ltr"==(fr=="after")?"left":"right",Zt=fr=="after"?ir.begin:ir.end-(/\s/.test(gt.text.charAt(ir.end-1))?2:1);return $t(Zt,tr)[tr]}var Dr=et(gt,n.direction);return Ye(Dr,ht||0,xt==null?At:xt,function(er,Rr,fr,ir){var tr=fr=="ltr",Zt=$t(er,tr?"left":"right"),Or=$t(Rr-1,tr?"right":"left"),un=ht==null&&er==0,Ri=xt==null&&Rr==At,Er=ir==0,ai=!Dr||ir==Dr.length-1;if(Or.top-Zt.top<=3){var ur=(q?un:Ri)&&Er,Va=(q?Ri:un)&&ai,di=ur?X:(tr?Zt:Or).left,Hi=Va?J:(tr?Or:Zt).right;ue(di,Zt.top,Hi-di,Zt.bottom)}else{var Gi,Cr,hn,Xa;tr?(Gi=q&&un&&Er?X:Zt.left,Cr=q?J:Ir(er,fr,"before"),hn=q?X:Ir(Rr,fr,"after"),Xa=q&&Ri&&ai?J:Or.right):(Gi=q?Ir(er,fr,"before"):X,Cr=!q&&un&&Er?J:Zt.right,hn=!q&&Ri&&ai?X:Or.left,Xa=q?Ir(Rr,fr,"after"):J),ue(Gi,Zt.top,Cr-Gi,Zt.bottom),Zt.bottom<Or.top&&ue(X,Zt.bottom,null,Or.top),ue(hn,Or.top,Xa-hn,Or.bottom)}(!Vt||zn(Zt,Vt)<0)&&(Vt=Zt),zn(Or,Vt)<0&&(Vt=Or),(!lr||zn(Zt,lr)<0)&&(lr=Zt),zn(Or,lr)<0&&(lr=Or)}),{start:Vt,end:lr}}var Le=t.from(),we=t.to();if(Le.line==we.line)fe(Le.line,Le.ch,we.ch);else{var Ne=ft(n,Le.line),Ke=ft(n,we.line),Xe=Sr(Ne)==Sr(Ke),tt=fe(Le.line,Le.ch,Xe?Ne.text.length+1:null).end,ot=fe(we.line,Xe?0:null,we.ch).start;Xe&&(tt.top<ot.top-2?(ue(tt.right,tt.top,null,tt.bottom),ue(X,ot.top,ot.left,ot.bottom)):ue(tt.right,tt.top,ot.left-tt.right,tt.bottom)),tt.bottom<ot.top&&ue(X,tt.bottom,null,ot.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||(Me(e,"focus",e,t),e.state.focused=!0,U(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),N&&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&&(Me(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,j=void 0,X=0;if(n.hidden)continue;if(z&&H<8){var J=n.node.offsetTop+n.node.offsetHeight;j=J-i,i=J}else{var q=n.node.getBoundingClientRect();j=q.bottom-q.top,!S&&n.text.firstChild&&(X=n.text.firstChild.getBoundingClientRect().right-q.left-1)}var ue=n.line.height-j;if((ue>.005||ue<-.005)&&(gr(n.line,j),bo(n.line),n.rest))for(var fe=0;fe<n.rest.length;fe++)bo(n.rest[fe]);if(X>e.display.sizerWidth){var Le=Math.ceil(X/$i(e.display));Le>e.display.maxLineLength&&(e.display.maxLineLength=Le,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),j=Fr(t,n);if(i&&i.ensure){var X=i.ensure.from.line,J=i.ensure.to.line;X<S?(S=X,j=Fr(t,$r(ft(t,X))+e.wrapper.clientHeight)):Math.min(J,t.lastLine())>=j&&(S=Fr(t,$r(ft(t,J))-e.wrapper.clientHeight),j=J)}return{from:S,to:Math.max(j,S+1)}}function Ys(e,t){if(Ge(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&&!A){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?Ve(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Ve(t.line,t.ch+1,"before"):t);for(var S=0;S<5;S++){var j=!1,X=Zr(e,t),J=!i||i==t?X:Zr(e,i);n={left:Math.min(X.left,J.left),top:Math.min(X.top,J.top)-r,right:Math.max(X.left,J.left),bottom:Math.max(X.bottom,J.bottom)+r};var q=Ca(e,n),ue=e.doc.scrollTop,fe=e.doc.scrollLeft;if(q.scrollTop!=null&&(En(e,q.scrollTop),Math.abs(e.doc.scrollTop-ue)>1&&(j=!0)),q.scrollLeft!=null&&(Fi(e,q.scrollLeft),Math.abs(e.doc.scrollLeft-fe)>1&&(j=!0)),!j)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),j={};t.bottom-t.top>S&&(t.bottom=t.top+S);var X=e.doc.height+da(i),J=t.top<r,q=t.bottom>X-r;if(t.top<n)j.scrollTop=J?0:t.top;else if(t.bottom>n+S){var ue=Math.min(t.top,(q?X:t.bottom)-S);ue!=n&&(j.scrollTop=ue)}var fe=e.options.fixedGutter?0:i.gutters.offsetWidth,Le=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-fe,we=Mi(e)-i.gutters.offsetWidth,Ne=t.right-t.left>we;return Ne&&(t.right=t.left+we),t.left<10?j.scrollLeft=0:t.left<Le?j.scrollLeft=Math.max(0,t.left+fe-(Ne?0:10)):t.right>we+Le-3&&(j.scrollLeft=t.right+(Ne?0:10)-we),j}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),Pe(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Pe(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&H<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 ee,this.disableVert=new ee},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),Pe(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&&U(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 j=0;j<t.length;j++)nl(t[j])}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-Mi(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==B();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,j=e.maybeUnhiddenMarkers;if(S)for(var X=0;X<S.length;++X)S[X].lines.length||Me(S[X],"hide");if(j)for(var J=0;J<j.length;++J)j[J].lines.length&&Me(j[J],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Me(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 Tr(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,P(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Je(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 j=S.styles,X=S.text.length>e.options.maxHighlightLength?Br(t.mode,r.state):null,J=ge(e,S,r,!0);X&&(r.state=X),S.styles=J.styles;var q=S.styleClasses,ue=J.classes;ue?S.styleClasses=ue:q&&(S.styleClasses=null);for(var fe=!j||j.length!=S.styles.length||q!=ue&&(!q||!ue||q.bgClass!=ue.bgClass||q.textClass!=ue.textClass),Le=0;!fe&&Le<j.length;++Le)fe=j[Le]!=S.styles[Le];fe&&n.push(r.line),S.stateAfter=r.save(),r.nextLine()}else S.text.length<=e.options.maxHighlightLength&&pt(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=Mi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){me(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Me.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=B();if(!t||!E(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&E(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==B())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&E(document.body,e.anchorNode)&&E(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),j=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>j&&i.viewTo-j<20&&(j=Math.min(n,i.viewTo)),nr&&(S=cn(e.doc,S),j=Si(e.doc,j));var X=S!=i.viewFrom||j!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,S,j),i.viewOffset=$r(ft(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var J=po(e);if(!X&&J==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var q=sl(e);return J>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),J>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(q),p(i.cursorDiv),p(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,X&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Mi(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,j=S.firstChild;function X(Ne){var Ke=Ne.nextSibling;return N&&l&&e.display.currentWheelTarget==Ne?Ne.style.display="none":Ne.parentNode.removeChild(Ne),Ke}for(var J=r.view,q=r.viewFrom,ue=0;ue<J.length;ue++){var fe=J[ue];if(!fe.hidden)if(!fe.node||fe.node.parentNode!=S){var Le=Ns(e,fe,q,i);S.insertBefore(Le,j)}else{for(;j!=fe.node;)j=X(j);var we=n&&t!=null&&t<=q&&fe.lineNumber;fe.changes&&(ae(fe.changes,"gutter")>-1&&(we=!1),Ya(e,fe,q,i)),we&&(p(fe.lineNumber),fe.lineNumber.appendChild(document.createTextNode(fi(e.options,q)))),j=fe.node.nextSibling}q+=fe.size}for(;j;)j=X(j)}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",j=0;j<i.length;j++)if(!i[j].hidden){e.options.fixedGutter&&(i[j].gutter&&(i[j].gutter.style.left=S),i[j].gutterBackground&&(i[j].gutterBackground.style.left=S));var X=i[j].alignable;if(X)for(var J=0;J<X.length;J++)X[J].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,j=n.offsetWidth-S;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(S,r.lineGutter.offsetWidth-j)+1,r.lineNumWidth=r.lineNumInnerWidth+j,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],j=null;if(typeof S!="string"&&(j=S.style,S=S.className),S=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:S,style:j})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;p(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],S=n.className,j=n.style,X=t.appendChild(a("div",null,"CodeMirror-gutter "+S));j&&(X.style.cssText=j),S=="CodeMirror-linenumbers"&&(e.lineGutter=X,X.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function wn(e){ko(e.display),Lr(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=b("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=b("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=b("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: "+ce+"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"),z&&H<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!N&&!(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;z?jr=-.53:D?jr=15:v?jr=-.7:O&&(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,j=S.scroller,X=j.scrollWidth>j.clientWidth,J=j.scrollHeight>j.clientHeight;if(!(r&&X||n&&J))return;if(n&&l&&N){e:for(var q=t.target,ue=S.view;q!=j;q=q.parentNode)for(var fe=0;fe<ue.length;fe++)if(ue[fe].node==q){e.display.currentWheelTarget=q;break e}}if(r&&!D&&!T&&jr!=null){n&&J&&En(e,Math.max(0,j.scrollTop+n*jr)),Fi(e,Math.max(0,j.scrollLeft+r*jr)),(!n||n&&J)&&re(t),S.wheelStartX=null;return}if(n&&jr!=null){var Le=n*jr,we=e.doc.scrollTop,Ne=we+S.wrapper.clientHeight;Le<0?we=Math.max(0,we+Le-50):Ne=Math.min(e.doc.height,Ne+Le+50),La(e,{top:we,bottom:Ne})}$n<20&&(S.wheelStartX==null?(S.wheelStartX=j.scrollLeft,S.wheelStartY=j.scrollTop,S.wheelDX=r,S.wheelDY=n,setTimeout(function(){if(S.wheelStartX==null)return;var Ke=j.scrollLeft-S.wheelStartX,Xe=j.scrollTop-S.wheelStartY,tt=Xe&&S.wheelDY&&Xe/S.wheelDY||Ke&&S.wheelDX&&Ke/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!tt)return;jr=(jr*$n+tt)/($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 Ht(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(Ct(t,r.from())>=0&&Ct(e,r.to())<=0)return i}return-1};var Ht=function(e,t){this.anchor=e,this.head=t};Ht.prototype.from=function(){return vi(this.anchor,this.head)},Ht.prototype.to=function(){return gi(this.anchor,this.head)},Ht.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(Le,we){return Ct(Le.from(),we.from())}),i=ae(t,n);for(var S=1;S<t.length;S++){var j=t[S],X=t[S-1],J=Ct(X.to(),j.from());if(r&&!j.empty()?J>0:J>=0){var q=vi(X.from(),j.from()),ue=gi(X.to(),j.to()),fe=X.empty()?j.from()==j.head:X.from()==X.head;S<=i&&--i,t.splice(--S,2,new Ht(fe?ue:q,fe?q:ue))}}return new Wr(t,i)}function wi(e,t){return new Wr([new Ht(e,t||e)],0)}function Ai(e){return e.text?Ve(e.from.line+e.text.length-1,te(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Oo(e,t){if(Ct(e,t.from)<0)return e;if(Ct(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),Ve(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 Ht(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?Ve(i.line,e.ch-t.ch+i.ch):Ve(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Ve(e.first,0),S=n,j=0;j<t.length;j++){var X=t[j],J=_o(X.from,n,S),q=_o(Ai(X),n,S);if(n=X.to,S=q,i=="around"){var ue=e.sel.ranges[j],fe=Ct(ue.head,ue.anchor)<0;r[j]=new Ht(fe?q:J,fe?J:q)}else r[j]=new Ht(J,J)}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&&Lr(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&te(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(ot){return i?i[ot]:null}function S(ot,rt,ht){ua(ot,rt,ht,r),cr(ot,"change",ot,t)}function j(ot,rt){for(var ht=[],xt=ot;xt<rt;++xt)ht.push(new Pi(q[xt],n(xt),r));return ht}var X=t.from,J=t.to,q=t.text,ue=ft(e,X.line),fe=ft(e,J.line),Le=te(q),we=n(q.length-1),Ne=J.line-X.line;if(t.full)e.insert(0,j(0,q.length)),e.remove(q.length,e.size-q.length);else if(Po(e,t)){var Ke=j(0,q.length-1);S(fe,fe.text,we),Ne&&e.remove(X.line,Ne),Ke.length&&e.insert(X.line,Ke)}else if(ue==fe)if(q.length==1)S(ue,ue.text.slice(0,X.ch)+Le+ue.text.slice(J.ch),we);else{var Xe=j(1,q.length-1);Xe.push(new Pi(Le+ue.text.slice(J.ch),we,r)),S(ue,ue.text.slice(0,X.ch)+q[0],n(0)),e.insert(X.line+1,Xe)}else if(q.length==1)S(ue,ue.text.slice(0,X.ch)+q[0]+fe.text.slice(J.ch),n(0)),e.remove(X.line+1,Ne);else{S(ue,ue.text.slice(0,X.ch)+q[0],n(0)),S(fe,Le+fe.text.slice(J.ch),we);var tt=j(1,q.length-1);Ne>1&&e.remove(X.line+1,Ne-1),e.insert(X.line+1,tt)}cr(e,"change",e,t)}function Li(e,t,i){function r(n,S,j){if(n.linked)for(var X=0;X<n.linked.length;++X){var J=n.linked[X];if(J.doc==S)continue;var q=j&&J.sharedHist;if(i&&!q)continue;t(J.doc,q),r(J.doc,n,q)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ea(e),_a(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Lr(e)}function Io(e){(e.doc.direction=="rtl"?U:f)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Mr(e,function(){Io(e),Lr(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 Ma(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=te(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),te(e.done);if(e.done.length&&!te(e.done).ranges)return te(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),te(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var S=+new Date,j,X;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)=="*"))&&(j=pl(n,n.lastOp==r)))X=te(j.changes),Ct(t.from,t.to)==0&&Ct(t.from,X.to)==0?X.to=Ai(t):j.changes.push(Ma(e,t));else{var J=te(n.done);for((!J||!J.ranges)&&Jn(e.sel,n.done),j={changes:[Ma(e,t)],generation:n.generation},n.done.push(j);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,X||Me(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,te(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=te(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(j){j.markedSpans&&((n||(n=t["spans_"+e.id]={}))[S]=j.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],j=r[n];if(S&&j){e:for(var X=0;X<j.length;++X){for(var J=j[X],q=0;q<S.length;++q)if(S[q].marker==J.marker)continue e;S.push(J)}}else j&&(i[n]=j)}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 j=S.changes,X=[];r.push({changes:X});for(var J=0;J<j.length;++J){var q=j[J],ue=void 0;if(X.push({from:q.from,to:q.to,text:q.text}),t)for(var fe in q)(ue=fe.match(/^spans_(\d+)$/))&&(ae(t,Number(ue[1]))>-1&&(te(X)[fe]=q[fe],delete q[fe]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var S=Ct(t,n)<0;S!=Ct(i,n)<0?(n=t,t=i):S!=Ct(t,i)<0&&(t=i)}return new Ht(n,t)}else return new Ht(i||t,t)}function Qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),xr(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 j=Jr(e.cm,r,e.sel.primIndex);xr(e,j,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,xr(e,Jr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){xr(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 Ht(s(e,n[S].anchor),s(e,n[S].head))},origin:i&&i.origin};return Me(e,"beforeSelectionChange",e,r),e.cm&&Me(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=te(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):xr(e,t,i)}function xr(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(me(e,"beforeSelectionChange")||e.cm&&me(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(Ct(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,xe(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 j=t.ranges[S],X=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[S],J=ea(e,j.anchor,X&&X.anchor,i,r),q=ea(e,j.head,X&&X.head,i,r);(n||J!=j.anchor||q!=j.head)&&(n||(n=t.ranges.slice(0,S)),n[S]=new Ht(J,q))}return n?Jr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var S=ft(e,t.line);if(S.markedSpans)for(var j=0;j<S.markedSpans.length;++j){var X=S.markedSpans[j],J=X.marker,q="selectLeft"in J?!J.selectLeft:J.inclusiveLeft,ue="selectRight"in J?!J.selectRight:J.inclusiveRight;if((X.from==null||(q?X.from<=t.ch:X.from<t.ch))&&(X.to==null||(ue?X.to>=t.ch:X.to>t.ch))){if(n&&(Me(J,"beforeCursorEnter"),J.explicitlyCleared))if(S.markedSpans){--j;continue}else break;if(!J.atomic)continue;if(i){var fe=J.find(r<0?1:-1),Le=void 0;if((r<0?ue:q)&&(fe=Vo(e,fe,-r,fe&&fe.line==t.line?S:null)),fe&&fe.line==t.line&&(Le=Ct(fe,i))&&(r<0?Le<0:Le>0))return en(e,fe,t,r,n)}var we=J.find(r<0?-1:1);return(r<0?q:ue)&&(we=Vo(e,we,r,we.line==t.line?S:null)),we?en(e,we,t,r,n):null}}return t}function ea(e,t,i,r,n){var S=r||1,j=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 j||(e.cantEdit=!0,Ve(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,Ve(t.line-1)):null:i>0&&t.ch==(r||ft(e,t.line)).text.length?t.line<e.first+e.size-1?Ve(t.line+1,0):null:new Ve(t.line,t.ch+i)}function Xo(e){e.setSelection(Ve(e.firstLine(),0),Ve(e.lastLine()),Se)}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,j,X){n&&(r.from=s(e,n)),S&&(r.to=s(e,S)),j&&(r.text=j),X!==void 0&&(r.origin=X)}),Me(e,"beforeChange",e,r),e.cm&&Me(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((me(e,"beforeChange")||e.cm&&me(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]==""&&Ct(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&&ae(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,j=e.sel,X=t=="undo"?n.done:n.undone,J=t=="undo"?n.undone:n.done,q=0;q<X.length&&!(S=X[q],i?S.ranges&&!S.equals(e.sel):!S.ranges);q++);if(q==X.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(S=X.pop(),S.ranges){if(Jn(S,J),i&&!S.equals(e.sel)){xr(e,S,{clearRedo:!1});return}j=S}else if(r){X.push(S);return}else break;var ue=[];Jn(j,J),J.push({changes:ue,generation:n.generation}),n.generation=S.generation||++n.maxGeneration;for(var fe=me(e,"beforeChange")||e.cm&&me(e.cm,"beforeChange"),Le=function(Ke){var Xe=S.changes[Ke];if(Xe.origin=t,fe&&!Yo(e,Xe,!1))return X.length=0,{};ue.push(Ma(e,Xe));var tt=Ke?Oa(e,Xe):te(X);Ln(e,Xe,tt,Uo(e,Xe)),!Ke&&e.cm&&e.cm.scrollIntoView({from:Xe.from,to:Ai(Xe)});var ot=[];Li(e,function(rt,ht){!ht&&ae(ot,rt.history)==-1&&(qo(rt.history,Xe),ot.push(rt.history)),Ln(rt,Xe,null,Uo(rt,Xe))})},we=S.changes.length-1;we>=0;--we){var Ne=Le(we);if(Ne)return Ne.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(de(e.sel.ranges,function(n){return new Ht(Ve(n.anchor.line+t,n.anchor.ch),Ve(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Lr(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:Ve(e.first,0),to:Ve(t.to.line+n,t.to.ch),text:[te(t.text)],origin:t.origin}}var S=e.lastLine();t.to.line>S&&(t={from:t.from,to:Ve(S,ft(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):Pa(e,t,r),qn(e,i,Se),e.cantEdit&&ea(e,Ve(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,S=t.from,j=t.to,X=!1,J=S.line;e.options.lineWrapping||(J=Dt(Sr(ft(r,S.line))),r.iter(J,j.line+1,function(we){if(we==n.maxLine)return X=!0,!0})),r.sel.contains(t.from,t.to)>-1&&xe(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(J,S.line+t.text.length,function(we){var Ne=pn(we);Ne>n.maxLineLength&&(n.maxLine=we,n.maxLineLength=Ne,n.maxLineChanged=!0,X=!1)}),X&&(e.curOp.updateMaxLine=!0)),Xr(r,S.line),Cn(e,400);var q=t.text.length-(j.line-S.line)-1;t.full?Lr(e):S.line==j.line&&t.text.length==1&&!Po(e.doc,t)?Ti(e,S.line,"text"):Lr(e,S.line,j.line+1,q);var ue=me(e,"changes"),fe=me(e,"change");if(fe||ue){var Le={from:S,to:j,text:t.text,removed:t.removed,origin:t.origin};fe&&cr(e,"change",e,Le),ue&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Le)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var S;r||(r=i),Ct(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],j=!0;if(S.ranges){S.copied||(S=e[n]=S.deepCopy(),S.copied=!0);for(var X=0;X<S.ranges.length;X++)Jo(S.ranges[X].anchor,t,i,r),Jo(S.ranges[X].head,t,i,r);continue}for(var J=0;J<S.changes.length;++J){var q=S.changes[J];if(i<q.from.line)q.from=Ve(q.from.line+r,q.from.ch),q.to=Ve(q.to.line+r,q.to.ch);else if(t<=q.to.line){j=!1;break}}j||(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=ft(e,G(e,t)):n=Dt(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,mt(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),j=r.height;if(r.removeInner(e,S),this.height-=j-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 X=[];this.collapse(X),this.children=[new Dn(X)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],S=n.chunkSize();if(e<=S){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var j=n.lines.length%25+25,X=j;X<n.lines.length;){var J=new Dn(n.lines.slice(X,X+=25));n.height-=J.height,this.children.splice(++r,0,J),J.parent=this}n.lines=n.lines.slice(0,j),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=ae(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 j=Math.min(t,S-e);if(n.iterN(e,j,i))return!0;if((t-=j)==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=Dt(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);gr(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)||gr(r,r.height+n),i&&Mr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,Dt(r))})},ye(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(j){var X=j.widgets||(j.widgets=[]);if(n.insertAt==null?X.push(n):X.splice(Math.min(X.length-1,Math.max(0,n.insertAt)),0,n),n.line=j,S&&!ri(e,j)){var J=$r(j)<e.scrollTop;gr(j,j.height+vn(n)),J&&wa(S,n.height),S.curOp.forceUpdate=!0}return!0}),S&&cr(S,"lineWidgetAdded",S,n,typeof t=="number"?t:Dt(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),me(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 j=this.lines[S],X=Pr(j.markedSpans,this);e&&!this.collapsed?Ti(e,Dt(j),"text"):e&&(X.to!=null&&(n=Dt(j)),X.from!=null&&(r=Dt(j))),j.markedSpans=_i(j.markedSpans,X),X.from==null&&this.collapsed&&!ri(this.doc,j)&&e&&gr(j,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var J=0;J<this.lines.length;++J){var q=Sr(this.lines[J]),ue=pn(q);ue>e.display.maxLineLength&&(e.display.maxLine=q,e.display.maxLineLength=ue,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Lr(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],j=Pr(S.markedSpans,this);if(j.from!=null&&(i=Ve(t?S:Dt(S),j.from),e==-1))return i;if(j.to!=null&&(r=Ve(t?S:Dt(S),j.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=Dt(t.line),j=fa(r,S);if(j&&(no(j),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var X=i.height;i.height=null;var J=vn(i)-X;J&&gr(n,n.height+J)}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||ae(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ki.prototype.detachLine=function(e){if(this.lines.splice(ae(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},ye(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),j=Ct(t,i);if(r&&_(r,S,!1),j>0||j==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=b("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 X=t.line,J=e.cm,q;if(e.iter(X,i.line+1,function(fe){J&&S.collapsed&&!J.options.lineWrapping&&Sr(fe)==J.display.maxLine&&(q=!0),S.collapsed&&X!=t.line&&gr(fe,0),yi(fe,new si(S,X==t.line?t.ch:null,X==i.line?i.ch:null)),++X}),S.collapsed&&e.iter(t.line,i.line+1,function(fe){ri(e,fe)&&gr(fe,0)}),S.clearOnEnter&&Pe(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),J){if(q&&(J.curOp.updateMaxLine=!0),S.collapsed)Lr(J,t.line,i.line+1);else if(S.className||S.startStyle||S.endStyle||S.css||S.attributes||S.title)for(var ue=t.line;ue<=i.line;ue++)Ti(J,ue,"text");S.atomic&&zo(J.doc),cr(J,"markerAdded",J,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)},ye(_n);function Sl(e,t,i,r,n){r=_(r),r.shared=!1;var S=[nn(e,t,i,r,n)],j=S[0],X=r.widgetNode;return Li(e,function(J){X&&(r.widgetNode=X.cloneNode(!0)),S.push(nn(J,s(J,t),s(J,i),r,n));for(var q=0;q<J.linked.length;++q)if(J.linked[q].isParent)return;j=te(S)}),new _n(S,j)}function rs(e){return e.findMarks(Ve(e.first,0),e.clipPos(Ve(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),j=e.clipPos(n.to);if(Ct(S,j)){var X=nn(e,S,j,r.primary,r.primary.type);r.markers.push(X),X.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],S=[n.primary.doc];Li(n.primary.doc,function(J){return S.push(J)});for(var j=0;j<n.markers.length;j++){var X=n.markers[j];ae(S,X.doc)==-1&&(X.parent=null,n.markers.splice(j--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,kr=function(e,t,i,r,n){if(!(this instanceof kr))return new kr(e,t,i,r,n);i==null&&(i=0),Rn.call(this,[new Dn([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var S=Ve(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)),Pa(this,{from:S,to:S,text:e}),xr(this,wi(S),Se)};kr.prototype=Oe(Rn.prototype,{constructor:kr,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=Ve(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Ve(i,ft(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&xn(this.cm,0,0),xr(this,wi(t),Se)}),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 ft(this,e)},getLineNumber:function(e){return Dt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ft(this,e)),Sr(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"?Ve(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,I(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=de(this.sel.ranges,e);jo(this,I(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 Ht(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),xr(this,Jr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Ht(s(this,e),s(this,t||e))),xr(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 j=n.ranges[S];r[S]={from:j.from(),to:j.to(),text:this.splitLines(e[S]),origin:i}}for(var X=t&&t!="end"&&cl(this,r,t),J=r.length-1;J>=0;J--)tn(this,r[J]);X?Ho(this,X):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&&ze(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,ze(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=ft(this,e),!e)return null}else if(t=Dt(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(x(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 j=S.match(x(i));if(!j)return!1;var X=j.index+j[0].length;r[n]=S.slice(0,j.index)+(!j.index||X==S.length?"":" ")+S.slice(X)||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=ft(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 j=S.markedSpans;if(j)for(var X=0;X<j.length;X++){var J=j[X];!(J.to!=null&&n==e.line&&e.ch>=J.to||J.from==null&&n!=e.line||J.from!=null&&n==t.line&&J.from>=t.ch)&&(!i||i(J.marker))&&r.push(J.marker.parent||J.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,Ve(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 kr(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 kr(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 Yt&&(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):Et(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)})}),kr.prototype.eachLine=kr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),Ge(t,e)||ui(t.display,e))return;re(e),z&&(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),j=0,X=function(){++j==n&&or(t,function(){i=s(t.doc,i);var we={from:i,to:i,text:t.doc.splitLines(S.filter(function(Ne){return Ne!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,we),Ho(t.doc,wi(s(t.doc,i),s(t.doc,Ai(we))))})()},J=function(we,Ne){if(t.options.allowDropFileTypes&&ae(t.options.allowDropFileTypes,we.type)==-1){X();return}var Ke=new FileReader;Ke.onerror=function(){return X()},Ke.onload=function(){var Xe=Ke.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Xe)){X();return}S[Ne]=Xe,X()},Ke.readAsText(we)},q=0;q<r.length;q++)J(r[q],q);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 ue=e.dataTransfer.getData("Text");if(ue){var fe;if(t.state.draggingText&&!t.state.draggingText.copy&&(fe=t.listSelections()),qn(t.doc,wi(i,i)),fe)for(var Le=0;Le<fe.length;++Le)rn(t.doc,"",fe[Le].anchor,fe[Le].head,"drag");t.replaceSelection(ue,"around","paste"),t.display.input.focus()}}catch(we){}}}function Ll(e,t){if(z&&(!e.state.draggingText||+new Date-is<100)){pe(t);return}if(Ge(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!O){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",T&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),T&&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;Pe(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Ol)},100))}),Pe(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"},Pn=0;Pn<10;Pn++)Di[Pn+48]=Di[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[Mn+63235]="F"+Mn;var 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,j=0;j<t.length-1;j++){var X=t[j];if(/^(cmd|meta|m)$/i.test(X))S=!0;else if(/^a(lt)?$/i.test(X))i=!0;else if(/^(c|ctrl|control)$/i.test(X))r=!0;else if(/^s(hift)?$/i.test(X))n=!0;else throw new Error("Unrecognized modifier name: "+X)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),S&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=de(i.split(" "),_l),S=0;S<n.length;S++){var j=void 0,X=void 0;S==n.length-1?(X=n.join(" "),j=r):(X=n.slice(0,S+1).join(" "),j="...");var J=t[X];if(!J)t[X]=j;else if(J!=j)throw new Error("Inconsistent bindings for "+X)}delete e[i]}for(var q in t)e[q]=t[q];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 j=an(e,t.fallthrough[S],i,r);if(j)return j}}}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),(g?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(g?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(T&&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&&Ct(S.from,te(r).to)<=0;){var j=r.pop();if(Ct(j.from,S.from)<0){S.from=j.from;break}}r.push(S)}Mr(e,function(){for(var X=r.length-1;X>=0;X--)rn(e.doc,"",r[X].from,r[X].to,"+delete");Ji(e)})}function Ba(e,t,i){var r=Ie(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Ve(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=et(i,t.doc.direction);if(S){var j=n<0?te(S):S[0],X=n<0==(j.level==1),J=X?"after":"before",q;if(j.level>0||t.doc.direction=="rtl"){var ue=Xi(t,i);q=n<0?i.text.length-1:0;var fe=ni(t,ue,q).top;q=it(function(Le){return ni(t,ue,Le).top==fe},n<0==(j.level==1)?j.from:j.to-1,q),J=="before"&&(q=Ba(i,q,1))}else q=n<0?j.to:j.from;return new Ve(r,q,J)}}return new Ve(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=et(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=qe(n,i.ch,i.sticky),j=n[S];if(e.doc.direction=="ltr"&&j.level%2==0&&(r>0?j.to>i.ch:j.from<i.ch))return Fa(t,i,r);var X=function(tt,ot){return Ba(t,tt instanceof Ve?tt.ch:tt,ot)},J,q=function(tt){return e.options.lineWrapping?(J=J||Xi(e,t),co(e,t,J,tt)):{begin:0,end:t.text.length}},ue=q(i.sticky=="before"?X(i,-1):i.ch);if(e.doc.direction=="rtl"||j.level==1){var fe=j.level==1==r<0,Le=X(i,fe?1:-1);if(Le!=null&&(fe?Le<=j.to&&Le<=ue.end:Le>=j.from&&Le>=ue.begin)){var we=fe?"before":"after";return new Ve(i.line,Le,we)}}var Ne=function(tt,ot,rt){for(var ht=function(Vt,lr){return lr?new Ve(i.line,X(Vt,1),"before"):new Ve(i.line,Vt,"after")};tt>=0&&tt<n.length;tt+=ot){var xt=n[tt],gt=ot>0==(xt.level!=1),At=gt?rt.begin:X(rt.end,-1);if(xt.from<=At&&At<xt.to)return ht(At,gt);if(At=gt?xt.from:X(xt.to,-1),rt.begin<=At&&At<rt.end)return ht(At,gt)}},Ke=Ne(S+r,r,ue);if(Ke)return Ke;var Xe=r>0?ue.end:X(ue.begin,-1);return Xe!=null&&!(r>0&&Xe==t.text.length)&&(Ke=Ne(r>0?0:n.length-1,r,q(Xe)),Ke)?Ke:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Se)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=ft(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Ve(t.head.line+1,0)}:{from:t.head,to:Ve(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:Ve(t.from().line,0),to:s(e.doc,Ve(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:Ve(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(Ve(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ve(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")},Ae)},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")},Ae)},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},Ae)},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(),j=Y(e.getLine(S.line),S.ch,r);t.push(le(r-j%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=ft(e.doc,n.line).text;if(S){if(n.ch==S.length&&(n=new Ve(n.line,n.ch-1)),n.ch>0)n=new Ve(n.line,n.ch+1),e.replaceRange(S.charAt(n.ch-1)+S.charAt(n.ch-2),Ve(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var j=ft(e.doc,n.line-1).text;j&&(n=new Ve(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+j.charAt(j.length-1),Ve(n.line-1,j.length-1),n,"+transpose"))}}i.push(new Ht(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=ft(e.doc,t),r=Sr(i);return r!=i&&(t=Dt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=ft(e.doc,t),r=Vi(i);return r!=i&&(t=Dt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=ft(e.doc,i.line),n=et(r,e.doc.direction);if(!n||n[0].level==0){var S=Math.max(i.ch,r.text.search(/\S/)),j=t.line==i.line&&t.ch<=S&&t.ch;return Ve(i.line,j?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)!=De}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 ee;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")&&(re(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=B(),Ge(t,e))return;z&&H<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);T&&(ja=r?i:null,!r&&i==88&&!Pt&&(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;U(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),at(document,"keyup",i),at(document,"mouseover",i))}Pe(document,"keyup",i),Pe(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ge(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Ge(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(T&&i==ja){ja=null,re(e);return}if(T&&(!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&&Ct(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(Ge(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){N||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=_e(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):be(e)==i.scroller&&re(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(j){if(typeof j=="string"&&(j=In[j]),!j)return!1;var X=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),X=j(e,i)!=De}finally{e.state.suppressEdits=!1}return X})}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){z?setTimeout(P(vo,e),0):e.curOp.focus=B();var n=Gl(e,i,r),S=e.doc.sel,j;e.options.dragDrop&&We&&!e.isReadOnly()&&i=="single"&&(j=S.contains(t))>-1&&(Ct((j=S.ranges[j]).from(),t)<0||t.xRel>0)&&(Ct(j.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,j=or(e,function(q){N&&(n.scroller.draggable=!1),e.state.draggingText=!1,at(n.wrapper.ownerDocument,"mouseup",j),at(n.wrapper.ownerDocument,"mousemove",X),at(n.scroller,"dragstart",J),at(n.scroller,"drop",j),S||(re(q),r.addNew||Qn(e.doc,i,null,null,r.extend),N&&!O||z&&H==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),X=function(q){S=S||Math.abs(t.clientX-q.clientX)+Math.abs(t.clientY-q.clientY)>=10},J=function(){return S=!0};N&&(n.scroller.draggable=!0),e.state.draggingText=j,j.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Pe(n.wrapper.ownerDocument,"mouseup",j),Pe(n.wrapper.ownerDocument,"mousemove",X),Pe(n.scroller,"dragstart",J),Pe(n.scroller,"drop",j),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new Ht(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Ht(Ve(t.line,0),s(e.doc,Ve(t.line+1,0)));var r=i(e,t);return new Ht(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,S=e.doc;re(t);var j,X,J=S.sel,q=J.ranges;if(r.addNew&&!r.extend?(X=S.sel.contains(i),X>-1?j=q[X]:j=new Ht(i,i)):(j=S.sel.primary(),X=S.sel.primIndex),r.unit=="rectangle")r.addNew||(j=new Ht(i,i)),i=Ni(e,t,!0,!0),X=-1;else{var ue=ys(e,i,r.unit);r.extend?j=Ia(j,ue.anchor,ue.head,r.extend):j=ue}r.addNew?X==-1?(X=q.length,xr(S,Jr(e,q.concat([j]),X),{scroll:!1,origin:"*mouse"})):q.length>1&&q[X].empty()&&r.unit=="char"&&!r.extend?(xr(S,Jr(e,q.slice(0,X).concat(q.slice(X+1)),0),{scroll:!1,origin:"*mouse"}),J=S.sel):Na(S,X,j,Ce):(X=0,xr(S,new Wr([j],0),Ce),J=S.sel);var fe=i;function Le(rt){if(Ct(fe,rt)==0)return;if(fe=rt,r.unit=="rectangle"){for(var ht=[],xt=e.options.tabSize,gt=Y(ft(S,i.line).text,i.ch,xt),At=Y(ft(S,rt.line).text,rt.ch,xt),Vt=Math.min(gt,At),lr=Math.max(gt,At),$t=Math.min(i.line,rt.line),Ir=Math.min(e.lastLine(),Math.max(i.line,rt.line));$t<=Ir;$t++){var Dr=ft(S,$t).text,er=Te(Dr,Vt,xt);Vt==lr?ht.push(new Ht(Ve($t,er),Ve($t,er))):Dr.length>er&&ht.push(new Ht(Ve($t,er),Ve($t,Te(Dr,lr,xt))))}ht.length||ht.push(new Ht(i,i)),xr(S,Jr(e,J.ranges.slice(0,X).concat(ht),X),{origin:"*mouse",scroll:!1}),e.scrollIntoView(rt)}else{var Rr=j,fr=ys(e,rt,r.unit),ir=Rr.anchor,tr;Ct(fr.anchor,ir)>0?(tr=fr.head,ir=vi(Rr.from(),fr.anchor)):(tr=fr.anchor,ir=gi(Rr.to(),fr.head));var Zt=J.ranges.slice(0);Zt[X]=Xl(e,new Ht(s(S,ir),tr)),xr(S,Jr(e,Zt,X),Ce)}}var we=n.wrapper.getBoundingClientRect(),Ne=0;function Ke(rt){var ht=++Ne,xt=Ni(e,rt,!0,r.unit=="rectangle");if(!xt)return;if(Ct(xt,fe)!=0){e.curOp.focus=B(),Le(xt);var gt=Vn(n,S);(xt.line>=gt.to||xt.line<gt.from)&&setTimeout(or(e,function(){Ne==ht&&Ke(rt)}),150)}else{var At=rt.clientY<we.top?-20:rt.clientY>we.bottom?20:0;At&&setTimeout(or(e,function(){if(Ne!=ht)return;n.scroller.scrollTop+=At,Ke(rt)}),50)}}function Xe(rt){e.state.selectingText=!1,Ne=Infinity,rt&&(re(rt),n.input.focus()),at(n.wrapper.ownerDocument,"mousemove",tt),at(n.wrapper.ownerDocument,"mouseup",ot),S.history.lastSelOrigin=null}var tt=or(e,function(rt){rt.buttons===0||!_e(rt)?Xe(rt):Ke(rt)}),ot=or(e,Xe);e.state.selectingText=ot,Pe(n.wrapper.ownerDocument,"mousemove",tt),Pe(n.wrapper.ownerDocument,"mouseup",ot)}function Xl(e,t){var i=t.anchor,r=t.head,n=ft(e.doc,i.line);if(Ct(i,r)==0&&i.sticky==r.sticky)return t;var S=et(n);if(!S)return t;var j=qe(S,i.ch,i.sticky),X=S[j];if(X.from!=i.ch&&X.to!=i.ch)return t;var J=j+(X.from==i.ch==(X.level!=1)?0:1);if(J==0||J==S.length)return t;var q;if(r.line!=i.line)q=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var ue=qe(S,r.ch,r.sticky),fe=ue-j||(r.ch-i.ch)*(X.level==1?-1:1);ue==J-1||ue==J?q=fe<0:q=fe>0}var Le=S[J+(q?-1:0)],we=q==(Le.level==1),Ne=we?Le.from:Le.to,Ke=we?"after":"before";return i.ch==Ne&&i.sticky==Ke?t:new Ht(new Ve(i.line,Ne,Ke),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(Le){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&re(t);var j=e.display,X=j.lineDiv.getBoundingClientRect();if(S>X.bottom||!me(e,i))return se(t);S-=X.top-j.viewOffset;for(var J=0;J<e.display.gutterSpecs.length;++J){var q=j.gutters.childNodes[J];if(q&&q.getBoundingClientRect().right>=n){var ue=Fr(e.doc,S),fe=e.display.gutterSpecs[J];return Me(e,i,e,ue,fe.className,t),se(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(Ge(e,t,"contextmenu"))return;k||e.display.input.onContextMenu(t)}function Yl(e,t){return me(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,j){e.defaults[r]=n,S&&(t[r]=j?function(X,J,q){q!=sn&&S(X,J,q)}: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),Lr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var S=[],j=r.doc.first;r.doc.iter(function(J){for(var q=0;;){var ue=J.text.indexOf(n,q);if(ue==-1)break;q=ue+n.length,S.push(Ve(j,ue))}j++});for(var X=S.length-1;X>=0;X--)rn(r.doc,n,S[X],Ve(S[X].line,S[X].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,S){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),S!=sn&&r.refresh()}),i("specialCharPlaceholder",Kt,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",!w),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),wn(r)},!0),i("keyMap","default",function(r,n,S){var j=ia(n),X=S!=sn&&ia(S);X&&X.detach&&X.detach(r,j),j.attach&&j.attach(r,X||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?Pe:at;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?(U(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(f(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Ea(e),Lr(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Yt(e,t){var i=this;if(!(this instanceof Yt))return new Yt(e,t);this.options=t=t?_(t):{},_(Ss,t,!1);var r=t.value;typeof r=="string"?r=new kr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Yt.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 ee,keySeq:null,specialChars:null},t.autofocus&&!o&&S.input.focus(),z&&H<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Zi(this);for(var j in aa)aa.hasOwnProperty(j)&&aa[j](this,t[j],sn);Lo(this),t.finishInit&&t.finishInit(this);for(var X=0;X<Ga.length;++X)Ga[X](this);Wi(this),N&&t.lineWrapping&&getComputedStyle(S.lineDiv).textRendering=="optimizelegibility"&&(S.lineDiv.style.textRendering="auto")}Yt.defaults=Ss,Yt.optionHandlers=aa;function Ql(e){var t=e.display;Pe(t.scroller,"mousedown",or(e,vs)),z&&H<11?Pe(t.scroller,"dblclick",or(e,function(J){if(Ge(e,J))return;var q=Ni(e,J);if(!q||Ha(e,J)||ui(e.display,J))return;re(J);var ue=e.findWordAt(q);Qn(e.doc,ue.anchor,ue.head)})):Pe(t.scroller,"dblclick",function(J){return Ge(e,J)||re(J)}),Pe(t.scroller,"contextmenu",function(J){return xs(e,J)}),Pe(t.input.getField(),"contextmenu",function(J){t.scroller.contains(J.target)||xs(e,J)});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(J){if(J.touches.length!=1)return!1;var q=J.touches[0];return q.radiusX<=1&&q.radiusY<=1}function j(J,q){if(q.left==null)return!0;var ue=q.left-J.left,fe=q.top-J.top;return ue*ue+fe*fe>20*20}Pe(t.scroller,"touchstart",function(J){if(!Ge(e,J)&&!S(J)&&!Ha(e,J)){t.input.ensurePolled(),clearTimeout(i);var q=+new Date;t.activeTouch={start:q,moved:!1,prev:q-r.end<=300?r:null},J.touches.length==1&&(t.activeTouch.left=J.touches[0].pageX,t.activeTouch.top=J.touches[0].pageY)}}),Pe(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Pe(t.scroller,"touchend",function(J){var q=t.activeTouch;if(q&&!ui(t,J)&&q.left!=null&&!q.moved&&new Date-q.start<300){var ue=e.coordsChar(t.activeTouch,"page"),fe;!q.prev||j(q,q.prev)?fe=new Ht(ue,ue):!q.prev.prev||j(q,q.prev.prev)?fe=e.findWordAt(ue):fe=new Ht(Ve(ue.line,0),s(e.doc,Ve(ue.line+1,0))),e.setSelection(fe.anchor,fe.head),e.focus(),re(J)}n()}),Pe(t.scroller,"touchcancel",n),Pe(t.scroller,"scroll",function(){t.scroller.clientHeight&&(En(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Me(e,"scroll",e))}),Pe(t.scroller,"mousewheel",function(J){return Ro(e,J)}),Pe(t.scroller,"DOMMouseScroll",function(J){return Ro(e,J)}),Pe(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(J){Ge(e,J)||pe(J)},over:function(J){Ge(e,J)||(kl(e,J),pe(J))},start:function(J){return Ll(e,J)},drop:or(e,Al),leave:function(J){Ge(e,J)||ns(e)}};var X=t.input.getField();Pe(X,"keyup",function(J){return ms.call(e,J)}),Pe(X,"keydown",or(e,ps)),Pe(X,"keypress",or(e,gs)),Pe(X,"focus",function(J){return Ta(e,J)}),Pe(X,"blur",function(J){return Zi(e,J)})}var Ga=[];Yt.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=Je(e,t).state:i="prev");var j=e.options.tabSize,X=ft(n,t),J=Y(X.text,null,j);X.stateAfter&&(X.stateAfter=null);var q=X.text.match(/^\s*/)[0],ue;if(!r&&!/\S/.test(X.text))ue=0,i="not";else if(i=="smart"&&(ue=n.mode.indent(S,X.text.slice(q.length),X.text),ue==De||ue>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?ue=Y(ft(n,t-1).text,null,j):ue=0:i=="add"?ue=J+e.options.indentUnit:i=="subtract"?ue=J-e.options.indentUnit:typeof i=="number"&&(ue=J+i),ue=Math.max(0,ue);var fe="",Le=0;if(e.options.indentWithTabs)for(var we=Math.floor(ue/j);we;--we)Le+=j,fe+=" ";if(Le<ue&&(fe+=le(ue-Le)),fe!=q)return rn(n,fe,Ve(t,0),Ve(t,q.length),"+input"),X.stateAfter=null,!0;for(var Ne=0;Ne<n.sel.ranges.length;Ne++){var Ke=n.sel.ranges[Ne];if(Ke.head.line==t&&Ke.head.ch<q.length){var Xe=Ve(t,q.length);Na(n,Ne,new Ht(Xe,Xe));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 j=+new Date-200,X=n=="paste"||e.state.pasteIncoming>j,J=Et(t),q=null;if(X&&r.ranges.length>1)if(Qr&&Qr.text.join(`
`)==t){if(r.ranges.length%Qr.text.length==0){q=[];for(var ue=0;ue<Qr.text.length;ue++)q.push(S.splitLines(Qr.text[ue]))}}else J.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(q=de(J,function(tt){return[tt]}));for(var fe=e.curOp.updateInput,Le=r.ranges.length-1;Le>=0;Le--){var we=r.ranges[Le],Ne=we.from(),Ke=we.to();we.empty()&&(i&&i>0?Ne=Ve(Ne.line,Ne.ch-i):e.state.overwrite&&!X?Ke=Ve(Ke.line,Math.min(ft(S,Ke.line).text.length,Ke.ch+te(J).length)):X&&Qr&&Qr.lineWise&&Qr.text.join(`
`)==J.join(`
`)&&(Ne=Ke=Ve(Ne.line,0)));var Xe={from:Ne,to:Ke,text:q?q[Le%q.length]:J,origin:n||(X?"paste":e.state.cutIncoming>j?"cut":"+input")};tn(e.doc,Xe),cr(e,"inputRead",e,Xe)}t&&!X&&Cs(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=fe),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),j=!1;if(S.electricChars){for(var X=0;X<S.electricChars.length;X++)if(t.indexOf(S.electricChars.charAt(X))>-1){j=Un(e,n.head.line,"smart");break}}else S.electricInput&&(S.electricInput.test(ft(e.doc,n.head.line).text.slice(0,n.head.ch))&&(j=Un(e,n.head.line,"smart")));j&&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:Ve(n,0),head:Ve(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 N?e.style.width="1000px":e.setAttribute("wrap","off"),C&&(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,j=S[r];if(S[r]==n&&r!="mode")return;S[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,j),Me(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:Tr(function(r,n){var S=r.token?r:e.getMode(this.options,r);if(S.startState)throw new Error("Overlays may not be stateful.");ne(this.state.overlays,{mode:S,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(j){return j.priority}),this.state.modeGen++,Lr(this)}),removeOverlay:Tr(function(r){for(var n=this.state.overlays,S=0;S<n.length;++S){var j=n[S].modeSpec;if(j==r||typeof r=="string"&&j.name==r){n.splice(S,1),this.state.modeGen++,Lr(this);return}}}),indentLine:Tr(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:Tr(function(r){for(var n=this.doc.sel.ranges,S=-1,j=0;j<n.length;j++){var X=n[j];if(X.empty())X.head.line>S&&(Un(this,X.head.line,r,!0),S=X.head.line,j==this.doc.sel.primIndex&&Ji(this));else{var J=X.from(),q=X.to(),ue=Math.max(S,J.line);S=Math.min(this.lastLine(),q.line-(q.ch?0:1))+1;for(var fe=ue;fe<S;++fe)Un(this,fe,r);var Le=this.doc.sel.ranges;J.ch==0&&n.length==Le.length&&Le[j].from().ch>0&&Na(this.doc,j,new Ht(J,Le[j].to()),Se)}}}),getTokenAt:function(r,n){return Xt(this,r,n)},getLineTokens:function(r,n){return Xt(this,Ve(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=je(this,ft(this.doc,r.line)),S=0,j=(n.length-1)/2,X=r.ch,J;if(X==0)J=n[2];else for(;;){var q=S+j>>1;if((q?n[q*2-1]:0)>=X)j=q;else if(n[q*2+1]<X)S=q+1;else{J=n[q*2+2];break}}var ue=J?J.indexOf("overlay "):-1;return ue<0?J:ue==0?null:J.slice(0,ue-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 j=i[n],X=this.getModeAt(r);if(typeof X[n]=="string")j[X[n]]&&S.push(j[X[n]]);else if(X[n])for(var J=0;J<X[n].length;J++){var q=j[X[n][J]];q&&S.push(q)}else X.helperType&&j[X.helperType]?S.push(j[X.helperType]):j[X.name]&&S.push(j[X.name]);for(var ue=0;ue<j._global.length;ue++){var fe=j._global[ue];fe.pred(X,this)&&ae(S,fe.val)==-1&&S.push(fe.val)}return S},getStateAfter:function(r,n){var S=this.doc;return r=G(S,r==null?S.first+S.size-1:r),Je(this,r+1,n).state},cursorCoords:function(r,n){var S,j=this.doc.sel.primary();return r==null?S=j.head:typeof r=="object"?S=s(this.doc,r):S=r?j.from():j.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 j=!1,X;if(typeof r=="number"){var J=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>J&&(r=J,j=!0),X=ft(this.doc,r)}else X=r;return Hn(this,X,{top:0,left:0},n||"page",S||j).top+(j?this.doc.height-$r(X):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,j,X){var J=this.display;r=Zr(this,s(this.doc,r));var q=r.bottom,ue=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),J.sizer.appendChild(n),j=="over")q=r.top;else if(j=="above"||j=="near"){var fe=Math.max(J.wrapper.clientHeight,this.doc.height),Le=Math.max(J.sizer.clientWidth,J.lineSpace.clientWidth);(j=="above"||r.bottom+n.offsetHeight>fe)&&r.top>n.offsetHeight?q=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=fe&&(q=r.bottom),ue+n.offsetWidth>Le&&(ue=Le-n.offsetWidth)}n.style.top=q+"px",n.style.left=n.style.right="",X=="right"?(ue=J.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(X=="left"?ue=0:X=="middle"&&(ue=(J.sizer.clientWidth-n.offsetWidth)/2),n.style.left=ue+"px"),S&&Zs(this,{left:ue,top:q,right:ue+n.offsetWidth,bottom:q+n.offsetHeight})},triggerOnKeyDown:Tr(ps),triggerOnKeyPress:Tr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Tr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Tr(function(r){Cs(this,r)}),findPosH:function(r,n,S,j){var X=1;n<0&&(X=-1,n=-n);for(var J=s(this.doc,r),q=0;q<n&&!(J=Ka(this.doc,J,X,S,j),J.hitSide);++q);return J},moveH:Tr(function(r,n){var S=this;this.extendSelectionsBy(function(j){return S.display.shift||S.doc.extend||j.empty()?Ka(S.doc,j.head,r,n,S.options.rtlMoveVisually):r<0?j.from():j.to()},Ae)}),deleteH:Tr(function(r,n){var S=this.doc.sel,j=this.doc;S.somethingSelected()?j.replaceSelection("",null,"+delete"):on(this,function(X){var J=Ka(j,X.head,r,n,!1);return r<0?{from:J,to:X.head}:{from:X.head,to:J}})}),findPosV:function(r,n,S,j){var X=1,J=j;n<0&&(X=-1,n=-n);for(var q=s(this.doc,r),ue=0;ue<n;++ue){var fe=Zr(this,q,"div");if(J==null?J=fe.left:fe.left=J,q=ks(this,fe,X,S),q.hitSide)break}return q},moveV:Tr(function(r,n){var S=this,j=this.doc,X=[],J=!this.display.shift&&!j.extend&&j.sel.somethingSelected();if(j.extendSelectionsBy(function(ue){if(J)return r<0?ue.from():ue.to();var fe=Zr(S,ue.head,"div");ue.goalColumn!=null&&(fe.left=ue.goalColumn),X.push(fe.left);var Le=ks(S,fe,r,n);return n=="page"&&ue==j.sel.primary()&&wa(S,ma(S,Le,"div").top-fe.top),Le},Ae),X.length)for(var q=0;q<j.sel.ranges.length;q++)j.sel.ranges[q].goalColumn=X[q]}),findWordAt:function(r){var n=this.doc,S=ft(n,r.line).text,j=r.ch,X=r.ch;if(S){var J=this.getHelper(r,"wordChars");(r.sticky=="before"||X==S.length)&&j?--j:++X;for(var q=S.charAt(j),ue=Be(q,J)?function(fe){return Be(fe,J)}:/\s/.test(q)?function(fe){return/\s/.test(fe)}:function(fe){return!/\s/.test(fe)&&!Be(fe)};j>0&&ue(S.charAt(j-1));)--j;for(;X<S.length&&ue(S.charAt(X));)++X}return new Ht(Ve(r.line,j),Ve(r.line,X))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?U(this.display.cursorDiv,"CodeMirror-overwrite"):f(this.display.cursorDiv,"CodeMirror-overwrite"),Me(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==B()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Tr(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:Mi(this)}},scrollIntoView:Tr(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:Ve(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:Tr(function(r,n){var S=this,j=function(J){return typeof J=="number"||/^\d+$/.test(String(J))?J+"px":J};r!=null&&(this.display.wrapper.style.width=j(r)),n!=null&&(this.display.wrapper.style.height=j(n)),this.options.lineWrapping&&ao(this);var X=this.display.viewFrom;this.doc.iter(X,this.display.viewTo,function(J){if(J.widgets){for(var q=0;q<J.widgets.length;q++)if(J.widgets[q].noHScroll){Ti(S,X,"widget");break}}++X}),this.curOp.forceUpdate=!0,Me(this,"refresh",this)}),operation:function(r){return Mr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Tr(function(){var r=this.display.cachedTextHeight;Lr(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),Me(this,"refresh",this)}),swapDoc:Tr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(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}},ye(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,j){e.registerHelper(r,n,j),i[r]._global.push({pred:S,val:j})}}function Ka(e,t,i,r,n){var S=t,j=i,X=ft(e,t.line),J=n&&e.direction=="rtl"?-i:i;function q(){var ot=t.line+J;return ot<e.first||ot>=e.first+e.size?!1:(t=new Ve(ot,t.ch,t.sticky),X=ft(e,ot))}function ue(ot){var rt;if(r=="codepoint"){var ht=X.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(ht)?rt=null:rt=new Ve(t.line,Math.max(0,Math.min(X.text.length,t.ch+i*(ht>=55296&&ht<56320?2:1))),-i)}else n?rt=Ml(e.cm,X,t,i):rt=Fa(X,t,i);if(rt==null)if(!ot&&q())t=Ua(n,e.cm,X,t.line,J);else return!1;else t=rt;return!0}if(r=="char"||r=="codepoint")ue();else if(r=="column")ue(!0);else if(r=="word"||r=="group")for(var fe=null,Le=r=="group",we=e.cm&&e.cm.getHelper(t,"wordChars"),Ne=!0;!(i<0&&!ue(!Ne));Ne=!1){var Ke=X.text.charAt(t.ch)||`
`,Xe=Be(Ke,we)?"w":Le&&Ke==`
`?"n":!Le||/\s/.test(Ke)?null:"p";if(Le&&!Ne&&!Xe&&(Xe="s"),fe&&fe!=Xe){i<0&&(i=1,ue(),t.sticky="after");break}if(Xe&&(fe=Xe),i>0&&!ue(!Ne))break}var tt=ea(e,t,S,j,!0);return pi(S,tt)&&(tt.hitSide=!0),tt}function ks(e,t,i,r){var n=e.doc,S=t.left,j;if(r=="page"){var X=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),J=Math.max(X-.5*Yi(e.display),3);j=(i>0?t.bottom:t.top)+i*J}else r=="line"&&(j=i>0?t.bottom+3:t.top-3);for(var q;!(q=va(e,S,j),!q.outside);){if(i<0?j<=0:j>=n.height){q.hitSide=!0;break}j+=i*5}return q}var zt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ee,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};zt.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(X){for(var J=X.target;J;J=J.parentNode){if(J==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(J.className))break}return!1}Pe(n,"paste",function(X){if(!S(X)||Ge(r,X)||Ts(X,r))return;H<=11&&setTimeout(or(r,function(){return t.updateFromDOM()}),20)}),Pe(n,"compositionstart",function(X){t.composing={data:X.data,done:!1}}),Pe(n,"compositionupdate",function(X){t.composing||(t.composing={data:X.data,done:!1})}),Pe(n,"compositionend",function(X){t.composing&&(X.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Pe(n,"touchstart",function(){return i.forceCompositionEnd()}),Pe(n,"input",function(){t.composing||t.readFromDOMSoon()});function j(X){if(!S(X)||Ge(r,X))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),X.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var J=ws(r);oa({lineWise:!0,text:J.text}),X.type=="cut"&&r.operation(function(){r.setSelections(J.ranges,0,Se),r.replaceSelection("",null,"cut")})}else return;if(X.clipboardData){X.clipboardData.clearData();var q=Qr.text.join(`
`);if(X.clipboardData.setData("Text",q),X.clipboardData.getData("Text")==q){X.preventDefault();return}}var ue=Ls(),fe=ue.firstChild;r.display.lineSpace.insertBefore(ue,r.display.lineSpace.firstChild),fe.value=Qr.text.join(`
`);var Le=document.activeElement;V(fe),setTimeout(function(){r.display.lineSpace.removeChild(ue),Le.focus(),Le==n&&i.showPrimarySelection()},50)}Pe(n,"copy",j),Pe(n,"cut",j)},zt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},zt.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},zt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},zt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},zt.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),j=sa(t,e.focusNode,e.focusOffset);if(S&&!S.bad&&j&&!j.bad&&Ct(vi(S,j),r)==0&&Ct(gi(S,j),n)==0)return;var X=t.display.view,J=r.line>=t.display.viewFrom&&Ds(t,r)||{node:X[0].measure.map[2],offset:0},q=n.line<t.display.viewTo&&Ds(t,n);if(!q){var ue=X[X.length-1].measure,fe=ue.maps?ue.maps[ue.maps.length-1]:ue.map;q={node:fe[fe.length-1],offset:fe[fe.length-2]-fe[fe.length-3]}}if(!J||!q){e.removeAllRanges();return}var Le=e.rangeCount&&e.getRangeAt(0),we;try{we=m(J.node,J.offset,q.offset,q.node)}catch(Ne){}we&&(!D&&t.state.focused?(e.collapse(J.node,J.offset),we.collapsed||(e.removeAllRanges(),e.addRange(we))):(e.removeAllRanges(),e.addRange(we)),Le&&e.anchorNode==null?e.addRange(Le):D&&this.startGracePeriod()),this.rememberSelection()},zt.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)},zt.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},zt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},zt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return E(this.div,t)},zt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},zt.prototype.blur=function(){this.div.blur()},zt.prototype.getField=function(){return this.div},zt.prototype.supportsTouch=function(){return!0},zt.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)},zt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},zt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&v&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Mr(t,function(){xr(t.doc,wi(i,r),Se),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},zt.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=Ve(r.line-1,ft(e.doc,r.line-1).length)),n.ch==ft(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Ve(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var S,j,X;r.line==t.viewFrom||(S=Bi(e,r.line))==0?(j=Dt(t.view[0].line),X=t.view[0].node):(j=Dt(t.view[S].line),X=t.view[S-1].node.nextSibling);var J=Bi(e,n.line),q,ue;if(J==t.view.length-1?(q=t.viewTo-1,ue=t.lineDiv.lastChild):(q=Dt(t.view[J+1].line)-1,ue=t.view[J+1].node.previousSibling),!X)return!1;for(var fe=e.doc.splitLines(tu(e,X,ue,j,q)),Le=Hr(e.doc,Ve(j,0),Ve(q,ft(e.doc,q).text.length));fe.length>1&&Le.length>1;)if(te(fe)==te(Le))fe.pop(),Le.pop(),q--;else if(fe[0]==Le[0])fe.shift(),Le.shift(),j++;else break;for(var we=0,Ne=0,Ke=fe[0],Xe=Le[0],tt=Math.min(Ke.length,Xe.length);we<tt&&Ke.charCodeAt(we)==Xe.charCodeAt(we);)++we;for(var ot=te(fe),rt=te(Le),ht=Math.min(ot.length-(fe.length==1?we:0),rt.length-(Le.length==1?we:0));Ne<ht&&ot.charCodeAt(ot.length-Ne-1)==rt.charCodeAt(rt.length-Ne-1);)++Ne;if(fe.length==1&&Le.length==1&&j==r.line)for(;we&&we>r.ch&&ot.charCodeAt(ot.length-Ne-1)==rt.charCodeAt(rt.length-Ne-1);)we--,Ne++;fe[fe.length-1]=ot.slice(0,ot.length-Ne).replace(/^\u200b+/,""),fe[0]=fe[0].slice(we).replace(/\u200b+$/,"");var xt=Ve(j,we),gt=Ve(q,Le.length?te(Le).length-Ne:0);if(fe.length>1||fe[0]||Ct(xt,gt))return rn(e.doc,fe,xt,gt,"+input"),!0},zt.prototype.ensurePolled=function(){this.forceCompositionEnd()},zt.prototype.reset=function(){this.forceCompositionEnd()},zt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},zt.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)},zt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Mr(this.cm,function(){return Lr(e.cm)})},zt.prototype.setUneditable=function(e){e.contentEditable="false"},zt.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)},zt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},zt.prototype.onContextMenu=function(){},zt.prototype.resetPosition=function(){},zt.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=ft(e.doc,t.line),n=eo(i,r,t.line),S=et(r,e.doc.direction),j="left";if(S){var X=qe(S,t.ch);j=X%2?"right":"left"}var J=io(n.map,t.ch,j);return J.offset=J.collapse=="right"?J.end:J.start,J}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="",j=!1,X=e.doc.lineSeparator(),J=!1;function q(we){return function(Ne){return Ne.id==we}}function ue(){j&&(S+=X,J&&(S+=X),j=J=!1)}function fe(we){we&&(ue(),S+=we)}function Le(we){if(we.nodeType==1){var Ne=we.getAttribute("cm-text");if(Ne){fe(Ne);return}var Ke=we.getAttribute("cm-marker"),Xe;if(Ke){var tt=e.findMarks(Ve(r,0),Ve(n+1,0),q(+Ke));tt.length&&(Xe=tt[0].find(0))&&fe(Hr(e.doc,Xe.from,Xe.to).join(X));return}if(we.getAttribute("contenteditable")=="false")return;var ot=/^(pre|div|p|li|table|br)$/i.test(we.nodeName);if(!/^br$/i.test(we.nodeName)&&we.textContent.length==0)return;ot&&ue();for(var rt=0;rt<we.childNodes.length;rt++)Le(we.childNodes[rt]);/^(pre|p)$/i.test(we.nodeName)&&(J=!0),ot&&(j=!0)}else we.nodeType==3&&fe(we.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Le(t),t==i);)t=t.nextSibling,J=!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(Ve(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||!E(r,t))return ln(Ve(Dt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var S=e.rest?te(e.rest):e.line;return ln(Ve(Dt(S),S.text.length),n)}var j=t.nodeType==3?t:null,X=t;for(!j&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(j=t.firstChild,i&&(i=j.nodeValue.length));X.parentNode!=r;)X=X.parentNode;var J=e.measure,q=J.maps;function ue(Xe,tt,ot){for(var rt=-1;rt<(q?q.length:0);rt++)for(var ht=rt<0?J.map:q[rt],xt=0;xt<ht.length;xt+=3){var gt=ht[xt+2];if(gt==Xe||gt==tt){var At=Dt(rt<0?e.line:e.rest[rt]),Vt=ht[xt]+ot;return(ot<0||gt!=Xe)&&(Vt=ht[xt+(ot?1:0)]),Ve(At,Vt)}}}var fe=ue(j,X,i);if(fe)return ln(fe,n);for(var Le=X.nextSibling,we=j?j.nodeValue.length-i:0;Le;Le=Le.nextSibling){if(fe=ue(Le,Le.firstChild,0),fe)return ln(Ve(fe.line,fe.ch-we),n);we+=Le.textContent.length}for(var Ne=X.previousSibling,Ke=i;Ne;Ne=Ne.previousSibling){if(fe=ue(Ne,Ne.firstChild,-1),fe)return ln(Ve(fe.line,fe.ch+Ke),n);Ke+=Ne.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ee,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),C&&(n.style.width="0px"),Pe(n,"input",function(){z&&H>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Pe(n,"paste",function(j){if(Ge(r,j)||Ts(j,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(j){if(Ge(r,j))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var X=ws(r);oa({lineWise:!0,text:X.text}),j.type=="cut"?r.setSelections(X.ranges,null,Se):(i.prevInput="",n.value=X.text.join(`
`),V(n))}else return;j.type=="cut"&&(r.state.cutIncoming=+new Date)}Pe(n,"cut",S),Pe(n,"copy",S),Pe(e.scroller,"paste",function(j){if(ui(e,j)||Ge(r,j))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var X=new Event("paste");X.clipboardData=j.clipboardData,n.dispatchEvent(X)}),Pe(e.lineSpace,"selectstart",function(j){ui(e,j)||re(j)}),Pe(n,"compositionstart",function(){var j=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:j,range:r.markText(j,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Pe(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(),j=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+j.top-S.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+j.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&&V(this.textarea),z&&H>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",z&&H>=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||B()!=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||lt(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(z&&H>=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 j=0,X=Math.min(r.length,n.length);j<X&&r.charCodeAt(j)==n.charCodeAt(j);)++j;return Mr(t,function(){za(t,n.slice(j),r.length-j,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(){z&&H>=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),j=r.scroller.scrollTop;if(!S||T)return;var X=i.options.resetSelectionOnContextMenu;X&&i.doc.sel.contains(S)==-1&&or(i,xr)(i.doc,wi(S),Se);var J=n.style.cssText,q=t.wrapper.style.cssText,ue=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-ue.top-5)+"px; left: "+(e.clientX-ue.left-5)+`px;
z-index: 1000; background: `+(z?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var fe;N&&(fe=window.scrollY),r.input.focus(),N&&window.scrollTo(null,fe),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=we,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function Le(){if(n.selectionStart!=null){var Ke=i.somethingSelected(),Xe="\u200B"+(Ke?n.value:"");n.value="\u21DA",n.value=Xe,t.prevInput=Ke?"":"\u200B",n.selectionStart=1,n.selectionEnd=Xe.length,r.selForContextMenu=i.doc.sel}}function we(){if(t.contextMenuPending!=we)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=q,n.style.cssText=J,z&&H<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=j),n.selectionStart!=null){(!z||z&&H<9)&&Le();var Ke=0,Xe=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):Ke++<10?r.detectingSelectAll=setTimeout(Xe,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Xe,200)}}if(z&&H>=9&&Le(),k){pe(e);var Ne=function(){at(window,"mouseup",Ne),setTimeout(we,20)};Pe(window,"mouseup",Ne)}else setTimeout(we,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?_(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=B();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=X.getValue()}var n;if(e.form&&(Pe(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var S=e.form;n=S.submit;try{var j=S.submit=function(){r(),S.submit=n,S.submit(),S.submit=j}}catch(J){}}t.finishInit=function(J){J.save=r,J.getTextArea=function(){return e},J.toTextArea=function(){J.toTextArea=isNaN,r(),e.parentNode.removeChild(J.getWrapperElement()),e.style.display="",e.form&&(at(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var X=Yt(function(J){return e.parentNode.insertBefore(J,e.nextSibling)},t);return X}function nu(e){e.off=at,e.on=Pe,e.wheelEventPixels=dl,e.Doc=kr,e.splitLines=Et,e.countColumn=Y,e.findColumn=Te,e.isWordChar=Re,e.Pass=De,e.signal=Me,e.Line=Pi,e.changeEnd=Ai,e.scrollbarModel=To,e.Pos=Ve,e.cmpPos=Ct,e.modes=jt,e.mimeModes=Lt,e.resolveMode=bt,e.getMode=Nr,e.modeExtensions=hr,e.extendMode=mr,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=Pl,e.StringStream=Bt,e.SharedTextMarker=_n,e.TextMarker=ki,e.LineWidget=On,e.e_preventDefault=re,e.e_stopPropagation=ie,e.e_stop=pe,e.addClass=U,e.contains=E,e.rmClass=f,e.keyNames=Di}$l(Yt),ql(Yt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in kr.prototype)kr.prototype.hasOwnProperty(la)&&ae(au,la)<0&&(Yt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(kr.prototype[la]));return ye(kr),Yt.inputStyles={textarea:Qt,contenteditable:zt},Yt.defineMode=function(e){!Yt.defaults.mode&&e!="null"&&(Yt.defaults.mode=e),pr.apply(this,arguments)},Yt.defineMIME=Kr,Yt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Yt.defineMIME("text/plain","null"),Yt.defineExtension=function(e,t){Yt.prototype[e]=t},Yt.defineDocExtension=function(e,t){kr.prototype[e]=t},Yt.fromTextArea=iu,nu(Yt),Yt.version="5.58.2",Yt})},Y1PL:function(Tt,ut,he){"use strict";he.r(ut),he.d(ut,"ResizableTextArea",function(){return ae});var oe=he("wx14"),$=he("1OyB"),D=he("vuIU"),Z=he("Ji7U"),F=he("LK+K"),M=he("q1tI"),z=he("VTBJ"),H=he("rePB"),N=he("Zm9Q"),R=he("Kwbf"),v=he("c+Xe"),T=he("m+aA"),O=he("bdgK"),L=new Map;function A(Se){Se.forEach(function(Ce){var Ae,Te=Ce.target;(Ae=L.get(Te))===null||Ae===void 0||Ae.forEach(function(ve){return ve(Te)})})}var C=new O.default(A),u=null,o=null;function l(Se,Ce){L.has(Se)||(L.set(Se,new Set),C.observe(Se)),L.get(Se).add(Ce)}function h(Se,Ce){L.has(Se)&&(L.get(Se).delete(Ce),L.get(Se).size||(C.unobserve(Se),L.delete(Se)))}var w=function(Se){Object(Z.a)(Ae,Se);var Ce=Object(F.a)(Ae);function Ae(){return Object($.a)(this,Ae),Ce.apply(this,arguments)}return Object(D.a)(Ae,[{key:"render",value:function(){return this.props.children}}]),Ae}(M.Component),y=M.createContext(null);function g(Se){var Ce=Se.children,Ae=Se.onBatchResize,Te=M.useRef(0),ve=M.useRef([]),le=M.useContext(y),te=M.useCallback(function(de,ne,ke){Te.current+=1;var Oe=Te.current;ve.current.push({size:de,element:ne,data:ke}),Promise.resolve().then(function(){Oe===Te.current&&(Ae==null||Ae(ve.current),ve.current=[])}),le==null||le(de,ne,ke)},[Ae,le]);return M.createElement(y.Provider,{value:te},Ce)}function k(Se){var Ce=Se.children,Ae=Se.disabled,Te=M.useRef(null),ve=M.useRef(null),le=M.useContext(y),te=M.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),de=M.isValidElement(Ce)&&Object(v.c)(Ce),ne=de?Ce.ref:null,ke=M.useMemo(function(){return Object(v.a)(ne,Te)},[ne,Te]),Oe=M.useRef(Se);Oe.current=Se;var Ee=M.useCallback(function(Re){var Be=Oe.current,ze=Be.onResize,Fe=Be.data,Ue=Re.getBoundingClientRect(),Ie=Ue.width,it=Ue.height,Ye=Re.offsetWidth,Qe=Re.offsetHeight,qe=Math.floor(Ie),ct=Math.floor(it);if(te.current.width!==qe||te.current.height!==ct||te.current.offsetWidth!==Ye||te.current.offsetHeight!==Qe){var et={width:qe,height:ct,offsetWidth:Ye,offsetHeight:Qe};te.current=et;var nt=Ye===Math.round(Ie)?Ie:Ye,Pe=Qe===Math.round(it)?it:Qe,dt=Object(z.a)(Object(z.a)({},et),{},{offsetWidth:nt,offsetHeight:Pe});le==null||le(dt,Re,Fe),ze&&Promise.resolve().then(function(){ze(dt,Re)})}},[]);return M.useEffect(function(){var Re=Object(T.a)(Te.current)||Object(T.a)(ve.current);return Re&&!Ae&&l(Re,Ee),function(){return h(Re,Ee)}},[Te.current,Ae]),M.createElement(w,{ref:ve},de?M.cloneElement(Ce,{ref:ke}):Ce)}var x="rc-observer-key";function f(Se){var Ce=Se.children,Ae=Object(N.a)(Ce);return Ae.map(function(Te,ve){var le=(Te==null?void 0:Te.key)||"".concat(x,"-").concat(ve);return M.createElement(k,Object(oe.a)({},Se,{key:le}),Te)})}f.Collection=g;var p=f,d=he("bT9E"),a=he("TSYQ"),b=he.n(a),m=`
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
`,E=["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"],B={},U;function K(Se){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ae=Se.getAttribute("id")||Se.getAttribute("data-reactid")||Se.getAttribute("name");if(Ce&&B[Ae])return B[Ae];var Te=window.getComputedStyle(Se),ve=Te.getPropertyValue("box-sizing")||Te.getPropertyValue("-moz-box-sizing")||Te.getPropertyValue("-webkit-box-sizing"),le=parseFloat(Te.getPropertyValue("padding-bottom"))+parseFloat(Te.getPropertyValue("padding-top")),te=parseFloat(Te.getPropertyValue("border-bottom-width"))+parseFloat(Te.getPropertyValue("border-top-width")),de=E.map(function(ke){return"".concat(ke,":").concat(Te.getPropertyValue(ke))}).join(";"),ne={sizingStyle:de,paddingSize:le,borderSize:te,boxSizing:ve};return Ce&&Ae&&(B[Ae]=ne),ne}function V(Se){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ae=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Te=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;U||(U=document.createElement("textarea"),U.setAttribute("tab-index","-1"),U.setAttribute("aria-hidden","true"),document.body.appendChild(U)),Se.getAttribute("wrap")?U.setAttribute("wrap",Se.getAttribute("wrap")):U.removeAttribute("wrap");var ve=K(Se,Ce),le=ve.paddingSize,te=ve.borderSize,de=ve.boxSizing,ne=ve.sizingStyle;U.setAttribute("style","".concat(ne,";").concat(m)),U.value=Se.value||Se.placeholder||"";var ke=Number.MIN_SAFE_INTEGER,Oe=Number.MAX_SAFE_INTEGER,Ee=U.scrollHeight,Re;if(de==="border-box"?Ee+=te:de==="content-box"&&(Ee-=le),Ae!==null||Te!==null){U.value=" ";var Be=U.scrollHeight-le;Ae!==null&&(ke=Be*Ae,de==="border-box"&&(ke=ke+le+te),Ee=Math.max(ke,Ee)),Te!==null&&(Oe=Be*Te,de==="border-box"&&(Oe=Oe+le+te),Re=Ee>Oe?"":"hidden",Ee=Math.min(Oe,Ee))}return{height:Ee,minHeight:ke,maxHeight:Oe,overflowY:Re,resize:"none"}}var P=he("Gytx"),_=he.n(P),Y;(function(Se){Se[Se.NONE=0]="NONE",Se[Se.RESIZING=1]="RESIZING",Se[Se.RESIZED=2]="RESIZED"})(Y||(Y={}));var ee=function(Se){Object(Z.a)(Ae,Se);var Ce=Object(F.a)(Ae);function Ae(Te){var ve;return Object($.a)(this,Ae),ve=Ce.call(this,Te),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(le){ve.textArea=le},ve.handleResize=function(le){var te=ve.state.resizeStatus,de=ve.props,ne=de.autoSize,ke=de.onResize;if(te!==Y.NONE)return;typeof ke=="function"&&ke(le),ne&&ve.resizeOnNextFrame()},ve.resizeOnNextFrame=function(){cancelAnimationFrame(ve.nextFrameActionId),ve.nextFrameActionId=requestAnimationFrame(ve.resizeTextarea)},ve.resizeTextarea=function(){var le=ve.props.autoSize;if(!le||!ve.textArea)return;var te=le.minRows,de=le.maxRows,ne=V(ve.textArea,!1,te,de);ve.setState({textareaStyles:ne,resizeStatus:Y.RESIZING},function(){cancelAnimationFrame(ve.resizeFrameId),ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:Y.RESIZED},function(){ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:Y.NONE}),ve.fixFirefoxAutoScroll()})})})})},ve.renderTextArea=function(){var le=ve.props,te=le.prefixCls,de=te===void 0?"rc-textarea":te,ne=le.autoSize,ke=le.onResize,Oe=le.className,Ee=le.disabled,Re=ve.state,Be=Re.textareaStyles,ze=Re.resizeStatus,Fe=Object(d.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ue=b()(de,Oe,Object(H.a)({},"".concat(de,"-disabled"),Ee));"value"in Fe&&(Fe.value=Fe.value||"");var Ie=Object(z.a)(Object(z.a)(Object(z.a)({},ve.props.style),Be),ze===Y.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return M.createElement(p,{onResize:ve.handleResize,disabled:!(ne||ke)},M.createElement("textarea",Object(oe.a)({},Fe,{className:Ue,style:Ie,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:Y.NONE},ve}return Object(D.a)(Ae,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!_()(ve.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ve=this.textArea.selectionStart,le=this.textArea.selectionEnd;this.textArea.setSelectionRange(ve,le)}}catch(te){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ae}(M.Component),ae=ee,ce=function(Se){Object(Z.a)(Ae,Se);var Ce=Object(F.a)(Ae);function Ae(Te){var ve;Object($.a)(this,Ae),ve=Ce.call(this,Te),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(te){ve.resizableTextArea=te},ve.handleChange=function(te){var de=ve.props.onChange;ve.setValue(te.target.value,function(){ve.resizableTextArea.resizeTextarea()}),de&&de(te)},ve.handleKeyDown=function(te){var de=ve.props,ne=de.onPressEnter,ke=de.onKeyDown;te.keyCode===13&&ne&&ne(te),ke&&ke(te)};var le=typeof Te.value=="undefined"||Te.value===null?Te.defaultValue:Te.value;return ve.state={value:le},ve}return Object(D.a)(Ae,[{key:"setValue",value:function(ve,le){"value"in this.props||this.setState({value:ve},le)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return M.createElement(ae,Object(oe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ve){return"value"in ve?{value:ve.value}:null}}]),Ae}(M.Component),De=ut.default=ce},ZpRC:function(Tt,ut,he){"use strict";function oe(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function $(v,T){return(!T||v!=="hidden")&&v!=="visible"&&v!=="clip"}function D(v,T){if(v.clientHeight<v.scrollHeight||v.clientWidth<v.scrollWidth){var O=getComputedStyle(v,null);return $(O.overflowY,T)||$(O.overflowX,T)||function(L){var A=function(C){if(!C.ownerDocument||!C.ownerDocument.defaultView)return null;try{return C.ownerDocument.defaultView.frameElement}catch(u){return null}}(L);return!!A&&(A.clientHeight<L.scrollHeight||A.clientWidth<L.scrollWidth)}(v)}return!1}function Z(v,T,O,L,A,C,u,o){return C<v&&u>T||C>v&&u<T?0:C<=v&&o<=O||u>=T&&o>=O?C-v-L:u>T&&o<O||C<v&&o>O?u-T+A:0}var F=function(v,T){var O=window,L=T.scrollMode,A=T.block,C=T.inline,u=T.boundary,o=T.skipOverflowHiddenElements,l=typeof u=="function"?u:function(Be){return Be!==u};if(!oe(v))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,w=[],y=v;oe(y)&&l(y);){if((y=y.parentElement)===h){w.push(y);break}y!=null&&y===document.body&&D(y)&&!D(document.documentElement)||y!=null&&D(y,o)&&w.push(y)}for(var g=O.visualViewport?O.visualViewport.width:innerWidth,k=O.visualViewport?O.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=v.getBoundingClientRect(),d=p.height,a=p.width,b=p.top,m=p.right,E=p.bottom,B=p.left,U=A==="start"||A==="nearest"?b:A==="end"?E:b+d/2,K=C==="center"?B+a/2:C==="end"?m:B,V=[],P=0;P<w.length;P++){var _=w[P],Y=_.getBoundingClientRect(),ee=Y.height,ae=Y.width,ce=Y.top,De=Y.right,Se=Y.bottom,Ce=Y.left;if(L==="if-needed"&&b>=0&&B>=0&&E<=k&&m<=g&&b>=ce&&E<=Se&&B>=Ce&&m<=De)return V;var Ae=getComputedStyle(_),Te=parseInt(Ae.borderLeftWidth,10),ve=parseInt(Ae.borderTopWidth,10),le=parseInt(Ae.borderRightWidth,10),te=parseInt(Ae.borderBottomWidth,10),de=0,ne=0,ke="offsetWidth"in _?_.offsetWidth-_.clientWidth-Te-le:0,Oe="offsetHeight"in _?_.offsetHeight-_.clientHeight-ve-te:0;if(h===_)de=A==="start"?U:A==="end"?U-k:A==="nearest"?Z(f,f+k,k,ve,te,f+U,f+U+d,d):U-k/2,ne=C==="start"?K:C==="center"?K-g/2:C==="end"?K-g:Z(x,x+g,g,Te,le,x+K,x+K+a,a),de=Math.max(0,de+f),ne=Math.max(0,ne+x);else{de=A==="start"?U-ce-ve:A==="end"?U-Se+te+Oe:A==="nearest"?Z(ce,Se,ee,ve,te+Oe,U,U+d,d):U-(ce+ee/2)+Oe/2,ne=C==="start"?K-Ce-Te:C==="center"?K-(Ce+ae/2)+ke/2:C==="end"?K-De+le+ke:Z(Ce,De,ae,Te,le+ke,K,K+a,a);var Ee=_.scrollLeft,Re=_.scrollTop;U+=Re-(de=Math.max(0,Math.min(Re+de,_.scrollHeight-ee+Oe))),K+=Ee-(ne=Math.max(0,Math.min(Ee+ne,_.scrollWidth-ae+ke)))}V.push({el:_,top:de,left:ne})}return V};function M(v){return v===Object(v)&&Object.keys(v).length!==0}function z(v,T){T===void 0&&(T="auto");var O="scrollBehavior"in document.body.style;v.forEach(function(L){var A=L.el,C=L.top,u=L.left;A.scroll&&O?A.scroll({top:C,left:u,behavior:T}):(A.scrollTop=C,A.scrollLeft=u)})}function H(v){return v===!1?{block:"end",inline:"nearest"}:M(v)?v:{block:"start",inline:"nearest"}}function N(v,T){var O=!v.ownerDocument.documentElement.contains(v);if(M(T)&&typeof T.behavior=="function")return T.behavior(O?[]:F(v,T));if(O)return;var L=H(T);return z(F(v,L),L.behavior)}var R=ut.a=N},Zss7:function(Tt,ut,he){var oe;(function($){var D=/^\s+/,Z=/\s+$/,F=0,M=$.round,z=$.min,H=$.max,N=$.random;function R(te,de){if(te=te||"",de=de||{},te instanceof R)return te;if(!(this instanceof R))return new R(te,de);var ne=v(te);this._originalInput=te,this._r=ne.r,this._g=ne.g,this._b=ne.b,this._a=ne.a,this._roundA=M(100*this._a)/100,this._format=de.format||ne.format,this._gradientType=de.gradientType,this._r<1&&(this._r=M(this._r)),this._g<1&&(this._g=M(this._g)),this._b<1&&(this._b=M(this._b)),this._ok=ne.ok,this._tc_id=F++}R.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var te=this.toRgb();return(te.r*299+te.g*587+te.b*114)/1e3},getLuminance:function(){var te=this.toRgb(),de,ne,ke,Oe,Ee,Re;return de=te.r/255,ne=te.g/255,ke=te.b/255,de<=.03928?Oe=de/12.92:Oe=$.pow((de+.055)/1.055,2.4),ne<=.03928?Ee=ne/12.92:Ee=$.pow((ne+.055)/1.055,2.4),ke<=.03928?Re=ke/12.92:Re=$.pow((ke+.055)/1.055,2.4),.2126*Oe+.7152*Ee+.0722*Re},setAlpha:function(te){return this._a=V(te),this._roundA=M(100*this._a)/100,this},toHsv:function(){var te=A(this._r,this._g,this._b);return{h:te.h*360,s:te.s,v:te.v,a:this._a}},toHsvString:function(){var te=A(this._r,this._g,this._b),de=M(te.h*360),ne=M(te.s*100),ke=M(te.v*100);return this._a==1?"hsv("+de+", "+ne+"%, "+ke+"%)":"hsva("+de+", "+ne+"%, "+ke+"%, "+this._roundA+")"},toHsl:function(){var te=O(this._r,this._g,this._b);return{h:te.h*360,s:te.s,l:te.l,a:this._a}},toHslString:function(){var te=O(this._r,this._g,this._b),de=M(te.h*360),ne=M(te.s*100),ke=M(te.l*100);return this._a==1?"hsl("+de+", "+ne+"%, "+ke+"%)":"hsla("+de+", "+ne+"%, "+ke+"%, "+this._roundA+")"},toHex:function(te){return u(this._r,this._g,this._b,te)},toHexString:function(te){return"#"+this.toHex(te)},toHex8:function(te){return o(this._r,this._g,this._b,this._a,te)},toHex8String:function(te){return"#"+this.toHex8(te)},toRgb:function(){return{r:M(this._r),g:M(this._g),b:M(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+M(this._r)+", "+M(this._g)+", "+M(this._b)+")":"rgba("+M(this._r)+", "+M(this._g)+", "+M(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:M(P(this._r,255)*100)+"%",g:M(P(this._g,255)*100)+"%",b:M(P(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+M(P(this._r,255)*100)+"%, "+M(P(this._g,255)*100)+"%, "+M(P(this._b,255)*100)+"%)":"rgba("+M(P(this._r,255)*100)+"%, "+M(P(this._g,255)*100)+"%, "+M(P(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:U[u(this._r,this._g,this._b,!0)]||!1},toFilter:function(te){var de="#"+l(this._r,this._g,this._b,this._a),ne=de,ke=this._gradientType?"GradientType = 1, ":"";if(te){var Oe=R(te);ne="#"+l(Oe._r,Oe._g,Oe._b,Oe._a)}return"progid:DXImageTransform.Microsoft.gradient("+ke+"startColorstr="+de+",endColorstr="+ne+")"},toString:function(te){var de=!!te;te=te||this._format;var ne=!1,ke=this._a<1&&this._a>=0,Oe=!de&&ke&&(te==="hex"||te==="hex6"||te==="hex3"||te==="hex4"||te==="hex8"||te==="name");return Oe?te==="name"&&this._a===0?this.toName():this.toRgbString():(te==="rgb"&&(ne=this.toRgbString()),te==="prgb"&&(ne=this.toPercentageRgbString()),(te==="hex"||te==="hex6")&&(ne=this.toHexString()),te==="hex3"&&(ne=this.toHexString(!0)),te==="hex4"&&(ne=this.toHex8String(!0)),te==="hex8"&&(ne=this.toHex8String()),te==="name"&&(ne=this.toName()),te==="hsl"&&(ne=this.toHslString()),te==="hsv"&&(ne=this.toHsvString()),ne||this.toHexString())},clone:function(){return R(this.toString())},_applyModification:function(te,de){var ne=te.apply(null,[this].concat([].slice.call(de)));return this._r=ne._r,this._g=ne._g,this._b=ne._b,this.setAlpha(ne._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(k,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(w,arguments)},greyscale:function(){return this._applyModification(y,arguments)},spin:function(){return this._applyModification(f,arguments)},_applyCombination:function(te,de){return te.apply(null,[this].concat([].slice.call(de)))},analogous:function(){return this._applyCombination(m,arguments)},complement:function(){return this._applyCombination(p,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(b,arguments)},triad:function(){return this._applyCombination(d,arguments)},tetrad:function(){return this._applyCombination(a,arguments)}},R.fromRatio=function(te,de){if(typeof te=="object"){var ne={};for(var ke in te)te.hasOwnProperty(ke)&&(ke==="a"?ne[ke]=te[ke]:ne[ke]=De(te[ke]));te=ne}return R(te,de)};function v(te){var de={r:0,g:0,b:0},ne=1,ke=null,Oe=null,Ee=null,Re=!1,Be=!1;return typeof te=="string"&&(te=ve(te)),typeof te=="object"&&(Te(te.r)&&Te(te.g)&&Te(te.b)?(de=T(te.r,te.g,te.b),Re=!0,Be=String(te.r).substr(-1)==="%"?"prgb":"rgb"):Te(te.h)&&Te(te.s)&&Te(te.v)?(ke=De(te.s),Oe=De(te.v),de=C(te.h,ke,Oe),Re=!0,Be="hsv"):Te(te.h)&&Te(te.s)&&Te(te.l)&&(ke=De(te.s),Ee=De(te.l),de=L(te.h,ke,Ee),Re=!0,Be="hsl"),te.hasOwnProperty("a")&&(ne=te.a)),ne=V(ne),{ok:Re,format:te.format||Be,r:z(255,H(de.r,0)),g:z(255,H(de.g,0)),b:z(255,H(de.b,0)),a:ne}}function T(te,de,ne){return{r:P(te,255)*255,g:P(de,255)*255,b:P(ne,255)*255}}function O(te,de,ne){te=P(te,255),de=P(de,255),ne=P(ne,255);var ke=H(te,de,ne),Oe=z(te,de,ne),Ee,Re,Be=(ke+Oe)/2;if(ke==Oe)Ee=Re=0;else{var ze=ke-Oe;Re=Be>.5?ze/(2-ke-Oe):ze/(ke+Oe);switch(ke){case te:Ee=(de-ne)/ze+(de<ne?6:0);break;case de:Ee=(ne-te)/ze+2;break;case ne:Ee=(te-de)/ze+4;break}Ee/=6}return{h:Ee,s:Re,l:Be}}function L(te,de,ne){var ke,Oe,Ee;te=P(te,360),de=P(de,100),ne=P(ne,100);function Re(Fe,Ue,Ie){return Ie<0&&(Ie+=1),Ie>1&&(Ie-=1),Ie<1/6?Fe+(Ue-Fe)*6*Ie:Ie<1/2?Ue:Ie<2/3?Fe+(Ue-Fe)*(2/3-Ie)*6:Fe}if(de===0)ke=Oe=Ee=ne;else{var Be=ne<.5?ne*(1+de):ne+de-ne*de,ze=2*ne-Be;ke=Re(ze,Be,te+1/3),Oe=Re(ze,Be,te),Ee=Re(ze,Be,te-1/3)}return{r:ke*255,g:Oe*255,b:Ee*255}}function A(te,de,ne){te=P(te,255),de=P(de,255),ne=P(ne,255);var ke=H(te,de,ne),Oe=z(te,de,ne),Ee,Re,Be=ke,ze=ke-Oe;if(Re=ke===0?0:ze/ke,ke==Oe)Ee=0;else{switch(ke){case te:Ee=(de-ne)/ze+(de<ne?6:0);break;case de:Ee=(ne-te)/ze+2;break;case ne:Ee=(te-de)/ze+4;break}Ee/=6}return{h:Ee,s:Re,v:Be}}function C(te,de,ne){te=P(te,360)*6,de=P(de,100),ne=P(ne,100);var ke=$.floor(te),Oe=te-ke,Ee=ne*(1-de),Re=ne*(1-Oe*de),Be=ne*(1-(1-Oe)*de),ze=ke%6,Fe=[ne,Re,Ee,Ee,Be,ne][ze],Ue=[Be,ne,ne,Re,Ee,Ee][ze],Ie=[Ee,Ee,Be,ne,ne,Re][ze];return{r:Fe*255,g:Ue*255,b:Ie*255}}function u(te,de,ne,ke){var Oe=[ce(M(te).toString(16)),ce(M(de).toString(16)),ce(M(ne).toString(16))];return ke&&Oe[0].charAt(0)==Oe[0].charAt(1)&&Oe[1].charAt(0)==Oe[1].charAt(1)&&Oe[2].charAt(0)==Oe[2].charAt(1)?Oe[0].charAt(0)+Oe[1].charAt(0)+Oe[2].charAt(0):Oe.join("")}function o(te,de,ne,ke,Oe){var Ee=[ce(M(te).toString(16)),ce(M(de).toString(16)),ce(M(ne).toString(16)),ce(Se(ke))];return Oe&&Ee[0].charAt(0)==Ee[0].charAt(1)&&Ee[1].charAt(0)==Ee[1].charAt(1)&&Ee[2].charAt(0)==Ee[2].charAt(1)&&Ee[3].charAt(0)==Ee[3].charAt(1)?Ee[0].charAt(0)+Ee[1].charAt(0)+Ee[2].charAt(0)+Ee[3].charAt(0):Ee.join("")}function l(te,de,ne,ke){var Oe=[ce(Se(ke)),ce(M(te).toString(16)),ce(M(de).toString(16)),ce(M(ne).toString(16))];return Oe.join("")}R.equals=function(te,de){return!te||!de?!1:R(te).toRgbString()==R(de).toRgbString()},R.random=function(){return R.fromRatio({r:N(),g:N(),b:N()})};function h(te,de){de=de===0?0:de||10;var ne=R(te).toHsl();return ne.s-=de/100,ne.s=_(ne.s),R(ne)}function w(te,de){de=de===0?0:de||10;var ne=R(te).toHsl();return ne.s+=de/100,ne.s=_(ne.s),R(ne)}function y(te){return R(te).desaturate(100)}function g(te,de){de=de===0?0:de||10;var ne=R(te).toHsl();return ne.l+=de/100,ne.l=_(ne.l),R(ne)}function k(te,de){de=de===0?0:de||10;var ne=R(te).toRgb();return ne.r=H(0,z(255,ne.r-M(255*-(de/100)))),ne.g=H(0,z(255,ne.g-M(255*-(de/100)))),ne.b=H(0,z(255,ne.b-M(255*-(de/100)))),R(ne)}function x(te,de){de=de===0?0:de||10;var ne=R(te).toHsl();return ne.l-=de/100,ne.l=_(ne.l),R(ne)}function f(te,de){var ne=R(te).toHsl(),ke=(ne.h+de)%360;return ne.h=ke<0?360+ke:ke,R(ne)}function p(te){var de=R(te).toHsl();return de.h=(de.h+180)%360,R(de)}function d(te){var de=R(te).toHsl(),ne=de.h;return[R(te),R({h:(ne+120)%360,s:de.s,l:de.l}),R({h:(ne+240)%360,s:de.s,l:de.l})]}function a(te){var de=R(te).toHsl(),ne=de.h;return[R(te),R({h:(ne+90)%360,s:de.s,l:de.l}),R({h:(ne+180)%360,s:de.s,l:de.l}),R({h:(ne+270)%360,s:de.s,l:de.l})]}function b(te){var de=R(te).toHsl(),ne=de.h;return[R(te),R({h:(ne+72)%360,s:de.s,l:de.l}),R({h:(ne+216)%360,s:de.s,l:de.l})]}function m(te,de,ne){de=de||6,ne=ne||30;var ke=R(te).toHsl(),Oe=360/ne,Ee=[R(te)];for(ke.h=(ke.h-(Oe*de>>1)+720)%360;--de;)ke.h=(ke.h+Oe)%360,Ee.push(R(ke));return Ee}function E(te,de){de=de||6;for(var ne=R(te).toHsv(),ke=ne.h,Oe=ne.s,Ee=ne.v,Re=[],Be=1/de;de--;)Re.push(R({h:ke,s:Oe,v:Ee})),Ee=(Ee+Be)%1;return Re}R.mix=function(te,de,ne){ne=ne===0?0:ne||50;var ke=R(te).toRgb(),Oe=R(de).toRgb(),Ee=ne/100,Re={r:(Oe.r-ke.r)*Ee+ke.r,g:(Oe.g-ke.g)*Ee+ke.g,b:(Oe.b-ke.b)*Ee+ke.b,a:(Oe.a-ke.a)*Ee+ke.a};return R(Re)},R.readability=function(te,de){var ne=R(te),ke=R(de);return($.max(ne.getLuminance(),ke.getLuminance())+.05)/($.min(ne.getLuminance(),ke.getLuminance())+.05)},R.isReadable=function(te,de,ne){var ke=R.readability(te,de),Oe,Ee;Ee=!1,Oe=le(ne);switch(Oe.level+Oe.size){case"AAsmall":case"AAAlarge":Ee=ke>=4.5;break;case"AAlarge":Ee=ke>=3;break;case"AAAsmall":Ee=ke>=7;break}return Ee},R.mostReadable=function(te,de,ne){var ke=null,Oe=0,Ee,Re,Be,ze;ne=ne||{},Re=ne.includeFallbackColors,Be=ne.level,ze=ne.size;for(var Fe=0;Fe<de.length;Fe++)Ee=R.readability(te,de[Fe]),Ee>Oe&&(Oe=Ee,ke=R(de[Fe]));return R.isReadable(te,ke,{level:Be,size:ze})||!Re?ke:(ne.includeFallbackColors=!1,R.mostReadable(te,["#fff","#000"],ne))};var B=R.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},U=R.hexNames=K(B);function K(te){var de={};for(var ne in te)te.hasOwnProperty(ne)&&(de[te[ne]]=ne);return de}function V(te){return te=parseFloat(te),(isNaN(te)||te<0||te>1)&&(te=1),te}function P(te,de){ee(te)&&(te="100%");var ne=ae(te);return te=z(de,H(0,parseFloat(te))),ne&&(te=parseInt(te*de,10)/100),$.abs(te-de)<1e-6?1:te%de/parseFloat(de)}function _(te){return z(1,H(0,te))}function Y(te){return parseInt(te,16)}function ee(te){return typeof te=="string"&&te.indexOf(".")!=-1&&parseFloat(te)===1}function ae(te){return typeof te=="string"&&te.indexOf("%")!=-1}function ce(te){return te.length==1?"0"+te:""+te}function De(te){return te<=1&&(te=te*100+"%"),te}function Se(te){return $.round(parseFloat(te)*255).toString(16)}function Ce(te){return Y(te)/255}var Ae=function(){var te="[-\\+]?\\d+%?",de="[-\\+]?\\d*\\.\\d+%?",ne="(?:"+de+")|(?:"+te+")",ke="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?",Oe="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?";return{CSS_UNIT:new RegExp(ne),rgb:new RegExp("rgb"+ke),rgba:new RegExp("rgba"+Oe),hsl:new RegExp("hsl"+ke),hsla:new RegExp("hsla"+Oe),hsv:new RegExp("hsv"+ke),hsva:new RegExp("hsva"+Oe),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Te(te){return!!Ae.CSS_UNIT.exec(te)}function ve(te){te=te.replace(D,"").replace(Z,"").toLowerCase();var de=!1;if(B[te])te=B[te],de=!0;else if(te=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var ne;return(ne=Ae.rgb.exec(te))?{r:ne[1],g:ne[2],b:ne[3]}:(ne=Ae.rgba.exec(te))?{r:ne[1],g:ne[2],b:ne[3],a:ne[4]}:(ne=Ae.hsl.exec(te))?{h:ne[1],s:ne[2],l:ne[3]}:(ne=Ae.hsla.exec(te))?{h:ne[1],s:ne[2],l:ne[3],a:ne[4]}:(ne=Ae.hsv.exec(te))?{h:ne[1],s:ne[2],v:ne[3]}:(ne=Ae.hsva.exec(te))?{h:ne[1],s:ne[2],v:ne[3],a:ne[4]}:(ne=Ae.hex8.exec(te))?{r:Y(ne[1]),g:Y(ne[2]),b:Y(ne[3]),a:Ce(ne[4]),format:de?"name":"hex8"}:(ne=Ae.hex6.exec(te))?{r:Y(ne[1]),g:Y(ne[2]),b:Y(ne[3]),format:de?"name":"hex"}:(ne=Ae.hex4.exec(te))?{r:Y(ne[1]+""+ne[1]),g:Y(ne[2]+""+ne[2]),b:Y(ne[3]+""+ne[3]),a:Ce(ne[4]+""+ne[4]),format:de?"name":"hex8"}:(ne=Ae.hex3.exec(te))?{r:Y(ne[1]+""+ne[1]),g:Y(ne[2]+""+ne[2]),b:Y(ne[3]+""+ne[3]),format:de?"name":"hex"}:!1}function le(te){var de,ne;return te=te||{level:"AA",size:"small"},de=(te.level||"AA").toUpperCase(),ne=(te.size||"small").toLowerCase(),de!=="AA"&&de!=="AAA"&&(de="AA"),ne!=="small"&&ne!=="large"&&(ne="small"),{level:de,size:ne}}Tt.exports?Tt.exports=R:!(oe=function(){return R}.call(ut,he,ut,Tt),oe!==void 0&&(Tt.exports=oe))})(Math)},bT9E:function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return $});var oe=he("VTBJ");function $(D,Z){var F=Object(oe.a)({},D);return Array.isArray(Z)&&Z.forEach(function(M){delete F[M]}),F}},c5Ni:function(Tt,ut,he){},dejd:function(Tt,ut,he){},dmUQ:function(Tt,ut,he){"use strict";var oe=he("Ff2n"),$=he("rePB"),D=he("1OyB"),Z=he("vuIU"),F=he("Ji7U"),M=he("md7G"),z=he("foSv"),H=he("q1tI"),N=he.n(H),R=he("TSYQ"),v=he.n(R),T=he("4IlW");function O(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(d);a&&(m=m.filter(function(E){return Object.getOwnPropertyDescriptor(d,E).enumerable})),b.push.apply(b,m)}return b}function L(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?O(Object(b),!0).forEach(function(m){Object($.a)(d,m,b[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):O(Object(b)).forEach(function(m){Object.defineProperty(d,m,Object.getOwnPropertyDescriptor(b,m))})}return d}function A(d){var a=C();return function(){var m=Object(z.a)(d),E;if(a){var B=Object(z.a)(this).constructor;E=Reflect.construct(m,arguments,B)}else E=m.apply(this,arguments);return Object(M.a)(this,E)}}function C(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(d){return!1}}function u(){}function o(d){d.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},h=200,w=600,y=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,g=function(a){return a!=null},k=function(a,b){return b===a||typeof b=="number"&&typeof a=="number"&&isNaN(b)&&isNaN(a)},x=function(d){Object(F.a)(b,d);var a=A(b);function b(m){var E;Object(D.a)(this,b),E=a.call(this,m),E.onKeyDown=function(K){var V=E.props,P=V.onKeyDown,_=V.onPressEnter;if(K.keyCode===T.a.UP){var Y=E.getRatio(K);E.up(K,Y,null),E.stop()}else if(K.keyCode===T.a.DOWN){var ee=E.getRatio(K);E.down(K,ee,null),E.stop()}else K.keyCode===T.a.ENTER&&_&&_(K);if(E.recordCursorPosition(),E.lastKeyCode=K.keyCode,P){for(var ae=arguments.length,ce=new Array(ae>1?ae-1:0),De=1;De<ae;De++)ce[De-1]=arguments[De];P.apply(void 0,[K].concat(ce))}},E.onKeyUp=function(K){var V=E.props.onKeyUp;if(E.stop(),E.recordCursorPosition(),V){for(var P=arguments.length,_=new Array(P>1?P-1:0),Y=1;Y<P;Y++)_[Y-1]=arguments[Y];V.apply(void 0,[K].concat(_))}},E.onChange=function(K){var V=E.props.onChange;E.state.focused&&(E.inputting=!0),E.rawInput=E.props.parser(E.getValueFromEvent(K)),E.setState({inputValue:E.rawInput}),V(E.toNumber(E.rawInput))},E.onMouseUp=function(){var K=E.props.onMouseUp;E.recordCursorPosition(),K&&K.apply(void 0,arguments)},E.onFocus=function(){var K;E.setState({focused:!0}),(K=E.props).onFocus.apply(K,arguments)},E.onBlur=function(){var K=E.props.onBlur;E.inputting=!1,E.setState({focused:!1});var V=E.getCurrentValidValue(E.state.inputValue),P=E.setValue(V,u);if(K){var _=E.input.value,Y=E.getInputDisplayValue({focus:!1,value:P});E.input.value=Y&&Number(Y),K.apply(void 0,arguments),E.input.value=_}},E.getRatio=function(K){var V=1;return K.metaKey||K.ctrlKey?V=.1:K.shiftKey&&(V=10),V},E.getFullNum=function(K){return isNaN(K)?K:/e/i.test(String(K))?Number(K).toFixed(18).replace(/\.?0+$/,""):K},E.getPrecision=function(K){if(g(E.props.precision))return E.props.precision;var V=String(K);if(V.indexOf("e-")>=0)return parseInt(V.slice(V.indexOf("e-")+2),10);var P=0;return V.indexOf(".")>=0&&(P=V.length-V.indexOf(".")-1),P},E.getInputDisplayValue=function(K){var V=K||E.state,P=V.focused,_=V.inputValue,Y=V.value,ee;P?ee=_:ee=E.toPrecisionAsStep(Y),ee==null&&(ee="");var ae=E.formatWrapper(ee);return g(E.props.decimalSeparator)&&(ae=ae.toString().replace(".",E.props.decimalSeparator)),ae},E.recordCursorPosition=function(){try{E.cursorStart=E.input.selectionStart,E.cursorEnd=E.input.selectionEnd,E.currentValue=E.input.value,E.cursorBefore=E.input.value.substring(0,E.cursorStart),E.cursorAfter=E.input.value.substring(E.cursorEnd)}catch(K){}},E.restoreByAfter=function(K){if(K===void 0)return!1;var V=E.input.value,P=V.lastIndexOf(K);if(P===-1)return!1;var _=E.cursorBefore.length;return E.lastKeyCode===T.a.DELETE&&E.cursorBefore.charAt(_-1)===K[0]?(E.fixCaret(_,_),!0):P+K.length===V.length?(E.fixCaret(P,P),!0):!1},E.partRestoreByAfter=function(K){return K===void 0?!1:Array.prototype.some.call(K,function(V,P){var _=K.substring(P);return E.restoreByAfter(_)})},E.isNotCompleteNumber=function(K){return isNaN(K)||K===""||K===null||K&&K.toString().indexOf(".")===K.toString().length-1},E.stop=function(){E.autoStepTimer&&clearTimeout(E.autoStepTimer)},E.down=function(K,V,P){E.pressingUpOrDown=!0,E.step("down",K,V,P)},E.up=function(K,V,P){E.pressingUpOrDown=!0,E.step("up",K,V,P)},E.saveInput=function(K){E.input=K};var B=m.value;B===void 0&&(B=m.defaultValue),E.state={focused:m.autoFocus};var U=E.getValidValue(E.toNumber(B));return E.state=L(L({},E.state),{},{inputValue:E.toPrecisionAsStep(U),value:U}),E}return Object(Z.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(E){var B=this.props,U=B.value,K=B.onChange,V=B.max,P=B.min,_=this.state.focused;if(E){if(!k(E.value,U)||!k(E.max,V)||!k(E.min,P)){var Y=_?U:this.getValidValue(U),ee;this.pressingUpOrDown?ee=Y:this.inputting?ee=this.rawInput:ee=this.toPrecisionAsStep(Y),this.setState({value:Y,inputValue:ee})}var ae="value"in this.props?U:this.state.value;"max"in this.props&&E.max!==V&&typeof ae=="number"&&ae>V&&K&&K(V),"min"in this.props&&E.min!==P&&typeof ae=="number"&&ae<P&&K&&K(P)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ce=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===T.a.BACKSPACE?ce=this.cursorStart-1:this.lastKeyCode===T.a.DELETE&&(ce=this.cursorStart):ce=this.input.value.length,this.fixCaret(ce,ce)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case T.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case T.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(De){}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(E){var B=E;return B===""?B="":this.isNotCompleteNumber(parseFloat(B))?B=this.state.value:B=this.getValidValue(B),this.toNumber(B)}},{key:"getValueFromEvent",value:function(E){var B=E.target.value.trim().replace(/。/g,".");return g(this.props.decimalSeparator)&&(B=B.replace(this.props.decimalSeparator,".")),B}},{key:"getValidValue",value:function(E){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,K=parseFloat(E);return isNaN(K)?E:(K<B&&(K=B),K>U&&(K=U),K)}},{key:"setValue",value:function(E,B){var U=this.props.precision,K=this.isNotCompleteNumber(parseFloat(E))?null:parseFloat(E),V=this.state.value,P=V===void 0?null:V,_=this.state.inputValue,Y=_===void 0?null:_,ee=typeof K=="number"?K.toFixed(U):"".concat(K),ae=K!==P||ee!=="".concat(Y);return"value"in this.props?(Y=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:Y},B)):this.setState({value:K,inputValue:this.toPrecisionAsStep(E)},B),ae&&this.props.onChange(K),K}},{key:"getMaxPrecision",value:function(E){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.props,K=U.precision,V=U.step;if(g(K))return K;var P=this.getPrecision(B),_=this.getPrecision(V),Y=this.getPrecision(E);return E?Math.max(Y,P+_):P+_}},{key:"getPrecisionFactor",value:function(E){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.getMaxPrecision(E,B);return Math.pow(10,U)}},{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(E){return this.props.formatter?this.props.formatter(E):E}},{key:"toPrecisionAsStep",value:function(E){if(this.isNotCompleteNumber(E)||E==="")return E;var B=Math.abs(this.getMaxPrecision(E));return isNaN(B)?E.toString():Number(E).toFixed(B)}},{key:"toNumber",value:function(E){var B=this.props.precision,U=this.state.focused,K=E&&E.length>16&&U;return this.isNotCompleteNumber(E)||K?E:g(B)?Math.round(E*Math.pow(10,B))/Math.pow(10,B):Number(E)}},{key:"upStep",value:function(E,B){var U=this.props.step,K=this.getPrecisionFactor(E,B),V=Math.abs(this.getMaxPrecision(E,B)),P=((K*E+K*U*B)/K).toFixed(V);return this.toNumber(P)}},{key:"downStep",value:function(E,B){var U=this.props.step,K=this.getPrecisionFactor(E,B),V=Math.abs(this.getMaxPrecision(E,B)),P=((K*E-K*U*B)/K).toFixed(V);return this.toNumber(P)}},{key:"step",value:function(E,B){var U=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,V=arguments.length>3?arguments[3]:void 0;this.stop(),B&&(B.persist(),B.preventDefault());var P=this.props;if(P.disabled)return;var _=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(_))return;var Y=this["".concat(E,"Step")](_,K),ee=Y>P.max||Y<P.min;if(Y>P.max?Y=P.max:Y<P.min&&(Y=P.min),this.setValue(Y,null),this.setState({focused:!0},function(){U.pressingUpOrDown=!1}),ee)return;this.autoStepTimer=setTimeout(function(){U[E](B,K,!0)},V?h:w)}},{key:"fixCaret",value:function(E,B){if(E===void 0||B===void 0||!this.input||!this.input.value)return;try{var U=this.input.selectionStart,K=this.input.selectionEnd;(E!==U||B!==K)&&this.input.setSelectionRange(E,B)}catch(V){}}},{key:"render",value:function(){var E,B=this.props,U=B.prefixCls,K=B.disabled,V=B.readOnly,P=B.useTouch,_=B.autoComplete,Y=B.upHandler,ee=B.downHandler,ae=B.className,ce=B.max,De=B.min,Se=B.style,Ce=B.title,Ae=B.onMouseEnter,Te=B.onMouseLeave,ve=B.onMouseOver,le=B.onMouseOut,te=B.required,de=B.onClick,ne=B.tabIndex,ke=B.type,Oe=B.placeholder,Ee=B.id,Re=B.inputMode,Be=B.pattern,ze=B.step,Fe=B.maxLength,Ue=B.autoFocus,Ie=B.name,it=B.onPaste,Ye=B.onInput,Qe=Object(oe.a)(B,["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"]),qe=this.state,ct=qe.value,et=qe.focused,nt=v()(U,(E={},Object($.a)(E,ae,!!ae),Object($.a)(E,"".concat(U,"-disabled"),K),Object($.a)(E,"".concat(U,"-focused"),et),E)),Pe={};Object.keys(Qe).forEach(function(pe){(pe.substr(0,5)==="data-"||pe.substr(0,5)==="aria-"||pe==="role")&&(Pe[pe]=Qe[pe])});var dt=!V&&!K,at=this.getInputDisplayValue(null),Me=(ct||ct===0)&&(isNaN(ct)||Number(ct)>=ce),Ge=(ct||ct===0)&&(isNaN(ct)||Number(ct)<=De),xe=Me||K||V,me=Ge||K||V,ye=v()("".concat(U,"-handler"),"".concat(U,"-handler-up"),Object($.a)({},"".concat(U,"-handler-up-disabled"),xe)),re=v()("".concat(U,"-handler"),"".concat(U,"-handler-down"),Object($.a)({},"".concat(U,"-handler-down-disabled"),me)),ie=P?{onTouchStart:xe?u:this.up,onTouchEnd:this.stop}:{onMouseDown:xe?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=P?{onTouchStart:me?u:this.down,onTouchEnd:this.stop}:{onMouseDown:me?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return N.a.createElement("div",{className:nt,style:Se,title:Ce,onMouseEnter:Ae,onMouseLeave:Te,onMouseOver:ve,onMouseOut:le,onFocus:function(){return null},onBlur:function(){return null}},N.a.createElement("div",{className:"".concat(U,"-handler-wrap")},N.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Increase Value","aria-disabled":xe,className:ye}),Y||N.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-up-inner"),onClick:o})),N.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":me,className:re}),ee||N.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-down-inner"),onClick:o}))),N.a.createElement("div",{className:"".concat(U,"-input-wrap")},N.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":ce,"aria-valuenow":ct,required:te,type:ke,placeholder:Oe,onPaste:it,onClick:de,onMouseUp:this.onMouseUp,className:"".concat(U,"-input"),tabIndex:ne,autoComplete:_,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:dt?this.onKeyDown:u,onKeyUp:dt?this.onKeyUp:u,autoFocus:Ue,maxLength:Fe,readOnly:V,disabled:K,max:ce,min:De,step:ze,name:Ie,title:Ce,id:Ee,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(at),pattern:Be,inputMode:Re,onInput:Ye},Pe))))}}]),b}(N.a.Component);x.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:y,min:-y,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var f=x,p=ut.a=f},gkVt:function(Tt,ut,he){"use strict";he.r(ut);var oe=he("DZo9"),$=he("8z0m"),D=he("+L6B"),Z=he("2/Rp"),F=he("miYZ"),M=he("tsqr"),z=he("9og8"),H=he("tJVT"),N=he("WmNS"),R=he.n(N),v=he("q1tI"),T=he.n(v),O=he("5NDa"),L=he("5rEg"),A=he("Ot1p"),C=he("ErOA");function u(d){var a=d.setIscreate,b=d.init,m=d.UpdateItem,E=Object(v.useState)(""),B=Object(H.a)(E,2),U=B[0],K=B[1],V=Object(v.useState)(""),P=Object(H.a)(V,2),_=P[0],Y=P[1];Object(v.useEffect)(function(){if(!m)return;K(m&&m.name),Y(m&&m.description)},[m]);function ee(){return ae.apply(this,arguments)}function ae(){return ae=Object(z.a)(R.a.mark(function Se(){var Ce;return R.a.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:if(U){Te.next=3;break}return M.b.info("\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A"),Te.abrupt("return");case 3:if(_){Te.next=6;break}return M.b.info("\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A"),Te.abrupt("return");case 6:if(!m){Te.next=9;break}return ce(),Te.abrupt("return");case 9:return Te.next=11,Object(C.a)("/api/hpc_courses.json",{method:"post",body:{name:U,description:_,container_type:window.location.pathname.split("/")[1]}});case 11:Ce=Te.sent,Ce&&(M.b.info("\u521B\u5EFA\u6210\u529F"),a(!1),b("add"));case 13:case"end":return Te.stop()}},Se)})),ae.apply(this,arguments)}function ce(){return De.apply(this,arguments)}function De(){return De=Object(z.a)(R.a.mark(function Se(){var Ce;return R.a.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Te.next=2,Object(C.a)("/api/hpc_courses/".concat(m.id,".json"),{method:"put",body:{name:U,description:_,container_type:window.location.pathname.split("/")[1]}});case 2:Ce=Te.sent,Ce&&(M.b.info("\u7F16\u8F91\u6210\u529F"),a(!1),b(""));case 4:case"end":return Te.stop()}},Se)})),De.apply(this,arguments)}return T.a.createElement("div",null,T.a.createElement(L.a,{style:{marginBottom:"20px"},placeholder:"\u8BF7\u8F93\u5165\u6807\u9898",value:U,maxLength:60,addonAfter:String(U.length)+"/60",onChange:function(Ce){return K(Ce.target.value)}}),T.a.createElement(A.a,{id:"courseContentMD",defaultValue:_,onChange:function(Ce){return Y(Ce)}}),T.a.createElement("div",{className:"clearfix mt30 mb30"},T.a.createElement(Z.a,{type:"primary",onClick:function(){return ee()},className:"defalutSubmitbtn fl mr20"},"\u63D0\u4EA4"),T.a.createElement("a",{className:"defalutCancelbtn fl",onClick:function(){return a(!1)}},"\u53D6\u6D88")))}var o=u,l=he("9Bee");function h(d){var a=d.CourseItem,b=d.userId,m=d.init,E=d.ItemUpdate,B=d.setSee,U=d.UserInfo;function K(){return V.apply(this,arguments)}function V(){return V=Object(z.a)(R.a.mark(function _(){var Y;return R.a.wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:return ae.next=2,Object(C.a)("/api/hpc_courses/".concat(a.id,".json"),{method:"delete"});case 2:Y=ae.sent,Y&&(M.b.info("\u5220\u9664\u6210\u529F"),m("delete"),B(!1));case 4:case"end":return ae.stop()}},_)})),V.apply(this,arguments)}function P(){E(a)}return T.a.createElement("div",null,b===299635||b===301458||U!=null&&U.admin||U!=null&&U.business?T.a.createElement("div",{style:{textAlign:"right"}},T.a.createElement(Z.a,{onClick:function(){return P()}},"\u7F16\u8F91"),T.a.createElement(Z.a,{onClick:function(){return K()},style:{marginLeft:"30px"}},"\u5220\u9664")):null,T.a.createElement("h1",null,a==null?void 0:a.name),T.a.createElement(l.a,{value:a==null?void 0:a.description}))}var w=h,y=he("9ivq"),g=he("m3rI"),k=he("Ty5D"),x=he("9kvl");function f(d){var a,b,m,E,B,U,K,V,P,_=d.user,Y=d.dispatch,ee=Object(v.useState)(1),ae=Object(H.a)(ee,2),ce=ae[0],De=ae[1],Se=Object(v.useState)(100),Ce=Object(H.a)(Se,2),Ae=Ce[0],Te=Ce[1],ve=Object(v.useState)([]),le=Object(H.a)(ve,2),te=le[0],de=le[1],ne=Object(v.useState)(!1),ke=Object(H.a)(ne,2),Oe=ke[0],Ee=ke[1],Re=Object(v.useState)(!1),Be=Object(H.a)(Re,2),ze=Be[0],Fe=Be[1],Ue=Object(v.useState)(""),Ie=Object(H.a)(Ue,2),it=Ie[0],Ye=Ie[1],Qe=Object(v.useState)(""),qe=Object(H.a)(Qe,2),ct=qe[0],et=qe[1],nt=Object(v.useState)(""),Pe=Object(H.a)(nt,2),dt=Pe[0],at=Pe[1],Me=Object(k.i)(),Ge=Me.itemname,xe=Object(v.useState)(""),me=Object(H.a)(xe,2),ye=me[0],re=me[1];Object(v.useEffect)(function(){Y({type:"globalSetting/headerToggle",payload:!1}),ce&&ie("")},[ce]);function ie($e){return se.apply(this,arguments)}function se(){return se=Object(z.a)(R.a.mark(function $e(st){var Ze,St,Et,lt,Pt;return R.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:return Mt.next=2,Object(C.a)("/api/hpc_courses.json",{method:"get",params:{page:ce,per_page:Ae,container_type:window.location.pathname.split("/")[1]}});case 2:if(Ze=Mt.sent,!Ze){Mt.next=24;break}if(St=Ze.data.hpc_courses.length,de(Ze.data.hpc_courses),at(Ze.data.file_url),et(""),St){Mt.next=10;break}return Mt.abrupt("return");case 10:if(ye){Mt.next=14;break}Ge?(Pt=0,Ze==null||((Et=Ze.data)===null||Et===void 0||((lt=Et.hpc_courses)===null||lt===void 0))||lt.map(function(jt,Lt){var pr;(Ge==null?void 0:Ge.toLocaleLowerCase())===(jt==null||((pr=jt.name)===null||pr===void 0)?void 0:pr.toLocaleLowerCase())&&(Pt=Lt)}),Ye(Ze.data.hpc_courses[Pt]),Fe(!0),re(Ze.data.hpc_courses[Pt].id),(Ge==null?void 0:Ge.toLocaleLowerCase())==="resources"&&(Ye(Ze.data.hpc_courses.filter(function(jt){return jt.id===15})[0]),Fe(!0),re(15))):(Ye(Ze.data.hpc_courses[0]),Fe(!0),re(Ze.data.hpc_courses[0].id)),Mt.next=24;break;case 14:if(!(st==="delete")){Mt.next=23;break}if(!(St===0)){Mt.next=18;break}return Fe(!1),Mt.abrupt("return");case 18:Ye(Ze.data.hpc_courses[0]),Fe(!0),re(Ze.data.hpc_courses[0].id),Mt.next=24;break;case 23:st==="add"?(Ye(Ze.data.hpc_courses[St-1]),Fe(!0),re(Ze.data.hpc_courses[St-1].id)):(Ye(Ze.data.hpc_courses.filter(function(jt){return jt.id===ye})[0]),Fe(!0),re(ye));case 24:case"end":return Mt.stop()}},$e)})),se.apply(this,arguments)}function pe($e){Ee(!1),Fe(!0),Ye($e),re($e.id)}function be($e){et($e),Ee(!0),Fe(!1)}function _e(){et(""),Ee(!0),Fe(!1)}var We={name:"file",multiple:!0,action:"https://www.educoder.net/api/hpc_courses/upload_file.json",data:{container_type:window.location.pathname.split("/")[1]},onChange:function(st){var Ze=st.file.status;Ze!=="uploading",Ze==="done"?(M.b.success("".concat(st.file.name," \u6587\u4EF6\u4E0A\u4F20\u6210\u529F")),ie("")):Ze==="error"&&M.b.error("".concat(st.file.name," \u6587\u4EF6\u4E0A\u4F20\u5931\u8D25"))},beforeUpload:function(st){var Ze=st.size/1024/1024<150;return Ze||M.b.info("\u6587\u4EF6\u5927\u5C0F\u5FC5\u987B\u5C0F\u4E8E150MB"),Ze}};return T.a.createElement("div",{style:{marginBottom:"40px"}},T.a.createElement("div",{className:"bannterdiv",style:{background:"url(".concat(g.a.IMG_SERVER+"/".concat(dt),")")}}),T.a.createElement("img",{style:{width:"100%"},src:g.a.IMG_SERVER+"/".concat(dt)}),T.a.createElement("div",{className:"edu-container minH500",style:{display:"flex",width:"1200px"}},T.a.createElement("div",{style:{flex:"1",marginTop:"17px"}},te&&te.map(function($e,st){return T.a.createElement("p",{key:st,onClick:function(){return pe($e)},className:ye===$e.id?"menuitemselect":"menuitem task-hide"},$e.name)}),(_==null||((a=_.userInfo)===null||a===void 0)?void 0:a.user_id)===299635||(_==null||((b=_.userInfo)===null||b===void 0)?void 0:b.user_id)===301458||_!=null&&(m=_.userInfo)!==null&&m!==void 0&&m.admin||_!=null&&(E=_.userInfo)!==null&&E!==void 0&&E.business?T.a.createElement("p",{onClick:function(){return _e()},className:"menuadd",style:{fontSize:"24px",paddingLeft:"10px"}},T.a.createElement("span",{style:{fontSize:"16px",marginLeft:"5px"}},"Last updated")):null),T.a.createElement("div",{className:"rightcount",style:{flex:"6",background:"#ffffff",padding:"20px",marginLeft:"30px",marginTop:"24px"}},Oe?T.a.createElement(o,{UpdateItem:ct,setIscreate:Ee,init:ie}):null,ze?T.a.createElement(w,{UserInfo:_==null?void 0:_.userInfo,setSee:Fe,userId:_==null||((B=_.userInfo)===null||B===void 0)?void 0:B.user_id,ItemUpdate:be,CourseItem:it,init:ie}):null)),(_==null||((U=_.userInfo)===null||U===void 0)?void 0:U.user_id)===299635||(_==null||((K=_.userInfo)===null||K===void 0)?void 0:K.user_id)===301458||_!=null&&(V=_.userInfo)!==null&&V!==void 0&&V.admin||_!=null&&(P=_.userInfo)!==null&&P!==void 0&&P.business?T.a.createElement($.a,We,T.a.createElement(Z.a,{className:"menuadd",style:{paddingLeft:"10px",marginLeft:"20px"}},"\u4E0A\u4F20\u9996\u9875\u56FE\u7247")):null)}var p=ut.default=Object(x.a)(function(d){var a=d.user;return{user:a}})(f)},h78n:function(Tt,ut,he){"use strict";he.d(ut,"a",function(){return E});var oe=he("q1tI"),$=he.n(oe),D=he("TSYQ"),Z=he.n(D),F={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1},M=function(K){var V=K.map(function(){return Object(oe.useRef)()}),P=Object(oe.useRef)();return Object(oe.useEffect)(function(){var _=Date.now(),Y=!1;Object.keys(V).forEach(function(ee){var ae=V[ee].current;if(!ae)return;Y=!0;var ce=ae.style;ce.transitionDuration=".3s, .3s, .3s, .06s",P.current&&_-P.current<100&&(ce.transitionDuration="0s, 0s")}),Y&&(P.current=Date.now())}),[V]};function z(){return z=Object.assign||function(U){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var P in V)Object.prototype.hasOwnProperty.call(V,P)&&(U[P]=V[P])}return U},z.apply(this,arguments)}function H(U,K){return O(U)||T(U,K)||R(U,K)||N()}function N(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R(U,K){if(!U)return;if(typeof U=="string")return v(U,K);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return v(U,K)}function v(U,K){(K==null||K>U.length)&&(K=U.length);for(var V=0,P=new Array(K);V<K;V++)P[V]=U[V];return P}function T(U,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],P=!0,_=!1,Y=void 0;try{for(var ee=U[Symbol.iterator](),ae;!(P=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);P=!0);}catch(ce){_=!0,Y=ce}finally{try{!P&&ee.return!=null&&ee.return()}finally{if(_)throw Y}}return V}function O(U){if(Array.isArray(U))return U}function L(U,K){if(U==null)return{};var V=A(U,K),P,_;if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(U);for(_=0;_<Y.length;_++){if(P=Y[_],K.indexOf(P)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,P))continue;V[P]=U[P]}}return V}function A(U,K){if(U==null)return{};var V={},P=Object.keys(U),_,Y;for(Y=0;Y<P.length;Y++){if(_=P[Y],K.indexOf(_)>=0)continue;V[_]=U[_]}return V}var C=function(K){var V=K.className,P=K.percent,_=K.prefixCls,Y=K.strokeColor,ee=K.strokeLinecap,ae=K.strokeWidth,ce=K.style,De=K.trailColor,Se=K.trailWidth,Ce=K.transition,Ae=L(K,["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"]);delete Ae.gapPosition;var Te=Array.isArray(P)?P:[P],ve=Array.isArray(Y)?Y:[Y],le=M(Te),te=H(le,1),de=te[0],ne=ae/2,ke=100-ae/2,Oe="M ".concat(ee==="round"?ne:0,",").concat(ne,`
L `).concat(ee==="round"?ke:100,",").concat(ne),Ee="0 0 100 ".concat(ae),Re=0;return $.a.createElement("svg",z({className:Z()("".concat(_,"-line"),V),viewBox:Ee,preserveAspectRatio:"none",style:ce},Ae),$.a.createElement("path",{className:"".concat(_,"-line-trail"),d:Oe,strokeLinecap:ee,stroke:De,strokeWidth:Se||ae,fillOpacity:"0"}),Te.map(function(Be,ze){var Fe={strokeDasharray:"".concat(Be,"px, 100px"),strokeDashoffset:"-".concat(Re,"px"),transition:Ce||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},Ue=ve[ze]||ve[ve.length-1];return Re+=Be,$.a.createElement("path",{key:ze,className:"".concat(_,"-line-path"),d:Oe,strokeLinecap:ee,stroke:Ue,strokeWidth:ae,fillOpacity:"0",ref:de[ze],style:Fe})}))};C.defaultProps=F;var u=C;function o(){return o=Object.assign||function(U){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var P in V)Object.prototype.hasOwnProperty.call(V,P)&&(U[P]=V[P])}return U},o.apply(this,arguments)}function l(U,K){return k(U)||g(U,K)||w(U,K)||h()}function h(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w(U,K){if(!U)return;if(typeof U=="string")return y(U,K);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return y(U,K)}function y(U,K){(K==null||K>U.length)&&(K=U.length);for(var V=0,P=new Array(K);V<K;V++)P[V]=U[V];return P}function g(U,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],P=!0,_=!1,Y=void 0;try{for(var ee=U[Symbol.iterator](),ae;!(P=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);P=!0);}catch(ce){_=!0,Y=ce}finally{try{!P&&ee.return!=null&&ee.return()}finally{if(_)throw Y}}return V}function k(U){if(Array.isArray(U))return U}function x(U,K){if(U==null)return{};var V=f(U,K),P,_;if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(U);for(_=0;_<Y.length;_++){if(P=Y[_],K.indexOf(P)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,P))continue;V[P]=U[P]}}return V}function f(U,K){if(U==null)return{};var V={},P=Object.keys(U),_,Y;for(Y=0;Y<P.length;Y++){if(_=P[Y],K.indexOf(_)>=0)continue;V[_]=U[_]}return V}var p=0;function d(U){return+U.replace("%","")}function a(U){return Array.isArray(U)?U:[U]}function b(U,K,V,P){var _=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,Y=arguments.length>5?arguments[5]:void 0,ee=50-P/2,ae=0,ce=-ee,De=0,Se=-2*ee;switch(Y){case"left":ae=-ee,ce=0,De=2*ee,Se=0;break;case"right":ae=ee,ce=0,De=-2*ee,Se=0;break;case"bottom":ce=ee,Se=2*ee;break;default:}var Ce="M 50,50 m ".concat(ae,",").concat(ce,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(De,",").concat(-Se,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(-De,",").concat(Se),Ae=Math.PI*2*ee,Te={stroke:V,strokeDasharray:"".concat(K/100*(Ae-_),"px ").concat(Ae,"px"),strokeDashoffset:"-".concat(_/2+U/100*(Ae-_),"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s"};return{pathString:Ce,pathStyle:Te}}var m=function(K){var V=K.prefixCls,P=K.strokeWidth,_=K.trailWidth,Y=K.gapDegree,ee=K.gapPosition,ae=K.trailColor,ce=K.strokeLinecap,De=K.style,Se=K.className,Ce=K.strokeColor,Ae=K.percent,Te=x(K,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"]),ve=Object(oe.useMemo)(function(){return p+=1,p},[]),le=b(0,100,ae,P,Y,ee),te=le.pathString,de=le.pathStyle,ne=a(Ae),ke=a(Ce),Oe=ke.find(function(Fe){return Object.prototype.toString.call(Fe)==="[object Object]"}),Ee=M(ne),Re=l(Ee,1),Be=Re[0],ze=function(){var Ue=0;return ne.map(function(Ie,it){var Ye=ke[it]||ke[ke.length-1],Qe=Object.prototype.toString.call(Ye)==="[object Object]"?"url(#".concat(V,"-gradient-").concat(ve,")"):"",qe=b(Ue,Ie,Ye,P,Y,ee);return Ue+=Ie,$.a.createElement("path",{key:it,className:"".concat(V,"-circle-path"),d:qe.pathString,stroke:Qe,strokeLinecap:ce,strokeWidth:P,opacity:Ie===0?0:1,fillOpacity:"0",style:qe.pathStyle,ref:Be[it]})})};return $.a.createElement("svg",o({className:Z()("".concat(V,"-circle"),Se),viewBox:"0 0 100 100",style:De},Te),Oe&&$.a.createElement("defs",null,$.a.createElement("linearGradient",{id:"".concat(V,"-gradient-").concat(ve),x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(Oe).sort(function(Fe,Ue){return d(Fe)-d(Ue)}).map(function(Fe,Ue){return $.a.createElement("stop",{key:Ue,offset:Fe,stopColor:Oe[Fe]})}))),$.a.createElement("path",{className:"".concat(V,"-circle-trail"),d:te,stroke:ae,strokeLinecap:ce,strokeWidth:_||P,fillOpacity:"0",style:de}),ze().reverse())};m.defaultProps=F;var E=m,B={Line:u,Circle:E}},kSUc:function(Tt,ut,he){},lZu9:function(Tt,ut,he){(function(oe){oe(he("VrN/"),he("1eCo"),he("8EBN"))})(function(oe){"use strict";oe.defineMode("markdown",function($,D){var Z=oe.getMode($,"text/html"),F=Z.name=="null";function M(P){if(oe.findModeByName){var _=oe.findModeByName(P);_&&(P=_.mime||_.mimes[0])}var Y=oe.getMode($,P);return Y.name=="null"?null:Y}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 z={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 H in z)z.hasOwnProperty(H)&&D.tokenTypeOverrides[H]&&(z[H]=D.tokenTypeOverrides[H]);var N=/^([*\-_])(?:\s*\1){2,}\s*$/,R=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,T=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,O=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,C=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function l(P,_,Y){return _.f=_.inline=Y,Y(P,_)}function h(P,_,Y){return _.f=_.block=Y,Y(P,_)}function w(P){return!P||!/\S/.test(P.string)}function y(P){if(P.linkTitle=!1,P.linkHref=!1,P.linkText=!1,P.em=!1,P.strong=!1,P.strikethrough=!1,P.quote=0,P.indentedCode=!1,P.f==k){var _=F;if(!_){var Y=oe.innerMode(Z,P.htmlState);_=Y.mode.name=="xml"&&Y.state.tagStart===null&&!Y.state.context&&Y.state.tokenize.isInText}_&&(P.f=d,P.block=g,P.htmlState=null)}return P.trailingSpace=0,P.trailingSpaceNewLine=!1,P.prevLine=P.thisLine,P.thisLine={stream:null},null}function g(P,_){var Y=P.column()===_.indentation,ee=w(_.prevLine.stream),ae=_.indentedCode,ce=_.prevLine.hr,De=_.list!==!1,Se=(_.listStack[_.listStack.length-1]||0)+3;_.indentedCode=!1;var Ce=_.indentation;if(_.indentationDiff===null&&(_.indentationDiff=_.indentation,De)){for(_.list=null;Ce<_.listStack[_.listStack.length-1];)_.listStack.pop(),_.listStack.length?_.indentation=_.listStack[_.listStack.length-1]:_.list=!1;_.list!==!1&&(_.indentationDiff=Ce-_.listStack[_.listStack.length-1])}var Ae=!ee&&!ce&&!_.prevLine.header&&(!De||!ae)&&!_.prevLine.fencedCodeEnd,Te=(_.list===!1||ce||ee)&&_.indentation<=Se&&P.match(N),ve=null;if(_.indentationDiff>=4&&(ae||_.prevLine.fencedCodeEnd||_.prevLine.header||ee))return P.skipToEnd(),_.indentedCode=!0,z.code;if(P.eatSpace())return null;if(Y&&_.indentation<=Se&&(ve=P.match(T))&&ve[1].length<=6)return _.quote=0,_.header=ve[1].length,_.thisLine.header=!0,D.highlightFormatting&&(_.formatting="header"),_.f=_.inline,f(_);if(_.indentation<=Se&&P.eat(">"))return _.quote=Y?1:_.quote+1,D.highlightFormatting&&(_.formatting="quote"),P.eatSpace(),f(_);if(!Te&&!_.setext&&Y&&_.indentation<=Se&&(ve=P.match(R))){var le=ve[1]?"ol":"ul";return _.indentation=Ce+P.current().length,_.list=!0,_.quote=0,_.listStack.push(_.indentation),_.em=!1,_.strong=!1,_.code=!1,_.strikethrough=!1,D.taskLists&&P.match(v,!1)&&(_.taskList=!0),_.f=_.inline,D.highlightFormatting&&(_.formatting=["list","list-"+le]),f(_)}else{if(Y&&_.indentation<=Se&&(ve=P.match(A,!0)))return _.quote=0,_.fencedEndRE=new RegExp(ve[1]+"+ *$"),_.localMode=D.fencedCodeBlockHighlighting&&M(ve[2]||D.fencedCodeBlockDefaultMode),_.localMode&&(_.localState=oe.startState(_.localMode)),_.f=_.block=x,D.highlightFormatting&&(_.formatting="code-block"),_.code=-1,f(_);if(_.setext||(!Ae||!De)&&!_.quote&&_.list===!1&&!_.code&&!Te&&!C.test(P.string)&&(ve=P.lookAhead(1))&&(ve=ve.match(O)))return _.setext?(_.header=_.setext,_.setext=0,P.skipToEnd(),D.highlightFormatting&&(_.formatting="header")):(_.header=ve[0].charAt(0)=="="?1:2,_.setext=_.header),_.thisLine.header=!0,_.f=_.inline,f(_);if(Te)return P.skipToEnd(),_.hr=!0,_.thisLine.hr=!0,z.hr;if(P.peek()==="[")return l(P,_,B)}return l(P,_,_.inline)}function k(P,_){var Y=Z.token(P,_.htmlState);if(!F){var ee=oe.innerMode(Z,_.htmlState);(ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText||_.md_inside&&P.current().indexOf(">")>-1)&&(_.f=d,_.block=g,_.htmlState=null)}return Y}function x(P,_){var Y=_.listStack[_.listStack.length-1]||0,ee=_.indentation<Y,ae=Y+3;if(_.fencedEndRE&&_.indentation<=ae&&(ee||P.match(_.fencedEndRE))){D.highlightFormatting&&(_.formatting="code-block");var ce;return ee||(ce=f(_)),_.localMode=_.localState=null,_.block=g,_.f=d,_.fencedEndRE=null,_.code=0,_.thisLine.fencedCodeEnd=!0,ee?h(P,_,_.block):ce}else return _.localMode?_.localMode.token(P,_.localState):(P.skipToEnd(),z.code)}function f(P){var _=[];if(P.formatting){_.push(z.formatting),typeof P.formatting=="string"&&(P.formatting=[P.formatting]);for(var Y=0;Y<P.formatting.length;Y++)_.push(z.formatting+"-"+P.formatting[Y]),P.formatting[Y]==="header"&&_.push(z.formatting+"-"+P.formatting[Y]+"-"+P.header),P.formatting[Y]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=P.quote?_.push(z.formatting+"-"+P.formatting[Y]+"-"+P.quote):_.push("error"))}if(P.taskOpen)return _.push("meta"),_.length?_.join(" "):null;if(P.taskClosed)return _.push("property"),_.length?_.join(" "):null;if(P.linkHref?_.push(z.linkHref,"url"):(P.strong&&_.push(z.strong),P.em&&_.push(z.em),P.strikethrough&&_.push(z.strikethrough),P.emoji&&_.push(z.emoji),P.linkText&&_.push(z.linkText),P.code&&_.push(z.code),P.image&&_.push(z.image),P.imageAltText&&_.push(z.imageAltText,"link"),P.imageMarker&&_.push(z.imageMarker)),P.header&&_.push(z.header,z.header+"-"+P.header),P.quote&&(_.push(z.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=P.quote?_.push(z.quote+"-"+P.quote):_.push(z.quote+"-"+D.maxBlockquoteDepth)),P.list!==!1){var ee=(P.listStack.length-1)%3;ee?ee===1?_.push(z.list2):_.push(z.list3):_.push(z.list1)}return P.trailingSpaceNewLine?_.push("trailing-space-new-line"):P.trailingSpace&&_.push("trailing-space-"+(P.trailingSpace%2?"a":"b")),_.length?_.join(" "):null}function p(P,_){return P.match(L,!0)?f(_):void 0}function d(P,_){var Y=_.text(P,_);if(typeof Y!="undefined")return Y;if(_.list)return _.list=null,f(_);if(_.taskList){var ee=P.match(v,!0)[1]===" ";return ee?_.taskOpen=!0:_.taskClosed=!0,D.highlightFormatting&&(_.formatting="task"),_.taskList=!1,f(_)}if(_.taskOpen=!1,_.taskClosed=!1,_.header&&P.match(/^#+$/,!0))return D.highlightFormatting&&(_.formatting="header"),f(_);var ae=P.next();if(_.linkTitle){_.linkTitle=!1;var ce=ae;ae==="("&&(ce=")"),ce=(ce+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+ce+"\\\\]+|\\\\\\\\|\\\\.)"+ce;if(P.match(new RegExp(De),!0))return z.linkHref}if(ae==="`"){var Se=_.formatting;D.highlightFormatting&&(_.formatting="code"),P.eatWhile("`");var Ce=P.current().length;if(_.code==0&&(!_.quote||Ce==1))return _.code=Ce,f(_);if(Ce==_.code){var Ae=f(_);return _.code=0,Ae}else return _.formatting=Se,f(_)}else if(_.code)return f(_);if(ae==="\\"&&(P.next(),D.highlightFormatting)){var Te=f(_),ve=z.formatting+"-escape";return Te?Te+" "+ve:ve}if(ae==="!"&&P.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return _.imageMarker=!0,_.image=!0,D.highlightFormatting&&(_.formatting="image"),f(_);if(ae==="["&&_.imageMarker&&P.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return _.imageMarker=!1,_.imageAltText=!0,D.highlightFormatting&&(_.formatting="image"),f(_);if(ae==="]"&&_.imageAltText){D.highlightFormatting&&(_.formatting="image");var Te=f(_);return _.imageAltText=!1,_.image=!1,_.inline=_.f=b,Te}if(ae==="["&&!_.image)return _.linkText&&P.match(/^.*?\]/)||(_.linkText=!0,D.highlightFormatting&&(_.formatting="link")),f(_);if(ae==="]"&&_.linkText){D.highlightFormatting&&(_.formatting="link");var Te=f(_);return _.linkText=!1,_.inline=_.f=P.match(/\(.*?\)| ?\[.*?\]/,!1)?b:d,Te}if(ae==="<"&&P.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){_.f=_.inline=a,D.highlightFormatting&&(_.formatting="link");var Te=f(_);return Te?Te+=" ":Te="",Te+z.linkInline}if(ae==="<"&&P.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){_.f=_.inline=a,D.highlightFormatting&&(_.formatting="link");var Te=f(_);return Te?Te+=" ":Te="",Te+z.linkEmail}if(D.xml&&ae==="<"&&P.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var le=P.string.indexOf(">",P.pos);if(le!=-1){var te=P.string.substring(P.start,le);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(te)&&(_.md_inside=!0)}return P.backUp(1),_.htmlState=oe.startState(Z),h(P,_,k)}if(D.xml&&ae==="<"&&P.match(/^\/\w*?>/))return _.md_inside=!1,"tag";if(ae==="*"||ae==="_"){for(var de=1,ne=P.pos==1?" ":P.string.charAt(P.pos-2);de<3&&P.eat(ae);)de++;var ke=P.peek()||" ",Oe=!/\s/.test(ke)&&(!u.test(ke)||/\s/.test(ne)||u.test(ne)),Ee=!/\s/.test(ne)&&(!u.test(ne)||/\s/.test(ke)||u.test(ke)),Re=null,Be=null;if(de%2&&(!_.em&&Oe&&(ae==="*"||!Ee||u.test(ne))?Re=!0:_.em==ae&&Ee&&(ae==="*"||!Oe||u.test(ke))&&(Re=!1)),de>1&&(!_.strong&&Oe&&(ae==="*"||!Ee||u.test(ne))?Be=!0:_.strong==ae&&Ee&&(ae==="*"||!Oe||u.test(ke))&&(Be=!1)),Be!=null||Re!=null){D.highlightFormatting&&(_.formatting=Re==null?"strong":Be==null?"em":"strong em"),Re===!0&&(_.em=ae),Be===!0&&(_.strong=ae);var Ae=f(_);return Re===!1&&(_.em=!1),Be===!1&&(_.strong=!1),Ae}}else if(ae===" "&&(P.eat("*")||P.eat("_"))){if(P.peek()===" ")return f(_);P.backUp(1)}if(D.strikethrough){if(ae==="~"&&P.eatWhile(ae)){if(_.strikethrough){D.highlightFormatting&&(_.formatting="strikethrough");var Ae=f(_);return _.strikethrough=!1,Ae}else if(P.match(/^[^\s]/,!1))return _.strikethrough=!0,D.highlightFormatting&&(_.formatting="strikethrough"),f(_)}else if(ae===" "&&P.match(/^~~/,!0)){if(P.peek()===" ")return f(_);P.backUp(2)}}if(D.emoji&&ae===":"&&P.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){_.emoji=!0,D.highlightFormatting&&(_.formatting="emoji");var ze=f(_);return _.emoji=!1,ze}return ae===" "&&(P.match(/^ +$/,!1)?_.trailingSpace++:_.trailingSpace&&(_.trailingSpaceNewLine=!0)),f(_)}function a(P,_){var Y=P.next();if(Y===">"){_.f=_.inline=d,D.highlightFormatting&&(_.formatting="link");var ee=f(_);return ee?ee+=" ":ee="",ee+z.linkInline}return P.match(/^[^>]+/,!0),z.linkInline}function b(P,_){if(P.eatSpace())return null;var Y=P.next();return Y==="("||Y==="["?(_.f=_.inline=E(Y==="("?")":"]"),D.highlightFormatting&&(_.formatting="link-string"),_.linkHref=!0,f(_)):"error"}var m={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function E(P){return function(_,Y){var ee=_.next();if(ee===P){Y.f=Y.inline=d,D.highlightFormatting&&(Y.formatting="link-string");var ae=f(Y);return Y.linkHref=!1,ae}return _.match(m[P]),Y.linkHref=!0,f(Y)}}function B(P,_){return P.match(/^([^\]\\]|\\.)*\]:/,!1)?(_.f=U,P.next(),D.highlightFormatting&&(_.formatting="link"),_.linkText=!0,f(_)):l(P,_,d)}function U(P,_){if(P.match(/^\]:/,!0)){_.f=_.inline=K,D.highlightFormatting&&(_.formatting="link");var Y=f(_);return _.linkText=!1,Y}return P.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function K(P,_){return P.eatSpace()?null:(P.match(/^[^\s]+/,!0),P.peek()===void 0?_.linkTitle=!0:P.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),_.f=_.inline=d,z.linkHref+" url")}var V={startState:function(){return{f:g,prevLine:{stream:null},thisLine:{stream:null},block:g,htmlState:null,indentation:0,inline:d,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(P){return{f:P.f,prevLine:P.prevLine,thisLine:P.thisLine,block:P.block,htmlState:P.htmlState&&oe.copyState(Z,P.htmlState),indentation:P.indentation,localMode:P.localMode,localState:P.localMode?oe.copyState(P.localMode,P.localState):null,inline:P.inline,text:P.text,formatting:!1,linkText:P.linkText,linkTitle:P.linkTitle,linkHref:P.linkHref,code:P.code,em:P.em,strong:P.strong,strikethrough:P.strikethrough,emoji:P.emoji,header:P.header,setext:P.setext,hr:P.hr,taskList:P.taskList,list:P.list,listStack:P.listStack.slice(0),quote:P.quote,indentedCode:P.indentedCode,trailingSpace:P.trailingSpace,trailingSpaceNewLine:P.trailingSpaceNewLine,md_inside:P.md_inside,fencedEndRE:P.fencedEndRE}},token:function(P,_){if(_.formatting=!1,P!=_.thisLine.stream){if(_.header=0,_.hr=!1,P.match(/^\s*$/,!0))return y(_),null;if(_.prevLine=_.thisLine,_.thisLine={stream:P},_.taskList=!1,_.trailingSpace=0,_.trailingSpaceNewLine=!1,!_.localState&&(_.f=_.block,_.f!=k)){var Y=P.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(_.indentation=Y,_.indentationDiff=null,Y>0)return null}}return _.f(P,_)},innerMode:function(P){return P.block==k?{state:P.htmlState,mode:Z}:P.localState?{state:P.localState,mode:P.localMode}:{state:P,mode:V}},indent:function(P,_,Y){return P.block==k&&Z.indent?Z.indent(P.htmlState,_,Y):P.localState&&P.localMode.indent?P.localMode.indent(P.localState,_,Y):oe.Pass},blankLine:y,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return V},"xml"),oe.defineMIME("text/markdown","markdown"),oe.defineMIME("text/x-markdown","markdown")})},osHv:function(Tt,ut,he){(function(oe){oe(he("VrN/"))})(function(oe){"use strict";var $=oe.Pos;function D(u,o){return u.line-o.line||u.ch-o.ch}var Z="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",F=Z+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",M=new RegExp("<(/?)(["+Z+"]["+F+"]*)","g");function z(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 H(u,o){var l=u.cm.getTokenTypeAt($(u.line,o));return l&&/\btag\b/.test(l)}function N(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function R(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function v(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(N(u))continue;return}if(!H(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 T(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(R(u))continue;return}if(!H(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 O(u){for(;;){M.lastIndex=u.ch;var o=M.exec(u.text);if(!o){if(N(u))continue;return}if(!H(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(R(u))continue;return}if(!H(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 A(u,o){for(var l=[];;){var h=O(u),w,y=u.line,g=u.ch-(h?h[0].length:0);if(!h||!(w=v(u)))return;if(w=="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:$(y,g),to:$(u.line,u.ch)}}else l.push(h[2])}}function C(u,o){for(var l=[];;){var h=L(u);if(!h)return;if(h=="selfClose"){T(u);continue}var w=u.line,y=u.ch,g=T(u);if(!g)return;if(g[1])l.push(g[2]);else{for(var k=l.length-1;k>=0;--k)if(l[k]==g[2]){l.length=k;break}if(k<0&&(!o||o==g[2]))return{tag:g[2],from:$(u.line,u.ch),to:$(w,y)}}}}oe.registerHelper("fold","xml",function(u,o){for(var l=new z(u,o.line,0);;){var h=O(l);if(!h||l.line!=o.line)return;var w=v(l);if(!w)return;if(!h[1]&&w!="selfClose"){var y=$(l.line,l.ch),g=A(l,h[2]);return g&&D(g.from,y)>0?{from:y,to:g.from}:null}}}),oe.findMatchingTag=function(u,o,l){var h=new z(u,o.line,o.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var w=v(h),y=w&&$(h.line,h.ch),g=w&&T(h);if(!w||!g||D(h,o)>0)return;var k={from:$(h.line,h.ch),to:y,tag:g[2]};return w=="selfClose"?{open:k,close:null,at:"open"}:g[1]?{open:C(h,g[2]),close:k,at:"close"}:(h=new z(u,y.line,y.ch,l),{open:k,close:A(h,g[2]),at:"open"})},oe.findEnclosingTag=function(u,o,l,h){for(var w=new z(u,o.line,o.ch,l);;){var y=C(w,h);if(!y)break;var g=new z(u,o.line,o.ch,l),k=A(g,y.tag);if(k)return{open:y,close:k}}},oe.scanForClosingTag=function(u,o,l,h){var w=new z(u,o.line,o.ch,h?{from:0,to:h}:null);return A(w,l)}})},p5ED:function(Tt,ut,he){"use strict";var oe=he("+L6B"),$=he("2/Rp"),D=he("5Dmo"),Z=he("3S7+"),F=he("k1fw"),M=he("9og8"),z=he("tJVT"),H=he("WmNS"),N=he.n(H),R=he("q1tI"),v=he.n(R),T=he("vHTk"),O=he.n(T),L=he("yEEn"),A=he("ZW9T"),C=he("1vsH"),u=he("V0Rq"),o=he("m3rI");ut.a=function(l){var h,w,y,g,k,x,f,p=l.editOffice,d=p===void 0?"view":p,a=l.data,b=l.theme,m=l.type,E=l.filename,B=l.monacoEditor,U=l.className,K=l.style,V=l.close,P=l.onClose,_=l.hasMask,Y=l.disabledDownload,ee=Object(R.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ae=Object(z.a)(ee,2),ce=ae[0],De=ae[1],Se=Object(R.useState)(""),Ce=Object(z.a)(Se,2),Ae=Ce[0],Te=Ce[1],ve=Object(R.useState)(),le=Object(z.a)(ve,2),te=le[0],de=le[1],ne=window.ENV==="build"?"/react/build":"",ke=o.a.PROXY_SERVER||location.origin,Oe,Ee=1024*1024,Re=10*Ee,Be=Object(R.useRef)();(h=a)!==null&&h!==void 0&&h.startsWith("/api")&&m!=="txt"&&(a=o.a.API_SERVER+a),m==="office"&&(Oe=Object(C.T)(a).filesize,Oe>Re&&(m="other")),E&&B&&(B.filename=E),Object(R.useEffect)(function(){var Ie,it,Ye=(Ie=document.cookie)===null||Ie===void 0||((it=Ie.replace(/\s/g,""))===null||it===void 0)?void 0:it.split(";");Ye==null||Ye.map(function(Qe){var qe=Qe.split("=");qe[0]==="_educoder_session"&&Te(qe[1])})},[]),Object(R.useEffect)(function(){m==="office"&&ze()},[m,a]);var ze=function(){var Ie=Object(M.a)(N.a.mark(function it(){var Ye,Qe,qe;return N.a.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return console.log("data:",a),Ye=a,a.startsWith("http")||(Ye=location.origin+Ye),Qe=new URL(Ye).pathname.split("/").pop(),et.next=6,Object(u.V)({attachment_id:Qe});case 6:qe=et.sent,de(qe);case 8:case"end":return et.stop()}},it)}));return function(){return Ie.apply(this,arguments)}}(),Fe=function(){if(a.startsWith("http")||a.startsWith("blob:")){Ue();return}Object(C.z)(E||"educoder",a,E)},Ue=function(){Object(C.x)(E||"educoder",decodeURIComponent(a))};return v.a.createElement("div",{style:Object(F.a)({},K||{}),className:"".concat(_&&O.a.bgBlack," ").concat(m?O.a.wrp:"hide")},V&&v.a.createElement("div",{className:O.a.close,ref:Be},!Y&&v.a.createElement(Z.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Be.current}},v.a.createElement("span",{onClick:Ue},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement(Z.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Be.current}},v.a.createElement("span",{className:"",onClick:P},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(O.a[U]," ").concat(U," ").concat(O.a.monaco," ").concat(m==="txt"?"show":"hide")},m==="txt"&&v.a.createElement(A.b,B)),m==="audio"&&v.a.createElement("audio",{src:"".concat(((w=a)===null||w===void 0?void 0:w.indexOf("http://"))>-1||((y=a)===null||y===void 0?void 0:y.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),m==="video"&&v.a.createElement(v.a.Fragment,null,((g=a)===null||g===void 0?void 0:g.indexOf("http"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),m==="office"&&te&&v.a.createElement("iframe",{src:"".concat(ne,"/office.html?key=").concat(te.key,"&url=").concat(ke+te.url,"&callbackUrl=").concat(ke+te.callbackUrl,"&fileType=").concat(te.fileType,"&title=").concat(te.title,"&model=").concat(d,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!Y)}),m==="html"&&v.a.createElement("iframe",{src:a+"&disposition=inline"}),m==="pdf"&&v.a.createElement("iframe",{src:"".concat(ne,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!Y)}),m==="image"&&v.a.createElement("img",{src:"".concat(((k=a)===null||k===void 0?void 0:k.indexOf("http://"))>-1||((x=a)===null||x===void 0?void 0:x.indexOf("https://"))>-1||(f=a)!==null&&f!==void 0&&f.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),m==="other"&&v.a.createElement("div",null,v.a.createElement($.a,{type:"primary",size:"large",onClick:Fe},v.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),m==="download"&&v.a.createElement($.a,{type:"primary",size:"large",onClick:Fe},v.a.createElement(L.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(Tt,ut,he){},rUJ1:function(Tt,ut){const he=/[&<>"']/,oe=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},F=x=>Z[x];function M(x,f){if(f){if(he.test(x))return x.replace(oe,F)}else if($.test(x))return x.replace(D,F);return x}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function H(x){return x.replace(z,(f,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const N=/(^|[^\[])\^/g;function R(x,f){x=x.source||x,f=f||"";const p={replace:(d,a)=>(a=a.source||a,a=a.replace(N,"$1"),x=x.replace(d,a),p),getRegex:()=>new RegExp(x,f)};return p}const v=/[^\w:]/g,T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function O(x,f,p){if(x){let d;try{d=decodeURIComponent(H(p)).replace(v,"").toLowerCase()}catch(a){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}f&&!T.test(p)&&(p=o(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(d){return null}return p}const L={},A=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(x,f){L[" "+x]||(A.test(x)?L[" "+x]=x+"/":L[" "+x]=y(x,"/",!0)),x=L[" "+x];const p=x.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:x.replace(C,"$1")+f:f.charAt(0)==="/"?p?f:x.replace(u,"$1")+f:x+f}const l={exec:function(){}};function h(x){let f=1,p,d;for(;f<arguments.length;f++){p=arguments[f];for(d in p)Object.prototype.hasOwnProperty.call(p,d)&&(x[d]=p[d])}return x}function w(x,f){const p=x.replace(/\|/g,(b,m,E)=>{let B=!1,U=m;for(;--U>=0&&E[U]==="\\";)B=!B;return B?"|":" |"}),d=p.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 y(x,f,p){const d=x.length;if(d===0)return"";let a=0;for(;a<d;){const b=x.charAt(d-a-1);if(b===f&&!p)a++;else if(b!==f&&p)a++;else break}return x.substr(0,d-a)}function g(x,f){if(x.indexOf(f[1])===-1)return-1;const p=x.length;let d=0,a=0;for(;a<p;a++)if(x[a]==="\\")a++;else if(x[a]===f[0])d++;else if(x[a]===f[1]&&(d--,d<0))return a;return-1}function k(x){x&&x.sanitize&&!x.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")}Tt.exports={escape:M,unescape:H,edit:R,cleanUrl:O,resolveUrl:o,noopTest:l,merge:h,splitCells:w,rtrim:y,findClosingBracket:g,checkSanitizeDeprecation:k}},ulZh:function(Tt,ut,he){typeof window!="undefined"&&function($,D){Tt.exports=D()}(this,function(){return function(oe){var $={};function D(Z){if($[Z])return $[Z].exports;var F=$[Z]={i:Z,l:!1,exports:{}};return oe[Z].call(F.exports,F,F.exports,D),F.l=!0,F.exports}return D.m=oe,D.c=$,D.d=function(Z,F,M){D.o(Z,F)||Object.defineProperty(Z,F,{enumerable:!0,get:M})},D.r=function(Z){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Z,"__esModule",{value:!0})},D.t=function(Z,F){if(F&1&&(Z=D(Z)),F&8)return Z;if(F&4&&typeof Z=="object"&&Z&&Z.__esModule)return Z;var M=Object.create(null);if(D.r(M),Object.defineProperty(M,"default",{enumerable:!0,value:Z}),F&2&&typeof Z!="string")for(var z in Z)D.d(M,z,function(H){return Z[H]}.bind(null,z));return M},D.n=function(Z){var F=Z&&Z.__esModule?function(){return Z.default}:function(){return Z};return D.d(F,"a",F),F},D.o=function(Z,F){return Object.prototype.hasOwnProperty.call(Z,F)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(oe,$,D){"use strict";var Z=Object.prototype.hasOwnProperty,F="~";function M(){}Object.create&&(M.prototype=Object.create(null),new M().__proto__||(F=!1));function z(v,T,O){this.fn=v,this.context=T,this.once=O||!1}function H(v,T,O,L,A){if(typeof O!="function")throw new TypeError("The listener must be a function");var C=new z(O,L||v,A),u=F?F+T:T;return v._events[u]?v._events[u].fn?v._events[u]=[v._events[u],C]:v._events[u].push(C):(v._events[u]=C,v._eventsCount++),v}function N(v,T){--v._eventsCount===0?v._events=new M:delete v._events[T]}function R(){this._events=new M,this._eventsCount=0}R.prototype.eventNames=function(){var T=[],O,L;if(this._eventsCount===0)return T;for(L in O=this._events)Z.call(O,L)&&T.push(F?L.slice(1):L);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(O)):T},R.prototype.listeners=function(T){var O=F?F+T:T,L=this._events[O];if(!L)return[];if(L.fn)return[L.fn];for(var A=0,C=L.length,u=new Array(C);A<C;A++)u[A]=L[A].fn;return u},R.prototype.listenerCount=function(T){var O=F?F+T:T,L=this._events[O];return L?L.fn?1:L.length:0},R.prototype.emit=function(T,O,L,A,C,u){var o=F?F+T:T;if(!this._events[o])return!1;var l=this._events[o],h=arguments.length,w,y;if(l.fn){l.once&&this.removeListener(T,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,O),!0;case 3:return l.fn.call(l.context,O,L),!0;case 4:return l.fn.call(l.context,O,L,A),!0;case 5:return l.fn.call(l.context,O,L,A,C),!0;case 6:return l.fn.call(l.context,O,L,A,C,u),!0}for(y=1,w=new Array(h-1);y<h;y++)w[y-1]=arguments[y];l.fn.apply(l.context,w)}else{var g=l.length,k;for(y=0;y<g;y++){l[y].once&&this.removeListener(T,l[y].fn,void 0,!0);switch(h){case 1:l[y].fn.call(l[y].context);break;case 2:l[y].fn.call(l[y].context,O);break;case 3:l[y].fn.call(l[y].context,O,L);break;case 4:l[y].fn.call(l[y].context,O,L,A);break;default:if(!w)for(k=1,w=new Array(h-1);k<h;k++)w[k-1]=arguments[k];l[y].fn.apply(l[y].context,w)}}}return!0},R.prototype.on=function(T,O,L){return H(this,T,O,L,!1)},R.prototype.once=function(T,O,L){return H(this,T,O,L,!0)},R.prototype.removeListener=function(T,O,L,A){var C=F?F+T:T;if(!this._events[C])return this;if(!O)return N(this,C),this;var u=this._events[C];if(u.fn)u.fn===O&&(!A||u.once)&&(!L||u.context===L)&&N(this,C);else{for(var o=0,l=[],h=u.length;o<h;o++)(u[o].fn!==O||A&&!u[o].once||L&&u[o].context!==L)&&l.push(u[o]);l.length?this._events[C]=l.length===1?l[0]:l:N(this,C)}return this},R.prototype.removeAllListeners=function(T){var O;return T?(O=F?F+T:T,this._events[O]&&N(this,O)):(this._events=new M,this._eventsCount=0),this},R.prototype.off=R.prototype.removeListener,R.prototype.addListener=R.prototype.on,R.prefixed=F,R.EventEmitter=R,oe.exports=R},"./node_modules/url-toolkit/src/url-toolkit.js":function(oe,$,D){(function(Z){var F=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,M=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,H=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,N={buildAbsoluteURL:function(R,v,T){if(T=T||{},R=R.trim(),v=v.trim(),!v){if(!T.alwaysNormalize)return R;var O=N.parseURL(R);if(!O)throw new Error("Error trying to parse base URL.");return O.path=N.normalizePath(O.path),N.buildURLFromParts(O)}var L=N.parseURL(v);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return T.alwaysNormalize?(L.path=N.normalizePath(L.path),N.buildURLFromParts(L)):v;var A=N.parseURL(R);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var C=M.exec(A.path);A.netLoc=C[1],A.path=C[2]}A.netLoc&&!A.path&&(A.path="/");var u={scheme:A.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(u.netLoc=A.netLoc,L.path[0]!=="/"))if(!L.path)u.path=A.path,L.params||(u.params=A.params,L.query||(u.query=A.query));else{var o=A.path,l=o.substring(0,o.lastIndexOf("/")+1)+L.path;u.path=N.normalizePath(l)}return u.path===null&&(u.path=T.alwaysNormalize?N.normalizePath(L.path):L.path),N.buildURLFromParts(u)},parseURL:function(R){var v=F.exec(R);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(R){for(R=R.split("").reverse().join("").replace(z,"");R.length!==(R=R.replace(H,"")).length;);return R.split("").reverse().join("")},buildURLFromParts:function(R){return R.scheme+R.netLoc+R.path+R.params+R.query+R.fragment}};oe.exports=N})(this)},"./node_modules/webworkify-webpack/index.js":function(oe,$,D){function Z(T){var O={};function L(C){if(O[C])return O[C].exports;var u=O[C]={i:C,l:!1,exports:{}};return T[C].call(u.exports,u,u.exports,L),u.l=!0,u.exports}L.m=T,L.c=O,L.i=function(C){return C},L.d=function(C,u,o){L.o(C,u)||Object.defineProperty(C,u,{configurable:!1,enumerable:!0,get:o})},L.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},L.n=function(C){var u=C&&C.__esModule?function(){return C.default}:function(){return C};return L.d(u,"a",u),u},L.o=function(C,u){return Object.prototype.hasOwnProperty.call(C,u)},L.p="/",L.oe=function(C){throw console.error(C),C};var A=L(L.s=ENTRY_MODULE);return A.default||A}var F="[\\.|\\-|\\+|\\w|/|@]+",M="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+F+").*?\\)";function z(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function H(T){return!isNaN(1*T)}function N(T,O,L){var A={};A[L]=[];var C=O.toString(),u=C.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return A;for(var o=u[1],l=new RegExp("(\\\\n|\\W)"+z(o)+M,"g"),h;h=l.exec(C);){if(h[3]==="dll-reference")continue;A[L].push(h[3])}for(l=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+F+'))"\\)\\)'+M,"g");h=l.exec(C);)T[h[2]]||(A[L].push(h[1]),T[h[2]]=D(h[1]).m),A[h[2]]=A[h[2]]||[],A[h[2]].push(h[4]);for(var w=Object.keys(A),y=0;y<w.length;y++)for(var g=0;g<A[w[y]].length;g++)H(A[w[y]][g])&&(A[w[y]][g]=1*A[w[y]][g]);return A}function R(T){var O=Object.keys(T);return O.reduce(function(L,A){return L||T[A].length>0},!1)}function v(T,O){for(var L={main:[O]},A={main:[]},C={main:{}};R(L);)for(var u=Object.keys(L),o=0;o<u.length;o++){var l=u[o],h=L[l],w=h.pop();if(C[l]=C[l]||{},C[l][w]||!T[l][w])continue;C[l][w]=!0,A[l]=A[l]||[],A[l].push(w);for(var y=N(T,T[l][w],l),g=Object.keys(y),k=0;k<g.length;k++)L[g[k]]=L[g[k]]||[],L[g[k]]=L[g[k]].concat(y[g[k]])}return A}oe.exports=function(T,O){O=O||{};var L={main:D.m},A=O.all?{main:Object.keys(L.main)}:v(L,T),C="";Object.keys(A).filter(function(w){return w!=="main"}).forEach(function(w){for(var y=0;A[w][y];)y++;A[w].push(y),L[w][y]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+w+" = ("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+A[w].map(function(g){return""+JSON.stringify(g)+": "+L[w][g].toString()}).join(",")+`});
`}),C=C+"new (("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+A.main.map(function(w){return""+JSON.stringify(w)+": "+L.main[w].toString()}).join(",")+"}))(self);";var u=new window.Blob([C],{type:"text/javascript"});if(O.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.createObjectURL(u),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(oe,$,D){"use strict";D.r($),D.d($,"hlsDefaultConfig",function(){return k}),D.d($,"mergeConfig",function(){return f}),D.d($,"enableStreamingMode",function(){return p});var Z=D("./src/controller/abr-controller.ts"),F=D("./src/controller/audio-stream-controller.ts"),M=D("./src/controller/audio-track-controller.ts"),z=D("./src/controller/subtitle-stream-controller.ts"),H=D("./src/controller/subtitle-track-controller.ts"),N=D("./src/controller/buffer-controller.ts"),R=D("./src/controller/timeline-controller.ts"),v=D("./src/controller/cap-level-controller.ts"),T=D("./src/controller/fps-controller.ts"),O=D("./src/controller/eme-controller.ts"),L=D("./src/controller/cmcd-controller.ts"),A=D("./src/utils/xhr-loader.ts"),C=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 b=arguments[a];for(var m in b)Object.prototype.hasOwnProperty.call(b,m)&&(d[m]=b[m])}return d},h.apply(this,arguments)}function w(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(d);a&&(m=m.filter(function(E){return Object.getOwnPropertyDescriptor(d,E).enumerable})),b.push.apply(b,m)}return b}function y(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?w(Object(b),!0).forEach(function(m){g(d,m,b[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):w(Object(b)).forEach(function(m){Object.defineProperty(d,m,Object.getOwnPropertyDescriptor(b,m))})}return d}function g(d,a,b){return a in d?Object.defineProperty(d,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):d[a]=b,d}var k=y(y({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:A.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Z.default,bufferController:N.default,capLevelController:v.default,fpsController:T.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},x()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:H.default,timelineController:R.TimelineController,audioStreamController:F.default,audioTrackController:M.default,emeController:O.default,cmcdController:L.default});function x(){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 p(d){var a=d.loader;if(a!==C.default&&a!==A.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var b=Object(C.fetchSupported)();b&&(d.loader=C.default,d.progressive=!0,d.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/ewma-bandwidth-estimator.ts"),M=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),H=D("./src/errors.ts"),N=D("./src/types/loader.ts"),R=D("./src/utils/logger.ts");function v(L,A){for(var C=0;C<A.length;C++){var u=A[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function T(L,A,C){return A&&v(L.prototype,A),C&&v(L,C),L}var O=function(){function L(C){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=C;var u=C.config;this.bwEstimator=new F.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var A=L.prototype;return A.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)},A.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)},A.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},A.onFragLoading=function(u,o){var l=o.frag;if(l.type===N.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=o.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},A.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)},A._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,w=l.config,y=l.media;if(!u||!y)return;var g=o?o.stats:u.stats,k=o?o.duration:u.duration;if(g.aborted){R.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||y.paused||!y.playbackRate||!y.readyState)return;var x=performance.now()-g.loading.start,f=Math.abs(y.playbackRate);if(x<=500*k/f)return;var p=l.levels,d=l.minAutoLevel,a=p[u.level],b=g.total||Math.max(g.loaded,Math.round(k*a.maxBitrate/8)),m=Math.max(1,g.bwEstimate?g.bwEstimate/8:g.loaded*1e3/x),E=(b-g.loaded)/m,B=y.currentTime,U=(z.BufferHelper.bufferInfo(y,B,w.maxBufferHole).end-B)/f;if(U>=2*k/f||E<=U)return;var K=Number.POSITIVE_INFINITY,V;for(V=u.level-1;V>d;V--){var P=p[V].maxBitrate;if(K=k*P/(8*.8*m),K<U)break}if(K>=E)return;var _=this.bwEstimator.getEstimate();R.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 "+V+`
Current BW estimate: `+(Object(Z.isFiniteNumber)(_)?(_/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+E.toFixed(3)+` s
Estimated load time for the next fragment: `+K.toFixed(3)+` s
Time to underbuffer: `+U.toFixed(3)+" s"),l.nextLoadLevel=V,this.bwEstimator.sample(x,g.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:g})},A.onFragLoaded=function(u,o){var l=o.frag,h=o.part;if(l.type===N.PlaylistLevelType.MAIN&&Object(Z.isFiniteNumber)(l.sn)){var w=h?h.stats:l.stats,y=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[l.level],k=(g.loaded?g.loaded.bytes:0)+w.loaded,x=(g.loaded?g.loaded.duration:0)+y;g.loaded={bytes:k,duration:x},g.realBitrate=Math.round(8*k/x)}if(l.bitrateTest){var f={stats:w,frag:l,part:h,id:l.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,f),l.bitrateTest=!1}}},A.onFragBuffered=function(u,o){var l=o.frag,h=o.part,w=h?h.stats:l.stats;if(w.aborted)return;if(l.type!==N.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var y=w.parsing.end-w.loading.start;this.bwEstimator.sample(y,w.loaded),w.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=y/1e3:this.bitrateTestDelay=0},A.onError=function(u,o){switch(o.details){case H.ErrorDetails.FRAG_LOAD_ERROR:case H.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var u=this.fragCurrent,o=this.partCurrent,l=this.hls,h=l.maxAutoLevel,w=l.config,y=l.minAutoLevel,g=l.media,k=o?o.duration:u?u.duration:0,x=g?g.currentTime:0,f=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():w.abrEwmaDefaultEstimate,d=(z.BufferHelper.bufferInfo(g,x,w.maxBufferHole).end-x)/f,a=this.findBestLevel(p,y,h,d,w.abrBandWidthFactor,w.abrBandWidthUpFactor);if(a>=0)return a;R.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=k?Math.min(k,w.maxStarvationDelay):w.maxStarvationDelay,m=w.abrBandWidthFactor,E=w.abrBandWidthUpFactor;if(!d){var B=this.bitrateTestDelay;if(B){var U=k?Math.min(k,w.maxLoadingDelay):w.maxLoadingDelay;b=U-B,R.logger.trace("bitrate test took "+Math.round(1e3*B)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),m=E=1}}return a=this.findBestLevel(p,y,h,d+b,m,E),Math.max(a,0)},A.findBestLevel=function(u,o,l,h,w,y){for(var g,k=this.fragCurrent,x=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,d=p[f],a=!!(d!=null&&(g=d.details)!==null&&g!==void 0&&g.live),b=d==null?void 0:d.codecSet,m=x?x.duration:k?k.duration:0,E=l;E>=o;E--){var B=p[E];if(!B||b&&B.codecSet!==b)continue;var U=B.details,K=(x?U==null?void 0:U.partTarget:U==null?void 0:U.averagetargetduration)||m,V=void 0;E<=f?V=w*u:V=y*u;var P=p[E].maxBitrate,_=P*K/V;if(R.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+E+"/"+Math.round(V)+"/"+P+"/"+K+"/"+h+"/"+_),V>P&&(!_||a&&!this.bitrateTestDelay||_<h))return E}return-1},T(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}();$.default=O},"./src/controller/audio-stream-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/polyfills/number.ts"),F=D("./src/controller/base-stream-controller.ts"),M=D("./src/events.ts"),z=D("./src/utils/buffer-helper.ts"),H=D("./src/controller/fragment-tracker.ts"),N=D("./src/types/level.ts"),R=D("./src/types/loader.ts"),v=D("./src/loader/fragment.ts"),T=D("./src/demux/chunk-cache.ts"),O=D("./src/demux/transmuxer-interface.ts"),L=D("./src/types/transmuxer.ts"),A=D("./src/controller/fragment-finders.ts"),C=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 x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(k[p]=f[p])}return k},l.apply(this,arguments)}function h(k,x){k.prototype=Object.create(x.prototype),k.prototype.constructor=k,w(k,x)}function w(k,x){return w=Object.setPrototypeOf||function(p,d){return p.__proto__=d,p},w(k,x)}var y=100,g=function(k){h(x,k);function x(p,d){var a;return a=k.call(this,p,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=x.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 b=a.frag,m=a.id,E=a.initPTS;if(m==="main"){var B=b.cc;this.initPTS[b.cc]=E,this.log("InitPTS for cc: "+B+" found from main: "+E),this.videoTrackCC=B,this.state===F.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=F.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(y),this.fragLoadError=0,a>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=F.State.IDLE):(this.loadedmetadata=!1,this.state=F.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},f.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_TRACK:{var d,a=this.levels,b=this.trackId,m=a==null||((d=a[b])===null||d===void 0)?void 0:d.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=F.State.WAITING_INIT_PTS}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var E,B=performance.now(),U=this.retryDate;(!U||B>=U||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=F.State.IDLE);break}case F.State.WAITING_INIT_PTS:{var K=this.waitingData;if(K){var V=K.frag,P=K.part,_=K.cache,Y=K.complete;if(this.initPTS[V.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=F.State.FRAG_LOADING;var ee=_.flush(),ae={frag:V,part:P,payload:ee,networkDetails:null};this._handleFragmentLoadProgress(ae),Y&&k.prototype._handleFragmentLoadComplete.call(this,ae)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+V.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ce=this.getLoadPosition(),De=z.BufferHelper.bufferInfo(this.mediaBuffer,ce,this.config.maxBufferHole),Se=Object(A.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,V);Se<0&&(o.logger.log("Waiting fragment cc ("+V.cc+") @ "+V.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=F.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=F.State.IDLE)},f.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:d,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},f.doTickIdle=function(){var d,a,b=this.hls,m=this.levels,E=this.media,B=this.trackId,U=b.config;if(!m||!m[B])return;if(!E&&(this.startFragRequested||!U.startFragPrefetch))return;var K=m[B],V=K.details;if(!V||V.live&&this.levelLastLoaded!==B||this.waitForCdnTuneIn(V)){this.state=F.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,R.PlaylistLevelType.AUDIO));var P=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,R.PlaylistLevelType.AUDIO);if(P===null)return;var _=P.len,Y=this.getMaxBufferLength(),ee=this.audioSwitch;if(_>=Y&&!ee)return;if(!ee&&this._streamEnded(P,V)){b.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=F.State.ENDED;return}var ae=V.fragments,ce=ae[0].start,De=P.end;if(ee){var Se=this.getLoadPosition();De=Se,V.PTSKnown&&Se<ce&&((P.end>ce||P.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),E.currentTime=ce+.05))}var Ce=this.getNextFragment(De,V);if(!Ce){this.bufferFlushed=!0;return}((d=Ce.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=Ce.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Ce,V):this.loadFragment(Ce,V,De)},f.getMaxBufferLength=function(){var d=k.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,R.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 b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(m){return new N.Level(m)})},f.onAudioTrackSwitching=function(d,a){var b=!!a.url;this.trackId=a.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(y):this.resetTransmuxer(),b?(this.audioSwitch=!0,this.state=F.State.IDLE):this.state=F.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 b,m=this.levels,E=a.details,B=a.id;if(!m){this.warn("Audio tracks were reset while loading level "+B);return}this.log("Track "+B+" loaded ["+E.startSN+","+E.endSN+"],duration:"+E.totalduration);var U=m[B],K=0;if(E.live||(b=U.details)!==null&&b!==void 0&&b.live){var V=this.mainDetails;if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed||!V)return;!U.details&&E.hasProgramDateTime&&V.hasProgramDateTime?(Object(C.alignMediaPlaylistByPDT)(E,V),K=E.fragments[0].start):K=this.alignPlaylists(E,U.details)}U.details=E,this.levelLastLoaded=B,!this.startFragRequested&&(this.mainDetails||!E.live)&&this.setStartPosition(U.details,K),this.state===F.State.WAITING_TRACK&&!this.waitForCdnTuneIn(E)&&(this.state=F.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(d){var a,b=d.frag,m=d.part,E=d.payload,B=this.config,U=this.trackId,K=this.levels;if(!K){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+b.sn+" of level "+b.level+" will not be buffered");return}var V=K[U];console.assert(V,"Audio track is defined on fragment load progress");var P=V.details;console.assert(P,"Audio track details are defined on fragment load progress");var _=B.defaultAudioCodec||V.audioCodec||"mp4a.40.2",Y=this.transmuxer;Y||(Y=this.transmuxer=new O.default(this.hls,R.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ee=this.initPTS[b.cc],ae=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(ee!==void 0){var ce=!1,De=m?m.index:-1,Se=De!==-1,Ce=new L.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,E.byteLength,De,Se);Y.push(E,ae,_,"",b,m,P.totalduration,ce,Ce,ee)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+U);var Ae=this.waitingData=this.waitingData||{frag:b,part:m,cache:new T.default,complete:!1},Te=Ae.cache;Te.push(new Uint8Array(E)),this.waitingVideoCC=this.videoTrackCC,this.state=F.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 b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(d,a){var b=a.frag,m=a.part;if(b.type!==R.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(m?" p: "+m.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,m)},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(R.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==F.State.ERROR&&this.state!==F.State.STOPPED&&(this.state=a.fatal?F.State.ERROR:F.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===F.State.PARSING||this.state===F.State.PARSED)){var b=!0,m=this.getFwdBufferInfo(this.mediaBuffer,R.PlaylistLevelType.AUDIO);m&&m.len>.5&&(b=!this.reduceMaxBufferLength(m.len)),b&&(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 b=a.type;b===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(d){var a,b="audio",m=this.hls,E=d.remuxResult,B=d.chunkMeta,U=this.getCurrentContext(B);if(!U){this.warn("The loading context changed while buffering fragment "+B.sn+" of level "+B.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(B.level);return}var K=U.frag,V=U.part,P=E.audio,_=E.text,Y=E.id3,ee=E.initSegment;if(this.fragContextChanged(K))return;if(this.state=F.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),ee!=null&&ee.tracks&&(this._bufferInitSegment(ee.tracks,K,B),m.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:K,id:b,tracks:ee.tracks})),P){var ae=P.startPTS,ce=P.endPTS,De=P.startDTS,Se=P.endDTS;V&&(V.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ae,endPTS:ce,startDTS:De,endDTS:Se}),K.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ae,ce,De,Se),this.bufferFragmentData(P,K,V,B)}if(Y!=null&&(a=Y.samples)!==null&&a!==void 0&&a.length){var Ce=l({frag:K,id:b},Y);m.trigger(M.Events.FRAG_PARSING_METADATA,Ce)}if(_){var Ae=l({frag:K,id:b},_);m.trigger(M.Events.FRAG_PARSING_USERDATA,Ae)}},f._bufferInitSegment=function(d,a,b){if(this.state!==F.State.PARSING)return;d.video&&delete d.video;var m=d.audio;if(!m)return;m.levelCodec=m.codec,m.id="audio",this.log("Init audio buffer, container:"+m.container+", codecs[parsed]=["+m.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,d);var E=m.initSegment;if(E!=null&&E.byteLength){var B={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:E};this.hls.trigger(M.Events.BUFFER_APPENDING,B)}this.tick()},f.loadFragment=function(d,a,b){var m=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||m===H.FragmentState.NOT_LOADED||m===H.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):a.live&&!Object(Z.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=F.State.WAITING_INIT_PTS):(this.startFragRequested=!0,k.prototype.loadFragment.call(this,d,a,b)))},f.completeAudioSwitch=function(){var d=this.hls,a=this.media,b=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:b})},x}(F.default);$.default=g},"./src/controller/audio-track-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts"),F=D("./src/errors.ts"),M=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function H(O,L){for(var A=0;A<L.length;A++){var C=L[A];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(O,C.key,C)}}function N(O,L,A){return L&&H(O.prototype,L),A&&H(O,A),O}function R(O,L){O.prototype=Object.create(L.prototype),O.prototype.constructor=O,v(O,L)}function v(O,L){return v=Object.setPrototypeOf||function(C,u){return C.__proto__=u,C},v(O,L)}var T=function(O){R(L,O);function L(C){var u;return u=O.call(this,C,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var A=L.prototype;return A.registerListeners=function(){var u=this.hls;u.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(Z.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var u=this.hls;u.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(Z.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,O.prototype.destroy.call(this)},A.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},A.onManifestParsed=function(u,o){this.tracks=o.audioTracks||[]},A.onAudioTrackLoaded=function(u,o){var l=o.id,h=o.details,w=this.tracksInGroup[l];if(!w){this.warn("Invalid audio track id "+l);return}var y=w.details;w.details=o.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,y))},A.onLevelLoading=function(u,o){this.switchLevel(o.level)},A.onLevelSwitching=function(u,o){this.switchLevel(o.level)},A.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(y){return!l||y.groupId===l});this.selectDefaultTrack&&!h.some(function(y){return y.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var w={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(Z.Events.AUDIO_TRACKS_UPDATED,w),this.selectInitialTrack()}},A.onError=function(u,o){if(O.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===z.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},A.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],w=h.id,y=h.groupId,g=y===void 0?"":y,k=h.name,x=h.type,f=h.url;if(this.trackId=u,this.trackName=k,this.selectDefaultTrack=!1,this.hls.trigger(Z.Events.AUDIO_TRACK_SWITCHING,{id:w,groupId:g,name:k,type:x,url:f}),h.details&&!h.details.live)return;var p=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(p)},A.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(Z.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.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},A.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,h=o.groupId,w=o.url;if(u)try{w=u.addDirectives(w)}catch(y){this.warn("Could not construct new URL with HLS Delivery Directives: "+y)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(Z.Events.AUDIO_TRACK_LOADING,{url:w,id:l,groupId:h,deliveryDirectives:u||null})}},N(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);$.default=T},"./src/controller/base-playlist-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return N});var Z=D("./src/polyfills/number.ts"),F=D("./src/types/level.ts"),M=D("./src/controller/level-helper.ts"),z=D("./src/utils/logger.ts"),H=D("./src/errors.ts"),N=function(){function R(T,O){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=z.logger.log.bind(z.logger,O+":"),this.warn=z.logger.warn.bind(z.logger,O+":"),this.hls=T}var v=R.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(O,L){L.fatal&&L.type===H.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},v.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},v.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},v.stopLoad=function(){this.canLoad=!1,this.clearTimer()},v.switchParams=function(O,L){var A=L==null?void 0:L.renditionReports;if(A)for(var C=0;C<A.length;C++){var u=A[C],o=""+u.URI;if(o===O.substr(-o.length)){var l=parseInt(u["LAST-MSN"]),h=parseInt(u["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var w=Math.min(L.age-L.partTarget,L.targetduration);h!==void 0&&w>L.partTarget&&(h+=1)}if(Object(Z.isFiniteNumber)(l))return new F.HlsUrlParameters(l,Object(Z.isFiniteNumber)(h)?h:void 0,F.HlsSkip.No)}}},v.loadPlaylist=function(O){},v.shouldLoadTrack=function(O){return this.canLoad&&O&&!!O.url&&(!O.details||O.details.live)},v.playlistLoaded=function(O,L,A){var C=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||A!=null&&A.live){if(u.reloaded(A),A&&this.log("live playlist "+O+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),A&&u.fragments.length>0&&Object(M.mergeDetails)(A,u),!this.canLoad||!u.live)return;var h,w=void 0,y=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var g=this.hls.config.lowLatencyMode,k=u.lastPartSn,x=u.endSN,f=u.lastPartIndex,p=f!==-1,d=k===x,a=g?0:f;p?(w=d?x+1:k,y=d?a:f+1):w=x+1;var b=u.age,m=b+u.ageHeader,E=Math.min(m-u.partTarget,u.targetduration*1.5);if(E>0){if(A&&E>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+E+" with playlist age: "+u.age),E=0;else{var B=Math.floor(E/u.targetduration);if(w+=B,y!==void 0){var U=Math.round(E%u.targetduration/u.partTarget);y+=U}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+E+" skip sn "+B+" to part "+y)}u.tuneInGoal=E}if(h=this.getDeliveryDirectives(u,L.deliveryDirectives,w,y),g||!d){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(u,L.deliveryDirectives,w,y);var K=Object(M.computeReloadInterval)(u,o);w!==void 0&&u.canBlockReload&&(K-=u.partTarget||1),this.log("reload live playlist "+O+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return C.loadPlaylist(h)},K)}else this.clearTimer()},v.getDeliveryDirectives=function(O,L,A,C){var u=Object(F.getSkipValue)(O,A);return L!=null&&L.skip&&O.deltaUpdateFailed&&(A=L.msn,C=L.part,u=F.HlsSkip.No),new F.HlsUrlParameters(A,C,u)},v.retryLoadingOrFail=function(O){var L=this,A=this.hls.config,C=this.retryCount<A.levelLoadingMaxRetry;if(C){var u;if(this.retryCount++,O.details.indexOf("LoadTimeOut")>-1&&(u=O.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+O.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+O.details+'"')}}else this.warn('cannot recover from error "'+O.details+'"'),this.clearTimer(),O.fatal=!0;return C},R}()},"./src/controller/base-stream-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"State",function(){return x}),D.d($,"default",function(){return f});var Z=D("./src/polyfills/number.ts"),F=D("./src/task-loop.ts"),M=D("./src/controller/fragment-tracker.ts"),z=D("./src/utils/buffer-helper.ts"),H=D("./src/utils/logger.ts"),N=D("./src/events.ts"),R=D("./src/errors.ts"),v=D("./src/types/transmuxer.ts"),T=D("./src/utils/mp4-tools.ts"),O=D("./src/utils/discontinuities.ts"),L=D("./src/controller/fragment-finders.ts"),A=D("./src/controller/level-helper.ts"),C=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(p,d){for(var a=0;a<d.length;a++){var b=d[a];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function w(p,d,a){return d&&h(p.prototype,d),a&&h(p,a),p}function y(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function g(p,d){p.prototype=Object.create(d.prototype),p.prototype.constructor=p,k(p,d)}function k(p,d){return k=Object.setPrototypeOf||function(b,m){return b.__proto__=m,b},k(p,d)}var x={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(p){g(d,p);function d(b,m,E){var B;return B=p.call(this)||this,B.hls=void 0,B.fragPrevious=null,B.fragCurrent=null,B.fragmentTracker=void 0,B.transmuxer=null,B._state=x.STOPPED,B.media=void 0,B.mediaBuffer=void 0,B.config=void 0,B.bitrateTest=!1,B.lastCurrentTime=0,B.nextLoadPosition=0,B.startPosition=0,B.loadedmetadata=!1,B.fragLoadError=0,B.retryDate=0,B.levels=null,B.fragmentLoader=void 0,B.levelLastLoaded=null,B.startFragRequested=!1,B.decrypter=void 0,B.initPTS=[],B.onvseeking=null,B.onvended=null,B.logPrefix="",B.log=void 0,B.warn=void 0,B.logPrefix=E,B.log=H.logger.log.bind(H.logger,E+":"),B.warn=H.logger.warn.bind(H.logger,E+":"),B.hls=b,B.fragmentLoader=new C.default(b.config),B.fragmentTracker=m,B.config=b.config,B.decrypter=new u.default(b,b.config),b.on(N.Events.KEY_LOADED,B.onKeyLoaded,y(B)),B}var a=d.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(m){},a.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},a._streamEnded=function(m,E){var B=this.fragCurrent,U=this.fragmentTracker;if(!E.live&&B&&B.sn===E.endSN&&!m.nextStart){var K=U.getState(B);return K===M.FragmentState.PARTIAL||K===M.FragmentState.OK}return!1},a.onMediaAttached=function(m,E){var B=this.media=this.mediaBuffer=E.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),B.addEventListener("seeking",this.onvseeking),B.addEventListener("ended",this.onvended);var U=this.config;this.levels&&U.autoStartLoad&&this.state===x.STOPPED&&this.startLoad(U.startPosition)},a.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&(m.removeEventListener("seeking",this.onvseeking),m.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 m=this.config,E=this.fragCurrent,B=this.media,U=this.mediaBuffer,K=this.state,V=B?B.currentTime:0,P=z.BufferHelper.bufferInfo(U||B,V,m.maxBufferHole);if(this.log("media seeking to "+(Object(Z.isFiniteNumber)(V)?V.toFixed(3):V)+", state: "+K),K===x.ENDED)this.resetLoadingState();else if(E&&!P.len){var _=m.maxFragLookUpTolerance,Y=E.start-_,ee=E.start+E.duration+_,ae=V>ee;(V<Y||ae)&&(ae&&E.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),E.loader.abort()),this.resetLoadingState())}B&&(this.lastCurrentTime=V),!this.loadedmetadata&&!P.len&&(this.nextLoadPosition=this.startPosition=V),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(m,E){if(this.state!==x.KEY_LOADING||E.frag!==this.fragCurrent||!this.levels)return;this.state=x.IDLE;var B=this.levels[E.frag.level].details;B&&this.loadFragment(E.frag,B,E.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=x.STOPPED,this.hls.off(N.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,p.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(m,E){this.log("Loading key for "+m.sn+" of ["+E.startSN+"-"+E.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=x.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(N.Events.KEY_LOADING,{frag:m})},a.loadFragment=function(m,E,B){this._loadFragForPlayback(m,E,B)},a._loadFragForPlayback=function(m,E,B){var U=this,K=function(P){if(U.fragContextChanged(m)){U.warn("Fragment "+m.sn+(P.part?" p: "+P.part.index:"")+" of level "+m.level+" was dropped during download."),U.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,U._handleFragmentLoadProgress(P)};this._doFragLoad(m,E,B,K).then(function(V){if(!V)return;U.fragLoadError=0;var P=U.state;if(U.fragContextChanged(m)){(P===x.FRAG_LOADING||P===x.BACKTRACKING||!U.fragCurrent&&P===x.PARSING)&&(U.fragmentTracker.removeFragment(m),U.state=x.IDLE);return}if("payload"in V&&(U.log("Loaded fragment "+m.sn+" of level "+m.level),U.hls.trigger(N.Events.FRAG_LOADED,V),U.state===x.BACKTRACKING)){U.fragmentTracker.backtrack(m,V),U.resetFragmentLoading(m);return}U._handleFragmentLoadComplete(V)}).catch(function(V){U.warn(V),U.resetFragmentLoading(m)})},a.flushMainBuffer=function(m,E,B){if(B===void 0&&(B=null),!(m-E))return;var U={startOffset:m,endOffset:E,type:B};this.fragLoadError=0,this.hls.trigger(N.Events.BUFFER_FLUSHING,U)},a._loadInitSegment=function(m){var E=this;this._doFragLoad(m).then(function(B){if(!B||E.fragContextChanged(m)||!E.levels)throw new Error("init load aborted");return B}).then(function(B){var U=E.hls,K=B.payload,V=m.decryptdata;if(K&&K.byteLength>0&&V&&V.key&&V.iv&&V.method==="AES-128"){var P=self.performance.now();return E.decrypter.webCryptoDecrypt(new Uint8Array(K),V.key.buffer,V.iv.buffer).then(function(_){var Y=self.performance.now();return U.trigger(N.Events.FRAG_DECRYPTED,{frag:m,payload:_,stats:{tstart:P,tdecrypt:Y}}),B.payload=_,B})}return B}).then(function(B){var U=E.fragCurrent,K=E.hls,V=E.levels;if(!V)throw new Error("init load aborted, missing levels");var P=V[m.level].details;console.assert(P,"Level details are defined when init segment is loaded");var _=m.stats;E.state=x.IDLE,E.fragLoadError=0,m.data=new Uint8Array(B.payload),_.parsing.start=_.buffering.start=self.performance.now(),_.parsing.end=_.buffering.end=self.performance.now(),B.frag===U&&K.trigger(N.Events.FRAG_BUFFERED,{stats:_,frag:U,part:null,id:m.type}),E.tick()}).catch(function(B){E.warn(B),E.resetFragmentLoading(m)})},a.fragContextChanged=function(m){var E=this.fragCurrent;return!m||!E||m.level!==E.level||m.sn!==E.sn||m.urlId!==E.urlId},a.fragBufferedComplete=function(m,E){var B=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(E?" part: "+E.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+o.default.toString(z.BufferHelper.getBuffered(B))),this.state=x.IDLE,this.tick()},a._handleFragmentLoadComplete=function(m){var E=this.transmuxer;if(!E)return;var B=m.frag,U=m.part,K=m.partsLoaded,V=!K||K.length===0||K.some(function(_){return!_}),P=new v.ChunkMetadata(B.level,B.sn,B.stats.chunkCount+1,0,U?U.index:-1,!V);E.flush(P)},a._handleFragmentLoadProgress=function(m){},a._doFragLoad=function(m,E,B,U){var K=this;if(B===void 0&&(B=null),!this.levels)throw new Error("frag load aborted, missing levels");if(B=Math.max(m.start,B||0),this.config.lowLatencyMode&&E){var V=E.partList;if(V&&U){B>m.end&&E.fragmentHint&&(m=E.fragmentHint);var P=this.getNextPart(V,m,B);if(P>-1){var _=V[P];return this.log("Loading part sn: "+m.sn+" p: "+_.index+" cc: "+m.cc+" of playlist ["+E.startSN+"-"+E.endSN+"] parts [0-"+P+"-"+(V.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(B.toFixed(3))),this.nextLoadPosition=_.start+_.duration,this.state=x.FRAG_LOADING,this.hls.trigger(N.Events.FRAG_LOADING,{frag:m,part:V[P],targetBufferTime:B}),this.doFragPartsLoad(m,V,P,U).catch(function(Y){return K.handleFragLoadError(Y)})}else if(!m.url||this.loadedEndOfParts(V,B))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(E?"of ["+E.startSN+"-"+E.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(B.toFixed(3))),Object(Z.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=x.FRAG_LOADING,this.hls.trigger(N.Events.FRAG_LOADING,{frag:m,targetBufferTime:B}),this.fragmentLoader.load(m,U).catch(function(Y){return K.handleFragLoadError(Y)})},a.doFragPartsLoad=function(m,E,B,U){var K=this;return new Promise(function(V,P){var _=[],Y=function ee(ae){var ce=E[ae];K.fragmentLoader.loadPart(m,ce,U).then(function(De){_[ce.index]=De;var Se=De.part;K.hls.trigger(N.Events.FRAG_LOADED,De);var Ce=E[ae+1];if(Ce&&Ce.fragment===m)ee(ae+1);else return V({frag:m,part:Se,partsLoaded:_})}).catch(P)};Y(B)})},a.handleFragLoadError=function(m){var E=m.data;return E&&E.details===R.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(E.frag,E.part):this.hls.trigger(N.Events.ERROR,E),null},a._handleTransmuxerFlush=function(m){var E=this.getCurrentContext(m);if(!E||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var B=E.frag,U=E.part,K=E.level,V=self.performance.now();B.stats.parsing.end=V,U&&(U.stats.parsing.end=V),this.updateLevelTiming(B,U,K,m.partial)},a.getCurrentContext=function(m){var E=this.levels,B=m.level,U=m.sn,K=m.part;if(!E||!E[B])return this.warn("Levels object was unset while buffering fragment "+U+" of level "+B+". The current chunk will not be buffered."),null;var V=E[B],P=K>-1?Object(A.getPartWith)(V,U,K):null,_=P?P.fragment:Object(A.getFragmentWithSN)(V,U,this.fragCurrent);return _?{frag:_,part:P,level:V}:null},a.bufferFragmentData=function(m,E,B,U){if(!m||this.state!==x.PARSING)return;var K=m.data1,V=m.data2,P=K;if(K&&V&&(P=Object(T.appendUint8Array)(K,V)),!P||!P.length)return;var _={type:m.type,frag:E,part:B,chunkMeta:U,parent:E.type,data:P};this.hls.trigger(N.Events.BUFFER_APPENDING,_),m.dropped&&m.independent&&!B&&this.flushBufferGap(E)},a.flushBufferGap=function(m){var E=this.media;if(!E)return;if(!z.BufferHelper.isBuffered(E,E.currentTime)){this.flushMainBuffer(0,m.start);return}var B=E.currentTime,U=z.BufferHelper.bufferInfo(E,B,0),K=m.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,K*.25),P=Math.max(Math.min(m.start-V,U.end-V),B+V);m.start-P>V&&this.flushMainBuffer(P,m.start)},a.getFwdBufferInfo=function(m,E){var B=this.config,U=this.getLoadPosition();if(!Object(Z.isFiniteNumber)(U))return null;var K=z.BufferHelper.bufferInfo(m,U,B.maxBufferHole);if(K.len===0&&K.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(U,E);if(V&&K.nextStart<V.end)return z.BufferHelper.bufferInfo(m,U,Math.max(K.nextStart,B.maxBufferHole))}return K},a.getMaxBufferLength=function(m){var E=this.config,B;return m?B=Math.max(8*E.maxBufferSize/m,E.maxBufferLength):B=E.maxBufferLength,Math.min(B,E.maxMaxBufferLength)},a.reduceMaxBufferLength=function(m){var E=this.config,B=m||E.maxBufferLength;return E.maxMaxBufferLength>=B?(E.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+E.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(m,E){var B,U,K=E.fragments,V=K.length;if(!V)return null;var P=this.config,_=K[0].start,Y;if(E.live){var ee=P.initialLiveManifestSize;if(V<ee)return this.warn("Not enough fragments to start playback (have: "+V+", need: "+ee+")"),null;!E.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Y=this.getInitialLiveFragment(E,K),this.startPosition=Y?this.hls.liveSyncPosition||Y.start:m)}else m<=_&&(Y=K[0]);if(!Y){var ae=P.lowLatencyMode?E.partEnd:E.fragmentEnd;Y=this.getFragmentAtPosition(m,ae,E)}return(B=Y)!==null&&B!==void 0&&B.initSegment&&!((U=Y)!==null&&U!==void 0&&U.initSegment.data)&&!this.bitrateTest&&(Y=Y.initSegment),Y},a.getNextPart=function(m,E,B){for(var U=-1,K=!1,V=!0,P=0,_=m.length;P<_;P++){var Y=m[P];if(V=V&&!Y.independent,U>-1&&B<Y.start)break;var ee=Y.loaded;!ee&&(K||Y.independent||V)&&Y.fragment===E&&(U=P),K=ee}return U},a.loadedEndOfParts=function(m,E){var B=m[m.length-1];return B&&E>B.start&&B.loaded},a.getInitialLiveFragment=function(m,E){var B=this.fragPrevious,U=null;if(B){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+B.programDateTime),U=Object(L.findFragmentByPDT)(E,B.endProgramDateTime,this.config.maxFragLookUpTolerance)),!U){var K=B.sn+1;if(K>=m.startSN&&K<=m.endSN){var V=E[K-m.startSN];B.cc===V.cc&&(U=V,this.log("Live playlist, switching playlist, load frag with next SN: "+U.sn))}U||(U=Object(L.findFragWithCC)(E,B.cc),U&&this.log("Live playlist, switching playlist, load frag with same CC: "+U.sn))}}else{var P=this.hls.liveSyncPosition;P!==null&&(U=this.getFragmentAtPosition(P,this.bitrateTest?m.fragmentEnd:m.edge,m))}return U},a.getFragmentAtPosition=function(m,E,B){var U=this.config,K=this.fragPrevious,V=B.fragments,P=B.endSN,_=B.fragmentHint,Y=U.maxFragLookUpTolerance,ee=!!(U.lowLatencyMode&&B.partList&&_);ee&&_&&!this.bitrateTest&&(V=V.concat(_),P=_.sn);var ae;if(m<E){var ce=m>E-Y?0:Y;ae=Object(L.findFragmentByPTS)(K,V,m,ce)}else ae=V[V.length-1];if(ae){var De=ae.sn-B.startSN,Se=K&&ae.level===K.level,Ce=V[De+1],Ae=this.fragmentTracker.getState(ae);if(Ae===M.FragmentState.BACKTRACKED){ae=null;for(var Te=De;V[Te]&&this.fragmentTracker.getState(V[Te])===M.FragmentState.BACKTRACKED;)K?ae=V[Te--]:ae=V[--Te];ae||(ae=Ce)}else K&&ae.sn===K.sn&&!ee&&(Se&&(ae.sn<P&&this.fragmentTracker.getState(Ce)!==M.FragmentState.OK?(this.log("SN "+ae.sn+" just loaded, load next one: "+Ce.sn),ae=Ce):ae=null))}return ae},a.synchronizeToLiveEdge=function(m){var E=this.config,B=this.media;if(!B)return;var U=this.hls.liveSyncPosition,K=B.currentTime,V=m.fragments[0].start,P=m.edge,_=K>=V-E.maxFragLookUpTolerance&&K<=P;if(U!==null&&B.duration>U&&(K<U||!_)){var Y=E.liveMaxLatencyDuration!==void 0?E.liveMaxLatencyDuration:E.liveMaxLatencyDurationCount*m.targetduration;(!_&&B.readyState<4||K<P-Y)&&(this.loadedmetadata||(this.nextLoadPosition=U),B.readyState&&(this.warn("Playback: "+K.toFixed(3)+" is located too far from the end of live sliding playlist: "+P+", reset currentTime to : "+U.toFixed(3)),B.currentTime=U))}},a.alignPlaylists=function(m,E){var B=this.levels,U=this.levelLastLoaded,K=this.fragPrevious,V=U!==null?B[U]:null,P=m.fragments.length;if(!P)return this.warn("No fragments in live playlist"),0;var _=m.fragments[0].start,Y=!E,ee=m.alignedSliding&&Object(Z.isFiniteNumber)(_);if(Y||!ee&&!_){Object(O.alignStream)(K,V,m);var ae=m.fragments[0].start;return this.log("Live playlist sliding: "+ae.toFixed(2)+" start-sn: "+(E?E.startSN:"na")+"->"+m.startSN+" prev-sn: "+(K?K.sn:"na")+" fragments: "+P),ae}return _},a.waitForCdnTuneIn=function(m){var E=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*E)},a.setStartPosition=function(m,E){var B=this.startPosition;if(B<E&&(B=-1),B===-1||this.lastCurrentTime===-1){var U=m.startTimeOffset;Object(Z.isFiniteNumber)(U)?(B=E+U,U<0&&(B+=m.totalduration),B=Math.min(Math.max(E,B),E+m.totalduration),this.log("Start time offset "+U+" found in playlist, adjust startPosition to "+B),this.startPosition=B):m.live?B=this.hls.liveSyncPosition||E:this.startPosition=B=0,this.lastCurrentTime=B}this.nextLoadPosition=B},a.getLoadPosition=function(){var m=this.media,E=0;return this.loadedmetadata&&m?E=m.currentTime:this.nextLoadPosition&&(E=this.nextLoadPosition),E},a.handleFragLoadAborted=function(m,E){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(E?" part"+E.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},a.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=x.IDLE)},a.onFragmentOrKeyLoadError=function(m,E){if(E.fatal)return;var B=E.frag;if(!B||B.type!==m)return;var U=this.fragCurrent;console.assert(U&&B.sn===U.sn&&B.level===U.level&&B.urlId===U.urlId,"Frag load error must match current frag to retry");var K=this.config;if(this.fragLoadError+1<=K.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(B.level))return;var V=Math.min(Math.pow(2,this.fragLoadError)*K.fragLoadingRetryDelay,K.fragLoadingMaxRetryTimeout);this.warn("Fragment "+B.sn+" of "+m+" "+B.level+" failed to load, retrying in "+V+"ms"),this.retryDate=self.performance.now()+V,this.fragLoadError++,this.state=x.FRAG_LOADING_WAITING_RETRY}else E.levelRetry?(m===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(H.logger.error(E.details+" reaches max retry, redispatch as fatal ..."),E.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},a.afterBufferFlushed=function(m,E,B){if(!m)return;var U=z.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(E,U,B),this.state===x.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},a.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var E=this.levels?this.levels[m].details:null;if(E!=null&&E.live)return this.startPosition=-1,this.setStartPosition(E,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(m,E,B,U){var K=this,V=B.details;console.assert(!!V,"level.details must be defined");var P=Object.keys(m.elementaryStreams).reduce(function(_,Y){var ee=m.elementaryStreams[Y];if(ee){var ae=ee.endPTS-ee.startPTS;if(ae<=0)return K.warn("Could not parse fragment "+m.sn+" "+Y+" duration reliably ("+ae+") resetting transmuxer to fallback to playlist timing"),K.resetTransmuxer(),_||!1;var ce=U?0:Object(A.updateFragPTSDTS)(V,m,ee.startPTS,ee.endPTS,ee.startDTS,ee.endDTS);return K.hls.trigger(N.Events.LEVEL_PTS_UPDATED,{details:V,level:B,drift:ce,type:Y,frag:m,start:ee.startPTS,end:ee.endPTS}),!0}return _},!1);P?(this.state=x.PARSED,this.hls.trigger(N.Events.FRAG_PARSED,{frag:m,part:E})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},w(d,[{key:"state",get:function(){return this._state},set:function(m){var E=this._state;E!==m&&(this._state=m,this.log(E+"->"+m))}}]),d}(F.default)},"./src/controller/buffer-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var Z=D("./src/polyfills/number.ts"),F=D("./src/events.ts"),M=D("./src/utils/logger.ts"),z=D("./src/errors.ts"),H=D("./src/utils/buffer-helper.ts"),N=D("./src/utils/mediasource-helper.ts"),R=D("./src/loader/fragment.ts"),v=D("./src/controller/buffer-operation-queue.ts"),T=Object(N.getMediaSource)(),O=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function A(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,w=o.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),h&&(o.updateMediaElementDuration(),l.trigger(F.Events.MEDIA_ATTACHED,{media:h})),w&&w.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 C=A.prototype;return C.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},C.destroy=function(){this.unregisterListeners(),this.details=null},C.registerListeners=function(){var o=this.hls;o.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(F.Events.BUFFER_RESET,this.onBufferReset,this),o.on(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(F.Events.BUFFER_EOS,this.onBufferEos,this),o.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(F.Events.FRAG_PARSED,this.onFragParsed,this),o.on(F.Events.FRAG_CHANGED,this.onFragChanged,this)},C.unregisterListeners=function(){var o=this.hls;o.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(F.Events.BUFFER_RESET,this.onBufferReset,this),o.off(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(F.Events.BUFFER_EOS,this.onBufferEos,this),o.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(F.Events.FRAG_PARSED,this.onFragParsed,this),o.off(F.Events.FRAG_CHANGED,this.onFragChanged,this)},C._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},C.onManifestParsed=function(o,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},C.onMediaAttaching=function(o,l){var h=this.media=l.media;if(h&&T){var w=this.mediaSource=new T;w.addEventListener("sourceopen",this._onMediaSourceOpen),w.addEventListener("sourceended",this._onMediaSourceEnded),w.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(w),this._objectUrl=h.src}},C.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(w){M.logger.warn("[buffer-controller]: onMediaDetaching: "+w.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(F.Events.MEDIA_DETACHED,void 0)},C.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var h=o.sourceBuffer[l];try{h&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(h),o.sourceBuffer[l]=void 0)}catch(w){M.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",w)}}),this._initSourceBuffer()},C.onBufferCodecs=function(o,l){var h=this,w=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(y){if(w){var g=h.tracks[y];if(g&&typeof g.buffer.changeType=="function"){var k=l[y],x=k.codec,f=k.levelCodec,p=k.container,d=(g.levelCodec||g.codec).replace(O,"$1"),a=(f||x).replace(O,"$1");if(d!==a){var b=p+";codecs="+(f||x);h.appendChangeType(y,b)}}}else h.pendingTracks[y]=l[y]}),w)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},C.appendChangeType=function(o,l){var h=this,w=this.operationQueue,y={execute:function(){var k=h.sourceBuffer[o];k&&(M.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),k.changeType(l)),w.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(k){M.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",k)}};w.append(y,o)},C.onBufferAppending=function(o,l){var h=this,w=this.hls,y=this.operationQueue,g=this.tracks,k=l.data,x=l.type,f=l.frag,p=l.part,d=l.chunkMeta,a=d.buffering[x],b=self.performance.now();a.start=b;var m=f.stats.buffering,E=p?p.stats.buffering:null;m.start===0&&(m.start=b),E&&E.start===0&&(E.start=b);var B=g.audio,U=x==="audio"&&d.id===1&&(B==null?void 0:B.container)==="audio/mpeg",K={execute:function(){if(a.executeStart=self.performance.now(),U){var P=h.sourceBuffer[x];if(P){var _=f.start-P.timestampOffset;Math.abs(_)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+_+") sn: "+f.sn+")"),P.timestampOffset=f.start)}}h.appendExecutor(k,x)},onStart:function(){},onComplete:function(){var P=self.performance.now();a.executeEnd=a.end=P,m.first===0&&(m.first=P),E&&E.first===0&&(E.first=P);var _=h.sourceBuffer,Y={};for(var ee in _)Y[ee]=H.BufferHelper.getBuffered(_[ee]);h.appendError=0,h.hls.trigger(F.Events.BUFFER_APPENDED,{type:x,frag:f,part:p,chunkMeta:d,parent:f.type,timeRanges:Y})},onError:function(P){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",P);var _={type:z.ErrorTypes.MEDIA_ERROR,parent:f.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:P,fatal:!1};P.code===DOMException.QUOTA_EXCEEDED_ERR?_.details=z.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,_.details=z.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>w.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+w.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),_.fatal=!0)),w.trigger(F.Events.ERROR,_)}};y.append(K,x)},C.onBufferFlushing=function(o,l){var h=this,w=this.operationQueue,y=function(k){return{execute:h.removeExecutor.bind(h,k,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(F.Events.BUFFER_FLUSHED,{type:k})},onError:function(f){M.logger.warn("[buffer-controller]: Failed to remove from "+k+" SourceBuffer",f)}}};l.type?w.append(y(l.type),l.type):this.getSourceBufferTypes().forEach(function(g){w.append(y(g),g)})},C.onFragParsed=function(o,l){var h=this,w=l.frag,y=l.part,g=[],k=y?y.elementaryStreams:w.elementaryStreams;k[R.ElementaryStreamTypes.AUDIOVIDEO]?g.push("audiovideo"):(k[R.ElementaryStreamTypes.AUDIO]&&g.push("audio"),k[R.ElementaryStreamTypes.VIDEO]&&g.push("video"));var x=function(){var p=self.performance.now();w.stats.buffering.end=p,y&&(y.stats.buffering.end=p);var d=y?y.stats:w.stats;h.hls.trigger(F.Events.FRAG_BUFFERED,{frag:w,part:y,stats:d,id:w.type})};g.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+w.type+" level: "+w.level+" sn: "+w.sn),this.blockBuffers(x,g)},C.onFragChanged=function(o,l){this.flushBackBuffer()},C.onBufferEos=function(o,l){var h=this,w=this.getSourceBufferTypes().reduce(function(y,g){var k=h.sourceBuffer[g];return(!l.type||l.type===g)&&(k&&!k.ended&&(k.ended=!0,M.logger.log("[buffer-controller]: "+g+" sourceBuffer now EOS"))),y&&!!(!k||k.ended)},!0);w&&this.blockBuffers(function(){var y=h.mediaSource;if(!y||y.readyState!=="open")return;y.endOfStream()})},C.onLevelUpdated=function(o,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},C.flushBackBuffer=function(){var o=this.hls,l=this.details,h=this.media,w=this.sourceBuffer;if(!h||l===null)return;var y=this.getSourceBufferTypes();if(!y.length)return;var g=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(Z.isFiniteNumber)(g)||g<0)return;var k=h.currentTime,x=l.levelTargetDuration,f=Math.max(g,x),p=Math.floor(k/x)*x-f;y.forEach(function(d){var a=w[d];if(a){var b=H.BufferHelper.getBuffered(a);b.length>0&&p>b.start(0)&&(o.trigger(F.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),l.live&&o.trigger(F.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),o.trigger(F.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:d}))}})},C.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,h=this.media,w=this.mediaSource,y=o.fragments[0].start+o.totalduration,g=h.duration,k=Object(Z.isFiniteNumber)(w.duration)?w.duration:0;o.live&&l.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),w.duration=Infinity,this.updateSeekableRange(o)):(y>k&&y>g||!Object(Z.isFiniteNumber)(g))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+y.toFixed(3)),w.duration=y)},C.updateSeekableRange=function(o){var l=this.mediaSource,h=o.fragments,w=h.length;if(w&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var y=Math.max(0,h[0].start),g=Math.max(y,y+o.totalduration);l.setLiveSeekableRange(y,g)}},C.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,w=Object.keys(h).length;if(w&&!o||w===2){this.createSourceBuffers(h),this.pendingTracks={};var y=this.getSourceBufferTypes();if(y.length===0){this.hls.trigger(F.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}y.forEach(function(g){l.executeNext(g)})}},C.createSourceBuffers=function(o){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var w=0;for(var y in o)if(!l[y]){var g=o[y];if(!g)throw Error("source buffer exists for track "+y+", however track does not");var k=g.levelCodec||g.codec,x=g.container+";codecs="+k;M.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var f=l[y]=h.addSourceBuffer(x),p=y;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[y]={buffer:f,codec:k,container:g.container,levelCodec:g.levelCodec,id:g.id},w++}catch(d){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(F.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:x})}}w&&this.hls.trigger(F.Events.BUFFER_CREATED,{tracks:this.tracks})},C._onSBUpdateStart=function(o){var l=this.operationQueue,h=l.current(o);h.onStart()},C._onSBUpdateEnd=function(o){var l=this.operationQueue,h=l.current(o);h.onComplete(),l.shiftAndExecuteNext(o)},C._onSBUpdateError=function(o,l){M.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(F.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(o);h&&h.onError(l)},C.removeExecutor=function(o,l,h){var w=this.media,y=this.mediaSource,g=this.operationQueue,k=this.sourceBuffer,x=k[o];if(!w||!y||!x){M.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),g.shiftAndExecuteNext(o);return}var f=Object(Z.isFiniteNumber)(w.duration)?w.duration:Infinity,p=Object(Z.isFiniteNumber)(y.duration)?y.duration:Infinity,d=Math.max(0,l),a=Math.min(h,f,p);a>d?(M.logger.log("[buffer-controller]: Removing ["+d+","+a+"] from the "+o+" SourceBuffer"),console.assert(!x.updating,o+" sourceBuffer must not be updating"),x.remove(d,a)):g.shiftAndExecuteNext(o)},C.appendExecutor=function(o,l){var h=this.operationQueue,w=this.sourceBuffer,y=w[l];if(!y){M.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}y.ended=!1,console.assert(!y.updating,l+" sourceBuffer must not be updating"),y.appendBuffer(o)},C.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 w=this.operationQueue,y=l.map(function(g){return w.appendBlocker(g)});Promise.all(y).then(function(){o(),l.forEach(function(g){var k=h.sourceBuffer[g];(!k||!k.updating)&&w.shiftAndExecuteNext(g)})})},C.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},C.addBufferListener=function(o,l,h){var w=this.sourceBuffer[o];if(!w)return;var y=h.bind(this,o);this.listeners[o].push({event:l,listener:y}),w.addEventListener(l,y)},C.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(h){l.removeEventListener(h.event,h.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return F});var Z=D("./src/utils/logger.ts"),F=function(){function M(H){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=H}var z=M.prototype;return z.append=function(N,R){var v=this.queues[R];v.push(N),v.length===1&&this.buffers[R]&&this.executeNext(R)},z.insertAbort=function(N,R){var v=this.queues[R];v.unshift(N),this.executeNext(R)},z.appendBlocker=function(N){var R,v=new Promise(function(O){R=O}),T={execute:R,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,N),v},z.executeNext=function(N){var R=this.buffers,v=this.queues,T=R[N],O=v[N];if(O.length){var L=O[0];try{L.execute()}catch(A){Z.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(A),(!T||!T.updating)&&(O.shift(),this.executeNext(N))}}},z.shiftAndExecuteNext=function(N){this.queues[N].shift(),this.executeNext(N)},z.current=function(N){return this.queues[N][0]},M}()},"./src/controller/cap-level-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts");function F(H,N){for(var R=0;R<N.length;R++){var v=N[R];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(H,v.key,v)}}function M(H,N,R){return N&&F(H.prototype,N),R&&F(H,R),H}var z=function(){function H(R){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=R,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var N=H.prototype;return N.setStreamController=function(v){this.streamController=v},N.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},N.registerListeners=function(){var v=this.hls;v.on(Z.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(Z.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},N.unregisterListener=function(){var v=this.hls;v.off(Z.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(Z.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},N.onFpsDropLevelCapping=function(v,T){H.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},N.onMediaAttaching=function(v,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},N.onManifestParsed=function(v,T){var O=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,O.config.capLevelToPlayerSize&&T.video&&this.startCapping()},N.onBufferCodecs=function(v,T){var O=this.hls;O.config.capLevelToPlayerSize&&T.video&&this.startCapping()},N.onMediaDetaching=function(){this.stopCapping()},N.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(v.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},N.getMaxLevel=function(v){var T=this,O=this.hls.levels;if(!O.length)return-1;var L=O.filter(function(A,C){return H.isLevelAllowed(C,T.restrictedLevels)&&C<=v});return this.clientRect=null,H.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},N.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()},N.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},N.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,T={width:0,height:0};if(v){var O=v.getBoundingClientRect();T.width=O.width,T.height=O.height,!T.width&&!T.height&&(T.width=O.right-O.left||v.width||0,T.height=O.bottom-O.top||v.height||0)}return this.clientRect=T,T},H.isLevelAllowed=function(v,T){return T===void 0&&(T=[]),T.indexOf(v)===-1},H.getMaxLevelByMediaSize=function(v,T,O){if(!v||!v.length)return-1;for(var L=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},A=v.length-1,C=0;C<v.length;C+=1){var u=v[C];if((u.width>=T||u.height>=O)&&L(u,v[C+1])){A=C;break}}return A},M(H,[{key:"mediaWidth",get:function(){return this.getDimensions().width*H.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*H.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(T){}return v}}]),H}();$.default=z},"./src/controller/cmcd-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var Z=D("./src/events.ts"),F=D("./src/types/cmcd.ts"),M=D("./src/utils/buffer-helper.ts"),z=D("./src/utils/logger.ts");function H(A,C){for(var u=0;u<C.length;u++){var o=C[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(A,o.key,o)}}function N(A,C,u){return C&&H(A.prototype,C),u&&H(A,u),A}function R(A,C){var u=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(u)return(u=u.call(A)).next.bind(u);if(Array.isArray(A)||(u=v(A))||C&&A&&typeof A.length=="number"){u&&(A=u);var o=0;return function(){return o>=A.length?{done:!0}:{done:!1,value:A[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(A,C){if(!A)return;if(typeof A=="string")return T(A,C);var u=Object.prototype.toString.call(A).slice(8,-1);if(u==="Object"&&A.constructor&&(u=A.constructor.name),u==="Map"||u==="Set")return Array.from(A);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(A,C)}function T(A,C){(C==null||C>A.length)&&(C=A.length);for(var u=0,o=new Array(C);u<C;u++)o[u]=A[u];return o}function O(){return O=Object.assign||function(A){for(var C=1;C<arguments.length;C++){var u=arguments[C];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(A[o]=u[o])}return A},O.apply(this,arguments)}var L=function(){function A(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(w){try{o.apply(w,{ot:F.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(y){z.logger.warn("Could not generate manifest CMCD data.",y)}},this.applyFragmentData=function(w){try{var y=w.frag,g=o.hls.levels[y.level],k=o.getObjectType(y),x={d:y.duration*1e3,ot:k};(k===F.CMCDObjectType.VIDEO||k===F.CMCDObjectType.AUDIO||k==F.CMCDObjectType.MUXED)&&(x.br=g.bitrate/1e3,x.tb=o.getTopBandwidth(k),x.bl=o.getBufferLength(k)),o.apply(w,x)}catch(f){z.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||A.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var C=A.prototype;return C.registerListeners=function(){var o=this.hls;o.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(Z.Events.BUFFER_CREATED,this.onBufferCreated,this)},C.unregisterListeners=function(){var o=this.hls;o.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(Z.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},C.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},C.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},C.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},C.onBufferCreated=function(o,l){var h,w;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(w=l.tracks.video)===null||w===void 0?void 0:w.buffer},C.createData=function(){var o;return{v:F.CMCDVersion,sf:F.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},C.apply=function(o,l){l===void 0&&(l={}),O(l,this.createData());var h=l.ot===F.CMCDObjectType.INIT||l.ot===F.CMCDObjectType.VIDEO||l.ot===F.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 w=A.toHeaders(l);if(!Object.keys(w).length)return;o.headers||(o.headers={}),O(o.headers,w)}else{var y=A.toQuery(l);if(!y)return;o.url=A.appendQueryToUri(o.url,y)}},C.getObjectType=function(o){var l=o.type;return l==="subtitle"?F.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?F.CMCDObjectType.INIT:l==="audio"?F.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?F.CMCDObjectType.VIDEO:F.CMCDObjectType.MUXED:void 0},C.getTopBandwidth=function(o){for(var l=0,h=o===F.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,w=R(h),y;!(y=w()).done;){var g=y.value;g.bitrate>l&&(l=g.bitrate)}return l>0?l:NaN},C.getBufferLength=function(o){var l=this.hls.media,h=o===F.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var w=M.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return w.len*1e3},C.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,h=o||this.config.loader;return function(){function w(g){this.loader=void 0,this.loader=new h(g)}var y=w.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(k,x,f){l(k),this.loader.load(k,x,f)},N(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},C.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,h=o||this.config.loader;return function(){function w(g){this.loader=void 0,this.loader=new h(g)}var y=w.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(k,x,f){l(k),this.loader.load(k,x,f)},N(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},A.uuid=function(){var o=URL.createObjectURL(new Blob),l=o.toString();return URL.revokeObjectURL(o),l.substr(l.lastIndexOf("/")+1)},A.serialize=function(o){for(var l=[],h=function(U){return!Number.isNaN(U)&&U!=null&&U!==""&&U!==!1},w=function(U){return Math.round(U)},y=function(U){return w(U/100)*100},g=function(U){return encodeURIComponent(U)},k={br:w,d:w,bl:y,dl:y,mtp:y,nor:g,rtp:y,tb:w},x=Object.keys(o||{}).sort(),f=R(x),p;!(p=f()).done;){var d=p.value,a=o[d];if(!h(a))continue;if(d==="v"&&a===1)continue;if(d=="pr"&&a===1)continue;var b=k[d];b&&(a=b(a));var m=typeof a,E=void 0;d==="ot"||d==="sf"||d==="st"?E=d+"="+a:m==="boolean"?E=d:m==="number"?E=d+"="+a:E=d+"="+JSON.stringify(a),l.push(E)}return l.join(",")},A.toHeaders=function(o){for(var l=Object.keys(o),h={},w=["Object","Request","Session","Status"],y=[{},{},{},{}],g={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,x=l;k<x.length;k++){var f=x[k],p=g[f]!=null?g[f]:1;y[p][f]=o[f]}for(var d=0;d<y.length;d++){var a=A.serialize(y[d]);a&&(h["CMCD-"+w[d]]=a)}return h},A.toQuery=function(o){return"CMCD="+encodeURIComponent(A.serialize(o))},A.appendQueryToUri=function(o,l){if(!l)return o;var h=o.includes("?")?"&":"?";return""+o+h+l},A}()},"./src/controller/eme-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts"),F=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),z=D("./src/utils/mediakeys-helper.ts");function H(L,A){for(var C=0;C<A.length;C++){var u=A[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function N(L,A,C){return A&&H(L.prototype,A),C&&H(L,C),L}var R=3,v=function(A,C,u){var o={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),C.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[o]},T=function(A,C,u,o){switch(A){case z.KeySystems.WIDEVINE:return v(C,u,o);default:throw new Error("Unknown key-system: "+A)}},O=function(){function L(C){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=C,this._config=C.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var A=L.prototype;return A.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},A._registerListeners=function(){this.hls.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A._unregisterListeners=function(){this.hls.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A.getLicenseServerUrl=function(u){switch(u){case z.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},A._attemptKeySystemAccess=function(u,o,l){var h=this,w=T(u,o,l,this._drmSystemOptions);M.logger.log("Requesting encrypted media key-system access");var y=this.requestMediaKeySystemAccess(u,w);this.mediaKeysPromise=y.then(function(g){return h._onMediaKeySystemAccessObtained(u,g)}),y.catch(function(g){M.logger.error('Failed to obtain key-system "'+u+'" access:',g)})},A._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 w=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(y){return h.mediaKeys=y,M.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),y});return w.catch(function(y){M.logger.error("Failed to create media-keys:",y)}),w},A._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},A._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)},A._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)})},A.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(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(w){if(!o._media)return;o._attemptSetMediaKeys(w),o._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},A._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(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}M.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},A._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(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){M.logger.warn("Key-Session already initialized but requested again");return}var w=h.mediaKeysSession;if(!w){M.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.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(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}M.logger.log('Generating key-session request for "'+u+'" init data type'),h.mediaKeysSessionInitialized=!0,w.generateRequest(u,o).then(function(){M.logger.debug("Key-session generation succeeded")}).catch(function(y){M.logger.error("Error generating key-session request:",y),l.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(u,o,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,u,o,l);var w=this._licenseXhrSetup;if(w)try{w.call(this.hls,h,u),w=void 0}catch(y){M.logger.error(y)}try{h.readyState||h.open("POST",u,!0),w&&w.call(this.hls,h,u)}catch(y){throw new Error("issue setting up KeySystem license XHR "+y)}return h},A._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 w=u.response,y=this._licenseResponseCallback;if(y)try{w=y.call(this.hls,u,o)}catch(k){M.logger.error(k)}h(w)}else{if(M.logger.error("License Request XHR failed ("+o+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>R){this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var g=R-this._requestLicenseFailureCount+1;M.logger.warn("Retrying license request, "+g+" attempts left"),this._requestLicense(l,h)}break}},A._generateLicenseRequestChallenge=function(u,o){switch(u.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},A._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(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),w=this._createLicenseXhr(h,u,o);M.logger.log("Sending license request to URL: "+h);var y=this._generateLicenseRequestChallenge(l,u);w.send(y)}catch(g){M.logger.error("Failure requesting DRM license: "+g),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(u,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},A.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(){})},A.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var l=o.levels.map(function(w){return w.audioCodec}).filter(function(w){return!!w}),h=o.levels.map(function(w){return w.videoCodec}).filter(function(w){return!!w});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,l,h)},N(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();$.default=O},"./src/controller/fps-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts"),F=D("./src/utils/logger.ts"),M=function(){function z(N){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=N,this.registerListeners()}var H=z.prototype;return H.setStreamController=function(R){this.streamController=R},H.registerListeners=function(){this.hls.on(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},H.unregisterListeners=function(){this.hls.off(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching)},H.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},H.onMediaAttaching=function(R,v){var T=this.hls.config;if(T.capLevelOnFPSDrop){var O=v.media instanceof self.HTMLVideoElement?v.media:null;this.media=O,O&&typeof O.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},H.checkFPS=function(R,v,T){var O=performance.now();if(v){if(this.lastTime){var L=O-this.lastTime,A=T-this.lastDroppedFrames,C=v-this.lastDecodedFrames,u=1e3*A/L,o=this.hls;if(o.trigger(Z.Events.FPS_DROP,{currentDropped:A,currentDecoded:C,totalDroppedFrames:T}),u>0&&A>o.config.fpsDroppedMonitoringThreshold*C){var l=o.currentLevel;F.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(Z.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=O,this.lastDroppedFrames=T,this.lastDecodedFrames=v}},H.checkFPSInterval=function(){var R=this.media;if(R)if(this.isVideoPlaybackQualityAvailable){var v=R.getVideoPlaybackQuality();this.checkFPS(R,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(R,R.webkitDecodedFrameCount,R.webkitDroppedFrameCount)},z}();$.default=M},"./src/controller/fragment-finders.ts":function(oe,$,D){"use strict";D.r($),D.d($,"findFragmentByPDT",function(){return M}),D.d($,"findFragmentByPTS",function(){return z}),D.d($,"fragmentWithinToleranceTest",function(){return H}),D.d($,"pdtWithinToleranceTest",function(){return N}),D.d($,"findFragWithCC",function(){return R});var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/binary-search.ts");function M(v,T,O){if(T===null||!Array.isArray(v)||!v.length||!Object(Z.isFiniteNumber)(T))return null;var L=v[0].programDateTime;if(T<(L||0))return null;var A=v[v.length-1].endProgramDateTime;if(T>=(A||0))return null;O=O||0;for(var C=0;C<v.length;++C){var u=v[C];if(N(T,O,u))return u}return null}function z(v,T,O,L){O===void 0&&(O=0),L===void 0&&(L=0);var A=null;if(v?A=T[v.sn-T[0].sn+1]||null:O===0&&T[0].start===0&&(A=T[0]),A&&H(O,L,A)===0)return A;var C=F.default.search(T,H.bind(null,O,L));return C||A}function H(v,T,O){v===void 0&&(v=0),T===void 0&&(T=0);var L=Math.min(T,O.duration+(O.deltaPTS?O.deltaPTS:0));return O.start+O.duration-L<=v?1:O.start-L>v&&O.start?-1:0}function N(v,T,O){var L=Math.min(T,O.duration+(O.deltaPTS?O.deltaPTS:0))*1e3,A=O.endProgramDateTime||0;return A-L>v}function R(v,T){return F.default.search(v,function(O){return O.cc<T?1:O.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(oe,$,D){"use strict";D.r($),D.d($,"FragmentState",function(){return M}),D.d($,"FragmentTracker",function(){return z});var Z=D("./src/events.ts"),F=D("./src/types/loader.ts"),M;(function(R){R.NOT_LOADED="NOT_LOADED",R.BACKTRACKED="BACKTRACKED",R.APPENDING="APPENDING",R.PARTIAL="PARTIAL",R.OK="OK"})(M||(M={}));var z=function(){function R(T){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=T,this._registerListeners()}var v=R.prototype;return v._registerListeners=function(){var O=this.hls;O.on(Z.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.on(Z.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.on(Z.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var O=this.hls;O.off(Z.Events.BUFFER_APPENDED,this.onBufferAppended,this),O.off(Z.Events.FRAG_BUFFERED,this.onFragBuffered,this),O.off(Z.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(O,L){if(L===F.PlaylistLevelType.MAIN){var A=this.activeFragment,C=this.activeParts;if(!A)return null;if(C)for(var u=C.length;u--;){var o=C[u],l=o?o.end:A.appendedPTS;if(o.start<=O&&l!==void 0&&O<=l)return u>9&&(this.activeParts=C.slice(u-9)),o}else if(A.start<=O&&A.appendedPTS!==void 0&&O<=A.appendedPTS)return A}return this.getBufferedFrag(O,L)},v.getBufferedFrag=function(O,L){for(var A=this.fragments,C=Object.keys(A),u=C.length;u--;){var o=A[C[u]];if((o==null?void 0:o.body.type)===L&&o.buffered){var l=o.body;if(l.start<=O&&O<=l.end)return l}}return null},v.detectEvictedFragments=function(O,L,A){var C=this;Object.keys(this.fragments).forEach(function(u){var o=C.fragments[u];if(!o)return;if(!o.buffered){o.body.type===A&&C.removeFragment(o.body);return}var l=o.range[O];if(!l)return;l.time.some(function(h){var w=!C.isTimeBuffered(h.startPTS,h.endPTS,L);return w&&C.removeFragment(o.body),w})})},v.detectPartialFragments=function(O){var L=this,A=this.timeRanges,C=O.frag,u=O.part;if(!A||C.sn==="initSegment")return;var o=N(C),l=this.fragments[o];if(!l)return;Object.keys(A).forEach(function(h){var w=C.elementaryStreams[h];if(!w)return;var y=A[h],g=u!==null||w.partial===!0;l.range[h]=L.getBufferedTimes(C,u,g,y)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},v.fragBuffered=function(O){var L=N(O),A=this.fragments[L];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},v.getBufferedTimes=function(O,L,A,C){for(var u={time:[],partial:A},o=L?L.start:O.start,l=L?L.end:O.end,h=O.minEndPTS||l,w=O.maxStartPTS||o,y=0;y<C.length;y++){var g=C.start(y)-this.bufferPadding,k=C.end(y)+this.bufferPadding;if(w>=g&&h<=k){u.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(l,C.end(y))});break}else if(o<k&&l>g)u.partial=!0,u.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(l,C.end(y))});else if(l<=g)break}return u},v.getPartialFragment=function(O){var L=null,A,C,u,o=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(w){var y=h[w];if(!y)return;H(y)&&(C=y.body.start-l,u=y.body.end+l,O>=C&&O<=u&&(A=Math.min(O-C,u-O),o<=A&&(L=y.body,o=A)))}),L},v.getState=function(O){var L=N(O),A=this.fragments[L];return A?A.buffered?H(A)?M.PARTIAL:M.OK:A.backtrack?M.BACKTRACKED:M.APPENDING:M.NOT_LOADED},v.backtrack=function(O,L){var A=N(O),C=this.fragments[A];if(!C||C.backtrack)return null;var u=C.backtrack=L||C.loaded;return C.loaded=null,u},v.getBacktrackData=function(O){var L=N(O),A=this.fragments[L];if(A){var C,u=A.backtrack;if(u!=null&&(C=u.payload)!==null&&C!==void 0&&C.byteLength)return u;this.removeFragment(O)}return null},v.isTimeBuffered=function(O,L,A){for(var C,u,o=0;o<A.length;o++){if(C=A.start(o)-this.bufferPadding,u=A.end(o)+this.bufferPadding,O>=C&&L<=u)return!0;if(L<=C)return!1}return!1},v.onFragLoaded=function(O,L){var A=L.frag,C=L.part;if(A.sn==="initSegment"||A.bitrateTest||C)return;var u=N(A);this.fragments[u]={body:A,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(O,L){var A=this,C=L.frag,u=L.part,o=L.timeRanges;if(C.type===F.PlaylistLevelType.MAIN)if(this.activeFragment=C,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(h){var w=o[h];if(A.detectEvictedFragments(h,w),!u)for(var y=0;y<w.length;y++)C.appendedPTS=Math.max(w.end(y),C.appendedPTS||0)})},v.onFragBuffered=function(O,L){this.detectPartialFragments(L)},v.hasFragment=function(O){var L=N(O);return!!this.fragments[L]},v.removeFragmentsInRange=function(O,L,A){var C=this;Object.keys(this.fragments).forEach(function(u){var o=C.fragments[u];if(!o)return;if(o.buffered){var l=o.body;l.type===A&&l.start<L&&l.end>O&&C.removeFragment(l)}})},v.removeFragment=function(O){var L=N(O);O.stats.loaded=0,O.clearElementaryStreamInfo(),delete this.fragments[L]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},R}();function H(R){var v,T;return R.buffered&&(((v=R.range.video)===null||v===void 0?void 0:v.partial)||((T=R.range.audio)===null||T===void 0?void 0:T.partial))}function N(R){return R.type+"_"+R.level+"_"+R.urlId+"_"+R.sn}},"./src/controller/gap-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"STALL_MINIMUM_DURATION_MS",function(){return H}),D.d($,"MAX_START_GAP_JUMP",function(){return N}),D.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return R}),D.d($,"SKIP_BUFFER_RANGE_START",function(){return v}),D.d($,"default",function(){return T});var Z=D("./src/utils/buffer-helper.ts"),F=D("./src/errors.ts"),M=D("./src/events.ts"),z=D("./src/utils/logger.ts"),H=250,N=2,R=.1,v=.05,T=function(){function O(A,C,u,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=A,this.media=C,this.fragmentTracker=u,this.hls=o}var L=O.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(C){var u=this.config,o=this.media,l=this.stalled,h=o.currentTime,w=o.seeking,y=this.seeking&&!w,g=!this.seeking&&w;if(this.seeking=w,h!==C){if(this.moved=!0,l!==null){if(this.stallReported){var k=self.performance.now()-l;z.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((g||y)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!Z.BufferHelper.getBuffered(o).length)return;var x=Z.BufferHelper.bufferInfo(o,h,0),f=x.len>0,p=x.nextStart||0;if(!f&&!p)return;if(w){var d=x.len>N,a=!p||p-h>N&&!this.fragmentTracker.getPartialFragment(h);if(d||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,m=Math.max(p,x.start||0)-h,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,B=E==null||((b=E.details)===null||b===void 0)?void 0:b.live,U=B?E.details.targetduration*2:N;if(m>0&&m<=U){this._trySkipBufferHole(null);return}}var K=self.performance.now();if(l===null){this.stalled=K;return}var V=K-l;!w&&V>=H&&this._reportStall(x.len);var P=Z.BufferHelper.bufferInfo(o,h,u.maxBufferHole);this._tryFixBufferStall(P,V)},L._tryFixBufferStall=function(C,u){var o=this.config,l=this.fragmentTracker,h=this.media,w=h.currentTime,y=l.getPartialFragment(w);if(y){var g=this._trySkipBufferHole(y);if(g)return}C.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(C){var u=this.hls,o=this.media,l=this.stallReported;l||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+C+")"),u.trigger(M.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:C}))},L._trySkipBufferHole=function(C){for(var u=this.config,o=this.hls,l=this.media,h=l.currentTime,w=0,y=Z.BufferHelper.getBuffered(l),g=0;g<y.length;g++){var k=y.start(g);if(h+u.maxBufferHole>=w&&h<k){var x=Math.max(k+v,l.currentTime+R);return z.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+x),this.moved=!0,this.stalled=null,l.currentTime=x,C&&o.trigger(M.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+x,frag:C}),x}w=y.end(g)}return 0},L._tryNudgeBuffer=function(){var C=this.config,u=this.hls,o=this.media,l=o.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<C.nudgeMaxRetry){var w=l+h*C.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+l+" to "+w),o.currentTime=w,u.trigger(M.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else z.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+C.nudgeMaxRetry+" nudges"),u.trigger(M.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},O}()},"./src/controller/id3-track-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts"),F=D("./src/utils/texttrack-utils.ts"),M=D("./src/demux/id3.ts"),z=.25,H=function(){function N(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var R=N.prototype;return R.destroy=function(){this._unregisterListeners()},R._registerListeners=function(){var T=this.hls;T.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.on(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.on(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R._unregisterListeners=function(){var T=this.hls;T.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.off(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},R.onMediaAttached=function(T,O){this.media=O.media},R.onMediaDetaching=function(){if(!this.id3Track)return;Object(F.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},R.getID3Track=function(T){if(!this.media)return;for(var O=0;O<T.length;O++){var L=T[O];if(L.kind==="metadata"&&L.label==="id3")return Object(F.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},R.onFragParsingMetadata=function(T,O){if(!this.media)return;var L=O.frag,A=O.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var C=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<A.length;u++){var o=M.getID3Frames(A[u].data);if(o){var l=A[u].pts,h=u<A.length-1?A[u+1].pts:L.end,w=h-l;w<=0&&(h=l+z);for(var y=0;y<o.length;y++){var g=o[y];if(!M.isTimeStampFrame(g)){var k=new C(l,h,"");k.value=g,this.id3Track.addCue(k)}}}}},R.onBufferFlushing=function(T,O){var L=O.startOffset,A=O.endOffset,C=O.type;if(!C||C==="audio"){var u=this.id3Track;u&&Object(F.removeCuesInRange)(u,L,A)}},N}();$.default=H},"./src/controller/latency-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return N});var Z=D("./src/errors.ts"),F=D("./src/events.ts"),M=D("./src/utils/logger.ts");function z(R,v){for(var T=0;T<v.length;T++){var O=v[T];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function H(R,v,T){return v&&z(R.prototype,v),T&&z(R,T),R}var N=function(){function R(T){var O=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return O.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var v=R.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(F.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(F.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(F.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(F.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(F.Events.ERROR,this.onError)},v.onMediaAttached=function(O,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},v.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},v.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},v.onLevelUpdated=function(O,L){var A=L.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(O,L){if(L.details!==Z.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var O=this.media,L=this.levelDetails;if(!O||!L)return;this.currentTime=O.currentTime;var A=this.computeLatency();if(A===null)return;this._latency=A;var C=this.config,u=C.lowLatencyMode,o=C.maxLiveSyncPlaybackRate;if(!u||o===1)return;var l=this.targetLatency;if(l===null)return;var h=A-l,w=Math.min(this.maxLatency,l+L.targetduration),y=h<w;if(L.live&&y&&h>.05&&this.forwardBufferLength>1){var g=Math.min(2,Math.max(1,o)),k=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;O.playbackRate=Math.min(g,Math.max(1,k))}else O.playbackRate!==1&&O.playbackRate!==0&&(O.playbackRate=1)},v.estimateLiveEdge=function(){var O=this.levelDetails;return O===null?null:O.edge+O.age},v.computeLatency=function(){var O=this.estimateLiveEdge();return O===null?null:O-this.currentTime},H(R,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var O=this.config,L=this.levelDetails;return O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:L?O.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var O=this.levelDetails;if(O===null)return null;var L=O.holdBack,A=O.partHoldBack,C=O.targetduration,u=this.config,o=u.liveSyncDuration,l=u.liveSyncDurationCount,h=u.lowLatencyMode,w=this.hls.userConfig,y=h&&A||L;(w.liveSyncDuration||w.liveSyncDurationCount||y===0)&&(y=o!==void 0?o:l*C);var g=C,k=1;return y+Math.min(this.stallCount*k,g)}},{key:"liveSyncPosition",get:function(){var O=this.estimateLiveEdge(),L=this.targetLatency,A=this.levelDetails;if(O===null||L===null||A===null)return null;var C=A.edge,u=O-L-this.edgeStalled,o=C-A.totalduration,l=C-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,u),l)}},{key:"drift",get:function(){var O=this.levelDetails;return O===null?1:O.drift}},{key:"edgeStalled",get:function(){var O=this.levelDetails;if(O===null)return 0;var L=(this.config.lowLatencyMode&&O.partTarget||O.targetduration)*3;return Math.max(O.age-L,0)}},{key:"forwardBufferLength",get:function(){var O=this.media,L=this.levelDetails;if(!O||!L)return 0;var A=O.buffered.length;return A?O.buffered.end(A-1):L.edge-this.currentTime}}]),R}()},"./src/controller/level-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return u});var Z=D("./src/types/level.ts"),F=D("./src/events.ts"),M=D("./src/errors.ts"),z=D("./src/utils/codecs.ts"),H=D("./src/controller/level-helper.ts"),N=D("./src/controller/base-playlist-controller.ts"),R=D("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var w in h)Object.prototype.hasOwnProperty.call(h,w)&&(o[w]=h[w])}return o},v.apply(this,arguments)}function T(o,l){for(var h=0;h<l.length;h++){var w=l[h];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function O(o,l,h){return l&&T(o.prototype,l),h&&T(o,h),o}function L(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,A(o,l)}function A(o,l){return A=Object.setPrototypeOf||function(w,y){return w.__proto__=y,w},A(o,l)}var C=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){L(l,o);function l(w){var y;return y=o.call(this,w,"[level-controller]")||this,y._levels=[],y._firstLevel=-1,y._startLevel=void 0,y.currentLevelIndex=-1,y.manualLevelIndex=-1,y.onParsedComplete=void 0,y._registerListeners(),y}var h=l.prototype;return h._registerListeners=function(){var y=this.hls;y.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.on(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.on(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),y.on(F.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var y=this.hls;y.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.off(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.off(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),y.off(F.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 y=this._levels;y.forEach(function(g){g.loadError=0}),o.prototype.startLoad.call(this)},h.onManifestLoaded=function(y,g){var k=[],x=[],f=[],p,d={},a,b=!1,m=!1,E=!1;if(g.levels.forEach(function(V){var P=V.attrs;b=b||!!(V.width&&V.height),m=m||!!V.videoCodec,E=E||!!V.audioCodec,C&&V.audioCodec&&V.audioCodec.indexOf("mp4a.40.34")!==-1&&(V.audioCodec=void 0);var _=V.bitrate+"-"+V.attrs.RESOLUTION+"-"+V.attrs.CODECS;a=d[_],a?a.url.push(V.url):(a=new Z.Level(V),d[_]=a,k.push(a)),P&&(P.AUDIO&&Object(H.addGroupId)(a,"audio",P.AUDIO),P.SUBTITLES&&Object(H.addGroupId)(a,"text",P.SUBTITLES))}),(b||m)&&E&&(k=k.filter(function(V){var P=V.videoCodec,_=V.width,Y=V.height;return!!P||!!(_&&Y)})),k=k.filter(function(V){var P=V.audioCodec,_=V.videoCodec;return(!P||Object(z.isCodecSupportedInMp4)(P,"audio"))&&(!_||Object(z.isCodecSupportedInMp4)(_,"video"))}),g.audioTracks&&(x=g.audioTracks.filter(function(V){return!V.audioCodec||Object(z.isCodecSupportedInMp4)(V.audioCodec,"audio")}),Object(H.assignTrackIdsByGroup)(x)),g.subtitles&&(f=g.subtitles,Object(H.assignTrackIdsByGroup)(f)),k.length>0){p=k[0].bitrate,k.sort(function(V,P){return V.bitrate-P.bitrate}),this._levels=k;for(var B=0;B<k.length;B++)if(k[B].bitrate===p){this._firstLevel=B,this.log("manifest loaded, "+k.length+" level(s) found, first bitrate: "+p);break}var U=E&&!m,K={levels:k,audioTracks:x,subtitleTracks:f,firstLevel:this._firstLevel,stats:g.stats,audio:E,video:m,altAudio:!U&&x.some(function(V){return!!V.url})};this.hls.trigger(F.Events.MANIFEST_PARSED,K),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(F.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:g.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(y,g){if(o.prototype.onError.call(this,y,g),g.fatal)return;var k=g.context,x=this._levels[this.currentLevelIndex];if(k&&(k.type===R.PlaylistContextType.AUDIO_TRACK&&x.audioGroupIds&&k.groupId===x.audioGroupIds[x.urlId]||k.type===R.PlaylistContextType.SUBTITLE_TRACK&&x.textGroupIds&&k.groupId===x.textGroupIds[x.urlId])){this.redundantFailover(this.currentLevelIndex);return}var f=!1,p=!0,d;switch(g.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(g.frag){var a=this._levels[g.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=g.frag.level)):d=g.frag.level}break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:k&&(k.deliveryDirectives&&(p=!1),d=k.level),f=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:d=g.level,f=!0;break}d!==void 0&&this.recoverLevel(g,d,f,p)},h.recoverLevel=function(y,g,k,x){var f=y.details,p=this._levels[g];if(p.loadError++,k){var d=this.retryLoadingOrFail(y);if(d)y.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var a=p.url.length;if(a>1&&p.loadError<a)y.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){var b=g===0?this._levels.length-1:g-1;this.currentLevelIndex!==b&&this._levels[b].loadError===0&&(this.warn(f+": switch to "+b),y.levelRetry=!0,this.hls.nextAutoLevel=b)}}},h.redundantFailover=function(y){var g=this._levels[y],k=g.url.length;if(k>1){var x=(g.urlId+1)%k;this.warn("Switching to redundant URL-id "+x),this._levels.forEach(function(f){f.urlId=x}),this.level=y}},h.onFragLoaded=function(y,g){var k=g.frag;if(k!==void 0&&k.type===R.PlaylistLevelType.MAIN){var x=this._levels[k.level];x!==void 0&&(x.fragmentError=0,x.loadError=0)}},h.onLevelLoaded=function(y,g){var k,x=g.level,f=g.details,p=this._levels[x];if(!p){var d;this.warn("Invalid level index "+x),(d=g.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(f.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(x,g,p.details)):(k=g.deliveryDirectives)!==null&&k!==void 0&&k.skip&&(f.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(y,g){var k=this.hls.levels[this.currentLevelIndex];if(!k)return;if(k.audioGroupIds){for(var x=-1,f=this.hls.audioTracks[g.id].groupId,p=0;p<k.audioGroupIds.length;p++)if(k.audioGroupIds[p]===f){x=p;break}x!==k.urlId&&(k.urlId=x,this.startLoad())}},h.loadPlaylist=function(y){var g=this.currentLevelIndex,k=this._levels[g];if(this.canLoad&&k&&k.url.length>0){var x=k.urlId,f=k.url[x];if(y)try{f=y.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+g+(y?" at sn "+y.msn+" part "+y.part:"")+" with URL-id "+x+" "+f),this.clearTimer(),this.hls.trigger(F.Events.LEVEL_LOADING,{url:f,level:g,id:x,deliveryDirectives:y||null})}},h.removeLevel=function(y,g){var k=function(p,d){return d!==g},x=this._levels.filter(function(f,p){return p!==y?!0:f.url.length>1&&g!==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,p){var d=f.details;return d!=null&&d.fragments&&d.fragments.forEach(function(a){a.level=p}),f});this._levels=x,this.hls.trigger(F.Events.LEVELS_UPDATED,{levels:x})},O(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(y){var g,k=this._levels;if(k.length===0)return;if(this.currentLevelIndex===y&&(g=k[y])!==null&&g!==void 0&&g.details)return;if(y<0||y>=k.length){var x=y<0;if(this.hls.trigger(F.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:y,fatal:x,reason:"invalid level idx"}),x)return;y=Math.min(y,k.length-1)}this.clearTimer();var f=this.currentLevelIndex,p=k[f],d=k[y];this.log("switching to level "+y+" from "+f),this.currentLevelIndex=y;var a=v({},d,{level:y,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete a._urlId,this.hls.trigger(F.Events.LEVEL_SWITCHING,a);var b=d.details;if(!b||b.live){var m=this.switchParams(d.uri,p==null?void 0:p.details);this.loadPlaylist(m)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(y){this.manualLevelIndex=y,this._startLevel===void 0&&(this._startLevel=y),y!==-1&&(this.level=y)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(y){this._firstLevel=y}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var y=this.hls.config.startLevel;return y!==void 0?y:this._firstLevel}else return this._startLevel},set:function(y){this._startLevel=y}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(y){this.level=y,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=y)}}]),l}(N.default)},"./src/controller/level-helper.ts":function(oe,$,D){"use strict";D.r($),D.d($,"addGroupId",function(){return M}),D.d($,"assignTrackIdsByGroup",function(){return z}),D.d($,"updatePTS",function(){return H}),D.d($,"updateFragPTSDTS",function(){return R}),D.d($,"mergeDetails",function(){return v}),D.d($,"mapPartIntersection",function(){return T}),D.d($,"mapFragmentIntersection",function(){return O}),D.d($,"adjustSliding",function(){return L}),D.d($,"addSliding",function(){return A}),D.d($,"computeReloadInterval",function(){return C}),D.d($,"getFragmentWithSN",function(){return u}),D.d($,"getPartWith",function(){return o});var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/logger.ts");function M(l,h,w){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(w);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(w);break}}function z(l){var h={};l.forEach(function(w){var y=w.groupId||"";w.id=h[y]=h[y]||0,h[y]++})}function H(l,h,w){var y=l[h],g=l[w];N(y,g)}function N(l,h){var w=h.startPTS;if(Object(Z.isFiniteNumber)(w)){var y=0,g;h.sn>l.sn?(y=w-l.start,g=l):(y=l.start-w,g=h),g.duration!==y&&(g.duration=y)}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 R(l,h,w,y,g,k){var x=y-w;x<=0&&(F.logger.warn("Fragment should have a positive duration",h),y=w+h.duration,k=g+h.duration);var f=w,p=y,d=h.startPTS,a=h.endPTS;if(Object(Z.isFiniteNumber)(d)){var b=Math.abs(d-w);Object(Z.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(b,h.deltaPTS):h.deltaPTS=b,f=Math.max(w,d),w=Math.min(w,d),g=Math.min(g,h.startDTS),p=Math.min(y,a),y=Math.max(y,a),k=Math.max(k,h.endDTS)}h.duration=y-w;var m=w-h.start;h.appendedPTS=y,h.start=h.startPTS=w,h.maxStartPTS=f,h.startDTS=g,h.endPTS=y,h.minEndPTS=p,h.endDTS=k;var E=h.sn;if(!l||E<l.startSN||E>l.endSN)return 0;var B,U=E-l.startSN,K=l.fragments;for(K[U]=h,B=U;B>0;B--)N(K[B],K[B-1]);for(B=U;B<K.length-1;B++)N(K[B],K[B+1]);return l.fragmentHint&&N(K[K.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,m}function v(l,h){for(var w=null,y=l.fragments,g=y.length-1;g>=0;g--){var k=y[g].initSegment;if(k){w=k;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var x=0,f;if(O(l,h,function(B,U){B.relurl&&(x=B.cc-U.cc),Object(Z.isFiniteNumber)(B.startPTS)&&Object(Z.isFiniteNumber)(B.endPTS)&&(U.start=U.startPTS=B.startPTS,U.startDTS=B.startDTS,U.appendedPTS=B.appendedPTS,U.maxStartPTS=B.maxStartPTS,U.endPTS=B.endPTS,U.endDTS=B.endDTS,U.minEndPTS=B.minEndPTS,U.duration=B.endPTS-B.startPTS,U.duration&&(f=U),h.PTSKnown=h.alignedSliding=!0),U.elementaryStreams=B.elementaryStreams,U.loader=B.loader,U.stats=B.stats,U.urlId=B.urlId,B.initSegment&&(U.initSegment=B.initSegment,w=B.initSegment)}),w){var p=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;p.forEach(function(B){var U;(!B.initSegment||B.initSegment.relurl===((U=w)===null||U===void 0?void 0:U.relurl))&&(B.initSegment=w)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(B){return!B}),h.deltaUpdateFailed)){F.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(x){F.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].cc+=x}h.skippedSegments&&(h.startCC=h.fragments[0].cc),T(l.partList,h.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),f?R(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 m=h.advancedDateTime;if(h.advanced&&m){var E=h.edge;h.driftStart||(h.driftStartTime=m,h.driftStart=E),h.driftEndTime=m,h.driftEnd=E}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function T(l,h,w){if(l&&h)for(var y=0,g=0,k=l.length;g<=k;g++){var x=l[g],f=h[g+y];x&&f&&x.index===f.index&&x.fragment.sn===f.fragment.sn?w(x,f):y--}}function O(l,h,w){for(var y=h.skippedSegments,g=Math.max(l.startSN,h.startSN)-h.startSN,k=(l.fragmentHint?1:0)+(y?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,x=h.startSN-l.startSN,f=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,d=g;d<=k;d++){var a=p[x+d],b=f[d];y&&!b&&d<y&&(b=h.fragments[d]=a),a&&b&&w(a,b)}}function L(l,h){var w=h.startSN+h.skippedSegments-l.startSN,y=l.fragments;if(w<0||w>=y.length)return;A(h,y[w].start)}function A(l,h){if(h){for(var w=l.fragments,y=l.skippedSegments;y<w.length;y++)w[y].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function C(l,h){var w=1e3*l.levelTargetDuration,y=w/2,g=l.age,k=g>0&&g<w*3,x=h.loading.end-h.loading.start,f,p=l.availabilityDelay;if(l.updated===!1)if(k){var d=333*l.misses;f=Math.max(Math.min(y,x*2),d),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=y;else k?(p=Math.min(p||w/2,g),l.availabilityDelay=p,f=p+w-g):f=w-x;return Math.round(f)}function u(l,h,w){if(!l||!l.details)return null;var y=l.details,g=y.fragments[h-y.startSN];return g||(g=y.fragmentHint,g&&g.sn===h?g:h<y.startSN&&w&&w.sn===h?w:null)}function o(l,h,w){if(!l||!l.details)return null;var y=l.details.partList;if(y)for(var g=y.length;g--;){var k=y[g];if(k.index===w&&k.fragment.sn===h)return k}return null}},"./src/controller/stream-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return y});var Z=D("./src/polyfills/number.ts"),F=D("./src/controller/base-stream-controller.ts"),M=D("./src/is-supported.ts"),z=D("./src/events.ts"),H=D("./src/utils/buffer-helper.ts"),N=D("./src/controller/fragment-tracker.ts"),R=D("./src/types/loader.ts"),v=D("./src/loader/fragment.ts"),T=D("./src/demux/transmuxer-interface.ts"),O=D("./src/types/transmuxer.ts"),L=D("./src/controller/gap-controller.ts"),A=D("./src/errors.ts"),C=D("./src/utils/logger.ts");function u(g,k){for(var x=0;x<k.length;x++){var f=k[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(g,f.key,f)}}function o(g,k,x){return k&&u(g.prototype,k),x&&u(g,x),g}function l(g,k){g.prototype=Object.create(k.prototype),g.prototype.constructor=g,h(g,k)}function h(g,k){return h=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},h(g,k)}var w=100,y=function(g){l(k,g);function k(f,p){var d;return d=g.call(this,f,p,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var x=k.prototype;return x._registerListeners=function(){var p=this.hls;p.on(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(z.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(z.Events.ERROR,this.onError,this),p.on(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(z.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x._unregisterListeners=function(){var p=this.hls;p.off(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(z.Events.ERROR,this.onError,this),p.off(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(z.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},x.startLoad=function(p){if(this.levels){var d=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=a.startLevel;b===-1&&(a.config.testBandwidth?(b=0,this.bitrateTest=!0):b=a.nextAutoLevel),this.level=a.nextLoadLevel=b,this.loadedmetadata=!1}d>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),p=d),this.state=F.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=F.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,g.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_LEVEL:{var p,d=this.levels,a=this.level,b=d==null||((p=d[a])===null||p===void 0)?void 0:p.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=F.State.IDLE;break}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var m,E=self.performance.now(),B=this.retryDate;(!B||E>=B||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=F.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){g.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var p,d,a=this.hls,b=this.levelLastLoaded,m=this.levels,E=this.media,B=a.config,U=a.nextLoadLevel;if(b===null||!E&&(this.startFragRequested||!B.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!m||!m[U])return;var K=m[U];this.level=a.nextLoadLevel=U;var V=K.details;if(!V||this.state===F.State.WAITING_LEVEL||V.live&&this.levelLastLoaded!==U){this.state=F.State.WAITING_LEVEL;return}var P=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:E,R.PlaylistLevelType.MAIN);if(P===null)return;var _=P.len,Y=this.getMaxBufferLength(K.maxBitrate);if(_>=Y)return;if(this._streamEnded(P,V)){var ee={};this.altAudio&&(ee.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,ee),this.state=F.State.ENDED;return}var ae=P.end,ce=this.getNextFragment(ae,V);if(this.couldBacktrack&&!this.fragPrevious&&ce&&ce.sn!=="initSegment"){var De=ce.sn-V.startSN;De>1&&(ce=V.fragments[De-1],this.fragmentTracker.removeFragment(ce))}if(ce&&this.fragmentTracker.getState(ce)===N.FragmentState.OK&&this.nextLoadPosition>ae){var Se=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(E,Se,R.PlaylistLevelType.MAIN),ce=this.getNextFragment(this.nextLoadPosition,V)}if(!ce)return;ce.initSegment&&!ce.initSegment.data&&!this.bitrateTest&&(ce=ce.initSegment),((p=ce.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((d=ce.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(ce,V):this.loadFragment(ce,V,ae)},x.loadFragment=function(p,d,a){var b,m=this.fragmentTracker.getState(p);if(this.fragCurrent=p,m===N.FragmentState.BACKTRACKED){var E=this.fragmentTracker.getBacktrackData(p);if(E){this._handleFragmentLoadProgress(E),this._handleFragmentLoadComplete(E);return}else m=N.FragmentState.NOT_LOADED}m===N.FragmentState.NOT_LOADED||m===N.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,g.prototype.loadFragment.call(this,p,d,a)):m===N.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((b=this.media)===null||b===void 0?void 0:b.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(p){var d=this.fragmentTracker.getAppendedFrag(p,R.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},x.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,R.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var p=this.levels,d=this.media;if(d!=null&&d.readyState){var a,b=this.getAppendedFrag(d.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!d.paused&&p){var m=this.hls.nextLoadLevel,E=p[m],B=this.fragLastKbps;B&&this.fragCurrent?a=this.fragCurrent.duration*E.maxBitrate/(1e3*B)+1:a=0}else a=0;var U=this.getBufferedFrag(d.currentTime+a);if(U){var K=this.followingBufferedFrag(U);if(K){this.abortCurrentFrag();var V=K.maxStartPTS?K.maxStartPTS:K.start,P=K.duration,_=Math.max(U.end,V+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,P*.5),P*.75));this.flushMainBuffer(_,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===F.State.KEY_LOADING&&(this.state=F.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(p,d){g.prototype.flushMainBuffer.call(this,p,d,this.altAudio?"video":null)},x.onMediaAttached=function(p,d){g.prototype.onMediaAttached.call(this,p,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)},x.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),g.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var p=this.media,d=p?p.currentTime:null;Object(Z.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},x.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(z.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},x.onManifestParsed=function(p,d){var a=!1,b=!1,m;d.levels.forEach(function(E){m=E.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(a=!0),m.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!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},x.onLevelLoading=function(p,d){var a=this.levels;if(!a||this.state!==F.State.IDLE)return;var b=a[d.level];(!b.details||b.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(b.details))&&(this.state=F.State.WAITING_LEVEL)},x.onLevelLoaded=function(p,d){var a,b=this.levels,m=d.level,E=d.details,B=E.totalduration;if(!b){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+E.startSN+","+E.endSN+"], cc ["+E.startCC+", "+E.endCC+"] duration:"+B);var U=this.fragCurrent;U&&(this.state===F.State.FRAG_LOADING||this.state===F.State.FRAG_LOADING_WAITING_RETRY)&&(U.level!==d.level&&U.loader&&(this.state=F.State.IDLE,U.loader.abort()));var K=b[m],V=0;if(E.live||(a=K.details)!==null&&a!==void 0&&a.live){if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed)return;V=this.alignPlaylists(E,K.details)}if(K.details=E,this.levelLastLoaded=m,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:E,level:m}),this.state===F.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(E))return;this.state=F.State.IDLE}this.startFragRequested?E.live&&this.synchronizeToLiveEdge(E):this.setStartPosition(E,V),this.tick()},x._handleFragmentLoadProgress=function(p){var d,a=p.frag,b=p.part,m=p.payload,E=this.levels;if(!E){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var B=E[a.level],U=B.details;if(!U){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var K=B.videoCodec,V=U.PTSKnown||!U.live,P=(d=a.initSegment)===null||d===void 0?void 0:d.data,_=this._getAudioCodec(B),Y=this.transmuxer=this.transmuxer||new T.default(this.hls,R.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ee=b?b.index:-1,ae=ee!==-1,ce=new O.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,m.byteLength,ee,ae),De=this.initPTS[a.cc];Y.push(m,P,_,K,a,b,U.totalduration,V,ce,De)},x.onAudioTrackSwitching=function(p,d){var a=this.altAudio,b=!!d.url,m=d.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var E=this.fragCurrent;E!=null&&E.loader&&(this.log("Switching to main audio track, cancel main fragment load"),E.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var B=this.hls;a&&B.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),B.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:m})}},x.onAudioTrackSwitched=function(p,d){var a=d.id,b=!!this.hls.audioTracks[a].url;if(b){var m=this.videoBuffer;m&&this.mediaBuffer!==m&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=m)}this.altAudio=b,this.tick()},x.onBufferCreated=function(p,d){var a=d.tracks,b,m,E=!1;for(var B in a){var U=a[B];if(U.id==="main"){if(m=B,b=U,B==="video"){var K=a[B];K&&(this.videoBuffer=K.buffer)}}else E=!0}E&&b?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(p,d){var a=d.frag,b=d.part;if(a&&a.type!==R.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===F.State.PARSED&&(this.state=F.State.IDLE);return}var m=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},x.onError=function(p,d){switch(d.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,d);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==F.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=F.State.ERROR):!d.levelRetry&&this.state===F.State.WAITING_LEVEL&&(this.state=F.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===F.State.PARSING||this.state===F.State.PARSED)){var a=!0,b=this.getFwdBufferInfo(this.media,R.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var p=this.media,d=this.gapController;if(!p||!d||!p.readyState)return;var a=H.BufferHelper.getBuffered(p);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=F.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(p,d){var a=d.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,R.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(p,d){this.levels=d.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var p=this.media,d=p.currentTime,a=this.startPosition;if(a>=0&&d<a){if(p.seeking){C.logger.log("could not seek to "+a+", already seeking at "+d);return}var b=H.BufferHelper.getBuffered(p),m=b.length?b.start(0):0,E=m-a;E>0&&(E<this.config.maxBufferHole||E<this.config.maxFragLookUpTolerance)&&(C.logger.log("adjusting start position by "+E+" to match buffer start"),a+=E,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+d),p.currentTime=a}},x._getAudioCodec=function(p){var d=this.config.defaultAudioCodec||p.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},x._loadBitrateTestFrag=function(p){var d=this;this._doFragLoad(p).then(function(a){var b=d.hls;if(!a||b.nextLoadLevel||d.fragContextChanged(p))return;d.fragLoadError=0,d.state=F.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var m=p.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),b.trigger(z.Events.FRAG_LOADED,a)})},x._handleTransmuxComplete=function(p){var d,a="main",b=this.hls,m=p.remuxResult,E=p.chunkMeta,B=this.getCurrentContext(E);if(!B){this.warn("The loading context changed while buffering fragment "+E.sn+" of level "+E.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(E.level);return}var U=B.frag,K=B.part,V=B.level,P=m.video,_=m.text,Y=m.id3,ee=m.initSegment,ae=this.altAudio?void 0:m.audio;if(this.fragContextChanged(U))return;if(this.state=F.State.PARSING,ee){ee.tracks&&(this._bufferInitSegment(V,ee.tracks,U,E),b.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:a,tracks:ee.tracks}));var ce=ee.initPTS,De=ee.timescale;Object(Z.isFiniteNumber)(ce)&&(this.initPTS[U.cc]=ce,b.trigger(z.Events.INIT_PTS_FOUND,{frag:U,id:a,initPTS:ce,timescale:De}))}if(P&&m.independent!==!1){if(V.details){var Se=P.startPTS,Ce=P.endPTS,Ae=P.startDTS,Te=P.endDTS;if(K)K.elementaryStreams[P.type]={startPTS:Se,endPTS:Ce,startDTS:Ae,endDTS:Te};else if(P.firstKeyFrame&&P.independent&&(this.couldBacktrack=!0),P.dropped&&P.independent){var ve=this.getLoadPosition()+this.config.maxBufferHole;if(ve<Se){this.backtrack(U);return}U.setElementaryStreamInfo(P.type,U.start,Ce,U.start,Te,!0)}U.setElementaryStreamInfo(P.type,Se,Ce,Ae,Te),this.bufferFragmentData(P,U,K,E)}}else if(m.independent===!1){this.backtrack(U);return}if(ae){var le=ae.startPTS,te=ae.endPTS,de=ae.startDTS,ne=ae.endDTS;K&&(K.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:le,endPTS:te,startDTS:de,endDTS:ne}),U.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,le,te,de,ne),this.bufferFragmentData(ae,U,K,E)}if(Y!=null&&(d=Y.samples)!==null&&d!==void 0&&d.length){var ke={frag:U,id:a,samples:Y.samples};b.trigger(z.Events.FRAG_PARSING_METADATA,ke)}if(_){var Oe={frag:U,id:a,samples:_.samples};b.trigger(z.Events.FRAG_PARSING_USERDATA,Oe)}},x._bufferInitSegment=function(p,d,a,b){var m=this;if(this.state!==F.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var E=d.audio,B=d.video,U=d.audiovideo;if(E){var K=p.audioCodec,V=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(K&&(K.indexOf("mp4a.40.5")!==-1?K="mp4a.40.2":K="mp4a.40.5"),E.metadata.channelCount!==1&&V.indexOf("firefox")===-1&&(K="mp4a.40.5")),V.indexOf("android")!==-1&&E.container!=="audio/mpeg"&&(K="mp4a.40.2",this.log("Android: force audio codec to "+K)),p.audioCodec&&p.audioCodec!==K&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+K+'"'),E.levelCodec=K,E.id="main",this.log("Init audio buffer, container:"+E.container+", codecs[selected/level/parsed]=["+(K||"")+"/"+(p.audioCodec||"")+"/"+E.codec+"]")}B&&(B.levelCodec=p.videoCodec,B.id="main",this.log("Init video buffer, container:"+B.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+B.codec+"]")),U&&this.log("Init audiovideo buffer, container:"+U.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+U.codec+"]"),this.hls.trigger(z.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(P){var _=d[P],Y=_.initSegment;Y!=null&&Y.byteLength&&m.hls.trigger(z.Events.BUFFER_APPENDING,{type:P,data:Y,frag:a,part:null,chunkMeta:b,parent:a.type})}),this.tick()},x.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var d=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,d?this.resetFragmentLoading(p):this.state=F.State.BACKTRACKING},x.checkFragmentChanged=function(){var p=this.media,d=null;if(p&&p.readyState>1&&p.seeking===!1){var a=p.currentTime;if(H.BufferHelper.isBuffered(p,a)?d=this.getAppendedFrag(a):H.BufferHelper.isBuffered(p,a+.1)&&(d=this.getAppendedFrag(a+.1)),d){var b=this.fragPlaying,m=d.level;(!b||d.sn!==b.sn||b.level!==m||d.urlId!==b.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:d}),(!b||b.level!==m)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=d)}}},o(k,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var d=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),k}(F.default)},"./src/controller/subtitle-stream-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"SubtitleStreamController",function(){return l});var Z=D("./src/events.ts"),F=D("./src/utils/logger.ts"),M=D("./src/utils/buffer-helper.ts"),z=D("./src/controller/fragment-finders.ts"),H=D("./src/utils/discontinuities.ts"),N=D("./src/controller/level-helper.ts"),R=D("./src/controller/fragment-tracker.ts"),v=D("./src/controller/base-stream-controller.ts"),T=D("./src/types/loader.ts"),O=D("./src/types/level.ts");function L(h,w){for(var y=0;y<w.length;y++){var g=w[y];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(h,g.key,g)}}function A(h,w,y){return w&&L(h.prototype,w),y&&L(h,y),h}function C(h,w){h.prototype=Object.create(w.prototype),h.prototype.constructor=h,u(h,w)}function u(h,w){return u=Object.setPrototypeOf||function(g,k){return g.__proto__=k,g},u(h,w)}var o=500,l=function(h){C(w,h);function w(g,k){var x;return x=h.call(this,g,k,"[subtitle-stream-controller]")||this,x.levels=[],x.currentTrackId=-1,x.tracksBuffered=[],x.mainDetails=null,x._registerListeners(),x}var y=w.prototype;return y.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},y._registerListeners=function(){var k=this.hls;k.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.on(Z.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.on(Z.Events.ERROR,this.onError,this),k.on(Z.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.on(Z.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.on(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.on(Z.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.on(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y._unregisterListeners=function(){var k=this.hls;k.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),k.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),k.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),k.off(Z.Events.LEVEL_LOADED,this.onLevelLoaded,this),k.off(Z.Events.ERROR,this.onError,this),k.off(Z.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),k.off(Z.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),k.off(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),k.off(Z.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),k.off(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y.startLoad=function(){this.stopLoad(),this.state=v.State.IDLE,this.setInterval(o),this.tick()},y.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},y.onLevelLoaded=function(k,x){this.mainDetails=x.details},y.onSubtitleFragProcessed=function(k,x){var f=x.frag,p=x.success;if(this.fragPrevious=f,this.state=v.State.IDLE,!p)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var a,b=f.start,m=0;m<d.length;m++)if(b>=d[m].start&&b<=d[m].end){a=d[m];break}var E=f.start+f.duration;a?a.end=E:(a={start:b,end:E},d.push(a)),this.fragmentTracker.fragBuffered(f)},y.onBufferFlushing=function(k,x){var f=x.startOffset,p=x.endOffset;if(f===0&&p!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,a=this.levels;if(!a.length||!a[d]||!a[d].details)return;var b=a[d].details,m=b.targetduration,E=p-m;if(E<=0)return;x.endOffsetSubtitles=Math.max(0,E),this.tracksBuffered.forEach(function(B){for(var U=0;U<B.length;){if(B[U].end<=E){B.shift();continue}else if(B[U].start<E)B[U].start=E;else break;U++}}),this.fragmentTracker.removeFragmentsInRange(f,E,T.PlaylistLevelType.SUBTITLE)}},y.onError=function(k,x){var f,p=x.frag;if(!p||p.type!==T.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},y.onSubtitleTracksUpdated=function(k,x){var f=this,p=x.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(d){return new O.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){f.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},y.onSubtitleTrackSwitch=function(k,x){if(this.currentTrackId=x.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)},y.onSubtitleTrackLoaded=function(k,x){var f,p=x.details,d=x.id,a=this.currentTrackId,b=this.levels;if(!b.length)return;var m=b[a];if(d>=b.length||d!==a||!m)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=m.details)!==null&&f!==void 0&&f.live){var E=this.mainDetails;if(p.deltaUpdateFailed||!E)return;var B=E.fragments[0];if(!m.details)p.hasProgramDateTime&&E.hasProgramDateTime?Object(H.alignMediaPlaylistByPDT)(p,E):B&&Object(N.addSliding)(p,B.start);else{var U=this.alignPlaylists(p,m.details);U===0&&B&&Object(N.addSliding)(p,B.start)}}if(m.details=p,this.levelLastLoaded=d,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var K=Object(z.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);K||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}},y._handleFragmentLoadComplete=function(k){var x=k.frag,f=k.payload,p=x.decryptdata,d=this.hls;if(this.fragContextChanged(x))return;if(f&&f.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(b){var m=performance.now();d.trigger(Z.Events.FRAG_DECRYPTED,{frag:x,payload:b,stats:{tstart:a,tdecrypt:m}})})}},y.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var k,x=this.currentTrackId,f=this.levels;if(!f.length||!f[x]||!f[x].details)return;var p=f[x].details,d=p.targetduration,a=this.config,b=this.media,m=M.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-d,a.maxBufferHole),E=m.end,B=m.len,U=this.getMaxBufferLength()+d;if(B>U)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var K=p.fragments,V=K.length,P=p.edge,_,Y=this.fragPrevious;if(E<P){var ee=a.maxFragLookUpTolerance;Y&&p.hasProgramDateTime&&(_=Object(z.findFragmentByPDT)(K,Y.endProgramDateTime,ee)),_||(_=Object(z.findFragmentByPTS)(Y,K,E,ee),!_&&Y&&Y.start<K[0].start&&(_=K[0]))}else _=K[V-1];(k=_)!==null&&k!==void 0&&k.encrypted?(F.logger.log("Loading key for "+_.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(Z.Events.KEY_LOADING,{frag:_})):_&&this.fragmentTracker.getState(_)===R.FragmentState.NOT_LOADED&&this.loadFragment(_,p,E)}},y.loadFragment=function(k,x,f){this.fragCurrent=k,h.prototype.loadFragment.call(this,k,x,f)},A(w,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),w}(v.default)},"./src/controller/subtitle-track-controller.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/events.ts"),F=D("./src/utils/texttrack-utils.ts"),M=D("./src/controller/base-playlist-controller.ts"),z=D("./src/types/loader.ts");function H(L,A){for(var C=0;C<A.length;C++){var u=A[C];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(L,u.key,u)}}function N(L,A,C){return A&&H(L.prototype,A),C&&H(L,C),L}function R(L,A){L.prototype=Object.create(A.prototype),L.prototype.constructor=L,v(L,A)}function v(L,A){return v=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},v(L,A)}var T=function(L){R(A,L);function A(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 C=A.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},C.registerListeners=function(){var o=this.hls;o.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(Z.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var o=this.hls;o.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(Z.Events.ERROR,this.onError,this)},C.onMediaAttached=function(o,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},C.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},C.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=O(this.media.textTracks);o.forEach(function(l){Object(F.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},C.onSubtitleTrackLoaded=function(o,l){var h=l.id,w=l.details,y=this.trackId,g=this.tracksInGroup[y];if(!g){this.warn("Invalid subtitle track id "+h);return}var k=g.details;g.details=l.details,this.log("subtitle track "+h+" loaded ["+w.startSN+"-"+w.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,k))},C.onLevelLoading=function(o,l){this.switchLevel(l.level)},C.onLevelSwitching=function(o,l){this.switchLevel(l.level)},C.switchLevel=function(o){var l=this.hls.levels[o];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var w=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,y=this.tracks.filter(function(x){return!h||x.groupId===h});this.tracksInGroup=y;var g=this.findTrackId(w==null?void 0:w.name)||this.findTrackId();this.groupId=h;var k={subtitleTracks:y};this.log("Updating subtitle tracks, "+y.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(Z.Events.SUBTITLE_TRACKS_UPDATED,k),g!==-1&&this.setSubtitleTrack(g,w)}},C.findTrackId=function(o){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var w=l[h];if((!this.selectDefaultTrack||w.default)&&(!o||o===w.name))return w.id}return-1},C.onError=function(o,l){if(L.prototype.onError.call(this,o,l),l.fatal||!l.context)return;l.context.type===z.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},C.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,w=l.groupId,y=l.url;if(o)try{y=o.addDirectives(y)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(Z.Events.SUBTITLE_TRACK_LOADING,{url:y,id:h,groupId:w,deliveryDirectives:o||null})}},C.toggleTrackModes=function(o){var l=this,h=this.media,w=this.subtitleDisplay,y=this.trackId;if(!h)return;var g=O(h.textTracks),k=g.filter(function(p){return p.groupId===l.groupId});if(o===-1)[].slice.call(g).forEach(function(p){p.mode="disabled"});else{var x=k[y];x&&(x.mode="disabled")}var f=k[o];f&&(f.mode=w?"showing":"hidden")},C.setSubtitleTrack=function(o,l){var h,w=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(h=w[o])!==null&&h!==void 0&&h.details)||o<-1||o>=w.length)return;this.clearTimer();var y=w[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,y){var g=y.id,k=y.groupId,x=k===void 0?"":k,f=y.name,p=y.type,d=y.url;this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:g,groupId:x,name:f,type:p,url:d});var a=this.switchParams(y.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:o})},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,l=O(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)},N(A,[{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)}}]),A}(M.default);function O(L){for(var A=[],C=0;C<L.length;C++){var u=L[C];u.kind==="subtitles"&&u.label&&A.push(L[C])}return A}$.default=T},"./src/controller/timeline-controller.ts":function(oe,$,D){"use strict";D.r($),D.d($,"TimelineController",function(){return O});var Z=D("./src/polyfills/number.ts"),F=D("./src/events.ts"),M=D("./src/utils/cea-608-parser.ts"),z=D("./src/utils/output-filter.ts"),H=D("./src/utils/webvtt-parser.ts"),N=D("./src/utils/texttrack-utils.ts"),R=D("./src/utils/imsc1-ttml-parser.ts"),v=D("./src/types/loader.ts"),T=D("./src/utils/logger.ts"),O=function(){function u(l){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var h=new z.default(this,"textTrack1"),w=new z.default(this,"textTrack2"),y=new z.default(this,"textTrack3"),g=new z.default(this,"textTrack4");this.cea608Parser1=new M.default(1,h,w),this.cea608Parser2=new M.default(3,y,g)}l.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(F.Events.FRAG_LOADING,this.onFragLoading,this),l.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=u.prototype;return o.destroy=function(){var h=this.hls;h.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(F.Events.FRAG_LOADING,this.onFragLoading,this),h.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(h,w,y,g,k){for(var x=!1,f=k.length;f--;){var p=k[f],d=A(p[0],p[1],w,y);if(d>=0&&(p[0]=Math.min(p[0],w),p[1]=Math.max(p[1],y),x=!0,d/(y-w)>.5))return}if(x||k.push([w,y]),this.config.renderTextTracksNatively){var a=this.captionsTracks[h];this.Cues.newCue(a,w,y,g)}else{var b=this.Cues.newCue(null,w,y,g);this.hls.trigger(F.Events.CUES_PARSED,{type:"captions",cues:b,track:h})}},o.onInitPtsFound=function(h,w){var y=this,g=w.frag,k=w.id,x=w.initPTS,f=w.timescale,p=this.unparsedVttFrags;k==="main"&&(this.initPTS[g.cc]=x,this.timescale[g.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(d){y.onFragLoaded(F.Events.FRAG_LOADED,d)}))},o.getExistingTrack=function(h){var w=this.media;if(w)for(var y=0;y<w.textTracks.length;y++){var g=w.textTracks[y];if(g[h])return g}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 w=this.captionsProperties,y=this.captionsTracks,g=this.media,k=w[h],x=k.label,f=k.languageCode,p=this.getExistingTrack(h);if(p)y[h]=p,Object(N.clearCurrentCues)(y[h]),Object(N.sendAddTrackEvent)(y[h],g);else{var d=this.createTextTrack("captions",x,f);d&&(d[h]=!0,y[h]=d)}},o.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var w=this.captionsProperties[h];if(!w)return;var y=w.label,g={_id:h,label:y,kind:"captions",default:w.media?!!w.media.default:!1,closedCaptions:w.media};this.nonNativeCaptionsTracks[h]=g,this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[g]})},o.createTextTrack=function(h,w,y){var g=this.media;return g?g.addTextTrack(h,w,y):void 0},o.onMediaAttaching=function(h,w){this.media=w.media,this._cleanTracks()},o.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(w){Object(N.clearCurrentCues)(h[w]),delete h[w]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var h=this.media;if(!h)return;var w=h.textTracks;if(w)for(var y=0;y<w.length;y++)Object(N.clearCurrentCues)(w[y])},o.onSubtitleTracksUpdated=function(h,w){var y=this;this.textTracks=[];var g=w.subtitleTracks||[],k=g.some(function(d){return d.textCodec===R.IMSC1_CODEC});if(this.config.enableWebVTT||k&&this.config.enableIMSC1){var x=this.tracks&&g&&this.tracks.length===g.length;if(this.tracks=g||[],this.config.renderTextTracksNatively){var f=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,a){var b;if(a<f.length){for(var m=null,E=0;E<f.length;E++)if(L(f[E],d)){m=f[E];break}m&&(b=m)}b?Object(N.clearCurrentCues)(b):(b=y.createTextTrack("subtitles",d.name,d.lang),b&&(b.mode="disabled")),b&&(b.groupId=d.groupId,y.textTracks.push(b))})}else if(!x&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},o.onManifestLoaded=function(h,w){var y=this;this.config.enableCEA708Captions&&w.captions&&w.captions.forEach(function(g){var k=/(?:CC|SERVICE)([1-4])/.exec(g.instreamId);if(!k)return;var x="textTrack"+k[1],f=y.captionsProperties[x];if(!f)return;f.label=g.name,g.lang&&(f.languageCode=g.lang),f.media=g})},o.onFragLoading=function(h,w){var y=this.cea608Parser1,g=this.cea608Parser2,k=this.lastSn,x=this.lastPartIndex;if(!this.enabled||!(y&&g))return;if(w.frag.type===v.PlaylistLevelType.MAIN){var f,p,d=w.frag.sn,a=(f=w==null||((p=w.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;d===k+1||d===k&&a===x+1||(y.reset(),g.reset()),this.lastSn=d,this.lastPartIndex=a}},o.onFragLoaded=function(h,w){var y=w.frag,g=w.payload,k=this.initPTS,x=this.unparsedVttFrags;if(y.type===v.PlaylistLevelType.SUBTITLE)if(g.byteLength){if(!Object(Z.isFiniteNumber)(k[y.cc])){x.push(w),k.length&&this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Missing initial subtitle PTS")});return}var f=y.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var p=this.tracks[y.level],d=this.vttCCs;d[y.cc]||(d[y.cc]={start:y.start,prevCC:this.prevCC,new:!0},this.prevCC=y.cc),p&&p.textCodec===R.IMSC1_CODEC?this._parseIMSC1(y,g):this._parseVTTs(y,g,d)}}else this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(h,w){var y=this,g=this.hls;Object(R.parseIMSC1)(w,this.initPTS[h.cc],this.timescale[h.cc],function(k){y._appendCues(k,h.level),g.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(k){T.logger.log("Failed to parse IMSC1: "+k),g.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:k})})},o._parseVTTs=function(h,w,y){var g=this,k=this.hls;Object(H.parseWebVTT)(w,this.initPTS[h.cc],this.timescale[h.cc],y,h.cc,h.start,function(x){g._appendCues(x,h.level),k.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(x){g._fallbackToIMSC1(h,w),T.logger.log("Failed to parse VTT cue: "+x),k.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:x})})},o._fallbackToIMSC1=function(h,w){var y=this,g=this.tracks[h.level];g.textCodec||Object(R.parseIMSC1)(w,this.initPTS[h.cc],this.timescale[h.cc],function(){g.textCodec=R.IMSC1_CODEC,y._parseIMSC1(h,w)},function(){g.textCodec="wvtt"})},o._appendCues=function(h,w){var y=this.hls;if(this.config.renderTextTracksNatively){var g=this.textTracks[w];if(g.mode==="disabled")return;h.forEach(function(f){return Object(N.addCueToTrack)(g,f)})}else{var k=this.tracks[w],x=k.default?"default":"subtitles"+w;y.trigger(F.Events.CUES_PARSED,{type:"subtitles",cues:h,track:x})}},o.onFragDecrypted=function(h,w){var y=w.frag;if(y.type===v.PlaylistLevelType.SUBTITLE){if(!Object(Z.isFiniteNumber)(this.initPTS[y.cc])){this.unparsedVttFrags.push(w);return}this.onFragLoaded(F.Events.FRAG_LOADED,w)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(h,w){var y=this.cea608Parser1,g=this.cea608Parser2;if(!this.enabled||!(y&&g))return;for(var k=0;k<w.samples.length;k++){var x=w.samples[k].bytes;if(x){var f=this.extractCea608Data(x);y.addData(w.samples[k].pts,f[0]),g.addData(w.samples[k].pts,f[1])}}},o.onBufferFlushing=function(h,w){var y=w.startOffset,g=w.endOffset,k=w.endOffsetSubtitles,x=w.type,f=this.media;if(!f||f.currentTime<g)return;if(!x||x==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(a){return Object(N.removeCuesInRange)(p[a],y,g)})}if(this.config.renderTextTracksNatively&&(y===0&&k!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(a){return Object(N.removeCuesInRange)(d[a],y,k)})}},o.extractCea608Data=function(h){for(var w=h[0]&31,y=2,g=[[],[]],k=0;k<w;k++){var x=h[y++],f=127&h[y++],p=127&h[y++],d=(4&x)!==0,a=3&x;if(f===0&&p===0)continue;d&&((a===0||a===1)&&(g[a].push(f),g[a].push(p)))}return g},u}();function L(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function A(u,o,l,h){return Math.min(o,h)-Math.max(u,l)}function C(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return Z});var Z=function(){function F(z,H){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=H}var M=F.prototype;return M.decrypt=function(H,N){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},N,H)},F}()},"./src/crypt/aes-decryptor.ts":function(oe,$,D){"use strict";D.r($),D.d($,"removePadding",function(){return F}),D.d($,"default",function(){return M});var Z=D("./src/utils/typed-array.ts");function F(z){var H=z.byteLength,N=H&&new DataView(z.buffer).getUint8(H-1);return N?Object(Z.sliceUint8)(z,0,H-N):z}var M=function(){function z(){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 H=z.prototype;return H.uint8ArrayToUint32Array_=function(R){for(var v=new DataView(R),T=new Uint32Array(4),O=0;O<4;O++)T[O]=v.getUint32(O*4);return T},H.initTable=function(){var R=this.sBox,v=this.invSBox,T=this.subMix,O=T[0],L=T[1],A=T[2],C=T[3],u=this.invSubMix,o=u[0],l=u[1],h=u[2],w=u[3],y=new Uint32Array(256),g=0,k=0,x=0;for(x=0;x<256;x++)x<128?y[x]=x<<1:y[x]=x<<1^283;for(x=0;x<256;x++){var f=k^k<<1^k<<2^k<<3^k<<4;f=f>>>8^f&255^99,R[g]=f,v[f]=g;var p=y[g],d=y[p],a=y[d],b=y[f]*257^f*16843008;O[g]=b<<24|b>>>8,L[g]=b<<16|b>>>16,A[g]=b<<8|b>>>24,C[g]=b,b=a*16843009^d*65537^p*257^g*16843008,o[f]=b<<24|b>>>8,l[f]=b<<16|b>>>16,h[f]=b<<8|b>>>24,w[f]=b,g?(g=p^y[y[y[a^p]]],k^=y[y[k]]):g=k=1}},H.expandKey=function(R){for(var v=this.uint8ArrayToUint32Array_(R),T=!0,O=0;O<v.length&&T;)T=v[O]===this.key[O],O++;if(T)return;this.key=v;var L=this.keySize=v.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var A=this.ksRows=(L+6+1)*4,C,u,o=this.keySchedule=new Uint32Array(A),l=this.invKeySchedule=new Uint32Array(A),h=this.sBox,w=this.rcon,y=this.invSubMix,g=y[0],k=y[1],x=y[2],f=y[3],p,d;for(C=0;C<A;C++){if(C<L){p=o[C]=v[C];continue}d=p,C%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^=w[C/L|0]<<24):L>6&&C%L===4&&(d=h[d>>>24]<<24|h[d>>>16&255]<<16|h[d>>>8&255]<<8|h[d&255]),o[C]=p=(o[C-L]^d)>>>0}for(u=0;u<A;u++)C=A-u,u&3?d=o[C]:d=o[C-4],u<4||C<=4?l[u]=d:l[u]=g[h[d>>>24]]^k[h[d>>>16&255]]^x[h[d>>>8&255]]^f[h[d&255]],l[u]=l[u]>>>0},H.networkToHostOrderSwap=function(R){return R<<24|(R&65280)<<8|(R&16711680)>>8|R>>>24},H.decrypt=function(R,v,T){for(var O=this.keySize+6,L=this.invKeySchedule,A=this.invSBox,C=this.invSubMix,u=C[0],o=C[1],l=C[2],h=C[3],w=this.uint8ArrayToUint32Array_(T),y=w[0],g=w[1],k=w[2],x=w[3],f=new Int32Array(R),p=new Int32Array(f.length),d,a,b,m,E,B,U,K,V,P,_,Y,ee,ae,ce=this.networkToHostOrderSwap;v<f.length;){for(V=ce(f[v]),P=ce(f[v+1]),_=ce(f[v+2]),Y=ce(f[v+3]),E=V^L[0],B=Y^L[1],U=_^L[2],K=P^L[3],ee=4,ae=1;ae<O;ae++)d=u[E>>>24]^o[B>>16&255]^l[U>>8&255]^h[K&255]^L[ee],a=u[B>>>24]^o[U>>16&255]^l[K>>8&255]^h[E&255]^L[ee+1],b=u[U>>>24]^o[K>>16&255]^l[E>>8&255]^h[B&255]^L[ee+2],m=u[K>>>24]^o[E>>16&255]^l[B>>8&255]^h[U&255]^L[ee+3],E=d,B=a,U=b,K=m,ee=ee+4;d=A[E>>>24]<<24^A[B>>16&255]<<16^A[U>>8&255]<<8^A[K&255]^L[ee],a=A[B>>>24]<<24^A[U>>16&255]<<16^A[K>>8&255]<<8^A[E&255]^L[ee+1],b=A[U>>>24]<<24^A[K>>16&255]<<16^A[E>>8&255]<<8^A[B&255]^L[ee+2],m=A[K>>>24]<<24^A[E>>16&255]<<16^A[B>>8&255]<<8^A[U&255]^L[ee+3],p[v]=ce(d^y),p[v+1]=ce(m^g),p[v+2]=ce(b^k),p[v+3]=ce(a^x),y=V,g=P,k=_,x=Y,v=v+4}return p.buffer},z}()},"./src/crypt/decrypter.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return v});var Z=D("./src/crypt/aes-crypto.ts"),F=D("./src/crypt/fast-aes-key.ts"),M=D("./src/crypt/aes-decryptor.ts"),z=D("./src/utils/logger.ts"),H=D("./src/utils/mp4-tools.ts"),N=D("./src/utils/typed-array.ts"),R=16,v=function(){function T(L,A,C){var u=C===void 0?{}:C,o=u.removePKCS7Padding,l=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=L,this.config=A,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(w){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var O=T.prototype;return O.destroy=function(){this.observer=null},O.isSync=function(){return this.config.enableSoftwareAES},O.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var C=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(M.removePadding)(C):C},O.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},O.decrypt=function(A,C,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),C,u);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),C,u).then(o)},O.softwareDecrypt=function(A,C,u){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(A=Object(H.appendUint8Array)(h,A),this.remainderData=null);var w=this.getValidChunk(A);if(!w.length)return null;o&&(u=o);var y=this.softwareDecrypter;y||(y=this.softwareDecrypter=new M.default),y.expandKey(C);var g=l;return this.currentResult=y.decrypt(w.buffer,0,u),this.currentIV=Object(N.sliceUint8)(w,-16).buffer,g||null},O.webCryptoDecrypt=function(A,C,u){var o=this,l=this.subtle;return(this.key!==C||!this.fastAesKey)&&(this.key=C,this.fastAesKey=new F.default(l,C)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var w=new Z.default(l,u);return w.decrypt(A.buffer,h)}).catch(function(h){return o.onWebCryptoError(h,A,C,u)})},O.onWebCryptoError=function(A,C,u,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(C,u,o)},O.getValidChunk=function(A){var C=A,u=A.length-A.length%R;return u!==A.length&&(C=Object(N.sliceUint8)(A,0,u),this.remainderData=Object(N.sliceUint8)(A,u)),C},O.logOnce=function(A){if(!this.logEnabled)return;z.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1},T}()},"./src/crypt/fast-aes-key.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return Z});var Z=function(){function F(z,H){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=H}var M=F.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},F}()},"./src/demux/aacdemuxer.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/demux/base-audio-demuxer.ts"),F=D("./src/demux/adts.ts"),M=D("./src/utils/logger.ts"),z=D("./src/demux/id3.ts");function H(v,T){v.prototype=Object.create(T.prototype),v.prototype.constructor=v,N(v,T)}function N(v,T){return N=Object.setPrototypeOf||function(L,A){return L.__proto__=A,L},N(v,T)}var R=function(v){H(T,v);function T(L,A){var C;return C=v.call(this)||this,C.observer=void 0,C.config=void 0,C.observer=L,C.config=A,C}var O=T.prototype;return O.resetInitSegment=function(A,C,u){v.prototype.resetInitSegment.call(this,A,C,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:A,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(A){if(!A)return!1;for(var C=z.getID3Data(A,0)||[],u=C.length,o=A.length;u<o;u++)if(F.probe(A,u))return M.logger.log("ADTS sync word found !"),!0;return!1},O.canParse=function(A,C){return F.canParse(A,C)},O.appendFrame=function(A,C,u){F.initTrackConfig(A,this.observer,C,u,A.manifestCodec);var o=F.appendFrame(A,C,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},T}(Z.default);R.minProbeByteLength=9,$.default=R},"./src/demux/adts.ts":function(oe,$,D){"use strict";D.r($),D.d($,"getAudioConfig",function(){return z}),D.d($,"isHeaderPattern",function(){return H}),D.d($,"getHeaderLength",function(){return N}),D.d($,"getFullFrameLength",function(){return R}),D.d($,"canGetFrameLength",function(){return v}),D.d($,"isHeader",function(){return T}),D.d($,"canParse",function(){return O}),D.d($,"probe",function(){return L}),D.d($,"initTrackConfig",function(){return A}),D.d($,"getFrameDuration",function(){return C}),D.d($,"parseFrameHeader",function(){return u}),D.d($,"appendFrame",function(){return o});var Z=D("./src/utils/logger.ts"),F=D("./src/errors.ts"),M=D("./src/events.ts");function z(l,h,w,y){var g,k,x,f,p=navigator.userAgent.toLowerCase(),d=y,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];g=((h[w+2]&192)>>>6)+1;var b=(h[w+2]&60)>>>2;if(b>a.length-1){l.trigger(M.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b});return}return x=(h[w+2]&1)<<2,x|=(h[w+3]&192)>>>6,Z.logger.log("manifest codec:"+y+", ADTS type:"+g+", samplingIndex:"+b),/firefox/i.test(p)?b>=6?(g=5,f=new Array(4),k=b-3):(g=2,f=new Array(2),k=b):p.indexOf("android")!==-1?(g=2,f=new Array(2),k=b):(g=5,f=new Array(4),y&&(y.indexOf("mp4a.40.29")!==-1||y.indexOf("mp4a.40.5")!==-1)||!y&&b>=6?k=b-3:((y&&y.indexOf("mp4a.40.2")!==-1&&(b>=6&&x===1||/vivaldi/i.test(p))||!y&&x===1)&&(g=2,f=new Array(2)),k=b)),f[0]=g<<3,f[0]|=(b&14)>>1,f[1]|=(b&1)<<7,f[1]|=x<<3,g===5&&(f[1]|=(k&14)>>1,f[2]=(k&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:a[b],channelCount:x,codec:"mp4a.40."+g,manifestCodec:d}}function H(l,h){return l[h]===255&&(l[h+1]&246)===240}function N(l,h){return l[h+1]&1?7:9}function R(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function v(l,h){return h+5<l.length}function T(l,h){return h+1<l.length&&H(l,h)}function O(l,h){return v(l,h)&&H(l,h)&&R(l,h)<=l.length-h}function L(l,h){if(T(l,h)){var w=N(l,h);if(h+w>=l.length)return!1;var y=R(l,h);if(y<=w)return!1;var g=h+y;return g===l.length||T(l,g)}return!1}function A(l,h,w,y,g){if(!l.samplerate){var k=z(h,w,y,g);if(!k)return;l.config=k.config,l.samplerate=k.samplerate,l.channelCount=k.channelCount,l.codec=k.codec,l.manifestCodec=k.manifestCodec,Z.logger.log("parsed codec:"+l.codec+", rate:"+k.samplerate+", channels:"+k.channelCount)}}function C(l){return 1024*9e4/l}function u(l,h,w,y,g){var k=N(l,h),x=R(l,h);if(x-=k,x>0){var f=w+y*g;return{headerLength:k,frameLength:x,stamp:f}}}function o(l,h,w,y,g){var k=C(l.samplerate),x=u(h,w,y,g,k);if(x){var f=x.frameLength,p=x.headerLength,d=x.stamp,a=p+f,b=Math.max(0,w+a-h.length),m;b?(m=new Uint8Array(a-p),m.set(h.subarray(w+p,h.length),0)):m=h.subarray(w+p,w+a);var E={unit:m,pts:d};return b||l.samples.push(E),{sample:E,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(oe,$,D){"use strict";D.r($),D.d($,"initPTSFn",function(){return R});var Z=D("./src/polyfills/number.ts"),F=D("./src/demux/id3.ts"),M=D("./src/demux/dummy-demuxed-track.ts"),z=D("./src/utils/mp4-tools.ts"),H=D("./src/utils/typed-array.ts"),N=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var T=v.prototype;return T.resetInitSegment=function(L,A,C){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},T.resetTimeStamp=function(){},T.resetContiguity=function(){},T.canParse=function(L,A){return!1},T.appendFrame=function(L,A,C){},T.demux=function(L,A){this.cachedData&&(L=Object(z.appendUint8Array)(this.cachedData,L),this.cachedData=null);var C=F.getID3Data(L,0),u=C?C.length:0,o,l,h=this._audioTrack,w=this._id3Track,y=C?F.getTimeStamp(C):void 0,g=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=R(y,A)),C&&C.length>0&&w.samples.push({pts:this.initPTS,dts:this.initPTS,data:C}),l=this.initPTS;u<g;){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=g}else F.canParse(L,u)?(C=F.getID3Data(L,u),w.samples.push({pts:l,dts:l,data:C}),u+=C.length,o=u):u++;if(u===g&&o!==g){var x=Object(H.sliceUint8)(L,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,x):this.cachedData=x}}return{audioTrack:h,avcTrack:Object(M.dummyTrack)(),id3Track:w,textTrack:Object(M.dummyTrack)()}},T.demuxSampleAes=function(L,A,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},T.flush=function(L){var A=this.cachedData;return A&&(this.cachedData=null,this.demux(A,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},T.destroy=function(){},v}(),R=function(T,O){return Object(Z.isFiniteNumber)(T)?T*90:O*9e4};$.default=N},"./src/demux/chunk-cache.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return Z});var Z=function(){function M(){this.chunks=[],this.dataLength=0}var z=M.prototype;return z.push=function(N){this.chunks.push(N),this.dataLength+=N.length},z.flush=function(){var N=this.chunks,R=this.dataLength,v;if(N.length)N.length===1?v=N[0]:v=F(N,R);else return new Uint8Array(0);return this.reset(),v},z.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function F(M,z){for(var H=new Uint8Array(z),N=0,R=0;R<M.length;R++){var v=M[R];H.set(v,N),N+=v.length}return H}},"./src/demux/dummy-demuxed-track.ts":function(oe,$,D){"use strict";D.r($),D.d($,"dummyTrack",function(){return Z});function Z(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/utils/logger.ts"),F=function(){function M(H){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=H,this.bytesAvailable=H.byteLength,this.word=0,this.bitsAvailable=0}var z=M.prototype;return z.loadWord=function(){var N=this.data,R=this.bytesAvailable,v=N.byteLength-R,T=new Uint8Array(4),O=Math.min(4,R);if(O===0)throw new Error("no bytes available");T.set(N.subarray(v,v+O)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=O*8,this.bytesAvailable-=O},z.skipBits=function(N){var R;this.bitsAvailable>N?(this.word<<=N,this.bitsAvailable-=N):(N-=this.bitsAvailable,R=N>>3,N-=R>>3,this.bytesAvailable-=R,this.loadWord(),this.word<<=N,this.bitsAvailable-=N)},z.readBits=function(N){var R=Math.min(this.bitsAvailable,N),v=this.word>>>32-R;return N>32&&Z.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=R,this.bitsAvailable>0?this.word<<=R:this.bytesAvailable>0&&this.loadWord(),R=N-R,R>0&&this.bitsAvailable?v<<R|this.readBits(R):v},z.skipLZ=function(){var N;for(N=0;N<this.bitsAvailable;++N)if((this.word&2147483648>>>N)!==0)return this.word<<=N,this.bitsAvailable-=N,N;return this.loadWord(),N+this.skipLZ()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var N=this.skipLZ();return this.readBits(N+1)-1},z.readEG=function(){var N=this.readUEG();return 1&N?1+N>>>1:-1*(N>>>1)},z.readBoolean=function(){return this.readBits(1)===1},z.readUByte=function(){return this.readBits(8)},z.readUShort=function(){return this.readBits(16)},z.readUInt=function(){return this.readBits(32)},z.skipScalingList=function(N){for(var R=8,v=8,T,O=0;O<N;O++)v!==0&&(T=this.readEG(),v=(R+T+256)%256),R=v===0?R:v},z.readSPS=function(){var N=0,R=0,v=0,T=0,O,L,A,C=this.readUByte.bind(this),u=this.readBits.bind(this),o=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),w=this.skipEG.bind(this),y=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);C();var k=C();if(u(5),h(3),C(),y(),k===100||k===110||k===122||k===244||k===44||k===83||k===86||k===118||k===128){var x=o();if(x===3&&h(1),y(),y(),h(1),l())for(L=x!==3?8:12,A=0;A<L;A++)l()&&(A<6?g(16):g(64))}y();var f=o();if(f===0)o();else if(f===1)for(h(1),w(),w(),O=o(),A=0;A<O;A++)w();y(),h(1);var p=o(),d=o(),a=u(1);a===0&&h(1),h(1),l()&&(N=o(),R=o(),v=o(),T=o());var b=[1,1];if(l()&&l()){var m=C();switch(m){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[C()<<8|C(),C()<<8|C()];break}}}return{width:Math.ceil((p+1)*16-N*2-R*2),height:(2-a)*(d+1)*16-(a?2:4)*(v+T),pixelRatio:b}},z.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},M}();$.default=F},"./src/demux/id3.ts":function(oe,$,D){"use strict";D.r($),D.d($,"isHeader",function(){return Z}),D.d($,"isFooter",function(){return F}),D.d($,"getID3Data",function(){return M}),D.d($,"canParse",function(){return H}),D.d($,"getTimeStamp",function(){return N}),D.d($,"isTimeStampFrame",function(){return R}),D.d($,"getID3Frames",function(){return T}),D.d($,"decodeFrame",function(){return O}),D.d($,"utf8ArrayToStr",function(){return o}),D.d($,"testables",function(){return l});var Z=function(g,k){return k+10<=g.length&&(g[k]===73&&g[k+1]===68&&g[k+2]===51&&(g[k+3]<255&&g[k+4]<255&&(g[k+6]<128&&g[k+7]<128&&g[k+8]<128&&g[k+9]<128)))},F=function(g,k){return k+10<=g.length&&(g[k]===51&&g[k+1]===68&&g[k+2]===73&&(g[k+3]<255&&g[k+4]<255&&(g[k+6]<128&&g[k+7]<128&&g[k+8]<128&&g[k+9]<128)))},M=function(g,k){for(var x=k,f=0;Z(g,k);){f+=10;var p=z(g,k+6);f+=p,F(g,k+10)&&(f+=10),k+=f}return f>0?g.subarray(x,x+f):void 0},z=function(g,k){var x=0;return x=(g[k]&127)<<21,x|=(g[k+1]&127)<<14,x|=(g[k+2]&127)<<7,x|=g[k+3]&127,x},H=function(g,k){return Z(g,k)&&z(g,k+6)+10<=g.length-k},N=function(g){for(var k=T(g),x=0;x<k.length;x++){var f=k[x];if(R(f))return u(f)}return},R=function(g){return g&&g.key==="PRIV"&&g.info==="com.apple.streaming.transportStreamTimestamp"},v=function(g){var k=String.fromCharCode(g[0],g[1],g[2],g[3]),x=z(g,4),f=10;return{type:k,size:x,data:g.subarray(f,f+x)}},T=function(g){for(var k=0,x=[];Z(g,k);){var f=z(g,k+6);k+=10;for(var p=k+f;k+8<p;){var d=v(g.subarray(k)),a=O(d);a&&x.push(a),k+=d.size+10}F(g,k)&&(k+=10)}return x},O=function(g){return g.type==="PRIV"?L(g):g.type[0]==="W"?C(g):A(g)},L=function(g){if(g.size<2)return;var k=o(g.data,!0),x=new Uint8Array(g.data.subarray(k.length+1));return{key:g.type,info:k,data:x.buffer}},A=function(g){if(g.size<2)return;if(g.type==="TXXX"){var k=1,x=o(g.data.subarray(k),!0);k+=x.length+1;var f=o(g.data.subarray(k));return{key:g.type,info:x,data:f}}var p=o(g.data.subarray(1));return{key:g.type,data:p}},C=function(g){if(g.type==="WXXX"){if(g.size<2)return;var k=1,x=o(g.data.subarray(k),!0);k+=x.length+1;var f=o(g.data.subarray(k));return{key:g.type,info:x,data:f}}var p=o(g.data);return{key:g.type,data:p}},u=function(g){if(g.data.byteLength===8){var k=new Uint8Array(g.data),x=k[3]&1,f=(k[4]<<23)+(k[5]<<15)+(k[6]<<7)+k[7];return f/=45,x&&(f+=4772185884e-2),Math.round(f)}return},o=function(g,k){k===void 0&&(k=!1);var x=w();if(x){var f=x.decode(g);if(k){var p=f.indexOf("\0");return p!==-1?f.substring(0,p):f}return f.replace(/\0/g,"")}for(var d=g.length,a,b,m,E="",B=0;B<d;){if(a=g[B++],a===0&&k)return E;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:E+=String.fromCharCode(a);break;case 12:case 13:b=g[B++],E+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=g[B++],m=g[B++],E+=String.fromCharCode((a&15)<<12|(b&63)<<6|(m&63)<<0);break;default:}}return E},l={decodeTextFrame:A},h;function w(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/demux/base-audio-demuxer.ts"),F=D("./src/demux/id3.ts"),M=D("./src/utils/logger.ts"),z=D("./src/demux/mpegaudio.ts");function H(v,T){v.prototype=Object.create(T.prototype),v.prototype.constructor=v,N(v,T)}function N(v,T){return N=Object.setPrototypeOf||function(L,A){return L.__proto__=A,L},N(v,T)}var R=function(v){H(T,v);function T(){return v.apply(this,arguments)||this}var O=T.prototype;return O.resetInitSegment=function(A,C,u){v.prototype.resetInitSegment.call(this,A,C,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:A,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(A){if(!A)return!1;for(var C=F.getID3Data(A,0)||[],u=C.length,o=A.length;u<o;u++)if(z.probe(A,u))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},O.canParse=function(A,C){return z.canParse(A,C)},O.appendFrame=function(A,C,u){return this.initPTS===null?void 0:z.appendFrame(A,C,u,this.initPTS,this.frameIndex)},T}(Z.default);R.minProbeByteLength=4,$.default=R},"./src/demux/mp4demuxer.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/utils/mp4-tools.ts"),F=D("./src/demux/dummy-demuxed-track.ts"),M=function(){function z(N,R){this.remainderData=null,this.config=void 0,this.config=R}var H=z.prototype;return H.resetTimeStamp=function(){},H.resetInitSegment=function(){},H.resetContiguity=function(){},z.probe=function(R){return Object(Z.findBox)({data:R,start:0,end:Math.min(R.length,16384)},["moof"]).length>0},H.demux=function(R){var v=R,T=Object(F.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(Z.appendUint8Array)(this.remainderData,R));var O=Object(Z.segmentValidRange)(v);this.remainderData=O.remainder,T.samples=O.valid||new Uint8Array}else T.samples=v;return{audioTrack:Object(F.dummyTrack)(),avcTrack:T,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},H.flush=function(){var R=Object(F.dummyTrack)();return R.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(F.dummyTrack)(),avcTrack:R,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},H.demuxSampleAes=function(R,v,T){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},H.destroy=function(){},z}();M.minProbeByteLength=1024,$.default=M},"./src/demux/mpegaudio.ts":function(oe,$,D){"use strict";D.r($),D.d($,"appendFrame",function(){return N}),D.d($,"parseHeader",function(){return R}),D.d($,"isHeaderPattern",function(){return v}),D.d($,"isHeader",function(){return T}),D.d($,"canParse",function(){return O}),D.d($,"probe",function(){return L});var Z=null,F=[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],z=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],H=[0,1,1,4];function N(A,C,u,o,l){if(u+24>C.length)return;var h=R(C,u);if(h&&u+h.frameLength<=C.length){var w=h.samplesPerFrame*9e4/h.sampleRate,y=o+l*w,g={unit:C.subarray(u,u+h.frameLength),pts:y,dts:y};return A.config=[],A.channelCount=h.channelCount,A.samplerate=h.sampleRate,A.samples.push(g),{sample:g,length:h.frameLength,missing:0}}}function R(A,C){var u=A[C+1]>>3&3,o=A[C+1]>>1&3,l=A[C+2]>>4&15,h=A[C+2]>>2&3;if(u!==1&&l!==0&&l!==15&&h!==3){var w=A[C+2]>>1&1,y=A[C+3]>>6,g=u===3?3-o:o===3?3:4,k=F[g*14+l-1]*1e3,x=u===3?0:u===2?1:2,f=M[x*3+h],p=y===3?1:2,d=z[u][o],a=H[o],b=d*8*a,m=Math.floor(d*k/f+w)*a;if(Z===null){var E=navigator.userAgent||"",B=E.match(/Chrome\/(\d+)/i);Z=B?parseInt(B[1]):0}var U=!!Z&&Z<=87;return U&&o===2&&k>=224e3&&y===0&&(A[C+3]=A[C+3]|128),{sampleRate:f,channelCount:p,frameLength:m,samplesPerFrame:b}}}function v(A,C){return A[C]===255&&(A[C+1]&224)===224&&(A[C+1]&6)!==0}function T(A,C){return C+1<A.length&&v(A,C)}function O(A,C){var u=4;return v(A,C)&&u<=A.length-C}function L(A,C){if(C+1<A.length&&v(A,C)){var u=4,o=R(A,C),l=u;o!=null&&o.frameLength&&(l=o.frameLength);var h=C+l;return h===A.length||T(A,h)}return!1}},"./src/demux/sample-aes.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/crypt/decrypter.ts"),F=D("./src/demux/tsdemuxer.ts"),M=function(){function z(N,R,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new Z.default(N,R,{removePKCS7Padding:!1})}var H=z.prototype;return H.decryptBuffer=function(R,v){this.decrypter.decrypt(R,this.keyData.key.buffer,this.keyData.iv.buffer,v)},H.decryptAacSample=function(R,v,T,O){var L=R[v].unit,A=L.subarray(16,L.length-L.length%16),C=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),u=this;this.decryptBuffer(C,function(o){var l=new Uint8Array(o);L.set(l,16),O||u.decryptAacSamples(R,v+1,T)})},H.decryptAacSamples=function(R,v,T){for(;;v++){if(v>=R.length){T();return}if(R[v].unit.length<32)continue;var O=this.decrypter.isSync();if(this.decryptAacSample(R,v,T,O),!O)return}},H.getAvcEncryptedData=function(R){for(var v=Math.floor((R.length-48)/160)*16+16,T=new Int8Array(v),O=0,L=32;L<=R.length-16;L+=160,O+=16)T.set(R.subarray(L,L+16),O);return T},H.getAvcDecryptedUnit=function(R,v){for(var T=new Uint8Array(v),O=0,L=32;L<=R.length-16;L+=160,O+=16)R.set(T.subarray(O,O+16),L);return R},H.decryptAvcSample=function(R,v,T,O,L,A){var C=Object(F.discardEPB)(L.data),u=this.getAvcEncryptedData(C),o=this;this.decryptBuffer(u.buffer,function(l){L.data=o.getAvcDecryptedUnit(C,l),A||o.decryptAvcSamples(R,v,T+1,O)})},H.decryptAvcSamples=function(R,v,T,O){if(R instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,T=0){if(v>=R.length){O();return}for(var L=R[v].units;!(T>=L.length);T++){var A=L[T];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var C=this.decrypter.isSync();if(this.decryptAvcSample(R,v,T,O,A,C),!C)return}}},z}();$.default=M},"./src/demux/transmuxer-interface.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return L});var Z=D("./node_modules/webworkify-webpack/index.js"),F=D.n(Z),M=D("./src/events.ts"),z=D("./src/demux/transmuxer.ts"),H=D("./src/utils/logger.ts"),N=D("./src/errors.ts"),R=D("./src/utils/mediasource-helper.ts"),v=D("./node_modules/eventemitter3/index.js"),T=D.n(v),O=Object(R.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function A(u,o,l,h){var w=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 y=u.config,g=function(d,a){a=a||{},a.frag=w.frag,a.id=w.id,u.trigger(d,a)};this.observer=new v.EventEmitter,this.observer.on(M.Events.FRAG_DECRYPTED,g),this.observer.on(M.Events.ERROR,g);var k={mp4:O.isTypeSupported("video/mp4"),mpeg:O.isTypeSupported("audio/mpeg"),mp3:O.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(y.enableWorker&&typeof Worker!="undefined"){H.logger.log("demuxing in webworker");var f;try{f=this.worker=Z("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(p){u.trigger(M.Events.ERROR,{type:N.ErrorTypes.OTHER_ERROR,details:N.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},f.postMessage({cmd:"init",typeSupported:k,vendor:x,id:o,config:JSON.stringify(y)})}catch(p){H.logger.warn("Error in worker:",p),H.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new z.default(this.observer,k,y,x,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,k,y,x,o)}var C=A.prototype;return C.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},C.push=function(o,l,h,w,y,g,k,x,f,p){var d=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,m=g?g.start:y.start,E=y.decryptdata,B=this.frag,U=!(B&&y.cc===B.cc),K=!(B&&f.level===B.level),V=B?f.sn-B.sn:-1,P=this.part?f.part-this.part.index:1,_=!K&&(V===1||V===0&&P===1),Y=self.performance.now();(K||V||y.stats.parsing.start===0)&&(y.stats.parsing.start=Y),g&&(P||!_)&&(g.stats.parsing.start=Y);var ee=new z.TransmuxState(U,_,x,K,m);if(!_||U){H.logger.log("[transmuxer-interface, "+y.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
discontinuity: `+U+`
trackSwitch: `+K+`
contiguous: `+_+`
accurateTimeOffset: `+x+`
timeOffset: `+m);var ae=new z.TransmuxConfig(h,w,l,k,p);this.configureTransmuxer(ae)}if(this.frag=y,this.part=g,b)b.postMessage({cmd:"demux",data:o,decryptdata:E,chunkMeta:f,state:ee},o instanceof ArrayBuffer?[o]:[]);else if(a){var ce=a.push(o,E,f,ee);Object(z.isPromise)(ce)?ce.then(function(De){d.handleTransmuxComplete(De)}):this.handleTransmuxComplete(ce)}},C.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var h=this.transmuxer,w=this.worker;if(w)w.postMessage({cmd:"flush",chunkMeta:o});else if(h){var y=h.flush(o);Object(z.isPromise)(y)?y.then(function(g){l.handleFlushResult(g,o)}):this.handleFlushResult(y,o)}},C.handleFlushResult=function(o,l){var h=this;o.forEach(function(w){h.handleTransmuxComplete(w)}),this.onFlush(l)},C.onWorkerMessage=function(o){var l=o.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},C.configureTransmuxer=function(o){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):h&&h.configure(o)},C.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},A}()},"./src/demux/transmuxer-worker.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return N});var Z=D("./src/demux/transmuxer.ts"),F=D("./src/events.ts"),M=D("./src/utils/logger.ts"),z=D("./node_modules/eventemitter3/index.js"),H=D.n(z);function N(L){var A=new z.EventEmitter,C=function(o,l){L.postMessage({event:o,data:l})};A.on(F.Events.FRAG_DECRYPTED,C),A.on(F.Events.ERROR,C),L.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);L.transmuxer=new Z.default(A,o.typeSupported,l,o.vendor,o.id),Object(M.enableLogs)(l.debug),C("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(Z.isPromise)(h)?h.then(function(g){R(L,g)}):R(L,h);break}case"flush":{var w=o.chunkMeta,y=L.transmuxer.flush(w);Object(Z.isPromise)(y)?y.then(function(g){T(L,g,w)}):T(L,y,w);break}default:break}})}function R(L,A){if(O(A.remuxResult))return;var C=[],u=A.remuxResult,o=u.audio,l=u.video;o&&v(C,o),l&&v(C,l),L.postMessage({event:"transmuxComplete",data:A},C)}function v(L,A){A.data1&&L.push(A.data1.buffer),A.data2&&L.push(A.data2.buffer)}function T(L,A,C){A.forEach(function(u){R(L,u)}),L.postMessage({event:"flush",data:C})}function O(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return l}),D.d($,"isPromise",function(){return y}),D.d($,"TransmuxConfig",function(){return g}),D.d($,"TransmuxState",function(){return k});var Z=D("./src/events.ts"),F=D("./src/errors.ts"),M=D("./src/crypt/decrypter.ts"),z=D("./src/demux/aacdemuxer.ts"),H=D("./src/demux/mp4demuxer.ts"),N=D("./src/demux/tsdemuxer.ts"),R=D("./src/demux/mp3demuxer.ts"),v=D("./src/remux/mp4-remuxer.ts"),T=D("./src/remux/passthrough-remuxer.ts"),O=D("./src/demux/chunk-cache.ts"),L=D("./src/utils/mp4-tools.ts"),A=D("./src/utils/logger.ts"),C;try{C=self.performance.now.bind(self.performance)}catch(x){A.logger.debug("Unable to use Performance API on this environment"),C=self.Date.now}var u=[{demux:N.default,remux:v.default},{demux:H.default,remux:T.default},{demux:z.default,remux:v.default},{demux:R.default,remux:v.default}],o=1024;u.forEach(function(x){var f=x.demux;o=Math.max(o,f.minProbeByteLength)});var l=function(){function x(p,d,a,b,m){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new O.default,this.observer=p,this.typeSupported=d,this.config=a,this.vendor=b,this.id=m}var f=x.prototype;return f.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},f.push=function(d,a,b,m){var E=this,B=b.transmuxing;B.executeStart=C();var U=new Uint8Array(d),K=this.cache,V=this.config,P=this.currentTransmuxState,_=this.transmuxConfig;m&&(this.currentTransmuxState=m);var Y=h(U,a);if(Y&&Y.method==="AES-128"){var ee=this.getDecrypter();if(V.enableSoftwareAES){var ae=ee.softwareDecrypt(U,Y.key.buffer,Y.iv.buffer);if(!ae)return B.executeEnd=C(),w(b);U=new Uint8Array(ae)}else return this.decryptionPromise=ee.webCryptoDecrypt(U,Y.key.buffer,Y.iv.buffer).then(function(Re){var Be=E.push(Re,null,b);return E.decryptionPromise=null,Be}),this.decryptionPromise}var ce=m||P,De=ce.contiguous,Se=ce.discontinuity,Ce=ce.trackSwitch,Ae=ce.accurateTimeOffset,Te=ce.timeOffset,ve=_.audioCodec,le=_.videoCodec,te=_.defaultInitPts,de=_.duration,ne=_.initSegmentData;if((Se||Ce)&&this.resetInitSegment(ne,ve,le,de),Se&&this.resetInitialTimestamp(te),De||this.resetContiguity(),this.needsProbing(U,Se,Ce)){if(K.dataLength){var ke=K.flush();U=Object(L.appendUint8Array)(ke,U)}this.configureTransmuxer(U,_)}var Oe=this.transmux(U,Y,Te,Ae,b),Ee=this.currentTransmuxState;return Ee.contiguous=!0,Ee.discontinuity=!1,Ee.trackSwitch=!1,B.executeEnd=C(),Oe},f.flush=function(d){var a=this,b=d.transmuxing;b.executeStart=C();var m=this.decrypter,E=this.cache,B=this.currentTransmuxState,U=this.decryptionPromise;if(U)return U.then(function(){return a.flush(d)});var K=[],V=B.timeOffset;if(m){var P=m.flush();P&&K.push(this.push(P,null,d))}var _=E.dataLength;E.reset();var Y=this.demuxer,ee=this.remuxer;if(!Y||!ee)return _>=o&&this.observer.emit(Z.Events.ERROR,Z.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),b.executeEnd=C(),[w(d)];var ae=Y.flush(V);return y(ae)?ae.then(function(ce){return a.flushRemux(K,ce,d),K}):(this.flushRemux(K,ae,d),K)},f.flushRemux=function(d,a,b){var m=a.audioTrack,E=a.avcTrack,B=a.id3Track,U=a.textTrack,K=this.currentTransmuxState,V=K.accurateTimeOffset,P=K.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var _=this.remuxer.remux(m,E,B,U,P,V,!0,this.id);d.push({remuxResult:_,chunkMeta:b}),b.transmuxing.executeEnd=C()},f.resetInitialTimestamp=function(d){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(d),b.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,b,m){var E=this.demuxer,B=this.remuxer;if(!E||!B)return;E.resetInitSegment(a,b,m),B.resetInitSegment(d,a,b)},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,b,m,E){var B;return a&&a.method==="SAMPLE-AES"?B=this.transmuxSampleAes(d,a,b,m,E):B=this.transmuxUnencrypted(d,b,m,E),B},f.transmuxUnencrypted=function(d,a,b,m){var E=this.demuxer.demux(d,a,!1,!this.config.progressive),B=E.audioTrack,U=E.avcTrack,K=E.id3Track,V=E.textTrack,P=this.remuxer.remux(B,U,K,V,a,b,!1,this.id);return{remuxResult:P,chunkMeta:m}},f.transmuxSampleAes=function(d,a,b,m,E){var B=this;return this.demuxer.demuxSampleAes(d,a,b).then(function(U){var K=B.remuxer.remux(U.audioTrack,U.avcTrack,U.id3Track,U.textTrack,b,m,!1,B.id);return{remuxResult:K,chunkMeta:E}})},f.configureTransmuxer=function(d,a){for(var b=this.config,m=this.observer,E=this.typeSupported,B=this.vendor,U=a.audioCodec,K=a.defaultInitPts,V=a.duration,P=a.initSegmentData,_=a.videoCodec,Y,ee=0,ae=u.length;ee<ae;ee++)if(u[ee].demux.probe(d)){Y=u[ee];break}Y||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Y={demux:H.default,remux:T.default});var ce=this.demuxer,De=this.remuxer,Se=Y.remux,Ce=Y.demux;(!De||!(De instanceof Se))&&(this.remuxer=new Se(m,b,E,B)),(!ce||!(ce instanceof Ce))&&(this.demuxer=new Ce(m,b,E),this.probe=Ce.probe),this.resetInitSegment(P,U,_,V),this.resetInitialTimestamp(K)},f.needsProbing=function(d,a,b){return!this.demuxer||!this.remuxer||a||b},f.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new M.default(this.observer,this.config)),d},x}();function h(x,f){var p=null;return x.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var w=function(f){return{remuxResult:{},chunkMeta:f}};function y(x){return"then"in x&&x.then instanceof Function}var g=function(f,p,d,a,b){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=p,this.initSegmentData=d,this.duration=a,this.defaultInitPts=b},k=function(f,p,d,a,b){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=p,this.accurateTimeOffset=d,this.trackSwitch=a,this.timeOffset=b}},"./src/demux/tsdemuxer.ts":function(oe,$,D){"use strict";D.r($),D.d($,"discardEPB",function(){return w});var Z=D("./src/demux/adts.ts"),F=D("./src/demux/mpegaudio.ts"),M=D("./src/demux/exp-golomb.ts"),z=D("./src/demux/id3.ts"),H=D("./src/demux/sample-aes.ts"),N=D("./src/events.ts"),R=D("./src/utils/mp4-tools.ts"),v=D("./src/utils/logger.ts"),T=D("./src/errors.ts"),O={video:1,audio:2,id3:3,text:4},L=function(){function y(k,x,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=x,this.typeSupported=f}y.probe=function(x){var f=y.syncOffset(x);return f<0?!1:(f&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},y.syncOffset=function(x){for(var f=Math.min(1e3,x.length-3*188),p=0;p<f;){if(x[p]===71&&x[p+188]===71&&x[p+2*188]===71)return p;p++}return-1},y.createTrack=function(x,f){return{container:x==="video"||x==="audio"?"video/mp2t":void 0,type:x,id:O[x],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:x==="audio"?f:void 0}};var g=y.prototype;return g.resetInitSegment=function(x,f,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=y.createTrack("video",p),this._audioTrack=y.createTrack("audio",p),this._id3Track=y.createTrack("id3",p),this._txtTrack=y.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=f,this._duration=p},g.resetTimeStamp=function(){},g.resetContiguity=function(){var x=this._audioTrack,f=this._avcTrack,p=this._id3Track;x&&(x.pesData=null),f&&(f.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},g.demux=function(x,f,p,d){p===void 0&&(p=!1),d===void 0&&(d=!1),p||(this.sampleAes=null);var a,b=this._avcTrack,m=this._audioTrack,E=this._id3Track,B=b.pid,U=b.pesData,K=m.pid,V=E.pid,P=m.pesData,_=E.pesData,Y=!1,ee=this.pmtParsed,ae=this._pmtId,ce=x.length;if(this.remainderData&&(x=Object(R.appendUint8Array)(this.remainderData,x),ce=x.length,this.remainderData=null),ce<188&&!d)return this.remainderData=x,{audioTrack:m,avcTrack:b,id3Track:E,textTrack:this._txtTrack};var De=Math.max(0,y.syncOffset(x));ce-=(ce+De)%188,ce<x.byteLength&&!d&&(this.remainderData=new Uint8Array(x.buffer,ce,x.buffer.byteLength-ce));for(var Se=De;Se<ce;Se+=188)if(x[Se]===71){var Ce=!!(x[Se+1]&64),Ae=((x[Se+1]&31)<<8)+x[Se+2],Te=(x[Se+3]&48)>>4,ve=void 0;if(Te>1){if(ve=Se+5+x[Se+4],ve===Se+188)continue}else ve=Se+4;switch(Ae){case B:Ce&&(U&&(a=o(U))&&this.parseAVCPES(a,!1),U={data:[],size:0}),U&&(U.data.push(x.subarray(ve,Se+188)),U.size+=Se+188-ve);break;case K:Ce&&(P&&(a=o(P))&&(m.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),P={data:[],size:0}),P&&(P.data.push(x.subarray(ve,Se+188)),P.size+=Se+188-ve);break;case V:Ce&&(_&&(a=o(_))&&this.parseID3PES(a),_={data:[],size:0}),_&&(_.data.push(x.subarray(ve,Se+188)),_.size+=Se+188-ve);break;case 0:Ce&&(ve+=x[ve]+1),ae=this._pmtId=C(x,ve);break;case ae:{Ce&&(ve+=x[ve]+1);var le=u(x,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);B=le.avc,B>0&&(b.pid=B),K=le.audio,K>0&&(m.pid=K,m.isAAC=le.isAAC),V=le.id3,V>0&&(E.pid=V),Y&&!ee&&(v.logger.log("reparse from beginning"),Y=!1,Se=De-188),ee=this.pmtParsed=!0;break}case 17:case 8191:break;default:Y=!0;break}}else this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b.pesData=U,m.pesData=P,E.pesData=_;var te={audioTrack:m,avcTrack:b,id3Track:E,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(te),te},g.flush=function(){var x=this.remainderData;this.remainderData=null;var f;return x?f=this.demux(x,-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},g.extractRemainingSamples=function(x){var f=x.audioTrack,p=x.avcTrack,d=x.id3Track,a=p.pesData,b=f.pesData,m=d.pesData,E;a&&(E=o(a))?(this.parseAVCPES(E,!0),p.pesData=null):p.pesData=a,b&&(E=o(b))?(f.isAAC?this.parseAACPES(E):this.parseMPEGPES(E),f.pesData=null):(b!=null&&b.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=b),m&&(E=o(m))?(this.parseID3PES(E),d.pesData=null):d.pesData=m},g.demuxSampleAes=function(x,f,p){var d=this.demux(x,p,!0,!this.config.progressive),a=this.sampleAes=new H.default(this.observer,this.config,f);return this.decrypt(d,a)},g.decrypt=function(x,f){return new Promise(function(p){var d=x.audioTrack,a=x.avcTrack;d.samples&&d.isAAC?f.decryptAacSamples(d.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){p(x)}):p(x)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){p(x)})})},g.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},g.parseAVCPES=function(x,f){var p=this,d=this._avcTrack,a=this.parseAVCNALu(x.data),b=!1,m=this.avcSample,E,B=!1;x.data=null,m&&a.length&&!d.audFound&&(l(m,d),m=this.avcSample=A(!1,x.pts,x.dts,"")),a.forEach(function(U){switch(U.type){case 1:{E=!0,m||(m=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(m.debug+="NDR "),m.frame=!0;var K=U.data;if(B&&K.length>4){var V=new M.default(K).readSliceType();(V===2||V===4||V===7||V===9)&&(m.key=!0)}break}case 5:E=!0,m||(m=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{E=!0,b&&m&&(m.debug+="SEI ");var P=new M.default(w(U.data));P.readUByte();for(var _=0,Y=0,ee=!1,ae=0;!ee&&P.bytesAvailable>1;){_=0;do ae=P.readUByte(),_+=ae;while(ae===255);Y=0;do ae=P.readUByte(),Y+=ae;while(ae===255);if(_===4&&P.bytesAvailable!==0){ee=!0;var ce=P.readUByte();if(ce===181){var De=P.readUShort();if(De===49){var Se=P.readUInt();if(Se===1195456820){var Ce=P.readUByte();if(Ce===3){for(var Ae=P.readUByte(),Te=P.readUByte(),ve=31&Ae,le=[Ae,Te],te=0;te<ve;te++)le.push(P.readUByte()),le.push(P.readUByte()),le.push(P.readUByte());h(p._txtTrack.samples,{type:3,pts:x.pts,bytes:le})}}}}}else if(_===5&&P.bytesAvailable!==0){if(ee=!0,Y>16){for(var de=[],ne=0;ne<16;ne++)de.push(P.readUByte().toString(16)),(ne===3||ne===5||ne===7||ne===9)&&de.push("-");for(var ke=Y-16,Oe=new Uint8Array(ke),Ee=0;Ee<ke;Ee++)Oe[Ee]=P.readUByte();h(p._txtTrack.samples,{pts:x.pts,payloadType:_,uuid:de.join(""),userData:Object(z.utf8ArrayToStr)(Oe),userDataBytes:Oe})}}else if(Y<P.bytesAvailable)for(var Re=0;Re<Y;Re++)P.readUByte()}break}case 7:if(E=!0,B=!0,b&&m&&(m.debug+="SPS "),!d.sps){var Be=new M.default(U.data),ze=Be.readSPS();d.width=ze.width,d.height=ze.height,d.pixelRatio=ze.pixelRatio,d.sps=[U.data],d.duration=p._duration;for(var Fe=U.data.subarray(1,4),Ue="avc1.",Ie=0;Ie<3;Ie++){var it=Fe[Ie].toString(16);it.length<2&&(it="0"+it),Ue+=it}d.codec=Ue}break;case 8:E=!0,b&&m&&(m.debug+="PPS "),d.pps||(d.pps=[U.data]);break;case 9:E=!1,d.audFound=!0,m&&l(m,d),m=p.avcSample=A(!1,x.pts,x.dts,b?"AUD ":"");break;case 12:E=!1;break;default:E=!1,m&&(m.debug+="unknown NAL "+U.type+" ");break}if(m&&E){var Ye=m.units;Ye.push(U)}}),f&&m&&(l(m,d),this.avcSample=null)},g.getLastNalUnit=function(){var x,f=this.avcSample,p;if(!f||f.units.length===0){var d=this._avcTrack.samples;f=d[d.length-1]}if((x=f)!==null&&x!==void 0&&x.units){var a=f.units;p=a[a.length-1]}return p},g.parseAVCNALu=function(x){var f=x.byteLength,p=this._avcTrack,d=p.naluState||0,a=d,b=[],m=0,E,B,U,K=-1,V=0;for(d===-1&&(K=0,V=x[0]&31,d=0,m=1);m<f;){if(E=x[m++],!d){d=E?0:1;continue}if(d===1){d=E?0:2;continue}if(!E)d=3;else if(E===1){if(K>=0){var P={data:x.subarray(K,m-d-1),type:V};b.push(P)}else{var _=this.getLastNalUnit();if(_&&(a&&m<=4-a&&(_.state&&(_.data=_.data.subarray(0,_.data.byteLength-a))),B=m-d-1,B>0)){var Y=new Uint8Array(_.data.byteLength+B);Y.set(_.data,0),Y.set(x.subarray(0,B),_.data.byteLength),_.data=Y,_.state=0}}m<f?(U=x[m]&31,K=m,V=U,d=0):d=-1}else d=0}if(K>=0&&d>=0){var ee={data:x.subarray(K,f),type:V,state:d};b.push(ee)}if(b.length===0){var ae=this.getLastNalUnit();if(ae){var ce=new Uint8Array(ae.data.byteLength+x.byteLength);ce.set(ae.data,0),ce.set(x,ae.data.byteLength),ae.data=ce}}return p.naluState=d,b},g.parseAACPES=function(x){var f=0,p=this._audioTrack,d=this.aacOverFlow,a=x.data;if(d){this.aacOverFlow=null;var b=d.sample.unit.byteLength,m=Math.min(d.missing,b),E=b-m;d.sample.unit.set(a.subarray(0,m),E),p.samples.push(d.sample),f=d.missing}var B,U;for(B=f,U=a.length;B<U-1&&!Z.isHeader(a,B);B++);if(B!==f){var K,V;if(B<U-1?(K="AAC PES did not start with ADTS header,offset:"+B,V=!1):(K="no ADTS header found in AAC PES",V=!0),v.logger.warn("parsing error:"+K),this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:K}),V)return}Z.initTrackConfig(p,this.observer,a,B,this.audioCodec);var P;if(x.pts!==void 0)P=x.pts;else if(d){var _=Z.getFrameDuration(p.samplerate);P=d.sample.pts+_}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Y=0;B<U;)if(Z.isHeader(a,B)){if(B+5<U){var ee=Z.appendFrame(p,a,B,P,Y);if(ee)if(ee.missing)this.aacOverFlow=ee;else{B+=ee.length,Y++;continue}}break}else B++},g.parseMPEGPES=function(x){var f=x.data,p=f.length,d=0,a=0,b=x.pts;if(b===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<p;)if(F.isHeader(f,a)){var m=F.appendFrame(this._audioTrack,f,a,b,d);if(m)a+=m.length,d++;else break}else a++},g.parseID3PES=function(x){if(x.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(x)},y}();L.minProbeByteLength=188;function A(y,g,k,x){return{key:y,frame:!1,pts:g,dts:k,units:[],debug:x,length:0}}function C(y,g){return(y[g+10]&31)<<8|y[g+11]}function u(y,g,k,x){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(y[g+1]&15)<<8|y[g+2],d=g+3+p-4,a=(y[g+10]&15)<<8|y[g+11];for(g+=12+a;g<d;){var b=(y[g+1]&31)<<8|y[g+2];switch(y[g]){case 207:if(!x){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=b);break;case 21:f.id3===-1&&(f.id3=b);break;case 219:if(!x){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=b);break;case 3:case 4:k?f.audio===-1&&(f.audio=b,f.isAAC=!1):v.logger.log("MPEG audio found, not supported in this browser");break;case 36:v.logger.warn("Unsupported HEVC stream type found");break;default:break}g+=((y[g+3]&15)<<8|y[g+4])+5}return f}function o(y){var g=0,k,x,f,p,d,a=y.data;if(!y||y.size===0)return null;for(;a[0].length<19&&a.length>1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}k=a[0];var m=(k[0]<<16)+(k[1]<<8)+k[2];if(m===1){if(x=(k[4]<<8)+k[5],x&&x>y.size-6)return null;var E=k[7];E&192&&(p=(k[9]&14)*536870912+(k[10]&255)*4194304+(k[11]&254)*16384+(k[12]&255)*128+(k[13]&254)/2,E&64?(d=(k[14]&14)*536870912+(k[15]&255)*4194304+(k[16]&254)*16384+(k[17]&255)*128+(k[18]&254)/2,p-d>60*9e4&&(v.logger.warn(Math.round((p-d)/9e4)+"s delta between PTS and DTS, align them"),p=d)):d=p),f=k[8];var B=f+9;if(y.size<=B)return null;y.size-=B;for(var U=new Uint8Array(y.size),K=0,V=a.length;K<V;K++){k=a[K];var P=k.byteLength;if(B)if(B>P){B-=P;continue}else k=k.subarray(B),P-=B,B=0;U.set(k,g),g+=P}return x&&(x-=f+3),{data:U,pts:p,dts:d,len:x}}return null}function l(y,g){if(y.units.length&&y.frame){if(y.pts===void 0){var k=g.samples,x=k.length;if(x){var f=k[x-1];y.pts=f.pts,y.dts=f.dts}else{g.dropped++;return}}g.samples.push(y)}y.debug.length&&v.logger.log(y.pts+"/"+y.dts+":"+y.debug)}function h(y,g){var k=y.length;if(k>0){if(g.pts>=y[k-1].pts)y.push(g);else for(var x=k-1;x>=0;x--)if(g.pts<y[x].pts){y.splice(x,0,g);break}}else y.push(g)}function w(y){for(var g=y.byteLength,k=[],x=1;x<g-2;)y[x]===0&&y[x+1]===0&&y[x+2]===3?(k.push(x+2),x+=2):x++;if(k.length===0)return y;var f=g-k.length,p=new Uint8Array(f),d=0;for(x=0;x<f;d++,x++)d===k[0]&&(d++,k.shift()),p[x]=y[d];return p}$.default=L},"./src/errors.ts":function(oe,$,D){"use strict";D.r($),D.d($,"ErrorTypes",function(){return Z}),D.d($,"ErrorDetails",function(){return F});var Z;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(Z||(Z={}));var F;(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"})(F||(F={}))},"./src/events.ts":function(oe,$,D){"use strict";D.r($),D.d($,"Events",function(){return Z});var Z;(function(F){F.MEDIA_ATTACHING="hlsMediaAttaching",F.MEDIA_ATTACHED="hlsMediaAttached",F.MEDIA_DETACHING="hlsMediaDetaching",F.MEDIA_DETACHED="hlsMediaDetached",F.BUFFER_RESET="hlsBufferReset",F.BUFFER_CODECS="hlsBufferCodecs",F.BUFFER_CREATED="hlsBufferCreated",F.BUFFER_APPENDING="hlsBufferAppending",F.BUFFER_APPENDED="hlsBufferAppended",F.BUFFER_EOS="hlsBufferEos",F.BUFFER_FLUSHING="hlsBufferFlushing",F.BUFFER_FLUSHED="hlsBufferFlushed",F.MANIFEST_LOADING="hlsManifestLoading",F.MANIFEST_LOADED="hlsManifestLoaded",F.MANIFEST_PARSED="hlsManifestParsed",F.LEVEL_SWITCHING="hlsLevelSwitching",F.LEVEL_SWITCHED="hlsLevelSwitched",F.LEVEL_LOADING="hlsLevelLoading",F.LEVEL_LOADED="hlsLevelLoaded",F.LEVEL_UPDATED="hlsLevelUpdated",F.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",F.LEVELS_UPDATED="hlsLevelsUpdated",F.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",F.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",F.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",F.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",F.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",F.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",F.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",F.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",F.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",F.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",F.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",F.CUES_PARSED="hlsCuesParsed",F.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",F.INIT_PTS_FOUND="hlsInitPtsFound",F.FRAG_LOADING="hlsFragLoading",F.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",F.FRAG_LOADED="hlsFragLoaded",F.FRAG_DECRYPTED="hlsFragDecrypted",F.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",F.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",F.FRAG_PARSING_METADATA="hlsFragParsingMetadata",F.FRAG_PARSED="hlsFragParsed",F.FRAG_BUFFERED="hlsFragBuffered",F.FRAG_CHANGED="hlsFragChanged",F.FPS_DROP="hlsFpsDrop",F.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",F.ERROR="hlsError",F.DESTROYING="hlsDestroying",F.KEY_LOADING="hlsKeyLoading",F.KEY_LOADED="hlsKeyLoaded",F.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",F.BACK_BUFFER_REACHED="hlsBackBufferReached"})(Z||(Z={}))},"./src/hls.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return y});var Z=D("./node_modules/url-toolkit/src/url-toolkit.js"),F=D.n(Z),M=D("./src/loader/playlist-loader.ts"),z=D("./src/loader/key-loader.ts"),H=D("./src/controller/id3-track-controller.ts"),N=D("./src/controller/latency-controller.ts"),R=D("./src/controller/level-controller.ts"),v=D("./src/controller/fragment-tracker.ts"),T=D("./src/controller/stream-controller.ts"),O=D("./src/is-supported.ts"),L=D("./src/utils/logger.ts"),A=D("./src/config.ts"),C=D("./node_modules/eventemitter3/index.js"),u=D.n(C),o=D("./src/events.ts"),l=D("./src/errors.ts");function h(g,k){for(var x=0;x<k.length;x++){var f=k[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(g,f.key,f)}}function w(g,k,x){return k&&h(g.prototype,k),x&&h(g,x),g}var y=function(){g.isSupported=function(){return Object(O.isSupported)()};function g(x){x===void 0&&(x={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new C.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var f=this.config=Object(A.mergeConfig)(g.DefaultConfig,x);this.userConfig=x,Object(L.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(A.enableStreamingMode)(f);var p=f.abrController,d=f.bufferController,a=f.capLevelController,b=f.fpsController,m=this.abrController=new p(this),E=this.bufferController=new d(this),B=this.capLevelController=new a(this),U=new b(this),K=new M.default(this),V=new z.default(this),P=new H.default(this),_=this.levelController=new R.default(this),Y=new v.FragmentTracker(this),ee=this.streamController=new T.default(this,Y);B.setStreamController(ee),U.setStreamController(ee);var ae=[_,ee];this.networkControllers=ae;var ce=[K,V,m,E,B,U,P,Y];this.audioTrackController=this.createController(f.audioTrackController,null,ae),this.createController(f.audioStreamController,Y,ae),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,ae),this.createController(f.subtitleStreamController,Y,ae),this.createController(f.timelineController,null,ce),this.emeController=this.createController(f.emeController,null,ce),this.cmcdController=this.createController(f.cmcdController,null,ce),this.latencyController=this.createController(N.default,null,ce),this.coreComponents=ce}var k=g.prototype;return k.createController=function(f,p,d){if(f){var a=p?new f(this,p):new f(this);return d&&d.push(a),a}return null},k.on=function(f,p,d){d===void 0&&(d=this),this._emitter.on(f,p,d)},k.once=function(f,p,d){d===void 0&&(d=this),this._emitter.once(f,p,d)},k.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},k.off=function(f,p,d,a){d===void 0&&(d=this),this._emitter.off(f,p,d,a)},k.listeners=function(f){return this._emitter.listeners(f)},k.emit=function(f,p,d){return this._emitter.emit(f,p,d)},k.trigger=function(f,p){if(this.config.debug)return this.emit(f,f,p);try{return this.emit(f,f,p)}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 p=this.media,d=this.url,a=this.url=Z.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});L.logger.log("loadSource:"+a),p&&d&&d!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),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(p){p.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,p){p===void 0&&(p=0),this.levelController.removeLevel(f,p)},w(g,[{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 p=!!f;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(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,p=this.config.minAutoBitrate;if(!f)return 0;for(var d=f.length,a=0;a<d;a++)if(f[a].maxBitrate>p)return a;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,p=this.autoLevelCapping,d;return p===-1&&f&&f.length?d=f.length-1:d=p,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 p=this.audioTrackController;p&&(p.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 p=this.subtitleTrackController;p&&(p.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 p=this.subtitleTrackController;p&&(p.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 g.defaultConfig?g.defaultConfig:A.hlsDefaultConfig},set:function(f){g.defaultConfig=f}}]),g}();y.defaultConfig=void 0},"./src/is-supported.ts":function(oe,$,D){"use strict";D.r($),D.d($,"isSupported",function(){return M}),D.d($,"changeTypeSupported",function(){return z});var Z=D("./src/utils/mediasource-helper.ts");function F(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var H=Object(Z.getMediaSource)();if(!H)return!1;var N=F(),R=H&&typeof H.isTypeSupported=="function"&&H.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!N||N.prototype&&typeof N.prototype.appendBuffer=="function"&&typeof N.prototype.remove=="function";return!!R&&!!v}function z(){var H,N=F();return typeof(N==null||((H=N.prototype)===null||H===void 0)?void 0:H.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return L}),D.d($,"LoadError",function(){return C});var Z=D("./src/polyfills/number.ts"),F=D("./src/errors.ts");function M(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,v(u,o)}function z(u){var o=typeof Map=="function"?new Map:void 0;return z=function(h){if(h===null||!R(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(h))return o.get(h);o.set(h,w)}function w(){return H(h,arguments,T(this).constructor)}return w.prototype=Object.create(h.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v(w,h)},z(u)}function H(u,o,l){return N()?H=Reflect.construct:H=function(w,y,g){var k=[null];k.push.apply(k,y);var x=Function.bind.apply(w,k),f=new x;return g&&v(f,g.prototype),f},H.apply(null,arguments)}function N(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(u){return!1}}function R(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function v(u,o){return v=Object.setPrototypeOf||function(h,w){return h.__proto__=w,h},v(u,o)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},T(u)}var O=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,w){var y=this,g=h.url;if(!g)return Promise.reject(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(g?"part list":"url")));this.abort();var k=this.config,x=k.fLoader,f=k.loader;return new Promise(function(p,d){y.loader&&y.loader.destroy();var a=y.loader=h.loader=x?new x(k):new f(k),b=A(h),m={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:O};h.stats=a.stats,a.load(b,m,{onSuccess:function(B,U,K,V){y.resetLoader(h,a),p({frag:h,part:null,payload:B.data,networkDetails:V})},onError:function(B,U,K){y.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:B,networkDetails:K}))},onAbort:function(B,U,K){y.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:K}))},onTimeout:function(B,U,K){y.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:K}))},onProgress:function(B,U,K,V){w&&w({frag:h,part:null,payload:K,networkDetails:V})}})})},o.loadPart=function(h,w,y){var g=this;this.abort();var k=this.config,x=k.fLoader,f=k.loader;return new Promise(function(p,d){g.loader&&g.loader.destroy();var a=g.loader=h.loader=x?new x(k):new f(k),b=A(h,w),m={timeout:k.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:k.fragLoadingMaxRetryTimeout,highWaterMark:O};w.stats=a.stats,a.load(b,m,{onSuccess:function(B,U,K,V){g.resetLoader(h,a),g.updateStatsFromPart(h,w);var P={frag:h,part:w,payload:B.data,networkDetails:V};y(P),p(P)},onError:function(B,U,K){g.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:w,response:B,networkDetails:K}))},onAbort:function(B,U,K){h.stats.aborted=w.stats.aborted,g.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:w,networkDetails:K}))},onTimeout:function(B,U,K){g.resetLoader(h,a),d(new C({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:w,networkDetails:K}))}})})},o.updateStatsFromPart=function(h,w){var y=h.stats,g=w.stats,k=g.total;if(y.loaded+=g.loaded,k){var x=Math.round(h.duration/w.duration),f=Math.min(Math.round(y.loaded/k),x),p=x-f,d=p*Math.round(y.loaded/f);y.total=y.loaded+d}else y.total=Math.max(y.loaded,y.total);var a=y.loading,b=g.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(h,w){h.loader=null,this.loader===w&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),w.destroy()},u}();function A(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},w=l.byteRangeStartOffset,y=l.byteRangeEndOffset;return Object(Z.isFiniteNumber)(w)&&Object(Z.isFiniteNumber)(y)&&(h.rangeStart=w,h.rangeEnd=y),h}var C=function(u){M(o,u);function o(l){for(var h,w=arguments.length,y=new Array(w>1?w-1:0),g=1;g<w;g++)y[g-1]=arguments[g];return h=u.call.apply(u,[this].concat(y))||this,h.data=void 0,h.data=l,h}return o}(z(Error))},"./src/loader/fragment.ts":function(oe,$,D){"use strict";D.r($),D.d($,"ElementaryStreamTypes",function(){return L}),D.d($,"BaseSegment",function(){return A}),D.d($,"Fragment",function(){return C}),D.d($,"Part",function(){return u});var Z=D("./src/polyfills/number.ts"),F=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(F),z=D("./src/utils/logger.ts"),H=D("./src/loader/level-key.ts"),N=D("./src/loader/load-stats.ts");function R(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,v(o,l)}function v(o,l){return v=Object.setPrototypeOf||function(w,y){return w.__proto__=y,w},v(o,l)}function T(o,l){for(var h=0;h<l.length;h++){var w=l[h];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function O(o,l,h){return l&&T(o.prototype,l),h&&T(o,h),o}var L;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(L||(L={}));var A=function(){function o(h){var w;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(w={},w[L.AUDIO]=null,w[L.VIDEO]=null,w[L.AUDIOVIDEO]=null,w),this.baseurl=h}var l=o.prototype;return l.setByteRange=function(w,y){var g=w.split("@",2),k=[];g.length===1?k[0]=y?y.byteRangeEndOffset:0:k[0]=parseInt(g[1]),k[1]=parseInt(g[0])+k[0],this._byteRange=k},O(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(F.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(w){this._url=w}}]),o}(),C=function(o){R(l,o);function l(w,y){var g;return g=o.call(this,y)||this,g._decryptdata=null,g.rawProgramDateTime=null,g.programDateTime=null,g.tagList=[],g.duration=0,g.sn=0,g.levelkey=void 0,g.type=void 0,g.loader=null,g.level=-1,g.cc=0,g.startPTS=void 0,g.endPTS=void 0,g.appendedPTS=void 0,g.startDTS=void 0,g.endDTS=void 0,g.start=0,g.deltaPTS=void 0,g.maxStartPTS=void 0,g.minEndPTS=void 0,g.stats=new N.LoadStats,g.urlId=0,g.data=void 0,g.bitrateTest=!1,g.title=null,g.initSegment=null,g.type=w,g}var h=l.prototype;return h.createInitializationVector=function(y){for(var g=new Uint8Array(16),k=12;k<16;k++)g[k]=y>>8*(15-k)&255;return g},h.setDecryptDataFromLevelKey=function(y,g){var k=y;return(y==null?void 0:y.method)==="AES-128"&&y.uri&&!y.iv&&(k=H.LevelKey.fromURI(y.uri),k.method=y.method,k.iv=this.createInitializationVector(g),k.keyFormat="identity"),k},h.setElementaryStreamInfo=function(y,g,k,x,f,p){p===void 0&&(p=!1);var d=this.elementaryStreams,a=d[y];if(!a){d[y]={startPTS:g,endPTS:k,startDTS:x,endDTS:f,partial:p};return}a.startPTS=Math.min(a.startPTS,g),a.endPTS=Math.max(a.endPTS,k),a.startDTS=Math.min(a.startDTS,x),a.endDTS=Math.max(a.endDTS,f)},h.clearElementaryStreamInfo=function(){var y=this.elementaryStreams;y[L.AUDIO]=null,y[L.VIDEO]=null,y[L.AUDIOVIDEO]=null},O(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var y=this.sn;typeof y!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&z.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),y=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,y)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(Z.isFiniteNumber)(this.programDateTime))return null;var y=Object(Z.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+y*1e3}},{key:"encrypted",get:function(){var y;return!!((y=this.decryptdata)!==null&&y!==void 0&&y.keyFormat&&this.decryptdata.uri)}}]),l}(A),u=function(o){R(l,o);function l(h,w,y,g,k){var x;x=o.call(this,y)||this,x.fragOffset=0,x.duration=0,x.gap=!1,x.independent=!1,x.relurl=void 0,x.fragment=void 0,x.index=void 0,x.stats=new N.LoadStats,x.duration=h.decimalFloatingPoint("DURATION"),x.gap=h.bool("GAP"),x.independent=h.bool("INDEPENDENT"),x.relurl=h.enumeratedString("URI"),x.fragment=w,x.index=g;var f=h.enumeratedString("BYTERANGE");return f&&x.setByteRange(f,k),k&&(x.fragOffset=k.fragOffset+k.duration),x}return O(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 w=this.elementaryStreams;return!!(w.audio||w.video||w.audiovideo)}}]),l}(A)},"./src/loader/key-loader.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return z});var Z=D("./src/events.ts"),F=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),z=function(){function H(R){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=R,this._registerListeners()}var N=H.prototype;return N._registerListeners=function(){this.hls.on(Z.Events.KEY_LOADING,this.onKeyLoading,this)},N._unregisterListeners=function(){this.hls.off(Z.Events.KEY_LOADING,this.onKeyLoading)},N.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var T=this.loaders[v];T&&T.destroy()}this.loaders={}},N.onKeyLoading=function(v,T){var O=T.frag,L=O.type,A=this.loaders[L];if(!O.decryptdata){M.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var C=O.decryptdata.uri;if(C!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(A&&(M.logger.warn("abort previous key loader for type:"+L),A.abort()),!C){M.logger.warn("key uri is falsy");return}var o=u.loader,l=O.loader=this.loaders[L]=new o(u);this.decrypturl=C,this.decryptkey=null;var h={url:C,frag:O,responseType:"arraybuffer"},w={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,w,y)}else this.decryptkey&&(O.decryptdata.key=this.decryptkey,this.hls.trigger(Z.Events.KEY_LOADED,{frag:O}))},N.loadsuccess=function(v,T,O){var L=O.frag;if(!L.decryptdata){M.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(v.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger(Z.Events.KEY_LOADED,{frag:L})},N.loaderror=function(v,T){var O=T.frag,L=O.loader;L&&L.abort(),delete this.loaders[O.type],this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:O,response:v})},N.loadtimeout=function(v,T){var O=T.frag,L=O.loader;L&&L.abort(),delete this.loaders[O.type],this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:O})},H}()},"./src/loader/level-details.ts":function(oe,$,D){"use strict";D.r($),D.d($,"LevelDetails",function(){return H});var Z=D("./src/polyfills/number.ts");function F(N,R){for(var v=0;v<R.length;v++){var T=R[v];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(N,T.key,T)}}function M(N,R,v){return R&&F(N.prototype,R),v&&F(N,v),N}var z=10,H=function(){function N(v){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=v}var R=N.prototype;return R.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var O=this.lastPartSn-T.lastPartSn,L=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!L||!!O,this.advanced=this.endSN>T.endSN||O>0||O===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},M(N,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(Z.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||z}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var O=this.driftEnd-this.driftStart;return O*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.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 T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),N}()},"./src/loader/level-key.ts":function(oe,$,D){"use strict";D.r($),D.d($,"LevelKey",function(){return H});var Z=D("./node_modules/url-toolkit/src/url-toolkit.js"),F=D.n(Z);function M(N,R){for(var v=0;v<R.length;v++){var T=R[v];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(N,T.key,T)}}function z(N,R,v){return R&&M(N.prototype,R),v&&M(N,v),N}var H=function(){N.fromURL=function(v,T){return new N(v,T)},N.fromURI=function(v){return new N(v)};function N(R,v){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,v?this._uri=Object(Z.buildAbsoluteURL)(R,v,{alwaysNormalize:!0}):this._uri=R}return z(N,[{key:"uri",get:function(){return this._uri}}]),N}()},"./src/loader/load-stats.ts":function(oe,$,D){"use strict";D.r($),D.d($,"LoadStats",function(){return Z});var Z=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return l});var Z=D("./src/polyfills/number.ts"),F=D("./node_modules/url-toolkit/src/url-toolkit.js"),M=D.n(F),z=D("./src/loader/fragment.ts"),H=D("./src/loader/level-details.ts"),N=D("./src/loader/level-key.ts"),R=D("./src/utils/attr-list.ts"),v=D("./src/utils/logger.ts"),T=D("./src/utils/codecs.ts"),O=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,A=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),C=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(k){var x,f;return u.test((x=(f=F.parseURL(k))===null||f===void 0?void 0:f.path)!=null?x:"")}var l=function(){function k(){}return k.findGroup=function(f,p){for(var d=0;d<f.length;d++){var a=f[d];if(a.id===p)return a}},k.convertAVC1ToAVCOTI=function(f){var p=f.split(".");if(p.length>2){var d=p.shift()+".";return d+=parseInt(p.shift()).toString(16),d+=("000"+parseInt(p.shift()).toString(16)).substr(-4),d}return f},k.resolve=function(f,p){return F.buildAbsoluteURL(p,f,{alwaysNormalize:!0})},k.parseMasterPlaylist=function(f,p){var d=[],a={},b=!1;O.lastIndex=0;for(var m;(m=O.exec(f))!=null;)if(m[1]){var E=new R.AttrList(m[1]),B={attrs:E,bitrate:E.decimalInteger("AVERAGE-BANDWIDTH")||E.decimalInteger("BANDWIDTH"),name:E.NAME,url:k.resolve(m[2],p)},U=E.decimalResolution("RESOLUTION");U&&(B.width=U.width,B.height=U.height),h((E.CODECS||"").split(/[ ,]+/).filter(function(V){return V}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=k.convertAVC1ToAVCOTI(B.videoCodec)),d.push(B)}else if(m[3]){var K=new R.AttrList(m[3]);K["DATA-ID"]&&(b=!0,a[K["DATA-ID"]]=K)}return{levels:d,sessionData:b?a:null}},k.parseMasterPlaylistMedia=function(f,p,d,a){a===void 0&&(a=[]);var b,m=[],E=0;for(L.lastIndex=0;(b=L.exec(f))!==null;){var B=new R.AttrList(b[1]);if(B.TYPE===d){var U={attrs:B,bitrate:0,id:E++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:d,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?k.resolve(B.URI,p):""};if(a.length){var K=k.findGroup(a,U.groupId)||a[0];w(U,K,"audioCodec"),w(U,K,"textCodec")}m.push(U)}}return m},k.parseLevelPlaylist=function(f,p,d,a,b){var m=new H.LevelDetails(p),E=m.fragments,B=null,U=0,K=0,V=0,P=0,_=null,Y=new z.Fragment(a,p),ee,ae,ce,De=-1,Se=!1;for(A.lastIndex=0,m.m3u8=f;(ee=A.exec(f))!==null;){Se&&(Se=!1,Y=new z.Fragment(a,p),Y.start=V,Y.sn=U,Y.cc=P,Y.level=d,B&&(Y.initSegment=B,Y.rawProgramDateTime=B.rawProgramDateTime));var Ce=ee[1];if(Ce){Y.duration=parseFloat(Ce);var Ae=(" "+ee[2]).slice(1);Y.title=Ae||null,Y.tagList.push(Ae?["INF",Ce,Ae]:["INF",Ce])}else if(ee[3])Object(Z.isFiniteNumber)(Y.duration)&&(Y.start=V,ce&&(Y.levelkey=ce),Y.sn=U,Y.level=d,Y.cc=P,Y.urlId=b,E.push(Y),Y.relurl=(" "+ee[3]).slice(1),g(Y,_),_=Y,V+=Y.duration,U++,K=0,Se=!0);else if(ee[4]){var Te=(" "+ee[4]).slice(1);_?Y.setByteRange(Te,_):Y.setByteRange(Te)}else if(ee[5])Y.rawProgramDateTime=(" "+ee[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),De===-1&&(De=E.length);else{if(ee=ee[0].match(C),!ee){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ae=1;ae<ee.length&&!(typeof ee[ae]!="undefined");ae++);var ve=(" "+ee[ae]).slice(1),le=(" "+ee[ae+1]).slice(1),te=ee[ae+2]?(" "+ee[ae+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":m.type=le.toUpperCase();break;case"MEDIA-SEQUENCE":U=m.startSN=parseInt(le);break;case"SKIP":{var de=new R.AttrList(le),ne=de.decimalInteger("SKIPPED-SEGMENTS");if(Object(Z.isFiniteNumber)(ne)){m.skippedSegments=ne;for(var ke=ne;ke--;)E.unshift(null);U+=ne}var Oe=de.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(m.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(le);break;case"VERSION":m.version=parseInt(le);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(le||te)&&Y.tagList.push(te?[le,te]:[le]);break;case"DIS":P++;case"GAP":Y.tagList.push([ve]);break;case"BITRATE":Y.tagList.push([ve,le]);break;case"DISCONTINUITY-SEQ":P=parseInt(le);break;case"KEY":{var Ee,Re=new R.AttrList(le),Be=Re.enumeratedString("METHOD"),ze=Re.URI,Fe=Re.hexadecimalInteger("IV"),Ue=Re.enumeratedString("KEYFORMATVERSIONS"),Ie=Re.enumeratedString("KEYID"),it=(Ee=Re.enumeratedString("KEYFORMAT"))!=null?Ee:"identity",Ye=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ye.indexOf(it)>-1){v.logger.warn("Keyformat "+it+" is not supported from the manifest");continue}else if(it!=="identity")continue;Be&&(ce=N.LevelKey.fromURL(p,ze),ze&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Be)>=0&&(ce.method=Be,ce.keyFormat=it,Ie&&(ce.keyID=Ie),Ue&&(ce.keyFormatVersions=Ue),ce.iv=Fe));break}case"START":{var Qe=new R.AttrList(le),qe=Qe.decimalFloatingPoint("TIME-OFFSET");Object(Z.isFiniteNumber)(qe)&&(m.startTimeOffset=qe);break}case"MAP":{var ct=new R.AttrList(le);Y.relurl=ct.URI,ct.BYTERANGE&&Y.setByteRange(ct.BYTERANGE),Y.level=d,Y.sn="initSegment",ce&&(Y.levelkey=ce),Y.initSegment=null,B=Y,Se=!0;break}case"SERVER-CONTROL":{var et=new R.AttrList(le);m.canBlockReload=et.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=et.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&et.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=et.optionalFloat("PART-HOLD-BACK",0),m.holdBack=et.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var nt=new R.AttrList(le);m.partTarget=nt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Pe=m.partList;Pe||(Pe=m.partList=[]);var dt=K>0?Pe[Pe.length-1]:void 0,at=K++,Me=new z.Part(new R.AttrList(le),Y,p,at,dt);Pe.push(Me),Y.duration+=Me.duration;break}case"PRELOAD-HINT":{var Ge=new R.AttrList(le);m.preloadHint=Ge;break}case"RENDITION-REPORT":{var xe=new R.AttrList(le);m.renditionReports=m.renditionReports||[],m.renditionReports.push(xe);break}default:v.logger.warn("line parsed but not handled: "+ee);break}}}_&&!_.relurl?(E.pop(),V-=_.duration,m.partList&&(m.fragmentHint=_)):m.partList&&(g(Y,_),Y.cc=P,m.fragmentHint=Y);var me=E.length,ye=E[0],re=E[me-1];if(V+=m.skippedSegments*m.targetduration,V>0&&me&&re){m.averagetargetduration=V/me;var ie=re.sn;m.endSN=ie!=="initSegment"?ie:0,ye&&(m.startCC=ye.cc,ye.initSegment||m.fragments.every(function(se){return se.relurl&&o(se.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new z.Fragment(a,p),Y.relurl=re.relurl,Y.level=d,Y.sn="initSegment",ye.initSegment=Y,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(V+=m.fragmentHint.duration),m.totalduration=V,m.endCC=P,De>0&&y(E,De),m},k}();function h(k,x){["video","audio","text"].forEach(function(f){var p=k.filter(function(a){return Object(T.isCodecType)(a,f)});if(p.length){var d=p.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});x[f+"Codec"]=d.length>0?d[0]:p[0],k=k.filter(function(a){return p.indexOf(a)===-1})}}),x.unknownCodecs=k}function w(k,x,f){var p=x[f];p&&(k[f]=p)}function y(k,x){for(var f=k[x],p=x;p--;){var d=k[p];if(!d)return;d.programDateTime=f.programDateTime-d.duration*1e3,f=d}}function g(k,x){k.rawProgramDateTime?k.programDateTime=Date.parse(k.rawProgramDateTime):x!=null&&x.programDateTime&&(k.programDateTime=x.endProgramDateTime),Object(Z.isFiniteNumber)(k.programDateTime)||(k.programDateTime=null,k.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/polyfills/number.ts"),F=D("./src/events.ts"),M=D("./src/errors.ts"),z=D("./src/utils/logger.ts"),H=D("./src/utils/mp4-tools.ts"),N=D("./src/loader/m3u8-parser.ts"),R=D("./src/types/loader.ts"),v=D("./src/utils/attr-list.ts");function T(A){var C=A.type;switch(C){case R.PlaylistContextType.AUDIO_TRACK:return R.PlaylistLevelType.AUDIO;case R.PlaylistContextType.SUBTITLE_TRACK:return R.PlaylistLevelType.SUBTITLE;default:return R.PlaylistLevelType.MAIN}}function O(A,C){var u=A.url;return(u===void 0||u.indexOf("data:")===0)&&(u=C.url),u}var L=function(){function A(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var C=A.prototype;return C.registerListeners=function(){var o=this.hls;o.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(F.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.unregisterListeners=function(){var o=this.hls;o.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(F.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.createInternalLoader=function(o){var l=this.hls.config,h=l.pLoader,w=l.loader,y=h||w,g=new y(l);return o.loader=g,this.loaders[o.type]=g,g},C.getInternalLoader=function(o){return this.loaders[o.type]},C.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},C.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},C.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},C.onManifestLoading=function(o,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:R.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},C.onLevelLoading=function(o,l){var h=l.id,w=l.level,y=l.url,g=l.deliveryDirectives;this.load({id:h,groupId:null,level:w,responseType:"text",type:R.PlaylistContextType.LEVEL,url:y,deliveryDirectives:g})},C.onAudioTrackLoading=function(o,l){var h=l.id,w=l.groupId,y=l.url,g=l.deliveryDirectives;this.load({id:h,groupId:w,level:null,responseType:"text",type:R.PlaylistContextType.AUDIO_TRACK,url:y,deliveryDirectives:g})},C.onSubtitleTrackLoading=function(o,l){var h=l.id,w=l.groupId,y=l.url,g=l.deliveryDirectives;this.load({id:h,groupId:w,level:null,responseType:"text",type:R.PlaylistContextType.SUBTITLE_TRACK,url:y,deliveryDirectives:g})},C.load=function(o){var l,h=this.hls.config,w=this.getInternalLoader(o);if(w){var y=w.context;if(y&&y.url===o.url){z.logger.trace("[playlist-loader]: playlist request ongoing");return}z.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),w.abort()}var g,k,x,f;switch(o.type){case R.PlaylistContextType.MANIFEST:g=h.manifestLoadingMaxRetry,k=h.manifestLoadingTimeOut,x=h.manifestLoadingRetryDelay,f=h.manifestLoadingMaxRetryTimeout;break;case R.PlaylistContextType.LEVEL:case R.PlaylistContextType.AUDIO_TRACK:case R.PlaylistContextType.SUBTITLE_TRACK:g=0,k=h.levelLoadingTimeOut;break;default:g=h.levelLoadingMaxRetry,k=h.levelLoadingTimeOut,x=h.levelLoadingRetryDelay,f=h.levelLoadingMaxRetryTimeout;break}if(w=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var p;if(o.type===R.PlaylistContextType.LEVEL&&o.level!==null?p=this.hls.levels[o.level].details:o.type===R.PlaylistContextType.AUDIO_TRACK&&o.id!==null?p=this.hls.audioTracks[o.id].details:o.type===R.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(p=this.hls.subtitleTracks[o.id].details),p){var d=p.partTarget,a=p.targetduration;d&&a&&(k=Math.min(Math.max(d*3,a*.8)*1e3,k))}}var b={timeout:k,maxRetry:g,retryDelay:x,maxRetryDelay:f,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};w.load(o,b,m)},C.loadsuccess=function(o,l,h,w){if(w===void 0&&(w=null),h.isSidxRequest){this.handleSidxRequest(o,h),this.handlePlaylistLoaded(o,l,h,w);return}this.resetInternalLoader(h.type);var y=o.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,h,"no EXTM3U delimiter",w);return}l.parsing.start=performance.now(),y.indexOf("#EXTINF:")>0||y.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,h,w):this.handleMasterPlaylist(o,l,h,w)},C.loaderror=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,o)},C.loadtimeout=function(o,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},C.handleMasterPlaylist=function(o,l,h,w){var y=this.hls,g=o.data,k=O(o,h),x=N.default.parseMasterPlaylist(g,k),f=x.levels,p=x.sessionData;if(!f.length){this.handleManifestParsingError(o,h,"no level found in manifest",w);return}var d=f.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),a=f.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),b=N.default.parseMasterPlaylistMedia(g,k,"AUDIO",d),m=N.default.parseMasterPlaylistMedia(g,k,"SUBTITLES",a),E=N.default.parseMasterPlaylistMedia(g,k,"CLOSED-CAPTIONS");if(b.length){var B=b.some(function(U){return!U.url});!B&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}y.trigger(F.Events.MANIFEST_LOADED,{levels:f,audioTracks:b,subtitles:m,captions:E,url:k,stats:l,networkDetails:w,sessionData:p})},C.handleTrackOrLevelPlaylist=function(o,l,h,w){var y=this.hls,g=h.id,k=h.level,x=h.type,f=O(o,h),p=Object(Z.isFiniteNumber)(g)?g:0,d=Object(Z.isFiniteNumber)(k)?k:p,a=T(h),b=N.default.parseLevelPlaylist(o.data,f,d,a,p);if(!b.fragments.length){y.trigger(F.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(x===R.PlaylistContextType.MANIFEST){var m={attrs:new v.AttrList({}),bitrate:0,details:b,name:"",url:f};y.trigger(F.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:f,stats:l,networkDetails:w,sessionData:null})}if(l.parsing.end=performance.now(),b.needSidxRanges){var E,B=(E=b.fragments[0].initSegment)===null||E===void 0?void 0:E.url;this.load({url:B,isSidxRequest:!0,type:x,level:k,levelDetails:b,id:g,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=b,this.handlePlaylistLoaded(o,l,h,w)},C.handleSidxRequest=function(o,l){var h=Object(H.parseSegmentIndex)(new Uint8Array(o.data));if(!h)return;var w=h.references,y=l.levelDetails;w.forEach(function(g,k){var x=g.info,f=y.fragments[k];f.byteRange.length===0&&f.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),f.initSegment&&f.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},C.handleManifestParsingError=function(o,l,h,w){this.hls.trigger(F.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===R.PlaylistContextType.MANIFEST,url:o.url,reason:h,response:o,context:l,networkDetails:w})},C.handleNetworkError=function(o,l,h,w){h===void 0&&(h=!1),z.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 y=M.ErrorDetails.UNKNOWN,g=!1,k=this.getInternalLoader(o);switch(o.type){case R.PlaylistContextType.MANIFEST:y=h?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,g=!0;break;case R.PlaylistContextType.LEVEL:y=h?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,g=!1;break;case R.PlaylistContextType.AUDIO_TRACK:y=h?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,g=!1;break;case R.PlaylistContextType.SUBTITLE_TRACK:y=h?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,g=!1;break}k&&this.resetInternalLoader(o.type);var x={type:M.ErrorTypes.NETWORK_ERROR,details:y,fatal:g,url:o.url,loader:k,context:o,networkDetails:l};w&&(x.response=w),this.hls.trigger(F.Events.ERROR,x)},C.handlePlaylistLoaded=function(o,l,h,w){var y=h.type,g=h.level,k=h.id,x=h.groupId,f=h.loader,p=h.levelDetails,d=h.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(o,h,"invalid target duration",w);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(y){case R.PlaylistContextType.MANIFEST:case R.PlaylistContextType.LEVEL:this.hls.trigger(F.Events.LEVEL_LOADED,{details:p,level:g||0,id:k||0,stats:l,networkDetails:w,deliveryDirectives:d});break;case R.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(F.Events.AUDIO_TRACK_LOADED,{details:p,id:k||0,groupId:x||"",stats:l,networkDetails:w,deliveryDirectives:d});break;case R.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(F.Events.SUBTITLE_TRACK_LOADED,{details:p,id:k||0,groupId:x||"",stats:l,networkDetails:w,deliveryDirectives:d});break}},A}();$.default=L},"./src/polyfills/number.ts":function(oe,$,D){"use strict";D.r($),D.d($,"isFiniteNumber",function(){return Z}),D.d($,"MAX_SAFE_INTEGER",function(){return F});var Z=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},F=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(oe,$,D){"use strict";D.r($);var Z=function(){function F(){}return F.getSilentFrame=function(z,H){switch(z){case"mp4a.40.2":if(H===1)return new Uint8Array([0,200,0,128,35,128]);if(H===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(H===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(H===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(H===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(H===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(H===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(H===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(H===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},F}();$.default=Z},"./src/remux/mp4-generator.ts":function(oe,$,D){"use strict";D.r($);var Z=Math.pow(2,32)-1,F=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 H;for(H in M.types)M.types.hasOwnProperty(H)&&(M.types[H]=[H.charCodeAt(0),H.charCodeAt(1),H.charCodeAt(2),H.charCodeAt(3)]);var N=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),R=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);M.HDLR_TYPES={video:N,audio:R};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);M.STTS=M.STSC=M.STCO=T,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 O=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);M.FTYP=M.box(M.types.ftyp,O,A,O,L),M.DINF=M.box(M.types.dinf,M.box(M.types.dref,v))},M.box=function(H){for(var N=8,R=arguments.length,v=new Array(R>1?R-1:0),T=1;T<R;T++)v[T-1]=arguments[T];for(var O=v.length,L=O;O--;)N+=v[O].byteLength;var A=new Uint8Array(N);for(A[0]=N>>24&255,A[1]=N>>16&255,A[2]=N>>8&255,A[3]=N&255,A.set(H,4),O=0,N=8;O<L;O++)A.set(v[O],N),N+=v[O].byteLength;return A},M.hdlr=function(H){return M.box(M.types.hdlr,M.HDLR_TYPES[H])},M.mdat=function(H){return M.box(M.types.mdat,H)},M.mdhd=function(H,N){N*=H;var R=Math.floor(N/(Z+1)),v=Math.floor(N%(Z+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,H>>24&255,H>>16&255,H>>8&255,H&255,R>>24,R>>16&255,R>>8&255,R&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},M.mdia=function(H){return M.box(M.types.mdia,M.mdhd(H.timescale,H.duration),M.hdlr(H.type),M.minf(H))},M.mfhd=function(H){return M.box(M.types.mfhd,new Uint8Array([0,0,0,0,H>>24,H>>16&255,H>>8&255,H&255]))},M.minf=function(H){return H.type==="audio"?M.box(M.types.minf,M.box(M.types.smhd,M.SMHD),M.DINF,M.stbl(H)):M.box(M.types.minf,M.box(M.types.vmhd,M.VMHD),M.DINF,M.stbl(H))},M.moof=function(H,N,R){return M.box(M.types.moof,M.mfhd(H),M.traf(R,N))},M.moov=function(H){for(var N=H.length,R=[];N--;)R[N]=M.trak(H[N]);return M.box.apply(null,[M.types.moov,M.mvhd(H[0].timescale,H[0].duration)].concat(R).concat(M.mvex(H)))},M.mvex=function(H){for(var N=H.length,R=[];N--;)R[N]=M.trex(H[N]);return M.box.apply(null,[M.types.mvex].concat(R))},M.mvhd=function(H,N){N*=H;var R=Math.floor(N/(Z+1)),v=Math.floor(N%(Z+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,H>>24&255,H>>16&255,H>>8&255,H&255,R>>24,R>>16&255,R>>8&255,R&255,v>>24,v>>16&255,v>>8&255,v&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return M.box(M.types.mvhd,T)},M.sdtp=function(H){var N=H.samples||[],R=new Uint8Array(4+N.length),v,T;for(v=0;v<N.length;v++)T=N[v].flags,R[v+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return M.box(M.types.sdtp,R)},M.stbl=function(H){return M.box(M.types.stbl,M.stsd(H),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(H){var N=[],R=[],v,T,O;for(v=0;v<H.sps.length;v++)T=H.sps[v],O=T.byteLength,N.push(O>>>8&255),N.push(O&255),N=N.concat(Array.prototype.slice.call(T));for(v=0;v<H.pps.length;v++)T=H.pps[v],O=T.byteLength,R.push(O>>>8&255),R.push(O&255),R=R.concat(Array.prototype.slice.call(T));var L=M.box(M.types.avcC,new Uint8Array([1,N[3],N[4],N[5],252|3,224|H.sps.length].concat(N).concat([H.pps.length]).concat(R))),A=H.width,C=H.height,u=H.pixelRatio[0],o=H.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,A>>8&255,A&255,C>>8&255,C&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),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(H){var N=H.config.length;return new Uint8Array([0,0,0,0,3,23+N,0,1,0,4,15+N,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([N]).concat(H.config).concat([6,1,2]))},M.mp4a=function(H){var N=H.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,H.channelCount,0,16,0,0,0,0,N>>8&255,N&255,0,0]),M.box(M.types.esds,M.esds(H)))},M.mp3=function(H){var N=H.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,H.channelCount,0,16,0,0,0,0,N>>8&255,N&255,0,0]))},M.stsd=function(H){return H.type==="audio"?!H.isAAC&&H.codec==="mp3"?M.box(M.types.stsd,M.STSD,M.mp3(H)):M.box(M.types.stsd,M.STSD,M.mp4a(H)):M.box(M.types.stsd,M.STSD,M.avc1(H))},M.tkhd=function(H){var N=H.id,R=H.duration*H.timescale,v=H.width,T=H.height,O=Math.floor(R/(Z+1)),L=Math.floor(R%(Z+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,N>>24&255,N>>16&255,N>>8&255,N&255,0,0,0,0,O>>24,O>>16&255,O>>8&255,O&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,v>>8&255,v&255,0,0,T>>8&255,T&255,0,0]))},M.traf=function(H,N){var R=M.sdtp(H),v=H.id,T=Math.floor(N/(Z+1)),O=Math.floor(N%(Z+1));return M.box(M.types.traf,M.box(M.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),M.box(M.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,O>>24,O>>16&255,O>>8&255,O&255])),M.trun(H,R.length+16+20+8+16+8+8),R)},M.trak=function(H){return H.duration=H.duration||4294967295,M.box(M.types.trak,M.tkhd(H),M.mdia(H))},M.trex=function(H){var N=H.id;return M.box(M.types.trex,new Uint8Array([0,0,0,0,N>>24,N>>16&255,N>>8&255,N&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},M.trun=function(H,N){var R=H.samples||[],v=R.length,T=12+16*v,O=new Uint8Array(T),L,A,C,u,o,l;for(N+=8+T,O.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255],0),L=0;L<v;L++)A=R[L],C=A.duration,u=A.size,o=A.flags,l=A.cts,O.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*L);return M.box(M.types.trun,O)},M.initSegment=function(H){M.types||M.init();var N=M.moov(H),R=new Uint8Array(M.FTYP.byteLength+N.byteLength);return R.set(M.FTYP),R.set(N,M.FTYP.byteLength),R},M}();F.types=void 0,F.HDLR_TYPES=void 0,F.STTS=void 0,F.STSC=void 0,F.STCO=void 0,F.STSZ=void 0,F.VMHD=void 0,F.SMHD=void 0,F.STSD=void 0,F.FTYP=void 0,F.DINF=void 0,$.default=F},"./src/remux/mp4-remuxer.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return l}),D.d($,"normalizePts",function(){return h});var Z=D("./src/polyfills/number.ts"),F=D("./src/remux/aac-helper.ts"),M=D("./src/remux/mp4-generator.ts"),z=D("./src/events.ts"),H=D("./src/errors.ts"),N=D("./src/utils/logger.ts"),R=D("./src/types/loader.ts"),v=D("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign||function(k){for(var x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(k[p]=f[p])}return k},T.apply(this,arguments)}var O=10*1e3,L=1024,A=1152,C=null,u=null,o=!1,l=function(){function k(f,p,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=p,this.typeSupported=d,this.ISGenerated=!1,C===null){var b=navigator.userAgent||"",m=b.match(/Chrome\/(\d+)/i);C=m?parseInt(m[1]):0}if(u===null){var E=navigator.userAgent.match(/Safari\/(\d+)/i);u=E?parseInt(E[1]):0}o=!!C&&C<75||!!u&&u<600}var x=k.prototype;return x.destroy=function(){},x.resetTimeStamp=function(p){N.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},x.resetNextTimestamp=function(){N.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},x.resetInitSegment=function(){N.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},x.getVideoStartPts=function(p){var d=!1,a=p.reduce(function(b,m){var E=m.pts-b;return E<-4294967296?(d=!0,h(b,m.pts)):E>0?b:m.pts},p[0].pts);return d&&N.logger.debug("PTS rollover detected"),a},x.remux=function(p,d,a,b,m,E,B,U){var K,V,P,_,Y,ee,ae=m,ce=m,De=p.pid>-1,Se=d.pid>-1,Ce=d.samples.length,Ae=p.samples.length>0,Te=Ce>1,ve=(!De||Ae)&&(!Se||Te)||this.ISGenerated||B;if(ve){this.ISGenerated||(P=this.generateIS(p,d,m));var le=this.isVideoContiguous,te=-1;if(Te&&(te=w(d.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(ee=!0,te>0){N.logger.warn("[mp4-remuxer]: Dropped "+te+" out of "+Ce+" video samples due to a missing keyframe");var de=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(te),d.dropped+=te,ce+=(d.samples[0].pts-de)/(d.timescale||9e4)}else te===-1&&(N.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ee=!1);if(this.ISGenerated){if(Ae&&Te){var ne=this.getVideoStartPts(d.samples),ke=h(p.samples[0].pts,ne)-ne,Oe=ke/d.inputTimeScale;ae+=Math.max(0,Oe),ce+=Math.max(0,-Oe)}if(Ae){if(p.samplerate||(N.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),P=this.generateIS(p,d,m)),V=this.remuxAudio(p,ae,this.isAudioContiguous,E,Se||Te||U===R.PlaylistLevelType.AUDIO?ce:void 0),Te){var Ee=V?V.endPTS-V.startPTS:0;d.inputTimeScale||(N.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),P=this.generateIS(p,d,m)),K=this.remuxVideo(d,ce,le,Ee)}}else Te&&(K=this.remuxVideo(d,ce,le,0));K&&(K.firstKeyFrame=te,K.independent=te!==-1)}}return this.ISGenerated&&(a.samples.length&&(Y=this.remuxID3(a,m)),b.samples.length&&(_=this.remuxText(b,m))),{audio:V,video:K,initSegment:P,independent:ee,text:_,id3:Y}},x.generateIS=function(p,d,a){var b=p.samples,m=d.samples,E=this.typeSupported,B={},U=!Object(Z.isFiniteNumber)(this._initPTS),K="audio/mp4",V,P,_;if(U&&(V=P=Infinity),p.config&&b.length&&(p.timescale=p.samplerate,p.isAAC||(E.mpeg?(K="audio/mpeg",p.codec=""):E.mp3&&(p.codec="mp3")),B.audio={id:"audio",container:K,codec:p.codec,initSegment:!p.isAAC&&E.mpeg?new Uint8Array(0):M.default.initSegment([p]),metadata:{channelCount:p.channelCount}},U&&(_=p.inputTimeScale,V=P=b[0].pts-Math.round(_*a))),d.sps&&d.pps&&m.length&&(d.timescale=d.inputTimeScale,B.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:M.default.initSegment([d]),metadata:{width:d.width,height:d.height}},U)){_=d.inputTimeScale;var Y=this.getVideoStartPts(m),ee=Math.round(_*a);P=Math.min(P,h(m[0].dts,Y)-ee),V=Math.min(V,Y-ee)}if(Object.keys(B).length)return this.ISGenerated=!0,U&&(this._initPTS=V,this._initDTS=P),{tracks:B,initPTS:V,timescale:_}},x.remuxVideo=function(p,d,a,b){var m=p.inputTimeScale,E=p.samples,B=[],U=E.length,K=this._initPTS,V=this.nextAvcDts,P=8,_,Y,ee,ae=Number.POSITIVE_INFINITY,ce=Number.NEGATIVE_INFINITY,De=0,Se=!1;if(!a||V===null){var Ce=d*m,Ae=E[0].pts-h(E[0].dts,E[0].pts);V=Ce-Ae}for(var Te=0;Te<U;Te++){var ve=E[Te];if(ve.pts=h(ve.pts-K,V),ve.dts=h(ve.dts-K,V),ve.dts>ve.pts){var le=9e4*.2;De=Math.max(Math.min(De,ve.pts-ve.dts),-1*le)}ve.dts<E[Te>0?Te-1:Te].dts&&(Se=!0)}Se&&E.sort(function(St,Et){var lt=St.dts-Et.dts,Pt=St.pts-Et.pts;return lt||Pt}),Y=E[0].dts,ee=E[E.length-1].dts;var te=Math.round((ee-Y)/(U-1));if(De<0){if(De<te*-2){N.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-te,!0)+" ms");for(var de=De,ne=0;ne<U;ne++)E[ne].dts=de=Math.max(de,E[ne].pts-te),E[ne].pts=Math.max(de,E[ne].pts)}else{N.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var ke=0;ke<U;ke++)E[ke].dts=E[ke].dts+De}Y=E[0].dts}if(a){var Oe=Y-V,Ee=Oe>te,Re=Oe<-1;if(Ee||Re){Ee?N.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(Oe,!0)+" ms ("+Oe+"dts) hole between fragments detected, filling it"):N.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-Oe,!0)+" ms ("+Oe+"dts) overlapping between fragments detected"),Y=V;var Be=E[0].pts-Oe;E[0].dts=Y,E[0].pts=Be,N.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(Be,!0)+"/"+Object(v.toMsFromMpegTsClock)(Y,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(Oe,!0)+" ms")}}o&&(Y=Math.max(0,Y));for(var ze=0,Fe=0,Ue=0;Ue<U;Ue++){for(var Ie=E[Ue],it=Ie.units,Ye=it.length,Qe=0,qe=0;qe<Ye;qe++)Qe+=it[qe].data.length;Fe+=Qe,ze+=Ye,Ie.length=Qe,Ie.dts=Math.max(Ie.dts,Y),Ie.pts=Math.max(Ie.pts,Ie.dts,0),ae=Math.min(Ie.pts,ae),ce=Math.max(Ie.pts,ce)}ee=E[U-1].dts;var ct=Fe+4*ze+8,et;try{et=new Uint8Array(ct)}catch(St){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:H.ErrorTypes.MUX_ERROR,details:H.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ct,reason:"fail allocating video mdat "+ct});return}var nt=new DataView(et.buffer);nt.setUint32(0,ct),et.set(M.default.types.mdat,4);for(var Pe=0;Pe<U;Pe++){for(var dt=E[Pe],at=dt.units,Me=0,Ge=0,xe=at.length;Ge<xe;Ge++){var me=at[Ge],ye=me.data,re=me.data.byteLength;nt.setUint32(P,re),P+=4,et.set(ye,P),P+=re,Me+=4+re}if(Pe<U-1)_=E[Pe+1].dts-dt.dts;else{var ie=this.config,se=dt.dts-E[Pe>0?Pe-1:Pe].dts;if(ie.stretchShortVideoTrack&&this.nextAudioPts!==null){var pe=Math.floor(ie.maxBufferHole*m),be=(b?ae+b*m:this.nextAudioPts)-dt.pts;be>pe?(_=be-se,_<0&&(_=se),N.logger.log("[mp4-remuxer]: It is approximately "+be/90+" ms to the next segment; using duration "+_/90+" ms for the last video frame.")):_=se}else _=se}var _e=Math.round(dt.pts-dt.dts);B.push(new y(dt.key,_,Me,_e))}if(B.length&&C&&C<70){var We=B[0].flags;We.dependsOn=2,We.isNonSync=0}console.assert(_!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=V=ee+_,this.isVideoContiguous=!0;var $e=M.default.moof(p.sequenceNumber++,Y,T({},p,{samples:B})),st="video",Ze={data1:$e,data2:et,startPTS:ae/m,endPTS:(ce+_)/m,startDTS:Y/m,endDTS:V/m,type:st,hasAudio:!1,hasVideo:!0,nb:B.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(et.length,"MDAT length must not be zero"),Ze},x.remuxAudio=function(p,d,a,b,m){var E=p.inputTimeScale,B=p.samplerate?p.samplerate:E,U=E/B,K=p.isAAC?L:A,V=K*U,P=this._initPTS,_=!p.isAAC&&this.typeSupported.mpeg,Y=[],ee=p.samples,ae=_?0:8,ce=this.nextAudioPts||-1,De=d*E;if(this.isAudioContiguous=a=a||ee.length&&ce>0&&(b&&Math.abs(De-ce)<9e3||Math.abs(h(ee[0].pts-P,De)-ce)<20*V),ee.forEach(function(ye){ye.pts=h(ye.pts-P,De)}),!a||ce<0){if(ee=ee.filter(function(ye){return ye.pts>=0}),!ee.length)return;m===0?ce=0:b?ce=Math.max(0,De):ce=ee[0].pts}if(p.isAAC)for(var Se=m!==void 0,Ce=this.config.maxAudioFramesDrift,Ae=0,Te=ce;Ae<ee.length;Ae++){var ve=ee[Ae],le=ve.pts,te=le-Te,de=Math.abs(1e3*te/E);if(te<=-Ce*V&&Se)Ae===0&&(N.logger.warn("Audio frame @ "+(le/E).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/E)+" ms."),this.nextAudioPts=ce=Te=le);else if(te>=Ce*V&&de<O&&Se){var ne=Math.round(te/V);Te=le-ne*V,Te<0&&(ne--,Te+=V),Ae===0&&(this.nextAudioPts=ce=Te),N.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(Te/E).toFixed(3)+"s due to "+Math.round(1e3*te/E)+" ms gap.");for(var ke=0;ke<ne;ke++){var Oe=Math.max(Te,0),Ee=F.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);Ee||(N.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ee=ve.unit.subarray()),ee.splice(Ae,0,{unit:Ee,pts:Oe}),Te+=V,Ae++}}ve.pts=Te,Te+=V}for(var Re=null,Be=null,ze,Fe=0,Ue=ee.length;Ue--;)Fe+=ee[Ue].unit.byteLength;for(var Ie=0,it=ee.length;Ie<it;Ie++){var Ye=ee[Ie],Qe=Ye.unit,qe=Ye.pts;if(Be!==null){var ct=Y[Ie-1];ct.duration=Math.round((qe-Be)/U)}else if(a&&p.isAAC&&(qe=ce),Re=qe,Fe>0){Fe+=ae;try{ze=new Uint8Array(Fe)}catch(ye){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:H.ErrorTypes.MUX_ERROR,details:H.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Fe,reason:"fail allocating audio mdat "+Fe});return}if(!_){var et=new DataView(ze.buffer);et.setUint32(0,Fe),ze.set(M.default.types.mdat,4)}}else return;ze.set(Qe,ae);var nt=Qe.byteLength;ae+=nt,Y.push(new y(!0,K,nt,0)),Be=qe}var Pe=Y.length;if(!Pe)return;var dt=Y[Y.length-1];this.nextAudioPts=ce=Be+U*dt.duration;var at=_?new Uint8Array(0):M.default.moof(p.sequenceNumber++,Re/U,T({},p,{samples:Y}));p.samples=[];var Me=Re/E,Ge=ce/E,xe="audio",me={data1:at,data2:ze,startPTS:Me,endPTS:Ge,startDTS:Me,endDTS:Ge,type:xe,hasAudio:!0,hasVideo:!1,nb:Pe};return this.isAudioContiguous=!0,console.assert(ze.length,"MDAT length must not be zero"),me},x.remuxEmptyAudio=function(p,d,a,b){var m=p.inputTimeScale,E=p.samplerate?p.samplerate:m,B=m/E,U=this.nextAudioPts,K=(U!==null?U:b.startDTS*m)+this._initDTS,V=b.endDTS*m+this._initDTS,P=B*L,_=Math.ceil((V-K)/P),Y=F.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(N.logger.warn("[mp4-remuxer]: remux empty Audio"),!Y){N.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ee=[],ae=0;ae<_;ae++){var ce=K+ae*P;ee.push({unit:Y,pts:ce,dts:ce})}return p.samples=ee,this.remuxAudio(p,d,a,!1)},x.remuxID3=function(p,d){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,m=this._initPTS,E=this._initDTS,B=0;B<a;B++){var U=p.samples[B];U.pts=h(U.pts-m,d*b)/b,U.dts=h(U.dts-E,d*b)/b}var K=p.samples;return p.samples=[],{samples:K}},x.remuxText=function(p,d){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,m=this._initPTS,E=0;E<a;E++){var B=p.samples[E];B.pts=h(B.pts-m,d*b)/b}p.samples.sort(function(K,V){return K.pts-V.pts});var U=p.samples;return p.samples=[],{samples:U}},k}();function h(k,x){var f;if(x===null)return k;for(x<k?f=-8589934592:f=8589934592;Math.abs(k-x)>4294967296;)k+=f;return k}function w(k){for(var x=0;x<k.length;x++)if(k[x].key)return x;return-1}var y=function(x,f,p,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=p,this.cts=d,this.flags=new g(x)},g=function(x){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=x?2:1,this.isNonSync=x?0:1}},"./src/remux/passthrough-remuxer.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/fragment.ts"),z=D("./src/utils/logger.ts"),H=function(){function v(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var T=v.prototype;return T.destroy=function(){},T.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},T.resetNextTimestamp=function(){this.lastEndDTS=null},T.resetInitSegment=function(L,A,C){this.audioCodec=A,this.videoCodec=C,this.generateInitSegment(L),this.emitInitSegment=!0},T.generateInitSegment=function(L){var A=this.audioCodec,C=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(F.parseInitSegment)(L);A||(A=R(u.audio,M.ElementaryStreamTypes.AUDIO)),C||(C=R(u.video,M.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:A+","+C,initSegment:L,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:A,initSegment:L,id:"audio"}:u.video?o.video={container:"video/mp4",codec:C,initSegment:L,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},T.remux=function(L,A,C,u,o){var l=this.initPTS,h=this.lastEndDTS,w={audio:void 0,video:void 0,text:u,id3:C,initSegment:void 0};Object(Z.isFiniteNumber)(h)||(h=this.lastEndDTS=o||0);var y=A.samples;if(!y||!y.length)return w;var g={initPTS:void 0,timescale:1},k=this.initData;if((!k||!k.length)&&(this.generateInitSegment(y),k=this.initData),!k||!k.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1),Object(Z.isFiniteNumber)(l)||(this.initPTS=g.initPTS=l=N(k,y,h));var x=Object(F.getDuration)(y,k),f=h,p=x+f;Object(F.offsetStartDTS)(k,y,l),x>0?this.lastEndDTS=p:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!k.audio,a=!!k.video,b="";d&&(b+="audio"),a&&(b+="video");var m={data1:y,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:b,hasAudio:d,hasVideo:a,nb:1,dropped:0};return w.audio=m.type==="audio"?m:void 0,w.video=m.type!=="audio"?m:void 0,w.text=u,w.id3=C,w.initSegment=g,w},v}(),N=function(T,O,L){return Object(F.getStartDTS)(T,O)-L};function R(v,T){var O=v==null?void 0:v.codec;return O&&O.length>4?O:O==="hvc1"?"hvc1.1.c.L120.90":O==="av01"?"av01.0.04M.08":O==="avc1"||T===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=H},"./src/task-loop.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return Z});var Z=function(){function F(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=F.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(H){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,H),!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(){},F}()},"./src/types/cmcd.ts":function(oe,$,D){"use strict";D.r($),D.d($,"CMCDVersion",function(){return Z}),D.d($,"CMCDObjectType",function(){return F}),D.d($,"CMCDStreamingFormat",function(){return M}),D.d($,"CMCDStreamType",function(){return z});var Z=1,F;(function(H){H.MANIFEST="m",H.AUDIO="a",H.VIDEO="v",H.MUXED="av",H.INIT="i",H.CAPTION="c",H.TIMED_TEXT="tt",H.KEY="k",H.OTHER="o"})(F||(F={}));var M;(function(H){H.DASH="d",H.HLS="h",H.SMOOTH="s",H.OTHER="o"})(M||(M={}));var z;(function(H){H.VOD="v",H.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(oe,$,D){"use strict";D.r($),D.d($,"HlsSkip",function(){return M}),D.d($,"getSkipValue",function(){return z}),D.d($,"HlsUrlParameters",function(){return H}),D.d($,"Level",function(){return N});function Z(R,v){for(var T=0;T<v.length;T++){var O=v[T];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(R,O.key,O)}}function F(R,v,T){return v&&Z(R.prototype,v),T&&Z(R,T),R}var M;(function(R){R.No="",R.Yes="YES",R.v2="v2"})(M||(M={}));function z(R,v){var T=R.canSkipUntil,O=R.canSkipDateRanges,L=R.endSN,A=v!==void 0?v-L:0;return T&&A<T?O?M.v2:M.Yes:M.No}var H=function(){function R(T,O,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=O,this.skip=L}var v=R.prototype;return v.addDirectives=function(O){var L=new self.URL(O);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()},R}(),N=function(){function R(v){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[v.url],this.attrs=v.attrs,this.bitrate=v.bitrate,v.details&&(this.details=v.details),this.id=v.id||0,this.name=v.name,this.width=v.width||0,this.height=v.height||0,this.audioCodec=v.audioCodec,this.videoCodec=v.videoCodec,this.unknownCodecs=v.unknownCodecs,this.codecSet=[v.videoCodec,v.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return F(R,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(T){var O=T%this.url.length;this._urlId!==O&&(this.details=void 0,this._urlId=O)}}]),R}()},"./src/types/loader.ts":function(oe,$,D){"use strict";D.r($),D.d($,"PlaylistContextType",function(){return Z}),D.d($,"PlaylistLevelType",function(){return F});var Z;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(Z||(Z={}));var F;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(F||(F={}))},"./src/types/transmuxer.ts":function(oe,$,D){"use strict";D.r($),D.d($,"ChunkMetadata",function(){return Z});var Z=function(z,H,N,R,v,T){R===void 0&&(R=0),v===void 0&&(v=-1),T===void 0&&(T=!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=F(),this.buffering={audio:F(),video:F(),audiovideo:F()},this.level=z,this.sn=H,this.id=N,this.size=R,this.part=v,this.partial=T};function F(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(oe,$,D){"use strict";D.r($),D.d($,"AttrList",function(){return M});var Z=/^(\d+)x(\d+)$/,F=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function z(N){typeof N=="string"&&(N=z.parseAttrList(N));for(var R in N)N.hasOwnProperty(R)&&(this[R]=N[R])}var H=z.prototype;return H.decimalInteger=function(R){var v=parseInt(this[R],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},H.hexadecimalInteger=function(R){if(this[R]){var v=(this[R]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var T=new Uint8Array(v.length/2),O=0;O<v.length/2;O++)T[O]=parseInt(v.slice(O*2,O*2+2),16);return T}else return null},H.hexadecimalIntegerAsNumber=function(R){var v=parseInt(this[R],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},H.decimalFloatingPoint=function(R){return parseFloat(this[R])},H.optionalFloat=function(R,v){var T=this[R];return T?parseFloat(T):v},H.enumeratedString=function(R){return this[R]},H.bool=function(R){return this[R]==="YES"},H.decimalResolution=function(R){var v=Z.exec(this[R]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},z.parseAttrList=function(R){var v,T={},O='"';for(F.lastIndex=0;(v=F.exec(R))!==null;){var L=v[2];L.indexOf(O)===0&&L.lastIndexOf(O)===L.length-1&&(L=L.slice(1,-1)),T[v[1]]=L}return T},z}()},"./src/utils/binary-search.ts":function(oe,$,D){"use strict";D.r($);var Z={search:function(M,z){for(var H=0,N=M.length-1,R=null,v=null;H<=N;){R=(H+N)/2|0,v=M[R];var T=z(v);if(T>0)H=R+1;else if(T<0)N=R-1;else return v}return null}};$.default=Z},"./src/utils/buffer-helper.ts":function(oe,$,D){"use strict";D.r($),D.d($,"BufferHelper",function(){return M});var Z=D("./src/utils/logger.ts"),F={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function z(){}return z.isBuffered=function(N,R){try{if(N){for(var v=z.getBuffered(N),T=0;T<v.length;T++)if(R>=v.start(T)&&R<=v.end(T))return!0}}catch(O){}return!1},z.bufferInfo=function(N,R,v){try{if(N){var T=z.getBuffered(N),O=[],L;for(L=0;L<T.length;L++)O.push({start:T.start(L),end:T.end(L)});return this.bufferedInfo(O,R,v)}}catch(A){}return{len:0,start:R,end:R,nextStart:void 0}},z.bufferedInfo=function(N,R,v){R=Math.max(0,R),N.sort(function(g,k){var x=g.start-k.start;return x||k.end-g.end});var T=[];if(v)for(var O=0;O<N.length;O++){var L=T.length;if(L){var A=T[L-1].end;N[O].start-A<v?N[O].end>A&&(T[L-1].end=N[O].end):T.push(N[O])}else T.push(N[O])}else T=N;for(var C=0,u,o=R,l=R,h=0;h<T.length;h++){var w=T[h].start,y=T[h].end;if(R+v>=w&&R<y)o=w,l=y,C=l-R;else if(R+v<w){u=w;break}}return{len:C,start:o||0,end:l||0,nextStart:u}},z.getBuffered=function(N){try{return N.buffered}catch(R){return Z.logger.log("failed to get media.buffered",R),F}},z}()},"./src/utils/cea-608-parser.ts":function(oe,$,D){"use strict";D.r($),D.d($,"Row",function(){return l}),D.d($,"CaptionScreen",function(){return h});var Z=D("./src/utils/logger.ts"),F={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(p){var d=p;return F.hasOwnProperty(p)&&(d=F[p]),String.fromCharCode(d)},z=15,H=100,N={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},R={17:2,18:4,21:6,22:8,23:10,19:13,20:15},v={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},O=["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 A=function(){function f(){this.time=null,this.verboseLevel=L.ERROR}var p=f.prototype;return p.log=function(a,b){this.verboseLevel>=a&&Z.logger.log(this.time+" ["+a+"] "+b)},f}(),C=function(p){for(var d=[],a=0;a<p.length;a++)d.push(p[a].toString(16));return d},u=function(){function f(d,a,b,m,E){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=b||!1,this.background=m||"black",this.flash=E||!1}var p=f.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(a){for(var b=["foreground","underline","italics","background","flash"],m=0;m<b.length;m++){var E=b[m];a.hasOwnProperty(E)&&(this[E]=a[E])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},p.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},p.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,b,m,E,B){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new u(a,b,m,E,B)}var p=f.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(a,b){this.uchar=a,this.penState.copy(b)},p.setPenState=function(a){this.penState.copy(a)},p.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},p.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},p.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<H;a++)this.chars.push(new o);this.logger=d,this.pos=0,this.currPenState=new u}var p=f.prototype;return p.equals=function(a){for(var b=!0,m=0;m<H;m++)if(!this.chars[m].equals(a.chars[m])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<H;b++)this.chars[b].copy(a.chars[b])},p.isEmpty=function(){for(var a=!0,b=0;b<H;b++)if(!this.chars[b].isEmpty()){a=!1;break}return a},p.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>H&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=H)},p.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var m=this.pos+1;m<b+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(b)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(a){a>=144&&this.backSpace();var b=M(a);if(this.pos>=H){this.logger.log(L.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(a){var b;for(b=a;b<H;b++)this.chars[b].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var a=[],b=!0,m=0;m<H;m++){var E=this.chars[m].uchar;E!==" "&&(b=!1),a.push(E)}return b?"":a.join("")},p.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.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<z;a++)this.rows.push(new l(d));this.logger=d,this.currRow=z-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=f.prototype;return p.reset=function(){for(var a=0;a<z;a++)this.rows[a].clear();this.currRow=z-1},p.equals=function(a){for(var b=!0,m=0;m<z;m++)if(!this.rows[m].equals(a.rows[m])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<z;b++)this.rows[b].copy(a.rows[b])},p.isEmpty=function(){for(var a=!0,b=0;b<z;b++)if(!this.rows[b].isEmpty()){a=!1;break}return a},p.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},p.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},p.insertChar=function(a){var b=this.rows[this.currRow];b.insertChar(a)},p.setPen=function(a){var b=this.rows[this.currRow];b.setPenStyles(a)},p.moveCursor=function(a){var b=this.rows[this.currRow];b.moveCursor(a)},p.setCursor=function(a){this.logger.log(L.INFO,"setCursor: "+a);var b=this.rows[this.currRow];b.setCursor(a)},p.setPAC=function(a){this.logger.log(L.INFO,"pacData = "+JSON.stringify(a));var b=a.row-1;if(this.nrRollUpRows&&b<this.nrRollUpRows-1&&(b=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==b){for(var m=0;m<z;m++)this.rows[m].clear();var E=this.currRow+1-this.nrRollUpRows,B=this.lastOutputScreen;if(B){var U=B.rows[E].cueStartTime,K=this.logger.time;if(U&&K!==null&&U<K)for(var V=0;V<this.nrRollUpRows;V++)this.rows[b-this.nrRollUpRows+V+1].copy(B.rows[E+V])}}this.currRow=b;var P=this.rows[this.currRow];if(a.indent!==null){var _=a.indent,Y=Math.max(_-1,0);P.setCursor(a.indent),a.color=P.chars[Y].penState.foreground}var ee={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ee)},p.setBkgData=function(a){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},p.setRollUpRows=function(a){this.nrRollUpRows=a},p.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,b=this.rows.splice(a,1)[0];b.clear(),this.rows.splice(this.currRow,0,b),this.logger.log(L.INFO,"Rolling up")},p.getDisplayText=function(a){a=a||!1;for(var b=[],m="",E=-1,B=0;B<z;B++){var U=this.rows[B].getTextString();U&&(E=B+1,a?b.push("Row "+E+": '"+U+"'"):b.push(U.trim()))}return b.length>0&&(a?m="["+b.join(" | ")+"]":m=b.join(`
`)),m},p.getTextAndFormat=function(){return this.rows},f}(),w=function(){function f(d,a,b){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(b),this.nonDisplayedMemory=new h(b),this.lastOutputScreen=new h(b),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}var p=f.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(a){this.outputFilter=a},p.setPAC=function(a){this.writeScreen.setPAC(a)},p.setBkgData=function(a){this.writeScreen.setBkgData(a)},p.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},p.insertChars=function(a){for(var b=0;b<a.length;b++)this.writeScreen.insertChar(a[b]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,m+": "+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())},p.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){if(this.logger.log(L.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.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)},p.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.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)},p.ccTO=function(a){this.logger.log(L.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},p.ccMIDROW=function(a){var b={flash:!1};if(b.underline=a%2===1,b.italics=a>=46,b.italics)b.foreground="white";else{var m=Math.floor(a/2)-16,E=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=E[m]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},p.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),y=function(){function f(d,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new A;this.channels=[null,new w(d,a,m),new w(d+1,b,m)],this.cmdHistory=x(),this.logger=m}var p=f.prototype;return p.getHandler=function(a){return this.channels[a].getHandler()},p.setHandler=function(a,b){this.channels[a].setHandler(b)},p.addData=function(a,b){var m,E,B,U=!1;this.logger.time=a;for(var K=0;K<b.length;K+=2){if(E=b[K]&127,B=b[K+1]&127,E===0&&B===0)continue;if(this.logger.log(L.DATA,"["+C([b[K],b[K+1]])+"] -> ("+C([E,B])+")"),m=this.parseCmd(E,B),m||(m=this.parseMidrow(E,B)),m||(m=this.parsePAC(E,B)),m||(m=this.parseBackgroundAttributes(E,B)),!m&&(U=this.parseChars(E,B),U)){var V=this.currentChannel;if(V&&V>0){var P=this.channels[V];P.insertChars(U)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!U&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+C([E,B])+" orig: "+C([b[K],b[K+1]]))}},p.parseCmd=function(a,b){var m=this.cmdHistory,E=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,B=(a===23||a===31)&&b>=33&&b<=35;if(!(E||B))return!1;if(k(a,b,m))return g(null,null,m),this.logger.log(L.DEBUG,"Repeated command ("+C([a,b])+") is dropped"),!0;var U=a===20||a===21||a===23?1:2,K=this.channels[U];return a===20||a===21||a===28||a===29?b===32?K.ccRCL():b===33?K.ccBS():b===34?K.ccAOF():b===35?K.ccAON():b===36?K.ccDER():b===37?K.ccRU(2):b===38?K.ccRU(3):b===39?K.ccRU(4):b===40?K.ccFON():b===41?K.ccRDC():b===42?K.ccTR():b===43?K.ccRTD():b===44?K.ccEDM():b===45?K.ccCR():b===46?K.ccENM():b===47&&K.ccEOC():K.ccTO(b-32),g(a,b,m),this.currentChannel=U,!0},p.parseMidrow=function(a,b){var m=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var E=this.channels[m];return E?(E.ccMIDROW(b),this.logger.log(L.DEBUG,"MIDROW ("+C([a,b])+")"),!0):!1}return!1},p.parsePAC=function(a,b){var m,E=this.cmdHistory,B=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,U=(a===16||a===24)&&b>=64&&b<=95;if(!(B||U))return!1;if(k(a,b,E))return g(null,null,E),!0;var K=a<=23?1:2;b>=64&&b<=95?m=K===1?N[a]:v[a]:m=K===1?R[a]:T[a];var V=this.channels[K];return V?(V.setPAC(this.interpretPAC(m,b)),g(a,b,E),this.currentChannel=K,!0):!1},p.interpretPAC=function(a,b){var m,E={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?m=b-96:m=b-64,E.underline=(m&1)===1,m<=13?E.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(E.italics=!0,E.color="white"):E.indent=Math.floor((m-16)/2)*4,E},p.parseChars=function(a,b){var m,E=null,B=null;if(a>=25?(m=2,B=a-8):(m=1,B=a),B>=17&&B<=19){var U;B===17?U=b+80:B===18?U=b+112:U=b+144,this.logger.log(L.INFO,"Special char '"+M(U)+"' in channel "+m),E=[U]}else a>=32&&a<=127&&(E=b===0?[a]:[a,b]);if(E){var K=C(E);this.logger.log(L.DEBUG,"Char codes = "+K.join(",")),g(a,b,this.cmdHistory)}return E},p.parseBackgroundAttributes=function(a,b){var m=(a===16||a===24)&&b>=32&&b<=47,E=(a===23||a===31)&&b>=45&&b<=47;if(!(m||E))return!1;var B,U={};a===16||a===24?(B=Math.floor((b-32)/2),U.background=O[B],b%2===1&&(U.background=U.background+"_semi")):b===45?U.background="transparent":(U.foreground="black",b===47&&(U.underline=!0));var K=a<=23?1:2,V=this.channels[K];return V.setBkgData(U),g(a,b,this.cmdHistory),!0},p.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var b=this.channels[a];b&&b.reset()}this.cmdHistory=x()},p.cueSplitAtTime=function(a){for(var b=0;b<this.channels.length;b++){var m=this.channels[b];m&&m.cueSplitAtTime(a)}},f}();function g(f,p,d){d.a=f,d.b=p}function k(f,p,d){return d.a===f&&d.b===p}function x(){return{a:null,b:null}}$.default=y},"./src/utils/codecs.ts":function(oe,$,D){"use strict";D.r($),D.d($,"isCodecType",function(){return F}),D.d($,"isCodecSupportedInMp4",function(){return M});var Z={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 F(z,H){var N=Z[H];return!!N&&N[z.slice(0,4)]===!0}function M(z,H){return MediaSource.isTypeSupported((H||"video")+'/mp4;codecs="'+z+'"')}},"./src/utils/cues.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/utils/vttparser.ts"),F=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),z=/\s/,H={newCue:function(R,v,T,O){for(var L=[],A,C,u,o,l,h=self.VTTCue||self.TextTrackCue,w=0;w<O.rows.length;w++)if(A=O.rows[w],u=!0,o=0,l="",!A.isEmpty()){for(var y=0;y<A.chars.length;y++)z.test(A.chars[y].uchar)&&u?o++:(l+=A.chars[y].uchar,u=!1);A.cueStartTime=v,v===T&&(T+=1e-4),o>=16?o--:o++;var g=Object(Z.fixLineBreaks)(l.trim()),k=Object(F.generateCueId)(v,T,g);(!R||!R.cues||!R.cues.getCueById(k))&&(C=new h(v,T,g),C.id=k,C.line=w+1,C.align="left",C.position=10+Math.min(80,Math.floor(o*8/32)*10),L.push(C))}return R&&L.length&&(L.sort(function(x,f){return x.line==="auto"||f.line==="auto"?0:x.line>8&&f.line>8?f.line-x.line:x.line-f.line}),L.forEach(function(x){return Object(M.addCueToTrack)(R,x)})),L}};$.default=H},"./src/utils/discontinuities.ts":function(oe,$,D){"use strict";D.r($),D.d($,"findFirstFragWithCC",function(){return z}),D.d($,"shouldAlignOnDiscontinuities",function(){return H}),D.d($,"findDiscontinuousReferenceFrag",function(){return N}),D.d($,"adjustSlidingStart",function(){return v}),D.d($,"alignStream",function(){return T}),D.d($,"alignPDT",function(){return L}),D.d($,"alignFragmentByPDTDelta",function(){return A}),D.d($,"alignMediaPlaylistByPDT",function(){return C});var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/logger.ts"),M=D("./src/controller/level-helper.ts");function z(u,o){for(var l=null,h=0,w=u.length;h<w;h++){var y=u[h];if(y&&y.cc===o){l=y;break}}return l}function H(u,o,l){return!!(o.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function N(u,o){var l=u.fragments,h=o.fragments;if(!h.length||!l.length){F.logger.log("No fragments to align");return}var w=z(l,h[0].cc);if(!w||w&&!w.startPTS){F.logger.log("No frag in previous level to align on");return}return w}function R(u,o){if(u){var l=u.start+o;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function v(u,o){for(var l=o.fragments,h=0,w=l.length;h<w;h++)R(l[h],u);o.fragmentHint&&R(o.fragmentHint,u),o.alignedSliding=!0}function T(u,o,l){if(!o)return;O(u,l,o),!l.alignedSliding&&o.details&&L(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(M.adjustSliding)(o.details,l)}function O(u,o,l){if(H(u,l,o)){var h=N(l.details,o);h&&Object(Z.isFiniteNumber)(h.start)&&(F.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(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,w=(h-l)/1e3+o.fragments[0].start;w&&Object(Z.isFiniteNumber)(w)&&(F.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+w.toFixed(3)+" "+u.url+" "),v(w,u))}function A(u,o){var l=u.programDateTime;if(!l)return;var h=(l-o)/1e3;u.start=u.startPTS=h,u.endPTS=h+u.duration}function C(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,h=o.fragments[0].start,w=l-h*1e3;u.fragments.forEach(function(y){A(y,w)}),u.fragmentHint&&A(u.fragmentHint,w),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/utils/ewma.ts"),F=function(){function M(H,N,R){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=R,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Z.default(H),this.fast_=new Z.default(N)}var z=M.prototype;return z.update=function(N,R){var v=this.slow_,T=this.fast_;this.slow_.halfLife!==N&&(this.slow_=new Z.default(N,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==R&&(this.fast_=new Z.default(R,T.getEstimate(),T.getTotalWeight()))},z.sample=function(N,R){N=Math.max(N,this.minDelayMs_);var v=8*R,T=N/1e3,O=v/T;this.fast_.sample(T,O),this.slow_.sample(T,O)},z.canEstimate=function(){var N=this.fast_;return N&&N.getTotalWeight()>=this.minWeight_},z.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},z.destroy=function(){},M}();$.default=F},"./src/utils/ewma.ts":function(oe,$,D){"use strict";D.r($);var Z=function(){function F(z,H,N){H===void 0&&(H=0),N===void 0&&(N=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=z,this.alpha_=z?Math.exp(Math.log(.5)/z):0,this.estimate_=H,this.totalWeight_=N}var M=F.prototype;return M.sample=function(H,N){var R=Math.pow(this.alpha_,H);this.estimate_=N*(1-R)+R*this.estimate_,this.totalWeight_+=H},M.getTotalWeight=function(){return this.totalWeight_},M.getEstimate=function(){if(this.alpha_){var H=1-Math.pow(this.alpha_,this.totalWeight_);if(H)return this.estimate_/H}return this.estimate_},F}();$.default=Z},"./src/utils/fetch-loader.ts":function(oe,$,D){"use strict";D.r($),D.d($,"fetchSupported",function(){return A});var Z=D("./src/polyfills/number.ts"),F=D("./src/loader/load-stats.ts"),M=D("./src/demux/chunk-cache.ts");function z(h,w){h.prototype=Object.create(w.prototype),h.prototype.constructor=h,T(h,w)}function H(h){var w=typeof Map=="function"?new Map:void 0;return H=function(g){if(g===null||!v(g))return g;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(typeof w!="undefined"){if(w.has(g))return w.get(g);w.set(g,k)}function k(){return N(g,arguments,O(this).constructor)}return k.prototype=Object.create(g.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),T(k,g)},H(h)}function N(h,w,y){return R()?N=Reflect.construct:N=function(k,x,f){var p=[null];p.push.apply(p,x);var d=Function.bind.apply(k,p),a=new d;return f&&T(a,f.prototype),a},N.apply(null,arguments)}function R(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function v(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function T(h,w){return T=Object.setPrototypeOf||function(g,k){return g.__proto__=k,g},T(h,w)}function O(h){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(y){return y.__proto__||Object.getPrototypeOf(y)},O(h)}function L(){return L=Object.assign||function(h){for(var w=1;w<arguments.length;w++){var y=arguments[w];for(var g in y)Object.prototype.hasOwnProperty.call(y,g)&&(h[g]=y[g])}return h},L.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var C=function(){function h(y){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=y.fetchSetup||o,this.controller=new self.AbortController,this.stats=new F.LoadStats}var w=h.prototype;return w.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},w.abortInternal=function(){var g=this.response;(!g||!g.ok)&&(this.stats.aborted=!0,this.controller.abort())},w.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},w.load=function(g,k,x){var f=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var d=u(g,this.controller.signal),a=x.onProgress,b=g.responseType==="arraybuffer",m=b?"byteLength":"length";this.context=g,this.config=k,this.callbacks=x,this.request=this.fetchSetup(g,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),x.onTimeout(p,g,f.response)},k.timeout),self.fetch(this.request).then(function(E){if(f.response=f.loader=E,!E.ok){var B=E.status,U=E.statusText;throw new l(U||"fetch, bad network response",B,E)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(E.headers.get("Content-Length")||"0"),a&&Object(Z.isFiniteNumber)(k.highWaterMark)?f.loadProgressively(E,p,g,k.highWaterMark,a):b?E.arrayBuffer():E.text()}).then(function(E){var B=f.response;self.clearTimeout(f.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=E[m];var U={url:B.url,data:E};a&&!Object(Z.isFiniteNumber)(k.highWaterMark)&&a(p,g,E,B),x.onSuccess(U,p,g,B)}).catch(function(E){if(self.clearTimeout(f.requestTimeout),p.aborted)return;var B=E.code||0;x.onError({code:B,text:E.message},g,E.details)})},w.getCacheAge=function(){var g=null;if(this.response){var k=this.response.headers.get("age");g=k?parseFloat(k):null}return g},w.loadProgressively=function(g,k,x,f,p){f===void 0&&(f=0);var d=new M.default,a=g.body.getReader(),b=function m(){return a.read().then(function(E){if(E.done)return d.dataLength&&p(k,x,d.flush(),g),Promise.resolve(new ArrayBuffer(0));var B=E.value,U=B.length;return k.loaded+=U,U<f||d.dataLength?(d.push(B),d.dataLength>=f&&p(k,x,d.flush(),g)):p(k,x,B,g),m()}).catch(function(){return Promise.reject()})};return b()},h}();function u(h,w){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:w,headers:new self.Headers(L({},h.headers))};return h.rangeEnd&&y.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),y}function o(h,w){return new self.Request(h.url,w)}var l=function(h){z(w,h);function w(y,g,k){var x;return x=h.call(this,y)||this,x.code=void 0,x.details=void 0,x.code=g,x.details=k,x}return w}(H(Error));$.default=C},"./src/utils/imsc1-ttml-parser.ts":function(oe,$,D){"use strict";D.r($),D.d($,"IMSC1_CODEC",function(){return v}),D.d($,"parseIMSC1",function(){return A});var Z=D("./src/utils/mp4-tools.ts"),F=D("./src/utils/vttparser.ts"),M=D("./src/utils/vttcue.ts"),z=D("./src/demux/id3.ts"),H=D("./src/utils/timescale-conversion.ts"),N=D("./src/utils/webvtt-parser.ts");function R(){return R=Object.assign||function(f){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var a in d)Object.prototype.hasOwnProperty.call(d,a)&&(f[a]=d[a])}return f},R.apply(this,arguments)}var v="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,O=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function A(f,p,d,a,b){var m=Object(Z.findBox)(new Uint8Array(f),["mdat"]);if(m.length===0){b(new Error("Could not parse IMSC1 mdat"));return}var E=m[0],B=Object(z.utf8ArrayToStr)(new Uint8Array(f,E.start,E.end-E.start)),U=Object(H.toTimescaleFromScale)(p,1,d);try{a(C(B,U))}catch(K){b(K)}}function C(f,p){var d=new DOMParser,a=d.parseFromString(f,"text/xml"),b=a.getElementsByTagName("tt")[0];if(!b)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},E=Object.keys(m).reduce(function(P,_){return P[_]=b.getAttribute("ttp:"+_)||m[_],P},{}),B=b.getAttribute("xml:space")!=="preserve",U=o(u(b,"styling","style")),K=o(u(b,"layout","region")),V=u(b,"body","[begin]");return[].map.call(V,function(P){var _=l(P,B);if(!_||!P.hasAttribute("begin"))return null;var Y=g(P.getAttribute("begin"),E),ee=g(P.getAttribute("dur"),E),ae=g(P.getAttribute("end"),E);if(Y===null)throw y(P);if(ae===null){if(ee===null)throw y(P);ae=Y+ee}var ce=new M.default(Y-p,ae-p,_);ce.id=Object(N.generateCueId)(ce.startTime,ce.endTime,ce.text);var De=K[P.getAttribute("region")],Se=U[P.getAttribute("style")];ce.position=10,ce.size=80;var Ce=h(De,Se),Ae=Ce.textAlign;if(Ae){var Te=L[Ae];Te&&(ce.lineAlign=Te),ce.align=Ae}return R(ce,Ce),ce}).filter(function(P){return P!==null})}function u(f,p,d){var a=f.getElementsByTagName(p)[0];return a?[].slice.call(a.querySelectorAll(d)):[]}function o(f){return f.reduce(function(p,d){var a=d.getAttribute("xml:id");return a&&(p[a]=d),p},{})}function l(f,p){return[].slice.call(f.childNodes).reduce(function(d,a,b){var m;return a.nodeName==="br"&&b?d+`
`:(m=a.childNodes)!==null&&m!==void 0&&m.length?l(a,p):p?d+a.textContent.trim().replace(/\s+/g," "):d+a.textContent},"")}function h(f,p){var d="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(b,m){var E=w(p,d,m)||w(f,d,m);return E&&(b[m]=E),b},{})}function w(f,p,d){return f.hasAttributeNS(p,d)?f.getAttributeNS(p,d):null}function y(f){return new Error("Could not parse ttml timestamp "+f)}function g(f,p){if(!f)return null;var d=Object(F.parseTimeStamp)(f);return d===null&&(T.test(f)?d=k(f,p):O.test(f)&&(d=x(f,p))),d}function k(f,p){var d=T.exec(f),a=(d[4]|0)+(d[5]|0)/p.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+a/p.frameRate}function x(f,p){var d=O.exec(f),a=Number(d[1]),b=d[2];switch(b){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/p.frameRate;case"t":return a/p.tickRate}return a}},"./src/utils/logger.ts":function(oe,$,D){"use strict";D.r($),D.d($,"enableLogs",function(){return N}),D.d($,"logger",function(){return R});var Z=function(){},F={trace:Z,debug:Z,log:Z,warn:Z,info:Z,error:Z},M=F;function z(v){var T=self.console[v];return T?T.bind(self.console,"["+v+"] >"):Z}function H(v){for(var T=arguments.length,O=new Array(T>1?T-1:0),L=1;L<T;L++)O[L-1]=arguments[L];O.forEach(function(A){M[A]=v[A]?v[A].bind(v):z(A)})}function N(v){if(self.console&&v===!0||typeof v=="object"){H(v,"debug","log","info","warn","error");try{M.log()}catch(T){M=F}}else M=F}var R=M},"./src/utils/mediakeys-helper.ts":function(oe,$,D){"use strict";D.r($),D.d($,"KeySystems",function(){return Z}),D.d($,"requestMediaKeySystemAccess",function(){return F});var Z;(function(M){M.WIDEVINE="com.widevine.alpha",M.PLAYREADY="com.microsoft.playready"})(Z||(Z={}));var F=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(oe,$,D){"use strict";D.r($),D.d($,"getMediaSource",function(){return Z});function Z(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(oe,$,D){"use strict";D.r($),D.d($,"bin2str",function(){return H}),D.d($,"readUint16",function(){return N}),D.d($,"readUint32",function(){return R}),D.d($,"writeUint32",function(){return v}),D.d($,"findBox",function(){return T}),D.d($,"parseSegmentIndex",function(){return O}),D.d($,"parseInitSegment",function(){return L}),D.d($,"getStartDTS",function(){return A}),D.d($,"getDuration",function(){return C}),D.d($,"computeRawDurationFromSamples",function(){return u}),D.d($,"offsetStartDTS",function(){return o}),D.d($,"segmentValidRange",function(){return l}),D.d($,"appendUint8Array",function(){return h});var Z=D("./src/utils/typed-array.ts"),F=D("./src/loader/fragment.ts"),M=Math.pow(2,32)-1,z=[].push;function H(w){return String.fromCharCode.apply(null,w)}function N(w,y){"data"in w&&(y+=w.start,w=w.data);var g=w[y]<<8|w[y+1];return g<0?65536+g:g}function R(w,y){"data"in w&&(y+=w.start,w=w.data);var g=w[y]<<24|w[y+1]<<16|w[y+2]<<8|w[y+3];return g<0?4294967296+g:g}function v(w,y,g){"data"in w&&(y+=w.start,w=w.data),w[y]=g>>24,w[y+1]=g>>16&255,w[y+2]=g>>8&255,w[y+3]=g&255}function T(w,y){var g=[];if(!y.length)return g;var k,x,f;"data"in w?(k=w.data,x=w.start,f=w.end):(k=w,x=0,f=k.byteLength);for(var p=x;p<f;){var d=R(k,p),a=H(k.subarray(p+4,p+8)),b=d>1?p+d:f;if(a===y[0])if(y.length===1)g.push({data:k,start:p+8,end:b});else{var m=T({data:k,start:p+8,end:b},y.slice(1));m.length&&z.apply(g,m)}p=b}return g}function O(w){var y=T(w,["moov"]),g=y[0],k=g?g.end:null,x=T(w,["sidx"]);if(!x||!x[0])return null;var f=[],p=x[0],d=p.data[0],a=d===0?8:16,b=R(p,a);a+=4;var m=0,E=0;d===0?a+=8:a+=16,a+=2;var B=p.end+E,U=N(p,a);a+=2;for(var K=0;K<U;K++){var V=a,P=R(p,V);V+=4;var _=P&2147483647,Y=(P&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ee=R(p,V);V+=4,f.push({referenceSize:_,subsegmentDuration:ee,info:{duration:ee/b,start:B,end:B+_-1}}),B+=_,V+=4,a=V}return{earliestPresentationTime:m,timescale:b,version:d,referencesCount:U,references:f,moovEndOffset:k}}function L(w){for(var y=[],g=T(w,["moov","trak"]),k=0;k<g.length;k++){var x=g[k],f=T(x,["tkhd"])[0];if(f){var p=f.data[f.start],d=p===0?12:20,a=R(f,d),b=T(x,["mdia","mdhd"])[0];if(b){p=b.data[b.start],d=p===0?12:20;var m=R(b,d),E=T(x,["mdia","hdlr"])[0];if(E){var B=H(E.data.subarray(E.start+8,E.start+12)),U={soun:F.ElementaryStreamTypes.AUDIO,vide:F.ElementaryStreamTypes.VIDEO}[B];if(U){var K=T(x,["mdia","minf","stbl","stsd"])[0],V=void 0;K&&(V=H(K.data.subarray(K.start+12,K.start+16))),y[a]={timescale:m,type:U},y[U]={timescale:m,id:a,codec:V}}}}}}var P=T(w,["moov","mvex","trex"]);return P.forEach(function(_){var Y=R(_,4),ee=y[Y];ee&&(ee.default={duration:R(_,12),flags:R(_,20)})}),y}function A(w,y){return T(y,["moof","traf"]).reduce(function(g,k){var x=T(k,["tfdt"])[0],f=x.data[x.start],p=T(k,["tfhd"]).reduce(function(d,a){var b=R(a,4),m=w[b];if(m){var E=R(x,4);f===1&&(E*=Math.pow(2,32),E+=R(x,8));var B=m.timescale||9e4,U=E/B;if(isFinite(U)&&(d===null||U<d))return U}return d},null);return p!==null&&isFinite(p)&&(g===null||p<g)?p:g},null)||0}function C(w,y){for(var g=0,k=0,x=0,f=T(w,["moof","traf"]),p=0;p<f.length;p++){var d=f[p],a=T(d,["tfhd"])[0],b=R(a,4),m=y[b];if(!m)continue;var E=m.default,B=R(a,0)|(E==null?void 0:E.flags),U=E==null?void 0:E.duration;B&8&&(B&2?U=R(a,12):U=R(a,8));for(var K=m.timescale||9e4,V=T(d,["trun"]),P=0;P<V.length;P++){if(U){var _=R(V[P],4);g=U*_}else g=u(V[P]);m.type===F.ElementaryStreamTypes.VIDEO?k+=g/K:m.type===F.ElementaryStreamTypes.AUDIO&&(x+=g/K)}}if(k===0&&x===0){var Y=O(w);if(Y!=null&&Y.references)return Y.references.reduce(function(ee,ae){return ee+ae.info.duration||0},0)}return k||x}function u(w){var y=R(w,0),g=8;y&1&&(g+=4),y&4&&(g+=4);for(var k=0,x=R(w,4),f=0;f<x;f++){if(y&256){var p=R(w,g);k+=p,g+=4}y&512&&(g+=4),y&1024&&(g+=4),y&2048&&(g+=4)}return k}function o(w,y,g){T(y,["moof","traf"]).forEach(function(k){T(k,["tfhd"]).forEach(function(x){var f=R(x,4),p=w[f];if(!p)return;var d=p.timescale||9e4;T(k,["tfdt"]).forEach(function(a){var b=a.data[a.start],m=R(a,4);if(b===0)v(a,4,m-g*d);else{m*=Math.pow(2,32),m+=R(a,8),m-=g*d,m=Math.max(m,0);var E=Math.floor(m/(M+1)),B=Math.floor(m%(M+1));v(a,4,E),v(a,8,B)}})})})}function l(w){var y={valid:null,remainder:null},g=T(w,["moof"]);if(g){if(g.length<2)return y.remainder=w,y}else return y;var k=g[g.length-1];return y.valid=Object(Z.sliceUint8)(w,0,k.start-8),y.remainder=Object(Z.sliceUint8)(w,k.start-8),y}function h(w,y){var g=new Uint8Array(w.length+y.length);return g.set(w),g.set(y,w.length),g}},"./src/utils/output-filter.ts":function(oe,$,D){"use strict";D.r($),D.d($,"default",function(){return Z});var Z=function(){function F(z,H){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=H}var M=F.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(H,N,R){(this.startTime===null||this.startTime>H)&&(this.startTime=H),this.endTime=N,this.screen=R,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[]},F}()},"./src/utils/texttrack-utils.ts":function(oe,$,D){"use strict";D.r($),D.d($,"sendAddTrackEvent",function(){return F}),D.d($,"addCueToTrack",function(){return M}),D.d($,"clearCurrentCues",function(){return z}),D.d($,"removeCuesInRange",function(){return H}),D.d($,"getCuesInRange",function(){return R});var Z=D("./src/utils/logger.ts");function F(v,T){var O;try{O=new Event("addtrack")}catch(L){O=document.createEvent("Event"),O.initEvent("addtrack",!1,!1)}O.track=v,T.dispatchEvent(O)}function M(v,T){var O=v.mode;if(O==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(T.id))try{if(v.addCue(T),!v.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(A){Z.logger.debug("[texttrack-utils]: "+A);var L=new self.TextTrackCue(T.startTime,T.endTime,T.text);L.id=T.id,v.addCue(L)}O==="disabled"&&(v.mode=O)}function z(v){var T=v.mode;if(T==="disabled"&&(v.mode="hidden"),v.cues)for(var O=v.cues.length;O--;)v.removeCue(v.cues[O]);T==="disabled"&&(v.mode=T)}function H(v,T,O){var L=v.mode;if(L==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var A=R(v.cues,T,O),C=0;C<A.length;C++)v.removeCue(A[C]);L==="disabled"&&(v.mode=L)}function N(v,T){if(T<v[0].startTime)return 0;var O=v.length-1;if(T>v[O].endTime)return-1;for(var L=0,A=O;L<=A;){var C=Math.floor((A+L)/2);if(T<v[C].startTime)A=C-1;else if(T>v[C].startTime&&L<O)L=C+1;else return C}return v[L].startTime-T<T-v[A].startTime?L:A}function R(v,T,O){var L=[],A=N(v,T);if(A>-1)for(var C=A,u=v.length;C<u;C++){var o=v[C];if(o.startTime>=T&&o.endTime<=O)L.push(o);else if(o.startTime>O)return L}return L}},"./src/utils/time-ranges.ts":function(oe,$,D){"use strict";D.r($);var Z={toString:function(M){for(var z="",H=M.length,N=0;N<H;N++)z+="["+M.start(N).toFixed(3)+","+M.end(N).toFixed(3)+"]";return z}};$.default=Z},"./src/utils/timescale-conversion.ts":function(oe,$,D){"use strict";D.r($),D.d($,"toTimescaleFromBase",function(){return F}),D.d($,"toTimescaleFromScale",function(){return M}),D.d($,"toMsFromMpegTsClock",function(){return z}),D.d($,"toMpegTsClockFromTimescale",function(){return H});var Z=9e4;function F(N,R,v,T){v===void 0&&(v=1),T===void 0&&(T=!1);var O=N*R*v;return T?Math.round(O):O}function M(N,R,v,T){return v===void 0&&(v=1),T===void 0&&(T=!1),F(N,R,1/v,T)}function z(N,R){return R===void 0&&(R=!1),F(N,1e3,1/Z,R)}function H(N,R){return R===void 0&&(R=1),F(N,Z,1/R)}},"./src/utils/typed-array.ts":function(oe,$,D){"use strict";D.r($),D.d($,"sliceUint8",function(){return Z});function Z(F,M,z){return Uint8Array.prototype.slice?F.slice(M,z):new Uint8Array(Array.prototype.slice.call(F,M,z))}},"./src/utils/vttcue.ts":function(oe,$,D){"use strict";D.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var Z=["","lr","rl"],F=["start","middle","end","left","right"];function M(v,T){if(typeof T!="string")return!1;if(!Array.isArray(v))return!1;var O=T.toLowerCase();return~v.indexOf(O)?O:!1}function z(v){return M(Z,v)}function H(v){return M(F,v)}function N(v){for(var T=arguments.length,O=new Array(T>1?T-1:0),L=1;L<T;L++)O[L-1]=arguments[L];for(var A=1;A<arguments.length;A++){var C=arguments[A];for(var u in C)v[u]=C[u]}return v}function R(v,T,O){var L=this,A={enumerable:!0};L.hasBeenReset=!1;var C="",u=!1,o=v,l=T,h=O,w=null,y="",g=!0,k="auto",x="start",f=50,p="middle",d=50,a="middle";Object.defineProperty(L,"id",N({},A,{get:function(){return C},set:function(m){C=""+m}})),Object.defineProperty(L,"pauseOnExit",N({},A,{get:function(){return u},set:function(m){u=!!m}})),Object.defineProperty(L,"startTime",N({},A,{get:function(){return o},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");o=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",N({},A,{get:function(){return l},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",N({},A,{get:function(){return h},set:function(m){h=""+m,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",N({},A,{get:function(){return w},set:function(m){w=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",N({},A,{get:function(){return y},set:function(m){var E=z(m);if(E===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",N({},A,{get:function(){return g},set:function(m){g=!!m,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",N({},A,{get:function(){return k},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");k=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",N({},A,{get:function(){return x},set:function(m){var E=H(m);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");x=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",N({},A,{get:function(){return f},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");f=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",N({},A,{get:function(){return p},set:function(m){var E=H(m);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");p=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",N({},A,{get:function(){return d},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");d=m,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",N({},A,{get:function(){return a},set:function(m){var E=H(m);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");a=E,this.hasBeenReset=!0}})),L.displayState=void 0}return R.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},R}()},"./src/utils/vttparser.ts":function(oe,$,D){"use strict";D.r($),D.d($,"parseTimeStamp",function(){return M}),D.d($,"fixLineBreaks",function(){return T}),D.d($,"VTTParser",function(){return O});var Z=D("./src/utils/vttcue.ts"),F=function(){function L(){}var A=L.prototype;return A.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 A(u,o,l,h){return(u|0)*3600+(o|0)*60+(l|0)+parseFloat(h||0)}var C=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?A(C[2],C[3],0,C[4]):A(C[1],C[2],C[3],C[4]):null}var z=function(){function L(){this.values=Object.create(null)}var A=L.prototype;return A.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},A.get=function(u,o,l){return l?this.has(u)?this.values[u]:o[l]:this.has(u)?this.values[u]:o},A.has=function(u){return u in this.values},A.alt=function(u,o,l){for(var h=0;h<l.length;++h)if(o===l[h]){this.set(u,o);break}},A.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},A.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 H(L,A,C,u){var o=u?L.split(u):[L];for(var l in o){if(typeof o[l]!="string")continue;var h=o[l].split(C);if(h.length!==2)continue;var w=h[0],y=h[1];A(w,y)}}var N=new Z.default(0,0,""),R=N.align==="middle"?"middle":"center";function v(L,A,C){var u=L;function o(){var w=M(L);if(w===null)throw new Error("Malformed timestamp: "+u);return L=L.replace(/^[^\sa-zA-Z-]+/,""),w}function l(w,y){var g=new z;H(w,function(f,p){var d;switch(f){case"region":for(var a=C.length-1;a>=0;a--)if(C[a].id===p){g.set(f,C[a].region);break}break;case"vertical":g.alt(f,p,["rl","lr"]);break;case"line":d=p.split(","),g.integer(f,d[0]),g.percent(f,d[0])&&g.set("snapToLines",!1),g.alt(f,d[0],["auto"]),d.length===2&&g.alt("lineAlign",d[1],["start",R,"end"]);break;case"position":d=p.split(","),g.percent(f,d[0]),d.length===2&&g.alt("positionAlign",d[1],["start",R,"end","line-left","line-right","auto"]);break;case"size":g.percent(f,p);break;case"align":g.alt(f,p,["start",R,"end","left","right"]);break}},/:/,/\s/),y.region=g.get("region",null),y.vertical=g.get("vertical","");var k=g.get("line","auto");k==="auto"&&N.line===-1&&(k=-1),y.line=k,y.lineAlign=g.get("lineAlign","start"),y.snapToLines=g.get("snapToLines",!0),y.size=g.get("size",100),y.align=g.get("align",R);var x=g.get("position","auto");x==="auto"&&N.position===50&&(x=y.align==="start"||y.align==="left"?0:y.align==="end"||y.align==="right"?100:50),y.position=x}function h(){L=L.replace(/^\s+/,"")}if(h(),A.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(),A.endTime=o(),h(),l(L,A)}function T(L){return L.replace(/<br(?: \/)?>/gi,`
`)}var O=function(){function L(){this.state="INITIAL",this.buffer="",this.decoder=new F,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=L.prototype;return A.parse=function(u){var o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function l(){var x=o.buffer,f=0;for(x=T(x);f<x.length&&x[f]!=="\r"&&x[f]!==`
`;)++f;var p=x.substr(0,f);return x[f]==="\r"&&++f,x[f]===`
`&&++f,o.buffer=x.substr(f),p}function h(x){H(x,function(f,p){},/:/)}try{var w="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;w=l();var y=w.match(/^()?WEBVTT([ \t].*)?$/);if(!y||!y[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var g=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;g?g=!1:w=l();switch(o.state){case"HEADER":/:/.test(w)?h(w):w||(o.state="ID");continue;case"NOTE":w||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(w)){o.state="NOTE";break}if(!w)continue;if(o.cue=new Z.default(0,0,""),o.state="CUE",w.indexOf("-->")===-1){o.cue.id=w;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(w,o.cue,o.regionList)}catch(x){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var k=w.indexOf("-->")!==-1;if(!w||k&&(g=!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+=w}continue;case"BADCUE":w||(o.state="ID")}}}catch(x){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},A.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(oe,$,D){"use strict";D.r($),D.d($,"generateCueId",function(){return O}),D.d($,"parseWebVTT",function(){return A});var Z=D("./src/polyfills/number.ts"),F=D("./src/utils/vttparser.ts"),M=D("./src/demux/id3.ts"),z=D("./src/utils/timescale-conversion.ts"),H=D("./src/remux/mp4-remuxer.ts"),N=/\r\n|\n\r|\n|\r/g,R=function(u,o,l){return l===void 0&&(l=0),u.substr(l,o.length)===o},v=function(u){var o=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),h=parseInt(u.substr(-9,2)),w=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(Z.isFiniteNumber)(o)||!Object(Z.isFiniteNumber)(l)||!Object(Z.isFiniteNumber)(h)||!Object(Z.isFiniteNumber)(w))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*l,o+=60*1e3*h,o+=60*60*1e3*w,o},T=function(u){for(var o=5381,l=u.length;l;)o=o*33^u.charCodeAt(--l);return(o>>>0).toString()};function O(C,u,o){return T(C.toString())+T(u.toString())+T(o)}var L=function(u,o,l){var h=u[o],w=u[h.prevCC];if(!w||!w.new&&h.new){u.ccOffset=u.presentationOffset=h.start,h.new=!1;return}for(;(y=w)!==null&&y!==void 0&&y.new;){var y;u.ccOffset+=h.start-w.start,h.new=!1,h=w,w=u[h.prevCC]}u.presentationOffset=l};function A(C,u,o,l,h,w,y,g){var k=new F.VTTParser,x=Object(M.utf8ArrayToStr)(new Uint8Array(C)).trim().replace(N,`
`).split(`
`),f=[],p=Object(z.toMpegTsClockFromTimescale)(u,o),d="00:00.000",a=0,b=0,m,E=!0,B=!1;k.oncue=function(U){var K=l[h],V=l.ccOffset,P=(a-p)/9e4;if(K!=null&&K.new&&(b!==void 0?V=l.ccOffset=K.start:L(l,h,P)),P&&(V=P-l.presentationOffset),B){var _=U.endTime-U.startTime,Y=Object(H.normalizePts)((U.startTime+V-b)*9e4,w*9e4)/9e4;U.startTime=Y,U.endTime=Y+_}var ee=U.text.trim();U.text=decodeURIComponent(encodeURIComponent(ee)),U.id||(U.id=O(U.startTime,U.endTime,ee)),U.endTime>0&&f.push(U)},k.onparsingerror=function(U){m=U},k.onflush=function(){if(m){g(m);return}y(f)},x.forEach(function(U){if(E)if(R(U,"X-TIMESTAMP-MAP=")){E=!1,B=!0,U.substr(16).split(",").forEach(function(K){R(K,"LOCAL:")?d=K.substr(6):R(K,"MPEGTS:")&&(a=parseInt(K.substr(7)))});try{b=v(d)/1e3}catch(K){B=!1,m=K}return}else U===""&&(E=!1);k.parse(U+`
`)}),k.flush()}},"./src/utils/xhr-loader.ts":function(oe,$,D){"use strict";D.r($);var Z=D("./src/utils/logger.ts"),F=D("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,z=function(){function H(R){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=R?R.xhrSetup:null,this.stats=new F.LoadStats,this.retryDelay=0}var N=H.prototype;return N.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},N.abortInternal=function(){var v=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),v&&(v.onreadystatechange=null,v.onprogress=null,v.readyState!==4&&(this.stats.aborted=!0,v.abort()))},N.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},N.load=function(v,T,O){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=v,this.config=T,this.callbacks=O,this.retryDelay=T.retryDelay,this.loadInternal()},N.loadInternal=function(){var v=this.config,T=this.context;if(!v)return;var O=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var A=this.xhrSetup;try{if(A)try{A(O,T.url)}catch(o){O.open("GET",T.url,!0),A(O,T.url)}O.readyState||O.open("GET",T.url,!0);var C=this.context.headers;if(C)for(var u in C)O.setRequestHeader(u,C[u])}catch(o){this.callbacks.onError({code:O.status,text:o.message},T,O);return}T.rangeEnd&&O.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),O.onreadystatechange=this.readystatechange.bind(this),O.onprogress=this.loadprogress.bind(this),O.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),O.send()},N.readystatechange=function(){var v=this.context,T=this.loader,O=this.stats;if(!v||!T)return;var L=T.readyState,A=this.config;if(O.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),O.loading.first===0&&(O.loading.first=Math.max(self.performance.now(),O.loading.start)),L===4){T.onreadystatechange=null,T.onprogress=null;var C=T.status;if(C>=200&&C<300){O.loading.end=Math.max(self.performance.now(),O.loading.first);var u,o;if(v.responseType==="arraybuffer"?(u=T.response,o=u.byteLength):(u=T.responseText,o=u.length),O.loaded=O.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(O,v,u,T),!this.callbacks)return;var h={url:T.responseURL,data:u};this.callbacks.onSuccess(h,O,v,T)}else O.retry>=A.maxRetry||C>=400&&C<499?(Z.logger.error(C+" while loading "+v.url),this.callbacks.onError({code:C,text:T.statusText},v,T)):(Z.logger.warn(C+" while loading "+v.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,A.maxRetryDelay),O.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)},N.loadtimeout=function(){Z.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},N.loadprogress=function(v){var T=this.stats;T.loaded=v.loaded,v.lengthComputable&&(T.total=v.total)},N.getCacheAge=function(){var v=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");v=T?parseFloat(T):null}return v},H}();$.default=z}}).default})},vHTk:function(Tt,ut,he){Tt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);