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__User__Detail__Topics__Gr...

372 lines
944 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[251,5,6,7],{"+NIl":function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){"use strict";le.defineMode("stex",function(Q,_){"use strict";function Z(k,A){k.cmdState.push(A)}function B(k){return k.cmdState.length>0?k.cmdState[k.cmdState.length-1]:null}function P(k){var A=k.cmdState.pop();A&&A.closeBracket()}function z(k){for(var A=k.cmdState,T=A.length-1;T>=0;T--){var h=A[T];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function W(k,A,T){return function(){this.name=k,this.bracketNo=0,this.style=A,this.styles=T,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var I={};I.importmodule=W("importmodule","tag",["string","builtin"]),I.documentclass=W("documentclass","tag",["","atom"]),I.usepackage=W("usepackage","tag",["atom"]),I.begin=W("begin","tag",["atom"]),I.end=W("end","tag",["atom"]),I.label=W("label","tag",["atom"]),I.ref=W("ref","tag",["atom"]),I.eqref=W("eqref","tag",["atom"]),I.cite=W("cite","tag",["atom"]),I.bibitem=W("bibitem","tag",["atom"]),I.Bibitem=W("Bibitem","tag",["atom"]),I.RBibitem=W("RBibitem","tag",["atom"]),I.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function D(k,A){k.f=A}function y(k,A){var T;if(k.match(/^\\[a-zA-Z@]+/)){var h=k.current().slice(1);return T=I.hasOwnProperty(h)?I[h]:I.DEFAULT,T=new T,Z(A,T),D(A,O),T.style}if(k.match(/^\\[$&%#{}_]/))return"tag";if(k.match(/^\\[,;!\/\\]/))return"tag";if(k.match("\\["))return D(A,function(l,d){return w(l,d,"\\]")}),"keyword";if(k.match("\\("))return D(A,function(l,d){return w(l,d,"\\)")}),"keyword";if(k.match("$$"))return D(A,function(l,d){return w(l,d,"$$")}),"keyword";if(k.match("$"))return D(A,function(l,d){return w(l,d,"$")}),"keyword";var o=k.next();if(o=="%")return k.skipToEnd(),"comment";if(o=="}"||o=="]"){if(T=B(A),T)T.closeBracket(o),D(A,O);else return"error";return"bracket"}else return o=="{"||o=="["?(T=I.DEFAULT,T=new T,Z(A,T),"bracket"):/\d/.test(o)?(k.eatWhile(/[\w.%]/),"atom"):(k.eatWhile(/[\w\-_]/),T=z(A),T.name=="begin"&&(T.argument=k.current()),T.styleIdentifier())}function w(k,A,T){if(k.eatSpace())return null;if(T&&k.match(T))return D(A,y),"keyword";if(k.match(/^\\[a-zA-Z@]+/))return"tag";if(k.match(/^[a-zA-Z]+/))return"variable-2";if(k.match(/^\\[$&%#{}_]/))return"tag";if(k.match(/^\\[,;!\/]/))return"tag";if(k.match(/^[\^_&]/))return"tag";if(k.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(k.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var h=k.next();return h=="{"||h=="}"||h=="["||h=="]"||h=="("||h==")"?"bracket":h=="%"?(k.skipToEnd(),"comment"):"error"}function O(k,A){var T=k.peek(),h;return T=="{"||T=="["?(h=B(A),h.openBracket(T),k.eat(T),D(A,y),"bracket"):/[ \t\r]/.test(T)?(k.eat(T),null):(D(A,y),P(A),y(k,A))}return{startState:function(){var k=_.inMathMode?function(A,T){return w(A,T)}:y;return{cmdState:[],f:k}},copyState:function(k){return{cmdState:k.cmdState.slice(),f:k.f}},token:function(k,A){return A.f(k,A)},blankLine:function(k){k.f=y,k.cmdState.length=0},lineComment:"%"}}),le.defineMIME("text/x-stex","stex"),le.defineMIME("text/x-latex","stex")})},"19Vz":function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){le.defineOption("placeholder","",function(W,I,D){var y=D&&D!=le.Init;if(I&&!y)W.on("blur",B),W.on("change",P),W.on("swapDoc",P),le.on(W.getInputField(),"compositionupdate",W.state.placeholderCompose=function(){Z(W)}),P(W);else if(!I&&y){W.off("blur",B),W.off("change",P),W.off("swapDoc",P),le.off(W.getInputField(),"compositionupdate",W.state.placeholderCompose),Q(W);var w=W.getWrapperElement();w.className=w.className.replace(" CodeMirror-empty","")}I&&!W.hasFocus()&&B(W)});function Q(W){W.state.placeholder&&(W.state.placeholder.parentNode.removeChild(W.state.placeholder),W.state.placeholder=null)}function _(W){Q(W);var I=W.state.placeholder=document.createElement("pre");I.style.cssText="height: 0; overflow: visible",I.style.direction=W.getOption("direction"),I.className="CodeMirror-placeholder CodeMirror-line-like";var D=W.getOption("placeholder");typeof D=="string"&&(D=document.createTextNode(D)),I.appendChild(D),W.display.lineSpace.insertBefore(I,W.display.lineSpace.firstChild)}function Z(W){setTimeout(function(){var I=!1,D=W.getInputField();D.nodeName=="TEXTAREA"?I=!D.value:W.lineCount()==1&&(I=!/[^\u200b]/.test(D.querySelector(".CodeMirror-line").textContent)),I?_(W):Q(W)},20)}function B(W){z(W)&&_(W)}function P(W){var I=W.getWrapperElement(),D=z(W);I.className=I.className.replace(" CodeMirror-empty","")+(D?" CodeMirror-empty":""),D?_(W):Q(W)}function z(W){return W.lineCount()===1&&W.getLine(0)===""}})},"1eCo":function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){"use strict";var Q={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},_={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};le.defineMode("xml",function(Z,B){var P=Z.indentUnit,z={},W=B.htmlMode?Q:_;for(var I in W)z[I]=W[I];for(var I in B)z[I]=B[I];var D,y;function w(a,x){function v(F){return x.tokenize=F,F(a,x)}var E=a.next();if(E=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?v(A("atom","]]>")):null:a.match("--")?v(A("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),v(T(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),x.tokenize=A("meta","?>"),"meta"):(D=a.eat("/")?"closeTag":"openTag",x.tokenize=O,"tag bracket");if(E=="&"){var N;return a.eat("#")?a.eat("x")?N=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):N=a.eatWhile(/[\d]/)&&a.eat(";"):N=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),N?"atom":"error"}else return a.eatWhile(/[^&<]/),null}w.isInText=!0;function O(a,x){var v=a.next();if(v==">"||v=="/"&&a.eat(">"))return x.tokenize=w,D=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return D="equals",null;if(v=="<"){x.tokenize=w,x.state=d,x.tagName=x.tagStart=null;var E=x.tokenize(a,x);return E?E+" tag error":"tag error"}else return/[\'\"]/.test(v)?(x.tokenize=k(v),x.stringStartCol=a.column(),x.tokenize(a,x)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function k(a){var x=function(v,E){for(;!v.eol();)if(v.next()==a){E.tokenize=O;break}return"string"};return x.isInAttribute=!0,x}function A(a,x){return function(v,E){for(;!v.eol();){if(v.match(x)){E.tokenize=w;break}v.next()}return a}}function T(a){return function(x,v){for(var E;(E=x.next())!=null;){if(E=="<")return v.tokenize=T(a+1),v.tokenize(x,v);if(E==">")if(a==1){v.tokenize=w;break}else return v.tokenize=T(a-1),v.tokenize(x,v)}return"meta"}}function h(a,x,v){this.prev=a.context,this.tagName=x,this.indent=a.indented,this.startOfLine=v,(z.doNotIndent.hasOwnProperty(x)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function l(a,x){for(var v;;){if(!a.context)return;if(v=a.context.tagName,!z.contextGrabbers.hasOwnProperty(v)||!z.contextGrabbers[v].hasOwnProperty(x))return;o(a)}}function d(a,x,v){return a=="openTag"?(v.tagStart=x.column(),C):a=="closeTag"?f:d}function C(a,x,v){return a=="word"?(v.tagName=x.current(),y="tag",b):z.allowMissingTagName&&a=="endTag"?(y="tag bracket",b(a,x,v)):(y="error",C)}function f(a,x,v){if(a=="word"){var E=x.current();return v.context&&v.context.tagName!=E&&z.implicitlyClosed.hasOwnProperty(v.context.tagName)&&o(v),v.context&&v.context.tagName==E||z.matchClosing===!1?(y="tag",p):(y="tag error",L)}else return z.allowMissingTagName&&a=="endTag"?(y="tag bracket",p(a,x,v)):(y="error",L)}function p(a,x,v){return a!="endTag"?(y="error",p):(o(v),d)}function L(a,x,v){return y="error",p(a,x,v)}function b(a,x,v){if(a=="word")return y="attribute",g;if(a=="endTag"||a=="selfcloseTag"){var E=v.tagName,N=v.tagStart;return v.tagName=v.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(E)?l(v,E):(l(v,E),v.context=new h(v,E,N==v.indented)),d}return y="error",b}function g(a,x,v){return a=="equals"?c:(z.allowMissing||(y="error"),b(a,x,v))}function c(a,x,v){return a=="string"?u:a=="word"&&z.allowUnquoted?(y="string",b):(y="error",b(a,x,v))}function u(a,x,v){return a=="string"?u:b(a,x,v)}return{startState:function(a){var x={tokenize:w,state:d,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(x.baseIndent=a),x},token:function(a,x){if(!x.tagName&&a.sol()&&(x.indented=a.indentation()),a.eatSpace())return null;D=null;var v=x.tokenize(a,x);return(v||D)&&v!="comment"&&(y=null,x.state=x.state(D||v,a,x),y&&(v=y=="error"?v+" error":y)),v},indent:function(a,x,v){var E=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+P;if(E&&E.noIndent)return le.Pass;if(a.tokenize!=O&&a.tokenize!=w)return v?v.match(/^(\s*)/)[0].length:0;if(a.tagName)return z.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+P*(z.multilineTagIndentFactor||1);if(z.alignCDATA&&/<!\[CDATA\[/.test(x))return 0;var N=x&&/^<(\/)?([\w_:\.-]*)/.exec(x);if(N&&N[1])for(;E;)if(E.tagName==N[2]){E=E.prev;break}else if(z.implicitlyClosed.hasOwnProperty(E.tagName))E=E.prev;else break;else if(N)for(;E;){var F=z.contextGrabbers[E.tagName];if(F&&F.hasOwnProperty(N[2]))E=E.prev;else break}for(;E&&E.prev&&!E.startOfLine;)E=E.prev;return E?E.indent+P:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=b)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var x=[],v=a.context;v;v=v.prev)v.tagName&&x.push(v.tagName);return x.reverse()}}}),le.defineMIME("text/xml","xml"),le.defineMIME("application/xml","xml"),le.mimeModes.hasOwnProperty("text/html")||le.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(xt,at,se){"use strict";se.d(at,"a",function(){return l}),se.d(at,"b",function(){return b});var le=se("Ty5D"),Q=se("dI71"),_=se("q1tI"),Z=se.n(_),B=se("YS25"),P=se("17x9"),z=se.n(P),W=se("wx14"),I=se("zLVn"),D=se("9R94"),y=function(c){Object(Q.a)(u,c);function u(){for(var x,v=arguments.length,E=new Array(v),N=0;N<v;N++)E[N]=arguments[N];return x=c.call.apply(c,[this].concat(E))||this,x.history=Object(B.a)(x.props),x}var a=u.prototype;return a.render=function(){return Z.a.createElement(le.c,{history:this.history,children:this.props.children})},u}(Z.a.Component),w=function(c){Object(Q.a)(u,c);function u(){for(var x,v=arguments.length,E=new Array(v),N=0;N<v;N++)E[N]=arguments[N];return x=c.call.apply(c,[this].concat(E))||this,x.history=Object(B.b)(x.props),x}var a=u.prototype;return a.render=function(){return Z.a.createElement(le.c,{history:this.history,children:this.props.children})},u}(Z.a.Component),O=function(u,a){return typeof u=="function"?u(a):u},k=function(u,a){return typeof u=="string"?Object(B.c)(u,null,null,a):u},A=function(u){return u},T=Z.a.forwardRef;typeof T=="undefined"&&(T=A);function h(c){return!!(c.metaKey||c.altKey||c.ctrlKey||c.shiftKey)}var o=T(function(c,u){var a=c.innerRef,x=c.navigate,v=c.onClick,E=Object(I.a)(c,["innerRef","navigate","onClick"]),N=E.target,F=Object(W.a)({},E,{onClick:function(V){try{v&&v(V)}catch(R){throw V.preventDefault(),R}!V.defaultPrevented&&V.button===0&&(!N||N==="_self")&&!h(V)&&(V.preventDefault(),x())}});return A!==T?F.ref=u||a:F.ref=a,Z.a.createElement("a",F)}),l=T(function(c,u){var a=c.component,x=a===void 0?o:a,v=c.replace,E=c.to,N=c.innerRef,F=Object(I.a)(c,["component","replace","to","innerRef"]);return Z.a.createElement(le.e.Consumer,null,function(K){K||Object(D.a)(!1);var V=K.history,R=k(O(E,K.location),K.location),M=R?V.createHref(R):"",$=Object(W.a)({},F,{href:M,navigate:function(){var ae=O(E,K.location),fe=v?V.replace:V.push;fe(ae)}});return A!==T?$.ref=u||N:$.innerRef=N,Z.a.createElement(x,$)})});if(!1)var d,C;var f=function(u){return u},p=Z.a.forwardRef;typeof p=="undefined"&&(p=f);function L(){for(var c=arguments.length,u=new Array(c),a=0;a<c;a++)u[a]=arguments[a];return u.filter(function(x){return x}).join(" ")}var b=p(function(c,u){var a=c["aria-current"],x=a===void 0?"page":a,v=c.activeClassName,E=v===void 0?"active":v,N=c.activeStyle,F=c.className,K=c.exact,V=c.isActive,R=c.location,M=c.sensitive,$=c.strict,ee=c.style,ae=c.to,fe=c.innerRef,De=Object(I.a)(c,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Z.a.createElement(le.e.Consumer,null,function(Se){Se||Object(D.a)(!1);var Ce=R||Se.location,we=k(O(ae,Ce),Ce),Te=we.pathname,me=Te&&Te.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),he=me?Object(le.f)(Ce.pathname,{path:me,exact:K,sensitive:M,strict:$}):null,te=!!(V?V(he,Ce):he),de=te?L(F,E):F,ne=te?Object(W.a)({},ee,{},N):ee,Le=Object(W.a)({"aria-current":te&&x||null,className:de,style:ne,to:we},De);return f!==p?Le.ref=u||fe:Le.innerRef=fe,Z.a.createElement(l,Le)})});if(!1)var g},"6xqJ":function(xt,at,se){"use strict";se.r(at);var le=se("+L6B"),Q=se("2/Rp"),_=se("sRBo"),Z=se("kaz8"),B=se("14J3"),P=se("BMrR"),z=se("jCWc"),W=se("kPKH"),I=se("giR+"),D=se("fyUT"),y=se("DZo9"),w=se("8z0m"),O=se("0Owb"),k=se("5NDa"),A=se("5rEg"),T=se("sPJy"),h=se("bE4q"),o=se("oBTY"),l=se("k1fw"),d=se("9og8"),C=se("miYZ"),f=se("tsqr"),p=se("y8nQ"),L=se("Vl3Y"),b=se("tJVT"),g=se("WmNS"),c=se.n(g),u=se("q1tI"),a=se.n(u),x=se("Ty5D"),v=se("9kvl"),E=se("55Ip"),N=se("Ot1p"),F=se("XYT7"),K=se("m3rI"),V=se("I98M"),R=se.n(V),M=function(ee){var ae,fe=ee.shixunHomeworks,De=ee.newCourse,Se=ee.globalSetting,Ce=ee.loading,we=ee.dispatch,Te=ee.match,me=Object(x.i)(),he=L.a.useForm(),te=Object(b.a)(he,1),de=te[0],ne=Object(u.useState)({}),Le=Object(b.a)(ne,2),Re=Le[0],xe=Le[1],Oe=Object(u.useState)(!1),Me=Object(b.a)(Oe,2),He=Me[0],We=Me[1],Fe=Object(u.useState)([]),Be=Object(b.a)(Fe,2),tt=Be[0],qe=Be[1],Ze=Object(u.useState)([]),$e=Object(b.a)(Ze,2),ct=$e[0],rt=$e[1],it=fe.commonHomeWorkEditDefaultData,Pe={name:"file",multiple:!0,action:K.a.API_SERVER+"/api/attachments.json",defaultFileList:tt,onChange:function(be){var pe=be.file.status;pe!=="uploading",pe==="done"?f.b.success("".concat(be.file.name," \u6587\u4EF6\u4E0A\u4F20\u6210\u529F")):pe==="error"&&f.b.error("".concat(be.file.name," \u6587\u4EF6\u4E0A\u4F20\u5931\u8D25"))}};Object(u.useEffect)(function(){nt()},[me.topicId]);var st=function(be){return be==null?void 0:be.map(function(pe){return{uid:pe.id,response:{id:pe.id},name:pe.title,status:"done",url:pe.url}})},nt=function(){var ze=Object(d.a)(c.a.mark(function be(){var pe;return c.a.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return re.next=2,we({type:"shixunHomeworks/editCommonHomeWorkDefaultBankData",payload:{id:me.topicId}});case 2:pe=re.sent,pe&&(de.setFieldsValue({name:pe.name}),de.setFieldsValue({description:pe.description}),de.setFieldsValue(Object(l.a)({},pe)),xe(Object(l.a)({},pe)),qe(Object(o.a)(st(pe.attachments))),rt(Object(o.a)(st(pe.reference_attachments))),We(!0));case 4:case"end":return re.stop()}},be)}));return function(){return ze.apply(this,arguments)}}(),Ie=function(){var ze=Object(d.a)(c.a.mark(function be(pe){var ve,re,ie,oe;return c.a.wrap(function(ke){for(;;)switch(ke.prev=ke.next){case 0:return ve=Object(l.a)({},pe),ve.attachment_ids&&(ve.attachment_ids=ve==null||((re=ve.attachment_ids.fileList)===null||re===void 0)?void 0:re.map(function(Ee){return Ee.response.id})),ve.reference_attachment_ids&&(ve.reference_attachment_ids=ve==null||((ie=ve.reference_attachment_ids.fileList)===null||ie===void 0)?void 0:ie.map(function(Ee){return Ee.response.id})),ke.next=5,Object(F.n)(Object(l.a)(Object(l.a)(Object(l.a)({id:me.topicId},Te.params),ve),{},{type:3}));case 5:oe=ke.sent,oe&&v.d.push("/users/".concat(me.username,"/topics/").concat(me.topicId,"/").concat(me.topictype,"/group/detail"));case 7:case"end":return ke.stop()}},be)}));return function(pe){return ze.apply(this,arguments)}}();return a.a.createElement("section",{className:R.a.bg},a.a.createElement("section",{className:"animated fadeIn"},a.a.createElement("aside",{className:"mt10"},a.a.createElement(h.a,{separator:">"},a.a.createElement(h.a.Item,null,a.a.createElement(E.a,{to:"/users/".concat(me.username,"/").concat(me.topictype==="personal"?"topics":"topicbank","/").concat(me.topictype)},me.topictype==="personal"?"\u6211\u7684\u8BFE\u5802\u8D44\u6E90":"\u516C\u5171\u9898\u5E93")),a.a.createElement(h.a.Item,null,a.a.createElement(E.a,{to:"/users/".concat(me.username,"/topics/").concat(me.topicId,"/").concat(me.topictype,"/group/detail")},"\u8BE6\u60C5")),a.a.createElement(h.a.Item,null,"\u7F16\u8F91")))),a.a.createElement("aside",{className:"font24 bold mt20 mb20"},"\u7F16\u8F91\u666E\u901A\u4F5C\u4E1A"),a.a.createElement(L.a,{form:de,className:R.a.formWrap,scrollToFirstError:!0,layout:"vertical",onValuesChange:function(){xe(Object(l.a)({},de.getFieldsValue()))},onFinish:Ie},a.a.createElement("div",{className:R.a.fieldWrap},a.a.createElement(L.a.Item,{name:"name",label:"\u6807\u9898:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6807\u9898"}]},a.a.createElement(A.a,{maxLength:60,suffix:"".concat(((ae=Re.name)===null||ae===void 0?void 0:ae.length)||0,"/60"),placeholder:"\u4F8B\u5982\uFF1A\u4ECEPython\u7A0B\u5E8F\u8BBE\u8BA1-\u5165\u95E8\u7CBE\u901A"}))),a.a.createElement("div",{className:R.a.mdWrap},a.a.createElement(L.a.Item,{name:"description",label:"\u7B80\u4ECB:",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4F5C\u4E1A\u7684\u7B80\u4ECB"},{max:5e3,message:"\u4F5C\u4E1A\u7B80\u4ECB\u6700\u5927\u9650\u52365000\u4E2A\u5B57\u7B26"}]},a.a.createElement(N.a,{watch:!0,defaultValue:it.description})),a.a.createElement("div",null,a.a.createElement(L.a.Item,{name:"attachment_ids"},He&&a.a.createElement(w.a,Object(O.a)({defaultFileList:tt},Pe),a.a.createElement("span",{className:"c-blue"},"\u4E0A\u4F20\u9644\u4EF6")," \uFF08\u5355\u4E2A\u6587\u4EF6150MB\u4EE5\u5185\uFF09"))),a.a.createElement(P.a,{gutter:[20,20]},a.a.createElement(W.a,{flex:"230px"},a.a.createElement(L.a.Item,{name:"min_num",label:"\u5206\u7EC4\u8BBE\u7F6E",rules:[{required:!0,message:"\u8BF7\u586B\u5199\u6BCF\u7EC4\u6700\u5C0F\u4EBA\u6570"}]},a.a.createElement(D.a,{style:{width:200},min:1,placeholder:"\u8BF7\u586B\u5199\u6BCF\u7EC4\u6700\u5C0F\u4EBA\u6570"}))),a.a.createElement(W.a,{flex:"230px"},a.a.createElement(L.a.Item,{name:"max_num",label:a.a.createElement("div",null,"\xA0"),rules:[{required:!0,message:"\u8BF7\u586B\u5199\u6BCF\u7EC4\u6700\u5927\u4EBA\u6570"}]},a.a.createElement(D.a,{style:{width:200},max:10,placeholder:"\u8BF7\u586B\u5199\u6BCF\u7EC4\u6700\u5927\u4EBA\u6570"}))),a.a.createElement(W.a,null,a.a.createElement("div",{className:"mt30"},"\uFF08\u5B66\u751F\u63D0\u4EA4\u4F5C\u54C1\u65F6\u9700\u8981\u5173\u8054\u540C\u7EC4\u6210\u5458\uFF0C\u7EC4\u5185\u6210\u5458\u4F5C\u54C1\u5171\u4EAB\uFF09"))),a.a.createElement(P.a,null,a.a.createElement(W.a,null,a.a.createElement(L.a.Item,{name:"base_on_project",valuePropName:"checked"},a.a.createElement(Z.a,{value:1,defaultChecked:!0},"\u57FA\u4E8E\u9879\u76EE\u5B9E\u65BD")),a.a.createElement("span",{className:"c-light-black"},"\uFF08\u9009\u4E2D\uFF0C\u5219\u5FC5\u987B\u5728\u672C\u5E73\u53F0\u521B\u5EFA\u9879\u76EE\uFF0C\u9879\u76EE\u7BA1\u7406\u5458\u53EF\u4EE5\u63D0\u4EA4\u4F5C\u54C1\uFF1B\u4E0D\u9009\u4E2D\uFF0C\u65E0\u9700\u5728\u5E73\u53F0\u521B\u5EFA\u9879\u76EE\uFF0C\u4EFB\u610F\u5C0F\u7EC4\u6210\u5458\u5747\u53EF\u4EE5\u63D0\u4EA4\u4F5C\u54C1\uFF09")))),a.a.createElement("div",{className:R.a.mdWrap},a.a.createElement(L.a.Item,{name:"reference_answer",label:"\u53C2\u8003\u7B54\u6848:"},a.a.createElement(N.a,{defaultValue:it.reference_answer,watch:!0})),a.a.createElement("div",null,a.a.createElement(L.a.Item,{name:"reference_attachment_ids"},He&&a.a.createElement(w.a,Object(O.a)({},Pe,{defaultFileList:ct}),a.a.createElement("span",{className:"c-blue"},"\u4E0A\u4F20\u9644\u4EF6")," \uFF08\u5355\u4E2A\u6587\u4EF6150MB\u4EE5\u5185\uFF09")))),a.a.createElement("div",{className:R.a.backgroundFa},a.a.createElement("div",{className:"pt40 mb30"},a.a.createElement(L.a.Item,null,a.a.createElement(Q.a,{size:"large",type:"primary",className:"".concat(R.a.button," mr20"),htmlType:"submit"},"\u63D0\u4EA4"),a.a.createElement(Q.a,{size:"large",type:"primary",ghost:!0,className:R.a.button,onClick:function(){return v.d.push("/users/".concat(me.username,"/topics/").concat(me.topicId,"/").concat(me.topictype,"/group/detail"))}},"\u53D6\u6D88"))))))};at.default=Object(v.a)(function($){var ee=$.shixunHomeworks,ae=$.newCourse,fe=$.loading,De=$.globalSetting;return{shixunHomeworks:ee,newCourse:ae,globalSetting:De,loading:fe.effects}})(M)},"7Cbv":function(xt,at,se){"use strict";var le=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Q=new Uint8Array(16);function _(){if(!le)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return le(Q)}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 B(O){return typeof O=="string"&&Z.test(O)}for(var P=B,z=[],W=0;W<256;++W)z.push((W+256).toString(16).substr(1));function I(O){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(z[O[k+0]]+z[O[k+1]]+z[O[k+2]]+z[O[k+3]]+"-"+z[O[k+4]]+z[O[k+5]]+"-"+z[O[k+6]]+z[O[k+7]]+"-"+z[O[k+8]]+z[O[k+9]]+"-"+z[O[k+10]]+z[O[k+11]]+z[O[k+12]]+z[O[k+13]]+z[O[k+14]]+z[O[k+15]]).toLowerCase();if(!P(A))throw TypeError("Stringified UUID is invalid");return A}var D=I;function y(O,k,A){O=O||{};var T=O.random||(O.rng||_)();if(T[6]=T[6]&15|64,T[8]=T[8]&63|128,k){A=A||0;for(var h=0;h<16;++h)k[A+h]=T[h];return k}return D(T)}var w=at.a=y},"7ahc":function(xt,at,se){"use strict";se.d(at,"a",function(){return C});var le=se("k1fw"),Q=se("0Owb"),_=se("+L6B"),Z=se("2/Rp"),B=se("y8nQ"),P=se("Vl3Y"),z=se("tJVT"),W=se("OaEy"),I=se("2fM7"),D=se("q1tI"),y=se.n(D),w=se("VrN/"),O=se.n(w),k=se("p77/"),A=se.n(k),T=se("c5Ni"),h=se.n(T),o=I.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},d={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};at.b=function(f){var p=f.callback,L=f.onCancel,b=Object(D.useState)("python"),g=Object(z.a)(b,2),c=g[0],u=g[1];function a(v){u(d[v][1])}function x(v){p(v)}return y.a.createElement(P.a,Object(Q.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:x}),y.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},y.a.createElement(I.a,{onChange:a},Object.keys(d).map(function(v){return y.a.createElement(o,{key:v,value:v},d[v][0])}))),y.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},y.a.createElement(C,{mode:c})),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(Z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(Z.a,{type:"ghost",onClick:L},"\u53D6\u6D88")))};function C(f){var p=f.value,L=f.onChange,b=f.mode,g=f.options,c=g===void 0?{}:g,u=Object(D.useRef)(),a=Object(D.useState)(),x=Object(z.a)(a,2),v=x[0],E=x[1];return Object(D.useEffect)(function(){if(v){function N(F){var K=F.getValue();L&&L(K)}return v.on("change",N),function(){v.off("change",N)}}},[v,L]),Object(D.useEffect)(function(){v&&v.setOption("mode",b)},[v,b]),Object(D.useEffect)(function(){v&&((p!==v.getValue()||p==="")&&setTimeout(function(){v.setValue(p||" ")},300))},[v,p]),Object(D.useEffect)(function(){if(u.current&&!v){var N=O.a.fromTextArea(u.current,Object(le.a)({mode:b,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));E(N)}},[u.current,v]),y.a.createElement("div",{className:"my-codemirror-container"},y.a.createElement("textarea",{ref:u}))}},"8EBN":function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){"use strict";le.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var Q=0;Q<le.modeInfo.length;Q++){var _=le.modeInfo[Q];_.mimes&&(_.mime=_.mimes[0])}le.findModeByMIME=function(Z){Z=Z.toLowerCase();for(var B=0;B<le.modeInfo.length;B++){var P=le.modeInfo[B];if(P.mime==Z)return P;if(P.mimes){for(var z=0;z<P.mimes.length;z++)if(P.mimes[z]==Z)return P}}if(/\+xml$/.test(Z))return le.findModeByMIME("application/xml");if(/\+json$/.test(Z))return le.findModeByMIME("application/json")},le.findModeByExtension=function(Z){Z=Z.toLowerCase();for(var B=0;B<le.modeInfo.length;B++){var P=le.modeInfo[B];if(P.ext){for(var z=0;z<P.ext.length;z++)if(P.ext[z]==Z)return P}}},le.findModeByFileName=function(Z){for(var B=0;B<le.modeInfo.length;B++){var P=le.modeInfo[B];if(P.file&&P.file.test(Z))return P}var z=Z.lastIndexOf("."),W=z>-1&&Z.substring(z+1,Z.length);if(W)return le.findModeByExtension(W)},le.findModeByName=function(Z){Z=Z.toLowerCase();for(var B=0;B<le.modeInfo.length;B++){var P=le.modeInfo[B];if(P.name.toLowerCase()==Z)return P;if(P.alias){for(var z=0;z<P.alias.length;z++)if(P.alias[z].toLowerCase()==Z)return P}}}})},"8hTe":function(xt,at,se){xt.exports={button:"button___1wy9m"}},"9Bee":function(xt,at,se){"use strict";var le=se("DYRE"),Q=se("zeV3"),_=se("+L6B"),Z=se("2/Rp"),B=se("k1fw"),P=se("9og8"),z=se("tJVT"),W=se("WmNS"),I=se.n(W),D=se("q1tI"),y=se.n(D),w=se("vg9a"),O=se("DlQD"),k=se.n(O),A=se("rUJ1");function T(G,s){var m=G.match(/^(\s+)(?:```)/);if(m===null)return s;var j=m[1];return s.split(`
`).map(function(X){var H=X.match(/^\s+/);if(H===null)return X;var ye=Object(z.a)(H,1),je=ye[0];return je.length>=j.length?X.slice(j.length):X}).join(`
`)}var h=[],o=["<ul>"],l=new k.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function C(){h.length=0,o=["<ul>"]}var f={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function p(G,s,m,j){if(s>=G.length||G[s].level<=m)return s;var X=G[s];j.push("<li><a href='#"+X.anchor+"'>"+X.text+"</a>"),s++;var H=[];return s=p(G,s,X.level,H),H.length>0&&(j.push("<ul>"),H.forEach(function(ye){j.push(ye)}),j.push("</ul>")),j.push("</li>"),s=p(G,s,m,j),s}function L(){return p(h,0,0,o),o.push("</ul>"),o.join("")}var b={heading:function(s){var m=d.exec(s);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(s){var m=this.rules.block.fences.exec(s);if(m){var j=m[0],X=T(j,m[3]||""),H=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(H)>=0){var ye=u(),je=X;X=ye,a[ye]={type:"block",expression:je}}return{type:"code",raw:j,lang:H,text:X}}}},g=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,u=function(){return"__special_katext_id_".concat(c++,"__")},a={};function x(){return a}function v(){c=0,a={}}function E(G){return G=G.replace(g,function(s,m){var j=u();return a[j]={type:"inline",expression:m},j}),G}var N=l.listitem;l.listitem=function(G){return N(E(G))};var F=l.paragraph;l.paragraph=function(G){return F(E(G))};var K=l.tablecell;l.tablecell=function(G,s){return K(E(G),s)},l.code=function(G,s,m){var j=(s||"").match(/\S*/)[0];return j?["latex","katex","math"].indexOf(j)>=0?"<p class='editormd-tex'>".concat(G,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(m?G:Object(A.escape)(G,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(m?G:Object(A.escape)(G,!0))+"</code></pre>"},l.heading=function(G,s,m){var j=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:j,level:s,text:G}),"<h"+s+' id="'+j+'">'+G+"</h"+s+">"},k.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),k.a.use({tokenizer:b,renderer:l});var V=k.a,R=se("SJMd"),M=se("ulZh"),$=se.n(M),ee=se("m3rI"),ae=se("Oy/b"),fe=se("p5ED"),De=se("ErOA");/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Se=function(G,s){return(Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,j){m.__proto__=j}||function(m,j){for(var X in j)Object.prototype.hasOwnProperty.call(j,X)&&(m[X]=j[X])})(G,s)};function Ce(G,s){function m(){this.constructor=G}Se(G,s),G.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function we(G,s,m,j){return new(m||(m=Promise))(function(X,H){function ye(ut){try{Ye(j.next(ut))}catch(Ge){H(Ge)}}function je(ut){try{Ye(j.throw(ut))}catch(Ge){H(Ge)}}function Ye(ut){var Ge;ut.done?X(ut.value):(Ge=ut.value,Ge instanceof m?Ge:new m(function(Et){Et(Ge)})).then(ye,je)}Ye((j=j.apply(G,s||[])).next())})}function Te(G,s){var m,j,X,H,ye={label:0,sent:function(){if(1&X[0])throw X[1];return X[1]},trys:[],ops:[]};return H={next:je(0),throw:je(1),return:je(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function je(Ye){return function(ut){return function(Ge){if(m)throw new TypeError("Generator is already executing.");for(;ye;)try{if(m=1,j&&(X=2&Ge[0]?j.return:Ge[0]?j.throw||((X=j.return)&&X.call(j),0):j.next)&&!(X=X.call(j,Ge[1])).done)return X;switch(j=0,X&&(Ge=[2&Ge[0],X.value]),Ge[0]){case 0:case 1:X=Ge;break;case 4:return ye.label++,{value:Ge[1],done:!1};case 5:ye.label++,j=Ge[1],Ge=[0];continue;case 7:Ge=ye.ops.pop(),ye.trys.pop();continue;default:if(!(X=ye.trys,(X=X.length>0&&X[X.length-1])||Ge[0]!==6&&Ge[0]!==2)){ye=0;continue}if(Ge[0]===3&&(!X||Ge[1]>X[0]&&Ge[1]<X[3])){ye.label=Ge[1];break}if(Ge[0]===6&&ye.label<X[1]){ye.label=X[1],X=Ge;break}if(X&&ye.label<X[2]){ye.label=X[2],ye.ops.push(Ge);break}X[2]&&ye.ops.pop(),ye.trys.pop();continue}Ge=s.call(G,ye)}catch(Et){Ge=[6,Et],j=0}finally{m=X=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([Ye,ut])}}}function me(){for(var G=0,s=0,m=arguments.length;s<m;s++)G+=arguments[s].length;var j=Array(G),X=0;for(s=0;s<m;s++)for(var H=arguments[s],ye=0,je=H.length;ye<je;ye++,X++)j[X]=H[ye];return j}var he=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,m){for(var j=0,X=m;j<X.length;j++){var H=X[j],ye=H[0],je=H[1];s.setAttribute(ye,je)}},G.createRect=function(s,m,j){var X=document.createElementNS("http://www.w3.org/2000/svg","rect");return X.setAttribute("width",s.toString()),X.setAttribute("height",m.toString()),j&&G.setAttributes(X,j),X},G.createLine=function(s,m,j,X,H){var ye=document.createElementNS("http://www.w3.org/2000/svg","line");return ye.setAttribute("x1",s.toString()),ye.setAttribute("y1",m.toString()),ye.setAttribute("x2",j.toString()),ye.setAttribute("y2",X.toString()),H&&G.setAttributes(ye,H),ye},G.createPolygon=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","polygon");return j.setAttribute("points",s),m&&G.setAttributes(j,m),j},G.createCircle=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","circle");return j.setAttribute("cx",(s/2).toString()),j.setAttribute("cy",(s/2).toString()),j.setAttribute("r",s.toString()),m&&G.setAttributes(j,m),j},G.createEllipse=function(s,m,j){var X=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return X.setAttribute("cx",(s/2).toString()),X.setAttribute("cy",(m/2).toString()),X.setAttribute("rx",(s/2).toString()),X.setAttribute("ry",(m/2).toString()),j&&G.setAttributes(X,j),X},G.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(m,s),m},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,m,j,X,H,ye,je){var Ye=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Ye,[["id",s],["orient",m],["markerWidth",j.toString()],["markerHeight",X.toString()],["refX",H.toString()],["refY",ye.toString()]]),Ye.appendChild(je),Ye},G.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&G.setAttributes(m,s),m},G.createTSpan=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","tspan");return j.textContent=s,m&&G.setAttributes(j,m),j},G.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(m,s),m},G.createPoint=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return j.x=s,j.y=m,j},G.createPath=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","path");return j.setAttribute("d",s),m&&G.setAttributes(j,m),j},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,m,j){var X=this;return new Promise(function(H){var ye=j!==void 0?j:document.createElement("canvas");s===null&&(X.markersOnly=!0,X.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",m.width.baseVal.valueAsString),je.setAttribute("height",m.height.baseVal.valueAsString),je.setAttribute("viewBox","0 0 "+m.viewBox.baseVal.width.toString()+" "+m.viewBox.baseVal.height.toString()),je.innerHTML=m.innerHTML,X.naturalSize===!0?(je.width.baseVal.value=s.naturalWidth,je.height.baseVal.value=s.naturalHeight):X.width!==void 0&&X.height!==void 0&&(je.width.baseVal.value=X.width,je.height.baseVal.value=X.height),ye.width=je.width.baseVal.value,ye.height=je.height.baseVal.value;var Ye=je.outerHTML,ut=ye.getContext("2d");X.markersOnly!==!0&&ut.drawImage(s,0,0,ye.width,ye.height);var Ge=window.URL,Et=new Image(ye.width,ye.height);Et.setAttribute("crossOrigin","anonymous");var Dt=new Blob([Ye],{type:"image/svg+xml"}),Vt=Ge.createObjectURL(Dt);Et.onload=function(){ut.drawImage(Et,0,0),Ge.revokeObjectURL(Vt);var Ir=ye.toDataURL(X.imageType,X.imageQuality);H(Ir)},Et.src=Vt})},G}(),ne=function(){},Le=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 Re("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new xe("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new xe("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}(),Re=function(G,s){this.selector=G,this.style=s},xe=function(G,s){this.localName=G,this.style=s},Oe=function(){function G(s,m,j,X,H){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=m,this.markerItems=j,this.uiStyleSettings=X,this.styles=H,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 m=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var j=document.createElement("div");j.className=this.toolbarBlockStyleClass.name,j.style.whiteSpace="nowrap",this.uiContainer.appendChild(j),this.addActionButton(j,'<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(j,'<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(j,'<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(j,'<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(j,'<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(j,'<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(j,'<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(j,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(H){var ye=document.createElement("div");ye.className=""+m.toolbarButtonStyleClass.name,ye.setAttribute("data-type-name",H.typeName),ye.innerHTML=H.icon,ye.addEventListener("click",function(){m.markerToolbarButtonClicked(ye,H)}),m.buttons.push(ye),m.markerButtons.push(ye)}),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 X=document.createElement("div");X.className=this.toolbarBlockStyleClass.name,X.style.whiteSpace="nowrap",X.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(X),this.addActionButton(X,'<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(X,'<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 m=0;m<this.markerButtons.length;m++)m<s||m===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[m]):(m===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[m]))}},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(m){m.className=m.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),m.className=m.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),m.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},G.prototype.addActionButton=function(s,m,j){var X=this,H=document.createElement("div");switch(H.className=""+this.toolbarButtonStyleClass.name,H.innerHTML=m,H.setAttribute("data-action",j),H.addEventListener("click",function(){X.actionToolbarButtonClicked(H,j)}),j){case"select":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":H.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":H.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":H.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(H),this.buttons.push(H)},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new xe("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 xe("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new xe("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new xe("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 xe("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new xe("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 xe("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new xe("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},G.prototype.markerToolbarButtonClicked=function(s,m){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(j){return j("marker",m)}),this.markerButtonOverflowBlock.style.display="none"},G.prototype.actionToolbarButtonClicked=function(s,m){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(j){return j("action",m)}),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 m=this.markerButtons.find(function(j){return j.getAttribute("data-type-name")===s});m&&this.setActiveButton(m)},G.prototype.setCurrentMarker=function(s){var m=this;this.currentMarker=s,this.buttons.filter(function(j){return/delete|notes/.test(j.getAttribute("data-action"))}).forEach(function(j){m.currentMarker===void 0?(j.style.fillOpacity="0.4",j.style.pointerEvents="none"):(j.style.fillOpacity="1",j.style.pointerEvents="all")})},G}(),Me=function(){function G(s,m,j,X){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=m,this.uiStyleSettings=j,this.styles=X,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return G.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new xe("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 xe("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var m=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new xe("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new xe("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new xe("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 xe("toolbox-panel-row_colors",`
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new xe("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
padding: `+m+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new xe("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new xe("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},G.prototype.show=function(s){var m;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((m=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},G.prototype.setPanelButtons=function(s){var m,j,X=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((m=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((j=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&j!==void 0?j:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(H){var ye;H.uiStyleSettings=X.uiStyleSettings;var je=document.createElement("div");je.className=X.toolboxButtonStyleClass.name+" "+((ye=X.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ye!==void 0?ye:X.toolboxButtonStyleColorsClass.name),je.innerHTML=H.icon,je.title=H.title,je.addEventListener("click",function(){X.panelButtonClick(H)}),X.panelButtons.push(je),X.buttonRow.appendChild(je)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},G.prototype.panelButtonClick=function(s){var m=this,j=-1;if(s!==this.activePanel){j=this.panels.indexOf(s),this.panelRow.innerHTML="";var X=s.getUi();X.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(X),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){m.displayMode==="inline"?m.panelRow.style.display="none":m.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(H,ye){var je,Ye;H.className=m.toolboxButtonStyleClass.name+" "+(ye===j?""+((je=m.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&je!==void 0?je:m.toolboxActiveButtonStyleColorsClass.name):""+((Ye=m.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ye!==void 0?Ye:m.toolboxButtonStyleColorsClass.name))})},G}(),He=function(G,s){this.title=G,this.icon=s},We=function(G){function s(m,j,X,H){var ye=G.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return ye.colors=[],ye.addTransparent=!1,ye.colorBoxes=[],ye.colors=j,ye.currentColor=X,ye.setCurrentColor=ye.setCurrentColor.bind(ye),ye.getColorBox=ye.getColorBox.bind(ye),ye}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");return j.style.overflow="hidden",j.style.whiteSpace="nowrap",this.colors.forEach(function(X){var H=m.getColorBox(X);j.appendChild(H),m.colorBoxes.push(H)}),j},s.prototype.getColorBox=function(m){var j=this,X=this.uiStyleSettings.toolbarHeight/4,H=this.uiStyleSettings.toolbarHeight-X,ye=document.createElement("div");ye.style.display="inline-block",ye.style.boxSizing="content-box",ye.style.width=H-2+"px",ye.style.height=H-2+"px",ye.style.padding="1px",ye.style.marginRight="2px",ye.style.marginBottom="2px",ye.style.borderWidth="2px",ye.style.borderStyle="solid",ye.style.borderRadius=(H+2)/2+"px",ye.style.borderColor=m===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ye.addEventListener("click",function(){j.setCurrentColor(m,ye)});var je=document.createElement("div");return je.style.display="inline-block",je.style.width=H-2+"px",je.style.height=H-2+"px",je.style.backgroundColor=m,je.style.borderRadius=H/2+"px",m==="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>`),ye.appendChild(je),ye},s.prototype.setCurrentColor=function(m,j){var X=this;this.currentColor=m,this.colorBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(m)},s}(He),Fe=function(){function G(s,m,j){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=m,this.globalSettings=j,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,m){},G.prototype.dblClick=function(s,m){},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,m){},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}(),Be=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}(),tt=function(){function G(){this.GRIP_SIZE=10,this.visual=he.createGroup(),this.visual.appendChild(he.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(he.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}(),qe=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,m){return s.a=m.a,s.b=m.b,s.c=m.c,s.d=m.d,s.e=m.e,s.f=m.f,s},G}(),Ze=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.left=0,H.top=0,H.width=0,H.height=0,H.defaultSize={x:50,y:20},H.offsetX=0,H.offsetY=0,H.rotationAngle=0,H.CB_DISTANCE=10,H._suppressMarkerCreateEvent=!1,H.container.transform.baseVal.appendItem(he.createTransform()),H.setupControlBox(),H}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(m){this._visual=m;var j=he.createTransform();this._visual.transform.baseVal.appendItem(j)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!!G.prototype.ownsTarget.call(this,m)||!!(this.controlGrips.findGripByVisual(m)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(m))},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.state==="new"&&(this.left=m.x,this.top=m.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var X=this.unrotatePoint(m);if(this.manipulationStartX=X.x,this.manipulationStartY=X.y,this.offsetX=X.x-this.left,this.offsetY=X.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(j),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(j)){this.activeGrip=this.rotatorGrip;var H=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=H.x-this.width/2,this.top=H.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ye=this.container.transform.baseVal.getItem(0);ye.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ye,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(m){var j=this.state;G.prototype.pointerUp.call(this,m),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(m),this._state="select",j==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(m){this.visual.style.transform="translate("+m.x+"px, "+m.y+"px)"},s.prototype.manipulate=function(m){var j=this.unrotatePoint(m);this.state==="creating"?this.resize(m):this.state==="move"?(this.left=this.manipulationStartLeft+(j.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(j.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(j):this.state==="rotate"&&this.rotate(m)},s.prototype.resize=function(m){var j=this.manipulationStartLeft,X=this.manipulationStartWidth,H=this.manipulationStartTop,ye=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:j=this.manipulationStartLeft+m.x-this.manipulationStartX,X=this.manipulationStartWidth+this.manipulationStartLeft-j;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:X=this.manipulationStartWidth+m.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:H=this.manipulationStartTop+m.y-this.manipulationStartY,ye=this.manipulationStartHeight+this.manipulationStartTop-H;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ye=this.manipulationStartHeight+m.y-this.manipulationStartY}X>=0?(this.left=j,this.width=X):(this.left=j+X,this.width=-X),ye>=0?(this.top=H,this.height=ye):(this.top=H+ye,this.height=-ye),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(m){if(Math.abs(m.x-this.centerX)>.1){var j=Math.sign(m.x-this.centerX);this.rotationAngle=180*Math.atan((m.y-this.centerY)/(m.x-this.centerX))/Math.PI+90*j,this.applyRotation()}},s.prototype.applyRotation=function(){var m=this.container.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(m,0)},s.prototype.rotatePoint=function(m){if(this.rotationAngle===0)return m;var j=this.container.getCTM(),X=he.createPoint(m.x,m.y);return{x:(X=X.matrixTransform(j)).x,y:X.y}},s.prototype.unrotatePoint=function(m){if(this.rotationAngle===0)return m;var j=this.container.getCTM();j=j.inverse();var X=he.createPoint(m.x,m.y);return{x:(X=X.matrixTransform(j)).x,y:X.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=he.createGroup();var m=he.createTransform();m.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(m),this.container.appendChild(this.controlBox),this.controlRect=he.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=he.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Be,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var m=this.controlBox.transform.baseVal.getItem(0);m.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(m,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var m=new tt;return m.visual.transform.baseVal.appendItem(he.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.controlGrips.topLeft.GRIP_SIZE,j=-m/2,X=j,H=(this.width+this.CB_DISTANCE)/2-m/2,ye=(this.height+this.CB_DISTANCE)/2-m/2,je=this.height+this.CB_DISTANCE-m/2,Ye=this.width+this.CB_DISTANCE-m/2;this.positionGrip(this.controlGrips.topLeft.visual,j,X),this.positionGrip(this.controlGrips.topCenter.visual,H,X),this.positionGrip(this.controlGrips.topRight.visual,Ye,X),this.positionGrip(this.controlGrips.centerLeft.visual,j,ye),this.positionGrip(this.controlGrips.centerRight.visual,Ye,ye),this.positionGrip(this.controlGrips.bottomLeft.visual,j,je),this.positionGrip(this.controlGrips.bottomCenter.visual,H,je),this.positionGrip(this.controlGrips.bottomRight.visual,Ye,je),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,H,X-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(m,j,X){var H=m.transform.baseVal.getItem(0);H.setTranslate(j,X),m.transform.baseVal.replaceItem(H,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:qe.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:qe.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},G.prototype.getState.call(this))},s.prototype.restoreState=function(m){G.prototype.restoreState.call(this,m);var j=m;this.left=j.left,this.top=j.top,this.width=j.width,this.height=j.height,this.rotationAngle=j.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,j.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(qe.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,j.containerTransformMatrix))},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j);var X=this.rotatePoint({x:this.left,y:this.top}),H=this.unrotatePoint({x:X.x*m,y:X.y*j});this.left=H.x,this.top=H.y,this.width=this.width*m,this.height=this.height*j,this.adjustControlBox()},s}(Fe),$e=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.createVisual=H.createVisual.bind(H),H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=he.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){G.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){G.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),he.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){G.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&he.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&he.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&he.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&he.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(m){var j=m;this.fillColor=j.fillColor,this.strokeColor=j.strokeColor,this.strokeWidth=j.strokeWidth,this.strokeDasharray=j.strokeDasharray,this.opacity=j.opacity,this.createVisual(),G.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),this.setSize()},s.title="Rectangle marker",s}(Ze),ct=function(G){function s(m,j,X,H){var ye=G.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ye.widths=[],ye.widthBoxes=[],ye.widths=j,ye.currentWidth=X,ye.setCurrentWidth=ye.setCurrentWidth.bind(ye),ye}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");return j.style.display="flex",j.style.overflow="hidden",j.style.flexGrow="2",this.widths.forEach(function(X){var H=document.createElement("div");H.style.display="flex",H.style.flexGrow="2",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=X===m.currentWidth?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentWidth(X,H)}),j.appendChild(H);var ye=document.createElement("div");ye.innerText=X.toString(),ye.style.marginRight="5px",H.appendChild(ye);var je=document.createElement("div");je.style.minHeight="20px",je.style.flexGrow="2",je.style.display="flex",je.style.alignItems="center";var Ye=document.createElement("hr");Ye.style.minWidth="20px",Ye.style.border="0px",Ye.style.borderTop=X+"px solid "+m.uiStyleSettings.toolboxColor,Ye.style.flexGrow="2",je.appendChild(Ye),H.appendChild(je),m.widthBoxes.push(H)}),j},s.prototype.setCurrentWidth=function(m,j){var X=this;this.currentWidth=m,this.widthBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(He),rt=function(G){function s(m,j,X,H){var ye=G.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return ye.styles=[],ye.styleBoxes=[],ye.styles=j,ye.currentStyle=X,ye.setCurrentStyle=ye.setCurrentStyle.bind(ye),ye}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");return j.style.display="flex",j.style.overflow="hidden",j.style.flexGrow="2",this.styles.forEach(function(X){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/m.styles.length-5+"%",H.style.borderColor=X===m.currentStyle?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentStyle(X,H)}),j.appendChild(H);var ye=document.createElement("div");ye.style.minHeight="20px",ye.style.flexGrow="2",ye.style.overflow="hidden";var je=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+m.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(X!==""?'stroke-dasharray="'+X+'"':"")+` />
</svg>`;ye.innerHTML=je,H.appendChild(ye),m.styleBoxes.push(H)}),j},s.prototype.setCurrentStyle=function(m,j){var X=this;this.currentStyle=m,this.styleBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(He),it=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.strokeColor=X.defaultColor,H.strokeWidth=X.defaultStrokeWidth,H.strokeDasharray=X.defaultStrokeDasharray,H.strokePanel=new We("Line color",X.defaultColorSet,X.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new ct("Line width",X.defaultStrokeWidths,X.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new rt("Line style",X.defaultStrokeDasharrays,X.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}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 m=G.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}($e),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},st=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.x1=0,H.y1=0,H.x2=0,H.y2=0,H.defaultLength=50,H.manipulationStartX=0,H.manipulationStartY=0,H.manipulationStartX1=0,H.manipulationStartY1=0,H.manipulationStartX2=0,H.manipulationStartY2=0,H.setupControlBox(),H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!!G.prototype.ownsTarget.call(this,m)||!(!this.grip1.ownsTarget(m)&&!this.grip2.ownsTarget(m))},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.manipulationStartX=m.x,this.manipulationStartY=m.y,this.state==="new"&&(this.x1=m.x,this.y1=m.y,this.x2=m.x,this.y2=m.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(j)?this.activeGrip=this.grip1:this.grip2.ownsTarget(j)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(m){var j=this.state;G.prototype.pointerUp.call(this,m),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(m),this._state="select",j==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(m){this.state==="creating"?this.resize(m):this.state==="move"?(this.x1=this.manipulationStartX1+m.x-this.manipulationStartX,this.y1=this.manipulationStartY1+m.y-this.manipulationStartY,this.x2=this.manipulationStartX2+m.x-this.manipulationStartX,this.y2=this.manipulationStartY2+m.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(m)},s.prototype.resize=function(m){switch(this.activeGrip){case this.grip1:this.x1=m.x,this.y1=m.y;break;case this.grip2:case void 0:this.x2=m.x,this.y2=m.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){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=he.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var m=new tt;return m.visual.transform.baseVal.appendItem(he.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-m/2,this.y1-m/2),this.positionGrip(this.grip2.visual,this.x2-m/2,this.y2-m/2)},s.prototype.positionGrip=function(m,j,X){var H=m.transform.baseVal.getItem(0);H.setTranslate(j,X),m.transform.baseVal.replaceItem(H,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(m){G.prototype.restoreState.call(this,m);var j=m;this.x1=j.x1,this.y1=j.y1,this.x2=j.x2,this.y2=j.y2},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),this.x1=this.x1*m,this.y1=this.y1*j,this.x2=this.x2*m,this.y2=this.y2*j,this.adjustVisual(),this.adjustControlBox()},s}(Fe),nt=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.strokeColor=X.defaultColor,H.strokeWidth=X.defaultStrokeWidth,H.strokeDasharray=X.defaultStrokeDasharray,H.strokePanel=new We("Line color",X.defaultColorSet,X.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new ct("Line width",X.defaultStrokeWidths,X.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new rt("Line style",X.defaultStrokeDasharrays,X.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorLine&&m!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=he.createGroup(),this.selectorLine=he.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=he.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),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()),he.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),he.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),he.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){G.prototype.restoreState.call(this,m);var j=m;this.strokeColor=j.strokeColor,this.strokeWidth=j.strokeWidth,this.strokeDasharray=j.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(st),Ie=function(G){function s(m,j,X,H){var ye=G.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return ye.fonts=[],ye.fontBoxes=[],ye.fonts=j,ye.currentFont=X,ye.setCurrentFont=ye.setCurrentFont.bind(ye),ye}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");return j.style.overflow="hidden",j.style.flexGrow="2",this.fonts.forEach(function(X){var H=document.createElement("div");H.style.display="inline-block",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/m.fonts.length-5+"%",H.style.borderColor=X===m.currentFont?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentFont(X,H)}),j.appendChild(H);var ye=document.createElement("div");ye.style.display="flex",ye.style.minHeight="20px",ye.style.flexGrow="2",ye.style.fontFamily=X,ye.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",ye.appendChild(je),H.appendChild(ye),m.fontBoxes.push(H)}),j},s.prototype.setCurrentFont=function(m,j){var X=this;this.currentFont=m,this.fontBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(He),ze=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.color="transparent",H.padding=5,H.DEFAULT_TEXT="your text here",H.text=H.DEFAULT_TEXT,H.isMoved=!1,H.color=X.defaultColor,H.fontFamily=X.defaultFontFamily,H.defaultSize={x:100,y:30},H.setColor=H.setColor.bind(H),H.setFont=H.setFont.bind(H),H.renderText=H.renderText.bind(H),H.sizeText=H.sizeText.bind(H),H.textEditDivClicked=H.textEditDivClicked.bind(H),H.showTextEditor=H.showTextEditor.bind(H),H.setSize=H.setSize.bind(H),H.positionTextEditor=H.positionTextEditor.bind(H),H.colorPanel=new We("Color",X.defaultColorSet,X.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.fontFamilyPanel=new Ie("Font",X.defaultFontFamilies,X.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H}return Ce(s,G),s.prototype.ownsTarget=function(m){if(G.prototype.ownsTarget.call(this,m)||m===this.visual||m===this.textElement||m===this.bgRectangle)return!0;var j=!1;return this.textElement.childNodes.forEach(function(X){X===m&&(j=!0)}),j},s.prototype.createVisual=function(){this.visual=he.createGroup(),this.bgRectangle=he.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=he.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(he.createTransform()),this.textElement.transform.baseVal.appendItem(he.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.isMoved=!1,this.pointerDownPoint=m,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.renderText=function(){var m=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(j){m.textElement.appendChild(he.createTSpan(j.trim()===""?" ":j.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var m=this.textElement.getBBox(),j=1;if(m.width>0&&m.height>0){var X=(1*this.width-this.width*this.padding*2/100)/m.width,H=(1*this.height-this.height*this.padding*2/100)/m.height;j=Math.min(X,H)}return j},s.prototype.getTextPosition=function(m){var j=this.textElement.getBBox(),X=0,H=0;return j.width>0&&j.height>0&&(X=(this.width-j.width*m)/2,H=this.height/2-j.height*m/2),{x:X,y:H}},s.prototype.sizeText=function(){var m=this.textElement.getBBox(),j=this.getTextScale(),X=this.getTextPosition(j);X.y-=m.y*j,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+X.x+"px, "+X.y+"px) scale("+j+", "+j+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(X.x,X.y),this.textElement.transform.baseVal.getItem(1).setScale(j,j))},s.prototype.manipulate=function(m){G.prototype.manipulate.call(this,m),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(m.x-this.pointerDownPoint.x)>5||Math.abs(m.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(m){G.prototype.resize.call(this,m),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){G.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(he.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),he.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(m){var j=this.state;j==="creating"&&(this._suppressMarkerCreateEvent=!0),G.prototype.pointerUp.call(this,m),this.setSize(),(j==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var m=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(j){j.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var j=Number.parseFloat(m.textEditor.style.fontSize);m.textEditor.clientWidth>=Number.parseInt(m.textEditor.style.maxWidth)&&j>.9;)j-=.1,m.textEditor.style.fontSize=Math.max(j,.9)+"em"}),this.textEditor.addEventListener("keyup",function(j){j.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(j){if(j.clipboardData){var X=j.clipboardData.getData("text"),H=window.getSelection();if(!H.rangeCount)return!1;H.deleteFromDocument(),H.getRangeAt(0).insertNode(document.createTextNode(X)),j.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){m.textEditDivClicked(m.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var m=this.getTextScale(),j=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),X=this.textElement.getBBox(),H={x:X.width*m,y:X.height*m};j.x-=H.x/2,j.y-=H.y/2,this.textEditor.style.top=j.y+"px",this.textEditor.style.left=j.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-j.x+"px",this.textEditor.style.fontSize=Math.max(16*m,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(m){this.text=m.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){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(m,j){G.prototype.dblClick.call(this,m,j),this.showTextEditor()},s.prototype.setColor=function(m){this.textElement&&he.setAttributes(this.textElement,[["fill",m]]),this.color=m,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(m)},s.prototype.setFont=function(m){this.textElement&&he.setAttributes(this.textElement,[["font-family",m]]),this.fontFamily=m,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var j=m;this.color=j.color,this.fontFamily=j.fontFamily,this.padding=j.padding,this.text=j.text,this.createVisual(),G.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),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}(Ze),be=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.color="transparent",H.lineWidth=3,H.drawing=!1,H.pixelRatio=1,H.color=X.defaultColor,H.lineWidth=X.defaultStrokeWidth,H.pixelRatio=X.freehandPixelRatio,H.setColor=H.setColor.bind(H),H.addCanvas=H.addCanvas.bind(H),H.finishCreation=H.finishCreation.bind(H),H.setLineWidth=H.setLineWidth.bind(H),H.colorPanel=new We("Color",X.defaultColorSet,X.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.lineWidthPanel=new ct("Line width",X.defaultStrokeWidths,X.defaultStrokeWidth),H.lineWidthPanel.onWidthChanged=H.setLineWidth,H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=he.createGroup(),this.drawingImage=he.createImage(),this.visual.appendChild(this.drawingImage);var m=he.createTransform();this.visual.transform.baseVal.appendItem(m),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,j){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(m.x,m.y),this.drawing=!0):G.prototype.pointerDown.call(this,m,j)},s.prototype.manipulate=function(m){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(m.x,m.y),this.canvasContext.stroke()):G.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){G.prototype.resize.call(this,m),he.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),he.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):G.prototype.pointerUp.call(this,m)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),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 m=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),j=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],X=j[0],H=j[1],ye=j[2],je=j[3],Ye=!1,ut=0;ut<this.canvasElement.height;ut++)for(var Ge=0;Ge<this.canvasElement.width;Ge++)m.data[ut*this.canvasElement.width*4+4*Ge+3]>0&&(Ye=!0,ut<H&&(H=ut),Ge<X&&(X=Ge),ut>je&&(je=ut),Ge>ye&&(ye=Ge));if(Ye){this.left=X/this.pixelRatio,this.top=H/this.pixelRatio,this.width=(ye-X)/this.pixelRatio,this.height=(je-H)/this.pixelRatio;var Et=document.createElement("canvas");Et.width=ye-X,Et.height=je-H,Et.getContext("2d").putImageData(this.canvasContext.getImageData(X,H,ye-X,je-H),0,0),this.drawingImgUrl=Et.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){he.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),he.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(m){this.color=m,this.colorChanged(m)},s.prototype.setLineWidth=function(m){this.lineWidth=m},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({drawingImgUrl:this.drawingImgUrl},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){this.createVisual(),G.prototype.restoreState.call(this,m),this.drawingImgUrl=m.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),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}(Ze),pe=function(G){function s(m,j,X){var H=G.call(this,m,X||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return H.typeBoxes=[],H.currentType=j,H.setCurrentType=H.setCurrentType.bind(H),H}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");j.style.display="flex",j.style.overflow="hidden",j.style.flexGrow="2";for(var X=function(je){var Ye="both";switch(je){case 0:Ye="both";break;case 1:Ye="start";break;case 2:Ye="end";break;case 3:Ye="none"}var ut=document.createElement("div");if(ut.style.display="flex",ut.style.flexGrow="2",ut.style.alignItems="center",ut.style.justifyContent="space-between",ut.style.padding="5px",ut.style.borderWidth="2px",ut.style.borderStyle="solid",ut.style.borderColor=Ye===H.currentType?H.uiStyleSettings.toolboxAccentColor:"transparent",ut.addEventListener("click",function(){m.setCurrentType(Ye,ut)}),j.appendChild(ut),Ye==="both"||Ye==="start"){var Ge=document.createElement("div");Ge.style.display="flex",Ge.style.alignItems="center",Ge.style.minHeight="20px",Ge.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,5 10,0 10,10" fill="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Ge.style.marginLeft="5px",ut.appendChild(Ge)}var Et=document.createElement("div");Et.style.display="flex",Et.style.alignItems="center",Et.style.minHeight="20px",Et.style.flexGrow="2";var Dt=document.createElement("hr");if(Dt.style.minWidth="20px",Dt.style.border="0px",Dt.style.borderTop="3px solid "+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee"),Dt.style.flexGrow="2",Et.appendChild(Dt),ut.appendChild(Et),Ye==="both"||Ye==="end"){var Vt=document.createElement("div");Vt.style.display="flex",Vt.style.alignItems="center",Vt.style.minHeight="20px",Vt.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 10,5 0,10" fill="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Vt.style.marginRight="5px",ut.appendChild(Vt)}H.typeBoxes.push(ut)},H=this,ye=0;ye<4;ye++)X(ye);return j},s.prototype.setCurrentType=function(m,j){var X=this;this.currentType=m,this.typeBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings!==void 0?X.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(He),ve=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.arrowType="end",H.arrowBaseHeight=10,H.arrowBaseWidth=10,H.getArrowPoints=H.getArrowPoints.bind(H),H.setArrowType=H.setArrowType.bind(H),H.arrowTypePanel=new pe("Arrow type","end"),H.arrowTypePanel.onArrowTypeChanged=H.setArrowType,H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.arrow1&&m!==this.arrow2)},s.prototype.getArrowPoints=function(m,j){var X=this.arrowBaseWidth+2*this.strokeWidth,H=this.arrowBaseHeight+2*this.strokeWidth;return m-X/2+","+(j+H/2)+" "+m+","+(j-H/2)+" "+(m+X/2)+","+(j+H/2)},s.prototype.createTips=function(){this.arrow1=he.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(he.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=he.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(he.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),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",he.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),he.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),j=this.arrow1.transform.baseVal.getItem(0);j.setRotate(m,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(j,0);var X=this.arrow2.transform.baseVal.getItem(0);X.setRotate(m+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(X,0)}},s.prototype.setArrowType=function(m){this.arrowType=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({arrowType:this.arrowType},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){G.prototype.restoreState.call(this,m);var j=m;this.arrowType=j.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(nt),re=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.fillColor=X.defaultFillColor,H.strokeWidth=0,H.fillPanel=new We("Color",X.defaultColorSet,X.defaultFillColor),H.fillPanel.onColorChanged=H.setFillColor,H}return Ce(s,G),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=G.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}($e),ie=function(G){function s(m,j,X,H){var ye=G.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return ye.opacities=[],ye.opacityBoxes=[],ye.opacities=j,ye.currentOpacity=X,ye.setCurrentOpacity=ye.setCurrentOpacity.bind(ye),ye}return Ce(s,G),s.prototype.getUi=function(){var m=this,j=document.createElement("div");return j.style.display="flex",j.style.overflow="hidden",j.style.flexGrow="2",j.style.justifyContent="space-between",this.opacities.forEach(function(X){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="center",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=X===m.currentOpacity?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentOpacity(X,H)}),j.appendChild(H);var ye=document.createElement("div");ye.innerText=100*X+"%",H.appendChild(ye),m.opacityBoxes.push(H)}),j},s.prototype.setCurrentOpacity=function(m,j){var X=this;this.currentOpacity=m,this.opacityBoxes.forEach(function(H){H.style.borderColor=H===j?X.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(He),oe=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.setOpacity=H.setOpacity.bind(H),H.fillColor=X.defaultHighlightColor,H.strokeWidth=0,H.opacity=X.defaultHighlightOpacity,H.fillPanel=new We("Color",X.defaultColorSet,H.fillColor),H.fillPanel.onColorChanged=H.setFillColor,H.opacityPanel=new ie("Opacity",X.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Ce(s,G),s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&he.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=G.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',s}(re),ue='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',ke=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.bgColor="transparent",H.tipPosition={x:0,y:0},H.tipBase1Position={x:0,y:0},H.tipBase2Position={x:0,y:0},H.tipMoving=!1,H.color=X.defaultStrokeColor,H.bgColor=X.defaultFillColor,H.fontFamily=X.defaultFontFamily,H.defaultSize={x:100,y:30},H.setBgColor=H.setBgColor.bind(H),H.getTipPoints=H.getTipPoints.bind(H),H.positionTip=H.positionTip.bind(H),H.setTipPoints=H.setTipPoints.bind(H),H.colorPanel=new We("Text color",X.defaultColorSet,H.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),H.colorPanel.onColorChanged=H.setColor,H.bgColorPanel=new We("Fill color",X.defaultColorSet,H.bgColor,ue),H.bgColorPanel.onColorChanged=H.setBgColor,H.fontFamilyPanel=new Ie("Font",X.defaultFontFamilies,X.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H.tipGrip=new tt,H.tipGrip.visual.transform.baseVal.appendItem(he.createTransform()),H.controlBox.appendChild(H.tipGrip.visual),H}return Ce(s,G),s.prototype.ownsTarget=function(m){return G.prototype.ownsTarget.call(this,m)||this.tipGrip.ownsTarget(m)||this.tip===m},s.prototype.createTip=function(){he.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=he.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(m,j){this.state==="new"&&G.prototype.pointerDown.call(this,m,j),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(j)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):G.prototype.pointerDown.call(this,m,j)},s.prototype.pointerUp=function(m){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,G.prototype.pointerUp.call(this,m);else{var j=this.state==="creating";G.prototype.pointerUp.call(this,m),this.setTipPoints(j),this.positionTip()}},s.prototype.manipulate=function(m){if(this.tipMoving){var j=this.unrotatePoint(m);this.tipPosition={x:j.x-this.manipulationStartLeft,y:j.y-this.manipulationStartTop},this.positionTip()}else G.prototype.manipulate.call(this,m)},s.prototype.setBgColor=function(m){this.bgRectangle&&this.tip&&(he.setAttributes(this.bgRectangle,[["fill",m]]),he.setAttributes(this.tip,[["fill",m]])),this.bgColor=m,this.fillColorChanged(m)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(m){m===void 0&&(m=!1);var j=Math.min(this.height/2,15),X=this.height/5;m&&(this.tipPosition={x:j+X/2,y:this.height+20});var H=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(X=this.width/5,j=Math.min(this.width/2,15),this.tipBase1Position={x:j,y:0},this.tipBase2Position={x:j+X,y:0}):(this.tipBase1Position={x:0,y:j},this.tipBase2Position={x:0,y:j+X}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(X=this.width/5,j=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-j-X,y:0},this.tipBase2Position={x:this.width-j,y:0}):(this.tipBase1Position={x:this.width,y:j},this.tipBase2Position={x:this.width,y:j+X}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?H<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(X=this.width/5,j=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-j-X,y:this.height},this.tipBase2Position={x:this.width-j,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-j-X},this.tipBase2Position={x:this.width,y:this.height-j}):H<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(X=this.width/5,j=Math.min(this.width/2,15),this.tipBase1Position={x:j,y:this.height},this.tipBase2Position={x:j+X,y:this.height}):(this.tipBase1Position={x:0,y:this.height-j},this.tipBase2Position={x:0,y:this.height-j-X})},s.prototype.resize=function(m){G.prototype.resize.call(this,m),this.positionTip()},s.prototype.positionTip=function(){he.setAttributes(this.tip,[["points",this.getTipPoints()]]);var m=this.tipGrip.visual.transform.baseVal.getItem(0);m.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(m,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),G.prototype.select.call(this)},s.prototype.getState=function(){var m=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var j=m;this.bgColor=j.bgColor,this.tipPosition=j.tipPosition,G.prototype.restoreState.call(this,m),this.createTip(),this.setTipPoints()},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),this.tipPosition={x:this.tipPosition.x*m,y:this.tipPosition.y*j},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}(ze),Ee=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.strokeColor=X.defaultColor,H.strokeWidth=X.defaultStrokeWidth,H.strokeDasharray=X.defaultStrokeDasharray,H.fillColor=X.defaultFillColor,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.setOpacity=H.setOpacity.bind(H),H.createVisual=H.createVisual.bind(H),H.strokePanel=new We("Line color",me(X.defaultColorSet,["transparent"]),X.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.fillPanel=new We("Fill color",me(X.defaultColorSet,["transparent"]),H.fillColor,ue),H.fillPanel.onColorChanged=H.setFillColor,H.strokeWidthPanel=new ct("Line width",X.defaultStrokeWidths,X.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new rt("Line style",X.defaultStrokeDasharrays,X.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H.opacityPanel=new ie("Opacity",X.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=he.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){G.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){G.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){G.prototype.setSize.call(this),he.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(m){G.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&he.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&he.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(m),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&he.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&he.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&he.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var j=m;this.fillColor=j.fillColor,this.strokeColor=j.strokeColor,this.strokeWidth=j.strokeWidth,this.strokeDasharray=j.strokeDasharray,this.opacity=j.opacity,this.createVisual(),G.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,j){G.prototype.scale.call(this,m,j),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}(Ze),Ue=function(G){function s(m,j,X){return G.call(this,m,j,X)||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(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.tip1&&m!==this.tip2)},s.prototype.createTips=function(){this.tip1=he.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(he.createTransform()),this.visual.appendChild(this.tip1),this.tip2=he.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(he.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(G.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(he.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()]]),he.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),j=this.tip1.transform.baseVal.getItem(0);j.setRotate(m,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(j,0);var X=this.tip2.transform.baseVal.getItem(0);X.setRotate(m+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(X,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=G.prototype.getState.call(this);return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){G.prototype.restoreState.call(this,m),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',s}(nt),et=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.strokePanel.colors=X.defaultColorSet,H.fillColor="transparent",H}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 m=G.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Ee),ft=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}(),lt=function(G){function s(m,j,X){var H=G.call(this,m,j,X)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.curveX=0,H.curveY=0,H.manipulationStartCurveX=0,H.manipulationStartCurveY=0,H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.positionGrips=H.positionGrips.bind(H),H.addControlGrips=H.addControlGrips.bind(H),H.adjustVisual=H.adjustVisual.bind(H),H.setupControlBox=H.setupControlBox.bind(H),H.resize=H.resize.bind(H),H.strokeColor=X.defaultColor,H.strokeWidth=X.defaultStrokeWidth,H.strokeDasharray=X.defaultStrokeDasharray,H.strokePanel=new We("Line color",X.defaultColorSet,X.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new ct("Line width",X.defaultStrokeWidths,X.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new rt("Line style",X.defaultStrokeDasharrays,X.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Ce(s,G),s.prototype.ownsTarget=function(m){return!(!G.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorCurve&&m!==this.visibleCurve&&!this.curveGrip.ownsTarget(m))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=he.createGroup(),this.selectorCurve=he.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=he.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,j){G.prototype.pointerDown.call(this,m,j),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=m.x,this.curveY=m.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(j)&&(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()),he.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),he.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),he.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){G.prototype.setupControlBox.call(this),this.curveControlLine1=he.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=he.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 m=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-m/2,this.curveY-m/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},s.prototype.manipulate=function(m){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+m.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+m.y-this.manipulationStartY),G.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){this.activeGrip===this.curveGrip&&(this.curveX=m.x,this.curveY=m.y),G.prototype.resize.call(this,m),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual()},s.prototype.scale=function(m,j){this.curveX=this.curveX*m,this.curveY=this.curveY*j,G.prototype.scale.call(this,m,j)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},G.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){G.prototype.restoreState.call(this,m);var j=m;this.strokeColor=j.strokeColor,this.strokeWidth=j.strokeWidth,this.strokeDasharray=j.strokeDasharray,this.curveX=j.curveX,this.curveY=j.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',s}(st),wt=function(){function G(s,m){m===void 0&&(m=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=m}return Object.defineProperty(G.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),G.prototype.preventDefault=function(){this._defaultPrevented=!0},G}(),St=function(G){function s(m,j,X){var H=G.call(this,m,!1)||this;return H.dataUrl=j,H.state=X,H}return Ce(s,G),s}(wt),dt=function(G){function s(m,j,X){X===void 0&&(X=!1);var H=G.call(this,m,X)||this;return H.marker=j,H}return Ce(s,G),s}(wt),zt=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,m){this[s].push(m)},G.prototype.removeEventListener=function(s,m){var j=this[s].indexOf(m);j>-1&&this[s].splice(j,1)},G}(),It=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 ft,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 zt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=G.instanceCounter++,this.styles=new Le(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[it,be,ve,ze,et,Ee,oe,ke,Ue,re,nt,lt]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[it,be,ve,ze,Ee,oe,ke]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"BASIC_MARKER_TYPES",{get:function(){return[it,be,ve,ze,oe]},enumerable:!1,configurable:!0}),Object.defineProperty(G.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var m=this;this._availableMarkerTypes.splice(0),s.forEach(function(j){if(typeof j=="string"){var X=m.ALL_MARKER_TYPES.find(function(H){return H.typeName===j});X!==void 0&&m._availableMarkerTypes.push(X)}else m._availableMarkerTypes.push(j)})},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(m){return m(new wt(s))})},G.prototype.render=function(){return we(this,void 0,void 0,function(){var s;return Te(this,function(m){switch(m.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 m.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,m.sent()]}})})},G.prototype.close=function(s){var m=this;if(s===void 0&&(s=!1),this.isOpen){var j=!1;s||this.eventListeners.beforeclose.forEach(function(X){var H=new wt(m,!0);X(H),H.defaultPrevented&&(j=!0)}),j||(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(X){return X(new wt(m))}),this.detachEvents(),this._isOpen=!1)}},G.prototype.addMarkersToToolbar=function(){for(var s,m=[],j=0;j<arguments.length;j++)m[j]=arguments[j];(s=this._availableMarkerTypes).push.apply(s,m)},G.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(m){s(m.dataUrl,m.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,m=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,j=m<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(m,j)},G.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},G.prototype.resize=function(s,m){this._isResizing=!0;var j=s/this.imageWidth,X=m/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(j,X),this._isResizing=!1},G.prototype.scaleMarkers=function(s,m){var j,X=this;this._currentMarker&&this._currentMarker instanceof ze?this._currentMarker.scale(s,m):(j=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(H){H!==X._currentMarker&&H.scale(s,m)}),j!==void 0&&this.setCurrentMarker(j)},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(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left,this.top=s.top-m.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,m=[],j=0;j<arguments.length;j++)m[j]=arguments[j];this.defs=he.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,m)},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 Oe(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 Me(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,m){if(s==="marker"&&m!==void 0)this.createNewMarker(m);else if(s==="action")switch(m){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},G.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var m=!1;if(this.eventListeners.markerbeforedelete.forEach(function(X){var H=new dt(s,s._currentMarker,!0);X(H),H.defaultPrevented&&(m=!0)}),!m){var j=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(X){return X(new dt(s,j))})}}},G.prototype.clear=function(){var s=this,m=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ye){var je=new dt(s,void 0,!0);ye(je),je.defaultPrevented&&(m=!0)}),!m)){this.setCurrentMarker();for(var j=function(ye){var je=X.markers[ye];X.setCurrentMarker(X.markers[ye]),X._currentMarker.dispose(),X.markerImage.removeChild(X._currentMarker.container),X.markers.splice(X.markers.indexOf(X._currentMarker),1),X.eventListeners.markerdelete.forEach(function(Ye){return Ye(new dt(s,je))})},X=this,H=this.markers.length-1;H>=0;H--)j(H);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 m=this.getState(),j=this.undoRedoManager.getLastUndoStep();if(!j||j.width===m.width&&j.height===m.height){var X=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(m),X<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}else this.undoRedoManager.replaceLastUndoStep(m),this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}},G.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},G.prototype.undoStep=function(){var s=this,m=this.undoRedoManager.undo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(j){return j(new wt(s))}))},G.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},G.prototype.redoStep=function(){var s=this,m=this.undoRedoManager.redo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(j){return j(new wt(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 we(this,void 0,void 0,function(){var s,m,j=this;return Te(this,function(X){switch(X.label){case 0:return[4,this.render()];case 1:return s=X.sent(),m=this.getState(),this.eventListeners.render.forEach(function(H){return H(new St(j,s,m))}),this.close(!0),[2]}})})},G.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var m={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(j){return m.markers.push(j.getState())}),m},G.prototype.restoreState=function(s){var m=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(j){var X=m._availableMarkerTypes.find(function(ye){return ye.typeName===j.typeName});if(X!==void 0){var H=m.addNewMarker(X);H.restoreState(j),m.markers.push(H)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(j){return j(new wt(m))})},G.prototype.addNewMarker=function(s){var m=he.createGroup();return this.markerImage.appendChild(m),new s(m,this.overlayContainer,this.settings)},G.prototype.createNewMarker=function(s){var m,j=this;(m=typeof s=="string"?this._availableMarkerTypes.find(function(X){return X.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(m),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(m.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(X){return X(new dt(j,j._currentMarker))}))},G.prototype.markerCreated=function(s){var m=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof be&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(be):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(j){return j(new dt(m,m._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 m=this;this.eventListeners.markerchange.forEach(function(j){return j(new dt(m,s))})},G.prototype.setCurrentMarker=function(s){var m=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(j){return j(new dt(m,m._currentMarker))})),this._currentMarker=s,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(j){return j(new dt(m,m._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 m=this.markers.find(function(j){return j.ownsTarget(s.target)});m!==void 0?(this.setCurrentMarker(m),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},G.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var m=this.markers.find(function(j){return j.ownsTarget(s.target)});m!==void 0&&m!==this._currentMarker&&this.setCurrentMarker(m),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},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,m){var j=this.markerImage.getBoundingClientRect();return{x:(s-j.left)/this.zoomLevel,y:(m-j.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,m){this.eventListeners.addEventListener(s,m)},G.prototype.removeEventListener=function(s,m){this.eventListeners.removeEventListener(s,m)},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(m){return m(new wt(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(m){return m(new wt(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 Kt=function(G,s){return(Kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,j){m.__proto__=j}||function(m,j){for(var X in j)Object.prototype.hasOwnProperty.call(j,X)&&(m[X]=j[X])})(G,s)};function Wt(G,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function m(){this.constructor=G}Kt(G,s),G.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Lt(G,s,m,j){return new(m||(m=Promise))(function(X,H){function ye(ut){try{Ye(j.next(ut))}catch(Ge){H(Ge)}}function je(ut){try{Ye(j.throw(ut))}catch(Ge){H(Ge)}}function Ye(ut){var Ge;ut.done?X(ut.value):(Ge=ut.value,Ge instanceof m?Ge:new m(function(Et){Et(Ge)})).then(ye,je)}Ye((j=j.apply(G,s||[])).next())})}function Wr(G,s){var m,j,X,H,ye={label:0,sent:function(){if(1&X[0])throw X[1];return X[1]},trys:[],ops:[]};return H={next:je(0),throw:je(1),return:je(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function je(Ye){return function(ut){return function(Ge){if(m)throw new TypeError("Generator is already executing.");for(;ye;)try{if(m=1,j&&(X=2&Ge[0]?j.return:Ge[0]?j.throw||((X=j.return)&&X.call(j),0):j.next)&&!(X=X.call(j,Ge[1])).done)return X;switch(j=0,X&&(Ge=[2&Ge[0],X.value]),Ge[0]){case 0:case 1:X=Ge;break;case 4:return ye.label++,{value:Ge[1],done:!1};case 5:ye.label++,j=Ge[1],Ge=[0];continue;case 7:Ge=ye.ops.pop(),ye.trys.pop();continue;default:if(!(X=ye.trys,(X=X.length>0&&X[X.length-1])||Ge[0]!==6&&Ge[0]!==2)){ye=0;continue}if(Ge[0]===3&&(!X||Ge[1]>X[0]&&Ge[1]<X[3])){ye.label=Ge[1];break}if(Ge[0]===6&&ye.label<X[1]){ye.label=X[1],X=Ge;break}if(X&&ye.label<X[2]){ye.label=X[2],ye.ops.push(Ge);break}X[2]&&ye.ops.pop(),ye.trys.pop();continue}Ge=s.call(G,ye)}catch(Et){Ge=[6,Et],j=0}finally{m=X=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([Ye,ut])}}}var ai=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}(),vt=function(){function G(){}return G.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},G.setAttributes=function(s,m){for(var j=0,X=m;j<X.length;j++){var H=X[j],ye=H[0],je=H[1];s.setAttribute(ye,je)}},G.createRect=function(s,m,j){var X=document.createElementNS("http://www.w3.org/2000/svg","rect");return X.setAttribute("width",s.toString()),X.setAttribute("height",m.toString()),j&&G.setAttributes(X,j),X},G.createLine=function(s,m,j,X,H){var ye=document.createElementNS("http://www.w3.org/2000/svg","line");return ye.setAttribute("x1",s.toString()),ye.setAttribute("y1",m.toString()),ye.setAttribute("x2",j.toString()),ye.setAttribute("y2",X.toString()),H&&G.setAttributes(ye,H),ye},G.createPolygon=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","polygon");return j.setAttribute("points",s),m&&G.setAttributes(j,m),j},G.createCircle=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","circle");return j.setAttribute("cx",(s/2).toString()),j.setAttribute("cy",(s/2).toString()),j.setAttribute("r",s.toString()),m&&G.setAttributes(j,m),j},G.createEllipse=function(s,m,j){var X=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return X.setAttribute("cx",(s/2).toString()),X.setAttribute("cy",(m/2).toString()),X.setAttribute("rx",(s/2).toString()),X.setAttribute("ry",(m/2).toString()),j&&G.setAttributes(X,j),X},G.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&G.setAttributes(m,s),m},G.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},G.createMarker=function(s,m,j,X,H,ye,je){var Ye=document.createElementNS("http://www.w3.org/2000/svg","marker");return G.setAttributes(Ye,[["id",s],["orient",m],["markerWidth",j.toString()],["markerHeight",X.toString()],["refX",H.toString()],["refY",ye.toString()]]),Ye.appendChild(je),Ye},G.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&G.setAttributes(m,s),m},G.createTSpan=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","tspan");return j.textContent=s,m&&G.setAttributes(j,m),j},G.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&G.setAttributes(m,s),m},G.createPoint=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return j.x=s,j.y=m,j},G.createPath=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg","path");return j.setAttribute("d",s),m&&G.setAttributes(j,m),j},G.createElement=function(s,m){var j=document.createElementNS("http://www.w3.org/2000/svg",s);return m&&G.setAttributes(j,m),j},G.getHollowRectanglePath=function(s,m,j,X,H,ye,je,Ye){return"M"+s+","+m+"V"+(m+X)+"H"+(s+j)+"V"+m+"H"+H+"V"+ye+"H"+(H+je)+"V"+(ye+Ye)+"H"+H+"V"+m+"Z"},G}(),Vr=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 nr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new nr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new nr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new cr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new cr("_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}(),nr=function(G,s){this.selector=G,this.style=s},cr=function(G,s){this.localName=G,this.style=s},Hr=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(m){return s.appendChild(m.getUI())}),s},G}(),oi=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}(),si=function(G){function s(){var m=G!==null&&G.apply(this,arguments)||this;return m.buttons=[],m}return Wt(s,G),s.prototype.addButton=function(m){m.className=this.buttonClassName,m.colorsClassName=this.buttonColorsClassName,m.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(m)},s.prototype.getUI=function(){var m=G.prototype.getUI.call(this);return this.buttons.forEach(function(j){return m.appendChild(j.getUI())}),m},s}(oi),Pt=function(){function G(s,m){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=m,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(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}(),pt=function(G){function s(){var m=G!==null&&G.apply(this,arguments)||this;return m.elements=[],m}return Wt(s,G),s.prototype.addElement=function(m){this.elements.push(m)},s.prototype.getUI=function(){var m=G.prototype.getUI.call(this);return this.elements.forEach(function(j){return m.appendChild(j)}),m},s}(oi),Pr=function(){function G(s,m){this.horizontal=s,this.vertical=m}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}(),li=function(){function G(){}return G.getIcon=function(s,m){if(s>0&&m>0){var j=new Pr(s,m),X=j.ratio>=1?20:j.getHorizontalLength(20),H=j.ratio<1?20:j.getVerticalLength(20),ye=document.createElementNS("http://www.w3.org/2000/svg","svg");ye.setAttribute("xmlns","http://www.w3.org/2000/svg"),ye.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ye);var je=vt.createDefs();ye.appendChild(je);var Ye=vt.createElement("clipPath",[["id","text-bg-clip"]]);je.appendChild(Ye);var ut=vt.createPath(vt.getHollowRectanglePath((24-X)/2,(24-H)/2,X,H,(24-X)/2+2,(24-H)/2+2,X-4,H-4));ye.appendChild(ut);var Ge=vt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ge.appendChild(vt.createTSpan(s+":"+m)),ye.appendChild(Ge);var Et=Ge.getBBox();vt.setAttributes(Ge,[["x",((24-Et.width)/2).toString()],["y",((24-Et.height)/2-Et.y).toString()]]);var Dt=vt.createPath(vt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Et.width))/2,(24-Math.ceil(Et.height))/2,Math.ceil(Et.width),Math.ceil(Et.height)));return Ye.appendChild(Dt),vt.setAttributes(ut,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ye),ye.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}(),xr=function(G){function s(m,j,X){var H=G.call(this,m,j)||this;return H.isDropdownOpen=!1,H.onClick=H.dropdownButtonClicked,H.dropdownButtons=X,H}return Wt(s,G),s.prototype.setupDropdown=function(){var m=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(j){j.className=m.className,j.colorsClassName=m.colorsClassName,m.dropdownBlock.appendChild(j.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}(Pt),kt=function(){function G(s,m){this.GRIP_SIZE=10,this.color=s,this.fillColor=m,this.visual=vt.createGroup(),this.visual.appendChild(vt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(vt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return G.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},G.prototype.setCenter=function(s,m){this.visual.childNodes.forEach(function(j){return vt.setAttributes(j,[["cx",s.toString()],["cy",m.toString()]])})},G}(),Mr=function(){function G(s,m,j,X){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=m,this.margin=j,this.container=X,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&&vt.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=vt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=vt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var m=0;m<this.numberOfGridLines;m++)this.horizontalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(vt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(j){return s.gridContainer.appendChild(j)}),this.verticalGridLines.forEach(function(j){return s.gridContainer.appendChild(j)}),this.cropRectElement=vt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new kt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},G.prototype.setCropRectangle=function(s){this.cropRect=s;var m=Object.assign({},this.cropRect);this.zoomFactor!==1&&(m.width=this.cropRect.width*this.zoomFactor,m.height=this.cropRect.height*this.zoomFactor,m.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-m.width/2,m.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-m.height/2),vt.setAttributes(this.cropRectElement,[["x",m.x.toString()],["y",m.y.toString()],["width",m.width.toString()],["height",m.height.toString()]]);var j=m.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(H,ye){var je=m.y+j*(ye+1);vt.setAttributes(H,[["x1",""+m.x],["y1",""+je],["x2",""+(m.x+m.width)],["y2",""+je]])});var X=m.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(H,ye){var je=m.x+X*(ye+1);vt.setAttributes(H,[["x1",""+je],["y1",""+m.y],["x2",""+je],["y2",""+(m.y+m.height)]])}),vt.setAttributes(this.cropShadeElement,[["d",vt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,m.x,m.y,m.width,m.height)]]),this.topLeftGrip.setCenter(m.x,m.y),this.topRightGrip.setCenter(m.x+m.width,m.y),this.bottomLeftGrip.setCenter(m.x,m.y+m.height),this.bottomRightGrip.setCenter(m.x+m.width,m.y+m.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},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,m){var j=this.container.getBoundingClientRect();return{x:s-j.left+this.margin,y:m-j.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 m=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(m)}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 m=s.x-this.previousPoint.x,j=s.y-this.previousPoint.y;this.zoomFactor!==1&&(m=-m/this.zoomFactor,j=-j/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+m),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+j),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 m=Object.assign({},this.cropRect),j=s.x-this.previousPoint.x,X=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:m.x+j<this.margin&&(j=this.margin-m.x),m.x+=j,m.width=this.cropRect.x+this.cropRect.width-m.x;break;case this.bottomRightGrip:case this.topRightGrip:m.width+j>this.canvasWidth*this.zoomFactor&&(j=this.canvasWidth*this.zoomFactor-m.width),m.width+=j}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(m.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(j),m.height=this.aspectRatio.getVerticalLength(m.width)):(m.y+=X,m.height=this.cropRect.y+this.cropRect.height-m.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?m.height=this.aspectRatio.getVerticalLength(m.width):m.height+=X}m.width<10&&(m.x=this.cropRect.x,m.width=10),m.height<10&&(m.y=this.cropRect.y,m.height=10),this.previousPoint=s,m.x>=this.margin&&m.y>=this.margin&&m.x-this.margin+m.width<=this.canvasWidth&&m.y-this.margin+m.height<=this.canvasHeight&&(this.cropRect=m,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},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,m=this.cropRect.y+this.cropRect.height/2,j=this.aspectRatio.getHorizontalLength(this.cropRect.height),X=this.aspectRatio.getVerticalLength(this.cropRect.width);j/this.canvasWidth<X/this.canvasHeight?this.cropRect.width=j:this.cropRect.height=X,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=m-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},G.prototype.getRescaledRect=function(s,m,j,X,H,ye){var je=j/s,Ye=X/m;return{x:(H.x-ye)*je+ye,y:(H.y-ye)*Ye+ye,width:H.width*je,height:H.height*Ye}},G.prototype.scaleCanvas=function(s,m){var j=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,m,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=m,this.onCropChange&&this.onCropChange(j),this.setCropRectangle(j)},G}(),Xr=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();vt.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 m="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,j=1;j<=this.width/5+10;j++){var X=j%5==0?this.height/3:this.height/6;m+="h4v"+-X+"h1v"+X}m+="v1H0Z",this.scaleShape=vt.createPath(m);var H=vt.createTransform();this.scaleShape.transform.baseVal.appendItem(H),s.appendChild(this.scaleShape),this.angleLabelElement=vt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=vt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ye=vt.createTSpan("");return ye.innerHTML="&deg;",this.angleLabelElement.appendChild(ye),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},G}(),ui=function(){function G(){this.naturalSize=!1,this.imageType="image/png"}return G.prototype.rasterize=function(s,m,j,X,H,ye,je){var Ye=this;return new Promise(function(ut){var Ge=document.createElement("canvas");Ge.width=s.width.baseVal.value-2*X,Ge.height=s.height.baseVal.value-2*X;var Et=1,Dt=1;Ye.naturalSize===!0?(Et=m.naturalWidth/(s.width.baseVal.value-2*X)/ye,Dt=m.naturalHeight/(s.height.baseVal.value-2*X)/je,Ge.width=m.naturalWidth/ye,Ge.height=m.naturalHeight/je):Ye.width!==void 0&&Ye.height!==void 0&&(Et=Ye.width/j.width,Dt=Ye.height/j.height,Ge.width*=Et,Ge.height*=Dt);var Vt=Ge.getContext("2d");Vt.translate(Ge.width/2,Ge.height/2),Vt.rotate(H*Math.PI/180),Vt.scale(ye,je),Vt.translate(-Ge.width/2,-Ge.height/2),Vt.drawImage(m,0,0,Ge.width,Ge.height);var Ir=document.createElement("canvas");Ir.width=j.width*Et,Ir.height=j.height*Dt,Ir.getContext("2d").putImageData(Vt.getImageData((j.x-X)*Et,(j.y-X)*Dt,j.width*Et,j.height*Dt),0,0),ut(Ir.toDataURL(Ye.imageType,Ye.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 Vr(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(m){return m()}),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,m=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,j=m+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(m,j)}},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",vt.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,m){this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},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 m=s.toDataURL();vt.setAttributes(this.editingTarget,[["href",m]]),this.setEditingTargetSize()},G.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left-this.CANVAS_MARGIN,this.top=s.top-m.top-this.CANVAS_MARGIN},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=vt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=vt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=vt.createGroup(),this.editingTargetRotationScaleContainer=vt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=vt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var m=vt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(m),this.editingTargetContainer=vt.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},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=vt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Mr(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,m=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=s+"px "+m+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-m+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},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,m=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=m+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},G.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},G.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Hr,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var m=new si;m.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(m);var j=[];this.aspectRatios.forEach(function(Dt){var Vt=new Pt(li.getIcon(Dt.horizontal,Dt.vertical),Dt.horizontal===0&&Dt.vertical===0?"FREE":Dt.horizontal+":"+Dt.vertical);Vt.onClick=function(){return s.ratioButtonClicked(Dt)},j.push(Vt)}),this.aspectRatioButton=new xr(li.getIcon(0,0),"Aspect ratio",j),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,m.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var X=new Pt('<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");X.isActive=this.isGridVisible,X.onClick=function(){s.isGridVisible=!s.isGridVisible,X.isActive=s.isGridVisible},m.addButton(X);var H=new Pt('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(H.isActive=this.zoomToCropEnabled,H.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,H.isActive=s.zoomToCropEnabled},m.addButton(H),!ai.isLicensed){var ye=new pt;this.topToolbar.addElementBlock(ye);var je=document.createElement("div");je.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ye=document.createElement("a");Ye.style.color="currentColor",Ye.href="https://markerjs.com/products/cropro",Ye.target="_blank",Ye.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(Ye),ye.addElement(je)}var ut=new si;ut.minWidth=3*this.toolbarHeight+"px",ut.contentAlign="end",this.topToolbar.addButtonBlock(ut);var Ge=new Pt('<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");Ge.onClick=this.startRenderAndClose,ut.addButton(Ge),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ge.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Et=new Pt('<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");Et.onClick=this.close,ut.addButton(Et),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Et.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},G.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Hr,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var m=new si;m.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(m);var j=new Pt('<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");j.onClick=this.rotateLeftButtonClicked,m.addButton(j);var X=new Pt('<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");X.onClick=this.rotateRightButtonClicked,m.addButton(X);var H=new pt;H.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(H),this.straightener=new Xr("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(ut){s.rotateBy(ut),s.straightener.angle=s.rotationAngle},H.addElement(this.straightener.getUI());var ye=new si;ye.minWidth=2*this.toolbarHeight+"px",ye.contentAlign="end",this.bottomToolbar.addButtonBlock(ye);var je=new Pt('<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,ye.addButton(je);var Ye=new Pt('<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");Ye.onClick=this.flipVerticallyButtonClicked,ye.addButton(Ye)},G.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},G.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=li.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 Pr(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 m=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(m),this.cropRectChanged(m),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},G.prototype.clientToLocalCoordinates=function(s,m){var j=this.cropImage.getBoundingClientRect();return{x:s-j.left,y:m-j.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 m=this.editingTargetRotationContainer.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(m,0);var j=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/j.width,this.imageHeight/j.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,m;return Wr(this,function(j){switch(j.label){case 0:return[4,this.render()];case 1:return s=j.sent(),m=this.getState(),this.renderEventListeners.forEach(function(X){return X(s,m)}),this.close(!0),[2]}})})},G.prototype.render=function(){return Lt(this,void 0,void 0,function(){var s;return Wr(this,function(m){switch(m.label){case 0:return(s=new ui).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),vt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return m.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,m.sent()]}})})},G.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new cr("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 cr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new cr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new cr("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 cr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new cr("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new nr("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new nr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new cr("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 cr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new cr("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 cr("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 cr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},G.instanceCounter=0,G}(),Tt=se("8hTe"),hi=se.n(Tt),Li=/<pre[^>]*>/g;function di(G){var s=document.createElement("div");return s.innerHTML=G,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var ki=at.a=function(G){var s=G.value,m=s===void 0?"":s,j=G.edit,X=j===void 0?!1:j,H=G.className,ye=G.showTextOnly,je=G.showLines,Ye=G.replaces,ut=G.zoomImg,Ge=G.hasMask,Et=G.style,Dt=Et===void 0?{}:Et,Vt=G.stylesPrev,Ir=Vt===void 0?{}:Vt,Nr=String(m),ar=Object(D.useRef)(),Gr=Object(D.useRef)(),Hi=Object(D.useState)(""),Er=Object(z.a)(Hi,2),Br=Er[0],_r=Er[1],gi=Object(D.useState)("office"),Yr=Object(z.a)(gi,2),ci=Yr[0],ei=Yr[1],dn=function(){var Nt=new Ve(Gr.current);Nt.displayMode="popup",Nt.addRenderEventListener(function(){var fr=Object(P.a)(I.a.mark(function Mt(er){var Ut;return I.a.wrap(function(Qt){for(;;)switch(Qt.prev=Qt.next){case 0:return ar.current.style.display="none",Qt.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:er}});case 3:Ut=Qt.sent,Ut!=null&&Ut.id&&Ye(Gr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Ut==null?void 0:Ut.id,"?type=").concat(Ut.content_type));case 5:case"end":return Qt.stop()}},Mt)}));return function(Mt){return fr.apply(this,arguments)}}()),Nt.show()},Gi=function(){var Nt=new It(Gr.current);Nt.settings.displayMode="popup",Nt.addEventListener("render",function(){var fr=Object(P.a)(I.a.mark(function Mt(er){var Ut;return I.a.wrap(function(Qt){for(;;)switch(Qt.prev=Qt.next){case 0:if(ar.current.style.display="none",!Gr.current){Qt.next=6;break}return Qt.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:er.dataUrl}});case 4:Ut=Qt.sent,Ut!=null&&Ut.id&&Ye(Gr.current.getAttribute("src").replace(ee.a.API_SERVER,""),"/api/attachments/".concat(Ut==null?void 0:Ut.id,"?type=").concat(Ut.content_type));case 6:case"end":return Qt.stop()}},Mt)}));return function(Mt){return fr.apply(this,arguments)}}()),Nt.show(),window.markerArea=Nt},$r=Object(D.useMemo)(function(){try{var Zt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Nt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,fr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Nr=Nr.replace(Zt,"("+ee.a.API_SERVER+"/api/attachments/").replace(Nt,'"'+ee.a.API_SERVER+"/api/attachments/").replace(fr,'"'+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,`
`),Nr=Nr.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
`)}catch(ti){}var Mt=V(Nr),er=x();if(Nr.match(/\[TOC\]/)&&(Mt=Mt.replace("<p>[TOC]</p>",L()),C()),Mt=Mt.replace(/(__special_katext_id_\d+__)/g,function(ti,Qt){var Sr=er[Qt],zi=Sr.type,Ki=Sr.expression;return Object(ae.renderToString)(di(Ki)||"",{displayMode:zi==="block",throwOnError:!1,output:"html"})}),Mt=Mt.replace(/▁/g,"\u2581\u2581\u2581"),v(),ye){var Ut=document.createElement("div");return Ut.innerHTML=Mt,Ut.innerText}return setTimeout(function(){return Di()},500),Mt},[Nr]),Fr=Object(D.useRef)();f.WebkitLineClamp=je,je&&(Dt=Object(B.a)(Object(B.a)({},Dt),f));function _i(Zt){var Nt=Zt.target;if(Nt.tagName.toUpperCase()==="IMG"){if(ut){var fr=Nt.getAttribute("src");_r(fr),ei("image")}}else if(Nt.tagName.toUpperCase()==="A"){var Mt=Nt.getAttribute("href");if(Mt.indexOf("office")>-1)Zt.preventDefault(),_r(Mt),ei("office");else if(Mt.indexOf("application/pdf")>-1)Zt.preventDefault(),_r(Mt),ei("pdf");else if(Mt.indexOf("type=text")>-1)Zt.preventDefault(),_r(Mt),ei("html");else if(Mt.startsWith("#")){Zt.preventDefault();var er=document.getElementById(Mt.replace("#",""));er&&er.scrollIntoView(!0)}}}var Di=function(){var Nt,fr=(Nt=Fr.current)===null||Nt===void 0?void 0:Nt.querySelectorAll("video");fr==null||fr.forEach(function(Mt){if(Mt.oncontextmenu=function(){return!1},Mt.src.indexOf(".m3u8")>-1&&!Mt.canPlayType("application/vnd.apple.mpegurl")){if($.a.isSupported()){var er=new $.a;er.loadSource(Mt.src),er.attachMedia(Mt)}}})};Object(D.useEffect)(function(){if(Fr.current&&$r&&($r.match(Li)&&window.PR.prettyPrint()),Fr.current)return Fr.current.addEventListener("click",_i),function(){Fr.current.removeEventListener("click",_i),v(),C()}},[$r,Fr.current,_i]);var cn=function(Nt){if(!X)return;Nt.target.nodeName==="IMG"?(ar.current.style.display="flex",ar.current.style.width=Nt.target.clientWidth+"px",ar.current.style.height=Nt.target.clientHeight+"px",ar.current.style.top=Nt.target.offsetTop+"px",ar.current.style.left=Nt.target.offsetLeft+"px",Gr.current.src=Nt.target.getAttribute("src")):ar.current.style.display="none"};return y.a.createElement("div",{style:{position:"relative"}},y.a.createElement("div",{ref:Fr,style:Object(B.a)({},Dt),className:"".concat(H||""," markdown-body ").concat(hi.a.mdBody),onMouseOver:cn,dangerouslySetInnerHTML:{__html:$r}}),y.a.createElement("div",{ref:ar,className:hi.a.button},y.a.createElement(Q.a,null,y.a.createElement(Z.a,{onClick:function(){return dn()}},"\u88C1\u526A"),y.a.createElement(Z.a,{onClick:function(){return Gi()}},"\u7F16\u8F91"))),y.a.createElement("img",{ref:Gr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),y.a.createElement(fe.a,{close:!0,data:Br,hasMask:Ge,type:Br!=null&&Br.length?ci:"",style:Object(B.a)({},Ir),onClose:function(){return _r("")}}))}},"9VGf":function(xt,at,se){"use strict";se.d(at,"a",function(){return _});var le=se("q1tI"),Q=se.n(le);function _(Z,B){var P=Object(le.useRef)();Object(le.useEffect)(function(){P.current=Z}),Object(le.useEffect)(function(){function z(){P.current()}if(B!==null){var W=setInterval(z,B);return function(){return clearInterval(W)}}},[B])}},BU3w:function(xt,at,se){"use strict";se.d(at,"a",function(){return P});var le=se("MNnm"),Q="rc-util-key";function _(z){if(z.attachTo)return z.attachTo;var W=document.querySelector("head");return W||document.body}function Z(z){var W,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(le.a)())return null;var D=document.createElement("style");if((W=I.csp)===null||W===void 0?void 0:W.nonce){var y;D.nonce=(y=I.csp)===null||y===void 0?void 0:y.nonce}D.innerHTML=z;var w=_(I),O=w.firstChild;return I.prepend&&w.prepend?w.prepend(D):I.prepend&&O?w.insertBefore(D,O):w.appendChild(D),D}var B=new Map;function P(z,W){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},D=_(I);if(!B.has(D)){var y=Z("",I),w=y.parentNode;B.set(D,w),w.removeChild(y)}var O=Array.from(B.get(D).children).find(function(o){return o.tagName==="STYLE"&&o[Q]===W});if(O){var k,A;if(((k=I.csp)===null||k===void 0?void 0:k.nonce)&&O.nonce!==((A=I.csp)===null||A===void 0?void 0:A.nonce)){var T;O.nonce=(T=I.csp)===null||T===void 0?void 0:T.nonce}return O.innerHTML!==z&&(O.innerHTML=z),O}var h=Z(z,I);return h[Q]=W,h}},Bd2K:function(xt,at,se){(function(le){le(se("VrN/"),se("osHv"))})(function(le){le.defineOption("autoCloseTags",!1,function(I,D,y){if(y!=le.Init&&y&&I.removeKeyMap("autoCloseTags"),!D)return;var w={name:"autoCloseTags"};(typeof D!="object"||D.whenClosing!==!1)&&(w["'/'"]=function(O){return P(O)}),(typeof D!="object"||D.whenOpening!==!1)&&(w["'>'"]=function(O){return Z(O)}),I.addKeyMap(w)});var Q=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function Z(I){if(I.getOption("disableInput"))return le.Pass;for(var D=I.listSelections(),y=[],w=I.getOption("autoCloseTags"),O=0;O<D.length;O++){if(!D[O].empty())return le.Pass;var k=D[O].head,A=I.getTokenAt(k),T=le.innerMode(I.getMode(),A.state),h=T.state,o=T.mode.xmlCurrentTag&&T.mode.xmlCurrentTag(h),l=o&&o.name;if(!l)return le.Pass;var d=T.mode.configuration=="html",C=typeof w=="object"&&w.dontCloseTags||d&&Q,f=typeof w=="object"&&w.indentTags||d&&_;A.end>k.ch&&(l=l.slice(0,l.length-A.end+k.ch));var p=l.toLowerCase();if(!l||A.type=="string"&&(A.end!=k.ch||!/[\"\']/.test(A.string.charAt(A.string.length-1))||A.string.length==1)||A.type=="tag"&&o.close||A.string.indexOf("/")==k.ch-A.start-1||C&&z(C,p)>-1||W(I,T.mode.xmlCurrentContext&&T.mode.xmlCurrentContext(h)||[],l,k,!0))return le.Pass;var L=typeof w=="object"&&w.emptyTags;if(L&&z(L,l)>-1){y[O]={text:"/>",newPos:le.Pos(k.line,k.ch+2)};continue}var b=f&&z(f,p)>-1;y[O]={indent:b,text:">"+(b?`
`:"")+"</"+l+">",newPos:b?le.Pos(k.line+1,0):le.Pos(k.line,k.ch+1)}}for(var g=typeof w=="object"&&w.dontIndentOnAutoClose,O=D.length-1;O>=0;O--){var c=y[O];I.replaceRange(c.text,D[O].head,D[O].anchor,"+insert");var u=I.listSelections().slice(0);u[O]={head:c.newPos,anchor:c.newPos},I.setSelections(u),!g&&c.indent&&(I.indentLine(c.newPos.line,null,!0),I.indentLine(c.newPos.line+1,null,!0))}}function B(I,D){for(var y=I.listSelections(),w=[],O=D?"/":"</",k=I.getOption("autoCloseTags"),A=typeof k=="object"&&k.dontIndentOnSlash,T=0;T<y.length;T++){if(!y[T].empty())return le.Pass;var h=y[T].head,o=I.getTokenAt(h),l=le.innerMode(I.getMode(),o.state),d=l.state;if(D&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=h.ch-1))return le.Pass;var C,f=l.mode.name!="xml"&&I.getMode().name=="htmlmixed";if(f&&l.mode.name=="javascript")C=O+"script";else if(f&&l.mode.name=="css")C=O+"style";else{var p=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(d);if(!p||p.length&&W(I,p,p[p.length-1],h))return le.Pass;C=O+p[p.length-1]}I.getLine(h.line).charAt(o.end)!=">"&&(C+=">"),w[T]=C}if(I.replaceSelections(w),y=I.listSelections(),!A)for(var T=0;T<y.length;T++)(T==y.length-1||y[T].head.line<y[T+1].head.line)&&I.indentLine(y[T].head.line)}function P(I){return I.getOption("disableInput")?le.Pass:B(I,!0)}le.commands.closeTag=function(I){return B(I)};function z(I,D){if(I.indexOf)return I.indexOf(D);for(var y=0,w=I.length;y<w;++y)if(I[y]==D)return y;return-1}function W(I,D,y,w,O){if(!le.scanForClosingTag)return!1;var k=Math.min(I.lastLine()+1,w.line+500),A=le.scanForClosingTag(I,w,null,k);if(!A||A.tag!=y)return!1;for(var T=O?1:0,h=D.length-1;h>=0&&D[h]==y;h--)++T;w=A.to;for(var h=1;h<T;h++){var o=le.scanForClosingTag(I,w,null,k);if(!o||o.tag!=y)return!1;w=o.to}return!0}})},BjJ7:function(xt,at,se){"use strict";se.d(at,"d",function(){return Q}),se.d(at,"c",function(){return _}),se.d(at,"e",function(){return Z}),se.d(at,"b",function(){return B}),se.d(at,"a",function(){return z});var le=se("m3rI");function Q(W){var I=!0;if(W.length>0){for(var D=0;D<W.length;D++)if(W[D].compile_success==0||!W[D].compile_success){I=!1;break}}else I=!1;return I}function _(W){for(var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",D=[],y=0;y<W.length;y++){var w=W[y],O=I?"".concat(I,"/").concat(w.name):"".concat(w.name);D.push({title:w.name,isLeaf:!(w.type==="tree"),key:O})}return D}function Z(W,I,D){for(var y=0;y<W.length;y++){var w=W[y];if(w.key===I){w.children=D;break}w.children&&Z(w.children,I,D)}return W}function B(W,I,D){var y;return function(){var w=this,O=arguments,k=function(){y=null,D||W.apply(w,O)},A=D&&!y;clearTimeout(y),y=setTimeout(k,I),A&&W.apply(w,O)}}var P=!0,z=le.a.API_SERVER},"C+DQ":function(xt,at,se){},DlQD:function(xt,at,se){(function(le,Q){xt.exports=Q()})(this,function(){"use strict";function le(be,pe){for(var ve=0;ve<pe.length;ve++){var re=pe[ve];re.enumerable=re.enumerable||!1,re.configurable=!0,"value"in re&&(re.writable=!0),Object.defineProperty(be,re.key,re)}}function Q(be,pe,ve){return pe&&le(be.prototype,pe),ve&&le(be,ve),be}function _(be,pe){if(!be)return;if(typeof be=="string")return Z(be,pe);var ve=Object.prototype.toString.call(be).slice(8,-1);if(ve==="Object"&&be.constructor&&(ve=be.constructor.name),ve==="Map"||ve==="Set")return Array.from(be);if(ve==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ve))return Z(be,pe)}function Z(be,pe){(pe==null||pe>be.length)&&(pe=be.length);for(var ve=0,re=new Array(pe);ve<pe;ve++)re[ve]=be[ve];return re}function B(be,pe){var ve;if(typeof Symbol=="undefined"||be[Symbol.iterator]==null){if(Array.isArray(be)||(ve=_(be))||pe&&be&&typeof be.length=="number"){ve&&(be=ve);var re=0;return function(){return re>=be.length?{done:!0}:{done:!1,value:be[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 ve=be[Symbol.iterator](),ve.next.bind(ve)}function P(be,pe){return pe={exports:{}},be(pe,pe.exports),pe.exports}var z=P(function(be){function pe(){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 ve(re){be.exports.defaults=re}be.exports={defaults:pe(),getDefaults:pe,changeDefaults:ve}}),W=z.defaults,I=z.getDefaults,D=z.changeDefaults,y=/[&<>"']/,w=/[&<>"']/g,O=/[<>"']|&(?!#?\w+;)/,k=/[<>"']|&(?!#?\w+;)/g,A={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},T=function(pe){return A[pe]};function h(be,pe){if(pe){if(y.test(be))return be.replace(w,T)}else if(O.test(be))return be.replace(k,T);return be}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(be){return be.replace(o,function(pe,ve){return ve=ve.toLowerCase(),ve==="colon"?":":ve.charAt(0)==="#"?ve.charAt(1)==="x"?String.fromCharCode(parseInt(ve.substring(2),16)):String.fromCharCode(+ve.substring(1)):""})}var d=/(^|[^\[])\^/g;function C(be,pe){be=be.source||be,pe=pe||"";var ve={replace:function(ie,oe){return oe=oe.source||oe,oe=oe.replace(d,"$1"),be=be.replace(ie,oe),ve},getRegex:function(){return new RegExp(be,pe)}};return ve}var f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(be,pe,ve){if(be){var re;try{re=decodeURIComponent(l(ve)).replace(f,"").toLowerCase()}catch(ie){return null}if(re.indexOf("javascript:")===0||re.indexOf("vbscript:")===0||re.indexOf("data:")===0)return null}pe&&!p.test(ve)&&(ve=a(pe,ve));try{ve=encodeURI(ve).replace(/%25/g,"%")}catch(ie){return null}return ve}var b={},g=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(be,pe){b[" "+be]||(g.test(be)?b[" "+be]=be+"/":b[" "+be]=N(be,"/",!0)),be=b[" "+be];var ve=be.indexOf(":")===-1;return pe.substring(0,2)==="//"?ve?pe:be.replace(c,"$1")+pe:pe.charAt(0)==="/"?ve?pe:be.replace(u,"$1")+pe:be+pe}var x={exec:function(){}};function v(be){for(var pe=1,ve,re;pe<arguments.length;pe++){ve=arguments[pe];for(re in ve)Object.prototype.hasOwnProperty.call(ve,re)&&(be[re]=ve[re])}return be}function E(be,pe){var ve=be.replace(/\|/g,function(oe,ue,ke){for(var Ee=!1,Ue=ue;--Ue>=0&&ke[Ue]==="\\";)Ee=!Ee;return Ee?"|":" |"}),re=ve.split(/ \|/),ie=0;if(re.length>pe)re.splice(pe);else for(;re.length<pe;)re.push("");for(;ie<re.length;ie++)re[ie]=re[ie].trim().replace(/\\\|/g,"|");return re}function N(be,pe,ve){var re=be.length;if(re===0)return"";for(var ie=0;ie<re;){var oe=be.charAt(re-ie-1);if(oe===pe&&!ve)ie++;else if(oe!==pe&&ve)ie++;else break}return be.substr(0,re-ie)}function F(be,pe){if(be.indexOf(pe[1])===-1)return-1;for(var ve=be.length,re=0,ie=0;ie<ve;ie++)if(be[ie]==="\\")ie++;else if(be[ie]===pe[0])re++;else if(be[ie]===pe[1]&&(re--,re<0))return ie;return-1}function K(be){be&&be.sanitize&&!be.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:h,unescape:l,edit:C,cleanUrl:L,resolveUrl:a,noopTest:x,merge:v,splitCells:E,rtrim:N,findClosingBracket:F,checkSanitizeDeprecation:K},R=z.defaults,M=V.rtrim,$=V.splitCells,ee=V.escape,ae=V.findClosingBracket;function fe(be,pe,ve){var re=pe.href,ie=pe.title?ee(pe.title):null,oe=be[1].replace(/\\([\[\]])/g,"$1");return be[0].charAt(0)!=="!"?{type:"link",raw:ve,href:re,title:ie,text:oe}:{type:"image",raw:ve,href:re,title:ie,text:ee(oe)}}function De(be,pe){var ve=be.match(/^(\s+)(?:```)/);if(ve===null)return pe;var re=ve[1];return pe.split(`
`).map(function(ie){var oe=ie.match(/^\s+/);if(oe===null)return ie;var ue=oe[0];return ue.length>=re.length?ie.slice(re.length):ie}).join(`
`)}var Se=function(){function be(ve){this.options=ve||R}var pe=be.prototype;return pe.space=function(re){var ie=this.rules.block.newline.exec(re);if(ie)return ie[0].length>1?{type:"space",raw:ie[0]}:{raw:`
`}},pe.code=function(re,ie){var oe=this.rules.block.code.exec(re);if(oe){var ue=ie[ie.length-1];if(ue&&ue.type==="paragraph")return{raw:oe[0],text:oe[0].trimRight()};var ke=oe[0].replace(/^ {4}/gm,"");return{type:"code",raw:oe[0],codeBlockStyle:"indented",text:this.options.pedantic?ke:M(ke,`
`)}}},pe.fences=function(re){var ie=this.rules.block.fences.exec(re);if(ie){var oe=ie[0],ue=De(oe,ie[3]||"");return{type:"code",raw:oe,lang:ie[2]?ie[2].trim():ie[2],text:ue}}},pe.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]}},pe.nptable=function(re){var ie=this.rules.block.nptable.exec(re);if(ie){var oe={type:"table",header:$(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[],raw:ie[0]};if(oe.header.length===oe.align.length){var ue=oe.align.length,ke;for(ke=0;ke<ue;ke++)/^ *-+: *$/.test(oe.align[ke])?oe.align[ke]="right":/^ *:-+: *$/.test(oe.align[ke])?oe.align[ke]="center":/^ *:-+ *$/.test(oe.align[ke])?oe.align[ke]="left":oe.align[ke]=null;for(ue=oe.cells.length,ke=0;ke<ue;ke++)oe.cells[ke]=$(oe.cells[ke],oe.header.length);return oe}}},pe.hr=function(re){var ie=this.rules.block.hr.exec(re);if(ie)return{type:"hr",raw:ie[0]}},pe.blockquote=function(re){var ie=this.rules.block.blockquote.exec(re);if(ie){var oe=ie[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:ie[0],text:oe}}},pe.list=function(re){var ie=this.rules.block.list.exec(re);if(ie){for(var oe=ie[0],ue=ie[2],ke=ue.length>1,Ee=ue[ue.length-1]===")",Ue={type:"list",raw:oe,ordered:ke,start:ke?+ue.slice(0,-1):"",loose:!1,items:[]},et=ie[0].match(this.rules.block.item),ft=!1,lt,wt,St,dt,zt,It,Kt,Wt=et.length,Lt=0;Lt<Wt;Lt++)lt=et[Lt],oe=lt,wt=lt.length,lt=lt.replace(/^ *([*+-]|\d+[.)]) */,""),~lt.indexOf(`
`)&&(wt-=lt.length,lt=this.options.pedantic?lt.replace(/^ {1,4}/gm,""):lt.replace(new RegExp("^ {1,"+wt+"}","gm"),"")),Lt!==Wt-1&&(St=this.rules.block.bullet.exec(et[Lt+1])[0],(ke?St.length===1||!Ee&&St[St.length-1]===")":St.length>1||this.options.smartLists&&St!==ue)&&(dt=et.slice(Lt+1).join(`
`),Ue.raw=Ue.raw.substring(0,Ue.raw.length-dt.length),Lt=Wt-1)),zt=ft||/\n\n(?!\s*$)/.test(lt),Lt!==Wt-1&&(ft=lt.charAt(lt.length-1)===`
`,zt||(zt=ft)),zt&&(Ue.loose=!0),It=/^\[[ xX]\] /.test(lt),Kt=void 0,It&&(Kt=lt[1]!==" ",lt=lt.replace(/^\[[ xX]\] +/,"")),Ue.items.push({type:"list_item",raw:oe,task:It,checked:Kt,loose:zt,text:lt});return Ue}},pe.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]}},pe.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 oe=ie[1].toLowerCase().replace(/\s+/g," ");return{tag:oe,raw:ie[0],href:ie[2],title:ie[3]}}},pe.table=function(re){var ie=this.rules.block.table.exec(re);if(ie){var oe={type:"table",header:$(ie[1].replace(/^ *| *\| *$/g,"")),align:ie[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ie[3]?ie[3].replace(/\n$/,"").split(`
`):[]};if(oe.header.length===oe.align.length){oe.raw=ie[0];var ue=oe.align.length,ke;for(ke=0;ke<ue;ke++)/^ *-+: *$/.test(oe.align[ke])?oe.align[ke]="right":/^ *:-+: *$/.test(oe.align[ke])?oe.align[ke]="center":/^ *:-+ *$/.test(oe.align[ke])?oe.align[ke]="left":oe.align[ke]=null;for(ue=oe.cells.length,ke=0;ke<ue;ke++)oe.cells[ke]=$(oe.cells[ke].replace(/^ *\| *| *\| *$/g,""),oe.header.length);return oe}}},pe.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]}},pe.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]}},pe.text=function(re,ie){var oe=this.rules.block.text.exec(re);if(oe){var ue=ie[ie.length-1];return ue&&ue.type==="text"?{raw:oe[0],text:oe[0]}:{type:"text",raw:oe[0],text:oe[0]}}},pe.escape=function(re){var ie=this.rules.inline.escape.exec(re);if(ie)return{type:"escape",raw:ie[0],text:ee(ie[1])}},pe.tag=function(re,ie,oe){var ue=this.rules.inline.tag.exec(re);if(ue)return!ie&&/^<a /i.test(ue[0])?ie=!0:ie&&/^<\/a>/i.test(ue[0])&&(ie=!1),!oe&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?oe=!0:oe&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(oe=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:ie,inRawBlock:oe,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ee(ue[0]):ue[0]}},pe.link=function(re){var ie=this.rules.inline.link.exec(re);if(ie){var oe=ae(ie[2],"()");if(oe>-1){var ue=ie[0].indexOf("!")===0?5:4,ke=ue+ie[1].length+oe;ie[2]=ie[2].substring(0,oe),ie[0]=ie[0].substring(0,ke).trim(),ie[3]=""}var Ee=ie[2],Ue="";if(this.options.pedantic){var et=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Ee);et?(Ee=et[1],Ue=et[3]):Ue=""}else Ue=ie[3]?ie[3].slice(1,-1):"";Ee=Ee.trim().replace(/^<([\s\S]*)>$/,"$1");var ft=fe(ie,{href:Ee&&Ee.replace(this.rules.inline._escapes,"$1"),title:Ue&&Ue.replace(this.rules.inline._escapes,"$1")},ie[0]);return ft}},pe.reflink=function(re,ie){var oe;if((oe=this.rules.inline.reflink.exec(re))||(oe=this.rules.inline.nolink.exec(re))){var ue=(oe[2]||oe[1]).replace(/\s+/g," ");if(ue=ie[ue.toLowerCase()],!ue||!ue.href){var ke=oe[0].charAt(0);return{type:"text",raw:ke,text:ke}}var Ee=fe(oe,ue,oe[0]);return Ee}},pe.strong=function(re,ie,oe){oe===void 0&&(oe="");var ue=this.rules.inline.strong.start.exec(re);if(ue&&(!ue[1]||ue[1]&&(oe===""||this.rules.inline.punctuation.exec(oe)))){ie=ie.slice(-1*re.length);var ke=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ke.lastIndex=0;for(var Ee;(ue=ke.exec(ie))!=null;)if(Ee=this.rules.inline.strong.middle.exec(ie.slice(0,ue.index+3)),Ee)return{type:"strong",raw:re.slice(0,Ee[0].length),text:re.slice(2,Ee[0].length-2)}}},pe.em=function(re,ie,oe){oe===void 0&&(oe="");var ue=this.rules.inline.em.start.exec(re);if(ue&&(!ue[1]||ue[1]&&(oe===""||this.rules.inline.punctuation.exec(oe)))){ie=ie.slice(-1*re.length);var ke=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ke.lastIndex=0;for(var Ee;(ue=ke.exec(ie))!=null;)if(Ee=this.rules.inline.em.middle.exec(ie.slice(0,ue.index+2)),Ee)return{type:"em",raw:re.slice(0,Ee[0].length),text:re.slice(1,Ee[0].length-1)}}},pe.codespan=function(re){var ie=this.rules.inline.code.exec(re);if(ie){var oe=ie[2].replace(/\n/g," "),ue=/[^ ]/.test(oe),ke=oe.startsWith(" ")&&oe.endsWith(" ");return ue&&ke&&(oe=oe.substring(1,oe.length-1)),oe=ee(oe,!0),{type:"codespan",raw:ie[0],text:oe}}},pe.br=function(re){var ie=this.rules.inline.br.exec(re);if(ie)return{type:"br",raw:ie[0]}},pe.del=function(re){var ie=this.rules.inline.del.exec(re);if(ie)return{type:"del",raw:ie[0],text:ie[1]}},pe.autolink=function(re,ie){var oe=this.rules.inline.autolink.exec(re);if(oe){var ue,ke;return oe[2]==="@"?(ue=ee(this.options.mangle?ie(oe[1]):oe[1]),ke="mailto:"+ue):(ue=ee(oe[1]),ke=ue),{type:"link",raw:oe[0],text:ue,href:ke,tokens:[{type:"text",raw:ue,text:ue}]}}},pe.url=function(re,ie){var oe;if(oe=this.rules.inline.url.exec(re)){var ue,ke;if(oe[2]==="@")ue=ee(this.options.mangle?ie(oe[0]):oe[0]),ke="mailto:"+ue;else{var Ee;do Ee=oe[0],oe[0]=this.rules.inline._backpedal.exec(oe[0])[0];while(Ee!==oe[0]);ue=ee(oe[0]),oe[1]==="www."?ke="http://"+ue:ke=ue}return{type:"link",raw:oe[0],text:ue,href:ke,tokens:[{type:"text",raw:ue,text:ue}]}}},pe.inlineText=function(re,ie,oe){var ue=this.rules.inline.text.exec(re);if(ue){var ke;return ie?ke=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ee(ue[0]):ue[0]:ke=ee(this.options.smartypants?oe(ue[0]):ue[0]),{type:"text",raw:ue[0],text:ke}}},be}(),Ce=V.noopTest,we=V.edit,Te=V.merge,me={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Ce,table:Ce,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=we(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=we(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=we(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",me._comment=/<!--(?!-?>)[\s\S]*?-->/,me.html=we(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=we(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.blockquote=we(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Te({},me),me.gfm=Te({},me.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),me.gfm.nptable=we(me.gfm.nptable).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.gfm.table=we(me.gfm.table).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.pedantic=Te({},me.normal,{html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Ce,paragraph:we(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var he={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])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=we(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",he._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",he.em.start=we(he.em.start).replace(/punctuation/g,he._punctuation).getRegex(),he.em.middle=we(he.em.middle).replace(/punctuation/g,he._punctuation).replace(/overlapSkip/g,he._overlapSkip).getRegex(),he.em.endAst=we(he.em.endAst,"g").replace(/punctuation/g,he._punctuation).getRegex(),he.em.endUnd=we(he.em.endUnd,"g").replace(/punctuation/g,he._punctuation).getRegex(),he.strong.start=we(he.strong.start).replace(/punctuation/g,he._punctuation).getRegex(),he.strong.middle=we(he.strong.middle).replace(/punctuation/g,he._punctuation).replace(/blockSkip/g,he._blockSkip).getRegex(),he.strong.endAst=we(he.strong.endAst,"g").replace(/punctuation/g,he._punctuation).getRegex(),he.strong.endUnd=we(he.strong.endUnd,"g").replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=we(he._blockSkip,"g").getRegex(),he.overlapSkip=we(he._overlapSkip,"g").getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=we(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=we(he.tag).replace("comment",me._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=we(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=we(he.reflink).replace("label",he._label).getRegex(),he.reflinkSearch=we(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal=Te({},he),he.pedantic=Te({},he.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:we(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()}),he.gfm=Te({},he.normal,{escape:we(he.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),he.gfm.url=we(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks=Te({},he.gfm,{br:we(he.br).replace("{2,}","*").getRegex(),text:we(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var te={block:me,inline:he},de=z.defaults,ne=te.block,Le=te.inline;function Re(be){return be.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 xe(be){var pe="",ve,re,ie=be.length;for(ve=0;ve<ie;ve++)re=be.charCodeAt(ve),Math.random()>.5&&(re="x"+re.toString(16)),pe+="&#"+re+";";return pe}var Oe=function(){function be(ve){this.tokens=[],this.tokens.links=Object.create(null),this.options=ve||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:Le.normal};this.options.pedantic?(re.block=ne.pedantic,re.inline=Le.pedantic):this.options.gfm&&(re.block=ne.gfm,this.options.breaks?re.inline=Le.breaks:re.inline=Le.gfm),this.tokenizer.rules=re}be.lex=function(re,ie){var oe=new be(ie);return oe.lex(re)};var pe=be.prototype;return pe.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},pe.blockTokens=function(re,ie,oe){ie===void 0&&(ie=[]),oe===void 0&&(oe=!0),re=re.replace(/^ +$/gm,"");for(var ue,ke,Ee,Ue;re;){if(ue=this.tokenizer.space(re)){re=re.substring(ue.raw.length),ue.type&&ie.push(ue);continue}if(ue=this.tokenizer.code(re,ie)){re=re.substring(ue.raw.length),ue.type?ie.push(ue):(Ue=ie[ie.length-1],Ue.raw+=`
`+ue.raw,Ue.text+=`
`+ue.text);continue}if(ue=this.tokenizer.fences(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.heading(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.nptable(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.hr(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.blockquote(re)){re=re.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],oe),ie.push(ue);continue}if(ue=this.tokenizer.list(re)){for(re=re.substring(ue.raw.length),Ee=ue.items.length,ke=0;ke<Ee;ke++)ue.items[ke].tokens=this.blockTokens(ue.items[ke].text,[],!1);ie.push(ue);continue}if(ue=this.tokenizer.html(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(oe&&(ue=this.tokenizer.def(re))){re=re.substring(ue.raw.length),this.tokens.links[ue.tag]||(this.tokens.links[ue.tag]={href:ue.href,title:ue.title});continue}if(ue=this.tokenizer.table(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.lheading(re)){re=re.substring(ue.raw.length),ie.push(ue);continue}if(oe&&(ue=this.tokenizer.paragraph(re))){re=re.substring(ue.raw.length),ie.push(ue);continue}if(ue=this.tokenizer.text(re,ie)){re=re.substring(ue.raw.length),ue.type?ie.push(ue):(Ue=ie[ie.length-1],Ue.raw+=`
`+ue.raw,Ue.text+=`
`+ue.text);continue}if(re){var et="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error(et);break}else throw new Error(et)}}return ie},pe.inline=function(re){var ie,oe,ue,ke,Ee,Ue,et=re.length;for(ie=0;ie<et;ie++){Ue=re[ie];switch(Ue.type){case"paragraph":case"text":case"heading":{Ue.tokens=[],this.inlineTokens(Ue.text,Ue.tokens);break}case"table":{for(Ue.tokens={header:[],cells:[]},ke=Ue.header.length,oe=0;oe<ke;oe++)Ue.tokens.header[oe]=[],this.inlineTokens(Ue.header[oe],Ue.tokens.header[oe]);for(ke=Ue.cells.length,oe=0;oe<ke;oe++)for(Ee=Ue.cells[oe],Ue.tokens.cells[oe]=[],ue=0;ue<Ee.length;ue++)Ue.tokens.cells[oe][ue]=[],this.inlineTokens(Ee[ue],Ue.tokens.cells[oe][ue]);break}case"blockquote":{this.inline(Ue.tokens);break}case"list":{for(ke=Ue.items.length,oe=0;oe<ke;oe++)this.inline(Ue.items[oe].tokens);break}}}return re},pe.inlineTokens=function(re,ie,oe,ue,ke){ie===void 0&&(ie=[]),oe===void 0&&(oe=!1),ue===void 0&&(ue=!1),ke===void 0&&(ke="");var Ee,Ue=re,et;if(this.tokens.links){var ft=Object.keys(this.tokens.links);if(ft.length>0)for(;(et=this.tokenizer.rules.inline.reflinkSearch.exec(Ue))!=null;)ft.includes(et[0].slice(et[0].lastIndexOf("[")+1,-1))&&(Ue=Ue.slice(0,et.index)+"["+"a".repeat(et[0].length-2)+"]"+Ue.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(et=this.tokenizer.rules.inline.blockSkip.exec(Ue))!=null;)Ue=Ue.slice(0,et.index)+"["+"a".repeat(et[0].length-2)+"]"+Ue.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;re;){if(Ee=this.tokenizer.escape(re)){re=re.substring(Ee.raw.length),ie.push(Ee);continue}if(Ee=this.tokenizer.tag(re,oe,ue)){re=re.substring(Ee.raw.length),oe=Ee.inLink,ue=Ee.inRawBlock,ie.push(Ee);continue}if(Ee=this.tokenizer.link(re)){re=re.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,ue)),ie.push(Ee);continue}if(Ee=this.tokenizer.reflink(re,this.tokens.links)){re=re.substring(Ee.raw.length),Ee.type==="link"&&(Ee.tokens=this.inlineTokens(Ee.text,[],!0,ue)),ie.push(Ee);continue}if(Ee=this.tokenizer.strong(re,Ue,ke)){re=re.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],oe,ue),ie.push(Ee);continue}if(Ee=this.tokenizer.em(re,Ue,ke)){re=re.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],oe,ue),ie.push(Ee);continue}if(Ee=this.tokenizer.codespan(re)){re=re.substring(Ee.raw.length),ie.push(Ee);continue}if(Ee=this.tokenizer.br(re)){re=re.substring(Ee.raw.length),ie.push(Ee);continue}if(Ee=this.tokenizer.del(re)){re=re.substring(Ee.raw.length),Ee.tokens=this.inlineTokens(Ee.text,[],oe,ue),ie.push(Ee);continue}if(Ee=this.tokenizer.autolink(re,xe)){re=re.substring(Ee.raw.length),ie.push(Ee);continue}if(!oe&&(Ee=this.tokenizer.url(re,xe))){re=re.substring(Ee.raw.length),ie.push(Ee);continue}if(Ee=this.tokenizer.inlineText(re,ue,Re)){re=re.substring(Ee.raw.length),ke=Ee.raw.slice(-1),ie.push(Ee);continue}if(re){var lt="Infinite loop on byte: "+re.charCodeAt(0);if(this.options.silent){console.error(lt);break}else throw new Error(lt)}}return ie},Q(be,null,[{key:"rules",get:function(){return{block:ne,inline:Le}}}]),be}(),Me=z.defaults,He=V.cleanUrl,We=V.escape,Fe=function(){function be(ve){this.options=ve||Me}var pe=be.prototype;return pe.code=function(re,ie,oe){var ue=(ie||"").match(/\S*/)[0];if(this.options.highlight){var ke=this.options.highlight(re,ue);ke!=null&&ke!==re&&(oe=!0,re=ke)}return ue?'<pre><code class="'+this.options.langPrefix+We(ue,!0)+'">'+(oe?re:We(re,!0))+`</code></pre>
`:"<pre><code>"+(oe?re:We(re,!0))+`</code></pre>
`},pe.blockquote=function(re){return`<blockquote>
`+re+`</blockquote>
`},pe.html=function(re){return re},pe.heading=function(re,ie,oe,ue){return this.options.headerIds?"<h"+ie+' id="'+this.options.headerPrefix+ue.slug(oe)+'">'+re+"</h"+ie+`>
`:"<h"+ie+">"+re+"</h"+ie+`>
`},pe.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},pe.list=function(re,ie,oe){var ue=ie?"ol":"ul",ke=ie&&oe!==1?' start="'+oe+'"':"";return"<"+ue+ke+`>
`+re+"</"+ue+`>
`},pe.listitem=function(re){return"<li>"+re+`</li>
`},pe.checkbox=function(re){return"<input "+(re?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},pe.paragraph=function(re){return"<p>"+re+`</p>
`},pe.table=function(re,ie){return ie&&(ie="<tbody>"+ie+"</tbody>"),`<table>
<thead>
`+re+`</thead>
`+ie+`</table>
`},pe.tablerow=function(re){return`<tr>
`+re+`</tr>
`},pe.tablecell=function(re,ie){var oe=ie.header?"th":"td",ue=ie.align?"<"+oe+' align="'+ie.align+'">':"<"+oe+">";return ue+re+"</"+oe+`>
`},pe.strong=function(re){return"<strong>"+re+"</strong>"},pe.em=function(re){return"<em>"+re+"</em>"},pe.codespan=function(re){return"<code>"+re+"</code>"},pe.br=function(){return this.options.xhtml?"<br/>":"<br>"},pe.del=function(re){return"<del>"+re+"</del>"},pe.link=function(re,ie,oe){if(re=He(this.options.sanitize,this.options.baseUrl,re),re===null)return oe;var ue='<a href="'+We(re)+'"';return ie&&(ue+=' title="'+ie+'"'),ue+=">"+oe+"</a>",ue},pe.image=function(re,ie,oe){if(re=He(this.options.sanitize,this.options.baseUrl,re),re===null)return oe;var ue='<img src="'+re+'" alt="'+oe+'"';return ie&&(ue+=' title="'+ie+'"'),ue+=this.options.xhtml?"/>":">",ue},pe.text=function(re){return re},be}(),Be=function(){function be(){}var pe=be.prototype;return pe.strong=function(re){return re},pe.em=function(re){return re},pe.codespan=function(re){return re},pe.del=function(re){return re},pe.html=function(re){return re},pe.text=function(re){return re},pe.link=function(re,ie,oe){return""+oe},pe.image=function(re,ie,oe){return""+oe},pe.br=function(){return""},be}(),tt=function(){function be(){this.seen={}}var pe=be.prototype;return pe.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 oe=ie;do this.seen[oe]++,ie=oe+"-"+this.seen[oe];while(this.seen.hasOwnProperty(ie))}return this.seen[ie]=0,ie},be}(),qe=z.defaults,Ze=V.unescape,$e=function(){function be(ve){this.options=ve||qe,this.options.renderer=this.options.renderer||new Fe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Be,this.slugger=new tt}be.parse=function(re,ie){var oe=new be(ie);return oe.parse(re)};var pe=be.prototype;return pe.parse=function(re,ie){ie===void 0&&(ie=!0);var oe="",ue,ke,Ee,Ue,et,ft,lt,wt,St,dt,zt,It,Kt,Wt,Lt,Wr,ai,vt,Vr=re.length;for(ue=0;ue<Vr;ue++){dt=re[ue];switch(dt.type){case"space":continue;case"hr":{oe+=this.renderer.hr();continue}case"heading":{oe+=this.renderer.heading(this.parseInline(dt.tokens),dt.depth,Ze(this.parseInline(dt.tokens,this.textRenderer)),this.slugger);continue}case"code":{oe+=this.renderer.code(dt.text,dt.lang,dt.escaped);continue}case"table":{for(wt="",lt="",Ue=dt.header.length,ke=0;ke<Ue;ke++)lt+=this.renderer.tablecell(this.parseInline(dt.tokens.header[ke]),{header:!0,align:dt.align[ke]});for(wt+=this.renderer.tablerow(lt),St="",Ue=dt.cells.length,ke=0;ke<Ue;ke++){for(ft=dt.tokens.cells[ke],lt="",et=ft.length,Ee=0;Ee<et;Ee++)lt+=this.renderer.tablecell(this.parseInline(ft[Ee]),{header:!1,align:dt.align[Ee]});St+=this.renderer.tablerow(lt)}oe+=this.renderer.table(wt,St);continue}case"blockquote":{St=this.parse(dt.tokens),oe+=this.renderer.blockquote(St);continue}case"list":{for(zt=dt.ordered,It=dt.start,Kt=dt.loose,Ue=dt.items.length,St="",ke=0;ke<Ue;ke++)Lt=dt.items[ke],Wr=Lt.checked,ai=Lt.task,Wt="",Lt.task&&(vt=this.renderer.checkbox(Wr),Kt?Lt.tokens.length>0&&Lt.tokens[0].type==="text"?(Lt.tokens[0].text=vt+" "+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=vt+" "+Lt.tokens[0].tokens[0].text)):Lt.tokens.unshift({type:"text",text:vt}):Wt+=vt),Wt+=this.parse(Lt.tokens,Kt),St+=this.renderer.listitem(Wt,ai,Wr);oe+=this.renderer.list(St,zt,It);continue}case"html":{oe+=this.renderer.html(dt.text);continue}case"paragraph":{oe+=this.renderer.paragraph(this.parseInline(dt.tokens));continue}case"text":{for(St=dt.tokens?this.parseInline(dt.tokens):dt.text;ue+1<Vr&&re[ue+1].type==="text";)dt=re[++ue],St+=`
`+(dt.tokens?this.parseInline(dt.tokens):dt.text);oe+=ie?this.renderer.paragraph(St):St;continue}default:{var nr='Token with "'+dt.type+'" type was not found.';if(this.options.silent){console.error(nr);return}else throw new Error(nr)}}}return oe},pe.parseInline=function(re,ie){ie=ie||this.renderer;var oe="",ue,ke,Ee=re.length;for(ue=0;ue<Ee;ue++){ke=re[ue];switch(ke.type){case"escape":{oe+=ie.text(ke.text);break}case"html":{oe+=ie.html(ke.text);break}case"link":{oe+=ie.link(ke.href,ke.title,this.parseInline(ke.tokens,ie));break}case"image":{oe+=ie.image(ke.href,ke.title,ke.text);break}case"strong":{oe+=ie.strong(this.parseInline(ke.tokens,ie));break}case"em":{oe+=ie.em(this.parseInline(ke.tokens,ie));break}case"codespan":{oe+=ie.codespan(ke.text);break}case"br":{oe+=ie.br();break}case"del":{oe+=ie.del(this.parseInline(ke.tokens,ie));break}case"text":{oe+=ie.text(ke.text);break}default:{var Ue='Token with "'+ke.type+'" type was not found.';if(this.options.silent){console.error(Ue);return}else throw new Error(Ue)}}}return oe},be}(),ct=V.merge,rt=V.checkSanitizeDeprecation,it=V.escape,Pe=z.getDefaults,st=z.changeDefaults,nt=z.defaults;function Ie(be,pe,ve){if(typeof be=="undefined"||be===null)throw new Error("marked(): input parameter is undefined or null");if(typeof be!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(be)+", string expected");if(typeof pe=="function"&&(ve=pe,pe=null),pe=ct({},Ie.defaults,pe||{}),rt(pe),ve){var re=pe.highlight,ie;try{ie=Oe.lex(be,pe)}catch(Ee){return ve(Ee)}var oe=function(Ue){var et;if(!Ue)try{et=$e.parse(ie,pe)}catch(ft){Ue=ft}return pe.highlight=re,Ue?ve(Ue):ve(null,et)};if(!re||re.length<3)return oe();if(delete pe.highlight,!ie.length)return oe();var ue=0;Ie.walkTokens(ie,function(Ee){Ee.type==="code"&&(ue++,setTimeout(function(){re(Ee.text,Ee.lang,function(Ue,et){if(Ue)return oe(Ue);et!=null&&et!==Ee.text&&(Ee.text=et,Ee.escaped=!0),ue--,ue===0&&oe()})},0))}),ue===0&&oe();return}try{var ke=Oe.lex(be,pe);return pe.walkTokens&&Ie.walkTokens(ke,pe.walkTokens),$e.parse(ke,pe)}catch(Ee){if(Ee.message+=`
Please report this to https://github.com/markedjs/marked.`,pe.silent)return"<p>An error occurred:</p><pre>"+it(Ee.message+"",!0)+"</pre>";throw Ee}}Ie.options=Ie.setOptions=function(be){return ct(Ie.defaults,be),st(Ie.defaults),Ie},Ie.getDefaults=Pe,Ie.defaults=nt,Ie.use=function(be){var pe=ct({},be);if(be.renderer&&function(){var re=Ie.defaults.renderer||new Fe,ie=function(ke){var Ee=re[ke];re[ke]=function(){for(var Ue=arguments.length,et=new Array(Ue),ft=0;ft<Ue;ft++)et[ft]=arguments[ft];var lt=be.renderer[ke].apply(re,et);return lt===!1&&(lt=Ee.apply(re,et)),lt}};for(var oe in be.renderer)ie(oe);pe.renderer=re}(),be.tokenizer&&function(){var re=Ie.defaults.tokenizer||new Se,ie=function(ke){var Ee=re[ke];re[ke]=function(){for(var Ue=arguments.length,et=new Array(Ue),ft=0;ft<Ue;ft++)et[ft]=arguments[ft];var lt=be.tokenizer[ke].apply(re,et);return lt===!1&&(lt=Ee.apply(re,et)),lt}};for(var oe in be.tokenizer)ie(oe);pe.tokenizer=re}(),be.walkTokens){var ve=Ie.defaults.walkTokens;pe.walkTokens=function(re){be.walkTokens(re),ve&&ve(re)}}Ie.setOptions(pe)},Ie.walkTokens=function(be,pe){for(var ve=B(be),re;!(re=ve()).done;){var ie=re.value;pe(ie);switch(ie.type){case"table":{for(var oe=B(ie.tokens.header),ue;!(ue=oe()).done;){var ke=ue.value;Ie.walkTokens(ke,pe)}for(var Ee=B(ie.tokens.cells),Ue;!(Ue=Ee()).done;)for(var et=Ue.value,ft=B(et),lt;!(lt=ft()).done;){var wt=lt.value;Ie.walkTokens(wt,pe)}break}case"list":{Ie.walkTokens(ie.items,pe);break}default:ie.tokens&&Ie.walkTokens(ie.tokens,pe)}}},Ie.Parser=$e,Ie.parser=$e.parse,Ie.Renderer=Fe,Ie.TextRenderer=Be,Ie.Lexer=Oe,Ie.lexer=Oe.lex,Ie.Tokenizer=Se,Ie.Slugger=tt,Ie.parse=Ie;var ze=Ie;return ze})},ELLl:function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){var Q={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=le.Pos;le.defineOption("autoCloseBrackets",!1,function(A,T,h){h&&h!=le.Init&&(A.removeKeyMap(B),A.state.closeBrackets=null),T&&(P(Z(T,"pairs")),A.state.closeBrackets=T,A.addKeyMap(B))});function Z(A,T){return T=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[T]!=null?A[T]:Q[T]}var B={Backspace:I,Enter:D};function P(A){for(var T=0;T<A.length;T++){var h=A.charAt(T),o="'"+h+"'";B[o]||(B[o]=z(h))}}P(Q.pairs+"`");function z(A){return function(T){return w(T,A)}}function W(A){var T=A.state.closeBrackets;if(!T||T.override)return T;var h=A.getModeAt(A.getCursor());return h.closeBrackets||T}function I(A){var T=W(A);if(!T||A.getOption("disableInput"))return le.Pass;for(var h=Z(T,"pairs"),o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return le.Pass;var d=O(A,o[l].head);if(!d||h.indexOf(d)%2!=0)return le.Pass}for(var l=o.length-1;l>=0;l--){var C=o[l].head;A.replaceRange("",_(C.line,C.ch-1),_(C.line,C.ch+1),"+delete")}}function D(A){var T=W(A),h=T&&Z(T,"explode");if(!h||A.getOption("disableInput"))return le.Pass;for(var o=A.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return le.Pass;var d=O(A,o[l].head);if(!d||h.indexOf(d)%2!=0)return le.Pass}A.operation(function(){var C=A.lineSeparator()||`
`;A.replaceSelection(C+C,null),A.execCommand("goCharLeft"),o=A.listSelections();for(var f=0;f<o.length;f++){var p=o[f].head.line;A.indentLine(p,null,!0),A.indentLine(p+1,null,!0)}})}function y(A){var T=le.cmpPos(A.anchor,A.head)>0;return{anchor:new _(A.anchor.line,A.anchor.ch+(T?-1:1)),head:new _(A.head.line,A.head.ch+(T?1:-1))}}function w(A,T){var h=W(A);if(!h||A.getOption("disableInput"))return le.Pass;var o=Z(h,"pairs"),l=o.indexOf(T);if(l==-1)return le.Pass;for(var d=Z(h,"closeBefore"),C=Z(h,"triples"),f=o.charAt(l+1)==T,p=A.listSelections(),L=l%2==0,b,g=0;g<p.length;g++){var c=p[g],u=c.head,a,x=A.getRange(u,_(u.line,u.ch+1));if(L&&!c.empty())a="surround";else if((f||!L)&&x==T)f&&k(A,u)?a="both":C.indexOf(T)>=0&&A.getRange(u,_(u.line,u.ch+3))==T+T+T?a="skipThree":a="skip";else if(f&&u.ch>1&&C.indexOf(T)>=0&&A.getRange(_(u.line,u.ch-2),u)==T+T){if(u.ch>2&&/\bstring/.test(A.getTokenTypeAt(_(u.line,u.ch-2))))return le.Pass;a="addFour"}else if(f){var v=u.ch==0?" ":A.getRange(_(u.line,u.ch-1),u);if(!le.isWordChar(x)&&v!=T&&!le.isWordChar(v))a="both";else return le.Pass}else if(L&&(x.length===0||/\s/.test(x)||d.indexOf(x)>-1))a="both";else return le.Pass;if(!b)b=a;else if(b!=a)return le.Pass}var E=l%2?o.charAt(l-1):T,N=l%2?T:o.charAt(l+1);A.operation(function(){if(b=="skip")A.execCommand("goCharRight");else if(b=="skipThree")for(var F=0;F<3;F++)A.execCommand("goCharRight");else if(b=="surround"){for(var K=A.getSelections(),F=0;F<K.length;F++)K[F]=E+K[F]+N;A.replaceSelections(K,"around"),K=A.listSelections().slice();for(var F=0;F<K.length;F++)K[F]=y(K[F]);A.setSelections(K)}else b=="both"?(A.replaceSelection(E+N,null),A.triggerElectric(E+N),A.execCommand("goCharLeft")):b=="addFour"&&(A.replaceSelection(E+E+E+E,"before"),A.execCommand("goCharRight"))})}function O(A,T){var h=A.getRange(_(T.line,T.ch-1),_(T.line,T.ch+1));return h.length==2?h:null}function k(A,T){var h=A.getTokenAt(_(T.line,T.ch+1));return/\bstring/.test(h.type)&&h.start==T.ch&&(T.ch==0||!/\bstring/.test(A.getTokenTypeAt(T)))}})},GfqC:function(xt,at,se){"use strict";var le=se("q1tI"),Q=se.n(le),_=se("TSYQ"),Z=se.n(_);function B(V,R){var M="cannot "+V.method+" "+V.action+" "+R.status+"'",$=new Error(M);return $.status=R.status,$.method=V.method,$.url=V.action,$}function P(V){var R=V.responseText||V.response;if(!R)return R;try{return JSON.parse(R)}catch(M){return R}}function z(V){var R=new XMLHttpRequest;V.onProgress&&R.upload&&(R.upload.onprogress=function(ae){ae.total>0&&(ae.percent=ae.loaded/ae.total*100),V.onProgress(ae)});var M=new FormData;V.data&&Object.keys(V.data).forEach(function(ee){var ae=V.data[ee];if(Array.isArray(ae)){ae.forEach(function(fe){M.append(ee+"[]",fe)});return}M.append(ee,V.data[ee])}),V.file instanceof Blob?M.append(V.filename,V.file,V.file.name):M.append(V.filename,V.file),R.onerror=function(ae){V.onError(ae)},R.onload=function(){return R.status<200||R.status>=300?V.onError(B(V,R),P(R)):V.onSuccess(P(R),R)},R.open(V.method,V.action,!0),V.withCredentials&&"withCredentials"in R&&(R.withCredentials=!0);var $=V.headers||{};return $["X-Requested-With"]!==null&&R.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys($).forEach(function(ee){$[ee]!==null&&R.setRequestHeader(ee,$[ee])}),R.send(M),{abort:function(){R.abort()}}}var W=+new Date,I=0;function D(){return"rc-upload-"+W+"-"+ ++I}function y(V,R){return V.indexOf(R,V.length-R.length)!==-1}var w=function(V,R){if(V&&R){var M=Array.isArray(R)?R:R.split(","),$=V.name||"",ee=V.type||"",ae=ee.replace(/\/.*$/,"");return M.some(function(fe){var De=fe.trim();return De.charAt(0)==="."?y($.toLowerCase(),De.toLowerCase()):/\/\*$/.test(De)?ae===De.replace(/\/.*$/,""):ee===De})}return!0};function O(V,R){var M=V.createReader(),$=[];function ee(){M.readEntries(function(ae){var fe=Array.prototype.slice.apply(ae);$=$.concat(fe);var De=!fe.length;De?R($):ee()})}ee()}var k=function(R,M,$){var ee=function ae(fe,De){De=De||"",fe.isFile?fe.file(function(Se){$(Se)&&(fe.fullPath&&!Se.webkitRelativePath&&(Object.defineProperties(Se,{webkitRelativePath:{writable:!0}}),Se.webkitRelativePath=fe.fullPath.replace(/^\//,""),Object.defineProperties(Se,{webkitRelativePath:{writable:!1}})),M([Se]))}):fe.isDirectory&&O(fe,function(Se){Se.forEach(function(Ce){ae(Ce,""+De+fe.name+"/")})})};R.forEach(function(ae){ee(ae.webkitGetAsEntry())})},A=k,T=Object.assign||function(V){for(var R=1;R<arguments.length;R++){var M=arguments[R];for(var $ in M)Object.prototype.hasOwnProperty.call(M,$)&&(V[$]=M[$])}return V},h=function(){function V(R,M){var $=[],ee=!0,ae=!1,fe=void 0;try{for(var De=R[Symbol.iterator](),Se;!(ee=(Se=De.next()).done)&&!($.push(Se.value),M&&$.length===M);ee=!0);}catch(Ce){ae=!0,fe=Ce}finally{try{!ee&&De.return&&De.return()}finally{if(ae)throw fe}}return $}return function(R,M){if(Array.isArray(R))return R;if(Symbol.iterator in Object(R))return V(R,M);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function V(R,M){for(var $=0;$<M.length;$++){var ee=M[$];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(R,ee.key,ee)}}return function(R,M,$){return M&&V(R.prototype,M),$&&V(R,$),R}}();function l(V,R,M){return R in V?Object.defineProperty(V,R,{value:M,enumerable:!0,configurable:!0,writable:!0}):V[R]=M,V}function d(V,R){var M={};for(var $ in V){if(R.indexOf($)>=0)continue;if(!Object.prototype.hasOwnProperty.call(V,$))continue;M[$]=V[$]}return M}function C(V,R){if(!(V instanceof R))throw new TypeError("Cannot call a class as a function")}function f(V,R){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:V}function p(V,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);V.prototype=Object.create(R&&R.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(V,R):V.__proto__=R)}var L=function(R){return Object.keys(R).reduce(function(M,$){return($.substr(0,5)==="data-"||$.substr(0,5)==="aria-"||$==="role")&&(M[$]=R[$]),M},{})},b=function(V){p(R,V);function R(){var M,$,ee,ae;C(this,R);for(var fe=arguments.length,De=Array(fe),Se=0;Se<fe;Se++)De[Se]=arguments[Se];return ae=($=(ee=f(this,(M=R.__proto__||Object.getPrototypeOf(R)).call.apply(M,[this].concat(De))),ee),ee.state={uid:D()},ee.reqs={},ee.onChange=function(Ce){var we=Ce.target.files;ee.uploadFiles(we),ee.reset()},ee.onClick=function(Ce){var we=ee.fileInput;if(!we)return;var Te=ee.props,me=Te.children,he=Te.onClick;me&&me.type==="button"&&(we.parentNode.focus(),we.parentNode.querySelector("button").blur()),we.click(),he&&he(Ce)},ee.onKeyDown=function(Ce){Ce.key==="Enter"&&ee.onClick()},ee.onFileDrop=function(Ce){var we=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(me){return w(me,ee.props.accept)});else{var Te=Array.prototype.slice.call(Ce.dataTransfer.files).filter(function(me){return w(me,ee.props.accept)});we===!1&&(Te=Te.slice(0,1)),ee.uploadFiles(Te)}},ee.uploadFiles=function(Ce){var we=Array.prototype.slice.call(Ce);we.map(function(Te){return Te.uid=D(),Te}).forEach(function(Te){ee.upload(Te,we)})},ee.saveFileInput=function(Ce){ee.fileInput=Ce},$),f(ee,ae)}return o(R,[{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.abort()}},{key:"upload",value:function($,ee){var ae=this,fe=this.props;if(!fe.beforeUpload)return setTimeout(function(){return ae.post($)},0);var De=fe.beforeUpload($,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($)}).catch(function(Se){console.log(Se)}):De!==!1&&setTimeout(function(){return ae.post($)},0);return}},{key:"post",value:function($){var ee=this;if(!this._isMounted)return;var ae=this.props,fe=ae.onStart,De=ae.onProgress,Se=ae.transformFile,Ce=Se===void 0?function(we){return we}:Se;new Promise(function(we){var Te=ae.action;return typeof Te=="function"&&(Te=Te($)),we(Te)}).then(function(we){var Te=$.uid,me=ae.customRequest||z,he=Promise.resolve(Ce($)).then(function(te){var de=ae.data;return typeof de=="function"&&(de=de(te)),Promise.all([te,de])}).catch(function(te){console.error(te)});he.then(function(te){var de=h(te,2),ne=de[0],Le=de[1],Re={action:we,filename:ae.name,data:Le,file:ne,headers:ae.headers,withCredentials:ae.withCredentials,method:ae.method||"post",onProgress:De?function(xe){De(xe,$)}:null,onSuccess:function(Oe,Me){delete ee.reqs[Te],ae.onSuccess(Oe,$,Me)},onError:function(Oe,Me){delete ee.reqs[Te],ae.onError(Oe,Me,$)}};fe($),ee.reqs[Te]=me(Re)})})}},{key:"reset",value:function(){this.setState({uid:D()})}},{key:"abort",value:function($){var ee=this.reqs;if($){var ae=$;$&&$.uid&&(ae=$.uid),ee[ae]&&ee[ae].abort&&ee[ae].abort(),delete ee[ae]}else Object.keys(ee).forEach(function(fe){ee[fe]&&ee[fe].abort&&ee[fe].abort(),delete ee[fe]})}},{key:"render",value:function(){var $,ee=this.props,ae=ee.component,fe=ee.prefixCls,De=ee.className,Se=ee.disabled,Ce=ee.id,we=ee.style,Te=ee.multiple,me=ee.accept,he=ee.children,te=ee.directory,de=ee.openFileDialogOnClick,ne=ee.onMouseEnter,Le=ee.onMouseLeave,Re=d(ee,["component","prefixCls","className","disabled","id","style","multiple","accept","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"]),xe=Z()(($={},l($,fe,!0),l($,fe+"-disabled",Se),l($,De,De),$)),Oe=Se?{}:{onClick:de?this.onClick:function(){},onKeyDown:de?this.onKeyDown:function(){},onMouseEnter:ne,onMouseLeave:Le,onDrop:this.onFileDrop,onDragOver:this.onFileDrop,tabIndex:"0"};return Q.a.createElement(ae,T({},Oe,{className:xe,role:"button",style:we}),Q.a.createElement("input",T({},L(Re),{id:Ce,type:"file",ref:this.saveFileInput,onClick:function(He){return He.stopPropagation()},key:this.state.uid,style:{display:"none"},accept:me,directory:te?"directory":null,webkitdirectory:te?"webkitdirectory":null,multiple:Te,onChange:this.onChange})),he)}}]),R}(le.Component),g=b,c=Object.assign||function(V){for(var R=1;R<arguments.length;R++){var M=arguments[R];for(var $ in M)Object.prototype.hasOwnProperty.call(M,$)&&(V[$]=M[$])}return V},u=function(){function V(R,M){for(var $=0;$<M.length;$++){var ee=M[$];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(R,ee.key,ee)}}return function(R,M,$){return M&&V(R.prototype,M),$&&V(R,$),R}}();function a(V,R){if(!(V instanceof R))throw new TypeError("Cannot call a class as a function")}function x(V,R){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:V}function v(V,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);V.prototype=Object.create(R&&R.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(V,R):V.__proto__=R)}function E(){}var N=function(V){v(R,V);function R(){var M,$,ee,ae;a(this,R);for(var fe=arguments.length,De=Array(fe),Se=0;Se<fe;Se++)De[Se]=arguments[Se];return ae=($=(ee=x(this,(M=R.__proto__||Object.getPrototypeOf(R)).call.apply(M,[this].concat(De))),ee),ee.saveUploader=function(Ce){ee.uploader=Ce},$),x(ee,ae)}return u(R,[{key:"abort",value:function($){this.uploader.abort($)}},{key:"render",value:function(){return Q.a.createElement(g,c({},this.props,{ref:this.saveUploader}))}}]),R}(le.Component);N.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 F=N,K=at.a=F},HmJG:function(xt,at,se){},I98M:function(xt,at,se){xt.exports={bg:"bg___t_hxx",flexRow:"flexRow___270qZ",flexJustifyCenter:"flexJustifyCenter___2lHrn",flexAlignEnd:"flexAlignEnd___1fRWo",flexAlignCenter:"flexAlignCenter___294G5",flexColumn:"flexColumn___3XrvP",formWrap:"formWrap___3oELa",titleWrap:"titleWrap___2fHnj",fieldWrap:"fieldWrap___2vew4",mdWrap:"mdWrap___9LUV8",backgroundFa:"backgroundFa___2z4YG",button:"button___3lyyu"}},LdHM:function(xt,at,se){"use strict";se.d(at,"b",function(){return d}),se.d(at,"a",function(){return f});var le=se("1OyB"),Q=se("vuIU"),_=se("Ji7U"),Z=se("LK+K"),B=se("q1tI"),P=se("rePB"),z=se("Ff2n"),W=se("ODXe"),I=se("4IlW"),D=se("bX4T"),y=se("YrtM"),w=se("TSYQ"),O=se.n(w),k=se("+nKL"),A=se("8OUc"),T=function($,ee){var ae=$.prefixCls,fe=$.id,De=$.flattenOptions,Se=$.childrenAsData,Ce=$.values,we=$.searchValue,Te=$.multiple,me=$.defaultActiveFirstOption,he=$.height,te=$.itemHeight,de=$.notFoundContent,ne=$.open,Le=$.menuItemSelectedIcon,Re=$.virtual,xe=$.onSelect,Oe=$.onToggleOpen,Me=$.onActiveValue,He=$.onScroll,We=$.onMouseEnter,Fe="".concat(ae,"-item"),Be=Object(y.a)(function(){return De},[ne,De],function(ze,be){return be[0]&&ze[1]!==be[1]}),tt=B.useRef(null),qe=function(be){be.preventDefault()},Ze=function(be){tt.current&&tt.current.scrollTo({index:be})},$e=function(be){for(var pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ve=Be.length,re=0;re<ve;re+=1){var ie=(be+re*pe+ve)%ve,oe=Be[ie],ue=oe.group,ke=oe.data;if(!ue&&!ke.disabled)return ie}return-1},ct=B.useState(function(){return $e(0)}),rt=Object(W.a)(ct,2),it=rt[0],Pe=rt[1],st=function(be){Pe(be);var pe=Be[be];if(!pe){Me(null,-1);return}Me(pe.data.value,be)};B.useEffect(function(){st(me!==!1?$e(0):-1)},[Be.length,we]),B.useEffect(function(){var ze=setTimeout(function(){if(!Te&&ne&&Ce.size===1){var be=Array.from(Ce)[0],pe=Be.findIndex(function(ve){var re=ve.data;return re.value===be});st(pe),Ze(pe)}});return function(){return clearTimeout(ze)}},[ne]);var nt=function(be){be!==void 0&&xe(be,{selected:!Ce.has(be)}),Te||Oe(!1)};if(B.useImperativeHandle(ee,function(){return{onKeyDown:function(be){var pe=be.which;switch(pe){case I.a.UP:case I.a.DOWN:{var ve=0;if(pe===I.a.UP?ve=-1:pe===I.a.DOWN&&(ve=1),ve!==0){var re=$e(it+ve,ve);Ze(re),st(re)}break}case I.a.ENTER:{var ie=Be[it];ie&&!ie.data.disabled?nt(ie.data.value):nt(void 0),ne&&be.preventDefault();break}case I.a.ESC:Oe(!1)}},onKeyUp:function(){},scrollTo:function(be){Ze(be)}}}),Be.length===0)return B.createElement("div",{role:"listbox",id:"".concat(fe,"_list"),className:"".concat(Fe,"-empty"),onMouseDown:qe},de);function Ie(ze){var be=Be[ze];if(!be)return null;var pe=be.data||{},ve=pe.value,re=pe.label,ie=pe.children,oe=Object(D.a)(pe,!0),ue=Se?ie:re;return be?B.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},oe,{key:ze,role:"option",id:"".concat(fe,"_list_").concat(ze),"aria-selected":Ce.has(ve)}),ve):null}return B.createElement(B.Fragment,null,B.createElement("div",{role:"listbox",id:"".concat(fe,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ie(it-1),Ie(it),Ie(it+1)),B.createElement(k.a,{itemKey:"key",ref:tt,data:Be,height:he,itemHeight:te,fullHeight:!1,onMouseDown:qe,onScroll:He,virtual:Re,onMouseEnter:We},function(ze,be){var pe,ve=ze.group,re=ze.groupOption,ie=ze.data,oe=ie.label,ue=ie.key;if(ve)return B.createElement("div",{className:O()(Fe,"".concat(Fe,"-group"))},oe!==void 0?oe:ue);var ke=ie.disabled,Ee=ie.value,Ue=ie.title,et=ie.children,ft=ie.style,lt=ie.className,wt=Object(z.a)(ie,["disabled","value","title","children","style","className"]),St=Ce.has(Ee),dt="".concat(Fe,"-option"),zt=O()(Fe,dt,lt,(pe={},Object(P.a)(pe,"".concat(dt,"-grouped"),re),Object(P.a)(pe,"".concat(dt,"-active"),it===be&&!ke),Object(P.a)(pe,"".concat(dt,"-disabled"),ke),Object(P.a)(pe,"".concat(dt,"-selected"),St),pe)),It=Se?et:oe,Kt=!Le||typeof Le=="function"||St;return B.createElement("div",Object.assign({},wt,{"aria-selected":St,className:zt,title:Ue,onMouseMove:function(){if(it===be||ke)return;st(be)},onClick:function(){ke||nt(Ee)},style:ft}),B.createElement("div",{className:"".concat(dt,"-content")},It||Ee),B.isValidElement(Le)||St,Kt&&B.createElement(A.a,{className:"".concat(Fe,"-option-state"),customizeIcon:Le,customizeIconProps:{isSelected:St}},St?"\u2713":null))}))},h=B.forwardRef(T);h.displayName="OptionList";var o=h,l=function(){return null};l.isSelectOption=!0;var d=l,C=function(){return null};C.isSelectOptGroup=!0;var f=C,p=se("VTBJ"),L=se("Zm9Q");function b(M){var $=M.key,ee=M.props,ae=ee.children,fe=ee.value,De=Object(z.a)(ee,["children","value"]);return Object(p.a)({key:$,value:fe!==void 0?fe:$,children:ae},De)}function g(M){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(M).map(function(ee,ae){if(!B.isValidElement(ee)||!ee.type)return null;var fe=ee.type.isSelectOptGroup,De=ee.key,Se=ee.props,Ce=Se.children,we=Object(z.a)(Se,["children"]);return $||!fe?b(ee):Object(p.a)(Object(p.a)({key:"__RC_SELECT_GRP__".concat(De===null?ae:De,"__"),label:De},we),{},{options:g(Ce)})}).filter(function(ee){return ee})}var c=se("2Qr1"),u=se("qNPg"),a=se("U8pU"),x=se("Kwbf"),v=se("WKfj");function E(M){var $=M.mode,ee=M.options,ae=M.children,fe=M.backfill,De=M.allowClear,Se=M.placeholder,Ce=M.getInputElement,we=M.showSearch,Te=M.onSearch,me=M.defaultOpen,he=M.autoFocus,te=M.labelInValue,de=M.value,ne=M.inputValue,Le=M.optionLabelProp,Re=$==="multiple"||$==="tags",xe=we!==void 0?we:Re||$==="combobox",Oe=ee||g(ae);if(Object(x.a)($!=="tags"||Oe.every(function(Fe){return!Fe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),$==="tags"||$==="combobox"){var Me=Oe.some(function(Fe){return Fe.options?Fe.options.some(function(Be){return typeof("value"in Be?Be.value:Be.key)=="number"}):typeof("value"in Fe?Fe.value:Fe.key)=="number"});Object(x.a)(!Me,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(x.a)($!=="combobox"||!Le,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(x.a)($==="combobox"||!fe,"`backfill` only works with `combobox` mode."),Object(x.a)($==="combobox"||!Ce,"`getInputElement` only work with `combobox` mode."),Object(x.b)($!=="combobox"||!Ce||!De||!Se,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Te&&!xe&&$!=="combobox"&&$!=="tags"&&Object(x.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(x.b)(!me||he,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),de!=null){var He=Object(v.d)(de);Object(x.a)(!te||He.every(function(Fe){return Object(a.a)(Fe)==="object"&&("key"in Fe||"value"in Fe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(x.a)(!Re||Array.isArray(de),"`value` should be array when `mode` is `multiple` or `tags`")}if(ae){var We=null;Object(L.a)(ae).some(function(Fe){if(!B.isValidElement(Fe)||!Fe.type)return!1;var Be=Fe.type;if(Be.isSelectOption)return!1;if(Be.isSelectOptGroup){var tt=Object(L.a)(Fe.props.children).every(function(qe){return!B.isValidElement(qe)||!Fe.type||qe.type.isSelectOption?!0:(We=qe.type,!1)});return!tt}return We=Be,!0}),We&&Object(x.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(We.displayName||We.name||We,"`.")),Object(x.a)(ne===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var N=E,F=Object(u.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:g,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:N,fillOptionsWithMissingValue:c.a}),K=function(M){Object(_.a)(ee,M);var $=Object(Z.a)(ee);function ee(){var ae;return Object(le.a)(this,ee),ae=$.apply(this,arguments),ae.selectRef=B.createRef(),ae.focus=function(){ae.selectRef.current.focus()},ae.blur=function(){ae.selectRef.current.blur()},ae}return Object(Q.a)(ee,[{key:"render",value:function(){return B.createElement(F,Object.assign({ref:this.selectRef},this.props))}}]),ee}(B.Component);K.Option=d,K.OptGroup=f;var V=K,R=at.c=V},M8RZ:function(xt,at,se){"use strict";se.d(at,"a",function(){return I});var le=se("fWQN"),Q=se("mtLc"),_=se("yKVA"),Z=se("879j"),B=se("q1tI"),P=se.n(B),z=se("i8i4"),W=se.n(z),I=function(D){Object(_.a)(w,D);var y=Object(Z.a)(w);function w(O){var k;Object(le.a)(this,w),k=y.call(this,O);var A=window.document;return k.node=A.createElement("div"),A.body.appendChild(k.node),k}return Object(Q.a)(w,[{key:"render",value:function(){var k=this.props.children;return Object(z.createPortal)(k,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),w}(P.a.Component)},Ot1p:function(xt,at,se){"use strict";var le=se("2qtc"),Q=se("kLXV"),_=se("rAM+"),Z=se("miYZ"),B=se("tsqr"),P=se("9og8"),z=se("tJVT"),W=se("jrin"),I=se("WmNS"),D=se.n(I),y=se("q1tI"),w=se.n(y),O=se("VrN/"),k=se.n(O),A=se("bdgK"),T=se("p77/"),h=se("Bd2K"),o=se("ELLl"),l=se("19Vz"),d=se("lZu9"),C=se("+NIl"),f=se("kSUc"),p=se("9Bee"),L=function(Ee){var Ue=Ee.value,et=Ue===void 0?"":Ue,ft=Ee.className,lt=Ee.showTextOnly,wt=Ee.showLines,St=Ee.style,dt=St===void 0?{}:St,zt=Object(y.useMemo)(function(){return""},[et]);return w.a.createElement(w.a.Fragment,null,w.a.createElement("div",{dangerouslySetInnerHTML:{__html:zt}}))},b=se("0Owb"),g=se("dejd"),c=se("C+DQ"),u=se("1vsH"),a=se("m3rI"),x=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function v(Ee){var Ue=Ee.onActionCallback,et=Ee.title,ft=Ee.icon,lt=Ee.actionName,wt=Ee.className,St=wt===void 0?"":wt,dt=Ee.children;function zt(){Ue(lt)}return w.a.createElement("a",{title:et,className:St,onClick:zt},w.a.createElement("i",{className:"md-iconfont ".concat(ft)}),dt)}var E=function(Ee){var Ue=Ee.watch,et=Ee.showNullButton,ft=Ee.onActionCallback,lt=Ee.fullScreen,wt=Ee.insertTemp,St=Ee.hidetoolBar,dt=Ee.uuid,zt=Ee.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(u.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(u.E)("_educoder_session"),"&key=").concat(dt,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var It=[].concat(x,[{title:"".concat(Ue?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Ue?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return w.a.createElement("ul",{className:"markdown-toolbar-container"},!St&&It.map(function(Kt,Wt){return w.a.createElement("li",{key:Wt},Kt.actionName?w.a.createElement(v,Object(b.a)({},Kt,{onActionCallback:ft})):w.a.createElement("span",{className:"v-line"}))}),et?w.a.createElement("li",null,w.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:ft},w.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,wt&&w.a.createElement("li",null,w.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(wt),onActionCallback:ft},w.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),w.a.createElement("li",{className:"btn-full-screen"},w.a.createElement(v,{icon:"".concat(lt?"icon-shrink":"icon-enlarge"),title:lt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:ft})))},N=se("M8RZ"),F=se("+L6B"),K=se("2/Rp"),V=se("y8nQ"),R=se("Vl3Y"),M=se("5NDa"),$=se("5rEg"),ee={labelCol:{span:4},wrapperCol:{span:20}},ae=function(Ee){var Ue=Ee.callback,et=Ee.onCancel;function ft(lt){Ue(lt)}return w.a.createElement(R.a,Object(b.a)({},ee,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:ft}),w.a.createElement(R.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},w.a.createElement($.a,null)),w.a.createElement(R.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},w.a.createElement($.a,null)),w.a.createElement("div",{className:"flex-container flex-end"},w.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(K.a,{type:"ghost",onClick:et},"\u53D6\u6D88")))},fe=se("7ahc"),De=se("k1fw"),Se=se("HmJG"),Ce=se("BjJ7"),we=R.a.useForm,Te={width:280,marginRight:10},me={labelCol:{span:5},wrapperCol:{span:19}},he=function(Ee){var Ue=Ee.callback,et=Ee.onCancel,ft=we(),lt=Object(z.a)(ft,1),wt=lt[0],St=Object(y.useRef)();function dt(Kt){Ue(Object(De.a)(Object(De.a)({},Kt),{},{name:St.current}))}function zt(Kt,Wt){wt.setFieldsValue({src:"/api/attachments/".concat(Kt.id,"?type=").concat(Kt.content_type),type:Wt.type})}function It(Kt){var Wt=Kt.target.files[0];St.current=Wt.name,de(Wt,zt)}return w.a.createElement(R.a,Object(b.a)({form:wt},me,{className:"upload-image-panel",onFinish:dt}),w.a.createElement(R.a.Item,{label:"\u6587\u4EF6\u5730\u5740",required:!0},w.a.createElement("div",{className:"flex-container"},w.a.createElement(R.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6587\u4EF6\u5730\u5740"}]},w.a.createElement($.a,{style:Te})),w.a.createElement(te,{onFileChange:It}))),w.a.createElement(R.a.Item,{label:"\u6587\u4EF6\u63CF\u8FF0",name:"alt"},w.a.createElement($.a,{style:{width:264}})),w.a.createElement(R.a.Item,{style:{textAlign:"right"}},w.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(K.a,{type:"ghost",onClick:et},"\u53D6\u6D88")))};function te(Ee){var Ue=Ee.onFileChange;return w.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",w.a.createElement("input",{type:"file",onChange:Ue}))}function de(Ee,Ue){if(!Ee)throw new String("\u6CA1\u6709\u6587\u4EF6");var et=new FormData;et.append("editormd-image-file",Ee),et.append("file_param_name","editormd-image-file"),et.append("byxhr","true");var ft=new window.XMLHttpRequest;ft.withCredentials=!0,ft.addEventListener("load",function(lt){Ue(JSON.parse(lt.target.responseText),Ee)},!1),ft.addEventListener("error",function(lt){console.error(lt)},!1),ft.open("POST","".concat(Ce.a,"/api/attachments.json")),ft.send(et)}var ne=se("giR+"),Le=se("fyUT"),Re=se("7Kak"),xe=se("9yH6"),Oe=xe.a.Group,Me={margin:"0 8px"},He=function(Ee){var Ue=Ee.callback,et=Ee.onCancel;function ft(lt){Ue(lt)}return w.a.createElement(R.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:ft},w.a.createElement("div",{className:"flex-container"},w.a.createElement("span",{style:Me},"\u5355\u5143\u683C\u6570\uFF1A"),w.a.createElement("span",{style:Me},"\u884C\u6570"),w.a.createElement(R.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},w.a.createElement(Le.a,null)),w.a.createElement("span",{style:Me},"\u5217\u6570"),w.a.createElement(R.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},w.a.createElement(Le.a,null))),w.a.createElement("div",{className:"flex-container",style:{marginTop:12}},w.a.createElement("span",{style:Me},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),w.a.createElement(R.a.Item,{name:"align"},w.a.createElement(Oe,null,w.a.createElement(xe.a,{value:"default"},w.a.createElement("i",{className:"fa fa-align-justify"})),w.a.createElement(xe.a,{value:"left"},w.a.createElement("i",{className:"fa fa-align-left"})),w.a.createElement(xe.a,{value:"center"},w.a.createElement("i",{className:"fa fa-align-center"})),w.a.createElement(xe.a,{value:"right"},w.a.createElement("i",{className:"fa fa-align-right"}))))),w.a.createElement("div",{className:"flex-container flex-end"},w.a.createElement(K.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),w.a.createElement(K.a,{type:"ghost",onClick:et},"\u53D6\u6D88")))},We=se("ErOA"),Fe=se("7Cbv"),Be="link",tt="upload-image",qe="code-block",Ze="add-table",$e="------------",ct={default:$e,left:":".concat($e),center:":".concat($e,":"),right:"".concat($e,":")},rt=se("9VGf"),it,Pe;function st(){}var nt=0,Ie=1e4,ze="\u2581",be=`
**\u6A21\u677F\u6807\u9898**
\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C`;function pe(Ee){return/^\d+$/.test(Ee)?"".concat(Ee,"px"):Ee}var ve=navigator.platform.toUpperCase().indexOf("MAC")>=0,re=ve?"Cmd":"Ctrl",ie=["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"],oe=(it={},Object(W.a)(it,re+"-B","bold"),Object(W.a)(it,re+"-I","italic"),it),ue=(Pe={},Object(W.a)(Pe,Be,"\u6DFB\u52A0\u94FE\u63A5"),Object(W.a)(Pe,qe,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(W.a)(Pe,tt,"\u6DFB\u52A0\u6587\u4EF6"),Object(W.a)(Pe,Ze,"\u6DFB\u52A0\u8868\u683C"),Pe),ke=at.a=function(Ee){var Ue=Ee.defaultValue,et=Ue===void 0?"":Ue,ft=Ee.onChange,lt=Ee.width,wt=lt===void 0?"100%":lt,St=Ee.height,dt=St===void 0?400:St,zt=Ee.miniToolbar,It=zt===void 0?!1:zt,Kt=Ee.isFocus,Wt=Kt===void 0?!1:Kt,Lt=Ee.watch,Wr=Ee.insertTemp,ai=Ee.mode,vt=ai===void 0?"markdown":ai,Vr=Ee.id,nr=Vr===void 0?"markdown-editor-id":Vr,cr=Ee.showResizeBar,Hr=cr===void 0?!1:cr,oi=Ee.noStorage,si=oi===void 0?!1:oi,Pt=Ee.showNullButton,pt=Pt===void 0?!1:Pt,Pr=Ee.hidetoolBar,li=Pr===void 0?!1:Pr,xr=Ee.fullScreen,kt=xr===void 0?!1:xr,Mr=Ee.onBlur,Xr=Ee.onCMBeforeChange,ui=Ee.onFullScreen,Ve=Ee.className,Tt=Ve===void 0?"":Ve,hi=Ee.disablePaste,Li=hi===void 0?!1:hi,di=Ee.placeholder,ki=di===void 0?"":di,G=Ee.values,s=G===void 0?"":G,m=Object(y.useState)(null),j=Object(z.a)(m,2),X=j[0],H=j[1],ye=Object(y.useState)(et),je=Object(z.a)(ye,2),Ye=je[0],ut=je[1],Ge=Object(y.useState)(Lt),Et=Object(z.a)(Ge,2),Dt=Et[0],Vt=Et[1],Ir=Object(y.useState)(kt),Nr=Object(z.a)(Ir,2),ar=Nr[0],Gr=Nr[1],Hi=Object(y.useState)(""),Er=Object(z.a)(Hi,2),Br=Er[0],_r=Er[1],gi=Object(y.useState)(0),Yr=Object(z.a)(gi,2),ci=Yr[0],ei=Yr[1],dn=Object(y.useState)(dt),Gi=Object(z.a)(dn,2),$r=Gi[0],Fr=Gi[1],_i=Object(y.useState)(!1),Di=Object(z.a)(_i,2),cn=Di[0],Zt=Di[1],Nt=Object(y.useRef)(Object(Fe.a)()),fr=Object(y.useRef)(!1),Mt=Object(y.useRef)(),er=Object(y.useRef)(),Ut=Object(y.useRef)(),ti=Object(y.useRef)(),Qt=Object(y.useRef)(),Sr=function(){var mt=Object(P.a)(D.a.mark(function Ct(){var yt,_t;return D.a.wrap(function(Ht){for(;;)switch(Ht.prev=Ht.next){case 0:return Ht.next=2,Object(We.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Nt.current}});case 2:_t=Ht.sent,_t!=null&&(yt=_t.attachments)!==null&&yt!==void 0&&yt.length&&(console.log("cm:",X,er),_t.attachments.map(function(Ot){Ot.content_type.indexOf("image")>-1?X.replaceSelection("![,](/api/attachments/".concat(Ot.id,"?type=").concat(Ot.content_type,")")):Ot.content_type.indexOf("video")>-1?X.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Ot.content_type.indexOf("pdf")>-1?X.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ot.id,"?type=").concat(Ot.content_type,'&disposition=inline" target="_blank">').concat(Ot.name,"</a>")):X.replaceSelection("[".concat(Ot.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ot.id,"?type=").concat(Ot.content_type,")"))}));case 4:case"end":return Ht.stop()}},Ct)}));return function(){return mt.apply(this,arguments)}}();Object(y.useEffect)(function(){ut(s),X==null||X.setValue(s)},[s]),Object(y.useEffect)(function(){ui==null||ui(ar)},[ar]),Object(y.useEffect)(function(){if(er.current){var mt=k.a.fromTextArea(er.current,{mode:vt,lineNumbers:!It,lineWrapping:!0,value:et,autoCloseTags:!0,autoCloseBrackets:!0});Wt&&mt.focus();function Ct(yt,_t){if(Li){_t.preventDefault();return}var Bt=_t.clipboardData;if(Bt){var Ht=Bt.types.toString(),Ot=Bt.items;if(Ht==="Files"||Bt.types.indexOf("Files")>-1){if(_t.preventDefault(),vt=="stex")return;try{var tr,Tr=Ot[1];((tr=Ot[0])===null||tr===void 0?void 0:tr.kind)==="file"&&(Tr=Ot[0]);var Rt=Tr.getAsFile(),yi=Rt.name.split(".").pop();de(Rt,function(Ft){if(Ft.id){var sr,zr,Kr;(Rt==null||((sr=Rt.type)===null||sr===void 0)?void 0:sr.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Ft.id,"?type=").concat(Ft.content_type,")")):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,'"></video>')):(Rt==null||((Kr=Rt.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ie.includes(yi)?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):mt.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,"?type=").concat(Ft.content_type,")"))}else(Ft==null?void 0:Ft.status)===401&&(document.location.href="/user/login")})}catch(Ft){B.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return mt.on("paste",Ct),mt.on("dragleave",function(yt,_t){Ut.current.classList.remove("mouse-hover-md")}),mt.on("dragover",function(yt,_t){Ut.current.classList.add("mouse-hover-md")}),mt.on("drop",function(yt,_t){Ut.current.classList.add("mouse-hover-md");var Bt;if(Bt=_t.dataTransfer.files,Bt.length>0){_t.preventDefault(),_t.stopPropagation();for(var Ht=function(Tr){var Rt=Bt[Tr],yi=Rt.name.split(".").pop();de(Rt,function(Ft){if(Ft.id){var sr,zr,Kr;(Rt==null||((sr=Rt.type)===null||sr===void 0)?void 0:sr.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Ft.id,"?type=").concat(Ft.content_type,")")):(Rt==null||((zr=Rt.type)===null||zr===void 0)?void 0:zr.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,'"></video>')):(Rt==null||((Kr=Rt.type)===null||Kr===void 0)?void 0:Kr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ie.includes(yi)?mt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):mt.replaceSelection("[".concat(Rt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Ft.id,"?type=").concat(Ft.content_type,")"))}else(Ft==null?void 0:Ft.status)===401&&(document.location.href="/user/login")})},Ot=0;Ot<Bt.length;Ot++)Ht(Ot)}}),H(mt),function(){mt.off("paste",Ct)}}},[]);var zi=Object(y.useCallback)(function(){if(Ut.current)try{}catch(mt){console.log(mt,"---- to set md editor body height")}},[$r,Ut,ar]);Object(y.useEffect)(function(){function mt(){var yt=new A.default(function(_t){var Bt=Object(_.a)(_t),Ht;try{for(Bt.s();!(Ht=Bt.n()).done;){var Ot=Ht.value;(Ot.target.offsetHeight>0||Ot.target.offsetWidth>0)&&(zi(),X.setSize("100%","100%"),X.refresh())}}catch(tr){Bt.e(tr)}finally{Bt.f()}});return yt.observe(er.current.parentElement),yt}if(X){var Ct=mt();return function(){Ct.unobserve(er.current.parentElement)}}},[X,zi]),Object(y.useEffect)(function(){if(X){for(var mt=[],Ct=function(){var Ot=_t[yt];Bt=Object(z.a)(Ot,2);var tr=Bt[0],Tr=Bt[1],Rt=Object(W.a)({},tr,function(){Ki(Tr)});mt.push(Rt),X.addKeyMap(Rt)},yt=0,_t=Object.entries(oe);yt<_t.length;yt++){var Bt;Ct()}return Mt.current=setInterval(function(){fr.current&&Sr()},4e3),function(){clearInterval(Mt.current);var Ht=Object(_.a)(mt),Ot;try{for(Ht.s();!(Ot=Ht.n()).done;){var tr=Ot.value;X.removeKeyMap(tr)}}catch(Tr){Ht.e(Tr)}finally{Ht.f()}}}},[X]),Object(y.useEffect)(function(){kt!==ar&&Gr(kt)},[kt]),Object(rt.a)(function(){if(!si&&ci>0){var mt=new Date().getTime(),Ct=window.sessionStorage.getItem(nr);mt>=ci+Ie&&(!Ct||Ct!==Ye)&&(window.sessionStorage.setItem(nr,Ye),Zt(!0))}},Ie),Object(y.useEffect)(function(){Vt(Lt)},[X,Lt]),Object(y.useEffect)(function(){X&&(Wt&&X.focus())},[X,Wt]),Object(y.useEffect)(function(){if(Dt&&X){var mt=X.getScrollerElement();function Ct(yt){var _t=yt.target;if(Qt.current){var Bt=_t.scrollTop/_t.scrollHeight;Qt.current.scrollTop=Qt.current.scrollHeight*Bt}}return mt.addEventListener("scroll",Ct),function(){mt.removeEventListener("scroll",Ct)}}},[X,Dt]),Object(y.useEffect)(function(){if(X&&Xr){function mt(Ct,yt){Xr(Ct,yt)}return X.on("beforeChange",mt),function(){X.off("beforeChange",mt)}}},[X,Xr]),Object(y.useEffect)(function(){if(X&&Mr){function mt(){Mr(X.getValue())}return X.on("blur",mt),function(){X.off("blur",mt)}}},[X,Mr]),Object(y.useEffect)(function(){if(X){function mt(Ct){var yt=Ct.getValue();ut(yt),ei(new Date().getTime()),Ct.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),ft&&ft(yt)}return X.on("change",mt),function(){X.off("change",mt)}}},[X,ft]),Object(y.useEffect)(function(){X&&(et==null?(X.setValue(""),ut("")):et!==X.getValue()&&(X.setValue(et),ut(et),X.setCursor(X.lineCount(),0)))},[X,et]);var Ki=Object(y.useCallback)(function(mt){var Ct=X.getCursor(),yt=X.getSelection(),_t=yt.split(`
`);switch(mt){case"bold":return X.replaceSelection("**"+yt+"**"),yt===""&&X.setCursor(Ct.line,Ct.ch+2),X.focus();case"italic":return X.replaceSelection("*"+yt+"*"),yt===""&&X.setCursor(Ct.line,Ct.ch+1),X.focus();case"code":return X.replaceSelection("`"+yt+"`"),yt===""&&X.setCursor(Ct.line,Ct.ch+1),X.focus();case"inline-latex":return X.replaceSelection("`$$"+yt+"$$`"),yt===""&&X.setCursor(Ct.line,Ct.ch+3),X.focus();case"latex":return X.replaceSelection("```latex\n"+yt+"\n```"),X.setCursor(Ct.line+1,yt.length+1),X.focus();case"line-break":return X.replaceSelection(`<br/>
`),X.focus();case"list-ul":return yt===""?X.replaceSelection("- "+yt):X.replaceSelection(_t.map(function(Bt){return Bt===""?"":"- ".concat(Bt)}).join(`
`)),X.focus();case"list-ol":return yt===""?X.replaceSelection("1. "+yt):X.replaceSelection(_t.map(function(Bt,Ht){return Bt===""?"":"".concat(Ht+1,". ").concat(Bt)}).join(`
`)),X.focus();case"add-null-ch":return yt===""&&X.setCursor(Ct.line,Ct.ch+1),X.replaceSelection(ze),X.focus();case"inster-template-1":return yt===""&&X.setCursor(Ct.line,Ct.ch),X.replaceSelection(be),X.focus();case"eraser":return X.setValue(""),X.focus();case"trigger-watch":return Vt(!Dt),X.focus();case"trigger-full-screen":return Gr(!ar),X.focus();case Be:_r(Be);return;case qe:_r(qe);return;case tt:_r(tt);return;case Ze:_r(Ze);return;default:throw new Error}},[X,Dt,ar]),vi=Object(y.useCallback)(function(mt){_r("");switch(Br){case Be:var Ct=mt.title,yt=mt.link;return X.replaceSelection("[".concat(Ct,"](").concat(yt,")")),X.focus();case qe:var _t=mt.language,Bt=mt.content;return X.replaceSelection(["```"+_t,Bt,"```"].join(`
`)),X.focus();case tt:var Ht=mt.src,Ot=mt.alt,tr=mt.name;return Ht.indexOf("type=image")>-1?X.replaceSelection("![ ".concat(Ot||""," ]( ").concat(Ht,' "').concat(Ot||"",'" )')):Ht.indexOf("type=application/pdf")>-1?X.replaceSelection('<a href="'.concat(Ht,'&disposition=inline" target="_blank">').concat(tr,"</a>")):X.replaceSelection('<a href="'.concat(Ht,'" target="_blank">').concat(tr,"</a>")),X.focus();case Ze:for(var Tr=mt.row,Rt=mt.col,yi=mt.align,Ft=`
`,sr=0;sr<Tr;sr++){for(var zr=[],Kr=[],Wn=0;Wn<Rt;Wn++)sr===1&&Kr.push(ct[yi]),zr.push(" ");sr===1&&(Ft+="| ".concat(Kr.join(" | "),` |
`)),Ft+="| ".concat(zr.join(Rt===1?"":" | "),` |
`)}return X.replaceSelection(Ft+`
`),X.focus();default:throw new Error}},[X,Br]),Un=Object(y.useMemo)(function(){switch(Br){case Be:return w.a.createElement(ae,{callback:vi,onCancel:Dr});case qe:return w.a.createElement(fe.b,{callback:vi,onCancel:Dr});case tt:return w.a.createElement(he,{callback:vi,onCancel:Dr});case Ze:return w.a.createElement(He,{callback:vi,onCancel:Dr});default:return null}},[Br]);function Dr(){_r("")}Object(y.useEffect)(function(){if(ti.current){var mt=ti.current,Ct=!1,yt=0;function _t(Ot){Ct=!0,yt=Ot.pageY}function Bt(){Ct=!1}function Ht(Ot){if(Ct){var tr=Ot.pageY-yt;tr<0&&(tr=0),tr>300&&(tr=300);var Tr=dt+tr+"px";Fr(Tr)}}return mt.addEventListener("mousedown",_t),document.addEventListener("mousemove",Ht),document.addEventListener("mouseup",Bt),function(){mt.removeEventListener("mousedown",_t),document.removeEventListener("mousemove",Ht),document.removeEventListener("mouseup",Bt)}}},[X,ti]),Object(y.useEffect)(function(){Fr(dt)},[dt]);var fn=pe(wt),Zr=pe($r),Vi={width:fn,height:Zr},jn=Object(y.useMemo)(function(){if(ci){var mt=new Date(ci),Ct=mt.getHours(),yt=mt.getMinutes(),_t=mt.getSeconds();return Ct=Ct<10?"0"+Ct:Ct,yt=yt<10?"0"+yt:yt,_t=_t<10?"0"+_t:_t,"".concat(Ct,":").concat(yt,":").concat(_t)}return 0},[ci]);function Ri(){window.sessionStorage.removeItem(nr),Zt(!1),ei(0)}function $a(){Zt(!1),ei(0),X.setValue(window.sessionStorage.getItem(nr))}function ha(mt,Ct){var yt=X.getValue();yt=yt.replace(mt,Ct),ut(yt),X==null||X.setValue(yt)}return w.a.createElement(y.Fragment,null,w.a.createElement("div",{className:"markdown-editor-wrapper",ref:Ut},w.a.createElement("div",{className:"markdown-editor-container ".concat(Tt," ").concat(Dt?"on-preview":""," ").concat(It?"mini":""," ").concat(ar?"full-screen":""),style:Vi},w.a.createElement(E,{insertTemp:Wr,watch:Dt,fullScreen:ar,showNullButton:pt,onActionCallback:Ki,hidetoolBar:li,uuid:Nt.current,setOpenPhones:function(){fr.current=!0}}),w.a.createElement("div",{className:"markdown-editor-body"},w.a.createElement("div",{className:"codemirror-container"},w.a.createElement("textarea",{ref:er,placeholder:ki})),Dt?w.a.createElement("div",{ref:Qt,className:"preview-container"},vt==="stex"&&w.a.createElement(L,{value:Ye}),vt!=="stex"&&w.a.createElement(p.a,{edit:!0,value:Ye,replaces:ha})):null))),Hr?w.a.createElement("a",{ref:ti,className:"editor-resize"}):null,w.a.createElement(N.a,null,ue[Br]?w.a.createElement(Q.a,{centered:!0,title:ue[Br],visible:!0,onCancel:Dr,footer:null},Un):null))}},SJMd:function(xt,at){/**
* @license
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var se,le,Q,_=!1,Z,B;window.PR_SHOULD_USE_CONTINUATION=!0;var P,z;(function(){var W=window,I=["break,continue,do,else,for,if,return,while"],D=[I,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],y=[D,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],w=[y,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],O=[y,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],k=[y,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],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",T=[y,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="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=[I,"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=[I,"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"],d=[I,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],C=[w,k,O,T,h,o,l,d],f=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,p="str",L="kwd",b="com",g="typ",c="lit",u="pun",a="pln",x="tag",v="dec",E="src",N="atn",F="atv",K="nocode",V="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function R(xe){for(var Oe=0,Me=!1,He=!1,We=0,Fe=xe.length;We<Fe;++We){var Be=xe[We];if(Be.ignoreCase)He=!0;else if(/[a-z]/i.test(Be.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Me=!0,He=!1;break}}var tt={b:8,t:9,n:10,v:11,f:12,r:13};function qe(it){var Pe=it.charCodeAt(0);if(Pe!==92)return Pe;var st=it.charAt(1);return Pe=tt[st],Pe||("0"<=st&&st<="7"?parseInt(it.substring(1),8):st==="u"||st==="x"?parseInt(it.substring(2),16):it.charCodeAt(1))}function Ze(it){if(it<32)return(it<16?"\\x0":"\\x")+it.toString(16);var Pe=String.fromCharCode(it);return Pe==="\\"||Pe==="-"||Pe==="]"||Pe==="^"?"\\"+Pe:Pe}function $e(it){var Pe=it.substring(1,it.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),st=[],nt=Pe[0]==="^",Ie=["["];nt&&Ie.push("^");for(var ze=nt?1:0,be=Pe.length;ze<be;++ze){var pe=Pe[ze];if(/\\[bdsw]/i.test(pe))Ie.push(pe);else{var ve=qe(pe),re;ze+2<be&&Pe[ze+1]==="-"?(re=qe(Pe[ze+2]),ze+=2):re=ve,st.push([ve,re]),re<65||ve>122||(re<65||ve>90||st.push([Math.max(65,ve)|32,Math.min(re,90)|32]),re<97||ve>122||st.push([Math.max(97,ve)&~32,Math.min(re,122)&~32]))}}st.sort(function(ke,Ee){return ke[0]-Ee[0]||Ee[1]-ke[1]});for(var ie=[],oe=[],ze=0;ze<st.length;++ze){var ue=st[ze];ue[0]<=oe[1]+1?oe[1]=Math.max(oe[1],ue[1]):ie.push(oe=ue)}for(var ze=0;ze<ie.length;++ze){var ue=ie[ze];Ie.push(Ze(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&Ie.push("-"),Ie.push(Ze(ue[1])))}return Ie.push("]"),Ie.join("")}function ct(it){for(var Pe=it.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),st=Pe.length,nt=[],Ie=0,ze=0;Ie<st;++Ie){var be=Pe[Ie];if(be==="(")++ze;else if(be.charAt(0)==="\\"){var pe=+be.substring(1);pe&&(pe<=ze?nt[pe]=-1:Pe[Ie]=Ze(pe))}}for(var Ie=1;Ie<nt.length;++Ie)nt[Ie]===-1&&(nt[Ie]=++Oe);for(var Ie=0,ze=0;Ie<st;++Ie){var be=Pe[Ie];if(be==="(")++ze,nt[ze]||(Pe[Ie]="(?:");else if(be.charAt(0)==="\\"){var pe=+be.substring(1);pe&&pe<=ze&&(Pe[Ie]="\\"+nt[pe])}}for(var Ie=0;Ie<st;++Ie)Pe[Ie]==="^"&&Pe[Ie+1]!=="^"&&(Pe[Ie]="");if(it.ignoreCase&&Me)for(var Ie=0;Ie<st;++Ie){var be=Pe[Ie],ve=be.charAt(0);be.length>=2&&ve==="["?Pe[Ie]=$e(be):ve!=="\\"&&(Pe[Ie]=be.replace(/[a-zA-Z]/g,function(oe){var ue=oe.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return Pe.join("")}for(var rt=[],We=0,Fe=xe.length;We<Fe;++We){var Be=xe[We];if(Be.global||Be.multiline)throw new Error(""+Be);rt.push("(?:"+ct(Be)+")")}return new RegExp(rt.join("|"),He?"gi":"g")}function M(xe,Oe){var Me=/(?:^|\s)nocode(?:\s|$)/,He=[],We=0,Fe=[],Be=0;function tt(qe){var Ze=qe.nodeType;if(Ze==1){if(Me.test(qe.className))return;for(var $e=qe.firstChild;$e;$e=$e.nextSibling)tt($e);var ct=qe.nodeName.toLowerCase();(ct==="br"||ct==="li")&&(He[Be]=`
`,Fe[Be<<1]=We++,Fe[Be++<<1|1]=qe)}else if(Ze==3||Ze==4){var rt=qe.nodeValue;rt.length&&(Oe?rt=rt.replace(/\r\n?/g,`
`):rt=rt.replace(/[ \t\r\n]+/g," "),He[Be]=rt,Fe[Be<<1]=We,We+=rt.length,Fe[Be++<<1|1]=qe)}}return tt(xe),{sourceCode:He.join("").replace(/\n$/,""),spans:Fe}}function $(xe,Oe,Me,He,We){if(!Me)return;var Fe={sourceNode:xe,pre:1,langExtension:null,numberLines:null,sourceCode:Me,spans:null,basePos:Oe,decorations:null};He(Fe),We.push.apply(We,Fe.decorations)}var ee=/\S/;function ae(xe){for(var Oe=void 0,Me=xe.firstChild;Me;Me=Me.nextSibling){var He=Me.nodeType;Oe=He===1?Oe?xe:Me:He===3&&ee.test(Me.nodeValue)?xe:Oe}return Oe===xe?void 0:Oe}function fe(xe,Oe){var Me={},He;(function(){for(var Be=xe.concat(Oe),tt=[],qe={},Ze=0,$e=Be.length;Ze<$e;++Ze){var ct=Be[Ze],rt=ct[3];if(rt)for(var it=rt.length;--it>=0;)Me[rt.charAt(it)]=ct;var Pe=ct[1],st=""+Pe;qe.hasOwnProperty(st)||(tt.push(Pe),qe[st]=null)}tt.push(/[\0-\uffff]/),He=R(tt)})();var We=Oe.length,Fe=function(Be){for(var tt=Be.sourceCode,qe=Be.basePos,Ze=Be.sourceNode,$e=[qe,a],ct=0,rt=tt.match(He)||[],it={},Pe=0,st=rt.length;Pe<st;++Pe){var nt=rt[Pe],Ie=it[nt],ze=void 0,be;if(typeof Ie=="string")be=!1;else{var pe=Me[nt.charAt(0)];if(pe)ze=nt.match(pe[1]),Ie=pe[0];else{for(var ve=0;ve<We;++ve)if(pe=Oe[ve],ze=nt.match(pe[1]),ze){Ie=pe[0];break}ze||(Ie=a)}be=Ie.length>=5&&Ie.substring(0,5)==="lang-",be&&!(ze&&typeof ze[1]=="string")&&(be=!1,Ie=E),be||(it[nt]=Ie)}var re=ct;if(ct+=nt.length,!be)$e.push(qe+re,Ie);else{var ie=ze[1],oe=nt.indexOf(ie),ue=oe+ie.length;ze[2]&&(ue=nt.length-ze[2].length,oe=ue-ie.length);var ke=Ie.substring(5);$(Ze,qe+re,nt.substring(0,oe),Fe,$e),$(Ze,qe+re+oe,ie,he(ke,ie),$e),$(Ze,qe+re+ue,nt.substring(ue),Fe,$e)}}Be.decorations=$e};return Fe}function De(xe){var Oe=[],Me=[];xe.tripleQuotedStrings?Oe.push([p,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):xe.multiLineStrings?Oe.push([p,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Oe.push([p,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),xe.verbatimStrings&&Me.push([p,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var He=xe.hashComments;He&&(xe.cStyleComments?(He>1?Oe.push([b,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Oe.push([b,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Me.push([p,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Oe.push([b,/^#[^\r\n]*/,null,"#"])),xe.cStyleComments&&(Me.push([b,/^\/\/[^\r\n]*/,null]),Me.push([b,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var We=xe.regexLiterals;if(We){var Fe=We>1?"":`
\r`,Be=Fe?".":"[\\S\\s]",tt="/(?=[^/*"+Fe+"])(?:[^/\\x5B\\x5C"+Fe+"]|\\x5C"+Be+"|\\x5B(?:[^\\x5C\\x5D"+Fe+"]|\\x5C"+Be+")*(?:\\x5D|$))+/";Me.push(["lang-regex",RegExp("^"+V+"("+tt+")")])}var qe=xe.types;qe&&Me.push([g,qe]);var Ze=(""+xe.keywords).replace(/^ | $/g,"");Ze.length&&Me.push([L,new RegExp("^(?:"+Ze.replace(/[\s,]+/g,"|")+")\\b"),null]),Oe.push([a,/^\s+/,null,` \r
\xA0`]);var $e="^.[^\\s\\w.$@'\"`/\\\\]*";return xe.regexLiterals&&($e+="(?!s*/)"),Me.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[g,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[u,new RegExp($e),null]),fe(Oe,Me)}var Se=De({keywords:C,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ce(xe,Oe,Me){for(var He=/(?:^|\s)nocode(?:\s|$)/,We=/\r\n?|\n/,Fe=xe.ownerDocument,Be=Fe.createElement("li");xe.firstChild;)Be.appendChild(xe.firstChild);var tt=[Be];function qe(Pe){var st=Pe.nodeType;if(st==1&&!He.test(Pe.className))if(Pe.nodeName==="br")Ze(Pe),Pe.parentNode&&Pe.parentNode.removeChild(Pe);else for(var nt=Pe.firstChild;nt;nt=nt.nextSibling)qe(nt);else if((st==3||st==4)&&Me){var Ie=Pe.nodeValue,ze=Ie.match(We);if(ze){var be=Ie.substring(0,ze.index);Pe.nodeValue=be;var pe=Ie.substring(ze.index+ze[0].length);if(pe){var ve=Pe.parentNode;ve.insertBefore(Fe.createTextNode(pe),Pe.nextSibling)}Ze(Pe),be||Pe.parentNode.removeChild(Pe)}}}function Ze(Pe){for(;!Pe.nextSibling;)if(Pe=Pe.parentNode,!Pe)return;function st(ze,be){var pe=be?ze.cloneNode(!1):ze,ve=ze.parentNode;if(ve){var re=st(ve,1),ie=ze.nextSibling;re.appendChild(pe);for(var oe=ie;oe;oe=ie)ie=oe.nextSibling,re.appendChild(oe)}return pe}for(var nt=st(Pe.nextSibling,0),Ie;(Ie=nt.parentNode)&&Ie.nodeType===1;)nt=Ie;tt.push(nt)}for(var $e=0;$e<tt.length;++$e)qe(tt[$e]);Oe===(Oe|0)&&tt[0].setAttribute("value",Oe);var ct=Fe.createElement("ol");ct.className="linenums";for(var rt=Math.max(0,Oe-1|0)||0,$e=0,it=tt.length;$e<it;++$e)Be=tt[$e],Be.className="L"+($e+rt)%10,Be.firstChild||Be.appendChild(Fe.createTextNode("\xA0")),ct.appendChild(Be);xe.appendChild(ct)}function we(xe){var Oe=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Oe=Oe&&+Oe[1]<=8;var Me=/\n/g,He=xe.sourceCode,We=He.length,Fe=0,Be=xe.spans,tt=Be.length,qe=0,Ze=xe.decorations,$e=Ze.length,ct=0;Ze[$e]=We;var rt,it;for(it=rt=0;it<$e;)Ze[it]!==Ze[it+2]?(Ze[rt++]=Ze[it++],Ze[rt++]=Ze[it++]):it+=2;for($e=rt,it=rt=0;it<$e;){for(var Pe=Ze[it],st=Ze[it+1],nt=it+2;nt+2<=$e&&Ze[nt+1]===st;)nt+=2;Ze[rt++]=Pe,Ze[rt++]=st,it=nt}$e=Ze.length=rt;var Ie=xe.sourceNode,ze="";Ie&&(ze=Ie.style.display,Ie.style.display="none");try{for(var be=null;qe<tt;){var pe=Be[qe],ve=Be[qe+2]||We,re=Ze[ct+2]||We,nt=Math.min(ve,re),ie=Be[qe+1],oe;if(ie.nodeType!==1&&(oe=He.substring(Fe,nt))){Oe&&(oe=oe.replace(Me,"\r")),ie.nodeValue=oe;var ue=ie.ownerDocument,ke=ue.createElement("span");ke.className=Ze[ct+1];var Ee=ie.parentNode;Ee.replaceChild(ke,ie),ke.appendChild(ie),Fe<ve&&(Be[qe+1]=ie=ue.createTextNode(He.substring(nt,ve)),Ee.insertBefore(ie,ke.nextSibling))}Fe=nt,Fe>=ve&&(qe+=2),Fe>=re&&(ct+=2)}}finally{Ie&&(Ie.style.display=ze)}}var Te={};function me(xe,Oe){for(var Me=Oe.length;--Me>=0;){var He=Oe[Me];Te.hasOwnProperty(He)?W.console&&console.warn("cannot override language handler %s",He):Te[He]=xe}}function he(xe,Oe){return xe&&Te.hasOwnProperty(xe)||(xe=/^\s*</.test(Oe)?"default-markup":"default-code"),Te[xe]}me(Se,["default-code"]),me(fe([],[[a,/^[^<?]+/],[v,/^<!\w[^>]*(?:>|$)/],[b,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[u,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),me(fe([[a,/^[\s]+/,null,` \r
`],[F,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[x,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[N,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[u,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),me(fe([],[[F,/^[\s\S]+/]]),["uq.val"]),me(De({keywords:w,hashComments:!0,cStyleComments:!0,types:f}),["c","cc","cpp","cxx","cyc","m"]),me(De({keywords:"null,true,false"}),["json"]),me(De({keywords:k,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:f}),["cs"]),me(De({keywords:O,cStyleComments:!0}),["java"]),me(De({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(De({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(De({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(De({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(De({keywords:T,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(De({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(fe([],[[p,/^[\s\S]+/]]),["regex"]);function te(xe){var Oe=xe.langExtension;try{var Me=M(xe.sourceNode,xe.pre),He=Me.sourceCode;xe.sourceCode=He,xe.spans=Me.spans,xe.basePos=0,he(Oe,He)(xe),we(xe)}catch(We){W.console&&console.log(We&&We.stack||We)}}function de(xe,Oe,Me){var He=Me||!1,We=Oe||null,Fe=document.createElement("div");Fe.innerHTML="<pre>"+xe+"</pre>",Fe=Fe.firstChild,He&&Ce(Fe,He,!0);var Be={langExtension:We,numberLines:He,sourceNode:Fe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return te(Be),Fe.innerHTML}function ne(xe,Oe){var Me=Oe||document.body,He=Me.ownerDocument||document;function We(pe){return Me.getElementsByTagName(pe)}for(var Fe=[We("pre"),We("code"),We("xmp")],Be=[],tt=0;tt<Fe.length;++tt)for(var qe=0,Ze=Fe[tt].length;qe<Ze;++qe)Be.push(Fe[tt][qe]);Fe=null;var $e=Date;$e.now||($e={now:function(){return+new Date}});var ct=0,rt=/\blang(?:uage)?-([\w.]+)(?!\S)/,it=/\bprettyprint\b/,Pe=/\bprettyprinted\b/,st=/pre|xmp/i,nt=/^code$/i,Ie=/^(?:pre|code|xmp)$/i,ze={};function be(){for(var pe=W.PR_SHOULD_USE_CONTINUATION?$e.now()+250:Infinity;ct<Be.length&&$e.now()<pe;ct++){for(var ve=Be[ct],re=ze,ie=ve;ie=ie.previousSibling;){var oe=ie.nodeType,ue=(oe===7||oe===8)&&ie.nodeValue;if(ue?!/^\??prettify\b/.test(ue):oe!==3||/\S/.test(ie.nodeValue))break;if(ue){re={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Wt,Lt,Wr){re[Lt]=Wr});break}}var ke=ve.className;if((re!==ze||it.test(ke))&&!Pe.test(ke)){for(var Ee=!1,Ue=ve.parentNode;Ue;Ue=Ue.parentNode){var et=Ue.tagName;if(Ie.test(et)&&Ue.className&&it.test(Ue.className)){Ee=!0;break}}if(!Ee){ve.className+=" prettyprinted";var ft=re.lang;if(!ft){ft=ke.match(rt);var lt;!ft&&(lt=ae(ve))&&nt.test(lt.tagName)&&(ft=lt.className.match(rt)),ft&&(ft=ft[1])}var wt;if(st.test(ve.tagName))wt=1;else{var St=ve.currentStyle,dt=He.defaultView,zt=St?St.whiteSpace:dt&&dt.getComputedStyle?dt.getComputedStyle(ve,null).getPropertyValue("white-space"):0;wt=zt&&zt.substring(0,3)==="pre"}var It=re.linenums;(It=It==="true"||+It)||(It=ke.match(/\blinenums\b(?::(\d+))?/),It=It?It[1]&&It[1].length?+It[1]:!0:!1),It&&Ce(ve,It,wt);var Kt={langExtension:ft,sourceNode:ve,numberLines:It,pre:wt,sourceCode:null,basePos:null,spans:null,decorations:null};te(Kt)}}}ct<Be.length?W.setTimeout(be,250):typeof xe=="function"&&xe()}be()}var Le=W.PR={createSimpleLexer:fe,registerLangHandler:me,sourceDecorator:De,PR_ATTRIB_NAME:N,PR_ATTRIB_VALUE:F,PR_COMMENT:b,PR_DECLARATION:v,PR_KEYWORD:L,PR_LITERAL:c,PR_NOCODE:K,PR_PLAIN:a,PR_PUNCTUATION:u,PR_SOURCE:E,PR_STRING:p,PR_TAG:x,PR_TYPE:g,prettyPrintOne:_?W.prettyPrintOne=de:P=de,prettyPrint:z=_?W.prettyPrint=ne:z=ne},Re=W.define;typeof Re=="function"&&Re.amd&&Re("google-code-prettify",[],function(){return Le})})()},"VrN/":function(xt,at,se){(function(le,Q){xt.exports=Q()})(this,function(){"use strict";var le=navigator.userAgent,Q=navigator.platform,_=/gecko\/\d/i.test(le),Z=/MSIE \d/.test(le),B=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(le),P=/Edge\/(\d+)/.exec(le),z=Z||B||P,W=z&&(Z?document.documentMode||6:+(P||B)[1]),I=!P&&/WebKit\//.test(le),D=I&&/Qt\/\d+\.\d+/.test(le),y=!P&&/Chrome\//.test(le),w=/Opera\//.test(le),O=/Apple Computer/.test(navigator.vendor),k=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(le),A=/PhantomJS/.test(le),T=!P&&/AppleWebKit/.test(le)&&/Mobile\/\w+/.test(le),h=/Android/.test(le),o=T||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(le),l=T||/Mac/.test(Q),d=/\bCrOS\b/.test(le),C=/win/i.test(Q),f=w&&le.match(/Version\/(\d*\.\d*)/);f&&(f=Number(f[1])),f&&f>=15&&(w=!1,I=!0);var p=l&&(D||w&&(f==null||f<12.11)),L=_||z&&W>=9;function b(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var g=function(e,t){var i=e.className,r=b(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function c(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function u(e,t){return c(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var S=0;S<t.length;++S)n.appendChild(t[S]);return n}function x(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var v;document.createRange?v=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:v=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function 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 N(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function F(e,t){var i=e.className;b(t).test(i)||(e.className+=(i?" ":"")+t)}function K(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!b(i[r]).test(t)&&(t+=" "+i[r]);return t}var V=function(e){e.select()};T?V=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:z&&(V=function(e){try{e.select()}catch(t){}});function R(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function M(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 $(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var S=r||0,U=n||0;;){var Y=e.indexOf(" ",S);if(Y<0||Y>=t)return U+(t-S);U+=Y-S,U+=i-U%i,S=Y+1}}var ee=function(){this.id=null,this.f=null,this.time=0,this.handler=R(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 fe=50,De={toString:function(){return"CodeMirror.Pass"}},Se={scroll:!1},Ce={origin:"*mouse"},we={origin:"+move"};function Te(e,t,i){for(var r=0,n=0;;){var S=e.indexOf(" ",r);S==-1&&(S=e.length);var U=S-r;if(S==e.length||n+U>=t)return r+Math.min(U,t-n);if(n+=S-r,n+=i-n%i,r=S+1,n>=t)return r}}var me=[""];function he(e){for(;me.length<=e;)me.push(te(me)+" ");return me[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 Le(){}function Re(e,t){var i;return Object.create?i=Object.create(e):(Le.prototype=e,i=new Le),t&&M(t,i),i}var xe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Oe(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||xe.test(e))}function Me(e,t){return t?t.source.indexOf("\\w")>-1&&Oe(e)?!0:t.test(e):Oe(e)}function He(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var We=/[\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 Fe(e){return e.charCodeAt(0)>=768&&We.test(e)}function Be(e,t,i){for(;(i<0?t>0:t<e.length)&&Fe(e.charAt(t));)t+=i;return t}function tt(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,S=r<0?Math.ceil(n):Math.floor(n);if(S==t)return e(S)?t:i;e(S)?i=S:t=S+r}}function qe(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,S=0;S<e.length;++S){var U=e[S];(U.from<i&&U.to>t||t==i&&U.to==t)&&(r(Math.max(U.from,t),Math.min(U.to,i),U.level==1?"rtl":"ltr",S),n=!0)}n||r(t,i,"ltr")}var Ze=null;function $e(e,t,i){var r;Ze=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:Ze=n),S.from==t&&(S.from!=S.to&&i!="before"?r=n:Ze=n)}return r!=null?r:Ze}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]/,U=/[Lb1n]/,Y=/[1n]/;function J(q,ce,ge){this.level=q,this.from=ce,this.to=ge}return function(q,ce){var ge=ce=="ltr"?"L":"R";if(q.length==0||ce=="ltr"&&!r.test(q))return!1;for(var _e=q.length,Ae=[],Ne=0;Ne<_e;++Ne)Ae.push(i(q.charCodeAt(Ne)));for(var Ke=0,Xe=ge;Ke<_e;++Ke){var Je=Ae[Ke];Je=="m"?Ae[Ke]=Xe:Xe=Je}for(var ot=0,Qe=ge;ot<_e;++ot){var ht=Ae[ot];ht=="1"&&Qe=="r"?Ae[ot]="n":S.test(ht)&&(Qe=ht,ht=="r"&&(Ae[ot]="R"))}for(var bt=1,gt=Ae[0];bt<_e-1;++bt){var At=Ae[bt];At=="+"&&gt=="1"&&Ae[bt+1]=="1"?Ae[bt]="1":At==","&&gt==Ae[bt+1]&&(gt=="1"||gt=="n")&&(Ae[bt]=gt),gt=At}for(var Xt=0;Xt<_e;++Xt){var hr=Ae[Xt];if(hr==",")Ae[Xt]="N";else if(hr=="%"){var $t=void 0;for($t=Xt+1;$t<_e&&Ae[$t]=="%";++$t);for(var Or=Xt&&Ae[Xt-1]=="!"||$t<_e&&Ae[$t]=="1"?"1":"N",Ar=Xt;Ar<$t;++Ar)Ae[Ar]=Or;Xt=$t-1}}for(var rr=0,Lr=ge;rr<_e;++rr){var mr=Ae[rr];Lr=="L"&&mr=="1"?Ae[rr]="L":S.test(mr)&&(Lr=mr)}for(var or=0;or<_e;++or)if(n.test(Ae[or])){var ir=void 0;for(ir=or+1;ir<_e&&n.test(Ae[ir]);++ir);for(var Jt=(or?Ae[or-1]:ge)=="L",kr=(ir<_e?Ae[ir]:ge)=="L",un=Jt==kr?Jt?"L":"R":ge,Ai=or;Ai<ir;++Ai)Ae[Ai]=un;or=ir-1}for(var vr=[],ni,dr=0;dr<_e;)if(U.test(Ae[dr])){var Xa=dr;for(++dr;dr<_e&&U.test(Ae[dr]);++dr);vr.push(new J(0,Xa,dr))}else{var mi=dr,ji=vr.length,Wi=ce=="rtl"?1:0;for(++dr;dr<_e&&Ae[dr]!="L";++dr);for(var br=mi;br<dr;)if(Y.test(Ae[br])){mi<br&&(vr.splice(ji,0,new J(1,mi,br)),ji+=Wi);var hn=br;for(++br;br<dr&&Y.test(Ae[br]);++br);vr.splice(ji,0,new J(2,hn,br)),ji+=Wi,mi=br}else++br;mi<dr&&vr.splice(ji,0,new J(1,mi,dr))}return ce=="ltr"&&(vr[0].level==1&&(ni=q.match(/^\s+/))&&(vr[0].from=ni[0].length,vr.unshift(new J(0,0,ni[0].length))),te(vr).level==1&&(ni=q.match(/\s+$/))&&(te(vr).to-=ni[0].length,vr.push(new J(0,_e-ni[0].length,_e)))),ce=="rtl"?vr.reverse():vr}}();function rt(e,t){var i=e.order;return i==null&&(i=e.order=ct(e.text,t)),i}var it=[],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]||it).concat(i)}};function st(e,t){return e._handlers&&e._handlers[t]||it}function nt(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var S=ae(n,i);S>-1&&(r[t]=n.slice(0,S).concat(n.slice(S+1)))}}}function Ie(e,t){var i=st(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function ze(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ie(e,i||t.type,e,t),oe(t)||t.codemirrorIgnore}function be(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 pe(e,t){return st(e,t).length>0}function ve(e){e.prototype.on=function(t,i){Pe(this,t,i)},e.prototype.off=function(t,i){nt(this,t,i)}}function re(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function ie(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function oe(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){re(e),ie(e)}function ke(e){return e.target||e.srcElement}function Ee(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),l&&e.ctrlKey&&t==1&&(t=3),t}var Ue=function(){if(z&&W<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),et;function ft(e){if(et==null){var t=a("span","\u200B");u(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(et=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&W<8))}var i=et?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var lt;function wt(e){if(lt!=null)return lt;var t=u(e,document.createTextNode("A\u062EA")),i=v(t,0,1).getBoundingClientRect(),r=v(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:lt=r.right-i.right<3}var St=`
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
`,t);n==-1&&(n=e.length);var S=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),U=S.indexOf("\r");U!=-1?(i.push(S.slice(0,U)),t+=U+1):(i.push(S),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},dt=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},zt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),It=null;function Kt(e){if(It!=null)return It;var t=u(e,a("span","x")),i=t.getBoundingClientRect(),r=v(t,0,1).getBoundingClientRect();return It=Math.abs(i.left-r.left)>1}var Wt={},Lt={};function Wr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Wt[e]=t}function ai(e,t){Lt[e]=t}function vt(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=Re(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return vt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return vt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Vr(e,t){t=vt(t);var i=Wt[t.name];if(!i)return Vr(e,"text/plain");var r=i(e,t);if(nr.hasOwnProperty(t.name)){var n=nr[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 U in t.modeProps)r[U]=t.modeProps[U];return r}var nr={};function cr(e,t){var i=nr.hasOwnProperty(e)?nr[e]:nr[e]={};M(t,i)}function Hr(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 oi(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 si(e,t,i){return e.startState?e.startState(t,i):!0}var Pt=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};Pt.prototype.eol=function(){return this.pos>=this.string.length},Pt.prototype.sol=function(){return this.pos==this.lineStart},Pt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Pt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Pt.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},Pt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Pt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Pt.prototype.skipToEnd=function(){this.pos=this.string.length},Pt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Pt.prototype.backUp=function(e){this.pos-=e},Pt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=$(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?$(this.string,this.lineStart,this.tabSize):0)},Pt.prototype.indentation=function(){return $(this.string,null,this.tabSize)-(this.lineStart?$(this.string,this.lineStart,this.tabSize):0)},Pt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(U){return i?U.toLowerCase():U},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var S=this.string.slice(this.pos).match(e);return S&&S.index>0?null:(S&&t!==!1&&(this.pos+=S[0].length),S)}},Pt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Pt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Pt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Pt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function pt(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],S=n.chunkSize();if(t<S){i=n;break}t-=S}return i.lines[t]}function Pr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(S){var U=S.text;n==i.line&&(U=U.slice(0,i.ch)),n==t.line&&(U=U.slice(t.ch)),r.push(U),++n}),r}function li(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function xr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function kt(e){if(e.parent==null)return null;for(var t=e.parent,i=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 Mr(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 U=0;U<e.lines.length;++U){var Y=e.lines[U],J=Y.height;if(t<J)break;t-=J}return i+U}function Xr(e,t){return t>=e.first&&t<e.first+e.size}function ui(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 Tt(e,t){return e.line-t.line||e.ch-t.ch}function hi(e,t){return e.sticky==t.sticky&&Tt(e,t)==0}function Li(e){return Ve(e.line,e.ch)}function di(e,t){return Tt(e,t)<0?t:e}function ki(e,t){return Tt(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,pt(e,i).text.length):m(t,pt(e,t.line).text.length)}function m(e,t){var i=e.ch;return i==null||i>t?Ve(e.line,t):i<0?Ve(e.line,0):e}function j(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var X=function(e,t){this.state=e,this.lookAhead=t},H=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};H.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},H.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},H.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},H.fromSaved=function(e,t,i){return t instanceof X?new H(e,Hr(e.mode,t.state),i,t.lookAhead):new H(e,Hr(e.mode,t),i)},H.prototype.save=function(e){var t=e!==!1?Hr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new X(t,this.maxLookAhead):t};function ye(e,t,i,r){var n=[e.state.modeGen],S={};Nr(e,t.text,e.doc.mode,i,function(q,ce){return n.push(q,ce)},S,r);for(var U=i.state,Y=function(q){i.baseTokens=n;var ce=e.state.overlays[q],ge=1,_e=0;i.state=!0,Nr(e,t.text,ce.mode,i,function(Ae,Ne){for(var Ke=ge;_e<Ae;){var Xe=n[ge];Xe>Ae&&n.splice(ge,1,Ae,n[ge+1],Xe),ge+=2,_e=Math.min(Ae,Xe)}if(!Ne)return;if(ce.opaque)n.splice(Ke,ge-Ke,Ae,"overlay "+Ne),ge=Ke+2;else for(;Ke<ge;Ke+=2){var Je=n[Ke+1];n[Ke+1]=(Je?Je+" ":"")+"overlay "+Ne}},S),i.state=U,i.baseTokens=null,i.baseTokenPos=1},J=0;J<e.state.overlays.length;++J)Y(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=Ye(e,kt(t)),n=t.text.length>e.options.maxHighlightLength&&Hr(e.doc.mode,r.state),S=ye(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 Ye(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new H(r,!0,t);var S=ar(e,t,i),U=S>r.first&&pt(r,S-1).stateAfter,Y=U?H.fromSaved(r,U,S):new H(r,si(r.mode),S);return r.iter(S,t,function(J){ut(e,J.text,Y);var q=Y.line;J.stateAfter=q==t-1||q%5==0||q>=n.viewFrom&&q<n.viewTo?Y.save():null,Y.nextLine()}),i&&(r.modeFrontier=Y.line),Y}function ut(e,t,i,r){var n=e.doc.mode,S=new Pt(t,e.options.tabSize,i);for(S.start=S.pos=r||0,t==""&&Ge(n,i.state);!S.eol();)Et(n,S,i.state),S.start=S.pos}function Ge(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=oi(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function Et(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=oi(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 Dt=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Vt(e,t,i,r){var n=e.doc,S=n.mode,U;t=s(n,t);var Y=pt(n,t.line),J=Ye(e,t.line,i),q=new Pt(Y.text,e.options.tabSize,J),ce;for(r&&(ce=[]);(r||q.pos<t.ch)&&!q.eol();)q.start=q.pos,U=Et(S,q,J.state),r&&ce.push(new Dt(q,U,Hr(n.mode,J.state)));return r?ce:new Dt(q,U,J.state)}function Ir(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 Nr(e,t,i,r,n,S,U){var Y=i.flattenSpans;Y==null&&(Y=e.options.flattenSpans);var J=0,q=null,ce=new Pt(t,e.options.tabSize,r),ge,_e=e.options.addModeClass&&[null];for(t==""&&Ir(Ge(i,r.state),S);!ce.eol();){if(ce.pos>e.options.maxHighlightLength?(Y=!1,U&&ut(e,t,r,ce.pos),ce.pos=t.length,ge=null):ge=Ir(Et(i,ce,r.state,_e),S),_e){var Ae=_e[0].name;Ae&&(ge="m-"+(ge?Ae+" "+ge:Ae))}if(!Y||q!=ge){for(;J<ce.start;)J=Math.min(ce.start,J+5e3),n(J,q);q=ge}ce.start=ce.pos}for(;J<ce.pos;){var Ne=Math.min(ce.pos,J+5e3);n(Ne,q),J=Ne}}function ar(e,t,i){for(var r,n,S=e.doc,U=i?-1:t-(e.doc.mode.innerMode?1e3:100),Y=t;Y>U;--Y){if(Y<=S.first)return S.first;var J=pt(S,Y-1),q=J.stateAfter;if(q&&(!i||Y+(q instanceof X?q.lookAhead:0)<=S.modeFrontier))return Y;var ce=$(J.text,null,e.options.tabSize);(n==null||r>ce)&&(n=Y-1,r=ce)}return n}function Gr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=pt(e,r).stateAfter;if(n&&(!(n instanceof X)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Hi=!1,Er=!1;function Br(){Hi=!0}function _r(){Er=!0}function gi(e,t,i){this.marker=e,this.from=t,this.to=i}function Yr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function ci(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function ei(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function dn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],U=S.marker,Y=S.from==null||(U.inclusiveLeft?S.from<=t:S.from<t);if(Y||S.from==t&&U.type=="bookmark"&&(!i||!S.marker.insertLeft)){var J=S.to==null||(U.inclusiveRight?S.to>=t:S.to>t);(r||(r=[])).push(new gi(U,S.from,J?null:S.to))}}return r}function Gi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var S=e[n],U=S.marker,Y=S.to==null||(U.inclusiveRight?S.to>=t:S.to>t);if(Y||S.from==t&&U.type=="bookmark"&&(!i||S.marker.insertLeft)){var J=S.from==null||(U.inclusiveLeft?S.from<=t:S.from<t);(r||(r=[])).push(new gi(U,J?null:S.from-t,S.to==null?null:S.to-t))}}return r}function $r(e,t){if(t.full)return null;var i=Xr(e,t.from.line)&&pt(e,t.from.line).markedSpans,r=Xr(e,t.to.line)&&pt(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,S=t.to.ch,U=Tt(t.from,t.to)==0,Y=dn(i,n,U),J=Gi(r,S,U),q=t.text.length==1,ce=te(t.text).length+(q?n:0);if(Y)for(var ge=0;ge<Y.length;++ge){var _e=Y[ge];if(_e.to==null){var Ae=Yr(J,_e.marker);Ae?q&&(_e.to=Ae.to==null?null:Ae.to+ce):_e.to=n}}if(J)for(var Ne=0;Ne<J.length;++Ne){var Ke=J[Ne];if(Ke.to!=null&&(Ke.to+=ce),Ke.from==null){var Xe=Yr(Y,Ke.marker);Xe||(Ke.from=ce,q&&(Y||(Y=[])).push(Ke))}else Ke.from+=ce,q&&(Y||(Y=[])).push(Ke)}Y&&(Y=Fr(Y)),J&&J!=Y&&(J=Fr(J));var Je=[Y];if(!q){var ot=t.text.length-2,Qe;if(ot>0&&Y)for(var ht=0;ht<Y.length;++ht)Y[ht].to==null&&(Qe||(Qe=[])).push(new gi(Y[ht].marker,null,null));for(var bt=0;bt<ot;++bt)Je.push(Qe);Je.push(J)}return Je}function Fr(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function _i(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(Ae){if(Ae.markedSpans)for(var Ne=0;Ne<Ae.markedSpans.length;++Ne){var Ke=Ae.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 U=r[S],Y=U.find(0),J=0;J<n.length;++J){var q=n[J];if(Tt(q.to,Y.from)<0||Tt(q.from,Y.to)>0)continue;var ce=[J,1],ge=Tt(q.from,Y.from),_e=Tt(q.to,Y.to);(ge<0||!U.inclusiveLeft&&!ge)&&ce.push({from:q.from,to:Y.from}),(_e>0||!U.inclusiveRight&&!_e)&&ce.push({from:Y.to,to:q.to}),n.splice.apply(n,ce),J+=ce.length-3}return n}function Di(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function cn(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Zt(e){return e.inclusiveLeft?-1:0}function Nt(e){return e.inclusiveRight?1:0}function fr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),S=Tt(r.from,n.from)||Zt(e)-Zt(t);if(S)return-S;var U=Tt(r.to,n.to)||Nt(e)-Nt(t);return U||t.id-e.id}function Mt(e,t){var i=Er&&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||fr(r,n.marker)<0)&&(r=n.marker);return r}function er(e){return Mt(e,!0)}function Ut(e){return Mt(e,!1)}function ti(e,t){var i=Er&&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||fr(r,S.marker)<0)&&(r=S.marker)}return r}function Qt(e,t,i,r,n){var S=pt(e,t),U=Er&&S.markedSpans;if(U)for(var Y=0;Y<U.length;++Y){var J=U[Y];if(!J.marker.collapsed)continue;var q=J.marker.find(0),ce=Tt(q.from,i)||Zt(J.marker)-Zt(n),ge=Tt(q.to,r)||Nt(J.marker)-Nt(n);if(ce>=0&&ge<=0||ce<=0&&ge>=0)continue;if(ce<=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?Tt(q.to,i)>=0:Tt(q.to,i)>0)||ce>=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?Tt(q.from,r)<=0:Tt(q.from,r)<0))return!0}}function Sr(e){for(var t;t=er(e);)e=t.find(-1,!0).line;return e}function zi(e){for(var t;t=Ut(e);)e=t.find(1,!0).line;return e}function Ki(e){for(var t,i;t=Ut(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function vi(e,t){var i=pt(e,t),r=Sr(i);return i==r?t:kt(r)}function Un(e,t){if(t>e.lastLine())return t;var i=pt(e,t),r;if(!Dr(e,i))return t;for(;r=Ut(i);)i=r.find(1,!0).line;return kt(i)+1}function Dr(e,t){var i=Er&&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,Yr(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 Zr(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 U=0;U<S.children.length;++U){var Y=S.children[U];if(Y==i)break;t+=Y.height}return t}function Vi(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=er(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Ut(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=pt(i,i.first),t.maxLineLength=Vi(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=Vi(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Ri=function(e,t,i){this.text=e,cn(this,t),this.height=i?i(this):1};Ri.prototype.lineNo=function(){return kt(this)},ve(Ri);function $a(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Di(e),cn(e,i);var n=r?r(e):1;n!=e.height&&xr(e,n)}function ha(e){e.parent=null,Di(e)}var mt={},Ct={};function yt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ct:mt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function _t(e,t){var i=x("span",null,null,I?"padding-right: .1px":null),r={pre:x("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var S=n?t.rest[n-1]:t.line,U=void 0;r.pos=0,r.addToken=Ht,wt(e.display.measure)&&(U=rt(S,e.doc.direction))&&(r.addToken=tr(r.addToken,U)),r.map=[];var Y=t!=e.display.externalMeasured&&kt(S);Rt(S,r,je(e,S,Y)),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(ft(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(I){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 Ie(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=K(r.pre.className,r.textClass||"")),r}function Bt(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 Ht(e,t,i,r,n,S,U){if(!t)return;var Y=e.splitSpaces?Ot(t,e.trailingSpace):t,J=e.cm.state.specialChars,q=!1,ce;if(!J.test(t))e.col+=t.length,ce=document.createTextNode(Y),e.map.push(e.pos,e.pos+t.length,ce),z&&W<9&&(q=!0),e.pos+=t.length;else{ce=document.createDocumentFragment();for(var ge=0;;){J.lastIndex=ge;var _e=J.exec(t),Ae=_e?_e.index-ge:t.length-ge;if(Ae){var Ne=document.createTextNode(Y.slice(ge,ge+Ae));z&&W<9?ce.appendChild(a("span",[Ne])):ce.appendChild(Ne),e.map.push(e.pos,e.pos+Ae,Ne),e.col+=Ae,e.pos+=Ae}if(!_e)break;ge+=Ae+1;var Ke=void 0;if(_e[0]==" "){var Xe=e.cm.options.tabSize,Je=Xe-e.col%Xe;Ke=ce.appendChild(a("span",he(Je),"cm-tab")),Ke.setAttribute("role","presentation"),Ke.setAttribute("cm-text"," "),e.col+=Je}else _e[0]=="\r"||_e[0]==`
`?(Ke=ce.appendChild(a("span",_e[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ke.setAttribute("cm-text",_e[0]),e.col+=1):(Ke=e.cm.options.specialCharPlaceholder(_e[0]),Ke.setAttribute("cm-text",_e[0]),z&&W<9?ce.appendChild(a("span",[Ke])):ce.appendChild(Ke),e.col+=1);e.map.push(e.pos,e.pos+1,Ke),e.pos++}}if(e.trailingSpace=Y.charCodeAt(t.length-1)==32,i||r||n||q||S||U){var ot=i||"";r&&(ot+=r),n&&(ot+=n);var Qe=a("span",[ce],ot,S);if(U)for(var ht in U)U.hasOwnProperty(ht)&&ht!="style"&&ht!="class"&&Qe.setAttribute(ht,U[ht]);return e.content.appendChild(Qe)}e.content.appendChild(ce)}function Ot(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 tr(e,t){return function(i,r,n,S,U,Y,J){n=n?n+" cm-force-border":"cm-force-border";for(var q=i.pos,ce=q+r.length;;){for(var ge=void 0,_e=0;_e<t.length&&!(ge=t[_e],ge.to>q&&ge.from<=q);_e++);if(ge.to>=ce)return e(i,r,n,S,U,Y,J);e(i,r.slice(0,ge.to-q),n,S,null,Y,J),S=null,r=r.slice(ge.to-q),q=ge.to}}}function Tr(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 Rt(e,t,i){var r=e.markedSpans,n=e.text,S=0;if(!r){for(var U=1;U<i.length;U+=2)t.addToken(t,n.slice(S,S=i[U]),yt(i[U+1],t.cm.options));return}for(var Y=n.length,J=0,q=1,ce="",ge,_e,Ae=0,Ne,Ke,Xe,Je,ot;;){if(Ae==J){Ne=Ke=Xe=_e="",ot=null,Je=null,Ae=Infinity;for(var Qe=[],ht=void 0,bt=0;bt<r.length;++bt){var gt=r[bt],At=gt.marker;if(At.type=="bookmark"&&gt.from==J&&At.widgetNode)Qe.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&&Ae>gt.to&&(Ae=gt.to,Ke=""),At.className&&(Ne+=" "+At.className),At.css&&(_e=(_e?_e+";":"")+At.css),At.startStyle&&gt.from==J&&(Xe+=" "+At.startStyle),At.endStyle&&gt.to==Ae&&(ht||(ht=[])).push(At.endStyle,gt.to),At.title&&((ot||(ot={})).title=At.title),At.attributes)for(var Xt in At.attributes)(ot||(ot={}))[Xt]=At.attributes[Xt];At.collapsed&&(!Je||fr(Je.marker,At)<0)&&(Je=gt)}else gt.from>J&&Ae>gt.from&&(Ae=gt.from)}if(ht)for(var hr=0;hr<ht.length;hr+=2)ht[hr+1]==Ae&&(Ke+=" "+ht[hr]);if(!Je||Je.from==J)for(var $t=0;$t<Qe.length;++$t)Tr(t,0,Qe[$t]);if(Je&&(Je.from||0)==J){if(Tr(t,(Je.to==null?Y+1:Je.to)-J,Je.marker,Je.from==null),Je.to==null)return;Je.to==J&&(Je=!1)}}if(J>=Y)break;for(var Or=Math.min(Y,Ae);;){if(ce){var Ar=J+ce.length;if(!Je){var rr=Ar>Or?ce.slice(0,Or-J):ce;t.addToken(t,rr,ge?ge+Ne:Ne,Xe,J+rr.length==Ae?Ke:"",_e,ot)}if(Ar>=Or){ce=ce.slice(Or-J),J=Or;break}J=Ar,Xe=""}ce=n.slice(S,S=i[q++]),ge=yt(i[q++],t.cm.options)}}}function yi(e,t,i){this.line=t,this.rest=Ki(t),this.size=this.rest?kt(te(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Dr(e,t)}function Ft(e,t,i){for(var r=[],n,S=t;S<i;S=n){var U=new yi(e.doc,pt(e.doc,S),S);n=S+U.size,r.push(U)}return r}var sr=null;function zr(e){sr?sr.ops.push(e):e.ownsGroup=sr={ops:[e],delayedCallbacks:[]}}function Kr(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function Wn(e,t){var i=e.ownsGroup;if(!i)return;try{Kr(i)}finally{sr=null,t(i)}}var pn=null;function pr(e,t){var i=st(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;sr?n=sr.delayedCallbacks:pn?n=pn:(n=pn=[],setTimeout(Os,0));for(var S=function(Y){n.push(function(){return i[Y].apply(null,r)})},U=0;U<i.length;++U)S(U)}function Os(){var e=pn;pn=null;for(var t=0;t<e.length;++t)e[t]()}function Za(e,t,i,r){for(var n=0;n<t.changes.length;n++){var S=t.changes[n];S=="text"?Ms(e,t):S=="gutter"?Qa(e,t,i,r):S=="class"?da(e,t):S=="widget"&&Is(e,t,r)}t.changes=null}function mn(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),z&&W<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=mn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function Ja(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):_t(e,t)}function Ms(e,t){var i=t.text.className,r=Ja(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,da(e,t)):i&&(t.text.className=i)}function da(e,t){Ps(e,t),t.line.wrapClass?mn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Qa(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=mn(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var S=t.line.gutterMarkers;if(e.options.lineNumbers||S){var U=mn(t),Y=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(Y),U.insertBefore(Y,t.text),t.line.gutterClass&&(Y.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!S||!S["CodeMirror-linenumbers"])&&(t.lineNumber=Y.appendChild(a("div",ui(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,ce=S.hasOwnProperty(q)&&S[q];ce&&Y.appendChild(a("div",[ce],"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=b("CodeMirror-linewidget"),n=t.node.firstChild,S=void 0;n;n=S)S=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);qa(e,t,i)}function Ns(e,t,i,r){var n=Ja(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),da(e,t),Qa(e,t,i,r),qa(e,t,r),t.node}function qa(e,t,i){if(eo(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)eo(e,t.rest[r],t,i,!1)}function eo(e,t,i,r,n){if(!t.widgets)return;for(var S=mn(i),U=0,Y=t.widgets;U<Y.length;++U){var J=Y[U],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),pr(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 gn(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;"),u(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function fi(e,t){for(var i=ke(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Hn(e){return e.lineSpace.offsetTop}function ca(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function to(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=u(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 ri(e){return fe-e.display.nativeBarWidth}function Oi(e){return e.display.scroller.clientWidth-ri(e)-e.display.barWidth}function fa(e){return e.display.scroller.clientHeight-ri(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&Oi(e);if(!t.measure.heights||r&&t.measure.width!=n){var S=t.measure.heights=[];if(r){t.measure.width=n;for(var U=t.text.firstChild.getClientRects(),Y=0;Y<U.length-1;Y++){var J=U[Y],q=U[Y+1];Math.abs(J.bottom-q.bottom)>2&&S.push((J.bottom+q.top)/2-i.top)}}S.push(i.bottom-i.top)}}function ro(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(kt(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=kt(t),r=e.display.externalMeasured=new yi(e.doc,t,i);r.lineN=i;var n=r.built=_t(e,r);return r.text=n.pre,u(e.display.lineMeasure,n.pre),r}function io(e,t,i,r){return ii(e,Xi(e,t),i,r)}function pa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ii(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=kt(t),r=pa(e,i);r&&!r.text?r=null:r&&r.changes&&(Za(e,r,i,xa(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=ro(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ii(e,t,i,r,n){t.before&&(i=-1);var S=i+(r||""),U;return t.cache.hasOwnProperty(S)?U=t.cache[S]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),U=Ws(e,t,i,r),U.bogus||(t.cache[S]=U)),{left:U.left,right:U.right,top:n?U.rtop:U.top,bottom:n?U.rbottom:U.bottom}}var no={left:0,right:0,top:0,bottom:0};function ao(e,t,i){for(var r,n,S,U,Y,J,q=0;q<e.length;q+=3)if(Y=e[q],J=e[q+1],t<Y?(n=0,S=1,U="left"):t<J?(n=t-Y,S=n+1):(q==e.length-3||t==J&&e[q+3]>t)&&(S=J-Y,n=S-1,t>=J&&(U="right")),n!=null){if(r=e[q+2],Y==J&&i==(r.insertLeft?"left":"right")&&(U=i),i=="left"&&n==0)for(;q&&e[q-2]==e[q-3]&&e[q-1].insertLeft;)r=e[(q-=3)+2],U="left";if(i=="right"&&n==J-Y)for(;q<e.length-3&&e[q+3]==e[q+4]&&!e[q+5].insertLeft;)r=e[(q+=3)+2],U="right";break}return{node:r,start:n,end:S,collapse:U,coverStart:Y,coverEnd:J}}function js(e,t){var i=no;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=ao(t.map,i,r),S=n.node,U=n.start,Y=n.end,J=n.collapse,q;if(S.nodeType==3){for(var ce=0;ce<4;ce++){for(;U&&Fe(t.line.text.charAt(n.coverStart+U));)--U;for(;n.coverStart+Y<n.coverEnd&&Fe(t.line.text.charAt(n.coverStart+Y));)++Y;if(z&&W<9&&U==0&&Y==n.coverEnd-n.coverStart?q=S.parentNode.getBoundingClientRect():q=js(v(S,U,Y).getClientRects(),r),q.left||q.right||U==0)break;Y=U,U=U-1,J="right"}z&&W<11&&(q=Hs(e.display.measure,q))}else{U>0&&(J=r="right");var ge;e.options.lineWrapping&&(ge=S.getClientRects()).length>1?q=ge[r=="right"?ge.length-1:0]:q=S.getBoundingClientRect()}if(z&&W<9&&!U&&(!q||!q.left&&!q.right)){var _e=S.parentNode.getClientRects()[0];_e?q={left:_e.left,right:_e.left+$i(e.display),top:_e.top,bottom:_e.bottom}:q=no}for(var Ae=q.top-t.rect.top,Ne=q.bottom-t.rect.top,Ke=(Ae+Ne)/2,Xe=t.view.measure.heights,Je=0;Je<Xe.length-1&&!(Ke<Xe[Je]);Je++);var ot=Je?Xe[Je-1]:0,Qe=Xe[Je],ht={left:(J=="right"?q.right:q.left)-t.rect.left,right:(J=="left"?q.left:q.right)-t.rect.left,top:ot,bottom:Qe};return!q.left&&!q.right&&(ht.bogus=!0),e.options.singleCursorHeightPerLine||(ht.rtop=Ae,ht.rbottom=Ne),ht}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Kt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function oo(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function so(e){e.display.externalMeasure=null,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)oo(e.display.view[t])}function vn(e){so(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function lo(){return y&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function uo(){return y&&h?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ma(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=gn(e.widgets[i]));return t}function Gn(e,t,i,r,n){if(!n){var S=ma(t);i.top+=S,i.bottom+=S}if(r=="line")return i;r||(r="local");var U=Zr(t);if(r=="local"?U+=Hn(e.display):U-=e.display.viewOffset,r=="page"||r=="window"){var Y=e.display.lineSpace.getBoundingClientRect();U+=Y.top+(r=="window"?0:uo());var J=Y.left+(r=="window"?0:lo());i.left+=J,i.right+=J}return i.top+=U,i.bottom+=U,i}function ho(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=lo(),n-=uo();else if(i=="local"||!i){var S=e.display.sizer.getBoundingClientRect();r+=S.left,n+=S.top}var U=e.display.lineSpace.getBoundingClientRect();return{left:r-U.left,top:n-U.top}}function ga(e,t,i,r,n){return r||(r=pt(e.doc,t.line)),Gn(e,r,io(e,r,t.ch,n),i)}function Jr(e,t,i,r,n,S){r=r||pt(e.doc,t.line),n||(n=Xi(e,r));function U(Ne,Ke){var Xe=ii(e,n,Ne,Ke?"right":"left",S);return Ke?Xe.left=Xe.right:Xe.right=Xe.left,Gn(e,r,Xe,i)}var Y=rt(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"),!Y)return U(q=="before"?J-1:J,q=="before");function ce(Ne,Ke,Xe){var Je=Y[Ke],ot=Je.level==1;return U(Xe?Ne-1:Ne,ot!=Xe)}var ge=$e(Y,J,q),_e=Ze,Ae=ce(J,ge,q=="before");return _e!=null&&(Ae.other=ce(J,_e,q!="before")),Ae}function co(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=pt(e.doc,t.line),n=Zr(r)+Hn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function va(e,t,i,r,n){var S=Ve(e,t,i);return S.xRel=n,r&&(S.outside=r),S}function ya(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return va(r.first,0,null,-1,-1);var n=Mr(r,i),S=r.first+r.size-1;if(n>S)return va(r.first+r.size-1,pt(r,S).text.length,null,1,1);t<0&&(t=0);for(var U=pt(r,n);;){var Y=Gs(e,U,n,t,i),J=ti(U,Y.ch+(Y.xRel>0||Y.outside>0?1:0));if(!J)return Y;var q=J.find(1);if(q.line==n)return q;U=pt(r,n=q.line)}}function fo(e,t,i,r){r-=ma(t);var n=t.text.length,S=tt(function(U){return ii(e,i,U-1).bottom<=r},n,0);return n=tt(function(U){return ii(e,i,U).top>r},S,n),{begin:S,end:n}}function po(e,t,i,r){i||(i=Xi(e,t));var n=Gn(e,t,ii(e,i,r),"line").top;return fo(e,t,i,n)}function ba(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=Zr(t);var S=Xi(e,t),U=ma(t),Y=0,J=t.text.length,q=!0,ce=rt(t,e.doc.direction);if(ce){var ge=(e.options.lineWrapping?Ks:zs)(e,t,i,S,ce,r,n);q=ge.level!=1,Y=q?ge.from:ge.to-1,J=q?ge.to:ge.from-1}var _e=null,Ae=null,Ne=tt(function(bt){var gt=ii(e,S,bt);return gt.top+=U,gt.bottom+=U,ba(gt,r,n,!1)?(gt.top<=n&&gt.left<=r&&(_e=bt,Ae=gt),!0):!1},Y,J),Ke,Xe,Je=!1;if(Ae){var ot=r-Ae.left<Ae.right-r,Qe=ot==q;Ne=_e+(Qe?0:1),Xe=Qe?"after":"before",Ke=ot?Ae.left:Ae.right}else{!q&&(Ne==J||Ne==Y)&&Ne++,Xe=Ne==0?"after":Ne==t.text.length?"before":ii(e,S,Ne-(q?1:0)).bottom+U<=n==q?"after":"before";var ht=Jr(e,Ve(i,Ne,Xe),"line",t,S);Ke=ht.left,Je=n<ht.top?-1:n>=ht.bottom?1:0}return Ne=Be(t.text,Ne,1),va(i,Ne,Xe,Je,r-Ke)}function zs(e,t,i,r,n,S,U){var Y=tt(function(ge){var _e=n[ge],Ae=_e.level!=1;return ba(Jr(e,Ve(i,Ae?_e.to:_e.from,Ae?"before":"after"),"line",t,r),S,U,!0)},0,n.length-1),J=n[Y];if(Y>0){var q=J.level!=1,ce=Jr(e,Ve(i,q?J.from:J.to,q?"after":"before"),"line",t,r);ba(ce,S,U,!0)&&ce.top>U&&(J=n[Y-1])}return J}function Ks(e,t,i,r,n,S,U){var Y=fo(e,t,r,U),J=Y.begin,q=Y.end;/\s/.test(t.text.charAt(q-1))&&q--;for(var ce=null,ge=null,_e=0;_e<n.length;_e++){var Ae=n[_e];if(Ae.from>=q||Ae.to<=J)continue;var Ne=Ae.level!=1,Ke=ii(e,r,Ne?Math.min(q,Ae.to)-1:Math.max(J,Ae.from)).right,Xe=Ke<S?S-Ke+1e9:Ke-S;(!ce||ge>Xe)&&(ce=Ae,ge=Xe)}return ce||(ce=n[n.length-1]),ce.from<J&&(ce={from:J,to:ce.to,level:ce.level}),ce.to>q&&(ce={from:ce.from,to:q,level:ce.level}),ce}var Pi;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Pi==null){Pi=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Pi.appendChild(document.createTextNode("x")),Pi.appendChild(a("br"));Pi.appendChild(document.createTextNode("x"))}u(e.measure,Pi);var i=Pi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");u(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function xa(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,S=t.gutters.firstChild,U=0;S;S=S.nextSibling,++U){var Y=e.display.gutterSpecs[U].className;i[Y]=S.offsetLeft+S.clientLeft+n,r[Y]=S.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function mo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(Dr(e.doc,n))return 0;var S=0;if(n.widgets)for(var U=0;U<n.widgets.length;U++)n.widgets[U].height&&(S+=n.widgets[U].height);return i?S+(Math.ceil(n.text.length/r)||1)*t:S+t}}function Sa(e){var t=e.doc,i=mo(e);t.iter(function(r){var n=i(r);n!=r.height&&xr(r,n)})}function Mi(e,t,i,r){var n=e.display;if(!i&&ke(t).getAttribute("cm-not-content")=="true")return null;var S,U,Y=n.lineSpace.getBoundingClientRect();try{S=t.clientX-Y.left,U=t.clientY-Y.top}catch(ge){return null}var J=ya(e,S,U),q;if(r&&J.xRel>0&&(q=pt(e.doc,J.line).text).length==J.ch){var ce=$(q,q.length,e.options.tabSize)-q.length;J=Ve(J.line,Math.max(0,Math.round((S-to(e.display).left)/$i(e.display))-ce))}return J}function Ii(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function Cr(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)Er&&vi(e.doc,t)<n.viewTo&&xi(e);else if(i<=n.viewFrom)Er&&Un(e.doc,i+r)>n.viewFrom?xi(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)xi(e);else if(t<=n.viewFrom){var S=zn(e,i,i+r,1);S?(n.view=n.view.slice(S.index),n.viewFrom=S.lineN,n.viewTo+=r):xi(e)}else if(i>=n.viewTo){var U=zn(e,t,t,-1);U?(n.view=n.view.slice(0,U.index),n.viewTo=U.lineN):xi(e)}else{var Y=zn(e,t,t,-1),J=zn(e,i,i+r,1);Y&&J?(n.view=n.view.slice(0,Y.index).concat(Ft(e,Y.lineN,J.lineN)).concat(n.view.slice(J.index)),n.viewTo+=r):xi(e)}var q=n.externalMeasured;q&&(i<q.lineN?q.lineN+=r:t<q.lineN+q.size&&(n.externalMeasured=null))}function bi(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var S=r.view[Ii(e,t)];if(S.node==null)return;var U=S.changes||(S.changes=[]);ae(U,i)==-1&&U.push(i)}function xi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,i,r){var n=Ii(e,t),S,U=e.display.view;if(!Er||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var Y=e.display.viewFrom,J=0;J<n;J++)Y+=U[J].size;if(Y!=t){if(r>0){if(n==U.length-1)return null;S=Y+U[n].size-t,n++}else S=Y-t;t+=S,i+=S}for(;vi(e.doc,i)!=i;){if(n==(r<0?0:U.length-1))return null;i+=r*U[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Ft(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Ft(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Ii(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(Ft(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Ii(e,i)))),r.viewTo=i}function go(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function yn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function vo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),S=r.selection=document.createDocumentFragment(),U=0;U<i.sel.ranges.length;U++){if(!t&&U==i.sel.primIndex)continue;var Y=i.sel.ranges[U];if(Y.from().line>=e.display.viewTo||Y.to().line<e.display.viewFrom)continue;var J=Y.empty();(J||e.options.showCursorWhenSelecting)&&yo(e,Y.head,n),J||Xs(e,Y,S)}return r}function yo(e,t,i){var r=Jr(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 Kn(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(),U=to(e.display),Y=U.left,J=Math.max(r.sizerWidth,Oi(e)-r.sizer.offsetLeft)-U.right,q=n.direction=="ltr";function ce(Qe,ht,bt,gt){ht<0&&(ht=0),ht=Math.round(ht),gt=Math.round(gt),S.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Qe+`px;
top: `+ht+"px; width: "+(bt==null?J-Qe:bt)+`px;
height: `+(gt-ht)+"px"))}function ge(Qe,ht,bt){var gt=pt(n,Qe),At=gt.text.length,Xt,hr;function $t(rr,Lr){return ga(e,Ve(Qe,rr),"div",gt,Lr)}function Or(rr,Lr,mr){var or=po(e,gt,null,rr),ir=Lr=="ltr"==(mr=="after")?"left":"right",Jt=mr=="after"?or.begin:or.end-(/\s/.test(gt.text.charAt(or.end-1))?2:1);return $t(Jt,ir)[ir]}var Ar=rt(gt,n.direction);return qe(Ar,ht||0,bt==null?At:bt,function(rr,Lr,mr,or){var ir=mr=="ltr",Jt=$t(rr,ir?"left":"right"),kr=$t(Lr-1,ir?"right":"left"),un=ht==null&&rr==0,Ai=bt==null&&Lr==At,vr=or==0,ni=!Ar||or==Ar.length-1;if(kr.top-Jt.top<=3){var dr=(q?un:Ai)&&vr,Xa=(q?Ai:un)&&ni,mi=dr?Y:(ir?Jt:kr).left,ji=Xa?J:(ir?kr:Jt).right;ce(mi,Jt.top,ji-mi,Jt.bottom)}else{var Wi,br,hn,Ya;ir?(Wi=q&&un&&vr?Y:Jt.left,br=q?J:Or(rr,mr,"before"),hn=q?Y:Or(Lr,mr,"after"),Ya=q&&Ai&&ni?J:kr.right):(Wi=q?Or(rr,mr,"before"):Y,br=!q&&un&&vr?J:Jt.right,hn=!q&&Ai&&ni?Y:kr.left,Ya=q?Or(Lr,mr,"after"):J),ce(Wi,Jt.top,br-Wi,Jt.bottom),Jt.bottom<kr.top&&ce(Y,Jt.bottom,null,kr.top),ce(hn,kr.top,Ya-hn,kr.bottom)}(!Xt||Kn(Jt,Xt)<0)&&(Xt=Jt),Kn(kr,Xt)<0&&(Xt=kr),(!hr||Kn(Jt,hr)<0)&&(hr=Jt),Kn(kr,hr)<0&&(hr=kr)}),{start:Xt,end:hr}}var _e=t.from(),Ae=t.to();if(_e.line==Ae.line)ge(_e.line,_e.ch,Ae.ch);else{var Ne=pt(n,_e.line),Ke=pt(n,Ae.line),Xe=Sr(Ne)==Sr(Ke),Je=ge(_e.line,_e.ch,Xe?Ne.text.length+1:null).end,ot=ge(Ae.line,Xe?0:null,Ae.ch).start;Xe&&(Je.top<ot.top-2?(ce(Je.right,Je.top,null,Je.bottom),ce(Y,ot.top,ot.left,ot.bottom)):ce(Je.right,Je.top,ot.left-Je.right,Je.bottom)),Je.bottom<ot.top&&ce(Y,Je.bottom,null,ot.top)}i.appendChild(S)}function Ta(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function bo(e){e.state.focused||(e.display.input.focus(),Ca(e))}function xo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function Ca(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Ie(e,"focus",e,t),e.state.focused=!0,F(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),I&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ta(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ie(e,"blur",e,t),e.state.focused=!1,g(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Vn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],S=e.options.lineWrapping,U=void 0,Y=0;if(n.hidden)continue;if(z&&W<8){var J=n.node.offsetTop+n.node.offsetHeight;U=J-i,i=J}else{var q=n.node.getBoundingClientRect();U=q.bottom-q.top,!S&&n.text.firstChild&&(Y=n.text.firstChild.getBoundingClientRect().right-q.left-1)}var ce=n.line.height-U;if((ce>.005||ce<-.005)&&(xr(n.line,U),Eo(n.line),n.rest))for(var ge=0;ge<n.rest.length;ge++)Eo(n.rest[ge]);if(Y>e.display.sizerWidth){var _e=Math.ceil(Y/$i(e.display));_e>e.display.maxLineLength&&(e.display.maxLineLength=_e,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function Eo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Xn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Hn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,S=Mr(t,r),U=Mr(t,n);if(i&&i.ensure){var Y=i.ensure.from.line,J=i.ensure.to.line;Y<S?(S=Y,U=Mr(t,Zr(pt(t,Y))+e.wrapper.clientHeight)):Math.min(J,t.lastLine())>=U&&(S=Mr(t,Zr(pt(t,J))-e.wrapper.clientHeight),U=J)}return{from:S,to:Math.max(U,S+1)}}function Ys(e,t){if(ze(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-Hn(e.display))+`px;
height: `+(t.bottom-t.top+ri(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 U=!1,Y=Jr(e,t),J=!i||i==t?Y:Jr(e,i);n={left:Math.min(Y.left,J.left),top:Math.min(Y.top,J.top)-r,right:Math.max(Y.left,J.left),bottom:Math.max(Y.bottom,J.bottom)+r};var q=wa(e,n),ce=e.doc.scrollTop,ge=e.doc.scrollLeft;if(q.scrollTop!=null&&(xn(e,q.scrollTop),Math.abs(e.doc.scrollTop-ce)>1&&(U=!0)),q.scrollLeft!=null&&(Ni(e,q.scrollLeft),Math.abs(e.doc.scrollLeft-ge)>1&&(U=!0)),!U)break}return n}function Zs(e,t){var i=wa(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Ni(e,i.scrollLeft)}function wa(e,t){var i=e.display,r=Yi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,S=fa(e),U={};t.bottom-t.top>S&&(t.bottom=t.top+S);var Y=e.doc.height+ca(i),J=t.top<r,q=t.bottom>Y-r;if(t.top<n)U.scrollTop=J?0:t.top;else if(t.bottom>n+S){var ce=Math.min(t.top,(q?Y:t.bottom)-S);ce!=n&&(U.scrollTop=ce)}var ge=e.options.fixedGutter?0:i.gutters.offsetWidth,_e=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-ge,Ae=Oi(e)-i.gutters.offsetWidth,Ne=t.right-t.left>Ae;return Ne&&(t.right=t.left+Ae),t.left<10?U.scrollLeft=0:t.left<_e?U.scrollLeft=Math.max(0,t.left+ge-(Ne?0:10)):t.right>Ae+_e-3&&(U.scrollLeft=t.right+(Ne?0:10)-Ae),U}function Aa(e,t){if(t==null)return;Yn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Yn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function bn(e,t,i){(t!=null||i!=null)&&Yn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Yn(e),e.curOp.scrollToPos=t}function Yn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=co(e,t.from),r=co(e,t.to);So(e,i,r,t.margin)}}function So(e,t,i,r){var n=wa(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});bn(e,n.scrollLeft,n.scrollTop)}function xn(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;_||ka(e,{top:t}),To(e,t,!0),_&&ka(e),Tn(e,100)}function To(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Ni(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,ko(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function En(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ri(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Bi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Pe(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Pe(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&W<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Bi.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var 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}},Bi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Bi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Bi.prototype.zeroWidthHack=function(){var e=l&&!k?"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},Bi.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)},Bi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Sn=function(){};Sn.prototype.update=function(){return{bottom:0,right:0}},Sn.prototype.setScrollLeft=function(){},Sn.prototype.setScrollTop=function(){},Sn.prototype.clear=function(){};function Qi(e,t){t||(t=En(e));var i=e.display.barWidth,r=e.display.barHeight;Co(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Vn(e),Co(e,En(e)),i=e.display.barWidth,r=e.display.barHeight}function Co(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var wo={native:Bi,null:Sn};function Ao(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&g(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new wo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),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"?Ni(e,t):xn(e,t)},e),e.display.scrollbars.addClass&&F(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function Fi(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 Ui(e){var t=e.curOp;t&&Wn(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var S=0;S<t.length;S++)il(t[S]);for(var U=0;U<t.length;U++)nl(t[U])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new $n(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&La(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Vn(t),e.barMeasure=En(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=io(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ri(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Oi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Ni(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==N();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&&Ta(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&bo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&Lo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&To(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Ni(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var S=e.maybeHiddenMarkers,U=e.maybeUnhiddenMarkers;if(S)for(var Y=0;Y<S.length;++Y)S[Y].lines.length||Ie(S[Y],"hide");if(U)for(var J=0;J<U.length;++J)U[J].lines.length&&Ie(U[J],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ie(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Rr(e,t){if(e.curOp)return t();Fi(e);try{return t()}finally{Ui(e)}}function lr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Fi(e);try{return t.apply(e,arguments)}finally{Ui(e)}}}function yr(e){return function(){if(this.curOp)return e.apply(this,arguments);Fi(this);try{return e.apply(this,arguments)}finally{Ui(this)}}}function ur(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Fi(t);try{return e.apply(this,arguments)}finally{Ui(t)}}}function Tn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,R(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Ye(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 U=S.styles,Y=S.text.length>e.options.maxHighlightLength?Hr(t.mode,r.state):null,J=ye(e,S,r,!0);Y&&(r.state=Y),S.styles=J.styles;var q=S.styleClasses,ce=J.classes;ce?S.styleClasses=ce:q&&(S.styleClasses=null);for(var ge=!U||U.length!=S.styles.length||q!=ce&&(!q||!ce||q.bgClass!=ce.bgClass||q.textClass!=ce.textClass),_e=0;!ge&&_e<U.length;++_e)ge=U[_e]!=S.styles[_e];ge&&n.push(r.line),S.stateAfter=r.save(),r.nextLine()}else S.text.length<=e.options.maxHighlightLength&&ut(e,S.text,r),S.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Tn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Rr(e,function(){for(var S=0;S<n.length;S++)bi(e,n[S],"text")})}var $n=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Xn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Oi(e),this.force=i,this.dims=xa(e),this.events=[]};$n.prototype.signal=function(e,t){pe(e,t)&&this.events.push(arguments)},$n.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ie.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=ri(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ri(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=N();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==N())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 La(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return xi(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&go(e)==0)return!1;_o(e)&&(xi(e),t.dims=xa(e));var n=r.first+r.size,S=Math.max(t.visible.from-e.options.viewportMargin,r.first),U=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>U&&i.viewTo-U<20&&(U=Math.min(n,i.viewTo)),Er&&(S=vi(e.doc,S),U=Un(e.doc,U));var Y=S!=i.viewFrom||U!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,S,U),i.viewOffset=Zr(pt(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var J=go(e);if(!Y&&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),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,Y&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Tn(e,400)),i.updateLineNumbers=null,!0}function Lo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Oi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ca(e.display)-fa(e),i.top)}),t.visible=Xn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xn(e.display,e.doc,i));if(!La(e,t))break;Vn(e);var n=En(e);yn(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 ka(e,t){var i=new $n(e,t);if(La(e,i)){Vn(e),Lo(e,i);var r=En(e);yn(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,U=S.firstChild;function Y(Ne){var Ke=Ne.nextSibling;return I&&l&&e.display.currentWheelTarget==Ne?Ne.style.display="none":Ne.parentNode.removeChild(Ne),Ke}for(var J=r.view,q=r.viewFrom,ce=0;ce<J.length;ce++){var ge=J[ce];if(!ge.hidden)if(!ge.node||ge.node.parentNode!=S){var _e=Ns(e,ge,q,i);S.insertBefore(_e,U)}else{for(;U!=ge.node;)U=Y(U);var Ae=n&&t!=null&&t<=q&&ge.lineNumber;ge.changes&&(ae(ge.changes,"gutter")>-1&&(Ae=!1),Za(e,ge,q,i)),Ae&&(c(ge.lineNumber),ge.lineNumber.appendChild(document.createTextNode(ui(e.options,q)))),U=ge.node.nextSibling}q+=ge.size}for(;U;)U=Y(U)}function _a(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+ri(e)+"px"}function ko(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,S=r+"px",U=0;U<i.length;U++)if(!i[U].hidden){e.options.fixedGutter&&(i[U].gutter&&(i[U].gutter.style.left=S),i[U].gutterBackground&&(i[U].gutterBackground.style.left=S));var Y=i[U].alignable;if(Y)for(var J=0;J<Y.length;J++)Y[J].style.left=S}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function _o(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=ui(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),S=n.firstChild.offsetWidth,U=n.offsetWidth-S;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(S,r.lineGutter.offsetWidth-U)+1,r.lineNumWidth=r.lineNumInnerWidth+U,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_a(e.display),!0}return!1}function Ra(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var S=e[n],U=null;if(typeof S!="string"&&(U=S.style,S=S.className),S=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:S,style:U})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function Do(e){var t=e.gutters,i=e.gutterSpecs;c(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],S=n.className,U=n.style,Y=t.appendChild(a("div",null,"CodeMirror-gutter "+S));U&&(Y.style.cssText=U),S=="CodeMirror-linenumbers"&&(e.lineGutter=Y,Y.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",_a(e)}function Cn(e){Do(e.display),Cr(e),ko(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=x("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=x("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var S=x("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[S],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+fe+"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&&W<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!I&&!(_&&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),Do(n),i.init(n)}var Zn=0,Ur=null;z?Ur=-.53:_?Ur=15:y?Ur=-.7:O&&(Ur=-1/3);function Ro(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=Ro(e);return t.x*=Ur,t.y*=Ur,t}function Oo(e,t){var i=Ro(t),r=i.x,n=i.y,S=e.display,U=S.scroller,Y=U.scrollWidth>U.clientWidth,J=U.scrollHeight>U.clientHeight;if(!(r&&Y||n&&J))return;if(n&&l&&I){e:for(var q=t.target,ce=S.view;q!=U;q=q.parentNode)for(var ge=0;ge<ce.length;ge++)if(ce[ge].node==q){e.display.currentWheelTarget=q;break e}}if(r&&!_&&!w&&Ur!=null){n&&J&&xn(e,Math.max(0,U.scrollTop+n*Ur)),Ni(e,Math.max(0,U.scrollLeft+r*Ur)),(!n||n&&J)&&re(t),S.wheelStartX=null;return}if(n&&Ur!=null){var _e=n*Ur,Ae=e.doc.scrollTop,Ne=Ae+S.wrapper.clientHeight;_e<0?Ae=Math.max(0,Ae+_e-50):Ne=Math.min(e.doc.height,Ne+_e+50),ka(e,{top:Ae,bottom:Ne})}Zn<20&&(S.wheelStartX==null?(S.wheelStartX=U.scrollLeft,S.wheelStartY=U.scrollTop,S.wheelDX=r,S.wheelDY=n,setTimeout(function(){if(S.wheelStartX==null)return;var Ke=U.scrollLeft-S.wheelStartX,Xe=U.scrollTop-S.wheelStartY,Je=Xe&&S.wheelDY&&Xe/S.wheelDY||Ke&&S.wheelDX&&Ke/S.wheelDX;if(S.wheelStartX=S.wheelStartY=null,!Je)return;Ur=(Ur*Zn+Je)/(Zn+1),++Zn},200)):(S.wheelDX+=r,S.wheelDY+=n))}var jr=function(e,t){this.ranges=e,this.primIndex=t};jr.prototype.primary=function(){return this.ranges[this.primIndex]},jr.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(!hi(i.anchor,r.anchor)||!hi(i.head,r.head))return!1}return!0},jr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new jt(Li(this.ranges[t].anchor),Li(this.ranges[t].head));return new jr(e,this.primIndex)},jr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},jr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(Tt(t,r.from())>=0&&Tt(e,r.to())<=0)return i}return-1};var jt=function(e,t){this.anchor=e,this.head=t};jt.prototype.from=function(){return ki(this.anchor,this.head)},jt.prototype.to=function(){return di(this.anchor,this.head)},jt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Qr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(_e,Ae){return Tt(_e.from(),Ae.from())}),i=ae(t,n);for(var S=1;S<t.length;S++){var U=t[S],Y=t[S-1],J=Tt(Y.to(),U.from());if(r&&!U.empty()?J>0:J>=0){var q=ki(Y.from(),U.from()),ce=di(Y.to(),U.to()),ge=Y.empty()?U.from()==U.head:Y.from()==Y.head;S<=i&&--i,t.splice(--S,2,new jt(ge?ce:q,ge?q:ce))}}return new jr(t,i)}function Ei(e,t){return new jr([new jt(e,t||e)],0)}function Si(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 Po(e,t){if(Tt(e,t.from)<0)return e;if(Tt(e,t.to)<=0)return Si(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Si(t).ch-t.to.ch),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 jt(Po(n.anchor,t),Po(n.head,t)))}return Qr(e.cm,i,e.sel.primIndex)}function Mo(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,U=0;U<t.length;U++){var Y=t[U],J=Mo(Y.from,n,S),q=Mo(Si(Y),n,S);if(n=Y.to,S=q,i=="around"){var ce=e.sel.ranges[U],ge=Tt(ce.head,ce.anchor)<0;r[U]=new jt(ge?q:J,ge?J:q)}else r[U]=new jt(J,J)}return new jr(r,e.sel.primIndex)}function Pa(e){e.doc.mode=Vr(e.options,e.doc.modeOption),wn(e)}function wn(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Tn(e,100),e.state.modeGen++,e.curOp&&Cr(e)}function Io(e,t){return t.from.ch==0&&t.to.ch==0&&te(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ma(e,t,i,r){function n(ot){return i?i[ot]:null}function S(ot,Qe,ht){$a(ot,Qe,ht,r),pr(ot,"change",ot,t)}function U(ot,Qe){for(var ht=[],bt=ot;bt<Qe;++bt)ht.push(new Ri(q[bt],n(bt),r));return ht}var Y=t.from,J=t.to,q=t.text,ce=pt(e,Y.line),ge=pt(e,J.line),_e=te(q),Ae=n(q.length-1),Ne=J.line-Y.line;if(t.full)e.insert(0,U(0,q.length)),e.remove(q.length,e.size-q.length);else if(Io(e,t)){var Ke=U(0,q.length-1);S(ge,ge.text,Ae),Ne&&e.remove(Y.line,Ne),Ke.length&&e.insert(Y.line,Ke)}else if(ce==ge)if(q.length==1)S(ce,ce.text.slice(0,Y.ch)+_e+ce.text.slice(J.ch),Ae);else{var Xe=U(1,q.length-1);Xe.push(new Ri(_e+ce.text.slice(J.ch),Ae,r)),S(ce,ce.text.slice(0,Y.ch)+q[0],n(0)),e.insert(Y.line+1,Xe)}else if(q.length==1)S(ce,ce.text.slice(0,Y.ch)+q[0]+ge.text.slice(J.ch),n(0)),e.remove(Y.line+1,Ne);else{S(ce,ce.text.slice(0,Y.ch)+q[0],n(0)),S(ge,_e+ge.text.slice(J.ch),Ae);var Je=U(1,q.length-1);Ne>1&&e.remove(Y.line+1,Ne-1),e.insert(Y.line+1,Je)}pr(e,"change",e,t)}function Ti(e,t,i){function r(n,S,U){if(n.linked)for(var Y=0;Y<n.linked.length;++Y){var J=n.linked[Y];if(J.doc==S)continue;var q=U&&J.sharedHist;if(i&&!q)continue;t(J.doc,q),r(J.doc,n,q)}}r(e,null,!0)}function No(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Sa(e),Pa(e),Bo(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,Cr(e)}function Bo(e){(e.doc.direction=="rtl"?F:g)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Rr(e,function(){Bo(e),Cr(e)})}function Jn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ia(e,t){var i={from:Li(t.from),to:Si(t),text:Pr(e,t.from,t.to)};return jo(e,i,t.from.line,t.to.line+1),Ti(e,function(r){return jo(r,i,t.from.line,t.to.line+1)},!0),i}function Fo(e){for(;e.length;){var t=te(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return Fo(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 Uo(e,t,i,r){var n=e.history;n.undone.length=0;var S=+new Date,U,Y;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)=="*"))&&(U=pl(n,n.lastOp==r)))Y=te(U.changes),Tt(t.from,t.to)==0&&Tt(t.from,Y.to)==0?Y.to=Si(t):U.changes.push(Ia(e,t));else{var J=te(n.done);for((!J||!J.ranges)&&Qn(e.sel,n.done),U={changes:[Ia(e,t)],generation:n.generation},n.done.push(U);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=S,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,Y||Ie(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:Qn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=S,n.lastSelOp=i,r&&r.clearRedo!==!1&&Fo(n.undone)}function Qn(e,t){var i=te(t);i&&i.ranges&&i.equals(e)||t.push(e)}function jo(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(U){U.markedSpans&&((n||(n=t["spans_"+e.id]={}))[S]=U.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 Wo(e,t){var i=yl(e,t),r=$r(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var S=i[n],U=r[n];if(S&&U){e:for(var Y=0;Y<U.length;++Y){for(var J=U[Y],q=0;q<S.length;++q)if(S[q].marker==J.marker)continue e;S.push(J)}}else U&&(i[n]=U)}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?jr.prototype.deepCopy.call(S):S);continue}var U=S.changes,Y=[];r.push({changes:Y});for(var J=0;J<U.length;++J){var q=U[J],ce=void 0;if(Y.push({from:q.from,to:q.to,text:q.text}),t)for(var ge in q)(ce=ge.match(/^spans_(\d+)$/))&&(ae(t,Number(ce[1]))>-1&&(te(Y)[ge]=q[ge],delete q[ge]))}}return r}function Na(e,t,i,r){if(r){var n=e.anchor;if(i){var S=Tt(t,n)<0;S!=Tt(i,n)<0?(n=t,t=i):S!=Tt(t,i)<0&&(t=i)}return new jt(n,t)}else return new jt(i||t,t)}function qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),gr(e,new jr([Na(e.sel.primary(),t,i,n)],0),r)}function Ho(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),S=0;S<e.sel.ranges.length;S++)r[S]=Na(e.sel.ranges[S],t[S],null,n);var U=Qr(e.cm,r,e.sel.primIndex);gr(e,U,i)}function Ba(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,gr(e,Qr(e.cm,n,e.sel.primIndex),r)}function Go(e,t,i,r){gr(e,Ei(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var S=0;S<n.length;S++)this.ranges[S]=new jt(s(e,n[S].anchor),s(e,n[S].head))},origin:i&&i.origin};return Ie(e,"beforeSelectionChange",e,r),e.cm&&Ie(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Qr(e.cm,r.ranges,r.ranges.length-1):t}function zo(e,t,i){var r=e.history.done,n=te(r);n&&n.ranges?(r[r.length-1]=t,ea(e,t,i)):gr(e,t,i)}function gr(e,t,i){ea(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function ea(e,t,i){(pe(e,"beforeSelectionChange")||e.cm&&pe(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(Tt(t.primary().head,e.sel.primary().head)<0?-1:1);Ko(e,Xo(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(e.cm)}function Ko(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,be(e.cm)),pr(e,"cursorActivity",e)}function Vo(e){Ko(e,Xo(e,e.sel,null,!1))}function Xo(e,t,i,r){for(var n,S=0;S<t.ranges.length;S++){var U=t.ranges[S],Y=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[S],J=ta(e,U.anchor,Y&&Y.anchor,i,r),q=ta(e,U.head,Y&&Y.head,i,r);(n||J!=U.anchor||q!=U.head)&&(n||(n=t.ranges.slice(0,S)),n[S]=new jt(J,q))}return n?Qr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var S=pt(e,t.line);if(S.markedSpans)for(var U=0;U<S.markedSpans.length;++U){var Y=S.markedSpans[U],J=Y.marker,q="selectLeft"in J?!J.selectLeft:J.inclusiveLeft,ce="selectRight"in J?!J.selectRight:J.inclusiveRight;if((Y.from==null||(q?Y.from<=t.ch:Y.from<t.ch))&&(Y.to==null||(ce?Y.to>=t.ch:Y.to>t.ch))){if(n&&(Ie(J,"beforeCursorEnter"),J.explicitlyCleared))if(S.markedSpans){--U;continue}else break;if(!J.atomic)continue;if(i){var ge=J.find(r<0?1:-1),_e=void 0;if((r<0?ce:q)&&(ge=Yo(e,ge,-r,ge&&ge.line==t.line?S:null)),ge&&ge.line==t.line&&(_e=Tt(ge,i))&&(r<0?_e<0:_e>0))return en(e,ge,t,r,n)}var Ae=J.find(r<0?-1:1);return(r<0?q:ce)&&(Ae=Yo(e,Ae,r,Ae.line==t.line?S:null)),Ae?en(e,Ae,t,r,n):null}}return t}function ta(e,t,i,r,n){var S=r||1,U=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 U||(e.cantEdit=!0,Ve(e.first,0))}function Yo(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||pt(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 $o(e){e.setSelection(Ve(e.firstLine(),0),Ve(e.lastLine()),Se)}function Zo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,S,U,Y){n&&(r.from=s(e,n)),S&&(r.to=s(e,S)),U&&(r.text=U),Y!==void 0&&(r.origin=Y)}),Ie(e,"beforeChange",e,r),e.cm&&Ie(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 lr(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((pe(e,"beforeChange")||e.cm&&pe(e.cm,"beforeChange"))&&(t=Zo(e,t,!0),!t))return;var r=Hi&&!i&&_i(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)Jo(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Jo(e,t)}function Jo(e,t){if(t.text.length==1&&t.text[0]==""&&Tt(t.from,t.to)==0)return;var i=Oa(e,t);Uo(e,t,i,e.cm?e.cm.curOp.id:NaN),An(e,t,i,$r(e,t));var r=[];Ti(e,function(n,S){!S&&ae(r,n.history)==-1&&(ts(n.history,t),r.push(n.history)),An(n,t,null,$r(n,t))})}function ra(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,S,U=e.sel,Y=t=="undo"?n.done:n.undone,J=t=="undo"?n.undone:n.done,q=0;q<Y.length&&!(S=Y[q],i?S.ranges&&!S.equals(e.sel):!S.ranges);q++);if(q==Y.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(S=Y.pop(),S.ranges){if(Qn(S,J),i&&!S.equals(e.sel)){gr(e,S,{clearRedo:!1});return}U=S}else if(r){Y.push(S);return}else break;var ce=[];Qn(U,J),J.push({changes:ce,generation:n.generation}),n.generation=S.generation||++n.maxGeneration;for(var ge=pe(e,"beforeChange")||e.cm&&pe(e.cm,"beforeChange"),_e=function(Ke){var Xe=S.changes[Ke];if(Xe.origin=t,ge&&!Zo(e,Xe,!1))return Y.length=0,{};ce.push(Ia(e,Xe));var Je=Ke?Oa(e,Xe):te(Y);An(e,Xe,Je,Wo(e,Xe)),!Ke&&e.cm&&e.cm.scrollIntoView({from:Xe.from,to:Si(Xe)});var ot=[];Ti(e,function(Qe,ht){!ht&&ae(ot,Qe.history)==-1&&(ts(Qe.history,Xe),ot.push(Qe.history)),An(Qe,Xe,null,Wo(Qe,Xe))})},Ae=S.changes.length-1;Ae>=0;--Ae){var Ne=_e(Ae);if(Ne)return Ne.v}}function Qo(e,t){if(t==0)return;if(e.first+=t,e.sel=new jr(de(e.sel.ranges,function(n){return new jt(Ve(n.anchor.line+t,n.anchor.ch),Ve(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Cr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)bi(e.cm,r,"gutter")}}function An(e,t,i,r){if(e.cm&&!e.cm.curOp)return lr(e.cm,An)(e,t,i,r);if(t.to.line<e.first){Qo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Qo(e,n),t={from: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,pt(e,S).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Pr(e,t.from,t.to),i||(i=Oa(e,t)),e.cm?xl(e.cm,t,r):Ma(e,t,r),ea(e,i,Se),e.cantEdit&&ta(e,Ve(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,S=t.from,U=t.to,Y=!1,J=S.line;e.options.lineWrapping||(J=kt(Sr(pt(r,S.line))),r.iter(J,U.line+1,function(Ae){if(Ae==n.maxLine)return Y=!0,!0})),r.sel.contains(t.from,t.to)>-1&&be(e),Ma(r,t,i,mo(e)),e.options.lineWrapping||(r.iter(J,S.line+t.text.length,function(Ae){var Ne=Vi(Ae);Ne>n.maxLineLength&&(n.maxLine=Ae,n.maxLineLength=Ne,n.maxLineChanged=!0,Y=!1)}),Y&&(e.curOp.updateMaxLine=!0)),Gr(r,S.line),Tn(e,400);var q=t.text.length-(U.line-S.line)-1;t.full?Cr(e):S.line==U.line&&t.text.length==1&&!Io(e.doc,t)?bi(e,S.line,"text"):Cr(e,S.line,U.line+1,q);var ce=pe(e,"changes"),ge=pe(e,"change");if(ge||ce){var _e={from:S,to:U,text:t.text,removed:t.removed,origin:t.origin};ge&&pr(e,"change",e,_e),ce&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(_e)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var S;r||(r=i),Tt(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 qo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function es(e,t,i,r){for(var n=0;n<e.length;++n){var S=e[n],U=!0;if(S.ranges){S.copied||(S=e[n]=S.deepCopy(),S.copied=!0);for(var Y=0;Y<S.ranges.length;Y++)qo(S.ranges[Y].anchor,t,i,r),qo(S.ranges[Y].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){U=!1;break}}U||(e.splice(0,n+1),n=0)}}function ts(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;es(e.done,i,r,n),es(e.undone,i,r,n)}function Ln(e,t,i,r){var n=t,S=t;return typeof t=="number"?S=pt(e,G(e,t)):n=kt(t),n==null?null:(r(S,n)&&e.cm&&bi(e.cm,n,i),S)}function kn(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}kn.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,ha(n),pr(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function _n(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}_n.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var S=Math.min(t,n-e),U=r.height;if(r.removeInner(e,S),this.height-=U-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 kn))){var Y=[];this.collapse(Y),this.children=[new kn(Y)],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 U=n.lines.length%25+25,Y=U;Y<n.lines.length;){var J=new kn(n.lines.slice(Y,Y+=25));n.height-=J.height,this.children.splice(++r,0,J),J.parent=this}n.lines=n.lines.slice(0,U),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 _n(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 _n(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],S=n.chunkSize();if(e<S){var U=Math.min(t,S-e);if(n.iterN(e,U,i))return!0;if((t-=U)==0)break;e=0}else e-=S}}};var Dn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};Dn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=kt(i);if(r==null||!t)return;for(var n=0;n<t.length;++n)t[n]==this&&t.splice(n--,1);t.length||(i.widgets=null);var S=gn(this);xr(i,Math.max(0,i.height-S)),e&&(Rr(e,function(){rs(e,i,-S),bi(e,r,"widget")}),pr(e,"lineWidgetCleared",e,this,r))},Dn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=gn(this)-t;if(!n)return;Dr(this.doc,r)||xr(r,r.height+n),i&&Rr(i,function(){i.curOp.forceUpdate=!0,rs(i,r,n),pr(i,"lineWidgetChanged",i,e,kt(r))})},ve(Dn);function rs(e,t,i){Zr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Aa(e,i)}function El(e,t,i,r){var n=new Dn(e,i,r),S=e.cm;return S&&n.noHScroll&&(S.display.alignWidgets=!0),Ln(e,t,"widget",function(U){var Y=U.widgets||(U.widgets=[]);if(n.insertAt==null?Y.push(n):Y.splice(Math.min(Y.length-1,Math.max(0,n.insertAt)),0,n),n.line=U,S&&!Dr(e,U)){var J=Zr(U)<e.scrollTop;xr(U,U.height+gn(n)),J&&Aa(S,n.height),S.curOp.forceUpdate=!0}return!0}),S&&pr(S,"lineWidgetAdded",S,n,typeof t=="number"?t:kt(t)),n}var is=0,Ci=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++is};Ci.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Fi(e),pe(this,"clear")){var i=this.find();i&&pr(this,"clear",i.from,i.to)}for(var r=null,n=null,S=0;S<this.lines.length;++S){var U=this.lines[S],Y=Yr(U.markedSpans,this);e&&!this.collapsed?bi(e,kt(U),"text"):e&&(Y.to!=null&&(n=kt(U)),Y.from!=null&&(r=kt(U))),U.markedSpans=ci(U.markedSpans,Y),Y.from==null&&this.collapsed&&!Dr(this.doc,U)&&e&&xr(U,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]),ce=Vi(q);ce>e.display.maxLineLength&&(e.display.maxLine=q,e.display.maxLineLength=ce,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Cr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Vo(e.doc)),e&&pr(e,"markerCleared",e,this,r,n),t&&Ui(e),this.parent&&this.parent.clear()},Ci.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],U=Yr(S.markedSpans,this);if(U.from!=null&&(i=Ve(t?S:kt(S),U.from),e==-1))return i;if(U.to!=null&&(r=Ve(t?S:kt(S),U.to),e==1))return r}return i&&{from:i,to:r}},Ci.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Rr(r,function(){var n=t.line,S=kt(t.line),U=pa(r,S);if(U&&(oo(U),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Dr(i.doc,n)&&i.height!=null){var Y=i.height;i.height=null;var J=gn(i)-Y;J&&xr(n,n.height+J)}pr(r,"markerChanged",r,e)})},Ci.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)},Ci.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)}},ve(Ci);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 lr(e.cm,nn)(e,t,i,r,n);var S=new Ci(e,n),U=Tt(t,i);if(r&&M(r,S,!1),U>0||U==0&&S.clearWhenEmpty!==!1)return S;if(S.replacedWith&&(S.collapsed=!0,S.widgetNode=x("span",[S.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||S.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(S.widgetNode.insertLeft=!0)),S.collapsed){if(Qt(e,t.line,t,i,S)||t.line!=i.line&&Qt(e,i.line,t,i,S))throw new Error("Inserting collapsed marker partially overlapping an existing one");_r()}S.addToHistory&&Uo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var Y=t.line,J=e.cm,q;if(e.iter(Y,i.line+1,function(ge){J&&S.collapsed&&!J.options.lineWrapping&&Sr(ge)==J.display.maxLine&&(q=!0),S.collapsed&&Y!=t.line&&xr(ge,0),ei(ge,new gi(S,Y==t.line?t.ch:null,Y==i.line?i.ch:null)),++Y}),S.collapsed&&e.iter(t.line,i.line+1,function(ge){Dr(e,ge)&&xr(ge,0)}),S.clearOnEnter&&Pe(S,"beforeCursorEnter",function(){return S.clear()}),S.readOnly&&(Br(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),S.collapsed&&(S.id=++is,S.atomic=!0),J){if(q&&(J.curOp.updateMaxLine=!0),S.collapsed)Cr(J,t.line,i.line+1);else if(S.className||S.startStyle||S.endStyle||S.css||S.attributes||S.title)for(var ce=t.line;ce<=i.line;ce++)bi(J,ce,"text");S.atomic&&Vo(J.doc),pr(J,"markerAdded",J,S)}return S}var Rn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};Rn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();pr(this,"clear")},Rn.prototype.find=function(e,t){return this.primary.find(e,t)},ve(Rn);function Sl(e,t,i,r,n){r=M(r),r.shared=!1;var S=[nn(e,t,i,r,n)],U=S[0],Y=r.widgetNode;return Ti(e,function(J){Y&&(r.widgetNode=Y.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;U=te(S)}),new Rn(S,U)}function ns(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),U=e.clipPos(n.to);if(Tt(S,U)){var Y=nn(e,S,U,r.primary,r.primary.type);r.markers.push(Y),Y.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],S=[n.primary.doc];Ti(n.primary.doc,function(J){return S.push(J)});for(var U=0;U<n.markers.length;U++){var Y=n.markers[U];ae(S,Y.doc)==-1&&(Y.parent=null,n.markers.splice(U--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,wr=function(e,t,i,r,n){if(!(this instanceof wr))return new wr(e,t,i,r,n);i==null&&(i=0),_n.call(this,[new kn([new Ri("",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=Ei(S),this.history=new Jn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Ma(this,{from:S,to:S,text:e}),gr(this,Ei(S),Se)};wr.prototype=Re(_n.prototype,{constructor:wr,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=li(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:ur(function(e){var t=Ve(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:Ve(i,pt(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&bn(this.cm,0,0),gr(this,Ei(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=Pr(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(Xr(this,e))return pt(this,e)},getLineNumber:function(e){return kt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=pt(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:ur(function(e,t,i){Go(this,s(this,typeof e=="number"?Ve(e,t||0):e),null,i)}),setSelection:ur(function(e,t,i){Go(this,s(this,e),s(this,t||e),i)}),extendSelection:ur(function(e,t,i){qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:ur(function(e,t){Ho(this,j(this,e),t)}),extendSelectionsBy:ur(function(e,t){var i=de(this.sel.ranges,e);Ho(this,j(this,i),t)}),setSelections:ur(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new jt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),gr(this,Qr(this.cm,r,t),i)}),addSelection:ur(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new jt(s(this,e),s(this,t||e))),gr(this,Qr(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=Pr(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=Pr(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:ur(function(e,t,i){for(var r=[],n=this.sel,S=0;S<n.ranges.length;S++){var U=n.ranges[S];r[S]={from:U.from(),to:U.to(),text:this.splitLines(e[S]),origin:i}}for(var Y=t&&t!="end"&&cl(this,r,t),J=r.length-1;J>=0;J--)tn(this,r[J]);Y?zo(this,Y):this.cm&&Ji(this.cm)}),undo:ur(function(){ra(this,"undo")}),redo:ur(function(){ra(this,"redo")}),undoSelection:ur(function(){ra(this,"undo",!0)}),redoSelection:ur(function(){ra(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Jn(this.history.maxGeneration),Ti(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Jn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:ur(function(e,t,i){return Ln(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&He(n)&&(r.gutterMarkers=null),!0})}),clearGutter:ur(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&Ln(t,i,"gutter",function(){return i.gutterMarkers[e]=null,He(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Xr(this,e))return null;if(t=e,e=pt(this,e),!e)return null}else if(t=kt(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:ur(function(e,t,i){return Ln(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(b(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:ur(function(e,t,i){return Ln(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 U=S.match(b(i));if(!U)return!1;var Y=U.index+U[0].length;r[n]=S.slice(0,U.index)+(!U.index||Y==S.length?"":" ")+S.slice(Y)||null}else return!1;return!0})}),addLineWidget:ur(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return nn(this,s(this,e),s(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=s(this,e),nn(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=pt(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(S){var U=S.markedSpans;if(U)for(var Y=0;Y<U.length;Y++){var J=U[Y];!(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 wr(li(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 wr(li(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,ns(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(ns(this));break}if(e.history==this.history){var r=[e.id];Ti(e,function(n){return r.push(n.id)},!0),e.history=new Jn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Ti(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):St(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:ur(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)})}),wr.prototype.eachLine=wr.prototype.iter;var as=0;function Al(e){var t=this;if(os(t),ze(t,e)||fi(t.display,e))return;re(e),z&&(as=+new Date);var i=Mi(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),U=0,Y=function(){++U==n&&lr(t,function(){i=s(t.doc,i);var Ae={from:i,to:i,text:t.doc.splitLines(S.filter(function(Ne){return Ne!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,Ae),zo(t.doc,Ei(s(t.doc,i),s(t.doc,Si(Ae))))})()},J=function(Ae,Ne){if(t.options.allowDropFileTypes&&ae(t.options.allowDropFileTypes,Ae.type)==-1){Y();return}var Ke=new FileReader;Ke.onerror=function(){return Y()},Ke.onload=function(){var Xe=Ke.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Xe)){Y();return}S[Ne]=Xe,Y()},Ke.readAsText(Ae)},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 ce=e.dataTransfer.getData("Text");if(ce){var ge;if(t.state.draggingText&&!t.state.draggingText.copy&&(ge=t.listSelections()),ea(t.doc,Ei(i,i)),ge)for(var _e=0;_e<ge.length;++_e)rn(t.doc,"",ge[_e].anchor,ge[_e].head,"drag");t.replaceSelection(ce,"around","paste"),t.display.input.focus()}}catch(Ae){}}}function Ll(e,t){if(z&&(!e.state.draggingText||+new Date-as<100)){ue(t);return}if(ze(e,t)||fi(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!O){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",w&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),w&&i.parentNode.removeChild(i)}}function kl(e,t){var i=Mi(e,t);if(!i)return;var r=document.createDocumentFragment();yo(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),u(e.display.dragCursor,r)}function os(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ss(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var S=0;S<i.length;S++)e(i[S])})}var ls=!1;function _l(){if(ls)return;Dl(),ls=!0}function Dl(){var e;Pe(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,ss(Rl)},100))}),Pe(window,"blur",function(){return ss(Zi)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var wi={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},On=0;On<10;On++)wi[On+48]=wi[On+96]=String(On);for(var ia=65;ia<=90;ia++)wi[ia]=String.fromCharCode(ia);for(var Pn=1;Pn<=12;Pn++)wi[Pn+111]=wi[Pn+63235]="F"+Pn;var pi={};pi.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},pi.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},pi.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},pi.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},pi.default=l?pi.macDefault:pi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,S,U=0;U<t.length-1;U++){var Y=t[U];if(/^(cmd|meta|m)$/i.test(Y))S=!0;else if(/^a(lt)?$/i.test(Y))i=!0;else if(/^(c|ctrl|control)$/i.test(Y))r=!0;else if(/^s(hift)?$/i.test(Y))n=!0;else throw new Error("Unrecognized modifier name: "+Y)}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(" "),Ol),S=0;S<n.length;S++){var U=void 0,Y=void 0;S==n.length-1?(Y=n.join(" "),U=r):(Y=n.slice(0,S+1).join(" "),U="...");var J=t[Y];if(!J)t[Y]=U;else if(J!=U)throw new Error("Inconsistent bindings for "+Y)}delete e[i]}for(var q in t)e[q]=t[q];return e}function an(e,t,i,r){t=na(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var S=0;S<t.fallthrough.length;S++){var U=an(e,t.fallthrough[S],i,r);if(U)return U}}}function us(e){var t=typeof e=="string"?e:wi[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function hs(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(p?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(p?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function ds(e,t){if(w&&e.keyCode==34&&e.char)return!1;var i=wi[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),hs(i,e,t))}function na(e){return typeof e=="string"?pi[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var S=t(i[n]);r.length&&Tt(S.from,te(r).to)<=0;){var U=r.pop();if(Tt(U.from,S.from)<0){S.from=U.from;break}}r.push(S)}Rr(e,function(){for(var Y=r.length-1;Y>=0;Y--)rn(e.doc,"",r[Y].from,r[Y].to,"+delete");Ji(e)})}function Fa(e,t,i){var r=Be(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Ua(e,t,i){var r=Fa(e,t.ch,i);return r==null?null:new Ve(t.line,r,i<0?"after":"before")}function ja(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var S=rt(i,t.doc.direction);if(S){var U=n<0?te(S):S[0],Y=n<0==(U.level==1),J=Y?"after":"before",q;if(U.level>0||t.doc.direction=="rtl"){var ce=Xi(t,i);q=n<0?i.text.length-1:0;var ge=ii(t,ce,q).top;q=tt(function(_e){return ii(t,ce,_e).top==ge},n<0==(U.level==1)?U.from:U.to-1,q),J=="before"&&(q=Fa(i,q,1))}else q=n<0?U.to:U.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=rt(t,e.doc.direction);if(!n)return Ua(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=$e(n,i.ch,i.sticky),U=n[S];if(e.doc.direction=="ltr"&&U.level%2==0&&(r>0?U.to>i.ch:U.from<i.ch))return Ua(t,i,r);var Y=function(Je,ot){return Fa(t,Je instanceof Ve?Je.ch:Je,ot)},J,q=function(Je){return e.options.lineWrapping?(J=J||Xi(e,t),po(e,t,J,Je)):{begin:0,end:t.text.length}},ce=q(i.sticky=="before"?Y(i,-1):i.ch);if(e.doc.direction=="rtl"||U.level==1){var ge=U.level==1==r<0,_e=Y(i,ge?1:-1);if(_e!=null&&(ge?_e<=U.to&&_e<=ce.end:_e>=U.from&&_e>=ce.begin)){var Ae=ge?"before":"after";return new Ve(i.line,_e,Ae)}}var Ne=function(Je,ot,Qe){for(var ht=function(Xt,hr){return hr?new Ve(i.line,Y(Xt,1),"before"):new Ve(i.line,Xt,"after")};Je>=0&&Je<n.length;Je+=ot){var bt=n[Je],gt=ot>0==(bt.level!=1),At=gt?Qe.begin:Y(Qe.end,-1);if(bt.from<=At&&At<bt.to)return ht(At,gt);if(At=gt?bt.from:Y(bt.to,-1),Qe.begin<=At&&At<Qe.end)return ht(At,gt)}},Ke=Ne(S+r,r,ce);if(Ke)return Ke;var Xe=r>0?ce.end:Y(ce.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 Mn={selectAll:$o,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=pt(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 cs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return fs(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},we)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},we)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?fs(e,t.head):r},we)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var S=i[n].from(),U=$(e.getLine(S.line),S.ch,r);t.push(he(r-U%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Rr(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=pt(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 U=pt(e.doc,n.line-1).text;U&&(n=new Ve(n.line,1),e.replaceRange(S.charAt(0)+e.doc.lineSeparator()+U.charAt(U.length-1),Ve(n.line-1,U.length-1),n,"+transpose"))}}i.push(new jt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Rr(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Ji(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function cs(e,t){var i=pt(e.doc,t),r=Sr(i);return r!=i&&(t=kt(r)),ja(!0,e,r,t,1)}function Il(e,t){var i=pt(e.doc,t),r=zi(i);return r!=i&&(t=kt(r)),ja(!0,e,i,t,-1)}function fs(e,t){var i=cs(e,t.line),r=pt(e.doc,i.line),n=rt(r,e.doc.direction);if(!n||n[0].level==0){var S=Math.max(i.ch,r.text.search(/\S/)),U=t.line==i.line&&t.ch<=S&&t.ch;return Ve(i.line,U?0:S,i.sticky)}return i}function aa(e,t,i){if(typeof t=="string"&&(t=Mn[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 In(e,t,i,r){var n=e.state.keySeq;if(n){if(us(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),ps(e,n+" "+t,i,r))return!0}return ps(e,t,i,r)}function ps(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&pr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(re(i),Ta(e)),!!n}function ms(e,t){var i=ds(t,!0);return i?t.shiftKey&&!e.state.keySeq?In(e,"Shift-"+i,t,function(r){return aa(e,r,!0)})||In(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return aa(e,r)}):In(e,i,t,function(r){return aa(e,r)}):!1}function Fl(e,t,i){return In(e,"'"+i+"'",t,function(r){return aa(e,r,!0)})}var Wa=null;function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=N(),ze(t,e))return;z&&W<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=ms(t,e);w&&(Wa=r?i:null,!r&&i==88&&!zt&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),_&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;F(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(g(t,"CodeMirror-crosshair"),nt(document,"keyup",i),nt(document,"mouseover",i))}Pe(document,"keyup",i),Pe(document,"mouseover",i)}function vs(e){e.keyCode==16&&(this.doc.sel.shift=!1),ze(this,e)}function ys(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(fi(t.display,e)||ze(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(w&&i==Wa){Wa=null,re(e);return}if(w&&(!e.which||e.which<10)&&ms(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,Ha=function(e,t,i){this.time=e,this.pos=t,this.button=i};Ha.prototype.compare=function(e,t,i){return this.time+jl>e&&Tt(t,this.pos)==0&&i==this.button};var Nn,Bn;function Wl(e,t){var i=+new Date;return Bn&&Bn.compare(i,e,t)?(Nn=Bn=null,"triple"):Nn&&Nn.compare(i,e,t)?(Bn=new Ha(i,e,t),Nn=null,"double"):(Nn=new Ha(i,e,t),Bn=null,"single")}function bs(e){var t=this,i=t.display;if(ze(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,fi(i,e)){I||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ga(t,e))return;var r=Mi(t,e),n=Ee(e),S=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,S,e))return;n==1?r?zl(t,r,S,e):ke(e)==i.scroller&&re(e):n==2?(r&&qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(L?t.display.input.onContextMenu(e):xo(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,In(e,hs(S,n),n,function(U){if(typeof U=="string"&&(U=Mn[U]),!U)return!1;var Y=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),Y=U(e,i)!=De}finally{e.state.suppressEdits=!1}return Y})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var S=d?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(R(bo,e),0):e.curOp.focus=N();var n=Gl(e,i,r),S=e.doc.sel,U;e.options.dragDrop&&Ue&&!e.isReadOnly()&&i=="single"&&(U=S.contains(t))>-1&&(Tt((U=S.ranges[U]).from(),t)<0||t.xRel>0)&&(Tt(U.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,S=!1,U=lr(e,function(q){I&&(n.scroller.draggable=!1),e.state.draggingText=!1,nt(n.wrapper.ownerDocument,"mouseup",U),nt(n.wrapper.ownerDocument,"mousemove",Y),nt(n.scroller,"dragstart",J),nt(n.scroller,"drop",U),S||(re(q),r.addNew||qn(e.doc,i,null,null,r.extend),I&&!O||z&&W==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),Y=function(q){S=S||Math.abs(t.clientX-q.clientX)+Math.abs(t.clientY-q.clientY)>=10},J=function(){return S=!0};I&&(n.scroller.draggable=!0),e.state.draggingText=U,U.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Pe(n.wrapper.ownerDocument,"mouseup",U),Pe(n.wrapper.ownerDocument,"mousemove",Y),Pe(n.scroller,"dragstart",J),Pe(n.scroller,"drop",U),xo(e),setTimeout(function(){return n.input.focus()},20)}function xs(e,t,i){if(i=="char")return new jt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new jt(Ve(t.line,0),s(e.doc,Ve(t.line+1,0)));var r=i(e,t);return new jt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,S=e.doc;re(t);var U,Y,J=S.sel,q=J.ranges;if(r.addNew&&!r.extend?(Y=S.sel.contains(i),Y>-1?U=q[Y]:U=new jt(i,i)):(U=S.sel.primary(),Y=S.sel.primIndex),r.unit=="rectangle")r.addNew||(U=new jt(i,i)),i=Mi(e,t,!0,!0),Y=-1;else{var ce=xs(e,i,r.unit);r.extend?U=Na(U,ce.anchor,ce.head,r.extend):U=ce}r.addNew?Y==-1?(Y=q.length,gr(S,Qr(e,q.concat([U]),Y),{scroll:!1,origin:"*mouse"})):q.length>1&&q[Y].empty()&&r.unit=="char"&&!r.extend?(gr(S,Qr(e,q.slice(0,Y).concat(q.slice(Y+1)),0),{scroll:!1,origin:"*mouse"}),J=S.sel):Ba(S,Y,U,Ce):(Y=0,gr(S,new jr([U],0),Ce),J=S.sel);var ge=i;function _e(Qe){if(Tt(ge,Qe)==0)return;if(ge=Qe,r.unit=="rectangle"){for(var ht=[],bt=e.options.tabSize,gt=$(pt(S,i.line).text,i.ch,bt),At=$(pt(S,Qe.line).text,Qe.ch,bt),Xt=Math.min(gt,At),hr=Math.max(gt,At),$t=Math.min(i.line,Qe.line),Or=Math.min(e.lastLine(),Math.max(i.line,Qe.line));$t<=Or;$t++){var Ar=pt(S,$t).text,rr=Te(Ar,Xt,bt);Xt==hr?ht.push(new jt(Ve($t,rr),Ve($t,rr))):Ar.length>rr&&ht.push(new jt(Ve($t,rr),Ve($t,Te(Ar,hr,bt))))}ht.length||ht.push(new jt(i,i)),gr(S,Qr(e,J.ranges.slice(0,Y).concat(ht),Y),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Qe)}else{var Lr=U,mr=xs(e,Qe,r.unit),or=Lr.anchor,ir;Tt(mr.anchor,or)>0?(ir=mr.head,or=ki(Lr.from(),mr.anchor)):(ir=mr.anchor,or=di(Lr.to(),mr.head));var Jt=J.ranges.slice(0);Jt[Y]=Xl(e,new jt(s(S,or),ir)),gr(S,Qr(e,Jt,Y),Ce)}}var Ae=n.wrapper.getBoundingClientRect(),Ne=0;function Ke(Qe){var ht=++Ne,bt=Mi(e,Qe,!0,r.unit=="rectangle");if(!bt)return;if(Tt(bt,ge)!=0){e.curOp.focus=N(),_e(bt);var gt=Xn(n,S);(bt.line>=gt.to||bt.line<gt.from)&&setTimeout(lr(e,function(){Ne==ht&&Ke(Qe)}),150)}else{var At=Qe.clientY<Ae.top?-20:Qe.clientY>Ae.bottom?20:0;At&&setTimeout(lr(e,function(){if(Ne!=ht)return;n.scroller.scrollTop+=At,Ke(Qe)}),50)}}function Xe(Qe){e.state.selectingText=!1,Ne=Infinity,Qe&&(re(Qe),n.input.focus()),nt(n.wrapper.ownerDocument,"mousemove",Je),nt(n.wrapper.ownerDocument,"mouseup",ot),S.history.lastSelOrigin=null}var Je=lr(e,function(Qe){Qe.buttons===0||!Ee(Qe)?Xe(Qe):Ke(Qe)}),ot=lr(e,Xe);e.state.selectingText=ot,Pe(n.wrapper.ownerDocument,"mousemove",Je),Pe(n.wrapper.ownerDocument,"mouseup",ot)}function Xl(e,t){var i=t.anchor,r=t.head,n=pt(e.doc,i.line);if(Tt(i,r)==0&&i.sticky==r.sticky)return t;var S=rt(n);if(!S)return t;var U=$e(S,i.ch,i.sticky),Y=S[U];if(Y.from!=i.ch&&Y.to!=i.ch)return t;var J=U+(Y.from==i.ch==(Y.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 ce=$e(S,r.ch,r.sticky),ge=ce-U||(r.ch-i.ch)*(Y.level==1?-1:1);ce==J-1||ce==J?q=ge<0:q=ge>0}var _e=S[J+(q?-1:0)],Ae=q==(_e.level==1),Ne=Ae?_e.from:_e.to,Ke=Ae?"after":"before";return i.ch==Ne&&i.sticky==Ke?t:new jt(new Ve(i.line,Ne,Ke),r)}function Es(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(_e){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&re(t);var U=e.display,Y=U.lineDiv.getBoundingClientRect();if(S>Y.bottom||!pe(e,i))return oe(t);S-=Y.top-U.viewOffset;for(var J=0;J<e.display.gutterSpecs.length;++J){var q=U.gutters.childNodes[J];if(q&&q.getBoundingClientRect().right>=n){var ce=Mr(e.doc,S),ge=e.display.gutterSpecs[J];return Ie(e,i,e,ce,ge.className,t),oe(t)}}}function Ga(e,t){return Es(e,t,"gutterClick",!0)}function Ss(e,t){if(fi(e.display,t)||Yl(e,t))return;if(ze(e,t,"contextmenu"))return;L||e.display.input.onContextMenu(t)}function Yl(e,t){return pe(e,"gutterContextMenu")?Es(e,t,"gutterContextMenu",!1):!1}function Ts(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),vn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Cs={},oa={};function $l(e){var t=e.optionHandlers;function i(r,n,S,U){e.defaults[r]=n,S&&(t[r]=U?function(Y,J,q){q!=sn&&S(Y,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,Pa(r)},!0),i("indentUnit",2,Pa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){wn(r),vn(r),Cr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var S=[],U=r.doc.first;r.doc.iter(function(J){for(var q=0;;){var ce=J.text.indexOf(n,q);if(ce==-1)break;q=ce+n.length,S.push(Ve(U,ce))}U++});for(var Y=S.length-1;Y>=0;Y--)rn(r.doc,n,S[Y],Ve(S[Y].line,S[Y].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",Bt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!C),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Ts(r),Cn(r)},!0),i("keyMap","default",function(r,n,S){var U=na(n),Y=S!=sn&&na(S);Y&&Y.detach&&Y.detach(r,U),U.attach&&U.attach(r,Y||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),Cn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Ea(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Qi(r)},!0),i("scrollbarStyle","native",function(r){Ao(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),Cn(r)},!0),i("firstLineNumber",1,Cn,!0),i("lineNumberFormatter",function(r){return r},Cn,!0),i("showCursorWhenSelecting",!1,yn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,yn,!0),i("singleCursorHeightPerLine",!0,yn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,wn,!0),i("addModeClass",!1,wn,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,wn,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=sn;if(!t!=!r){var n=e.display.dragFunctions,S=t?Pe:nt;S(e.display.scroller,"dragstart",n.start),S(e.display.scroller,"dragenter",n.enter),S(e.display.scroller,"dragover",n.over),S(e.display.scroller,"dragleave",n.leave),S(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(F(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(g(e.display.wrapper,"CodeMirror-wrap"),jn(e)),Sa(e),Cr(e),vn(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?M(t):{},M(Cs,t,!1);var r=t.value;typeof r=="string"?r=new wr(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,Ts(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ao(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new ee,keySeq:null,specialChars:null},t.autofocus&&!o&&S.input.focus(),z&&W<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),_l(),Fi(this),this.curOp.forceUpdate=!0,No(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ca(i)},20):Zi(this);for(var U in oa)oa.hasOwnProperty(U)&&oa[U](this,t[U],sn);_o(this),t.finishInit&&t.finishInit(this);for(var Y=0;Y<za.length;++Y)za[Y](this);Ui(this),I&&t.lineWrapping&&getComputedStyle(S.lineDiv).textRendering=="optimizelegibility"&&(S.lineDiv.style.textRendering="auto")}Yt.defaults=Cs,Yt.optionHandlers=oa;function Ql(e){var t=e.display;Pe(t.scroller,"mousedown",lr(e,bs)),z&&W<11?Pe(t.scroller,"dblclick",lr(e,function(J){if(ze(e,J))return;var q=Mi(e,J);if(!q||Ga(e,J)||fi(e.display,J))return;re(J);var ce=e.findWordAt(q);qn(e.doc,ce.anchor,ce.head)})):Pe(t.scroller,"dblclick",function(J){return ze(e,J)||re(J)}),Pe(t.scroller,"contextmenu",function(J){return Ss(e,J)}),Pe(t.input.getField(),"contextmenu",function(J){t.scroller.contains(J.target)||Ss(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 U(J,q){if(q.left==null)return!0;var ce=q.left-J.left,ge=q.top-J.top;return ce*ce+ge*ge>20*20}Pe(t.scroller,"touchstart",function(J){if(!ze(e,J)&&!S(J)&&!Ga(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&&!fi(t,J)&&q.left!=null&&!q.moved&&new Date-q.start<300){var ce=e.coordsChar(t.activeTouch,"page"),ge;!q.prev||U(q,q.prev)?ge=new jt(ce,ce):!q.prev.prev||U(q,q.prev.prev)?ge=e.findWordAt(ce):ge=new jt(Ve(ce.line,0),s(e.doc,Ve(ce.line+1,0))),e.setSelection(ge.anchor,ge.head),e.focus(),re(J)}n()}),Pe(t.scroller,"touchcancel",n),Pe(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Ni(e,t.scroller.scrollLeft,!0),Ie(e,"scroll",e))}),Pe(t.scroller,"mousewheel",function(J){return Oo(e,J)}),Pe(t.scroller,"DOMMouseScroll",function(J){return Oo(e,J)}),Pe(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(J){ze(e,J)||ue(J)},over:function(J){ze(e,J)||(kl(e,J),ue(J))},start:function(J){return Ll(e,J)},drop:lr(e,Al),leave:function(J){ze(e,J)||os(e)}};var Y=t.input.getField();Pe(Y,"keyup",function(J){return vs.call(e,J)}),Pe(Y,"keydown",lr(e,gs)),Pe(Y,"keypress",lr(e,ys)),Pe(Y,"focus",function(J){return Ca(e,J)}),Pe(Y,"blur",function(J){return Zi(e,J)})}var za=[];Yt.defineInitHook=function(e){return za.push(e)};function Fn(e,t,i,r){var n=e.doc,S;i==null&&(i="add"),i=="smart"&&(n.mode.indent?S=Ye(e,t).state:i="prev");var U=e.options.tabSize,Y=pt(n,t),J=$(Y.text,null,U);Y.stateAfter&&(Y.stateAfter=null);var q=Y.text.match(/^\s*/)[0],ce;if(!r&&!/\S/.test(Y.text))ce=0,i="not";else if(i=="smart"&&(ce=n.mode.indent(S,Y.text.slice(q.length),Y.text),ce==De||ce>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?ce=$(pt(n,t-1).text,null,U):ce=0:i=="add"?ce=J+e.options.indentUnit:i=="subtract"?ce=J-e.options.indentUnit:typeof i=="number"&&(ce=J+i),ce=Math.max(0,ce);var ge="",_e=0;if(e.options.indentWithTabs)for(var Ae=Math.floor(ce/U);Ae;--Ae)_e+=U,ge+=" ";if(_e<ce&&(ge+=he(ce-_e)),ge!=q)return rn(n,ge,Ve(t,0),Ve(t,q.length),"+input"),Y.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);Ba(n,Ne,new jt(Xe,Xe));break}}}var qr=null;function sa(e){qr=e}function Ka(e,t,i,r,n){var S=e.doc;e.display.shift=!1,r||(r=S.sel);var U=+new Date-200,Y=n=="paste"||e.state.pasteIncoming>U,J=St(t),q=null;if(Y&&r.ranges.length>1)if(qr&&qr.text.join(`
`)==t){if(r.ranges.length%qr.text.length==0){q=[];for(var ce=0;ce<qr.text.length;ce++)q.push(S.splitLines(qr.text[ce]))}}else J.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(q=de(J,function(Je){return[Je]}));for(var ge=e.curOp.updateInput,_e=r.ranges.length-1;_e>=0;_e--){var Ae=r.ranges[_e],Ne=Ae.from(),Ke=Ae.to();Ae.empty()&&(i&&i>0?Ne=Ve(Ne.line,Ne.ch-i):e.state.overwrite&&!Y?Ke=Ve(Ke.line,Math.min(pt(S,Ke.line).text.length,Ke.ch+te(J).length)):Y&&qr&&qr.lineWise&&qr.text.join(`
`)==J.join(`
`)&&(Ne=Ke=Ve(Ne.line,0)));var Xe={from:Ne,to:Ke,text:q?q[_e%q.length]:J,origin:n||(Y?"paste":e.state.cutIncoming>U?"cut":"+input")};tn(e.doc,Xe),pr(e,"inputRead",e,Xe)}t&&!Y&&As(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=ge),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function ws(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Rr(t,function(){return Ka(t,i,0,null,"paste")}),!0}function As(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var S=e.getModeAt(n.head),U=!1;if(S.electricChars){for(var Y=0;Y<S.electricChars.length;Y++)if(t.indexOf(S.electricChars.charAt(Y))>-1){U=Fn(e,n.head.line,"smart");break}}else S.electricInput&&(S.electricInput.test(pt(e.doc,n.head.line).text.slice(0,n.head.ch))&&(U=Fn(e,n.head.line,"smart")));U&&pr(e,"electricInput",e,n.head.line)}}function Ls(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 ks(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function _s(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return I?e.style.width="1000px":e.setAttribute("wrap","off"),T&&(e.style.border="1px solid black"),ks(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,U=S[r];if(S[r]==n&&r!="mode")return;S[r]=n,t.hasOwnProperty(r)&&lr(this,t[r])(this,n,U),Ie(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](na(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,S=0;S<n.length;++S)if(n[S]==r||n[S].name==r)return n.splice(S,1),!0},addOverlay:yr(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(U){return U.priority}),this.state.modeGen++,Cr(this)}),removeOverlay:yr(function(r){for(var n=this.state.overlays,S=0;S<n.length;++S){var U=n[S].modeSpec;if(U==r||typeof r=="string"&&U.name==r){n.splice(S,1),this.state.modeGen++,Cr(this);return}}}),indentLine:yr(function(r,n,S){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Xr(this.doc,r)&&Fn(this,r,n,S)}),indentSelection:yr(function(r){for(var n=this.doc.sel.ranges,S=-1,U=0;U<n.length;U++){var Y=n[U];if(Y.empty())Y.head.line>S&&(Fn(this,Y.head.line,r,!0),S=Y.head.line,U==this.doc.sel.primIndex&&Ji(this));else{var J=Y.from(),q=Y.to(),ce=Math.max(S,J.line);S=Math.min(this.lastLine(),q.line-(q.ch?0:1))+1;for(var ge=ce;ge<S;++ge)Fn(this,ge,r);var _e=this.doc.sel.ranges;J.ch==0&&n.length==_e.length&&_e[U].from().ch>0&&Ba(this.doc,U,new jt(J,_e[U].to()),Se)}}}),getTokenAt:function(r,n){return Vt(this,r,n)},getLineTokens:function(r,n){return Vt(this,Ve(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=je(this,pt(this.doc,r.line)),S=0,U=(n.length-1)/2,Y=r.ch,J;if(Y==0)J=n[2];else for(;;){var q=S+U>>1;if((q?n[q*2-1]:0)>=Y)U=q;else if(n[q*2+1]<Y)S=q+1;else{J=n[q*2+2];break}}var ce=J?J.indexOf("overlay "):-1;return ce<0?J:ce==0?null:J.slice(0,ce-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 U=i[n],Y=this.getModeAt(r);if(typeof Y[n]=="string")U[Y[n]]&&S.push(U[Y[n]]);else if(Y[n])for(var J=0;J<Y[n].length;J++){var q=U[Y[n][J]];q&&S.push(q)}else Y.helperType&&U[Y.helperType]?S.push(U[Y.helperType]):U[Y.name]&&S.push(U[Y.name]);for(var ce=0;ce<U._global.length;ce++){var ge=U._global[ce];ge.pred(Y,this)&&ae(S,ge.val)==-1&&S.push(ge.val)}return S},getStateAfter:function(r,n){var S=this.doc;return r=G(S,r==null?S.first+S.size-1:r),Ye(this,r+1,n).state},cursorCoords:function(r,n){var S,U=this.doc.sel.primary();return r==null?S=U.head:typeof r=="object"?S=s(this.doc,r):S=r?U.from():U.to(),Jr(this,S,n||"page")},charCoords:function(r,n){return ga(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=ho(this,r,n||"page"),ya(this,r.left,r.top)},lineAtHeight:function(r,n){return r=ho(this,{top:r,left:0},n||"page").top,Mr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,S){var U=!1,Y;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,U=!0),Y=pt(this.doc,r)}else Y=r;return Gn(this,Y,{top:0,left:0},n||"page",S||U).top+(U?this.doc.height-Zr(Y):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,U,Y){var J=this.display;r=Jr(this,s(this.doc,r));var q=r.bottom,ce=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),J.sizer.appendChild(n),U=="over")q=r.top;else if(U=="above"||U=="near"){var ge=Math.max(J.wrapper.clientHeight,this.doc.height),_e=Math.max(J.sizer.clientWidth,J.lineSpace.clientWidth);(U=="above"||r.bottom+n.offsetHeight>ge)&&r.top>n.offsetHeight?q=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=ge&&(q=r.bottom),ce+n.offsetWidth>_e&&(ce=_e-n.offsetWidth)}n.style.top=q+"px",n.style.left=n.style.right="",Y=="right"?(ce=J.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(Y=="left"?ce=0:Y=="middle"&&(ce=(J.sizer.clientWidth-n.offsetWidth)/2),n.style.left=ce+"px"),S&&Zs(this,{left:ce,top:q,right:ce+n.offsetWidth,bottom:q+n.offsetHeight})},triggerOnKeyDown:yr(gs),triggerOnKeyPress:yr(ys),triggerOnKeyUp:vs,triggerOnMouseDown:yr(bs),execCommand:function(r){if(Mn.hasOwnProperty(r))return Mn[r].call(null,this)},triggerElectric:yr(function(r){As(this,r)}),findPosH:function(r,n,S,U){var Y=1;n<0&&(Y=-1,n=-n);for(var J=s(this.doc,r),q=0;q<n&&!(J=Va(this.doc,J,Y,S,U),J.hitSide);++q);return J},moveH:yr(function(r,n){var S=this;this.extendSelectionsBy(function(U){return S.display.shift||S.doc.extend||U.empty()?Va(S.doc,U.head,r,n,S.options.rtlMoveVisually):r<0?U.from():U.to()},we)}),deleteH:yr(function(r,n){var S=this.doc.sel,U=this.doc;S.somethingSelected()?U.replaceSelection("",null,"+delete"):on(this,function(Y){var J=Va(U,Y.head,r,n,!1);return r<0?{from:J,to:Y.head}:{from:Y.head,to:J}})}),findPosV:function(r,n,S,U){var Y=1,J=U;n<0&&(Y=-1,n=-n);for(var q=s(this.doc,r),ce=0;ce<n;++ce){var ge=Jr(this,q,"div");if(J==null?J=ge.left:ge.left=J,q=Ds(this,ge,Y,S),q.hitSide)break}return q},moveV:yr(function(r,n){var S=this,U=this.doc,Y=[],J=!this.display.shift&&!U.extend&&U.sel.somethingSelected();if(U.extendSelectionsBy(function(ce){if(J)return r<0?ce.from():ce.to();var ge=Jr(S,ce.head,"div");ce.goalColumn!=null&&(ge.left=ce.goalColumn),Y.push(ge.left);var _e=Ds(S,ge,r,n);return n=="page"&&ce==U.sel.primary()&&Aa(S,ga(S,_e,"div").top-ge.top),_e},we),Y.length)for(var q=0;q<U.sel.ranges.length;q++)U.sel.ranges[q].goalColumn=Y[q]}),findWordAt:function(r){var n=this.doc,S=pt(n,r.line).text,U=r.ch,Y=r.ch;if(S){var J=this.getHelper(r,"wordChars");(r.sticky=="before"||Y==S.length)&&U?--U:++Y;for(var q=S.charAt(U),ce=Me(q,J)?function(ge){return Me(ge,J)}:/\s/.test(q)?function(ge){return/\s/.test(ge)}:function(ge){return!/\s/.test(ge)&&!Me(ge)};U>0&&ce(S.charAt(U-1));)--U;for(;Y<S.length&&ce(S.charAt(Y));)++Y}return new jt(Ve(r.line,U),Ve(r.line,Y))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?F(this.display.cursorDiv,"CodeMirror-overwrite"):g(this.display.cursorDiv,"CodeMirror-overwrite"),Ie(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==N()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:yr(function(r,n){bn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ri(this)-this.display.barHeight,width:r.scrollWidth-ri(this)-this.display.barWidth,clientHeight:fa(this),clientWidth:Oi(this)}},scrollIntoView:yr(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):So(this,r.from,r.to,r.margin)}),setSize:yr(function(r,n){var S=this,U=function(J){return typeof J=="number"||/^\d+$/.test(String(J))?J+"px":J};r!=null&&(this.display.wrapper.style.width=U(r)),n!=null&&(this.display.wrapper.style.height=U(n)),this.options.lineWrapping&&so(this);var Y=this.display.viewFrom;this.doc.iter(Y,this.display.viewTo,function(J){if(J.widgets){for(var q=0;q<J.widgets.length;q++)if(J.widgets[q].noHScroll){bi(S,Y,"widget");break}}++Y}),this.curOp.forceUpdate=!0,Ie(this,"refresh",this)}),operation:function(r){return Rr(this,r)},startOperation:function(){return Fi(this)},endOperation:function(){return Ui(this)},refresh:yr(function(){var r=this.display.cachedTextHeight;Cr(this),this.curOp.forceUpdate=!0,vn(this),bn(this,this.doc.scrollLeft,this.doc.scrollTop),_a(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&Sa(this),Ie(this,"refresh",this)}),swapDoc:yr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),No(this,r),vn(this),this.display.input.reset(),bn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,pr(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}},ve(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,U){e.registerHelper(r,n,U),i[r]._global.push({pred:S,val:U})}}function Va(e,t,i,r,n){var S=t,U=i,Y=pt(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),Y=pt(e,ot))}function ce(ot){var Qe;if(r=="codepoint"){var ht=Y.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(ht)?Qe=null:Qe=new Ve(t.line,Math.max(0,Math.min(Y.text.length,t.ch+i*(ht>=55296&&ht<56320?2:1))),-i)}else n?Qe=Ml(e.cm,Y,t,i):Qe=Ua(Y,t,i);if(Qe==null)if(!ot&&q())t=ja(n,e.cm,Y,t.line,J);else return!1;else t=Qe;return!0}if(r=="char"||r=="codepoint")ce();else if(r=="column")ce(!0);else if(r=="word"||r=="group")for(var ge=null,_e=r=="group",Ae=e.cm&&e.cm.getHelper(t,"wordChars"),Ne=!0;!(i<0&&!ce(!Ne));Ne=!1){var Ke=Y.text.charAt(t.ch)||`
`,Xe=Me(Ke,Ae)?"w":_e&&Ke==`
`?"n":!_e||/\s/.test(Ke)?null:"p";if(_e&&!Ne&&!Xe&&(Xe="s"),ge&&ge!=Xe){i<0&&(i=1,ce(),t.sticky="after");break}if(Xe&&(ge=Xe),i>0&&!ce(!Ne))break}var Je=ta(e,t,S,U,!0);return hi(S,Je)&&(Je.hitSide=!0),Je}function Ds(e,t,i,r){var n=e.doc,S=t.left,U;if(r=="page"){var Y=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),J=Math.max(Y-.5*Yi(e.display),3);U=(i>0?t.bottom:t.top)+i*J}else r=="line"&&(U=i>0?t.bottom+3:t.top-3);for(var q;!(q=ya(e,S,U),!q.outside);){if(i<0?U<=0:U>=n.height){q.hitSide=!0;break}U+=i*5}return q}var Gt=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};Gt.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;ks(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function S(Y){for(var J=Y.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(Y){if(!S(Y)||ze(r,Y)||ws(Y,r))return;W<=11&&setTimeout(lr(r,function(){return t.updateFromDOM()}),20)}),Pe(n,"compositionstart",function(Y){t.composing={data:Y.data,done:!1}}),Pe(n,"compositionupdate",function(Y){t.composing||(t.composing={data:Y.data,done:!1})}),Pe(n,"compositionend",function(Y){t.composing&&(Y.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 U(Y){if(!S(Y)||ze(r,Y))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()}),Y.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var J=Ls(r);sa({lineWise:!0,text:J.text}),Y.type=="cut"&&r.operation(function(){r.setSelections(J.ranges,0,Se),r.replaceSelection("",null,"cut")})}else return;if(Y.clipboardData){Y.clipboardData.clearData();var q=qr.text.join(`
`);if(Y.clipboardData.setData("Text",q),Y.clipboardData.getData("Text")==q){Y.preventDefault();return}}var ce=_s(),ge=ce.firstChild;r.display.lineSpace.insertBefore(ce,r.display.lineSpace.firstChild),ge.value=qr.text.join(`
`);var _e=document.activeElement;V(ge),setTimeout(function(){r.display.lineSpace.removeChild(ce),_e.focus(),_e==n&&i.showPrimarySelection()},50)}Pe(n,"copy",U),Pe(n,"cut",U)},Gt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Gt.prototype.prepareSelection=function(){var e=vo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Gt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Gt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Gt.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=la(t,e.anchorNode,e.anchorOffset),U=la(t,e.focusNode,e.focusOffset);if(S&&!S.bad&&U&&!U.bad&&Tt(ki(S,U),r)==0&&Tt(di(S,U),n)==0)return;var Y=t.display.view,J=r.line>=t.display.viewFrom&&Rs(t,r)||{node:Y[0].measure.map[2],offset:0},q=n.line<t.display.viewTo&&Rs(t,n);if(!q){var ce=Y[Y.length-1].measure,ge=ce.maps?ce.maps[ce.maps.length-1]:ce.map;q={node:ge[ge.length-1],offset:ge[ge.length-2]-ge[ge.length-3]}}if(!J||!q){e.removeAllRanges();return}var _e=e.rangeCount&&e.getRangeAt(0),Ae;try{Ae=v(J.node,J.offset,q.offset,q.node)}catch(Ne){}Ae&&(!_&&t.state.focused?(e.collapse(J.node,J.offset),Ae.collapsed||(e.removeAllRanges(),e.addRange(Ae))):(e.removeAllRanges(),e.addRange(Ae)),_e&&e.anchorNode==null?e.addRange(_e):_&&this.startGracePeriod()),this.rememberSelection()},Gt.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)},Gt.prototype.showMultipleSelections=function(e){u(this.cm.display.cursorDiv,e.cursors),u(this.cm.display.selectionDiv,e.selection)},Gt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Gt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return E(this.div,t)},Gt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Gt.prototype.blur=function(){this.div.blur()},Gt.prototype.getField=function(){return this.div},Gt.prototype.supportsTouch=function(){return!0},Gt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Rr(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)},Gt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Gt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(h&&y&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=la(t,e.anchorNode,e.anchorOffset),r=la(t,e.focusNode,e.focusOffset);i&&r&&Rr(t,function(){gr(t.doc,Ei(i,r),Se),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Gt.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,pt(e.doc,r.line-1).length)),n.ch==pt(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,U,Y;r.line==t.viewFrom||(S=Ii(e,r.line))==0?(U=kt(t.view[0].line),Y=t.view[0].node):(U=kt(t.view[S].line),Y=t.view[S-1].node.nextSibling);var J=Ii(e,n.line),q,ce;if(J==t.view.length-1?(q=t.viewTo-1,ce=t.lineDiv.lastChild):(q=kt(t.view[J+1].line)-1,ce=t.view[J+1].node.previousSibling),!Y)return!1;for(var ge=e.doc.splitLines(tu(e,Y,ce,U,q)),_e=Pr(e.doc,Ve(U,0),Ve(q,pt(e.doc,q).text.length));ge.length>1&&_e.length>1;)if(te(ge)==te(_e))ge.pop(),_e.pop(),q--;else if(ge[0]==_e[0])ge.shift(),_e.shift(),U++;else break;for(var Ae=0,Ne=0,Ke=ge[0],Xe=_e[0],Je=Math.min(Ke.length,Xe.length);Ae<Je&&Ke.charCodeAt(Ae)==Xe.charCodeAt(Ae);)++Ae;for(var ot=te(ge),Qe=te(_e),ht=Math.min(ot.length-(ge.length==1?Ae:0),Qe.length-(_e.length==1?Ae:0));Ne<ht&&ot.charCodeAt(ot.length-Ne-1)==Qe.charCodeAt(Qe.length-Ne-1);)++Ne;if(ge.length==1&&_e.length==1&&U==r.line)for(;Ae&&Ae>r.ch&&ot.charCodeAt(ot.length-Ne-1)==Qe.charCodeAt(Qe.length-Ne-1);)Ae--,Ne++;ge[ge.length-1]=ot.slice(0,ot.length-Ne).replace(/^\u200b+/,""),ge[0]=ge[0].slice(Ae).replace(/\u200b+$/,"");var bt=Ve(U,Ae),gt=Ve(q,_e.length?te(_e).length-Ne:0);if(ge.length>1||ge[0]||Tt(bt,gt))return rn(e.doc,ge,bt,gt,"+input"),!0},Gt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Gt.prototype.reset=function(){this.forceCompositionEnd()},Gt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Gt.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)},Gt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Rr(this.cm,function(){return Cr(e.cm)})},Gt.prototype.setUneditable=function(e){e.contentEditable="false"},Gt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||lr(this.cm,Ka)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Gt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Gt.prototype.onContextMenu=function(){},Gt.prototype.resetPosition=function(){},Gt.prototype.needsContentAttribute=!0;function Rs(e,t){var i=pa(e,t.line);if(!i||i.hidden)return null;var r=pt(e.doc,t.line),n=ro(i,r,t.line),S=rt(r,e.doc.direction),U="left";if(S){var Y=$e(S,t.ch);U=Y%2?"right":"left"}var J=ao(n.map,t.ch,U);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="",U=!1,Y=e.doc.lineSeparator(),J=!1;function q(Ae){return function(Ne){return Ne.id==Ae}}function ce(){U&&(S+=Y,J&&(S+=Y),U=J=!1)}function ge(Ae){Ae&&(ce(),S+=Ae)}function _e(Ae){if(Ae.nodeType==1){var Ne=Ae.getAttribute("cm-text");if(Ne){ge(Ne);return}var Ke=Ae.getAttribute("cm-marker"),Xe;if(Ke){var Je=e.findMarks(Ve(r,0),Ve(n+1,0),q(+Ke));Je.length&&(Xe=Je[0].find(0))&&ge(Pr(e.doc,Xe.from,Xe.to).join(Y));return}if(Ae.getAttribute("contenteditable")=="false")return;var ot=/^(pre|div|p|li|table|br)$/i.test(Ae.nodeName);if(!/^br$/i.test(Ae.nodeName)&&Ae.textContent.length==0)return;ot&&ce();for(var Qe=0;Qe<Ae.childNodes.length;Qe++)_e(Ae.childNodes[Qe]);/^(pre|p)$/i.test(Ae.nodeName)&&(J=!0),ot&&(U=!0)}else Ae.nodeType==3&&ge(Ae.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(_e(t),t==i);)t=t.nextSibling,J=!1;return S}function la(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(kt(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(kt(S),S.text.length),n)}var U=t.nodeType==3?t:null,Y=t;for(!U&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(U=t.firstChild,i&&(i=U.nodeValue.length));Y.parentNode!=r;)Y=Y.parentNode;var J=e.measure,q=J.maps;function ce(Xe,Je,ot){for(var Qe=-1;Qe<(q?q.length:0);Qe++)for(var ht=Qe<0?J.map:q[Qe],bt=0;bt<ht.length;bt+=3){var gt=ht[bt+2];if(gt==Xe||gt==Je){var At=kt(Qe<0?e.line:e.rest[Qe]),Xt=ht[bt]+ot;return(ot<0||gt!=Xe)&&(Xt=ht[bt+(ot?1:0)]),Ve(At,Xt)}}}var ge=ce(U,Y,i);if(ge)return ln(ge,n);for(var _e=Y.nextSibling,Ae=U?U.nodeValue.length-i:0;_e;_e=_e.nextSibling){if(ge=ce(_e,_e.firstChild,0),ge)return ln(Ve(ge.line,ge.ch-Ae),n);Ae+=_e.textContent.length}for(var Ne=Y.previousSibling,Ke=i;Ne;Ne=Ne.previousSibling){if(ge=ce(Ne,Ne.firstChild,-1),ge)return ln(Ve(ge.line,ge.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),T&&(n.style.width="0px"),Pe(n,"input",function(){z&&W>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Pe(n,"paste",function(U){if(ze(r,U)||ws(U,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function S(U){if(ze(r,U))return;if(r.somethingSelected())sa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var Y=Ls(r);sa({lineWise:!0,text:Y.text}),U.type=="cut"?r.setSelections(Y.ranges,null,Se):(i.prevInput="",n.value=Y.text.join(`
`),V(n))}else return;U.type=="cut"&&(r.state.cutIncoming=+new Date)}Pe(n,"cut",S),Pe(n,"copy",S),Pe(e.scroller,"paste",function(U){if(fi(e,U)||ze(r,U))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var Y=new Event("paste");Y.clipboardData=U.clipboardData,n.dispatchEvent(Y)}),Pe(e.lineSpace,"selectstart",function(U){fi(e,U)||re(U)}),Pe(n,"compositionstart",function(){var U=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:U,range:r.markText(U,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Pe(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},qt.prototype.createField=function(e){this.wrapper=_s(),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=vo(e);if(e.options.moveInputWithCursor){var n=Jr(e,i.sel.primary().head,"div"),S=t.wrapper.getBoundingClientRect(),U=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+U.top-S.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+U.left-S.left))}return r},qt.prototype.showSelection=function(e){var t=this.cm,i=t.display;u(i.cursorDiv,e.cursors),u(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&&W>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",z&&W>=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||N()!=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||dt(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&&W>=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 U=0,Y=Math.min(r.length,n.length);U<Y&&r.charCodeAt(U)==n.charCodeAt(U);)++U;return Rr(t,function(){Ka(t,n.slice(U),r.length-U,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},qt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},qt.prototype.onKeyPress=function(){z&&W>=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=Mi(i,e),U=r.scroller.scrollTop;if(!S||w)return;var Y=i.options.resetSelectionOnContextMenu;Y&&i.doc.sel.contains(S)==-1&&lr(i,gr)(i.doc,Ei(S),Se);var J=n.style.cssText,q=t.wrapper.style.cssText,ce=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-ce.top-5)+"px; left: "+(e.clientX-ce.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 ge;I&&(ge=window.scrollY),r.input.focus(),I&&window.scrollTo(null,ge),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=Ae,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function _e(){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 Ae(){if(t.contextMenuPending!=Ae)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=q,n.style.cssText=J,z&&W<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=U),n.selectionStart!=null){(!z||z&&W<9)&&_e();var Ke=0,Xe=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?lr(i,$o)(i):Ke++<10?r.detectingSelectAll=setTimeout(Xe,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Xe,200)}}if(z&&W>=9&&_e(),L){ue(e);var Ne=function(){nt(window,"mouseup",Ne),setTimeout(Ae,20)};Pe(window,"mouseup",Ne)}else setTimeout(Ae,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?M(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=N();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=Y.getValue()}var n;if(e.form&&(Pe(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var S=e.form;n=S.submit;try{var U=S.submit=function(){r(),S.submit=n,S.submit(),S.submit=U}}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&&(nt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var Y=Yt(function(J){return e.parentNode.insertBefore(J,e.nextSibling)},t);return Y}function nu(e){e.off=nt,e.on=Pe,e.wheelEventPixels=dl,e.Doc=wr,e.splitLines=St,e.countColumn=$,e.findColumn=Te,e.isWordChar=Oe,e.Pass=De,e.signal=Ie,e.Line=Ri,e.changeEnd=Si,e.scrollbarModel=wo,e.Pos=Ve,e.cmpPos=Tt,e.modes=Wt,e.mimeModes=Lt,e.resolveMode=vt,e.getMode=Vr,e.modeExtensions=nr,e.extendMode=cr,e.copyState=Hr,e.startState=si,e.innerMode=oi,e.commands=Mn,e.keyMap=pi,e.keyName=ds,e.isModifierKey=us,e.lookupKey=an,e.normalizeKeyMap=Pl,e.StringStream=Pt,e.SharedTextMarker=Rn,e.TextMarker=Ci,e.LineWidget=Dn,e.e_preventDefault=re,e.e_stopPropagation=ie,e.e_stop=ue,e.addClass=F,e.contains=E,e.rmClass=g,e.keyNames=wi}$l(Yt),ql(Yt);var au="iter insert remove copy getEditor constructor".split(" ");for(var ua in wr.prototype)wr.prototype.hasOwnProperty(ua)&&ae(au,ua)<0&&(Yt.prototype[ua]=function(e){return function(){return e.apply(this.doc,arguments)}}(wr.prototype[ua]));return ve(wr),Yt.inputStyles={textarea:qt,contenteditable:Gt},Yt.defineMode=function(e){!Yt.defaults.mode&&e!="null"&&(Yt.defaults.mode=e),Wr.apply(this,arguments)},Yt.defineMIME=ai,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){wr.prototype[e]=t},Yt.fromTextArea=iu,nu(Yt),Yt.version="5.58.2",Yt})},Y1PL:function(xt,at,se){"use strict";se.r(at),se.d(at,"ResizableTextArea",function(){return ae});var le=se("wx14"),Q=se("1OyB"),_=se("vuIU"),Z=se("Ji7U"),B=se("LK+K"),P=se("q1tI"),z=se("VTBJ"),W=se("rePB"),I=se("Zm9Q"),D=se("Kwbf"),y=se("c+Xe"),w=se("m+aA"),O=se("bdgK"),k=new Map;function A(Se){Se.forEach(function(Ce){var we,Te=Ce.target;(we=k.get(Te))===null||we===void 0||we.forEach(function(me){return me(Te)})})}var T=new O.default(A),h=null,o=null;function l(Se,Ce){k.has(Se)||(k.set(Se,new Set),T.observe(Se)),k.get(Se).add(Ce)}function d(Se,Ce){k.has(Se)&&(k.get(Se).delete(Ce),k.get(Se).size||(T.unobserve(Se),k.delete(Se)))}var C=function(Se){Object(Z.a)(we,Se);var Ce=Object(B.a)(we);function we(){return Object(Q.a)(this,we),Ce.apply(this,arguments)}return Object(_.a)(we,[{key:"render",value:function(){return this.props.children}}]),we}(P.Component),f=P.createContext(null);function p(Se){var Ce=Se.children,we=Se.onBatchResize,Te=P.useRef(0),me=P.useRef([]),he=P.useContext(f),te=P.useCallback(function(de,ne,Le){Te.current+=1;var Re=Te.current;me.current.push({size:de,element:ne,data:Le}),Promise.resolve().then(function(){Re===Te.current&&(we==null||we(me.current),me.current=[])}),he==null||he(de,ne,Le)},[we,he]);return P.createElement(f.Provider,{value:te},Ce)}function L(Se){var Ce=Se.children,we=Se.disabled,Te=P.useRef(null),me=P.useRef(null),he=P.useContext(f),te=P.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),de=P.isValidElement(Ce)&&Object(y.c)(Ce),ne=de?Ce.ref:null,Le=P.useMemo(function(){return Object(y.a)(ne,Te)},[ne,Te]),Re=P.useRef(Se);Re.current=Se;var xe=P.useCallback(function(Oe){var Me=Re.current,He=Me.onResize,We=Me.data,Fe=Oe.getBoundingClientRect(),Be=Fe.width,tt=Fe.height,qe=Oe.offsetWidth,Ze=Oe.offsetHeight,$e=Math.floor(Be),ct=Math.floor(tt);if(te.current.width!==$e||te.current.height!==ct||te.current.offsetWidth!==qe||te.current.offsetHeight!==Ze){var rt={width:$e,height:ct,offsetWidth:qe,offsetHeight:Ze};te.current=rt;var it=qe===Math.round(Be)?Be:qe,Pe=Ze===Math.round(tt)?tt:Ze,st=Object(z.a)(Object(z.a)({},rt),{},{offsetWidth:it,offsetHeight:Pe});he==null||he(st,Oe,We),He&&Promise.resolve().then(function(){He(st,Oe)})}},[]);return P.useEffect(function(){var Oe=Object(w.a)(Te.current)||Object(w.a)(me.current);return Oe&&!we&&l(Oe,xe),function(){return d(Oe,xe)}},[Te.current,we]),P.createElement(C,{ref:me},de?P.cloneElement(Ce,{ref:Le}):Ce)}var b="rc-observer-key";function g(Se){var Ce=Se.children,we=Object(I.a)(Ce);return we.map(function(Te,me){var he=(Te==null?void 0:Te.key)||"".concat(b,"-").concat(me);return P.createElement(L,Object(le.a)({},Se,{key:he}),Te)})}g.Collection=p;var c=g,u=se("bT9E"),a=se("TSYQ"),x=se.n(a),v=`
min-height:0 !important;
max-height:none !important;
height:0 !important;
visibility:hidden !important;
overflow:hidden !important;
position:absolute !important;
z-index:-1000 !important;
top:0 !important;
right:0 !important
`,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"],N={},F;function K(Se){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=Se.getAttribute("id")||Se.getAttribute("data-reactid")||Se.getAttribute("name");if(Ce&&N[we])return N[we];var Te=window.getComputedStyle(Se),me=Te.getPropertyValue("box-sizing")||Te.getPropertyValue("-moz-box-sizing")||Te.getPropertyValue("-webkit-box-sizing"),he=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(Le){return"".concat(Le,":").concat(Te.getPropertyValue(Le))}).join(";"),ne={sizingStyle:de,paddingSize:he,borderSize:te,boxSizing:me};return Ce&&we&&(N[we]=ne),ne}function V(Se){var Ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,we=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Te=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;F||(F=document.createElement("textarea"),F.setAttribute("tab-index","-1"),F.setAttribute("aria-hidden","true"),document.body.appendChild(F)),Se.getAttribute("wrap")?F.setAttribute("wrap",Se.getAttribute("wrap")):F.removeAttribute("wrap");var me=K(Se,Ce),he=me.paddingSize,te=me.borderSize,de=me.boxSizing,ne=me.sizingStyle;F.setAttribute("style","".concat(ne,";").concat(v)),F.value=Se.value||Se.placeholder||"";var Le=Number.MIN_SAFE_INTEGER,Re=Number.MAX_SAFE_INTEGER,xe=F.scrollHeight,Oe;if(de==="border-box"?xe+=te:de==="content-box"&&(xe-=he),we!==null||Te!==null){F.value=" ";var Me=F.scrollHeight-he;we!==null&&(Le=Me*we,de==="border-box"&&(Le=Le+he+te),xe=Math.max(Le,xe)),Te!==null&&(Re=Me*Te,de==="border-box"&&(Re=Re+he+te),Oe=xe>Re?"":"hidden",xe=Math.min(Re,xe))}return{height:xe,minHeight:Le,maxHeight:Re,overflowY:Oe,resize:"none"}}var R=se("Gytx"),M=se.n(R),$;(function(Se){Se[Se.NONE=0]="NONE",Se[Se.RESIZING=1]="RESIZING",Se[Se.RESIZED=2]="RESIZED"})($||($={}));var ee=function(Se){Object(Z.a)(we,Se);var Ce=Object(B.a)(we);function we(Te){var me;return Object(Q.a)(this,we),me=Ce.call(this,Te),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(he){me.textArea=he},me.handleResize=function(he){var te=me.state.resizeStatus,de=me.props,ne=de.autoSize,Le=de.onResize;if(te!==$.NONE)return;typeof Le=="function"&&Le(he),ne&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var he=me.props.autoSize;if(!he||!me.textArea)return;var te=he.minRows,de=he.maxRows,ne=V(me.textArea,!1,te,de);me.setState({textareaStyles:ne,resizeStatus:$.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:$.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:$.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var he=me.props,te=he.prefixCls,de=te===void 0?"rc-textarea":te,ne=he.autoSize,Le=he.onResize,Re=he.className,xe=he.disabled,Oe=me.state,Me=Oe.textareaStyles,He=Oe.resizeStatus,We=Object(u.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Fe=x()(de,Re,Object(W.a)({},"".concat(de,"-disabled"),xe));"value"in We&&(We.value=We.value||"");var Be=Object(z.a)(Object(z.a)(Object(z.a)({},me.props.style),Me),He===$.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return P.createElement(c,{onResize:me.handleResize,disabled:!(ne||Le)},P.createElement("textarea",Object(le.a)({},We,{className:Fe,style:Be,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:$.NONE},me}return Object(_.a)(we,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!M()(me.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var me=this.textArea.selectionStart,he=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,he)}}catch(te){}}},{key:"render",value:function(){return this.renderTextArea()}}]),we}(P.Component),ae=ee,fe=function(Se){Object(Z.a)(we,Se);var Ce=Object(B.a)(we);function we(Te){var me;Object(Q.a)(this,we),me=Ce.call(this,Te),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(te){me.resizableTextArea=te},me.handleChange=function(te){var de=me.props.onChange;me.setValue(te.target.value,function(){me.resizableTextArea.resizeTextarea()}),de&&de(te)},me.handleKeyDown=function(te){var de=me.props,ne=de.onPressEnter,Le=de.onKeyDown;te.keyCode===13&&ne&&ne(te),Le&&Le(te)};var he=typeof Te.value=="undefined"||Te.value===null?Te.defaultValue:Te.value;return me.state={value:he},me}return Object(_.a)(we,[{key:"setValue",value:function(me,he){"value"in this.props||this.setState({value:me},he)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return P.createElement(ae,Object(le.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(me){return"value"in me?{value:me.value}:null}}]),we}(P.Component),De=at.default=fe},ZW9T:function(xt,at,se){"use strict";se.d(at,"a",function(){return C});var le=se("k1fw"),Q=se("miYZ"),_=se("tsqr"),Z=se("rAM+"),B=se("tJVT"),P=se("PpiC"),z=se("q1tI"),W=se.n(z),I=se("bdgK");function D(f,p,L,b,g){var c=p.getWordUntilPosition(L),u={startLineNumber:L.lineNumber,endLineNumber:L.lineNumber,startColumn:c.startColumn,endColumn:c.endColumn},a=b.map(function(x){return{label:x,kind:f.languages.CompletionItemKind.Keyword,insertText:x,insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:u}});return g.map(function(x){a.push(Object(le.a)(Object(le.a)({},x),{},{range:u}))}),a}var y=function(f){var p={label:"ifelse",kind:f.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},L=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];f.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(u,a){var x=D(f,u,a,L,[p]);return{suggestions:x}}});var b=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];f.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(u,a){var x=[{label:"print",kind:f.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],v=D(f,u,a,b,x);return{suggestions:v}}});var g=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];f.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(u,a){var x=[p,{label:"main",kind:f.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:f.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],v=D(f,u,a,g,x);return{suggestions:v}}})},w="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",O=se("LvDl");function k(f){return/^\d+$/.test(f)?"".concat(f,"px"):f}function A(){}var T=!1,h={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function o(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=f;if(Array.isArray(f)){for(var L=0;L<f.length;L++){var b=h[f[L]];if(b)return b}return p[0]}return h[p]||p}var l=null,d=at.b=function(f){var p=f.width,L=p===void 0?"100%":p,b=f.height,g=b===void 0?"100%":b,c=f.value,u=f.language,a=u===void 0?"javascript":u,x=f.style,v=x===void 0?{}:x,E=f.options,N=E===void 0?{}:E,F=f.overrideServices,K=F===void 0?{}:F,V=f.theme,R=V===void 0?"vs-dark":V,M=f.onEditBlur,$=f.onSave,ee=f.autoHeight,ae=ee===void 0?!1:ee,fe=f.forbidCopy,De=fe===void 0?!1:fe,Se=f.onChange,Ce=Se===void 0?A:Se,we=f.editorDidMount,Te=we===void 0?A:we,me=f.onFocus,he=me===void 0?A:me,te=f.filename,de=te===void 0?"educoder.txt":te,ne=Object(P.a)(f,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Le=Object(z.useRef)(),Re=Object(z.useRef)({}),xe=Object(z.useRef)(),Oe=Object(z.useRef)(!1),Me=Object(z.useRef)(),He=Object(z.useState)(!1),We=Object(B.a)(He,2),Fe=We[0],Be=We[1];function tt(){var oe;return Le.current&&(oe=new I.default(function(ue){var ke=Object(Z.a)(ue),Ee;try{for(ke.s();!(Ee=ke.n()).done;){var Ue=Ee.value;(Ue.target.offsetHeight>0||Ue.target.offsetWidth>0)&&Re.current.instance.layout()}}catch(et){ke.e(et)}finally{ke.f()}}),oe.observe(Le.current)),oe}function qe(){_.b.warn(decodeURIComponent(w))}var Ze=function(){var ue=Re.current.instance;if(c!=null&&ue&&Fe){var ke=ue.getModel();ke&&c!==ke.getValue()&&(T=!0,ke.setValue(c),ue.layout(),T=!1)}};Object(z.useEffect)(function(){xe.current&&clearTimeout(xe.current),xe.current=setTimeout(function(){Ze()},500)},[c,Fe,Re.current]);function $e(){var oe=Re.current.instance;if(oe){var ue=oe.getSelection(),ke=Re.current.pastePos||{},Ee=new l.Range(ke.startLineNumber||ue.endLineNumber,ke.startColumn||ue.endColumn,ke.endLineNumber||ue.endLineNumber,ke.endColumn||ue.endColumn);setTimeout(function(){oe.executeEdits("",[{range:Ee,text:""}])},300)}}function ct(oe){(window.navigator.platform.match("Mac")?oe.metaKey:oe.ctrlKey)&&oe.keyCode==83&&(oe.preventDefault(),$())}var rt=function(){if(ae&&Re.current.instance){var ue=Re.current.instance.getContentHeight();re(ue<g?g:ue)}else re(g)};function it(oe){var ue=document.createEvent("MouseEvents");ue.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),oe.dispatchEvent(ue)}function Pe(oe,ue){var ke=window.URL||window.webkitURL||window,Ee=new Blob([ue]),Ue=document.createElementNS("http://www.w3.org/1999/xhtml","a");Ue.href=ke.createObjectURL(Ee),Ue.download=oe,it(Ue)}Object(z.useEffect)(function(){rt()},[rt]),Object(z.useEffect)(function(){Le.current&&!Fe&&se.e(27).then(se.t.bind(null,"M/lh",7)).then(function(oe){try{l=oe,Re.current.instance=l.editor.create(Le.current,{value:c,language:o(a),theme:R,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},K);var ue=Re.current.instance;if(Te(ue,l),setTimeout(function(){rt(),Re.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Pe(de||"educoder.txt",ue.getValue())}})},500),Re.current.subscription=ue.onDidChangeModelContent(function(Ee){Oe.current?clearTimeout(Me.current):(rt(),Ce(ue.getValue(),Ee)),Me.current=setTimeout(function(){Oe.current=!1},500)}),window.Monaco||y(l),De&&(ue.addCommand(l.KeyMod.CtrlCmd|l.KeyMod.Shift|l.KeyCode.KEY_V,function(){return qe(),null}),ue.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_C,function(){return qe(),null})),window.Monaco=l,M&&ue.onDidBlurEditorWidget(function(){M(ue.getValue())}),he&&ue.onDidFocusEditorText(function(){he(ue.getValue())}),De){ue.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_V,function(){return qe(),null}),ue.onDidPaste(function(Ee){Re.current.pastePos=Ee});try{window.addEventListener("paste",$e)}catch(Ee){}}var ke=tt();return Be(!0),function(){var Ee=Re.current.instance;Ee.dispose();var Ue=Ee.getModel();Ue&&Ue.dispose(),Re.current.subscription&&Re.current.subscription.dispose(),De&&window.removeEventListener("paste",$e),ke.unobserve(Le.current)}}catch(Ee){}})},[]),Object(z.useEffect)(function(){var oe=Re.current.instance;if(oe&&Fe)return document.addEventListener("keydown",ct,!1),function(){document.removeEventListener("keydown",ct)}},[$,Fe]),Object(z.useEffect)(function(){var oe=Re.current.instance;if(oe&&Fe){var ue=o(a);l.editor.setModelLanguage(oe.getModel(),ue),console.log("language:",a,oe.getModel(),ue)}},[a,Fe]),Object(z.useEffect)(function(){var oe=Re.current.instance;oe&&Fe&&l.editor.setTheme(R)},[R,Fe]),Object(z.useEffect)(function(){var oe=Re.current.instance;oe&&Fe&&(oe.updateOptions(Object(le.a)({},N)),setTimeout(function(){oe.getModel().updateOptions(Object(le.a)({},N))},200))},[JSON.stringify(N),Fe]),Object(z.useEffect)(function(){var oe=Re.current.instance;oe&&Fe&&oe.layout()},[L,g,Fe]);var st=Object(z.useState)(k(L)),nt=Object(B.a)(st,2),Ie=nt[0],ze=nt[1],be=Object(z.useState)(k(g)),pe=Object(B.a)(be,2),ve=pe[0],re=pe[1],ie=Object(le.a)(Object(le.a)({},v),{},{width:Ie,height:ve});return W.a.createElement("div",{className:"my-monaco-editor",ref:Le,style:ie})};function C(f){var p=f.width,L=p===void 0?"100%":p,b=f.height,g=b===void 0?"100%":b,c=f.original,u=f.modified,a=f.language,x=f.options,v=x===void 0?{}:x,E=Object(z.useRef)(),N=Object(z.useState)(null),F=Object(B.a)(N,2),K=F[0],V=F[1];function R(ae){var fe;return E.current&&(fe=new I.default(function(De){var Se=Object(Z.a)(De),Ce;try{for(Se.s();!(Ce=Se.n()).done;){var we=Ce.value;(we.target.offsetHeight>0||we.target.offsetWidth>0)&&ae.layout()}}catch(Te){Se.e(Te)}finally{Se.f()}}),fe.observe(E.current)),fe}Object(z.useEffect)(function(){E.current&&se.e(27).then(se.t.bind(null,"M/lh",7)).then(function(ae){l=ae;var fe=l.editor.createDiffEditor(E.current,Object(le.a)(Object(le.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},v),{},{wordWrap:!0}));V(fe);var De=R(fe);return function(){fe.dispose();var Se=fe.getModel();Se&&Se.dispose(),De.unobserve(E.current)}})},[]),Object(z.useEffect)(function(){K&&K.setModel({original:l.editor.createModel(c,a),modified:l.editor.createModel(u,a)})},[c,u,a,K]);var M=k(L),$=k(g),ee={width:M,height:$};return W.a.createElement("div",{className:"my-diff-editor",ref:E,style:ee})}},ZpRC:function(xt,at,se){"use strict";function le(y){return typeof y=="object"&&y!=null&&y.nodeType===1}function Q(y,w){return(!w||y!=="hidden")&&y!=="visible"&&y!=="clip"}function _(y,w){if(y.clientHeight<y.scrollHeight||y.clientWidth<y.scrollWidth){var O=getComputedStyle(y,null);return Q(O.overflowY,w)||Q(O.overflowX,w)||function(k){var A=function(T){if(!T.ownerDocument||!T.ownerDocument.defaultView)return null;try{return T.ownerDocument.defaultView.frameElement}catch(h){return null}}(k);return!!A&&(A.clientHeight<k.scrollHeight||A.clientWidth<k.scrollWidth)}(y)}return!1}function Z(y,w,O,k,A,T,h,o){return T<y&&h>w||T>y&&h<w?0:T<=y&&o<=O||h>=w&&o>=O?T-y-k:h>w&&o<O||T<y&&o>O?h-w+A:0}var B=function(y,w){var O=window,k=w.scrollMode,A=w.block,T=w.inline,h=w.boundary,o=w.skipOverflowHiddenElements,l=typeof h=="function"?h:function(Me){return Me!==h};if(!le(y))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,C=[],f=y;le(f)&&l(f);){if((f=f.parentElement)===d){C.push(f);break}f!=null&&f===document.body&&_(f)&&!_(document.documentElement)||f!=null&&_(f,o)&&C.push(f)}for(var p=O.visualViewport?O.visualViewport.width:innerWidth,L=O.visualViewport?O.visualViewport.height:innerHeight,b=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,c=y.getBoundingClientRect(),u=c.height,a=c.width,x=c.top,v=c.right,E=c.bottom,N=c.left,F=A==="start"||A==="nearest"?x:A==="end"?E:x+u/2,K=T==="center"?N+a/2:T==="end"?v:N,V=[],R=0;R<C.length;R++){var M=C[R],$=M.getBoundingClientRect(),ee=$.height,ae=$.width,fe=$.top,De=$.right,Se=$.bottom,Ce=$.left;if(k==="if-needed"&&x>=0&&N>=0&&E<=L&&v<=p&&x>=fe&&E<=Se&&N>=Ce&&v<=De)return V;var we=getComputedStyle(M),Te=parseInt(we.borderLeftWidth,10),me=parseInt(we.borderTopWidth,10),he=parseInt(we.borderRightWidth,10),te=parseInt(we.borderBottomWidth,10),de=0,ne=0,Le="offsetWidth"in M?M.offsetWidth-M.clientWidth-Te-he:0,Re="offsetHeight"in M?M.offsetHeight-M.clientHeight-me-te:0;if(d===M)de=A==="start"?F:A==="end"?F-L:A==="nearest"?Z(g,g+L,L,me,te,g+F,g+F+u,u):F-L/2,ne=T==="start"?K:T==="center"?K-p/2:T==="end"?K-p:Z(b,b+p,p,Te,he,b+K,b+K+a,a),de=Math.max(0,de+g),ne=Math.max(0,ne+b);else{de=A==="start"?F-fe-me:A==="end"?F-Se+te+Re:A==="nearest"?Z(fe,Se,ee,me,te+Re,F,F+u,u):F-(fe+ee/2)+Re/2,ne=T==="start"?K-Ce-Te:T==="center"?K-(Ce+ae/2)+Le/2:T==="end"?K-De+he+Le:Z(Ce,De,ae,Te,he+Le,K,K+a,a);var xe=M.scrollLeft,Oe=M.scrollTop;F+=Oe-(de=Math.max(0,Math.min(Oe+de,M.scrollHeight-ee+Re))),K+=xe-(ne=Math.max(0,Math.min(xe+ne,M.scrollWidth-ae+Le)))}V.push({el:M,top:de,left:ne})}return V};function P(y){return y===Object(y)&&Object.keys(y).length!==0}function z(y,w){w===void 0&&(w="auto");var O="scrollBehavior"in document.body.style;y.forEach(function(k){var A=k.el,T=k.top,h=k.left;A.scroll&&O?A.scroll({top:T,left:h,behavior:w}):(A.scrollTop=T,A.scrollLeft=h)})}function W(y){return y===!1?{block:"end",inline:"nearest"}:P(y)?y:{block:"start",inline:"nearest"}}function I(y,w){var O=!y.ownerDocument.documentElement.contains(y);if(P(w)&&typeof w.behavior=="function")return w.behavior(O?[]:B(y,w));if(O)return;var k=W(w);return z(B(y,k),k.behavior)}var D=at.a=I},Zss7:function(xt,at,se){var le;(function(Q){var _=/^\s+/,Z=/\s+$/,B=0,P=Q.round,z=Q.min,W=Q.max,I=Q.random;function D(te,de){if(te=te||"",de=de||{},te instanceof D)return te;if(!(this instanceof D))return new D(te,de);var ne=y(te);this._originalInput=te,this._r=ne.r,this._g=ne.g,this._b=ne.b,this._a=ne.a,this._roundA=P(100*this._a)/100,this._format=de.format||ne.format,this._gradientType=de.gradientType,this._r<1&&(this._r=P(this._r)),this._g<1&&(this._g=P(this._g)),this._b<1&&(this._b=P(this._b)),this._ok=ne.ok,this._tc_id=B++}D.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,Le,Re,xe,Oe;return de=te.r/255,ne=te.g/255,Le=te.b/255,de<=.03928?Re=de/12.92:Re=Q.pow((de+.055)/1.055,2.4),ne<=.03928?xe=ne/12.92:xe=Q.pow((ne+.055)/1.055,2.4),Le<=.03928?Oe=Le/12.92:Oe=Q.pow((Le+.055)/1.055,2.4),.2126*Re+.7152*xe+.0722*Oe},setAlpha:function(te){return this._a=V(te),this._roundA=P(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=P(te.h*360),ne=P(te.s*100),Le=P(te.v*100);return this._a==1?"hsv("+de+", "+ne+"%, "+Le+"%)":"hsva("+de+", "+ne+"%, "+Le+"%, "+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=P(te.h*360),ne=P(te.s*100),Le=P(te.l*100);return this._a==1?"hsl("+de+", "+ne+"%, "+Le+"%)":"hsla("+de+", "+ne+"%, "+Le+"%, "+this._roundA+")"},toHex:function(te){return h(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:P(this._r),g:P(this._g),b:P(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+P(this._r)+", "+P(this._g)+", "+P(this._b)+")":"rgba("+P(this._r)+", "+P(this._g)+", "+P(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:P(R(this._r,255)*100)+"%",g:P(R(this._g,255)*100)+"%",b:P(R(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+P(R(this._r,255)*100)+"%, "+P(R(this._g,255)*100)+"%, "+P(R(this._b,255)*100)+"%)":"rgba("+P(R(this._r,255)*100)+"%, "+P(R(this._g,255)*100)+"%, "+P(R(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:F[h(this._r,this._g,this._b,!0)]||!1},toFilter:function(te){var de="#"+l(this._r,this._g,this._b,this._a),ne=de,Le=this._gradientType?"GradientType = 1, ":"";if(te){var Re=D(te);ne="#"+l(Re._r,Re._g,Re._b,Re._a)}return"progid:DXImageTransform.Microsoft.gradient("+Le+"startColorstr="+de+",endColorstr="+ne+")"},toString:function(te){var de=!!te;te=te||this._format;var ne=!1,Le=this._a<1&&this._a>=0,Re=!de&&Le&&(te==="hex"||te==="hex6"||te==="hex3"||te==="hex4"||te==="hex8"||te==="name");return Re?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 D(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(p,arguments)},brighten:function(){return this._applyModification(L,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(C,arguments)},greyscale:function(){return this._applyModification(f,arguments)},spin:function(){return this._applyModification(g,arguments)},_applyCombination:function(te,de){return te.apply(null,[this].concat([].slice.call(de)))},analogous:function(){return this._applyCombination(v,arguments)},complement:function(){return this._applyCombination(c,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(x,arguments)},triad:function(){return this._applyCombination(u,arguments)},tetrad:function(){return this._applyCombination(a,arguments)}},D.fromRatio=function(te,de){if(typeof te=="object"){var ne={};for(var Le in te)te.hasOwnProperty(Le)&&(Le==="a"?ne[Le]=te[Le]:ne[Le]=De(te[Le]));te=ne}return D(te,de)};function y(te){var de={r:0,g:0,b:0},ne=1,Le=null,Re=null,xe=null,Oe=!1,Me=!1;return typeof te=="string"&&(te=me(te)),typeof te=="object"&&(Te(te.r)&&Te(te.g)&&Te(te.b)?(de=w(te.r,te.g,te.b),Oe=!0,Me=String(te.r).substr(-1)==="%"?"prgb":"rgb"):Te(te.h)&&Te(te.s)&&Te(te.v)?(Le=De(te.s),Re=De(te.v),de=T(te.h,Le,Re),Oe=!0,Me="hsv"):Te(te.h)&&Te(te.s)&&Te(te.l)&&(Le=De(te.s),xe=De(te.l),de=k(te.h,Le,xe),Oe=!0,Me="hsl"),te.hasOwnProperty("a")&&(ne=te.a)),ne=V(ne),{ok:Oe,format:te.format||Me,r:z(255,W(de.r,0)),g:z(255,W(de.g,0)),b:z(255,W(de.b,0)),a:ne}}function w(te,de,ne){return{r:R(te,255)*255,g:R(de,255)*255,b:R(ne,255)*255}}function O(te,de,ne){te=R(te,255),de=R(de,255),ne=R(ne,255);var Le=W(te,de,ne),Re=z(te,de,ne),xe,Oe,Me=(Le+Re)/2;if(Le==Re)xe=Oe=0;else{var He=Le-Re;Oe=Me>.5?He/(2-Le-Re):He/(Le+Re);switch(Le){case te:xe=(de-ne)/He+(de<ne?6:0);break;case de:xe=(ne-te)/He+2;break;case ne:xe=(te-de)/He+4;break}xe/=6}return{h:xe,s:Oe,l:Me}}function k(te,de,ne){var Le,Re,xe;te=R(te,360),de=R(de,100),ne=R(ne,100);function Oe(We,Fe,Be){return Be<0&&(Be+=1),Be>1&&(Be-=1),Be<1/6?We+(Fe-We)*6*Be:Be<1/2?Fe:Be<2/3?We+(Fe-We)*(2/3-Be)*6:We}if(de===0)Le=Re=xe=ne;else{var Me=ne<.5?ne*(1+de):ne+de-ne*de,He=2*ne-Me;Le=Oe(He,Me,te+1/3),Re=Oe(He,Me,te),xe=Oe(He,Me,te-1/3)}return{r:Le*255,g:Re*255,b:xe*255}}function A(te,de,ne){te=R(te,255),de=R(de,255),ne=R(ne,255);var Le=W(te,de,ne),Re=z(te,de,ne),xe,Oe,Me=Le,He=Le-Re;if(Oe=Le===0?0:He/Le,Le==Re)xe=0;else{switch(Le){case te:xe=(de-ne)/He+(de<ne?6:0);break;case de:xe=(ne-te)/He+2;break;case ne:xe=(te-de)/He+4;break}xe/=6}return{h:xe,s:Oe,v:Me}}function T(te,de,ne){te=R(te,360)*6,de=R(de,100),ne=R(ne,100);var Le=Q.floor(te),Re=te-Le,xe=ne*(1-de),Oe=ne*(1-Re*de),Me=ne*(1-(1-Re)*de),He=Le%6,We=[ne,Oe,xe,xe,Me,ne][He],Fe=[Me,ne,ne,Oe,xe,xe][He],Be=[xe,xe,Me,ne,ne,Oe][He];return{r:We*255,g:Fe*255,b:Be*255}}function h(te,de,ne,Le){var Re=[fe(P(te).toString(16)),fe(P(de).toString(16)),fe(P(ne).toString(16))];return Le&&Re[0].charAt(0)==Re[0].charAt(1)&&Re[1].charAt(0)==Re[1].charAt(1)&&Re[2].charAt(0)==Re[2].charAt(1)?Re[0].charAt(0)+Re[1].charAt(0)+Re[2].charAt(0):Re.join("")}function o(te,de,ne,Le,Re){var xe=[fe(P(te).toString(16)),fe(P(de).toString(16)),fe(P(ne).toString(16)),fe(Se(Le))];return Re&&xe[0].charAt(0)==xe[0].charAt(1)&&xe[1].charAt(0)==xe[1].charAt(1)&&xe[2].charAt(0)==xe[2].charAt(1)&&xe[3].charAt(0)==xe[3].charAt(1)?xe[0].charAt(0)+xe[1].charAt(0)+xe[2].charAt(0)+xe[3].charAt(0):xe.join("")}function l(te,de,ne,Le){var Re=[fe(Se(Le)),fe(P(te).toString(16)),fe(P(de).toString(16)),fe(P(ne).toString(16))];return Re.join("")}D.equals=function(te,de){return!te||!de?!1:D(te).toRgbString()==D(de).toRgbString()},D.random=function(){return D.fromRatio({r:I(),g:I(),b:I()})};function d(te,de){de=de===0?0:de||10;var ne=D(te).toHsl();return ne.s-=de/100,ne.s=M(ne.s),D(ne)}function C(te,de){de=de===0?0:de||10;var ne=D(te).toHsl();return ne.s+=de/100,ne.s=M(ne.s),D(ne)}function f(te){return D(te).desaturate(100)}function p(te,de){de=de===0?0:de||10;var ne=D(te).toHsl();return ne.l+=de/100,ne.l=M(ne.l),D(ne)}function L(te,de){de=de===0?0:de||10;var ne=D(te).toRgb();return ne.r=W(0,z(255,ne.r-P(255*-(de/100)))),ne.g=W(0,z(255,ne.g-P(255*-(de/100)))),ne.b=W(0,z(255,ne.b-P(255*-(de/100)))),D(ne)}function b(te,de){de=de===0?0:de||10;var ne=D(te).toHsl();return ne.l-=de/100,ne.l=M(ne.l),D(ne)}function g(te,de){var ne=D(te).toHsl(),Le=(ne.h+de)%360;return ne.h=Le<0?360+Le:Le,D(ne)}function c(te){var de=D(te).toHsl();return de.h=(de.h+180)%360,D(de)}function u(te){var de=D(te).toHsl(),ne=de.h;return[D(te),D({h:(ne+120)%360,s:de.s,l:de.l}),D({h:(ne+240)%360,s:de.s,l:de.l})]}function a(te){var de=D(te).toHsl(),ne=de.h;return[D(te),D({h:(ne+90)%360,s:de.s,l:de.l}),D({h:(ne+180)%360,s:de.s,l:de.l}),D({h:(ne+270)%360,s:de.s,l:de.l})]}function x(te){var de=D(te).toHsl(),ne=de.h;return[D(te),D({h:(ne+72)%360,s:de.s,l:de.l}),D({h:(ne+216)%360,s:de.s,l:de.l})]}function v(te,de,ne){de=de||6,ne=ne||30;var Le=D(te).toHsl(),Re=360/ne,xe=[D(te)];for(Le.h=(Le.h-(Re*de>>1)+720)%360;--de;)Le.h=(Le.h+Re)%360,xe.push(D(Le));return xe}function E(te,de){de=de||6;for(var ne=D(te).toHsv(),Le=ne.h,Re=ne.s,xe=ne.v,Oe=[],Me=1/de;de--;)Oe.push(D({h:Le,s:Re,v:xe})),xe=(xe+Me)%1;return Oe}D.mix=function(te,de,ne){ne=ne===0?0:ne||50;var Le=D(te).toRgb(),Re=D(de).toRgb(),xe=ne/100,Oe={r:(Re.r-Le.r)*xe+Le.r,g:(Re.g-Le.g)*xe+Le.g,b:(Re.b-Le.b)*xe+Le.b,a:(Re.a-Le.a)*xe+Le.a};return D(Oe)},D.readability=function(te,de){var ne=D(te),Le=D(de);return(Q.max(ne.getLuminance(),Le.getLuminance())+.05)/(Q.min(ne.getLuminance(),Le.getLuminance())+.05)},D.isReadable=function(te,de,ne){var Le=D.readability(te,de),Re,xe;xe=!1,Re=he(ne);switch(Re.level+Re.size){case"AAsmall":case"AAAlarge":xe=Le>=4.5;break;case"AAlarge":xe=Le>=3;break;case"AAAsmall":xe=Le>=7;break}return xe},D.mostReadable=function(te,de,ne){var Le=null,Re=0,xe,Oe,Me,He;ne=ne||{},Oe=ne.includeFallbackColors,Me=ne.level,He=ne.size;for(var We=0;We<de.length;We++)xe=D.readability(te,de[We]),xe>Re&&(Re=xe,Le=D(de[We]));return D.isReadable(te,Le,{level:Me,size:He})||!Oe?Le:(ne.includeFallbackColors=!1,D.mostReadable(te,["#fff","#000"],ne))};var N=D.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"},F=D.hexNames=K(N);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 R(te,de){ee(te)&&(te="100%");var ne=ae(te);return te=z(de,W(0,parseFloat(te))),ne&&(te=parseInt(te*de,10)/100),Q.abs(te-de)<1e-6?1:te%de/parseFloat(de)}function M(te){return z(1,W(0,te))}function $(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 fe(te){return te.length==1?"0"+te:""+te}function De(te){return te<=1&&(te=te*100+"%"),te}function Se(te){return Q.round(parseFloat(te)*255).toString(16)}function Ce(te){return $(te)/255}var we=function(){var te="[-\\+]?\\d+%?",de="[-\\+]?\\d*\\.\\d+%?",ne="(?:"+de+")|(?:"+te+")",Le="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?",Re="[\\s|\\(]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")[,|\\s]+("+ne+")\\s*\\)?";return{CSS_UNIT:new RegExp(ne),rgb:new RegExp("rgb"+Le),rgba:new RegExp("rgba"+Re),hsl:new RegExp("hsl"+Le),hsla:new RegExp("hsla"+Re),hsv:new RegExp("hsv"+Le),hsva:new RegExp("hsva"+Re),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!!we.CSS_UNIT.exec(te)}function me(te){te=te.replace(_,"").replace(Z,"").toLowerCase();var de=!1;if(N[te])te=N[te],de=!0;else if(te=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var ne;return(ne=we.rgb.exec(te))?{r:ne[1],g:ne[2],b:ne[3]}:(ne=we.rgba.exec(te))?{r:ne[1],g:ne[2],b:ne[3],a:ne[4]}:(ne=we.hsl.exec(te))?{h:ne[1],s:ne[2],l:ne[3]}:(ne=we.hsla.exec(te))?{h:ne[1],s:ne[2],l:ne[3],a:ne[4]}:(ne=we.hsv.exec(te))?{h:ne[1],s:ne[2],v:ne[3]}:(ne=we.hsva.exec(te))?{h:ne[1],s:ne[2],v:ne[3],a:ne[4]}:(ne=we.hex8.exec(te))?{r:$(ne[1]),g:$(ne[2]),b:$(ne[3]),a:Ce(ne[4]),format:de?"name":"hex8"}:(ne=we.hex6.exec(te))?{r:$(ne[1]),g:$(ne[2]),b:$(ne[3]),format:de?"name":"hex"}:(ne=we.hex4.exec(te))?{r:$(ne[1]+""+ne[1]),g:$(ne[2]+""+ne[2]),b:$(ne[3]+""+ne[3]),a:Ce(ne[4]+""+ne[4]),format:de?"name":"hex8"}:(ne=we.hex3.exec(te))?{r:$(ne[1]+""+ne[1]),g:$(ne[2]+""+ne[2]),b:$(ne[3]+""+ne[3]),format:de?"name":"hex"}:!1}function he(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}}xt.exports?xt.exports=D:!(le=function(){return D}.call(at,se,at,xt),le!==void 0&&(xt.exports=le))})(Math)},bT9E:function(xt,at,se){"use strict";se.d(at,"a",function(){return Q});var le=se("VTBJ");function Q(_,Z){var B=Object(le.a)({},_);return Array.isArray(Z)&&Z.forEach(function(P){delete B[P]}),B}},c5Ni:function(xt,at,se){},dejd:function(xt,at,se){},dmUQ:function(xt,at,se){"use strict";var le=se("Ff2n"),Q=se("rePB"),_=se("1OyB"),Z=se("vuIU"),B=se("Ji7U"),P=se("md7G"),z=se("foSv"),W=se("q1tI"),I=se.n(W),D=se("TSYQ"),y=se.n(D),w=se("4IlW");function O(u,a){var x=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);a&&(v=v.filter(function(E){return Object.getOwnPropertyDescriptor(u,E).enumerable})),x.push.apply(x,v)}return x}function k(u){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?O(Object(x),!0).forEach(function(v){Object(Q.a)(u,v,x[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(x)):O(Object(x)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(x,v))})}return u}function A(u){var a=T();return function(){var v=Object(z.a)(u),E;if(a){var N=Object(z.a)(this).constructor;E=Reflect.construct(v,arguments,N)}else E=v.apply(this,arguments);return Object(P.a)(this,E)}}function T(){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(u){return!1}}function h(){}function o(u){u.preventDefault()}var l=function(a){return a.replace(/[^\w.-]+/g,"")},d=200,C=600,f=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,p=function(a){return a!=null},L=function(a,x){return x===a||typeof x=="number"&&typeof a=="number"&&isNaN(x)&&isNaN(a)},b=function(u){Object(B.a)(x,u);var a=A(x);function x(v){var E;Object(_.a)(this,x),E=a.call(this,v),E.onKeyDown=function(K){var V=E.props,R=V.onKeyDown,M=V.onPressEnter;if(K.keyCode===w.a.UP){var $=E.getRatio(K);E.up(K,$,null),E.stop()}else if(K.keyCode===w.a.DOWN){var ee=E.getRatio(K);E.down(K,ee,null),E.stop()}else K.keyCode===w.a.ENTER&&M&&M(K);if(E.recordCursorPosition(),E.lastKeyCode=K.keyCode,R){for(var ae=arguments.length,fe=new Array(ae>1?ae-1:0),De=1;De<ae;De++)fe[De-1]=arguments[De];R.apply(void 0,[K].concat(fe))}},E.onKeyUp=function(K){var V=E.props.onKeyUp;if(E.stop(),E.recordCursorPosition(),V){for(var R=arguments.length,M=new Array(R>1?R-1:0),$=1;$<R;$++)M[$-1]=arguments[$];V.apply(void 0,[K].concat(M))}},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),R=E.setValue(V,h);if(K){var M=E.input.value,$=E.getInputDisplayValue({focus:!1,value:R});E.input.value=$&&Number($),K.apply(void 0,arguments),E.input.value=M}},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(p(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 R=0;return V.indexOf(".")>=0&&(R=V.length-V.indexOf(".")-1),R},E.getInputDisplayValue=function(K){var V=K||E.state,R=V.focused,M=V.inputValue,$=V.value,ee;R?ee=M:ee=E.toPrecisionAsStep($),ee==null&&(ee="");var ae=E.formatWrapper(ee);return p(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,R=V.lastIndexOf(K);if(R===-1)return!1;var M=E.cursorBefore.length;return E.lastKeyCode===w.a.DELETE&&E.cursorBefore.charAt(M-1)===K[0]?(E.fixCaret(M,M),!0):R+K.length===V.length?(E.fixCaret(R,R),!0):!1},E.partRestoreByAfter=function(K){return K===void 0?!1:Array.prototype.some.call(K,function(V,R){var M=K.substring(R);return E.restoreByAfter(M)})},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,R){E.pressingUpOrDown=!0,E.step("down",K,V,R)},E.up=function(K,V,R){E.pressingUpOrDown=!0,E.step("up",K,V,R)},E.saveInput=function(K){E.input=K};var N=v.value;N===void 0&&(N=v.defaultValue),E.state={focused:v.autoFocus};var F=E.getValidValue(E.toNumber(N));return E.state=k(k({},E.state),{},{inputValue:E.toPrecisionAsStep(F),value:F}),E}return Object(Z.a)(x,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(E){var N=this.props,F=N.value,K=N.onChange,V=N.max,R=N.min,M=this.state.focused;if(E){if(!L(E.value,F)||!L(E.max,V)||!L(E.min,R)){var $=M?F:this.getValidValue(F),ee;this.pressingUpOrDown?ee=$:this.inputting?ee=this.rawInput:ee=this.toPrecisionAsStep($),this.setState({value:$,inputValue:ee})}var ae="value"in this.props?F:this.state.value;"max"in this.props&&E.max!==V&&typeof ae=="number"&&ae>V&&K&&K(V),"min"in this.props&&E.min!==R&&typeof ae=="number"&&ae<R&&K&&K(R)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var fe=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===w.a.BACKSPACE?fe=this.cursorStart-1:this.lastKeyCode===w.a.DELETE&&(fe=this.cursorStart):fe=this.input.value.length,this.fixCaret(fe,fe)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case w.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case w.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(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 N=E;return N===""?N="":this.isNotCompleteNumber(parseFloat(N))?N=this.state.value:N=this.getValidValue(N),this.toNumber(N)}},{key:"getValueFromEvent",value:function(E){var N=E.target.value.trim().replace(/。/g,".");return p(this.props.decimalSeparator)&&(N=N.replace(this.props.decimalSeparator,".")),N}},{key:"getValidValue",value:function(E){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,K=parseFloat(E);return isNaN(K)?E:(K<N&&(K=N),K>F&&(K=F),K)}},{key:"setValue",value:function(E,N){var F=this.props.precision,K=this.isNotCompleteNumber(parseFloat(E))?null:parseFloat(E),V=this.state.value,R=V===void 0?null:V,M=this.state.inputValue,$=M===void 0?null:M,ee=typeof K=="number"?K.toFixed(F):"".concat(K),ae=K!==R||ee!=="".concat($);return"value"in this.props?($=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:$},N)):this.setState({value:K,inputValue:this.toPrecisionAsStep(E)},N),ae&&this.props.onChange(K),K}},{key:"getMaxPrecision",value:function(E){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,F=this.props,K=F.precision,V=F.step;if(p(K))return K;var R=this.getPrecision(N),M=this.getPrecision(V),$=this.getPrecision(E);return E?Math.max($,R+M):R+M}},{key:"getPrecisionFactor",value:function(E){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,F=this.getMaxPrecision(E,N);return Math.pow(10,F)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(E){return this.props.formatter?this.props.formatter(E):E}},{key:"toPrecisionAsStep",value:function(E){if(this.isNotCompleteNumber(E)||E==="")return E;var N=Math.abs(this.getMaxPrecision(E));return isNaN(N)?E.toString():Number(E).toFixed(N)}},{key:"toNumber",value:function(E){var N=this.props.precision,F=this.state.focused,K=E&&E.length>16&&F;return this.isNotCompleteNumber(E)||K?E:p(N)?Math.round(E*Math.pow(10,N))/Math.pow(10,N):Number(E)}},{key:"upStep",value:function(E,N){var F=this.props.step,K=this.getPrecisionFactor(E,N),V=Math.abs(this.getMaxPrecision(E,N)),R=((K*E+K*F*N)/K).toFixed(V);return this.toNumber(R)}},{key:"downStep",value:function(E,N){var F=this.props.step,K=this.getPrecisionFactor(E,N),V=Math.abs(this.getMaxPrecision(E,N)),R=((K*E-K*F*N)/K).toFixed(V);return this.toNumber(R)}},{key:"step",value:function(E,N){var F=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,V=arguments.length>3?arguments[3]:void 0;this.stop(),N&&(N.persist(),N.preventDefault());var R=this.props;if(R.disabled)return;var M=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(M))return;var $=this["".concat(E,"Step")](M,K),ee=$>R.max||$<R.min;if($>R.max?$=R.max:$<R.min&&($=R.min),this.setValue($,null),this.setState({focused:!0},function(){F.pressingUpOrDown=!1}),ee)return;this.autoStepTimer=setTimeout(function(){F[E](N,K,!0)},V?d:C)}},{key:"fixCaret",value:function(E,N){if(E===void 0||N===void 0||!this.input||!this.input.value)return;try{var F=this.input.selectionStart,K=this.input.selectionEnd;(E!==F||N!==K)&&this.input.setSelectionRange(E,N)}catch(V){}}},{key:"render",value:function(){var E,N=this.props,F=N.prefixCls,K=N.disabled,V=N.readOnly,R=N.useTouch,M=N.autoComplete,$=N.upHandler,ee=N.downHandler,ae=N.className,fe=N.max,De=N.min,Se=N.style,Ce=N.title,we=N.onMouseEnter,Te=N.onMouseLeave,me=N.onMouseOver,he=N.onMouseOut,te=N.required,de=N.onClick,ne=N.tabIndex,Le=N.type,Re=N.placeholder,xe=N.id,Oe=N.inputMode,Me=N.pattern,He=N.step,We=N.maxLength,Fe=N.autoFocus,Be=N.name,tt=N.onPaste,qe=N.onInput,Ze=Object(le.a)(N,["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"]),$e=this.state,ct=$e.value,rt=$e.focused,it=y()(F,(E={},Object(Q.a)(E,ae,!!ae),Object(Q.a)(E,"".concat(F,"-disabled"),K),Object(Q.a)(E,"".concat(F,"-focused"),rt),E)),Pe={};Object.keys(Ze).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(Pe[ue]=Ze[ue])});var st=!V&&!K,nt=this.getInputDisplayValue(null),Ie=(ct||ct===0)&&(isNaN(ct)||Number(ct)>=fe),ze=(ct||ct===0)&&(isNaN(ct)||Number(ct)<=De),be=Ie||K||V,pe=ze||K||V,ve=y()("".concat(F,"-handler"),"".concat(F,"-handler-up"),Object(Q.a)({},"".concat(F,"-handler-up-disabled"),be)),re=y()("".concat(F,"-handler"),"".concat(F,"-handler-down"),Object(Q.a)({},"".concat(F,"-handler-down-disabled"),pe)),ie=R?{onTouchStart:be?h:this.up,onTouchEnd:this.stop}:{onMouseDown:be?h:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},oe=R?{onTouchStart:pe?h:this.down,onTouchEnd:this.stop}:{onMouseDown:pe?h:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return I.a.createElement("div",{className:it,style:Se,title:Ce,onMouseEnter:we,onMouseLeave:Te,onMouseOver:me,onMouseOut:he,onFocus:function(){return null},onBlur:function(){return null}},I.a.createElement("div",{className:"".concat(F,"-handler-wrap")},I.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Increase Value","aria-disabled":be,className:ve}),$||I.a.createElement("span",{unselectable:"on",className:"".concat(F,"-handler-up-inner"),onClick:o})),I.a.createElement("span",Object.assign({unselectable:"on"},oe,{role:"button","aria-label":"Decrease Value","aria-disabled":pe,className:re}),ee||I.a.createElement("span",{unselectable:"on",className:"".concat(F,"-handler-down-inner"),onClick:o}))),I.a.createElement("div",{className:"".concat(F,"-input-wrap")},I.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":fe,"aria-valuenow":ct,required:te,type:Le,placeholder:Re,onPaste:tt,onClick:de,onMouseUp:this.onMouseUp,className:"".concat(F,"-input"),tabIndex:ne,autoComplete:M,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:st?this.onKeyDown:h,onKeyUp:st?this.onKeyUp:h,autoFocus:Fe,maxLength:We,readOnly:V,disabled:K,max:fe,min:De,step:He,name:Be,title:Ce,id:xe,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(nt),pattern:Me,inputMode:Oe,onInput:qe},Pe))))}}]),x}(I.a.Component);b.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:f,min:-f,step:1,style:{},onChange:h,onKeyDown:h,onPressEnter:h,onFocus:h,onBlur:h,parser:l,required:!1,autoComplete:"off"};var g=b,c=at.a=g},h78n:function(xt,at,se){"use strict";se.d(at,"a",function(){return E});var le=se("q1tI"),Q=se.n(le),_=se("TSYQ"),Z=se.n(_),B={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1},P=function(K){var V=K.map(function(){return Object(le.useRef)()}),R=Object(le.useRef)();return Object(le.useEffect)(function(){var M=Date.now(),$=!1;Object.keys(V).forEach(function(ee){var ae=V[ee].current;if(!ae)return;$=!0;var fe=ae.style;fe.transitionDuration=".3s, .3s, .3s, .06s",R.current&&M-R.current<100&&(fe.transitionDuration="0s, 0s")}),$&&(R.current=Date.now())}),[V]};function z(){return z=Object.assign||function(F){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var R in V)Object.prototype.hasOwnProperty.call(V,R)&&(F[R]=V[R])}return F},z.apply(this,arguments)}function W(F,K){return O(F)||w(F,K)||D(F,K)||I()}function I(){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 D(F,K){if(!F)return;if(typeof F=="string")return y(F,K);var V=Object.prototype.toString.call(F).slice(8,-1);if(V==="Object"&&F.constructor&&(V=F.constructor.name),V==="Map"||V==="Set")return Array.from(F);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return y(F,K)}function y(F,K){(K==null||K>F.length)&&(K=F.length);for(var V=0,R=new Array(K);V<K;V++)R[V]=F[V];return R}function w(F,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(F)))return;var V=[],R=!0,M=!1,$=void 0;try{for(var ee=F[Symbol.iterator](),ae;!(R=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);R=!0);}catch(fe){M=!0,$=fe}finally{try{!R&&ee.return!=null&&ee.return()}finally{if(M)throw $}}return V}function O(F){if(Array.isArray(F))return F}function k(F,K){if(F==null)return{};var V=A(F,K),R,M;if(Object.getOwnPropertySymbols){var $=Object.getOwnPropertySymbols(F);for(M=0;M<$.length;M++){if(R=$[M],K.indexOf(R)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(F,R))continue;V[R]=F[R]}}return V}function A(F,K){if(F==null)return{};var V={},R=Object.keys(F),M,$;for($=0;$<R.length;$++){if(M=R[$],K.indexOf(M)>=0)continue;V[M]=F[M]}return V}var T=function(K){var V=K.className,R=K.percent,M=K.prefixCls,$=K.strokeColor,ee=K.strokeLinecap,ae=K.strokeWidth,fe=K.style,De=K.trailColor,Se=K.trailWidth,Ce=K.transition,we=k(K,["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"]);delete we.gapPosition;var Te=Array.isArray(R)?R:[R],me=Array.isArray($)?$:[$],he=P(Te),te=W(he,1),de=te[0],ne=ae/2,Le=100-ae/2,Re="M ".concat(ee==="round"?ne:0,",").concat(ne,`
L `).concat(ee==="round"?Le:100,",").concat(ne),xe="0 0 100 ".concat(ae),Oe=0;return Q.a.createElement("svg",z({className:Z()("".concat(M,"-line"),V),viewBox:xe,preserveAspectRatio:"none",style:fe},we),Q.a.createElement("path",{className:"".concat(M,"-line-trail"),d:Re,strokeLinecap:ee,stroke:De,strokeWidth:Se||ae,fillOpacity:"0"}),Te.map(function(Me,He){var We={strokeDasharray:"".concat(Me,"px, 100px"),strokeDashoffset:"-".concat(Oe,"px"),transition:Ce||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},Fe=me[He]||me[me.length-1];return Oe+=Me,Q.a.createElement("path",{key:He,className:"".concat(M,"-line-path"),d:Re,strokeLinecap:ee,stroke:Fe,strokeWidth:ae,fillOpacity:"0",ref:de[He],style:We})}))};T.defaultProps=B;var h=T;function o(){return o=Object.assign||function(F){for(var K=1;K<arguments.length;K++){var V=arguments[K];for(var R in V)Object.prototype.hasOwnProperty.call(V,R)&&(F[R]=V[R])}return F},o.apply(this,arguments)}function l(F,K){return L(F)||p(F,K)||C(F,K)||d()}function d(){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 C(F,K){if(!F)return;if(typeof F=="string")return f(F,K);var V=Object.prototype.toString.call(F).slice(8,-1);if(V==="Object"&&F.constructor&&(V=F.constructor.name),V==="Map"||V==="Set")return Array.from(F);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return f(F,K)}function f(F,K){(K==null||K>F.length)&&(K=F.length);for(var V=0,R=new Array(K);V<K;V++)R[V]=F[V];return R}function p(F,K){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(F)))return;var V=[],R=!0,M=!1,$=void 0;try{for(var ee=F[Symbol.iterator](),ae;!(R=(ae=ee.next()).done)&&!(V.push(ae.value),K&&V.length===K);R=!0);}catch(fe){M=!0,$=fe}finally{try{!R&&ee.return!=null&&ee.return()}finally{if(M)throw $}}return V}function L(F){if(Array.isArray(F))return F}function b(F,K){if(F==null)return{};var V=g(F,K),R,M;if(Object.getOwnPropertySymbols){var $=Object.getOwnPropertySymbols(F);for(M=0;M<$.length;M++){if(R=$[M],K.indexOf(R)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(F,R))continue;V[R]=F[R]}}return V}function g(F,K){if(F==null)return{};var V={},R=Object.keys(F),M,$;for($=0;$<R.length;$++){if(M=R[$],K.indexOf(M)>=0)continue;V[M]=F[M]}return V}var c=0;function u(F){return+F.replace("%","")}function a(F){return Array.isArray(F)?F:[F]}function x(F,K,V,R){var M=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,$=arguments.length>5?arguments[5]:void 0,ee=50-R/2,ae=0,fe=-ee,De=0,Se=-2*ee;switch($){case"left":ae=-ee,fe=0,De=2*ee,Se=0;break;case"right":ae=ee,fe=0,De=-2*ee,Se=0;break;case"bottom":fe=ee,Se=2*ee;break;default:}var Ce="M 50,50 m ".concat(ae,",").concat(fe,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(De,",").concat(-Se,`
a `).concat(ee,",").concat(ee," 0 1 1 ").concat(-De,",").concat(Se),we=Math.PI*2*ee,Te={stroke:V,strokeDasharray:"".concat(K/100*(we-M),"px ").concat(we,"px"),strokeDashoffset:"-".concat(M/2+F/100*(we-M),"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 v=function(K){var V=K.prefixCls,R=K.strokeWidth,M=K.trailWidth,$=K.gapDegree,ee=K.gapPosition,ae=K.trailColor,fe=K.strokeLinecap,De=K.style,Se=K.className,Ce=K.strokeColor,we=K.percent,Te=b(K,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"]),me=Object(le.useMemo)(function(){return c+=1,c},[]),he=x(0,100,ae,R,$,ee),te=he.pathString,de=he.pathStyle,ne=a(we),Le=a(Ce),Re=Le.find(function(We){return Object.prototype.toString.call(We)==="[object Object]"}),xe=P(ne),Oe=l(xe,1),Me=Oe[0],He=function(){var Fe=0;return ne.map(function(Be,tt){var qe=Le[tt]||Le[Le.length-1],Ze=Object.prototype.toString.call(qe)==="[object Object]"?"url(#".concat(V,"-gradient-").concat(me,")"):"",$e=x(Fe,Be,qe,R,$,ee);return Fe+=Be,Q.a.createElement("path",{key:tt,className:"".concat(V,"-circle-path"),d:$e.pathString,stroke:Ze,strokeLinecap:fe,strokeWidth:R,opacity:Be===0?0:1,fillOpacity:"0",style:$e.pathStyle,ref:Me[tt]})})};return Q.a.createElement("svg",o({className:Z()("".concat(V,"-circle"),Se),viewBox:"0 0 100 100",style:De},Te),Re&&Q.a.createElement("defs",null,Q.a.createElement("linearGradient",{id:"".concat(V,"-gradient-").concat(me),x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(Re).sort(function(We,Fe){return u(We)-u(Fe)}).map(function(We,Fe){return Q.a.createElement("stop",{key:Fe,offset:We,stopColor:Re[We]})}))),Q.a.createElement("path",{className:"".concat(V,"-circle-trail"),d:te,stroke:ae,strokeLinecap:fe,strokeWidth:M||R,fillOpacity:"0",style:de}),He().reverse())};v.defaultProps=B;var E=v,N={Line:h,Circle:E}},kSUc:function(xt,at,se){},lZu9:function(xt,at,se){(function(le){le(se("VrN/"),se("1eCo"),se("8EBN"))})(function(le){"use strict";le.defineMode("markdown",function(Q,_){var Z=le.getMode(Q,"text/html"),B=Z.name=="null";function P(R){if(le.findModeByName){var M=le.findModeByName(R);M&&(R=M.mime||M.mimes[0])}var $=le.getMode(Q,R);return $.name=="null"?null:$}_.highlightFormatting===void 0&&(_.highlightFormatting=!1),_.maxBlockquoteDepth===void 0&&(_.maxBlockquoteDepth=0),_.taskLists===void 0&&(_.taskLists=!1),_.strikethrough===void 0&&(_.strikethrough=!1),_.emoji===void 0&&(_.emoji=!1),_.fencedCodeBlockHighlighting===void 0&&(_.fencedCodeBlockHighlighting=!0),_.fencedCodeBlockDefaultMode===void 0&&(_.fencedCodeBlockDefaultMode="text/plain"),_.xml===void 0&&(_.xml=!0),_.tokenTypeOverrides===void 0&&(_.tokenTypeOverrides={});var 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 W in z)z.hasOwnProperty(W)&&_.tokenTypeOverrides[W]&&(z[W]=_.tokenTypeOverrides[W]);var I=/^([*\-_])(?:\s*\1){2,}\s*$/,D=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,y=/^\[(x| )\](?=\s)/i,w=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,O=/^ {0,3}(?:\={1,}|-{2,})\s*$/,k=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,T=/^\s*\[[^\]]+?\]:.*$/,h=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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(R,M,$){return M.f=M.inline=$,$(R,M)}function d(R,M,$){return M.f=M.block=$,$(R,M)}function C(R){return!R||!/\S/.test(R.string)}function f(R){if(R.linkTitle=!1,R.linkHref=!1,R.linkText=!1,R.em=!1,R.strong=!1,R.strikethrough=!1,R.quote=0,R.indentedCode=!1,R.f==L){var M=B;if(!M){var $=le.innerMode(Z,R.htmlState);M=$.mode.name=="xml"&&$.state.tagStart===null&&!$.state.context&&$.state.tokenize.isInText}M&&(R.f=u,R.block=p,R.htmlState=null)}return R.trailingSpace=0,R.trailingSpaceNewLine=!1,R.prevLine=R.thisLine,R.thisLine={stream:null},null}function p(R,M){var $=R.column()===M.indentation,ee=C(M.prevLine.stream),ae=M.indentedCode,fe=M.prevLine.hr,De=M.list!==!1,Se=(M.listStack[M.listStack.length-1]||0)+3;M.indentedCode=!1;var Ce=M.indentation;if(M.indentationDiff===null&&(M.indentationDiff=M.indentation,De)){for(M.list=null;Ce<M.listStack[M.listStack.length-1];)M.listStack.pop(),M.listStack.length?M.indentation=M.listStack[M.listStack.length-1]:M.list=!1;M.list!==!1&&(M.indentationDiff=Ce-M.listStack[M.listStack.length-1])}var we=!ee&&!fe&&!M.prevLine.header&&(!De||!ae)&&!M.prevLine.fencedCodeEnd,Te=(M.list===!1||fe||ee)&&M.indentation<=Se&&R.match(I),me=null;if(M.indentationDiff>=4&&(ae||M.prevLine.fencedCodeEnd||M.prevLine.header||ee))return R.skipToEnd(),M.indentedCode=!0,z.code;if(R.eatSpace())return null;if($&&M.indentation<=Se&&(me=R.match(w))&&me[1].length<=6)return M.quote=0,M.header=me[1].length,M.thisLine.header=!0,_.highlightFormatting&&(M.formatting="header"),M.f=M.inline,g(M);if(M.indentation<=Se&&R.eat(">"))return M.quote=$?1:M.quote+1,_.highlightFormatting&&(M.formatting="quote"),R.eatSpace(),g(M);if(!Te&&!M.setext&&$&&M.indentation<=Se&&(me=R.match(D))){var he=me[1]?"ol":"ul";return M.indentation=Ce+R.current().length,M.list=!0,M.quote=0,M.listStack.push(M.indentation),M.em=!1,M.strong=!1,M.code=!1,M.strikethrough=!1,_.taskLists&&R.match(y,!1)&&(M.taskList=!0),M.f=M.inline,_.highlightFormatting&&(M.formatting=["list","list-"+he]),g(M)}else{if($&&M.indentation<=Se&&(me=R.match(A,!0)))return M.quote=0,M.fencedEndRE=new RegExp(me[1]+"+ *$"),M.localMode=_.fencedCodeBlockHighlighting&&P(me[2]||_.fencedCodeBlockDefaultMode),M.localMode&&(M.localState=le.startState(M.localMode)),M.f=M.block=b,_.highlightFormatting&&(M.formatting="code-block"),M.code=-1,g(M);if(M.setext||(!we||!De)&&!M.quote&&M.list===!1&&!M.code&&!Te&&!T.test(R.string)&&(me=R.lookAhead(1))&&(me=me.match(O)))return M.setext?(M.header=M.setext,M.setext=0,R.skipToEnd(),_.highlightFormatting&&(M.formatting="header")):(M.header=me[0].charAt(0)=="="?1:2,M.setext=M.header),M.thisLine.header=!0,M.f=M.inline,g(M);if(Te)return R.skipToEnd(),M.hr=!0,M.thisLine.hr=!0,z.hr;if(R.peek()==="[")return l(R,M,N)}return l(R,M,M.inline)}function L(R,M){var $=Z.token(R,M.htmlState);if(!B){var ee=le.innerMode(Z,M.htmlState);(ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText||M.md_inside&&R.current().indexOf(">")>-1)&&(M.f=u,M.block=p,M.htmlState=null)}return $}function b(R,M){var $=M.listStack[M.listStack.length-1]||0,ee=M.indentation<$,ae=$+3;if(M.fencedEndRE&&M.indentation<=ae&&(ee||R.match(M.fencedEndRE))){_.highlightFormatting&&(M.formatting="code-block");var fe;return ee||(fe=g(M)),M.localMode=M.localState=null,M.block=p,M.f=u,M.fencedEndRE=null,M.code=0,M.thisLine.fencedCodeEnd=!0,ee?d(R,M,M.block):fe}else return M.localMode?M.localMode.token(R,M.localState):(R.skipToEnd(),z.code)}function g(R){var M=[];if(R.formatting){M.push(z.formatting),typeof R.formatting=="string"&&(R.formatting=[R.formatting]);for(var $=0;$<R.formatting.length;$++)M.push(z.formatting+"-"+R.formatting[$]),R.formatting[$]==="header"&&M.push(z.formatting+"-"+R.formatting[$]+"-"+R.header),R.formatting[$]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=R.quote?M.push(z.formatting+"-"+R.formatting[$]+"-"+R.quote):M.push("error"))}if(R.taskOpen)return M.push("meta"),M.length?M.join(" "):null;if(R.taskClosed)return M.push("property"),M.length?M.join(" "):null;if(R.linkHref?M.push(z.linkHref,"url"):(R.strong&&M.push(z.strong),R.em&&M.push(z.em),R.strikethrough&&M.push(z.strikethrough),R.emoji&&M.push(z.emoji),R.linkText&&M.push(z.linkText),R.code&&M.push(z.code),R.image&&M.push(z.image),R.imageAltText&&M.push(z.imageAltText,"link"),R.imageMarker&&M.push(z.imageMarker)),R.header&&M.push(z.header,z.header+"-"+R.header),R.quote&&(M.push(z.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=R.quote?M.push(z.quote+"-"+R.quote):M.push(z.quote+"-"+_.maxBlockquoteDepth)),R.list!==!1){var ee=(R.listStack.length-1)%3;ee?ee===1?M.push(z.list2):M.push(z.list3):M.push(z.list1)}return R.trailingSpaceNewLine?M.push("trailing-space-new-line"):R.trailingSpace&&M.push("trailing-space-"+(R.trailingSpace%2?"a":"b")),M.length?M.join(" "):null}function c(R,M){return R.match(k,!0)?g(M):void 0}function u(R,M){var $=M.text(R,M);if(typeof $!="undefined")return $;if(M.list)return M.list=null,g(M);if(M.taskList){var ee=R.match(y,!0)[1]===" ";return ee?M.taskOpen=!0:M.taskClosed=!0,_.highlightFormatting&&(M.formatting="task"),M.taskList=!1,g(M)}if(M.taskOpen=!1,M.taskClosed=!1,M.header&&R.match(/^#+$/,!0))return _.highlightFormatting&&(M.formatting="header"),g(M);var ae=R.next();if(M.linkTitle){M.linkTitle=!1;var fe=ae;ae==="("&&(fe=")"),fe=(fe+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+fe+"\\\\]+|\\\\\\\\|\\\\.)"+fe;if(R.match(new RegExp(De),!0))return z.linkHref}if(ae==="`"){var Se=M.formatting;_.highlightFormatting&&(M.formatting="code"),R.eatWhile("`");var Ce=R.current().length;if(M.code==0&&(!M.quote||Ce==1))return M.code=Ce,g(M);if(Ce==M.code){var we=g(M);return M.code=0,we}else return M.formatting=Se,g(M)}else if(M.code)return g(M);if(ae==="\\"&&(R.next(),_.highlightFormatting)){var Te=g(M),me=z.formatting+"-escape";return Te?Te+" "+me:me}if(ae==="!"&&R.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return M.imageMarker=!0,M.image=!0,_.highlightFormatting&&(M.formatting="image"),g(M);if(ae==="["&&M.imageMarker&&R.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return M.imageMarker=!1,M.imageAltText=!0,_.highlightFormatting&&(M.formatting="image"),g(M);if(ae==="]"&&M.imageAltText){_.highlightFormatting&&(M.formatting="image");var Te=g(M);return M.imageAltText=!1,M.image=!1,M.inline=M.f=x,Te}if(ae==="["&&!M.image)return M.linkText&&R.match(/^.*?\]/)||(M.linkText=!0,_.highlightFormatting&&(M.formatting="link")),g(M);if(ae==="]"&&M.linkText){_.highlightFormatting&&(M.formatting="link");var Te=g(M);return M.linkText=!1,M.inline=M.f=R.match(/\(.*?\)| ?\[.*?\]/,!1)?x:u,Te}if(ae==="<"&&R.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){M.f=M.inline=a,_.highlightFormatting&&(M.formatting="link");var Te=g(M);return Te?Te+=" ":Te="",Te+z.linkInline}if(ae==="<"&&R.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){M.f=M.inline=a,_.highlightFormatting&&(M.formatting="link");var Te=g(M);return Te?Te+=" ":Te="",Te+z.linkEmail}if(_.xml&&ae==="<"&&R.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var he=R.string.indexOf(">",R.pos);if(he!=-1){var te=R.string.substring(R.start,he);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(te)&&(M.md_inside=!0)}return R.backUp(1),M.htmlState=le.startState(Z),d(R,M,L)}if(_.xml&&ae==="<"&&R.match(/^\/\w*?>/))return M.md_inside=!1,"tag";if(ae==="*"||ae==="_"){for(var de=1,ne=R.pos==1?" ":R.string.charAt(R.pos-2);de<3&&R.eat(ae);)de++;var Le=R.peek()||" ",Re=!/\s/.test(Le)&&(!h.test(Le)||/\s/.test(ne)||h.test(ne)),xe=!/\s/.test(ne)&&(!h.test(ne)||/\s/.test(Le)||h.test(Le)),Oe=null,Me=null;if(de%2&&(!M.em&&Re&&(ae==="*"||!xe||h.test(ne))?Oe=!0:M.em==ae&&xe&&(ae==="*"||!Re||h.test(Le))&&(Oe=!1)),de>1&&(!M.strong&&Re&&(ae==="*"||!xe||h.test(ne))?Me=!0:M.strong==ae&&xe&&(ae==="*"||!Re||h.test(Le))&&(Me=!1)),Me!=null||Oe!=null){_.highlightFormatting&&(M.formatting=Oe==null?"strong":Me==null?"em":"strong em"),Oe===!0&&(M.em=ae),Me===!0&&(M.strong=ae);var we=g(M);return Oe===!1&&(M.em=!1),Me===!1&&(M.strong=!1),we}}else if(ae===" "&&(R.eat("*")||R.eat("_"))){if(R.peek()===" ")return g(M);R.backUp(1)}if(_.strikethrough){if(ae==="~"&&R.eatWhile(ae)){if(M.strikethrough){_.highlightFormatting&&(M.formatting="strikethrough");var we=g(M);return M.strikethrough=!1,we}else if(R.match(/^[^\s]/,!1))return M.strikethrough=!0,_.highlightFormatting&&(M.formatting="strikethrough"),g(M)}else if(ae===" "&&R.match(/^~~/,!0)){if(R.peek()===" ")return g(M);R.backUp(2)}}if(_.emoji&&ae===":"&&R.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){M.emoji=!0,_.highlightFormatting&&(M.formatting="emoji");var He=g(M);return M.emoji=!1,He}return ae===" "&&(R.match(/^ +$/,!1)?M.trailingSpace++:M.trailingSpace&&(M.trailingSpaceNewLine=!0)),g(M)}function a(R,M){var $=R.next();if($===">"){M.f=M.inline=u,_.highlightFormatting&&(M.formatting="link");var ee=g(M);return ee?ee+=" ":ee="",ee+z.linkInline}return R.match(/^[^>]+/,!0),z.linkInline}function x(R,M){if(R.eatSpace())return null;var $=R.next();return $==="("||$==="["?(M.f=M.inline=E($==="("?")":"]"),_.highlightFormatting&&(M.formatting="link-string"),M.linkHref=!0,g(M)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function E(R){return function(M,$){var ee=M.next();if(ee===R){$.f=$.inline=u,_.highlightFormatting&&($.formatting="link-string");var ae=g($);return $.linkHref=!1,ae}return M.match(v[R]),$.linkHref=!0,g($)}}function N(R,M){return R.match(/^([^\]\\]|\\.)*\]:/,!1)?(M.f=F,R.next(),_.highlightFormatting&&(M.formatting="link"),M.linkText=!0,g(M)):l(R,M,u)}function F(R,M){if(R.match(/^\]:/,!0)){M.f=M.inline=K,_.highlightFormatting&&(M.formatting="link");var $=g(M);return M.linkText=!1,$}return R.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function K(R,M){return R.eatSpace()?null:(R.match(/^[^\s]+/,!0),R.peek()===void 0?M.linkTitle=!0:R.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),M.f=M.inline=u,z.linkHref+" url")}var V={startState:function(){return{f:p,prevLine:{stream:null},thisLine:{stream:null},block:p,htmlState:null,indentation:0,inline:u,text:c,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(R){return{f:R.f,prevLine:R.prevLine,thisLine:R.thisLine,block:R.block,htmlState:R.htmlState&&le.copyState(Z,R.htmlState),indentation:R.indentation,localMode:R.localMode,localState:R.localMode?le.copyState(R.localMode,R.localState):null,inline:R.inline,text:R.text,formatting:!1,linkText:R.linkText,linkTitle:R.linkTitle,linkHref:R.linkHref,code:R.code,em:R.em,strong:R.strong,strikethrough:R.strikethrough,emoji:R.emoji,header:R.header,setext:R.setext,hr:R.hr,taskList:R.taskList,list:R.list,listStack:R.listStack.slice(0),quote:R.quote,indentedCode:R.indentedCode,trailingSpace:R.trailingSpace,trailingSpaceNewLine:R.trailingSpaceNewLine,md_inside:R.md_inside,fencedEndRE:R.fencedEndRE}},token:function(R,M){if(M.formatting=!1,R!=M.thisLine.stream){if(M.header=0,M.hr=!1,R.match(/^\s*$/,!0))return f(M),null;if(M.prevLine=M.thisLine,M.thisLine={stream:R},M.taskList=!1,M.trailingSpace=0,M.trailingSpaceNewLine=!1,!M.localState&&(M.f=M.block,M.f!=L)){var $=R.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(M.indentation=$,M.indentationDiff=null,$>0)return null}}return M.f(R,M)},innerMode:function(R){return R.block==L?{state:R.htmlState,mode:Z}:R.localState?{state:R.localState,mode:R.localMode}:{state:R,mode:V}},indent:function(R,M,$){return R.block==L&&Z.indent?Z.indent(R.htmlState,M,$):R.localState&&R.localMode.indent?R.localMode.indent(R.localState,M,$):le.Pass},blankLine:f,getType:g,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return V},"xml"),le.defineMIME("text/markdown","markdown"),le.defineMIME("text/x-markdown","markdown")})},osHv:function(xt,at,se){(function(le){le(se("VrN/"))})(function(le){"use strict";var Q=le.Pos;function _(h,o){return h.line-o.line||h.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",B=Z+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",P=new RegExp("<(/?)(["+Z+"]["+B+"]*)","g");function z(h,o,l,d){this.line=o,this.ch=l,this.cm=h,this.text=h.getLine(o),this.min=d?Math.max(d.from,h.firstLine()):h.firstLine(),this.max=d?Math.min(d.to-1,h.lastLine()):h.lastLine()}function W(h,o){var l=h.cm.getTokenTypeAt(Q(h.line,o));return l&&/\btag\b/.test(l)}function I(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function D(h){return h.line<=h.min?void 0:(h.text=h.cm.getLine(--h.line),h.ch=h.text.length,!0)}function y(h){for(;;){var o=h.text.indexOf(">",h.ch);if(o==-1){if(I(h))continue;return}if(!W(h,o+1)){h.ch=o+1;continue}var l=h.text.lastIndexOf("/",o),d=l>-1&&!/\S/.test(h.text.slice(l+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function w(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!W(h,o+1)){h.ch=o;continue}P.lastIndex=o,h.ch=o;var l=P.exec(h.text);if(l&&l.index==o)return l}}function O(h){for(;;){P.lastIndex=h.ch;var o=P.exec(h.text);if(!o){if(I(h))continue;return}if(!W(h,o.index+1)){h.ch=o.index+1;continue}return h.ch=o.index+o[0].length,o}}function k(h){for(;;){var o=h.ch?h.text.lastIndexOf(">",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!W(h,o+1)){h.ch=o;continue}var l=h.text.lastIndexOf("/",o),d=l>-1&&!/\S/.test(h.text.slice(l+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function A(h,o){for(var l=[];;){var d=O(h),C,f=h.line,p=h.ch-(d?d[0].length:0);if(!d||!(C=y(h)))return;if(C=="selfClose")continue;if(d[1]){for(var L=l.length-1;L>=0;--L)if(l[L]==d[2]){l.length=L;break}if(L<0&&(!o||o==d[2]))return{tag:d[2],from:Q(f,p),to:Q(h.line,h.ch)}}else l.push(d[2])}}function T(h,o){for(var l=[];;){var d=k(h);if(!d)return;if(d=="selfClose"){w(h);continue}var C=h.line,f=h.ch,p=w(h);if(!p)return;if(p[1])l.push(p[2]);else{for(var L=l.length-1;L>=0;--L)if(l[L]==p[2]){l.length=L;break}if(L<0&&(!o||o==p[2]))return{tag:p[2],from:Q(h.line,h.ch),to:Q(C,f)}}}}le.registerHelper("fold","xml",function(h,o){for(var l=new z(h,o.line,0);;){var d=O(l);if(!d||l.line!=o.line)return;var C=y(l);if(!C)return;if(!d[1]&&C!="selfClose"){var f=Q(l.line,l.ch),p=A(l,d[2]);return p&&_(p.from,f)>0?{from:f,to:p.from}:null}}}),le.findMatchingTag=function(h,o,l){var d=new z(h,o.line,o.ch,l);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var C=y(d),f=C&&Q(d.line,d.ch),p=C&&w(d);if(!C||!p||_(d,o)>0)return;var L={from:Q(d.line,d.ch),to:f,tag:p[2]};return C=="selfClose"?{open:L,close:null,at:"open"}:p[1]?{open:T(d,p[2]),close:L,at:"close"}:(d=new z(h,f.line,f.ch,l),{open:L,close:A(d,p[2]),at:"open"})},le.findEnclosingTag=function(h,o,l,d){for(var C=new z(h,o.line,o.ch,l);;){var f=T(C,d);if(!f)break;var p=new z(h,o.line,o.ch,l),L=A(p,f.tag);if(L)return{open:f,close:L}}},le.scanForClosingTag=function(h,o,l,d){var C=new z(h,o.line,o.ch,d?{from:0,to:d}:null);return A(C,l)}})},p5ED:function(xt,at,se){"use strict";var le=se("+L6B"),Q=se("2/Rp"),_=se("5Dmo"),Z=se("3S7+"),B=se("k1fw"),P=se("9og8"),z=se("tJVT"),W=se("WmNS"),I=se.n(W),D=se("q1tI"),y=se.n(D),w=se("vHTk"),O=se.n(w),k=se("yEEn"),A=se("ZW9T"),T=se("1vsH"),h=se("V0Rq"),o=se("m3rI"),l=function(C){var f=C.name,p=C.data,L=C.theme,b=C.type,g=C.filename,c=C.monacoEditor,u=C.className,a=C.style,x=C.close,v=C.onClose,E=C.hasMask,N=C.otherData,F=N===void 0?{}:N,K=Object(D.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),V=Object(z.a)(K,2),R=V[0],M=V[1],$=Object(D.useState)(""),ee=Object(z.a)($,2),ae=ee[0],fe=ee[1],De=Object(D.useState)(),Se=Object(z.a)(De,2),Ce=Se[0],we=Se[1],Te=window.ENV==="build"?"/react/build/office.html":"/office.html",me,he=1024*1024,te=10*he,de=Object(D.useRef)();b==="office"&&(me=Object(T.R)(p).filesize,me>te&&(b="other")),g&&(c.filename=g),Object(D.useEffect)(function(){var xe,Oe,Me=(xe=document.cookie)===null||xe===void 0||((Oe=xe.replace(/\s/g,""))===null||Oe===void 0)?void 0:Oe.split(";");Me==null||Me.map(function(He){var We=He.split("=");We[0]==="_educoder_session"&&fe(We[1])})},[]),Object(D.useEffect)(function(){b==="office"&&ne()},[b]);var ne=function(){var xe=Object(P.a)(I.a.mark(function Oe(){var Me,He,We;return I.a.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:return console.log("data:",p),Me=p,p.startsWith("http")||(Me=location.origin+Me),He=new URL(Me).pathname.split("/").pop(),Be.next=6,Object(h.U)({attachment_id:He});case 6:We=Be.sent,we(We);case 8:case"end":return Be.stop()}},Oe)}));return function(){return xe.apply(this,arguments)}}(),Le=function(){if(p.startsWith("http")||p.startsWith("/api")||p.startsWith("blob:")){Re();return}Object(T.x)(g||"educoder",p,g||"educoder")},Re=function(){Object(T.v)(g||"educoder",decodeURIComponent(p))};return y.a.createElement("div",{style:Object(B.a)({},a||{}),className:"".concat(E&&O.a.bgBlack," ").concat(b?O.a.wrp:"hide")},x&&y.a.createElement("div",{className:O.a.close,ref:de},y.a.createElement(Z.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return de.current}},y.a.createElement("span",{onClick:Re},y.a.createElement("i",{className:"icon-quxiaozhiding"}))),y.a.createElement(Z.a,{title:"\u5173\u95ED",getPopupContainer:function(){return de.current}},y.a.createElement("span",{className:"",onClick:function(){v(),we(null)}},y.a.createElement("i",{className:"icon-guanbi1"})))),y.a.createElement("div",{className:"".concat(O.a[u]," ").concat(u," ").concat(O.a.monaco," ").concat(b==="txt"?"show":"hide")},b==="txt"&&y.a.createElement(A.b,c)),b==="audio"&&y.a.createElement("audio",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(p),autoPlay:!0}),b==="video"&&y.a.createElement(y.a.Fragment,null,(p==null?void 0:p.indexOf("/api"))>-1?y.a.createElement("video",{controls:!0,src:"".concat(p),autoPlay:!0}):y.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(p),autoPlay:!0})),b==="office"&&Ce&&y.a.createElement("iframe",{src:"".concat(Te,"?key=").concat(Ce.key,"&url=").concat(o.a.API_SERVER+Ce.url,"&callbackUrl=").concat(o.a.API_SERVER+Ce.callbackUrl,"&fileType=").concat(Ce.fileType,"&title=").concat(Ce.title,"&model=view")}),(b==="xlsx"||b==="doc"||b==="pptx"||b==="docx")&&y.a.createElement("iframe",{src:"".concat(Te,"?key=").concat(F.key,"&url=").concat(o.a.API_SERVER+F.url,"&callbackUrl=").concat(o.a.API_SERVER+F.callbackUrl,"&fileType=").concat(F.fileType,"&title=").concat(F.title,"&model=").concat(F.model)}),b==="html"&&y.a.createElement("iframe",{src:p+"&disposition=inline"}),b==="pdf"&&y.a.createElement("embed",{className:O.a.embed,src:p,type:"application/pdf"}),b==="image"&&y.a.createElement("img",{src:"".concat((p==null?void 0:p.indexOf("http://"))>-1||(p==null?void 0:p.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(p)}),b==="other"&&y.a.createElement("div",null,y.a.createElement(Q.a,{type:"primary",size:"large",onClick:Le},y.a.createElement(k.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),b==="download"&&y.a.createElement(Q.a,{type:"primary",size:"large",onClick:Le},y.a.createElement(k.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))};at.a=l},"p77/":function(xt,at,se){},"rAM+":function(xt,at,se){"use strict";se.d(at,"a",function(){return Q});var le=se("Qw5x");function Q(_,Z){var B;if(typeof Symbol=="undefined"||_[Symbol.iterator]==null){if(Array.isArray(_)||(B=Object(le.a)(_))||Z&&_&&typeof _.length=="number"){B&&(_=B);var P=0,z=function(){};return{s:z,n:function(){return P>=_.length?{done:!0}:{done:!1,value:_[P++]}},e:function(w){throw w},f:z}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var W=!0,I=!1,D;return{s:function(){B=_[Symbol.iterator]()},n:function(){var w=B.next();return W=w.done,w},e:function(w){I=!0,D=w},f:function(){try{!W&&B.return!=null&&B.return()}finally{if(I)throw D}}}}},rUJ1:function(xt,at){const se=/[&<>"']/,le=/[&<>"']/g,Q=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},B=b=>Z[b];function P(b,g){if(g){if(se.test(b))return b.replace(le,B)}else if(Q.test(b))return b.replace(_,B);return b}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function W(b){return b.replace(z,(g,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const I=/(^|[^\[])\^/g;function D(b,g){b=b.source||b,g=g||"";const c={replace:(u,a)=>(a=a.source||a,a=a.replace(I,"$1"),b=b.replace(u,a),c),getRegex:()=>new RegExp(b,g)};return c}const y=/[^\w:]/g,w=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function O(b,g,c){if(b){let u;try{u=decodeURIComponent(W(c)).replace(y,"").toLowerCase()}catch(a){return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}g&&!w.test(c)&&(c=o(g,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(u){return null}return c}const k={},A=/^[^:]+:\/*[^/]*$/,T=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(b,g){k[" "+b]||(A.test(b)?k[" "+b]=b+"/":k[" "+b]=f(b,"/",!0)),b=k[" "+b];const c=b.indexOf(":")===-1;return g.substring(0,2)==="//"?c?g:b.replace(T,"$1")+g:g.charAt(0)==="/"?c?g:b.replace(h,"$1")+g:b+g}const l={exec:function(){}};function d(b){let g=1,c,u;for(;g<arguments.length;g++){c=arguments[g];for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(b[u]=c[u])}return b}function C(b,g){const c=b.replace(/\|/g,(x,v,E)=>{let N=!1,F=v;for(;--F>=0&&E[F]==="\\";)N=!N;return N?"|":" |"}),u=c.split(/ \|/);let a=0;if(u.length>g)u.splice(g);else for(;u.length<g;)u.push("");for(;a<u.length;a++)u[a]=u[a].trim().replace(/\\\|/g,"|");return u}function f(b,g,c){const u=b.length;if(u===0)return"";let a=0;for(;a<u;){const x=b.charAt(u-a-1);if(x===g&&!c)a++;else if(x!==g&&c)a++;else break}return b.substr(0,u-a)}function p(b,g){if(b.indexOf(g[1])===-1)return-1;const c=b.length;let u=0,a=0;for(;a<c;a++)if(b[a]==="\\")a++;else if(b[a]===g[0])u++;else if(b[a]===g[1]&&(u--,u<0))return a;return-1}function L(b){b&&b.sanitize&&!b.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")}xt.exports={escape:P,unescape:W,edit:D,cleanUrl:O,resolveUrl:o,noopTest:l,merge:d,splitCells:C,rtrim:f,findClosingBracket:p,checkSanitizeDeprecation:L}},ulZh:function(xt,at,se){typeof window!="undefined"&&function(Q,_){xt.exports=_()}(this,function(){return function(le){var Q={};function _(Z){if(Q[Z])return Q[Z].exports;var B=Q[Z]={i:Z,l:!1,exports:{}};return le[Z].call(B.exports,B,B.exports,_),B.l=!0,B.exports}return _.m=le,_.c=Q,_.d=function(Z,B,P){_.o(Z,B)||Object.defineProperty(Z,B,{enumerable:!0,get:P})},_.r=function(Z){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Z,"__esModule",{value:!0})},_.t=function(Z,B){if(B&1&&(Z=_(Z)),B&8)return Z;if(B&4&&typeof Z=="object"&&Z&&Z.__esModule)return Z;var P=Object.create(null);if(_.r(P),Object.defineProperty(P,"default",{enumerable:!0,value:Z}),B&2&&typeof Z!="string")for(var z in Z)_.d(P,z,function(W){return Z[W]}.bind(null,z));return P},_.n=function(Z){var B=Z&&Z.__esModule?function(){return Z.default}:function(){return Z};return _.d(B,"a",B),B},_.o=function(Z,B){return Object.prototype.hasOwnProperty.call(Z,B)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(le,Q,_){"use strict";var Z=Object.prototype.hasOwnProperty,B="~";function P(){}Object.create&&(P.prototype=Object.create(null),new P().__proto__||(B=!1));function z(y,w,O){this.fn=y,this.context=w,this.once=O||!1}function W(y,w,O,k,A){if(typeof O!="function")throw new TypeError("The listener must be a function");var T=new z(O,k||y,A),h=B?B+w:w;return y._events[h]?y._events[h].fn?y._events[h]=[y._events[h],T]:y._events[h].push(T):(y._events[h]=T,y._eventsCount++),y}function I(y,w){--y._eventsCount===0?y._events=new P:delete y._events[w]}function D(){this._events=new P,this._eventsCount=0}D.prototype.eventNames=function(){var w=[],O,k;if(this._eventsCount===0)return w;for(k in O=this._events)Z.call(O,k)&&w.push(B?k.slice(1):k);return Object.getOwnPropertySymbols?w.concat(Object.getOwnPropertySymbols(O)):w},D.prototype.listeners=function(w){var O=B?B+w:w,k=this._events[O];if(!k)return[];if(k.fn)return[k.fn];for(var A=0,T=k.length,h=new Array(T);A<T;A++)h[A]=k[A].fn;return h},D.prototype.listenerCount=function(w){var O=B?B+w:w,k=this._events[O];return k?k.fn?1:k.length:0},D.prototype.emit=function(w,O,k,A,T,h){var o=B?B+w:w;if(!this._events[o])return!1;var l=this._events[o],d=arguments.length,C,f;if(l.fn){l.once&&this.removeListener(w,l.fn,void 0,!0);switch(d){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,k),!0;case 4:return l.fn.call(l.context,O,k,A),!0;case 5:return l.fn.call(l.context,O,k,A,T),!0;case 6:return l.fn.call(l.context,O,k,A,T,h),!0}for(f=1,C=new Array(d-1);f<d;f++)C[f-1]=arguments[f];l.fn.apply(l.context,C)}else{var p=l.length,L;for(f=0;f<p;f++){l[f].once&&this.removeListener(w,l[f].fn,void 0,!0);switch(d){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,O);break;case 3:l[f].fn.call(l[f].context,O,k);break;case 4:l[f].fn.call(l[f].context,O,k,A);break;default:if(!C)for(L=1,C=new Array(d-1);L<d;L++)C[L-1]=arguments[L];l[f].fn.apply(l[f].context,C)}}}return!0},D.prototype.on=function(w,O,k){return W(this,w,O,k,!1)},D.prototype.once=function(w,O,k){return W(this,w,O,k,!0)},D.prototype.removeListener=function(w,O,k,A){var T=B?B+w:w;if(!this._events[T])return this;if(!O)return I(this,T),this;var h=this._events[T];if(h.fn)h.fn===O&&(!A||h.once)&&(!k||h.context===k)&&I(this,T);else{for(var o=0,l=[],d=h.length;o<d;o++)(h[o].fn!==O||A&&!h[o].once||k&&h[o].context!==k)&&l.push(h[o]);l.length?this._events[T]=l.length===1?l[0]:l:I(this,T)}return this},D.prototype.removeAllListeners=function(w){var O;return w?(O=B?B+w:w,this._events[O]&&I(this,O)):(this._events=new P,this._eventsCount=0),this},D.prototype.off=D.prototype.removeListener,D.prototype.addListener=D.prototype.on,D.prefixed=B,D.EventEmitter=D,le.exports=D},"./node_modules/url-toolkit/src/url-toolkit.js":function(le,Q,_){(function(Z){var B=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,P=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,W=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,I={buildAbsoluteURL:function(D,y,w){if(w=w||{},D=D.trim(),y=y.trim(),!y){if(!w.alwaysNormalize)return D;var O=I.parseURL(D);if(!O)throw new Error("Error trying to parse base URL.");return O.path=I.normalizePath(O.path),I.buildURLFromParts(O)}var k=I.parseURL(y);if(!k)throw new Error("Error trying to parse relative URL.");if(k.scheme)return w.alwaysNormalize?(k.path=I.normalizePath(k.path),I.buildURLFromParts(k)):y;var A=I.parseURL(D);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var T=P.exec(A.path);A.netLoc=T[1],A.path=T[2]}A.netLoc&&!A.path&&(A.path="/");var h={scheme:A.scheme,netLoc:k.netLoc,path:null,params:k.params,query:k.query,fragment:k.fragment};if(!k.netLoc&&(h.netLoc=A.netLoc,k.path[0]!=="/"))if(!k.path)h.path=A.path,k.params||(h.params=A.params,k.query||(h.query=A.query));else{var o=A.path,l=o.substring(0,o.lastIndexOf("/")+1)+k.path;h.path=I.normalizePath(l)}return h.path===null&&(h.path=w.alwaysNormalize?I.normalizePath(k.path):k.path),I.buildURLFromParts(h)},parseURL:function(D){var y=B.exec(D);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(D){for(D=D.split("").reverse().join("").replace(z,"");D.length!==(D=D.replace(W,"")).length;);return D.split("").reverse().join("")},buildURLFromParts:function(D){return D.scheme+D.netLoc+D.path+D.params+D.query+D.fragment}};le.exports=I})(this)},"./node_modules/webworkify-webpack/index.js":function(le,Q,_){function Z(w){var O={};function k(T){if(O[T])return O[T].exports;var h=O[T]={i:T,l:!1,exports:{}};return w[T].call(h.exports,h,h.exports,k),h.l=!0,h.exports}k.m=w,k.c=O,k.i=function(T){return T},k.d=function(T,h,o){k.o(T,h)||Object.defineProperty(T,h,{configurable:!1,enumerable:!0,get:o})},k.r=function(T){Object.defineProperty(T,"__esModule",{value:!0})},k.n=function(T){var h=T&&T.__esModule?function(){return T.default}:function(){return T};return k.d(h,"a",h),h},k.o=function(T,h){return Object.prototype.hasOwnProperty.call(T,h)},k.p="/",k.oe=function(T){throw console.error(T),T};var A=k(k.s=ENTRY_MODULE);return A.default||A}var B="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+B+").*?\\)";function z(w){return(w+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function W(w){return!isNaN(1*w)}function I(w,O,k){var A={};A[k]=[];var T=O.toString(),h=T.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return A;for(var o=h[1],l=new RegExp("(\\\\n|\\W)"+z(o)+P,"g"),d;d=l.exec(T);){if(d[3]==="dll-reference")continue;A[k].push(d[3])}for(l=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+B+'))"\\)\\)'+P,"g");d=l.exec(T);)w[d[2]]||(A[k].push(d[1]),w[d[2]]=_(d[1]).m),A[d[2]]=A[d[2]]||[],A[d[2]].push(d[4]);for(var C=Object.keys(A),f=0;f<C.length;f++)for(var p=0;p<A[C[f]].length;p++)W(A[C[f]][p])&&(A[C[f]][p]=1*A[C[f]][p]);return A}function D(w){var O=Object.keys(w);return O.reduce(function(k,A){return k||w[A].length>0},!1)}function y(w,O){for(var k={main:[O]},A={main:[]},T={main:{}};D(k);)for(var h=Object.keys(k),o=0;o<h.length;o++){var l=h[o],d=k[l],C=d.pop();if(T[l]=T[l]||{},T[l][C]||!w[l][C])continue;T[l][C]=!0,A[l]=A[l]||[],A[l].push(C);for(var f=I(w,w[l][C],l),p=Object.keys(f),L=0;L<p.length;L++)k[p[L]]=k[p[L]]||[],k[p[L]]=k[p[L]].concat(f[p[L]])}return A}le.exports=function(w,O){O=O||{};var k={main:_.m},A=O.all?{main:Object.keys(k.main)}:y(k,w),T="";Object.keys(A).filter(function(C){return C!=="main"}).forEach(function(C){for(var f=0;A[C][f];)f++;A[C].push(f),k[C][f]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",T=T+"var "+C+" = ("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(f))+")({"+A[C].map(function(p){return""+JSON.stringify(p)+": "+k[C][p].toString()}).join(",")+`});
`}),T=T+"new (("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(w))+")({"+A.main.map(function(C){return""+JSON.stringify(C)+": "+k.main[C].toString()}).join(",")+"}))(self);";var h=new window.Blob([T],{type:"text/javascript"});if(O.bare)return h;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,l=o.createObjectURL(h),d=new window.Worker(l);return d.objectURL=l,d}},"./src/config.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"hlsDefaultConfig",function(){return L}),_.d(Q,"mergeConfig",function(){return g}),_.d(Q,"enableStreamingMode",function(){return c});var Z=_("./src/controller/abr-controller.ts"),B=_("./src/controller/audio-stream-controller.ts"),P=_("./src/controller/audio-track-controller.ts"),z=_("./src/controller/subtitle-stream-controller.ts"),W=_("./src/controller/subtitle-track-controller.ts"),I=_("./src/controller/buffer-controller.ts"),D=_("./src/controller/timeline-controller.ts"),y=_("./src/controller/cap-level-controller.ts"),w=_("./src/controller/fps-controller.ts"),O=_("./src/controller/eme-controller.ts"),k=_("./src/controller/cmcd-controller.ts"),A=_("./src/utils/xhr-loader.ts"),T=_("./src/utils/fetch-loader.ts"),h=_("./src/utils/cues.ts"),o=_("./src/utils/mediakeys-helper.ts"),l=_("./src/utils/logger.ts");function d(){return d=Object.assign||function(u){for(var a=1;a<arguments.length;a++){var x=arguments[a];for(var v in x)Object.prototype.hasOwnProperty.call(x,v)&&(u[v]=x[v])}return u},d.apply(this,arguments)}function C(u,a){var x=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);a&&(v=v.filter(function(E){return Object.getOwnPropertyDescriptor(u,E).enumerable})),x.push.apply(x,v)}return x}function f(u){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?C(Object(x),!0).forEach(function(v){p(u,v,x[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(x)):C(Object(x)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(x,v))})}return u}function p(u,a,x){return a in u?Object.defineProperty(u,a,{value:x,enumerable:!0,configurable:!0,writable:!0}):u[a]=x,u}var L=f(f({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:A.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Z.default,bufferController:I.default,capLevelController:y.default,fpsController:w.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},b()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:W.default,timelineController:D.TimelineController,audioStreamController:B.default,audioTrackController:P.default,emeController:O.default,cmcdController:k.default});function b(){return{cueHandler:h.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function g(u,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 d({},u,a)}function c(u){var a=u.loader;if(a!==T.default&&a!==A.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var x=Object(T.fetchSupported)();x&&(u.loader=T.default,u.progressive=!0,u.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/ewma-bandwidth-estimator.ts"),P=_("./src/events.ts"),z=_("./src/utils/buffer-helper.ts"),W=_("./src/errors.ts"),I=_("./src/types/loader.ts"),D=_("./src/utils/logger.ts");function y(k,A){for(var T=0;T<A.length;T++){var h=A[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(k,h.key,h)}}function w(k,A,T){return A&&y(k.prototype,A),T&&y(k,T),k}var O=function(){function k(T){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=T;var h=T.config;this.bwEstimator=new B.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var A=k.prototype;return A.registerListeners=function(){var h=this.hls;h.on(P.Events.FRAG_LOADING,this.onFragLoading,this),h.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(P.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var h=this.hls;h.off(P.Events.FRAG_LOADING,this.onFragLoading,this),h.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(P.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(h,o){var l=o.frag;if(l.type===I.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=l,this.partCurrent=(d=o.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(h,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 h=this.fragCurrent,o=this.partCurrent,l=this.hls,d=l.autoLevelEnabled,C=l.config,f=l.media;if(!h||!f)return;var p=o?o.stats:h.stats,L=o?o.duration:h.duration;if(p.aborted){D.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||f.paused||!f.playbackRate||!f.readyState)return;var b=performance.now()-p.loading.start,g=Math.abs(f.playbackRate);if(b<=500*L/g)return;var c=l.levels,u=l.minAutoLevel,a=c[h.level],x=p.total||Math.max(p.loaded,Math.round(L*a.maxBitrate/8)),v=Math.max(1,p.bwEstimate?p.bwEstimate/8:p.loaded*1e3/b),E=(x-p.loaded)/v,N=f.currentTime,F=(z.BufferHelper.bufferInfo(f,N,C.maxBufferHole).end-N)/g;if(F>=2*L/g||E<=F)return;var K=Number.POSITIVE_INFINITY,V;for(V=h.level-1;V>u;V--){var R=c[V].maxBitrate;if(K=L*R/(8*.8*v),K<F)break}if(K>=E)return;var M=this.bwEstimator.getEstimate();D.logger.warn("Fragment "+h.sn+(o?" part "+o.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+V+`
Current BW estimate: `+(Object(Z.isFiniteNumber)(M)?(M/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: `+F.toFixed(3)+" s"),l.nextLoadLevel=V,this.bwEstimator.sample(b,p.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),l.trigger(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:p})},A.onFragLoaded=function(h,o){var l=o.frag,d=o.part;if(l.type===I.PlaylistLevelType.MAIN&&Object(Z.isFiniteNumber)(l.sn)){var C=d?d.stats:l.stats,f=d?d.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var p=this.hls.levels[l.level],L=(p.loaded?p.loaded.bytes:0)+C.loaded,b=(p.loaded?p.loaded.duration:0)+f;p.loaded={bytes:L,duration:b},p.realBitrate=Math.round(8*L/b)}if(l.bitrateTest){var g={stats:C,frag:l,part:d,id:l.type};this.onFragBuffered(P.Events.FRAG_BUFFERED,g),l.bitrateTest=!1}}},A.onFragBuffered=function(h,o){var l=o.frag,d=o.part,C=d?d.stats:l.stats;if(C.aborted)return;if(l.type!==I.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var f=C.parsing.end-C.loading.start;this.bwEstimator.sample(f,C.loaded),C.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=f/1e3:this.bitrateTestDelay=0},A.onError=function(h,o){switch(o.details){case W.ErrorDetails.FRAG_LOAD_ERROR:case W.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,l=this.hls,d=l.maxAutoLevel,C=l.config,f=l.minAutoLevel,p=l.media,L=o?o.duration:h?h.duration:0,b=p?p.currentTime:0,g=p&&p.playbackRate!==0?Math.abs(p.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():C.abrEwmaDefaultEstimate,u=(z.BufferHelper.bufferInfo(p,b,C.maxBufferHole).end-b)/g,a=this.findBestLevel(c,f,d,u,C.abrBandWidthFactor,C.abrBandWidthUpFactor);if(a>=0)return a;D.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=L?Math.min(L,C.maxStarvationDelay):C.maxStarvationDelay,v=C.abrBandWidthFactor,E=C.abrBandWidthUpFactor;if(!u){var N=this.bitrateTestDelay;if(N){var F=L?Math.min(L,C.maxLoadingDelay):C.maxLoadingDelay;x=F-N,D.logger.trace("bitrate test took "+Math.round(1e3*N)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),v=E=1}}return a=this.findBestLevel(c,f,d,u+x,v,E),Math.max(a,0)},A.findBestLevel=function(h,o,l,d,C,f){for(var p,L=this.fragCurrent,b=this.partCurrent,g=this.lastLoadedFragLevel,c=this.hls.levels,u=c[g],a=!!(u!=null&&(p=u.details)!==null&&p!==void 0&&p.live),x=u==null?void 0:u.codecSet,v=b?b.duration:L?L.duration:0,E=l;E>=o;E--){var N=c[E];if(!N||x&&N.codecSet!==x)continue;var F=N.details,K=(b?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||v,V=void 0;E<=g?V=C*h:V=f*h;var R=c[E].maxBitrate,M=R*K/V;if(D.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+E+"/"+Math.round(V)+"/"+R+"/"+K+"/"+d+"/"+M),V>R&&(!M||a&&!this.bitrateTestDelay||M<d))return E}return-1},w(k,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&(!o||!o.canEstimate()))return h;var l=this.getNextABRAutoLevel();return h!==-1&&(l=Math.min(h,l)),l},set:function(h){this._nextAutoLevel=h}}]),k}();Q.default=O},"./src/controller/audio-stream-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/polyfills/number.ts"),B=_("./src/controller/base-stream-controller.ts"),P=_("./src/events.ts"),z=_("./src/utils/buffer-helper.ts"),W=_("./src/controller/fragment-tracker.ts"),I=_("./src/types/level.ts"),D=_("./src/types/loader.ts"),y=_("./src/loader/fragment.ts"),w=_("./src/demux/chunk-cache.ts"),O=_("./src/demux/transmuxer-interface.ts"),k=_("./src/types/transmuxer.ts"),A=_("./src/controller/fragment-finders.ts"),T=_("./src/utils/discontinuities.ts"),h=_("./src/errors.ts"),o=_("./src/utils/logger.ts");function l(){return l=Object.assign||function(L){for(var b=1;b<arguments.length;b++){var g=arguments[b];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(L[c]=g[c])}return L},l.apply(this,arguments)}function d(L,b){L.prototype=Object.create(b.prototype),L.prototype.constructor=L,C(L,b)}function C(L,b){return C=Object.setPrototypeOf||function(c,u){return c.__proto__=u,c},C(L,b)}var f=100,p=function(L){d(b,L);function b(c,u){var a;return a=L.call(this,c,u,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var g=b.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var u=this.hls;u.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(P.Events.ERROR,this.onError,this),u.on(P.Events.BUFFER_RESET,this.onBufferReset,this),u.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),u.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.on(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var u=this.hls;u.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(P.Events.ERROR,this.onError,this),u.off(P.Events.BUFFER_RESET,this.onBufferReset,this),u.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),u.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.off(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onInitPtsFound=function(u,a){var x=a.frag,v=a.id,E=a.initPTS;if(v==="main"){var N=x.cc;this.initPTS[x.cc]=E,this.log("InitPTS for cc: "+N+" found from main: "+E),this.videoTrackCC=N,this.state===B.State.WAITING_INIT_PTS&&this.tick()}},g.startLoad=function(u){if(!this.levels){this.startPosition=u,this.state=B.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(f),this.fragLoadError=0,a>0&&u===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=B.State.IDLE):(this.loadedmetadata=!1,this.state=B.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()},g.doTick=function(){switch(this.state){case B.State.IDLE:this.doTickIdle();break;case B.State.WAITING_TRACK:{var u,a=this.levels,x=this.trackId,v=a==null||((u=a[x])===null||u===void 0)?void 0:u.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=B.State.WAITING_INIT_PTS}break}case B.State.FRAG_LOADING_WAITING_RETRY:{var E,N=performance.now(),F=this.retryDate;(!F||N>=F||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=B.State.IDLE);break}case B.State.WAITING_INIT_PTS:{var K=this.waitingData;if(K){var V=K.frag,R=K.part,M=K.cache,$=K.complete;if(this.initPTS[V.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=B.State.FRAG_LOADING;var ee=M.flush(),ae={frag:V,part:R,payload:ee,networkDetails:null};this._handleFragmentLoadProgress(ae),$&&L.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 fe=this.getLoadPosition(),De=z.BufferHelper.bufferInfo(this.mediaBuffer,fe,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=B.State.IDLE}}this.onTickEnd()},g.clearWaitingFragment=function(){var u=this.waitingData;u&&(this.fragmentTracker.removeFragment(u.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=B.State.IDLE)},g.onTickEnd=function(){var u=this.media;if(!u||!u.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:u,x=a.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=u.currentTime},g.doTickIdle=function(){var u,a,x=this.hls,v=this.levels,E=this.media,N=this.trackId,F=x.config;if(!v||!v[N])return;if(!E&&(this.startFragRequested||!F.startFragPrefetch))return;var K=v[N],V=K.details;if(!V||V.live&&this.levelLastLoaded!==N||this.waitForCdnTuneIn(V)){this.state=B.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,D.PlaylistLevelType.AUDIO));var R=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,D.PlaylistLevelType.AUDIO);if(R===null)return;var M=R.len,$=this.getMaxBufferLength(),ee=this.audioSwitch;if(M>=$&&!ee)return;if(!ee&&this._streamEnded(R,V)){x.trigger(P.Events.BUFFER_EOS,{type:"audio"}),this.state=B.State.ENDED;return}var ae=V.fragments,fe=ae[0].start,De=R.end;if(ee){var Se=this.getLoadPosition();De=Se,V.PTSKnown&&Se<fe&&((R.end>fe||R.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),E.currentTime=fe+.05))}var Ce=this.getNextFragment(De,V);if(!Ce){this.bufferFlushed=!0;return}((u=Ce.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((a=Ce.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Ce,V):this.loadFragment(Ce,V,De)},g.getMaxBufferLength=function(){var u=L.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,D.PlaylistLevelType.MAIN);return a===null?u:Math.max(u,a.len)},g.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},g.onAudioTracksUpdated=function(u,a){var x=a.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(v){return new I.Level(v)})},g.onAudioTrackSwitching=function(u,a){var x=!!a.url;this.trackId=a.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(f):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=B.State.IDLE):this.state=B.State.STOPPED,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},g.onLevelLoaded=function(u,a){this.mainDetails=a.details},g.onAudioTrackLoaded=function(u,a){var x,v=this.levels,E=a.details,N=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+N);return}this.log("Track "+N+" loaded ["+E.startSN+","+E.endSN+"],duration:"+E.totalduration);var F=v[N],K=0;if(E.live||(x=F.details)!==null&&x!==void 0&&x.live){var V=this.mainDetails;if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed||!V)return;!F.details&&E.hasProgramDateTime&&V.hasProgramDateTime?(Object(T.alignMediaPlaylistByPDT)(E,V),K=E.fragments[0].start):K=this.alignPlaylists(E,F.details)}F.details=E,this.levelLastLoaded=N,!this.startFragRequested&&(this.mainDetails||!E.live)&&this.setStartPosition(F.details,K),this.state===B.State.WAITING_TRACK&&!this.waitForCdnTuneIn(E)&&(this.state=B.State.IDLE),this.tick()},g._handleFragmentLoadProgress=function(u){var a,x=u.frag,v=u.part,E=u.payload,N=this.config,F=this.trackId,K=this.levels;if(!K){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var V=K[F];console.assert(V,"Audio track is defined on fragment load progress");var R=V.details;console.assert(R,"Audio track details are defined on fragment load progress");var M=N.defaultAudioCodec||V.audioCodec||"mp4a.40.2",$=this.transmuxer;$||($=this.transmuxer=new O.default(this.hls,D.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ee=this.initPTS[x.cc],ae=(a=x.initSegment)===null||a===void 0?void 0:a.data;if(ee!==void 0){var fe=!1,De=v?v.index:-1,Se=De!==-1,Ce=new k.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,E.byteLength,De,Se);$.push(E,ae,M,"",x,v,R.totalduration,fe,Ce,ee)}else{o.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+R.startSN+" ,"+R.endSN+"],track "+F);var we=this.waitingData=this.waitingData||{frag:x,part:v,cache:new w.default,complete:!1},Te=we.cache;Te.push(new Uint8Array(E)),this.waitingVideoCC=this.videoTrackCC,this.state=B.State.WAITING_INIT_PTS}},g._handleFragmentLoadComplete=function(u){if(this.waitingData){this.waitingData.complete=!0;return}L.prototype._handleFragmentLoadComplete.call(this,u)},g.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},g.onBufferCreated=function(u,a){var x=a.tracks.audio;x&&(this.mediaBuffer=x.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},g.onFragBuffered=function(u,a){var x=a.frag,v=a.part;if(x.type!==D.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(v?" p: "+v.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,v)},g.onError=function(u,a){switch(a.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.AUDIO,a);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==B.State.ERROR&&this.state!==B.State.STOPPED&&(this.state=a.fatal?B.State.ERROR:B.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===B.State.PARSING||this.state===B.State.PARSED)){var x=!0,v=this.getFwdBufferInfo(this.mediaBuffer,D.PlaylistLevelType.AUDIO);v&&v.len>.5&&(x=!this.reduceMaxBufferLength(v.len)),x&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},g.onBufferFlushed=function(u,a){var x=a.type;x===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},g._handleTransmuxComplete=function(u){var a,x="audio",v=this.hls,E=u.remuxResult,N=u.chunkMeta,F=this.getCurrentContext(N);if(!F){this.warn("The loading context changed while buffering fragment "+N.sn+" of level "+N.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(N.level);return}var K=F.frag,V=F.part,R=E.audio,M=E.text,$=E.id3,ee=E.initSegment;if(this.fragContextChanged(K))return;if(this.state=B.State.PARSING,this.audioSwitch&&R&&this.completeAudioSwitch(),ee!=null&&ee.tracks&&(this._bufferInitSegment(ee.tracks,K,N),v.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:K,id:x,tracks:ee.tracks})),R){var ae=R.startPTS,fe=R.endPTS,De=R.startDTS,Se=R.endDTS;V&&(V.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:ae,endPTS:fe,startDTS:De,endDTS:Se}),K.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,ae,fe,De,Se),this.bufferFragmentData(R,K,V,N)}if($!=null&&(a=$.samples)!==null&&a!==void 0&&a.length){var Ce=l({frag:K,id:x},$);v.trigger(P.Events.FRAG_PARSING_METADATA,Ce)}if(M){var we=l({frag:K,id:x},M);v.trigger(P.Events.FRAG_PARSING_USERDATA,we)}},g._bufferInitSegment=function(u,a,x){if(this.state!==B.State.PARSING)return;u.video&&delete u.video;var v=u.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,u);var E=v.initSegment;if(E!=null&&E.byteLength){var N={type:"audio",frag:a,part:null,chunkMeta:x,parent:a.type,data:E};this.hls.trigger(P.Events.BUFFER_APPENDING,N)}this.tick()},g.loadFragment=function(u,a,x){var v=this.fragmentTracker.getState(u);this.fragCurrent=u,(this.audioSwitch||v===W.FragmentState.NOT_LOADED||v===W.FragmentState.PARTIAL)&&(u.sn==="initSegment"?this._loadInitSegment(u):a.live&&!Object(Z.isFiniteNumber)(this.initPTS[u.cc])?(this.log("Waiting for video PTS in continuity counter "+u.cc+" of live stream before loading audio fragment "+u.sn+" of level "+this.trackId),this.state=B.State.WAITING_INIT_PTS):(this.startFragRequested=!0,L.prototype.loadFragment.call(this,u,a,x)))},g.completeAudioSwitch=function(){var u=this.hls,a=this.media,x=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,u.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:x})},b}(B.default);Q.default=p},"./src/controller/audio-track-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts"),B=_("./src/errors.ts"),P=_("./src/controller/base-playlist-controller.ts"),z=_("./src/types/loader.ts");function W(O,k){for(var A=0;A<k.length;A++){var T=k[A];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function I(O,k,A){return k&&W(O.prototype,k),A&&W(O,A),O}function D(O,k){O.prototype=Object.create(k.prototype),O.prototype.constructor=O,y(O,k)}function y(O,k){return y=Object.setPrototypeOf||function(T,h){return T.__proto__=h,T},y(O,k)}var w=function(O){D(k,O);function k(T){var h;return h=O.call(this,T,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var A=k.prototype;return A.registerListeners=function(){var h=this.hls;h.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(Z.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var h=this.hls;h.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.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(h,o){this.tracks=o.audioTracks||[]},A.onAudioTrackLoaded=function(h,o){var l=o.id,d=o.details,C=this.tracksInGroup[l];if(!C){this.warn("Invalid audio track id "+l);return}var f=C.details;C.details=o.details,this.log("audioTrack "+l+" loaded ["+d.startSN+"-"+d.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,o,f))},A.onLevelLoading=function(h,o){this.switchLevel(o.level)},A.onLevelSwitching=function(h,o){this.switchLevel(o.level)},A.switchLevel=function(h){var o=this.hls.levels[h];if(!(o!=null&&o.audioGroupIds))return;var l=o.audioGroupIds[o.urlId];if(this.groupId!==l){this.groupId=l;var d=this.tracks.filter(function(f){return!l||f.groupId===l});this.selectDefaultTrack&&!d.some(function(f){return f.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var C={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(Z.Events.AUDIO_TRACKS_UPDATED,C),this.selectInitialTrack()}},A.onError=function(h,o){if(O.prototype.onError.call(this,h,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(h){var o=this.tracksInGroup;if(h<0||h>=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 "+h);var d=o[h],C=d.id,f=d.groupId,p=f===void 0?"":f,L=d.name,b=d.type,g=d.url;if(this.trackId=h,this.trackName=L,this.selectDefaultTrack=!1,this.hls.trigger(Z.Events.AUDIO_TRACK_SWITCHING,{id:C,groupId:p,name:L,type:b,url:g}),d.details&&!d.details.live)return;var c=this.switchParams(d.url,l==null?void 0:l.details);this.loadPlaylist(c)},A.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.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:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(h){for(var o=this.tracksInGroup,l=0;l<o.length;l++){var d=o[l];if((!this.selectDefaultTrack||d.default)&&(!h||h===d.name))return d.id}return-1},A.loadPlaylist=function(h){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var l=o.id,d=o.groupId,C=o.url;if(h)try{C=h.addDirectives(C)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(Z.Events.AUDIO_TRACK_LOADING,{url:C,id:l,groupId:d,deliveryDirectives:h||null})}},I(k,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),k}(P.default);Q.default=w},"./src/controller/base-playlist-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return I});var Z=_("./src/polyfills/number.ts"),B=_("./src/types/level.ts"),P=_("./src/controller/level-helper.ts"),z=_("./src/utils/logger.ts"),W=_("./src/errors.ts"),I=function(){function D(w,O){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=z.logger.log.bind(z.logger,O+":"),this.warn=z.logger.warn.bind(z.logger,O+":"),this.hls=w}var y=D.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(O,k){k.fatal&&k.type===W.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(O,k){var A=k==null?void 0:k.renditionReports;if(A)for(var T=0;T<A.length;T++){var h=A[T],o=""+h.URI;if(o===O.substr(-o.length)){var l=parseInt(h["LAST-MSN"]),d=parseInt(h["LAST-PART"]);if(k&&this.hls.config.lowLatencyMode){var C=Math.min(k.age-k.partTarget,k.targetduration);d!==void 0&&C>k.partTarget&&(d+=1)}if(Object(Z.isFiniteNumber)(l))return new B.HlsUrlParameters(l,Object(Z.isFiniteNumber)(d)?d:void 0,B.HlsSkip.No)}}},y.loadPlaylist=function(O){},y.shouldLoadTrack=function(O){return this.canLoad&&O&&!!O.url&&(!O.details||O.details.live)},y.playlistLoaded=function(O,k,A){var T=this,h=k.details,o=k.stats,l=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-l,h.live||A!=null&&A.live){if(h.reloaded(A),A&&this.log("live playlist "+O+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),A&&h.fragments.length>0&&Object(P.mergeDetails)(A,h),!this.canLoad||!h.live)return;var d,C=void 0,f=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var p=this.hls.config.lowLatencyMode,L=h.lastPartSn,b=h.endSN,g=h.lastPartIndex,c=g!==-1,u=L===b,a=p?0:g;c?(C=u?b+1:L,f=u?a:g+1):C=b+1;var x=h.age,v=x+h.ageHeader,E=Math.min(v-h.partTarget,h.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: "+h.age),E=0;else{var N=Math.floor(E/h.targetduration);if(C+=N,f!==void 0){var F=Math.round(E%h.targetduration/h.partTarget);f+=F}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+E+" skip sn "+N+" to part "+f)}h.tuneInGoal=E}if(d=this.getDeliveryDirectives(h,k.deliveryDirectives,C,f),p||!u){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(h,k.deliveryDirectives,C,f);var K=Object(P.computeReloadInterval)(h,o);C!==void 0&&h.canBlockReload&&(K-=h.partTarget||1),this.log("reload live playlist "+O+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return T.loadPlaylist(d)},K)}else this.clearTimer()},y.getDeliveryDirectives=function(O,k,A,T){var h=Object(B.getSkipValue)(O,A);return k!=null&&k.skip&&O.deltaUpdateFailed&&(A=k.msn,T=k.part,h=B.HlsSkip.No),new B.HlsUrlParameters(A,T,h)},y.retryLoadingOrFail=function(O){var k=this,A=this.hls.config,T=this.retryCount<A.levelLoadingMaxRetry;if(T){var h;if(this.retryCount++,O.details.indexOf("LoadTimeOut")>-1&&(h=O.context)!==null&&h!==void 0&&h.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 k.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 T},D}()},"./src/controller/base-stream-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"State",function(){return b}),_.d(Q,"default",function(){return g});var Z=_("./src/polyfills/number.ts"),B=_("./src/task-loop.ts"),P=_("./src/controller/fragment-tracker.ts"),z=_("./src/utils/buffer-helper.ts"),W=_("./src/utils/logger.ts"),I=_("./src/events.ts"),D=_("./src/errors.ts"),y=_("./src/types/transmuxer.ts"),w=_("./src/utils/mp4-tools.ts"),O=_("./src/utils/discontinuities.ts"),k=_("./src/controller/fragment-finders.ts"),A=_("./src/controller/level-helper.ts"),T=_("./src/loader/fragment-loader.ts"),h=_("./src/crypt/decrypter.ts"),o=_("./src/utils/time-ranges.ts"),l=_("./src/types/loader.ts");function d(c,u){for(var a=0;a<u.length;a++){var x=u[a];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(c,x.key,x)}}function C(c,u,a){return u&&d(c.prototype,u),a&&d(c,a),c}function f(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function p(c,u){c.prototype=Object.create(u.prototype),c.prototype.constructor=c,L(c,u)}function L(c,u){return L=Object.setPrototypeOf||function(x,v){return x.__proto__=v,x},L(c,u)}var b={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},g=function(c){p(u,c);function u(x,v,E){var N;return N=c.call(this)||this,N.hls=void 0,N.fragPrevious=null,N.fragCurrent=null,N.fragmentTracker=void 0,N.transmuxer=null,N._state=b.STOPPED,N.media=void 0,N.mediaBuffer=void 0,N.config=void 0,N.bitrateTest=!1,N.lastCurrentTime=0,N.nextLoadPosition=0,N.startPosition=0,N.loadedmetadata=!1,N.fragLoadError=0,N.retryDate=0,N.levels=null,N.fragmentLoader=void 0,N.levelLastLoaded=null,N.startFragRequested=!1,N.decrypter=void 0,N.initPTS=[],N.onvseeking=null,N.onvended=null,N.logPrefix="",N.log=void 0,N.warn=void 0,N.logPrefix=E,N.log=W.logger.log.bind(W.logger,E+":"),N.warn=W.logger.warn.bind(W.logger,E+":"),N.hls=x,N.fragmentLoader=new T.default(x.config),N.fragmentTracker=v,N.config=x.config,N.decrypter=new h.default(x,x.config),x.on(I.Events.KEY_LOADED,N.onKeyLoaded,f(N)),N}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=b.STOPPED},a._streamEnded=function(v,E){var N=this.fragCurrent,F=this.fragmentTracker;if(!E.live&&N&&N.sn===E.endSN&&!v.nextStart){var K=F.getState(N);return K===P.FragmentState.PARTIAL||K===P.FragmentState.OK}return!1},a.onMediaAttached=function(v,E){var N=this.media=this.mediaBuffer=E.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),N.addEventListener("seeking",this.onvseeking),N.addEventListener("ended",this.onvended);var F=this.config;this.levels&&F.autoStartLoad&&this.state===b.STOPPED&&this.startLoad(F.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,E=this.fragCurrent,N=this.media,F=this.mediaBuffer,K=this.state,V=N?N.currentTime:0,R=z.BufferHelper.bufferInfo(F||N,V,v.maxBufferHole);if(this.log("media seeking to "+(Object(Z.isFiniteNumber)(V)?V.toFixed(3):V)+", state: "+K),K===b.ENDED)this.resetLoadingState();else if(E&&!R.len){var M=v.maxFragLookUpTolerance,$=E.start-M,ee=E.start+E.duration+M,ae=V>ee;(V<$||ae)&&(ae&&E.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),E.loader.abort()),this.resetLoadingState())}N&&(this.lastCurrentTime=V),!this.loadedmetadata&&!R.len&&(this.nextLoadPosition=this.startPosition=V),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,E){if(this.state!==b.KEY_LOADING||E.frag!==this.fragCurrent||!this.levels)return;this.state=b.IDLE;var N=this.levels[E.frag.level].details;N&&this.loadFragment(E.frag,N,E.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=b.STOPPED,this.hls.off(I.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,E){this.log("Loading key for "+v.sn+" of ["+E.startSN+"-"+E.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=b.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(I.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,E,N){this._loadFragForPlayback(v,E,N)},a._loadFragForPlayback=function(v,E,N){var F=this,K=function(R){if(F.fragContextChanged(v)){F.warn("Fragment "+v.sn+(R.part?" p: "+R.part.index:"")+" of level "+v.level+" was dropped during download."),F.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,F._handleFragmentLoadProgress(R)};this._doFragLoad(v,E,N,K).then(function(V){if(!V)return;F.fragLoadError=0;var R=F.state;if(F.fragContextChanged(v)){(R===b.FRAG_LOADING||R===b.BACKTRACKING||!F.fragCurrent&&R===b.PARSING)&&(F.fragmentTracker.removeFragment(v),F.state=b.IDLE);return}if("payload"in V&&(F.log("Loaded fragment "+v.sn+" of level "+v.level),F.hls.trigger(I.Events.FRAG_LOADED,V),F.state===b.BACKTRACKING)){F.fragmentTracker.backtrack(v,V),F.resetFragmentLoading(v);return}F._handleFragmentLoadComplete(V)}).catch(function(V){F.warn(V),F.resetFragmentLoading(v)})},a.flushMainBuffer=function(v,E,N){if(N===void 0&&(N=null),!(v-E))return;var F={startOffset:v,endOffset:E,type:N};this.fragLoadError=0,this.hls.trigger(I.Events.BUFFER_FLUSHING,F)},a._loadInitSegment=function(v){var E=this;this._doFragLoad(v).then(function(N){if(!N||E.fragContextChanged(v)||!E.levels)throw new Error("init load aborted");return N}).then(function(N){var F=E.hls,K=N.payload,V=v.decryptdata;if(K&&K.byteLength>0&&V&&V.key&&V.iv&&V.method==="AES-128"){var R=self.performance.now();return E.decrypter.webCryptoDecrypt(new Uint8Array(K),V.key.buffer,V.iv.buffer).then(function(M){var $=self.performance.now();return F.trigger(I.Events.FRAG_DECRYPTED,{frag:v,payload:M,stats:{tstart:R,tdecrypt:$}}),N.payload=M,N})}return N}).then(function(N){var F=E.fragCurrent,K=E.hls,V=E.levels;if(!V)throw new Error("init load aborted, missing levels");var R=V[v.level].details;console.assert(R,"Level details are defined when init segment is loaded");var M=v.stats;E.state=b.IDLE,E.fragLoadError=0,v.data=new Uint8Array(N.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),N.frag===F&&K.trigger(I.Events.FRAG_BUFFERED,{stats:M,frag:F,part:null,id:v.type}),E.tick()}).catch(function(N){E.warn(N),E.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var E=this.fragCurrent;return!v||!E||v.level!==E.level||v.sn!==E.sn||v.urlId!==E.urlId},a.fragBufferedComplete=function(v,E){var N=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(E?" part: "+E.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+o.default.toString(z.BufferHelper.getBuffered(N))),this.state=b.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var E=this.transmuxer;if(!E)return;var N=v.frag,F=v.part,K=v.partsLoaded,V=!K||K.length===0||K.some(function(M){return!M}),R=new y.ChunkMetadata(N.level,N.sn,N.stats.chunkCount+1,0,F?F.index:-1,!V);E.flush(R)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,E,N,F){var K=this;if(N===void 0&&(N=null),!this.levels)throw new Error("frag load aborted, missing levels");if(N=Math.max(v.start,N||0),this.config.lowLatencyMode&&E){var V=E.partList;if(V&&F){N>v.end&&E.fragmentHint&&(v=E.fragmentHint);var R=this.getNextPart(V,v,N);if(R>-1){var M=V[R];return this.log("Loading part sn: "+v.sn+" p: "+M.index+" cc: "+v.cc+" of playlist ["+E.startSN+"-"+E.endSN+"] parts [0-"+R+"-"+(V.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(N.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=b.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:v,part:V[R],targetBufferTime:N}),this.doFragPartsLoad(v,V,R,F).catch(function($){return K.handleFragLoadError($)})}else if(!v.url||this.loadedEndOfParts(V,N))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(E?"of ["+E.startSN+"-"+E.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(N.toFixed(3))),Object(Z.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=b.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:v,targetBufferTime:N}),this.fragmentLoader.load(v,F).catch(function($){return K.handleFragLoadError($)})},a.doFragPartsLoad=function(v,E,N,F){var K=this;return new Promise(function(V,R){var M=[],$=function ee(ae){var fe=E[ae];K.fragmentLoader.loadPart(v,fe,F).then(function(De){M[fe.index]=De;var Se=De.part;K.hls.trigger(I.Events.FRAG_LOADED,De);var Ce=E[ae+1];if(Ce&&Ce.fragment===v)ee(ae+1);else return V({frag:v,part:Se,partsLoaded:M})}).catch(R)};$(N)})},a.handleFragLoadError=function(v){var E=v.data;return E&&E.details===D.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(E.frag,E.part):this.hls.trigger(I.Events.ERROR,E),null},a._handleTransmuxerFlush=function(v){var E=this.getCurrentContext(v);if(!E||this.state!==b.PARSING){this.fragCurrent||(this.state=b.IDLE);return}var N=E.frag,F=E.part,K=E.level,V=self.performance.now();N.stats.parsing.end=V,F&&(F.stats.parsing.end=V),this.updateLevelTiming(N,F,K,v.partial)},a.getCurrentContext=function(v){var E=this.levels,N=v.level,F=v.sn,K=v.part;if(!E||!E[N])return this.warn("Levels object was unset while buffering fragment "+F+" of level "+N+". The current chunk will not be buffered."),null;var V=E[N],R=K>-1?Object(A.getPartWith)(V,F,K):null,M=R?R.fragment:Object(A.getFragmentWithSN)(V,F,this.fragCurrent);return M?{frag:M,part:R,level:V}:null},a.bufferFragmentData=function(v,E,N,F){if(!v||this.state!==b.PARSING)return;var K=v.data1,V=v.data2,R=K;if(K&&V&&(R=Object(w.appendUint8Array)(K,V)),!R||!R.length)return;var M={type:v.type,frag:E,part:N,chunkMeta:F,parent:E.type,data:R};this.hls.trigger(I.Events.BUFFER_APPENDING,M),v.dropped&&v.independent&&!N&&this.flushBufferGap(E)},a.flushBufferGap=function(v){var E=this.media;if(!E)return;if(!z.BufferHelper.isBuffered(E,E.currentTime)){this.flushMainBuffer(0,v.start);return}var N=E.currentTime,F=z.BufferHelper.bufferInfo(E,N,0),K=v.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,K*.25),R=Math.max(Math.min(v.start-V,F.end-V),N+V);v.start-R>V&&this.flushMainBuffer(R,v.start)},a.getFwdBufferInfo=function(v,E){var N=this.config,F=this.getLoadPosition();if(!Object(Z.isFiniteNumber)(F))return null;var K=z.BufferHelper.bufferInfo(v,F,N.maxBufferHole);if(K.len===0&&K.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(F,E);if(V&&K.nextStart<V.end)return z.BufferHelper.bufferInfo(v,F,Math.max(K.nextStart,N.maxBufferHole))}return K},a.getMaxBufferLength=function(v){var E=this.config,N;return v?N=Math.max(8*E.maxBufferSize/v,E.maxBufferLength):N=E.maxBufferLength,Math.min(N,E.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var E=this.config,N=v||E.maxBufferLength;return E.maxMaxBufferLength>=N?(E.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+E.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,E){var N,F,K=E.fragments,V=K.length;if(!V)return null;var R=this.config,M=K[0].start,$;if(E.live){var ee=R.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&&($=this.getInitialLiveFragment(E,K),this.startPosition=$?this.hls.liveSyncPosition||$.start:v)}else v<=M&&($=K[0]);if(!$){var ae=R.lowLatencyMode?E.partEnd:E.fragmentEnd;$=this.getFragmentAtPosition(v,ae,E)}return(N=$)!==null&&N!==void 0&&N.initSegment&&!((F=$)!==null&&F!==void 0&&F.initSegment.data)&&!this.bitrateTest&&($=$.initSegment),$},a.getNextPart=function(v,E,N){for(var F=-1,K=!1,V=!0,R=0,M=v.length;R<M;R++){var $=v[R];if(V=V&&!$.independent,F>-1&&N<$.start)break;var ee=$.loaded;!ee&&(K||$.independent||V)&&$.fragment===E&&(F=R),K=ee}return F},a.loadedEndOfParts=function(v,E){var N=v[v.length-1];return N&&E>N.start&&N.loaded},a.getInitialLiveFragment=function(v,E){var N=this.fragPrevious,F=null;if(N){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+N.programDateTime),F=Object(k.findFragmentByPDT)(E,N.endProgramDateTime,this.config.maxFragLookUpTolerance)),!F){var K=N.sn+1;if(K>=v.startSN&&K<=v.endSN){var V=E[K-v.startSN];N.cc===V.cc&&(F=V,this.log("Live playlist, switching playlist, load frag with next SN: "+F.sn))}F||(F=Object(k.findFragWithCC)(E,N.cc),F&&this.log("Live playlist, switching playlist, load frag with same CC: "+F.sn))}}else{var R=this.hls.liveSyncPosition;R!==null&&(F=this.getFragmentAtPosition(R,this.bitrateTest?v.fragmentEnd:v.edge,v))}return F},a.getFragmentAtPosition=function(v,E,N){var F=this.config,K=this.fragPrevious,V=N.fragments,R=N.endSN,M=N.fragmentHint,$=F.maxFragLookUpTolerance,ee=!!(F.lowLatencyMode&&N.partList&&M);ee&&M&&!this.bitrateTest&&(V=V.concat(M),R=M.sn);var ae;if(v<E){var fe=v>E-$?0:$;ae=Object(k.findFragmentByPTS)(K,V,v,fe)}else ae=V[V.length-1];if(ae){var De=ae.sn-N.startSN,Se=K&&ae.level===K.level,Ce=V[De+1],we=this.fragmentTracker.getState(ae);if(we===P.FragmentState.BACKTRACKED){ae=null;for(var Te=De;V[Te]&&this.fragmentTracker.getState(V[Te])===P.FragmentState.BACKTRACKED;)K?ae=V[Te--]:ae=V[--Te];ae||(ae=Ce)}else K&&ae.sn===K.sn&&!ee&&(Se&&(ae.sn<R&&this.fragmentTracker.getState(Ce)!==P.FragmentState.OK?(this.log("SN "+ae.sn+" just loaded, load next one: "+Ce.sn),ae=Ce):ae=null))}return ae},a.synchronizeToLiveEdge=function(v){var E=this.config,N=this.media;if(!N)return;var F=this.hls.liveSyncPosition,K=N.currentTime,V=v.fragments[0].start,R=v.edge,M=K>=V-E.maxFragLookUpTolerance&&K<=R;if(F!==null&&N.duration>F&&(K<F||!M)){var $=E.liveMaxLatencyDuration!==void 0?E.liveMaxLatencyDuration:E.liveMaxLatencyDurationCount*v.targetduration;(!M&&N.readyState<4||K<R-$)&&(this.loadedmetadata||(this.nextLoadPosition=F),N.readyState&&(this.warn("Playback: "+K.toFixed(3)+" is located too far from the end of live sliding playlist: "+R+", reset currentTime to : "+F.toFixed(3)),N.currentTime=F))}},a.alignPlaylists=function(v,E){var N=this.levels,F=this.levelLastLoaded,K=this.fragPrevious,V=F!==null?N[F]:null,R=v.fragments.length;if(!R)return this.warn("No fragments in live playlist"),0;var M=v.fragments[0].start,$=!E,ee=v.alignedSliding&&Object(Z.isFiniteNumber)(M);if($||!ee&&!M){Object(O.alignStream)(K,V,v);var ae=v.fragments[0].start;return this.log("Live playlist sliding: "+ae.toFixed(2)+" start-sn: "+(E?E.startSN:"na")+"->"+v.startSN+" prev-sn: "+(K?K.sn:"na")+" fragments: "+R),ae}return M},a.waitForCdnTuneIn=function(v){var E=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*E)},a.setStartPosition=function(v,E){var N=this.startPosition;if(N<E&&(N=-1),N===-1||this.lastCurrentTime===-1){var F=v.startTimeOffset;Object(Z.isFiniteNumber)(F)?(N=E+F,F<0&&(N+=v.totalduration),N=Math.min(Math.max(E,N),E+v.totalduration),this.log("Start time offset "+F+" found in playlist, adjust startPosition to "+N),this.startPosition=N):v.live?N=this.hls.liveSyncPosition||E:this.startPosition=N=0,this.lastCurrentTime=N}this.nextLoadPosition=N},a.getLoadPosition=function(){var v=this.media,E=0;return this.loadedmetadata&&v?E=v.currentTime:this.nextLoadPosition&&(E=this.nextLoadPosition),E},a.handleFragLoadAborted=function(v,E){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(E?" part"+E.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=b.IDLE)},a.onFragmentOrKeyLoadError=function(v,E){if(E.fatal)return;var N=E.frag;if(!N||N.type!==v)return;var F=this.fragCurrent;console.assert(F&&N.sn===F.sn&&N.level===F.level&&N.urlId===F.urlId,"Frag load error must match current frag to retry");var K=this.config;if(this.fragLoadError+1<=K.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(N.level))return;var V=Math.min(Math.pow(2,this.fragLoadError)*K.fragLoadingRetryDelay,K.fragLoadingMaxRetryTimeout);this.warn("Fragment "+N.sn+" of "+v+" "+N.level+" failed to load, retrying in "+V+"ms"),this.retryDate=self.performance.now()+V,this.fragLoadError++,this.state=b.FRAG_LOADING_WAITING_RETRY}else E.levelRetry?(v===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=b.IDLE):(W.logger.error(E.details+" reaches max retry, redispatch as fatal ..."),E.fatal=!0,this.hls.stopLoad(),this.state=b.ERROR)},a.afterBufferFlushed=function(v,E,N){if(!v)return;var F=z.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(E,F,N),this.state===b.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=b.IDLE},a.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var E=this.levels?this.levels[v].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(v,E,N,F){var K=this,V=N.details;console.assert(!!V,"level.details must be defined");var R=Object.keys(v.elementaryStreams).reduce(function(M,$){var ee=v.elementaryStreams[$];if(ee){var ae=ee.endPTS-ee.startPTS;if(ae<=0)return K.warn("Could not parse fragment "+v.sn+" "+$+" duration reliably ("+ae+") resetting transmuxer to fallback to playlist timing"),K.resetTransmuxer(),M||!1;var fe=F?0:Object(A.updateFragPTSDTS)(V,v,ee.startPTS,ee.endPTS,ee.startDTS,ee.endDTS);return K.hls.trigger(I.Events.LEVEL_PTS_UPDATED,{details:V,level:N,drift:fe,type:$,frag:v,start:ee.startPTS,end:ee.endPTS}),!0}return M},!1);R?(this.state=b.PARSED,this.hls.trigger(I.Events.FRAG_PARSED,{frag:v,part:E})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C(u,[{key:"state",get:function(){return this._state},set:function(v){var E=this._state;E!==v&&(this._state=v,this.log(E+"->"+v))}}]),u}(B.default)},"./src/controller/buffer-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return k});var Z=_("./src/polyfills/number.ts"),B=_("./src/events.ts"),P=_("./src/utils/logger.ts"),z=_("./src/errors.ts"),W=_("./src/utils/buffer-helper.ts"),I=_("./src/utils/mediasource-helper.ts"),D=_("./src/loader/fragment.ts"),y=_("./src/controller/buffer-operation-queue.ts"),w=Object(I.getMediaSource)(),O=/([ha]vc.)(?:\.[^.,]+)+/,k=function(){function A(h){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,d=o.media,C=o.mediaSource;P.logger.log("[buffer-controller]: Media source opened"),d&&(o.updateMediaElementDuration(),l.trigger(B.Events.MEDIA_ATTACHED,{media:d})),C&&C.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){P.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var T=A.prototype;return T.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},T.destroy=function(){this.unregisterListeners(),this.details=null},T.registerListeners=function(){var o=this.hls;o.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(B.Events.BUFFER_RESET,this.onBufferReset,this),o.on(B.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(B.Events.BUFFER_EOS,this.onBufferEos,this),o.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(B.Events.FRAG_PARSED,this.onFragParsed,this),o.on(B.Events.FRAG_CHANGED,this.onFragChanged,this)},T.unregisterListeners=function(){var o=this.hls;o.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(B.Events.BUFFER_RESET,this.onBufferReset,this),o.off(B.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(B.Events.BUFFER_EOS,this.onBufferEos,this),o.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(B.Events.FRAG_PARSED,this.onFragParsed,this),o.off(B.Events.FRAG_CHANGED,this.onFragChanged,this)},T._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},T.onManifestParsed=function(o,l){var d=2;(l.audio&&!l.video||!l.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,P.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},T.onMediaAttaching=function(o,l){var d=this.media=l.media;if(d&&w){var C=this.mediaSource=new w;C.addEventListener("sourceopen",this._onMediaSourceOpen),C.addEventListener("sourceended",this._onMediaSourceEnded),C.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(C),this._objectUrl=d.src}},T.onMediaDetaching=function(){var o=this.media,l=this.mediaSource,d=this._objectUrl;if(l){if(P.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(C){P.logger.warn("[buffer-controller]: onMediaDetaching: "+C.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(d&&self.URL.revokeObjectURL(d),o.src===d?(o.removeAttribute("src"),o.load()):P.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(B.Events.MEDIA_DETACHED,void 0)},T.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(l){var d=o.sourceBuffer[l];try{d&&(o.removeBufferListeners(l),o.mediaSource&&o.mediaSource.removeSourceBuffer(d),o.sourceBuffer[l]=void 0)}catch(C){P.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",C)}}),this._initSourceBuffer()},T.onBufferCodecs=function(o,l){var d=this,C=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(f){if(C){var p=d.tracks[f];if(p&&typeof p.buffer.changeType=="function"){var L=l[f],b=L.codec,g=L.levelCodec,c=L.container,u=(p.levelCodec||p.codec).replace(O,"$1"),a=(g||b).replace(O,"$1");if(u!==a){var x=c+";codecs="+(g||b);d.appendChangeType(f,x)}}}else d.pendingTracks[f]=l[f]}),C)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},T.appendChangeType=function(o,l){var d=this,C=this.operationQueue,f={execute:function(){var L=d.sourceBuffer[o];L&&(P.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+l),L.changeType(l)),C.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(L){P.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",L)}};C.append(f,o)},T.onBufferAppending=function(o,l){var d=this,C=this.hls,f=this.operationQueue,p=this.tracks,L=l.data,b=l.type,g=l.frag,c=l.part,u=l.chunkMeta,a=u.buffering[b],x=self.performance.now();a.start=x;var v=g.stats.buffering,E=c?c.stats.buffering:null;v.start===0&&(v.start=x),E&&E.start===0&&(E.start=x);var N=p.audio,F=b==="audio"&&u.id===1&&(N==null?void 0:N.container)==="audio/mpeg",K={execute:function(){if(a.executeStart=self.performance.now(),F){var R=d.sourceBuffer[b];if(R){var M=g.start-R.timestampOffset;Math.abs(M)>=.1&&(P.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+M+") sn: "+g.sn+")"),R.timestampOffset=g.start)}}d.appendExecutor(L,b)},onStart:function(){},onComplete:function(){var R=self.performance.now();a.executeEnd=a.end=R,v.first===0&&(v.first=R),E&&E.first===0&&(E.first=R);var M=d.sourceBuffer,$={};for(var ee in M)$[ee]=W.BufferHelper.getBuffered(M[ee]);d.appendError=0,d.hls.trigger(B.Events.BUFFER_APPENDED,{type:b,frag:g,part:c,chunkMeta:u,parent:g.type,timeRanges:$})},onError:function(R){P.logger.error("[buffer-controller]: Error encountered while trying to append to the "+b+" SourceBuffer",R);var M={type:z.ErrorTypes.MEDIA_ERROR,parent:g.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:R,fatal:!1};R.code===DOMException.QUOTA_EXCEEDED_ERR?M.details=z.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,M.details=z.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>C.config.appendErrorMaxRetry&&(P.logger.error("[buffer-controller]: Failed "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),M.fatal=!0)),C.trigger(B.Events.ERROR,M)}};f.append(K,b)},T.onBufferFlushing=function(o,l){var d=this,C=this.operationQueue,f=function(L){return{execute:d.removeExecutor.bind(d,L,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(B.Events.BUFFER_FLUSHED,{type:L})},onError:function(g){P.logger.warn("[buffer-controller]: Failed to remove from "+L+" SourceBuffer",g)}}};l.type?C.append(f(l.type),l.type):this.getSourceBufferTypes().forEach(function(p){C.append(f(p),p)})},T.onFragParsed=function(o,l){var d=this,C=l.frag,f=l.part,p=[],L=f?f.elementaryStreams:C.elementaryStreams;L[D.ElementaryStreamTypes.AUDIOVIDEO]?p.push("audiovideo"):(L[D.ElementaryStreamTypes.AUDIO]&&p.push("audio"),L[D.ElementaryStreamTypes.VIDEO]&&p.push("video"));var b=function(){var c=self.performance.now();C.stats.buffering.end=c,f&&(f.stats.buffering.end=c);var u=f?f.stats:C.stats;d.hls.trigger(B.Events.FRAG_BUFFERED,{frag:C,part:f,stats:u,id:C.type})};p.length===0&&P.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+C.type+" level: "+C.level+" sn: "+C.sn),this.blockBuffers(b,p)},T.onFragChanged=function(o,l){this.flushBackBuffer()},T.onBufferEos=function(o,l){var d=this,C=this.getSourceBufferTypes().reduce(function(f,p){var L=d.sourceBuffer[p];return(!l.type||l.type===p)&&(L&&!L.ended&&(L.ended=!0,P.logger.log("[buffer-controller]: "+p+" sourceBuffer now EOS"))),f&&!!(!L||L.ended)},!0);C&&this.blockBuffers(function(){var f=d.mediaSource;if(!f||f.readyState!=="open")return;f.endOfStream()})},T.onLevelUpdated=function(o,l){var d=l.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},T.flushBackBuffer=function(){var o=this.hls,l=this.details,d=this.media,C=this.sourceBuffer;if(!d||l===null)return;var f=this.getSourceBufferTypes();if(!f.length)return;var p=l.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(Z.isFiniteNumber)(p)||p<0)return;var L=d.currentTime,b=l.levelTargetDuration,g=Math.max(p,b),c=Math.floor(L/b)*b-g;f.forEach(function(u){var a=C[u];if(a){var x=W.BufferHelper.getBuffered(a);x.length>0&&c>x.start(0)&&(o.trigger(B.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),l.live&&o.trigger(B.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u}))}})},T.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,l=this.hls,d=this.media,C=this.mediaSource,f=o.fragments[0].start+o.totalduration,p=d.duration,L=Object(Z.isFiniteNumber)(C.duration)?C.duration:0;o.live&&l.config.liveDurationInfinity?(P.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),C.duration=Infinity,this.updateSeekableRange(o)):(f>L&&f>p||!Object(Z.isFiniteNumber)(p))&&(P.logger.log("[buffer-controller]: Updating Media Source duration to "+f.toFixed(3)),C.duration=f)},T.updateSeekableRange=function(o){var l=this.mediaSource,d=o.fragments,C=d.length;if(C&&o.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var f=Math.max(0,d[0].start),p=Math.max(f,f+o.totalduration);l.setLiveSeekableRange(f,p)}},T.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,l=this.operationQueue,d=this.pendingTracks,C=Object.keys(d).length;if(C&&!o||C===2){this.createSourceBuffers(d),this.pendingTracks={};var f=this.getSourceBufferTypes();if(f.length===0){this.hls.trigger(B.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}f.forEach(function(p){l.executeNext(p)})}},T.createSourceBuffers=function(o){var l=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var C=0;for(var f in o)if(!l[f]){var p=o[f];if(!p)throw Error("source buffer exists for track "+f+", however track does not");var L=p.levelCodec||p.codec,b=p.container+";codecs="+L;P.logger.log("[buffer-controller]: creating sourceBuffer("+b+")");try{var g=l[f]=d.addSourceBuffer(b),c=f;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[f]={buffer:g,codec:L,container:p.container,levelCodec:p.levelCodec,id:p.id},C++}catch(u){P.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(B.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:b})}}C&&this.hls.trigger(B.Events.BUFFER_CREATED,{tracks:this.tracks})},T._onSBUpdateStart=function(o){var l=this.operationQueue,d=l.current(o);d.onStart()},T._onSBUpdateEnd=function(o){var l=this.operationQueue,d=l.current(o);d.onComplete(),l.shiftAndExecuteNext(o)},T._onSBUpdateError=function(o,l){P.logger.error("[buffer-controller]: "+o+" SourceBuffer error",l),this.hls.trigger(B.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(o);d&&d.onError(l)},T.removeExecutor=function(o,l,d){var C=this.media,f=this.mediaSource,p=this.operationQueue,L=this.sourceBuffer,b=L[o];if(!C||!f||!b){P.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(o);return}var g=Object(Z.isFiniteNumber)(C.duration)?C.duration:Infinity,c=Object(Z.isFiniteNumber)(f.duration)?f.duration:Infinity,u=Math.max(0,l),a=Math.min(d,g,c);a>u?(P.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+o+" SourceBuffer"),console.assert(!b.updating,o+" sourceBuffer must not be updating"),b.remove(u,a)):p.shiftAndExecuteNext(o)},T.appendExecutor=function(o,l){var d=this.operationQueue,C=this.sourceBuffer,f=C[l];if(!f){P.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(l);return}f.ended=!1,console.assert(!f.updating,l+" sourceBuffer must not be updating"),f.appendBuffer(o)},T.blockBuffers=function(o,l){var d=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){P.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var C=this.operationQueue,f=l.map(function(p){return C.appendBlocker(p)});Promise.all(f).then(function(){o(),l.forEach(function(p){var L=d.sourceBuffer[p];(!L||!L.updating)&&C.shiftAndExecuteNext(p)})})},T.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},T.addBufferListener=function(o,l,d){var C=this.sourceBuffer[o];if(!C)return;var f=d.bind(this,o);this.listeners[o].push({event:l,listener:f}),C.addEventListener(l,f)},T.removeBufferListeners=function(o){var l=this.sourceBuffer[o];if(!l)return;this.listeners[o].forEach(function(d){l.removeEventListener(d.event,d.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return B});var Z=_("./src/utils/logger.ts"),B=function(){function P(W){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=W}var z=P.prototype;return z.append=function(I,D){var y=this.queues[D];y.push(I),y.length===1&&this.buffers[D]&&this.executeNext(D)},z.insertAbort=function(I,D){var y=this.queues[D];y.unshift(I),this.executeNext(D)},z.appendBlocker=function(I){var D,y=new Promise(function(O){D=O}),w={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(w,I),y},z.executeNext=function(I){var D=this.buffers,y=this.queues,w=D[I],O=y[I];if(O.length){var k=O[0];try{k.execute()}catch(A){Z.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),k.onError(A),(!w||!w.updating)&&(O.shift(),this.executeNext(I))}}},z.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},z.current=function(I){return this.queues[I][0]},P}()},"./src/controller/cap-level-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts");function B(W,I){for(var D=0;D<I.length;D++){var y=I[D];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(W,y.key,y)}}function P(W,I,D){return I&&B(W.prototype,I),D&&B(W,D),W}var z=function(){function W(D){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=D,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var I=W.prototype;return I.setStreamController=function(y){this.streamController=y},I.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},I.registerListeners=function(){var y=this.hls;y.on(Z.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(Z.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.unregisterListener=function(){var y=this.hls;y.off(Z.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(Z.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.onFpsDropLevelCapping=function(y,w){W.isLevelAllowed(w.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(w.droppedLevel)},I.onMediaAttaching=function(y,w){this.media=w.media instanceof HTMLVideoElement?w.media:null},I.onManifestParsed=function(y,w){var O=this.hls;this.restrictedLevels=[],this.firstLevel=w.firstLevel,O.config.capLevelToPlayerSize&&w.video&&this.startCapping()},I.onBufferCodecs=function(y,w){var O=this.hls;O.config.capLevelToPlayerSize&&w.video&&this.startCapping()},I.onMediaDetaching=function(){this.stopCapping()},I.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var w=this.hls;w.autoLevelCapping=this.getMaxLevel(y.length-1),w.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=w.autoLevelCapping}}},I.getMaxLevel=function(y){var w=this,O=this.hls.levels;if(!O.length)return-1;var k=O.filter(function(A,T){return W.isLevelAllowed(T,w.restrictedLevels)&&T<=y});return this.clientRect=null,W.getMaxLevelByMediaSize(k,this.mediaWidth,this.mediaHeight)},I.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()},I.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},I.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,w={width:0,height:0};if(y){var O=y.getBoundingClientRect();w.width=O.width,w.height=O.height,!w.width&&!w.height&&(w.width=O.right-O.left||y.width||0,w.height=O.bottom-O.top||y.height||0)}return this.clientRect=w,w},W.isLevelAllowed=function(y,w){return w===void 0&&(w=[]),w.indexOf(y)===-1},W.getMaxLevelByMediaSize=function(y,w,O){if(!y||!y.length)return-1;for(var k=function(l,d){return d?l.width!==d.width||l.height!==d.height:!0},A=y.length-1,T=0;T<y.length;T+=1){var h=y[T];if((h.width>=w||h.height>=O)&&k(h,y[T+1])){A=T;break}}return A},P(W,[{key:"mediaWidth",get:function(){return this.getDimensions().width*W.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*W.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var y=1;try{y=self.devicePixelRatio}catch(w){}return y}}]),W}();Q.default=z},"./src/controller/cmcd-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return k});var Z=_("./src/events.ts"),B=_("./src/types/cmcd.ts"),P=_("./src/utils/buffer-helper.ts"),z=_("./src/utils/logger.ts");function W(A,T){for(var h=0;h<T.length;h++){var o=T[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(A,o.key,o)}}function I(A,T,h){return T&&W(A.prototype,T),h&&W(A,h),A}function D(A,T){var h=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(h)return(h=h.call(A)).next.bind(h);if(Array.isArray(A)||(h=y(A))||T&&A&&typeof A.length=="number"){h&&(A=h);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 y(A,T){if(!A)return;if(typeof A=="string")return w(A,T);var h=Object.prototype.toString.call(A).slice(8,-1);if(h==="Object"&&A.constructor&&(h=A.constructor.name),h==="Map"||h==="Set")return Array.from(A);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return w(A,T)}function w(A,T){(T==null||T>A.length)&&(T=A.length);for(var h=0,o=new Array(T);h<T;h++)o[h]=A[h];return o}function O(){return O=Object.assign||function(A){for(var T=1;T<arguments.length;T++){var h=arguments[T];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(A[o]=h[o])}return A},O.apply(this,arguments)}var k=function(){function A(h){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(C){try{o.apply(C,{ot:B.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(f){z.logger.warn("Could not generate manifest CMCD data.",f)}},this.applyFragmentData=function(C){try{var f=C.frag,p=o.hls.levels[f.level],L=o.getObjectType(f),b={d:f.duration*1e3,ot:L};(L===B.CMCDObjectType.VIDEO||L===B.CMCDObjectType.AUDIO||L==B.CMCDObjectType.MUXED)&&(b.br=p.bitrate/1e3,b.tb=o.getTopBandwidth(L),b.bl=o.getBufferLength(L)),o.apply(C,b)}catch(g){z.logger.warn("Could not generate segment CMCD data.",g)}},this.hls=h;var l=this.config=h.config,d=l.cmcd;d!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||A.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var T=A.prototype;return T.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)},T.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()},T.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},T.onMediaAttached=function(o,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},T.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},T.onBufferCreated=function(o,l){var d,C;this.audioBuffer=(d=l.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(C=l.tracks.video)===null||C===void 0?void 0:C.buffer},T.createData=function(){var o;return{v:B.CMCDVersion,sf:B.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}},T.apply=function(o,l){l===void 0&&(l={}),O(l,this.createData());var d=l.ot===B.CMCDObjectType.INIT||l.ot===B.CMCDObjectType.VIDEO||l.ot===B.CMCDObjectType.MUXED;if(this.starved&&d&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var C=A.toHeaders(l);if(!Object.keys(C).length)return;o.headers||(o.headers={}),O(o.headers,C)}else{var f=A.toQuery(l);if(!f)return;o.url=A.appendQueryToUri(o.url,f)}},T.getObjectType=function(o){var l=o.type;return l==="subtitle"?B.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?B.CMCDObjectType.INIT:l==="audio"?B.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?B.CMCDObjectType.VIDEO:B.CMCDObjectType.MUXED:void 0},T.getTopBandwidth=function(o){for(var l=0,d=o===B.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,C=D(d),f;!(f=C()).done;){var p=f.value;p.bitrate>l&&(l=p.bitrate)}return l>0?l:NaN},T.getBufferLength=function(o){var l=this.hls.media,d=o===B.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!l)return NaN;var C=P.BufferHelper.bufferInfo(d,l.currentTime,this.config.maxBufferHole);return C.len*1e3},T.createPlaylistLoader=function(){var o=this.config.pLoader,l=this.applyPlaylistData,d=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new d(p)}var f=C.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(L,b,g){l(L),this.loader.load(L,b,g)},I(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},T.createFragmentLoader=function(){var o=this.config.fLoader,l=this.applyFragmentData,d=o||this.config.loader;return function(){function C(p){this.loader=void 0,this.loader=new d(p)}var f=C.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(L,b,g){l(L),this.loader.load(L,b,g)},I(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},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=[],d=function(F){return!Number.isNaN(F)&&F!=null&&F!==""&&F!==!1},C=function(F){return Math.round(F)},f=function(F){return C(F/100)*100},p=function(F){return encodeURIComponent(F)},L={br:C,d:C,bl:f,dl:f,mtp:f,nor:p,rtp:f,tb:C},b=Object.keys(o||{}).sort(),g=D(b),c;!(c=g()).done;){var u=c.value,a=o[u];if(!d(a))continue;if(u==="v"&&a===1)continue;if(u=="pr"&&a===1)continue;var x=L[u];x&&(a=x(a));var v=typeof a,E=void 0;u==="ot"||u==="sf"||u==="st"?E=u+"="+a:v==="boolean"?E=u:v==="number"?E=u+"="+a:E=u+"="+JSON.stringify(a),l.push(E)}return l.join(",")},A.toHeaders=function(o){for(var l=Object.keys(o),d={},C=["Object","Request","Session","Status"],f=[{},{},{},{}],p={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},L=0,b=l;L<b.length;L++){var g=b[L],c=p[g]!=null?p[g]:1;f[c][g]=o[g]}for(var u=0;u<f.length;u++){var a=A.serialize(f[u]);a&&(d["CMCD-"+C[u]]=a)}return d},A.toQuery=function(o){return"CMCD="+encodeURIComponent(A.serialize(o))},A.appendQueryToUri=function(o,l){if(!l)return o;var d=o.includes("?")?"&":"?";return""+o+d+l},A}()},"./src/controller/eme-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts"),B=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),z=_("./src/utils/mediakeys-helper.ts");function W(k,A){for(var T=0;T<A.length;T++){var h=A[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(k,h.key,h)}}function I(k,A,T){return A&&W(k.prototype,A),T&&W(k,T),k}var D=3,y=function(A,T,h){var o={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(l){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:h.audioRobustness||""})}),T.forEach(function(l){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:h.videoRobustness||""})}),[o]},w=function(A,T,h,o){switch(A){case z.KeySystems.WIDEVINE:return y(T,h,o);default:throw new Error("Unknown key-system: "+A)}},O=function(){function k(T){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=T,this._config=T.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=k.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(h){switch(h){case z.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},A._attemptKeySystemAccess=function(h,o,l){var d=this,C=w(h,o,l,this._drmSystemOptions);P.logger.log("Requesting encrypted media key-system access");var f=this.requestMediaKeySystemAccess(h,C);this.mediaKeysPromise=f.then(function(p){return d._onMediaKeySystemAccessObtained(h,p)}),f.catch(function(p){P.logger.error('Failed to obtain key-system "'+h+'" access:',p)})},A._onMediaKeySystemAccessObtained=function(h,o){var l=this;P.logger.log('Access for key-system "'+h+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:h};this._mediaKeysList.push(d);var C=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(f){return d.mediaKeys=f,P.logger.log('Media-keys created for key-system "'+h+'"'),l._onMediaKeysCreated(),f});return C.catch(function(f){P.logger.error("Failed to create media-keys:",f)}),C},A._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),h._onNewMediaKeySession(o.mediaKeysSession))})},A._onNewMediaKeySession=function(h){var o=this;P.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(l){o._onKeySessionMessage(h,l.message)},!1)},A._onKeySessionMessage=function(h,o){P.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(l){P.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),h.update(l)})},A.onMediaEncrypted=function(h){var o=this;if(P.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(C){if(!o._media)return;o._attemptSetMediaKeys(C),o._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(l).catch(l)},A._attemptSetMediaKeys=function(h){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){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}P.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(h,o){var l=this,d=this._mediaKeysList[0];if(!d){P.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){P.logger.warn("Key-Session already initialized but requested again");return}var C=d.mediaKeysSession;if(!C){P.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){P.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}P.logger.log('Generating key-session request for "'+h+'" init data type'),d.mediaKeysSessionInitialized=!0,C.generateRequest(h,o).then(function(){P.logger.debug("Key-session generation succeeded")}).catch(function(f){P.logger.error("Error generating key-session request:",f),l.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(h,o,l){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,h,o,l);var C=this._licenseXhrSetup;if(C)try{C.call(this.hls,d,h),C=void 0}catch(f){P.logger.error(f)}try{d.readyState||d.open("POST",h,!0),C&&C.call(this.hls,d,h)}catch(f){throw new Error("issue setting up KeySystem license XHR "+f)}return d},A._onLicenseRequestReadyStageChange=function(h,o,l,d){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,P.logger.log("License request succeeded");var C=h.response,f=this._licenseResponseCallback;if(f)try{C=f.call(this.hls,h,o)}catch(L){P.logger.error(L)}d(C)}else{if(P.logger.error("License Request XHR failed ("+o+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>D){this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var p=D-this._requestLicenseFailureCount+1;P.logger.warn("Retrying license request, "+p+" attempts left"),this._requestLicense(l,d)}break}},A._generateLicenseRequestChallenge=function(h,o){switch(h.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},A._requestLicense=function(h,o){P.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){P.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(l.mediaKeySystemDomain),C=this._createLicenseXhr(d,h,o);P.logger.log("Sending license request to URL: "+d);var f=this._generateLicenseRequestChallenge(l,h);C.send(f)}catch(p){P.logger.error("Failure requesting DRM license: "+p),this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.KEY_SYSTEM_ERROR,details:B.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(h,o){if(!this._emeEnabled)return;var l=o.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},A.onMediaDetached=function(){var h=this._media,o=this._mediaKeysList;if(!h)return;h.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 h.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var l=o.levels.map(function(C){return C.audioCodec}).filter(function(C){return!!C}),d=o.levels.map(function(C){return C.videoCodec}).filter(function(C){return!!C});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,l,d)},I(k,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),k}();Q.default=O},"./src/controller/fps-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts"),B=_("./src/utils/logger.ts"),P=function(){function z(I){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=I,this.registerListeners()}var W=z.prototype;return W.setStreamController=function(D){this.streamController=D},W.registerListeners=function(){this.hls.on(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},W.unregisterListeners=function(){this.hls.off(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching)},W.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},W.onMediaAttaching=function(D,y){var w=this.hls.config;if(w.capLevelOnFPSDrop){var O=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=O,O&&typeof O.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),w.fpsDroppedMonitoringPeriod)}},W.checkFPS=function(D,y,w){var O=performance.now();if(y){if(this.lastTime){var k=O-this.lastTime,A=w-this.lastDroppedFrames,T=y-this.lastDecodedFrames,h=1e3*A/k,o=this.hls;if(o.trigger(Z.Events.FPS_DROP,{currentDropped:A,currentDecoded:T,totalDroppedFrames:w}),h>0&&A>o.config.fpsDroppedMonitoringThreshold*T){var l=o.currentLevel;B.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=w,this.lastDecodedFrames=y}},W.checkFPSInterval=function(){var D=this.media;if(D)if(this.isVideoPlaybackQualityAvailable){var y=D.getVideoPlaybackQuality();this.checkFPS(D,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(D,D.webkitDecodedFrameCount,D.webkitDroppedFrameCount)},z}();Q.default=P},"./src/controller/fragment-finders.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"findFragmentByPDT",function(){return P}),_.d(Q,"findFragmentByPTS",function(){return z}),_.d(Q,"fragmentWithinToleranceTest",function(){return W}),_.d(Q,"pdtWithinToleranceTest",function(){return I}),_.d(Q,"findFragWithCC",function(){return D});var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/binary-search.ts");function P(y,w,O){if(w===null||!Array.isArray(y)||!y.length||!Object(Z.isFiniteNumber)(w))return null;var k=y[0].programDateTime;if(w<(k||0))return null;var A=y[y.length-1].endProgramDateTime;if(w>=(A||0))return null;O=O||0;for(var T=0;T<y.length;++T){var h=y[T];if(I(w,O,h))return h}return null}function z(y,w,O,k){O===void 0&&(O=0),k===void 0&&(k=0);var A=null;if(y?A=w[y.sn-w[0].sn+1]||null:O===0&&w[0].start===0&&(A=w[0]),A&&W(O,k,A)===0)return A;var T=B.default.search(w,W.bind(null,O,k));return T||A}function W(y,w,O){y===void 0&&(y=0),w===void 0&&(w=0);var k=Math.min(w,O.duration+(O.deltaPTS?O.deltaPTS:0));return O.start+O.duration-k<=y?1:O.start-k>y&&O.start?-1:0}function I(y,w,O){var k=Math.min(w,O.duration+(O.deltaPTS?O.deltaPTS:0))*1e3,A=O.endProgramDateTime||0;return A-k>y}function D(y,w){return B.default.search(y,function(O){return O.cc<w?1:O.cc>w?-1:0})}},"./src/controller/fragment-tracker.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"FragmentState",function(){return P}),_.d(Q,"FragmentTracker",function(){return z});var Z=_("./src/events.ts"),B=_("./src/types/loader.ts"),P;(function(D){D.NOT_LOADED="NOT_LOADED",D.BACKTRACKED="BACKTRACKED",D.APPENDING="APPENDING",D.PARTIAL="PARTIAL",D.OK="OK"})(P||(P={}));var z=function(){function D(w){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=w,this._registerListeners()}var y=D.prototype;return y._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)},y._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)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(O,k){if(k===B.PlaylistLevelType.MAIN){var A=this.activeFragment,T=this.activeParts;if(!A)return null;if(T)for(var h=T.length;h--;){var o=T[h],l=o?o.end:A.appendedPTS;if(o.start<=O&&l!==void 0&&O<=l)return h>9&&(this.activeParts=T.slice(h-9)),o}else if(A.start<=O&&A.appendedPTS!==void 0&&O<=A.appendedPTS)return A}return this.getBufferedFrag(O,k)},y.getBufferedFrag=function(O,k){for(var A=this.fragments,T=Object.keys(A),h=T.length;h--;){var o=A[T[h]];if((o==null?void 0:o.body.type)===k&&o.buffered){var l=o.body;if(l.start<=O&&O<=l.end)return l}}return null},y.detectEvictedFragments=function(O,k,A){var T=this;Object.keys(this.fragments).forEach(function(h){var o=T.fragments[h];if(!o)return;if(!o.buffered){o.body.type===A&&T.removeFragment(o.body);return}var l=o.range[O];if(!l)return;l.time.some(function(d){var C=!T.isTimeBuffered(d.startPTS,d.endPTS,k);return C&&T.removeFragment(o.body),C})})},y.detectPartialFragments=function(O){var k=this,A=this.timeRanges,T=O.frag,h=O.part;if(!A||T.sn==="initSegment")return;var o=I(T),l=this.fragments[o];if(!l)return;Object.keys(A).forEach(function(d){var C=T.elementaryStreams[d];if(!C)return;var f=A[d],p=h!==null||C.partial===!0;l.range[d]=k.getBufferedTimes(T,h,p,f)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},y.fragBuffered=function(O){var k=I(O),A=this.fragments[k];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},y.getBufferedTimes=function(O,k,A,T){for(var h={time:[],partial:A},o=k?k.start:O.start,l=k?k.end:O.end,d=O.minEndPTS||l,C=O.maxStartPTS||o,f=0;f<T.length;f++){var p=T.start(f)-this.bufferPadding,L=T.end(f)+this.bufferPadding;if(C>=p&&d<=L){h.time.push({startPTS:Math.max(o,T.start(f)),endPTS:Math.min(l,T.end(f))});break}else if(o<L&&l>p)h.partial=!0,h.time.push({startPTS:Math.max(o,T.start(f)),endPTS:Math.min(l,T.end(f))});else if(l<=p)break}return h},y.getPartialFragment=function(O){var k=null,A,T,h,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(C){var f=d[C];if(!f)return;W(f)&&(T=f.body.start-l,h=f.body.end+l,O>=T&&O<=h&&(A=Math.min(O-T,h-O),o<=A&&(k=f.body,o=A)))}),k},y.getState=function(O){var k=I(O),A=this.fragments[k];return A?A.buffered?W(A)?P.PARTIAL:P.OK:A.backtrack?P.BACKTRACKED:P.APPENDING:P.NOT_LOADED},y.backtrack=function(O,k){var A=I(O),T=this.fragments[A];if(!T||T.backtrack)return null;var h=T.backtrack=k||T.loaded;return T.loaded=null,h},y.getBacktrackData=function(O){var k=I(O),A=this.fragments[k];if(A){var T,h=A.backtrack;if(h!=null&&(T=h.payload)!==null&&T!==void 0&&T.byteLength)return h;this.removeFragment(O)}return null},y.isTimeBuffered=function(O,k,A){for(var T,h,o=0;o<A.length;o++){if(T=A.start(o)-this.bufferPadding,h=A.end(o)+this.bufferPadding,O>=T&&k<=h)return!0;if(k<=T)return!1}return!1},y.onFragLoaded=function(O,k){var A=k.frag,T=k.part;if(A.sn==="initSegment"||A.bitrateTest||T)return;var h=I(A);this.fragments[h]={body:A,loaded:k,backtrack:null,buffered:!1,range:Object.create(null)}},y.onBufferAppended=function(O,k){var A=this,T=k.frag,h=k.part,o=k.timeRanges;if(T.type===B.PlaylistLevelType.MAIN)if(this.activeFragment=T,h){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(d){var C=o[d];if(A.detectEvictedFragments(d,C),!h)for(var f=0;f<C.length;f++)T.appendedPTS=Math.max(C.end(f),T.appendedPTS||0)})},y.onFragBuffered=function(O,k){this.detectPartialFragments(k)},y.hasFragment=function(O){var k=I(O);return!!this.fragments[k]},y.removeFragmentsInRange=function(O,k,A){var T=this;Object.keys(this.fragments).forEach(function(h){var o=T.fragments[h];if(!o)return;if(o.buffered){var l=o.body;l.type===A&&l.start<k&&l.end>O&&T.removeFragment(l)}})},y.removeFragment=function(O){var k=I(O);O.stats.loaded=0,O.clearElementaryStreamInfo(),delete this.fragments[k]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},D}();function W(D){var y,w;return D.buffered&&(((y=D.range.video)===null||y===void 0?void 0:y.partial)||((w=D.range.audio)===null||w===void 0?void 0:w.partial))}function I(D){return D.type+"_"+D.level+"_"+D.urlId+"_"+D.sn}},"./src/controller/gap-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"STALL_MINIMUM_DURATION_MS",function(){return W}),_.d(Q,"MAX_START_GAP_JUMP",function(){return I}),_.d(Q,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return D}),_.d(Q,"SKIP_BUFFER_RANGE_START",function(){return y}),_.d(Q,"default",function(){return w});var Z=_("./src/utils/buffer-helper.ts"),B=_("./src/errors.ts"),P=_("./src/events.ts"),z=_("./src/utils/logger.ts"),W=250,I=2,D=.1,y=.05,w=function(){function O(A,T,h,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=T,this.fragmentTracker=h,this.hls=o}var k=O.prototype;return k.destroy=function(){this.hls=this.fragmentTracker=this.media=null},k.poll=function(T){var h=this.config,o=this.media,l=this.stalled,d=o.currentTime,C=o.seeking,f=this.seeking&&!C,p=!this.seeking&&C;if(this.seeking=C,d!==T){if(this.moved=!0,l!==null){if(this.stallReported){var L=self.performance.now()-l;z.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((p||f)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!Z.BufferHelper.getBuffered(o).length)return;var b=Z.BufferHelper.bufferInfo(o,d,0),g=b.len>0,c=b.nextStart||0;if(!g&&!c)return;if(C){var u=b.len>I,a=!c||c-d>I&&!this.fragmentTracker.getPartialFragment(d);if(u||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,v=Math.max(c,b.start||0)-d,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=E==null||((x=E.details)===null||x===void 0)?void 0:x.live,F=N?E.details.targetduration*2:I;if(v>0&&v<=F){this._trySkipBufferHole(null);return}}var K=self.performance.now();if(l===null){this.stalled=K;return}var V=K-l;!C&&V>=W&&this._reportStall(b.len);var R=Z.BufferHelper.bufferInfo(o,d,h.maxBufferHole);this._tryFixBufferStall(R,V)},k._tryFixBufferStall=function(T,h){var o=this.config,l=this.fragmentTracker,d=this.media,C=d.currentTime,f=l.getPartialFragment(C);if(f){var p=this._trySkipBufferHole(f);if(p)return}T.len>o.maxBufferHole&&h>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},k._reportStall=function(T){var h=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="+T+")"),h.trigger(P.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:T}))},k._trySkipBufferHole=function(T){for(var h=this.config,o=this.hls,l=this.media,d=l.currentTime,C=0,f=Z.BufferHelper.getBuffered(l),p=0;p<f.length;p++){var L=f.start(p);if(d+h.maxBufferHole>=C&&d<L){var b=Math.max(L+y,l.currentTime+D);return z.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+b),this.moved=!0,this.stalled=null,l.currentTime=b,T&&o.trigger(P.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+b,frag:T}),b}C=f.end(p)}return 0},k._tryNudgeBuffer=function(){var T=this.config,h=this.hls,o=this.media,l=o.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<T.nudgeMaxRetry){var C=l+d*T.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+l+" to "+C),o.currentTime=C,h.trigger(P.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else z.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+T.nudgeMaxRetry+" nudges"),h.trigger(P.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},O}()},"./src/controller/id3-track-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts"),B=_("./src/utils/texttrack-utils.ts"),P=_("./src/demux/id3.ts"),z=.25,W=function(){function I(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var D=I.prototype;return D.destroy=function(){this._unregisterListeners()},D._registerListeners=function(){var w=this.hls;w.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),w.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),w.on(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),w.on(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D._unregisterListeners=function(){var w=this.hls;w.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),w.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),w.off(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),w.off(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D.onMediaAttached=function(w,O){this.media=O.media},D.onMediaDetaching=function(){if(!this.id3Track)return;Object(B.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},D.getID3Track=function(w){if(!this.media)return;for(var O=0;O<w.length;O++){var k=w[O];if(k.kind==="metadata"&&k.label==="id3")return Object(B.sendAddTrackEvent)(k,this.media),k}return this.media.addTextTrack("metadata","id3")},D.onFragParsingMetadata=function(w,O){if(!this.media)return;var k=O.frag,A=O.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var T=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<A.length;h++){var o=P.getID3Frames(A[h].data);if(o){var l=A[h].pts,d=h<A.length-1?A[h+1].pts:k.end,C=d-l;C<=0&&(d=l+z);for(var f=0;f<o.length;f++){var p=o[f];if(!P.isTimeStampFrame(p)){var L=new T(l,d,"");L.value=p,this.id3Track.addCue(L)}}}}},D.onBufferFlushing=function(w,O){var k=O.startOffset,A=O.endOffset,T=O.type;if(!T||T==="audio"){var h=this.id3Track;h&&Object(B.removeCuesInRange)(h,k,A)}},I}();Q.default=W},"./src/controller/latency-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return I});var Z=_("./src/errors.ts"),B=_("./src/events.ts"),P=_("./src/utils/logger.ts");function z(D,y){for(var w=0;w<y.length;w++){var O=y[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(D,O.key,O)}}function W(D,y,w){return y&&z(D.prototype,y),w&&z(D,w),D}var I=function(){function D(w){var O=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return O.timeupdate()},this.hls=w,this.config=w.config,this.registerListeners()}var y=D.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(B.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(B.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(B.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(B.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(B.Events.ERROR,this.onError)},y.onMediaAttached=function(O,k){this.media=k.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(O,k){var A=k.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(O,k){if(k.details!==Z.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,P.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},y.timeupdate=function(){var O=this.media,k=this.levelDetails;if(!O||!k)return;this.currentTime=O.currentTime;var A=this.computeLatency();if(A===null)return;this._latency=A;var T=this.config,h=T.lowLatencyMode,o=T.maxLiveSyncPlaybackRate;if(!h||o===1)return;var l=this.targetLatency;if(l===null)return;var d=A-l,C=Math.min(this.maxLatency,l+k.targetduration),f=d<C;if(k.live&&f&&d>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,o)),L=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;O.playbackRate=Math.min(p,Math.max(1,L))}else O.playbackRate!==1&&O.playbackRate!==0&&(O.playbackRate=1)},y.estimateLiveEdge=function(){var O=this.levelDetails;return O===null?null:O.edge+O.age},y.computeLatency=function(){var O=this.estimateLiveEdge();return O===null?null:O-this.currentTime},W(D,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var O=this.config,k=this.levelDetails;return O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:k?O.liveMaxLatencyDurationCount*k.targetduration:0}},{key:"targetLatency",get:function(){var O=this.levelDetails;if(O===null)return null;var k=O.holdBack,A=O.partHoldBack,T=O.targetduration,h=this.config,o=h.liveSyncDuration,l=h.liveSyncDurationCount,d=h.lowLatencyMode,C=this.hls.userConfig,f=d&&A||k;(C.liveSyncDuration||C.liveSyncDurationCount||f===0)&&(f=o!==void 0?o:l*T);var p=T,L=1;return f+Math.min(this.stallCount*L,p)}},{key:"liveSyncPosition",get:function(){var O=this.estimateLiveEdge(),k=this.targetLatency,A=this.levelDetails;if(O===null||k===null||A===null)return null;var T=A.edge,h=O-k-this.edgeStalled,o=T-A.totalduration,l=T-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,h),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 k=(this.config.lowLatencyMode&&O.partTarget||O.targetduration)*3;return Math.max(O.age-k,0)}},{key:"forwardBufferLength",get:function(){var O=this.media,k=this.levelDetails;if(!O||!k)return 0;var A=O.buffered.length;return A?O.buffered.end(A-1):k.edge-this.currentTime}}]),D}()},"./src/controller/level-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return h});var Z=_("./src/types/level.ts"),B=_("./src/events.ts"),P=_("./src/errors.ts"),z=_("./src/utils/codecs.ts"),W=_("./src/controller/level-helper.ts"),I=_("./src/controller/base-playlist-controller.ts"),D=_("./src/types/loader.ts");function y(){return y=Object.assign||function(o){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var C in d)Object.prototype.hasOwnProperty.call(d,C)&&(o[C]=d[C])}return o},y.apply(this,arguments)}function w(o,l){for(var d=0;d<l.length;d++){var C=l[d];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function O(o,l,d){return l&&w(o.prototype,l),d&&w(o,d),o}function k(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,A(o,l)}function A(o,l){return A=Object.setPrototypeOf||function(C,f){return C.__proto__=f,C},A(o,l)}var T=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){k(l,o);function l(C){var f;return f=o.call(this,C,"[level-controller]")||this,f._levels=[],f._firstLevel=-1,f._startLevel=void 0,f.currentLevelIndex=-1,f.manualLevelIndex=-1,f.onParsedComplete=void 0,f._registerListeners(),f}var d=l.prototype;return d._registerListeners=function(){var f=this.hls;f.on(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(B.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(B.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var f=this.hls;f.off(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(B.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(B.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},d.startLoad=function(){var f=this._levels;f.forEach(function(p){p.loadError=0}),o.prototype.startLoad.call(this)},d.onManifestLoaded=function(f,p){var L=[],b=[],g=[],c,u={},a,x=!1,v=!1,E=!1;if(p.levels.forEach(function(V){var R=V.attrs;x=x||!!(V.width&&V.height),v=v||!!V.videoCodec,E=E||!!V.audioCodec,T&&V.audioCodec&&V.audioCodec.indexOf("mp4a.40.34")!==-1&&(V.audioCodec=void 0);var M=V.bitrate+"-"+V.attrs.RESOLUTION+"-"+V.attrs.CODECS;a=u[M],a?a.url.push(V.url):(a=new Z.Level(V),u[M]=a,L.push(a)),R&&(R.AUDIO&&Object(W.addGroupId)(a,"audio",R.AUDIO),R.SUBTITLES&&Object(W.addGroupId)(a,"text",R.SUBTITLES))}),(x||v)&&E&&(L=L.filter(function(V){var R=V.videoCodec,M=V.width,$=V.height;return!!R||!!(M&&$)})),L=L.filter(function(V){var R=V.audioCodec,M=V.videoCodec;return(!R||Object(z.isCodecSupportedInMp4)(R,"audio"))&&(!M||Object(z.isCodecSupportedInMp4)(M,"video"))}),p.audioTracks&&(b=p.audioTracks.filter(function(V){return!V.audioCodec||Object(z.isCodecSupportedInMp4)(V.audioCodec,"audio")}),Object(W.assignTrackIdsByGroup)(b)),p.subtitles&&(g=p.subtitles,Object(W.assignTrackIdsByGroup)(g)),L.length>0){c=L[0].bitrate,L.sort(function(V,R){return V.bitrate-R.bitrate}),this._levels=L;for(var N=0;N<L.length;N++)if(L[N].bitrate===c){this._firstLevel=N,this.log("manifest loaded, "+L.length+" level(s) found, first bitrate: "+c);break}var F=E&&!v,K={levels:L,audioTracks:b,subtitleTracks:g,firstLevel:this._firstLevel,stats:p.stats,audio:E,video:v,altAudio:!F&&b.some(function(V){return!!V.url})};this.hls.trigger(B.Events.MANIFEST_PARSED,K),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(B.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(f,p){if(o.prototype.onError.call(this,f,p),p.fatal)return;var L=p.context,b=this._levels[this.currentLevelIndex];if(L&&(L.type===D.PlaylistContextType.AUDIO_TRACK&&b.audioGroupIds&&L.groupId===b.audioGroupIds[b.urlId]||L.type===D.PlaylistContextType.SUBTITLE_TRACK&&b.textGroupIds&&L.groupId===b.textGroupIds[b.urlId])){this.redundantFailover(this.currentLevelIndex);return}var g=!1,c=!0,u;switch(p.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var a=this._levels[p.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(u=p.frag.level)):u=p.frag.level}break;case P.ErrorDetails.LEVEL_LOAD_ERROR:case P.ErrorDetails.LEVEL_LOAD_TIMEOUT:L&&(L.deliveryDirectives&&(c=!1),u=L.level),g=!0;break;case P.ErrorDetails.REMUX_ALLOC_ERROR:u=p.level,g=!0;break}u!==void 0&&this.recoverLevel(p,u,g,c)},d.recoverLevel=function(f,p,L,b){var g=f.details,c=this._levels[p];if(c.loadError++,L){var u=this.retryLoadingOrFail(f);if(u)f.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(b){var a=c.url.length;if(a>1&&c.loadError<a)f.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var x=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==x&&this._levels[x].loadError===0&&(this.warn(g+": switch to "+x),f.levelRetry=!0,this.hls.nextAutoLevel=x)}}},d.redundantFailover=function(f){var p=this._levels[f],L=p.url.length;if(L>1){var b=(p.urlId+1)%L;this.warn("Switching to redundant URL-id "+b),this._levels.forEach(function(g){g.urlId=b}),this.level=f}},d.onFragLoaded=function(f,p){var L=p.frag;if(L!==void 0&&L.type===D.PlaylistLevelType.MAIN){var b=this._levels[L.level];b!==void 0&&(b.fragmentError=0,b.loadError=0)}},d.onLevelLoaded=function(f,p){var L,b=p.level,g=p.details,c=this._levels[b];if(!c){var u;this.warn("Invalid level index "+b),(u=p.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(g.deltaUpdateFailed=!0);return}b===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(b,p,c.details)):(L=p.deliveryDirectives)!==null&&L!==void 0&&L.skip&&(g.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(f,p){var L=this.hls.levels[this.currentLevelIndex];if(!L)return;if(L.audioGroupIds){for(var b=-1,g=this.hls.audioTracks[p.id].groupId,c=0;c<L.audioGroupIds.length;c++)if(L.audioGroupIds[c]===g){b=c;break}b!==L.urlId&&(L.urlId=b,this.startLoad())}},d.loadPlaylist=function(f){var p=this.currentLevelIndex,L=this._levels[p];if(this.canLoad&&L&&L.url.length>0){var b=L.urlId,g=L.url[b];if(f)try{g=f.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+p+(f?" at sn "+f.msn+" part "+f.part:"")+" with URL-id "+b+" "+g),this.clearTimer(),this.hls.trigger(B.Events.LEVEL_LOADING,{url:g,level:p,id:b,deliveryDirectives:f||null})}},d.removeLevel=function(f,p){var L=function(c,u){return u!==p},b=this._levels.filter(function(g,c){return c!==f?!0:g.url.length>1&&p!==void 0?(g.url=g.url.filter(L),g.audioGroupIds&&(g.audioGroupIds=g.audioGroupIds.filter(L)),g.textGroupIds&&(g.textGroupIds=g.textGroupIds.filter(L)),g.urlId=0,!0):!1}).map(function(g,c){var u=g.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=c}),g});this._levels=b,this.hls.trigger(B.Events.LEVELS_UPDATED,{levels:b})},O(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(f){var p,L=this._levels;if(L.length===0)return;if(this.currentLevelIndex===f&&(p=L[f])!==null&&p!==void 0&&p.details)return;if(f<0||f>=L.length){var b=f<0;if(this.hls.trigger(B.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.LEVEL_SWITCH_ERROR,level:f,fatal:b,reason:"invalid level idx"}),b)return;f=Math.min(f,L.length-1)}this.clearTimer();var g=this.currentLevelIndex,c=L[g],u=L[f];this.log("switching to level "+f+" from "+g),this.currentLevelIndex=f;var a=y({},u,{level:f,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(B.Events.LEVEL_SWITCHING,a);var x=u.details;if(!x||x.live){var v=this.switchParams(u.uri,c==null?void 0:c.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(f){this.manualLevelIndex=f,this._startLevel===void 0&&(this._startLevel=f),f!==-1&&(this.level=f)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(f){this._firstLevel=f}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var f=this.hls.config.startLevel;return f!==void 0?f:this._firstLevel}else return this._startLevel},set:function(f){this._startLevel=f}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(f){this.level=f,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=f)}}]),l}(I.default)},"./src/controller/level-helper.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"addGroupId",function(){return P}),_.d(Q,"assignTrackIdsByGroup",function(){return z}),_.d(Q,"updatePTS",function(){return W}),_.d(Q,"updateFragPTSDTS",function(){return D}),_.d(Q,"mergeDetails",function(){return y}),_.d(Q,"mapPartIntersection",function(){return w}),_.d(Q,"mapFragmentIntersection",function(){return O}),_.d(Q,"adjustSliding",function(){return k}),_.d(Q,"addSliding",function(){return A}),_.d(Q,"computeReloadInterval",function(){return T}),_.d(Q,"getFragmentWithSN",function(){return h}),_.d(Q,"getPartWith",function(){return o});var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/logger.ts");function P(l,d,C){switch(d){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(C);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(C);break}}function z(l){var d={};l.forEach(function(C){var f=C.groupId||"";C.id=d[f]=d[f]||0,d[f]++})}function W(l,d,C){var f=l[d],p=l[C];I(f,p)}function I(l,d){var C=d.startPTS;if(Object(Z.isFiniteNumber)(C)){var f=0,p;d.sn>l.sn?(f=C-l.start,p=l):(f=l.start-C,p=d),p.duration!==f&&(p.duration=f)}else if(d.sn>l.sn){var L=l.cc===d.cc;L&&l.minEndPTS?d.start=l.start+(l.minEndPTS-l.start):d.start=l.start+l.duration}else d.start=Math.max(l.start-d.duration,0)}function D(l,d,C,f,p,L){var b=f-C;b<=0&&(B.logger.warn("Fragment should have a positive duration",d),f=C+d.duration,L=p+d.duration);var g=C,c=f,u=d.startPTS,a=d.endPTS;if(Object(Z.isFiniteNumber)(u)){var x=Math.abs(u-C);Object(Z.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(x,d.deltaPTS):d.deltaPTS=x,g=Math.max(C,u),C=Math.min(C,u),p=Math.min(p,d.startDTS),c=Math.min(f,a),f=Math.max(f,a),L=Math.max(L,d.endDTS)}d.duration=f-C;var v=C-d.start;d.appendedPTS=f,d.start=d.startPTS=C,d.maxStartPTS=g,d.startDTS=p,d.endPTS=f,d.minEndPTS=c,d.endDTS=L;var E=d.sn;if(!l||E<l.startSN||E>l.endSN)return 0;var N,F=E-l.startSN,K=l.fragments;for(K[F]=d,N=F;N>0;N--)I(K[N],K[N-1]);for(N=F;N<K.length-1;N++)I(K[N],K[N+1]);return l.fragmentHint&&I(K[K.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,v}function y(l,d){for(var C=null,f=l.fragments,p=f.length-1;p>=0;p--){var L=f[p].initSegment;if(L){C=L;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var b=0,g;if(O(l,d,function(N,F){N.relurl&&(b=N.cc-F.cc),Object(Z.isFiniteNumber)(N.startPTS)&&Object(Z.isFiniteNumber)(N.endPTS)&&(F.start=F.startPTS=N.startPTS,F.startDTS=N.startDTS,F.appendedPTS=N.appendedPTS,F.maxStartPTS=N.maxStartPTS,F.endPTS=N.endPTS,F.endDTS=N.endDTS,F.minEndPTS=N.minEndPTS,F.duration=N.endPTS-N.startPTS,F.duration&&(g=F),d.PTSKnown=d.alignedSliding=!0),F.elementaryStreams=N.elementaryStreams,F.loader=N.loader,F.stats=N.stats,F.urlId=N.urlId,N.initSegment&&(F.initSegment=N.initSegment,C=N.initSegment)}),C){var c=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;c.forEach(function(N){var F;(!N.initSegment||N.initSegment.relurl===((F=C)===null||F===void 0?void 0:F.relurl))&&(N.initSegment=C)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(N){return!N}),d.deltaUpdateFailed)){B.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=d.skippedSegments;u--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var a=d.fragments;if(b){B.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<a.length;x++)a[x].cc+=b}d.skippedSegments&&(d.startCC=d.fragments[0].cc),w(l.partList,d.partList,function(N,F){F.elementaryStreams=N.elementaryStreams,F.stats=N.stats}),g?D(d,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):k(l,d),a.length&&(d.totalduration=d.edge-a[0].start),d.driftStartTime=l.driftStartTime,d.driftStart=l.driftStart;var v=d.advancedDateTime;if(d.advanced&&v){var E=d.edge;d.driftStart||(d.driftStartTime=v,d.driftStart=E),d.driftEndTime=v,d.driftEnd=E}else d.driftEndTime=l.driftEndTime,d.driftEnd=l.driftEnd,d.advancedDateTime=l.advancedDateTime}function w(l,d,C){if(l&&d)for(var f=0,p=0,L=l.length;p<=L;p++){var b=l[p],g=d[p+f];b&&g&&b.index===g.index&&b.fragment.sn===g.fragment.sn?C(b,g):f--}}function O(l,d,C){for(var f=d.skippedSegments,p=Math.max(l.startSN,d.startSN)-d.startSN,L=(l.fragmentHint?1:0)+(f?d.endSN:Math.min(l.endSN,d.endSN))-d.startSN,b=d.startSN-l.startSN,g=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,u=p;u<=L;u++){var a=c[b+u],x=g[u];f&&!x&&u<f&&(x=d.fragments[u]=a),a&&x&&C(a,x)}}function k(l,d){var C=d.startSN+d.skippedSegments-l.startSN,f=l.fragments;if(C<0||C>=f.length)return;A(d,f[C].start)}function A(l,d){if(d){for(var C=l.fragments,f=l.skippedSegments;f<C.length;f++)C[f].start+=d;l.fragmentHint&&(l.fragmentHint.start+=d)}}function T(l,d){var C=1e3*l.levelTargetDuration,f=C/2,p=l.age,L=p>0&&p<C*3,b=d.loading.end-d.loading.start,g,c=l.availabilityDelay;if(l.updated===!1)if(L){var u=333*l.misses;g=Math.max(Math.min(f,b*2),u),l.availabilityDelay=(l.availabilityDelay||0)+g}else g=f;else L?(c=Math.min(c||C/2,p),l.availabilityDelay=c,g=c+C-p):g=C-b;return Math.round(g)}function h(l,d,C){if(!l||!l.details)return null;var f=l.details,p=f.fragments[d-f.startSN];return p||(p=f.fragmentHint,p&&p.sn===d?p:d<f.startSN&&C&&C.sn===d?C:null)}function o(l,d,C){if(!l||!l.details)return null;var f=l.details.partList;if(f)for(var p=f.length;p--;){var L=f[p];if(L.index===C&&L.fragment.sn===d)return L}return null}},"./src/controller/stream-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return f});var Z=_("./src/polyfills/number.ts"),B=_("./src/controller/base-stream-controller.ts"),P=_("./src/is-supported.ts"),z=_("./src/events.ts"),W=_("./src/utils/buffer-helper.ts"),I=_("./src/controller/fragment-tracker.ts"),D=_("./src/types/loader.ts"),y=_("./src/loader/fragment.ts"),w=_("./src/demux/transmuxer-interface.ts"),O=_("./src/types/transmuxer.ts"),k=_("./src/controller/gap-controller.ts"),A=_("./src/errors.ts"),T=_("./src/utils/logger.ts");function h(p,L){for(var b=0;b<L.length;b++){var g=L[b];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}function o(p,L,b){return L&&h(p.prototype,L),b&&h(p,b),p}function l(p,L){p.prototype=Object.create(L.prototype),p.prototype.constructor=p,d(p,L)}function d(p,L){return d=Object.setPrototypeOf||function(g,c){return g.__proto__=c,g},d(p,L)}var C=100,f=function(p){l(L,p);function L(g,c){var u;return u=p.call(this,g,c,"[stream-controller]")||this,u.audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.stalled=!1,u.couldBacktrack=!1,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}var b=L.prototype;return b._registerListeners=function(){var c=this.hls;c.on(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(z.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(z.Events.ERROR,this.onError,this),c.on(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var c=this.hls;c.off(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(z.Events.ERROR,this.onError,this),c.off(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(z.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},b.startLoad=function(c){if(this.levels){var u=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(C),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var x=a.startLevel;x===-1&&(a.config.testBandwidth?(x=0,this.bitrateTest=!0):x=a.nextAutoLevel),this.level=a.nextLoadLevel=x,this.loadedmetadata=!1}u>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),c=u),this.state=B.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=B.State.STOPPED},b.stopLoad=function(){this._forceStartLoad=!1,p.prototype.stopLoad.call(this)},b.doTick=function(){switch(this.state){case B.State.IDLE:this.doTickIdle();break;case B.State.WAITING_LEVEL:{var c,u=this.levels,a=this.level,x=u==null||((c=u[a])===null||c===void 0)?void 0:c.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=B.State.IDLE;break}break}case B.State.FRAG_LOADING_WAITING_RETRY:{var v,E=self.performance.now(),N=this.retryDate;(!N||E>=N||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=B.State.IDLE)}break;default:break}this.onTickEnd()},b.onTickEnd=function(){p.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},b.doTickIdle=function(){var c,u,a=this.hls,x=this.levelLastLoaded,v=this.levels,E=this.media,N=a.config,F=a.nextLoadLevel;if(x===null||!E&&(this.startFragRequested||!N.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[F])return;var K=v[F];this.level=a.nextLoadLevel=F;var V=K.details;if(!V||this.state===B.State.WAITING_LEVEL||V.live&&this.levelLastLoaded!==F){this.state=B.State.WAITING_LEVEL;return}var R=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:E,D.PlaylistLevelType.MAIN);if(R===null)return;var M=R.len,$=this.getMaxBufferLength(K.maxBitrate);if(M>=$)return;if(this._streamEnded(R,V)){var ee={};this.altAudio&&(ee.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,ee),this.state=B.State.ENDED;return}var ae=R.end,fe=this.getNextFragment(ae,V);if(this.couldBacktrack&&!this.fragPrevious&&fe&&fe.sn!=="initSegment"){var De=fe.sn-V.startSN;De>1&&(fe=V.fragments[De-1],this.fragmentTracker.removeFragment(fe))}if(fe&&this.fragmentTracker.getState(fe)===I.FragmentState.OK&&this.nextLoadPosition>ae){var Se=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(E,Se,D.PlaylistLevelType.MAIN),fe=this.getNextFragment(this.nextLoadPosition,V)}if(!fe)return;fe.initSegment&&!fe.initSegment.data&&!this.bitrateTest&&(fe=fe.initSegment),((c=fe.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((u=fe.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(fe,V):this.loadFragment(fe,V,ae)},b.loadFragment=function(c,u,a){var x,v=this.fragmentTracker.getState(c);if(this.fragCurrent=c,v===I.FragmentState.BACKTRACKED){var E=this.fragmentTracker.getBacktrackData(c);if(E){this._handleFragmentLoadProgress(E),this._handleFragmentLoadComplete(E);return}else v=I.FragmentState.NOT_LOADED}v===I.FragmentState.NOT_LOADED||v===I.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,c,u,a)):v===I.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},b.getAppendedFrag=function(c){var u=this.fragmentTracker.getAppendedFrag(c,D.PlaylistLevelType.MAIN);return u&&"fragment"in u?u.fragment:u},b.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,D.PlaylistLevelType.MAIN)},b.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},b.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},b.nextLevelSwitch=function(){var c=this.levels,u=this.media;if(u!=null&&u.readyState){var a,x=this.getAppendedFrag(u.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!u.paused&&c){var v=this.hls.nextLoadLevel,E=c[v],N=this.fragLastKbps;N&&this.fragCurrent?a=this.fragCurrent.duration*E.maxBitrate/(1e3*N)+1:a=0}else a=0;var F=this.getBufferedFrag(u.currentTime+a);if(F){var K=this.followingBufferedFrag(F);if(K){this.abortCurrentFrag();var V=K.maxStartPTS?K.maxStartPTS:K.start,R=K.duration,M=Math.max(F.end,V+Math.min(Math.max(R-this.config.maxFragLookUpTolerance,R*.5),R*.75));this.flushMainBuffer(M,Number.POSITIVE_INFINITY)}}}},b.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===B.State.KEY_LOADING&&(this.state=B.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},b.flushMainBuffer=function(c,u){p.prototype.flushMainBuffer.call(this,c,u,this.altAudio?"video":null)},b.onMediaAttached=function(c,u){p.prototype.onMediaAttached.call(this,c,u);var a=u.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 k.default(this.config,a,this.fragmentTracker,this.hls)},b.onMediaDetaching=function(){var c=this.media;c&&(c.removeEventListener("playing",this.onvplaying),c.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),p.prototype.onMediaDetaching.call(this)},b.onMediaPlaying=function(){this.tick()},b.onMediaSeeked=function(){var c=this.media,u=c?c.currentTime:null;Object(Z.isFiniteNumber)(u)&&this.log("Media seeked to "+u.toFixed(3)),this.tick()},b.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},b.onManifestParsed=function(c,u){var a=!1,x=!1,v;u.levels.forEach(function(E){v=E.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(a=!0),v.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=a&&x&&!Object(P.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=u.levels,this.startFragRequested=!1},b.onLevelLoading=function(c,u){var a=this.levels;if(!a||this.state!==B.State.IDLE)return;var x=a[u.level];(!x.details||x.details.live&&this.levelLastLoaded!==u.level||this.waitForCdnTuneIn(x.details))&&(this.state=B.State.WAITING_LEVEL)},b.onLevelLoaded=function(c,u){var a,x=this.levels,v=u.level,E=u.details,N=E.totalduration;if(!x){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+E.startSN+","+E.endSN+"], cc ["+E.startCC+", "+E.endCC+"] duration:"+N);var F=this.fragCurrent;F&&(this.state===B.State.FRAG_LOADING||this.state===B.State.FRAG_LOADING_WAITING_RETRY)&&(F.level!==u.level&&F.loader&&(this.state=B.State.IDLE,F.loader.abort()));var K=x[v],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=v,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:E,level:v}),this.state===B.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(E))return;this.state=B.State.IDLE}this.startFragRequested?E.live&&this.synchronizeToLiveEdge(E):this.setStartPosition(E,V),this.tick()},b._handleFragmentLoadProgress=function(c){var u,a=c.frag,x=c.part,v=c.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 N=E[a.level],F=N.details;if(!F){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var K=N.videoCodec,V=F.PTSKnown||!F.live,R=(u=a.initSegment)===null||u===void 0?void 0:u.data,M=this._getAudioCodec(N),$=this.transmuxer=this.transmuxer||new w.default(this.hls,D.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ee=x?x.index:-1,ae=ee!==-1,fe=new O.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,ee,ae),De=this.initPTS[a.cc];$.push(v,R,M,K,a,x,F.totalduration,V,fe,De)},b.onAudioTrackSwitching=function(c,u){var a=this.altAudio,x=!!u.url,v=u.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var 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 N=this.hls;a&&N.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),N.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:v})}},b.onAudioTrackSwitched=function(c,u){var a=u.id,x=!!this.hls.audioTracks[a].url;if(x){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=x,this.tick()},b.onBufferCreated=function(c,u){var a=u.tracks,x,v,E=!1;for(var N in a){var F=a[N];if(F.id==="main"){if(v=N,x=F,N==="video"){var K=a[N];K&&(this.videoBuffer=K.buffer)}}else E=!0}E&&x?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},b.onFragBuffered=function(c,u){var a=u.frag,x=u.part;if(a&&a.type!==D.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(x?" p: "+x.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===B.State.PARSED&&(this.state=B.State.IDLE);return}var v=x?x.stats:a.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,x)},b.onError=function(c,u){switch(u.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(D.PlaylistLevelType.MAIN,u);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==B.State.ERROR&&(u.fatal?(this.warn(""+u.details),this.state=B.State.ERROR):!u.levelRetry&&this.state===B.State.WAITING_LEVEL&&(this.state=B.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="main"&&(this.state===B.State.PARSING||this.state===B.State.PARSED)){var a=!0,x=this.getFwdBufferInfo(this.media,D.PlaylistLevelType.MAIN);x&&x.len>.5&&(a=!this.reduceMaxBufferLength(x.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},b.checkBuffer=function(){var c=this.media,u=this.gapController;if(!c||!u||!c.readyState)return;var a=W.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):u.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},b.onFragLoadEmergencyAborted=function(){this.state=B.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},b.onBufferFlushed=function(c,u){var a=u.type;if(a!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(a===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,a,D.PlaylistLevelType.MAIN)}},b.onLevelsUpdated=function(c,u){this.levels=u.levels},b.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},b.seekToStartPos=function(){var c=this.media,u=c.currentTime,a=this.startPosition;if(a>=0&&u<a){if(c.seeking){T.logger.log("could not seek to "+a+", already seeking at "+u);return}var x=W.BufferHelper.getBuffered(c),v=x.length?x.start(0):0,E=v-a;E>0&&(E<this.config.maxBufferHole||E<this.config.maxFragLookUpTolerance)&&(T.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 "+u),c.currentTime=a}},b._getAudioCodec=function(c){var u=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&u&&(this.log("Swapping audio codec"),u.indexOf("mp4a.40.5")!==-1?u="mp4a.40.2":u="mp4a.40.5"),u},b._loadBitrateTestFrag=function(c){var u=this;this._doFragLoad(c).then(function(a){var x=u.hls;if(!a||x.nextLoadLevel||u.fragContextChanged(c))return;u.fragLoadError=0,u.state=B.State.IDLE,u.startFragRequested=!1,u.bitrateTest=!1;var v=c.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),x.trigger(z.Events.FRAG_LOADED,a)})},b._handleTransmuxComplete=function(c){var u,a="main",x=this.hls,v=c.remuxResult,E=c.chunkMeta,N=this.getCurrentContext(E);if(!N){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 F=N.frag,K=N.part,V=N.level,R=v.video,M=v.text,$=v.id3,ee=v.initSegment,ae=this.altAudio?void 0:v.audio;if(this.fragContextChanged(F))return;if(this.state=B.State.PARSING,ee){ee.tracks&&(this._bufferInitSegment(V,ee.tracks,F,E),x.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:a,tracks:ee.tracks}));var fe=ee.initPTS,De=ee.timescale;Object(Z.isFiniteNumber)(fe)&&(this.initPTS[F.cc]=fe,x.trigger(z.Events.INIT_PTS_FOUND,{frag:F,id:a,initPTS:fe,timescale:De}))}if(R&&v.independent!==!1){if(V.details){var Se=R.startPTS,Ce=R.endPTS,we=R.startDTS,Te=R.endDTS;if(K)K.elementaryStreams[R.type]={startPTS:Se,endPTS:Ce,startDTS:we,endDTS:Te};else if(R.firstKeyFrame&&R.independent&&(this.couldBacktrack=!0),R.dropped&&R.independent){var me=this.getLoadPosition()+this.config.maxBufferHole;if(me<Se){this.backtrack(F);return}F.setElementaryStreamInfo(R.type,F.start,Ce,F.start,Te,!0)}F.setElementaryStreamInfo(R.type,Se,Ce,we,Te),this.bufferFragmentData(R,F,K,E)}}else if(v.independent===!1){this.backtrack(F);return}if(ae){var he=ae.startPTS,te=ae.endPTS,de=ae.startDTS,ne=ae.endDTS;K&&(K.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:he,endPTS:te,startDTS:de,endDTS:ne}),F.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,he,te,de,ne),this.bufferFragmentData(ae,F,K,E)}if($!=null&&(u=$.samples)!==null&&u!==void 0&&u.length){var Le={frag:F,id:a,samples:$.samples};x.trigger(z.Events.FRAG_PARSING_METADATA,Le)}if(M){var Re={frag:F,id:a,samples:M.samples};x.trigger(z.Events.FRAG_PARSING_USERDATA,Re)}},b._bufferInitSegment=function(c,u,a,x){var v=this;if(this.state!==B.State.PARSING)return;this.audioOnly=!!u.audio&&!u.video,this.altAudio&&!this.audioOnly&&delete u.audio;var E=u.audio,N=u.video,F=u.audiovideo;if(E){var K=c.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)),c.audioCodec&&c.audioCodec!==K&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+K+'"'),E.levelCodec=K,E.id="main",this.log("Init audio buffer, container:"+E.container+", codecs[selected/level/parsed]=["+(K||"")+"/"+(c.audioCodec||"")+"/"+E.codec+"]")}N&&(N.levelCodec=c.videoCodec,N.id="main",this.log("Init video buffer, container:"+N.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+N.codec+"]")),F&&this.log("Init audiovideo buffer, container:"+F.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+F.codec+"]"),this.hls.trigger(z.Events.BUFFER_CODECS,u),Object.keys(u).forEach(function(R){var M=u[R],$=M.initSegment;$!=null&&$.byteLength&&v.hls.trigger(z.Events.BUFFER_APPENDING,{type:R,data:$,frag:a,part:null,chunkMeta:x,parent:a.type})}),this.tick()},b.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var u=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,u?this.resetFragmentLoading(c):this.state=B.State.BACKTRACKING},b.checkFragmentChanged=function(){var c=this.media,u=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(W.BufferHelper.isBuffered(c,a)?u=this.getAppendedFrag(a):W.BufferHelper.isBuffered(c,a+.1)&&(u=this.getAppendedFrag(a+.1)),u){var x=this.fragPlaying,v=u.level;(!x||u.sn!==x.sn||x.level!==v||u.urlId!==x.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:u}),(!x||x.level!==v)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=u)}}},o(L,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);if(u)return u.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(u)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),L}(B.default)},"./src/controller/subtitle-stream-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"SubtitleStreamController",function(){return l});var Z=_("./src/events.ts"),B=_("./src/utils/logger.ts"),P=_("./src/utils/buffer-helper.ts"),z=_("./src/controller/fragment-finders.ts"),W=_("./src/utils/discontinuities.ts"),I=_("./src/controller/level-helper.ts"),D=_("./src/controller/fragment-tracker.ts"),y=_("./src/controller/base-stream-controller.ts"),w=_("./src/types/loader.ts"),O=_("./src/types/level.ts");function k(d,C){for(var f=0;f<C.length;f++){var p=C[f];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(d,p.key,p)}}function A(d,C,f){return C&&k(d.prototype,C),f&&k(d,f),d}function T(d,C){d.prototype=Object.create(C.prototype),d.prototype.constructor=d,h(d,C)}function h(d,C){return h=Object.setPrototypeOf||function(p,L){return p.__proto__=L,p},h(d,C)}var o=500,l=function(d){T(C,d);function C(p,L){var b;return b=d.call(this,p,L,"[subtitle-stream-controller]")||this,b.levels=[],b.currentTrackId=-1,b.tracksBuffered=[],b.mainDetails=null,b._registerListeners(),b}var f=C.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var L=this.hls;L.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.on(Z.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.on(Z.Events.ERROR,this.onError,this),L.on(Z.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.on(Z.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.on(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.on(Z.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.on(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f._unregisterListeners=function(){var L=this.hls;L.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.off(Z.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.off(Z.Events.ERROR,this.onError,this),L.off(Z.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.off(Z.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.off(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.off(Z.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.off(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f.startLoad=function(){this.stopLoad(),this.state=y.State.IDLE,this.setInterval(o),this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},f.onLevelLoaded=function(L,b){this.mainDetails=b.details},f.onSubtitleFragProcessed=function(L,b){var g=b.frag,c=b.success;if(this.fragPrevious=g,this.state=y.State.IDLE,!c)return;var u=this.tracksBuffered[this.currentTrackId];if(!u)return;for(var a,x=g.start,v=0;v<u.length;v++)if(x>=u[v].start&&x<=u[v].end){a=u[v];break}var E=g.start+g.duration;a?a.end=E:(a={start:x,end:E},u.push(a)),this.fragmentTracker.fragBuffered(g)},f.onBufferFlushing=function(L,b){var g=b.startOffset,c=b.endOffset;if(g===0&&c!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var x=a[u].details,v=x.targetduration,E=c-v;if(E<=0)return;b.endOffsetSubtitles=Math.max(0,E),this.tracksBuffered.forEach(function(N){for(var F=0;F<N.length;){if(N[F].end<=E){N.shift();continue}else if(N[F].start<E)N[F].start=E;else break;F++}}),this.fragmentTracker.removeFragmentsInRange(g,E,w.PlaylistLevelType.SUBTITLE)}},f.onError=function(L,b){var g,c=b.frag;if(!c||c.type!==w.PlaylistLevelType.SUBTITLE)return;(g=this.fragCurrent)!==null&&g!==void 0&&g.loader&&this.fragCurrent.loader.abort(),this.state=y.State.IDLE},f.onSubtitleTracksUpdated=function(L,b){var g=this,c=b.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(u){return new O.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){g.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},f.onSubtitleTrackSwitch=function(L,b){if(this.currentTrackId=b.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var g=this.levels[this.currentTrackId];g!=null&&g.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,g&&this.setInterval(o)},f.onSubtitleTrackLoaded=function(L,b){var g,c=b.details,u=b.id,a=this.currentTrackId,x=this.levels;if(!x.length)return;var v=x[a];if(u>=x.length||u!==a||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(g=v.details)!==null&&g!==void 0&&g.live){var E=this.mainDetails;if(c.deltaUpdateFailed||!E)return;var N=E.fragments[0];if(!v.details)c.hasProgramDateTime&&E.hasProgramDateTime?Object(W.alignMediaPlaylistByPDT)(c,E):N&&Object(I.addSliding)(c,N.start);else{var F=this.alignPlaylists(c,v.details);F===0&&N&&Object(I.addSliding)(c,N.start)}}if(v.details=c,this.levelLastLoaded=u,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===y.State.IDLE){var K=Object(z.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);K||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},f._handleFragmentLoadComplete=function(L){var b=L.frag,g=L.payload,c=b.decryptdata,u=this.hls;if(this.fragContextChanged(b))return;if(g&&g.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),c.key.buffer,c.iv.buffer).then(function(x){var v=performance.now();u.trigger(Z.Events.FRAG_DECRYPTED,{frag:b,payload:x,stats:{tstart:a,tdecrypt:v}})})}},f.doTick=function(){if(!this.media){this.state=y.State.IDLE;return}if(this.state===y.State.IDLE){var L,b=this.currentTrackId,g=this.levels;if(!g.length||!g[b]||!g[b].details)return;var c=g[b].details,u=c.targetduration,a=this.config,x=this.media,v=P.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,x.currentTime-u,a.maxBufferHole),E=v.end,N=v.len,F=this.getMaxBufferLength()+u;if(N>F)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var K=c.fragments,V=K.length,R=c.edge,M,$=this.fragPrevious;if(E<R){var ee=a.maxFragLookUpTolerance;$&&c.hasProgramDateTime&&(M=Object(z.findFragmentByPDT)(K,$.endProgramDateTime,ee)),M||(M=Object(z.findFragmentByPTS)($,K,E,ee),!M&&$&&$.start<K[0].start&&(M=K[0]))}else M=K[V-1];(L=M)!==null&&L!==void 0&&L.encrypted?(B.logger.log("Loading key for "+M.sn),this.state=y.State.KEY_LOADING,this.hls.trigger(Z.Events.KEY_LOADING,{frag:M})):M&&this.fragmentTracker.getState(M)===D.FragmentState.NOT_LOADED&&this.loadFragment(M,c,E)}},f.loadFragment=function(L,b,g){this.fragCurrent=L,d.prototype.loadFragment.call(this,L,b,g)},A(C,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),C}(y.default)},"./src/controller/subtitle-track-controller.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/events.ts"),B=_("./src/utils/texttrack-utils.ts"),P=_("./src/controller/base-playlist-controller.ts"),z=_("./src/types/loader.ts");function W(k,A){for(var T=0;T<A.length;T++){var h=A[T];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(k,h.key,h)}}function I(k,A,T){return A&&W(k.prototype,A),T&&W(k,T),k}function D(k,A){k.prototype=Object.create(A.prototype),k.prototype.constructor=k,y(k,A)}function y(k,A){return y=Object.setPrototypeOf||function(h,o){return h.__proto__=o,h},y(k,A)}var w=function(k){D(A,k);function A(h){var o;return o=k.call(this,h,"[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 T=A.prototype;return T.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,k.prototype.destroy.call(this)},T.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)},T.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)},T.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)},T.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},T.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(B.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},T.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},T.onManifestParsed=function(o,l){this.tracks=l.subtitleTracks},T.onSubtitleTrackLoaded=function(o,l){var d=l.id,C=l.details,f=this.trackId,p=this.tracksInGroup[f];if(!p){this.warn("Invalid subtitle track id "+d);return}var L=p.details;p.details=l.details,this.log("subtitle track "+d+" loaded ["+C.startSN+"-"+C.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,l,L))},T.onLevelLoading=function(o,l){this.switchLevel(l.level)},T.onLevelSwitching=function(o,l){this.switchLevel(l.level)},T.switchLevel=function(o){var l=this.hls.levels[o];if(!(l!=null&&l.textGroupIds))return;var d=l.textGroupIds[l.urlId];if(this.groupId!==d){var C=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,f=this.tracks.filter(function(b){return!d||b.groupId===d});this.tracksInGroup=f;var p=this.findTrackId(C==null?void 0:C.name)||this.findTrackId();this.groupId=d;var L={subtitleTracks:f};this.log("Updating subtitle tracks, "+f.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(Z.Events.SUBTITLE_TRACKS_UPDATED,L),p!==-1&&this.setSubtitleTrack(p,C)}},T.findTrackId=function(o){for(var l=this.tracksInGroup,d=0;d<l.length;d++){var C=l[d];if((!this.selectDefaultTrack||C.default)&&(!o||o===C.name))return C.id}return-1},T.onError=function(o,l){if(k.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)},T.loadPlaylist=function(o){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var d=l.id,C=l.groupId,f=l.url;if(o)try{f=o.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger(Z.Events.SUBTITLE_TRACK_LOADING,{url:f,id:d,groupId:C,deliveryDirectives:o||null})}},T.toggleTrackModes=function(o){var l=this,d=this.media,C=this.subtitleDisplay,f=this.trackId;if(!d)return;var p=O(d.textTracks),L=p.filter(function(c){return c.groupId===l.groupId});if(o===-1)[].slice.call(p).forEach(function(c){c.mode="disabled"});else{var b=L[f];b&&(b.mode="disabled")}var g=L[o];g&&(g.mode=C?"showing":"hidden")},T.setSubtitleTrack=function(o,l){var d,C=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(d=C[o])!==null&&d!==void 0&&d.details)||o<-1||o>=C.length)return;this.clearTimer();var f=C[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,f){var p=f.id,L=f.groupId,b=L===void 0?"":L,g=f.name,c=f.type,u=f.url;this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:b,name:g,type:c,url:u});var a=this.switchParams(f.url,l==null?void 0:l.details);this.loadPlaylist(a)}else this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:o})},T.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),d=0;d<l.length;d++)if(l[d].mode==="hidden")o=d;else if(l[d].mode==="showing"){o=d;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},I(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}(P.default);function O(k){for(var A=[],T=0;T<k.length;T++){var h=k[T];h.kind==="subtitles"&&h.label&&A.push(k[T])}return A}Q.default=w},"./src/controller/timeline-controller.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"TimelineController",function(){return O});var Z=_("./src/polyfills/number.ts"),B=_("./src/events.ts"),P=_("./src/utils/cea-608-parser.ts"),z=_("./src/utils/output-filter.ts"),W=_("./src/utils/webvtt-parser.ts"),I=_("./src/utils/texttrack-utils.ts"),D=_("./src/utils/imsc1-ttml-parser.ts"),y=_("./src/types/loader.ts"),w=_("./src/utils/logger.ts"),O=function(){function h(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=T(),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 d=new z.default(this,"textTrack1"),C=new z.default(this,"textTrack2"),f=new z.default(this,"textTrack3"),p=new z.default(this,"textTrack4");this.cea608Parser1=new P.default(1,d,C),this.cea608Parser2=new P.default(3,f,p)}l.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(B.Events.FRAG_LOADING,this.onFragLoading,this),l.on(B.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(B.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(B.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(B.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(B.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=h.prototype;return o.destroy=function(){var d=this.hls;d.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(B.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(B.Events.FRAG_LOADING,this.onFragLoading,this),d.off(B.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(B.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(B.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(B.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(B.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(d,C,f,p,L){for(var b=!1,g=L.length;g--;){var c=L[g],u=A(c[0],c[1],C,f);if(u>=0&&(c[0]=Math.min(c[0],C),c[1]=Math.max(c[1],f),b=!0,u/(f-C)>.5))return}if(b||L.push([C,f]),this.config.renderTextTracksNatively){var a=this.captionsTracks[d];this.Cues.newCue(a,C,f,p)}else{var x=this.Cues.newCue(null,C,f,p);this.hls.trigger(B.Events.CUES_PARSED,{type:"captions",cues:x,track:d})}},o.onInitPtsFound=function(d,C){var f=this,p=C.frag,L=C.id,b=C.initPTS,g=C.timescale,c=this.unparsedVttFrags;L==="main"&&(this.initPTS[p.cc]=b,this.timescale[p.cc]=g),c.length&&(this.unparsedVttFrags=[],c.forEach(function(u){f.onFragLoaded(B.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(d){var C=this.media;if(C)for(var f=0;f<C.textTracks.length;f++){var p=C.textTracks[f];if(p[d])return p}return null},o.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},o.createNativeTrack=function(d){if(this.captionsTracks[d])return;var C=this.captionsProperties,f=this.captionsTracks,p=this.media,L=C[d],b=L.label,g=L.languageCode,c=this.getExistingTrack(d);if(c)f[d]=c,Object(I.clearCurrentCues)(f[d]),Object(I.sendAddTrackEvent)(f[d],p);else{var u=this.createTextTrack("captions",b,g);u&&(u[d]=!0,f[d]=u)}},o.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var C=this.captionsProperties[d];if(!C)return;var f=C.label,p={_id:d,label:f,kind:"captions",default:C.media?!!C.media.default:!1,closedCaptions:C.media};this.nonNativeCaptionsTracks[d]=p,this.hls.trigger(B.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[p]})},o.createTextTrack=function(d,C,f){var p=this.media;return p?p.addTextTrack(d,C,f):void 0},o.onMediaAttaching=function(d,C){this.media=C.media,this._cleanTracks()},o.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(C){Object(I.clearCurrentCues)(d[C]),delete d[C]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=T(),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 d=this.media;if(!d)return;var C=d.textTracks;if(C)for(var f=0;f<C.length;f++)Object(I.clearCurrentCues)(C[f])},o.onSubtitleTracksUpdated=function(d,C){var f=this;this.textTracks=[];var p=C.subtitleTracks||[],L=p.some(function(u){return u.textCodec===D.IMSC1_CODEC});if(this.config.enableWebVTT||L&&this.config.enableIMSC1){var b=this.tracks&&p&&this.tracks.length===p.length;if(this.tracks=p||[],this.config.renderTextTracksNatively){var g=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,a){var x;if(a<g.length){for(var v=null,E=0;E<g.length;E++)if(k(g[E],u)){v=g[E];break}v&&(x=v)}x?Object(I.clearCurrentCues)(x):(x=f.createTextTrack("subtitles",u.name,u.lang),x&&(x.mode="disabled")),x&&(x.groupId=u.groupId,f.textTracks.push(x))})}else if(!b&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(B.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(d,C){var f=this;this.config.enableCEA708Captions&&C.captions&&C.captions.forEach(function(p){var L=/(?:CC|SERVICE)([1-4])/.exec(p.instreamId);if(!L)return;var b="textTrack"+L[1],g=f.captionsProperties[b];if(!g)return;g.label=p.name,p.lang&&(g.languageCode=p.lang),g.media=p})},o.onFragLoading=function(d,C){var f=this.cea608Parser1,p=this.cea608Parser2,L=this.lastSn,b=this.lastPartIndex;if(!this.enabled||!(f&&p))return;if(C.frag.type===y.PlaylistLevelType.MAIN){var g,c,u=C.frag.sn,a=(g=C==null||((c=C.part)===null||c===void 0)?void 0:c.index)!=null?g:-1;u===L+1||u===L&&a===b+1||(f.reset(),p.reset()),this.lastSn=u,this.lastPartIndex=a}},o.onFragLoaded=function(d,C){var f=C.frag,p=C.payload,L=this.initPTS,b=this.unparsedVttFrags;if(f.type===y.PlaylistLevelType.SUBTITLE)if(p.byteLength){if(!Object(Z.isFiniteNumber)(L[f.cc])){b.push(C),L.length&&this.hls.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Missing initial subtitle PTS")});return}var g=f.decryptdata;if(g==null||g.key==null||g.method!=="AES-128"){var c=this.tracks[f.level],u=this.vttCCs;u[f.cc]||(u[f.cc]={start:f.start,prevCC:this.prevCC,new:!0},this.prevCC=f.cc),c&&c.textCodec===D.IMSC1_CODEC?this._parseIMSC1(f,p):this._parseVTTs(f,p,u)}}else this.hls.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(d,C){var f=this,p=this.hls;Object(D.parseIMSC1)(C,this.initPTS[d.cc],this.timescale[d.cc],function(L){f._appendCues(L,d.level),p.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(L){w.logger.log("Failed to parse IMSC1: "+L),p.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:L})})},o._parseVTTs=function(d,C,f){var p=this,L=this.hls;Object(W.parseWebVTT)(C,this.initPTS[d.cc],this.timescale[d.cc],f,d.cc,d.start,function(b){p._appendCues(b,d.level),L.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(b){p._fallbackToIMSC1(d,C),w.logger.log("Failed to parse VTT cue: "+b),L.trigger(B.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:b})})},o._fallbackToIMSC1=function(d,C){var f=this,p=this.tracks[d.level];p.textCodec||Object(D.parseIMSC1)(C,this.initPTS[d.cc],this.timescale[d.cc],function(){p.textCodec=D.IMSC1_CODEC,f._parseIMSC1(d,C)},function(){p.textCodec="wvtt"})},o._appendCues=function(d,C){var f=this.hls;if(this.config.renderTextTracksNatively){var p=this.textTracks[C];if(p.mode==="disabled")return;d.forEach(function(g){return Object(I.addCueToTrack)(p,g)})}else{var L=this.tracks[C],b=L.default?"default":"subtitles"+C;f.trigger(B.Events.CUES_PARSED,{type:"subtitles",cues:d,track:b})}},o.onFragDecrypted=function(d,C){var f=C.frag;if(f.type===y.PlaylistLevelType.SUBTITLE){if(!Object(Z.isFiniteNumber)(this.initPTS[f.cc])){this.unparsedVttFrags.push(C);return}this.onFragLoaded(B.Events.FRAG_LOADED,C)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(d,C){var f=this.cea608Parser1,p=this.cea608Parser2;if(!this.enabled||!(f&&p))return;for(var L=0;L<C.samples.length;L++){var b=C.samples[L].bytes;if(b){var g=this.extractCea608Data(b);f.addData(C.samples[L].pts,g[0]),p.addData(C.samples[L].pts,g[1])}}},o.onBufferFlushing=function(d,C){var f=C.startOffset,p=C.endOffset,L=C.endOffsetSubtitles,b=C.type,g=this.media;if(!g||g.currentTime<p)return;if(!b||b==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(I.removeCuesInRange)(c[a],f,p)})}if(this.config.renderTextTracksNatively&&(f===0&&L!==void 0)){var u=this.textTracks;Object.keys(u).forEach(function(a){return Object(I.removeCuesInRange)(u[a],f,L)})}},o.extractCea608Data=function(d){for(var C=d[0]&31,f=2,p=[[],[]],L=0;L<C;L++){var b=d[f++],g=127&d[f++],c=127&d[f++],u=(4&b)!==0,a=3&b;if(g===0&&c===0)continue;u&&((a===0||a===1)&&(p[a].push(g),p[a].push(c)))}return p},h}();function k(h,o){return h&&h.label===o.name&&!(h.textTrack1||h.textTrack2)}function A(h,o,l,d){return Math.min(o,d)-Math.max(h,l)}function T(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return Z});var Z=function(){function B(z,W){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=W}var P=B.prototype;return P.decrypt=function(W,I){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},I,W)},B}()},"./src/crypt/aes-decryptor.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"removePadding",function(){return B}),_.d(Q,"default",function(){return P});var Z=_("./src/utils/typed-array.ts");function B(z){var W=z.byteLength,I=W&&new DataView(z.buffer).getUint8(W-1);return I?Object(Z.sliceUint8)(z,0,W-I):z}var P=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 W=z.prototype;return W.uint8ArrayToUint32Array_=function(D){for(var y=new DataView(D),w=new Uint32Array(4),O=0;O<4;O++)w[O]=y.getUint32(O*4);return w},W.initTable=function(){var D=this.sBox,y=this.invSBox,w=this.subMix,O=w[0],k=w[1],A=w[2],T=w[3],h=this.invSubMix,o=h[0],l=h[1],d=h[2],C=h[3],f=new Uint32Array(256),p=0,L=0,b=0;for(b=0;b<256;b++)b<128?f[b]=b<<1:f[b]=b<<1^283;for(b=0;b<256;b++){var g=L^L<<1^L<<2^L<<3^L<<4;g=g>>>8^g&255^99,D[p]=g,y[g]=p;var c=f[p],u=f[c],a=f[u],x=f[g]*257^g*16843008;O[p]=x<<24|x>>>8,k[p]=x<<16|x>>>16,A[p]=x<<8|x>>>24,T[p]=x,x=a*16843009^u*65537^c*257^p*16843008,o[g]=x<<24|x>>>8,l[g]=x<<16|x>>>16,d[g]=x<<8|x>>>24,C[g]=x,p?(p=c^f[f[f[a^c]]],L^=f[f[L]]):p=L=1}},W.expandKey=function(D){for(var y=this.uint8ArrayToUint32Array_(D),w=!0,O=0;O<y.length&&w;)w=y[O]===this.key[O],O++;if(w)return;this.key=y;var k=this.keySize=y.length;if(k!==4&&k!==6&&k!==8)throw new Error("Invalid aes key size="+k);var A=this.ksRows=(k+6+1)*4,T,h,o=this.keySchedule=new Uint32Array(A),l=this.invKeySchedule=new Uint32Array(A),d=this.sBox,C=this.rcon,f=this.invSubMix,p=f[0],L=f[1],b=f[2],g=f[3],c,u;for(T=0;T<A;T++){if(T<k){c=o[T]=y[T];continue}u=c,T%k===0?(u=u<<8|u>>>24,u=d[u>>>24]<<24|d[u>>>16&255]<<16|d[u>>>8&255]<<8|d[u&255],u^=C[T/k|0]<<24):k>6&&T%k===4&&(u=d[u>>>24]<<24|d[u>>>16&255]<<16|d[u>>>8&255]<<8|d[u&255]),o[T]=c=(o[T-k]^u)>>>0}for(h=0;h<A;h++)T=A-h,h&3?u=o[T]:u=o[T-4],h<4||T<=4?l[h]=u:l[h]=p[d[u>>>24]]^L[d[u>>>16&255]]^b[d[u>>>8&255]]^g[d[u&255]],l[h]=l[h]>>>0},W.networkToHostOrderSwap=function(D){return D<<24|(D&65280)<<8|(D&16711680)>>8|D>>>24},W.decrypt=function(D,y,w){for(var O=this.keySize+6,k=this.invKeySchedule,A=this.invSBox,T=this.invSubMix,h=T[0],o=T[1],l=T[2],d=T[3],C=this.uint8ArrayToUint32Array_(w),f=C[0],p=C[1],L=C[2],b=C[3],g=new Int32Array(D),c=new Int32Array(g.length),u,a,x,v,E,N,F,K,V,R,M,$,ee,ae,fe=this.networkToHostOrderSwap;y<g.length;){for(V=fe(g[y]),R=fe(g[y+1]),M=fe(g[y+2]),$=fe(g[y+3]),E=V^k[0],N=$^k[1],F=M^k[2],K=R^k[3],ee=4,ae=1;ae<O;ae++)u=h[E>>>24]^o[N>>16&255]^l[F>>8&255]^d[K&255]^k[ee],a=h[N>>>24]^o[F>>16&255]^l[K>>8&255]^d[E&255]^k[ee+1],x=h[F>>>24]^o[K>>16&255]^l[E>>8&255]^d[N&255]^k[ee+2],v=h[K>>>24]^o[E>>16&255]^l[N>>8&255]^d[F&255]^k[ee+3],E=u,N=a,F=x,K=v,ee=ee+4;u=A[E>>>24]<<24^A[N>>16&255]<<16^A[F>>8&255]<<8^A[K&255]^k[ee],a=A[N>>>24]<<24^A[F>>16&255]<<16^A[K>>8&255]<<8^A[E&255]^k[ee+1],x=A[F>>>24]<<24^A[K>>16&255]<<16^A[E>>8&255]<<8^A[N&255]^k[ee+2],v=A[K>>>24]<<24^A[E>>16&255]<<16^A[N>>8&255]<<8^A[F&255]^k[ee+3],c[y]=fe(u^f),c[y+1]=fe(v^p),c[y+2]=fe(x^L),c[y+3]=fe(a^b),f=V,p=R,L=M,b=$,y=y+4}return c.buffer},z}()},"./src/crypt/decrypter.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return y});var Z=_("./src/crypt/aes-crypto.ts"),B=_("./src/crypt/fast-aes-key.ts"),P=_("./src/crypt/aes-decryptor.ts"),z=_("./src/utils/logger.ts"),W=_("./src/utils/mp4-tools.ts"),I=_("./src/utils/typed-array.ts"),D=16,y=function(){function w(k,A,T){var h=T===void 0?{}:T,o=h.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=k,this.config=A,this.removePKCS7Padding=l,l)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(C){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var O=w.prototype;return O.destroy=function(){this.observer=null},O.isSync=function(){return this.config.enableSoftwareAES},O.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var T=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(P.removePadding)(T):T},O.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},O.decrypt=function(A,T,h,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),T,h);var l=this.flush();l&&o(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),T,h).then(o)},O.softwareDecrypt=function(A,T,h){var o=this.currentIV,l=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(A=Object(W.appendUint8Array)(d,A),this.remainderData=null);var C=this.getValidChunk(A);if(!C.length)return null;o&&(h=o);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new P.default),f.expandKey(T);var p=l;return this.currentResult=f.decrypt(C.buffer,0,h),this.currentIV=Object(I.sliceUint8)(C,-16).buffer,p||null},O.webCryptoDecrypt=function(A,T,h){var o=this,l=this.subtle;return(this.key!==T||!this.fastAesKey)&&(this.key=T,this.fastAesKey=new B.default(l,T)),this.fastAesKey.expandKey().then(function(d){if(!l)return Promise.reject(new Error("web crypto not initialized"));var C=new Z.default(l,h);return C.decrypt(A.buffer,d)}).catch(function(d){return o.onWebCryptoError(d,A,T,h)})},O.onWebCryptoError=function(A,T,h,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(T,h,o)},O.getValidChunk=function(A){var T=A,h=A.length-A.length%D;return h!==A.length&&(T=Object(I.sliceUint8)(A,0,h),this.remainderData=Object(I.sliceUint8)(A,h)),T},O.logOnce=function(A){if(!this.logEnabled)return;z.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1},w}()},"./src/crypt/fast-aes-key.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return Z});var Z=function(){function B(z,W){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=W}var P=B.prototype;return P.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},B}()},"./src/demux/aacdemuxer.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/demux/base-audio-demuxer.ts"),B=_("./src/demux/adts.ts"),P=_("./src/utils/logger.ts"),z=_("./src/demux/id3.ts");function W(y,w){y.prototype=Object.create(w.prototype),y.prototype.constructor=y,I(y,w)}function I(y,w){return I=Object.setPrototypeOf||function(k,A){return k.__proto__=A,k},I(y,w)}var D=function(y){W(w,y);function w(k,A){var T;return T=y.call(this)||this,T.observer=void 0,T.config=void 0,T.observer=k,T.config=A,T}var O=w.prototype;return O.resetInitSegment=function(A,T,h){y.prototype.resetInitSegment.call(this,A,T,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:A,duration:h,inputTimeScale:9e4,dropped:0}},w.probe=function(A){if(!A)return!1;for(var T=z.getID3Data(A,0)||[],h=T.length,o=A.length;h<o;h++)if(B.probe(A,h))return P.logger.log("ADTS sync word found !"),!0;return!1},O.canParse=function(A,T){return B.canParse(A,T)},O.appendFrame=function(A,T,h){B.initTrackConfig(A,this.observer,T,h,A.manifestCodec);var o=B.appendFrame(A,T,h,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},w}(Z.default);D.minProbeByteLength=9,Q.default=D},"./src/demux/adts.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"getAudioConfig",function(){return z}),_.d(Q,"isHeaderPattern",function(){return W}),_.d(Q,"getHeaderLength",function(){return I}),_.d(Q,"getFullFrameLength",function(){return D}),_.d(Q,"canGetFrameLength",function(){return y}),_.d(Q,"isHeader",function(){return w}),_.d(Q,"canParse",function(){return O}),_.d(Q,"probe",function(){return k}),_.d(Q,"initTrackConfig",function(){return A}),_.d(Q,"getFrameDuration",function(){return T}),_.d(Q,"parseFrameHeader",function(){return h}),_.d(Q,"appendFrame",function(){return o});var Z=_("./src/utils/logger.ts"),B=_("./src/errors.ts"),P=_("./src/events.ts");function z(l,d,C,f){var p,L,b,g,c=navigator.userAgent.toLowerCase(),u=f,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=((d[C+2]&192)>>>6)+1;var x=(d[C+2]&60)>>>2;if(x>a.length-1){l.trigger(P.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return b=(d[C+2]&1)<<2,b|=(d[C+3]&192)>>>6,Z.logger.log("manifest codec:"+f+", ADTS type:"+p+", samplingIndex:"+x),/firefox/i.test(c)?x>=6?(p=5,g=new Array(4),L=x-3):(p=2,g=new Array(2),L=x):c.indexOf("android")!==-1?(p=2,g=new Array(2),L=x):(p=5,g=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&x>=6?L=x-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(x>=6&&b===1||/vivaldi/i.test(c))||!f&&b===1)&&(p=2,g=new Array(2)),L=x)),g[0]=p<<3,g[0]|=(x&14)>>1,g[1]|=(x&1)<<7,g[1]|=b<<3,p===5&&(g[1]|=(L&14)>>1,g[2]=(L&1)<<7,g[2]|=2<<2,g[3]=0),{config:g,samplerate:a[x],channelCount:b,codec:"mp4a.40."+p,manifestCodec:u}}function W(l,d){return l[d]===255&&(l[d+1]&246)===240}function I(l,d){return l[d+1]&1?7:9}function D(l,d){return(l[d+3]&3)<<11|l[d+4]<<3|(l[d+5]&224)>>>5}function y(l,d){return d+5<l.length}function w(l,d){return d+1<l.length&&W(l,d)}function O(l,d){return y(l,d)&&W(l,d)&&D(l,d)<=l.length-d}function k(l,d){if(w(l,d)){var C=I(l,d);if(d+C>=l.length)return!1;var f=D(l,d);if(f<=C)return!1;var p=d+f;return p===l.length||w(l,p)}return!1}function A(l,d,C,f,p){if(!l.samplerate){var L=z(d,C,f,p);if(!L)return;l.config=L.config,l.samplerate=L.samplerate,l.channelCount=L.channelCount,l.codec=L.codec,l.manifestCodec=L.manifestCodec,Z.logger.log("parsed codec:"+l.codec+", rate:"+L.samplerate+", channels:"+L.channelCount)}}function T(l){return 1024*9e4/l}function h(l,d,C,f,p){var L=I(l,d),b=D(l,d);if(b-=L,b>0){var g=C+f*p;return{headerLength:L,frameLength:b,stamp:g}}}function o(l,d,C,f,p){var L=T(l.samplerate),b=h(d,C,f,p,L);if(b){var g=b.frameLength,c=b.headerLength,u=b.stamp,a=c+g,x=Math.max(0,C+a-d.length),v;x?(v=new Uint8Array(a-c),v.set(d.subarray(C+c,d.length),0)):v=d.subarray(C+c,C+a);var E={unit:v,pts:u};return x||l.samples.push(E),{sample:E,length:a,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"initPTSFn",function(){return D});var Z=_("./src/polyfills/number.ts"),B=_("./src/demux/id3.ts"),P=_("./src/demux/dummy-demuxed-track.ts"),z=_("./src/utils/mp4-tools.ts"),W=_("./src/utils/typed-array.ts"),I=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var w=y.prototype;return w.resetInitSegment=function(k,A,T){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},w.resetTimeStamp=function(){},w.resetContiguity=function(){},w.canParse=function(k,A){return!1},w.appendFrame=function(k,A,T){},w.demux=function(k,A){this.cachedData&&(k=Object(z.appendUint8Array)(this.cachedData,k),this.cachedData=null);var T=B.getID3Data(k,0),h=T?T.length:0,o,l,d=this._audioTrack,C=this._id3Track,f=T?B.getTimeStamp(T):void 0,p=k.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=D(f,A)),T&&T.length>0&&C.samples.push({pts:this.initPTS,dts:this.initPTS,data:T}),l=this.initPTS;h<p;){if(this.canParse(k,h)){var L=this.appendFrame(d,k,h);L?(this.frameIndex++,l=L.sample.pts,h+=L.length,o=h):h=p}else B.canParse(k,h)?(T=B.getID3Data(k,h),C.samples.push({pts:l,dts:l,data:T}),h+=T.length,o=h):h++;if(h===p&&o!==p){var b=Object(W.sliceUint8)(k,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,b):this.cachedData=b}}return{audioTrack:d,avcTrack:Object(P.dummyTrack)(),id3Track:C,textTrack:Object(P.dummyTrack)()}},w.demuxSampleAes=function(k,A,T){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},w.flush=function(k){var A=this.cachedData;return A&&(this.cachedData=null,this.demux(A,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(P.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(P.dummyTrack)()}},w.destroy=function(){},y}(),D=function(w,O){return Object(Z.isFiniteNumber)(w)?w*90:O*9e4};Q.default=I},"./src/demux/chunk-cache.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return Z});var Z=function(){function P(){this.chunks=[],this.dataLength=0}var z=P.prototype;return z.push=function(I){this.chunks.push(I),this.dataLength+=I.length},z.flush=function(){var I=this.chunks,D=this.dataLength,y;if(I.length)I.length===1?y=I[0]:y=B(I,D);else return new Uint8Array(0);return this.reset(),y},z.reset=function(){this.chunks.length=0,this.dataLength=0},P}();function B(P,z){for(var W=new Uint8Array(z),I=0,D=0;D<P.length;D++){var y=P[D];W.set(y,I),I+=y.length}return W}},"./src/demux/dummy-demuxed-track.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"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(le,Q,_){"use strict";_.r(Q);var Z=_("./src/utils/logger.ts"),B=function(){function P(W){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=W,this.bytesAvailable=W.byteLength,this.word=0,this.bitsAvailable=0}var z=P.prototype;return z.loadWord=function(){var I=this.data,D=this.bytesAvailable,y=I.byteLength-D,w=new Uint8Array(4),O=Math.min(4,D);if(O===0)throw new Error("no bytes available");w.set(I.subarray(y,y+O)),this.word=new DataView(w.buffer).getUint32(0),this.bitsAvailable=O*8,this.bytesAvailable-=O},z.skipBits=function(I){var D;this.bitsAvailable>I?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,D=I>>3,I-=D>>3,this.bytesAvailable-=D,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},z.readBits=function(I){var D=Math.min(this.bitsAvailable,I),y=this.word>>>32-D;return I>32&&Z.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=D,this.bitsAvailable>0?this.word<<=D:this.bytesAvailable>0&&this.loadWord(),D=I-D,D>0&&this.bitsAvailable?y<<D|this.readBits(D):y},z.skipLZ=function(){var I;for(I=0;I<this.bitsAvailable;++I)if((this.word&2147483648>>>I)!==0)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},z.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>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(I){for(var D=8,y=8,w,O=0;O<I;O++)y!==0&&(w=this.readEG(),y=(D+w+256)%256),D=y===0?D:y},z.readSPS=function(){var I=0,D=0,y=0,w=0,O,k,A,T=this.readUByte.bind(this),h=this.readBits.bind(this),o=this.readUEG.bind(this),l=this.readBoolean.bind(this),d=this.skipBits.bind(this),C=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);T();var L=T();if(h(5),d(3),T(),f(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var b=o();if(b===3&&d(1),f(),f(),d(1),l())for(k=b!==3?8:12,A=0;A<k;A++)l()&&(A<6?p(16):p(64))}f();var g=o();if(g===0)o();else if(g===1)for(d(1),C(),C(),O=o(),A=0;A<O;A++)C();f(),d(1);var c=o(),u=o(),a=h(1);a===0&&d(1),d(1),l()&&(I=o(),D=o(),y=o(),w=o());var x=[1,1];if(l()&&l()){var v=T();switch(v){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:{x=[T()<<8|T(),T()<<8|T()];break}}}return{width:Math.ceil((c+1)*16-I*2-D*2),height:(2-a)*(u+1)*16-(a?2:4)*(y+w),pixelRatio:x}},z.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();Q.default=B},"./src/demux/id3.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"isHeader",function(){return Z}),_.d(Q,"isFooter",function(){return B}),_.d(Q,"getID3Data",function(){return P}),_.d(Q,"canParse",function(){return W}),_.d(Q,"getTimeStamp",function(){return I}),_.d(Q,"isTimeStampFrame",function(){return D}),_.d(Q,"getID3Frames",function(){return w}),_.d(Q,"decodeFrame",function(){return O}),_.d(Q,"utf8ArrayToStr",function(){return o}),_.d(Q,"testables",function(){return l});var Z=function(p,L){return L+10<=p.length&&(p[L]===73&&p[L+1]===68&&p[L+2]===51&&(p[L+3]<255&&p[L+4]<255&&(p[L+6]<128&&p[L+7]<128&&p[L+8]<128&&p[L+9]<128)))},B=function(p,L){return L+10<=p.length&&(p[L]===51&&p[L+1]===68&&p[L+2]===73&&(p[L+3]<255&&p[L+4]<255&&(p[L+6]<128&&p[L+7]<128&&p[L+8]<128&&p[L+9]<128)))},P=function(p,L){for(var b=L,g=0;Z(p,L);){g+=10;var c=z(p,L+6);g+=c,B(p,L+10)&&(g+=10),L+=g}return g>0?p.subarray(b,b+g):void 0},z=function(p,L){var b=0;return b=(p[L]&127)<<21,b|=(p[L+1]&127)<<14,b|=(p[L+2]&127)<<7,b|=p[L+3]&127,b},W=function(p,L){return Z(p,L)&&z(p,L+6)+10<=p.length-L},I=function(p){for(var L=w(p),b=0;b<L.length;b++){var g=L[b];if(D(g))return h(g)}return},D=function(p){return p&&p.key==="PRIV"&&p.info==="com.apple.streaming.transportStreamTimestamp"},y=function(p){var L=String.fromCharCode(p[0],p[1],p[2],p[3]),b=z(p,4),g=10;return{type:L,size:b,data:p.subarray(g,g+b)}},w=function(p){for(var L=0,b=[];Z(p,L);){var g=z(p,L+6);L+=10;for(var c=L+g;L+8<c;){var u=y(p.subarray(L)),a=O(u);a&&b.push(a),L+=u.size+10}B(p,L)&&(L+=10)}return b},O=function(p){return p.type==="PRIV"?k(p):p.type[0]==="W"?T(p):A(p)},k=function(p){if(p.size<2)return;var L=o(p.data,!0),b=new Uint8Array(p.data.subarray(L.length+1));return{key:p.type,info:L,data:b.buffer}},A=function(p){if(p.size<2)return;if(p.type==="TXXX"){var L=1,b=o(p.data.subarray(L),!0);L+=b.length+1;var g=o(p.data.subarray(L));return{key:p.type,info:b,data:g}}var c=o(p.data.subarray(1));return{key:p.type,data:c}},T=function(p){if(p.type==="WXXX"){if(p.size<2)return;var L=1,b=o(p.data.subarray(L),!0);L+=b.length+1;var g=o(p.data.subarray(L));return{key:p.type,info:b,data:g}}var c=o(p.data);return{key:p.type,data:c}},h=function(p){if(p.data.byteLength===8){var L=new Uint8Array(p.data),b=L[3]&1,g=(L[4]<<23)+(L[5]<<15)+(L[6]<<7)+L[7];return g/=45,b&&(g+=4772185884e-2),Math.round(g)}return},o=function(p,L){L===void 0&&(L=!1);var b=C();if(b){var g=b.decode(p);if(L){var c=g.indexOf("\0");return c!==-1?g.substring(0,c):g}return g.replace(/\0/g,"")}for(var u=p.length,a,x,v,E="",N=0;N<u;){if(a=p[N++],a===0&&L)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:x=p[N++],E+=String.fromCharCode((a&31)<<6|x&63);break;case 14:x=p[N++],v=p[N++],E+=String.fromCharCode((a&15)<<12|(x&63)<<6|(v&63)<<0);break;default:}}return E},l={decodeTextFrame:A},d;function C(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/demux/base-audio-demuxer.ts"),B=_("./src/demux/id3.ts"),P=_("./src/utils/logger.ts"),z=_("./src/demux/mpegaudio.ts");function W(y,w){y.prototype=Object.create(w.prototype),y.prototype.constructor=y,I(y,w)}function I(y,w){return I=Object.setPrototypeOf||function(k,A){return k.__proto__=A,k},I(y,w)}var D=function(y){W(w,y);function w(){return y.apply(this,arguments)||this}var O=w.prototype;return O.resetInitSegment=function(A,T,h){y.prototype.resetInitSegment.call(this,A,T,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:A,duration:h,inputTimeScale:9e4,dropped:0}},w.probe=function(A){if(!A)return!1;for(var T=B.getID3Data(A,0)||[],h=T.length,o=A.length;h<o;h++)if(z.probe(A,h))return P.logger.log("MPEG Audio sync word found !"),!0;return!1},O.canParse=function(A,T){return z.canParse(A,T)},O.appendFrame=function(A,T,h){return this.initPTS===null?void 0:z.appendFrame(A,T,h,this.initPTS,this.frameIndex)},w}(Z.default);D.minProbeByteLength=4,Q.default=D},"./src/demux/mp4demuxer.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/utils/mp4-tools.ts"),B=_("./src/demux/dummy-demuxed-track.ts"),P=function(){function z(I,D){this.remainderData=null,this.config=void 0,this.config=D}var W=z.prototype;return W.resetTimeStamp=function(){},W.resetInitSegment=function(){},W.resetContiguity=function(){},z.probe=function(D){return Object(Z.findBox)({data:D,start:0,end:Math.min(D.length,16384)},["moof"]).length>0},W.demux=function(D){var y=D,w=Object(B.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object(Z.appendUint8Array)(this.remainderData,D));var O=Object(Z.segmentValidRange)(y);this.remainderData=O.remainder,w.samples=O.valid||new Uint8Array}else w.samples=y;return{audioTrack:Object(B.dummyTrack)(),avcTrack:w,id3Track:Object(B.dummyTrack)(),textTrack:Object(B.dummyTrack)()}},W.flush=function(){var D=Object(B.dummyTrack)();return D.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(B.dummyTrack)(),avcTrack:D,id3Track:Object(B.dummyTrack)(),textTrack:Object(B.dummyTrack)()}},W.demuxSampleAes=function(D,y,w){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},W.destroy=function(){},z}();P.minProbeByteLength=1024,Q.default=P},"./src/demux/mpegaudio.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"appendFrame",function(){return I}),_.d(Q,"parseHeader",function(){return D}),_.d(Q,"isHeaderPattern",function(){return y}),_.d(Q,"isHeader",function(){return w}),_.d(Q,"canParse",function(){return O}),_.d(Q,"probe",function(){return k});var Z=null,B=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],P=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],z=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],W=[0,1,1,4];function I(A,T,h,o,l){if(h+24>T.length)return;var d=D(T,h);if(d&&h+d.frameLength<=T.length){var C=d.samplesPerFrame*9e4/d.sampleRate,f=o+l*C,p={unit:T.subarray(h,h+d.frameLength),pts:f,dts:f};return A.config=[],A.channelCount=d.channelCount,A.samplerate=d.sampleRate,A.samples.push(p),{sample:p,length:d.frameLength,missing:0}}}function D(A,T){var h=A[T+1]>>3&3,o=A[T+1]>>1&3,l=A[T+2]>>4&15,d=A[T+2]>>2&3;if(h!==1&&l!==0&&l!==15&&d!==3){var C=A[T+2]>>1&1,f=A[T+3]>>6,p=h===3?3-o:o===3?3:4,L=B[p*14+l-1]*1e3,b=h===3?0:h===2?1:2,g=P[b*3+d],c=f===3?1:2,u=z[h][o],a=W[o],x=u*8*a,v=Math.floor(u*L/g+C)*a;if(Z===null){var E=navigator.userAgent||"",N=E.match(/Chrome\/(\d+)/i);Z=N?parseInt(N[1]):0}var F=!!Z&&Z<=87;return F&&o===2&&L>=224e3&&f===0&&(A[T+3]=A[T+3]|128),{sampleRate:g,channelCount:c,frameLength:v,samplesPerFrame:x}}}function y(A,T){return A[T]===255&&(A[T+1]&224)===224&&(A[T+1]&6)!==0}function w(A,T){return T+1<A.length&&y(A,T)}function O(A,T){var h=4;return y(A,T)&&h<=A.length-T}function k(A,T){if(T+1<A.length&&y(A,T)){var h=4,o=D(A,T),l=h;o!=null&&o.frameLength&&(l=o.frameLength);var d=T+l;return d===A.length||w(A,d)}return!1}},"./src/demux/sample-aes.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/crypt/decrypter.ts"),B=_("./src/demux/tsdemuxer.ts"),P=function(){function z(I,D,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new Z.default(I,D,{removePKCS7Padding:!1})}var W=z.prototype;return W.decryptBuffer=function(D,y){this.decrypter.decrypt(D,this.keyData.key.buffer,this.keyData.iv.buffer,y)},W.decryptAacSample=function(D,y,w,O){var k=D[y].unit,A=k.subarray(16,k.length-k.length%16),T=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),h=this;this.decryptBuffer(T,function(o){var l=new Uint8Array(o);k.set(l,16),O||h.decryptAacSamples(D,y+1,w)})},W.decryptAacSamples=function(D,y,w){for(;;y++){if(y>=D.length){w();return}if(D[y].unit.length<32)continue;var O=this.decrypter.isSync();if(this.decryptAacSample(D,y,w,O),!O)return}},W.getAvcEncryptedData=function(D){for(var y=Math.floor((D.length-48)/160)*16+16,w=new Int8Array(y),O=0,k=32;k<=D.length-16;k+=160,O+=16)w.set(D.subarray(k,k+16),O);return w},W.getAvcDecryptedUnit=function(D,y){for(var w=new Uint8Array(y),O=0,k=32;k<=D.length-16;k+=160,O+=16)D.set(w.subarray(O,O+16),k);return D},W.decryptAvcSample=function(D,y,w,O,k,A){var T=Object(B.discardEPB)(k.data),h=this.getAvcEncryptedData(T),o=this;this.decryptBuffer(h.buffer,function(l){k.data=o.getAvcDecryptedUnit(T,l),A||o.decryptAvcSamples(D,y,w+1,O)})},W.decryptAvcSamples=function(D,y,w,O){if(D instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,w=0){if(y>=D.length){O();return}for(var k=D[y].units;!(w>=k.length);w++){var A=k[w];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var T=this.decrypter.isSync();if(this.decryptAvcSample(D,y,w,O,A,T),!T)return}}},z}();Q.default=P},"./src/demux/transmuxer-interface.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return k});var Z=_("./node_modules/webworkify-webpack/index.js"),B=_.n(Z),P=_("./src/events.ts"),z=_("./src/demux/transmuxer.ts"),W=_("./src/utils/logger.ts"),I=_("./src/errors.ts"),D=_("./src/utils/mediasource-helper.ts"),y=_("./node_modules/eventemitter3/index.js"),w=_.n(y),O=Object(D.getMediaSource)()||{isTypeSupported:function(){return!1}},k=function(){function A(h,o,l,d){var C=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=h,this.id=o,this.onTransmuxComplete=l,this.onFlush=d;var f=h.config,p=function(u,a){a=a||{},a.frag=C.frag,a.id=C.id,h.trigger(u,a)};this.observer=new y.EventEmitter,this.observer.on(P.Events.FRAG_DECRYPTED,p),this.observer.on(P.Events.ERROR,p);var L={mp4:O.isTypeSupported("video/mp4"),mpeg:O.isTypeSupported("audio/mpeg"),mp3:O.isTypeSupported('audio/mp4; codecs="mp3"')},b=navigator.vendor;if(f.enableWorker&&typeof Worker!="undefined"){W.logger.log("demuxing in webworker");var g;try{g=this.worker=Z("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){h.trigger(P.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:L,vendor:b,id:o,config:JSON.stringify(f)})}catch(c){W.logger.warn("Error in worker:",c),W.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new z.default(this.observer,L,f,b,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,L,f,b,o)}var T=A.prototype;return T.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 d=this.observer;d&&d.removeAllListeners(),this.observer=null},T.push=function(o,l,d,C,f,p,L,b,g,c){var u=this;g.transmuxing.start=self.performance.now();var a=this.transmuxer,x=this.worker,v=p?p.start:f.start,E=f.decryptdata,N=this.frag,F=!(N&&f.cc===N.cc),K=!(N&&g.level===N.level),V=N?g.sn-N.sn:-1,R=this.part?g.part-this.part.index:1,M=!K&&(V===1||V===0&&R===1),$=self.performance.now();(K||V||f.stats.parsing.start===0)&&(f.stats.parsing.start=$),p&&(R||!M)&&(p.stats.parsing.start=$);var ee=new z.TransmuxState(F,M,b,K,v);if(!M||F){W.logger.log("[transmuxer-interface, "+f.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
discontinuity: `+F+`
trackSwitch: `+K+`
contiguous: `+M+`
accurateTimeOffset: `+b+`
timeOffset: `+v);var ae=new z.TransmuxConfig(d,C,l,L,c);this.configureTransmuxer(ae)}if(this.frag=f,this.part=p,x)x.postMessage({cmd:"demux",data:o,decryptdata:E,chunkMeta:g,state:ee},o instanceof ArrayBuffer?[o]:[]);else if(a){var fe=a.push(o,E,g,ee);Object(z.isPromise)(fe)?fe.then(function(De){u.handleTransmuxComplete(De)}):this.handleTransmuxComplete(fe)}},T.flush=function(o){var l=this;o.transmuxing.start=self.performance.now();var d=this.transmuxer,C=this.worker;if(C)C.postMessage({cmd:"flush",chunkMeta:o});else if(d){var f=d.flush(o);Object(z.isPromise)(f)?f.then(function(p){l.handleFlushResult(p,o)}):this.handleFlushResult(f,o)}},T.handleFlushResult=function(o,l){var d=this;o.forEach(function(C){d.handleTransmuxComplete(C)}),this.onFlush(l)},T.onWorkerMessage=function(o){var l=o.data,d=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,d.trigger(l.event,l.data);break}}},T.configureTransmuxer=function(o){var l=this.worker,d=this.transmuxer;l?l.postMessage({cmd:"configure",config:o}):d&&d.configure(o)},T.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},A}()},"./src/demux/transmuxer-worker.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return I});var Z=_("./src/demux/transmuxer.ts"),B=_("./src/events.ts"),P=_("./src/utils/logger.ts"),z=_("./node_modules/eventemitter3/index.js"),W=_.n(z);function I(k){var A=new z.EventEmitter,T=function(o,l){k.postMessage({event:o,data:l})};A.on(B.Events.FRAG_DECRYPTED,T),A.on(B.Events.ERROR,T),k.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var l=JSON.parse(o.config);k.transmuxer=new Z.default(A,o.typeSupported,l,o.vendor,o.id),Object(P.enableLogs)(l.debug),T("init",null);break}case"configure":{k.transmuxer.configure(o.config);break}case"demux":{var d=k.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(Z.isPromise)(d)?d.then(function(p){D(k,p)}):D(k,d);break}case"flush":{var C=o.chunkMeta,f=k.transmuxer.flush(C);Object(Z.isPromise)(f)?f.then(function(p){w(k,p,C)}):w(k,f,C);break}default:break}})}function D(k,A){if(O(A.remuxResult))return;var T=[],h=A.remuxResult,o=h.audio,l=h.video;o&&y(T,o),l&&y(T,l),k.postMessage({event:"transmuxComplete",data:A},T)}function y(k,A){A.data1&&k.push(A.data1.buffer),A.data2&&k.push(A.data2.buffer)}function w(k,A,T){A.forEach(function(h){D(k,h)}),k.postMessage({event:"flush",data:T})}function O(k){return!k.audio&&!k.video&&!k.text&&!k.id3&&!k.initSegment}},"./src/demux/transmuxer.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return l}),_.d(Q,"isPromise",function(){return f}),_.d(Q,"TransmuxConfig",function(){return p}),_.d(Q,"TransmuxState",function(){return L});var Z=_("./src/events.ts"),B=_("./src/errors.ts"),P=_("./src/crypt/decrypter.ts"),z=_("./src/demux/aacdemuxer.ts"),W=_("./src/demux/mp4demuxer.ts"),I=_("./src/demux/tsdemuxer.ts"),D=_("./src/demux/mp3demuxer.ts"),y=_("./src/remux/mp4-remuxer.ts"),w=_("./src/remux/passthrough-remuxer.ts"),O=_("./src/demux/chunk-cache.ts"),k=_("./src/utils/mp4-tools.ts"),A=_("./src/utils/logger.ts"),T;try{T=self.performance.now.bind(self.performance)}catch(b){A.logger.debug("Unable to use Performance API on this environment"),T=self.Date.now}var h=[{demux:I.default,remux:y.default},{demux:W.default,remux:w.default},{demux:z.default,remux:y.default},{demux:D.default,remux:y.default}],o=1024;h.forEach(function(b){var g=b.demux;o=Math.max(o,g.minProbeByteLength)});var l=function(){function b(c,u,a,x,v){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new O.default,this.observer=c,this.typeSupported=u,this.config=a,this.vendor=x,this.id=v}var g=b.prototype;return g.configure=function(u){this.transmuxConfig=u,this.decrypter&&this.decrypter.reset()},g.push=function(u,a,x,v){var E=this,N=x.transmuxing;N.executeStart=T();var F=new Uint8Array(u),K=this.cache,V=this.config,R=this.currentTransmuxState,M=this.transmuxConfig;v&&(this.currentTransmuxState=v);var $=d(F,a);if($&&$.method==="AES-128"){var ee=this.getDecrypter();if(V.enableSoftwareAES){var ae=ee.softwareDecrypt(F,$.key.buffer,$.iv.buffer);if(!ae)return N.executeEnd=T(),C(x);F=new Uint8Array(ae)}else return this.decryptionPromise=ee.webCryptoDecrypt(F,$.key.buffer,$.iv.buffer).then(function(Oe){var Me=E.push(Oe,null,x);return E.decryptionPromise=null,Me}),this.decryptionPromise}var fe=v||R,De=fe.contiguous,Se=fe.discontinuity,Ce=fe.trackSwitch,we=fe.accurateTimeOffset,Te=fe.timeOffset,me=M.audioCodec,he=M.videoCodec,te=M.defaultInitPts,de=M.duration,ne=M.initSegmentData;if((Se||Ce)&&this.resetInitSegment(ne,me,he,de),Se&&this.resetInitialTimestamp(te),De||this.resetContiguity(),this.needsProbing(F,Se,Ce)){if(K.dataLength){var Le=K.flush();F=Object(k.appendUint8Array)(Le,F)}this.configureTransmuxer(F,M)}var Re=this.transmux(F,$,Te,we,x),xe=this.currentTransmuxState;return xe.contiguous=!0,xe.discontinuity=!1,xe.trackSwitch=!1,N.executeEnd=T(),Re},g.flush=function(u){var a=this,x=u.transmuxing;x.executeStart=T();var v=this.decrypter,E=this.cache,N=this.currentTransmuxState,F=this.decryptionPromise;if(F)return F.then(function(){return a.flush(u)});var K=[],V=N.timeOffset;if(v){var R=v.flush();R&&K.push(this.push(R,null,u))}var M=E.dataLength;E.reset();var $=this.demuxer,ee=this.remuxer;if(!$||!ee)return M>=o&&this.observer.emit(Z.Events.ERROR,Z.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=T(),[C(u)];var ae=$.flush(V);return f(ae)?ae.then(function(fe){return a.flushRemux(K,fe,u),K}):(this.flushRemux(K,ae,u),K)},g.flushRemux=function(u,a,x){var v=a.audioTrack,E=a.avcTrack,N=a.id3Track,F=a.textTrack,K=this.currentTransmuxState,V=K.accurateTimeOffset,R=K.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var M=this.remuxer.remux(v,E,N,F,R,V,!0,this.id);u.push({remuxResult:M,chunkMeta:x}),x.transmuxing.executeEnd=T()},g.resetInitialTimestamp=function(u){var a=this.demuxer,x=this.remuxer;if(!a||!x)return;a.resetTimeStamp(u),x.resetTimeStamp(u)},g.resetContiguity=function(){var u=this.demuxer,a=this.remuxer;if(!u||!a)return;u.resetContiguity(),a.resetNextTimestamp()},g.resetInitSegment=function(u,a,x,v){var E=this.demuxer,N=this.remuxer;if(!E||!N)return;E.resetInitSegment(a,x,v),N.resetInitSegment(u,a,x)},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(u,a,x,v,E){var N;return a&&a.method==="SAMPLE-AES"?N=this.transmuxSampleAes(u,a,x,v,E):N=this.transmuxUnencrypted(u,x,v,E),N},g.transmuxUnencrypted=function(u,a,x,v){var E=this.demuxer.demux(u,a,!1,!this.config.progressive),N=E.audioTrack,F=E.avcTrack,K=E.id3Track,V=E.textTrack,R=this.remuxer.remux(N,F,K,V,a,x,!1,this.id);return{remuxResult:R,chunkMeta:v}},g.transmuxSampleAes=function(u,a,x,v,E){var N=this;return this.demuxer.demuxSampleAes(u,a,x).then(function(F){var K=N.remuxer.remux(F.audioTrack,F.avcTrack,F.id3Track,F.textTrack,x,v,!1,N.id);return{remuxResult:K,chunkMeta:E}})},g.configureTransmuxer=function(u,a){for(var x=this.config,v=this.observer,E=this.typeSupported,N=this.vendor,F=a.audioCodec,K=a.defaultInitPts,V=a.duration,R=a.initSegmentData,M=a.videoCodec,$,ee=0,ae=h.length;ee<ae;ee++)if(h[ee].demux.probe(u)){$=h[ee];break}$||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),$={demux:W.default,remux:w.default});var fe=this.demuxer,De=this.remuxer,Se=$.remux,Ce=$.demux;(!De||!(De instanceof Se))&&(this.remuxer=new Se(v,x,E,N)),(!fe||!(fe instanceof Ce))&&(this.demuxer=new Ce(v,x,E),this.probe=Ce.probe),this.resetInitSegment(R,F,M,V),this.resetInitialTimestamp(K)},g.needsProbing=function(u,a,x){return!this.demuxer||!this.remuxer||a||x},g.getDecrypter=function(){var u=this.decrypter;return u||(u=this.decrypter=new P.default(this.observer,this.config)),u},b}();function d(b,g){var c=null;return b.byteLength>0&&g!=null&&g.key!=null&&g.iv!==null&&g.method!=null&&(c=g),c}var C=function(g){return{remuxResult:{},chunkMeta:g}};function f(b){return"then"in b&&b.then instanceof Function}var p=function(g,c,u,a,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=g,this.videoCodec=c,this.initSegmentData=u,this.duration=a,this.defaultInitPts=x},L=function(g,c,u,a,x){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=g,this.contiguous=c,this.accurateTimeOffset=u,this.trackSwitch=a,this.timeOffset=x}},"./src/demux/tsdemuxer.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"discardEPB",function(){return C});var Z=_("./src/demux/adts.ts"),B=_("./src/demux/mpegaudio.ts"),P=_("./src/demux/exp-golomb.ts"),z=_("./src/demux/id3.ts"),W=_("./src/demux/sample-aes.ts"),I=_("./src/events.ts"),D=_("./src/utils/mp4-tools.ts"),y=_("./src/utils/logger.ts"),w=_("./src/errors.ts"),O={video:1,audio:2,id3:3,text:4},k=function(){function f(L,b,g){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=L,this.config=b,this.typeSupported=g}f.probe=function(b){var g=f.syncOffset(b);return g<0?!1:(g&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),!0)},f.syncOffset=function(b){for(var g=Math.min(1e3,b.length-3*188),c=0;c<g;){if(b[c]===71&&b[c+188]===71&&b[c+2*188]===71)return c;c++}return-1},f.createTrack=function(b,g){return{container:b==="video"||b==="audio"?"video/mp2t":void 0,type:b,id:O[b],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:b==="audio"?g:void 0}};var p=f.prototype;return p.resetInitSegment=function(b,g,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=f.createTrack("video",c),this._audioTrack=f.createTrack("audio",c),this._id3Track=f.createTrack("id3",c),this._txtTrack=f.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=b,this.videoCodec=g,this._duration=c},p.resetTimeStamp=function(){},p.resetContiguity=function(){var b=this._audioTrack,g=this._avcTrack,c=this._id3Track;b&&(b.pesData=null),g&&(g.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},p.demux=function(b,g,c,u){c===void 0&&(c=!1),u===void 0&&(u=!1),c||(this.sampleAes=null);var a,x=this._avcTrack,v=this._audioTrack,E=this._id3Track,N=x.pid,F=x.pesData,K=v.pid,V=E.pid,R=v.pesData,M=E.pesData,$=!1,ee=this.pmtParsed,ae=this._pmtId,fe=b.length;if(this.remainderData&&(b=Object(D.appendUint8Array)(this.remainderData,b),fe=b.length,this.remainderData=null),fe<188&&!u)return this.remainderData=b,{audioTrack:v,avcTrack:x,id3Track:E,textTrack:this._txtTrack};var De=Math.max(0,f.syncOffset(b));fe-=(fe+De)%188,fe<b.byteLength&&!u&&(this.remainderData=new Uint8Array(b.buffer,fe,b.buffer.byteLength-fe));for(var Se=De;Se<fe;Se+=188)if(b[Se]===71){var Ce=!!(b[Se+1]&64),we=((b[Se+1]&31)<<8)+b[Se+2],Te=(b[Se+3]&48)>>4,me=void 0;if(Te>1){if(me=Se+5+b[Se+4],me===Se+188)continue}else me=Se+4;switch(we){case N:Ce&&(F&&(a=o(F))&&this.parseAVCPES(a,!1),F={data:[],size:0}),F&&(F.data.push(b.subarray(me,Se+188)),F.size+=Se+188-me);break;case K:Ce&&(R&&(a=o(R))&&(v.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),R={data:[],size:0}),R&&(R.data.push(b.subarray(me,Se+188)),R.size+=Se+188-me);break;case V:Ce&&(M&&(a=o(M))&&this.parseID3PES(a),M={data:[],size:0}),M&&(M.data.push(b.subarray(me,Se+188)),M.size+=Se+188-me);break;case 0:Ce&&(me+=b[me]+1),ae=this._pmtId=T(b,me);break;case ae:{Ce&&(me+=b[me]+1);var he=h(b,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);N=he.avc,N>0&&(x.pid=N),K=he.audio,K>0&&(v.pid=K,v.isAAC=he.isAAC),V=he.id3,V>0&&(E.pid=V),$&&!ee&&(y.logger.log("reparse from beginning"),$=!1,Se=De-188),ee=this.pmtParsed=!0;break}case 17:case 8191:break;default:$=!0;break}}else this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});x.pesData=F,v.pesData=R,E.pesData=M;var te={audioTrack:v,avcTrack:x,id3Track:E,textTrack:this._txtTrack};return u&&this.extractRemainingSamples(te),te},p.flush=function(){var b=this.remainderData;this.remainderData=null;var g;return b?g=this.demux(b,-1,!1,!0):g={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},p.extractRemainingSamples=function(b){var g=b.audioTrack,c=b.avcTrack,u=b.id3Track,a=c.pesData,x=g.pesData,v=u.pesData,E;a&&(E=o(a))?(this.parseAVCPES(E,!0),c.pesData=null):c.pesData=a,x&&(E=o(x))?(g.isAAC?this.parseAACPES(E):this.parseMPEGPES(E),g.pesData=null):(x!=null&&x.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),g.pesData=x),v&&(E=o(v))?(this.parseID3PES(E),u.pesData=null):u.pesData=v},p.demuxSampleAes=function(b,g,c){var u=this.demux(b,c,!0,!this.config.progressive),a=this.sampleAes=new W.default(this.observer,this.config,g);return this.decrypt(u,a)},p.decrypt=function(b,g){return new Promise(function(c){var u=b.audioTrack,a=b.avcTrack;u.samples&&u.isAAC?g.decryptAacSamples(u.samples,0,function(){a.samples?g.decryptAvcSamples(a.samples,0,0,function(){c(b)}):c(b)}):a.samples&&g.decryptAvcSamples(a.samples,0,0,function(){c(b)})})},p.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},p.parseAVCPES=function(b,g){var c=this,u=this._avcTrack,a=this.parseAVCNALu(b.data),x=!1,v=this.avcSample,E,N=!1;b.data=null,v&&a.length&&!u.audFound&&(l(v,u),v=this.avcSample=A(!1,b.pts,b.dts,"")),a.forEach(function(F){switch(F.type){case 1:{E=!0,v||(v=c.avcSample=A(!0,b.pts,b.dts,"")),x&&(v.debug+="NDR "),v.frame=!0;var K=F.data;if(N&&K.length>4){var V=new P.default(K).readSliceType();(V===2||V===4||V===7||V===9)&&(v.key=!0)}break}case 5:E=!0,v||(v=c.avcSample=A(!0,b.pts,b.dts,"")),x&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{E=!0,x&&v&&(v.debug+="SEI ");var R=new P.default(C(F.data));R.readUByte();for(var M=0,$=0,ee=!1,ae=0;!ee&&R.bytesAvailable>1;){M=0;do ae=R.readUByte(),M+=ae;while(ae===255);$=0;do ae=R.readUByte(),$+=ae;while(ae===255);if(M===4&&R.bytesAvailable!==0){ee=!0;var fe=R.readUByte();if(fe===181){var De=R.readUShort();if(De===49){var Se=R.readUInt();if(Se===1195456820){var Ce=R.readUByte();if(Ce===3){for(var we=R.readUByte(),Te=R.readUByte(),me=31&we,he=[we,Te],te=0;te<me;te++)he.push(R.readUByte()),he.push(R.readUByte()),he.push(R.readUByte());d(c._txtTrack.samples,{type:3,pts:b.pts,bytes:he})}}}}}else if(M===5&&R.bytesAvailable!==0){if(ee=!0,$>16){for(var de=[],ne=0;ne<16;ne++)de.push(R.readUByte().toString(16)),(ne===3||ne===5||ne===7||ne===9)&&de.push("-");for(var Le=$-16,Re=new Uint8Array(Le),xe=0;xe<Le;xe++)Re[xe]=R.readUByte();d(c._txtTrack.samples,{pts:b.pts,payloadType:M,uuid:de.join(""),userData:Object(z.utf8ArrayToStr)(Re),userDataBytes:Re})}}else if($<R.bytesAvailable)for(var Oe=0;Oe<$;Oe++)R.readUByte()}break}case 7:if(E=!0,N=!0,x&&v&&(v.debug+="SPS "),!u.sps){var Me=new P.default(F.data),He=Me.readSPS();u.width=He.width,u.height=He.height,u.pixelRatio=He.pixelRatio,u.sps=[F.data],u.duration=c._duration;for(var We=F.data.subarray(1,4),Fe="avc1.",Be=0;Be<3;Be++){var tt=We[Be].toString(16);tt.length<2&&(tt="0"+tt),Fe+=tt}u.codec=Fe}break;case 8:E=!0,x&&v&&(v.debug+="PPS "),u.pps||(u.pps=[F.data]);break;case 9:E=!1,u.audFound=!0,v&&l(v,u),v=c.avcSample=A(!1,b.pts,b.dts,x?"AUD ":"");break;case 12:E=!1;break;default:E=!1,v&&(v.debug+="unknown NAL "+F.type+" ");break}if(v&&E){var qe=v.units;qe.push(F)}}),g&&v&&(l(v,u),this.avcSample=null)},p.getLastNalUnit=function(){var b,g=this.avcSample,c;if(!g||g.units.length===0){var u=this._avcTrack.samples;g=u[u.length-1]}if((b=g)!==null&&b!==void 0&&b.units){var a=g.units;c=a[a.length-1]}return c},p.parseAVCNALu=function(b){var g=b.byteLength,c=this._avcTrack,u=c.naluState||0,a=u,x=[],v=0,E,N,F,K=-1,V=0;for(u===-1&&(K=0,V=b[0]&31,u=0,v=1);v<g;){if(E=b[v++],!u){u=E?0:1;continue}if(u===1){u=E?0:2;continue}if(!E)u=3;else if(E===1){if(K>=0){var R={data:b.subarray(K,v-u-1),type:V};x.push(R)}else{var M=this.getLastNalUnit();if(M&&(a&&v<=4-a&&(M.state&&(M.data=M.data.subarray(0,M.data.byteLength-a))),N=v-u-1,N>0)){var $=new Uint8Array(M.data.byteLength+N);$.set(M.data,0),$.set(b.subarray(0,N),M.data.byteLength),M.data=$,M.state=0}}v<g?(F=b[v]&31,K=v,V=F,u=0):u=-1}else u=0}if(K>=0&&u>=0){var ee={data:b.subarray(K,g),type:V,state:u};x.push(ee)}if(x.length===0){var ae=this.getLastNalUnit();if(ae){var fe=new Uint8Array(ae.data.byteLength+b.byteLength);fe.set(ae.data,0),fe.set(b,ae.data.byteLength),ae.data=fe}}return c.naluState=u,x},p.parseAACPES=function(b){var g=0,c=this._audioTrack,u=this.aacOverFlow,a=b.data;if(u){this.aacOverFlow=null;var x=u.sample.unit.byteLength,v=Math.min(u.missing,x),E=x-v;u.sample.unit.set(a.subarray(0,v),E),c.samples.push(u.sample),g=u.missing}var N,F;for(N=g,F=a.length;N<F-1&&!Z.isHeader(a,N);N++);if(N!==g){var K,V;if(N<F-1?(K="AAC PES did not start with ADTS header,offset:"+N,V=!1):(K="no ADTS header found in AAC PES",V=!0),y.logger.warn("parsing error:"+K),this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:K}),V)return}Z.initTrackConfig(c,this.observer,a,N,this.audioCodec);var R;if(b.pts!==void 0)R=b.pts;else if(u){var M=Z.getFrameDuration(c.samplerate);R=u.sample.pts+M}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var $=0;N<F;)if(Z.isHeader(a,N)){if(N+5<F){var ee=Z.appendFrame(c,a,N,R,$);if(ee)if(ee.missing)this.aacOverFlow=ee;else{N+=ee.length,$++;continue}}break}else N++},p.parseMPEGPES=function(b){var g=b.data,c=g.length,u=0,a=0,x=b.pts;if(x===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(B.isHeader(g,a)){var v=B.appendFrame(this._audioTrack,g,a,x,u);if(v)a+=v.length,u++;else break}else a++},p.parseID3PES=function(b){if(b.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(b)},f}();k.minProbeByteLength=188;function A(f,p,L,b){return{key:f,frame:!1,pts:p,dts:L,units:[],debug:b,length:0}}function T(f,p){return(f[p+10]&31)<<8|f[p+11]}function h(f,p,L,b){var g={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(f[p+1]&15)<<8|f[p+2],u=p+3+c-4,a=(f[p+10]&15)<<8|f[p+11];for(p+=12+a;p<u;){var x=(f[p+1]&31)<<8|f[p+2];switch(f[p]){case 207:if(!b){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:g.audio===-1&&(g.audio=x);break;case 21:g.id3===-1&&(g.id3=x);break;case 219:if(!b){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:g.avc===-1&&(g.avc=x);break;case 3:case 4:L?g.audio===-1&&(g.audio=x,g.isAAC=!1):y.logger.log("MPEG audio found, not supported in this browser");break;case 36:y.logger.warn("Unsupported HEVC stream type found");break;default:break}p+=((f[p+3]&15)<<8|f[p+4])+5}return g}function o(f){var p=0,L,b,g,c,u,a=f.data;if(!f||f.size===0)return null;for(;a[0].length<19&&a.length>1;){var x=new Uint8Array(a[0].length+a[1].length);x.set(a[0]),x.set(a[1],a[0].length),a[0]=x,a.splice(1,1)}L=a[0];var v=(L[0]<<16)+(L[1]<<8)+L[2];if(v===1){if(b=(L[4]<<8)+L[5],b&&b>f.size-6)return null;var E=L[7];E&192&&(c=(L[9]&14)*536870912+(L[10]&255)*4194304+(L[11]&254)*16384+(L[12]&255)*128+(L[13]&254)/2,E&64?(u=(L[14]&14)*536870912+(L[15]&255)*4194304+(L[16]&254)*16384+(L[17]&255)*128+(L[18]&254)/2,c-u>60*9e4&&(y.logger.warn(Math.round((c-u)/9e4)+"s delta between PTS and DTS, align them"),c=u)):u=c),g=L[8];var N=g+9;if(f.size<=N)return null;f.size-=N;for(var F=new Uint8Array(f.size),K=0,V=a.length;K<V;K++){L=a[K];var R=L.byteLength;if(N)if(N>R){N-=R;continue}else L=L.subarray(N),R-=N,N=0;F.set(L,p),p+=R}return b&&(b-=g+3),{data:F,pts:c,dts:u,len:b}}return null}function l(f,p){if(f.units.length&&f.frame){if(f.pts===void 0){var L=p.samples,b=L.length;if(b){var g=L[b-1];f.pts=g.pts,f.dts=g.dts}else{p.dropped++;return}}p.samples.push(f)}f.debug.length&&y.logger.log(f.pts+"/"+f.dts+":"+f.debug)}function d(f,p){var L=f.length;if(L>0){if(p.pts>=f[L-1].pts)f.push(p);else for(var b=L-1;b>=0;b--)if(p.pts<f[b].pts){f.splice(b,0,p);break}}else f.push(p)}function C(f){for(var p=f.byteLength,L=[],b=1;b<p-2;)f[b]===0&&f[b+1]===0&&f[b+2]===3?(L.push(b+2),b+=2):b++;if(L.length===0)return f;var g=p-L.length,c=new Uint8Array(g),u=0;for(b=0;b<g;u++,b++)u===L[0]&&(u++,L.shift()),c[b]=f[u];return c}Q.default=k},"./src/errors.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"ErrorTypes",function(){return Z}),_.d(Q,"ErrorDetails",function(){return B});var Z;(function(P){P.NETWORK_ERROR="networkError",P.MEDIA_ERROR="mediaError",P.KEY_SYSTEM_ERROR="keySystemError",P.MUX_ERROR="muxError",P.OTHER_ERROR="otherError"})(Z||(Z={}));var B;(function(P){P.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",P.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",P.KEY_SYSTEM_NO_SESSION="keySystemNoSession",P.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",P.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",P.MANIFEST_LOAD_ERROR="manifestLoadError",P.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",P.MANIFEST_PARSING_ERROR="manifestParsingError",P.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",P.LEVEL_EMPTY_ERROR="levelEmptyError",P.LEVEL_LOAD_ERROR="levelLoadError",P.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",P.LEVEL_SWITCH_ERROR="levelSwitchError",P.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",P.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",P.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",P.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",P.FRAG_LOAD_ERROR="fragLoadError",P.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",P.FRAG_DECRYPT_ERROR="fragDecryptError",P.FRAG_PARSING_ERROR="fragParsingError",P.REMUX_ALLOC_ERROR="remuxAllocError",P.KEY_LOAD_ERROR="keyLoadError",P.KEY_LOAD_TIMEOUT="keyLoadTimeOut",P.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",P.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",P.BUFFER_APPEND_ERROR="bufferAppendError",P.BUFFER_APPENDING_ERROR="bufferAppendingError",P.BUFFER_STALLED_ERROR="bufferStalledError",P.BUFFER_FULL_ERROR="bufferFullError",P.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",P.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",P.INTERNAL_EXCEPTION="internalException",P.INTERNAL_ABORTED="aborted",P.UNKNOWN="unknown"})(B||(B={}))},"./src/events.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"Events",function(){return Z});var Z;(function(B){B.MEDIA_ATTACHING="hlsMediaAttaching",B.MEDIA_ATTACHED="hlsMediaAttached",B.MEDIA_DETACHING="hlsMediaDetaching",B.MEDIA_DETACHED="hlsMediaDetached",B.BUFFER_RESET="hlsBufferReset",B.BUFFER_CODECS="hlsBufferCodecs",B.BUFFER_CREATED="hlsBufferCreated",B.BUFFER_APPENDING="hlsBufferAppending",B.BUFFER_APPENDED="hlsBufferAppended",B.BUFFER_EOS="hlsBufferEos",B.BUFFER_FLUSHING="hlsBufferFlushing",B.BUFFER_FLUSHED="hlsBufferFlushed",B.MANIFEST_LOADING="hlsManifestLoading",B.MANIFEST_LOADED="hlsManifestLoaded",B.MANIFEST_PARSED="hlsManifestParsed",B.LEVEL_SWITCHING="hlsLevelSwitching",B.LEVEL_SWITCHED="hlsLevelSwitched",B.LEVEL_LOADING="hlsLevelLoading",B.LEVEL_LOADED="hlsLevelLoaded",B.LEVEL_UPDATED="hlsLevelUpdated",B.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",B.LEVELS_UPDATED="hlsLevelsUpdated",B.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",B.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",B.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",B.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",B.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",B.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",B.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",B.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",B.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",B.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",B.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",B.CUES_PARSED="hlsCuesParsed",B.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",B.INIT_PTS_FOUND="hlsInitPtsFound",B.FRAG_LOADING="hlsFragLoading",B.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",B.FRAG_LOADED="hlsFragLoaded",B.FRAG_DECRYPTED="hlsFragDecrypted",B.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",B.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",B.FRAG_PARSING_METADATA="hlsFragParsingMetadata",B.FRAG_PARSED="hlsFragParsed",B.FRAG_BUFFERED="hlsFragBuffered",B.FRAG_CHANGED="hlsFragChanged",B.FPS_DROP="hlsFpsDrop",B.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",B.ERROR="hlsError",B.DESTROYING="hlsDestroying",B.KEY_LOADING="hlsKeyLoading",B.KEY_LOADED="hlsKeyLoaded",B.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",B.BACK_BUFFER_REACHED="hlsBackBufferReached"})(Z||(Z={}))},"./src/hls.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return f});var Z=_("./node_modules/url-toolkit/src/url-toolkit.js"),B=_.n(Z),P=_("./src/loader/playlist-loader.ts"),z=_("./src/loader/key-loader.ts"),W=_("./src/controller/id3-track-controller.ts"),I=_("./src/controller/latency-controller.ts"),D=_("./src/controller/level-controller.ts"),y=_("./src/controller/fragment-tracker.ts"),w=_("./src/controller/stream-controller.ts"),O=_("./src/is-supported.ts"),k=_("./src/utils/logger.ts"),A=_("./src/config.ts"),T=_("./node_modules/eventemitter3/index.js"),h=_.n(T),o=_("./src/events.ts"),l=_("./src/errors.ts");function d(p,L){for(var b=0;b<L.length;b++){var g=L[b];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}function C(p,L,b){return L&&d(p.prototype,L),b&&d(p,b),p}var f=function(){p.isSupported=function(){return Object(O.isSupported)()};function p(b){b===void 0&&(b={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new T.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var g=this.config=Object(A.mergeConfig)(p.DefaultConfig,b);this.userConfig=b,Object(k.enableLogs)(g.debug),this._autoLevelCapping=-1,g.progressive&&Object(A.enableStreamingMode)(g);var c=g.abrController,u=g.bufferController,a=g.capLevelController,x=g.fpsController,v=this.abrController=new c(this),E=this.bufferController=new u(this),N=this.capLevelController=new a(this),F=new x(this),K=new P.default(this),V=new z.default(this),R=new W.default(this),M=this.levelController=new D.default(this),$=new y.FragmentTracker(this),ee=this.streamController=new w.default(this,$);N.setStreamController(ee),F.setStreamController(ee);var ae=[M,ee];this.networkControllers=ae;var fe=[K,V,v,E,N,F,R,$];this.audioTrackController=this.createController(g.audioTrackController,null,ae),this.createController(g.audioStreamController,$,ae),this.subtitleTrackController=this.createController(g.subtitleTrackController,null,ae),this.createController(g.subtitleStreamController,$,ae),this.createController(g.timelineController,null,fe),this.emeController=this.createController(g.emeController,null,fe),this.cmcdController=this.createController(g.cmcdController,null,fe),this.latencyController=this.createController(I.default,null,fe),this.coreComponents=fe}var L=p.prototype;return L.createController=function(g,c,u){if(g){var a=c?new g(this,c):new g(this);return u&&u.push(a),a}return null},L.on=function(g,c,u){u===void 0&&(u=this),this._emitter.on(g,c,u)},L.once=function(g,c,u){u===void 0&&(u=this),this._emitter.once(g,c,u)},L.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},L.off=function(g,c,u,a){u===void 0&&(u=this),this._emitter.off(g,c,u,a)},L.listeners=function(g){return this._emitter.listeners(g)},L.emit=function(g,c,u){return this._emitter.emit(g,c,u)},L.trigger=function(g,c){if(this.config.debug)return this.emit(g,g,c);try{return this.emit(g,g,c)}catch(u){k.logger.error("An internal error happened while handling event "+g+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(o.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:u})}return!1},L.listenerCount=function(g){return this._emitter.listenerCount(g)},L.destroy=function(){k.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},L.attachMedia=function(g){k.logger.log("attachMedia"),this._media=g,this.trigger(o.Events.MEDIA_ATTACHING,{media:g})},L.detachMedia=function(){k.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(g){this.stopLoad();var c=this.media,u=this.url,a=this.url=Z.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});k.logger.log("loadSource:"+a),c&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:g})},L.startLoad=function(g){g===void 0&&(g=-1),k.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(c){c.startLoad(g)})},L.stopLoad=function(){k.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},L.swapAudioCodec=function(){k.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},L.recoverMediaError=function(){k.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},L.removeLevel=function(g,c){c===void 0&&(c=0),this.levelController.removeLevel(g,c)},C(p,[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){k.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){k.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){k.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){k.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){k.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var c=!!g;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(k.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,c=this.config.minAutoBitrate;if(!g)return 0;for(var u=g.length,a=0;a<u;a++)if(g[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,c=this.autoLevelCapping,u;return c===-1&&g&&g.length?u=g.length-1:u=c,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var c=this.audioTrackController;c&&(c.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return g?g.subtitleDisplay:!1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:A.hlsDefaultConfig},set:function(g){p.defaultConfig=g}}]),p}();f.defaultConfig=void 0},"./src/is-supported.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"isSupported",function(){return P}),_.d(Q,"changeTypeSupported",function(){return z});var Z=_("./src/utils/mediasource-helper.ts");function B(){return self.SourceBuffer||self.WebKitSourceBuffer}function P(){var W=Object(Z.getMediaSource)();if(!W)return!1;var I=B(),D=W&&typeof W.isTypeSupported=="function"&&W.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!I||I.prototype&&typeof I.prototype.appendBuffer=="function"&&typeof I.prototype.remove=="function";return!!D&&!!y}function z(){var W,I=B();return typeof(I==null||((W=I.prototype)===null||W===void 0)?void 0:W.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return k}),_.d(Q,"LoadError",function(){return T});var Z=_("./src/polyfills/number.ts"),B=_("./src/errors.ts");function P(h,o){h.prototype=Object.create(o.prototype),h.prototype.constructor=h,y(h,o)}function z(h){var o=typeof Map=="function"?new Map:void 0;return z=function(d){if(d===null||!D(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(d))return o.get(d);o.set(d,C)}function C(){return W(d,arguments,w(this).constructor)}return C.prototype=Object.create(d.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),y(C,d)},z(h)}function W(h,o,l){return I()?W=Reflect.construct:W=function(C,f,p){var L=[null];L.push.apply(L,f);var b=Function.bind.apply(C,L),g=new b;return p&&y(g,p.prototype),g},W.apply(null,arguments)}function I(){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 D(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function y(h,o){return y=Object.setPrototypeOf||function(d,C){return d.__proto__=C,d},y(h,o)}function w(h){return w=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},w(h)}var O=Math.pow(2,17),k=function(){function h(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var o=h.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(d,C){var f=this,p=d.url;if(!p)return Promise.reject(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(p?"part list":"url")));this.abort();var L=this.config,b=L.fLoader,g=L.loader;return new Promise(function(c,u){f.loader&&f.loader.destroy();var a=f.loader=d.loader=b?new b(L):new g(L),x=A(d),v={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:O};d.stats=a.stats,a.load(x,v,{onSuccess:function(N,F,K,V){f.resetLoader(d,a),c({frag:d,part:null,payload:N.data,networkDetails:V})},onError:function(N,F,K){f.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:N,networkDetails:K}))},onAbort:function(N,F,K){f.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:K}))},onTimeout:function(N,F,K){f.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:K}))},onProgress:function(N,F,K,V){C&&C({frag:d,part:null,payload:K,networkDetails:V})}})})},o.loadPart=function(d,C,f){var p=this;this.abort();var L=this.config,b=L.fLoader,g=L.loader;return new Promise(function(c,u){p.loader&&p.loader.destroy();var a=p.loader=d.loader=b?new b(L):new g(L),x=A(d,C),v={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:O};C.stats=a.stats,a.load(x,v,{onSuccess:function(N,F,K,V){p.resetLoader(d,a),p.updateStatsFromPart(d,C);var R={frag:d,part:C,payload:N.data,networkDetails:V};f(R),c(R)},onError:function(N,F,K){p.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:C,response:N,networkDetails:K}))},onAbort:function(N,F,K){d.stats.aborted=C.stats.aborted,p.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:C,networkDetails:K}))},onTimeout:function(N,F,K){p.resetLoader(d,a),u(new T({type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:C,networkDetails:K}))}})})},o.updateStatsFromPart=function(d,C){var f=d.stats,p=C.stats,L=p.total;if(f.loaded+=p.loaded,L){var b=Math.round(d.duration/C.duration),g=Math.min(Math.round(f.loaded/L),b),c=b-g,u=c*Math.round(f.loaded/g);f.total=f.loaded+u}else f.total=Math.max(f.loaded,f.total);var a=f.loading,x=p.loading;a.start?a.first+=x.first-x.start:(a.start=x.start,a.first=x.first),a.end=x.end},o.resetLoader=function(d,C){d.loader=null,this.loader===C&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),C.destroy()},h}();function A(h,o){o===void 0&&(o=null);var l=o||h,d={frag:h,part:o,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},C=l.byteRangeStartOffset,f=l.byteRangeEndOffset;return Object(Z.isFiniteNumber)(C)&&Object(Z.isFiniteNumber)(f)&&(d.rangeStart=C,d.rangeEnd=f),d}var T=function(h){P(o,h);function o(l){for(var d,C=arguments.length,f=new Array(C>1?C-1:0),p=1;p<C;p++)f[p-1]=arguments[p];return d=h.call.apply(h,[this].concat(f))||this,d.data=void 0,d.data=l,d}return o}(z(Error))},"./src/loader/fragment.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"ElementaryStreamTypes",function(){return k}),_.d(Q,"BaseSegment",function(){return A}),_.d(Q,"Fragment",function(){return T}),_.d(Q,"Part",function(){return h});var Z=_("./src/polyfills/number.ts"),B=_("./node_modules/url-toolkit/src/url-toolkit.js"),P=_.n(B),z=_("./src/utils/logger.ts"),W=_("./src/loader/level-key.ts"),I=_("./src/loader/load-stats.ts");function D(o,l){o.prototype=Object.create(l.prototype),o.prototype.constructor=o,y(o,l)}function y(o,l){return y=Object.setPrototypeOf||function(C,f){return C.__proto__=f,C},y(o,l)}function w(o,l){for(var d=0;d<l.length;d++){var C=l[d];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function O(o,l,d){return l&&w(o.prototype,l),d&&w(o,d),o}var k;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(k||(k={}));var A=function(){function o(d){var C;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(C={},C[k.AUDIO]=null,C[k.VIDEO]=null,C[k.AUDIOVIDEO]=null,C),this.baseurl=d}var l=o.prototype;return l.setByteRange=function(C,f){var p=C.split("@",2),L=[];p.length===1?L[0]=f?f.byteRangeEndOffset:0:L[0]=parseInt(p[1]),L[1]=parseInt(p[0])+L[0],this._byteRange=L},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(B.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(C){this._url=C}}]),o}(),T=function(o){D(l,o);function l(C,f){var p;return p=o.call(this,f)||this,p._decryptdata=null,p.rawProgramDateTime=null,p.programDateTime=null,p.tagList=[],p.duration=0,p.sn=0,p.levelkey=void 0,p.type=void 0,p.loader=null,p.level=-1,p.cc=0,p.startPTS=void 0,p.endPTS=void 0,p.appendedPTS=void 0,p.startDTS=void 0,p.endDTS=void 0,p.start=0,p.deltaPTS=void 0,p.maxStartPTS=void 0,p.minEndPTS=void 0,p.stats=new I.LoadStats,p.urlId=0,p.data=void 0,p.bitrateTest=!1,p.title=null,p.initSegment=null,p.type=C,p}var d=l.prototype;return d.createInitializationVector=function(f){for(var p=new Uint8Array(16),L=12;L<16;L++)p[L]=f>>8*(15-L)&255;return p},d.setDecryptDataFromLevelKey=function(f,p){var L=f;return(f==null?void 0:f.method)==="AES-128"&&f.uri&&!f.iv&&(L=W.LevelKey.fromURI(f.uri),L.method=f.method,L.iv=this.createInitializationVector(p),L.keyFormat="identity"),L},d.setElementaryStreamInfo=function(f,p,L,b,g,c){c===void 0&&(c=!1);var u=this.elementaryStreams,a=u[f];if(!a){u[f]={startPTS:p,endPTS:L,startDTS:b,endDTS:g,partial:c};return}a.startPTS=Math.min(a.startPTS,p),a.endPTS=Math.max(a.endPTS,L),a.startDTS=Math.min(a.startDTS,b),a.endDTS=Math.max(a.endDTS,g)},d.clearElementaryStreamInfo=function(){var f=this.elementaryStreams;f[k.AUDIO]=null,f[k.VIDEO]=null,f[k.AUDIOVIDEO]=null},O(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var f=this.sn;typeof f!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&z.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),f=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,f)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(Z.isFiniteNumber)(this.programDateTime))return null;var f=Object(Z.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+f*1e3}},{key:"encrypted",get:function(){var f;return!!((f=this.decryptdata)!==null&&f!==void 0&&f.keyFormat&&this.decryptdata.uri)}}]),l}(A),h=function(o){D(l,o);function l(d,C,f,p,L){var b;b=o.call(this,f)||this,b.fragOffset=0,b.duration=0,b.gap=!1,b.independent=!1,b.relurl=void 0,b.fragment=void 0,b.index=void 0,b.stats=new I.LoadStats,b.duration=d.decimalFloatingPoint("DURATION"),b.gap=d.bool("GAP"),b.independent=d.bool("INDEPENDENT"),b.relurl=d.enumeratedString("URI"),b.fragment=C,b.index=p;var g=d.enumeratedString("BYTERANGE");return g&&b.setByteRange(g,L),L&&(b.fragOffset=L.fragOffset+L.duration),b}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 C=this.elementaryStreams;return!!(C.audio||C.video||C.audiovideo)}}]),l}(A)},"./src/loader/key-loader.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return z});var Z=_("./src/events.ts"),B=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),z=function(){function W(D){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=D,this._registerListeners()}var I=W.prototype;return I._registerListeners=function(){this.hls.on(Z.Events.KEY_LOADING,this.onKeyLoading,this)},I._unregisterListeners=function(){this.hls.off(Z.Events.KEY_LOADING,this.onKeyLoading)},I.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var w=this.loaders[y];w&&w.destroy()}this.loaders={}},I.onKeyLoading=function(y,w){var O=w.frag,k=O.type,A=this.loaders[k];if(!O.decryptdata){P.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var T=O.decryptdata.uri;if(T!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(A&&(P.logger.warn("abort previous key loader for type:"+k),A.abort()),!T){P.logger.warn("key uri is falsy");return}var o=h.loader,l=O.loader=this.loaders[k]=new o(h);this.decrypturl=T,this.decryptkey=null;var d={url:T,frag:O,responseType:"arraybuffer"},C={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(d,C,f)}else this.decryptkey&&(O.decryptdata.key=this.decryptkey,this.hls.trigger(Z.Events.KEY_LOADED,{frag:O}))},I.loadsuccess=function(y,w,O){var k=O.frag;if(!k.decryptdata){P.logger.error("after key load, decryptdata unset");return}this.decryptkey=k.decryptdata.key=new Uint8Array(y.data),k.loader=null,delete this.loaders[k.type],this.hls.trigger(Z.Events.KEY_LOADED,{frag:k})},I.loaderror=function(y,w){var O=w.frag,k=O.loader;k&&k.abort(),delete this.loaders[O.type],this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:O,response:y})},I.loadtimeout=function(y,w){var O=w.frag,k=O.loader;k&&k.abort(),delete this.loaders[O.type],this.hls.trigger(Z.Events.ERROR,{type:B.ErrorTypes.NETWORK_ERROR,details:B.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:O})},W}()},"./src/loader/level-details.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"LevelDetails",function(){return W});var Z=_("./src/polyfills/number.ts");function B(I,D){for(var y=0;y<D.length;y++){var w=D[y];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(I,w.key,w)}}function P(I,D,y){return D&&B(I.prototype,D),y&&B(I,y),I}var z=10,W=function(){function I(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=y}var D=I.prototype;return D.reloaded=function(w){if(!w){this.advanced=!0,this.updated=!0;return}var O=this.lastPartSn-w.lastPartSn,k=this.lastPartIndex-w.lastPartIndex;this.updated=this.endSN!==w.endSN||!!k||!!O,this.advanced=this.endSN>w.endSN||O>0||O===0&&k>0,this.updated||this.advanced?this.misses=Math.floor(w.misses*.6):this.misses=w.misses+1,this.availabilityDelay=w.availabilityDelay},P(I,[{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 w=this.driftEndTime-this.driftStartTime;if(w>0){var O=this.driftEnd-this.driftStart;return O*1e3/w}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var w;return(w=this.fragments)!==null&&w!==void 0&&w.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var w;return(w=this.partList)!==null&&w!==void 0&&w.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),I}()},"./src/loader/level-key.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"LevelKey",function(){return W});var Z=_("./node_modules/url-toolkit/src/url-toolkit.js"),B=_.n(Z);function P(I,D){for(var y=0;y<D.length;y++){var w=D[y];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(I,w.key,w)}}function z(I,D,y){return D&&P(I.prototype,D),y&&P(I,y),I}var W=function(){I.fromURL=function(y,w){return new I(y,w)},I.fromURI=function(y){return new I(y)};function I(D,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(Z.buildAbsoluteURL)(D,y,{alwaysNormalize:!0}):this._uri=D}return z(I,[{key:"uri",get:function(){return this._uri}}]),I}()},"./src/loader/load-stats.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"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(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return l});var Z=_("./src/polyfills/number.ts"),B=_("./node_modules/url-toolkit/src/url-toolkit.js"),P=_.n(B),z=_("./src/loader/fragment.ts"),W=_("./src/loader/level-details.ts"),I=_("./src/loader/level-key.ts"),D=_("./src/utils/attr-list.ts"),y=_("./src/utils/logger.ts"),w=_("./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,k=/#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"),T=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("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function o(L){var b,g;return h.test((b=(g=B.parseURL(L))===null||g===void 0?void 0:g.path)!=null?b:"")}var l=function(){function L(){}return L.findGroup=function(g,c){for(var u=0;u<g.length;u++){var a=g[u];if(a.id===c)return a}},L.convertAVC1ToAVCOTI=function(g){var c=g.split(".");if(c.length>2){var u=c.shift()+".";return u+=parseInt(c.shift()).toString(16),u+=("000"+parseInt(c.shift()).toString(16)).substr(-4),u}return g},L.resolve=function(g,c){return B.buildAbsoluteURL(c,g,{alwaysNormalize:!0})},L.parseMasterPlaylist=function(g,c){var u=[],a={},x=!1;O.lastIndex=0;for(var v;(v=O.exec(g))!=null;)if(v[1]){var E=new D.AttrList(v[1]),N={attrs:E,bitrate:E.decimalInteger("AVERAGE-BANDWIDTH")||E.decimalInteger("BANDWIDTH"),name:E.NAME,url:L.resolve(v[2],c)},F=E.decimalResolution("RESOLUTION");F&&(N.width=F.width,N.height=F.height),d((E.CODECS||"").split(/[ ,]+/).filter(function(V){return V}),N),N.videoCodec&&N.videoCodec.indexOf("avc1")!==-1&&(N.videoCodec=L.convertAVC1ToAVCOTI(N.videoCodec)),u.push(N)}else if(v[3]){var K=new D.AttrList(v[3]);K["DATA-ID"]&&(x=!0,a[K["DATA-ID"]]=K)}return{levels:u,sessionData:x?a:null}},L.parseMasterPlaylistMedia=function(g,c,u,a){a===void 0&&(a=[]);var x,v=[],E=0;for(k.lastIndex=0;(x=k.exec(g))!==null;){var N=new D.AttrList(x[1]);if(N.TYPE===u){var F={attrs:N,bitrate:0,id:E++,groupId:N["GROUP-ID"],instreamId:N["INSTREAM-ID"],name:N.NAME||N.LANGUAGE||"",type:u,default:N.bool("DEFAULT"),autoselect:N.bool("AUTOSELECT"),forced:N.bool("FORCED"),lang:N.LANGUAGE,url:N.URI?L.resolve(N.URI,c):""};if(a.length){var K=L.findGroup(a,F.groupId)||a[0];C(F,K,"audioCodec"),C(F,K,"textCodec")}v.push(F)}}return v},L.parseLevelPlaylist=function(g,c,u,a,x){var v=new W.LevelDetails(c),E=v.fragments,N=null,F=0,K=0,V=0,R=0,M=null,$=new z.Fragment(a,c),ee,ae,fe,De=-1,Se=!1;for(A.lastIndex=0,v.m3u8=g;(ee=A.exec(g))!==null;){Se&&(Se=!1,$=new z.Fragment(a,c),$.start=V,$.sn=F,$.cc=R,$.level=u,N&&($.initSegment=N,$.rawProgramDateTime=N.rawProgramDateTime));var Ce=ee[1];if(Ce){$.duration=parseFloat(Ce);var we=(" "+ee[2]).slice(1);$.title=we||null,$.tagList.push(we?["INF",Ce,we]:["INF",Ce])}else if(ee[3])Object(Z.isFiniteNumber)($.duration)&&($.start=V,fe&&($.levelkey=fe),$.sn=F,$.level=u,$.cc=R,$.urlId=x,E.push($),$.relurl=(" "+ee[3]).slice(1),p($,M),M=$,V+=$.duration,F++,K=0,Se=!0);else if(ee[4]){var Te=(" "+ee[4]).slice(1);M?$.setByteRange(Te,M):$.setByteRange(Te)}else if(ee[5])$.rawProgramDateTime=(" "+ee[5]).slice(1),$.tagList.push(["PROGRAM-DATE-TIME",$.rawProgramDateTime]),De===-1&&(De=E.length);else{if(ee=ee[0].match(T),!ee){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(ae=1;ae<ee.length&&!(typeof ee[ae]!="undefined");ae++);var me=(" "+ee[ae]).slice(1),he=(" "+ee[ae+1]).slice(1),te=ee[ae+2]?(" "+ee[ae+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":v.type=he.toUpperCase();break;case"MEDIA-SEQUENCE":F=v.startSN=parseInt(he);break;case"SKIP":{var de=new D.AttrList(he),ne=de.decimalInteger("SKIPPED-SEGMENTS");if(Object(Z.isFiniteNumber)(ne)){v.skippedSegments=ne;for(var Le=ne;Le--;)E.unshift(null);F+=ne}var Re=de.enumeratedString("RECENTLY-REMOVED-DATERANGES");Re&&(v.recentlyRemovedDateranges=Re.split(" "));break}case"TARGETDURATION":v.targetduration=parseFloat(he);break;case"VERSION":v.version=parseInt(he);break;case"EXTM3U":break;case"ENDLIST":v.live=!1;break;case"#":(he||te)&&$.tagList.push(te?[he,te]:[he]);break;case"DIS":R++;case"GAP":$.tagList.push([me]);break;case"BITRATE":$.tagList.push([me,he]);break;case"DISCONTINUITY-SEQ":R=parseInt(he);break;case"KEY":{var xe,Oe=new D.AttrList(he),Me=Oe.enumeratedString("METHOD"),He=Oe.URI,We=Oe.hexadecimalInteger("IV"),Fe=Oe.enumeratedString("KEYFORMATVERSIONS"),Be=Oe.enumeratedString("KEYID"),tt=(xe=Oe.enumeratedString("KEYFORMAT"))!=null?xe:"identity",qe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(qe.indexOf(tt)>-1){y.logger.warn("Keyformat "+tt+" is not supported from the manifest");continue}else if(tt!=="identity")continue;Me&&(fe=I.LevelKey.fromURL(c,He),He&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Me)>=0&&(fe.method=Me,fe.keyFormat=tt,Be&&(fe.keyID=Be),Fe&&(fe.keyFormatVersions=Fe),fe.iv=We));break}case"START":{var Ze=new D.AttrList(he),$e=Ze.decimalFloatingPoint("TIME-OFFSET");Object(Z.isFiniteNumber)($e)&&(v.startTimeOffset=$e);break}case"MAP":{var ct=new D.AttrList(he);$.relurl=ct.URI,ct.BYTERANGE&&$.setByteRange(ct.BYTERANGE),$.level=u,$.sn="initSegment",fe&&($.levelkey=fe),$.initSegment=null,N=$,Se=!0;break}case"SERVER-CONTROL":{var rt=new D.AttrList(he);v.canBlockReload=rt.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=rt.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&rt.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=rt.optionalFloat("PART-HOLD-BACK",0),v.holdBack=rt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var it=new D.AttrList(he);v.partTarget=it.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Pe=v.partList;Pe||(Pe=v.partList=[]);var st=K>0?Pe[Pe.length-1]:void 0,nt=K++,Ie=new z.Part(new D.AttrList(he),$,c,nt,st);Pe.push(Ie),$.duration+=Ie.duration;break}case"PRELOAD-HINT":{var ze=new D.AttrList(he);v.preloadHint=ze;break}case"RENDITION-REPORT":{var be=new D.AttrList(he);v.renditionReports=v.renditionReports||[],v.renditionReports.push(be);break}default:y.logger.warn("line parsed but not handled: "+ee);break}}}M&&!M.relurl?(E.pop(),V-=M.duration,v.partList&&(v.fragmentHint=M)):v.partList&&(p($,M),$.cc=R,v.fragmentHint=$);var pe=E.length,ve=E[0],re=E[pe-1];if(V+=v.skippedSegments*v.targetduration,V>0&&pe&&re){v.averagetargetduration=V/pe;var ie=re.sn;v.endSN=ie!=="initSegment"?ie:0,ve&&(v.startCC=ve.cc,ve.initSegment||v.fragments.every(function(oe){return oe.relurl&&o(oe.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),$=new z.Fragment(a,c),$.relurl=re.relurl,$.level=u,$.sn="initSegment",ve.initSegment=$,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(V+=v.fragmentHint.duration),v.totalduration=V,v.endCC=R,De>0&&f(E,De),v},L}();function d(L,b){["video","audio","text"].forEach(function(g){var c=L.filter(function(a){return Object(w.isCodecType)(a,g)});if(c.length){var u=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});b[g+"Codec"]=u.length>0?u[0]:c[0],L=L.filter(function(a){return c.indexOf(a)===-1})}}),b.unknownCodecs=L}function C(L,b,g){var c=b[g];c&&(L[g]=c)}function f(L,b){for(var g=L[b],c=b;c--;){var u=L[c];if(!u)return;u.programDateTime=g.programDateTime-u.duration*1e3,g=u}}function p(L,b){L.rawProgramDateTime?L.programDateTime=Date.parse(L.rawProgramDateTime):b!=null&&b.programDateTime&&(L.programDateTime=b.endProgramDateTime),Object(Z.isFiniteNumber)(L.programDateTime)||(L.programDateTime=null,L.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/polyfills/number.ts"),B=_("./src/events.ts"),P=_("./src/errors.ts"),z=_("./src/utils/logger.ts"),W=_("./src/utils/mp4-tools.ts"),I=_("./src/loader/m3u8-parser.ts"),D=_("./src/types/loader.ts"),y=_("./src/utils/attr-list.ts");function w(A){var T=A.type;switch(T){case D.PlaylistContextType.AUDIO_TRACK:return D.PlaylistLevelType.AUDIO;case D.PlaylistContextType.SUBTITLE_TRACK:return D.PlaylistLevelType.SUBTITLE;default:return D.PlaylistLevelType.MAIN}}function O(A,T){var h=A.url;return(h===void 0||h.indexOf("data:")===0)&&(h=T.url),h}var k=function(){function A(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var T=A.prototype;return T.registerListeners=function(){var o=this.hls;o.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(B.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(B.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},T.unregisterListeners=function(){var o=this.hls;o.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(B.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(B.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},T.createInternalLoader=function(o){var l=this.hls.config,d=l.pLoader,C=l.loader,f=d||C,p=new f(l);return o.loader=p,this.loaders[o.type]=p,p},T.getInternalLoader=function(o){return this.loaders[o.type]},T.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},T.destroyInternalLoaders=function(){for(var o in this.loaders){var l=this.loaders[o];l&&l.destroy(),this.resetInternalLoader(o)}},T.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},T.onManifestLoading=function(o,l){var d=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:D.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},T.onLevelLoading=function(o,l){var d=l.id,C=l.level,f=l.url,p=l.deliveryDirectives;this.load({id:d,groupId:null,level:C,responseType:"text",type:D.PlaylistContextType.LEVEL,url:f,deliveryDirectives:p})},T.onAudioTrackLoading=function(o,l){var d=l.id,C=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:d,groupId:C,level:null,responseType:"text",type:D.PlaylistContextType.AUDIO_TRACK,url:f,deliveryDirectives:p})},T.onSubtitleTrackLoading=function(o,l){var d=l.id,C=l.groupId,f=l.url,p=l.deliveryDirectives;this.load({id:d,groupId:C,level:null,responseType:"text",type:D.PlaylistContextType.SUBTITLE_TRACK,url:f,deliveryDirectives:p})},T.load=function(o){var l,d=this.hls.config,C=this.getInternalLoader(o);if(C){var f=C.context;if(f&&f.url===o.url){z.logger.trace("[playlist-loader]: playlist request ongoing");return}z.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),C.abort()}var p,L,b,g;switch(o.type){case D.PlaylistContextType.MANIFEST:p=d.manifestLoadingMaxRetry,L=d.manifestLoadingTimeOut,b=d.manifestLoadingRetryDelay,g=d.manifestLoadingMaxRetryTimeout;break;case D.PlaylistContextType.LEVEL:case D.PlaylistContextType.AUDIO_TRACK:case D.PlaylistContextType.SUBTITLE_TRACK:p=0,L=d.levelLoadingTimeOut;break;default:p=d.levelLoadingMaxRetry,L=d.levelLoadingTimeOut,b=d.levelLoadingRetryDelay,g=d.levelLoadingMaxRetryTimeout;break}if(C=this.createInternalLoader(o),(l=o.deliveryDirectives)!==null&&l!==void 0&&l.part){var c;if(o.type===D.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===D.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===D.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var u=c.partTarget,a=c.targetduration;u&&a&&(L=Math.min(Math.max(u*3,a*.8)*1e3,L))}}var x={timeout:L,maxRetry:p,retryDelay:b,maxRetryDelay:g,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};C.load(o,x,v)},T.loadsuccess=function(o,l,d,C){if(C===void 0&&(C=null),d.isSidxRequest){this.handleSidxRequest(o,d),this.handlePlaylistLoaded(o,l,d,C);return}this.resetInternalLoader(d.type);var f=o.data;if(f.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,d,"no EXTM3U delimiter",C);return}l.parsing.start=performance.now(),f.indexOf("#EXTINF:")>0||f.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,l,d,C):this.handleMasterPlaylist(o,l,d,C)},T.loaderror=function(o,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!1,o)},T.loadtimeout=function(o,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!0)},T.handleMasterPlaylist=function(o,l,d,C){var f=this.hls,p=o.data,L=O(o,d),b=I.default.parseMasterPlaylist(p,L),g=b.levels,c=b.sessionData;if(!g.length){this.handleManifestParsingError(o,d,"no level found in manifest",C);return}var u=g.map(function(F){return{id:F.attrs.AUDIO,audioCodec:F.audioCodec}}),a=g.map(function(F){return{id:F.attrs.SUBTITLES,textCodec:F.textCodec}}),x=I.default.parseMasterPlaylistMedia(p,L,"AUDIO",u),v=I.default.parseMasterPlaylistMedia(p,L,"SUBTITLES",a),E=I.default.parseMasterPlaylistMedia(p,L,"CLOSED-CAPTIONS");if(x.length){var N=x.some(function(F){return!F.url});!N&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}f.trigger(B.Events.MANIFEST_LOADED,{levels:g,audioTracks:x,subtitles:v,captions:E,url:L,stats:l,networkDetails:C,sessionData:c})},T.handleTrackOrLevelPlaylist=function(o,l,d,C){var f=this.hls,p=d.id,L=d.level,b=d.type,g=O(o,d),c=Object(Z.isFiniteNumber)(p)?p:0,u=Object(Z.isFiniteNumber)(L)?L:c,a=w(d),x=I.default.parseLevelPlaylist(o.data,g,u,a,c);if(!x.fragments.length){f.trigger(B.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(b===D.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:x,name:"",url:g};f.trigger(B.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:g,stats:l,networkDetails:C,sessionData:null})}if(l.parsing.end=performance.now(),x.needSidxRanges){var E,N=(E=x.fragments[0].initSegment)===null||E===void 0?void 0:E.url;this.load({url:N,isSidxRequest:!0,type:b,level:L,levelDetails:x,id:p,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=x,this.handlePlaylistLoaded(o,l,d,C)},T.handleSidxRequest=function(o,l){var d=Object(W.parseSegmentIndex)(new Uint8Array(o.data));if(!d)return;var C=d.references,f=l.levelDetails;C.forEach(function(p,L){var b=p.info,g=f.fragments[L];g.byteRange.length===0&&g.setByteRange(String(1+b.end-b.start)+"@"+String(b.start)),g.initSegment&&g.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},T.handleManifestParsingError=function(o,l,d,C){this.hls.trigger(B.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===D.PlaylistContextType.MANIFEST,url:o.url,reason:d,response:o,context:l,networkDetails:C})},T.handleNetworkError=function(o,l,d,C){d===void 0&&(d=!1),z.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var f=P.ErrorDetails.UNKNOWN,p=!1,L=this.getInternalLoader(o);switch(o.type){case D.PlaylistContextType.MANIFEST:f=d?P.ErrorDetails.MANIFEST_LOAD_TIMEOUT:P.ErrorDetails.MANIFEST_LOAD_ERROR,p=!0;break;case D.PlaylistContextType.LEVEL:f=d?P.ErrorDetails.LEVEL_LOAD_TIMEOUT:P.ErrorDetails.LEVEL_LOAD_ERROR,p=!1;break;case D.PlaylistContextType.AUDIO_TRACK:f=d?P.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:P.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case D.PlaylistContextType.SUBTITLE_TRACK:f=d?P.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:P.ErrorDetails.SUBTITLE_LOAD_ERROR,p=!1;break}L&&this.resetInternalLoader(o.type);var b={type:P.ErrorTypes.NETWORK_ERROR,details:f,fatal:p,url:o.url,loader:L,context:o,networkDetails:l};C&&(b.response=C),this.hls.trigger(B.Events.ERROR,b)},T.handlePlaylistLoaded=function(o,l,d,C){var f=d.type,p=d.level,L=d.id,b=d.groupId,g=d.loader,c=d.levelDetails,u=d.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,d,"invalid target duration",C);return}if(!g)return;c.live&&(g.getCacheAge&&(c.ageHeader=g.getCacheAge()||0),(!g.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(f){case D.PlaylistContextType.MANIFEST:case D.PlaylistContextType.LEVEL:this.hls.trigger(B.Events.LEVEL_LOADED,{details:c,level:p||0,id:L||0,stats:l,networkDetails:C,deliveryDirectives:u});break;case D.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(B.Events.AUDIO_TRACK_LOADED,{details:c,id:L||0,groupId:b||"",stats:l,networkDetails:C,deliveryDirectives:u});break;case D.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(B.Events.SUBTITLE_TRACK_LOADED,{details:c,id:L||0,groupId:b||"",stats:l,networkDetails:C,deliveryDirectives:u});break}},A}();Q.default=k},"./src/polyfills/number.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"isFiniteNumber",function(){return Z}),_.d(Q,"MAX_SAFE_INTEGER",function(){return B});var Z=Number.isFinite||function(P){return typeof P=="number"&&isFinite(P)},B=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(le,Q,_){"use strict";_.r(Q);var Z=function(){function B(){}return B.getSilentFrame=function(z,W){switch(z){case"mp4a.40.2":if(W===1)return new Uint8Array([0,200,0,128,35,128]);if(W===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(W===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(W===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(W===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(W===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(W===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(W===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(W===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},B}();Q.default=Z},"./src/remux/mp4-generator.ts":function(le,Q,_){"use strict";_.r(Q);var Z=Math.pow(2,32)-1,B=function(){function P(){}return P.init=function(){P.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var W;for(W in P.types)P.types.hasOwnProperty(W)&&(P.types[W]=[W.charCodeAt(0),W.charCodeAt(1),W.charCodeAt(2),W.charCodeAt(3)]);var I=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]),D=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);P.HDLR_TYPES={video:I,audio:D};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),w=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=w,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var O=new Uint8Array([105,115,111,109]),k=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,O,A,O,k),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,y))},P.box=function(W){for(var I=8,D=arguments.length,y=new Array(D>1?D-1:0),w=1;w<D;w++)y[w-1]=arguments[w];for(var O=y.length,k=O;O--;)I+=y[O].byteLength;var A=new Uint8Array(I);for(A[0]=I>>24&255,A[1]=I>>16&255,A[2]=I>>8&255,A[3]=I&255,A.set(W,4),O=0,I=8;O<k;O++)A.set(y[O],I),I+=y[O].byteLength;return A},P.hdlr=function(W){return P.box(P.types.hdlr,P.HDLR_TYPES[W])},P.mdat=function(W){return P.box(P.types.mdat,W)},P.mdhd=function(W,I){I*=W;var D=Math.floor(I/(Z+1)),y=Math.floor(I%(Z+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,W>>24&255,W>>16&255,W>>8&255,W&255,D>>24,D>>16&255,D>>8&255,D&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},P.mdia=function(W){return P.box(P.types.mdia,P.mdhd(W.timescale,W.duration),P.hdlr(W.type),P.minf(W))},P.mfhd=function(W){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,W>>24,W>>16&255,W>>8&255,W&255]))},P.minf=function(W){return W.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(W)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(W))},P.moof=function(W,I,D){return P.box(P.types.moof,P.mfhd(W),P.traf(D,I))},P.moov=function(W){for(var I=W.length,D=[];I--;)D[I]=P.trak(W[I]);return P.box.apply(null,[P.types.moov,P.mvhd(W[0].timescale,W[0].duration)].concat(D).concat(P.mvex(W)))},P.mvex=function(W){for(var I=W.length,D=[];I--;)D[I]=P.trex(W[I]);return P.box.apply(null,[P.types.mvex].concat(D))},P.mvhd=function(W,I){I*=W;var D=Math.floor(I/(Z+1)),y=Math.floor(I%(Z+1)),w=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,W>>24&255,W>>16&255,W>>8&255,W&255,D>>24,D>>16&255,D>>8&255,D&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return P.box(P.types.mvhd,w)},P.sdtp=function(W){var I=W.samples||[],D=new Uint8Array(4+I.length),y,w;for(y=0;y<I.length;y++)w=I[y].flags,D[y+4]=w.dependsOn<<4|w.isDependedOn<<2|w.hasRedundancy;return P.box(P.types.sdtp,D)},P.stbl=function(W){return P.box(P.types.stbl,P.stsd(W),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(W){var I=[],D=[],y,w,O;for(y=0;y<W.sps.length;y++)w=W.sps[y],O=w.byteLength,I.push(O>>>8&255),I.push(O&255),I=I.concat(Array.prototype.slice.call(w));for(y=0;y<W.pps.length;y++)w=W.pps[y],O=w.byteLength,D.push(O>>>8&255),D.push(O&255),D=D.concat(Array.prototype.slice.call(w));var k=P.box(P.types.avcC,new Uint8Array([1,I[3],I[4],I[5],252|3,224|W.sps.length].concat(I).concat([W.pps.length]).concat(D))),A=W.width,T=W.height,h=W.pixelRatio[0],o=W.pixelRatio[1];return P.box(P.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A>>8&255,A&255,T>>8&255,T&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]),k,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,o>>24,o>>16&255,o>>8&255,o&255])))},P.esds=function(W){var I=W.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(W.config).concat([6,1,2]))},P.mp4a=function(W){var I=W.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,W.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]),P.box(P.types.esds,P.esds(W)))},P.mp3=function(W){var I=W.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,W.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]))},P.stsd=function(W){return W.type==="audio"?!W.isAAC&&W.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(W)):P.box(P.types.stsd,P.STSD,P.mp4a(W)):P.box(P.types.stsd,P.STSD,P.avc1(W))},P.tkhd=function(W){var I=W.id,D=W.duration*W.timescale,y=W.width,w=W.height,O=Math.floor(D/(Z+1)),k=Math.floor(D%(Z+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,I&255,0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,k>>24,k>>16&255,k>>8&255,k&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,w>>8&255,w&255,0,0]))},P.traf=function(W,I){var D=P.sdtp(W),y=W.id,w=Math.floor(I/(Z+1)),O=Math.floor(I%(Z+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,w>>24,w>>16&255,w>>8&255,w&255,O>>24,O>>16&255,O>>8&255,O&255])),P.trun(W,D.length+16+20+8+16+8+8),D)},P.trak=function(W){return W.duration=W.duration||4294967295,P.box(P.types.trak,P.tkhd(W),P.mdia(W))},P.trex=function(W){var I=W.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,I&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(W,I){var D=W.samples||[],y=D.length,w=12+16*y,O=new Uint8Array(w),k,A,T,h,o,l;for(I+=8+w,O.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255],0),k=0;k<y;k++)A=D[k],T=A.duration,h=A.size,o=A.flags,l=A.cts,O.set([T>>>24&255,T>>>16&255,T>>>8&255,T&255,h>>>24&255,h>>>16&255,h>>>8&255,h&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*k);return P.box(P.types.trun,O)},P.initSegment=function(W){P.types||P.init();var I=P.moov(W),D=new Uint8Array(P.FTYP.byteLength+I.byteLength);return D.set(P.FTYP),D.set(I,P.FTYP.byteLength),D},P}();B.types=void 0,B.HDLR_TYPES=void 0,B.STTS=void 0,B.STSC=void 0,B.STCO=void 0,B.STSZ=void 0,B.VMHD=void 0,B.SMHD=void 0,B.STSD=void 0,B.FTYP=void 0,B.DINF=void 0,Q.default=B},"./src/remux/mp4-remuxer.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return l}),_.d(Q,"normalizePts",function(){return d});var Z=_("./src/polyfills/number.ts"),B=_("./src/remux/aac-helper.ts"),P=_("./src/remux/mp4-generator.ts"),z=_("./src/events.ts"),W=_("./src/errors.ts"),I=_("./src/utils/logger.ts"),D=_("./src/types/loader.ts"),y=_("./src/utils/timescale-conversion.ts");function w(){return w=Object.assign||function(L){for(var b=1;b<arguments.length;b++){var g=arguments[b];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(L[c]=g[c])}return L},w.apply(this,arguments)}var O=10*1e3,k=1024,A=1152,T=null,h=null,o=!1,l=function(){function L(g,c,u,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=g,this.config=c,this.typeSupported=u,this.ISGenerated=!1,T===null){var x=navigator.userAgent||"",v=x.match(/Chrome\/(\d+)/i);T=v?parseInt(v[1]):0}if(h===null){var E=navigator.userAgent.match(/Safari\/(\d+)/i);h=E?parseInt(E[1]):0}o=!!T&&T<75||!!h&&h<600}var b=L.prototype;return b.destroy=function(){},b.resetTimeStamp=function(c){I.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},b.resetNextTimestamp=function(){I.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},b.resetInitSegment=function(){I.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},b.getVideoStartPts=function(c){var u=!1,a=c.reduce(function(x,v){var E=v.pts-x;return E<-4294967296?(u=!0,d(x,v.pts)):E>0?x:v.pts},c[0].pts);return u&&I.logger.debug("PTS rollover detected"),a},b.remux=function(c,u,a,x,v,E,N,F){var K,V,R,M,$,ee,ae=v,fe=v,De=c.pid>-1,Se=u.pid>-1,Ce=u.samples.length,we=c.samples.length>0,Te=Ce>1,me=(!De||we)&&(!Se||Te)||this.ISGenerated||N;if(me){this.ISGenerated||(R=this.generateIS(c,u,v));var he=this.isVideoContiguous,te=-1;if(Te&&(te=C(u.samples),!he&&this.config.forceKeyFrameOnDiscontinuity))if(ee=!0,te>0){I.logger.warn("[mp4-remuxer]: Dropped "+te+" out of "+Ce+" video samples due to a missing keyframe");var de=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(te),u.dropped+=te,fe+=(u.samples[0].pts-de)/(u.timescale||9e4)}else te===-1&&(I.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ce+" video samples"),ee=!1);if(this.ISGenerated){if(we&&Te){var ne=this.getVideoStartPts(u.samples),Le=d(c.samples[0].pts,ne)-ne,Re=Le/u.inputTimeScale;ae+=Math.max(0,Re),fe+=Math.max(0,-Re)}if(we){if(c.samplerate||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),R=this.generateIS(c,u,v)),V=this.remuxAudio(c,ae,this.isAudioContiguous,E,Se||Te||F===D.PlaylistLevelType.AUDIO?fe:void 0),Te){var xe=V?V.endPTS-V.startPTS:0;u.inputTimeScale||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),R=this.generateIS(c,u,v)),K=this.remuxVideo(u,fe,he,xe)}}else Te&&(K=this.remuxVideo(u,fe,he,0));K&&(K.firstKeyFrame=te,K.independent=te!==-1)}}return this.ISGenerated&&(a.samples.length&&($=this.remuxID3(a,v)),x.samples.length&&(M=this.remuxText(x,v))),{audio:V,video:K,initSegment:R,independent:ee,text:M,id3:$}},b.generateIS=function(c,u,a){var x=c.samples,v=u.samples,E=this.typeSupported,N={},F=!Object(Z.isFiniteNumber)(this._initPTS),K="audio/mp4",V,R,M;if(F&&(V=R=Infinity),c.config&&x.length&&(c.timescale=c.samplerate,c.isAAC||(E.mpeg?(K="audio/mpeg",c.codec=""):E.mp3&&(c.codec="mp3")),N.audio={id:"audio",container:K,codec:c.codec,initSegment:!c.isAAC&&E.mpeg?new Uint8Array(0):P.default.initSegment([c]),metadata:{channelCount:c.channelCount}},F&&(M=c.inputTimeScale,V=R=x[0].pts-Math.round(M*a))),u.sps&&u.pps&&v.length&&(u.timescale=u.inputTimeScale,N.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:P.default.initSegment([u]),metadata:{width:u.width,height:u.height}},F)){M=u.inputTimeScale;var $=this.getVideoStartPts(v),ee=Math.round(M*a);R=Math.min(R,d(v[0].dts,$)-ee),V=Math.min(V,$-ee)}if(Object.keys(N).length)return this.ISGenerated=!0,F&&(this._initPTS=V,this._initDTS=R),{tracks:N,initPTS:V,timescale:M}},b.remuxVideo=function(c,u,a,x){var v=c.inputTimeScale,E=c.samples,N=[],F=E.length,K=this._initPTS,V=this.nextAvcDts,R=8,M,$,ee,ae=Number.POSITIVE_INFINITY,fe=Number.NEGATIVE_INFINITY,De=0,Se=!1;if(!a||V===null){var Ce=u*v,we=E[0].pts-d(E[0].dts,E[0].pts);V=Ce-we}for(var Te=0;Te<F;Te++){var me=E[Te];if(me.pts=d(me.pts-K,V),me.dts=d(me.dts-K,V),me.dts>me.pts){var he=9e4*.2;De=Math.max(Math.min(De,me.pts-me.dts),-1*he)}me.dts<E[Te>0?Te-1:Te].dts&&(Se=!0)}Se&&E.sort(function(wt,St){var dt=wt.dts-St.dts,zt=wt.pts-St.pts;return dt||zt}),$=E[0].dts,ee=E[E.length-1].dts;var te=Math.round((ee-$)/(F-1));if(De<0){if(De<te*-2){I.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-te,!0)+" ms");for(var de=De,ne=0;ne<F;ne++)E[ne].dts=de=Math.max(de,E[ne].pts-te),E[ne].pts=Math.max(de,E[ne].pts)}else{I.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var Le=0;Le<F;Le++)E[Le].dts=E[Le].dts+De}$=E[0].dts}if(a){var Re=$-V,xe=Re>te,Oe=Re<-1;if(xe||Oe){xe?I.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms ("+Re+"dts) hole between fragments detected, filling it"):I.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-Re,!0)+" ms ("+Re+"dts) overlapping between fragments detected"),$=V;var Me=E[0].pts-Re;E[0].dts=$,E[0].pts=Me,I.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Me,!0)+"/"+Object(y.toMsFromMpegTsClock)($,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms")}}o&&($=Math.max(0,$));for(var He=0,We=0,Fe=0;Fe<F;Fe++){for(var Be=E[Fe],tt=Be.units,qe=tt.length,Ze=0,$e=0;$e<qe;$e++)Ze+=tt[$e].data.length;We+=Ze,He+=qe,Be.length=Ze,Be.dts=Math.max(Be.dts,$),Be.pts=Math.max(Be.pts,Be.dts,0),ae=Math.min(Be.pts,ae),fe=Math.max(Be.pts,fe)}ee=E[F-1].dts;var ct=We+4*He+8,rt;try{rt=new Uint8Array(ct)}catch(wt){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ct,reason:"fail allocating video mdat "+ct});return}var it=new DataView(rt.buffer);it.setUint32(0,ct),rt.set(P.default.types.mdat,4);for(var Pe=0;Pe<F;Pe++){for(var st=E[Pe],nt=st.units,Ie=0,ze=0,be=nt.length;ze<be;ze++){var pe=nt[ze],ve=pe.data,re=pe.data.byteLength;it.setUint32(R,re),R+=4,rt.set(ve,R),R+=re,Ie+=4+re}if(Pe<F-1)M=E[Pe+1].dts-st.dts;else{var ie=this.config,oe=st.dts-E[Pe>0?Pe-1:Pe].dts;if(ie.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(ie.maxBufferHole*v),ke=(x?ae+x*v:this.nextAudioPts)-st.pts;ke>ue?(M=ke-oe,M<0&&(M=oe),I.logger.log("[mp4-remuxer]: It is approximately "+ke/90+" ms to the next segment; using duration "+M/90+" ms for the last video frame.")):M=oe}else M=oe}var Ee=Math.round(st.pts-st.dts);N.push(new f(st.key,M,Ie,Ee))}if(N.length&&T&&T<70){var Ue=N[0].flags;Ue.dependsOn=2,Ue.isNonSync=0}console.assert(M!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=V=ee+M,this.isVideoContiguous=!0;var et=P.default.moof(c.sequenceNumber++,$,w({},c,{samples:N})),ft="video",lt={data1:et,data2:rt,startPTS:ae/v,endPTS:(fe+M)/v,startDTS:$/v,endDTS:V/v,type:ft,hasAudio:!1,hasVideo:!0,nb:N.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(rt.length,"MDAT length must not be zero"),lt},b.remuxAudio=function(c,u,a,x,v){var E=c.inputTimeScale,N=c.samplerate?c.samplerate:E,F=E/N,K=c.isAAC?k:A,V=K*F,R=this._initPTS,M=!c.isAAC&&this.typeSupported.mpeg,$=[],ee=c.samples,ae=M?0:8,fe=this.nextAudioPts||-1,De=u*E;if(this.isAudioContiguous=a=a||ee.length&&fe>0&&(x&&Math.abs(De-fe)<9e3||Math.abs(d(ee[0].pts-R,De)-fe)<20*V),ee.forEach(function(ve){ve.pts=d(ve.pts-R,De)}),!a||fe<0){if(ee=ee.filter(function(ve){return ve.pts>=0}),!ee.length)return;v===0?fe=0:x?fe=Math.max(0,De):fe=ee[0].pts}if(c.isAAC)for(var Se=v!==void 0,Ce=this.config.maxAudioFramesDrift,we=0,Te=fe;we<ee.length;we++){var me=ee[we],he=me.pts,te=he-Te,de=Math.abs(1e3*te/E);if(te<=-Ce*V&&Se)we===0&&(I.logger.warn("Audio frame @ "+(he/E).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/E)+" ms."),this.nextAudioPts=fe=Te=he);else if(te>=Ce*V&&de<O&&Se){var ne=Math.round(te/V);Te=he-ne*V,Te<0&&(ne--,Te+=V),we===0&&(this.nextAudioPts=fe=Te),I.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(Te/E).toFixed(3)+"s due to "+Math.round(1e3*te/E)+" ms gap.");for(var Le=0;Le<ne;Le++){var Re=Math.max(Te,0),xe=B.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);xe||(I.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),xe=me.unit.subarray()),ee.splice(we,0,{unit:xe,pts:Re}),Te+=V,we++}}me.pts=Te,Te+=V}for(var Oe=null,Me=null,He,We=0,Fe=ee.length;Fe--;)We+=ee[Fe].unit.byteLength;for(var Be=0,tt=ee.length;Be<tt;Be++){var qe=ee[Be],Ze=qe.unit,$e=qe.pts;if(Me!==null){var ct=$[Be-1];ct.duration=Math.round(($e-Me)/F)}else if(a&&c.isAAC&&($e=fe),Oe=$e,We>0){We+=ae;try{He=new Uint8Array(We)}catch(ve){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:W.ErrorTypes.MUX_ERROR,details:W.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:We,reason:"fail allocating audio mdat "+We});return}if(!M){var rt=new DataView(He.buffer);rt.setUint32(0,We),He.set(P.default.types.mdat,4)}}else return;He.set(Ze,ae);var it=Ze.byteLength;ae+=it,$.push(new f(!0,K,it,0)),Me=$e}var Pe=$.length;if(!Pe)return;var st=$[$.length-1];this.nextAudioPts=fe=Me+F*st.duration;var nt=M?new Uint8Array(0):P.default.moof(c.sequenceNumber++,Oe/F,w({},c,{samples:$}));c.samples=[];var Ie=Oe/E,ze=fe/E,be="audio",pe={data1:nt,data2:He,startPTS:Ie,endPTS:ze,startDTS:Ie,endDTS:ze,type:be,hasAudio:!0,hasVideo:!1,nb:Pe};return this.isAudioContiguous=!0,console.assert(He.length,"MDAT length must not be zero"),pe},b.remuxEmptyAudio=function(c,u,a,x){var v=c.inputTimeScale,E=c.samplerate?c.samplerate:v,N=v/E,F=this.nextAudioPts,K=(F!==null?F:x.startDTS*v)+this._initDTS,V=x.endDTS*v+this._initDTS,R=N*k,M=Math.ceil((V-K)/R),$=B.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(I.logger.warn("[mp4-remuxer]: remux empty Audio"),!$){I.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<M;ae++){var fe=K+ae*R;ee.push({unit:$,pts:fe,dts:fe})}return c.samples=ee,this.remuxAudio(c,u,a,!1)},b.remuxID3=function(c,u){var a=c.samples.length;if(!a)return;for(var x=c.inputTimeScale,v=this._initPTS,E=this._initDTS,N=0;N<a;N++){var F=c.samples[N];F.pts=d(F.pts-v,u*x)/x,F.dts=d(F.dts-E,u*x)/x}var K=c.samples;return c.samples=[],{samples:K}},b.remuxText=function(c,u){var a=c.samples.length;if(!a)return;for(var x=c.inputTimeScale,v=this._initPTS,E=0;E<a;E++){var N=c.samples[E];N.pts=d(N.pts-v,u*x)/x}c.samples.sort(function(K,V){return K.pts-V.pts});var F=c.samples;return c.samples=[],{samples:F}},L}();function d(L,b){var g;if(b===null)return L;for(b<L?g=-8589934592:g=8589934592;Math.abs(L-b)>4294967296;)L+=g;return L}function C(L){for(var b=0;b<L.length;b++)if(L[b].key)return b;return-1}var f=function(b,g,c,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=g,this.size=c,this.cts=u,this.flags=new p(b)},p=function(b){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=b?2:1,this.isNonSync=b?0:1}},"./src/remux/passthrough-remuxer.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/mp4-tools.ts"),P=_("./src/loader/fragment.ts"),z=_("./src/utils/logger.ts"),W=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var w=y.prototype;return w.destroy=function(){},w.resetTimeStamp=function(k){this.initPTS=k,this.lastEndDTS=null},w.resetNextTimestamp=function(){this.lastEndDTS=null},w.resetInitSegment=function(k,A,T){this.audioCodec=A,this.videoCodec=T,this.generateInitSegment(k),this.emitInitSegment=!0},w.generateInitSegment=function(k){var A=this.audioCodec,T=this.videoCodec;if(!k||!k.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(B.parseInitSegment)(k);A||(A=D(h.audio,P.ElementaryStreamTypes.AUDIO)),T||(T=D(h.video,P.ElementaryStreamTypes.VIDEO));var o={};h.audio&&h.video?o.audiovideo={container:"video/mp4",codec:A+","+T,initSegment:k,id:"main"}:h.audio?o.audio={container:"audio/mp4",codec:A,initSegment:k,id:"audio"}:h.video?o.video={container:"video/mp4",codec:T,initSegment:k,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},w.remux=function(k,A,T,h,o){var l=this.initPTS,d=this.lastEndDTS,C={audio:void 0,video:void 0,text:h,id3:T,initSegment:void 0};Object(Z.isFiniteNumber)(d)||(d=this.lastEndDTS=o||0);var f=A.samples;if(!f||!f.length)return C;var p={initPTS:void 0,timescale:1},L=this.initData;if((!L||!L.length)&&(this.generateInitSegment(f),L=this.initData),!L||!L.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),C;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1),Object(Z.isFiniteNumber)(l)||(this.initPTS=p.initPTS=l=I(L,f,d));var b=Object(B.getDuration)(f,L),g=d,c=b+g;Object(B.offsetStartDTS)(L,f,l),b>0?this.lastEndDTS=c:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!L.audio,a=!!L.video,x="";u&&(x+="audio"),a&&(x+="video");var v={data1:f,startPTS:g,startDTS:g,endPTS:c,endDTS:c,type:x,hasAudio:u,hasVideo:a,nb:1,dropped:0};return C.audio=v.type==="audio"?v:void 0,C.video=v.type!=="audio"?v:void 0,C.text=h,C.id3=T,C.initSegment=p,C},y}(),I=function(w,O,k){return Object(B.getStartDTS)(w,O)-k};function D(y,w){var O=y==null?void 0:y.codec;return O&&O.length>4?O:O==="hvc1"?"hvc1.1.c.L120.90":O==="av01"?"av01.0.04M.08":O==="avc1"||w===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Q.default=W},"./src/task-loop.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return Z});var Z=function(){function B(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var P=B.prototype;return P.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},P.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},P.onHandlerDestroyed=function(){},P.hasInterval=function(){return!!this._tickInterval},P.hasNextTick=function(){return!!this._tickTimer},P.setInterval=function(W){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,W),!0)},P.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},P.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},P.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},P.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},P.doTick=function(){},B}()},"./src/types/cmcd.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"CMCDVersion",function(){return Z}),_.d(Q,"CMCDObjectType",function(){return B}),_.d(Q,"CMCDStreamingFormat",function(){return P}),_.d(Q,"CMCDStreamType",function(){return z});var Z=1,B;(function(W){W.MANIFEST="m",W.AUDIO="a",W.VIDEO="v",W.MUXED="av",W.INIT="i",W.CAPTION="c",W.TIMED_TEXT="tt",W.KEY="k",W.OTHER="o"})(B||(B={}));var P;(function(W){W.DASH="d",W.HLS="h",W.SMOOTH="s",W.OTHER="o"})(P||(P={}));var z;(function(W){W.VOD="v",W.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"HlsSkip",function(){return P}),_.d(Q,"getSkipValue",function(){return z}),_.d(Q,"HlsUrlParameters",function(){return W}),_.d(Q,"Level",function(){return I});function Z(D,y){for(var w=0;w<y.length;w++){var O=y[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(D,O.key,O)}}function B(D,y,w){return y&&Z(D.prototype,y),w&&Z(D,w),D}var P;(function(D){D.No="",D.Yes="YES",D.v2="v2"})(P||(P={}));function z(D,y){var w=D.canSkipUntil,O=D.canSkipDateRanges,k=D.endSN,A=y!==void 0?y-k:0;return w&&A<w?O?P.v2:P.Yes:P.No}var W=function(){function D(w,O,k){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=w,this.part=O,this.skip=k}var y=D.prototype;return y.addDirectives=function(O){var k=new self.URL(O);return this.msn!==void 0&&k.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&k.searchParams.set("_HLS_part",this.part.toString()),this.skip&&k.searchParams.set("_HLS_skip",this.skip),k.toString()},D}(),I=function(){function D(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(w){return w}).join(",").replace(/\.[^.,]+/g,"")}return B(D,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(w){var O=w%this.url.length;this._urlId!==O&&(this.details=void 0,this._urlId=O)}}]),D}()},"./src/types/loader.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"PlaylistContextType",function(){return Z}),_.d(Q,"PlaylistLevelType",function(){return B});var Z;(function(P){P.MANIFEST="manifest",P.LEVEL="level",P.AUDIO_TRACK="audioTrack",P.SUBTITLE_TRACK="subtitleTrack"})(Z||(Z={}));var B;(function(P){P.MAIN="main",P.AUDIO="audio",P.SUBTITLE="subtitle"})(B||(B={}))},"./src/types/transmuxer.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"ChunkMetadata",function(){return Z});var Z=function(z,W,I,D,y,w){D===void 0&&(D=0),y===void 0&&(y=-1),w===void 0&&(w=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=B(),this.buffering={audio:B(),video:B(),audiovideo:B()},this.level=z,this.sn=W,this.id=I,this.size=D,this.part=y,this.partial=w};function B(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"AttrList",function(){return P});var Z=/^(\d+)x(\d+)$/,B=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,P=function(){function z(I){typeof I=="string"&&(I=z.parseAttrList(I));for(var D in I)I.hasOwnProperty(D)&&(this[D]=I[D])}var W=z.prototype;return W.decimalInteger=function(D){var y=parseInt(this[D],10);return y>Number.MAX_SAFE_INTEGER?Infinity:y},W.hexadecimalInteger=function(D){if(this[D]){var y=(this[D]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var w=new Uint8Array(y.length/2),O=0;O<y.length/2;O++)w[O]=parseInt(y.slice(O*2,O*2+2),16);return w}else return null},W.hexadecimalIntegerAsNumber=function(D){var y=parseInt(this[D],16);return y>Number.MAX_SAFE_INTEGER?Infinity:y},W.decimalFloatingPoint=function(D){return parseFloat(this[D])},W.optionalFloat=function(D,y){var w=this[D];return w?parseFloat(w):y},W.enumeratedString=function(D){return this[D]},W.bool=function(D){return this[D]==="YES"},W.decimalResolution=function(D){var y=Z.exec(this[D]);return y===null?void 0:{width:parseInt(y[1],10),height:parseInt(y[2],10)}},z.parseAttrList=function(D){var y,w={},O='"';for(B.lastIndex=0;(y=B.exec(D))!==null;){var k=y[2];k.indexOf(O)===0&&k.lastIndexOf(O)===k.length-1&&(k=k.slice(1,-1)),w[y[1]]=k}return w},z}()},"./src/utils/binary-search.ts":function(le,Q,_){"use strict";_.r(Q);var Z={search:function(P,z){for(var W=0,I=P.length-1,D=null,y=null;W<=I;){D=(W+I)/2|0,y=P[D];var w=z(y);if(w>0)W=D+1;else if(w<0)I=D-1;else return y}return null}};Q.default=Z},"./src/utils/buffer-helper.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"BufferHelper",function(){return P});var Z=_("./src/utils/logger.ts"),B={length:0,start:function(){return 0},end:function(){return 0}},P=function(){function z(){}return z.isBuffered=function(I,D){try{if(I){for(var y=z.getBuffered(I),w=0;w<y.length;w++)if(D>=y.start(w)&&D<=y.end(w))return!0}}catch(O){}return!1},z.bufferInfo=function(I,D,y){try{if(I){var w=z.getBuffered(I),O=[],k;for(k=0;k<w.length;k++)O.push({start:w.start(k),end:w.end(k)});return this.bufferedInfo(O,D,y)}}catch(A){}return{len:0,start:D,end:D,nextStart:void 0}},z.bufferedInfo=function(I,D,y){D=Math.max(0,D),I.sort(function(p,L){var b=p.start-L.start;return b||L.end-p.end});var w=[];if(y)for(var O=0;O<I.length;O++){var k=w.length;if(k){var A=w[k-1].end;I[O].start-A<y?I[O].end>A&&(w[k-1].end=I[O].end):w.push(I[O])}else w.push(I[O])}else w=I;for(var T=0,h,o=D,l=D,d=0;d<w.length;d++){var C=w[d].start,f=w[d].end;if(D+y>=C&&D<f)o=C,l=f,T=l-D;else if(D+y<C){h=C;break}}return{len:T,start:o||0,end:l||0,nextStart:h}},z.getBuffered=function(I){try{return I.buffered}catch(D){return Z.logger.log("failed to get media.buffered",D),B}},z}()},"./src/utils/cea-608-parser.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"Row",function(){return l}),_.d(Q,"CaptionScreen",function(){return d});var Z=_("./src/utils/logger.ts"),B={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},P=function(c){var u=c;return B.hasOwnProperty(c)&&(u=B[c]),String.fromCharCode(u)},z=15,W=100,I={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},D={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},w={25:2,26:4,29:6,30:8,31:10,27:13,28:15},O=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],k;(function(g){g[g.ERROR=0]="ERROR",g[g.TEXT=1]="TEXT",g[g.WARNING=2]="WARNING",g[g.INFO=2]="INFO",g[g.DEBUG=3]="DEBUG",g[g.DATA=3]="DATA"})(k||(k={}));var A=function(){function g(){this.time=null,this.verboseLevel=k.ERROR}var c=g.prototype;return c.log=function(a,x){this.verboseLevel>=a&&Z.logger.log(this.time+" ["+a+"] "+x)},g}(),T=function(c){for(var u=[],a=0;a<c.length;a++)u.push(c[a].toString(16));return u},h=function(){function g(u,a,x,v,E){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=a||!1,this.italics=x||!1,this.background=v||"black",this.flash=E||!1}var c=g.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var x=["foreground","underline","italics","background","flash"],v=0;v<x.length;v++){var E=x[v];a.hasOwnProperty(E)&&(this[E]=a[E])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},g}(),o=function(){function g(u,a,x,v,E,N){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new h(a,x,v,E,N)}var c=g.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,x){this.uchar=a,this.penState.copy(x)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},g}(),l=function(){function g(u){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<W;a++)this.chars.push(new o);this.logger=u,this.pos=0,this.currPenState=new h}var c=g.prototype;return c.equals=function(a){for(var x=!0,v=0;v<W;v++)if(!this.chars[v].equals(a.chars[v])){x=!1;break}return x},c.copy=function(a){for(var x=0;x<W;x++)this.chars[x].copy(a.chars[x])},c.isEmpty=function(){for(var a=!0,x=0;x<W;x++)if(!this.chars[x].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(k.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>W&&(this.logger.log(k.DEBUG,"Too large cursor position "+this.pos),this.pos=W)},c.moveCursor=function(a){var x=this.pos+a;if(a>1)for(var v=this.pos+1;v<x+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(x)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var x=P(a);if(this.pos>=W){this.logger.log(k.ERROR,"Cannot insert "+a.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var x;for(x=a;x<W;x++)this.chars[x].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],x=!0,v=0;v<W;v++){var E=this.chars[v].uchar;E!==" "&&(x=!1),a.push(E)}return x?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var x=this.chars[this.pos];x.setPenState(this.currPenState)},g}(),d=function(){function g(u){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(u));this.logger=u,this.currRow=z-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=g.prototype;return c.reset=function(){for(var a=0;a<z;a++)this.rows[a].clear();this.currRow=z-1},c.equals=function(a){for(var x=!0,v=0;v<z;v++)if(!this.rows[v].equals(a.rows[v])){x=!1;break}return x},c.copy=function(a){for(var x=0;x<z;x++)this.rows[x].copy(a.rows[x])},c.isEmpty=function(){for(var a=!0,x=0;x<z;x++)if(!this.rows[x].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var x=this.rows[this.currRow];x.insertChar(a)},c.setPen=function(a){var x=this.rows[this.currRow];x.setPenStyles(a)},c.moveCursor=function(a){var x=this.rows[this.currRow];x.moveCursor(a)},c.setCursor=function(a){this.logger.log(k.INFO,"setCursor: "+a);var x=this.rows[this.currRow];x.setCursor(a)},c.setPAC=function(a){this.logger.log(k.INFO,"pacData = "+JSON.stringify(a));var x=a.row-1;if(this.nrRollUpRows&&x<this.nrRollUpRows-1&&(x=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==x){for(var v=0;v<z;v++)this.rows[v].clear();var E=this.currRow+1-this.nrRollUpRows,N=this.lastOutputScreen;if(N){var F=N.rows[E].cueStartTime,K=this.logger.time;if(F&&K!==null&&F<K)for(var V=0;V<this.nrRollUpRows;V++)this.rows[x-this.nrRollUpRows+V+1].copy(N.rows[E+V])}}this.currRow=x;var R=this.rows[this.currRow];if(a.indent!==null){var M=a.indent,$=Math.max(M-1,0);R.setCursor(a.indent),a.color=R.chars[$].penState.foreground}var ee={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ee)},c.setBkgData=function(a){this.logger.log(k.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(k.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(k.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,x=this.rows.splice(a,1)[0];x.clear(),this.rows.splice(this.currRow,0,x),this.logger.log(k.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var x=[],v="",E=-1,N=0;N<z;N++){var F=this.rows[N].getTextString();F&&(E=N+1,a?x.push("Row "+E+": '"+F+"'"):x.push(F.trim()))}return x.length>0&&(a?v="["+x.join(" | ")+"]":v=x.join(`
`)),v},c.getTextAndFormat=function(){return this.rows},g}(),C=function(){function g(u,a,x){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new d(x),this.nonDisplayedMemory=new d(x),this.lastOutputScreen=new d(x),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var c=g.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(k.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},c.insertChars=function(a){for(var x=0;x<a.length;x++)this.writeScreen.insertChar(a[x]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(k.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(k.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(k.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(k.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(k.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(a){this.logger.log(k.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},c.ccFON=function(){this.logger.log(k.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(k.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(k.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(k.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(k.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(k.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(k.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(k.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(k.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(k.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var x={flash:!1};if(x.underline=a%2===1,x.italics=a>=46,x.italics)x.foreground="white";else{var v=Math.floor(a/2)-16,E=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=E[v]}this.logger.log(k.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var x=this.logger.time;if(x===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},g}(),f=function(){function g(u,a,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new A;this.channels=[null,new C(u,a,v),new C(u+1,x,v)],this.cmdHistory=b(),this.logger=v}var c=g.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,x){this.channels[a].setHandler(x)},c.addData=function(a,x){var v,E,N,F=!1;this.logger.time=a;for(var K=0;K<x.length;K+=2){if(E=x[K]&127,N=x[K+1]&127,E===0&&N===0)continue;if(this.logger.log(k.DATA,"["+T([x[K],x[K+1]])+"] -> ("+T([E,N])+")"),v=this.parseCmd(E,N),v||(v=this.parseMidrow(E,N)),v||(v=this.parsePAC(E,N)),v||(v=this.parseBackgroundAttributes(E,N)),!v&&(F=this.parseChars(E,N),F)){var V=this.currentChannel;if(V&&V>0){var R=this.channels[V];R.insertChars(F)}else this.logger.log(k.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!F&&this.logger.log(k.WARNING,"Couldn't parse cleaned data "+T([E,N])+" orig: "+T([x[K],x[K+1]]))}},c.parseCmd=function(a,x){var v=this.cmdHistory,E=(a===20||a===28||a===21||a===29)&&x>=32&&x<=47,N=(a===23||a===31)&&x>=33&&x<=35;if(!(E||N))return!1;if(L(a,x,v))return p(null,null,v),this.logger.log(k.DEBUG,"Repeated command ("+T([a,x])+") is dropped"),!0;var F=a===20||a===21||a===23?1:2,K=this.channels[F];return a===20||a===21||a===28||a===29?x===32?K.ccRCL():x===33?K.ccBS():x===34?K.ccAOF():x===35?K.ccAON():x===36?K.ccDER():x===37?K.ccRU(2):x===38?K.ccRU(3):x===39?K.ccRU(4):x===40?K.ccFON():x===41?K.ccRDC():x===42?K.ccTR():x===43?K.ccRTD():x===44?K.ccEDM():x===45?K.ccCR():x===46?K.ccENM():x===47&&K.ccEOC():K.ccTO(x-32),p(a,x,v),this.currentChannel=F,!0},c.parseMidrow=function(a,x){var v=0;if((a===17||a===25)&&x>=32&&x<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(k.ERROR,"Mismatch channel in midrow parsing"),!1;var E=this.channels[v];return E?(E.ccMIDROW(x),this.logger.log(k.DEBUG,"MIDROW ("+T([a,x])+")"),!0):!1}return!1},c.parsePAC=function(a,x){var v,E=this.cmdHistory,N=(a>=17&&a<=23||a>=25&&a<=31)&&x>=64&&x<=127,F=(a===16||a===24)&&x>=64&&x<=95;if(!(N||F))return!1;if(L(a,x,E))return p(null,null,E),!0;var K=a<=23?1:2;x>=64&&x<=95?v=K===1?I[a]:y[a]:v=K===1?D[a]:w[a];var V=this.channels[K];return V?(V.setPAC(this.interpretPAC(v,x)),p(a,x,E),this.currentChannel=K,!0):!1},c.interpretPAC=function(a,x){var v,E={color:null,italics:!1,indent:null,underline:!1,row:a};return x>95?v=x-96:v=x-64,E.underline=(v&1)===1,v<=13?E.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(E.italics=!0,E.color="white"):E.indent=Math.floor((v-16)/2)*4,E},c.parseChars=function(a,x){var v,E=null,N=null;if(a>=25?(v=2,N=a-8):(v=1,N=a),N>=17&&N<=19){var F;N===17?F=x+80:N===18?F=x+112:F=x+144,this.logger.log(k.INFO,"Special char '"+P(F)+"' in channel "+v),E=[F]}else a>=32&&a<=127&&(E=x===0?[a]:[a,x]);if(E){var K=T(E);this.logger.log(k.DEBUG,"Char codes = "+K.join(",")),p(a,x,this.cmdHistory)}return E},c.parseBackgroundAttributes=function(a,x){var v=(a===16||a===24)&&x>=32&&x<=47,E=(a===23||a===31)&&x>=45&&x<=47;if(!(v||E))return!1;var N,F={};a===16||a===24?(N=Math.floor((x-32)/2),F.background=O[N],x%2===1&&(F.background=F.background+"_semi")):x===45?F.background="transparent":(F.foreground="black",x===47&&(F.underline=!0));var K=a<=23?1:2,V=this.channels[K];return V.setBkgData(F),p(a,x,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var x=this.channels[a];x&&x.reset()}this.cmdHistory=b()},c.cueSplitAtTime=function(a){for(var x=0;x<this.channels.length;x++){var v=this.channels[x];v&&v.cueSplitAtTime(a)}},g}();function p(g,c,u){u.a=g,u.b=c}function L(g,c,u){return u.a===g&&u.b===c}function b(){return{a:null,b:null}}Q.default=f},"./src/utils/codecs.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"isCodecType",function(){return B}),_.d(Q,"isCodecSupportedInMp4",function(){return P});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 B(z,W){var I=Z[W];return!!I&&I[z.slice(0,4)]===!0}function P(z,W){return MediaSource.isTypeSupported((W||"video")+'/mp4;codecs="'+z+'"')}},"./src/utils/cues.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/utils/vttparser.ts"),B=_("./src/utils/webvtt-parser.ts"),P=_("./src/utils/texttrack-utils.ts"),z=/\s/,W={newCue:function(D,y,w,O){for(var k=[],A,T,h,o,l,d=self.VTTCue||self.TextTrackCue,C=0;C<O.rows.length;C++)if(A=O.rows[C],h=!0,o=0,l="",!A.isEmpty()){for(var f=0;f<A.chars.length;f++)z.test(A.chars[f].uchar)&&h?o++:(l+=A.chars[f].uchar,h=!1);A.cueStartTime=y,y===w&&(w+=1e-4),o>=16?o--:o++;var p=Object(Z.fixLineBreaks)(l.trim()),L=Object(B.generateCueId)(y,w,p);(!D||!D.cues||!D.cues.getCueById(L))&&(T=new d(y,w,p),T.id=L,T.line=C+1,T.align="left",T.position=10+Math.min(80,Math.floor(o*8/32)*10),k.push(T))}return D&&k.length&&(k.sort(function(b,g){return b.line==="auto"||g.line==="auto"?0:b.line>8&&g.line>8?g.line-b.line:b.line-g.line}),k.forEach(function(b){return Object(P.addCueToTrack)(D,b)})),k}};Q.default=W},"./src/utils/discontinuities.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"findFirstFragWithCC",function(){return z}),_.d(Q,"shouldAlignOnDiscontinuities",function(){return W}),_.d(Q,"findDiscontinuousReferenceFrag",function(){return I}),_.d(Q,"adjustSlidingStart",function(){return y}),_.d(Q,"alignStream",function(){return w}),_.d(Q,"alignPDT",function(){return k}),_.d(Q,"alignFragmentByPDTDelta",function(){return A}),_.d(Q,"alignMediaPlaylistByPDT",function(){return T});var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/logger.ts"),P=_("./src/controller/level-helper.ts");function z(h,o){for(var l=null,d=0,C=h.length;d<C;d++){var f=h[d];if(f&&f.cc===o){l=f;break}}return l}function W(h,o,l){return!!(o.details&&(l.endCC>l.startCC||h&&h.cc<l.startCC))}function I(h,o){var l=h.fragments,d=o.fragments;if(!d.length||!l.length){B.logger.log("No fragments to align");return}var C=z(l,d[0].cc);if(!C||C&&!C.startPTS){B.logger.log("No frag in previous level to align on");return}return C}function D(h,o){if(h){var l=h.start+o;h.start=h.startPTS=l,h.endPTS=l+h.duration}}function y(h,o){for(var l=o.fragments,d=0,C=l.length;d<C;d++)D(l[d],h);o.fragmentHint&&D(o.fragmentHint,h),o.alignedSliding=!0}function w(h,o,l){if(!o)return;O(h,l,o),!l.alignedSliding&&o.details&&k(l,o.details),!l.alignedSliding&&o.details&&!l.skippedSegments&&Object(P.adjustSliding)(o.details,l)}function O(h,o,l){if(W(h,l,o)){var d=I(l.details,o);d&&Object(Z.isFiniteNumber)(d.start)&&(B.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),y(d.start,o))}}function k(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,d=h.fragments[0].programDateTime,C=(d-l)/1e3+o.fragments[0].start;C&&Object(Z.isFiniteNumber)(C)&&(B.logger.log("Adjusting PTS using programDateTime delta "+(d-l)+"ms, sliding:"+C.toFixed(3)+" "+h.url+" "),y(C,h))}function A(h,o){var l=h.programDateTime;if(!l)return;var d=(l-o)/1e3;h.start=h.startPTS=d,h.endPTS=d+h.duration}function T(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var l=o.fragments[0].programDateTime,d=o.fragments[0].start,C=l-d*1e3;h.fragments.forEach(function(f){A(f,C)}),h.fragmentHint&&A(h.fragmentHint,C),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/utils/ewma.ts"),B=function(){function P(W,I,D){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=D,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Z.default(W),this.fast_=new Z.default(I)}var z=P.prototype;return z.update=function(I,D){var y=this.slow_,w=this.fast_;this.slow_.halfLife!==I&&(this.slow_=new Z.default(I,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==D&&(this.fast_=new Z.default(D,w.getEstimate(),w.getTotalWeight()))},z.sample=function(I,D){I=Math.max(I,this.minDelayMs_);var y=8*D,w=I/1e3,O=y/w;this.fast_.sample(w,O),this.slow_.sample(w,O)},z.canEstimate=function(){var I=this.fast_;return I&&I.getTotalWeight()>=this.minWeight_},z.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},z.destroy=function(){},P}();Q.default=B},"./src/utils/ewma.ts":function(le,Q,_){"use strict";_.r(Q);var Z=function(){function B(z,W,I){W===void 0&&(W=0),I===void 0&&(I=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_=W,this.totalWeight_=I}var P=B.prototype;return P.sample=function(W,I){var D=Math.pow(this.alpha_,W);this.estimate_=I*(1-D)+D*this.estimate_,this.totalWeight_+=W},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var W=1-Math.pow(this.alpha_,this.totalWeight_);if(W)return this.estimate_/W}return this.estimate_},B}();Q.default=Z},"./src/utils/fetch-loader.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"fetchSupported",function(){return A});var Z=_("./src/polyfills/number.ts"),B=_("./src/loader/load-stats.ts"),P=_("./src/demux/chunk-cache.ts");function z(d,C){d.prototype=Object.create(C.prototype),d.prototype.constructor=d,w(d,C)}function W(d){var C=typeof Map=="function"?new Map:void 0;return W=function(p){if(p===null||!y(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof C!="undefined"){if(C.has(p))return C.get(p);C.set(p,L)}function L(){return I(p,arguments,O(this).constructor)}return L.prototype=Object.create(p.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),w(L,p)},W(d)}function I(d,C,f){return D()?I=Reflect.construct:I=function(L,b,g){var c=[null];c.push.apply(c,b);var u=Function.bind.apply(L,c),a=new u;return g&&w(a,g.prototype),a},I.apply(null,arguments)}function D(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(d){return!1}}function y(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function w(d,C){return w=Object.setPrototypeOf||function(p,L){return p.__proto__=L,p},w(d,C)}function O(d){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(f){return f.__proto__||Object.getPrototypeOf(f)},O(d)}function k(){return k=Object.assign||function(d){for(var C=1;C<arguments.length;C++){var f=arguments[C];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(d[p]=f[p])}return d},k.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var T=function(){function d(f){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=f.fetchSetup||o,this.controller=new self.AbortController,this.stats=new B.LoadStats}var C=d.prototype;return C.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},C.abortInternal=function(){var p=this.response;(!p||!p.ok)&&(this.stats.aborted=!0,this.controller.abort())},C.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},C.load=function(p,L,b){var g=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var u=h(p,this.controller.signal),a=b.onProgress,x=p.responseType==="arraybuffer",v=x?"byteLength":"length";this.context=p,this.config=L,this.callbacks=b,this.request=this.fetchSetup(p,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){g.abortInternal(),b.onTimeout(c,p,g.response)},L.timeout),self.fetch(this.request).then(function(E){if(g.response=g.loader=E,!E.ok){var N=E.status,F=E.statusText;throw new l(F||"fetch, bad network response",N,E)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(E.headers.get("Content-Length")||"0"),a&&Object(Z.isFiniteNumber)(L.highWaterMark)?g.loadProgressively(E,c,p,L.highWaterMark,a):x?E.arrayBuffer():E.text()}).then(function(E){var N=g.response;self.clearTimeout(g.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=E[v];var F={url:N.url,data:E};a&&!Object(Z.isFiniteNumber)(L.highWaterMark)&&a(c,p,E,N),b.onSuccess(F,c,p,N)}).catch(function(E){if(self.clearTimeout(g.requestTimeout),c.aborted)return;var N=E.code||0;b.onError({code:N,text:E.message},p,E.details)})},C.getCacheAge=function(){var p=null;if(this.response){var L=this.response.headers.get("age");p=L?parseFloat(L):null}return p},C.loadProgressively=function(p,L,b,g,c){g===void 0&&(g=0);var u=new P.default,a=p.body.getReader(),x=function v(){return a.read().then(function(E){if(E.done)return u.dataLength&&c(L,b,u.flush(),p),Promise.resolve(new ArrayBuffer(0));var N=E.value,F=N.length;return L.loaded+=F,F<g||u.dataLength?(u.push(N),u.dataLength>=g&&c(L,b,u.flush(),p)):c(L,b,N,p),v()}).catch(function(){return Promise.reject()})};return x()},d}();function h(d,C){var f={method:"GET",mode:"cors",credentials:"same-origin",signal:C,headers:new self.Headers(k({},d.headers))};return d.rangeEnd&&f.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),f}function o(d,C){return new self.Request(d.url,C)}var l=function(d){z(C,d);function C(f,p,L){var b;return b=d.call(this,f)||this,b.code=void 0,b.details=void 0,b.code=p,b.details=L,b}return C}(W(Error));Q.default=T},"./src/utils/imsc1-ttml-parser.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"IMSC1_CODEC",function(){return y}),_.d(Q,"parseIMSC1",function(){return A});var Z=_("./src/utils/mp4-tools.ts"),B=_("./src/utils/vttparser.ts"),P=_("./src/utils/vttcue.ts"),z=_("./src/demux/id3.ts"),W=_("./src/utils/timescale-conversion.ts"),I=_("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign||function(g){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(g[a]=u[a])}return g},D.apply(this,arguments)}var y="stpp.ttml.im1t",w=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,O=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,k={left:"start",center:"center",right:"end",start:"start",end:"end"};function A(g,c,u,a,x){var v=Object(Z.findBox)(new Uint8Array(g),["mdat"]);if(v.length===0){x(new Error("Could not parse IMSC1 mdat"));return}var E=v[0],N=Object(z.utf8ArrayToStr)(new Uint8Array(g,E.start,E.end-E.start)),F=Object(W.toTimescaleFromScale)(c,1,u);try{a(T(N,F))}catch(K){x(K)}}function T(g,c){var u=new DOMParser,a=u.parseFromString(g,"text/xml"),x=a.getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},E=Object.keys(v).reduce(function(R,M){return R[M]=x.getAttribute("ttp:"+M)||v[M],R},{}),N=x.getAttribute("xml:space")!=="preserve",F=o(h(x,"styling","style")),K=o(h(x,"layout","region")),V=h(x,"body","[begin]");return[].map.call(V,function(R){var M=l(R,N);if(!M||!R.hasAttribute("begin"))return null;var $=p(R.getAttribute("begin"),E),ee=p(R.getAttribute("dur"),E),ae=p(R.getAttribute("end"),E);if($===null)throw f(R);if(ae===null){if(ee===null)throw f(R);ae=$+ee}var fe=new P.default($-c,ae-c,M);fe.id=Object(I.generateCueId)(fe.startTime,fe.endTime,fe.text);var De=K[R.getAttribute("region")],Se=F[R.getAttribute("style")];fe.position=10,fe.size=80;var Ce=d(De,Se),we=Ce.textAlign;if(we){var Te=k[we];Te&&(fe.lineAlign=Te),fe.align=we}return D(fe,Ce),fe}).filter(function(R){return R!==null})}function h(g,c,u){var a=g.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function o(g){return g.reduce(function(c,u){var a=u.getAttribute("xml:id");return a&&(c[a]=u),c},{})}function l(g,c){return[].slice.call(g.childNodes).reduce(function(u,a,x){var v;return a.nodeName==="br"&&x?u+`
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?l(a,c):c?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function d(g,c){var u="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(x,v){var E=C(c,u,v)||C(g,u,v);return E&&(x[v]=E),x},{})}function C(g,c,u){return g.hasAttributeNS(c,u)?g.getAttributeNS(c,u):null}function f(g){return new Error("Could not parse ttml timestamp "+g)}function p(g,c){if(!g)return null;var u=Object(B.parseTimeStamp)(g);return u===null&&(w.test(g)?u=L(g,c):O.test(g)&&(u=b(g,c))),u}function L(g,c){var u=w.exec(g),a=(u[4]|0)+(u[5]|0)/c.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/c.frameRate}function b(g,c){var u=O.exec(g),a=Number(u[1]),x=u[2];switch(x){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"enableLogs",function(){return I}),_.d(Q,"logger",function(){return D});var Z=function(){},B={trace:Z,debug:Z,log:Z,warn:Z,info:Z,error:Z},P=B;function z(y){var w=self.console[y];return w?w.bind(self.console,"["+y+"] >"):Z}function W(y){for(var w=arguments.length,O=new Array(w>1?w-1:0),k=1;k<w;k++)O[k-1]=arguments[k];O.forEach(function(A){P[A]=y[A]?y[A].bind(y):z(A)})}function I(y){if(self.console&&y===!0||typeof y=="object"){W(y,"debug","log","info","warn","error");try{P.log()}catch(w){P=B}}else P=B}var D=P},"./src/utils/mediakeys-helper.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"KeySystems",function(){return Z}),_.d(Q,"requestMediaKeySystemAccess",function(){return B});var Z;(function(P){P.WIDEVINE="com.widevine.alpha",P.PLAYREADY="com.microsoft.playready"})(Z||(Z={}));var B=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"getMediaSource",function(){return Z});function Z(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"bin2str",function(){return W}),_.d(Q,"readUint16",function(){return I}),_.d(Q,"readUint32",function(){return D}),_.d(Q,"writeUint32",function(){return y}),_.d(Q,"findBox",function(){return w}),_.d(Q,"parseSegmentIndex",function(){return O}),_.d(Q,"parseInitSegment",function(){return k}),_.d(Q,"getStartDTS",function(){return A}),_.d(Q,"getDuration",function(){return T}),_.d(Q,"computeRawDurationFromSamples",function(){return h}),_.d(Q,"offsetStartDTS",function(){return o}),_.d(Q,"segmentValidRange",function(){return l}),_.d(Q,"appendUint8Array",function(){return d});var Z=_("./src/utils/typed-array.ts"),B=_("./src/loader/fragment.ts"),P=Math.pow(2,32)-1,z=[].push;function W(C){return String.fromCharCode.apply(null,C)}function I(C,f){"data"in C&&(f+=C.start,C=C.data);var p=C[f]<<8|C[f+1];return p<0?65536+p:p}function D(C,f){"data"in C&&(f+=C.start,C=C.data);var p=C[f]<<24|C[f+1]<<16|C[f+2]<<8|C[f+3];return p<0?4294967296+p:p}function y(C,f,p){"data"in C&&(f+=C.start,C=C.data),C[f]=p>>24,C[f+1]=p>>16&255,C[f+2]=p>>8&255,C[f+3]=p&255}function w(C,f){var p=[];if(!f.length)return p;var L,b,g;"data"in C?(L=C.data,b=C.start,g=C.end):(L=C,b=0,g=L.byteLength);for(var c=b;c<g;){var u=D(L,c),a=W(L.subarray(c+4,c+8)),x=u>1?c+u:g;if(a===f[0])if(f.length===1)p.push({data:L,start:c+8,end:x});else{var v=w({data:L,start:c+8,end:x},f.slice(1));v.length&&z.apply(p,v)}c=x}return p}function O(C){var f=w(C,["moov"]),p=f[0],L=p?p.end:null,b=w(C,["sidx"]);if(!b||!b[0])return null;var g=[],c=b[0],u=c.data[0],a=u===0?8:16,x=D(c,a);a+=4;var v=0,E=0;u===0?a+=8:a+=16,a+=2;var N=c.end+E,F=I(c,a);a+=2;for(var K=0;K<F;K++){var V=a,R=D(c,V);V+=4;var M=R&2147483647,$=(R&2147483648)>>>31;if($===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ee=D(c,V);V+=4,g.push({referenceSize:M,subsegmentDuration:ee,info:{duration:ee/x,start:N,end:N+M-1}}),N+=M,V+=4,a=V}return{earliestPresentationTime:v,timescale:x,version:u,referencesCount:F,references:g,moovEndOffset:L}}function k(C){for(var f=[],p=w(C,["moov","trak"]),L=0;L<p.length;L++){var b=p[L],g=w(b,["tkhd"])[0];if(g){var c=g.data[g.start],u=c===0?12:20,a=D(g,u),x=w(b,["mdia","mdhd"])[0];if(x){c=x.data[x.start],u=c===0?12:20;var v=D(x,u),E=w(b,["mdia","hdlr"])[0];if(E){var N=W(E.data.subarray(E.start+8,E.start+12)),F={soun:B.ElementaryStreamTypes.AUDIO,vide:B.ElementaryStreamTypes.VIDEO}[N];if(F){var K=w(b,["mdia","minf","stbl","stsd"])[0],V=void 0;K&&(V=W(K.data.subarray(K.start+12,K.start+16))),f[a]={timescale:v,type:F},f[F]={timescale:v,id:a,codec:V}}}}}}var R=w(C,["moov","mvex","trex"]);return R.forEach(function(M){var $=D(M,4),ee=f[$];ee&&(ee.default={duration:D(M,12),flags:D(M,20)})}),f}function A(C,f){return w(f,["moof","traf"]).reduce(function(p,L){var b=w(L,["tfdt"])[0],g=b.data[b.start],c=w(L,["tfhd"]).reduce(function(u,a){var x=D(a,4),v=C[x];if(v){var E=D(b,4);g===1&&(E*=Math.pow(2,32),E+=D(b,8));var N=v.timescale||9e4,F=E/N;if(isFinite(F)&&(u===null||F<u))return F}return u},null);return c!==null&&isFinite(c)&&(p===null||c<p)?c:p},null)||0}function T(C,f){for(var p=0,L=0,b=0,g=w(C,["moof","traf"]),c=0;c<g.length;c++){var u=g[c],a=w(u,["tfhd"])[0],x=D(a,4),v=f[x];if(!v)continue;var E=v.default,N=D(a,0)|(E==null?void 0:E.flags),F=E==null?void 0:E.duration;N&8&&(N&2?F=D(a,12):F=D(a,8));for(var K=v.timescale||9e4,V=w(u,["trun"]),R=0;R<V.length;R++){if(F){var M=D(V[R],4);p=F*M}else p=h(V[R]);v.type===B.ElementaryStreamTypes.VIDEO?L+=p/K:v.type===B.ElementaryStreamTypes.AUDIO&&(b+=p/K)}}if(L===0&&b===0){var $=O(C);if($!=null&&$.references)return $.references.reduce(function(ee,ae){return ee+ae.info.duration||0},0)}return L||b}function h(C){var f=D(C,0),p=8;f&1&&(p+=4),f&4&&(p+=4);for(var L=0,b=D(C,4),g=0;g<b;g++){if(f&256){var c=D(C,p);L+=c,p+=4}f&512&&(p+=4),f&1024&&(p+=4),f&2048&&(p+=4)}return L}function o(C,f,p){w(f,["moof","traf"]).forEach(function(L){w(L,["tfhd"]).forEach(function(b){var g=D(b,4),c=C[g];if(!c)return;var u=c.timescale||9e4;w(L,["tfdt"]).forEach(function(a){var x=a.data[a.start],v=D(a,4);if(x===0)y(a,4,v-p*u);else{v*=Math.pow(2,32),v+=D(a,8),v-=p*u,v=Math.max(v,0);var E=Math.floor(v/(P+1)),N=Math.floor(v%(P+1));y(a,4,E),y(a,8,N)}})})})}function l(C){var f={valid:null,remainder:null},p=w(C,["moof"]);if(p){if(p.length<2)return f.remainder=C,f}else return f;var L=p[p.length-1];return f.valid=Object(Z.sliceUint8)(C,0,L.start-8),f.remainder=Object(Z.sliceUint8)(C,L.start-8),f}function d(C,f){var p=new Uint8Array(C.length+f.length);return p.set(C),p.set(f,C.length),p}},"./src/utils/output-filter.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"default",function(){return Z});var Z=function(){function B(z,W){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=W}var P=B.prototype;return P.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},P.newCue=function(W,I,D){(this.startTime===null||this.startTime>W)&&(this.startTime=W),this.endTime=I,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},P.reset=function(){this.cueRanges=[]},B}()},"./src/utils/texttrack-utils.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"sendAddTrackEvent",function(){return B}),_.d(Q,"addCueToTrack",function(){return P}),_.d(Q,"clearCurrentCues",function(){return z}),_.d(Q,"removeCuesInRange",function(){return W}),_.d(Q,"getCuesInRange",function(){return D});var Z=_("./src/utils/logger.ts");function B(y,w){var O;try{O=new Event("addtrack")}catch(k){O=document.createEvent("Event"),O.initEvent("addtrack",!1,!1)}O.track=y,w.dispatchEvent(O)}function P(y,w){var O=y.mode;if(O==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(w.id))try{if(y.addCue(w),!y.cues.getCueById(w.id))throw new Error("addCue is failed for: "+w)}catch(A){Z.logger.debug("[texttrack-utils]: "+A);var k=new self.TextTrackCue(w.startTime,w.endTime,w.text);k.id=w.id,y.addCue(k)}O==="disabled"&&(y.mode=O)}function z(y){var w=y.mode;if(w==="disabled"&&(y.mode="hidden"),y.cues)for(var O=y.cues.length;O--;)y.removeCue(y.cues[O]);w==="disabled"&&(y.mode=w)}function W(y,w,O){var k=y.mode;if(k==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var A=D(y.cues,w,O),T=0;T<A.length;T++)y.removeCue(A[T]);k==="disabled"&&(y.mode=k)}function I(y,w){if(w<y[0].startTime)return 0;var O=y.length-1;if(w>y[O].endTime)return-1;for(var k=0,A=O;k<=A;){var T=Math.floor((A+k)/2);if(w<y[T].startTime)A=T-1;else if(w>y[T].startTime&&k<O)k=T+1;else return T}return y[k].startTime-w<w-y[A].startTime?k:A}function D(y,w,O){var k=[],A=I(y,w);if(A>-1)for(var T=A,h=y.length;T<h;T++){var o=y[T];if(o.startTime>=w&&o.endTime<=O)k.push(o);else if(o.startTime>O)return k}return k}},"./src/utils/time-ranges.ts":function(le,Q,_){"use strict";_.r(Q);var Z={toString:function(P){for(var z="",W=P.length,I=0;I<W;I++)z+="["+P.start(I).toFixed(3)+","+P.end(I).toFixed(3)+"]";return z}};Q.default=Z},"./src/utils/timescale-conversion.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"toTimescaleFromBase",function(){return B}),_.d(Q,"toTimescaleFromScale",function(){return P}),_.d(Q,"toMsFromMpegTsClock",function(){return z}),_.d(Q,"toMpegTsClockFromTimescale",function(){return W});var Z=9e4;function B(I,D,y,w){y===void 0&&(y=1),w===void 0&&(w=!1);var O=I*D*y;return w?Math.round(O):O}function P(I,D,y,w){return y===void 0&&(y=1),w===void 0&&(w=!1),B(I,D,1/y,w)}function z(I,D){return D===void 0&&(D=!1),B(I,1e3,1/Z,D)}function W(I,D){return D===void 0&&(D=1),B(I,Z,1/D)}},"./src/utils/typed-array.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"sliceUint8",function(){return Z});function Z(B,P,z){return Uint8Array.prototype.slice?B.slice(P,z):new Uint8Array(Array.prototype.slice.call(B,P,z))}},"./src/utils/vttcue.ts":function(le,Q,_){"use strict";_.r(Q),Q.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var Z=["","lr","rl"],B=["start","middle","end","left","right"];function P(y,w){if(typeof w!="string")return!1;if(!Array.isArray(y))return!1;var O=w.toLowerCase();return~y.indexOf(O)?O:!1}function z(y){return P(Z,y)}function W(y){return P(B,y)}function I(y){for(var w=arguments.length,O=new Array(w>1?w-1:0),k=1;k<w;k++)O[k-1]=arguments[k];for(var A=1;A<arguments.length;A++){var T=arguments[A];for(var h in T)y[h]=T[h]}return y}function D(y,w,O){var k=this,A={enumerable:!0};k.hasBeenReset=!1;var T="",h=!1,o=y,l=w,d=O,C=null,f="",p=!0,L="auto",b="start",g=50,c="middle",u=50,a="middle";Object.defineProperty(k,"id",I({},A,{get:function(){return T},set:function(v){T=""+v}})),Object.defineProperty(k,"pauseOnExit",I({},A,{get:function(){return h},set:function(v){h=!!v}})),Object.defineProperty(k,"startTime",I({},A,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"endTime",I({},A,{get:function(){return l},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"text",I({},A,{get:function(){return d},set:function(v){d=""+v,this.hasBeenReset=!0}})),Object.defineProperty(k,"region",I({},A,{get:function(){return C},set:function(v){C=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"vertical",I({},A,{get:function(){return f},set:function(v){var E=z(v);if(E===!1)throw new SyntaxError("An invalid or illegal string was specified.");f=E,this.hasBeenReset=!0}})),Object.defineProperty(k,"snapToLines",I({},A,{get:function(){return p},set:function(v){p=!!v,this.hasBeenReset=!0}})),Object.defineProperty(k,"line",I({},A,{get:function(){return L},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"lineAlign",I({},A,{get:function(){return b},set:function(v){var E=W(v);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");b=E,this.hasBeenReset=!0}})),Object.defineProperty(k,"position",I({},A,{get:function(){return g},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");g=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"positionAlign",I({},A,{get:function(){return c},set:function(v){var E=W(v);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");c=E,this.hasBeenReset=!0}})),Object.defineProperty(k,"size",I({},A,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(k,"align",I({},A,{get:function(){return a},set:function(v){var E=W(v);if(!E)throw new SyntaxError("An invalid or illegal string was specified.");a=E,this.hasBeenReset=!0}})),k.displayState=void 0}return D.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},D}()},"./src/utils/vttparser.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"parseTimeStamp",function(){return P}),_.d(Q,"fixLineBreaks",function(){return w}),_.d(Q,"VTTParser",function(){return O});var Z=_("./src/utils/vttcue.ts"),B=function(){function k(){}var A=k.prototype;return A.decode=function(h,o){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},k}();function P(k){function A(h,o,l,d){return(h|0)*3600+(o|0)*60+(l|0)+parseFloat(d||0)}var T=k.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return T?parseFloat(T[2])>59?A(T[2],T[3],0,T[4]):A(T[1],T[2],T[3],T[4]):null}var z=function(){function k(){this.values=Object.create(null)}var A=k.prototype;return A.set=function(h,o){!this.get(h)&&o!==""&&(this.values[h]=o)},A.get=function(h,o,l){return l?this.has(h)?this.values[h]:o[l]:this.has(h)?this.values[h]:o},A.has=function(h){return h in this.values},A.alt=function(h,o,l){for(var d=0;d<l.length;++d)if(o===l[d]){this.set(h,o);break}},A.integer=function(h,o){/^-?\d+$/.test(o)&&this.set(h,parseInt(o,10))},A.percent=function(h,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var l=parseFloat(o);if(l>=0&&l<=100)return this.set(h,l),!0}return!1},k}();function W(k,A,T,h){var o=h?k.split(h):[k];for(var l in o){if(typeof o[l]!="string")continue;var d=o[l].split(T);if(d.length!==2)continue;var C=d[0],f=d[1];A(C,f)}}var I=new Z.default(0,0,""),D=I.align==="middle"?"middle":"center";function y(k,A,T){var h=k;function o(){var C=P(k);if(C===null)throw new Error("Malformed timestamp: "+h);return k=k.replace(/^[^\sa-zA-Z-]+/,""),C}function l(C,f){var p=new z;W(C,function(g,c){var u;switch(g){case"region":for(var a=T.length-1;a>=0;a--)if(T[a].id===c){p.set(g,T[a].region);break}break;case"vertical":p.alt(g,c,["rl","lr"]);break;case"line":u=c.split(","),p.integer(g,u[0]),p.percent(g,u[0])&&p.set("snapToLines",!1),p.alt(g,u[0],["auto"]),u.length===2&&p.alt("lineAlign",u[1],["start",D,"end"]);break;case"position":u=c.split(","),p.percent(g,u[0]),u.length===2&&p.alt("positionAlign",u[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":p.percent(g,c);break;case"align":p.alt(g,c,["start",D,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");var L=p.get("line","auto");L==="auto"&&I.line===-1&&(L=-1),f.line=L,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",D);var b=p.get("position","auto");b==="auto"&&I.position===50&&(b=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=b}function d(){k=k.replace(/^\s+/,"")}if(d(),A.startTime=o(),d(),k.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);k=k.substr(3),d(),A.endTime=o(),d(),l(k,A)}function w(k){return k.replace(/<br(?: \/)?>/gi,`
`)}var O=function(){function k(){this.state="INITIAL",this.buffer="",this.decoder=new B,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=k.prototype;return A.parse=function(h){var o=this;h&&(o.buffer+=o.decoder.decode(h,{stream:!0}));function l(){var b=o.buffer,g=0;for(b=w(b);g<b.length&&b[g]!=="\r"&&b[g]!==`
`;)++g;var c=b.substr(0,g);return b[g]==="\r"&&++g,b[g]===`
`&&++g,o.buffer=b.substr(g),c}function d(b){W(b,function(g,c){},/:/)}try{var C="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;C=l();var f=C.match(/^()?WEBVTT([ \t].*)?$/);if(!f||!f[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var p=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;p?p=!1:C=l();switch(o.state){case"HEADER":/:/.test(C)?d(C):C||(o.state="ID");continue;case"NOTE":C||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(C)){o.state="NOTE";break}if(!C)continue;if(o.cue=new Z.default(0,0,""),o.state="CUE",C.indexOf("-->")===-1){o.cue.id=C;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{y(C,o.cue,o.regionList)}catch(b){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var L=C.indexOf("-->")!==-1;if(!C||L&&(p=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
`),o.cue.text+=C}continue;case"BADCUE":C||(o.state="ID")}}}catch(b){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 h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){h.onparsingerror&&h.onparsingerror(o)}return h.onflush&&h.onflush(),this},k}()},"./src/utils/webvtt-parser.ts":function(le,Q,_){"use strict";_.r(Q),_.d(Q,"generateCueId",function(){return O}),_.d(Q,"parseWebVTT",function(){return A});var Z=_("./src/polyfills/number.ts"),B=_("./src/utils/vttparser.ts"),P=_("./src/demux/id3.ts"),z=_("./src/utils/timescale-conversion.ts"),W=_("./src/remux/mp4-remuxer.ts"),I=/\r\n|\n\r|\n|\r/g,D=function(h,o,l){return l===void 0&&(l=0),h.substr(l,o.length)===o},y=function(h){var o=parseInt(h.substr(-3)),l=parseInt(h.substr(-6,2)),d=parseInt(h.substr(-9,2)),C=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(Z.isFiniteNumber)(o)||!Object(Z.isFiniteNumber)(l)||!Object(Z.isFiniteNumber)(d)||!Object(Z.isFiniteNumber)(C))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*l,o+=60*1e3*d,o+=60*60*1e3*C,o},w=function(h){for(var o=5381,l=h.length;l;)o=o*33^h.charCodeAt(--l);return(o>>>0).toString()};function O(T,h,o){return w(T.toString())+w(h.toString())+w(o)}var k=function(h,o,l){var d=h[o],C=h[d.prevCC];if(!C||!C.new&&d.new){h.ccOffset=h.presentationOffset=d.start,d.new=!1;return}for(;(f=C)!==null&&f!==void 0&&f.new;){var f;h.ccOffset+=d.start-C.start,d.new=!1,d=C,C=h[d.prevCC]}h.presentationOffset=l};function A(T,h,o,l,d,C,f,p){var L=new B.VTTParser,b=Object(P.utf8ArrayToStr)(new Uint8Array(T)).trim().replace(I,`
`).split(`
`),g=[],c=Object(z.toMpegTsClockFromTimescale)(h,o),u="00:00.000",a=0,x=0,v,E=!0,N=!1;L.oncue=function(F){var K=l[d],V=l.ccOffset,R=(a-c)/9e4;if(K!=null&&K.new&&(x!==void 0?V=l.ccOffset=K.start:k(l,d,R)),R&&(V=R-l.presentationOffset),N){var M=F.endTime-F.startTime,$=Object(W.normalizePts)((F.startTime+V-x)*9e4,C*9e4)/9e4;F.startTime=$,F.endTime=$+M}var ee=F.text.trim();F.text=decodeURIComponent(encodeURIComponent(ee)),F.id||(F.id=O(F.startTime,F.endTime,ee)),F.endTime>0&&g.push(F)},L.onparsingerror=function(F){v=F},L.onflush=function(){if(v){p(v);return}f(g)},b.forEach(function(F){if(E)if(D(F,"X-TIMESTAMP-MAP=")){E=!1,N=!0,F.substr(16).split(",").forEach(function(K){D(K,"LOCAL:")?u=K.substr(6):D(K,"MPEGTS:")&&(a=parseInt(K.substr(7)))});try{x=y(u)/1e3}catch(K){N=!1,v=K}return}else F===""&&(E=!1);L.parse(F+`
`)}),L.flush()}},"./src/utils/xhr-loader.ts":function(le,Q,_){"use strict";_.r(Q);var Z=_("./src/utils/logger.ts"),B=_("./src/loader/load-stats.ts"),P=/^age:\s*[\d.]+\s*$/m,z=function(){function W(D){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=D?D.xhrSetup:null,this.stats=new B.LoadStats,this.retryDelay=0}var I=W.prototype;return I.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},I.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},I.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},I.load=function(y,w,O){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=w,this.callbacks=O,this.retryDelay=w.retryDelay,this.loadInternal()},I.loadInternal=function(){var y=this.config,w=this.context;if(!y)return;var O=this.loader=new self.XMLHttpRequest,k=this.stats;k.loading.first=0,k.loaded=0;var A=this.xhrSetup;try{if(A)try{A(O,w.url)}catch(o){O.open("GET",w.url,!0),A(O,w.url)}O.readyState||O.open("GET",w.url,!0);var T=this.context.headers;if(T)for(var h in T)O.setRequestHeader(h,T[h])}catch(o){this.callbacks.onError({code:O.status,text:o.message},w,O);return}w.rangeEnd&&O.setRequestHeader("Range","bytes="+w.rangeStart+"-"+(w.rangeEnd-1)),O.onreadystatechange=this.readystatechange.bind(this),O.onprogress=this.loadprogress.bind(this),O.responseType=w.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),O.send()},I.readystatechange=function(){var y=this.context,w=this.loader,O=this.stats;if(!y||!w)return;var k=w.readyState,A=this.config;if(O.aborted)return;if(k>=2)if(self.clearTimeout(this.requestTimeout),O.loading.first===0&&(O.loading.first=Math.max(self.performance.now(),O.loading.start)),k===4){w.onreadystatechange=null,w.onprogress=null;var T=w.status;if(T>=200&&T<300){O.loading.end=Math.max(self.performance.now(),O.loading.first);var h,o;if(y.responseType==="arraybuffer"?(h=w.response,o=h.byteLength):(h=w.responseText,o=h.length),O.loaded=O.total=o,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(O,y,h,w),!this.callbacks)return;var d={url:w.responseURL,data:h};this.callbacks.onSuccess(d,O,y,w)}else O.retry>=A.maxRetry||T>=400&&T<499?(Z.logger.error(T+" while loading "+y.url),this.callbacks.onError({code:T,text:w.statusText},y,w)):(Z.logger.warn(T+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,A.maxRetryDelay),O.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)},I.loadtimeout=function(){Z.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},I.loadprogress=function(y){var w=this.stats;w.loaded=y.loaded,y.lengthComputable&&(w.total=y.total)},I.getCacheAge=function(){var y=null;if(this.loader&&P.test(this.loader.getAllResponseHeaders())){var w=this.loader.getResponseHeader("age");y=w?parseFloat(w):null}return y},W}();Q.default=z}}).default})},vHTk:function(xt,at,se){xt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);