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

366 lines
957 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[305,6,7,14],{"+NIl":function(ut,Ze,re){(function(le){le(re("VrN/"))})(function(le){"use strict";le.defineMode("stex",function($,R){"use strict";function Z(T,C){T.cmdState.push(C)}function F(T){return T.cmdState.length>0?T.cmdState[T.cmdState.length-1]:null}function P(T){var C=T.cmdState.pop();C&&C.closeBracket()}function K(T){for(var C=T.cmdState,b=C.length-1;b>=0;b--){var u=C[b];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function j(T,C,b){return function(){this.name=T,this.bracketNo=0,this.style=C,this.styles=b,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var N={};N.importmodule=j("importmodule","tag",["string","builtin"]),N.documentclass=j("documentclass","tag",["","atom"]),N.usepackage=j("usepackage","tag",["atom"]),N.begin=j("begin","tag",["atom"]),N.end=j("end","tag",["atom"]),N.label=j("label","tag",["atom"]),N.ref=j("ref","tag",["atom"]),N.eqref=j("eqref","tag",["atom"]),N.cite=j("cite","tag",["atom"]),N.bibitem=j("bibitem","tag",["atom"]),N.Bibitem=j("Bibitem","tag",["atom"]),N.RBibitem=j("RBibitem","tag",["atom"]),N.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function D(T,C){T.f=C}function y(T,C){var b;if(T.match(/^\\[a-zA-Z@]+/)){var u=T.current().slice(1);return b=N.hasOwnProperty(u)?N[u]:N.DEFAULT,b=new b,Z(C,b),D(C,k),b.style}if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/\\]/))return"tag";if(T.match("\\["))return D(C,function(l,d){return A(l,d,"\\]")}),"keyword";if(T.match("\\("))return D(C,function(l,d){return A(l,d,"\\)")}),"keyword";if(T.match("$$"))return D(C,function(l,d){return A(l,d,"$$")}),"keyword";if(T.match("$"))return D(C,function(l,d){return A(l,d,"$")}),"keyword";var a=T.next();if(a=="%")return T.skipToEnd(),"comment";if(a=="}"||a=="]"){if(b=F(C),b)b.closeBracket(a),D(C,k);else return"error";return"bracket"}else return a=="{"||a=="["?(b=N.DEFAULT,b=new b,Z(C,b),"bracket"):/\d/.test(a)?(T.eatWhile(/[\w.%]/),"atom"):(T.eatWhile(/[\w\-_]/),b=K(C),b.name=="begin"&&(b.argument=T.current()),b.styleIdentifier())}function A(T,C,b){if(T.eatSpace())return null;if(b&&T.match(b))return D(C,y),"keyword";if(T.match(/^\\[a-zA-Z@]+/))return"tag";if(T.match(/^[a-zA-Z]+/))return"variable-2";if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/]/))return"tag";if(T.match(/^[\^_&]/))return"tag";if(T.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(T.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=T.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(T.skipToEnd(),"comment"):"error"}function k(T,C){var b=T.peek(),u;return b=="{"||b=="["?(u=F(C),u.openBracket(b),T.eat(b),D(C,y),"bracket"):/[ \t\r]/.test(b)?(T.eat(b),null):(D(C,y),P(C),y(T,C))}return{startState:function(){var T=R.inMathMode?function(C,b){return A(C,b)}:y;return{cmdState:[],f:T}},copyState:function(T){return{cmdState:T.cmdState.slice(),f:T.f}},token:function(T,C){return C.f(T,C)},blankLine:function(T){T.f=y,T.cmdState.length=0},lineComment:"%"}}),le.defineMIME("text/x-stex","stex"),le.defineMIME("text/x-latex","stex")})},"19Vz":function(ut,Ze,re){(function(le){le(re("VrN/"))})(function(le){le.defineOption("placeholder","",function(j,N,D){var y=D&&D!=le.Init;if(N&&!y)j.on("blur",F),j.on("change",P),j.on("swapDoc",P),le.on(j.getInputField(),"compositionupdate",j.state.placeholderCompose=function(){Z(j)}),P(j);else if(!N&&y){j.off("blur",F),j.off("change",P),j.off("swapDoc",P),le.off(j.getInputField(),"compositionupdate",j.state.placeholderCompose),$(j);var A=j.getWrapperElement();A.className=A.className.replace(" CodeMirror-empty","")}N&&!j.hasFocus()&&F(j)});function $(j){j.state.placeholder&&(j.state.placeholder.parentNode.removeChild(j.state.placeholder),j.state.placeholder=null)}function R(j){$(j);var N=j.state.placeholder=document.createElement("pre");N.style.cssText="height: 0; overflow: visible",N.style.direction=j.getOption("direction"),N.className="CodeMirror-placeholder CodeMirror-line-like";var D=j.getOption("placeholder");typeof D=="string"&&(D=document.createTextNode(D)),N.appendChild(D),j.display.lineSpace.insertBefore(N,j.display.lineSpace.firstChild)}function Z(j){setTimeout(function(){var N=!1,D=j.getInputField();D.nodeName=="TEXTAREA"?N=!D.value:j.lineCount()==1&&(N=!/[^\u200b]/.test(D.querySelector(".CodeMirror-line").textContent)),N?R(j):$(j)},20)}function F(j){K(j)&&R(j)}function P(j){var N=j.getWrapperElement(),D=K(j);N.className=N.className.replace(" CodeMirror-empty","")+(D?" CodeMirror-empty":""),D?R(j):$(j)}function K(j){return j.lineCount()===1&&j.getLine(0)===""}})},"1ZF9":function(ut,Ze,re){ut.exports=re.p+"static/Authorize.cc9c212f.png"},"1eCo":function(ut,Ze,re){(function(le){le(re("VrN/"))})(function(le){"use strict";var $={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},R={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};le.defineMode("xml",function(Z,F){var P=Z.indentUnit,K={},j=F.htmlMode?$:R;for(var N in j)K[N]=j[N];for(var N in F)K[N]=F[N];var D,y;function A(o,E){function g(U){return E.tokenize=U,U(o,E)}var S=o.next();if(S=="<")return o.eat("!")?o.eat("[")?o.match("CDATA[")?g(C("atom","]]>")):null:o.match("--")?g(C("comment","-->")):o.match("DOCTYPE",!0,!0)?(o.eatWhile(/[\w\._\-]/),g(b(1))):null:o.eat("?")?(o.eatWhile(/[\w\._\-]/),E.tokenize=C("meta","?>"),"meta"):(D=o.eat("/")?"closeTag":"openTag",E.tokenize=k,"tag bracket");if(S=="&"){var M;return o.eat("#")?o.eat("x")?M=o.eatWhile(/[a-fA-F\d]/)&&o.eat(";"):M=o.eatWhile(/[\d]/)&&o.eat(";"):M=o.eatWhile(/[\w\.\-:]/)&&o.eat(";"),M?"atom":"error"}else return o.eatWhile(/[^&<]/),null}A.isInText=!0;function k(o,E){var g=o.next();if(g==">"||g=="/"&&o.eat(">"))return E.tokenize=A,D=g==">"?"endTag":"selfcloseTag","tag bracket";if(g=="=")return D="equals",null;if(g=="<"){E.tokenize=A,E.state=d,E.tagName=E.tagStart=null;var S=E.tokenize(o,E);return S?S+" tag error":"tag error"}else return/[\'\"]/.test(g)?(E.tokenize=T(g),E.stringStartCol=o.column(),E.tokenize(o,E)):(o.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function T(o){var E=function(g,S){for(;!g.eol();)if(g.next()==o){S.tokenize=k;break}return"string"};return E.isInAttribute=!0,E}function C(o,E){return function(g,S){for(;!g.eol();){if(g.match(E)){S.tokenize=A;break}g.next()}return o}}function b(o){return function(E,g){for(var S;(S=E.next())!=null;){if(S=="<")return g.tokenize=b(o+1),g.tokenize(E,g);if(S==">")if(o==1){g.tokenize=A;break}else return g.tokenize=b(o-1),g.tokenize(E,g)}return"meta"}}function u(o,E,g){this.prev=o.context,this.tagName=E,this.indent=o.indented,this.startOfLine=g,(K.doNotIndent.hasOwnProperty(E)||o.context&&o.context.noIndent)&&(this.noIndent=!0)}function a(o){o.context&&(o.context=o.context.prev)}function l(o,E){for(var g;;){if(!o.context)return;if(g=o.context.tagName,!K.contextGrabbers.hasOwnProperty(g)||!K.contextGrabbers[g].hasOwnProperty(E))return;a(o)}}function d(o,E,g){return o=="openTag"?(g.tagStart=E.column(),_):o=="closeTag"?v:d}function _(o,E,g){return o=="word"?(g.tagName=E.current(),y="tag",x):K.allowMissingTagName&&o=="endTag"?(y="tag bracket",x(o,E,g)):(y="error",_)}function v(o,E,g){if(o=="word"){var S=E.current();return g.context&&g.context.tagName!=S&&K.implicitlyClosed.hasOwnProperty(g.context.tagName)&&a(g),g.context&&g.context.tagName==S||K.matchClosing===!1?(y="tag",m):(y="tag error",L)}else return K.allowMissingTagName&&o=="endTag"?(y="tag bracket",m(o,E,g)):(y="error",L)}function m(o,E,g){return o!="endTag"?(y="error",m):(a(g),d)}function L(o,E,g){return y="error",m(o,E,g)}function x(o,E,g){if(o=="word")return y="attribute",p;if(o=="endTag"||o=="selfcloseTag"){var S=g.tagName,M=g.tagStart;return g.tagName=g.tagStart=null,o=="selfcloseTag"||K.autoSelfClosers.hasOwnProperty(S)?l(g,S):(l(g,S),g.context=new u(g,S,M==g.indented)),d}return y="error",x}function p(o,E,g){return o=="equals"?f:(K.allowMissing||(y="error"),x(o,E,g))}function f(o,E,g){return o=="string"?h:o=="word"&&K.allowUnquoted?(y="string",x):(y="error",x(o,E,g))}function h(o,E,g){return o=="string"?h:x(o,E,g)}return{startState:function(o){var E={tokenize:A,state:d,indented:o||0,tagName:null,tagStart:null,context:null};return o!=null&&(E.baseIndent=o),E},token:function(o,E){if(!E.tagName&&o.sol()&&(E.indented=o.indentation()),o.eatSpace())return null;D=null;var g=E.tokenize(o,E);return(g||D)&&g!="comment"&&(y=null,E.state=E.state(D||g,o,E),y&&(g=y=="error"?g+" error":y)),g},indent:function(o,E,g){var S=o.context;if(o.tokenize.isInAttribute)return o.tagStart==o.indented?o.stringStartCol+1:o.indented+P;if(S&&S.noIndent)return le.Pass;if(o.tokenize!=k&&o.tokenize!=A)return g?g.match(/^(\s*)/)[0].length:0;if(o.tagName)return K.multilineTagIndentPastTag!==!1?o.tagStart+o.tagName.length+2:o.tagStart+P*(K.multilineTagIndentFactor||1);if(K.alignCDATA&&/<!\[CDATA\[/.test(E))return 0;var M=E&&/^<(\/)?([\w_:\.-]*)/.exec(E);if(M&&M[1])for(;S;)if(S.tagName==M[2]){S=S.prev;break}else if(K.implicitlyClosed.hasOwnProperty(S.tagName))S=S.prev;else break;else if(M)for(;S;){var U=K.contextGrabbers[S.tagName];if(U&&U.hasOwnProperty(M[2]))S=S.prev;else break}for(;S&&S.prev&&!S.startOfLine;)S=S.prev;return S?S.indent+P:o.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:K.htmlMode?"html":"xml",helperType:K.htmlMode?"html":"xml",skipAttribute:function(o){o.state==f&&(o.state=x)},xmlCurrentTag:function(o){return o.tagName?{name:o.tagName,close:o.type=="closeTag"}:null},xmlCurrentContext:function(o){for(var E=[],g=o.context;g;g=g.prev)g.tagName&&E.push(g.tagName);return E.reverse()}}}),le.defineMIME("text/xml","xml"),le.defineMIME("application/xml","xml"),le.mimeModes.hasOwnProperty("text/html")||le.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"3vs6":function(ut,Ze,re){"use strict";var le=re("+L6B"),$=re("2/Rp"),R=re("5Dmo"),Z=re("3S7+"),F=re("k1fw"),P=re("miYZ"),K=re("tsqr"),j=re("9og8"),N=re("2qtc"),D=re("kLXV"),y=re("tJVT"),A=re("WmNS"),k=re.n(A),T=re("cDcd"),C=re.n(T),b=re("ttuQ"),u=re.n(b),a=re("ErOA"),l=re("m3rI"),d=re("IE1O"),_=re("xKgJ"),v=re("NLgs"),m=re("Ty5D"),L=re("9kvl"),x=function(f){var h=f.virtualSpaces,o=f.user,E=f.dispatch,g=Object(T.useState)(!1),S=Object(y.a)(g,2),M=S[0],U=S[1],G=Object(m.i)(),V=h.virtualSpacesDetails;Object(T.useEffect)(function(){O()},[]);var O=function(){E({type:"virtualSpaces/getVirtualSpacesDetails",payload:{id:G==null?void 0:G.virtual_spacesId}})},I=function(){if(!Object(v.f)(E))return;D.a.confirm({centered:!0,width:424,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u786E\u8BA4\u7533\u8BF7\u52A0\u5165",icon:null,className:"custom-modal-divider",content:C.a.createElement("div",{className:"font14"},"\u786E\u8BA4\u5411\u7BA1\u7406\u5458\u7533\u8BF7\u52A0\u5165\u8BE5\u865A\u62DF\u793E\u533A\u5417\uFF1F"),onOk:function(){var Ee=Object(j.a)(k.a.mark(function Te(){var ye;return k.a.wrap(function(se){for(;;)switch(se.prev=se.next){case 0:return se.next=2,Object(a.a)("/api/virtual_classrooms/".concat(G==null?void 0:G.virtual_spacesId,"/apply_become_member.json"),{method:"post"});case 2:ye=se.sent,(ye==null?void 0:ye.status)!==-1&&(K.b.success(ye==null?void 0:ye.message),O());case 4:case"end":return se.stop()}},Te)}));function we(){return Ee.apply(this,arguments)}return we}()})},X=function(){D.a.confirm({centered:!0,width:424,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u786E\u8BA4\u7533\u8BF7\u516C\u5F00",icon:null,className:"custom-modal-divider",content:C.a.createElement("div",{className:"font14"},C.a.createElement("p",null,"\u786E\u8BA4\u5411\u5E73\u53F0\u7533\u8BF7\u516C\u5F00\u865A\u62DF\u793E\u533A\u5417\uFF1F"),C.a.createElement("p",null,"\u516C\u5F00\u865A\u62DF\u793E\u533A\u9700\u7ECF\u8FC7\u5E73\u53F0\u6807\u51C6\u5316\u5BA1\u6838\uFF0C\u5BA1\u6838\u5468\u671F\u4E3A1-2\u5929\uFF0C"),C.a.createElement("div",null,"\u516C\u5F00\u7684\u865A\u62DF\u793E\u533A\u5C06\u5BF9\u5E73\u53F0\u6240\u6709\u4EBA\u53EF\u89C1\u3002")),onOk:function(){var Ee=Object(j.a)(k.a.mark(function Te(){var ye;return k.a.wrap(function(se){for(;;)switch(se.prev=se.next){case 0:return se.next=2,Object(a.a)("/api/virtual_classrooms/".concat(G==null?void 0:G.virtual_spacesId,"/apply_public.json"),{method:"post"});case 2:ye=se.sent,(ye==null?void 0:ye.status)!==-1&&(K.b.success(ye==null?void 0:ye.message),O());case 4:case"end":return se.stop()}},Te)}));function we(){return Ee.apply(this,arguments)}return we}()})},q=function(){var Le=Object(j.a)(k.a.mark(function Ee(we){var Te;return k.a.wrap(function(fe){for(;;)switch(fe.prev=fe.next){case 0:return fe.next=2,Object(a.a)("/api/virtual_classrooms/".concat(G==null?void 0:G.virtual_spacesId,".json"),{method:"put",body:we});case 2:Te=fe.sent,(Te==null?void 0:Te.status)===0&&(O(),U(!1));case 4:case"end":return fe.stop()}},Ee)}));return function(we){return Le.apply(this,arguments)}}(),oe=function(){var Le=Object(j.a)(k.a.mark(function Ee(we){return k.a.wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:U(Object(F.a)({},V));case 1:case"end":return ye.stop()}},Ee)}));return function(we){return Le.apply(this,arguments)}}(),ce=(V==null?void 0:V.is_member)||Object(_.v)();return C.a.createElement("div",{className:u.a.bg,style:{background:"url('".concat(l.a.IMG_SERVER+(V==null?void 0:V.backbground_image_url),"') no-repeat center center")}},C.a.createElement("aside",null,C.a.createElement("div",null,C.a.createElement("div",{className:u.a.member},C.a.createElement("div",null,C.a.createElement(Z.a,{title:"\u6210\u5458\u603B\u6570"},C.a.createElement("i",{style:{color:"#FF8B58",fontSize:24},className:"iconfont icon-a-chengyuan1"})),C.a.createElement(Z.a,{title:"\u6210\u5458\u603B\u6570"},C.a.createElement("span",null,V==null?void 0:V.members_count))),C.a.createElement("div",null,C.a.createElement(Z.a,{title:"\u8D44\u6E90\u603B\u6570"},C.a.createElement("i",{style:{color:"#07C160",marginLeft:100},className:"iconfont icon-a-ziyuanku1"})),C.a.createElement(Z.a,{title:"\u8D44\u6E90\u603B\u6570"},C.a.createElement("span",null,V==null?void 0:V.resources_count)))),ce&&C.a.createElement($.a,{disabled:(V==null?void 0:V.status)!==2,onClick:X,type:"primary"},C.a.createElement("i",{className:"iconfont icon-sheweigongkai2 mr5 font14"}),(V==null?void 0:V.status)===2?"\u7533\u8BF7\u516C\u5F00":(V==null?void 0:V.status)===0?"\u7533\u8BF7\u4E2D":"\u5DF2\u516C\u5F00"),!ce&&C.a.createElement($.a,{onClick:I,type:"primary"},C.a.createElement("i",{className:"iconfont icon-shenqingjiaru2 mr5 font14"}),"\u7533\u8BF7\u52A0\u5165"))),C.a.createElement(d.b,{visible:M,title:"\u7F16\u8F91\u865A\u62DF\u793E\u533A",onCancel:function(){return U(!1)},onOk:q}))};Ze.a=Object(L.a)(function(p){var f=p.virtualSpaces,h=p.user;return{virtualSpaces:f,user:h}})(x)},"500L":function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return v});var le=re("+L6B"),$=re("2/Rp"),R=re("2qtc"),Z=re("kLXV"),F=re("9og8"),P=re("k1fw"),K=re("miYZ"),j=re("tsqr"),N=re("oBTY"),D=re("tJVT"),y=re("DZo9"),A=re("8z0m"),k=re("WmNS"),T=re.n(k),C=re("cDcd"),b=re.n(C),u=re("m3rI"),a=re("wzkS"),l=re("y5JW"),d=re("LtfV"),_=A.a.Dragger;function v(m){var L=[];return m&&m.length>0&&(L=m.map(function(x){return{uid:x.id,id:x.id,name:x.title+l.c+x.filesize,url:x.url,filesize:x.filesize,status:"done",response:{id:x.id}}})),L}Ze.b=function(m){var L=m.value,x=m.onChange,p=m.action,f=m.className,h=m.maxSize,o=h===void 0?150:h,E=m.title,g=E===void 0?"\u4E0A\u4F20\u9644\u4EF6":E,S=m.showRemoveModal,M=S===void 0?!1:S,U=m.accept,G=U===void 0?"":U,V=m.additionalText,O=m.isDragger,I=m.number,X=I===void 0?1e3:I,q=m.aloneClear,oe=q===void 0?!1:q,ce=Object(C.useState)(!1),Le=Object(D.a)(ce,2),Ee=Le[0],we=Le[1],Te=Object(C.useState)(L||[]),ye=Object(D.a)(Te,2),fe=ye[0],se=ye[1];Object(C.useEffect)(function(){L&&(se(Object(N.a)(L)),X===(L==null?void 0:L.length)&&we(!0))},[L]);var te=function(){setTimeout(function(){fe.pop(),se(Object(N.a)(fe))},500)},ue={multiple:!0,disabled:Ee,accept:G,withCredentials:!0,fileList:fe,beforeUpload:function(Re,xe){var ke=Re.size/1024/1024;return fe.concat(xe).length>X?(fe.pop(),se(Object(N.a)(fe)),j.b.error("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20".concat(X,"\u4E2A\u6587\u4EF6")),oe?Promise.reject():(te(),!1)):!0},action:p||"".concat(u.a.API_SERVER,"/api/attachments.json"),onChange:function(Re){var xe,ke,Ne=Object(N.a)(Re.fileList);if(Re.file.status==="done"&&((xe=Re.file)===null||xe===void 0||((ke=xe.response)===null||ke===void 0)?void 0:ke.status)===-1){var He,Be;j.b.error((He=Re.file)===null||He===void 0||((Be=He.response)===null||Be===void 0)?void 0:Be.message);return}Ne.length>=X?we(!0):we(!1),se(Object(N.a)(Ne)),Ne=Ne.map(function(Me){var Oe;if(Me!=null&&(Oe=Me.response)!==null&&Oe!==void 0&&Oe.id){var Ye;Me.url="/api/attachments/".concat(Me==null||((Ye=Me.response)===null||Ye===void 0)?void 0:Ye.id)}return Me.name.indexOf(l.c)===-1&&(Me.name="".concat(Me.name).concat(l.c).concat(Object(l.a)(Me.size))),Object(P.a)({},Me)}),console.log("info:",Re),x(Ne)},onRemove:function(){var _e=Object(F.a)(T.a.mark(function xe(ke){var Ne;return T.a.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:if(Ne=function(){var Me=Object(F.a)(T.a.mark(function Oe(){var Ye,Je;return T.a.wrap(function(je){for(;;)switch(je.prev=je.next){case 0:if(Ye=ke.response?ke.response.id:ke.id,!Ye){je.next=8;break}return je.next=4,Object(a.d)(ke.response?ke.response.id:ke.uid);case 4:return Je=je.sent,je.abrupt("return",Je);case 8:return je.abrupt("return",!0);case 9:case"end":return je.stop()}},Oe)}));return function(){return Me.apply(this,arguments)}}(),!M){Be.next=5;break}return Be.abrupt("return",new Promise(function(Me,Oe){Z.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:b.a.createElement("div",{className:"tc font16"},"\u662F\u5426\u786E\u8BA4\u5220\u9664?"),onOk:function(){var Ye=Object(F.a)(T.a.mark(function Ve(){var je;return T.a.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Qe.next=2,Ne();case 2:je=Qe.sent,j.b.success("\u5220\u9664\u6210\u529F"),Me(!0);case 5:case"end":return Qe.stop()}},Ve)}));function Je(){return Ye.apply(this,arguments)}return Je}(),onCancel:function(){return Me(!1)}})}));case 5:return Be.next=7,Ne();case 7:return Be.abrupt("return",Be.sent);case 8:case"end":return Be.stop()}},xe)}));function Re(xe){return _e.apply(this,arguments)}return Re}()};function ne(_e){_e.preventDefault(),_e.stopPropagation()}return b.a.createElement("div",{className:"multi-upload ".concat(f||"")},O&&b.a.createElement(_,ue,b.a.createElement("p",{className:"ant-upload-drag-icon"},b.a.createElement(d.a,null)),b.a.createElement("p",{className:"ant-upload-text"},"\u70B9\u51FB\u4E0A\u4F20\u56FE\u6807\uFF0C\u9009\u62E9\u8981\u4E0A\u4F20\u7684\u6587\u4EF6\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u6B64",b.a.createElement("br",null),"(\u5355\u4E2A\u6587\u4EF6\u6700\u5927\u9650\u5236\u4E3A",o,"MB)"," "),V),!O&&b.a.createElement(A.a,ue,b.a.createElement($.a,{disabled:Ee},g),b.a.createElement("span",{onClick:ne,style:{marginLeft:10,color:"#FA6400"}},"(\u5355\u4E2A\u6587\u4EF6\u6700\u5927",o,"MB)"," ")))}},"7Cbv":function(ut,Ze,re){"use strict";var le=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),$=new Uint8Array(16);function R(){if(!le)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return le($)}var Z=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function F(k){return typeof k=="string"&&Z.test(k)}for(var P=F,K=[],j=0;j<256;++j)K.push((j+256).toString(16).substr(1));function N(k){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,C=(K[k[T+0]]+K[k[T+1]]+K[k[T+2]]+K[k[T+3]]+"-"+K[k[T+4]]+K[k[T+5]]+"-"+K[k[T+6]]+K[k[T+7]]+"-"+K[k[T+8]]+K[k[T+9]]+"-"+K[k[T+10]]+K[k[T+11]]+K[k[T+12]]+K[k[T+13]]+K[k[T+14]]+K[k[T+15]]).toLowerCase();if(!P(C))throw TypeError("Stringified UUID is invalid");return C}var D=N;function y(k,T,C){k=k||{};var b=k.random||(k.rng||R)();if(b[6]=b[6]&15|64,b[8]=b[8]&63|128,T){C=C||0;for(var u=0;u<16;++u)T[C+u]=b[u];return T}return D(b)}var A=Ze.a=y},"7ahc":function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return _});var le=re("k1fw"),$=re("0Owb"),R=re("+L6B"),Z=re("2/Rp"),F=re("y8nQ"),P=re("Vl3Y"),K=re("tJVT"),j=re("OaEy"),N=re("2fM7"),D=re("cDcd"),y=re.n(D),A=re("VrN/"),k=re.n(A),T=re("p77/"),C=re.n(T),b=re("c5Ni"),u=re.n(b),a=N.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"]};Ze.b=function(v){var m=v.callback,L=v.onCancel,x=Object(D.useState)("python"),p=Object(K.a)(x,2),f=p[0],h=p[1];function o(g){h(d[g][1])}function E(g){m(g)}return y.a.createElement(P.a,Object($.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:E}),y.a.createElement(P.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},y.a.createElement(N.a,{onChange:o},Object.keys(d).map(function(g){return y.a.createElement(a,{key:g,value:g},d[g][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(_,{mode:f})),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 _(v){var m=v.value,L=v.onChange,x=v.mode,p=v.options,f=p===void 0?{}:p,h=Object(D.useRef)(),o=Object(D.useState)(),E=Object(K.a)(o,2),g=E[0],S=E[1];return Object(D.useEffect)(function(){if(g){function M(U){var G=U.getValue();L&&L(G)}return g.on("change",M),function(){g.off("change",M)}}},[g,L]),Object(D.useEffect)(function(){g&&g.setOption("mode",x)},[g,x]),Object(D.useEffect)(function(){g&&((m!==g.getValue()||m==="")&&setTimeout(function(){g.setValue(m||" ")},300))},[g,m]),Object(D.useEffect)(function(){if(h.current&&!g){var M=k.a.fromTextArea(h.current,Object(le.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},f));S(M)}},[h.current,g]),y.a.createElement("div",{className:"my-codemirror-container"},y.a.createElement("textarea",{ref:h}))}},"7ixt":function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return R});var le={adjustX:1,adjustY:1},$=[0,0],R={left:{points:["cr","cl"],overflow:le,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:le,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:le,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:le,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:le,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:le,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:le,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:le,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:le,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:le,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:le,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:le,offset:[-4,0],targetOffset:$}},Z=R},"8EBN":function(ut,Ze,re){(function(le){le(re("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 $=0;$<le.modeInfo.length;$++){var R=le.modeInfo[$];R.mimes&&(R.mime=R.mimes[0])}le.findModeByMIME=function(Z){Z=Z.toLowerCase();for(var F=0;F<le.modeInfo.length;F++){var P=le.modeInfo[F];if(P.mime==Z)return P;if(P.mimes){for(var K=0;K<P.mimes.length;K++)if(P.mimes[K]==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 F=0;F<le.modeInfo.length;F++){var P=le.modeInfo[F];if(P.ext){for(var K=0;K<P.ext.length;K++)if(P.ext[K]==Z)return P}}},le.findModeByFileName=function(Z){for(var F=0;F<le.modeInfo.length;F++){var P=le.modeInfo[F];if(P.file&&P.file.test(Z))return P}var K=Z.lastIndexOf("."),j=K>-1&&Z.substring(K+1,Z.length);if(j)return le.findModeByExtension(j)},le.findModeByName=function(Z){Z=Z.toLowerCase();for(var F=0;F<le.modeInfo.length;F++){var P=le.modeInfo[F];if(P.name.toLowerCase()==Z)return P;if(P.alias){for(var K=0;K<P.alias.length;K++)if(P.alias[K].toLowerCase()==Z)return P}}}})},"8hTe":function(ut,Ze,re){ut.exports={button:"button___1wy9m"}},"9Bee":function(ut,Ze,re){"use strict";var le=re("DYRE"),$=re("zeV3"),R=re("+L6B"),Z=re("2/Rp"),F=re("k1fw"),P=re("9og8"),K=re("tJVT"),j=re("WmNS"),N=re.n(j),D=re("cDcd"),y=re.n(D),A=re("vg9a"),k=re("DlQD"),T=re.n(k),C=re("rUJ1");function b(z,s){var c=z.match(/^(\s+)(?:```)/);if(c===null)return s;var B=c[1];return s.split(`
`).map(function(Q){var H=Q.match(/^\s+/);if(H===null)return Q;var ge=Object(K.a)(H,1),We=ge[0];return We.length>=B.length?Q.slice(B.length):Q}).join(`
`)}var u=[],a=["<ul>"],l=new T.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function _(){u.length=0,a=["<ul>"]}var v={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(z,s,c,B){if(s>=z.length||z[s].level<=c)return s;var Q=z[s];B.push("<li><a href='#"+Q.anchor+"'>"+Q.text+"</a>"),s++;var H=[];return s=m(z,s,Q.level,H),H.length>0&&(B.push("<ul>"),H.forEach(function(ge){B.push(ge)}),B.push("</ul>")),B.push("</li>"),s=m(z,s,c,B),s}function L(){return m(u,0,0,a),a.push("</ul>"),a.join("")}var x={heading:function(s){var c=d.exec(s);if(c)return{type:"heading",raw:c[0],depth:c[1].length,text:c[2]}},fences:function(s){var c=this.rules.block.fences.exec(s);if(c){var B=c[0],Q=b(B,c[3]||""),H=c[2]?c[2].trim():c[2];if(["latex","katex","math"].indexOf(H)>=0){var ge=h(),We=Q;Q=ge,o[ge]={type:"block",expression:We}}return{type:"code",raw:B,lang:H,text:Q}}}},p=/(?:\${2})([^\n`]+?)(?:\${2})/gi,f=0,h=function(){return"__special_katext_id_".concat(f++,"__")},o={};function E(){return o}function g(){f=0,o={}}function S(z){return z=z.replace(p,function(s,c){var B=h();return o[B]={type:"inline",expression:c},B}),z}var M=l.listitem;l.listitem=function(z){return M(S(z))};var U=l.paragraph;l.paragraph=function(z){return U(S(z))};var G=l.tablecell;l.tablecell=function(z,s){return G(S(z),s)},l.code=function(z,s,c){var B=(s||"").match(/\S*/)[0];return B?["latex","katex","math"].indexOf(B)>=0?"<p class='editormd-tex'>".concat(z,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(c?z:Object(C.escape)(z,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(c?z:Object(C.escape)(z,!0))+"</code></pre>"},l.heading=function(z,s,c){var B=this.options.headerPrefix+c.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:B,level:s,text:z}),"<h"+s+' id="'+B+'">'+z+"</h"+s+">"},T.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),T.a.use({tokenizer:x,renderer:l});var V=T.a,O=re("SJMd"),I=re("ulZh"),X=re.n(I),q=re("m3rI"),oe=re("Oy/b"),ce=re("p5ED"),Le=re("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 Ee=function(z,s){return(Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,B){c.__proto__=B}||function(c,B){for(var Q in B)Object.prototype.hasOwnProperty.call(B,Q)&&(c[Q]=B[Q])})(z,s)};function we(z,s){function c(){this.constructor=z}Ee(z,s),z.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function Te(z,s,c,B){return new(c||(c=Promise))(function(Q,H){function ge(ft){try{et(B.next(ft))}catch(Ge){H(Ge)}}function We(ft){try{et(B.throw(ft))}catch(Ge){H(Ge)}}function et(ft){var Ge;ft.done?Q(ft.value):(Ge=ft.value,Ge instanceof c?Ge:new c(function(yt){yt(Ge)})).then(ge,We)}et((B=B.apply(z,s||[])).next())})}function ye(z,s){var c,B,Q,H,ge={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:We(0),throw:We(1),return:We(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function We(et){return function(ft){return function(Ge){if(c)throw new TypeError("Generator is already executing.");for(;ge;)try{if(c=1,B&&(Q=2&Ge[0]?B.return:Ge[0]?B.throw||((Q=B.return)&&Q.call(B),0):B.next)&&!(Q=Q.call(B,Ge[1])).done)return Q;switch(B=0,Q&&(Ge=[2&Ge[0],Q.value]),Ge[0]){case 0:case 1:Q=Ge;break;case 4:return ge.label++,{value:Ge[1],done:!1};case 5:ge.label++,B=Ge[1],Ge=[0];continue;case 7:Ge=ge.ops.pop(),ge.trys.pop();continue;default:if(!(Q=ge.trys,(Q=Q.length>0&&Q[Q.length-1])||Ge[0]!==6&&Ge[0]!==2)){ge=0;continue}if(Ge[0]===3&&(!Q||Ge[1]>Q[0]&&Ge[1]<Q[3])){ge.label=Ge[1];break}if(Ge[0]===6&&ge.label<Q[1]){ge.label=Q[1],Q=Ge;break}if(Q&&ge.label<Q[2]){ge.label=Q[2],ge.ops.push(Ge);break}Q[2]&&ge.ops.pop(),ge.trys.pop();continue}Ge=s.call(z,ge)}catch(yt){Ge=[6,yt],B=0}finally{c=Q=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([et,ft])}}}function fe(){for(var z=0,s=0,c=arguments.length;s<c;s++)z+=arguments[s].length;var B=Array(z),Q=0;for(s=0;s<c;s++)for(var H=arguments[s],ge=0,We=H.length;ge<We;ge++,Q++)B[Q]=H[ge];return B}var se=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,c){for(var B=0,Q=c;B<Q.length;B++){var H=Q[B],ge=H[0],We=H[1];s.setAttribute(ge,We)}},z.createRect=function(s,c,B){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",c.toString()),B&&z.setAttributes(Q,B),Q},z.createLine=function(s,c,B,Q,H){var ge=document.createElementNS("http://www.w3.org/2000/svg","line");return ge.setAttribute("x1",s.toString()),ge.setAttribute("y1",c.toString()),ge.setAttribute("x2",B.toString()),ge.setAttribute("y2",Q.toString()),H&&z.setAttributes(ge,H),ge},z.createPolygon=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","polygon");return B.setAttribute("points",s),c&&z.setAttributes(B,c),B},z.createCircle=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","circle");return B.setAttribute("cx",(s/2).toString()),B.setAttribute("cy",(s/2).toString()),B.setAttribute("r",s.toString()),c&&z.setAttributes(B,c),B},z.createEllipse=function(s,c,B){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(c/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(c/2).toString()),B&&z.setAttributes(Q,B),Q},z.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(c,s),c},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,c,B,Q,H,ge,We){var et=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(et,[["id",s],["orient",c],["markerWidth",B.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",ge.toString()]]),et.appendChild(We),et},z.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&z.setAttributes(c,s),c},z.createTSpan=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","tspan");return B.textContent=s,c&&z.setAttributes(B,c),B},z.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(c,s),c},z.createPoint=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return B.x=s,B.y=c,B},z.createPath=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","path");return B.setAttribute("d",s),c&&z.setAttributes(B,c),B},z}(),te=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),ue=function(){function z(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return z.prototype.rasterize=function(s,c,B){var Q=this;return new Promise(function(H){var ge=B!==void 0?B:document.createElement("canvas");s===null&&(Q.markersOnly=!0,Q.naturalSize=!1);var We=document.createElementNS("http://www.w3.org/2000/svg","svg");We.setAttribute("xmlns","http://www.w3.org/2000/svg"),We.setAttribute("width",c.width.baseVal.valueAsString),We.setAttribute("height",c.height.baseVal.valueAsString),We.setAttribute("viewBox","0 0 "+c.viewBox.baseVal.width.toString()+" "+c.viewBox.baseVal.height.toString()),We.innerHTML=c.innerHTML,Q.naturalSize===!0?(We.width.baseVal.value=s.naturalWidth,We.height.baseVal.value=s.naturalHeight):Q.width!==void 0&&Q.height!==void 0&&(We.width.baseVal.value=Q.width,We.height.baseVal.value=Q.height),ge.width=We.width.baseVal.value,ge.height=We.height.baseVal.value;var et=We.outerHTML,ft=ge.getContext("2d");Q.markersOnly!==!0&&ft.drawImage(s,0,0,ge.width,ge.height);var Ge=window.URL,yt=new Image(ge.width,ge.height);yt.setAttribute("crossOrigin","anonymous");var Nt=new Blob([et],{type:"image/svg+xml"}),Kt=Ge.createObjectURL(Nt);yt.onload=function(){ft.drawImage(yt,0,0),Ge.revokeObjectURL(Kt);var kr=ge.toDataURL(Q.imageType,Q.imageQuality);H(kr)},yt.src=Kt})},z}(),ne=function(){},_e=function(){function z(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},z.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new 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;
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),Re=function(z,s){this.selector=z,this.style=s},xe=function(z,s){this.localName=z,this.style=s},ke=function(){function z(s,c,B,Q,H){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=c,this.markerItems=B,this.uiStyleSettings=Q,this.styles=H,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return z.prototype.show=function(s){var c=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var B=document.createElement("div");B.className=this.toolbarBlockStyleClass.name,B.style.whiteSpace="nowrap",this.uiContainer.appendChild(B),this.addActionButton(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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(B,'<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 ge=document.createElement("div");ge.className=""+c.toolbarButtonStyleClass.name,ge.setAttribute("data-type-name",H.typeName),ge.innerHTML=H.icon,ge.addEventListener("click",function(){c.markerToolbarButtonClicked(ge,H)}),c.buttons.push(ge),c.markerButtons.push(ge)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var Q=document.createElement("div");Q.className=this.toolbarBlockStyleClass.name,Q.style.whiteSpace="nowrap",Q.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(Q),this.addActionButton(Q,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(Q,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},z.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},z.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},z.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},z.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var c=0;c<this.markerButtons.length;c++)c<s||c===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[c]):(c===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[c]))}},z.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},z.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(c){c.className=c.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),c.className=c.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),c.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},z.prototype.addActionButton=function(s,c,B){var Q=this,H=document.createElement("div");switch(H.className=""+this.toolbarButtonStyleClass.name,H.innerHTML=c,H.setAttribute("data-action",B),H.addEventListener("click",function(){Q.actionToolbarButtonClicked(H,B)}),B){case"select":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":H.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":H.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":H.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(H),this.buttons.push(H)},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new 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+`
`))},z.prototype.markerToolbarButtonClicked=function(s,c){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(B){return B("marker",c)}),this.markerButtonOverflowBlock.style.display="none"},z.prototype.actionToolbarButtonClicked=function(s,c){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(B){return B("action",c)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},z.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},z.prototype.setActiveMarkerButton=function(s){var c=this.markerButtons.find(function(B){return B.getAttribute("data-type-name")===s});c&&this.setActiveButton(c)},z.prototype.setCurrentMarker=function(s){var c=this;this.currentMarker=s,this.buttons.filter(function(B){return/delete|notes/.test(B.getAttribute("data-action"))}).forEach(function(B){c.currentMarker===void 0?(B.style.fillOpacity="0.4",B.style.pointerEvents="none"):(B.style.fillOpacity="1",B.style.pointerEvents="all")})},z}(),Ne=function(){function z(s,c,B,Q){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=c,this.uiStyleSettings=B,this.styles=Q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return z.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 c=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*c)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*c)+`px;
padding: `+c+`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;
`))},z.prototype.show=function(s){var c;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((c=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},z.prototype.setPanelButtons=function(s){var c,B,Q=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((c=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&c!==void 0?c:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((B=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&B!==void 0?B:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(H){var ge;H.uiStyleSettings=Q.uiStyleSettings;var We=document.createElement("div");We.className=Q.toolboxButtonStyleClass.name+" "+((ge=Q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ge!==void 0?ge:Q.toolboxButtonStyleColorsClass.name),We.innerHTML=H.icon,We.title=H.title,We.addEventListener("click",function(){Q.panelButtonClick(H)}),Q.panelButtons.push(We),Q.buttonRow.appendChild(We)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},z.prototype.panelButtonClick=function(s){var c=this,B=-1;if(s!==this.activePanel){B=this.panels.indexOf(s),this.panelRow.innerHTML="";var Q=s.getUi();Q.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(Q),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){c.displayMode==="inline"?c.panelRow.style.display="none":c.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(H,ge){var We,et;H.className=c.toolboxButtonStyleClass.name+" "+(ge===B?""+((We=c.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&We!==void 0?We:c.toolboxActiveButtonStyleColorsClass.name):""+((et=c.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&et!==void 0?et:c.toolboxButtonStyleColorsClass.name))})},z}(),He=function(z,s){this.title=z,this.icon=s},Be=function(z){function s(c,B,Q,H){var ge=z.call(this,c,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 ge.colors=[],ge.addTransparent=!1,ge.colorBoxes=[],ge.colors=B,ge.currentColor=Q,ge.setCurrentColor=ge.setCurrentColor.bind(ge),ge.getColorBox=ge.getColorBox.bind(ge),ge}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");return B.style.overflow="hidden",B.style.whiteSpace="nowrap",this.colors.forEach(function(Q){var H=c.getColorBox(Q);B.appendChild(H),c.colorBoxes.push(H)}),B},s.prototype.getColorBox=function(c){var B=this,Q=this.uiStyleSettings.toolbarHeight/4,H=this.uiStyleSettings.toolbarHeight-Q,ge=document.createElement("div");ge.style.display="inline-block",ge.style.boxSizing="content-box",ge.style.width=H-2+"px",ge.style.height=H-2+"px",ge.style.padding="1px",ge.style.marginRight="2px",ge.style.marginBottom="2px",ge.style.borderWidth="2px",ge.style.borderStyle="solid",ge.style.borderRadius=(H+2)/2+"px",ge.style.borderColor=c===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ge.addEventListener("click",function(){B.setCurrentColor(c,ge)});var We=document.createElement("div");return We.style.display="inline-block",We.style.width=H-2+"px",We.style.height=H-2+"px",We.style.backgroundColor=c,We.style.borderRadius=H/2+"px",c==="transparent"&&(We.style.fill=this.uiStyleSettings.toolboxAccentColor,We.innerHTML=`<svg viewBox="0 0 24 24">
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
</svg>`),ge.appendChild(We),ge},s.prototype.setCurrentColor=function(c,B){var Q=this;this.currentColor=c,this.colorBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(c)},s}(He),Me=function(){function z(s,c,B){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=c,this.globalSettings=B,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(z.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),z.prototype.ownsTarget=function(s){return!1},Object.defineProperty(z.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),z.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},z.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},z.prototype.pointerDown=function(s,c){},z.prototype.dblClick=function(s,c){},z.prototype.manipulate=function(s){},z.prototype.pointerUp=function(s){this.stateChanged()},z.prototype.dispose=function(){},z.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},z.prototype.getState=function(){return{typeName:z.typeName,state:this.state,notes:this.notes}},z.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},z.prototype.scale=function(s,c){},z.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},z.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},z.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},z.typeName="MarkerBase",z}(),Oe=function(){function z(){this.findGripByVisual=this.findGripByVisual.bind(this)}return z.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},z}(),Ye=function(){function z(){this.GRIP_SIZE=10,this.visual=se.createGroup(),this.visual.appendChild(se.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(se.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z}(),Je=function(){function z(){}return z.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},z.toSVGMatrix=function(s,c){return s.a=c.a,s.b=c.b,s.c=c.c,s.d=c.d,s.e=c.e,s.f=c.f,s},z}(),Ve=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.left=0,H.top=0,H.width=0,H.height=0,H.defaultSize={x:50,y:20},H.offsetX=0,H.offsetY=0,H.rotationAngle=0,H.CB_DISTANCE=10,H._suppressMarkerCreateEvent=!1,H.container.transform.baseVal.appendItem(se.createTransform()),H.setupControlBox(),H}return we(s,z),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(c){this._visual=c;var B=se.createTransform();this._visual.transform.baseVal.appendItem(B)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!!z.prototype.ownsTarget.call(this,c)||!!(this.controlGrips.findGripByVisual(c)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(c))},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="new"&&(this.left=c.x,this.top=c.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var Q=this.unrotatePoint(c);if(this.manipulationStartX=Q.x,this.manipulationStartY=Q.y,this.offsetX=Q.x-this.left,this.offsetY=Q.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(B),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(B)){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 ge=this.container.transform.baseVal.getItem(0);ge.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ge,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(c){var B=this.state;z.prototype.pointerUp.call(this,c),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(c),this._state="select",B==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(c){this.visual.style.transform="translate("+c.x+"px, "+c.y+"px)"},s.prototype.manipulate=function(c){var B=this.unrotatePoint(c);this.state==="creating"?this.resize(c):this.state==="move"?(this.left=this.manipulationStartLeft+(B.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(B.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(B):this.state==="rotate"&&this.rotate(c)},s.prototype.resize=function(c){var B=this.manipulationStartLeft,Q=this.manipulationStartWidth,H=this.manipulationStartTop,ge=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:B=this.manipulationStartLeft+c.x-this.manipulationStartX,Q=this.manipulationStartWidth+this.manipulationStartLeft-B;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Q=this.manipulationStartWidth+c.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:H=this.manipulationStartTop+c.y-this.manipulationStartY,ge=this.manipulationStartHeight+this.manipulationStartTop-H;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ge=this.manipulationStartHeight+c.y-this.manipulationStartY}Q>=0?(this.left=B,this.width=Q):(this.left=B+Q,this.width=-Q),ge>=0?(this.top=H,this.height=ge):(this.top=H+ge,this.height=-ge),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(c){if(Math.abs(c.x-this.centerX)>.1){var B=Math.sign(c.x-this.centerX);this.rotationAngle=180*Math.atan((c.y-this.centerY)/(c.x-this.centerX))/Math.PI+90*B,this.applyRotation()}},s.prototype.applyRotation=function(){var c=this.container.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(c,0)},s.prototype.rotatePoint=function(c){if(this.rotationAngle===0)return c;var B=this.container.getCTM(),Q=se.createPoint(c.x,c.y);return{x:(Q=Q.matrixTransform(B)).x,y:Q.y}},s.prototype.unrotatePoint=function(c){if(this.rotationAngle===0)return c;var B=this.container.getCTM();B=B.inverse();var Q=se.createPoint(c.x,c.y);return{x:(Q=Q.matrixTransform(B)).x,y:Q.y}},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup();var c=se.createTransform();c.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(c),this.container.appendChild(this.controlBox),this.controlRect=se.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=se.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Oe,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var c=this.controlBox.transform.baseVal.getItem(0);c.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(c,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},s.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},s.prototype.createGrip=function(){var c=new Ye;return c.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.controlGrips.topLeft.GRIP_SIZE,B=-c/2,Q=B,H=(this.width+this.CB_DISTANCE)/2-c/2,ge=(this.height+this.CB_DISTANCE)/2-c/2,We=this.height+this.CB_DISTANCE-c/2,et=this.width+this.CB_DISTANCE-c/2;this.positionGrip(this.controlGrips.topLeft.visual,B,Q),this.positionGrip(this.controlGrips.topCenter.visual,H,Q),this.positionGrip(this.controlGrips.topRight.visual,et,Q),this.positionGrip(this.controlGrips.centerLeft.visual,B,ge),this.positionGrip(this.controlGrips.centerRight.visual,et,ge),this.positionGrip(this.controlGrips.bottomLeft.visual,B,We),this.positionGrip(this.controlGrips.bottomCenter.visual,H,We),this.positionGrip(this.controlGrips.bottomRight.visual,et,We),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,H,Q-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(c,B,Q){var H=c.transform.baseVal.getItem(0);H.setTranslate(B,Q),c.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:Je.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Je.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},z.prototype.getState.call(this))},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c);var B=c;this.left=B.left,this.top=B.top,this.width=B.width,this.height=B.height,this.rotationAngle=B.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Je.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,B.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Je.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,B.containerTransformMatrix))},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B);var Q=this.rotatePoint({x:this.left,y:this.top}),H=this.unrotatePoint({x:Q.x*c,y:Q.y*B});this.left=H.x,this.top=H.y,this.width=this.width*c,this.height=this.height*B,this.adjustControlBox()},s}(Me),je=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.createVisual=H.createVisual.bind(H),H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=se.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){z.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){z.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){z.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this))},s.prototype.restoreState=function(c){var B=c;this.fillColor=B.fillColor,this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.opacity=B.opacity,this.createVisual(),z.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),this.setSize()},s.title="Rectangle marker",s}(Ve),rt=function(z){function s(c,B,Q,H){var ge=z.call(this,c,H||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ge.widths=[],ge.widthBoxes=[],ge.widths=B,ge.currentWidth=Q,ge.setCurrentWidth=ge.setCurrentWidth.bind(ge),ge}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",this.widths.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.flexGrow="2",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===c.currentWidth?c.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){c.setCurrentWidth(Q,H)}),B.appendChild(H);var ge=document.createElement("div");ge.innerText=Q.toString(),ge.style.marginRight="5px",H.appendChild(ge);var We=document.createElement("div");We.style.minHeight="20px",We.style.flexGrow="2",We.style.display="flex",We.style.alignItems="center";var et=document.createElement("hr");et.style.minWidth="20px",et.style.border="0px",et.style.borderTop=Q+"px solid "+c.uiStyleSettings.toolboxColor,et.style.flexGrow="2",We.appendChild(et),H.appendChild(We),c.widthBoxes.push(H)}),B},s.prototype.setCurrentWidth=function(c,B){var Q=this;this.currentWidth=c,this.widthBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(He),Qe=function(z){function s(c,B,Q,H){var ge=z.call(this,c,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 ge.styles=[],ge.styleBoxes=[],ge.styles=B,ge.currentStyle=Q,ge.setCurrentStyle=ge.setCurrentStyle.bind(ge),ge}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",this.styles.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/c.styles.length-5+"%",H.style.borderColor=Q===c.currentStyle?c.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){c.setCurrentStyle(Q,H)}),B.appendChild(H);var ge=document.createElement("div");ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.overflow="hidden";var We=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+c.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Q!==""?'stroke-dasharray="'+Q+'"':"")+` />
</svg>`;ge.innerHTML=We,H.appendChild(ge),c.styleBoxes.push(H)}),B},s.prototype.setCurrentStyle=function(c,B){var Q=this;this.currentStyle=c,this.styleBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(He),tt=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Be("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new rt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Qe("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=z.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(je),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},lt=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.x1=0,H.y1=0,H.x2=0,H.y2=0,H.defaultLength=50,H.manipulationStartX=0,H.manipulationStartY=0,H.manipulationStartX1=0,H.manipulationStartY1=0,H.manipulationStartX2=0,H.manipulationStartY2=0,H.setupControlBox(),H}return we(s,z),s.prototype.ownsTarget=function(c){return!!z.prototype.ownsTarget.call(this,c)||!(!this.grip1.ownsTarget(c)&&!this.grip2.ownsTarget(c))},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.manipulationStartX=c.x,this.manipulationStartY=c.y,this.state==="new"&&(this.x1=c.x,this.y1=c.y,this.x2=c.x,this.y2=c.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(B)?this.activeGrip=this.grip1:this.grip2.ownsTarget(B)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(c){var B=this.state;z.prototype.pointerUp.call(this,c),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(c),this._state="select",B==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(c){this.state==="creating"?this.resize(c):this.state==="move"?(this.x1=this.manipulationStartX1+c.x-this.manipulationStartX,this.y1=this.manipulationStartY1+c.y-this.manipulationStartY,this.x2=this.manipulationStartX2+c.x-this.manipulationStartX,this.y2=this.manipulationStartY2+c.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(c)},s.prototype.resize=function(c){switch(this.activeGrip){case this.grip1:this.x1=c.x,this.y1=c.y;break;case this.grip2:case void 0:this.x2=c.x,this.y2=c.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var c=new Ye;return c.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(c.visual),c},s.prototype.positionGrips=function(){var c=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-c/2,this.y1-c/2),this.positionGrip(this.grip2.visual,this.x2-c/2,this.y2-c/2)},s.prototype.positionGrip=function(c,B,Q){var H=c.transform.baseVal.getItem(0);H.setTranslate(B,Q),c.transform.baseVal.replaceItem(H,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},z.prototype.getState.call(this))},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c);var B=c;this.x1=B.x1,this.y1=B.y1,this.x2=B.x2,this.y2=B.y2},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),this.x1=this.x1*c,this.y1=this.y1*B,this.x2=this.x2*c,this.y2=this.y2*B,this.adjustVisual(),this.adjustControlBox()},s}(Me),at=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Be("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new rt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Qe("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorLine&&c!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),se.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c);var B=c;this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(lt),Fe=function(z){function s(c,B,Q,H){var ge=z.call(this,c,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 ge.fonts=[],ge.fontBoxes=[],ge.fonts=B,ge.currentFont=Q,ge.setCurrentFont=ge.setCurrentFont.bind(ge),ge}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");return B.style.overflow="hidden",B.style.flexGrow="2",this.fonts.forEach(function(Q){var H=document.createElement("div");H.style.display="inline-block",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/c.fonts.length-5+"%",H.style.borderColor=Q===c.currentFont?c.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){c.setCurrentFont(Q,H)}),B.appendChild(H);var ge=document.createElement("div");ge.style.display="flex",ge.style.minHeight="20px",ge.style.flexGrow="2",ge.style.fontFamily=Q,ge.style.overflow="hidden";var We=document.createElement("div");We.style.whiteSpace="nowrap",We.style.overflow="hidden",We.style.textOverflow="ellipsis",We.innerHTML="The quick brown fox jumps over the lazy dog",ge.appendChild(We),H.appendChild(ge),c.fontBoxes.push(H)}),B},s.prototype.setCurrentFont=function(c,B){var Q=this;this.currentFont=c,this.fontBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(He),Xe=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.color="transparent",H.padding=5,H.DEFAULT_TEXT="your text here",H.text=H.DEFAULT_TEXT,H.isMoved=!1,H.color=Q.defaultColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setColor=H.setColor.bind(H),H.setFont=H.setFont.bind(H),H.renderText=H.renderText.bind(H),H.sizeText=H.sizeText.bind(H),H.textEditDivClicked=H.textEditDivClicked.bind(H),H.showTextEditor=H.showTextEditor.bind(H),H.setSize=H.setSize.bind(H),H.positionTextEditor=H.positionTextEditor.bind(H),H.colorPanel=new Be("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.fontFamilyPanel=new Fe("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H}return we(s,z),s.prototype.ownsTarget=function(c){if(z.prototype.ownsTarget.call(this,c)||c===this.visual||c===this.textElement||c===this.bgRectangle)return!0;var B=!1;return this.textElement.childNodes.forEach(function(Q){Q===c&&(B=!0)}),B},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.bgRectangle=se.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=se.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.isMoved=!1,this.pointerDownPoint=c,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.renderText=function(){var c=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(B){c.textElement.appendChild(se.createTSpan(B.trim()===""?" ":B.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var c=this.textElement.getBBox(),B=1;if(c.width>0&&c.height>0){var Q=(1*this.width-this.width*this.padding*2/100)/c.width,H=(1*this.height-this.height*this.padding*2/100)/c.height;B=Math.min(Q,H)}return B},s.prototype.getTextPosition=function(c){var B=this.textElement.getBBox(),Q=0,H=0;return B.width>0&&B.height>0&&(Q=(this.width-B.width*c)/2,H=this.height/2-B.height*c/2),{x:Q,y:H}},s.prototype.sizeText=function(){var c=this.textElement.getBBox(),B=this.getTextScale(),Q=this.getTextPosition(B);Q.y-=c.y*B,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Q.x+"px, "+Q.y+"px) scale("+B+", "+B+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Q.x,Q.y),this.textElement.transform.baseVal.getItem(1).setScale(B,B))},s.prototype.manipulate=function(c){z.prototype.manipulate.call(this,c),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(c.x-this.pointerDownPoint.x)>5||Math.abs(c.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(c){z.prototype.resize.call(this,c),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){z.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(c){var B=this.state;B==="creating"&&(this._suppressMarkerCreateEvent=!0),z.prototype.pointerUp.call(this,c),this.setSize(),(B==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var c=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(B){B.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var B=Number.parseFloat(c.textEditor.style.fontSize);c.textEditor.clientWidth>=Number.parseInt(c.textEditor.style.maxWidth)&&B>.9;)B-=.1,c.textEditor.style.fontSize=Math.max(B,.9)+"em"}),this.textEditor.addEventListener("keyup",function(B){B.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(B){if(B.clipboardData){var Q=B.clipboardData.getData("text"),H=window.getSelection();if(!H.rangeCount)return!1;H.deleteFromDocument(),H.getRangeAt(0).insertNode(document.createTextNode(Q)),B.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){c.textEditDivClicked(c.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var c=this.getTextScale(),B=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Q=this.textElement.getBBox(),H={x:Q.width*c,y:Q.height*c};B.x-=H.x/2,B.y-=H.y/2,this.textEditor.style.top=B.y+"px",this.textEditor.style.left=B.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-B.x+"px",this.textEditor.style.fontSize=Math.max(16*c,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(c){this.text=c.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){z.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),z.prototype.deselect.call(this)},s.prototype.dblClick=function(c,B){z.prototype.dblClick.call(this,c,B),this.showTextEditor()},s.prototype.setColor=function(c){this.textElement&&se.setAttributes(this.textElement,[["fill",c]]),this.color=c,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(c)},s.prototype.setFont=function(c){this.textElement&&se.setAttributes(this.textElement,[["font-family",c]]),this.fontFamily=c,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var B=c;this.color=B.color,this.fontFamily=B.fontFamily,this.padding=B.padding,this.text=B.text,this.createVisual(),z.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),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}(Ve),Ce=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.color="transparent",H.lineWidth=3,H.drawing=!1,H.pixelRatio=1,H.color=Q.defaultColor,H.lineWidth=Q.defaultStrokeWidth,H.pixelRatio=Q.freehandPixelRatio,H.setColor=H.setColor.bind(H),H.addCanvas=H.addCanvas.bind(H),H.finishCreation=H.finishCreation.bind(H),H.setLineWidth=H.setLineWidth.bind(H),H.colorPanel=new Be("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.lineWidthPanel=new rt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.lineWidthPanel.onWidthChanged=H.setLineWidth,H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.drawingImage=se.createImage(),this.visual.appendChild(this.drawingImage);var c=se.createTransform();this.visual.transform.baseVal.appendItem(c),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,B){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(c.x,c.y),this.drawing=!0):z.prototype.pointerDown.call(this,c,B)},s.prototype.manipulate=function(c){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(c.x,c.y),this.canvasContext.stroke()):z.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){z.prototype.resize.call(this,c),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(c){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):z.prototype.pointerUp.call(this,c)},s.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),z.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),z.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var c=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),B=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Q=B[0],H=B[1],ge=B[2],We=B[3],et=!1,ft=0;ft<this.canvasElement.height;ft++)for(var Ge=0;Ge<this.canvasElement.width;Ge++)c.data[ft*this.canvasElement.width*4+4*Ge+3]>0&&(et=!0,ft<H&&(H=ft),Ge<Q&&(Q=Ge),ft>We&&(We=ft),Ge>ge&&(ge=Ge));if(et){this.left=Q/this.pixelRatio,this.top=H/this.pixelRatio,this.width=(ge-Q)/this.pixelRatio,this.height=(We-H)/this.pixelRatio;var yt=document.createElement("canvas");yt.width=ge-Q,yt.height=We-H,yt.getContext("2d").putImageData(this.canvasContext.getImageData(Q,H,ge-Q,We-H),0,0),this.drawingImgUrl=yt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(c){this.color=c,this.colorChanged(c)},s.prototype.setLineWidth=function(c){this.lineWidth=c},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({drawingImgUrl:this.drawingImgUrl},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){this.createVisual(),z.prototype.restoreState.call(this,c),this.drawingImgUrl=c.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),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}(Ve),ve=function(z){function s(c,B,Q){var H=z.call(this,c,Q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return H.typeBoxes=[],H.currentType=B,H.setCurrentType=H.setCurrentType.bind(H),H}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2";for(var Q=function(We){var et="both";switch(We){case 0:et="both";break;case 1:et="start";break;case 2:et="end";break;case 3:et="none"}var ft=document.createElement("div");if(ft.style.display="flex",ft.style.flexGrow="2",ft.style.alignItems="center",ft.style.justifyContent="space-between",ft.style.padding="5px",ft.style.borderWidth="2px",ft.style.borderStyle="solid",ft.style.borderColor=et===H.currentType?H.uiStyleSettings.toolboxAccentColor:"transparent",ft.addEventListener("click",function(){c.setCurrentType(et,ft)}),B.appendChild(ft),et==="both"||et==="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",ft.appendChild(Ge)}var yt=document.createElement("div");yt.style.display="flex",yt.style.alignItems="center",yt.style.minHeight="20px",yt.style.flexGrow="2";var Nt=document.createElement("hr");if(Nt.style.minWidth="20px",Nt.style.border="0px",Nt.style.borderTop="3px solid "+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee"),Nt.style.flexGrow="2",yt.appendChild(Nt),ft.appendChild(yt),et==="both"||et==="end"){var Kt=document.createElement("div");Kt.style.display="flex",Kt.style.alignItems="center",Kt.style.minHeight="20px",Kt.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 10,5 0,10" fill="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Kt.style.marginRight="5px",ft.appendChild(Kt)}H.typeBoxes.push(ft)},H=this,ge=0;ge<4;ge++)Q(ge);return B},s.prototype.setCurrentType=function(c,B){var Q=this;this.currentType=c,this.typeBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings!==void 0?Q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(He),be=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.arrowType="end",H.arrowBaseHeight=10,H.arrowBaseWidth=10,H.getArrowPoints=H.getArrowPoints.bind(H),H.setArrowType=H.setArrowType.bind(H),H.arrowTypePanel=new ve("Arrow type","end"),H.arrowTypePanel.onArrowTypeChanged=H.setArrowType,H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.arrow1&&c!==this.arrow2)},s.prototype.getArrowPoints=function(c,B){var Q=this.arrowBaseWidth+2*this.strokeWidth,H=this.arrowBaseHeight+2*this.strokeWidth;return c-Q/2+","+(B+H/2)+" "+c+","+(B-H/2)+" "+(c+Q/2)+","+(B+H/2)},s.prototype.createTips=function(){this.arrow1=se.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=se.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",se.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),se.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),B=this.arrow1.transform.baseVal.getItem(0);B.setRotate(c,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(B,0);var Q=this.arrow2.transform.baseVal.getItem(0);Q.setRotate(c+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Q,0)}},s.prototype.setArrowType=function(c){this.arrowType=c,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({arrowType:this.arrowType},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c);var B=c;this.arrowType=B.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(at),ie=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.fillColor=Q.defaultFillColor,H.strokeWidth=0,H.fillPanel=new Be("Color",Q.defaultColorSet,Q.defaultFillColor),H.fillPanel.onColorChanged=H.setFillColor,H}return we(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=z.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(je),ae=function(z){function s(c,B,Q,H){var ge=z.call(this,c,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 ge.opacities=[],ge.opacityBoxes=[],ge.opacities=B,ge.currentOpacity=Q,ge.setCurrentOpacity=ge.setCurrentOpacity.bind(ge),ge}return we(s,z),s.prototype.getUi=function(){var c=this,B=document.createElement("div");return B.style.display="flex",B.style.overflow="hidden",B.style.flexGrow="2",B.style.justifyContent="space-between",this.opacities.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="center",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===c.currentOpacity?c.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){c.setCurrentOpacity(Q,H)}),B.appendChild(H);var ge=document.createElement("div");ge.innerText=100*Q+"%",H.appendChild(ge),c.opacityBoxes.push(H)}),B},s.prototype.setCurrentOpacity=function(c,B){var Q=this;this.currentOpacity=c,this.opacityBoxes.forEach(function(H){H.style.borderColor=H===B?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(He),de=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.setOpacity=H.setOpacity.bind(H),H.fillColor=Q.defaultHighlightColor,H.strokeWidth=0,H.opacity=Q.defaultHighlightOpacity,H.fillPanel=new Be("Color",Q.defaultColorSet,H.fillColor),H.fillPanel.onColorChanged=H.setFillColor,H.opacityPanel=new ae("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return we(s,z),s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=z.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="HighlightMarker",s.title="Highlight marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',s}(ie),me='<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>',Se=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.bgColor="transparent",H.tipPosition={x:0,y:0},H.tipBase1Position={x:0,y:0},H.tipBase2Position={x:0,y:0},H.tipMoving=!1,H.color=Q.defaultStrokeColor,H.bgColor=Q.defaultFillColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setBgColor=H.setBgColor.bind(H),H.getTipPoints=H.getTipPoints.bind(H),H.positionTip=H.positionTip.bind(H),H.setTipPoints=H.setTipPoints.bind(H),H.colorPanel=new Be("Text color",Q.defaultColorSet,H.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),H.colorPanel.onColorChanged=H.setColor,H.bgColorPanel=new Be("Fill color",Q.defaultColorSet,H.bgColor,me),H.bgColorPanel.onColorChanged=H.setBgColor,H.fontFamilyPanel=new Fe("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H.tipGrip=new Ye,H.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),H.controlBox.appendChild(H.tipGrip.visual),H}return we(s,z),s.prototype.ownsTarget=function(c){return z.prototype.ownsTarget.call(this,c)||this.tipGrip.ownsTarget(c)||this.tip===c},s.prototype.createTip=function(){se.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=se.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(c,B){this.state==="new"&&z.prototype.pointerDown.call(this,c,B),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(B)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):z.prototype.pointerDown.call(this,c,B)},s.prototype.pointerUp=function(c){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,z.prototype.pointerUp.call(this,c);else{var B=this.state==="creating";z.prototype.pointerUp.call(this,c),this.setTipPoints(B),this.positionTip()}},s.prototype.manipulate=function(c){if(this.tipMoving){var B=this.unrotatePoint(c);this.tipPosition={x:B.x-this.manipulationStartLeft,y:B.y-this.manipulationStartTop},this.positionTip()}else z.prototype.manipulate.call(this,c)},s.prototype.setBgColor=function(c){this.bgRectangle&&this.tip&&(se.setAttributes(this.bgRectangle,[["fill",c]]),se.setAttributes(this.tip,[["fill",c]])),this.bgColor=c,this.fillColorChanged(c)},s.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},s.prototype.setTipPoints=function(c){c===void 0&&(c=!1);var B=Math.min(this.height/2,15),Q=this.height/5;c&&(this.tipPosition={x:B+Q/2,y:this.height+20});var H=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:B,y:0},this.tipBase2Position={x:B+Q,y:0}):(this.tipBase1Position={x:0,y:B},this.tipBase2Position={x:0,y:B+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-B-Q,y:0},this.tipBase2Position={x:this.width-B,y:0}):(this.tipBase1Position={x:this.width,y:B},this.tipBase2Position={x:this.width,y:B+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?H<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-B-Q,y:this.height},this.tipBase2Position={x:this.width-B,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-B-Q},this.tipBase2Position={x:this.width,y:this.height-B}):H<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,B=Math.min(this.width/2,15),this.tipBase1Position={x:B,y:this.height},this.tipBase2Position={x:B+Q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-B},this.tipBase2Position={x:0,y:this.height-B-Q})},s.prototype.resize=function(c){z.prototype.resize.call(this,c),this.positionTip()},s.prototype.positionTip=function(){se.setAttributes(this.tip,[["points",this.getTipPoints()]]);var c=this.tipGrip.visual.transform.baseVal.getItem(0);c.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(c,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),z.prototype.select.call(this)},s.prototype.getState=function(){var c=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var B=c;this.bgColor=B.bgColor,this.tipPosition=B.tipPosition,z.prototype.restoreState.call(this,c),this.createTip(),this.setTipPoints()},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),this.tipPosition={x:this.tipPosition.x*c,y:this.tipPosition.y*B},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}(Xe),Ie=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.fillColor=Q.defaultFillColor,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.setOpacity=H.setOpacity.bind(H),H.createVisual=H.createVisual.bind(H),H.strokePanel=new Be("Line color",fe(Q.defaultColorSet,["transparent"]),Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.fillPanel=new Be("Fill color",fe(Q.defaultColorSet,["transparent"]),H.fillColor,me),H.fillPanel.onColorChanged=H.setFillColor,H.strokeWidthPanel=new rt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Qe("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H.opacityPanel=new ae("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.visual)},s.prototype.createVisual=function(){this.visual=se.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="new"&&(this.createVisual(),this.moveVisual(c),this._state="creating")},s.prototype.manipulate=function(c){z.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){z.prototype.resize.call(this,c),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(c){z.prototype.pointerUp.call(this,c),this.setSize()},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(c),this.stateChanged()},s.prototype.setFillColor=function(c){this.fillColor=c,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(c),this.stateChanged()},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(c){this.opacity=c,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){var B=c;this.fillColor=B.fillColor,this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.opacity=B.opacity,this.createVisual(),z.prototype.restoreState.call(this,c),this.setSize()},s.prototype.scale=function(c,B){z.prototype.scale.call(this,c,B),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}(Ve),ze=function(z){function s(c,B,Q){return z.call(this,c,B,Q)||this}return we(s,z),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.tip1&&c!==this.tip2)},s.prototype.createTips=function(){this.tip1=se.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip1),this.tip2=se.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(se.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var c=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),B=this.tip1.transform.baseVal.getItem(0);B.setRotate(c,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(B,0);var Q=this.tip2.transform.baseVal.getItem(0);Q.setRotate(c+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Q,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=z.prototype.getState.call(this);return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',s}(at),ot=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.strokePanel.colors=Q.defaultColorSet,H.fillColor="transparent",H}return we(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=z.prototype.getState.call(this);return c.typeName=s.typeName,c},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',s}(Ie),gt=function(){function z(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),z.prototype.addUndoStep=function(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},z.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},z.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},z.prototype.undo=function(){if(this.undoStack.length>1){var s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},z.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},z}(),pt=function(z){function s(c,B,Q){var H=z.call(this,c,B,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.curveX=0,H.curveY=0,H.manipulationStartCurveX=0,H.manipulationStartCurveY=0,H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.positionGrips=H.positionGrips.bind(H),H.addControlGrips=H.addControlGrips.bind(H),H.adjustVisual=H.adjustVisual.bind(H),H.setupControlBox=H.setupControlBox.bind(H),H.resize=H.resize.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Be("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new rt("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Qe("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return we(s,z),s.prototype.ownsTarget=function(c){return!(!z.prototype.ownsTarget.call(this,c)&&c!==this.visual&&c!==this.selectorCurve&&c!==this.visibleCurve&&!this.curveGrip.ownsTarget(c))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorCurve=se.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=se.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(c,B){z.prototype.pointerDown.call(this,c,B),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=c.x,this.curveY=c.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(B)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),se.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){z.prototype.setupControlBox.call(this),this.curveControlLine1=se.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=se.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,z.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){z.prototype.positionGrips.call(this);var c=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-c/2,this.curveY-c/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},s.prototype.manipulate=function(c){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+c.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+c.y-this.manipulationStartY),z.prototype.manipulate.call(this,c)},s.prototype.resize=function(c){this.activeGrip===this.curveGrip&&(this.curveX=c.x,this.curveY=c.y),z.prototype.resize.call(this,c),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(c){this.strokeColor=c,this.adjustVisual(),this.colorChanged(c)},s.prototype.setStrokeWidth=function(c){this.strokeWidth=c,this.adjustVisual()},s.prototype.setStrokeDasharray=function(c){this.strokeDasharray=c,this.adjustVisual()},s.prototype.scale=function(c,B){this.curveX=this.curveX*c,this.curveY=this.curveY*B,z.prototype.scale.call(this,c,B)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var c=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},z.prototype.getState.call(this));return c.typeName=s.typeName,c},s.prototype.restoreState=function(c){z.prototype.restoreState.call(this,c);var B=c;this.strokeColor=B.strokeColor,this.strokeWidth=B.strokeWidth,this.strokeDasharray=B.strokeDasharray,this.curveX=B.curveX,this.curveY=B.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',s}(lt),wt=function(){function z(s,c){c===void 0&&(c=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=c}return Object.defineProperty(z.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),z.prototype.preventDefault=function(){this._defaultPrevented=!0},z}(),Ct=function(z){function s(c,B,Q){var H=z.call(this,c,!1)||this;return H.dataUrl=B,H.state=Q,H}return we(s,z),s}(wt),ht=function(z){function s(c,B,Q){Q===void 0&&(Q=!1);var H=z.call(this,c,Q)||this;return H.marker=B,H}return we(s,z),s}(wt),Ft=function(){function z(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return z.prototype.addEventListener=function(s,c){this[s].push(c)},z.prototype.removeEventListener=function(s,c){var B=this[s].indexOf(c);B>-1&&this[s].splice(B,1)},z}(),Ot=function(){function z(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Pe,this._isOpen=!1,this.undoRedoManager=new gt,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new Ft,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=z.instanceCounter++,this.styles=new _e(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(z.prototype,"ALL_MARKER_TYPES",{get:function(){return[tt,Ce,be,Xe,ot,Ie,de,Se,ze,ie,at,pt]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[tt,Ce,be,Xe,Ie,de,Se]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"BASIC_MARKER_TYPES",{get:function(){return[tt,Ce,be,Xe,de]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var c=this;this._availableMarkerTypes.splice(0),s.forEach(function(B){if(typeof B=="string"){var Q=c.ALL_MARKER_TYPES.find(function(H){return H.typeName===B});Q!==void 0&&c._availableMarkerTypes.push(Q)}else c._availableMarkerTypes.push(B)})},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(s){this._zoomLevel=s,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),te.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},z.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&ne.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=ne.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(c){return c(new wt(s))})},z.prototype.render=function(){return Te(this,void 0,void 0,function(){var s;return ye(this,function(c){switch(c.label){case 0:return this.setCurrentMarker(),(s=new ue).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return c.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,c.sent()]}})})},z.prototype.close=function(s){var c=this;if(s===void 0&&(s=!1),this.isOpen){var B=!1;s||this.eventListeners.beforeclose.forEach(function(Q){var H=new wt(c,!0);Q(H),H.defaultPrevented&&(B=!0)}),B||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(Q){return Q(new wt(c))}),this.detachEvents(),this._isOpen=!1)}},z.prototype.addMarkersToToolbar=function(){for(var s,c=[],B=0;B<arguments.length;B++)c[B]=arguments[B];(s=this._availableMarkerTypes).push.apply(s,c)},z.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(c){s(c.dataUrl,c.state)})},z.prototype.removeRenderEventListener=function(s){},z.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},z.prototype.removeCloseEventListener=function(s){},z.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},z.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,B=c<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(c,B)},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.resize=function(s,c){this._isResizing=!0;var B=s/this.imageWidth,Q=c/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(B,Q),this._isResizing=!1},z.prototype.scaleMarkers=function(s,c){var B,Q=this;this._currentMarker&&this._currentMarker instanceof Xe?this._currentMarker.scale(s,c):(B=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(H){H!==Q._currentMarker&&H.scale(s,c)}),B!==void 0&&this.setCurrentMarker(B)},z.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},z.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left,this.top=s.top-c.top},z.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},z.prototype.addDefs=function(){for(var s,c=[],B=0;B<arguments.length;B++)c[B]=arguments[B];this.defs=se.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,c)},z.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},z.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},z.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},z.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},z.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},z.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},z.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},z.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},z.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},z.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new ke(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new Ne(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},z.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},z.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},z.prototype.toolbarButtonClicked=function(s,c){if(s==="marker"&&c!==void 0)this.createNewMarker(c);else if(s==="action")switch(c){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},z.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var c=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Q){var H=new ht(s,s._currentMarker,!0);Q(H),H.defaultPrevented&&(c=!0)}),!c){var B=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(Q){return Q(new ht(s,B))})}}},z.prototype.clear=function(){var s=this,c=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ge){var We=new ht(s,void 0,!0);ge(We),We.defaultPrevented&&(c=!0)}),!c)){this.setCurrentMarker();for(var B=function(ge){var We=Q.markers[ge];Q.setCurrentMarker(Q.markers[ge]),Q._currentMarker.dispose(),Q.markerImage.removeChild(Q._currentMarker.container),Q.markers.splice(Q.markers.indexOf(Q._currentMarker),1),Q.eventListeners.markerdelete.forEach(function(et){return et(new ht(s,We))})},Q=this,H=this.markers.length-1;H>=0;H--)B(H);this.addUndoStep()}},Object.defineProperty(z.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),z.prototype.showNotesEditor=function(){var s;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},z.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},z.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},z.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var c=this.getState(),B=this.undoRedoManager.getLastUndoStep();if(!B||B.width===c.width&&B.height===c.height){var Q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(c),Q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}else this.undoRedoManager.replaceLastUndoStep(c),this.eventListeners.statechange.forEach(function(H){return H(new wt(s))})}},z.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},z.prototype.undoStep=function(){var s=this,c=this.undoRedoManager.undo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(B){return B(new wt(s))}))},z.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},z.prototype.redoStep=function(){var s=this,c=this.undoRedoManager.redo();c!==void 0&&(this.restoreState(c),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(B){return B(new wt(s))}))},z.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},z.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},z.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var s,c,B=this;return ye(this,function(Q){switch(Q.label){case 0:return[4,this.render()];case 1:return s=Q.sent(),c=this.getState(),this.eventListeners.render.forEach(function(H){return H(new Ct(B,s,c))}),this.close(!0),[2]}})})},z.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var c={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(B){return c.markers.push(B.getState())}),c},z.prototype.restoreState=function(s){var c=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(B){var Q=c._availableMarkerTypes.find(function(ge){return ge.typeName===B.typeName});if(Q!==void 0){var H=c.addNewMarker(Q);H.restoreState(B),c.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(B){return B(new wt(c))})},z.prototype.addNewMarker=function(s){var c=se.createGroup();return this.markerImage.appendChild(c),new s(c,this.overlayContainer,this.settings)},z.prototype.createNewMarker=function(s){var c,B=this;(c=typeof s=="string"?this._availableMarkerTypes.find(function(Q){return Q.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(c),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(c.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(Q){return Q(new ht(B,B._currentMarker))}))},z.prototype.markerCreated=function(s){var c=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof Ce&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(Ce):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(B){return B(new ht(c,c._currentMarker))})},z.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},z.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},z.prototype.markerStateChanged=function(s){var c=this;this.eventListeners.markerchange.forEach(function(B){return B(new ht(c,s))})},z.prototype.setCurrentMarker=function(s){var c=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(B){return B(new ht(c,c._currentMarker))})),this._currentMarker=s,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(B){return B(new ht(c,c._currentMarker))}))},z.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var c=this.markers.find(function(B){return B.ownsTarget(s.target)});c!==void 0?(this.setCurrentMarker(c),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},z.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var c=this.markers.find(function(B){return B.ownsTarget(s.target)});c!==void 0&&c!==this._currentMarker&&this.setCurrentMarker(c),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},z.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},z.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},z.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},z.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},z.prototype.clientToLocalCoordinates=function(s,c){var B=this.markerImage.getBoundingClientRect();return{x:(s-B.left)/this.zoomLevel,y:(c-B.top)/this.zoomLevel}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},z.prototype.addLicenseKey=function(s){te.addKey(s)},z.prototype.addEventListener=function(s,c){this.eventListeners.addEventListener(s,c)},z.prototype.removeEventListener=function(s,c){this.eventListeners.removeEventListener(s,c)},z.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(z.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),z.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(c){return c(new wt(s))}))},z.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(c){return c(new wt(s))}))},z.instanceCounter=0,z}();/* **********************************
cropro version 1.2.0
@license SEE LICENSE IN LICENSE
copyright Alan Mendelevich
see README and LICENSE for details
********************************** *//*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Zt=function(z,s){return(Zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,B){c.__proto__=B}||function(c,B){for(var Q in B)Object.prototype.hasOwnProperty.call(B,Q)&&(c[Q]=B[Q])})(z,s)};function Xt(z,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function c(){this.constructor=z}Zt(z,s),z.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)}function kt(z,s,c,B){return new(c||(c=Promise))(function(Q,H){function ge(ft){try{et(B.next(ft))}catch(Ge){H(Ge)}}function We(ft){try{et(B.throw(ft))}catch(Ge){H(Ge)}}function et(ft){var Ge;ft.done?Q(ft.value):(Ge=ft.value,Ge instanceof c?Ge:new c(function(yt){yt(Ge)})).then(ge,We)}et((B=B.apply(z,s||[])).next())})}function Ir(z,s){var c,B,Q,H,ge={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:We(0),throw:We(1),return:We(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function We(et){return function(ft){return function(Ge){if(c)throw new TypeError("Generator is already executing.");for(;ge;)try{if(c=1,B&&(Q=2&Ge[0]?B.return:Ge[0]?B.throw||((Q=B.return)&&Q.call(B),0):B.next)&&!(Q=Q.call(B,Ge[1])).done)return Q;switch(B=0,Q&&(Ge=[2&Ge[0],Q.value]),Ge[0]){case 0:case 1:Q=Ge;break;case 4:return ge.label++,{value:Ge[1],done:!1};case 5:ge.label++,B=Ge[1],Ge=[0];continue;case 7:Ge=ge.ops.pop(),ge.trys.pop();continue;default:if(!(Q=ge.trys,(Q=Q.length>0&&Q[Q.length-1])||Ge[0]!==6&&Ge[0]!==2)){ge=0;continue}if(Ge[0]===3&&(!Q||Ge[1]>Q[0]&&Ge[1]<Q[3])){ge.label=Ge[1];break}if(Ge[0]===6&&ge.label<Q[1]){ge.label=Q[1],Q=Ge;break}if(Q&&ge.label<Q[2]){ge.label=Q[2],ge.ops.push(Ge);break}Q[2]&&ge.ops.pop(),ge.trys.pop();continue}Ge=s.call(z,ge)}catch(yt){Ge=[6,yt],B=0}finally{c=Q=0}if(5&Ge[0])throw Ge[1];return{value:Ge[0]?Ge[1]:void 0,done:!0}}([et,ft])}}}var Kr=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),Et=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,c){for(var B=0,Q=c;B<Q.length;B++){var H=Q[B],ge=H[0],We=H[1];s.setAttribute(ge,We)}},z.createRect=function(s,c,B){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",c.toString()),B&&z.setAttributes(Q,B),Q},z.createLine=function(s,c,B,Q,H){var ge=document.createElementNS("http://www.w3.org/2000/svg","line");return ge.setAttribute("x1",s.toString()),ge.setAttribute("y1",c.toString()),ge.setAttribute("x2",B.toString()),ge.setAttribute("y2",Q.toString()),H&&z.setAttributes(ge,H),ge},z.createPolygon=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","polygon");return B.setAttribute("points",s),c&&z.setAttributes(B,c),B},z.createCircle=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","circle");return B.setAttribute("cx",(s/2).toString()),B.setAttribute("cy",(s/2).toString()),B.setAttribute("r",s.toString()),c&&z.setAttributes(B,c),B},z.createEllipse=function(s,c,B){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(c/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(c/2).toString()),B&&z.setAttributes(Q,B),Q},z.createGroup=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(c,s),c},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,c,B,Q,H,ge,We){var et=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(et,[["id",s],["orient",c],["markerWidth",B.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",ge.toString()]]),et.appendChild(We),et},z.createText=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","text");return c.setAttribute("x","0"),c.setAttribute("y","0"),s&&z.setAttributes(c,s),c},z.createTSpan=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","tspan");return B.textContent=s,c&&z.setAttributes(B,c),B},z.createImage=function(s){var c=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(c,s),c},z.createPoint=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return B.x=s,B.y=c,B},z.createPath=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg","path");return B.setAttribute("d",s),c&&z.setAttributes(B,c),B},z.createElement=function(s,c){var B=document.createElementNS("http://www.w3.org/2000/svg",s);return c&&z.setAttributes(B,c),B},z.getHollowRectanglePath=function(s,c,B,Q,H,ge,We,et){return"M"+s+","+c+"V"+(c+Q)+"H"+(s+B)+"V"+c+"H"+H+"V"+ge+"H"+(H+We)+"V"+(ge+et)+"H"+H+"V"+c+"Z"},z}(),Nr=function(){function z(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},z.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new dr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new dr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new dr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new pr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new pr("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),dr=function(z,s){this.selector=z,this.style=s},pr=function(z,s){this.localName=z,this.style=s},Br=function(){function z(){this.blocks=[],this.display=""}return z.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},z.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},z.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(c){return s.appendChild(c.getUI())}),s},z}(),ci=function(){function z(){}return z.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},z}(),qr=function(z){function s(){var c=z!==null&&z.apply(this,arguments)||this;return c.buttons=[],c}return Xt(s,z),s.prototype.addButton=function(c){c.className=this.buttonClassName,c.colorsClassName=this.buttonColorsClassName,c.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(c)},s.prototype.getUI=function(){var c=z.prototype.getUI.call(this);return this.buttons.forEach(function(B){return c.appendChild(B.getUI())}),c},s}(ci),It=function(){function z(s,c){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=c,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(z.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),z.prototype.getUI=function(){var s=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},z.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},z.prototype.hide=function(){this._isHidden=!0},z}(),ct=function(z){function s(){var c=z!==null&&z.apply(this,arguments)||this;return c.elements=[],c}return Xt(s,z),s.prototype.addElement=function(c){this.elements.push(c)},s.prototype.getUI=function(){var c=z.prototype.getUI.call(this);return this.elements.forEach(function(B){return c.appendChild(B)}),c},s}(ci),Hr=function(){function z(s,c){this.horizontal=s,this.vertical=c}return Object.defineProperty(z.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),z.prototype.getVerticalLength=function(s){return s/this.ratio},z.prototype.getHorizontalLength=function(s){return s*this.ratio},z}(),ei=function(){function z(){}return z.getIcon=function(s,c){if(s>0&&c>0){var B=new Hr(s,c),Q=B.ratio>=1?20:B.getHorizontalLength(20),H=B.ratio<1?20:B.getVerticalLength(20),ge=document.createElementNS("http://www.w3.org/2000/svg","svg");ge.setAttribute("xmlns","http://www.w3.org/2000/svg"),ge.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ge);var We=Et.createDefs();ge.appendChild(We);var et=Et.createElement("clipPath",[["id","text-bg-clip"]]);We.appendChild(et);var ft=Et.createPath(Et.getHollowRectanglePath((24-Q)/2,(24-H)/2,Q,H,(24-Q)/2+2,(24-H)/2+2,Q-4,H-4));ge.appendChild(ft);var Ge=Et.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ge.appendChild(Et.createTSpan(s+":"+c)),ge.appendChild(Ge);var yt=Ge.getBBox();Et.setAttributes(Ge,[["x",((24-yt.width)/2).toString()],["y",((24-yt.height)/2-yt.y).toString()]]);var Nt=Et.createPath(Et.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(yt.width))/2,(24-Math.ceil(yt.height))/2,Math.ceil(yt.width),Math.ceil(yt.height)));return et.appendChild(Nt),Et.setAttributes(ft,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ge),ge.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},z}(),mr=function(z){function s(c,B,Q){var H=z.call(this,c,B)||this;return H.isDropdownOpen=!1,H.onClick=H.dropdownButtonClicked,H.dropdownButtons=Q,H}return Xt(s,z),s.prototype.setupDropdown=function(){var c=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(B){B.className=c.className,B.colorsClassName=c.colorsClassName,c.dropdownBlock.appendChild(B.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(It),Lt=function(){function z(s,c){this.GRIP_SIZE=10,this.color=s,this.fillColor=c,this.visual=Et.createGroup(),this.visual.appendChild(Et.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Et.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z.prototype.setCenter=function(s,c){this.visual.childNodes.forEach(function(B){return Et.setAttributes(B,[["cx",s.toString()],["cy",c.toString()]])})},z}(),Fr=function(){function z(s,c,B,Q){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=c,this.margin=B,this.container=Q,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(z.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&Et.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),z.prototype.open=function(){var s=this;this.cropShadeElement=Et.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Et.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var c=0;c<this.numberOfGridLines;c++)this.horizontalGridLines.push(Et.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Et.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(B){return s.gridContainer.appendChild(B)}),this.verticalGridLines.forEach(function(B){return s.gridContainer.appendChild(B)}),this.cropRectElement=Et.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Lt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Lt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Lt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Lt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},z.prototype.setCropRectangle=function(s){this.cropRect=s;var c=Object.assign({},this.cropRect);this.zoomFactor!==1&&(c.width=this.cropRect.width*this.zoomFactor,c.height=this.cropRect.height*this.zoomFactor,c.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-c.width/2,c.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-c.height/2),Et.setAttributes(this.cropRectElement,[["x",c.x.toString()],["y",c.y.toString()],["width",c.width.toString()],["height",c.height.toString()]]);var B=c.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(H,ge){var We=c.y+B*(ge+1);Et.setAttributes(H,[["x1",""+c.x],["y1",""+We],["x2",""+(c.x+c.width)],["y2",""+We]])});var Q=c.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(H,ge){var We=c.x+Q*(ge+1);Et.setAttributes(H,[["x1",""+We],["y1",""+c.y],["x2",""+We],["y2",""+(c.y+c.height)]])}),Et.setAttributes(this.cropShadeElement,[["d",Et.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,c.x,c.y,c.width,c.height)]]),this.topLeftGrip.setCenter(c.x,c.y),this.topRightGrip.setCenter(c.x+c.width,c.y),this.bottomLeftGrip.setCenter(c.x,c.y+c.height),this.bottomRightGrip.setCenter(c.x+c.width,c.y+c.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},z.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},z.prototype.clientToLocalCoordinates=function(s,c){var B=this.container.getBoundingClientRect();return{x:s-B.left+this.margin,y:c-B.top+this.margin}},z.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},z.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var c=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(c)}s.preventDefault()},z.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},z.prototype.move=function(s){var c=s.x-this.previousPoint.x,B=s.y-this.previousPoint.y;this.zoomFactor!==1&&(c=-c/this.zoomFactor,B=-B/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+c),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+B),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},z.prototype.resize=function(s){var c=Object.assign({},this.cropRect),B=s.x-this.previousPoint.x,Q=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:c.x+B<this.margin&&(B=this.margin-c.x),c.x+=B,c.width=this.cropRect.x+this.cropRect.width-c.x;break;case this.bottomRightGrip:case this.topRightGrip:c.width+B>this.canvasWidth*this.zoomFactor&&(B=this.canvasWidth*this.zoomFactor-c.width),c.width+=B}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(c.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(B),c.height=this.aspectRatio.getVerticalLength(c.width)):(c.y+=Q,c.height=this.cropRect.y+this.cropRect.height-c.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?c.height=this.aspectRatio.getVerticalLength(c.width):c.height+=Q}c.width<10&&(c.x=this.cropRect.x,c.width=10),c.height<10&&(c.y=this.cropRect.y,c.height=10),this.previousPoint=s,c.x>=this.margin&&c.y>=this.margin&&c.x-this.margin+c.width<=this.canvasWidth&&c.y-this.margin+c.height<=this.canvasHeight&&(this.cropRect=c,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},z.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,c=this.cropRect.y+this.cropRect.height/2,B=this.aspectRatio.getHorizontalLength(this.cropRect.height),Q=this.aspectRatio.getVerticalLength(this.cropRect.width);B/this.canvasWidth<Q/this.canvasHeight?this.cropRect.width=B:this.cropRect.height=Q,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=s-this.cropRect.width/2,this.cropRect.y=c-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},z.prototype.getRescaledRect=function(s,c,B,Q,H,ge){var We=B/s,et=Q/c;return{x:(H.x-ge)*We+ge,y:(H.y-ge)*et+ge,width:H.width*We,height:H.height*et}},z.prototype.scaleCanvas=function(s,c){var B=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,c,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=c,this.onCropChange&&this.onCropChange(B),this.setCropRectangle(B)},z}(),Vr=function(){function z(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(z.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),z.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},z.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},z.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},z.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},z.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();Et.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},z.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},z.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var c="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,B=1;B<=this.width/5+10;B++){var Q=B%5==0?this.height/3:this.height/6;c+="h4v"+-Q+"h1v"+Q}c+="v1H0Z",this.scaleShape=Et.createPath(c);var H=Et.createTransform();this.scaleShape.transform.baseVal.appendItem(H),s.appendChild(this.scaleShape),this.angleLabelElement=Et.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Et.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ge=Et.createTSpan("");return ge.innerHTML="&deg;",this.angleLabelElement.appendChild(ge),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},z}(),fi=function(){function z(){this.naturalSize=!1,this.imageType="image/png"}return z.prototype.rasterize=function(s,c,B,Q,H,ge,We){var et=this;return new Promise(function(ft){var Ge=document.createElement("canvas");Ge.width=s.width.baseVal.value-2*Q,Ge.height=s.height.baseVal.value-2*Q;var yt=1,Nt=1;et.naturalSize===!0?(yt=c.naturalWidth/(s.width.baseVal.value-2*Q)/ge,Nt=c.naturalHeight/(s.height.baseVal.value-2*Q)/We,Ge.width=c.naturalWidth/ge,Ge.height=c.naturalHeight/We):et.width!==void 0&&et.height!==void 0&&(yt=et.width/B.width,Nt=et.height/B.height,Ge.width*=yt,Ge.height*=Nt);var Kt=Ge.getContext("2d");Kt.translate(Ge.width/2,Ge.height/2),Kt.rotate(H*Math.PI/180),Kt.scale(ge,We),Kt.translate(-Ge.width/2,-Ge.height/2),Kt.drawImage(c,0,0,Ge.width,Ge.height);var kr=document.createElement("canvas");kr.width=B.width*yt,kr.height=B.height*Nt,kr.getContext("2d").putImageData(Kt.getImageData((B.x-Q)*yt,(B.y-Q)*Nt,B.width*yt,B.height*Nt),0,0),ft(kr.toDataURL(et.imageType,et.imageQuality))})},z}(),$e=function(){function z(s){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=z.instanceCounter++,this.styles=new Nr(this.instanceNo),this.target=s,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},z.prototype.show=function(){this.showUI(),this.open()},z.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(c){return c()}),this._isOpen=!1)},z.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},z.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},z.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},z.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},z.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},z.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,c=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,B=c+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(c,B)}},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",Et.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},z.prototype.resize=function(s,c){this.imageWidth=Math.round(s),this.imageHeight=Math.round(c),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},z.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var c=s.toDataURL();Et.setAttributes(this.editingTarget,[["href",c]]),this.setEditingTargetSize()},z.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),c=this.editorCanvas.getBoundingClientRect();this.left=s.left-c.left-this.CANVAS_MARGIN,this.top=s.top-c.top-this.CANVAS_MARGIN},z.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=Et.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Et.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Et.createGroup(),this.editingTargetRotationScaleContainer=Et.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=Et.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var c=Et.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(c),this.editingTargetContainer=Et.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},z.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},z.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Et.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Fr(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},z.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,c=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=s+"px "+c+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-c+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},z.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},z.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},z.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},z.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,c=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=c+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},z.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},z.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new Br,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(c);var B=[];this.aspectRatios.forEach(function(Nt){var Kt=new It(ei.getIcon(Nt.horizontal,Nt.vertical),Nt.horizontal===0&&Nt.vertical===0?"FREE":Nt.horizontal+":"+Nt.vertical);Kt.onClick=function(){return s.ratioButtonClicked(Nt)},B.push(Kt)}),this.aspectRatioButton=new mr(ei.getIcon(0,0),"Aspect ratio",B),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,c.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var Q=new It('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");Q.isActive=this.isGridVisible,Q.onClick=function(){s.isGridVisible=!s.isGridVisible,Q.isActive=s.isGridVisible},c.addButton(Q);var H=new It('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(H.isActive=this.zoomToCropEnabled,H.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,H.isActive=s.zoomToCropEnabled},c.addButton(H),!Kr.isLicensed){var ge=new ct;this.topToolbar.addElementBlock(ge);var We=document.createElement("div");We.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var et=document.createElement("a");et.style.color="currentColor",et.href="https://markerjs.com/products/cropro",et.target="_blank",et.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>',We.appendChild(et),ge.addElement(We)}var ft=new qr;ft.minWidth=3*this.toolbarHeight+"px",ft.contentAlign="end",this.topToolbar.addButtonBlock(ft);var Ge=new It('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");Ge.onClick=this.startRenderAndClose,ft.addButton(Ge),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ge.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var yt=new It('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");yt.onClick=this.close,ft.addButton(yt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(yt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},z.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new Br,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var c=new qr;c.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(c);var B=new It('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");B.onClick=this.rotateLeftButtonClicked,c.addButton(B);var Q=new It('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");Q.onClick=this.rotateRightButtonClicked,c.addButton(Q);var H=new ct;H.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(H),this.straightener=new Vr("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(ft){s.rotateBy(ft),s.straightener.angle=s.rotationAngle},H.addElement(this.straightener.getUI());var ge=new qr;ge.minWidth=2*this.toolbarHeight+"px",ge.contentAlign="end",this.bottomToolbar.addButtonBlock(ge);var We=new It('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");We.onClick=this.flipHorizontallyButtonClicked,ge.addButton(We);var et=new It('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");et.onClick=this.flipVerticallyButtonClicked,ge.addButton(et)},z.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},z.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ei.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},z.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Hr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},z.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},z.prototype.restoreState=function(s){if(s){var c=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(c),this.cropRectChanged(c),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},z.prototype.clientToLocalCoordinates=function(s,c){var B=this.cropImage.getBoundingClientRect();return{x:s-B.left,y:c-B.top}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},z.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},z.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},z.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},z.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},z.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var c=this.editingTargetRotationContainer.transform.baseVal.getItem(0);c.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(c,0);var B=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/B.width,this.imageHeight/B.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},z.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},z.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},z.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},z.prototype.startRenderAndClose=function(){return kt(this,void 0,void 0,function(){var s,c;return Ir(this,function(B){switch(B.label){case 0:return[4,this.render()];case 1:return s=B.sent(),c=this.getState(),this.renderEventListeners.forEach(function(Q){return Q(s,c)}),this.close(!0),[2]}})})},z.prototype.render=function(){return kt(this,void 0,void 0,function(){var s;return Ir(this,function(c){switch(c.label){case 0:return(s=new fi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),Et.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return c.sent(),[4,s.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,c.sent()]}})})},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new pr("toolbar",`
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
flex-shrink: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
height: `+this.toolbarHeight+`px;
box-sizing: content-box;
overflow: hidden;
line-height: 0px;
`)),this.toolbarStyleColorsClass=this.styles.addClass(new pr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new pr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new pr("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*s)+`px;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new pr("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new dr("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new dr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new pr("toolbar_dropdown",`
position: absolute;
max-width: `+4*this.toolbarHeight+`px;
z-index: 20;
white-space: normal;
box-sizing: content-box;
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
line-height: 0px;
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new pr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new pr("toolbar_straightener_block",`
display: flex;
overflow: hidden;
justify-content: center;
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new pr("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new pr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},z.instanceCounter=0,z}(),St=re("8hTe"),pi=re.n(St),mi=/<pre[^>]*>/g;function gi(z){var s=document.createElement("div");return s.innerHTML=z,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var vi=Ze.a=function(z){var s=z.value,c=s===void 0?"":s,B=z.edit,Q=B===void 0?!1:B,H=z.className,ge=z.showTextOnly,We=z.showLines,et=z.replaces,ft=z.zoomImg,Ge=z.hasMask,yt=z.style,Nt=yt===void 0?{}:yt,Kt=z.stylesPrev,kr=Kt===void 0?{}:Kt,gr=String(c),vr=Object(D.useRef)(),Xr=Object(D.useRef)(),ki=Object(D.useState)(""),nr=Object(K.a)(ki,2),Ur=nr[0],oi=nr[1],si=Object(D.useState)("office"),Or=Object(K.a)(si,2),Oi=Or[0],yi=Or[1],Gi=function(){var Bt=new $e(Xr.current);Bt.displayMode="popup",Bt.addRenderEventListener(function(){var hr=Object(P.a)(N.a.mark(function Dt(qt){var Wt;return N.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:return vr.current.style.display="none",ar.next=3,Object(Le.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt}});case 3:Wt=ar.sent,Wt!=null&&Wt.id&&et(Xr.current.getAttribute("src").replace(q.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 5:case"end":return ar.stop()}},Dt)}));return function(Dt){return hr.apply(this,arguments)}}()),Bt.show()},Ki=function(){var Bt=new Ot(Xr.current);Bt.settings.displayMode="popup",Bt.addEventListener("render",function(){var hr=Object(P.a)(N.a.mark(function Dt(qt){var Wt;return N.a.wrap(function(ar){for(;;)switch(ar.prev=ar.next){case 0:if(vr.current.style.display="none",!Xr.current){ar.next=6;break}return ar.next=4,Object(Le.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:qt.dataUrl}});case 4:Wt=ar.sent,Wt!=null&&Wt.id&&et(Xr.current.getAttribute("src").replace(q.a.API_SERVER,""),"/api/attachments/".concat(Wt==null?void 0:Wt.id,"?type=").concat(Wt.content_type));case 6:case"end":return ar.stop()}},Dt)}));return function(Dt){return hr.apply(this,arguments)}}()),Bt.show(),window.markerArea=Bt},Yr=Object(D.useMemo)(function(){vr.current&&(vr.current.style.zIndex=-1);try{var Jt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Bt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,hr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gr=gr.replace(Jt,"("+q.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+q.a.API_SERVER+"/api/attachments/").replace(hr,'"'+q.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
`)}catch(ti){}var Dt=V(gr),qt=E();if(gr.match(/\[TOC\]/)&&(Dt=Dt.replace("<p>[TOC]</p>",L()),_()),Dt=Dt.replace(/(__special_katext_id_\d+__)/g,function(ti,ar){var xr=qt[ar],Vi=xr.type,xi=xr.expression;return Object(oe.renderToString)(gi(xi)||"",{displayMode:Vi==="block",throwOnError:!1,output:"html"})}),Dt=Dt.replace(/▁/g,"\u2581\u2581\u2581"),g(),ge){var Wt=document.createElement("div");return Wt.innerHTML=Dt,Wt.innerText}return setTimeout(function(){return hn()},500),Dt},[gr]),zr=Object(D.useRef)();v.WebkitLineClamp=We,We&&(Nt=Object(F.a)(Object(F.a)({},Nt),v));function bi(Jt){var Bt=Jt.target;if(Bt.tagName.toUpperCase()==="IMG"){if(ft){var hr=Bt.getAttribute("src");oi(hr),yi("image")}}else if(Bt.tagName.toUpperCase()==="A"){var Dt=Bt.getAttribute("href");if(Dt.indexOf("office")>-1)Jt.preventDefault(),oi(Dt),yi("office");else if(Dt.indexOf("application/pdf")>-1)Jt.preventDefault(),oi(Dt),yi("pdf");else if(Dt.indexOf("text/html")>-1)Jt.preventDefault(),oi(Dt),yi("html");else if(Dt.startsWith("#")){Jt.preventDefault();var qt=document.getElementById(Dt.replace("#",""));qt&&qt.scrollIntoView(!0)}}}var hn=function(){var Bt,hr=(Bt=zr.current)===null||Bt===void 0?void 0:Bt.querySelectorAll("video");hr==null||hr.forEach(function(Dt){if(Dt.oncontextmenu=function(){return!1},Dt.src.indexOf(".m3u8")>-1&&!Dt.canPlayType("application/vnd.apple.mpegurl")){if(X.a.isSupported()){var qt=new X.a;qt.loadSource(Dt.src),qt.attachMedia(Dt)}}})};Object(D.useEffect)(function(){if(zr.current&&Yr&&(Yr.match(mi)&&window.PR.prettyPrint()),zr.current)return zr.current.addEventListener("click",bi),function(){zr.current.removeEventListener("click",bi),g(),_()}},[Yr,zr.current,bi]);var Ei=function(Bt){if(!Q)return;Bt.target.nodeName==="IMG"?(vr.current.style.zIndex=1,vr.current.style.display="flex",vr.current.style.width=Bt.target.clientWidth+"px",vr.current.style.height=Bt.target.clientHeight+"px",vr.current.style.top=Bt.target.offsetTop+"px",vr.current.style.left=Bt.target.offsetLeft+"px",Xr.current.src=Bt.target.getAttribute("src")):vr.current.style.display="none"};return y.a.createElement("div",{style:{position:"relative"}},y.a.createElement("div",{ref:zr,style:Object(F.a)({},Nt),className:"".concat(H||""," markdown-body ").concat(pi.a.mdBody),onMouseOver:Ei,dangerouslySetInnerHTML:{__html:Yr}}),y.a.createElement("div",{ref:vr,className:pi.a.button},y.a.createElement($.a,null,y.a.createElement(Z.a,{onClick:function(){return Gi()}},"\u88C1\u526A"),y.a.createElement(Z.a,{onClick:function(){return Ki()}},"\u7F16\u8F91"))),y.a.createElement("img",{ref:Xr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),y.a.createElement(ce.a,{close:!0,data:Ur,type:Ur!=null&&Ur.length?Oi:"",style:Object(F.a)({},kr),onClose:function(){return oi("")}}))}},"9VGf":function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return R});var le=re("cDcd"),$=re.n(le);function R(Z,F){var P=Object(le.useRef)();Object(le.useEffect)(function(){P.current=Z}),Object(le.useEffect)(function(){function K(){P.current()}if(F!==null){var j=setInterval(K,F);return function(){return clearInterval(j)}}},[F])}},Bd2K:function(ut,Ze,re){(function(le){le(re("VrN/"),re("osHv"))})(function(le){le.defineOption("autoCloseTags",!1,function(N,D,y){if(y!=le.Init&&y&&N.removeKeyMap("autoCloseTags"),!D)return;var A={name:"autoCloseTags"};(typeof D!="object"||D.whenClosing!==!1)&&(A["'/'"]=function(k){return P(k)}),(typeof D!="object"||D.whenOpening!==!1)&&(A["'>'"]=function(k){return Z(k)}),N.addKeyMap(A)});var $=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],R=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function Z(N){if(N.getOption("disableInput"))return le.Pass;for(var D=N.listSelections(),y=[],A=N.getOption("autoCloseTags"),k=0;k<D.length;k++){if(!D[k].empty())return le.Pass;var T=D[k].head,C=N.getTokenAt(T),b=le.innerMode(N.getMode(),C.state),u=b.state,a=b.mode.xmlCurrentTag&&b.mode.xmlCurrentTag(u),l=a&&a.name;if(!l)return le.Pass;var d=b.mode.configuration=="html",_=typeof A=="object"&&A.dontCloseTags||d&&$,v=typeof A=="object"&&A.indentTags||d&&R;C.end>T.ch&&(l=l.slice(0,l.length-C.end+T.ch));var m=l.toLowerCase();if(!l||C.type=="string"&&(C.end!=T.ch||!/[\"\']/.test(C.string.charAt(C.string.length-1))||C.string.length==1)||C.type=="tag"&&a.close||C.string.indexOf("/")==T.ch-C.start-1||_&&K(_,m)>-1||j(N,b.mode.xmlCurrentContext&&b.mode.xmlCurrentContext(u)||[],l,T,!0))return le.Pass;var L=typeof A=="object"&&A.emptyTags;if(L&&K(L,l)>-1){y[k]={text:"/>",newPos:le.Pos(T.line,T.ch+2)};continue}var x=v&&K(v,m)>-1;y[k]={indent:x,text:">"+(x?`
`:"")+"</"+l+">",newPos:x?le.Pos(T.line+1,0):le.Pos(T.line,T.ch+1)}}for(var p=typeof A=="object"&&A.dontIndentOnAutoClose,k=D.length-1;k>=0;k--){var f=y[k];N.replaceRange(f.text,D[k].head,D[k].anchor,"+insert");var h=N.listSelections().slice(0);h[k]={head:f.newPos,anchor:f.newPos},N.setSelections(h),!p&&f.indent&&(N.indentLine(f.newPos.line,null,!0),N.indentLine(f.newPos.line+1,null,!0))}}function F(N,D){for(var y=N.listSelections(),A=[],k=D?"/":"</",T=N.getOption("autoCloseTags"),C=typeof T=="object"&&T.dontIndentOnSlash,b=0;b<y.length;b++){if(!y[b].empty())return le.Pass;var u=y[b].head,a=N.getTokenAt(u),l=le.innerMode(N.getMode(),a.state),d=l.state;if(D&&(a.type=="string"||a.string.charAt(0)!="<"||a.start!=u.ch-1))return le.Pass;var _,v=l.mode.name!="xml"&&N.getMode().name=="htmlmixed";if(v&&l.mode.name=="javascript")_=k+"script";else if(v&&l.mode.name=="css")_=k+"style";else{var m=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(d);if(!m||m.length&&j(N,m,m[m.length-1],u))return le.Pass;_=k+m[m.length-1]}N.getLine(u.line).charAt(a.end)!=">"&&(_+=">"),A[b]=_}if(N.replaceSelections(A),y=N.listSelections(),!C)for(var b=0;b<y.length;b++)(b==y.length-1||y[b].head.line<y[b+1].head.line)&&N.indentLine(y[b].head.line)}function P(N){return N.getOption("disableInput")?le.Pass:F(N,!0)}le.commands.closeTag=function(N){return F(N)};function K(N,D){if(N.indexOf)return N.indexOf(D);for(var y=0,A=N.length;y<A;++y)if(N[y]==D)return y;return-1}function j(N,D,y,A,k){if(!le.scanForClosingTag)return!1;var T=Math.min(N.lastLine()+1,A.line+500),C=le.scanForClosingTag(N,A,null,T);if(!C||C.tag!=y)return!1;for(var b=k?1:0,u=D.length-1;u>=0&&D[u]==y;u--)++b;A=C.to;for(var u=1;u<b;u++){var a=le.scanForClosingTag(N,A,null,T);if(!a||a.tag!=y)return!1;A=a.to}return!0}})},BjJ7:function(ut,Ze,re){"use strict";re.d(Ze,"d",function(){return $}),re.d(Ze,"c",function(){return R}),re.d(Ze,"e",function(){return Z}),re.d(Ze,"b",function(){return F}),re.d(Ze,"a",function(){return K});var le=re("m3rI");function $(j){var N=!0;if(j.length>0){for(var D=0;D<j.length;D++)if(j[D].compile_success==0||!j[D].compile_success){N=!1;break}}else N=!1;return N}function R(j){for(var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",D=[],y=0;y<j.length;y++){var A=j[y],k=N?"".concat(N,"/").concat(A.name):"".concat(A.name);D.push({title:A.name,isLeaf:!(A.type==="tree"),key:k})}return D}function Z(j,N,D){for(var y=0;y<j.length;y++){var A=j[y];if(A.key===N){A.children=D;break}A.children&&Z(A.children,N,D)}return j}function F(j,N,D){var y;return function(){var A=this,k=arguments,T=function(){y=null,D||j.apply(A,k)},C=D&&!y;clearTimeout(y),y=setTimeout(T,N),C&&j.apply(A,k)}}var P=!0,K=le.a.API_SERVER},"C+DQ":function(ut,Ze,re){},DlQD:function(ut,Ze,re){(function(le,$){ut.exports=$()})(this,function(){"use strict";function le(Ce,ve){for(var be=0;be<ve.length;be++){var ie=ve[be];ie.enumerable=ie.enumerable||!1,ie.configurable=!0,"value"in ie&&(ie.writable=!0),Object.defineProperty(Ce,ie.key,ie)}}function $(Ce,ve,be){return ve&&le(Ce.prototype,ve),be&&le(Ce,be),Ce}function R(Ce,ve){if(!Ce)return;if(typeof Ce=="string")return Z(Ce,ve);var be=Object.prototype.toString.call(Ce).slice(8,-1);if(be==="Object"&&Ce.constructor&&(be=Ce.constructor.name),be==="Map"||be==="Set")return Array.from(Ce);if(be==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(be))return Z(Ce,ve)}function Z(Ce,ve){(ve==null||ve>Ce.length)&&(ve=Ce.length);for(var be=0,ie=new Array(ve);be<ve;be++)ie[be]=Ce[be];return ie}function F(Ce,ve){var be;if(typeof Symbol=="undefined"||Ce[Symbol.iterator]==null){if(Array.isArray(Ce)||(be=R(Ce))||ve&&Ce&&typeof Ce.length=="number"){be&&(Ce=be);var ie=0;return function(){return ie>=Ce.length?{done:!0}:{done:!1,value:Ce[ie++]}}}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 be=Ce[Symbol.iterator](),be.next.bind(be)}function P(Ce,ve){return ve={exports:{}},Ce(ve,ve.exports),ve.exports}var K=P(function(Ce){function ve(){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 be(ie){Ce.exports.defaults=ie}Ce.exports={defaults:ve(),getDefaults:ve,changeDefaults:be}}),j=K.defaults,N=K.getDefaults,D=K.changeDefaults,y=/[&<>"']/,A=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,T=/[<>"']|&(?!#?\w+;)/g,C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},b=function(ve){return C[ve]};function u(Ce,ve){if(ve){if(y.test(Ce))return Ce.replace(A,b)}else if(k.test(Ce))return Ce.replace(T,b);return Ce}var a=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(Ce){return Ce.replace(a,function(ve,be){return be=be.toLowerCase(),be==="colon"?":":be.charAt(0)==="#"?be.charAt(1)==="x"?String.fromCharCode(parseInt(be.substring(2),16)):String.fromCharCode(+be.substring(1)):""})}var d=/(^|[^\[])\^/g;function _(Ce,ve){Ce=Ce.source||Ce,ve=ve||"";var be={replace:function(ae,de){return de=de.source||de,de=de.replace(d,"$1"),Ce=Ce.replace(ae,de),be},getRegex:function(){return new RegExp(Ce,ve)}};return be}var v=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(Ce,ve,be){if(Ce){var ie;try{ie=decodeURIComponent(l(be)).replace(v,"").toLowerCase()}catch(ae){return null}if(ie.indexOf("javascript:")===0||ie.indexOf("vbscript:")===0||ie.indexOf("data:")===0)return null}ve&&!m.test(be)&&(be=o(ve,be));try{be=encodeURI(be).replace(/%25/g,"%")}catch(ae){return null}return be}var x={},p=/^[^:]+:\/*[^/]*$/,f=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(Ce,ve){x[" "+Ce]||(p.test(Ce)?x[" "+Ce]=Ce+"/":x[" "+Ce]=M(Ce,"/",!0)),Ce=x[" "+Ce];var be=Ce.indexOf(":")===-1;return ve.substring(0,2)==="//"?be?ve:Ce.replace(f,"$1")+ve:ve.charAt(0)==="/"?be?ve:Ce.replace(h,"$1")+ve:Ce+ve}var E={exec:function(){}};function g(Ce){for(var ve=1,be,ie;ve<arguments.length;ve++){be=arguments[ve];for(ie in be)Object.prototype.hasOwnProperty.call(be,ie)&&(Ce[ie]=be[ie])}return Ce}function S(Ce,ve){var be=Ce.replace(/\|/g,function(de,me,Se){for(var Ie=!1,ze=me;--ze>=0&&Se[ze]==="\\";)Ie=!Ie;return Ie?"|":" |"}),ie=be.split(/ \|/),ae=0;if(ie.length>ve)ie.splice(ve);else for(;ie.length<ve;)ie.push("");for(;ae<ie.length;ae++)ie[ae]=ie[ae].trim().replace(/\\\|/g,"|");return ie}function M(Ce,ve,be){var ie=Ce.length;if(ie===0)return"";for(var ae=0;ae<ie;){var de=Ce.charAt(ie-ae-1);if(de===ve&&!be)ae++;else if(de!==ve&&be)ae++;else break}return Ce.substr(0,ie-ae)}function U(Ce,ve){if(Ce.indexOf(ve[1])===-1)return-1;for(var be=Ce.length,ie=0,ae=0;ae<be;ae++)if(Ce[ae]==="\\")ae++;else if(Ce[ae]===ve[0])ie++;else if(Ce[ae]===ve[1]&&(ie--,ie<0))return ae;return-1}function G(Ce){Ce&&Ce.sanitize&&!Ce.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var V={escape:u,unescape:l,edit:_,cleanUrl:L,resolveUrl:o,noopTest:E,merge:g,splitCells:S,rtrim:M,findClosingBracket:U,checkSanitizeDeprecation:G},O=K.defaults,I=V.rtrim,X=V.splitCells,q=V.escape,oe=V.findClosingBracket;function ce(Ce,ve,be){var ie=ve.href,ae=ve.title?q(ve.title):null,de=Ce[1].replace(/\\([\[\]])/g,"$1");return Ce[0].charAt(0)!=="!"?{type:"link",raw:be,href:ie,title:ae,text:de}:{type:"image",raw:be,href:ie,title:ae,text:q(de)}}function Le(Ce,ve){var be=Ce.match(/^(\s+)(?:```)/);if(be===null)return ve;var ie=be[1];return ve.split(`
`).map(function(ae){var de=ae.match(/^\s+/);if(de===null)return ae;var me=de[0];return me.length>=ie.length?ae.slice(ie.length):ae}).join(`
`)}var Ee=function(){function Ce(be){this.options=be||O}var ve=Ce.prototype;return ve.space=function(ie){var ae=this.rules.block.newline.exec(ie);if(ae)return ae[0].length>1?{type:"space",raw:ae[0]}:{raw:`
`}},ve.code=function(ie,ae){var de=this.rules.block.code.exec(ie);if(de){var me=ae[ae.length-1];if(me&&me.type==="paragraph")return{raw:de[0],text:de[0].trimRight()};var Se=de[0].replace(/^ {4}/gm,"");return{type:"code",raw:de[0],codeBlockStyle:"indented",text:this.options.pedantic?Se:I(Se,`
`)}}},ve.fences=function(ie){var ae=this.rules.block.fences.exec(ie);if(ae){var de=ae[0],me=Le(de,ae[3]||"");return{type:"code",raw:de,lang:ae[2]?ae[2].trim():ae[2],text:me}}},ve.heading=function(ie){var ae=this.rules.block.heading.exec(ie);if(ae)return{type:"heading",raw:ae[0],depth:ae[1].length,text:ae[2]}},ve.nptable=function(ie){var ae=this.rules.block.nptable.exec(ie);if(ae){var de={type:"table",header:X(ae[1].replace(/^ *| *\| *$/g,"")),align:ae[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ae[3]?ae[3].replace(/\n$/,"").split(`
`):[],raw:ae[0]};if(de.header.length===de.align.length){var me=de.align.length,Se;for(Se=0;Se<me;Se++)/^ *-+: *$/.test(de.align[Se])?de.align[Se]="right":/^ *:-+: *$/.test(de.align[Se])?de.align[Se]="center":/^ *:-+ *$/.test(de.align[Se])?de.align[Se]="left":de.align[Se]=null;for(me=de.cells.length,Se=0;Se<me;Se++)de.cells[Se]=X(de.cells[Se],de.header.length);return de}}},ve.hr=function(ie){var ae=this.rules.block.hr.exec(ie);if(ae)return{type:"hr",raw:ae[0]}},ve.blockquote=function(ie){var ae=this.rules.block.blockquote.exec(ie);if(ae){var de=ae[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:ae[0],text:de}}},ve.list=function(ie){var ae=this.rules.block.list.exec(ie);if(ae){for(var de=ae[0],me=ae[2],Se=me.length>1,Ie=me[me.length-1]===")",ze={type:"list",raw:de,ordered:Se,start:Se?+me.slice(0,-1):"",loose:!1,items:[]},ot=ae[0].match(this.rules.block.item),gt=!1,pt,wt,Ct,ht,Ft,Ot,Zt,Xt=ot.length,kt=0;kt<Xt;kt++)pt=ot[kt],de=pt,wt=pt.length,pt=pt.replace(/^ *([*+-]|\d+[.)]) */,""),~pt.indexOf(`
`)&&(wt-=pt.length,pt=this.options.pedantic?pt.replace(/^ {1,4}/gm,""):pt.replace(new RegExp("^ {1,"+wt+"}","gm"),"")),kt!==Xt-1&&(Ct=this.rules.block.bullet.exec(ot[kt+1])[0],(Se?Ct.length===1||!Ie&&Ct[Ct.length-1]===")":Ct.length>1||this.options.smartLists&&Ct!==me)&&(ht=ot.slice(kt+1).join(`
`),ze.raw=ze.raw.substring(0,ze.raw.length-ht.length),kt=Xt-1)),Ft=gt||/\n\n(?!\s*$)/.test(pt),kt!==Xt-1&&(gt=pt.charAt(pt.length-1)===`
`,Ft||(Ft=gt)),Ft&&(ze.loose=!0),Ot=/^\[[ xX]\] /.test(pt),Zt=void 0,Ot&&(Zt=pt[1]!==" ",pt=pt.replace(/^\[[ xX]\] +/,"")),ze.items.push({type:"list_item",raw:de,task:Ot,checked:Zt,loose:Ft,text:pt});return ze}},ve.html=function(ie){var ae=this.rules.block.html.exec(ie);if(ae)return{type:this.options.sanitize?"paragraph":"html",raw:ae[0],pre:!this.options.sanitizer&&(ae[1]==="pre"||ae[1]==="script"||ae[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ae[0]):q(ae[0]):ae[0]}},ve.def=function(ie){var ae=this.rules.block.def.exec(ie);if(ae){ae[3]&&(ae[3]=ae[3].substring(1,ae[3].length-1));var de=ae[1].toLowerCase().replace(/\s+/g," ");return{tag:de,raw:ae[0],href:ae[2],title:ae[3]}}},ve.table=function(ie){var ae=this.rules.block.table.exec(ie);if(ae){var de={type:"table",header:X(ae[1].replace(/^ *| *\| *$/g,"")),align:ae[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ae[3]?ae[3].replace(/\n$/,"").split(`
`):[]};if(de.header.length===de.align.length){de.raw=ae[0];var me=de.align.length,Se;for(Se=0;Se<me;Se++)/^ *-+: *$/.test(de.align[Se])?de.align[Se]="right":/^ *:-+: *$/.test(de.align[Se])?de.align[Se]="center":/^ *:-+ *$/.test(de.align[Se])?de.align[Se]="left":de.align[Se]=null;for(me=de.cells.length,Se=0;Se<me;Se++)de.cells[Se]=X(de.cells[Se].replace(/^ *\| *| *\| *$/g,""),de.header.length);return de}}},ve.lheading=function(ie){var ae=this.rules.block.lheading.exec(ie);if(ae)return{type:"heading",raw:ae[0],depth:ae[2].charAt(0)==="="?1:2,text:ae[1]}},ve.paragraph=function(ie){var ae=this.rules.block.paragraph.exec(ie);if(ae)return{type:"paragraph",raw:ae[0],text:ae[1].charAt(ae[1].length-1)===`
`?ae[1].slice(0,-1):ae[1]}},ve.text=function(ie,ae){var de=this.rules.block.text.exec(ie);if(de){var me=ae[ae.length-1];return me&&me.type==="text"?{raw:de[0],text:de[0]}:{type:"text",raw:de[0],text:de[0]}}},ve.escape=function(ie){var ae=this.rules.inline.escape.exec(ie);if(ae)return{type:"escape",raw:ae[0],text:q(ae[1])}},ve.tag=function(ie,ae,de){var me=this.rules.inline.tag.exec(ie);if(me)return!ae&&/^<a /i.test(me[0])?ae=!0:ae&&/^<\/a>/i.test(me[0])&&(ae=!1),!de&&/^<(pre|code|kbd|script)(\s|>)/i.test(me[0])?de=!0:de&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(me[0])&&(de=!1),{type:this.options.sanitize?"text":"html",raw:me[0],inLink:ae,inRawBlock:de,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(me[0]):q(me[0]):me[0]}},ve.link=function(ie){var ae=this.rules.inline.link.exec(ie);if(ae){var de=oe(ae[2],"()");if(de>-1){var me=ae[0].indexOf("!")===0?5:4,Se=me+ae[1].length+de;ae[2]=ae[2].substring(0,de),ae[0]=ae[0].substring(0,Se).trim(),ae[3]=""}var Ie=ae[2],ze="";if(this.options.pedantic){var ot=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Ie);ot?(Ie=ot[1],ze=ot[3]):ze=""}else ze=ae[3]?ae[3].slice(1,-1):"";Ie=Ie.trim().replace(/^<([\s\S]*)>$/,"$1");var gt=ce(ae,{href:Ie&&Ie.replace(this.rules.inline._escapes,"$1"),title:ze&&ze.replace(this.rules.inline._escapes,"$1")},ae[0]);return gt}},ve.reflink=function(ie,ae){var de;if((de=this.rules.inline.reflink.exec(ie))||(de=this.rules.inline.nolink.exec(ie))){var me=(de[2]||de[1]).replace(/\s+/g," ");if(me=ae[me.toLowerCase()],!me||!me.href){var Se=de[0].charAt(0);return{type:"text",raw:Se,text:Se}}var Ie=ce(de,me,de[0]);return Ie}},ve.strong=function(ie,ae,de){de===void 0&&(de="");var me=this.rules.inline.strong.start.exec(ie);if(me&&(!me[1]||me[1]&&(de===""||this.rules.inline.punctuation.exec(de)))){ae=ae.slice(-1*ie.length);var Se=me[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;Se.lastIndex=0;for(var Ie;(me=Se.exec(ae))!=null;)if(Ie=this.rules.inline.strong.middle.exec(ae.slice(0,me.index+3)),Ie)return{type:"strong",raw:ie.slice(0,Ie[0].length),text:ie.slice(2,Ie[0].length-2)}}},ve.em=function(ie,ae,de){de===void 0&&(de="");var me=this.rules.inline.em.start.exec(ie);if(me&&(!me[1]||me[1]&&(de===""||this.rules.inline.punctuation.exec(de)))){ae=ae.slice(-1*ie.length);var Se=me[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;Se.lastIndex=0;for(var Ie;(me=Se.exec(ae))!=null;)if(Ie=this.rules.inline.em.middle.exec(ae.slice(0,me.index+2)),Ie)return{type:"em",raw:ie.slice(0,Ie[0].length),text:ie.slice(1,Ie[0].length-1)}}},ve.codespan=function(ie){var ae=this.rules.inline.code.exec(ie);if(ae){var de=ae[2].replace(/\n/g," "),me=/[^ ]/.test(de),Se=de.startsWith(" ")&&de.endsWith(" ");return me&&Se&&(de=de.substring(1,de.length-1)),de=q(de,!0),{type:"codespan",raw:ae[0],text:de}}},ve.br=function(ie){var ae=this.rules.inline.br.exec(ie);if(ae)return{type:"br",raw:ae[0]}},ve.del=function(ie){var ae=this.rules.inline.del.exec(ie);if(ae)return{type:"del",raw:ae[0],text:ae[1]}},ve.autolink=function(ie,ae){var de=this.rules.inline.autolink.exec(ie);if(de){var me,Se;return de[2]==="@"?(me=q(this.options.mangle?ae(de[1]):de[1]),Se="mailto:"+me):(me=q(de[1]),Se=me),{type:"link",raw:de[0],text:me,href:Se,tokens:[{type:"text",raw:me,text:me}]}}},ve.url=function(ie,ae){var de;if(de=this.rules.inline.url.exec(ie)){var me,Se;if(de[2]==="@")me=q(this.options.mangle?ae(de[0]):de[0]),Se="mailto:"+me;else{var Ie;do Ie=de[0],de[0]=this.rules.inline._backpedal.exec(de[0])[0];while(Ie!==de[0]);me=q(de[0]),de[1]==="www."?Se="http://"+me:Se=me}return{type:"link",raw:de[0],text:me,href:Se,tokens:[{type:"text",raw:me,text:me}]}}},ve.inlineText=function(ie,ae,de){var me=this.rules.inline.text.exec(ie);if(me){var Se;return ae?Se=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(me[0]):q(me[0]):me[0]:Se=q(this.options.smartypants?de(me[0]):me[0]),{type:"text",raw:me[0],text:Se}}},Ce}(),we=V.noopTest,Te=V.edit,ye=V.merge,fe={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:we,table:we,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};fe._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,fe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,fe.def=Te(fe.def).replace("label",fe._label).replace("title",fe._title).getRegex(),fe.bullet=/(?:[*+-]|\d{1,9}[.)])/,fe.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,fe.item=Te(fe.item,"gm").replace(/bull/g,fe.bullet).getRegex(),fe.list=Te(fe.list).replace(/bull/g,fe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+fe.def.source+")").getRegex(),fe._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",fe._comment=/<!--(?!-?>)[\s\S]*?-->/,fe.html=Te(fe.html,"i").replace("comment",fe._comment).replace("tag",fe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fe.paragraph=Te(fe._paragraph).replace("hr",fe.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",fe._tag).getRegex(),fe.blockquote=Te(fe.blockquote).replace("paragraph",fe.paragraph).getRegex(),fe.normal=ye({},fe),fe.gfm=ye({},fe.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*|$)"}),fe.gfm.nptable=Te(fe.gfm.nptable).replace("hr",fe.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",fe._tag).getRegex(),fe.gfm.table=Te(fe.gfm.table).replace("hr",fe.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",fe._tag).getRegex(),fe.pedantic=ye({},fe.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fe._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:we,paragraph:Te(fe.normal._paragraph).replace("hr",fe.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",fe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:we,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:we,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Te(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Te(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Te(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Te(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Te(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Te(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Te(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Te(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Te(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Te(se._blockSkip,"g").getRegex(),se.overlapSkip=Te(se._overlapSkip,"g").getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,se.autolink=Te(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Te(se.tag).replace("comment",fe._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Te(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Te(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Te(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal=ye({},se),se.pedantic=ye({},se.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Te(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=ye({},se.normal,{escape:Te(se.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),se.gfm.url=Te(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=ye({},se.gfm,{br:Te(se.br).replace("{2,}","*").getRegex(),text:Te(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var te={block:fe,inline:se},ue=K.defaults,ne=te.block,_e=te.inline;function Re(Ce){return Ce.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(Ce){var ve="",be,ie,ae=Ce.length;for(be=0;be<ae;be++)ie=Ce.charCodeAt(be),Math.random()>.5&&(ie="x"+ie.toString(16)),ve+="&#"+ie+";";return ve}var ke=function(){function Ce(be){this.tokens=[],this.tokens.links=Object.create(null),this.options=be||ue,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ie={block:ne.normal,inline:_e.normal};this.options.pedantic?(ie.block=ne.pedantic,ie.inline=_e.pedantic):this.options.gfm&&(ie.block=ne.gfm,this.options.breaks?ie.inline=_e.breaks:ie.inline=_e.gfm),this.tokenizer.rules=ie}Ce.lex=function(ie,ae){var de=new Ce(ae);return de.lex(ie)};var ve=Ce.prototype;return ve.lex=function(ie){return ie=ie.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(ie,this.tokens,!0),this.inline(this.tokens),this.tokens},ve.blockTokens=function(ie,ae,de){ae===void 0&&(ae=[]),de===void 0&&(de=!0),ie=ie.replace(/^ +$/gm,"");for(var me,Se,Ie,ze;ie;){if(me=this.tokenizer.space(ie)){ie=ie.substring(me.raw.length),me.type&&ae.push(me);continue}if(me=this.tokenizer.code(ie,ae)){ie=ie.substring(me.raw.length),me.type?ae.push(me):(ze=ae[ae.length-1],ze.raw+=`
`+me.raw,ze.text+=`
`+me.text);continue}if(me=this.tokenizer.fences(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.heading(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.nptable(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.hr(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.blockquote(ie)){ie=ie.substring(me.raw.length),me.tokens=this.blockTokens(me.text,[],de),ae.push(me);continue}if(me=this.tokenizer.list(ie)){for(ie=ie.substring(me.raw.length),Ie=me.items.length,Se=0;Se<Ie;Se++)me.items[Se].tokens=this.blockTokens(me.items[Se].text,[],!1);ae.push(me);continue}if(me=this.tokenizer.html(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(de&&(me=this.tokenizer.def(ie))){ie=ie.substring(me.raw.length),this.tokens.links[me.tag]||(this.tokens.links[me.tag]={href:me.href,title:me.title});continue}if(me=this.tokenizer.table(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.lheading(ie)){ie=ie.substring(me.raw.length),ae.push(me);continue}if(de&&(me=this.tokenizer.paragraph(ie))){ie=ie.substring(me.raw.length),ae.push(me);continue}if(me=this.tokenizer.text(ie,ae)){ie=ie.substring(me.raw.length),me.type?ae.push(me):(ze=ae[ae.length-1],ze.raw+=`
`+me.raw,ze.text+=`
`+me.text);continue}if(ie){var ot="Infinite loop on byte: "+ie.charCodeAt(0);if(this.options.silent){console.error(ot);break}else throw new Error(ot)}}return ae},ve.inline=function(ie){var ae,de,me,Se,Ie,ze,ot=ie.length;for(ae=0;ae<ot;ae++){ze=ie[ae];switch(ze.type){case"paragraph":case"text":case"heading":{ze.tokens=[],this.inlineTokens(ze.text,ze.tokens);break}case"table":{for(ze.tokens={header:[],cells:[]},Se=ze.header.length,de=0;de<Se;de++)ze.tokens.header[de]=[],this.inlineTokens(ze.header[de],ze.tokens.header[de]);for(Se=ze.cells.length,de=0;de<Se;de++)for(Ie=ze.cells[de],ze.tokens.cells[de]=[],me=0;me<Ie.length;me++)ze.tokens.cells[de][me]=[],this.inlineTokens(Ie[me],ze.tokens.cells[de][me]);break}case"blockquote":{this.inline(ze.tokens);break}case"list":{for(Se=ze.items.length,de=0;de<Se;de++)this.inline(ze.items[de].tokens);break}}}return ie},ve.inlineTokens=function(ie,ae,de,me,Se){ae===void 0&&(ae=[]),de===void 0&&(de=!1),me===void 0&&(me=!1),Se===void 0&&(Se="");var Ie,ze=ie,ot;if(this.tokens.links){var gt=Object.keys(this.tokens.links);if(gt.length>0)for(;(ot=this.tokenizer.rules.inline.reflinkSearch.exec(ze))!=null;)gt.includes(ot[0].slice(ot[0].lastIndexOf("[")+1,-1))&&(ze=ze.slice(0,ot.index)+"["+"a".repeat(ot[0].length-2)+"]"+ze.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(ot=this.tokenizer.rules.inline.blockSkip.exec(ze))!=null;)ze=ze.slice(0,ot.index)+"["+"a".repeat(ot[0].length-2)+"]"+ze.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ie;){if(Ie=this.tokenizer.escape(ie)){ie=ie.substring(Ie.raw.length),ae.push(Ie);continue}if(Ie=this.tokenizer.tag(ie,de,me)){ie=ie.substring(Ie.raw.length),de=Ie.inLink,me=Ie.inRawBlock,ae.push(Ie);continue}if(Ie=this.tokenizer.link(ie)){ie=ie.substring(Ie.raw.length),Ie.type==="link"&&(Ie.tokens=this.inlineTokens(Ie.text,[],!0,me)),ae.push(Ie);continue}if(Ie=this.tokenizer.reflink(ie,this.tokens.links)){ie=ie.substring(Ie.raw.length),Ie.type==="link"&&(Ie.tokens=this.inlineTokens(Ie.text,[],!0,me)),ae.push(Ie);continue}if(Ie=this.tokenizer.strong(ie,ze,Se)){ie=ie.substring(Ie.raw.length),Ie.tokens=this.inlineTokens(Ie.text,[],de,me),ae.push(Ie);continue}if(Ie=this.tokenizer.em(ie,ze,Se)){ie=ie.substring(Ie.raw.length),Ie.tokens=this.inlineTokens(Ie.text,[],de,me),ae.push(Ie);continue}if(Ie=this.tokenizer.codespan(ie)){ie=ie.substring(Ie.raw.length),ae.push(Ie);continue}if(Ie=this.tokenizer.br(ie)){ie=ie.substring(Ie.raw.length),ae.push(Ie);continue}if(Ie=this.tokenizer.del(ie)){ie=ie.substring(Ie.raw.length),Ie.tokens=this.inlineTokens(Ie.text,[],de,me),ae.push(Ie);continue}if(Ie=this.tokenizer.autolink(ie,xe)){ie=ie.substring(Ie.raw.length),ae.push(Ie);continue}if(!de&&(Ie=this.tokenizer.url(ie,xe))){ie=ie.substring(Ie.raw.length),ae.push(Ie);continue}if(Ie=this.tokenizer.inlineText(ie,me,Re)){ie=ie.substring(Ie.raw.length),Se=Ie.raw.slice(-1),ae.push(Ie);continue}if(ie){var pt="Infinite loop on byte: "+ie.charCodeAt(0);if(this.options.silent){console.error(pt);break}else throw new Error(pt)}}return ae},$(Ce,null,[{key:"rules",get:function(){return{block:ne,inline:_e}}}]),Ce}(),Ne=K.defaults,He=V.cleanUrl,Be=V.escape,Me=function(){function Ce(be){this.options=be||Ne}var ve=Ce.prototype;return ve.code=function(ie,ae,de){var me=(ae||"").match(/\S*/)[0];if(this.options.highlight){var Se=this.options.highlight(ie,me);Se!=null&&Se!==ie&&(de=!0,ie=Se)}return me?'<pre><code class="'+this.options.langPrefix+Be(me,!0)+'">'+(de?ie:Be(ie,!0))+`</code></pre>
`:"<pre><code>"+(de?ie:Be(ie,!0))+`</code></pre>
`},ve.blockquote=function(ie){return`<blockquote>
`+ie+`</blockquote>
`},ve.html=function(ie){return ie},ve.heading=function(ie,ae,de,me){return this.options.headerIds?"<h"+ae+' id="'+this.options.headerPrefix+me.slug(de)+'">'+ie+"</h"+ae+`>
`:"<h"+ae+">"+ie+"</h"+ae+`>
`},ve.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},ve.list=function(ie,ae,de){var me=ae?"ol":"ul",Se=ae&&de!==1?' start="'+de+'"':"";return"<"+me+Se+`>
`+ie+"</"+me+`>
`},ve.listitem=function(ie){return"<li>"+ie+`</li>
`},ve.checkbox=function(ie){return"<input "+(ie?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ve.paragraph=function(ie){return"<p>"+ie+`</p>
`},ve.table=function(ie,ae){return ae&&(ae="<tbody>"+ae+"</tbody>"),`<table>
<thead>
`+ie+`</thead>
`+ae+`</table>
`},ve.tablerow=function(ie){return`<tr>
`+ie+`</tr>
`},ve.tablecell=function(ie,ae){var de=ae.header?"th":"td",me=ae.align?"<"+de+' align="'+ae.align+'">':"<"+de+">";return me+ie+"</"+de+`>
`},ve.strong=function(ie){return"<strong>"+ie+"</strong>"},ve.em=function(ie){return"<em>"+ie+"</em>"},ve.codespan=function(ie){return"<code>"+ie+"</code>"},ve.br=function(){return this.options.xhtml?"<br/>":"<br>"},ve.del=function(ie){return"<del>"+ie+"</del>"},ve.link=function(ie,ae,de){if(ie=He(this.options.sanitize,this.options.baseUrl,ie),ie===null)return de;var me='<a href="'+Be(ie)+'"';return ae&&(me+=' title="'+ae+'"'),me+=">"+de+"</a>",me},ve.image=function(ie,ae,de){if(ie=He(this.options.sanitize,this.options.baseUrl,ie),ie===null)return de;var me='<img src="'+ie+'" alt="'+de+'"';return ae&&(me+=' title="'+ae+'"'),me+=this.options.xhtml?"/>":">",me},ve.text=function(ie){return ie},Ce}(),Oe=function(){function Ce(){}var ve=Ce.prototype;return ve.strong=function(ie){return ie},ve.em=function(ie){return ie},ve.codespan=function(ie){return ie},ve.del=function(ie){return ie},ve.html=function(ie){return ie},ve.text=function(ie){return ie},ve.link=function(ie,ae,de){return""+de},ve.image=function(ie,ae,de){return""+de},ve.br=function(){return""},Ce}(),Ye=function(){function Ce(){this.seen={}}var ve=Ce.prototype;return ve.slug=function(ie){var ae=ie.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(ae)){var de=ae;do this.seen[de]++,ae=de+"-"+this.seen[de];while(this.seen.hasOwnProperty(ae))}return this.seen[ae]=0,ae},Ce}(),Je=K.defaults,Ve=V.unescape,je=function(){function Ce(be){this.options=be||Je,this.options.renderer=this.options.renderer||new Me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Oe,this.slugger=new Ye}Ce.parse=function(ie,ae){var de=new Ce(ae);return de.parse(ie)};var ve=Ce.prototype;return ve.parse=function(ie,ae){ae===void 0&&(ae=!0);var de="",me,Se,Ie,ze,ot,gt,pt,wt,Ct,ht,Ft,Ot,Zt,Xt,kt,Ir,Kr,Et,Nr=ie.length;for(me=0;me<Nr;me++){ht=ie[me];switch(ht.type){case"space":continue;case"hr":{de+=this.renderer.hr();continue}case"heading":{de+=this.renderer.heading(this.parseInline(ht.tokens),ht.depth,Ve(this.parseInline(ht.tokens,this.textRenderer)),this.slugger);continue}case"code":{de+=this.renderer.code(ht.text,ht.lang,ht.escaped);continue}case"table":{for(wt="",pt="",ze=ht.header.length,Se=0;Se<ze;Se++)pt+=this.renderer.tablecell(this.parseInline(ht.tokens.header[Se]),{header:!0,align:ht.align[Se]});for(wt+=this.renderer.tablerow(pt),Ct="",ze=ht.cells.length,Se=0;Se<ze;Se++){for(gt=ht.tokens.cells[Se],pt="",ot=gt.length,Ie=0;Ie<ot;Ie++)pt+=this.renderer.tablecell(this.parseInline(gt[Ie]),{header:!1,align:ht.align[Ie]});Ct+=this.renderer.tablerow(pt)}de+=this.renderer.table(wt,Ct);continue}case"blockquote":{Ct=this.parse(ht.tokens),de+=this.renderer.blockquote(Ct);continue}case"list":{for(Ft=ht.ordered,Ot=ht.start,Zt=ht.loose,ze=ht.items.length,Ct="",Se=0;Se<ze;Se++)kt=ht.items[Se],Ir=kt.checked,Kr=kt.task,Xt="",kt.task&&(Et=this.renderer.checkbox(Ir),Zt?kt.tokens.length>0&&kt.tokens[0].type==="text"?(kt.tokens[0].text=Et+" "+kt.tokens[0].text,kt.tokens[0].tokens&&kt.tokens[0].tokens.length>0&&kt.tokens[0].tokens[0].type==="text"&&(kt.tokens[0].tokens[0].text=Et+" "+kt.tokens[0].tokens[0].text)):kt.tokens.unshift({type:"text",text:Et}):Xt+=Et),Xt+=this.parse(kt.tokens,Zt),Ct+=this.renderer.listitem(Xt,Kr,Ir);de+=this.renderer.list(Ct,Ft,Ot);continue}case"html":{de+=this.renderer.html(ht.text);continue}case"paragraph":{de+=this.renderer.paragraph(this.parseInline(ht.tokens));continue}case"text":{for(Ct=ht.tokens?this.parseInline(ht.tokens):ht.text;me+1<Nr&&ie[me+1].type==="text";)ht=ie[++me],Ct+=`
`+(ht.tokens?this.parseInline(ht.tokens):ht.text);de+=ae?this.renderer.paragraph(Ct):Ct;continue}default:{var dr='Token with "'+ht.type+'" type was not found.';if(this.options.silent){console.error(dr);return}else throw new Error(dr)}}}return de},ve.parseInline=function(ie,ae){ae=ae||this.renderer;var de="",me,Se,Ie=ie.length;for(me=0;me<Ie;me++){Se=ie[me];switch(Se.type){case"escape":{de+=ae.text(Se.text);break}case"html":{de+=ae.html(Se.text);break}case"link":{de+=ae.link(Se.href,Se.title,this.parseInline(Se.tokens,ae));break}case"image":{de+=ae.image(Se.href,Se.title,Se.text);break}case"strong":{de+=ae.strong(this.parseInline(Se.tokens,ae));break}case"em":{de+=ae.em(this.parseInline(Se.tokens,ae));break}case"codespan":{de+=ae.codespan(Se.text);break}case"br":{de+=ae.br();break}case"del":{de+=ae.del(this.parseInline(Se.tokens,ae));break}case"text":{de+=ae.text(Se.text);break}default:{var ze='Token with "'+Se.type+'" type was not found.';if(this.options.silent){console.error(ze);return}else throw new Error(ze)}}}return de},Ce}(),rt=V.merge,Qe=V.checkSanitizeDeprecation,tt=V.escape,Pe=K.getDefaults,lt=K.changeDefaults,at=K.defaults;function Fe(Ce,ve,be){if(typeof Ce=="undefined"||Ce===null)throw new Error("marked(): input parameter is undefined or null");if(typeof Ce!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(Ce)+", string expected");if(typeof ve=="function"&&(be=ve,ve=null),ve=rt({},Fe.defaults,ve||{}),Qe(ve),be){var ie=ve.highlight,ae;try{ae=ke.lex(Ce,ve)}catch(Ie){return be(Ie)}var de=function(ze){var ot;if(!ze)try{ot=je.parse(ae,ve)}catch(gt){ze=gt}return ve.highlight=ie,ze?be(ze):be(null,ot)};if(!ie||ie.length<3)return de();if(delete ve.highlight,!ae.length)return de();var me=0;Fe.walkTokens(ae,function(Ie){Ie.type==="code"&&(me++,setTimeout(function(){ie(Ie.text,Ie.lang,function(ze,ot){if(ze)return de(ze);ot!=null&&ot!==Ie.text&&(Ie.text=ot,Ie.escaped=!0),me--,me===0&&de()})},0))}),me===0&&de();return}try{var Se=ke.lex(Ce,ve);return ve.walkTokens&&Fe.walkTokens(Se,ve.walkTokens),je.parse(Se,ve)}catch(Ie){if(Ie.message+=`
Please report this to https://github.com/markedjs/marked.`,ve.silent)return"<p>An error occurred:</p><pre>"+tt(Ie.message+"",!0)+"</pre>";throw Ie}}Fe.options=Fe.setOptions=function(Ce){return rt(Fe.defaults,Ce),lt(Fe.defaults),Fe},Fe.getDefaults=Pe,Fe.defaults=at,Fe.use=function(Ce){var ve=rt({},Ce);if(Ce.renderer&&function(){var ie=Fe.defaults.renderer||new Me,ae=function(Se){var Ie=ie[Se];ie[Se]=function(){for(var ze=arguments.length,ot=new Array(ze),gt=0;gt<ze;gt++)ot[gt]=arguments[gt];var pt=Ce.renderer[Se].apply(ie,ot);return pt===!1&&(pt=Ie.apply(ie,ot)),pt}};for(var de in Ce.renderer)ae(de);ve.renderer=ie}(),Ce.tokenizer&&function(){var ie=Fe.defaults.tokenizer||new Ee,ae=function(Se){var Ie=ie[Se];ie[Se]=function(){for(var ze=arguments.length,ot=new Array(ze),gt=0;gt<ze;gt++)ot[gt]=arguments[gt];var pt=Ce.tokenizer[Se].apply(ie,ot);return pt===!1&&(pt=Ie.apply(ie,ot)),pt}};for(var de in Ce.tokenizer)ae(de);ve.tokenizer=ie}(),Ce.walkTokens){var be=Fe.defaults.walkTokens;ve.walkTokens=function(ie){Ce.walkTokens(ie),be&&be(ie)}}Fe.setOptions(ve)},Fe.walkTokens=function(Ce,ve){for(var be=F(Ce),ie;!(ie=be()).done;){var ae=ie.value;ve(ae);switch(ae.type){case"table":{for(var de=F(ae.tokens.header),me;!(me=de()).done;){var Se=me.value;Fe.walkTokens(Se,ve)}for(var Ie=F(ae.tokens.cells),ze;!(ze=Ie()).done;)for(var ot=ze.value,gt=F(ot),pt;!(pt=gt()).done;){var wt=pt.value;Fe.walkTokens(wt,ve)}break}case"list":{Fe.walkTokens(ae.items,ve);break}default:ae.tokens&&Fe.walkTokens(ae.tokens,ve)}}},Fe.Parser=je,Fe.parser=je.parse,Fe.Renderer=Me,Fe.TextRenderer=Oe,Fe.Lexer=ke,Fe.lexer=ke.lex,Fe.Tokenizer=Ee,Fe.Slugger=Ye,Fe.parse=Fe;var Xe=Fe;return Xe})},ELLl:function(ut,Ze,re){(function(le){le(re("VrN/"))})(function(le){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},R=le.Pos;le.defineOption("autoCloseBrackets",!1,function(C,b,u){u&&u!=le.Init&&(C.removeKeyMap(F),C.state.closeBrackets=null),b&&(P(Z(b,"pairs")),C.state.closeBrackets=b,C.addKeyMap(F))});function Z(C,b){return b=="pairs"&&typeof C=="string"?C:typeof C=="object"&&C[b]!=null?C[b]:$[b]}var F={Backspace:N,Enter:D};function P(C){for(var b=0;b<C.length;b++){var u=C.charAt(b),a="'"+u+"'";F[a]||(F[a]=K(u))}}P($.pairs+"`");function K(C){return function(b){return A(b,C)}}function j(C){var b=C.state.closeBrackets;if(!b||b.override)return b;var u=C.getModeAt(C.getCursor());return u.closeBrackets||b}function N(C){var b=j(C);if(!b||C.getOption("disableInput"))return le.Pass;for(var u=Z(b,"pairs"),a=C.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return le.Pass;var d=k(C,a[l].head);if(!d||u.indexOf(d)%2!=0)return le.Pass}for(var l=a.length-1;l>=0;l--){var _=a[l].head;C.replaceRange("",R(_.line,_.ch-1),R(_.line,_.ch+1),"+delete")}}function D(C){var b=j(C),u=b&&Z(b,"explode");if(!u||C.getOption("disableInput"))return le.Pass;for(var a=C.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return le.Pass;var d=k(C,a[l].head);if(!d||u.indexOf(d)%2!=0)return le.Pass}C.operation(function(){var _=C.lineSeparator()||`
`;C.replaceSelection(_+_,null),C.execCommand("goCharLeft"),a=C.listSelections();for(var v=0;v<a.length;v++){var m=a[v].head.line;C.indentLine(m,null,!0),C.indentLine(m+1,null,!0)}})}function y(C){var b=le.cmpPos(C.anchor,C.head)>0;return{anchor:new R(C.anchor.line,C.anchor.ch+(b?-1:1)),head:new R(C.head.line,C.head.ch+(b?1:-1))}}function A(C,b){var u=j(C);if(!u||C.getOption("disableInput"))return le.Pass;var a=Z(u,"pairs"),l=a.indexOf(b);if(l==-1)return le.Pass;for(var d=Z(u,"closeBefore"),_=Z(u,"triples"),v=a.charAt(l+1)==b,m=C.listSelections(),L=l%2==0,x,p=0;p<m.length;p++){var f=m[p],h=f.head,o,E=C.getRange(h,R(h.line,h.ch+1));if(L&&!f.empty())o="surround";else if((v||!L)&&E==b)v&&T(C,h)?o="both":_.indexOf(b)>=0&&C.getRange(h,R(h.line,h.ch+3))==b+b+b?o="skipThree":o="skip";else if(v&&h.ch>1&&_.indexOf(b)>=0&&C.getRange(R(h.line,h.ch-2),h)==b+b){if(h.ch>2&&/\bstring/.test(C.getTokenTypeAt(R(h.line,h.ch-2))))return le.Pass;o="addFour"}else if(v){var g=h.ch==0?" ":C.getRange(R(h.line,h.ch-1),h);if(!le.isWordChar(E)&&g!=b&&!le.isWordChar(g))o="both";else return le.Pass}else if(L&&(E.length===0||/\s/.test(E)||d.indexOf(E)>-1))o="both";else return le.Pass;if(!x)x=o;else if(x!=o)return le.Pass}var S=l%2?a.charAt(l-1):b,M=l%2?b:a.charAt(l+1);C.operation(function(){if(x=="skip")C.execCommand("goCharRight");else if(x=="skipThree")for(var U=0;U<3;U++)C.execCommand("goCharRight");else if(x=="surround"){for(var G=C.getSelections(),U=0;U<G.length;U++)G[U]=S+G[U]+M;C.replaceSelections(G,"around"),G=C.listSelections().slice();for(var U=0;U<G.length;U++)G[U]=y(G[U]);C.setSelections(G)}else x=="both"?(C.replaceSelection(S+M,null),C.triggerElectric(S+M),C.execCommand("goCharLeft")):x=="addFour"&&(C.replaceSelection(S+S+S+S,"before"),C.execCommand("goCharRight"))})}function k(C,b){var u=C.getRange(R(b.line,b.ch-1),R(b.line,b.ch+1));return u.length==2?u:null}function T(C,b){var u=C.getTokenAt(R(b.line,b.ch+1));return/\bstring/.test(u.type)&&u.start==b.ch&&(b.ch==0||!/\bstring/.test(C.getTokenTypeAt(b)))}})},Fhpe:function(ut,Ze,re){ut.exports={flex_box_center:"flex_box_center___1W7Bl",flex_space_between:"flex_space_between___3S4Sp",flex_box_vertical_center:"flex_box_vertical_center___5mGEA",flex_box_center_end:"flex_box_center_end___1blqp",flex_box_column:"flex_box_column___4i1E0",CustomCss:"CustomCss___3thFA",CustomTipsModalCss:"CustomTipsModalCss___2aNwC",dropdownmenus:"dropdownmenus___19dGk",popupClassNames:"popupClassNames___3LOFQ",selectdown:"selectdown___1_utH"}},GfqC:function(ut,Ze,re){"use strict";var le=re("cDcd"),$=re.n(le),R=re("TSYQ"),Z=re.n(R);function F(V,O){var I="cannot "+V.method+" "+V.action+" "+O.status+"'",X=new Error(I);return X.status=O.status,X.method=V.method,X.url=V.action,X}function P(V){var O=V.responseText||V.response;if(!O)return O;try{return JSON.parse(O)}catch(I){return O}}function K(V){var O=new XMLHttpRequest;V.onProgress&&O.upload&&(O.upload.onprogress=function(oe){oe.total>0&&(oe.percent=oe.loaded/oe.total*100),V.onProgress(oe)});var I=new FormData;V.data&&Object.keys(V.data).forEach(function(q){var oe=V.data[q];if(Array.isArray(oe)){oe.forEach(function(ce){I.append(q+"[]",ce)});return}I.append(q,V.data[q])}),V.file instanceof Blob?I.append(V.filename,V.file,V.file.name):I.append(V.filename,V.file),O.onerror=function(oe){V.onError(oe)},O.onload=function(){return O.status<200||O.status>=300?V.onError(F(V,O),P(O)):V.onSuccess(P(O),O)},O.open(V.method,V.action,!0),V.withCredentials&&"withCredentials"in O&&(O.withCredentials=!0);var X=V.headers||{};return X["X-Requested-With"]!==null&&O.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(X).forEach(function(q){X[q]!==null&&O.setRequestHeader(q,X[q])}),O.send(I),{abort:function(){O.abort()}}}var j=+new Date,N=0;function D(){return"rc-upload-"+j+"-"+ ++N}function y(V,O){return V.indexOf(O,V.length-O.length)!==-1}var A=function(V,O){if(V&&O){var I=Array.isArray(O)?O:O.split(","),X=V.name||"",q=V.type||"",oe=q.replace(/\/.*$/,"");return I.some(function(ce){var Le=ce.trim();return Le.charAt(0)==="."?y(X.toLowerCase(),Le.toLowerCase()):/\/\*$/.test(Le)?oe===Le.replace(/\/.*$/,""):q===Le})}return!0};function k(V,O){var I=V.createReader(),X=[];function q(){I.readEntries(function(oe){var ce=Array.prototype.slice.apply(oe);X=X.concat(ce);var Le=!ce.length;Le?O(X):q()})}q()}var T=function(O,I,X){var q=function oe(ce,Le){Le=Le||"",ce.isFile?ce.file(function(Ee){X(Ee)&&(ce.fullPath&&!Ee.webkitRelativePath&&(Object.defineProperties(Ee,{webkitRelativePath:{writable:!0}}),Ee.webkitRelativePath=ce.fullPath.replace(/^\//,""),Object.defineProperties(Ee,{webkitRelativePath:{writable:!1}})),I([Ee]))}):ce.isDirectory&&k(ce,function(Ee){Ee.forEach(function(we){oe(we,""+Le+ce.name+"/")})})};O.forEach(function(oe){q(oe.webkitGetAsEntry())})},C=T,b=Object.assign||function(V){for(var O=1;O<arguments.length;O++){var I=arguments[O];for(var X in I)Object.prototype.hasOwnProperty.call(I,X)&&(V[X]=I[X])}return V},u=function(){function V(O,I){var X=[],q=!0,oe=!1,ce=void 0;try{for(var Le=O[Symbol.iterator](),Ee;!(q=(Ee=Le.next()).done)&&!(X.push(Ee.value),I&&X.length===I);q=!0);}catch(we){oe=!0,ce=we}finally{try{!q&&Le.return&&Le.return()}finally{if(oe)throw ce}}return X}return function(O,I){if(Array.isArray(O))return O;if(Symbol.iterator in Object(O))return V(O,I);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function(){function V(O,I){for(var X=0;X<I.length;X++){var q=I[X];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(O,q.key,q)}}return function(O,I,X){return I&&V(O.prototype,I),X&&V(O,X),O}}();function l(V,O,I){return O in V?Object.defineProperty(V,O,{value:I,enumerable:!0,configurable:!0,writable:!0}):V[O]=I,V}function d(V,O){var I={};for(var X in V){if(O.indexOf(X)>=0)continue;if(!Object.prototype.hasOwnProperty.call(V,X))continue;I[X]=V[X]}return I}function _(V,O){if(!(V instanceof O))throw new TypeError("Cannot call a class as a function")}function v(V,O){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:V}function m(V,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);V.prototype=Object.create(O&&O.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(V,O):V.__proto__=O)}var L=function(O){return Object.keys(O).reduce(function(I,X){return(X.substr(0,5)==="data-"||X.substr(0,5)==="aria-"||X==="role")&&(I[X]=O[X]),I},{})},x=function(V){m(O,V);function O(){var I,X,q,oe;_(this,O);for(var ce=arguments.length,Le=Array(ce),Ee=0;Ee<ce;Ee++)Le[Ee]=arguments[Ee];return oe=(X=(q=v(this,(I=O.__proto__||Object.getPrototypeOf(O)).call.apply(I,[this].concat(Le))),q),q.state={uid:D()},q.reqs={},q.onChange=function(we){var Te=we.target.files;q.uploadFiles(Te),q.reset()},q.onClick=function(we){var Te=q.fileInput;if(!Te)return;var ye=q.props,fe=ye.children,se=ye.onClick;fe&&fe.type==="button"&&(Te.parentNode.focus(),Te.parentNode.querySelector("button").blur()),Te.click(),se&&se(we)},q.onKeyDown=function(we){we.key==="Enter"&&q.onClick()},q.onFileDrop=function(we){var Te=q.props.multiple;if(we.preventDefault(),we.type==="dragover")return;if(q.props.directory)C(Array.prototype.slice.call(we.dataTransfer.items),q.uploadFiles,function(fe){return A(fe,q.props.accept)});else{var ye=Array.prototype.slice.call(we.dataTransfer.files).filter(function(fe){return A(fe,q.props.accept)});Te===!1&&(ye=ye.slice(0,1)),q.uploadFiles(ye)}},q.uploadFiles=function(we){var Te=Array.prototype.slice.call(we);Te.map(function(ye){return ye.uid=D(),ye}).forEach(function(ye){q.upload(ye,Te)})},q.saveFileInput=function(we){q.fileInput=we},X),v(q,oe)}return a(O,[{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.abort()}},{key:"upload",value:function(X,q){var oe=this,ce=this.props;if(!ce.beforeUpload)return setTimeout(function(){return oe.post(X)},0);var Le=ce.beforeUpload(X,q);Le&&Le.then?Le.then(function(Ee){var we=Object.prototype.toString.call(Ee);return we==="[object File]"||we==="[object Blob]"?oe.post(Ee):oe.post(X)}).catch(function(Ee){console.log(Ee)}):Le!==!1&&setTimeout(function(){return oe.post(X)},0);return}},{key:"post",value:function(X){var q=this;if(!this._isMounted)return;var oe=this.props,ce=oe.onStart,Le=oe.onProgress,Ee=oe.transformFile,we=Ee===void 0?function(Te){return Te}:Ee;new Promise(function(Te){var ye=oe.action;return typeof ye=="function"&&(ye=ye(X)),Te(ye)}).then(function(Te){var ye=X.uid,fe=oe.customRequest||K,se=Promise.resolve(we(X)).then(function(te){var ue=oe.data;return typeof ue=="function"&&(ue=ue(te)),Promise.all([te,ue])}).catch(function(te){console.error(te)});se.then(function(te){var ue=u(te,2),ne=ue[0],_e=ue[1],Re={action:Te,filename:oe.name,data:_e,file:ne,headers:oe.headers,withCredentials:oe.withCredentials,method:oe.method||"post",onProgress:Le?function(xe){Le(xe,X)}:null,onSuccess:function(ke,Ne){delete q.reqs[ye],oe.onSuccess(ke,X,Ne)},onError:function(ke,Ne){delete q.reqs[ye],oe.onError(ke,Ne,X)}};ce(X),q.reqs[ye]=fe(Re)})})}},{key:"reset",value:function(){this.setState({uid:D()})}},{key:"abort",value:function(X){var q=this.reqs;if(X){var oe=X;X&&X.uid&&(oe=X.uid),q[oe]&&q[oe].abort&&q[oe].abort(),delete q[oe]}else Object.keys(q).forEach(function(ce){q[ce]&&q[ce].abort&&q[ce].abort(),delete q[ce]})}},{key:"render",value:function(){var X,q=this.props,oe=q.component,ce=q.prefixCls,Le=q.className,Ee=q.disabled,we=q.id,Te=q.style,ye=q.multiple,fe=q.accept,se=q.children,te=q.directory,ue=q.openFileDialogOnClick,ne=q.onMouseEnter,_e=q.onMouseLeave,Re=d(q,["component","prefixCls","className","disabled","id","style","multiple","accept","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"]),xe=Z()((X={},l(X,ce,!0),l(X,ce+"-disabled",Ee),l(X,Le,Le),X)),ke=Ee?{}:{onClick:ue?this.onClick:function(){},onKeyDown:ue?this.onKeyDown:function(){},onMouseEnter:ne,onMouseLeave:_e,onDrop:this.onFileDrop,onDragOver:this.onFileDrop,tabIndex:"0"};return $.a.createElement(oe,b({},ke,{className:xe,role:"button",style:Te}),$.a.createElement("input",b({},L(Re),{id:we,type:"file",ref:this.saveFileInput,onClick:function(He){return He.stopPropagation()},key:this.state.uid,style:{display:"none"},accept:fe,directory:te?"directory":null,webkitdirectory:te?"webkitdirectory":null,multiple:ye,onChange:this.onChange})),se)}}]),O}(le.Component),p=x,f=Object.assign||function(V){for(var O=1;O<arguments.length;O++){var I=arguments[O];for(var X in I)Object.prototype.hasOwnProperty.call(I,X)&&(V[X]=I[X])}return V},h=function(){function V(O,I){for(var X=0;X<I.length;X++){var q=I[X];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(O,q.key,q)}}return function(O,I,X){return I&&V(O.prototype,I),X&&V(O,X),O}}();function o(V,O){if(!(V instanceof O))throw new TypeError("Cannot call a class as a function")}function E(V,O){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:V}function g(V,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);V.prototype=Object.create(O&&O.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(V,O):V.__proto__=O)}function S(){}var M=function(V){g(O,V);function O(){var I,X,q,oe;o(this,O);for(var ce=arguments.length,Le=Array(ce),Ee=0;Ee<ce;Ee++)Le[Ee]=arguments[Ee];return oe=(X=(q=E(this,(I=O.__proto__||Object.getPrototypeOf(O)).call.apply(I,[this].concat(Le))),q),q.saveUploader=function(we){q.uploader=we},X),E(q,oe)}return h(O,[{key:"abort",value:function(X){this.uploader.abort(X)}},{key:"render",value:function(){return $.a.createElement(p,f({},this.props,{ref:this.saveUploader}))}}]),O}(le.Component);M.defaultProps={component:"span",prefixCls:"rc-upload",data:{},headers:{},name:"file",multipart:!1,onStart:S,onError:S,onSuccess:S,multiple:!1,beforeUpload:null,customRequest:null,withCredentials:!1,openFileDialogOnClick:!0};var U=M,G=Ze.a=U},Gytx:function(ut,Ze){ut.exports=function(le,$,R,Z){var F=R?R.call(Z,le,$):void 0;if(F!==void 0)return!!F;if(le===$)return!0;if(typeof le!="object"||!le||typeof $!="object"||!$)return!1;var P=Object.keys(le),K=Object.keys($);if(P.length!==K.length)return!1;for(var j=Object.prototype.hasOwnProperty.bind($),N=0;N<P.length;N++){var D=P[N];if(!j(D))return!1;var y=le[D],A=$[D];if(F=R?R.call(Z,y,A,D):void 0,F===!1||F===void 0&&y!==A)return!1}return!0}},HmJG:function(ut,Ze,re){},IE1O:function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return p});var le=re("+L6B"),$=re("2/Rp"),R=re("2qtc"),Z=re("kLXV"),F=re("DZo9"),P=re("8z0m"),K=re("5NDa"),j=re("5rEg"),N=re("miYZ"),D=re("tsqr"),y=re("9og8"),A=re("y8nQ"),k=re("Vl3Y"),T=re("tJVT"),C=re("WmNS"),b=re.n(C),u=re("cDcd"),a=re.n(u),l=re("KeLC"),d=re.n(l),_=re("Fhpe"),v=re.n(_),m=re("m3rI"),L=re("jN4g"),x=function(h){var o,E,g,S,M=h.visible,U=h.onOk,G=h.onCancel,V=h.title,O=V===void 0?"\u9009\u62E9\u8BA4\u8BC1\u56E2\u961F\u6559\u5E08":V,I=k.a.useForm(),X=Object(T.a)(I,1),q=X[0],oe=Object(u.useState)(!1),ce=Object(T.a)(oe,2),Le=ce[0],Ee=ce[1],we=Object(u.useState)([]),Te=Object(T.a)(we,2),ye=Te[0],fe=Te[1],se=Object(u.useState)([]),te=Object(T.a)(se,2),ue=te[0],ne=te[1],_e=Object(u.useState)(!1),Re=Object(T.a)(_e,2),xe=Re[0],ke=Re[1];Object(u.useEffect)(function(){if(M!=null&&M.name){var Ve,je,rt,Qe;q.setFieldsValue({name:M==null?void 0:M.name});var tt=M!=null&&(Ve=M.cover_url)!==null&&Ve!==void 0&&Ve.includes("attachments")?[{response:{id:M==null||((je=M.cover_url)===null||je===void 0)?void 0:je.split("/")[3]}}]:[],Pe=M!=null&&(rt=M.backbground_image_url)!==null&&rt!==void 0&&rt.includes("attachments")?[{response:{id:M==null||((Qe=M.backbground_image_url)===null||Qe===void 0)?void 0:Qe.split("/")[3]}}]:[];fe(tt),ne(Pe)}},[M]);var Ne=function(){q.submit()},He=function(){G()},Be=function(){var Ve=Object(y.a)(b.a.mark(function je(rt){var Qe,tt,Pe,lt,at;return b.a.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:Ee(!0),console.log(ye,ue,3333),at={name:rt==null?void 0:rt.name,cover_id:(ye==null||((Qe=ye[0])===null||Qe===void 0||((tt=Qe.response)===null||tt===void 0))?void 0:tt.id)||"",backbground_image_id:(ue==null||((Pe=ue[0])===null||Pe===void 0||((lt=Pe.response)===null||lt===void 0))?void 0:lt.id)||""},U(at);case 4:case"end":return Xe.stop()}},je)}));return function(rt){return Ve.apply(this,arguments)}}(),Me=function(je,rt){var Qe=["uploading","done","removed"];Qe.includes(je.file.status)&&(je.file.status==="uploading"&&ke(!0),je.file.status==="done"&&ke(!1),rt===1?fe(je.fileList):ne(je.fileList))},Oe=function(je,rt){rt===1?fe([]):ne([])},Ye=function(je,rt){var Qe=je.type==="image/jpeg"||je.type==="image/png";if(!Qe)return D.b.error("\u8BF7\u4E0A\u4F20jpg\u6216png\u7684\u56FE\u7247!"),!1;var tt=je.size/1024/1024>2;return tt?(D.b.info("\u6587\u4EF6\u5927\u5C0F\u5FC5\u987B\u5C0F\u4E8E2MB"),!1):(rt===1?fe([]):ne([]),!0)},Je=function(je){var rt,Qe,tt,Pe;return a.a.createElement("div",{className:d.a.img},a.a.createElement("img",{src:m.a.API_SERVER+"/api/attachments/"+(je===1?ye==null||((rt=ye[0])===null||rt===void 0||((Qe=rt.response)===null||Qe===void 0))?void 0:Qe.id:ue==null||((tt=ue[0])===null||tt===void 0||((Pe=tt.response)===null||Pe===void 0))?void 0:Pe.id),alt:"avatar",style:{width:"100%"}}),a.a.createElement("div",null,a.a.createElement(L.a,{onClick:function(){je===1?fe([]):ne([])},style:{fontSize:"16px",color:"red"}})))};return a.a.createElement(Z.a,{title:O,visible:M,onOk:Ne,centered:!0,onCancel:He,confirmLoading:Le,okButtonProps:{disabled:xe},width:686,afterClose:function(){Ee(!1),fe([]),ne([]),q.resetFields()},okText:M!=null&&M.name?"\u786E\u8BA4":"\u786E\u8BA4\u65B0\u5EFA",cancelText:"\u53D6\u6D88",wrapClassName:v.a.CustomCss},a.a.createElement(k.a,{form:q,colon:!1,onFinish:Be,className:d.a.form},a.a.createElement(k.a.Item,{label:"\u793E\u533A\u540D\u79F0",name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"},{whitespace:!0,message:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"},{max:60,message:"\u53EA\u80FD\u8F93\u516560\u4E2A\u5B57\u7B26"}]},a.a.createElement(j.a,{maxLength:60,placeholder:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"})),a.a.createElement(k.a.Item,{name:"cover_id",label:"\u4E0A\u4F20\u5C01\u9762\u56FE",valuePropName:"fileList",className:"mt30"},a.a.createElement("div",{className:d.a.upload},ye!=null&&(o=ye[0])!==null&&o!==void 0&&(E=o.response)!==null&&E!==void 0&&E.id?Je(1):a.a.createElement(P.a,{fileList:ye,action:"".concat(m.a.API_SERVER,"/api/attachments.json"),onChange:function(je){return Me(je,1)},onRemove:function(je){return Oe(je,1)},beforeUpload:function(je){return Ye(je,1)},withCredentials:!0,accept:"image/*"},a.a.createElement("div",{className:d.a.btn},a.a.createElement("i",{className:"iconfont icon-shangchuantupian2"}),"\u4E0A\u4F20\u56FE\u7247")))),a.a.createElement("aside",null,"\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u7528278*225\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"),a.a.createElement(k.a.Item,{name:"backbground_image_id",label:"\u8BE6\u60C5\u9876\u90E8\u80CC\u666F",valuePropName:"fileList",className:"mt30"},a.a.createElement("div",{className:d.a.upload},ue!=null&&(g=ue[0])!==null&&g!==void 0&&(S=g.response)!==null&&S!==void 0&&S.id?Je(2):a.a.createElement(P.a,{fileList:ue,action:"".concat(m.a.API_SERVER,"/api/attachments.json"),onChange:function(je){return Me(je,2)},onRemove:function(je){return Oe(je,2)},beforeUpload:function(je){return Ye(je,2)},withCredentials:!0,accept:"image/*"},a.a.createElement("div",{className:d.a.btn},a.a.createElement("i",{className:"iconfont icon-shangchuantupian2"}),"\u4E0A\u4F20\u56FE\u7247")))),a.a.createElement("aside",null,"\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u75281920*220\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002")))},p=function(h){var o,E,g,S,M=h.data,U=h.onOk,G=k.a.useForm(),V=Object(T.a)(G,1),O=V[0],I=Object(u.useState)(!1),X=Object(T.a)(I,2),q=X[0],oe=X[1],ce=Object(u.useState)([]),Le=Object(T.a)(ce,2),Ee=Le[0],we=Le[1],Te=Object(u.useState)([]),ye=Object(T.a)(Te,2),fe=ye[0],se=ye[1],te=Object(u.useState)(!1),ue=Object(T.a)(te,2),ne=ue[0],_e=ue[1];Object(u.useEffect)(function(){if(M!=null&&M.name){var Me,Oe,Ye,Je;O.setFieldsValue({name:M==null?void 0:M.name});var Ve=M!=null&&(Me=M.cover_url)!==null&&Me!==void 0&&Me.includes("attachments")?[{response:{id:M==null||((Oe=M.cover_url)===null||Oe===void 0)?void 0:Oe.split("/")[3]}}]:[],je=M!=null&&(Ye=M.backbground_image_url)!==null&&Ye!==void 0&&Ye.includes("attachments")?[{response:{id:M==null||((Je=M.backbground_image_url)===null||Je===void 0)?void 0:Je.split("/")[3]}}]:[];we(Ve),se(je)}},[M]);var Re=function(){O.submit()},xe=function(){var Me=Object(y.a)(b.a.mark(function Oe(Ye){var Je,Ve,je,rt,Qe;return b.a.wrap(function(Pe){for(;;)switch(Pe.prev=Pe.next){case 0:oe(!0),Qe={name:Ye==null?void 0:Ye.name,cover_id:(Ee==null||((Je=Ee[0])===null||Je===void 0||((Ve=Je.response)===null||Ve===void 0))?void 0:Ve.id)||"",backbground_image_id:(fe==null||((je=fe[0])===null||je===void 0||((rt=je.response)===null||rt===void 0))?void 0:rt.id)||""},U(Qe,function(){oe(!1)});case 3:case"end":return Pe.stop()}},Oe)}));return function(Ye){return Me.apply(this,arguments)}}(),ke=function(Oe,Ye){var Je=["uploading","done","removed"];Je.includes(Oe.file.status)&&(Oe.file.status==="uploading"&&_e(!0),Oe.file.status==="done"&&_e(!1),Ye===1?we(Oe.fileList):se(Oe.fileList))},Ne=function(Oe,Ye){Ye===1?we([]):se([])},He=function(Oe,Ye){var Je=Oe.type==="image/jpeg"||Oe.type==="image/png";if(!Je)return D.b.error("\u8BF7\u4E0A\u4F20jpg\u6216png\u7684\u56FE\u7247!"),!1;var Ve=Oe.size/1024/1024>2;return Ve?(D.b.info("\u6587\u4EF6\u5927\u5C0F\u5FC5\u987B\u5C0F\u4E8E2MB"),!1):(Ye===1?we([]):se([]),!0)},Be=function(Oe){var Ye,Je,Ve,je;return a.a.createElement("div",{className:d.a.img},a.a.createElement("img",{src:m.a.API_SERVER+"/api/attachments/"+(Oe===1?Ee==null||((Ye=Ee[0])===null||Ye===void 0||((Je=Ye.response)===null||Je===void 0))?void 0:Je.id:fe==null||((Ve=fe[0])===null||Ve===void 0||((je=Ve.response)===null||je===void 0))?void 0:je.id),alt:"avatar",style:{width:"100%"}}),a.a.createElement("div",null,a.a.createElement(L.a,{onClick:function(){Oe===1?we([]):se([])},style:{fontSize:"16px",color:"red"}})))};return a.a.createElement(k.a,{form:O,colon:!1,onFinish:xe,labelCol:{span:3},wrapperCol:{span:19},className:d.a.form},a.a.createElement(k.a.Item,{label:"\u793E\u533A\u540D\u79F0",name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"},{whitespace:!0,message:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"},{max:60,message:"\u53EA\u80FD\u8F93\u516560\u4E2A\u5B57\u7B26"}]},a.a.createElement(j.a,{maxLength:60,placeholder:"\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"})),a.a.createElement(k.a.Item,{name:"cover_id",label:"\u5C01\u9762\u56FE",valuePropName:"fileList"},a.a.createElement("div",{className:d.a.upload},Ee!=null&&(o=Ee[0])!==null&&o!==void 0&&(E=o.response)!==null&&E!==void 0&&E.id?Be(1):a.a.createElement(P.a,{fileList:Ee,action:"".concat(m.a.API_SERVER,"/api/attachments.json"),onChange:function(Oe){return ke(Oe,1)},onRemove:function(Oe){return Ne(Oe,1)},beforeUpload:function(Oe){return He(Oe,1)},withCredentials:!0,accept:"image/*"},a.a.createElement($.a,null,a.a.createElement("i",{className:"iconfont icon-shangchuantupian2 mr10"}),"\u4E0A\u4F20\u56FE\u7247")),a.a.createElement("aside",null,"\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u7528278*225\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"))),a.a.createElement(k.a.Item,{name:"backbground_image_id",label:"\u8BE6\u60C5\u9876\u90E8\u80CC\u666F",valuePropName:"fileList"},a.a.createElement("div",{className:d.a.upload},fe!=null&&(g=fe[0])!==null&&g!==void 0&&(S=g.response)!==null&&S!==void 0&&S.id?Be(2):a.a.createElement(P.a,{fileList:fe,action:"".concat(m.a.API_SERVER,"/api/attachments.json"),onChange:function(Oe){return ke(Oe,2)},onRemove:function(Oe){return Ne(Oe,2)},beforeUpload:function(Oe){return He(Oe,2)},withCredentials:!0,accept:"image/*"},a.a.createElement($.a,null,a.a.createElement("i",{className:"iconfont icon-shangchuantupian2 mr10"}),"\u4E0A\u4F20\u56FE\u7247")),a.a.createElement("aside",null,"\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u75281920*220\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"))),a.a.createElement($.a,{disabled:ne,loading:q,type:"primary",onClick:Re,style:{marginLeft:120}},"\u786E\u8BA4"))};Ze.b=x},KeLC:function(ut,Ze,re){ut.exports={flex_box_center:"flex_box_center___WC8D3",flex_space_between:"flex_space_between___1oJuS",flex_box_vertical_center:"flex_box_vertical_center___wHVAB",flex_box_center_end:"flex_box_center_end___2rX0l",flex_box_column:"flex_box_column___Iu_rf",form:"form___RRVwq",btn:"btn___144Et",img:"img___qC8f0"}},LdHM:function(ut,Ze,re){"use strict";re.d(Ze,"b",function(){return d}),re.d(Ze,"a",function(){return v});var le=re("1OyB"),$=re("vuIU"),R=re("Ji7U"),Z=re("LK+K"),F=re("cDcd"),P=re("rePB"),K=re("Ff2n"),j=re("ODXe"),N=re("4IlW"),D=re("bX4T"),y=re("YrtM"),A=re("TSYQ"),k=re.n(A),T=re("+nKL"),C=re("8OUc"),b=function(X,q){var oe=X.prefixCls,ce=X.id,Le=X.flattenOptions,Ee=X.childrenAsData,we=X.values,Te=X.searchValue,ye=X.multiple,fe=X.defaultActiveFirstOption,se=X.height,te=X.itemHeight,ue=X.notFoundContent,ne=X.open,_e=X.menuItemSelectedIcon,Re=X.virtual,xe=X.onSelect,ke=X.onToggleOpen,Ne=X.onActiveValue,He=X.onScroll,Be=X.onMouseEnter,Me="".concat(oe,"-item"),Oe=Object(y.a)(function(){return Le},[ne,Le],function(Xe,Ce){return Ce[0]&&Xe[1]!==Ce[1]}),Ye=F.useRef(null),Je=function(Ce){Ce.preventDefault()},Ve=function(Ce){Ye.current&&Ye.current.scrollTo({index:Ce})},je=function(Ce){for(var ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,be=Oe.length,ie=0;ie<be;ie+=1){var ae=(Ce+ie*ve+be)%be,de=Oe[ae],me=de.group,Se=de.data;if(!me&&!Se.disabled)return ae}return-1},rt=F.useState(function(){return je(0)}),Qe=Object(j.a)(rt,2),tt=Qe[0],Pe=Qe[1],lt=function(Ce){Pe(Ce);var ve=Oe[Ce];if(!ve){Ne(null,-1);return}Ne(ve.data.value,Ce)};F.useEffect(function(){lt(fe!==!1?je(0):-1)},[Oe.length,Te]),F.useEffect(function(){var Xe=setTimeout(function(){if(!ye&&ne&&we.size===1){var Ce=Array.from(we)[0],ve=Oe.findIndex(function(be){var ie=be.data;return ie.value===Ce});lt(ve),Ve(ve)}});return function(){return clearTimeout(Xe)}},[ne]);var at=function(Ce){Ce!==void 0&&xe(Ce,{selected:!we.has(Ce)}),ye||ke(!1)};if(F.useImperativeHandle(q,function(){return{onKeyDown:function(Ce){var ve=Ce.which;switch(ve){case N.a.UP:case N.a.DOWN:{var be=0;if(ve===N.a.UP?be=-1:ve===N.a.DOWN&&(be=1),be!==0){var ie=je(tt+be,be);Ve(ie),lt(ie)}break}case N.a.ENTER:{var ae=Oe[tt];ae&&!ae.data.disabled?at(ae.data.value):at(void 0),ne&&Ce.preventDefault();break}case N.a.ESC:ke(!1)}},onKeyUp:function(){},scrollTo:function(Ce){Ve(Ce)}}}),Oe.length===0)return F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),className:"".concat(Me,"-empty"),onMouseDown:Je},ue);function Fe(Xe){var Ce=Oe[Xe];if(!Ce)return null;var ve=Ce.data||{},be=ve.value,ie=ve.label,ae=ve.children,de=Object(D.a)(ve,!0),me=Ee?ae:ie;return Ce?F.createElement("div",Object.assign({"aria-label":typeof me=="string"?me:null},de,{key:Xe,role:"option",id:"".concat(ce,"_list_").concat(Xe),"aria-selected":we.has(be)}),be):null}return F.createElement(F.Fragment,null,F.createElement("div",{role:"listbox",id:"".concat(ce,"_list"),style:{height:0,width:0,overflow:"hidden"}},Fe(tt-1),Fe(tt),Fe(tt+1)),F.createElement(T.a,{itemKey:"key",ref:Ye,data:Oe,height:se,itemHeight:te,fullHeight:!1,onMouseDown:Je,onScroll:He,virtual:Re,onMouseEnter:Be},function(Xe,Ce){var ve,be=Xe.group,ie=Xe.groupOption,ae=Xe.data,de=ae.label,me=ae.key;if(be)return F.createElement("div",{className:k()(Me,"".concat(Me,"-group"))},de!==void 0?de:me);var Se=ae.disabled,Ie=ae.value,ze=ae.title,ot=ae.children,gt=ae.style,pt=ae.className,wt=Object(K.a)(ae,["disabled","value","title","children","style","className"]),Ct=we.has(Ie),ht="".concat(Me,"-option"),Ft=k()(Me,ht,pt,(ve={},Object(P.a)(ve,"".concat(ht,"-grouped"),ie),Object(P.a)(ve,"".concat(ht,"-active"),tt===Ce&&!Se),Object(P.a)(ve,"".concat(ht,"-disabled"),Se),Object(P.a)(ve,"".concat(ht,"-selected"),Ct),ve)),Ot=Ee?ot:de,Zt=!_e||typeof _e=="function"||Ct;return F.createElement("div",Object.assign({},wt,{"aria-selected":Ct,className:Ft,title:ze,onMouseMove:function(){if(tt===Ce||Se)return;lt(Ce)},onClick:function(){Se||at(Ie)},style:gt}),F.createElement("div",{className:"".concat(ht,"-content")},Ot||Ie),F.isValidElement(_e)||Ct,Zt&&F.createElement(C.a,{className:"".concat(Me,"-option-state"),customizeIcon:_e,customizeIconProps:{isSelected:Ct}},Ct?"\u2713":null))}))},u=F.forwardRef(b);u.displayName="OptionList";var a=u,l=function(){return null};l.isSelectOption=!0;var d=l,_=function(){return null};_.isSelectOptGroup=!0;var v=_,m=re("VTBJ"),L=re("Zm9Q");function x(I){var X=I.key,q=I.props,oe=q.children,ce=q.value,Le=Object(K.a)(q,["children","value"]);return Object(m.a)({key:X,value:ce!==void 0?ce:X,children:oe},Le)}function p(I){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(I).map(function(q,oe){if(!F.isValidElement(q)||!q.type)return null;var ce=q.type.isSelectOptGroup,Le=q.key,Ee=q.props,we=Ee.children,Te=Object(K.a)(Ee,["children"]);return X||!ce?x(q):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(Le===null?oe:Le,"__"),label:Le},Te),{},{options:p(we)})}).filter(function(q){return q})}var f=re("2Qr1"),h=re("qNPg"),o=re("U8pU"),E=re("Kwbf"),g=re("WKfj");function S(I){var X=I.mode,q=I.options,oe=I.children,ce=I.backfill,Le=I.allowClear,Ee=I.placeholder,we=I.getInputElement,Te=I.showSearch,ye=I.onSearch,fe=I.defaultOpen,se=I.autoFocus,te=I.labelInValue,ue=I.value,ne=I.inputValue,_e=I.optionLabelProp,Re=X==="multiple"||X==="tags",xe=Te!==void 0?Te:Re||X==="combobox",ke=q||p(oe);if(Object(E.a)(X!=="tags"||ke.every(function(Me){return!Me.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),X==="tags"||X==="combobox"){var Ne=ke.some(function(Me){return Me.options?Me.options.some(function(Oe){return typeof("value"in Oe?Oe.value:Oe.key)=="number"}):typeof("value"in Me?Me.value:Me.key)=="number"});Object(E.a)(!Ne,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(E.a)(X!=="combobox"||!_e,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(E.a)(X==="combobox"||!ce,"`backfill` only works with `combobox` mode."),Object(E.a)(X==="combobox"||!we,"`getInputElement` only work with `combobox` mode."),Object(E.b)(X!=="combobox"||!we||!Le||!Ee,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),ye&&!xe&&X!=="combobox"&&X!=="tags"&&Object(E.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(E.b)(!fe||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),ue!=null){var He=Object(g.d)(ue);Object(E.a)(!te||He.every(function(Me){return Object(o.a)(Me)==="object"&&("key"in Me||"value"in Me)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(E.a)(!Re||Array.isArray(ue),"`value` should be array when `mode` is `multiple` or `tags`")}if(oe){var Be=null;Object(L.a)(oe).some(function(Me){if(!F.isValidElement(Me)||!Me.type)return!1;var Oe=Me.type;if(Oe.isSelectOption)return!1;if(Oe.isSelectOptGroup){var Ye=Object(L.a)(Me.props.children).every(function(Je){return!F.isValidElement(Je)||!Me.type||Je.type.isSelectOption?!0:(Be=Je.type,!1)});return!Ye}return Be=Oe,!0}),Be&&Object(E.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Be.displayName||Be.name||Be,"`.")),Object(E.a)(ne===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=S,U=Object(h.a)({prefixCls:"rc-select",components:{optionList:a},convertChildrenToData:p,flattenOptions:f.d,getLabeledValue:f.e,filterOptions:f.b,isValueDisabled:f.g,findValueOption:f.c,warningProps:M,fillOptionsWithMissingValue:f.a}),G=function(I){Object(R.a)(q,I);var X=Object(Z.a)(q);function q(){var oe;return Object(le.a)(this,q),oe=X.apply(this,arguments),oe.selectRef=F.createRef(),oe.focus=function(){oe.selectRef.current.focus()},oe.blur=function(){oe.selectRef.current.blur()},oe}return Object($.a)(q,[{key:"render",value:function(){return F.createElement(U,Object.assign({ref:this.selectRef},this.props))}}]),q}(F.Component);G.Option=d,G.OptGroup=v;var V=G,O=Ze.c=V},M8RZ:function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return N});var le=re("fWQN"),$=re("mtLc"),R=re("yKVA"),Z=re("879j"),F=re("cDcd"),P=re.n(F),K=re("faye"),j=re.n(K),N=function(D){Object(R.a)(A,D);var y=Object(Z.a)(A);function A(k){var T;Object(le.a)(this,A),T=y.call(this,k);var C=window.document;return T.node=C.createElement("div"),C.body.appendChild(T.node),T}return Object($.a)(A,[{key:"render",value:function(){var T=this.props.children;return Object(K.createPortal)(T,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),A}(P.a.Component)},NLgs:function(ut,Ze,re){"use strict";re.d(Ze,"e",function(){return d}),re.d(Ze,"f",function(){return _}),re.d(Ze,"d",function(){return m}),re.d(Ze,"c",function(){return L}),re.d(Ze,"a",function(){return x}),re.d(Ze,"b",function(){return p});var le=re("miYZ"),$=re("tsqr"),R=re("9og8"),Z=re("2qtc"),F=re("kLXV"),P=re("WmNS"),K=re.n(P),j=re("cDcd"),N=re.n(j),D=re("9kvl"),y=re("xKgJ"),A=re("1vsH"),k=re("RCxd"),T=re("yTi+"),C=re.n(T),b=re("1ZF9"),u=re.n(b),a=re("NoGO"),l=re.n(a),d=function(h){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!!(_(h)&&v(o))},_=function(h){return Object(y.p)()?!0:(h({type:"user/showPopLogin",payload:{showPopLogin:!0,showClosable:!0}}),!1)},v=function(){var h,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,E=Object(D.c)()._store.getState(),g=E.user;return(h=g.userInfo)!==null&&h!==void 0&&h.profile_completed?!0:(F.a.confirm({title:"\u63D0\u793A",width:530,centered:!0,content:o?"\u6309\u7167\u6709\u5173\u653F\u7B56\u89C4\u5B9A\uFF0C\u7279\u6B8A\u5B9E\u9A8C\u9700\u8981\u5148\u7ED1\u5B9A\u624B\u673A\u53F7\u624D\u80FD\u4F7F\u7528\uFF0C\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A\u53F7\u7801":"\u60A8\u9700\u8981\u53BB\u5B8C\u5584\u60A8\u7684\u4E2A\u4EBA\u8D44\u6599\uFF0C\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD",okText:"\u7ACB\u5373\u5B8C\u5584",cancelText:"\u7A0D\u540E\u5B8C\u5584",onOk:function(){D.d.push("/account/profile/edit")}}),!1)},m=function(){var h,o=Object(D.c)()._store.getState(),E=o.user;return(h=E.userInfo)!==null&&h!==void 0&&h.professional_certification?!0:(F.a.confirm({title:"\u63D0\u793A",centered:!0,content:N.a.createElement("div",{className:"tc"},"\u60A8\u9700\u8981\u53BB\u5B8C\u6210\u60A8\u7684\u804C\u4E1A\u8BA4\u8BC1\uFF0C\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD"),okText:"\u7ACB\u5373\u5B8C\u5584",cancelText:"\u7A0D\u540E\u5B8C\u5584",onOk:function(){Object(A.U)("/account/certification")}}),!1)},L=function(){return Object(y.a)()?!0:(F.a.warning({centered:!0,width:530,title:"\u63D0\u793A",content:N.a.createElement("div",{className:"tc",style:{marginLeft:-38}},N.a.createElement("p",null,"\u626B\u7801\u52A0\u5934\u6B4C\u52A9\u6559\uFF0C\u7533\u8BF7\u64CD\u4F5C\u6743\u9650"),N.a.createElement("img",{src:l.a,width:200})),okText:"\u6211\u77E5\u9053\u4E86",maskClosable:!0}),!1)},x=function(h,o){return h?!0:(F.a.confirm({centered:!0,zIndex:1e4,width:530,title:"\u63D0\u793A",content:N.a.createElement("div",null,N.a.createElement("p",null,o||"\u8BE5\u5B9E\u8DF5\u8D44\u6E90\u9700\u6388\u6743\u540E\u624D\u53EF\u4F7F\u7528\u3002 \u60A8\u53EF\u4EE5\u5728QQ\u670D\u52A1\u7FA4\u5411\u7BA1\u7406\u5458\u7533\u8BF7\uFF0C\u83B7\u5F97\u7EE7\u7EED\u64CD\u4F5C\u7684\u6743\u9650\u3002"),N.a.createElement("div",{style:{marginLeft:"110px"}},N.a.createElement("img",{src:u.a,width:200}),N.a.createElement("div",{style:{marginLeft:"35px"}},"\u7FA4\u53F7\uFF1A","714336072"))),okText:"\u7ACB\u5373\u8054\u7CFB",cancelText:"\u53D6\u6D88",onOk:function(){Object(A.U)("https://qm.qq.com/cgi-bin/qm/qr?k=tIyDPXUtE0yEk-MOJxhH55lTUJS-nYAM&jump_from=webapi")}}),!1)},p=function(h){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",E=Object(D.c)()._store.getState(),g=E.shixunsDetail.detail;return(g==null?void 0:g.public)===2||(g==null?void 0:g.public)===1||(g==null?void 0:g.shixun_status)===3?(F.a.info({centered:!0,icon:N.a.createElement(k.a,{style:{color:"#faad14"}}),width:460,title:"\u63D0\u793A",content:N.a.createElement("div",{className:"tc",style:{marginLeft:-38}},N.a.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:38,margin:"12px 0"}},N.a.createElement("span",null,"\u8BE5\u5B9E\u8DF5\u9879\u76EE\u7684\u72B6\u6001\u4E3A",(g==null?void 0:g.public)===2?"\u5DF2\u516C\u5F00":(g==null?void 0:g.public)===1?"\u5F85\u5BA1\u6838":"\u5DF2\u5173\u95ED","\uFF0C",o,"\u3002"),N.a.createElement("p",null,"\u5982\u6709\u9700\u8981\uFF0C\u8BF7\u8054\u7CFB\u5E73\u53F0\u7BA1\u7406\u5458\u8FDB\u884C\u6280\u672F\u652F\u6301\u3002")),N.a.createElement("img",{style:{border:"4px solid #0152d9",borderRadius:"4px"},src:C.a,alt:"\u4E8C\u7EF4\u7801",width:160})),okText:"\u6211\u77E5\u9053\u4E86"}),!0):(g==null?void 0:g.shixun_status)===2?(F.a.confirm({centered:!0,icon:N.a.createElement(k.a,null),title:"\u63D0\u793A",content:N.a.createElement("div",null,N.a.createElement("span",null,"\u8BE5\u5B9E\u8DF5\u9879\u76EE\u5DF2\u53D1\u5E03\uFF0C",o,"\u3002"),N.a.createElement("br",null),N.a.createElement("span",null,"\u5982\u6709\u9700\u8981\uFF0C\u60A8\u53EF\u4EE5\u64A4\u9500\u53D1\u5E03\u540E\uFF0C\u518D\u8FDB\u884C\u64CD\u4F5C\u3002")),okText:"\u64A4\u9500\u53D1\u5E03",cancelText:"\u53D6\u6D88",onOk:function(){F.a.confirm({width:440,centered:!0,icon:N.a.createElement(k.a,{style:{color:"#faad14"}}),title:"\u63D0\u793A",content:"\u64A4\u9500\u53D1\u5E03\u540E\uFF0C\u5B66\u5458\u5C06\u65E0\u6CD5\u8FDB\u884C\u7EC3\u4E60\u3002\u662F\u5426\u786E\u8BA4\u64A4\u9500\u53D1\u5E03\uFF1F",okText:"\u786E\u5B9A\u64A4\u9500\u53D1\u5E03",cancelText:"\u53D6\u6D88",onOk:function(){var M=Object(R.a)(K.a.mark(function G(){var V;return K.a.wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return I.next=2,h({type:"shixunsDetail/cancelRelease",payload:{id:g==null?void 0:g.identifier}});case 2:V=I.sent,V.status!==401&&($.b.success("\u64A4\u9500\u53D1\u5E03\u6210\u529F\u3002\u5B9E\u8BAD\u56DE\u5230\u672A\u53D1\u5E03\u7684\u72B6\u6001\u3002"),h({type:"shixunsDetail/getShixunsDetail",payload:{id:g==null?void 0:g.identifier}}),h({type:"practiceSetting/getCommonData",payload:{id:g==null?void 0:g.identifier}}));case 4:case"end":return I.stop()}},G)}));function U(){return M.apply(this,arguments)}return U}()})}}),!0):!1}},NoGO:function(ut,Ze,re){ut.exports=re.p+"static/newqrcode.9bae6615.png"},OLES:function(ut,Ze,re){"use strict";var le=re("U8pU"),$=re("VTBJ"),R=re("Ff2n"),Z=re("cDcd"),F=re("uciX"),P=re("7ixt"),K=function(k){var T=k.overlay,C=k.prefixCls,b=k.id,u=k.overlayInnerStyle;return Z.createElement("div",{className:"".concat(C,"-inner"),id:b,role:"tooltip",style:u},typeof T=="function"?T():T)},j=K,N=function(k,T){var C=k.overlayClassName,b=k.trigger,u=b===void 0?["hover"]:b,a=k.mouseEnterDelay,l=a===void 0?0:a,d=k.mouseLeaveDelay,_=d===void 0?.1:d,v=k.overlayStyle,m=k.prefixCls,L=m===void 0?"rc-tooltip":m,x=k.children,p=k.onVisibleChange,f=k.afterVisibleChange,h=k.transitionName,o=k.animation,E=k.placement,g=E===void 0?"right":E,S=k.align,M=S===void 0?{}:S,U=k.destroyTooltipOnHide,G=U===void 0?!1:U,V=k.defaultVisible,O=k.getTooltipContainer,I=k.overlayInnerStyle,X=Object(R.a)(k,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),q=Object(Z.useRef)(null);Object(Z.useImperativeHandle)(T,function(){return q.current});var oe=Object($.a)({},X);"visible"in k&&(oe.popupVisible=k.visible);var ce=function(){var ye=k.arrowContent,fe=ye===void 0?null:ye,se=k.overlay,te=k.id;return[Z.createElement("div",{className:"".concat(L,"-arrow"),key:"arrow"},fe),Z.createElement(j,{key:"content",prefixCls:L,id:te,overlay:se,overlayInnerStyle:I})]},Le=!1,Ee=!1;if(typeof G=="boolean")Le=G;else if(G&&Object(le.a)(G)==="object"){var we=G.keepParent;Le=we===!0,Ee=we===!1}return Z.createElement(F.a,Object.assign({popupClassName:C,prefixCls:L,popup:ce,action:u,builtinPlacements:P.a,popupPlacement:g,ref:q,popupAlign:M,getPopupContainer:O,onPopupVisibleChange:p,afterPopupVisibleChange:f,popupTransitionName:h,popupAnimation:o,defaultPopupVisible:V,destroyPopupOnHide:Le,autoDestroy:Ee,mouseLeaveDelay:_,popupStyle:v,mouseEnterDelay:l},oe),x)},D=Object(Z.forwardRef)(N),y=Ze.a=D},Ot1p:function(ut,Ze,re){"use strict";var le=re("2qtc"),$=re("kLXV"),R=re("rAM+"),Z=re("miYZ"),F=re("tsqr"),P=re("9og8"),K=re("tJVT"),j=re("jrin"),N=re("WmNS"),D=re.n(N),y=re("cDcd"),A=re.n(y),k=re("VrN/"),T=re.n(k),C=re("bdgK"),b=re("p77/"),u=re("Bd2K"),a=re("ELLl"),l=re("19Vz"),d=re("lZu9"),_=re("+NIl"),v=re("kSUc"),m=re("9Bee"),L=function(Se){var Ie=Se.value,ze=Ie===void 0?"":Ie,ot=Se.className,gt=Se.showTextOnly,pt=Se.showLines,wt=Se.style,Ct=wt===void 0?{}:wt,ht=Object(y.useMemo)(function(){return""},[ze]);return A.a.createElement(A.a.Fragment,null,A.a.createElement("div",{dangerouslySetInnerHTML:{__html:ht}}))},x=re("0Owb"),p=re("dejd"),f=re("C+DQ"),h=re("1vsH"),o=re("m3rI"),E=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function g(Se){var Ie=Se.onActionCallback,ze=Se.title,ot=Se.icon,gt=Se.actionName,pt=Se.className,wt=pt===void 0?"":pt,Ct=Se.children;function ht(){Ie(gt)}return A.a.createElement("a",{title:ze,className:wt,onClick:ht},A.a.createElement("i",{className:"md-iconfont ".concat(ot)}),Ct)}var S=function(Se){var Ie=Se.watch,ze=Se.showNullButton,ot=Se.onActionCallback,gt=Se.fullScreen,pt=Se.insertTemp,wt=Se.hidetoolBar,Ct=Se.uuid,ht=Se.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(h.G)("_educoder_session_login"),"&_educoder_session=").concat(Object(h.G)("_educoder_session"),"&key=").concat(Ct,"&api=").concat(encodeURIComponent(o.a.PROXY_SERVER)));var Ft=[].concat(E,[{title:"".concat(Ie?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Ie?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return A.a.createElement("ul",{className:"markdown-toolbar-container"},!wt&&Ft.map(function(Ot,Zt){return A.a.createElement("li",{key:Zt},Ot.actionName?A.a.createElement(g,Object(x.a)({},Ot,{onActionCallback:ot})):A.a.createElement("span",{className:"v-line"}))}),ze?A.a.createElement("li",null,A.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:ot},A.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,pt&&A.a.createElement("li",null,A.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(pt),onActionCallback:ot},A.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),A.a.createElement("li",{className:"btn-full-screen"},A.a.createElement(g,{icon:"".concat(gt?"icon-shrink":"icon-enlarge"),title:gt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:ot})))},M=re("M8RZ"),U=re("+L6B"),G=re("2/Rp"),V=re("y8nQ"),O=re("Vl3Y"),I=re("5NDa"),X=re("5rEg"),q={labelCol:{span:4},wrapperCol:{span:20}},oe=function(Se){var Ie=Se.callback,ze=Se.onCancel;function ot(gt){Ie(gt)}return A.a.createElement(O.a,Object(x.a)({},q,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:ot}),A.a.createElement(O.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},A.a.createElement(X.a,null)),A.a.createElement(O.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},A.a.createElement(X.a,null)),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(G.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(G.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))},ce=re("7ahc"),Le=re("HmJG"),Ee=re("BjJ7"),we=O.a.useForm,Te={width:280,marginRight:10},ye={labelCol:{span:5},wrapperCol:{span:19}},fe=function(Se){var Ie=Se.callback,ze=Se.onCancel,ot=we(),gt=Object(K.a)(ot,1),pt=gt[0];function wt(Ft){Ie(Ft)}function Ct(Ft,Ot){if(Ft.status===-1){F.b.error(Ft.message);return}pt.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:Ot.type})}function ht(Ft){var Ot=Ft.target.files[0];te(Ot,Ct)}return A.a.createElement(O.a,Object(x.a)({form:pt},ye,{className:"upload-image-panel",onFinish:wt}),A.a.createElement(O.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},A.a.createElement("div",{className:"flex-container"},A.a.createElement(O.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},A.a.createElement(X.a,{style:Te})),A.a.createElement(se,{onFileChange:ht}))),A.a.createElement(O.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},A.a.createElement(X.a,{style:{width:264}})),A.a.createElement(O.a.Item,{style:{textAlign:"right"}},A.a.createElement(G.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(G.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))};function se(Se){var Ie=Se.onFileChange;return A.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",A.a.createElement("input",{type:"file",onChange:Ie}))}function te(Se,Ie){if(!Se)throw new String("\u6CA1\u6709\u6587\u4EF6");var ze=new FormData;ze.append("editormd-image-file",Se),ze.append("file_param_name","editormd-image-file"),ze.append("byxhr","true");var ot=new window.XMLHttpRequest;ot.withCredentials=!0,ot.addEventListener("load",function(gt){Ie(JSON.parse(gt.target.responseText),Se)},!1),ot.addEventListener("error",function(gt){console.error(gt)},!1),ot.open("POST","".concat(Ee.a,"/api/attachments.json")),ot.send(ze)}var ue=re("giR+"),ne=re("fyUT"),_e=re("7Kak"),Re=re("9yH6"),xe=Re.a.Group,ke={margin:"0 8px"},Ne=function(Se){var Ie=Se.callback,ze=Se.onCancel;function ot(gt){Ie(gt)}return A.a.createElement(O.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:ot},A.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},A.a.createElement("span",{style:ke},"\u5355\u5143\u683C\u6570\uFF1A"),A.a.createElement("span",{style:ke},"\u884C\u6570"),A.a.createElement(O.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},A.a.createElement(ne.a,null)),A.a.createElement("span",{style:ke},"\u5217\u6570"),A.a.createElement(O.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},A.a.createElement(ne.a,null))),A.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},A.a.createElement("span",{style:ke},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),A.a.createElement(O.a.Item,{name:"align"},A.a.createElement(xe,null,A.a.createElement(Re.a,{value:"default"},A.a.createElement("i",{className:"fa fa-align-justify"})),A.a.createElement(Re.a,{value:"left"},A.a.createElement("i",{className:"fa fa-align-left"})),A.a.createElement(Re.a,{value:"center"},A.a.createElement("i",{className:"fa fa-align-center"})),A.a.createElement(Re.a,{value:"right"},A.a.createElement("i",{className:"fa fa-align-right"}))))),A.a.createElement("div",{className:"flex-container flex-end"},A.a.createElement(G.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),A.a.createElement(G.a,{type:"ghost",onClick:ze},"\u53D6\u6D88")))},He=re("ErOA"),Be=re("7Cbv"),Me="link",Oe="upload-image",Ye="code-block",Je="add-table",Ve="------------",je={default:Ve,left:":".concat(Ve),center:":".concat(Ve,":"),right:"".concat(Ve,":")},rt=re("9VGf"),Qe,tt;function Pe(){}var lt=0,at=1e4,Fe="\u2581",Xe=`
**\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 Ce(Se){return/^\d+$/.test(Se)?"".concat(Se,"px"):Se}var ve=navigator.platform.toUpperCase().indexOf("MAC")>=0,be=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"],ae=(Qe={},Object(j.a)(Qe,be+"-B","bold"),Object(j.a)(Qe,be+"-I","italic"),Qe),de=(tt={},Object(j.a)(tt,Me,"\u6DFB\u52A0\u94FE\u63A5"),Object(j.a)(tt,Ye,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(j.a)(tt,Oe,"\u6DFB\u52A0\u6587\u4EF6"),Object(j.a)(tt,Je,"\u6DFB\u52A0\u8868\u683C"),tt),me=Ze.a=function(Se){var Ie=Se.defaultValue,ze=Ie===void 0?"":Ie,ot=Se.onChange,gt=Se.width,pt=gt===void 0?"100%":gt,wt=Se.height,Ct=wt===void 0?400:wt,ht=Se.miniToolbar,Ft=ht===void 0?!1:ht,Ot=Se.isFocus,Zt=Ot===void 0?!1:Ot,Xt=Se.watch,kt=Se.insertTemp,Ir=Se.mode,Kr=Ir===void 0?"markdown":Ir,Et=Se.id,Nr=Et===void 0?"markdown-editor-id":Et,dr=Se.showResizeBar,pr=dr===void 0?!1:dr,Br=Se.noStorage,ci=Br===void 0?!1:Br,qr=Se.showNullButton,It=qr===void 0?!1:qr,ct=Se.hidetoolBar,Hr=ct===void 0?!1:ct,ei=Se.fullScreen,mr=ei===void 0?!1:ei,Lt=Se.onBlur,Fr=Se.onCMBeforeChange,Vr=Se.onFullScreen,fi=Se.className,$e=fi===void 0?"":fi,St=Se.disablePaste,pi=St===void 0?!1:St,mi=Se.placeholder,gi=mi===void 0?"":mi,vi=Se.values,z=vi===void 0?"":vi,s=Object(y.useState)(null),c=Object(K.a)(s,2),B=c[0],Q=c[1],H=Object(y.useState)(ze),ge=Object(K.a)(H,2),We=ge[0],et=ge[1],ft=Object(y.useState)(Xt),Ge=Object(K.a)(ft,2),yt=Ge[0],Nt=Ge[1],Kt=Object(y.useState)(mr),kr=Object(K.a)(Kt,2),gr=kr[0],vr=kr[1],Xr=Object(y.useState)(""),ki=Object(K.a)(Xr,2),nr=ki[0],Ur=ki[1],oi=Object(y.useState)(0),si=Object(K.a)(oi,2),Or=si[0],Oi=si[1],yi=Object(y.useState)(Ct),Gi=Object(K.a)(yi,2),Ki=Gi[0],Yr=Gi[1],zr=Object(y.useState)(!1),bi=Object(K.a)(zr,2),hn=bi[0],Ei=bi[1],Jt=Object(y.useRef)(Object(Be.a)()),Bt=Object(y.useRef)(!1),hr=Object(y.useRef)(),Dt=Object(y.useRef)(),qt=Object(y.useRef)(),Wt=Object(y.useRef)(),ti=Object(y.useRef)(),ar=function(){var mt=Object(P.a)(D.a.mark(function Tt(){var bt,At;return D.a.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:return zt.next=2,Object(He.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:At=zt.sent,At!=null&&(bt=At.attachments)!==null&&bt!==void 0&&bt.length&&(console.log("cm:",B,Dt),At.attachments.map(function(Pt){Pt.content_type.indexOf("image")>-1?B.replaceSelection("![,](/api/attachments/".concat(Pt.id,"?type=").concat(Pt.content_type,")")):Pt.content_type.indexOf("video")>-1?B.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Pt.content_type.indexOf("pdf")>-1?B.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,'&disposition=inline" target="_blank">').concat(Pt.name,"</a>")):B.replaceSelection("[".concat(Pt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Pt.id,"?type=").concat(Pt.content_type,")"))}));case 4:case"end":return zt.stop()}},Tt)}));return function(){return mt.apply(this,arguments)}}();Object(y.useEffect)(function(){et(z),B==null||B.setValue(z)},[z]),Object(y.useEffect)(function(){Vr==null||Vr(gr)},[gr]),Object(y.useEffect)(function(){if(Dt.current){var mt=T.a.fromTextArea(Dt.current,{mode:Kr,lineNumbers:!Ft,lineWrapping:!0,value:ze,autoCloseTags:!0,autoCloseBrackets:!0});Zt&&mt.focus();function Tt(bt,At){if(pi){At.preventDefault();return}var Mt=At.clipboardData;if(Mt){var zt=Mt.types.toString(),Pt=Mt.items;if(zt==="Files"||Mt.types.indexOf("Files")>-1){if(At.preventDefault(),Kr=="stex")return;try{var rr,Tr=Pt[1];((rr=Pt[0])===null||rr===void 0?void 0:rr.kind)==="file"&&(Tr=Pt[0]);var Rt=Tr.getAsFile(),li=Rt.name.split(".").pop();te(Rt,function(Ut){if(Ut.id){var wr,yr,Gr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((Gr=Rt.type)===null||Gr===void 0)?void 0:Gr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ie.includes(li)?mt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):mt.replaceSelection("[".concat(Rt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})}catch(Ut){F.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return mt.on("paste",Tt),mt.on("dragleave",function(bt,At){qt.current.classList.remove("mouse-hover-md")}),mt.on("dragover",function(bt,At){qt.current.classList.add("mouse-hover-md")}),mt.on("drop",function(bt,At){qt.current.classList.add("mouse-hover-md");var Mt;if(Mt=At.dataTransfer.files,Mt.length>0){At.preventDefault(),At.stopPropagation();for(var zt=function(Tr){var Rt=Mt[Tr],li=Rt.name.split(".").pop();te(Rt,function(Ut){if(Ut.id){var wr,yr,Gr;(Rt==null||((wr=Rt.type)===null||wr===void 0)?void 0:wr.indexOf("image"))>-1?mt.replaceSelection("![,](/api/attachments/".concat(Ut.id,"?type=").concat(Ut.content_type,")")):(Rt==null||((yr=Rt.type)===null||yr===void 0)?void 0:yr.indexOf("video"))>-1?mt.replaceSelection('<video width="100%" controls src="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'"></video>')):(Rt==null||((Gr=Rt.type)===null||Gr===void 0)?void 0:Gr.indexOf("pdf"))>-1?mt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Rt.type,'&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):ie.includes(li)?mt.replaceSelection('<a href="'.concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,'?type=office&disposition=inline" target="_blank">').concat(Rt.name,"</a>")):mt.replaceSelection("[".concat(Rt.name,"](").concat(o.a.API_SERVER,"/api/attachments/").concat(Ut.id,"?type=").concat(Ut.content_type,")"))}else(Ut==null?void 0:Ut.status)===401&&(document.location.href="/user/login")})},Pt=0;Pt<Mt.length;Pt++)zt(Pt)}}),Q(mt),function(){mt.off("paste",Tt)}}},[]);var xr=Object(y.useCallback)(function(){if(qt.current)try{}catch(mt){console.log(mt,"---- to set md editor body height")}},[Ki,qt,gr]);Object(y.useEffect)(function(){function mt(){var bt=new C.default(function(At){var Mt=Object(R.a)(At),zt;try{for(Mt.s();!(zt=Mt.n()).done;){var Pt=zt.value;(Pt.target.offsetHeight>0||Pt.target.offsetWidth>0)&&(xr(),B.setSize("100%","100%"),B.refresh())}}catch(rr){Mt.e(rr)}finally{Mt.f()}});return bt.observe(Dt.current.parentElement),bt}if(B){var Tt=mt();return function(){Tt.unobserve(Dt.current.parentElement)}}},[B,xr]),Object(y.useEffect)(function(){if(B){for(var mt=[],Tt=function(){var Pt=At[bt];Mt=Object(K.a)(Pt,2);var rr=Mt[0],Tr=Mt[1],Rt=Object(j.a)({},rr,function(){Vi(Tr)});mt.push(Rt),B.addKeyMap(Rt)},bt=0,At=Object.entries(ae);bt<At.length;bt++){var Mt;Tt()}return hr.current=setInterval(function(){Bt.current&&ar()},4e3),function(){clearInterval(hr.current);var zt=Object(R.a)(mt),Pt;try{for(zt.s();!(Pt=zt.n()).done;){var rr=Pt.value;B.removeKeyMap(rr)}}catch(Tr){zt.e(Tr)}finally{zt.f()}}}},[B]),Object(y.useEffect)(function(){mr!==gr&&vr(mr)},[mr]),Object(rt.a)(function(){if(!ci&&Or>0){var mt=new Date().getTime(),Tt=window.sessionStorage.getItem(Nr);mt>=Or+at&&(!Tt||Tt!==We)&&(window.sessionStorage.setItem(Nr,We),Ei(!0))}},at),Object(y.useEffect)(function(){Nt(Xt)},[B,Xt]),Object(y.useEffect)(function(){B&&(Zt&&B.focus())},[B,Zt]),Object(y.useEffect)(function(){if(yt&&B){var mt=B.getScrollerElement();function Tt(bt){var At=bt.target;if(ti.current){var Mt=At.scrollTop/At.scrollHeight;ti.current.scrollTop=ti.current.scrollHeight*Mt}}return mt.addEventListener("scroll",Tt),function(){mt.removeEventListener("scroll",Tt)}}},[B,yt]),Object(y.useEffect)(function(){if(B&&Fr){function mt(Tt,bt){Fr(Tt,bt)}return B.on("beforeChange",mt),function(){B.off("beforeChange",mt)}}},[B,Fr]),Object(y.useEffect)(function(){if(B&&Lt){function mt(){Lt(B.getValue())}return B.on("blur",mt),function(){B.off("blur",mt)}}},[B,Lt]),Object(y.useEffect)(function(){if(B){function mt(Tt){var bt=Tt.getValue();et(bt),Oi(new Date().getTime()),Tt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),ot&&ot(bt)}return B.on("change",mt),function(){B.off("change",mt)}}},[B,ot]),Object(y.useEffect)(function(){B&&(ze==null?(B.setValue(""),et("")):ze!==B.getValue()&&(B.setValue(ze),et(ze),B.setCursor(B.lineCount(),0)))},[B,ze]);var Vi=Object(y.useCallback)(function(mt){var Tt=B.getCursor(),bt=B.getSelection(),At=bt.split(`
`);switch(mt){case"bold":return B.replaceSelection("**"+bt+"**"),bt===""&&B.setCursor(Tt.line,Tt.ch+2),B.focus();case"italic":return B.replaceSelection("*"+bt+"*"),bt===""&&B.setCursor(Tt.line,Tt.ch+1),B.focus();case"code":return B.replaceSelection("`"+bt+"`"),bt===""&&B.setCursor(Tt.line,Tt.ch+1),B.focus();case"inline-latex":return B.replaceSelection("`$$"+bt+"$$`"),bt===""&&B.setCursor(Tt.line,Tt.ch+3),B.focus();case"latex":return B.replaceSelection("```latex\n"+bt+"\n```"),B.setCursor(Tt.line+1,bt.length+1),B.focus();case"line-break":return B.replaceSelection(`<br/>
`),B.focus();case"list-ul":return bt===""?B.replaceSelection("- "+bt):B.replaceSelection(At.map(function(Mt){return Mt===""?"":"- ".concat(Mt)}).join(`
`)),B.focus();case"list-ol":return bt===""?B.replaceSelection("1. "+bt):B.replaceSelection(At.map(function(Mt,zt){return Mt===""?"":"".concat(zt+1,". ").concat(Mt)}).join(`
`)),B.focus();case"add-null-ch":return bt===""&&B.setCursor(Tt.line,Tt.ch+1),B.replaceSelection(Fe),B.focus();case"inster-template-1":return bt===""&&B.setCursor(Tt.line,Tt.ch),B.replaceSelection(Xe),B.focus();case"eraser":return B.setValue(""),B.focus();case"trigger-watch":return Nt(!yt),B.focus();case"trigger-full-screen":return vr(!gr),B.focus();case Me:Ur(Me);return;case Ye:Ur(Ye);return;case Oe:Ur(Oe);return;case Je:Ur(Je);return;default:throw new Error}},[B,yt,gr]),xi=Object(y.useCallback)(function(mt){Ur("");switch(nr){case Me:var Tt=mt.title,bt=mt.link;return B.replaceSelection("[".concat(Tt,"](").concat(bt,")")),B.focus();case Ye:var At=mt.language,Mt=mt.content;return B.replaceSelection(["```"+At,Mt,"```"].join(`
`)),B.focus();case Oe:var zt=mt.src,Pt=mt.alt;return Pt?B.replaceSelection("![ ".concat(Pt," ]( ").concat(zt,' "').concat(Pt,'" )')):B.replaceSelection("![,](".concat(zt,")")),B.focus();case Je:for(var rr=mt.row,Tr=mt.col,Rt=mt.align,li=`
`,Ut=0;Ut<rr;Ut++){for(var wr=[],yr=[],Gr=0;Gr<Tr;Gr++)Ut===1&&yr.push(je[Rt]),wr.push(" ");Ut===1&&(li+="| ".concat(yr.join(" | "),` |
`)),li+="| ".concat(wr.join(Tr===1?"":" | "),` |
`)}return B.replaceSelection(li+`
`),B.focus();default:throw new Error}},[B,nr]),cn=Object(y.useMemo)(function(){switch(nr){case Me:return A.a.createElement(oe,{callback:xi,onCancel:Si});case Ye:return A.a.createElement(ce.b,{callback:xi,onCancel:Si});case Oe:return A.a.createElement(fe,{callback:xi,onCancel:Si});case Je:return A.a.createElement(Ne,{callback:xi,onCancel:Si});default:return null}},[nr]);function Si(){Ur("")}Object(y.useEffect)(function(){if(Wt.current){var mt=Wt.current,Tt=!1,bt=0;function At(Pt){Tt=!0,bt=Pt.pageY}function Mt(){Tt=!1}function zt(Pt){if(Tt){var rr=Pt.pageY-bt;rr<0&&(rr=0),rr>300&&(rr=300);var Tr=Ct+rr+"px";Yr(Tr)}}return mt.addEventListener("mousedown",At),document.addEventListener("mousemove",zt),document.addEventListener("mouseup",Mt),function(){mt.removeEventListener("mousedown",At),document.removeEventListener("mousemove",zt),document.removeEventListener("mouseup",Mt)}}},[B,Wt]),Object(y.useEffect)(function(){Yr(Ct)},[Ct]);var ri=Ce(pt),fn=Ce(Ki),$r={width:ri,height:fn},pn=Object(y.useMemo)(function(){if(Or){var mt=new Date(Or),Tt=mt.getHours(),bt=mt.getMinutes(),At=mt.getSeconds();return Tt=Tt<10?"0"+Tt:Tt,bt=bt<10?"0"+bt:bt,At=At<10?"0"+At:At,"".concat(Tt,":").concat(bt,":").concat(At)}return 0},[Or]);function jn(){window.sessionStorage.removeItem(Nr),Ei(!1),Oi(0)}function Pi(){Ei(!1),Oi(0),B.setValue(window.sessionStorage.getItem(Nr))}function ua(mt,Tt){var bt=B.getValue();bt=bt.replace(mt,Tt),et(bt),B==null||B.setValue(bt)}return A.a.createElement(y.Fragment,null,A.a.createElement("div",{className:"markdown-editor-wrapper",ref:qt},A.a.createElement("div",{className:"markdown-editor-container ".concat($e," ").concat(yt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(gr?"full-screen":""),style:$r},A.a.createElement(S,{insertTemp:kt,watch:yt,fullScreen:gr,showNullButton:It,onActionCallback:Vi,hidetoolBar:Hr,uuid:Jt.current,setOpenPhones:function(){Bt.current=!0}}),A.a.createElement("div",{className:"markdown-editor-body"},A.a.createElement("div",{className:"codemirror-container"},A.a.createElement("textarea",{ref:Dt,placeholder:gi})),yt?A.a.createElement("div",{ref:ti,className:"preview-container"},Kr==="stex"&&A.a.createElement(L,{value:We}),Kr!=="stex"&&A.a.createElement(m.a,{edit:!0,value:We,replaces:ua})):null))),pr?A.a.createElement("a",{ref:Wt,className:"editor-resize"}):null,A.a.createElement(M.a,null,de[nr]?A.a.createElement($.a,{centered:!0,title:de[nr],visible:!0,onCancel:Si,footer:null,className:"markdown-popup-form"},cn):null))}},SJMd:function(ut,Ze){/**
* @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 re,le,$,R=!1,Z,F;window.PR_SHOULD_USE_CONTINUATION=!0;var P,K;(function(){var j=window,N=["break,continue,do,else,for,if,return,while"],D=[N,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],y=[D,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],A=[y,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],k=[y,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],T=[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"],C="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",b=[y,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",a=[N,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],l=[N,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],d=[N,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],_=[A,T,k,b,u,a,l,d],v=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,m="str",L="kwd",x="com",p="typ",f="lit",h="pun",o="pln",E="tag",g="dec",S="src",M="atn",U="atv",G="nocode",V="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function O(xe){for(var ke=0,Ne=!1,He=!1,Be=0,Me=xe.length;Be<Me;++Be){var Oe=xe[Be];if(Oe.ignoreCase)He=!0;else if(/[a-z]/i.test(Oe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Ne=!0,He=!1;break}}var Ye={b:8,t:9,n:10,v:11,f:12,r:13};function Je(tt){var Pe=tt.charCodeAt(0);if(Pe!==92)return Pe;var lt=tt.charAt(1);return Pe=Ye[lt],Pe||("0"<=lt&&lt<="7"?parseInt(tt.substring(1),8):lt==="u"||lt==="x"?parseInt(tt.substring(2),16):tt.charCodeAt(1))}function Ve(tt){if(tt<32)return(tt<16?"\\x0":"\\x")+tt.toString(16);var Pe=String.fromCharCode(tt);return Pe==="\\"||Pe==="-"||Pe==="]"||Pe==="^"?"\\"+Pe:Pe}function je(tt){var Pe=tt.substring(1,tt.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),lt=[],at=Pe[0]==="^",Fe=["["];at&&Fe.push("^");for(var Xe=at?1:0,Ce=Pe.length;Xe<Ce;++Xe){var ve=Pe[Xe];if(/\\[bdsw]/i.test(ve))Fe.push(ve);else{var be=Je(ve),ie;Xe+2<Ce&&Pe[Xe+1]==="-"?(ie=Je(Pe[Xe+2]),Xe+=2):ie=be,lt.push([be,ie]),ie<65||be>122||(ie<65||be>90||lt.push([Math.max(65,be)|32,Math.min(ie,90)|32]),ie<97||be>122||lt.push([Math.max(97,be)&~32,Math.min(ie,122)&~32]))}}lt.sort(function(Se,Ie){return Se[0]-Ie[0]||Ie[1]-Se[1]});for(var ae=[],de=[],Xe=0;Xe<lt.length;++Xe){var me=lt[Xe];me[0]<=de[1]+1?de[1]=Math.max(de[1],me[1]):ae.push(de=me)}for(var Xe=0;Xe<ae.length;++Xe){var me=ae[Xe];Fe.push(Ve(me[0])),me[1]>me[0]&&(me[1]+1>me[0]&&Fe.push("-"),Fe.push(Ve(me[1])))}return Fe.push("]"),Fe.join("")}function rt(tt){for(var Pe=tt.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),lt=Pe.length,at=[],Fe=0,Xe=0;Fe<lt;++Fe){var Ce=Pe[Fe];if(Ce==="(")++Xe;else if(Ce.charAt(0)==="\\"){var ve=+Ce.substring(1);ve&&(ve<=Xe?at[ve]=-1:Pe[Fe]=Ve(ve))}}for(var Fe=1;Fe<at.length;++Fe)at[Fe]===-1&&(at[Fe]=++ke);for(var Fe=0,Xe=0;Fe<lt;++Fe){var Ce=Pe[Fe];if(Ce==="(")++Xe,at[Xe]||(Pe[Fe]="(?:");else if(Ce.charAt(0)==="\\"){var ve=+Ce.substring(1);ve&&ve<=Xe&&(Pe[Fe]="\\"+at[ve])}}for(var Fe=0;Fe<lt;++Fe)Pe[Fe]==="^"&&Pe[Fe+1]!=="^"&&(Pe[Fe]="");if(tt.ignoreCase&&Ne)for(var Fe=0;Fe<lt;++Fe){var Ce=Pe[Fe],be=Ce.charAt(0);Ce.length>=2&&be==="["?Pe[Fe]=je(Ce):be!=="\\"&&(Pe[Fe]=Ce.replace(/[a-zA-Z]/g,function(de){var me=de.charCodeAt(0);return"["+String.fromCharCode(me&~32,me|32)+"]"}))}return Pe.join("")}for(var Qe=[],Be=0,Me=xe.length;Be<Me;++Be){var Oe=xe[Be];if(Oe.global||Oe.multiline)throw new Error(""+Oe);Qe.push("(?:"+rt(Oe)+")")}return new RegExp(Qe.join("|"),He?"gi":"g")}function I(xe,ke){var Ne=/(?:^|\s)nocode(?:\s|$)/,He=[],Be=0,Me=[],Oe=0;function Ye(Je){var Ve=Je.nodeType;if(Ve==1){if(Ne.test(Je.className))return;for(var je=Je.firstChild;je;je=je.nextSibling)Ye(je);var rt=Je.nodeName.toLowerCase();(rt==="br"||rt==="li")&&(He[Oe]=`
`,Me[Oe<<1]=Be++,Me[Oe++<<1|1]=Je)}else if(Ve==3||Ve==4){var Qe=Je.nodeValue;Qe.length&&(ke?Qe=Qe.replace(/\r\n?/g,`
`):Qe=Qe.replace(/[ \t\r\n]+/g," "),He[Oe]=Qe,Me[Oe<<1]=Be,Be+=Qe.length,Me[Oe++<<1|1]=Je)}}return Ye(xe),{sourceCode:He.join("").replace(/\n$/,""),spans:Me}}function X(xe,ke,Ne,He,Be){if(!Ne)return;var Me={sourceNode:xe,pre:1,langExtension:null,numberLines:null,sourceCode:Ne,spans:null,basePos:ke,decorations:null};He(Me),Be.push.apply(Be,Me.decorations)}var q=/\S/;function oe(xe){for(var ke=void 0,Ne=xe.firstChild;Ne;Ne=Ne.nextSibling){var He=Ne.nodeType;ke=He===1?ke?xe:Ne:He===3&&q.test(Ne.nodeValue)?xe:ke}return ke===xe?void 0:ke}function ce(xe,ke){var Ne={},He;(function(){for(var Oe=xe.concat(ke),Ye=[],Je={},Ve=0,je=Oe.length;Ve<je;++Ve){var rt=Oe[Ve],Qe=rt[3];if(Qe)for(var tt=Qe.length;--tt>=0;)Ne[Qe.charAt(tt)]=rt;var Pe=rt[1],lt=""+Pe;Je.hasOwnProperty(lt)||(Ye.push(Pe),Je[lt]=null)}Ye.push(/[\0-\uffff]/),He=O(Ye)})();var Be=ke.length,Me=function(Oe){for(var Ye=Oe.sourceCode,Je=Oe.basePos,Ve=Oe.sourceNode,je=[Je,o],rt=0,Qe=Ye.match(He)||[],tt={},Pe=0,lt=Qe.length;Pe<lt;++Pe){var at=Qe[Pe],Fe=tt[at],Xe=void 0,Ce;if(typeof Fe=="string")Ce=!1;else{var ve=Ne[at.charAt(0)];if(ve)Xe=at.match(ve[1]),Fe=ve[0];else{for(var be=0;be<Be;++be)if(ve=ke[be],Xe=at.match(ve[1]),Xe){Fe=ve[0];break}Xe||(Fe=o)}Ce=Fe.length>=5&&Fe.substring(0,5)==="lang-",Ce&&!(Xe&&typeof Xe[1]=="string")&&(Ce=!1,Fe=S),Ce||(tt[at]=Fe)}var ie=rt;if(rt+=at.length,!Ce)je.push(Je+ie,Fe);else{var ae=Xe[1],de=at.indexOf(ae),me=de+ae.length;Xe[2]&&(me=at.length-Xe[2].length,de=me-ae.length);var Se=Fe.substring(5);X(Ve,Je+ie,at.substring(0,de),Me,je),X(Ve,Je+ie+de,ae,se(Se,ae),je),X(Ve,Je+ie+me,at.substring(me),Me,je)}}Oe.decorations=je};return Me}function Le(xe){var ke=[],Ne=[];xe.tripleQuotedStrings?ke.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):xe.multiLineStrings?ke.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ke.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),xe.verbatimStrings&&Ne.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var He=xe.hashComments;He&&(xe.cStyleComments?(He>1?ke.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ke.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Ne.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ke.push([x,/^#[^\r\n]*/,null,"#"])),xe.cStyleComments&&(Ne.push([x,/^\/\/[^\r\n]*/,null]),Ne.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Be=xe.regexLiterals;if(Be){var Me=Be>1?"":`
\r`,Oe=Me?".":"[\\S\\s]",Ye="/(?=[^/*"+Me+"])(?:[^/\\x5B\\x5C"+Me+"]|\\x5C"+Oe+"|\\x5B(?:[^\\x5C\\x5D"+Me+"]|\\x5C"+Oe+")*(?:\\x5D|$))+/";Ne.push(["lang-regex",RegExp("^"+V+"("+Ye+")")])}var Je=xe.types;Je&&Ne.push([p,Je]);var Ve=(""+xe.keywords).replace(/^ | $/g,"");Ve.length&&Ne.push([L,new RegExp("^(?:"+Ve.replace(/[\s,]+/g,"|")+")\\b"),null]),ke.push([o,/^\s+/,null,` \r
\xA0`]);var je="^.[^\\s\\w.$@'\"`/\\\\]*";return xe.regexLiterals&&(je+="(?!s*/)"),Ne.push([f,/^@[a-z_$][a-z_$@0-9]*/i,null],[p,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[o,/^[a-z_$][a-z_$@0-9]*/i,null],[f,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[o,/^\\[\s\S]?/,null],[h,new RegExp(je),null]),ce(ke,Ne)}var Ee=Le({keywords:_,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function we(xe,ke,Ne){for(var He=/(?:^|\s)nocode(?:\s|$)/,Be=/\r\n?|\n/,Me=xe.ownerDocument,Oe=Me.createElement("li");xe.firstChild;)Oe.appendChild(xe.firstChild);var Ye=[Oe];function Je(Pe){var lt=Pe.nodeType;if(lt==1&&!He.test(Pe.className))if(Pe.nodeName==="br")Ve(Pe),Pe.parentNode&&Pe.parentNode.removeChild(Pe);else for(var at=Pe.firstChild;at;at=at.nextSibling)Je(at);else if((lt==3||lt==4)&&Ne){var Fe=Pe.nodeValue,Xe=Fe.match(Be);if(Xe){var Ce=Fe.substring(0,Xe.index);Pe.nodeValue=Ce;var ve=Fe.substring(Xe.index+Xe[0].length);if(ve){var be=Pe.parentNode;be.insertBefore(Me.createTextNode(ve),Pe.nextSibling)}Ve(Pe),Ce||Pe.parentNode.removeChild(Pe)}}}function Ve(Pe){for(;!Pe.nextSibling;)if(Pe=Pe.parentNode,!Pe)return;function lt(Xe,Ce){var ve=Ce?Xe.cloneNode(!1):Xe,be=Xe.parentNode;if(be){var ie=lt(be,1),ae=Xe.nextSibling;ie.appendChild(ve);for(var de=ae;de;de=ae)ae=de.nextSibling,ie.appendChild(de)}return ve}for(var at=lt(Pe.nextSibling,0),Fe;(Fe=at.parentNode)&&Fe.nodeType===1;)at=Fe;Ye.push(at)}for(var je=0;je<Ye.length;++je)Je(Ye[je]);ke===(ke|0)&&Ye[0].setAttribute("value",ke);var rt=Me.createElement("ol");rt.className="linenums";for(var Qe=Math.max(0,ke-1|0)||0,je=0,tt=Ye.length;je<tt;++je)Oe=Ye[je],Oe.className="L"+(je+Qe)%10,Oe.firstChild||Oe.appendChild(Me.createTextNode("\xA0")),rt.appendChild(Oe);xe.appendChild(rt)}function Te(xe){var ke=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ke=ke&&+ke[1]<=8;var Ne=/\n/g,He=xe.sourceCode,Be=He.length,Me=0,Oe=xe.spans,Ye=Oe.length,Je=0,Ve=xe.decorations,je=Ve.length,rt=0;Ve[je]=Be;var Qe,tt;for(tt=Qe=0;tt<je;)Ve[tt]!==Ve[tt+2]?(Ve[Qe++]=Ve[tt++],Ve[Qe++]=Ve[tt++]):tt+=2;for(je=Qe,tt=Qe=0;tt<je;){for(var Pe=Ve[tt],lt=Ve[tt+1],at=tt+2;at+2<=je&&Ve[at+1]===lt;)at+=2;Ve[Qe++]=Pe,Ve[Qe++]=lt,tt=at}je=Ve.length=Qe;var Fe=xe.sourceNode,Xe="";Fe&&(Xe=Fe.style.display,Fe.style.display="none");try{for(var Ce=null;Je<Ye;){var ve=Oe[Je],be=Oe[Je+2]||Be,ie=Ve[rt+2]||Be,at=Math.min(be,ie),ae=Oe[Je+1],de;if(ae.nodeType!==1&&(de=He.substring(Me,at))){ke&&(de=de.replace(Ne,"\r")),ae.nodeValue=de;var me=ae.ownerDocument,Se=me.createElement("span");Se.className=Ve[rt+1];var Ie=ae.parentNode;Ie.replaceChild(Se,ae),Se.appendChild(ae),Me<be&&(Oe[Je+1]=ae=me.createTextNode(He.substring(at,be)),Ie.insertBefore(ae,Se.nextSibling))}Me=at,Me>=be&&(Je+=2),Me>=ie&&(rt+=2)}}finally{Fe&&(Fe.style.display=Xe)}}var ye={};function fe(xe,ke){for(var Ne=ke.length;--Ne>=0;){var He=ke[Ne];ye.hasOwnProperty(He)?j.console&&console.warn("cannot override language handler %s",He):ye[He]=xe}}function se(xe,ke){return xe&&ye.hasOwnProperty(xe)||(xe=/^\s*</.test(ke)?"default-markup":"default-code"),ye[xe]}fe(Ee,["default-code"]),fe(ce([],[[o,/^[^<?]+/],[g,/^<!\w[^>]*(?:>|$)/],[x,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[h,/^(?:<[%?]|[%?]>)/],["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"]),fe(ce([[o,/^[\s]+/,null,` \r
`],[U,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[E,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[h,/^[=<>\/]+/],["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"]),fe(ce([],[[U,/^[\s\S]+/]]),["uq.val"]),fe(Le({keywords:A,hashComments:!0,cStyleComments:!0,types:v}),["c","cc","cpp","cxx","cyc","m"]),fe(Le({keywords:"null,true,false"}),["json"]),fe(Le({keywords:T,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:v}),["cs"]),fe(Le({keywords:k,cStyleComments:!0}),["java"]),fe(Le({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),fe(Le({keywords:a,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),fe(Le({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),fe(Le({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),fe(Le({keywords:b,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),fe(Le({keywords:C,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),fe(ce([],[[m,/^[\s\S]+/]]),["regex"]);function te(xe){var ke=xe.langExtension;try{var Ne=I(xe.sourceNode,xe.pre),He=Ne.sourceCode;xe.sourceCode=He,xe.spans=Ne.spans,xe.basePos=0,se(ke,He)(xe),Te(xe)}catch(Be){j.console&&console.log(Be&&Be.stack||Be)}}function ue(xe,ke,Ne){var He=Ne||!1,Be=ke||null,Me=document.createElement("div");Me.innerHTML="<pre>"+xe+"</pre>",Me=Me.firstChild,He&&we(Me,He,!0);var Oe={langExtension:Be,numberLines:He,sourceNode:Me,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return te(Oe),Me.innerHTML}function ne(xe,ke){var Ne=ke||document.body,He=Ne.ownerDocument||document;function Be(ve){return Ne.getElementsByTagName(ve)}for(var Me=[Be("pre"),Be("code"),Be("xmp")],Oe=[],Ye=0;Ye<Me.length;++Ye)for(var Je=0,Ve=Me[Ye].length;Je<Ve;++Je)Oe.push(Me[Ye][Je]);Me=null;var je=Date;je.now||(je={now:function(){return+new Date}});var rt=0,Qe=/\blang(?:uage)?-([\w.]+)(?!\S)/,tt=/\bprettyprint\b/,Pe=/\bprettyprinted\b/,lt=/pre|xmp/i,at=/^code$/i,Fe=/^(?:pre|code|xmp)$/i,Xe={};function Ce(){for(var ve=j.PR_SHOULD_USE_CONTINUATION?je.now()+250:Infinity;rt<Oe.length&&je.now()<ve;rt++){for(var be=Oe[rt],ie=Xe,ae=be;ae=ae.previousSibling;){var de=ae.nodeType,me=(de===7||de===8)&&ae.nodeValue;if(me?!/^\??prettify\b/.test(me):de!==3||/\S/.test(ae.nodeValue))break;if(me){ie={},me.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Xt,kt,Ir){ie[kt]=Ir});break}}var Se=be.className;if((ie!==Xe||tt.test(Se))&&!Pe.test(Se)){for(var Ie=!1,ze=be.parentNode;ze;ze=ze.parentNode){var ot=ze.tagName;if(Fe.test(ot)&&ze.className&&tt.test(ze.className)){Ie=!0;break}}if(!Ie){be.className+=" prettyprinted";var gt=ie.lang;if(!gt){gt=Se.match(Qe);var pt;!gt&&(pt=oe(be))&&at.test(pt.tagName)&&(gt=pt.className.match(Qe)),gt&&(gt=gt[1])}var wt;if(lt.test(be.tagName))wt=1;else{var Ct=be.currentStyle,ht=He.defaultView,Ft=Ct?Ct.whiteSpace:ht&&ht.getComputedStyle?ht.getComputedStyle(be,null).getPropertyValue("white-space"):0;wt=Ft&&Ft.substring(0,3)==="pre"}var Ot=ie.linenums;(Ot=Ot==="true"||+Ot)||(Ot=Se.match(/\blinenums\b(?::(\d+))?/),Ot=Ot?Ot[1]&&Ot[1].length?+Ot[1]:!0:!1),Ot&&we(be,Ot,wt);var Zt={langExtension:gt,sourceNode:be,numberLines:Ot,pre:wt,sourceCode:null,basePos:null,spans:null,decorations:null};te(Zt)}}}rt<Oe.length?j.setTimeout(Ce,250):typeof xe=="function"&&xe()}Ce()}var _e=j.PR={createSimpleLexer:ce,registerLangHandler:fe,sourceDecorator:Le,PR_ATTRIB_NAME:M,PR_ATTRIB_VALUE:U,PR_COMMENT:x,PR_DECLARATION:g,PR_KEYWORD:L,PR_LITERAL:f,PR_NOCODE:G,PR_PLAIN:o,PR_PUNCTUATION:h,PR_SOURCE:S,PR_STRING:m,PR_TAG:E,PR_TYPE:p,prettyPrintOne:R?j.prettyPrintOne=ue:P=ue,prettyPrint:K=R?j.prettyPrint=ne:K=ne},Re=j.define;typeof Re=="function"&&Re.amd&&Re("google-code-prettify",[],function(){return _e})})()},"VrN/":function(ut,Ze,re){(function(le,$){ut.exports=$()})(this,function(){"use strict";var le=navigator.userAgent,$=navigator.platform,R=/gecko\/\d/i.test(le),Z=/MSIE \d/.test(le),F=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(le),P=/Edge\/(\d+)/.exec(le),K=Z||F||P,j=K&&(Z?document.documentMode||6:+(P||F)[1]),N=!P&&/WebKit\//.test(le),D=N&&/Qt\/\d+\.\d+/.test(le),y=!P&&/Chrome\//.test(le),A=/Opera\//.test(le),k=/Apple Computer/.test(navigator.vendor),T=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(le),C=/PhantomJS/.test(le),b=!P&&/AppleWebKit/.test(le)&&/Mobile\/\w+/.test(le),u=/Android/.test(le),a=b||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(le),l=b||/Mac/.test($),d=/\bCrOS\b/.test(le),_=/win/i.test($),v=A&&le.match(/Version\/(\d*\.\d*)/);v&&(v=Number(v[1])),v&&v>=15&&(A=!1,N=!0);var m=l&&(D||A&&(v==null||v<12.11)),L=R||K&&j>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var p=function(e,t){var i=e.className,r=x(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function f(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function h(e,t){return f(e).appendChild(t)}function o(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var w=0;w<t.length;++w)n.appendChild(t[w]);return n}function E(e,t,i,r){var n=o(e,t,i,r);return n.setAttribute("role","presentation"),n}var g;document.createRange?g=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:g=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 S(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function M(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function U(e,t){var i=e.className;x(t).test(i)||(e.className+=(i?" ":"")+t)}function G(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!x(i[r]).test(t)&&(t+=" "+i[r]);return t}var V=function(e){e.select()};b?V=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:K&&(V=function(e){try{e.select()}catch(t){}});function O(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function I(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 X(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var w=r||0,W=n||0;;){var Y=e.indexOf(" ",w);if(Y<0||Y>=t)return W+(t-w);W+=Y-w,W+=i-W%i,w=Y+1}}var q=function(){this.id=null,this.f=null,this.time=0,this.handler=O(this.onTimeout,this)};q.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},q.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 oe(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ce=50,Le={toString:function(){return"CodeMirror.Pass"}},Ee={scroll:!1},we={origin:"*mouse"},Te={origin:"+move"};function ye(e,t,i){for(var r=0,n=0;;){var w=e.indexOf(" ",r);w==-1&&(w=e.length);var W=w-r;if(w==e.length||n+W>=t)return r+Math.min(W,t-n);if(n+=w-r,n+=i-n%i,r=w+1,n>=t)return r}}var fe=[""];function se(e){for(;fe.length<=e;)fe.push(te(fe)+" ");return fe[e]}function te(e){return e[e.length-1]}function ue(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 _e(){}function Re(e,t){var i;return Object.create?i=Object.create(e):(_e.prototype=e,i=new _e),t&&I(t,i),i}var xe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function ke(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||xe.test(e))}function Ne(e,t){return t?t.source.indexOf("\\w")>-1&&ke(e)?!0:t.test(e):ke(e)}function He(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Be=/[\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 Me(e){return e.charCodeAt(0)>=768&&Be.test(e)}function Oe(e,t,i){for(;(i<0?t>0:t<e.length)&&Me(e.charAt(t));)t+=i;return t}function Ye(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,w=r<0?Math.ceil(n):Math.floor(n);if(w==t)return e(w)?t:i;e(w)?i=w:t=w+r}}function Je(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,w=0;w<e.length;++w){var W=e[w];(W.from<i&&W.to>t||t==i&&W.to==t)&&(r(Math.max(W.from,t),Math.min(W.to,i),W.level==1?"rtl":"ltr",w),n=!0)}n||r(t,i,"ltr")}var Ve=null;function je(e,t,i){var r;Ve=null;for(var n=0;n<e.length;++n){var w=e[n];if(w.from<t&&w.to>t)return n;w.to==t&&(w.from!=w.to&&i=="before"?r=n:Ve=n),w.from==t&&(w.from!=w.to&&i!="before"?r=n:Ve=n)}return r!=null?r:Ve}var rt=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(ee){return ee<=247?e.charAt(ee):1424<=ee&&ee<=1524?"R":1536<=ee&&ee<=1785?t.charAt(ee-1536):1774<=ee&&ee<=2220?"r":8192<=ee&&ee<=8203?"w":ee==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,w=/[LRr]/,W=/[Lb1n]/,Y=/[1n]/;function J(ee,he,pe){this.level=ee,this.from=he,this.to=pe}return function(ee,he){var pe=he=="ltr"?"L":"R";if(ee.length==0||he=="ltr"&&!r.test(ee))return!1;for(var De=ee.length,Ae=[],Ue=0;Ue<De;++Ue)Ae.push(i(ee.charCodeAt(Ue)));for(var Ke=0,qe=pe;Ke<De;++Ke){var it=Ae[Ke];it=="m"?Ae[Ke]=qe:qe=it}for(var st=0,nt=pe;st<De;++st){var dt=Ae[st];dt=="1"&&nt=="r"?Ae[st]="n":w.test(dt)&&(nt=dt,dt=="r"&&(Ae[st]="R"))}for(var xt=1,vt=Ae[0];xt<De-1;++xt){var _t=Ae[xt];_t=="+"&&vt=="1"&&Ae[xt+1]=="1"?Ae[xt]="1":_t==","&&vt==Ae[xt+1]&&(vt=="1"||vt=="n")&&(Ae[xt]=vt),vt=_t}for(var Gt=0;Gt<De;++Gt){var lr=Ae[Gt];if(lr==",")Ae[Gt]="N";else if(lr=="%"){var Yt=void 0;for(Yt=Gt+1;Yt<De&&Ae[Yt]=="%";++Yt);for(var Mr=Gt&&Ae[Gt-1]=="!"||Yt<De&&Ae[Yt]=="1"?"1":"N",Lr=Gt;Lr<Yt;++Lr)Ae[Lr]=Mr;Gt=Yt-1}}for(var er=0,Dr=pe;er<De;++er){var fr=Ae[er];Dr=="L"&&fr=="1"?Ae[er]="L":w.test(fr)&&(Dr=fr)}for(var ir=0;ir<De;++ir)if(n.test(Ae[ir])){var tr=void 0;for(tr=ir+1;tr<De&&n.test(Ae[tr]);++tr);for(var $t=(ir?Ae[ir-1]:pe)=="L",Rr=(tr<De?Ae[tr]:pe)=="L",un=$t==Rr?$t?"L":"R":pe,Ri=ir;Ri<tr;++Ri)Ae[Ri]=un;ir=tr-1}for(var Er=[],ai,ur=0;ur<De;)if(W.test(Ae[ur])){var Va=ur;for(++ur;ur<De&&W.test(Ae[ur]);++ur);Er.push(new J(0,Va,ur))}else{var hi=ur,Hi=Er.length,zi=he=="rtl"?1:0;for(++ur;ur<De&&Ae[ur]!="L";++ur);for(var Cr=hi;Cr<ur;)if(Y.test(Ae[Cr])){hi<Cr&&(Er.splice(Hi,0,new J(1,hi,Cr)),Hi+=zi);var dn=Cr;for(++Cr;Cr<ur&&Y.test(Ae[Cr]);++Cr);Er.splice(Hi,0,new J(2,dn,Cr)),Hi+=zi,hi=Cr}else++Cr;hi<ur&&Er.splice(Hi,0,new J(1,hi,ur))}return he=="ltr"&&(Er[0].level==1&&(ai=ee.match(/^\s+/))&&(Er[0].from=ai[0].length,Er.unshift(new J(0,0,ai[0].length))),te(Er).level==1&&(ai=ee.match(/\s+$/))&&(te(Er).to-=ai[0].length,Er.push(new J(0,De-ai[0].length,De)))),he=="rtl"?Er.reverse():Er}}();function Qe(e,t){var i=e.order;return i==null&&(i=e.order=rt(e.text,t)),i}var tt=[],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]||tt).concat(i)}};function lt(e,t){return e._handlers&&e._handlers[t]||tt}function at(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var w=oe(n,i);w>-1&&(r[t]=n.slice(0,w).concat(n.slice(w+1)))}}}function Fe(e,t){var i=lt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function Xe(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Fe(e,i||t.type,e,t),de(t)||t.codemirrorIgnore}function Ce(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)oe(i,t[r])==-1&&i.push(t[r])}function ve(e,t){return lt(e,t).length>0}function be(e){e.prototype.on=function(t,i){Pe(this,t,i)},e.prototype.off=function(t,i){at(this,t,i)}}function ie(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function ae(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function de(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function me(e){ie(e),ae(e)}function Se(e){return e.target||e.srcElement}function Ie(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 ze=function(){if(K&&j<9)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),ot;function gt(e){if(ot==null){var t=o("span","\u200B");h(e,o("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(ot=t.offsetWidth<=1&&t.offsetHeight>2&&!(K&&j<8))}var i=ot?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var pt;function wt(e){if(pt!=null)return pt;var t=h(e,document.createTextNode("A\u062EA")),i=g(t,0,1).getBoundingClientRect(),r=g(t,1,2).getBoundingClientRect();return f(e),!i||i.left==i.right?!1:pt=r.right-i.right<3}var Ct=`
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 w=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),W=w.indexOf("\r");W!=-1?(i.push(w.slice(0,W)),t+=W+1):(i.push(w),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},ht=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Ft=function(){var e=o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ot=null;function Zt(e){if(Ot!=null)return Ot;var t=h(e,o("span","x")),i=t.getBoundingClientRect(),r=g(t,0,1).getBoundingClientRect();return Ot=Math.abs(i.left-r.left)>1}var Xt={},kt={};function Ir(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Xt[e]=t}function Kr(e,t){kt[e]=t}function Et(e){if(typeof e=="string"&&kt.hasOwnProperty(e))e=kt[e];else if(e&&typeof e.name=="string"&&kt.hasOwnProperty(e.name)){var t=kt[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 Et("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Et("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Nr(e,t){t=Et(t);var i=Xt[t.name];if(!i)return Nr(e,"text/plain");var r=i(e,t);if(dr.hasOwnProperty(t.name)){var n=dr[t.name];for(var w in n){if(!n.hasOwnProperty(w))continue;r.hasOwnProperty(w)&&(r["_"+w]=r[w]),r[w]=n[w]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var W in t.modeProps)r[W]=t.modeProps[W];return r}var dr={};function pr(e,t){var i=dr.hasOwnProperty(e)?dr[e]:dr[e]={};I(t,i)}function Br(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function ci(e,t){for(var i;e.innerMode&&!(i=e.innerMode(t),!i||i.mode==e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function qr(e,t,i){return e.startState?e.startState(t,i):!0}var It=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};It.prototype.eol=function(){return this.pos>=this.string.length},It.prototype.sol=function(){return this.pos==this.lineStart},It.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},It.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},It.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},It.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},It.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},It.prototype.skipToEnd=function(){this.pos=this.string.length},It.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},It.prototype.backUp=function(e){this.pos-=e},It.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=X(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?X(this.string,this.lineStart,this.tabSize):0)},It.prototype.indentation=function(){return X(this.string,null,this.tabSize)-(this.lineStart?X(this.string,this.lineStart,this.tabSize):0)},It.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(W){return i?W.toLowerCase():W},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var w=this.string.slice(this.pos).match(e);return w&&w.index>0?null:(w&&t!==!1&&(this.pos+=w[0].length),w)}},It.prototype.current=function(){return this.string.slice(this.start,this.pos)},It.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},It.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},It.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ct(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],w=n.chunkSize();if(t<w){i=n;break}t-=w}return i.lines[t]}function Hr(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(w){var W=w.text;n==i.line&&(W=W.slice(0,i.ch)),n==t.line&&(W=W.slice(t.ch)),r.push(W),++n}),r}function ei(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function mr(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Lt(e){if(e.parent==null)return null;for(var t=e.parent,i=oe(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function Fr(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],w=n.height;if(t<w){e=n;continue e}t-=w,i+=n.chunkSize()}return i}while(!e.lines);for(var W=0;W<e.lines.length;++W){var Y=e.lines[W],J=Y.height;if(t<J)break;t-=J}return i+W}function Vr(e,t){return t>=e.first&&t<e.first+e.size}function fi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function $e(e,t,i){if(i===void 0&&(i=null),!(this instanceof $e))return new $e(e,t,i);this.line=e,this.ch=t,this.sticky=i}function St(e,t){return e.line-t.line||e.ch-t.ch}function pi(e,t){return e.sticky==t.sticky&&St(e,t)==0}function mi(e){return $e(e.line,e.ch)}function gi(e,t){return St(e,t)<0?t:e}function vi(e,t){return St(e,t)<0?e:t}function z(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return $e(e.first,0);var i=e.first+e.size-1;return t.line>i?$e(i,ct(e,i).text.length):c(t,ct(e,t.line).text.length)}function c(e,t){var i=e.ch;return i==null||i>t?$e(e.line,t):i<0?$e(e.line,0):e}function B(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Q=function(e,t){this.state=e,this.lookAhead=t},H=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};H.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},H.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},H.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},H.fromSaved=function(e,t,i){return t instanceof Q?new H(e,Br(e.mode,t.state),i,t.lookAhead):new H(e,Br(e.mode,t),i)},H.prototype.save=function(e){var t=e!==!1?Br(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Q(t,this.maxLookAhead):t};function ge(e,t,i,r){var n=[e.state.modeGen],w={};gr(e,t.text,e.doc.mode,i,function(ee,he){return n.push(ee,he)},w,r);for(var W=i.state,Y=function(ee){i.baseTokens=n;var he=e.state.overlays[ee],pe=1,De=0;i.state=!0,gr(e,t.text,he.mode,i,function(Ae,Ue){for(var Ke=pe;De<Ae;){var qe=n[pe];qe>Ae&&n.splice(pe,1,Ae,n[pe+1],qe),pe+=2,De=Math.min(Ae,qe)}if(!Ue)return;if(he.opaque)n.splice(Ke,pe-Ke,Ae,"overlay "+Ue),pe=Ke+2;else for(;Ke<pe;Ke+=2){var it=n[Ke+1];n[Ke+1]=(it?it+" ":"")+"overlay "+Ue}},w),i.state=W,i.baseTokens=null,i.baseTokenPos=1},J=0;J<e.state.overlays.length;++J)Y(J);return{styles:n,classes:w.bgClass||w.textClass?w:null}}function We(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=et(e,Lt(t)),n=t.text.length>e.options.maxHighlightLength&&Br(e.doc.mode,r.state),w=ge(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=w.styles,w.classes?t.styleClasses=w.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 et(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new H(r,!0,t);var w=vr(e,t,i),W=w>r.first&&ct(r,w-1).stateAfter,Y=W?H.fromSaved(r,W,w):new H(r,qr(r.mode),w);return r.iter(w,t,function(J){ft(e,J.text,Y);var ee=Y.line;J.stateAfter=ee==t-1||ee%5==0||ee>=n.viewFrom&&ee<n.viewTo?Y.save():null,Y.nextLine()}),i&&(r.modeFrontier=Y.line),Y}function ft(e,t,i,r){var n=e.doc.mode,w=new It(t,e.options.tabSize,i);for(w.start=w.pos=r||0,t==""&&Ge(n,i.state);!w.eol();)yt(n,w,i.state),w.start=w.pos}function Ge(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=ci(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function yt(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=ci(e,i).mode);var w=e.token(t,i);if(t.pos>t.start)return w}throw new Error("Mode "+e.name+" failed to advance stream.")}var Nt=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Kt(e,t,i,r){var n=e.doc,w=n.mode,W;t=s(n,t);var Y=ct(n,t.line),J=et(e,t.line,i),ee=new It(Y.text,e.options.tabSize,J),he;for(r&&(he=[]);(r||ee.pos<t.ch)&&!ee.eol();)ee.start=ee.pos,W=yt(w,ee,J.state),r&&he.push(new Nt(ee,W,Br(n.mode,J.state)));return r?he:new Nt(ee,W,J.state)}function kr(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function gr(e,t,i,r,n,w,W){var Y=i.flattenSpans;Y==null&&(Y=e.options.flattenSpans);var J=0,ee=null,he=new It(t,e.options.tabSize,r),pe,De=e.options.addModeClass&&[null];for(t==""&&kr(Ge(i,r.state),w);!he.eol();){if(he.pos>e.options.maxHighlightLength?(Y=!1,W&&ft(e,t,r,he.pos),he.pos=t.length,pe=null):pe=kr(yt(i,he,r.state,De),w),De){var Ae=De[0].name;Ae&&(pe="m-"+(pe?Ae+" "+pe:Ae))}if(!Y||ee!=pe){for(;J<he.start;)J=Math.min(he.start,J+5e3),n(J,ee);ee=pe}he.start=he.pos}for(;J<he.pos;){var Ue=Math.min(he.pos,J+5e3);n(Ue,ee),J=Ue}}function vr(e,t,i){for(var r,n,w=e.doc,W=i?-1:t-(e.doc.mode.innerMode?1e3:100),Y=t;Y>W;--Y){if(Y<=w.first)return w.first;var J=ct(w,Y-1),ee=J.stateAfter;if(ee&&(!i||Y+(ee instanceof Q?ee.lookAhead:0)<=w.modeFrontier))return Y;var he=X(J.text,null,e.options.tabSize);(n==null||r>he)&&(n=Y-1,r=he)}return n}function Xr(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=ct(e,r).stateAfter;if(n&&(!(n instanceof Q)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var ki=!1,nr=!1;function Ur(){ki=!0}function oi(){nr=!0}function si(e,t,i){this.marker=e,this.from=t,this.to=i}function Or(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Oi(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function yi(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Gi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var w=e[n],W=w.marker,Y=w.from==null||(W.inclusiveLeft?w.from<=t:w.from<t);if(Y||w.from==t&&W.type=="bookmark"&&(!i||!w.marker.insertLeft)){var J=w.to==null||(W.inclusiveRight?w.to>=t:w.to>t);(r||(r=[])).push(new si(W,w.from,J?null:w.to))}}return r}function Ki(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var w=e[n],W=w.marker,Y=w.to==null||(W.inclusiveRight?w.to>=t:w.to>t);if(Y||w.from==t&&W.type=="bookmark"&&(!i||w.marker.insertLeft)){var J=w.from==null||(W.inclusiveLeft?w.from<=t:w.from<t);(r||(r=[])).push(new si(W,J?null:w.from-t,w.to==null?null:w.to-t))}}return r}function Yr(e,t){if(t.full)return null;var i=Vr(e,t.from.line)&&ct(e,t.from.line).markedSpans,r=Vr(e,t.to.line)&&ct(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,w=t.to.ch,W=St(t.from,t.to)==0,Y=Gi(i,n,W),J=Ki(r,w,W),ee=t.text.length==1,he=te(t.text).length+(ee?n:0);if(Y)for(var pe=0;pe<Y.length;++pe){var De=Y[pe];if(De.to==null){var Ae=Or(J,De.marker);Ae?ee&&(De.to=Ae.to==null?null:Ae.to+he):De.to=n}}if(J)for(var Ue=0;Ue<J.length;++Ue){var Ke=J[Ue];if(Ke.to!=null&&(Ke.to+=he),Ke.from==null){var qe=Or(Y,Ke.marker);qe||(Ke.from=he,ee&&(Y||(Y=[])).push(Ke))}else Ke.from+=he,ee&&(Y||(Y=[])).push(Ke)}Y&&(Y=zr(Y)),J&&J!=Y&&(J=zr(J));var it=[Y];if(!ee){var st=t.text.length-2,nt;if(st>0&&Y)for(var dt=0;dt<Y.length;++dt)Y[dt].to==null&&(nt||(nt=[])).push(new si(Y[dt].marker,null,null));for(var xt=0;xt<st;++xt)it.push(nt);it.push(J)}return it}function zr(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function bi(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(Ae){if(Ae.markedSpans)for(var Ue=0;Ue<Ae.markedSpans.length;++Ue){var Ke=Ae.markedSpans[Ue].marker;Ke.readOnly&&(!r||oe(r,Ke)==-1)&&(r||(r=[])).push(Ke)}}),!r)return null;for(var n=[{from:t,to:i}],w=0;w<r.length;++w)for(var W=r[w],Y=W.find(0),J=0;J<n.length;++J){var ee=n[J];if(St(ee.to,Y.from)<0||St(ee.from,Y.to)>0)continue;var he=[J,1],pe=St(ee.from,Y.from),De=St(ee.to,Y.to);(pe<0||!W.inclusiveLeft&&!pe)&&he.push({from:ee.from,to:Y.from}),(De>0||!W.inclusiveRight&&!De)&&he.push({from:Y.to,to:ee.to}),n.splice.apply(n,he),J+=he.length-3}return n}function hn(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 Ei(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function Jt(e){return e.inclusiveLeft?-1:0}function Bt(e){return e.inclusiveRight?1:0}function hr(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),w=St(r.from,n.from)||Jt(e)-Jt(t);if(w)return-w;var W=St(r.to,n.to)||Bt(e)-Bt(t);return W||t.id-e.id}function Dt(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=void 0,w=0;w<i.length;++w)n=i[w],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||hr(r,n.marker)<0)&&(r=n.marker);return r}function qt(e){return Dt(e,!0)}function Wt(e){return Dt(e,!1)}function ti(e,t){var i=nr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var w=i[n];w.marker.collapsed&&(w.from==null||w.from<t)&&(w.to==null||w.to>t)&&(!r||hr(r,w.marker)<0)&&(r=w.marker)}return r}function ar(e,t,i,r,n){var w=ct(e,t),W=nr&&w.markedSpans;if(W)for(var Y=0;Y<W.length;++Y){var J=W[Y];if(!J.marker.collapsed)continue;var ee=J.marker.find(0),he=St(ee.from,i)||Jt(J.marker)-Jt(n),pe=St(ee.to,r)||Bt(J.marker)-Bt(n);if(he>=0&&pe<=0||he<=0&&pe>=0)continue;if(he<=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?St(ee.to,i)>=0:St(ee.to,i)>0)||he>=0&&(J.marker.inclusiveRight&&n.inclusiveLeft?St(ee.from,r)<=0:St(ee.from,r)<0))return!0}}function xr(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Vi(e){for(var t;t=Wt(e);)e=t.find(1,!0).line;return e}function xi(e){for(var t,i;t=Wt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function cn(e,t){var i=ct(e,t),r=xr(i);return i==r?t:Lt(r)}function Si(e,t){if(t>e.lastLine())return t;var i=ct(e,t),r;if(!ri(e,i))return t;for(;r=Wt(i);)i=r.find(1,!0).line;return Lt(i)+1}function ri(e,t){var i=nr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fn(e,t,r))return!0}}function fn(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return fn(e,r.line,Or(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,w=0;w<t.markedSpans.length;++w)if(n=t.markedSpans[w],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&fn(e,t,n))return!0}function $r(e){e=xr(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 w=i.parent;w;i=w,w=i.parent)for(var W=0;W<w.children.length;++W){var Y=w.children[W];if(Y==i)break;t+=Y.height}return t}function pn(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=qt(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Wt(r);){var w=i.find(0,!0);t-=r.text.length-w.from.ch,r=w.to.line,t+=r.text.length-w.to.ch}return t}function jn(e){var t=e.display,i=e.doc;t.maxLine=ct(i,i.first),t.maxLineLength=pn(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=pn(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Pi=function(e,t,i){this.text=e,Ei(this,t),this.height=i?i(this):1};Pi.prototype.lineNo=function(){return Lt(this)},be(Pi);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),hn(e),Ei(e,i);var n=r?r(e):1;n!=e.height&&mr(e,n)}function mt(e){e.parent=null,hn(e)}var Tt={},bt={};function At(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?bt:Tt;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Mt(e,t){var i=E("span",null,null,N?"padding-right: .1px":null),r={pre:E("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 w=n?t.rest[n-1]:t.line,W=void 0;r.pos=0,r.addToken=Pt,wt(e.display.measure)&&(W=Qe(w,e.doc.direction))&&(r.addToken=Tr(r.addToken,W)),r.map=[];var Y=t!=e.display.externalMeasured&&Lt(w);li(w,r,We(e,w,Y)),w.styleClasses&&(w.styleClasses.bgClass&&(r.bgClass=G(w.styleClasses.bgClass,r.bgClass||"")),w.styleClasses.textClass&&(r.textClass=G(w.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(gt(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(N){var J=r.content.lastChild;(/\bcm-tab\b/.test(J.className)||J.querySelector&&J.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Fe(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=G(r.pre.className,r.textClass||"")),r}function zt(e){var t=o("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Pt(e,t,i,r,n,w,W){if(!t)return;var Y=e.splitSpaces?rr(t,e.trailingSpace):t,J=e.cm.state.specialChars,ee=!1,he;if(!J.test(t))e.col+=t.length,he=document.createTextNode(Y),e.map.push(e.pos,e.pos+t.length,he),K&&j<9&&(ee=!0),e.pos+=t.length;else{he=document.createDocumentFragment();for(var pe=0;;){J.lastIndex=pe;var De=J.exec(t),Ae=De?De.index-pe:t.length-pe;if(Ae){var Ue=document.createTextNode(Y.slice(pe,pe+Ae));K&&j<9?he.appendChild(o("span",[Ue])):he.appendChild(Ue),e.map.push(e.pos,e.pos+Ae,Ue),e.col+=Ae,e.pos+=Ae}if(!De)break;pe+=Ae+1;var Ke=void 0;if(De[0]==" "){var qe=e.cm.options.tabSize,it=qe-e.col%qe;Ke=he.appendChild(o("span",se(it),"cm-tab")),Ke.setAttribute("role","presentation"),Ke.setAttribute("cm-text"," "),e.col+=it}else De[0]=="\r"||De[0]==`
`?(Ke=he.appendChild(o("span",De[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ke.setAttribute("cm-text",De[0]),e.col+=1):(Ke=e.cm.options.specialCharPlaceholder(De[0]),Ke.setAttribute("cm-text",De[0]),K&&j<9?he.appendChild(o("span",[Ke])):he.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||ee||w||W){var st=i||"";r&&(st+=r),n&&(st+=n);var nt=o("span",[he],st,w);if(W)for(var dt in W)W.hasOwnProperty(dt)&&dt!="style"&&dt!="class"&&nt.setAttribute(dt,W[dt]);return e.content.appendChild(nt)}e.content.appendChild(he)}function rr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var w=e.charAt(n);w==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(w="\xA0"),r+=w,i=w==" "}return r}function Tr(e,t){return function(i,r,n,w,W,Y,J){n=n?n+" cm-force-border":"cm-force-border";for(var ee=i.pos,he=ee+r.length;;){for(var pe=void 0,De=0;De<t.length&&!(pe=t[De],pe.to>ee&&pe.from<=ee);De++);if(pe.to>=he)return e(i,r,n,w,W,Y,J);e(i,r.slice(0,pe.to-ee),n,w,null,Y,J),w=null,r=r.slice(pe.to-ee),ee=pe.to}}}function Rt(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function li(e,t,i){var r=e.markedSpans,n=e.text,w=0;if(!r){for(var W=1;W<i.length;W+=2)t.addToken(t,n.slice(w,w=i[W]),At(i[W+1],t.cm.options));return}for(var Y=n.length,J=0,ee=1,he="",pe,De,Ae=0,Ue,Ke,qe,it,st;;){if(Ae==J){Ue=Ke=qe=De="",st=null,it=null,Ae=Infinity;for(var nt=[],dt=void 0,xt=0;xt<r.length;++xt){var vt=r[xt],_t=vt.marker;if(_t.type=="bookmark"&&vt.from==J&&_t.widgetNode)nt.push(_t);else if(vt.from<=J&&(vt.to==null||vt.to>J||_t.collapsed&&vt.to==J&&vt.from==J)){if(vt.to!=null&&vt.to!=J&&Ae>vt.to&&(Ae=vt.to,Ke=""),_t.className&&(Ue+=" "+_t.className),_t.css&&(De=(De?De+";":"")+_t.css),_t.startStyle&&vt.from==J&&(qe+=" "+_t.startStyle),_t.endStyle&&vt.to==Ae&&(dt||(dt=[])).push(_t.endStyle,vt.to),_t.title&&((st||(st={})).title=_t.title),_t.attributes)for(var Gt in _t.attributes)(st||(st={}))[Gt]=_t.attributes[Gt];_t.collapsed&&(!it||hr(it.marker,_t)<0)&&(it=vt)}else vt.from>J&&Ae>vt.from&&(Ae=vt.from)}if(dt)for(var lr=0;lr<dt.length;lr+=2)dt[lr+1]==Ae&&(Ke+=" "+dt[lr]);if(!it||it.from==J)for(var Yt=0;Yt<nt.length;++Yt)Rt(t,0,nt[Yt]);if(it&&(it.from||0)==J){if(Rt(t,(it.to==null?Y+1:it.to)-J,it.marker,it.from==null),it.to==null)return;it.to==J&&(it=!1)}}if(J>=Y)break;for(var Mr=Math.min(Y,Ae);;){if(he){var Lr=J+he.length;if(!it){var er=Lr>Mr?he.slice(0,Mr-J):he;t.addToken(t,er,pe?pe+Ue:Ue,qe,J+er.length==Ae?Ke:"",De,st)}if(Lr>=Mr){he=he.slice(Mr-J),J=Mr;break}J=Lr,qe=""}he=n.slice(w,w=i[ee++]),pe=At(i[ee++],t.cm.options)}}}function Ut(e,t,i){this.line=t,this.rest=xi(t),this.size=this.rest?Lt(te(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ri(e,t)}function wr(e,t,i){for(var r=[],n,w=t;w<i;w=n){var W=new Ut(e.doc,ct(e.doc,w),w);n=w+W.size,r.push(W)}return r}var yr=null;function Gr(e){yr?yr.ops.push(e):e.ownsGroup=yr={ops:[e],delayedCallbacks:[]}}function Rs(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function ks(e,t){var i=e.ownsGroup;if(!i)return;try{Rs(i)}finally{yr=null,t(i)}}var mn=null;function cr(e,t){var i=lt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;yr?n=yr.delayedCallbacks:mn?n=mn:(n=mn=[],setTimeout(Os,0));for(var w=function(Y){n.push(function(){return i[Y].apply(null,r)})},W=0;W<i.length;++W)w(W)}function Os(){var e=mn;mn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var w=t.changes[n];w=="text"?Ms(e,t):w=="gutter"?Za(e,t,i,r):w=="class"?da(e,t):w=="widget"&&Is(e,t,r)}t.changes=null}function gn(e){return e.node==e.text&&(e.node=o("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),K&&j<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=gn(t);t.background=r.insertBefore(o("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Mt(e,t)}function Ms(e,t){var i=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,da(e,t)):i&&(t.text.className=i)}function da(e,t){Ps(e,t),t.line.wrapClass?gn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var n=gn(t);t.gutterBackground=o("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}var w=t.line.gutterMarkers;if(e.options.lineNumbers||w){var W=gn(t),Y=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(Y),W.insertBefore(Y,t.text),t.line.gutterClass&&(Y.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!w||!w["CodeMirror-linenumbers"])&&(t.lineNumber=Y.appendChild(o("div",fi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),w)for(var J=0;J<e.display.gutterSpecs.length;++J){var ee=e.display.gutterSpecs[J].className,he=w.hasOwnProperty(ee)&&w[ee];he&&Y.appendChild(o("div",[he],"CodeMirror-gutter-elt","left: "+r.gutterLeft[ee]+"px; width: "+r.gutterWidth[ee]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=x("CodeMirror-linewidget"),n=t.node.firstChild,w=void 0;n;n=w)w=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Ja(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),da(e,t),Za(e,t,i,r),Ja(e,t,r),t.node}function Ja(e,t,i){if(Qa(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Qa(e,t.rest[r],t,i,!1)}function Qa(e,t,i,r,n){if(!t.widgets)return;for(var w=gn(i),W=0,Y=t.widgets;W<Y.length;++W){var J=Y[W],ee=o("div",[J.node],"CodeMirror-linewidget"+(J.className?" "+J.className:""));J.handleMouseEvents||ee.setAttribute("cm-ignore-events","true"),Bs(J,ee,i,r),e.display.input.setUneditable(ee),n&&J.above?w.insertBefore(ee,i.gutter||i.text):w.appendChild(ee),cr(J,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function vn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!S(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;"),h(t.display.measure,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ui(e,t){for(var i=Se(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Wn(e){return e.lineSpace.offsetTop}function ha(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=h(e.measure,o("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ii(e){return ce-e.display.nativeBarWidth}function Mi(e){return e.display.scroller.clientWidth-ii(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-ii(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&Mi(e);if(!t.measure.heights||r&&t.measure.width!=n){var w=t.measure.heights=[];if(r){t.measure.width=n;for(var W=t.text.firstChild.getClientRects(),Y=0;Y<W.length-1;Y++){var J=W[Y],ee=W[Y+1];Math.abs(J.bottom-ee.bottom)>2&&w.push((J.bottom+ee.top)/2-i.top)}}w.push(i.bottom-i.top)}}function eo(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var n=0;n<e.rest.length;n++)if(Lt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=xr(t);var i=Lt(t),r=e.display.externalMeasured=new Ut(e.doc,t,i);r.lineN=i;var n=r.built=Mt(e,r);return r.text=n.pre,h(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return ni(e,Xi(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Bi(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Xi(e,t){var i=Lt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function ni(e,t,i,r,n){t.before&&(i=-1);var w=i+(r||""),W;return t.cache.hasOwnProperty(w)?W=t.cache[w]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),W=Ws(e,t,i,r),W.bogus||(t.cache[w]=W)),{left:W.left,right:W.right,top:n?W.rtop:W.top,bottom:n?W.rbottom:W.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,w,W,Y,J,ee=0;ee<e.length;ee+=3)if(Y=e[ee],J=e[ee+1],t<Y?(n=0,w=1,W="left"):t<J?(n=t-Y,w=n+1):(ee==e.length-3||t==J&&e[ee+3]>t)&&(w=J-Y,n=w-1,t>=J&&(W="right")),n!=null){if(r=e[ee+2],Y==J&&i==(r.insertLeft?"left":"right")&&(W=i),i=="left"&&n==0)for(;ee&&e[ee-2]==e[ee-3]&&e[ee-1].insertLeft;)r=e[(ee-=3)+2],W="left";if(i=="right"&&n==J-Y)for(;ee<e.length-3&&e[ee+3]==e[ee+4]&&!e[ee+5].insertLeft;)r=e[(ee+=3)+2],W="right";break}return{node:r,start:n,end:w,collapse:W,coverStart:Y,coverEnd:J}}function js(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function Ws(e,t,i,r){var n=io(t.map,i,r),w=n.node,W=n.start,Y=n.end,J=n.collapse,ee;if(w.nodeType==3){for(var he=0;he<4;he++){for(;W&&Me(t.line.text.charAt(n.coverStart+W));)--W;for(;n.coverStart+Y<n.coverEnd&&Me(t.line.text.charAt(n.coverStart+Y));)++Y;if(K&&j<9&&W==0&&Y==n.coverEnd-n.coverStart?ee=w.parentNode.getBoundingClientRect():ee=js(g(w,W,Y).getClientRects(),r),ee.left||ee.right||W==0)break;Y=W,W=W-1,J="right"}K&&j<11&&(ee=Hs(e.display.measure,ee))}else{W>0&&(J=r="right");var pe;e.options.lineWrapping&&(pe=w.getClientRects()).length>1?ee=pe[r=="right"?pe.length-1:0]:ee=w.getBoundingClientRect()}if(K&&j<9&&!W&&(!ee||!ee.left&&!ee.right)){var De=w.parentNode.getClientRects()[0];De?ee={left:De.left,right:De.left+$i(e.display),top:De.top,bottom:De.bottom}:ee=ro}for(var Ae=ee.top-t.rect.top,Ue=ee.bottom-t.rect.top,Ke=(Ae+Ue)/2,qe=t.view.measure.heights,it=0;it<qe.length-1&&!(Ke<qe[it]);it++);var st=it?qe[it-1]:0,nt=qe[it],dt={left:(J=="right"?ee.right:ee.left)-t.rect.left,right:(J=="left"?ee.left:ee.right)-t.rect.left,top:st,bottom:nt};return!ee.left&&!ee.right&&(dt.bogus=!0),e.options.singleCursorHeightPerLine||(dt.rtop=Ae,dt.rbottom=Ue),dt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Zt(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,f(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function yn(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return y&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return y&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=vn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var w=pa(t);i.top+=w,i.bottom+=w}if(r=="line")return i;r||(r="local");var W=$r(t);if(r=="local"?W+=Wn(e.display):W-=e.display.viewOffset,r=="page"||r=="window"){var Y=e.display.lineSpace.getBoundingClientRect();W+=Y.top+(r=="window"?0:so());var J=Y.left+(r=="window"?0:oo());i.left+=J,i.right+=J}return i.top+=W,i.bottom+=W,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var w=e.display.sizer.getBoundingClientRect();r+=w.left,n+=w.top}var W=e.display.lineSpace.getBoundingClientRect();return{left:r-W.left,top:n-W.top}}function ma(e,t,i,r,n){return r||(r=ct(e.doc,t.line)),Hn(e,r,to(e,r,t.ch,n),i)}function Zr(e,t,i,r,n,w){r=r||ct(e.doc,t.line),n||(n=Xi(e,r));function W(Ue,Ke){var qe=ni(e,n,Ue,Ke?"right":"left",w);return Ke?qe.left=qe.right:qe.right=qe.left,Hn(e,r,qe,i)}var Y=Qe(r,e.doc.direction),J=t.ch,ee=t.sticky;if(J>=r.text.length?(J=r.text.length,ee="before"):J<=0&&(J=0,ee="after"),!Y)return W(ee=="before"?J-1:J,ee=="before");function he(Ue,Ke,qe){var it=Y[Ke],st=it.level==1;return W(qe?Ue-1:Ue,st!=qe)}var pe=je(Y,J,ee),De=Ve,Ae=he(J,pe,ee=="before");return De!=null&&(Ae.other=he(J,De,ee!="before")),Ae}function uo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=$i(e.display)*t.ch);var r=ct(e.doc,t.line),n=$r(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var w=$e(e,t,i);return w.xRel=n,r&&(w.outside=r),w}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=Fr(r,i),w=r.first+r.size-1;if(n>w)return ga(r.first+r.size-1,ct(r,w).text.length,null,1,1);t<0&&(t=0);for(var W=ct(r,n);;){var Y=zs(e,W,n,t,i),J=ti(W,Y.ch+(Y.xRel>0||Y.outside>0?1:0));if(!J)return Y;var ee=J.find(1);if(ee.line==n)return ee;W=ct(r,n=ee.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,w=Ye(function(W){return ni(e,i,W-1).bottom<=r},n,0);return n=Ye(function(W){return ni(e,i,W).top>r},w,n),{begin:w,end:n}}function co(e,t,i,r){i||(i=Xi(e,t));var n=Hn(e,t,ni(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function zs(e,t,i,r,n){n-=$r(t);var w=Xi(e,t),W=pa(t),Y=0,J=t.text.length,ee=!0,he=Qe(t,e.doc.direction);if(he){var pe=(e.options.lineWrapping?Ks:Gs)(e,t,i,w,he,r,n);ee=pe.level!=1,Y=ee?pe.from:pe.to-1,J=ee?pe.to:pe.from-1}var De=null,Ae=null,Ue=Ye(function(xt){var vt=ni(e,w,xt);return vt.top+=W,vt.bottom+=W,ya(vt,r,n,!1)?(vt.top<=n&&vt.left<=r&&(De=xt,Ae=vt),!0):!1},Y,J),Ke,qe,it=!1;if(Ae){var st=r-Ae.left<Ae.right-r,nt=st==ee;Ue=De+(nt?0:1),qe=nt?"after":"before",Ke=st?Ae.left:Ae.right}else{!ee&&(Ue==J||Ue==Y)&&Ue++,qe=Ue==0?"after":Ue==t.text.length?"before":ni(e,w,Ue-(ee?1:0)).bottom+W<=n==ee?"after":"before";var dt=Zr(e,$e(i,Ue,qe),"line",t,w);Ke=dt.left,it=n<dt.top?-1:n>=dt.bottom?1:0}return Ue=Oe(t.text,Ue,1),ga(i,Ue,qe,it,r-Ke)}function Gs(e,t,i,r,n,w,W){var Y=Ye(function(pe){var De=n[pe],Ae=De.level!=1;return ya(Zr(e,$e(i,Ae?De.to:De.from,Ae?"before":"after"),"line",t,r),w,W,!0)},0,n.length-1),J=n[Y];if(Y>0){var ee=J.level!=1,he=Zr(e,$e(i,ee?J.from:J.to,ee?"after":"before"),"line",t,r);ya(he,w,W,!0)&&he.top>W&&(J=n[Y-1])}return J}function Ks(e,t,i,r,n,w,W){var Y=ho(e,t,r,W),J=Y.begin,ee=Y.end;/\s/.test(t.text.charAt(ee-1))&&ee--;for(var he=null,pe=null,De=0;De<n.length;De++){var Ae=n[De];if(Ae.from>=ee||Ae.to<=J)continue;var Ue=Ae.level!=1,Ke=ni(e,r,Ue?Math.min(ee,Ae.to)-1:Math.max(J,Ae.from)).right,qe=Ke<w?w-Ke+1e9:Ke-w;(!he||pe>qe)&&(he=Ae,pe=qe)}return he||(he=n[n.length-1]),he.from<J&&(he={from:J,to:he.to,level:he.level}),he.to>ee&&(he={from:he.from,to:ee,level:he.level}),he}var Ii;function Yi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ii==null){Ii=o("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(o("br"));Ii.appendChild(document.createTextNode("x"))}h(e.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),f(e.measure),i||1}function $i(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=o("span","xxxxxxxxxx"),i=o("pre",[t],"CodeMirror-line-like");h(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,w=t.gutters.firstChild,W=0;w;w=w.nextSibling,++W){var Y=e.display.gutterSpecs[W].className;i[Y]=w.offsetLeft+w.clientLeft+n,r[Y]=w.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 fo(e){var t=Yi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/$i(e.display)-3);return function(n){if(ri(e.doc,n))return 0;var w=0;if(n.widgets)for(var W=0;W<n.widgets.length;W++)n.widgets[W].height&&(w+=n.widgets[W].height);return i?w+(Math.ceil(n.text.length/r)||1)*t:w+t}}function xa(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&mr(r,n)})}function Ni(e,t,i,r){var n=e.display;if(!i&&Se(t).getAttribute("cm-not-content")=="true")return null;var w,W,Y=n.lineSpace.getBoundingClientRect();try{w=t.clientX-Y.left,W=t.clientY-Y.top}catch(pe){return null}var J=va(e,w,W),ee;if(r&&J.xRel>0&&(ee=ct(e.doc,J.line).text).length==J.ch){var he=X(ee,ee.length,e.options.tabSize)-ee.length;J=$e(J.line,Math.max(0,Math.round((w-qa(e.display).left)/$i(e.display))-he))}return J}function Bi(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function _r(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)nr&&cn(e.doc,t)<n.viewTo&&Ti(e);else if(i<=n.viewFrom)nr&&Si(e.doc,i+r)>n.viewFrom?Ti(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ti(e);else if(t<=n.viewFrom){var w=zn(e,i,i+r,1);w?(n.view=n.view.slice(w.index),n.viewFrom=w.lineN,n.viewTo+=r):Ti(e)}else if(i>=n.viewTo){var W=zn(e,t,t,-1);W?(n.view=n.view.slice(0,W.index),n.viewTo=W.lineN):Ti(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(wr(e,Y.lineN,J.lineN)).concat(n.view.slice(J.index)),n.viewTo+=r):Ti(e)}var ee=n.externalMeasured;ee&&(i<ee.lineN?ee.lineN+=r:t<ee.lineN+ee.size&&(n.externalMeasured=null))}function Ci(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 w=r.view[Bi(e,t)];if(w.node==null)return;var W=w.changes||(w.changes=[]);oe(W,i)==-1&&W.push(i)}function Ti(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=Bi(e,t),w,W=e.display.view;if(!nr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var Y=e.display.viewFrom,J=0;J<n;J++)Y+=W[J].size;if(Y!=t){if(r>0){if(n==W.length-1)return null;w=Y+W[n].size-t,n++}else w=Y-t;t+=w,i+=w}for(;cn(e.doc,i)!=i;){if(n==(r<0?0:W.length-1))return null;i+=r*W[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=wr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=wr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Bi(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(wr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Bi(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function bn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),w=r.selection=document.createDocumentFragment(),W=0;W<i.sel.ranges.length;W++){if(!t&&W==i.sel.primIndex)continue;var Y=i.sel.ranges[W];if(Y.from().line>=e.display.viewTo||Y.to().line<e.display.viewFrom)continue;var J=Y.empty();(J||e.options.showCursorWhenSelecting)&&go(e,Y.head,n),J||Xs(e,Y,w)}return r}function go(e,t,i){var r=Zr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(o("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var w=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));w.style.display="",w.style.left=r.other.left+"px",w.style.top=r.other.top+"px",w.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Gn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,w=document.createDocumentFragment(),W=qa(e.display),Y=W.left,J=Math.max(r.sizerWidth,Mi(e)-r.sizer.offsetLeft)-W.right,ee=n.direction=="ltr";function he(nt,dt,xt,vt){dt<0&&(dt=0),dt=Math.round(dt),vt=Math.round(vt),w.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+nt+`px;
top: `+dt+"px; width: "+(xt==null?J-nt:xt)+`px;
height: `+(vt-dt)+"px"))}function pe(nt,dt,xt){var vt=ct(n,nt),_t=vt.text.length,Gt,lr;function Yt(er,Dr){return ma(e,$e(nt,er),"div",vt,Dr)}function Mr(er,Dr,fr){var ir=co(e,vt,null,er),tr=Dr=="ltr"==(fr=="after")?"left":"right",$t=fr=="after"?ir.begin:ir.end-(/\s/.test(vt.text.charAt(ir.end-1))?2:1);return Yt($t,tr)[tr]}var Lr=Qe(vt,n.direction);return Je(Lr,dt||0,xt==null?_t:xt,function(er,Dr,fr,ir){var tr=fr=="ltr",$t=Yt(er,tr?"left":"right"),Rr=Yt(Dr-1,tr?"right":"left"),un=dt==null&&er==0,Ri=xt==null&&Dr==_t,Er=ir==0,ai=!Lr||ir==Lr.length-1;if(Rr.top-$t.top<=3){var ur=(ee?un:Ri)&&Er,Va=(ee?Ri:un)&&ai,hi=ur?Y:(tr?$t:Rr).left,Hi=Va?J:(tr?Rr:$t).right;he(hi,$t.top,Hi-hi,$t.bottom)}else{var zi,Cr,dn,Xa;tr?(zi=ee&&un&&Er?Y:$t.left,Cr=ee?J:Mr(er,fr,"before"),dn=ee?Y:Mr(Dr,fr,"after"),Xa=ee&&Ri&&ai?J:Rr.right):(zi=ee?Mr(er,fr,"before"):Y,Cr=!ee&&un&&Er?J:$t.right,dn=!ee&&Ri&&ai?Y:Rr.left,Xa=ee?Mr(Dr,fr,"after"):J),he(zi,$t.top,Cr-zi,$t.bottom),$t.bottom<Rr.top&&he(Y,$t.bottom,null,Rr.top),he(dn,Rr.top,Xa-dn,Rr.bottom)}(!Gt||Gn($t,Gt)<0)&&(Gt=$t),Gn(Rr,Gt)<0&&(Gt=Rr),(!lr||Gn($t,lr)<0)&&(lr=$t),Gn(Rr,lr)<0&&(lr=Rr)}),{start:Gt,end:lr}}var De=t.from(),Ae=t.to();if(De.line==Ae.line)pe(De.line,De.ch,Ae.ch);else{var Ue=ct(n,De.line),Ke=ct(n,Ae.line),qe=xr(Ue)==xr(Ke),it=pe(De.line,De.ch,qe?Ue.text.length+1:null).end,st=pe(Ae.line,qe?0:null,Ae.ch).start;qe&&(it.top<st.top-2?(he(it.right,it.top,null,it.bottom),he(Y,st.top,st.left,st.bottom)):he(it.right,it.top,st.left-it.right,it.bottom)),it.bottom<st.top&&he(Y,it.bottom,null,st.top)}i.appendChild(w)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ca(e))}function yo(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||(Fe(e,"focus",e,t),e.state.focused=!0,U(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),N&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Fe(e,"blur",e,t),e.state.focused=!1,p(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],w=e.options.lineWrapping,W=void 0,Y=0;if(n.hidden)continue;if(K&&j<8){var J=n.node.offsetTop+n.node.offsetHeight;W=J-i,i=J}else{var ee=n.node.getBoundingClientRect();W=ee.bottom-ee.top,!w&&n.text.firstChild&&(Y=n.text.firstChild.getBoundingClientRect().right-ee.left-1)}var he=n.line.height-W;if((he>.005||he<-.005)&&(mr(n.line,W),bo(n.line),n.rest))for(var pe=0;pe<n.rest.length;pe++)bo(n.rest[pe]);if(Y>e.display.sizerWidth){var De=Math.ceil(Y/$i(e.display));De>e.display.maxLineLength&&(e.display.maxLineLength=De,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,w=Fr(t,r),W=Fr(t,n);if(i&&i.ensure){var Y=i.ensure.from.line,J=i.ensure.to.line;Y<w?(w=Y,W=Fr(t,$r(ct(t,Y))+e.wrapper.clientHeight)):Math.min(J,t.lastLine())>=W&&(w=Fr(t,$r(ct(t,J))-e.wrapper.clientHeight),W=J)}return{from:w,to:Math.max(W,w+1)}}function Ys(e,t){if(Xe(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&&!C){var w=o("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
height: `+(t.bottom-t.top+ii(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(w),w.scrollIntoView(n),e.display.lineSpace.removeChild(w)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?$e(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?$e(t.line,t.ch+1,"before"):t);for(var w=0;w<5;w++){var W=!1,Y=Zr(e,t),J=!i||i==t?Y:Zr(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 ee=Ta(e,n),he=e.doc.scrollTop,pe=e.doc.scrollLeft;if(ee.scrollTop!=null&&(xn(e,ee.scrollTop),Math.abs(e.doc.scrollTop-he)>1&&(W=!0)),ee.scrollLeft!=null&&(Fi(e,ee.scrollLeft),Math.abs(e.doc.scrollLeft-pe)>1&&(W=!0)),!W)break}return n}function Zs(e,t){var i=Ta(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function Ta(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,w=ca(e),W={};t.bottom-t.top>w&&(t.bottom=t.top+w);var Y=e.doc.height+ha(i),J=t.top<r,ee=t.bottom>Y-r;if(t.top<n)W.scrollTop=J?0:t.top;else if(t.bottom>n+w){var he=Math.min(t.top,(ee?Y:t.bottom)-w);he!=n&&(W.scrollTop=he)}var pe=e.options.fixedGutter?0:i.gutters.offsetWidth,De=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-pe,Ae=Mi(e)-i.gutters.offsetWidth,Ue=t.right-t.left>Ae;return Ue&&(t.right=t.left+Ae),t.left<10?W.scrollLeft=0:t.left<De?W.scrollLeft=Math.max(0,t.left+pe-(Ue?0:10)):t.right>Ae+De-3&&(W.scrollLeft=t.right+(Ue?0:10)-Ae),W}function wa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Ji(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function En(e,t,i){(t!=null||i!=null)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);Eo(e,i,r,t.margin)}}function Eo(e,t,i,r){var n=Ta(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});En(e,n.scrollLeft,n.scrollTop)}function xn(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;R||Aa(e,{top:t}),xo(e,t,!0),R&&Aa(e),Tn(e,100)}function xo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Fi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,_o(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Sn(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ha(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ii(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Ui=function(e,t,i){this.cm=i;var r=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Pe(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Pe(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,K&&j<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ui.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var w=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+w)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},Ui.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ui.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ui.prototype.zeroWidthHack=function(){var e=l&&!T?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new q,this.disableVert=new q},Ui.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),w=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);w!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},Ui.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Cn=function(){};Cn.prototype.update=function(){return{bottom:0,right:0}},Cn.prototype.setScrollLeft=function(){},Cn.prototype.setScrollTop=function(){},Cn.prototype.clear=function(){};function Qi(e,t){t||(t=Sn(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),So(e,Sn(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var Co={native:Ui,null:Cn};function To(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&p(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Co[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Pe(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?Fi(e,t):xn(e,t)},e),e.display.scrollbars.addClass&&U(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function ji(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qs},Gr(e.curOp)}function Wi(e){var t=e.curOp;t&&ks(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 w=0;w<t.length;w++)il(t[w]);for(var W=0;W<t.length;W++)nl(t[W])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&jn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&_a(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=Sn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ii(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Mi(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==M();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Qi(t,e.barMeasure),e.updatedDisplay&&Da(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&xo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var w=e.maybeHiddenMarkers,W=e.maybeUnhiddenMarkers;if(w)for(var Y=0;Y<w.length;++Y)w[Y].lines.length||Fe(w[Y],"hide");if(W)for(var J=0;J<W.length;++J)W[J].lines.length&&Fe(W[J],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Fe(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Pr(e,t){if(e.curOp)return t();ji(e);try{return t()}finally{Wi(e)}}function or(e,t){return function(){if(e.curOp)return t.apply(e,arguments);ji(e);try{return t.apply(e,arguments)}finally{Wi(e)}}}function Sr(e){return function(){if(this.curOp)return e.apply(this,arguments);ji(this);try{return e.apply(this,arguments)}finally{Wi(this)}}}function sr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);ji(t);try{return e.apply(this,arguments)}finally{Wi(t)}}}function Tn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,O(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=et(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(w){if(r.line>=e.display.viewFrom){var W=w.styles,Y=w.text.length>e.options.maxHighlightLength?Br(t.mode,r.state):null,J=ge(e,w,r,!0);Y&&(r.state=Y),w.styles=J.styles;var ee=w.styleClasses,he=J.classes;he?w.styleClasses=he:ee&&(w.styleClasses=null);for(var pe=!W||W.length!=w.styles.length||ee!=he&&(!ee||!he||ee.bgClass!=he.bgClass||ee.textClass!=he.textClass),De=0;!pe&&De<W.length;++De)pe=W[De]!=w.styles[De];pe&&n.push(r.line),w.stateAfter=r.save(),r.nextLine()}else w.text.length<=e.options.maxHighlightLength&&ft(e,w.text,r),w.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&&Pr(e,function(){for(var w=0;w<n.length;w++)Ci(e,n[w],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Mi(e),this.force=i,this.dims=ba(e),this.events=[]};Yn.prototype.signal=function(e,t){ve(e,t)&&this.events.push(arguments)},Yn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Fe.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ii(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ii(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=M();if(!t||!S(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&S(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==M())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&S(document.body,e.anchorNode)&&S(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 _a(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ti(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Ao(e)&&(Ti(e),t.dims=ba(e));var n=r.first+r.size,w=Math.max(t.visible.from-e.options.viewportMargin,r.first),W=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<w&&w-i.viewFrom<20&&(w=Math.max(r.first,i.viewFrom)),i.viewTo>W&&i.viewTo-W<20&&(W=Math.min(n,i.viewTo)),nr&&(w=cn(e.doc,w),W=Si(e.doc,W));var Y=w!=i.viewFrom||W!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,w,W),i.viewOffset=$r(ct(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var J=po(e);if(!Y&&J==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var ee=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(ee),f(i.cursorDiv),f(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 wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Mi(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ha(e.display)-ca(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!_a(e,t))break;Kn(e);var n=Sn(e);bn(e),Qi(e,n),Da(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Aa(e,t){var i=new Yn(e,t);if(_a(e,i)){Kn(e),wo(e,i);var r=Sn(e);bn(e),Qi(e,r),Da(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,w=r.lineDiv,W=w.firstChild;function Y(Ue){var Ke=Ue.nextSibling;return N&&l&&e.display.currentWheelTarget==Ue?Ue.style.display="none":Ue.parentNode.removeChild(Ue),Ke}for(var J=r.view,ee=r.viewFrom,he=0;he<J.length;he++){var pe=J[he];if(!pe.hidden)if(!pe.node||pe.node.parentNode!=w){var De=Ns(e,pe,ee,i);w.insertBefore(De,W)}else{for(;W!=pe.node;)W=Y(W);var Ae=n&&t!=null&&t<=ee&&pe.lineNumber;pe.changes&&(oe(pe.changes,"gutter")>-1&&(Ae=!1),Ya(e,pe,ee,i)),Ae&&(f(pe.lineNumber),pe.lineNumber.appendChild(document.createTextNode(fi(e.options,ee)))),W=pe.node.nextSibling}ee+=pe.size}for(;W;)W=Y(W)}function La(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Da(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+ii(e)+"px"}function _o(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,w=r+"px",W=0;W<i.length;W++)if(!i[W].hidden){e.options.fixedGutter&&(i[W].gutter&&(i[W].gutter.style.left=w),i[W].gutterBackground&&(i[W].gutterBackground.style.left=w));var Y=i[W].alignable;if(Y)for(var J=0;J<Y.length;J++)Y[J].style.left=w}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=fi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),w=n.firstChild.offsetWidth,W=n.offsetWidth-w;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(w,r.lineGutter.offsetWidth-W)+1,r.lineNumWidth=r.lineNumInnerWidth+W,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",La(e.display),!0}return!1}function Ra(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var w=e[n],W=null;if(typeof w!="string"&&(W=w.style,w=w.className),w=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:w,style:W})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function Lo(e){var t=e.gutters,i=e.gutterSpecs;f(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],w=n.className,W=n.style,Y=t.appendChild(o("div",null,"CodeMirror-gutter "+w));W&&(Y.style.cssText=W),w=="CodeMirror-linenumbers"&&(e.lineGutter=Y,Y.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",La(e)}function wn(e){Lo(e.display),_r(e),_o(e)}function dl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=E("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=E("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var w=E("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[w],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: "+ce+"px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),K&&j<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!N&&!(R&&a)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Ra(r.gutters,r.lineNumbers),Lo(n),i.init(n)}var $n=0,jr=null;K?jr=-.53:R?jr=15:y?jr=-.7:k&&(jr=-1/3);function Do(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function hl(e){var t=Do(e);return t.x*=jr,t.y*=jr,t}function Ro(e,t){var i=Do(t),r=i.x,n=i.y,w=e.display,W=w.scroller,Y=W.scrollWidth>W.clientWidth,J=W.scrollHeight>W.clientHeight;if(!(r&&Y||n&&J))return;if(n&&l&&N){e:for(var ee=t.target,he=w.view;ee!=W;ee=ee.parentNode)for(var pe=0;pe<he.length;pe++)if(he[pe].node==ee){e.display.currentWheelTarget=ee;break e}}if(r&&!R&&!A&&jr!=null){n&&J&&xn(e,Math.max(0,W.scrollTop+n*jr)),Fi(e,Math.max(0,W.scrollLeft+r*jr)),(!n||n&&J)&&ie(t),w.wheelStartX=null;return}if(n&&jr!=null){var De=n*jr,Ae=e.doc.scrollTop,Ue=Ae+w.wrapper.clientHeight;De<0?Ae=Math.max(0,Ae+De-50):Ue=Math.min(e.doc.height,Ue+De+50),Aa(e,{top:Ae,bottom:Ue})}$n<20&&(w.wheelStartX==null?(w.wheelStartX=W.scrollLeft,w.wheelStartY=W.scrollTop,w.wheelDX=r,w.wheelDY=n,setTimeout(function(){if(w.wheelStartX==null)return;var Ke=W.scrollLeft-w.wheelStartX,qe=W.scrollTop-w.wheelStartY,it=qe&&w.wheelDY&&qe/w.wheelDY||Ke&&w.wheelDX&&Ke/w.wheelDX;if(w.wheelStartX=w.wheelStartY=null,!it)return;jr=(jr*$n+it)/($n+1),++$n},200)):(w.wheelDX+=r,w.wheelDY+=n))}var Wr=function(e,t){this.ranges=e,this.primIndex=t};Wr.prototype.primary=function(){return this.ranges[this.primIndex]},Wr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var i=this.ranges[t],r=e.ranges[t];if(!pi(i.anchor,r.anchor)||!pi(i.head,r.head))return!1}return!0},Wr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new jt(mi(this.ranges[t].anchor),mi(this.ranges[t].head));return new Wr(e,this.primIndex)},Wr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Wr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(St(t,r.from())>=0&&St(e,r.to())<=0)return i}return-1};var jt=function(e,t){this.anchor=e,this.head=t};jt.prototype.from=function(){return vi(this.anchor,this.head)},jt.prototype.to=function(){return gi(this.anchor,this.head)},jt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Jr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(De,Ae){return St(De.from(),Ae.from())}),i=oe(t,n);for(var w=1;w<t.length;w++){var W=t[w],Y=t[w-1],J=St(Y.to(),W.from());if(r&&!W.empty()?J>0:J>=0){var ee=vi(Y.from(),W.from()),he=gi(Y.to(),W.to()),pe=Y.empty()?W.from()==W.head:Y.from()==Y.head;w<=i&&--i,t.splice(--w,2,new jt(pe?he:ee,pe?ee:he))}}return new Wr(t,i)}function wi(e,t){return new Wr([new jt(e,t||e)],0)}function _i(e){return e.text?$e(e.from.line+e.text.length-1,te(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function ko(e,t){if(St(e,t.from)<0)return e;if(St(e,t.to)<=0)return _i(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+=_i(t).ch-t.to.ch),$e(i,r)}function ka(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new jt(ko(n.anchor,t),ko(n.head,t)))}return Jr(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?$e(i.line,e.ch-t.ch+i.ch):$e(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=$e(e.first,0),w=n,W=0;W<t.length;W++){var Y=t[W],J=Oo(Y.from,n,w),ee=Oo(_i(Y),n,w);if(n=Y.to,w=ee,i=="around"){var he=e.sel.ranges[W],pe=St(he.head,he.anchor)<0;r[W]=new jt(pe?ee:J,pe?J:ee)}else r[W]=new jt(J,J)}return new Wr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=Nr(e.options,e.doc.modeOption),_n(e)}function _n(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&&_r(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&te(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(st){return i?i[st]:null}function w(st,nt,dt){ua(st,nt,dt,r),cr(st,"change",st,t)}function W(st,nt){for(var dt=[],xt=st;xt<nt;++xt)dt.push(new Pi(ee[xt],n(xt),r));return dt}var Y=t.from,J=t.to,ee=t.text,he=ct(e,Y.line),pe=ct(e,J.line),De=te(ee),Ae=n(ee.length-1),Ue=J.line-Y.line;if(t.full)e.insert(0,W(0,ee.length)),e.remove(ee.length,e.size-ee.length);else if(Po(e,t)){var Ke=W(0,ee.length-1);w(pe,pe.text,Ae),Ue&&e.remove(Y.line,Ue),Ke.length&&e.insert(Y.line,Ke)}else if(he==pe)if(ee.length==1)w(he,he.text.slice(0,Y.ch)+De+he.text.slice(J.ch),Ae);else{var qe=W(1,ee.length-1);qe.push(new Pi(De+he.text.slice(J.ch),Ae,r)),w(he,he.text.slice(0,Y.ch)+ee[0],n(0)),e.insert(Y.line+1,qe)}else if(ee.length==1)w(he,he.text.slice(0,Y.ch)+ee[0]+pe.text.slice(J.ch),n(0)),e.remove(Y.line+1,Ue);else{w(he,he.text.slice(0,Y.ch)+ee[0],n(0)),w(pe,De+pe.text.slice(J.ch),Ae);var it=W(1,ee.length-1);Ue>1&&e.remove(Y.line+1,Ue-1),e.insert(Y.line+1,it)}cr(e,"change",e,t)}function Ai(e,t,i){function r(n,w,W){if(n.linked)for(var Y=0;Y<n.linked.length;++Y){var J=n.linked[Y];if(J.doc==w)continue;var ee=W&&J.sharedHist;if(i&&!ee)continue;t(J.doc,ee),r(J.doc,n,ee)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,xa(e),Oa(e),Io(e),e.options.lineWrapping||jn(e),e.options.mode=t.modeOption,_r(e)}function Io(e){(e.doc.direction=="rtl"?U:p)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Pr(e,function(){Io(e),_r(e)})}function Zn(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var i={from:mi(t.from),to:_i(t),text:Hr(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Ai(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=te(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),te(e.done);if(e.done.length&&!te(e.done).ranges)return te(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),te(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var w=+new Date,W,Y;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>w-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(W=pl(n,n.lastOp==r)))Y=te(W.changes),St(t.from,t.to)==0&&St(t.from,Y.to)==0?Y.to=_i(t):W.changes.push(Ma(e,t));else{var J=te(n.done);for((!J||!J.ranges)&&Jn(e.sel,n.done),W={changes:[Ma(e,t)],generation:n.generation},n.done.push(W);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=w,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,Y||Fe(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,w=r&&r.origin;i==n.lastSelOp||w&&n.lastSelOrigin==w&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==w||ml(e,w,te(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=w,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Jn(e,t){var i=te(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],w=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(W){W.markedSpans&&((n||(n=t["spans_"+e.id]={}))[w]=W.markedSpans),++w})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Yr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var w=i[n],W=r[n];if(w&&W){e:for(var Y=0;Y<W.length;++Y){for(var J=W[Y],ee=0;ee<w.length;++ee)if(w[ee].marker==J.marker)continue e;w.push(J)}}else W&&(i[n]=W)}return i}function qi(e,t,i){for(var r=[],n=0;n<e.length;++n){var w=e[n];if(w.ranges){r.push(i?Wr.prototype.deepCopy.call(w):w);continue}var W=w.changes,Y=[];r.push({changes:Y});for(var J=0;J<W.length;++J){var ee=W[J],he=void 0;if(Y.push({from:ee.from,to:ee.to,text:ee.text}),t)for(var pe in ee)(he=pe.match(/^spans_(\d+)$/))&&(oe(t,Number(he[1]))>-1&&(te(Y)[pe]=ee[pe],delete ee[pe]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var w=St(t,n)<0;w!=St(i,n)<0?(n=t,t=i):w!=St(t,i)<0&&(t=i)}return new jt(n,t)}else return new jt(i||t,t)}function Qn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),br(e,new Wr([Ia(e.sel.primary(),t,i,n)],0),r)}function jo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),w=0;w<e.sel.ranges.length;w++)r[w]=Ia(e.sel.ranges[w],t[w],null,n);var W=Jr(e.cm,r,e.sel.primIndex);br(e,W,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,br(e,Jr(e.cm,n,e.sel.primIndex),r)}function Wo(e,t,i,r){br(e,wi(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var w=0;w<n.length;w++)this.ranges[w]=new jt(s(e,n[w].anchor),s(e,n[w].head))},origin:i&&i.origin};return Fe(e,"beforeSelectionChange",e,r),e.cm&&Fe(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Jr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=te(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):br(e,t,i)}function br(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(ve(e,"beforeSelectionChange")||e.cm&&ve(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(St(t.primary().head,e.sel.primary().head)<0?-1:1);zo(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Ji(e.cm)}function zo(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,Ce(e.cm)),cr(e,"cursorActivity",e)}function Go(e){zo(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,w=0;w<t.ranges.length;w++){var W=t.ranges[w],Y=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[w],J=ea(e,W.anchor,Y&&Y.anchor,i,r),ee=ea(e,W.head,Y&&Y.head,i,r);(n||J!=W.anchor||ee!=W.head)&&(n||(n=t.ranges.slice(0,w)),n[w]=new jt(J,ee))}return n?Jr(e.cm,n,t.primIndex):t}function en(e,t,i,r,n){var w=ct(e,t.line);if(w.markedSpans)for(var W=0;W<w.markedSpans.length;++W){var Y=w.markedSpans[W],J=Y.marker,ee="selectLeft"in J?!J.selectLeft:J.inclusiveLeft,he="selectRight"in J?!J.selectRight:J.inclusiveRight;if((Y.from==null||(ee?Y.from<=t.ch:Y.from<t.ch))&&(Y.to==null||(he?Y.to>=t.ch:Y.to>t.ch))){if(n&&(Fe(J,"beforeCursorEnter"),J.explicitlyCleared))if(w.markedSpans){--W;continue}else break;if(!J.atomic)continue;if(i){var pe=J.find(r<0?1:-1),De=void 0;if((r<0?he:ee)&&(pe=Vo(e,pe,-r,pe&&pe.line==t.line?w:null)),pe&&pe.line==t.line&&(De=St(pe,i))&&(r<0?De<0:De>0))return en(e,pe,t,r,n)}var Ae=J.find(r<0?-1:1);return(r<0?ee:he)&&(Ae=Vo(e,Ae,r,Ae.line==t.line?w:null)),Ae?en(e,Ae,t,r,n):null}}return t}function ea(e,t,i,r,n){var w=r||1,W=en(e,t,i,w,n)||!n&&en(e,t,i,w,!0)||en(e,t,i,-w,n)||!n&&en(e,t,i,-w,!0);return W||(e.cantEdit=!0,$e(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,$e(t.line-1)):null:i>0&&t.ch==(r||ct(e,t.line)).text.length?t.line<e.first+e.size-1?$e(t.line+1,0):null:new $e(t.line,t.ch+i)}function Xo(e){e.setSelection($e(e.firstLine(),0),$e(e.lastLine()),Ee)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,w,W,Y){n&&(r.from=s(e,n)),w&&(r.to=s(e,w)),W&&(r.text=W),Y!==void 0&&(r.origin=Y)}),Fe(e,"beforeChange",e,r),e.cm&&Fe(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function tn(e,t,i){if(e.cm){if(!e.cm.curOp)return or(e.cm,tn)(e,t,i);if(e.cm.state.suppressEdits)return}if((ve(e,"beforeChange")||e.cm&&ve(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=ki&&!i&&bi(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&St(t.from,t.to)==0)return;var i=ka(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),An(e,t,i,Yr(e,t));var r=[];Ai(e,function(n,w){!w&&oe(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),An(n,t,null,Yr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,w,W=e.sel,Y=t=="undo"?n.done:n.undone,J=t=="undo"?n.undone:n.done,ee=0;ee<Y.length&&!(w=Y[ee],i?w.ranges&&!w.equals(e.sel):!w.ranges);ee++);if(ee==Y.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(w=Y.pop(),w.ranges){if(Jn(w,J),i&&!w.equals(e.sel)){br(e,w,{clearRedo:!1});return}W=w}else if(r){Y.push(w);return}else break;var he=[];Jn(W,J),J.push({changes:he,generation:n.generation}),n.generation=w.generation||++n.maxGeneration;for(var pe=ve(e,"beforeChange")||e.cm&&ve(e.cm,"beforeChange"),De=function(Ke){var qe=w.changes[Ke];if(qe.origin=t,pe&&!Yo(e,qe,!1))return Y.length=0,{};he.push(Ma(e,qe));var it=Ke?ka(e,qe):te(Y);An(e,qe,it,Uo(e,qe)),!Ke&&e.cm&&e.cm.scrollIntoView({from:qe.from,to:_i(qe)});var st=[];Ai(e,function(nt,dt){!dt&&oe(st,nt.history)==-1&&(qo(nt.history,qe),st.push(nt.history)),An(nt,qe,null,Uo(nt,qe))})},Ae=w.changes.length-1;Ae>=0;--Ae){var Ue=De(Ae);if(Ue)return Ue.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Wr(ue(e.sel.ranges,function(n){return new jt($e(n.anchor.line+t,n.anchor.ch),$e(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){_r(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ci(e.cm,r,"gutter")}}function An(e,t,i,r){if(e.cm&&!e.cm.curOp)return or(e.cm,An)(e,t,i,r);if(t.to.line<e.first){Zo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:$e(e.first,0),to:$e(t.to.line+n,t.to.ch),text:[te(t.text)],origin:t.origin}}var w=e.lastLine();t.to.line>w&&(t={from:t.from,to:$e(w,ct(e,w).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Hr(e,t.from,t.to),i||(i=ka(e,t)),e.cm?El(e.cm,t,r):Pa(e,t,r),qn(e,i,Ee),e.cantEdit&&ea(e,$e(e.firstLine(),0))&&(e.cantEdit=!1)}function El(e,t,i){var r=e.doc,n=e.display,w=t.from,W=t.to,Y=!1,J=w.line;e.options.lineWrapping||(J=Lt(xr(ct(r,w.line))),r.iter(J,W.line+1,function(Ae){if(Ae==n.maxLine)return Y=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Ce(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(J,w.line+t.text.length,function(Ae){var Ue=pn(Ae);Ue>n.maxLineLength&&(n.maxLine=Ae,n.maxLineLength=Ue,n.maxLineChanged=!0,Y=!1)}),Y&&(e.curOp.updateMaxLine=!0)),Xr(r,w.line),Tn(e,400);var ee=t.text.length-(W.line-w.line)-1;t.full?_r(e):w.line==W.line&&t.text.length==1&&!Po(e.doc,t)?Ci(e,w.line,"text"):_r(e,w.line,W.line+1,ee);var he=ve(e,"changes"),pe=ve(e,"change");if(pe||he){var De={from:w,to:W,text:t.text,removed:t.removed,origin:t.origin};pe&&cr(e,"change",e,De),he&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(De)}e.display.selForContextMenu=null}function rn(e,t,i,r,n){var w;r||(r=i),St(r,i)<0&&(w=[r,i],i=w[0],r=w[1]),typeof t=="string"&&(t=e.splitLines(t)),tn(e,{from:i,to:r,text:t,origin:n})}function Jo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Qo(e,t,i,r){for(var n=0;n<e.length;++n){var w=e[n],W=!0;if(w.ranges){w.copied||(w=e[n]=w.deepCopy(),w.copied=!0);for(var Y=0;Y<w.ranges.length;Y++)Jo(w.ranges[Y].anchor,t,i,r),Jo(w.ranges[Y].head,t,i,r);continue}for(var J=0;J<w.changes.length;++J){var ee=w.changes[J];if(i<ee.from.line)ee.from=$e(ee.from.line+r,ee.from.ch),ee.to=$e(ee.to.line+r,ee.to.ch);else if(t<=ee.to.line){W=!1;break}}W||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function Ln(e,t,i,r){var n=t,w=t;return typeof t=="number"?w=ct(e,z(e,t)):n=Lt(t),n==null?null:(r(w,n)&&e.cm&&Ci(e.cm,n,i),w)}function Dn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}Dn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,mt(n),cr(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function Rn(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}Rn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var w=Math.min(t,n-e),W=r.height;if(r.removeInner(e,w),this.height-=W-r.height,n==w&&(this.children.splice(i--,1),r.parent=null),(t-=w)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Dn))){var Y=[];this.collapse(Y),this.children=[new Dn(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],w=n.chunkSize();if(e<=w){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var W=n.lines.length%25+25,Y=W;Y<n.lines.length;){var J=new Dn(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,W),this.maybeSpill()}break}e-=w}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Rn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=oe(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Rn(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],w=n.chunkSize();if(e<w){var W=Math.min(t,w-e);if(n.iterN(e,W,i))return!0;if((t-=W)==0)break;e=0}else e-=w}}};var kn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};kn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=Lt(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 w=vn(this);mr(i,Math.max(0,i.height-w)),e&&(Pr(e,function(){es(e,i,-w),Ci(e,r,"widget")}),cr(e,"lineWidgetCleared",e,this,r))},kn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=vn(this)-t;if(!n)return;ri(this.doc,r)||mr(r,r.height+n),i&&Pr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),cr(i,"lineWidgetChanged",i,e,Lt(r))})},be(kn);function es(e,t,i){$r(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function xl(e,t,i,r){var n=new kn(e,i,r),w=e.cm;return w&&n.noHScroll&&(w.display.alignWidgets=!0),Ln(e,t,"widget",function(W){var Y=W.widgets||(W.widgets=[]);if(n.insertAt==null?Y.push(n):Y.splice(Math.min(Y.length-1,Math.max(0,n.insertAt)),0,n),n.line=W,w&&!ri(e,W)){var J=$r(W)<e.scrollTop;mr(W,W.height+vn(n)),J&&wa(w,n.height),w.curOp.forceUpdate=!0}return!0}),w&&cr(w,"lineWidgetAdded",w,n,typeof t=="number"?t:Lt(t)),n}var ts=0,Li=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};Li.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&ji(e),ve(this,"clear")){var i=this.find();i&&cr(this,"clear",i.from,i.to)}for(var r=null,n=null,w=0;w<this.lines.length;++w){var W=this.lines[w],Y=Or(W.markedSpans,this);e&&!this.collapsed?Ci(e,Lt(W),"text"):e&&(Y.to!=null&&(n=Lt(W)),Y.from!=null&&(r=Lt(W))),W.markedSpans=Oi(W.markedSpans,Y),Y.from==null&&this.collapsed&&!ri(this.doc,W)&&e&&mr(W,Yi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var J=0;J<this.lines.length;++J){var ee=xr(this.lines[J]),he=pn(ee);he>e.display.maxLineLength&&(e.display.maxLine=ee,e.display.maxLineLength=he,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&_r(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Go(e.doc)),e&&cr(e,"markerCleared",e,this,r,n),t&&Wi(e),this.parent&&this.parent.clear()},Li.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var w=this.lines[n],W=Or(w.markedSpans,this);if(W.from!=null&&(i=$e(t?w:Lt(w),W.from),e==-1))return i;if(W.to!=null&&(r=$e(t?w:Lt(w),W.to),e==1))return r}return i&&{from:i,to:r}},Li.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Pr(r,function(){var n=t.line,w=Lt(t.line),W=fa(r,w);if(W&&(no(W),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!ri(i.doc,n)&&i.height!=null){var Y=i.height;i.height=null;var J=vn(i)-Y;J&&mr(n,n.height+J)}cr(r,"markerChanged",r,e)})},Li.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||oe(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Li.prototype.detachLine=function(e){if(this.lines.splice(oe(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},be(Li);function nn(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return or(e.cm,nn)(e,t,i,r,n);var w=new Li(e,n),W=St(t,i);if(r&&I(r,w,!1),W>0||W==0&&w.clearWhenEmpty!==!1)return w;if(w.replacedWith&&(w.collapsed=!0,w.widgetNode=E("span",[w.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||w.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(w.widgetNode.insertLeft=!0)),w.collapsed){if(ar(e,t.line,t,i,w)||t.line!=i.line&&ar(e,i.line,t,i,w))throw new Error("Inserting collapsed marker partially overlapping an existing one");oi()}w.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var Y=t.line,J=e.cm,ee;if(e.iter(Y,i.line+1,function(pe){J&&w.collapsed&&!J.options.lineWrapping&&xr(pe)==J.display.maxLine&&(ee=!0),w.collapsed&&Y!=t.line&&mr(pe,0),yi(pe,new si(w,Y==t.line?t.ch:null,Y==i.line?i.ch:null)),++Y}),w.collapsed&&e.iter(t.line,i.line+1,function(pe){ri(e,pe)&&mr(pe,0)}),w.clearOnEnter&&Pe(w,"beforeCursorEnter",function(){return w.clear()}),w.readOnly&&(Ur(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),w.collapsed&&(w.id=++ts,w.atomic=!0),J){if(ee&&(J.curOp.updateMaxLine=!0),w.collapsed)_r(J,t.line,i.line+1);else if(w.className||w.startStyle||w.endStyle||w.css||w.attributes||w.title)for(var he=t.line;he<=i.line;he++)Ci(J,he,"text");w.atomic&&Go(J.doc),cr(J,"markerAdded",J,w)}return w}var On=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};On.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();cr(this,"clear")},On.prototype.find=function(e,t){return this.primary.find(e,t)},be(On);function Sl(e,t,i,r,n){r=I(r),r.shared=!1;var w=[nn(e,t,i,r,n)],W=w[0],Y=r.widgetNode;return Ai(e,function(J){Y&&(r.widgetNode=Y.cloneNode(!0)),w.push(nn(J,s(J,t),s(J,i),r,n));for(var ee=0;ee<J.linked.length;++ee)if(J.linked[ee].isParent)return;W=te(w)}),new On(w,W)}function rs(e){return e.findMarks($e(e.first,0),e.clipPos($e(e.lastLine())),function(t){return t.parent})}function Cl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),w=e.clipPos(n.from),W=e.clipPos(n.to);if(St(w,W)){var Y=nn(e,w,W,r.primary,r.primary.type);r.markers.push(Y),Y.parent=r}}}function Tl(e){for(var t=function(r){var n=e[r],w=[n.primary.doc];Ai(n.primary.doc,function(J){return w.push(J)});for(var W=0;W<n.markers.length;W++){var Y=n.markers[W];oe(w,Y.doc)==-1&&(Y.parent=null,n.markers.splice(W--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Ar=function(e,t,i,r,n){if(!(this instanceof Ar))return new Ar(e,t,i,r,n);i==null&&(i=0),Rn.call(this,[new Dn([new Pi("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var w=$e(i,0);this.sel=wi(w),this.history=new Zn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:w,to:w,text:e}),br(this,wi(w),Ee)};Ar.prototype=Re(Rn.prototype,{constructor:Ar,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=ei(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:sr(function(e){var t=$e(this.first,0),i=this.first+this.size-1;tn(this,{from:t,to:$e(i,ct(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&En(this.cm,0,0),br(this,wi(t),Ee)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,rn(this,e,t,i,r)},getRange:function(e,t,i){var r=Hr(this,s(this,e),s(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Vr(this,e))return ct(this,e)},getLineNumber:function(e){return Lt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ct(this,e)),xr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return s(this,e)},getCursor:function(e){var t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:sr(function(e,t,i){Wo(this,s(this,typeof e=="number"?$e(e,t||0):e),null,i)}),setSelection:sr(function(e,t,i){Wo(this,s(this,e),s(this,t||e),i)}),extendSelection:sr(function(e,t,i){Qn(this,s(this,e),t&&s(this,t),i)}),extendSelections:sr(function(e,t){jo(this,B(this,e),t)}),extendSelectionsBy:sr(function(e,t){var i=ue(this.sel.ranges,e);jo(this,B(this,i),t)}),setSelections:sr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new jt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),br(this,Jr(this.cm,r,t),i)}),addSelection:sr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new jt(s(this,e),s(this,t||e))),br(this,Jr(this.cm,r,r.length-1),i)}),getSelection:function(e){for(var t=this.sel.ranges,i,r=0;r<t.length;r++){var n=Hr(this,t[r].from(),t[r].to());i=i?i.concat(n):n}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],i=this.sel.ranges,r=0;r<i.length;r++){var n=Hr(this,i[r].from(),i[r].to());e!==!1&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){for(var r=[],n=0;n<this.sel.ranges.length;n++)r[n]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:sr(function(e,t,i){for(var r=[],n=this.sel,w=0;w<n.ranges.length;w++){var W=n.ranges[w];r[w]={from:W.from(),to:W.to(),text:this.splitLines(e[w]),origin:i}}for(var Y=t&&t!="end"&&cl(this,r,t),J=r.length-1;J>=0;J--)tn(this,r[J]);Y?Ho(this,Y):this.cm&&Ji(this.cm)}),undo:sr(function(){ta(this,"undo")}),redo:sr(function(){ta(this,"redo")}),undoSelection:sr(function(){ta(this,"undo",!0)}),redoSelection:sr(function(){ta(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Zn(this.history.maxGeneration),Ai(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:qi(this.history.done),undone:qi(this.history.undone)}},setHistory:function(e){var t=this.history=new Zn(this.history.maxGeneration);t.done=qi(e.done.slice(0),null,!0),t.undone=qi(e.undone.slice(0),null,!0)},setGutterMarker:sr(function(e,t,i){return Ln(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&He(n)&&(r.gutterMarkers=null),!0})}),clearGutter:sr(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(!Vr(this,e))return null;if(t=e,e=ct(this,e),!e)return null}else if(t=Lt(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:sr(function(e,t,i){return 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(x(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:sr(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",w=r[n];if(w)if(i==null)r[n]=null;else{var W=w.match(x(i));if(!W)return!1;var Y=W.index+W[0].length;r[n]=w.slice(0,W.index)+(!W.index||Y==w.length?"":" ")+w.slice(Y)||null}else return!1;return!0})}),addLineWidget:sr(function(e,t,i){return xl(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=ct(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(w){var W=w.markedSpans;if(W)for(var Y=0;Y<W.length;Y++){var J=W[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 w=n.text.length+r;if(w>e)return t=e,!0;e-=w,++i}),s(this,$e(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 Ar(ei(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new Ar(ei(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Cl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Vt&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Tl(rs(this));break}if(e.history==this.history){var r=[e.id];Ai(e,function(n){return r.push(n.id)},!0),e.history=new Zn(null),e.history.done=qi(this.history.done,r),e.history.undone=qi(this.history.undone,r)}},iterLinkedDocs:function(e){Ai(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Ct(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:sr(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&fl(this.cm)})}),Ar.prototype.eachLine=Ar.prototype.iter;var is=0;function _l(e){var t=this;if(ns(t),Xe(t,e)||ui(t.display,e))return;ie(e),K&&(is=+new Date);var i=Ni(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,w=Array(n),W=0,Y=function(){++W==n&&or(t,function(){i=s(t.doc,i);var Ae={from:i,to:i,text:t.doc.splitLines(w.filter(function(Ue){return Ue!=null}).join(t.doc.lineSeparator())),origin:"paste"};tn(t.doc,Ae),Ho(t.doc,wi(s(t.doc,i),s(t.doc,_i(Ae))))})()},J=function(Ae,Ue){if(t.options.allowDropFileTypes&&oe(t.options.allowDropFileTypes,Ae.type)==-1){Y();return}var Ke=new FileReader;Ke.onerror=function(){return Y()},Ke.onload=function(){var qe=Ke.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(qe)){Y();return}w[Ue]=qe,Y()},Ke.readAsText(Ae)},ee=0;ee<r.length;ee++)J(r[ee],ee);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var he=e.dataTransfer.getData("Text");if(he){var pe;if(t.state.draggingText&&!t.state.draggingText.copy&&(pe=t.listSelections()),qn(t.doc,wi(i,i)),pe)for(var De=0;De<pe.length;++De)rn(t.doc,"",pe[De].anchor,pe[De].head,"drag");t.replaceSelection(he,"around","paste"),t.display.input.focus()}}catch(Ae){}}}function Al(e,t){if(K&&(!e.state.draggingText||+new Date-is<100)){me(t);return}if(Xe(e,t)||ui(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!k){var i=o("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",A&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),A&&i.parentNode.removeChild(i)}}function Ll(e,t){var i=Ni(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),h(e.display.dragCursor,r)}function ns(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var w=0;w<i.length;w++)e(i[w])})}var os=!1;function Dl(){if(os)return;Rl(),os=!0}function Rl(){var e;Pe(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(kl)},100))}),Pe(window,"blur",function(){return as(Zi)})}function kl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Di={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Pn=0;Pn<10;Pn++)Di[Pn+48]=Di[Pn+96]=String(Pn);for(var ra=65;ra<=90;ra++)Di[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)Di[Mn+111]=Di[Mn+63235]="F"+Mn;var di={};di.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"},di.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"},di.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"},di.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"]},di.default=l?di.macDefault:di.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,w,W=0;W<t.length-1;W++){var Y=t[W];if(/^(cmd|meta|m)$/i.test(Y))w=!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),w&&(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=ue(i.split(" "),Ol),w=0;w<n.length;w++){var W=void 0,Y=void 0;w==n.length-1?(Y=n.join(" "),W=r):(Y=n.slice(0,w+1).join(" "),W="...");var J=t[Y];if(!J)t[Y]=W;else if(J!=W)throw new Error("Inconsistent bindings for "+Y)}delete e[i]}for(var ee in t)e[ee]=t[ee];return e}function an(e,t,i,r){t=ia(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return an(e,t.fallthrough,i,r);for(var w=0;w<t.fallthrough.length;w++){var W=an(e,t.fallthrough[w],i,r);if(W)return W}}}function ss(e){var t=typeof e=="string"?e:Di[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(m?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(m?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(A&&e.keyCode==34&&e.char)return!1;var i=Di[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function ia(e){return typeof e=="string"?di[e]:e}function on(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var w=t(i[n]);r.length&&St(w.from,te(r).to)<=0;){var W=r.pop();if(St(W.from,w.from)<0){w.from=W.from;break}}r.push(w)}Pr(e,function(){for(var Y=r.length-1;Y>=0;Y--)rn(e.doc,"",r[Y].from,r[Y].to,"+delete");Ji(e)})}function Ba(e,t,i){var r=Oe(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new $e(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var w=Qe(i,t.doc.direction);if(w){var W=n<0?te(w):w[0],Y=n<0==(W.level==1),J=Y?"after":"before",ee;if(W.level>0||t.doc.direction=="rtl"){var he=Xi(t,i);ee=n<0?i.text.length-1:0;var pe=ni(t,he,ee).top;ee=Ye(function(De){return ni(t,he,De).top==pe},n<0==(W.level==1)?W.from:W.to-1,ee),J=="before"&&(ee=Ba(i,ee,1))}else ee=n<0?W.to:W.from;return new $e(r,ee,J)}}return new $e(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=Qe(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var w=je(n,i.ch,i.sticky),W=n[w];if(e.doc.direction=="ltr"&&W.level%2==0&&(r>0?W.to>i.ch:W.from<i.ch))return Fa(t,i,r);var Y=function(it,st){return Ba(t,it instanceof $e?it.ch:it,st)},J,ee=function(it){return e.options.lineWrapping?(J=J||Xi(e,t),co(e,t,J,it)):{begin:0,end:t.text.length}},he=ee(i.sticky=="before"?Y(i,-1):i.ch);if(e.doc.direction=="rtl"||W.level==1){var pe=W.level==1==r<0,De=Y(i,pe?1:-1);if(De!=null&&(pe?De<=W.to&&De<=he.end:De>=W.from&&De>=he.begin)){var Ae=pe?"before":"after";return new $e(i.line,De,Ae)}}var Ue=function(it,st,nt){for(var dt=function(Gt,lr){return lr?new $e(i.line,Y(Gt,1),"before"):new $e(i.line,Gt,"after")};it>=0&&it<n.length;it+=st){var xt=n[it],vt=st>0==(xt.level!=1),_t=vt?nt.begin:Y(nt.end,-1);if(xt.from<=_t&&_t<xt.to)return dt(_t,vt);if(_t=vt?xt.from:Y(xt.to,-1),nt.begin<=_t&&_t<nt.end)return dt(_t,vt)}},Ke=Ue(w+r,r,he);if(Ke)return Ke;var qe=r>0?he.end:Y(he.begin,-1);return qe!=null&&!(r>0&&qe==t.text.length)&&(Ke=Ue(r>0?0:n.length-1,r,ee(qe)),Ke)?Ke:null}var In={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ee)},killLine:function(e){return on(e,function(t){if(t.empty()){var i=ct(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:$e(t.head.line+1,0)}:{from:t.head,to:$e(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return on(e,function(t){return{from:$e(t.from().line,0),to:s(e.doc,$e(t.to().line+1,0))}})},delLineLeft:function(e){return on(e,function(t){return{from:$e(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($e(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection($e(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Te)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Te)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?hs(e,t.head):r},Te)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var w=i[n].from(),W=X(e.getLine(w.line),w.ch,r);t.push(se(r-W%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Pr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,w=ct(e.doc,n.line).text;if(w){if(n.ch==w.length&&(n=new $e(n.line,n.ch-1)),n.ch>0)n=new $e(n.line,n.ch+1),e.replaceRange(w.charAt(n.ch-1)+w.charAt(n.ch-2),$e(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var W=ct(e.doc,n.line-1).text;W&&(n=new $e(n.line,1),e.replaceRange(w.charAt(0)+e.doc.lineSeparator()+W.charAt(W.length-1),$e(n.line-1,W.length-1),n,"+transpose"))}}i.push(new jt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Pr(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 ds(e,t){var i=ct(e.doc,t),r=xr(i);return r!=i&&(t=Lt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=ct(e.doc,t),r=Vi(i);return r!=i&&(t=Lt(r)),Ua(!0,e,i,t,-1)}function hs(e,t){var i=ds(e,t.line),r=ct(e.doc,i.line),n=Qe(r,e.doc.direction);if(!n||n[0].level==0){var w=Math.max(i.ch,r.text.search(/\S/)),W=t.line==i.line&&t.ch<=w&&t.ch;return $e(i.line,W?0:w,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=In[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=Le}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 q;function Nn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&cr(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(ie(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Nn(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||Nn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):Nn(e,i,t,function(r){return na(e,r)}):!1}function Fl(e,t,i){return Nn(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var ja=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=M(),Xe(t,e))return;K&&j<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);A&&(ja=r?i:null,!r&&i==88&&!Ft&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),R&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;U(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(p(t,"CodeMirror-crosshair"),at(document,"keyup",i),at(document,"mouseover",i))}Pe(document,"keyup",i),Pe(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),Xe(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(ui(t.display,e)||Xe(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(A&&i==ja){ja=null,ie(e);return}if(A&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,i){this.time=e,this.pos=t,this.button=i};Wa.prototype.compare=function(e,t,i){return this.time+jl>e&&St(t,this.pos)==0&&i==this.button};var Bn,Fn;function Wl(e,t){var i=+new Date;return Fn&&Fn.compare(i,e,t)?(Bn=Fn=null,"triple"):Bn&&Bn.compare(i,e,t)?(Fn=new Wa(i,e,t),Bn=null,"double"):(Bn=new Wa(i,e,t),Fn=null,"single")}function vs(e){var t=this,i=t.display;if(Xe(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ui(i,e)){N||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=Ni(t,e),n=Ie(e),w=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,w,e))return;n==1?r?Gl(t,r,w,e):Se(e)==i.scroller&&ie(e):n==2?(r&&Qn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(L?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var w="Click";return r=="double"?w="Double"+w:r=="triple"&&(w="Triple"+w),w=(t==1?"Left":t==2?"Middle":"Right")+w,Nn(e,ls(w,n),n,function(W){if(typeof W=="string"&&(W=In[W]),!W)return!1;var Y=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),Y=W(e,i)!=Le}finally{e.state.suppressEdits=!1}return Y})}function zl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var w=d?i.shiftKey&&i.metaKey:i.altKey;n.unit=w?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function Gl(e,t,i,r){K?setTimeout(O(vo,e),0):e.curOp.focus=M();var n=zl(e,i,r),w=e.doc.sel,W;e.options.dragDrop&&ze&&!e.isReadOnly()&&i=="single"&&(W=w.contains(t))>-1&&(St((W=w.ranges[W]).from(),t)<0||t.xRel>0)&&(St(W.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,w=!1,W=or(e,function(ee){N&&(n.scroller.draggable=!1),e.state.draggingText=!1,at(n.wrapper.ownerDocument,"mouseup",W),at(n.wrapper.ownerDocument,"mousemove",Y),at(n.scroller,"dragstart",J),at(n.scroller,"drop",W),w||(ie(ee),r.addNew||Qn(e.doc,i,null,null,r.extend),N&&!k||K&&j==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),Y=function(ee){w=w||Math.abs(t.clientX-ee.clientX)+Math.abs(t.clientY-ee.clientY)>=10},J=function(){return w=!0};N&&(n.scroller.draggable=!0),e.state.draggingText=W,W.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Pe(n.wrapper.ownerDocument,"mouseup",W),Pe(n.wrapper.ownerDocument,"mousemove",Y),Pe(n.scroller,"dragstart",J),Pe(n.scroller,"drop",W),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new jt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new jt($e(t.line,0),s(e.doc,$e(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,w=e.doc;ie(t);var W,Y,J=w.sel,ee=J.ranges;if(r.addNew&&!r.extend?(Y=w.sel.contains(i),Y>-1?W=ee[Y]:W=new jt(i,i)):(W=w.sel.primary(),Y=w.sel.primIndex),r.unit=="rectangle")r.addNew||(W=new jt(i,i)),i=Ni(e,t,!0,!0),Y=-1;else{var he=ys(e,i,r.unit);r.extend?W=Ia(W,he.anchor,he.head,r.extend):W=he}r.addNew?Y==-1?(Y=ee.length,br(w,Jr(e,ee.concat([W]),Y),{scroll:!1,origin:"*mouse"})):ee.length>1&&ee[Y].empty()&&r.unit=="char"&&!r.extend?(br(w,Jr(e,ee.slice(0,Y).concat(ee.slice(Y+1)),0),{scroll:!1,origin:"*mouse"}),J=w.sel):Na(w,Y,W,we):(Y=0,br(w,new Wr([W],0),we),J=w.sel);var pe=i;function De(nt){if(St(pe,nt)==0)return;if(pe=nt,r.unit=="rectangle"){for(var dt=[],xt=e.options.tabSize,vt=X(ct(w,i.line).text,i.ch,xt),_t=X(ct(w,nt.line).text,nt.ch,xt),Gt=Math.min(vt,_t),lr=Math.max(vt,_t),Yt=Math.min(i.line,nt.line),Mr=Math.min(e.lastLine(),Math.max(i.line,nt.line));Yt<=Mr;Yt++){var Lr=ct(w,Yt).text,er=ye(Lr,Gt,xt);Gt==lr?dt.push(new jt($e(Yt,er),$e(Yt,er))):Lr.length>er&&dt.push(new jt($e(Yt,er),$e(Yt,ye(Lr,lr,xt))))}dt.length||dt.push(new jt(i,i)),br(w,Jr(e,J.ranges.slice(0,Y).concat(dt),Y),{origin:"*mouse",scroll:!1}),e.scrollIntoView(nt)}else{var Dr=W,fr=ys(e,nt,r.unit),ir=Dr.anchor,tr;St(fr.anchor,ir)>0?(tr=fr.head,ir=vi(Dr.from(),fr.anchor)):(tr=fr.anchor,ir=gi(Dr.to(),fr.head));var $t=J.ranges.slice(0);$t[Y]=Xl(e,new jt(s(w,ir),tr)),br(w,Jr(e,$t,Y),we)}}var Ae=n.wrapper.getBoundingClientRect(),Ue=0;function Ke(nt){var dt=++Ue,xt=Ni(e,nt,!0,r.unit=="rectangle");if(!xt)return;if(St(xt,pe)!=0){e.curOp.focus=M(),De(xt);var vt=Vn(n,w);(xt.line>=vt.to||xt.line<vt.from)&&setTimeout(or(e,function(){Ue==dt&&Ke(nt)}),150)}else{var _t=nt.clientY<Ae.top?-20:nt.clientY>Ae.bottom?20:0;_t&&setTimeout(or(e,function(){if(Ue!=dt)return;n.scroller.scrollTop+=_t,Ke(nt)}),50)}}function qe(nt){e.state.selectingText=!1,Ue=Infinity,nt&&(ie(nt),n.input.focus()),at(n.wrapper.ownerDocument,"mousemove",it),at(n.wrapper.ownerDocument,"mouseup",st),w.history.lastSelOrigin=null}var it=or(e,function(nt){nt.buttons===0||!Ie(nt)?qe(nt):Ke(nt)}),st=or(e,qe);e.state.selectingText=st,Pe(n.wrapper.ownerDocument,"mousemove",it),Pe(n.wrapper.ownerDocument,"mouseup",st)}function Xl(e,t){var i=t.anchor,r=t.head,n=ct(e.doc,i.line);if(St(i,r)==0&&i.sticky==r.sticky)return t;var w=Qe(n);if(!w)return t;var W=je(w,i.ch,i.sticky),Y=w[W];if(Y.from!=i.ch&&Y.to!=i.ch)return t;var J=W+(Y.from==i.ch==(Y.level!=1)?0:1);if(J==0||J==w.length)return t;var ee;if(r.line!=i.line)ee=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var he=je(w,r.ch,r.sticky),pe=he-W||(r.ch-i.ch)*(Y.level==1?-1:1);he==J-1||he==J?ee=pe<0:ee=pe>0}var De=w[J+(ee?-1:0)],Ae=ee==(De.level==1),Ue=Ae?De.from:De.to,Ke=Ae?"after":"before";return i.ch==Ue&&i.sticky==Ke?t:new jt(new $e(i.line,Ue,Ke),r)}function bs(e,t,i,r){var n,w;if(t.touches)n=t.touches[0].clientX,w=t.touches[0].clientY;else try{n=t.clientX,w=t.clientY}catch(De){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ie(t);var W=e.display,Y=W.lineDiv.getBoundingClientRect();if(w>Y.bottom||!ve(e,i))return de(t);w-=Y.top-W.viewOffset;for(var J=0;J<e.display.gutterSpecs.length;++J){var ee=W.gutters.childNodes[J];if(ee&&ee.getBoundingClientRect().right>=n){var he=Fr(e.doc,w),pe=e.display.gutterSpecs[J];return Fe(e,i,e,he,pe.className,t),de(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function Es(e,t){if(ui(e.display,t)||Yl(e,t))return;if(Xe(e,t,"contextmenu"))return;L||e.display.input.onContextMenu(t)}function Yl(e,t){return ve(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function xs(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),yn(e)}var sn={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,w,W){e.defaults[r]=n,w&&(t[r]=W?function(Y,J,ee){ee!=sn&&w(Y,J,ee)}:w)}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,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){_n(r),yn(r),_r(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var w=[],W=r.doc.first;r.doc.iter(function(J){for(var ee=0;;){var he=J.text.indexOf(n,ee);if(he==-1)break;ee=he+n.length,w.push($e(W,he))}W++});for(var Y=w.length-1;Y>=0;Y--)rn(r.doc,n,w[Y],$e(w[Y].line,w[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,w){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),w!=sn&&r.refresh()}),i("specialCharPlaceholder",zt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",a?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!_),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){xs(r),wn(r)},!0),i("keyMap","default",function(r,n,w){var W=ia(n),Y=w!=sn&&ia(w);Y&&Y.detach&&Y.detach(r,W),W.attach&&W.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),wn(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){To(r),Qi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=Ra(r.options.gutters,n),wn(r)},!0),i("firstLineNumber",1,wn,!0),i("lineNumberFormatter",function(r){return r},wn,!0),i("showCursorWhenSelecting",!1,bn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,bn,!0),i("singleCursorHeightPerLine",!0,bn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,_n,!0),i("addModeClass",!1,_n,!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,_n,!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,w=t?Pe:at;w(e.display.scroller,"dragstart",n.start),w(e.display.scroller,"dragenter",n.enter),w(e.display.scroller,"dragover",n.over),w(e.display.scroller,"dragleave",n.leave),w(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(U(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(p(e.display.wrapper,"CodeMirror-wrap"),jn(e)),xa(e),_r(e),yn(e),setTimeout(function(){return Qi(e)},100)}function Vt(e,t){var i=this;if(!(this instanceof Vt))return new Vt(e,t);this.options=t=t?I(t):{},I(Ss,t,!1);var r=t.value;typeof r=="string"?r=new Ar(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Vt.inputStyles[t.inputStyle](this),w=this.display=new dl(e,r,n,t);w.wrapper.CodeMirror=this,xs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),To(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 q,keySeq:null,specialChars:null},t.autofocus&&!a&&w.input.focus(),K&&j<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),Dl(),ji(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!a||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ca(i)},20):Zi(this);for(var W in aa)aa.hasOwnProperty(W)&&aa[W](this,t[W],sn);Ao(this),t.finishInit&&t.finishInit(this);for(var Y=0;Y<za.length;++Y)za[Y](this);Wi(this),N&&t.lineWrapping&&getComputedStyle(w.lineDiv).textRendering=="optimizelegibility"&&(w.lineDiv.style.textRendering="auto")}Vt.defaults=Ss,Vt.optionHandlers=aa;function Ql(e){var t=e.display;Pe(t.scroller,"mousedown",or(e,vs)),K&&j<11?Pe(t.scroller,"dblclick",or(e,function(J){if(Xe(e,J))return;var ee=Ni(e,J);if(!ee||Ha(e,J)||ui(e.display,J))return;ie(J);var he=e.findWordAt(ee);Qn(e.doc,he.anchor,he.head)})):Pe(t.scroller,"dblclick",function(J){return Xe(e,J)||ie(J)}),Pe(t.scroller,"contextmenu",function(J){return Es(e,J)}),Pe(t.input.getField(),"contextmenu",function(J){t.scroller.contains(J.target)||Es(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 w(J){if(J.touches.length!=1)return!1;var ee=J.touches[0];return ee.radiusX<=1&&ee.radiusY<=1}function W(J,ee){if(ee.left==null)return!0;var he=ee.left-J.left,pe=ee.top-J.top;return he*he+pe*pe>20*20}Pe(t.scroller,"touchstart",function(J){if(!Xe(e,J)&&!w(J)&&!Ha(e,J)){t.input.ensurePolled(),clearTimeout(i);var ee=+new Date;t.activeTouch={start:ee,moved:!1,prev:ee-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 ee=t.activeTouch;if(ee&&!ui(t,J)&&ee.left!=null&&!ee.moved&&new Date-ee.start<300){var he=e.coordsChar(t.activeTouch,"page"),pe;!ee.prev||W(ee,ee.prev)?pe=new jt(he,he):!ee.prev.prev||W(ee,ee.prev.prev)?pe=e.findWordAt(he):pe=new jt($e(he.line,0),s(e.doc,$e(he.line+1,0))),e.setSelection(pe.anchor,pe.head),e.focus(),ie(J)}n()}),Pe(t.scroller,"touchcancel",n),Pe(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Fe(e,"scroll",e))}),Pe(t.scroller,"mousewheel",function(J){return Ro(e,J)}),Pe(t.scroller,"DOMMouseScroll",function(J){return Ro(e,J)}),Pe(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(J){Xe(e,J)||me(J)},over:function(J){Xe(e,J)||(Ll(e,J),me(J))},start:function(J){return Al(e,J)},drop:or(e,_l),leave:function(J){Xe(e,J)||ns(e)}};var Y=t.input.getField();Pe(Y,"keyup",function(J){return ms.call(e,J)}),Pe(Y,"keydown",or(e,ps)),Pe(Y,"keypress",or(e,gs)),Pe(Y,"focus",function(J){return Ca(e,J)}),Pe(Y,"blur",function(J){return Zi(e,J)})}var za=[];Vt.defineInitHook=function(e){return za.push(e)};function Un(e,t,i,r){var n=e.doc,w;i==null&&(i="add"),i=="smart"&&(n.mode.indent?w=et(e,t).state:i="prev");var W=e.options.tabSize,Y=ct(n,t),J=X(Y.text,null,W);Y.stateAfter&&(Y.stateAfter=null);var ee=Y.text.match(/^\s*/)[0],he;if(!r&&!/\S/.test(Y.text))he=0,i="not";else if(i=="smart"&&(he=n.mode.indent(w,Y.text.slice(ee.length),Y.text),he==Le||he>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?he=X(ct(n,t-1).text,null,W):he=0:i=="add"?he=J+e.options.indentUnit:i=="subtract"?he=J-e.options.indentUnit:typeof i=="number"&&(he=J+i),he=Math.max(0,he);var pe="",De=0;if(e.options.indentWithTabs)for(var Ae=Math.floor(he/W);Ae;--Ae)De+=W,pe+=" ";if(De<he&&(pe+=se(he-De)),pe!=ee)return rn(n,pe,$e(t,0),$e(t,ee.length),"+input"),Y.stateAfter=null,!0;for(var Ue=0;Ue<n.sel.ranges.length;Ue++){var Ke=n.sel.ranges[Ue];if(Ke.head.line==t&&Ke.head.ch<ee.length){var qe=$e(t,ee.length);Na(n,Ue,new jt(qe,qe));break}}}var Qr=null;function oa(e){Qr=e}function Ga(e,t,i,r,n){var w=e.doc;e.display.shift=!1,r||(r=w.sel);var W=+new Date-200,Y=n=="paste"||e.state.pasteIncoming>W,J=Ct(t),ee=null;if(Y&&r.ranges.length>1)if(Qr&&Qr.text.join(`
`)==t){if(r.ranges.length%Qr.text.length==0){ee=[];for(var he=0;he<Qr.text.length;he++)ee.push(w.splitLines(Qr.text[he]))}}else J.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(ee=ue(J,function(it){return[it]}));for(var pe=e.curOp.updateInput,De=r.ranges.length-1;De>=0;De--){var Ae=r.ranges[De],Ue=Ae.from(),Ke=Ae.to();Ae.empty()&&(i&&i>0?Ue=$e(Ue.line,Ue.ch-i):e.state.overwrite&&!Y?Ke=$e(Ke.line,Math.min(ct(w,Ke.line).text.length,Ke.ch+te(J).length)):Y&&Qr&&Qr.lineWise&&Qr.text.join(`
`)==J.join(`
`)&&(Ue=Ke=$e(Ue.line,0)));var qe={from:Ue,to:Ke,text:ee?ee[De%ee.length]:J,origin:n||(Y?"paste":e.state.cutIncoming>W?"cut":"+input")};tn(e.doc,qe),cr(e,"inputRead",e,qe)}t&&!Y&&Ts(e,t),Ji(e),e.curOp.updateInput<2&&(e.curOp.updateInput=pe),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Cs(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Pr(t,function(){return Ga(t,i,0,null,"paste")}),!0}function Ts(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 w=e.getModeAt(n.head),W=!1;if(w.electricChars){for(var Y=0;Y<w.electricChars.length;Y++)if(t.indexOf(w.electricChars.charAt(Y))>-1){W=Un(e,n.head.line,"smart");break}}else w.electricInput&&(w.electricInput.test(ct(e.doc,n.head.line).text.slice(0,n.head.ch))&&(W=Un(e,n.head.line,"smart")));W&&cr(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,w={anchor:$e(n,0),head:$e(n+1,0)};i.push(w),t.push(e.getRange(w.anchor,w.head))}return{text:t,ranges:i}}function _s(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return N?e.style.width="1000px":e.setAttribute("wrap","off"),b&&(e.style.border="1px solid black"),_s(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var w=this.options,W=w[r];if(w[r]==n&&r!="mode")return;w[r]=n,t.hasOwnProperty(r)&&or(this,t[r])(this,n,W),Fe(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,w=0;w<n.length;++w)if(n[w]==r||n[w].name==r)return n.splice(w,1),!0},addOverlay:Sr(function(r,n){var w=r.token?r:e.getMode(this.options,r);if(w.startState)throw new Error("Overlays may not be stateful.");ne(this.state.overlays,{mode:w,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(W){return W.priority}),this.state.modeGen++,_r(this)}),removeOverlay:Sr(function(r){for(var n=this.state.overlays,w=0;w<n.length;++w){var W=n[w].modeSpec;if(W==r||typeof r=="string"&&W.name==r){n.splice(w,1),this.state.modeGen++,_r(this);return}}}),indentLine:Sr(function(r,n,w){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Vr(this.doc,r)&&Un(this,r,n,w)}),indentSelection:Sr(function(r){for(var n=this.doc.sel.ranges,w=-1,W=0;W<n.length;W++){var Y=n[W];if(Y.empty())Y.head.line>w&&(Un(this,Y.head.line,r,!0),w=Y.head.line,W==this.doc.sel.primIndex&&Ji(this));else{var J=Y.from(),ee=Y.to(),he=Math.max(w,J.line);w=Math.min(this.lastLine(),ee.line-(ee.ch?0:1))+1;for(var pe=he;pe<w;++pe)Un(this,pe,r);var De=this.doc.sel.ranges;J.ch==0&&n.length==De.length&&De[W].from().ch>0&&Na(this.doc,W,new jt(J,De[W].to()),Ee)}}}),getTokenAt:function(r,n){return Kt(this,r,n)},getLineTokens:function(r,n){return Kt(this,$e(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=We(this,ct(this.doc,r.line)),w=0,W=(n.length-1)/2,Y=r.ch,J;if(Y==0)J=n[2];else for(;;){var ee=w+W>>1;if((ee?n[ee*2-1]:0)>=Y)W=ee;else if(n[ee*2+1]<Y)w=ee+1;else{J=n[ee*2+2];break}}var he=J?J.indexOf("overlay "):-1;return he<0?J:he==0?null:J.slice(0,he-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var w=[];if(!i.hasOwnProperty(n))return w;var W=i[n],Y=this.getModeAt(r);if(typeof Y[n]=="string")W[Y[n]]&&w.push(W[Y[n]]);else if(Y[n])for(var J=0;J<Y[n].length;J++){var ee=W[Y[n][J]];ee&&w.push(ee)}else Y.helperType&&W[Y.helperType]?w.push(W[Y.helperType]):W[Y.name]&&w.push(W[Y.name]);for(var he=0;he<W._global.length;he++){var pe=W._global[he];pe.pred(Y,this)&&oe(w,pe.val)==-1&&w.push(pe.val)}return w},getStateAfter:function(r,n){var w=this.doc;return r=z(w,r==null?w.first+w.size-1:r),et(this,r+1,n).state},cursorCoords:function(r,n){var w,W=this.doc.sel.primary();return r==null?w=W.head:typeof r=="object"?w=s(this.doc,r):w=r?W.from():W.to(),Zr(this,w,n||"page")},charCoords:function(r,n){return ma(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,Fr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,w){var W=!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,W=!0),Y=ct(this.doc,r)}else Y=r;return Hn(this,Y,{top:0,left:0},n||"page",w||W).top+(W?this.doc.height-$r(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,w,W,Y){var J=this.display;r=Zr(this,s(this.doc,r));var ee=r.bottom,he=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),J.sizer.appendChild(n),W=="over")ee=r.top;else if(W=="above"||W=="near"){var pe=Math.max(J.wrapper.clientHeight,this.doc.height),De=Math.max(J.sizer.clientWidth,J.lineSpace.clientWidth);(W=="above"||r.bottom+n.offsetHeight>pe)&&r.top>n.offsetHeight?ee=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=pe&&(ee=r.bottom),he+n.offsetWidth>De&&(he=De-n.offsetWidth)}n.style.top=ee+"px",n.style.left=n.style.right="",Y=="right"?(he=J.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(Y=="left"?he=0:Y=="middle"&&(he=(J.sizer.clientWidth-n.offsetWidth)/2),n.style.left=he+"px"),w&&Zs(this,{left:he,top:ee,right:he+n.offsetWidth,bottom:ee+n.offsetHeight})},triggerOnKeyDown:Sr(ps),triggerOnKeyPress:Sr(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Sr(vs),execCommand:function(r){if(In.hasOwnProperty(r))return In[r].call(null,this)},triggerElectric:Sr(function(r){Ts(this,r)}),findPosH:function(r,n,w,W){var Y=1;n<0&&(Y=-1,n=-n);for(var J=s(this.doc,r),ee=0;ee<n&&!(J=Ka(this.doc,J,Y,w,W),J.hitSide);++ee);return J},moveH:Sr(function(r,n){var w=this;this.extendSelectionsBy(function(W){return w.display.shift||w.doc.extend||W.empty()?Ka(w.doc,W.head,r,n,w.options.rtlMoveVisually):r<0?W.from():W.to()},Te)}),deleteH:Sr(function(r,n){var w=this.doc.sel,W=this.doc;w.somethingSelected()?W.replaceSelection("",null,"+delete"):on(this,function(Y){var J=Ka(W,Y.head,r,n,!1);return r<0?{from:J,to:Y.head}:{from:Y.head,to:J}})}),findPosV:function(r,n,w,W){var Y=1,J=W;n<0&&(Y=-1,n=-n);for(var ee=s(this.doc,r),he=0;he<n;++he){var pe=Zr(this,ee,"div");if(J==null?J=pe.left:pe.left=J,ee=Ls(this,pe,Y,w),ee.hitSide)break}return ee},moveV:Sr(function(r,n){var w=this,W=this.doc,Y=[],J=!this.display.shift&&!W.extend&&W.sel.somethingSelected();if(W.extendSelectionsBy(function(he){if(J)return r<0?he.from():he.to();var pe=Zr(w,he.head,"div");he.goalColumn!=null&&(pe.left=he.goalColumn),Y.push(pe.left);var De=Ls(w,pe,r,n);return n=="page"&&he==W.sel.primary()&&wa(w,ma(w,De,"div").top-pe.top),De},Te),Y.length)for(var ee=0;ee<W.sel.ranges.length;ee++)W.sel.ranges[ee].goalColumn=Y[ee]}),findWordAt:function(r){var n=this.doc,w=ct(n,r.line).text,W=r.ch,Y=r.ch;if(w){var J=this.getHelper(r,"wordChars");(r.sticky=="before"||Y==w.length)&&W?--W:++Y;for(var ee=w.charAt(W),he=Ne(ee,J)?function(pe){return Ne(pe,J)}:/\s/.test(ee)?function(pe){return/\s/.test(pe)}:function(pe){return!/\s/.test(pe)&&!Ne(pe)};W>0&&he(w.charAt(W-1));)--W;for(;Y<w.length&&he(w.charAt(Y));)++Y}return new jt($e(r.line,W),$e(r.line,Y))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?U(this.display.cursorDiv,"CodeMirror-overwrite"):p(this.display.cursorDiv,"CodeMirror-overwrite"),Fe(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==M()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Sr(function(r,n){En(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ii(this)-this.display.barHeight,width:r.scrollWidth-ii(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:Mi(this)}},scrollIntoView:Sr(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:$e(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):Eo(this,r.from,r.to,r.margin)}),setSize:Sr(function(r,n){var w=this,W=function(J){return typeof J=="number"||/^\d+$/.test(String(J))?J+"px":J};r!=null&&(this.display.wrapper.style.width=W(r)),n!=null&&(this.display.wrapper.style.height=W(n)),this.options.lineWrapping&&ao(this);var Y=this.display.viewFrom;this.doc.iter(Y,this.display.viewTo,function(J){if(J.widgets){for(var ee=0;ee<J.widgets.length;ee++)if(J.widgets[ee].noHScroll){Ci(w,Y,"widget");break}}++Y}),this.curOp.forceUpdate=!0,Fe(this,"refresh",this)}),operation:function(r){return Pr(this,r)},startOperation:function(){return ji(this)},endOperation:function(){return Wi(this)},refresh:Sr(function(){var r=this.display.cachedTextHeight;_r(this),this.curOp.forceUpdate=!0,yn(this),En(this,this.doc.scrollLeft,this.doc.scrollTop),La(this.display),(r==null||Math.abs(r-Yi(this.display))>.5||this.options.lineWrapping)&&xa(this),Fe(this,"refresh",this)}),swapDoc:Sr(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yn(this),this.display.input.reset(),En(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,cr(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},be(e),e.registerHelper=function(r,n,w){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=w},e.registerGlobalHelper=function(r,n,w,W){e.registerHelper(r,n,W),i[r]._global.push({pred:w,val:W})}}function Ka(e,t,i,r,n){var w=t,W=i,Y=ct(e,t.line),J=n&&e.direction=="rtl"?-i:i;function ee(){var st=t.line+J;return st<e.first||st>=e.first+e.size?!1:(t=new $e(st,t.ch,t.sticky),Y=ct(e,st))}function he(st){var nt;if(r=="codepoint"){var dt=Y.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(dt)?nt=null:nt=new $e(t.line,Math.max(0,Math.min(Y.text.length,t.ch+i*(dt>=55296&&dt<56320?2:1))),-i)}else n?nt=Ml(e.cm,Y,t,i):nt=Fa(Y,t,i);if(nt==null)if(!st&&ee())t=Ua(n,e.cm,Y,t.line,J);else return!1;else t=nt;return!0}if(r=="char"||r=="codepoint")he();else if(r=="column")he(!0);else if(r=="word"||r=="group")for(var pe=null,De=r=="group",Ae=e.cm&&e.cm.getHelper(t,"wordChars"),Ue=!0;!(i<0&&!he(!Ue));Ue=!1){var Ke=Y.text.charAt(t.ch)||`
`,qe=Ne(Ke,Ae)?"w":De&&Ke==`
`?"n":!De||/\s/.test(Ke)?null:"p";if(De&&!Ue&&!qe&&(qe="s"),pe&&pe!=qe){i<0&&(i=1,he(),t.sticky="after");break}if(qe&&(pe=qe),i>0&&!he(!Ue))break}var it=ea(e,t,w,W,!0);return pi(w,it)&&(it.hitSide=!0),it}function Ls(e,t,i,r){var n=e.doc,w=t.left,W;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);W=(i>0?t.bottom:t.top)+i*J}else r=="line"&&(W=i>0?t.bottom+3:t.top-3);for(var ee;!(ee=va(e,w,W),!ee.outside);){if(i<0?W<=0:W>=n.height){ee.hitSide=!0;break}W+=i*5}return ee}var Ht=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new q,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ht.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;_s(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function w(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(!w(Y)||Xe(r,Y)||Cs(Y,r))return;j<=11&&setTimeout(or(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 W(Y){if(!w(Y)||Xe(r,Y))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),Y.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var J=ws(r);oa({lineWise:!0,text:J.text}),Y.type=="cut"&&r.operation(function(){r.setSelections(J.ranges,0,Ee),r.replaceSelection("",null,"cut")})}else return;if(Y.clipboardData){Y.clipboardData.clearData();var ee=Qr.text.join(`
`);if(Y.clipboardData.setData("Text",ee),Y.clipboardData.getData("Text")==ee){Y.preventDefault();return}}var he=As(),pe=he.firstChild;r.display.lineSpace.insertBefore(he,r.display.lineSpace.firstChild),pe.value=Qr.text.join(`
`);var De=document.activeElement;V(pe),setTimeout(function(){r.display.lineSpace.removeChild(he),De.focus(),De==n&&i.showPrimarySelection()},50)}Pe(n,"copy",W),Pe(n,"cut",W)},Ht.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ht.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},Ht.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Ht.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ht.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line<t.display.viewFrom){e.removeAllRanges();return}var w=sa(t,e.anchorNode,e.anchorOffset),W=sa(t,e.focusNode,e.focusOffset);if(w&&!w.bad&&W&&!W.bad&&St(vi(w,W),r)==0&&St(gi(w,W),n)==0)return;var Y=t.display.view,J=r.line>=t.display.viewFrom&&Ds(t,r)||{node:Y[0].measure.map[2],offset:0},ee=n.line<t.display.viewTo&&Ds(t,n);if(!ee){var he=Y[Y.length-1].measure,pe=he.maps?he.maps[he.maps.length-1]:he.map;ee={node:pe[pe.length-1],offset:pe[pe.length-2]-pe[pe.length-3]}}if(!J||!ee){e.removeAllRanges();return}var De=e.rangeCount&&e.getRangeAt(0),Ae;try{Ae=g(J.node,J.offset,ee.offset,ee.node)}catch(Ue){}Ae&&(!R&&t.state.focused?(e.collapse(J.node,J.offset),Ae.collapsed||(e.removeAllRanges(),e.addRange(Ae))):(e.removeAllRanges(),e.addRange(Ae)),De&&e.anchorNode==null?e.addRange(De):R&&this.startGracePeriod()),this.rememberSelection()},Ht.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Ht.prototype.showMultipleSelections=function(e){h(this.cm.display.cursorDiv,e.cursors),h(this.cm.display.selectionDiv,e.selection)},Ht.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ht.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return S(this.div,t)},Ht.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ht.prototype.blur=function(){this.div.blur()},Ht.prototype.getField=function(){return this.div},Ht.prototype.supportsTouch=function(){return!0},Ht.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Pr(this.cm,function(){return e.cm.curOp.selectionChanged=!0});function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}this.polling.set(this.cm.options.pollInterval,t)},Ht.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ht.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&y&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var i=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Pr(t,function(){br(t.doc,wi(i,r),Ee),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Ht.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,i=e.doc.sel.primary(),r=i.from(),n=i.to();if(r.ch==0&&r.line>e.firstLine()&&(r=$e(r.line-1,ct(e.doc,r.line-1).length)),n.ch==ct(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=$e(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var w,W,Y;r.line==t.viewFrom||(w=Bi(e,r.line))==0?(W=Lt(t.view[0].line),Y=t.view[0].node):(W=Lt(t.view[w].line),Y=t.view[w-1].node.nextSibling);var J=Bi(e,n.line),ee,he;if(J==t.view.length-1?(ee=t.viewTo-1,he=t.lineDiv.lastChild):(ee=Lt(t.view[J+1].line)-1,he=t.view[J+1].node.previousSibling),!Y)return!1;for(var pe=e.doc.splitLines(tu(e,Y,he,W,ee)),De=Hr(e.doc,$e(W,0),$e(ee,ct(e.doc,ee).text.length));pe.length>1&&De.length>1;)if(te(pe)==te(De))pe.pop(),De.pop(),ee--;else if(pe[0]==De[0])pe.shift(),De.shift(),W++;else break;for(var Ae=0,Ue=0,Ke=pe[0],qe=De[0],it=Math.min(Ke.length,qe.length);Ae<it&&Ke.charCodeAt(Ae)==qe.charCodeAt(Ae);)++Ae;for(var st=te(pe),nt=te(De),dt=Math.min(st.length-(pe.length==1?Ae:0),nt.length-(De.length==1?Ae:0));Ue<dt&&st.charCodeAt(st.length-Ue-1)==nt.charCodeAt(nt.length-Ue-1);)++Ue;if(pe.length==1&&De.length==1&&W==r.line)for(;Ae&&Ae>r.ch&&st.charCodeAt(st.length-Ue-1)==nt.charCodeAt(nt.length-Ue-1);)Ae--,Ue++;pe[pe.length-1]=st.slice(0,st.length-Ue).replace(/^\u200b+/,""),pe[0]=pe[0].slice(Ae).replace(/\u200b+$/,"");var xt=$e(W,Ae),vt=$e(ee,De.length?te(De).length-Ue:0);if(pe.length>1||pe[0]||St(xt,vt))return rn(e.doc,pe,xt,vt,"+input"),!0},Ht.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ht.prototype.reset=function(){this.forceCompositionEnd()},Ht.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Ht.prototype.readFromDOMSoon=function(){var e=this;if(this.readDOMTimeout!=null)return;this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80)},Ht.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&Pr(this.cm,function(){return _r(e.cm)})},Ht.prototype.setUneditable=function(e){e.contentEditable="false"},Ht.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||or(this.cm,Ga)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Ht.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Ht.prototype.onContextMenu=function(){},Ht.prototype.resetPosition=function(){},Ht.prototype.needsContentAttribute=!0;function Ds(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=ct(e.doc,t.line),n=eo(i,r,t.line),w=Qe(r,e.doc.direction),W="left";if(w){var Y=je(w,t.ch);W=Y%2?"right":"left"}var J=io(n.map,t.ch,W);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 w="",W=!1,Y=e.doc.lineSeparator(),J=!1;function ee(Ae){return function(Ue){return Ue.id==Ae}}function he(){W&&(w+=Y,J&&(w+=Y),W=J=!1)}function pe(Ae){Ae&&(he(),w+=Ae)}function De(Ae){if(Ae.nodeType==1){var Ue=Ae.getAttribute("cm-text");if(Ue){pe(Ue);return}var Ke=Ae.getAttribute("cm-marker"),qe;if(Ke){var it=e.findMarks($e(r,0),$e(n+1,0),ee(+Ke));it.length&&(qe=it[0].find(0))&&pe(Hr(e.doc,qe.from,qe.to).join(Y));return}if(Ae.getAttribute("contenteditable")=="false")return;var st=/^(pre|div|p|li|table|br)$/i.test(Ae.nodeName);if(!/^br$/i.test(Ae.nodeName)&&Ae.textContent.length==0)return;st&&he();for(var nt=0;nt<Ae.childNodes.length;nt++)De(Ae.childNodes[nt]);/^(pre|p)$/i.test(Ae.nodeName)&&(J=!0),st&&(W=!0)}else Ae.nodeType==3&&pe(Ae.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(De(t),t==i);)t=t.nextSibling,J=!1;return w}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return ln(e.clipPos($e(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 w=e.display.view[n];if(w.node==r)return ru(w,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!S(r,t))return ln($e(Lt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var w=e.rest?te(e.rest):e.line;return ln($e(Lt(w),w.text.length),n)}var W=t.nodeType==3?t:null,Y=t;for(!W&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(W=t.firstChild,i&&(i=W.nodeValue.length));Y.parentNode!=r;)Y=Y.parentNode;var J=e.measure,ee=J.maps;function he(qe,it,st){for(var nt=-1;nt<(ee?ee.length:0);nt++)for(var dt=nt<0?J.map:ee[nt],xt=0;xt<dt.length;xt+=3){var vt=dt[xt+2];if(vt==qe||vt==it){var _t=Lt(nt<0?e.line:e.rest[nt]),Gt=dt[xt]+st;return(st<0||vt!=qe)&&(Gt=dt[xt+(st?1:0)]),$e(_t,Gt)}}}var pe=he(W,Y,i);if(pe)return ln(pe,n);for(var De=Y.nextSibling,Ae=W?W.nodeValue.length-i:0;De;De=De.nextSibling){if(pe=he(De,De.firstChild,0),pe)return ln($e(pe.line,pe.ch-Ae),n);Ae+=De.textContent.length}for(var Ue=Y.previousSibling,Ke=i;Ue;Ue=Ue.previousSibling){if(pe=he(Ue,Ue.firstChild,-1),pe)return ln($e(pe.line,pe.ch+Ke),n);Ke+=Ue.textContent.length}}var Qt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new q,this.hasSelection=!1,this.composing=null};Qt.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),b&&(n.style.width="0px"),Pe(n,"input",function(){K&&j>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Pe(n,"paste",function(W){if(Xe(r,W)||Cs(W,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function w(W){if(Xe(r,W))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var Y=ws(r);oa({lineWise:!0,text:Y.text}),W.type=="cut"?r.setSelections(Y.ranges,null,Ee):(i.prevInput="",n.value=Y.text.join(`
`),V(n))}else return;W.type=="cut"&&(r.state.cutIncoming=+new Date)}Pe(n,"cut",w),Pe(n,"copy",w),Pe(e.scroller,"paste",function(W){if(ui(e,W)||Xe(r,W))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var Y=new Event("paste");Y.clipboardData=W.clipboardData,n.dispatchEvent(Y)}),Pe(e.lineSpace,"selectstart",function(W){ui(e,W)||ie(W)}),Pe(n,"compositionstart",function(){var W=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:W,range:r.markText(W,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=As(),this.textarea=this.wrapper.firstChild},Qt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Qt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=Zr(e,i.sel.primary().head,"div"),w=t.wrapper.getBoundingClientRect(),W=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+W.top-w.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+W.left-w.left))}return r},Qt.prototype.showSelection=function(e){var t=this.cm,i=t.display;h(i.cursorDiv,e.cursors),h(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),K&&j>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",K&&j>=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"&&(!a||M()!=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||ht(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(K&&j>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var w=n.charCodeAt(0);if(w==8203&&!r&&(r="\u200B"),w==8666)return this.reset(),this.cm.execCommand("undo")}for(var W=0,Y=Math.min(r.length,n.length);W<Y&&r.charCodeAt(W)==n.charCodeAt(W);)++W;return Pr(t,function(){Ga(t,n.slice(W),r.length-W,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(){K&&j>=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 w=Ni(i,e),W=r.scroller.scrollTop;if(!w||A)return;var Y=i.options.resetSelectionOnContextMenu;Y&&i.doc.sel.contains(w)==-1&&or(i,br)(i.doc,wi(w),Ee);var J=n.style.cssText,ee=t.wrapper.style.cssText,he=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-he.top-5)+"px; left: "+(e.clientX-he.left-5)+`px;
z-index: 1000; background: `+(K?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var pe;N&&(pe=window.scrollY),r.input.focus(),N&&window.scrollTo(null,pe),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=Ae,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function De(){if(n.selectionStart!=null){var Ke=i.somethingSelected(),qe="\u200B"+(Ke?n.value:"");n.value="\u21DA",n.value=qe,t.prevInput=Ke?"":"\u200B",n.selectionStart=1,n.selectionEnd=qe.length,r.selForContextMenu=i.doc.sel}}function Ae(){if(t.contextMenuPending!=Ae)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=ee,n.style.cssText=J,K&&j<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=W),n.selectionStart!=null){(!K||K&&j<9)&&De();var Ke=0,qe=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?or(i,Xo)(i):Ke++<10?r.detectingSelectAll=setTimeout(qe,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(qe,200)}}if(K&&j>=9&&De(),L){me(e);var Ue=function(){at(window,"mouseup",Ue),setTimeout(Ae,20)};Pe(window,"mouseup",Ue)}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?I(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=M();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=Y.getValue()}var n;if(e.form&&(Pe(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var w=e.form;n=w.submit;try{var W=w.submit=function(){r(),w.submit=n,w.submit(),w.submit=W}}catch(J){}}t.finishInit=function(J){J.save=r,J.getTextArea=function(){return e},J.toTextArea=function(){J.toTextArea=isNaN,r(),e.parentNode.removeChild(J.getWrapperElement()),e.style.display="",e.form&&(at(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var Y=Vt(function(J){return e.parentNode.insertBefore(J,e.nextSibling)},t);return Y}function nu(e){e.off=at,e.on=Pe,e.wheelEventPixels=hl,e.Doc=Ar,e.splitLines=Ct,e.countColumn=X,e.findColumn=ye,e.isWordChar=ke,e.Pass=Le,e.signal=Fe,e.Line=Pi,e.changeEnd=_i,e.scrollbarModel=Co,e.Pos=$e,e.cmpPos=St,e.modes=Xt,e.mimeModes=kt,e.resolveMode=Et,e.getMode=Nr,e.modeExtensions=dr,e.extendMode=pr,e.copyState=Br,e.startState=qr,e.innerMode=ci,e.commands=In,e.keyMap=di,e.keyName=us,e.isModifierKey=ss,e.lookupKey=an,e.normalizeKeyMap=Pl,e.StringStream=It,e.SharedTextMarker=On,e.TextMarker=Li,e.LineWidget=kn,e.e_preventDefault=ie,e.e_stopPropagation=ae,e.e_stop=me,e.addClass=U,e.contains=S,e.rmClass=p,e.keyNames=Di}$l(Vt),ql(Vt);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Ar.prototype)Ar.prototype.hasOwnProperty(la)&&oe(au,la)<0&&(Vt.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Ar.prototype[la]));return be(Ar),Vt.inputStyles={textarea:Qt,contenteditable:Ht},Vt.defineMode=function(e){!Vt.defaults.mode&&e!="null"&&(Vt.defaults.mode=e),Ir.apply(this,arguments)},Vt.defineMIME=Kr,Vt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Vt.defineMIME("text/plain","null"),Vt.defineExtension=function(e,t){Vt.prototype[e]=t},Vt.defineDocExtension=function(e,t){Ar.prototype[e]=t},Vt.fromTextArea=iu,nu(Vt),Vt.version="5.58.2",Vt})},Y1PL:function(ut,Ze,re){"use strict";re.r(Ze),re.d(Ze,"ResizableTextArea",function(){return oe});var le=re("wx14"),$=re("1OyB"),R=re("vuIU"),Z=re("Ji7U"),F=re("LK+K"),P=re("cDcd"),K=re("VTBJ"),j=re("rePB"),N=re("Zm9Q"),D=re("Kwbf"),y=re("c+Xe"),A=re("m+aA"),k=re("bdgK"),T=new Map;function C(Ee){Ee.forEach(function(we){var Te,ye=we.target;(Te=T.get(ye))===null||Te===void 0||Te.forEach(function(fe){return fe(ye)})})}var b=new k.default(C),u=null,a=null;function l(Ee,we){T.has(Ee)||(T.set(Ee,new Set),b.observe(Ee)),T.get(Ee).add(we)}function d(Ee,we){T.has(Ee)&&(T.get(Ee).delete(we),T.get(Ee).size||(b.unobserve(Ee),T.delete(Ee)))}var _=function(Ee){Object(Z.a)(Te,Ee);var we=Object(F.a)(Te);function Te(){return Object($.a)(this,Te),we.apply(this,arguments)}return Object(R.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(P.Component),v=P.createContext(null);function m(Ee){var we=Ee.children,Te=Ee.onBatchResize,ye=P.useRef(0),fe=P.useRef([]),se=P.useContext(v),te=P.useCallback(function(ue,ne,_e){ye.current+=1;var Re=ye.current;fe.current.push({size:ue,element:ne,data:_e}),Promise.resolve().then(function(){Re===ye.current&&(Te==null||Te(fe.current),fe.current=[])}),se==null||se(ue,ne,_e)},[Te,se]);return P.createElement(v.Provider,{value:te},we)}function L(Ee){var we=Ee.children,Te=Ee.disabled,ye=P.useRef(null),fe=P.useRef(null),se=P.useContext(v),te=P.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),ue=P.isValidElement(we)&&Object(y.c)(we),ne=ue?we.ref:null,_e=P.useMemo(function(){return Object(y.a)(ne,ye)},[ne,ye]),Re=P.useRef(Ee);Re.current=Ee;var xe=P.useCallback(function(ke){var Ne=Re.current,He=Ne.onResize,Be=Ne.data,Me=ke.getBoundingClientRect(),Oe=Me.width,Ye=Me.height,Je=ke.offsetWidth,Ve=ke.offsetHeight,je=Math.floor(Oe),rt=Math.floor(Ye);if(te.current.width!==je||te.current.height!==rt||te.current.offsetWidth!==Je||te.current.offsetHeight!==Ve){var Qe={width:je,height:rt,offsetWidth:Je,offsetHeight:Ve};te.current=Qe;var tt=Je===Math.round(Oe)?Oe:Je,Pe=Ve===Math.round(Ye)?Ye:Ve,lt=Object(K.a)(Object(K.a)({},Qe),{},{offsetWidth:tt,offsetHeight:Pe});se==null||se(lt,ke,Be),He&&Promise.resolve().then(function(){He(lt,ke)})}},[]);return P.useEffect(function(){var ke=Object(A.a)(ye.current)||Object(A.a)(fe.current);return ke&&!Te&&l(ke,xe),function(){return d(ke,xe)}},[ye.current,Te]),P.createElement(_,{ref:fe},ue?P.cloneElement(we,{ref:_e}):we)}var x="rc-observer-key";function p(Ee){var we=Ee.children,Te=Object(N.a)(we);return Te.map(function(ye,fe){var se=(ye==null?void 0:ye.key)||"".concat(x,"-").concat(fe);return P.createElement(L,Object(le.a)({},Ee,{key:se}),ye)})}p.Collection=m;var f=p,h=re("bT9E"),o=re("TSYQ"),E=re.n(o),g=`
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
`,S=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],M={},U;function G(Ee){var we=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=Ee.getAttribute("id")||Ee.getAttribute("data-reactid")||Ee.getAttribute("name");if(we&&M[Te])return M[Te];var ye=window.getComputedStyle(Ee),fe=ye.getPropertyValue("box-sizing")||ye.getPropertyValue("-moz-box-sizing")||ye.getPropertyValue("-webkit-box-sizing"),se=parseFloat(ye.getPropertyValue("padding-bottom"))+parseFloat(ye.getPropertyValue("padding-top")),te=parseFloat(ye.getPropertyValue("border-bottom-width"))+parseFloat(ye.getPropertyValue("border-top-width")),ue=S.map(function(_e){return"".concat(_e,":").concat(ye.getPropertyValue(_e))}).join(";"),ne={sizingStyle:ue,paddingSize:se,borderSize:te,boxSizing:fe};return we&&Te&&(M[Te]=ne),ne}function V(Ee){var we=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,ye=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;U||(U=document.createElement("textarea"),U.setAttribute("tab-index","-1"),U.setAttribute("aria-hidden","true"),document.body.appendChild(U)),Ee.getAttribute("wrap")?U.setAttribute("wrap",Ee.getAttribute("wrap")):U.removeAttribute("wrap");var fe=G(Ee,we),se=fe.paddingSize,te=fe.borderSize,ue=fe.boxSizing,ne=fe.sizingStyle;U.setAttribute("style","".concat(ne,";").concat(g)),U.value=Ee.value||Ee.placeholder||"";var _e=Number.MIN_SAFE_INTEGER,Re=Number.MAX_SAFE_INTEGER,xe=U.scrollHeight,ke;if(ue==="border-box"?xe+=te:ue==="content-box"&&(xe-=se),Te!==null||ye!==null){U.value=" ";var Ne=U.scrollHeight-se;Te!==null&&(_e=Ne*Te,ue==="border-box"&&(_e=_e+se+te),xe=Math.max(_e,xe)),ye!==null&&(Re=Ne*ye,ue==="border-box"&&(Re=Re+se+te),ke=xe>Re?"":"hidden",xe=Math.min(Re,xe))}return{height:xe,minHeight:_e,maxHeight:Re,overflowY:ke,resize:"none"}}var O=re("Gytx"),I=re.n(O),X;(function(Ee){Ee[Ee.NONE=0]="NONE",Ee[Ee.RESIZING=1]="RESIZING",Ee[Ee.RESIZED=2]="RESIZED"})(X||(X={}));var q=function(Ee){Object(Z.a)(Te,Ee);var we=Object(F.a)(Te);function Te(ye){var fe;return Object($.a)(this,Te),fe=we.call(this,ye),fe.nextFrameActionId=void 0,fe.resizeFrameId=void 0,fe.textArea=void 0,fe.saveTextArea=function(se){fe.textArea=se},fe.handleResize=function(se){var te=fe.state.resizeStatus,ue=fe.props,ne=ue.autoSize,_e=ue.onResize;if(te!==X.NONE)return;typeof _e=="function"&&_e(se),ne&&fe.resizeOnNextFrame()},fe.resizeOnNextFrame=function(){cancelAnimationFrame(fe.nextFrameActionId),fe.nextFrameActionId=requestAnimationFrame(fe.resizeTextarea)},fe.resizeTextarea=function(){var se=fe.props.autoSize;if(!se||!fe.textArea)return;var te=se.minRows,ue=se.maxRows,ne=V(fe.textArea,!1,te,ue);fe.setState({textareaStyles:ne,resizeStatus:X.RESIZING},function(){cancelAnimationFrame(fe.resizeFrameId),fe.resizeFrameId=requestAnimationFrame(function(){fe.setState({resizeStatus:X.RESIZED},function(){fe.resizeFrameId=requestAnimationFrame(function(){fe.setState({resizeStatus:X.NONE}),fe.fixFirefoxAutoScroll()})})})})},fe.renderTextArea=function(){var se=fe.props,te=se.prefixCls,ue=te===void 0?"rc-textarea":te,ne=se.autoSize,_e=se.onResize,Re=se.className,xe=se.disabled,ke=fe.state,Ne=ke.textareaStyles,He=ke.resizeStatus,Be=Object(h.a)(fe.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Me=E()(ue,Re,Object(j.a)({},"".concat(ue,"-disabled"),xe));"value"in Be&&(Be.value=Be.value||"");var Oe=Object(K.a)(Object(K.a)(Object(K.a)({},fe.props.style),Ne),He===X.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return P.createElement(f,{onResize:fe.handleResize,disabled:!(ne||_e)},P.createElement("textarea",Object(le.a)({},Be,{className:Me,style:Oe,ref:fe.saveTextArea})))},fe.state={textareaStyles:{},resizeStatus:X.NONE},fe}return Object(R.a)(Te,[{key:"componentDidUpdate",value:function(fe){(fe.value!==this.props.value||!I()(fe.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 fe=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(fe,se)}}catch(te){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(P.Component),oe=q,ce=function(Ee){Object(Z.a)(Te,Ee);var we=Object(F.a)(Te);function Te(ye){var fe;Object($.a)(this,Te),fe=we.call(this,ye),fe.resizableTextArea=void 0,fe.focus=function(){fe.resizableTextArea.textArea.focus()},fe.saveTextArea=function(te){fe.resizableTextArea=te},fe.handleChange=function(te){var ue=fe.props.onChange;fe.setValue(te.target.value,function(){fe.resizableTextArea.resizeTextarea()}),ue&&ue(te)},fe.handleKeyDown=function(te){var ue=fe.props,ne=ue.onPressEnter,_e=ue.onKeyDown;te.keyCode===13&&ne&&ne(te),_e&&_e(te)};var se=typeof ye.value=="undefined"||ye.value===null?ye.defaultValue:ye.value;return fe.state={value:se},fe}return Object(R.a)(Te,[{key:"setValue",value:function(fe,se){"value"in this.props||this.setState({value:fe},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return P.createElement(oe,Object(le.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(fe){return"value"in fe?{value:fe.value}:null}}]),Te}(P.Component),Le=Ze.default=ce},ZpRC:function(ut,Ze,re){"use strict";function le(y){return typeof y=="object"&&y!=null&&y.nodeType===1}function $(y,A){return(!A||y!=="hidden")&&y!=="visible"&&y!=="clip"}function R(y,A){if(y.clientHeight<y.scrollHeight||y.clientWidth<y.scrollWidth){var k=getComputedStyle(y,null);return $(k.overflowY,A)||$(k.overflowX,A)||function(T){var C=function(b){if(!b.ownerDocument||!b.ownerDocument.defaultView)return null;try{return b.ownerDocument.defaultView.frameElement}catch(u){return null}}(T);return!!C&&(C.clientHeight<T.scrollHeight||C.clientWidth<T.scrollWidth)}(y)}return!1}function Z(y,A,k,T,C,b,u,a){return b<y&&u>A||b>y&&u<A?0:b<=y&&a<=k||u>=A&&a>=k?b-y-T:u>A&&a<k||b<y&&a>k?u-A+C:0}var F=function(y,A){var k=window,T=A.scrollMode,C=A.block,b=A.inline,u=A.boundary,a=A.skipOverflowHiddenElements,l=typeof u=="function"?u:function(Ne){return Ne!==u};if(!le(y))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,_=[],v=y;le(v)&&l(v);){if((v=v.parentElement)===d){_.push(v);break}v!=null&&v===document.body&&R(v)&&!R(document.documentElement)||v!=null&&R(v,a)&&_.push(v)}for(var m=k.visualViewport?k.visualViewport.width:innerWidth,L=k.visualViewport?k.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,p=window.scrollY||pageYOffset,f=y.getBoundingClientRect(),h=f.height,o=f.width,E=f.top,g=f.right,S=f.bottom,M=f.left,U=C==="start"||C==="nearest"?E:C==="end"?S:E+h/2,G=b==="center"?M+o/2:b==="end"?g:M,V=[],O=0;O<_.length;O++){var I=_[O],X=I.getBoundingClientRect(),q=X.height,oe=X.width,ce=X.top,Le=X.right,Ee=X.bottom,we=X.left;if(T==="if-needed"&&E>=0&&M>=0&&S<=L&&g<=m&&E>=ce&&S<=Ee&&M>=we&&g<=Le)return V;var Te=getComputedStyle(I),ye=parseInt(Te.borderLeftWidth,10),fe=parseInt(Te.borderTopWidth,10),se=parseInt(Te.borderRightWidth,10),te=parseInt(Te.borderBottomWidth,10),ue=0,ne=0,_e="offsetWidth"in I?I.offsetWidth-I.clientWidth-ye-se:0,Re="offsetHeight"in I?I.offsetHeight-I.clientHeight-fe-te:0;if(d===I)ue=C==="start"?U:C==="end"?U-L:C==="nearest"?Z(p,p+L,L,fe,te,p+U,p+U+h,h):U-L/2,ne=b==="start"?G:b==="center"?G-m/2:b==="end"?G-m:Z(x,x+m,m,ye,se,x+G,x+G+o,o),ue=Math.max(0,ue+p),ne=Math.max(0,ne+x);else{ue=C==="start"?U-ce-fe:C==="end"?U-Ee+te+Re:C==="nearest"?Z(ce,Ee,q,fe,te+Re,U,U+h,h):U-(ce+q/2)+Re/2,ne=b==="start"?G-we-ye:b==="center"?G-(we+oe/2)+_e/2:b==="end"?G-Le+se+_e:Z(we,Le,oe,ye,se+_e,G,G+o,o);var xe=I.scrollLeft,ke=I.scrollTop;U+=ke-(ue=Math.max(0,Math.min(ke+ue,I.scrollHeight-q+Re))),G+=xe-(ne=Math.max(0,Math.min(xe+ne,I.scrollWidth-oe+_e)))}V.push({el:I,top:ue,left:ne})}return V};function P(y){return y===Object(y)&&Object.keys(y).length!==0}function K(y,A){A===void 0&&(A="auto");var k="scrollBehavior"in document.body.style;y.forEach(function(T){var C=T.el,b=T.top,u=T.left;C.scroll&&k?C.scroll({top:b,left:u,behavior:A}):(C.scrollTop=b,C.scrollLeft=u)})}function j(y){return y===!1?{block:"end",inline:"nearest"}:P(y)?y:{block:"start",inline:"nearest"}}function N(y,A){var k=!y.ownerDocument.documentElement.contains(y);if(P(A)&&typeof A.behavior=="function")return A.behavior(k?[]:F(y,A));if(k)return;var T=j(A);return K(F(y,T),T.behavior)}var D=Ze.a=N},Zss7:function(ut,Ze,re){var le;(function($){var R=/^\s+/,Z=/\s+$/,F=0,P=$.round,K=$.min,j=$.max,N=$.random;function D(te,ue){if(te=te||"",ue=ue||{},te instanceof D)return te;if(!(this instanceof D))return new D(te,ue);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=ue.format||ne.format,this._gradientType=ue.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=F++}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(),ue,ne,_e,Re,xe,ke;return ue=te.r/255,ne=te.g/255,_e=te.b/255,ue<=.03928?Re=ue/12.92:Re=$.pow((ue+.055)/1.055,2.4),ne<=.03928?xe=ne/12.92:xe=$.pow((ne+.055)/1.055,2.4),_e<=.03928?ke=_e/12.92:ke=$.pow((_e+.055)/1.055,2.4),.2126*Re+.7152*xe+.0722*ke},setAlpha:function(te){return this._a=V(te),this._roundA=P(100*this._a)/100,this},toHsv:function(){var te=C(this._r,this._g,this._b);return{h:te.h*360,s:te.s,v:te.v,a:this._a}},toHsvString:function(){var te=C(this._r,this._g,this._b),ue=P(te.h*360),ne=P(te.s*100),_e=P(te.v*100);return this._a==1?"hsv("+ue+", "+ne+"%, "+_e+"%)":"hsva("+ue+", "+ne+"%, "+_e+"%, "+this._roundA+")"},toHsl:function(){var te=k(this._r,this._g,this._b);return{h:te.h*360,s:te.s,l:te.l,a:this._a}},toHslString:function(){var te=k(this._r,this._g,this._b),ue=P(te.h*360),ne=P(te.s*100),_e=P(te.l*100);return this._a==1?"hsl("+ue+", "+ne+"%, "+_e+"%)":"hsla("+ue+", "+ne+"%, "+_e+"%, "+this._roundA+")"},toHex:function(te){return u(this._r,this._g,this._b,te)},toHexString:function(te){return"#"+this.toHex(te)},toHex8:function(te){return a(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(O(this._r,255)*100)+"%",g:P(O(this._g,255)*100)+"%",b:P(O(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+P(O(this._r,255)*100)+"%, "+P(O(this._g,255)*100)+"%, "+P(O(this._b,255)*100)+"%)":"rgba("+P(O(this._r,255)*100)+"%, "+P(O(this._g,255)*100)+"%, "+P(O(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:U[u(this._r,this._g,this._b,!0)]||!1},toFilter:function(te){var ue="#"+l(this._r,this._g,this._b,this._a),ne=ue,_e=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("+_e+"startColorstr="+ue+",endColorstr="+ne+")"},toString:function(te){var ue=!!te;te=te||this._format;var ne=!1,_e=this._a<1&&this._a>=0,Re=!ue&&_e&&(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,ue){var ne=te.apply(null,[this].concat([].slice.call(ue)));return this._r=ne._r,this._g=ne._g,this._b=ne._b,this.setAlpha(ne._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(L,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(_,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(p,arguments)},_applyCombination:function(te,ue){return te.apply(null,[this].concat([].slice.call(ue)))},analogous:function(){return this._applyCombination(g,arguments)},complement:function(){return this._applyCombination(f,arguments)},monochromatic:function(){return this._applyCombination(S,arguments)},splitcomplement:function(){return this._applyCombination(E,arguments)},triad:function(){return this._applyCombination(h,arguments)},tetrad:function(){return this._applyCombination(o,arguments)}},D.fromRatio=function(te,ue){if(typeof te=="object"){var ne={};for(var _e in te)te.hasOwnProperty(_e)&&(_e==="a"?ne[_e]=te[_e]:ne[_e]=Le(te[_e]));te=ne}return D(te,ue)};function y(te){var ue={r:0,g:0,b:0},ne=1,_e=null,Re=null,xe=null,ke=!1,Ne=!1;return typeof te=="string"&&(te=fe(te)),typeof te=="object"&&(ye(te.r)&&ye(te.g)&&ye(te.b)?(ue=A(te.r,te.g,te.b),ke=!0,Ne=String(te.r).substr(-1)==="%"?"prgb":"rgb"):ye(te.h)&&ye(te.s)&&ye(te.v)?(_e=Le(te.s),Re=Le(te.v),ue=b(te.h,_e,Re),ke=!0,Ne="hsv"):ye(te.h)&&ye(te.s)&&ye(te.l)&&(_e=Le(te.s),xe=Le(te.l),ue=T(te.h,_e,xe),ke=!0,Ne="hsl"),te.hasOwnProperty("a")&&(ne=te.a)),ne=V(ne),{ok:ke,format:te.format||Ne,r:K(255,j(ue.r,0)),g:K(255,j(ue.g,0)),b:K(255,j(ue.b,0)),a:ne}}function A(te,ue,ne){return{r:O(te,255)*255,g:O(ue,255)*255,b:O(ne,255)*255}}function k(te,ue,ne){te=O(te,255),ue=O(ue,255),ne=O(ne,255);var _e=j(te,ue,ne),Re=K(te,ue,ne),xe,ke,Ne=(_e+Re)/2;if(_e==Re)xe=ke=0;else{var He=_e-Re;ke=Ne>.5?He/(2-_e-Re):He/(_e+Re);switch(_e){case te:xe=(ue-ne)/He+(ue<ne?6:0);break;case ue:xe=(ne-te)/He+2;break;case ne:xe=(te-ue)/He+4;break}xe/=6}return{h:xe,s:ke,l:Ne}}function T(te,ue,ne){var _e,Re,xe;te=O(te,360),ue=O(ue,100),ne=O(ne,100);function ke(Be,Me,Oe){return Oe<0&&(Oe+=1),Oe>1&&(Oe-=1),Oe<1/6?Be+(Me-Be)*6*Oe:Oe<1/2?Me:Oe<2/3?Be+(Me-Be)*(2/3-Oe)*6:Be}if(ue===0)_e=Re=xe=ne;else{var Ne=ne<.5?ne*(1+ue):ne+ue-ne*ue,He=2*ne-Ne;_e=ke(He,Ne,te+1/3),Re=ke(He,Ne,te),xe=ke(He,Ne,te-1/3)}return{r:_e*255,g:Re*255,b:xe*255}}function C(te,ue,ne){te=O(te,255),ue=O(ue,255),ne=O(ne,255);var _e=j(te,ue,ne),Re=K(te,ue,ne),xe,ke,Ne=_e,He=_e-Re;if(ke=_e===0?0:He/_e,_e==Re)xe=0;else{switch(_e){case te:xe=(ue-ne)/He+(ue<ne?6:0);break;case ue:xe=(ne-te)/He+2;break;case ne:xe=(te-ue)/He+4;break}xe/=6}return{h:xe,s:ke,v:Ne}}function b(te,ue,ne){te=O(te,360)*6,ue=O(ue,100),ne=O(ne,100);var _e=$.floor(te),Re=te-_e,xe=ne*(1-ue),ke=ne*(1-Re*ue),Ne=ne*(1-(1-Re)*ue),He=_e%6,Be=[ne,ke,xe,xe,Ne,ne][He],Me=[Ne,ne,ne,ke,xe,xe][He],Oe=[xe,xe,Ne,ne,ne,ke][He];return{r:Be*255,g:Me*255,b:Oe*255}}function u(te,ue,ne,_e){var Re=[ce(P(te).toString(16)),ce(P(ue).toString(16)),ce(P(ne).toString(16))];return _e&&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 a(te,ue,ne,_e,Re){var xe=[ce(P(te).toString(16)),ce(P(ue).toString(16)),ce(P(ne).toString(16)),ce(Ee(_e))];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,ue,ne,_e){var Re=[ce(Ee(_e)),ce(P(te).toString(16)),ce(P(ue).toString(16)),ce(P(ne).toString(16))];return Re.join("")}D.equals=function(te,ue){return!te||!ue?!1:D(te).toRgbString()==D(ue).toRgbString()},D.random=function(){return D.fromRatio({r:N(),g:N(),b:N()})};function d(te,ue){ue=ue===0?0:ue||10;var ne=D(te).toHsl();return ne.s-=ue/100,ne.s=I(ne.s),D(ne)}function _(te,ue){ue=ue===0?0:ue||10;var ne=D(te).toHsl();return ne.s+=ue/100,ne.s=I(ne.s),D(ne)}function v(te){return D(te).desaturate(100)}function m(te,ue){ue=ue===0?0:ue||10;var ne=D(te).toHsl();return ne.l+=ue/100,ne.l=I(ne.l),D(ne)}function L(te,ue){ue=ue===0?0:ue||10;var ne=D(te).toRgb();return ne.r=j(0,K(255,ne.r-P(255*-(ue/100)))),ne.g=j(0,K(255,ne.g-P(255*-(ue/100)))),ne.b=j(0,K(255,ne.b-P(255*-(ue/100)))),D(ne)}function x(te,ue){ue=ue===0?0:ue||10;var ne=D(te).toHsl();return ne.l-=ue/100,ne.l=I(ne.l),D(ne)}function p(te,ue){var ne=D(te).toHsl(),_e=(ne.h+ue)%360;return ne.h=_e<0?360+_e:_e,D(ne)}function f(te){var ue=D(te).toHsl();return ue.h=(ue.h+180)%360,D(ue)}function h(te){var ue=D(te).toHsl(),ne=ue.h;return[D(te),D({h:(ne+120)%360,s:ue.s,l:ue.l}),D({h:(ne+240)%360,s:ue.s,l:ue.l})]}function o(te){var ue=D(te).toHsl(),ne=ue.h;return[D(te),D({h:(ne+90)%360,s:ue.s,l:ue.l}),D({h:(ne+180)%360,s:ue.s,l:ue.l}),D({h:(ne+270)%360,s:ue.s,l:ue.l})]}function E(te){var ue=D(te).toHsl(),ne=ue.h;return[D(te),D({h:(ne+72)%360,s:ue.s,l:ue.l}),D({h:(ne+216)%360,s:ue.s,l:ue.l})]}function g(te,ue,ne){ue=ue||6,ne=ne||30;var _e=D(te).toHsl(),Re=360/ne,xe=[D(te)];for(_e.h=(_e.h-(Re*ue>>1)+720)%360;--ue;)_e.h=(_e.h+Re)%360,xe.push(D(_e));return xe}function S(te,ue){ue=ue||6;for(var ne=D(te).toHsv(),_e=ne.h,Re=ne.s,xe=ne.v,ke=[],Ne=1/ue;ue--;)ke.push(D({h:_e,s:Re,v:xe})),xe=(xe+Ne)%1;return ke}D.mix=function(te,ue,ne){ne=ne===0?0:ne||50;var _e=D(te).toRgb(),Re=D(ue).toRgb(),xe=ne/100,ke={r:(Re.r-_e.r)*xe+_e.r,g:(Re.g-_e.g)*xe+_e.g,b:(Re.b-_e.b)*xe+_e.b,a:(Re.a-_e.a)*xe+_e.a};return D(ke)},D.readability=function(te,ue){var ne=D(te),_e=D(ue);return($.max(ne.getLuminance(),_e.getLuminance())+.05)/($.min(ne.getLuminance(),_e.getLuminance())+.05)},D.isReadable=function(te,ue,ne){var _e=D.readability(te,ue),Re,xe;xe=!1,Re=se(ne);switch(Re.level+Re.size){case"AAsmall":case"AAAlarge":xe=_e>=4.5;break;case"AAlarge":xe=_e>=3;break;case"AAAsmall":xe=_e>=7;break}return xe},D.mostReadable=function(te,ue,ne){var _e=null,Re=0,xe,ke,Ne,He;ne=ne||{},ke=ne.includeFallbackColors,Ne=ne.level,He=ne.size;for(var Be=0;Be<ue.length;Be++)xe=D.readability(te,ue[Be]),xe>Re&&(Re=xe,_e=D(ue[Be]));return D.isReadable(te,_e,{level:Ne,size:He})||!ke?_e:(ne.includeFallbackColors=!1,D.mostReadable(te,["#fff","#000"],ne))};var M=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"},U=D.hexNames=G(M);function G(te){var ue={};for(var ne in te)te.hasOwnProperty(ne)&&(ue[te[ne]]=ne);return ue}function V(te){return te=parseFloat(te),(isNaN(te)||te<0||te>1)&&(te=1),te}function O(te,ue){q(te)&&(te="100%");var ne=oe(te);return te=K(ue,j(0,parseFloat(te))),ne&&(te=parseInt(te*ue,10)/100),$.abs(te-ue)<1e-6?1:te%ue/parseFloat(ue)}function I(te){return K(1,j(0,te))}function X(te){return parseInt(te,16)}function q(te){return typeof te=="string"&&te.indexOf(".")!=-1&&parseFloat(te)===1}function oe(te){return typeof te=="string"&&te.indexOf("%")!=-1}function ce(te){return te.length==1?"0"+te:""+te}function Le(te){return te<=1&&(te=te*100+"%"),te}function Ee(te){return $.round(parseFloat(te)*255).toString(16)}function we(te){return X(te)/255}var Te=function(){var te="[-\\+]?\\d+%?",ue="[-\\+]?\\d*\\.\\d+%?",ne="(?:"+ue+")|(?:"+te+")",_e="[\\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"+_e),rgba:new RegExp("rgba"+Re),hsl:new RegExp("hsl"+_e),hsla:new RegExp("hsla"+Re),hsv:new RegExp("hsv"+_e),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 ye(te){return!!Te.CSS_UNIT.exec(te)}function fe(te){te=te.replace(R,"").replace(Z,"").toLowerCase();var ue=!1;if(M[te])te=M[te],ue=!0;else if(te=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var ne;return(ne=Te.rgb.exec(te))?{r:ne[1],g:ne[2],b:ne[3]}:(ne=Te.rgba.exec(te))?{r:ne[1],g:ne[2],b:ne[3],a:ne[4]}:(ne=Te.hsl.exec(te))?{h:ne[1],s:ne[2],l:ne[3]}:(ne=Te.hsla.exec(te))?{h:ne[1],s:ne[2],l:ne[3],a:ne[4]}:(ne=Te.hsv.exec(te))?{h:ne[1],s:ne[2],v:ne[3]}:(ne=Te.hsva.exec(te))?{h:ne[1],s:ne[2],v:ne[3],a:ne[4]}:(ne=Te.hex8.exec(te))?{r:X(ne[1]),g:X(ne[2]),b:X(ne[3]),a:we(ne[4]),format:ue?"name":"hex8"}:(ne=Te.hex6.exec(te))?{r:X(ne[1]),g:X(ne[2]),b:X(ne[3]),format:ue?"name":"hex"}:(ne=Te.hex4.exec(te))?{r:X(ne[1]+""+ne[1]),g:X(ne[2]+""+ne[2]),b:X(ne[3]+""+ne[3]),a:we(ne[4]+""+ne[4]),format:ue?"name":"hex8"}:(ne=Te.hex3.exec(te))?{r:X(ne[1]+""+ne[1]),g:X(ne[2]+""+ne[2]),b:X(ne[3]+""+ne[3]),format:ue?"name":"hex"}:!1}function se(te){var ue,ne;return te=te||{level:"AA",size:"small"},ue=(te.level||"AA").toUpperCase(),ne=(te.size||"small").toLowerCase(),ue!=="AA"&&ue!=="AAA"&&(ue="AA"),ne!=="small"&&ne!=="large"&&(ne="small"),{level:ue,size:ne}}ut.exports?ut.exports=D:!(le=function(){return D}.call(Ze,re,Ze,ut),le!==void 0&&(ut.exports=le))})(Math)},bT9E:function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return $});var le=re("VTBJ");function $(R,Z){var F=Object(le.a)({},R);return Array.isArray(Z)&&Z.forEach(function(P){delete F[P]}),F}},c5Ni:function(ut,Ze,re){},dejd:function(ut,Ze,re){},dmUQ:function(ut,Ze,re){"use strict";var le=re("Ff2n"),$=re("rePB"),R=re("1OyB"),Z=re("vuIU"),F=re("Ji7U"),P=re("md7G"),K=re("foSv"),j=re("cDcd"),N=re.n(j),D=re("TSYQ"),y=re.n(D),A=re("4IlW");function k(h,o){var E=Object.keys(h);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(h);o&&(g=g.filter(function(S){return Object.getOwnPropertyDescriptor(h,S).enumerable})),E.push.apply(E,g)}return E}function T(h){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?k(Object(E),!0).forEach(function(g){Object($.a)(h,g,E[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(E)):k(Object(E)).forEach(function(g){Object.defineProperty(h,g,Object.getOwnPropertyDescriptor(E,g))})}return h}function C(h){var o=b();return function(){var g=Object(K.a)(h),S;if(o){var M=Object(K.a)(this).constructor;S=Reflect.construct(g,arguments,M)}else S=g.apply(this,arguments);return Object(P.a)(this,S)}}function b(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(h){return!1}}function u(){}function a(h){h.preventDefault()}var l=function(o){return o.replace(/[^\w.-]+/g,"")},d=200,_=600,v=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,m=function(o){return o!=null},L=function(o,E){return E===o||typeof E=="number"&&typeof o=="number"&&isNaN(E)&&isNaN(o)},x=function(h){Object(F.a)(E,h);var o=C(E);function E(g){var S;Object(R.a)(this,E),S=o.call(this,g),S.onKeyDown=function(G){var V=S.props,O=V.onKeyDown,I=V.onPressEnter;if(G.keyCode===A.a.UP){var X=S.getRatio(G);S.up(G,X,null),S.stop()}else if(G.keyCode===A.a.DOWN){var q=S.getRatio(G);S.down(G,q,null),S.stop()}else G.keyCode===A.a.ENTER&&I&&I(G);if(S.recordCursorPosition(),S.lastKeyCode=G.keyCode,O){for(var oe=arguments.length,ce=new Array(oe>1?oe-1:0),Le=1;Le<oe;Le++)ce[Le-1]=arguments[Le];O.apply(void 0,[G].concat(ce))}},S.onKeyUp=function(G){var V=S.props.onKeyUp;if(S.stop(),S.recordCursorPosition(),V){for(var O=arguments.length,I=new Array(O>1?O-1:0),X=1;X<O;X++)I[X-1]=arguments[X];V.apply(void 0,[G].concat(I))}},S.onChange=function(G){var V=S.props.onChange;S.state.focused&&(S.inputting=!0),S.rawInput=S.props.parser(S.getValueFromEvent(G)),S.setState({inputValue:S.rawInput}),V(S.toNumber(S.rawInput))},S.onMouseUp=function(){var G=S.props.onMouseUp;S.recordCursorPosition(),G&&G.apply(void 0,arguments)},S.onFocus=function(){var G;S.setState({focused:!0}),(G=S.props).onFocus.apply(G,arguments)},S.onBlur=function(){var G=S.props.onBlur;S.inputting=!1,S.setState({focused:!1});var V=S.getCurrentValidValue(S.state.inputValue),O=S.setValue(V,u);if(G){var I=S.input.value,X=S.getInputDisplayValue({focus:!1,value:O});S.input.value=X&&Number(X),G.apply(void 0,arguments),S.input.value=I}},S.getRatio=function(G){var V=1;return G.metaKey||G.ctrlKey?V=.1:G.shiftKey&&(V=10),V},S.getFullNum=function(G){return isNaN(G)?G:/e/i.test(String(G))?Number(G).toFixed(18).replace(/\.?0+$/,""):G},S.getPrecision=function(G){if(m(S.props.precision))return S.props.precision;var V=String(G);if(V.indexOf("e-")>=0)return parseInt(V.slice(V.indexOf("e-")+2),10);var O=0;return V.indexOf(".")>=0&&(O=V.length-V.indexOf(".")-1),O},S.getInputDisplayValue=function(G){var V=G||S.state,O=V.focused,I=V.inputValue,X=V.value,q;O?q=I:q=S.toPrecisionAsStep(X),q==null&&(q="");var oe=S.formatWrapper(q);return m(S.props.decimalSeparator)&&(oe=oe.toString().replace(".",S.props.decimalSeparator)),oe},S.recordCursorPosition=function(){try{S.cursorStart=S.input.selectionStart,S.cursorEnd=S.input.selectionEnd,S.currentValue=S.input.value,S.cursorBefore=S.input.value.substring(0,S.cursorStart),S.cursorAfter=S.input.value.substring(S.cursorEnd)}catch(G){}},S.restoreByAfter=function(G){if(G===void 0)return!1;var V=S.input.value,O=V.lastIndexOf(G);if(O===-1)return!1;var I=S.cursorBefore.length;return S.lastKeyCode===A.a.DELETE&&S.cursorBefore.charAt(I-1)===G[0]?(S.fixCaret(I,I),!0):O+G.length===V.length?(S.fixCaret(O,O),!0):!1},S.partRestoreByAfter=function(G){return G===void 0?!1:Array.prototype.some.call(G,function(V,O){var I=G.substring(O);return S.restoreByAfter(I)})},S.isNotCompleteNumber=function(G){return isNaN(G)||G===""||G===null||G&&G.toString().indexOf(".")===G.toString().length-1},S.stop=function(){S.autoStepTimer&&clearTimeout(S.autoStepTimer)},S.down=function(G,V,O){S.pressingUpOrDown=!0,S.step("down",G,V,O)},S.up=function(G,V,O){S.pressingUpOrDown=!0,S.step("up",G,V,O)},S.saveInput=function(G){S.input=G};var M=g.value;M===void 0&&(M=g.defaultValue),S.state={focused:g.autoFocus};var U=S.getValidValue(S.toNumber(M));return S.state=T(T({},S.state),{},{inputValue:S.toPrecisionAsStep(U),value:U}),S}return Object(Z.a)(E,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(S){var M=this.props,U=M.value,G=M.onChange,V=M.max,O=M.min,I=this.state.focused;if(S){if(!L(S.value,U)||!L(S.max,V)||!L(S.min,O)){var X=I?U:this.getValidValue(U),q;this.pressingUpOrDown?q=X:this.inputting?q=this.rawInput:q=this.toPrecisionAsStep(X),this.setState({value:X,inputValue:q})}var oe="value"in this.props?U:this.state.value;"max"in this.props&&S.max!==V&&typeof oe=="number"&&oe>V&&G&&G(V),"min"in this.props&&S.min!==O&&typeof oe=="number"&&oe<O&&G&&G(O)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ce=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===A.a.BACKSPACE?ce=this.cursorStart-1:this.lastKeyCode===A.a.DELETE&&(ce=this.cursorStart):ce=this.input.value.length,this.fixCaret(ce,ce)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case A.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case A.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Le){}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(S){var M=S;return M===""?M="":this.isNotCompleteNumber(parseFloat(M))?M=this.state.value:M=this.getValidValue(M),this.toNumber(M)}},{key:"getValueFromEvent",value:function(S){var M=S.target.value.trim().replace(/。/g,".");return m(this.props.decimalSeparator)&&(M=M.replace(this.props.decimalSeparator,".")),M}},{key:"getValidValue",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,G=parseFloat(S);return isNaN(G)?S:(G<M&&(G=M),G>U&&(G=U),G)}},{key:"setValue",value:function(S,M){var U=this.props.precision,G=this.isNotCompleteNumber(parseFloat(S))?null:parseFloat(S),V=this.state.value,O=V===void 0?null:V,I=this.state.inputValue,X=I===void 0?null:I,q=typeof G=="number"?G.toFixed(U):"".concat(G),oe=G!==O||q!=="".concat(X);return"value"in this.props?(X=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:X},M)):this.setState({value:G,inputValue:this.toPrecisionAsStep(S)},M),oe&&this.props.onChange(G),G}},{key:"getMaxPrecision",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.props,G=U.precision,V=U.step;if(m(G))return G;var O=this.getPrecision(M),I=this.getPrecision(V),X=this.getPrecision(S);return S?Math.max(X,O+I):O+I}},{key:"getPrecisionFactor",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,U=this.getMaxPrecision(S,M);return Math.pow(10,U)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(S){return this.props.formatter?this.props.formatter(S):S}},{key:"toPrecisionAsStep",value:function(S){if(this.isNotCompleteNumber(S)||S==="")return S;var M=Math.abs(this.getMaxPrecision(S));return isNaN(M)?S.toString():Number(S).toFixed(M)}},{key:"toNumber",value:function(S){var M=this.props.precision,U=this.state.focused,G=S&&S.length>16&&U;return this.isNotCompleteNumber(S)||G?S:m(M)?Math.round(S*Math.pow(10,M))/Math.pow(10,M):Number(S)}},{key:"upStep",value:function(S,M){var U=this.props.step,G=this.getPrecisionFactor(S,M),V=Math.abs(this.getMaxPrecision(S,M)),O=((G*S+G*U*M)/G).toFixed(V);return this.toNumber(O)}},{key:"downStep",value:function(S,M){var U=this.props.step,G=this.getPrecisionFactor(S,M),V=Math.abs(this.getMaxPrecision(S,M)),O=((G*S-G*U*M)/G).toFixed(V);return this.toNumber(O)}},{key:"step",value:function(S,M){var U=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,V=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var O=this.props;if(O.disabled)return;var I=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(I))return;var X=this["".concat(S,"Step")](I,G),q=X>O.max||X<O.min;if(X>O.max?X=O.max:X<O.min&&(X=O.min),this.setValue(X,null),this.setState({focused:!0},function(){U.pressingUpOrDown=!1}),q)return;this.autoStepTimer=setTimeout(function(){U[S](M,G,!0)},V?d:_)}},{key:"fixCaret",value:function(S,M){if(S===void 0||M===void 0||!this.input||!this.input.value)return;try{var U=this.input.selectionStart,G=this.input.selectionEnd;(S!==U||M!==G)&&this.input.setSelectionRange(S,M)}catch(V){}}},{key:"render",value:function(){var S,M=this.props,U=M.prefixCls,G=M.disabled,V=M.readOnly,O=M.useTouch,I=M.autoComplete,X=M.upHandler,q=M.downHandler,oe=M.className,ce=M.max,Le=M.min,Ee=M.style,we=M.title,Te=M.onMouseEnter,ye=M.onMouseLeave,fe=M.onMouseOver,se=M.onMouseOut,te=M.required,ue=M.onClick,ne=M.tabIndex,_e=M.type,Re=M.placeholder,xe=M.id,ke=M.inputMode,Ne=M.pattern,He=M.step,Be=M.maxLength,Me=M.autoFocus,Oe=M.name,Ye=M.onPaste,Je=M.onInput,Ve=Object(le.a)(M,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),je=this.state,rt=je.value,Qe=je.focused,tt=y()(U,(S={},Object($.a)(S,oe,!!oe),Object($.a)(S,"".concat(U,"-disabled"),G),Object($.a)(S,"".concat(U,"-focused"),Qe),S)),Pe={};Object.keys(Ve).forEach(function(me){(me.substr(0,5)==="data-"||me.substr(0,5)==="aria-"||me==="role")&&(Pe[me]=Ve[me])});var lt=!V&&!G,at=this.getInputDisplayValue(null),Fe=(rt||rt===0)&&(isNaN(rt)||Number(rt)>=ce),Xe=(rt||rt===0)&&(isNaN(rt)||Number(rt)<=Le),Ce=Fe||G||V,ve=Xe||G||V,be=y()("".concat(U,"-handler"),"".concat(U,"-handler-up"),Object($.a)({},"".concat(U,"-handler-up-disabled"),Ce)),ie=y()("".concat(U,"-handler"),"".concat(U,"-handler-down"),Object($.a)({},"".concat(U,"-handler-down-disabled"),ve)),ae=O?{onTouchStart:Ce?u:this.up,onTouchEnd:this.stop}:{onMouseDown:Ce?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},de=O?{onTouchStart:ve?u:this.down,onTouchEnd:this.stop}:{onMouseDown:ve?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return N.a.createElement("div",{className:tt,style:Ee,title:we,onMouseEnter:Te,onMouseLeave:ye,onMouseOver:fe,onMouseOut:se,onFocus:function(){return null},onBlur:function(){return null}},N.a.createElement("div",{className:"".concat(U,"-handler-wrap")},N.a.createElement("span",Object.assign({unselectable:"on"},ae,{role:"button","aria-label":"Increase Value","aria-disabled":Ce,className:be}),X||N.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-up-inner"),onClick:a})),N.a.createElement("span",Object.assign({unselectable:"on"},de,{role:"button","aria-label":"Decrease Value","aria-disabled":ve,className:ie}),q||N.a.createElement("span",{unselectable:"on",className:"".concat(U,"-handler-down-inner"),onClick:a}))),N.a.createElement("div",{className:"".concat(U,"-input-wrap")},N.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Le,"aria-valuemax":ce,"aria-valuenow":rt,required:te,type:_e,placeholder:Re,onPaste:Ye,onClick:ue,onMouseUp:this.onMouseUp,className:"".concat(U,"-input"),tabIndex:ne,autoComplete:I,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:lt?this.onKeyDown:u,onKeyUp:lt?this.onKeyUp:u,autoFocus:Me,maxLength:Be,readOnly:V,disabled:G,max:ce,min:Le,step:He,name:Oe,title:we,id:xe,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(at),pattern:Ne,inputMode:ke,onInput:Je},Pe))))}}]),E}(N.a.Component);x.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:v,min:-v,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:l,required:!1,autoComplete:"off"};var p=x,f=Ze.a=p},gHQ5:function(ut,Ze,re){"use strict";re.r(Ze);var le=re("+L6B"),$=re("2/Rp"),R=re("5NDa"),Z=re("5rEg"),F=re("k1fw"),P=re("9og8"),K=re("y8nQ"),j=re("Vl3Y"),N=re("tJVT"),D=re("CiB2"),y=re("WmNS"),A=re.n(y),k=re("cDcd"),T=re.n(k),C=re("3vs6"),b=re("l3Yi"),u=re.n(b),a=re("Ot1p"),l=re("500L"),d=re("ErOA"),_=re("Ty5D"),v=re("9kvl"),m=function(x){var p;Object(D.a)(x);var f=Object(k.useState)({}),h=Object(N.a)(f,2),o=h[0],E=h[1],g=j.a.useForm(),S=Object(N.a)(g,1),M=S[0],U=Object(k.useState)(!0),G=Object(N.a)(U,2),V=G[0],O=G[1],I=Object(k.useState)(!1),X=Object(N.a)(I,2),q=X[0],oe=X[1],ce=Object(k.useState)(!1),Le=Object(N.a)(ce,2),Ee=Le[0],we=Le[1],Te=Object(_.i)(),ye=Te==null?void 0:Te.virtual_spacesId;Object(k.useEffect)(function(){Te!=null&&Te.id?fe():we(!0)},[]);var fe=function(){var te=Object(P.a)(A.a.mark(function ue(){var ne,_e;return A.a.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:return xe.next=2,Object(d.a)("/api/virtual_classrooms/".concat(ye,"/syllabuses/").concat(Te==null?void 0:Te.id,"/edit.json"),{method:"get"});case 2:ne=xe.sent,ne&&(_e={title:ne.title,description:ne.description,attachment_ids:Object(l.a)(ne.attachments)},console.log(_e,"formData"),M.setFieldsValue(Object(F.a)({},_e)),E(Object(F.a)({},_e)),we(!0));case 4:case"end":return xe.stop()}},ue)}));return function(){return te.apply(this,arguments)}}(),se=function(){var te=Object(P.a)(A.a.mark(function ue(ne){var _e,Re,xe,ke,Ne;return A.a.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:if(Re=Object(F.a)({},o),Re.attachment_ids&&(Re.attachment_ids=Re==null||((xe=Re.attachment_ids)===null||xe===void 0)?void 0:xe.map(function(Me){return Me.response.id})),oe(!0),!(Te!=null&&Te.id)){Be.next=9;break}return Be.next=6,Object(d.a)("/api/virtual_classrooms/".concat(ye,"/syllabuses/").concat(Te==null?void 0:Te.id,".json"),{method:"put",body:Object(F.a)({},Re)});case 6:ke=Be.sent,Be.next=12;break;case 9:return Be.next=11,Object(d.a)("/api/virtual_classrooms/".concat(ye,"/syllabuses.json"),{method:"post",body:Object(F.a)({},Re)});case 11:ke=Be.sent;case 12:(_e=ke)!==null&&_e!==void 0&&_e.virtual_classroom_id&&v.d.push("/vspaces/".concat(ye,"/syllabuses/").concat((Ne=ke)===null||Ne===void 0?void 0:Ne.id,"/detail")),oe(!1);case 14:case"end":return Be.stop()}},ue)}));return function(ne){return te.apply(this,arguments)}}();return T.a.createElement("div",{className:u.a.wrap},T.a.createElement(C.a,null),T.a.createElement("div",{className:u.a.form},T.a.createElement("div",{className:u.a.title},T.a.createElement("span",{onClick:function(){return v.d.push("/vspaces/".concat(ye,"/syllabuses"))}},T.a.createElement("i",{className:"iconfont icon-zuoshangjiaofanhui"}),"\u8FD4\u56DE"),T.a.createElement("span",null,"\u65B0\u5EFA\u6559\u5B66\u5927\u7EB2")),T.a.createElement(j.a,{colon:!1,form:M,scrollToFirstError:!0,onValuesChange:function(){E(Object(F.a)({},M.getFieldsValue()))},onFinish:se},T.a.createElement(j.a.Item,{name:"title",label:"\u5927\u7EB2\u6807\u9898",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5927\u7EB2\u6807\u9898"}]},T.a.createElement(Z.a,{maxLength:60,suffix:"".concat(((p=o.title)===null||p===void 0?void 0:p.length)||0,"/60"),placeholder:"\u8BF7\u8F93\u5165\u5927\u7EB2\u6807\u9898"})),T.a.createElement("div",{style:{margin:"20px 0 12px 10px"}},"\u5927\u7EB2\u5185\u5BB9"),T.a.createElement(j.a.Item,{className:"ml10",name:"description",rules:[{max:5e4,message:"\u4F5C\u4E1A\u7B80\u4ECB\u6700\u5927\u9650\u523650000\u4E2A\u5B57\u7B26"}]},T.a.createElement(a.a,{watch:!0,defaultValue:o.description})),T.a.createElement(j.a.Item,{className:"ml10",name:"attachment_ids",label:"\u9644\u4EF6"},Ee&&T.a.createElement(l.b,{className:u.a.file,title:T.a.createElement("span",null,T.a.createElement("i",{className:"iconfont icon-shangchuan1 font14 mr5"}),"\u4E0A\u4F20\u9644\u4EF6")})),T.a.createElement("div",{style:{textAlign:"right"}},T.a.createElement(j.a.Item,null,T.a.createElement($.a,{onClick:function(){return v.d.push("/vspaces/".concat(ye,"/syllabuses"))},className:"mr10"},"\u53D6\u6D88"),T.a.createElement($.a,{type:"primary",htmlType:"submit",loading:q},"\u786E\u8BA4"))))))};Ze.default=m},h78n:function(ut,Ze,re){"use strict";re.d(Ze,"a",function(){return S});var le=re("cDcd"),$=re.n(le),R=re("TSYQ"),Z=re.n(R),F={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1},P=function(G){var V=G.map(function(){return Object(le.useRef)()}),O=Object(le.useRef)();return Object(le.useEffect)(function(){var I=Date.now(),X=!1;Object.keys(V).forEach(function(q){var oe=V[q].current;if(!oe)return;X=!0;var ce=oe.style;ce.transitionDuration=".3s, .3s, .3s, .06s",O.current&&I-O.current<100&&(ce.transitionDuration="0s, 0s")}),X&&(O.current=Date.now())}),[V]};function K(){return K=Object.assign||function(U){for(var G=1;G<arguments.length;G++){var V=arguments[G];for(var O in V)Object.prototype.hasOwnProperty.call(V,O)&&(U[O]=V[O])}return U},K.apply(this,arguments)}function j(U,G){return k(U)||A(U,G)||D(U,G)||N()}function N(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D(U,G){if(!U)return;if(typeof U=="string")return y(U,G);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return y(U,G)}function y(U,G){(G==null||G>U.length)&&(G=U.length);for(var V=0,O=new Array(G);V<G;V++)O[V]=U[V];return O}function A(U,G){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],O=!0,I=!1,X=void 0;try{for(var q=U[Symbol.iterator](),oe;!(O=(oe=q.next()).done)&&!(V.push(oe.value),G&&V.length===G);O=!0);}catch(ce){I=!0,X=ce}finally{try{!O&&q.return!=null&&q.return()}finally{if(I)throw X}}return V}function k(U){if(Array.isArray(U))return U}function T(U,G){if(U==null)return{};var V=C(U,G),O,I;if(Object.getOwnPropertySymbols){var X=Object.getOwnPropertySymbols(U);for(I=0;I<X.length;I++){if(O=X[I],G.indexOf(O)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,O))continue;V[O]=U[O]}}return V}function C(U,G){if(U==null)return{};var V={},O=Object.keys(U),I,X;for(X=0;X<O.length;X++){if(I=O[X],G.indexOf(I)>=0)continue;V[I]=U[I]}return V}var b=function(G){var V=G.className,O=G.percent,I=G.prefixCls,X=G.strokeColor,q=G.strokeLinecap,oe=G.strokeWidth,ce=G.style,Le=G.trailColor,Ee=G.trailWidth,we=G.transition,Te=T(G,["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"]);delete Te.gapPosition;var ye=Array.isArray(O)?O:[O],fe=Array.isArray(X)?X:[X],se=P(ye),te=j(se,1),ue=te[0],ne=oe/2,_e=100-oe/2,Re="M ".concat(q==="round"?ne:0,",").concat(ne,`
L `).concat(q==="round"?_e:100,",").concat(ne),xe="0 0 100 ".concat(oe),ke=0;return $.a.createElement("svg",K({className:Z()("".concat(I,"-line"),V),viewBox:xe,preserveAspectRatio:"none",style:ce},Te),$.a.createElement("path",{className:"".concat(I,"-line-trail"),d:Re,strokeLinecap:q,stroke:Le,strokeWidth:Ee||oe,fillOpacity:"0"}),ye.map(function(Ne,He){var Be={strokeDasharray:"".concat(Ne,"px, 100px"),strokeDashoffset:"-".concat(ke,"px"),transition:we||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},Me=fe[He]||fe[fe.length-1];return ke+=Ne,$.a.createElement("path",{key:He,className:"".concat(I,"-line-path"),d:Re,strokeLinecap:q,stroke:Me,strokeWidth:oe,fillOpacity:"0",ref:ue[He],style:Be})}))};b.defaultProps=F;var u=b;function a(){return a=Object.assign||function(U){for(var G=1;G<arguments.length;G++){var V=arguments[G];for(var O in V)Object.prototype.hasOwnProperty.call(V,O)&&(U[O]=V[O])}return U},a.apply(this,arguments)}function l(U,G){return L(U)||m(U,G)||_(U,G)||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 _(U,G){if(!U)return;if(typeof U=="string")return v(U,G);var V=Object.prototype.toString.call(U).slice(8,-1);if(V==="Object"&&U.constructor&&(V=U.constructor.name),V==="Map"||V==="Set")return Array.from(U);if(V==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V))return v(U,G)}function v(U,G){(G==null||G>U.length)&&(G=U.length);for(var V=0,O=new Array(G);V<G;V++)O[V]=U[V];return O}function m(U,G){if(typeof Symbol=="undefined"||!(Symbol.iterator in Object(U)))return;var V=[],O=!0,I=!1,X=void 0;try{for(var q=U[Symbol.iterator](),oe;!(O=(oe=q.next()).done)&&!(V.push(oe.value),G&&V.length===G);O=!0);}catch(ce){I=!0,X=ce}finally{try{!O&&q.return!=null&&q.return()}finally{if(I)throw X}}return V}function L(U){if(Array.isArray(U))return U}function x(U,G){if(U==null)return{};var V=p(U,G),O,I;if(Object.getOwnPropertySymbols){var X=Object.getOwnPropertySymbols(U);for(I=0;I<X.length;I++){if(O=X[I],G.indexOf(O)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(U,O))continue;V[O]=U[O]}}return V}function p(U,G){if(U==null)return{};var V={},O=Object.keys(U),I,X;for(X=0;X<O.length;X++){if(I=O[X],G.indexOf(I)>=0)continue;V[I]=U[I]}return V}var f=0;function h(U){return+U.replace("%","")}function o(U){return Array.isArray(U)?U:[U]}function E(U,G,V,O){var I=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,X=arguments.length>5?arguments[5]:void 0,q=50-O/2,oe=0,ce=-q,Le=0,Ee=-2*q;switch(X){case"left":oe=-q,ce=0,Le=2*q,Ee=0;break;case"right":oe=q,ce=0,Le=-2*q,Ee=0;break;case"bottom":ce=q,Ee=2*q;break;default:}var we="M 50,50 m ".concat(oe,",").concat(ce,`
a `).concat(q,",").concat(q," 0 1 1 ").concat(Le,",").concat(-Ee,`
a `).concat(q,",").concat(q," 0 1 1 ").concat(-Le,",").concat(Ee),Te=Math.PI*2*q,ye={stroke:V,strokeDasharray:"".concat(G/100*(Te-I),"px ").concat(Te,"px"),strokeDashoffset:"-".concat(I/2+U/100*(Te-I),"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s"};return{pathString:we,pathStyle:ye}}var g=function(G){var V=G.prefixCls,O=G.strokeWidth,I=G.trailWidth,X=G.gapDegree,q=G.gapPosition,oe=G.trailColor,ce=G.strokeLinecap,Le=G.style,Ee=G.className,we=G.strokeColor,Te=G.percent,ye=x(G,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"]),fe=Object(le.useMemo)(function(){return f+=1,f},[]),se=E(0,100,oe,O,X,q),te=se.pathString,ue=se.pathStyle,ne=o(Te),_e=o(we),Re=_e.find(function(Be){return Object.prototype.toString.call(Be)==="[object Object]"}),xe=P(ne),ke=l(xe,1),Ne=ke[0],He=function(){var Me=0;return ne.map(function(Oe,Ye){var Je=_e[Ye]||_e[_e.length-1],Ve=Object.prototype.toString.call(Je)==="[object Object]"?"url(#".concat(V,"-gradient-").concat(fe,")"):"",je=E(Me,Oe,Je,O,X,q);return Me+=Oe,$.a.createElement("path",{key:Ye,className:"".concat(V,"-circle-path"),d:je.pathString,stroke:Ve,strokeLinecap:ce,strokeWidth:O,opacity:Oe===0?0:1,fillOpacity:"0",style:je.pathStyle,ref:Ne[Ye]})})};return $.a.createElement("svg",a({className:Z()("".concat(V,"-circle"),Ee),viewBox:"0 0 100 100",style:Le},ye),Re&&$.a.createElement("defs",null,$.a.createElement("linearGradient",{id:"".concat(V,"-gradient-").concat(fe),x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(Re).sort(function(Be,Me){return h(Be)-h(Me)}).map(function(Be,Me){return $.a.createElement("stop",{key:Me,offset:Be,stopColor:Re[Be]})}))),$.a.createElement("path",{className:"".concat(V,"-circle-trail"),d:te,stroke:oe,strokeLinecap:ce,strokeWidth:I||O,fillOpacity:"0",style:ue}),He().reverse())};g.defaultProps=F;var S=g,M={Line:u,Circle:S}},kSUc:function(ut,Ze,re){},l3Yi:function(ut,Ze,re){ut.exports={flex_box_center:"flex_box_center___354pw",flex_space_between:"flex_space_between___10PE2",flex_box_vertical_center:"flex_box_vertical_center___YT9_A",flex_box_center_end:"flex_box_center_end___1qNoU",flex_box_column:"flex_box_column___2E4_8",wrap:"wrap___1umYZ",form:"form___2x_Sk",title:"title___idVlc",file:"file___1g_02"}},lZu9:function(ut,Ze,re){(function(le){le(re("VrN/"),re("1eCo"),re("8EBN"))})(function(le){"use strict";le.defineMode("markdown",function($,R){var Z=le.getMode($,"text/html"),F=Z.name=="null";function P(O){if(le.findModeByName){var I=le.findModeByName(O);I&&(O=I.mime||I.mimes[0])}var X=le.getMode($,O);return X.name=="null"?null:X}R.highlightFormatting===void 0&&(R.highlightFormatting=!1),R.maxBlockquoteDepth===void 0&&(R.maxBlockquoteDepth=0),R.taskLists===void 0&&(R.taskLists=!1),R.strikethrough===void 0&&(R.strikethrough=!1),R.emoji===void 0&&(R.emoji=!1),R.fencedCodeBlockHighlighting===void 0&&(R.fencedCodeBlockHighlighting=!0),R.fencedCodeBlockDefaultMode===void 0&&(R.fencedCodeBlockDefaultMode="text/plain"),R.xml===void 0&&(R.xml=!0),R.tokenTypeOverrides===void 0&&(R.tokenTypeOverrides={});var K={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 j in K)K.hasOwnProperty(j)&&R.tokenTypeOverrides[j]&&(K[j]=R.tokenTypeOverrides[j]);var N=/^([*\-_])(?:\s*\1){2,}\s*$/,D=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,y=/^\[(x| )\](?=\s)/i,A=R.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,T=/^[^#!\[\]*_\\<>` "'(~:]+/,C=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,b=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,a=" ";function l(O,I,X){return I.f=I.inline=X,X(O,I)}function d(O,I,X){return I.f=I.block=X,X(O,I)}function _(O){return!O||!/\S/.test(O.string)}function v(O){if(O.linkTitle=!1,O.linkHref=!1,O.linkText=!1,O.em=!1,O.strong=!1,O.strikethrough=!1,O.quote=0,O.indentedCode=!1,O.f==L){var I=F;if(!I){var X=le.innerMode(Z,O.htmlState);I=X.mode.name=="xml"&&X.state.tagStart===null&&!X.state.context&&X.state.tokenize.isInText}I&&(O.f=h,O.block=m,O.htmlState=null)}return O.trailingSpace=0,O.trailingSpaceNewLine=!1,O.prevLine=O.thisLine,O.thisLine={stream:null},null}function m(O,I){var X=O.column()===I.indentation,q=_(I.prevLine.stream),oe=I.indentedCode,ce=I.prevLine.hr,Le=I.list!==!1,Ee=(I.listStack[I.listStack.length-1]||0)+3;I.indentedCode=!1;var we=I.indentation;if(I.indentationDiff===null&&(I.indentationDiff=I.indentation,Le)){for(I.list=null;we<I.listStack[I.listStack.length-1];)I.listStack.pop(),I.listStack.length?I.indentation=I.listStack[I.listStack.length-1]:I.list=!1;I.list!==!1&&(I.indentationDiff=we-I.listStack[I.listStack.length-1])}var Te=!q&&!ce&&!I.prevLine.header&&(!Le||!oe)&&!I.prevLine.fencedCodeEnd,ye=(I.list===!1||ce||q)&&I.indentation<=Ee&&O.match(N),fe=null;if(I.indentationDiff>=4&&(oe||I.prevLine.fencedCodeEnd||I.prevLine.header||q))return O.skipToEnd(),I.indentedCode=!0,K.code;if(O.eatSpace())return null;if(X&&I.indentation<=Ee&&(fe=O.match(A))&&fe[1].length<=6)return I.quote=0,I.header=fe[1].length,I.thisLine.header=!0,R.highlightFormatting&&(I.formatting="header"),I.f=I.inline,p(I);if(I.indentation<=Ee&&O.eat(">"))return I.quote=X?1:I.quote+1,R.highlightFormatting&&(I.formatting="quote"),O.eatSpace(),p(I);if(!ye&&!I.setext&&X&&I.indentation<=Ee&&(fe=O.match(D))){var se=fe[1]?"ol":"ul";return I.indentation=we+O.current().length,I.list=!0,I.quote=0,I.listStack.push(I.indentation),I.em=!1,I.strong=!1,I.code=!1,I.strikethrough=!1,R.taskLists&&O.match(y,!1)&&(I.taskList=!0),I.f=I.inline,R.highlightFormatting&&(I.formatting=["list","list-"+se]),p(I)}else{if(X&&I.indentation<=Ee&&(fe=O.match(C,!0)))return I.quote=0,I.fencedEndRE=new RegExp(fe[1]+"+ *$"),I.localMode=R.fencedCodeBlockHighlighting&&P(fe[2]||R.fencedCodeBlockDefaultMode),I.localMode&&(I.localState=le.startState(I.localMode)),I.f=I.block=x,R.highlightFormatting&&(I.formatting="code-block"),I.code=-1,p(I);if(I.setext||(!Te||!Le)&&!I.quote&&I.list===!1&&!I.code&&!ye&&!b.test(O.string)&&(fe=O.lookAhead(1))&&(fe=fe.match(k)))return I.setext?(I.header=I.setext,I.setext=0,O.skipToEnd(),R.highlightFormatting&&(I.formatting="header")):(I.header=fe[0].charAt(0)=="="?1:2,I.setext=I.header),I.thisLine.header=!0,I.f=I.inline,p(I);if(ye)return O.skipToEnd(),I.hr=!0,I.thisLine.hr=!0,K.hr;if(O.peek()==="[")return l(O,I,M)}return l(O,I,I.inline)}function L(O,I){var X=Z.token(O,I.htmlState);if(!F){var q=le.innerMode(Z,I.htmlState);(q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText||I.md_inside&&O.current().indexOf(">")>-1)&&(I.f=h,I.block=m,I.htmlState=null)}return X}function x(O,I){var X=I.listStack[I.listStack.length-1]||0,q=I.indentation<X,oe=X+3;if(I.fencedEndRE&&I.indentation<=oe&&(q||O.match(I.fencedEndRE))){R.highlightFormatting&&(I.formatting="code-block");var ce;return q||(ce=p(I)),I.localMode=I.localState=null,I.block=m,I.f=h,I.fencedEndRE=null,I.code=0,I.thisLine.fencedCodeEnd=!0,q?d(O,I,I.block):ce}else return I.localMode?I.localMode.token(O,I.localState):(O.skipToEnd(),K.code)}function p(O){var I=[];if(O.formatting){I.push(K.formatting),typeof O.formatting=="string"&&(O.formatting=[O.formatting]);for(var X=0;X<O.formatting.length;X++)I.push(K.formatting+"-"+O.formatting[X]),O.formatting[X]==="header"&&I.push(K.formatting+"-"+O.formatting[X]+"-"+O.header),O.formatting[X]==="quote"&&(!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=O.quote?I.push(K.formatting+"-"+O.formatting[X]+"-"+O.quote):I.push("error"))}if(O.taskOpen)return I.push("meta"),I.length?I.join(" "):null;if(O.taskClosed)return I.push("property"),I.length?I.join(" "):null;if(O.linkHref?I.push(K.linkHref,"url"):(O.strong&&I.push(K.strong),O.em&&I.push(K.em),O.strikethrough&&I.push(K.strikethrough),O.emoji&&I.push(K.emoji),O.linkText&&I.push(K.linkText),O.code&&I.push(K.code),O.image&&I.push(K.image),O.imageAltText&&I.push(K.imageAltText,"link"),O.imageMarker&&I.push(K.imageMarker)),O.header&&I.push(K.header,K.header+"-"+O.header),O.quote&&(I.push(K.quote),!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=O.quote?I.push(K.quote+"-"+O.quote):I.push(K.quote+"-"+R.maxBlockquoteDepth)),O.list!==!1){var q=(O.listStack.length-1)%3;q?q===1?I.push(K.list2):I.push(K.list3):I.push(K.list1)}return O.trailingSpaceNewLine?I.push("trailing-space-new-line"):O.trailingSpace&&I.push("trailing-space-"+(O.trailingSpace%2?"a":"b")),I.length?I.join(" "):null}function f(O,I){return O.match(T,!0)?p(I):void 0}function h(O,I){var X=I.text(O,I);if(typeof X!="undefined")return X;if(I.list)return I.list=null,p(I);if(I.taskList){var q=O.match(y,!0)[1]===" ";return q?I.taskOpen=!0:I.taskClosed=!0,R.highlightFormatting&&(I.formatting="task"),I.taskList=!1,p(I)}if(I.taskOpen=!1,I.taskClosed=!1,I.header&&O.match(/^#+$/,!0))return R.highlightFormatting&&(I.formatting="header"),p(I);var oe=O.next();if(I.linkTitle){I.linkTitle=!1;var ce=oe;oe==="("&&(ce=")"),ce=(ce+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Le="^\\s*(?:[^"+ce+"\\\\]+|\\\\\\\\|\\\\.)"+ce;if(O.match(new RegExp(Le),!0))return K.linkHref}if(oe==="`"){var Ee=I.formatting;R.highlightFormatting&&(I.formatting="code"),O.eatWhile("`");var we=O.current().length;if(I.code==0&&(!I.quote||we==1))return I.code=we,p(I);if(we==I.code){var Te=p(I);return I.code=0,Te}else return I.formatting=Ee,p(I)}else if(I.code)return p(I);if(oe==="\\"&&(O.next(),R.highlightFormatting)){var ye=p(I),fe=K.formatting+"-escape";return ye?ye+" "+fe:fe}if(oe==="!"&&O.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return I.imageMarker=!0,I.image=!0,R.highlightFormatting&&(I.formatting="image"),p(I);if(oe==="["&&I.imageMarker&&O.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return I.imageMarker=!1,I.imageAltText=!0,R.highlightFormatting&&(I.formatting="image"),p(I);if(oe==="]"&&I.imageAltText){R.highlightFormatting&&(I.formatting="image");var ye=p(I);return I.imageAltText=!1,I.image=!1,I.inline=I.f=E,ye}if(oe==="["&&!I.image)return I.linkText&&O.match(/^.*?\]/)||(I.linkText=!0,R.highlightFormatting&&(I.formatting="link")),p(I);if(oe==="]"&&I.linkText){R.highlightFormatting&&(I.formatting="link");var ye=p(I);return I.linkText=!1,I.inline=I.f=O.match(/\(.*?\)| ?\[.*?\]/,!1)?E:h,ye}if(oe==="<"&&O.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=o,R.highlightFormatting&&(I.formatting="link");var ye=p(I);return ye?ye+=" ":ye="",ye+K.linkInline}if(oe==="<"&&O.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=o,R.highlightFormatting&&(I.formatting="link");var ye=p(I);return ye?ye+=" ":ye="",ye+K.linkEmail}if(R.xml&&oe==="<"&&O.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var se=O.string.indexOf(">",O.pos);if(se!=-1){var te=O.string.substring(O.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(te)&&(I.md_inside=!0)}return O.backUp(1),I.htmlState=le.startState(Z),d(O,I,L)}if(R.xml&&oe==="<"&&O.match(/^\/\w*?>/))return I.md_inside=!1,"tag";if(oe==="*"||oe==="_"){for(var ue=1,ne=O.pos==1?" ":O.string.charAt(O.pos-2);ue<3&&O.eat(oe);)ue++;var _e=O.peek()||" ",Re=!/\s/.test(_e)&&(!u.test(_e)||/\s/.test(ne)||u.test(ne)),xe=!/\s/.test(ne)&&(!u.test(ne)||/\s/.test(_e)||u.test(_e)),ke=null,Ne=null;if(ue%2&&(!I.em&&Re&&(oe==="*"||!xe||u.test(ne))?ke=!0:I.em==oe&&xe&&(oe==="*"||!Re||u.test(_e))&&(ke=!1)),ue>1&&(!I.strong&&Re&&(oe==="*"||!xe||u.test(ne))?Ne=!0:I.strong==oe&&xe&&(oe==="*"||!Re||u.test(_e))&&(Ne=!1)),Ne!=null||ke!=null){R.highlightFormatting&&(I.formatting=ke==null?"strong":Ne==null?"em":"strong em"),ke===!0&&(I.em=oe),Ne===!0&&(I.strong=oe);var Te=p(I);return ke===!1&&(I.em=!1),Ne===!1&&(I.strong=!1),Te}}else if(oe===" "&&(O.eat("*")||O.eat("_"))){if(O.peek()===" ")return p(I);O.backUp(1)}if(R.strikethrough){if(oe==="~"&&O.eatWhile(oe)){if(I.strikethrough){R.highlightFormatting&&(I.formatting="strikethrough");var Te=p(I);return I.strikethrough=!1,Te}else if(O.match(/^[^\s]/,!1))return I.strikethrough=!0,R.highlightFormatting&&(I.formatting="strikethrough"),p(I)}else if(oe===" "&&O.match(/^~~/,!0)){if(O.peek()===" ")return p(I);O.backUp(2)}}if(R.emoji&&oe===":"&&O.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){I.emoji=!0,R.highlightFormatting&&(I.formatting="emoji");var He=p(I);return I.emoji=!1,He}return oe===" "&&(O.match(/^ +$/,!1)?I.trailingSpace++:I.trailingSpace&&(I.trailingSpaceNewLine=!0)),p(I)}function o(O,I){var X=O.next();if(X===">"){I.f=I.inline=h,R.highlightFormatting&&(I.formatting="link");var q=p(I);return q?q+=" ":q="",q+K.linkInline}return O.match(/^[^>]+/,!0),K.linkInline}function E(O,I){if(O.eatSpace())return null;var X=O.next();return X==="("||X==="["?(I.f=I.inline=S(X==="("?")":"]"),R.highlightFormatting&&(I.formatting="link-string"),I.linkHref=!0,p(I)):"error"}var g={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function S(O){return function(I,X){var q=I.next();if(q===O){X.f=X.inline=h,R.highlightFormatting&&(X.formatting="link-string");var oe=p(X);return X.linkHref=!1,oe}return I.match(g[O]),X.linkHref=!0,p(X)}}function M(O,I){return O.match(/^([^\]\\]|\\.)*\]:/,!1)?(I.f=U,O.next(),R.highlightFormatting&&(I.formatting="link"),I.linkText=!0,p(I)):l(O,I,h)}function U(O,I){if(O.match(/^\]:/,!0)){I.f=I.inline=G,R.highlightFormatting&&(I.formatting="link");var X=p(I);return I.linkText=!1,X}return O.match(/^([^\]\\]|\\.)+/,!0),K.linkText}function G(O,I){return O.eatSpace()?null:(O.match(/^[^\s]+/,!0),O.peek()===void 0?I.linkTitle=!0:O.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),I.f=I.inline=h,K.linkHref+" url")}var V={startState:function(){return{f:m,prevLine:{stream:null},thisLine:{stream:null},block:m,htmlState:null,indentation:0,inline:h,text:f,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(O){return{f:O.f,prevLine:O.prevLine,thisLine:O.thisLine,block:O.block,htmlState:O.htmlState&&le.copyState(Z,O.htmlState),indentation:O.indentation,localMode:O.localMode,localState:O.localMode?le.copyState(O.localMode,O.localState):null,inline:O.inline,text:O.text,formatting:!1,linkText:O.linkText,linkTitle:O.linkTitle,linkHref:O.linkHref,code:O.code,em:O.em,strong:O.strong,strikethrough:O.strikethrough,emoji:O.emoji,header:O.header,setext:O.setext,hr:O.hr,taskList:O.taskList,list:O.list,listStack:O.listStack.slice(0),quote:O.quote,indentedCode:O.indentedCode,trailingSpace:O.trailingSpace,trailingSpaceNewLine:O.trailingSpaceNewLine,md_inside:O.md_inside,fencedEndRE:O.fencedEndRE}},token:function(O,I){if(I.formatting=!1,O!=I.thisLine.stream){if(I.header=0,I.hr=!1,O.match(/^\s*$/,!0))return v(I),null;if(I.prevLine=I.thisLine,I.thisLine={stream:O},I.taskList=!1,I.trailingSpace=0,I.trailingSpaceNewLine=!1,!I.localState&&(I.f=I.block,I.f!=L)){var X=O.match(/^\s*/,!0)[0].replace(/\t/g,a).length;if(I.indentation=X,I.indentationDiff=null,X>0)return null}}return I.f(O,I)},innerMode:function(O){return O.block==L?{state:O.htmlState,mode:Z}:O.localState?{state:O.localState,mode:O.localMode}:{state:O,mode:V}},indent:function(O,I,X){return O.block==L&&Z.indent?Z.indent(O.htmlState,I,X):O.localState&&O.localMode.indent?O.localMode.indent(O.localState,I,X):le.Pass},blankLine:v,getType:p,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return V},"xml"),le.defineMIME("text/markdown","markdown"),le.defineMIME("text/x-markdown","markdown")})},osHv:function(ut,Ze,re){(function(le){le(re("VrN/"))})(function(le){"use strict";var $=le.Pos;function R(u,a){return u.line-a.line||u.ch-a.ch}var Z="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",F=Z+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",P=new RegExp("<(/?)(["+Z+"]["+F+"]*)","g");function K(u,a,l,d){this.line=a,this.ch=l,this.cm=u,this.text=u.getLine(a),this.min=d?Math.max(d.from,u.firstLine()):u.firstLine(),this.max=d?Math.min(d.to-1,u.lastLine()):u.lastLine()}function j(u,a){var l=u.cm.getTokenTypeAt($(u.line,a));return l&&/\btag\b/.test(l)}function N(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function D(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function y(u){for(;;){var a=u.text.indexOf(">",u.ch);if(a==-1){if(N(u))continue;return}if(!j(u,a+1)){u.ch=a+1;continue}var l=u.text.lastIndexOf("/",a),d=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,d?"selfClose":"regular"}}function A(u){for(;;){var a=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(a==-1){if(D(u))continue;return}if(!j(u,a+1)){u.ch=a;continue}P.lastIndex=a,u.ch=a;var l=P.exec(u.text);if(l&&l.index==a)return l}}function k(u){for(;;){P.lastIndex=u.ch;var a=P.exec(u.text);if(!a){if(N(u))continue;return}if(!j(u,a.index+1)){u.ch=a.index+1;continue}return u.ch=a.index+a[0].length,a}}function T(u){for(;;){var a=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(a==-1){if(D(u))continue;return}if(!j(u,a+1)){u.ch=a;continue}var l=u.text.lastIndexOf("/",a),d=l>-1&&!/\S/.test(u.text.slice(l+1,a));return u.ch=a+1,d?"selfClose":"regular"}}function C(u,a){for(var l=[];;){var d=k(u),_,v=u.line,m=u.ch-(d?d[0].length:0);if(!d||!(_=y(u)))return;if(_=="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&&(!a||a==d[2]))return{tag:d[2],from:$(v,m),to:$(u.line,u.ch)}}else l.push(d[2])}}function b(u,a){for(var l=[];;){var d=T(u);if(!d)return;if(d=="selfClose"){A(u);continue}var _=u.line,v=u.ch,m=A(u);if(!m)return;if(m[1])l.push(m[2]);else{for(var L=l.length-1;L>=0;--L)if(l[L]==m[2]){l.length=L;break}if(L<0&&(!a||a==m[2]))return{tag:m[2],from:$(u.line,u.ch),to:$(_,v)}}}}le.registerHelper("fold","xml",function(u,a){for(var l=new K(u,a.line,0);;){var d=k(l);if(!d||l.line!=a.line)return;var _=y(l);if(!_)return;if(!d[1]&&_!="selfClose"){var v=$(l.line,l.ch),m=C(l,d[2]);return m&&R(m.from,v)>0?{from:v,to:m.from}:null}}}),le.findMatchingTag=function(u,a,l){var d=new K(u,a.line,a.ch,l);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var _=y(d),v=_&&$(d.line,d.ch),m=_&&A(d);if(!_||!m||R(d,a)>0)return;var L={from:$(d.line,d.ch),to:v,tag:m[2]};return _=="selfClose"?{open:L,close:null,at:"open"}:m[1]?{open:b(d,m[2]),close:L,at:"close"}:(d=new K(u,v.line,v.ch,l),{open:L,close:C(d,m[2]),at:"open"})},le.findEnclosingTag=function(u,a,l,d){for(var _=new K(u,a.line,a.ch,l);;){var v=b(_,d);if(!v)break;var m=new K(u,a.line,a.ch,l),L=C(m,v.tag);if(L)return{open:v,close:L}}},le.scanForClosingTag=function(u,a,l,d){var _=new K(u,a.line,a.ch,d?{from:0,to:d}:null);return C(_,l)}})},p5ED:function(ut,Ze,re){"use strict";var le=re("+L6B"),$=re("2/Rp"),R=re("5Dmo"),Z=re("3S7+"),F=re("k1fw"),P=re("tJVT"),K=re("cDcd"),j=re.n(K),N=re("vHTk"),D=re.n(N),y=re("yEEn"),A=re("ZW9T"),k=re("1vsH");Ze.a=function(T){var C=T.name,b=T.data,u=T.theme,a=T.type,l=T.filename,d=T.monacoEditor,_=T.className,v=T.style,m=T.close,L=T.onClose,x=T.hasMask,p=Object(K.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),f=Object(P.a)(p,2),h=f[0],o=f[1],E=Object(K.useState)(""),g=Object(P.a)(E,2),S=g[0],M=g[1],U,G=1024*1024,V=10*G,O=Object(K.useRef)();a==="office"&&(U=Object(k.V)(b).filesize,U>V&&(a="other")),l&&(d.filename=l),Object(K.useEffect)(function(){var q,oe,ce=(q=document.cookie)===null||q===void 0||((oe=q.replace(/\s/g,""))===null||oe===void 0)?void 0:oe.split(";");ce==null||ce.map(function(Le){var Ee=Le.split("=");Ee[0]==="_educoder_session"&&M(Ee[1])})},[]);var I=function(){if(b.startsWith("http")||b.startsWith("/")){X();return}Object(k.z)(l||"educoder",b,l)},X=function(){Object(k.x)(l||C,b)};return console.log("data:",b,"fileanme:",l," name:",C),j.a.createElement("div",{style:Object(F.a)({},v||{}),className:"".concat(x&&D.a.bgBlack," ").concat(a?D.a.wrp:"hide")},m&&j.a.createElement("div",{className:D.a.close,ref:O},j.a.createElement(Z.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return O.current}},j.a.createElement("span",{onClick:X},j.a.createElement("i",{className:"icon-quxiaozhiding"}))),j.a.createElement(Z.a,{title:"\u5173\u95ED",getPopupContainer:function(){return O.current}},j.a.createElement("span",{className:"",onClick:L},j.a.createElement("i",{className:"icon-guanbi1"})))),j.a.createElement("div",{className:"".concat(D.a[_]," ").concat(_," ").concat(D.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&j.a.createElement(A.b,d)),a==="audio"&&j.a.createElement("audio",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?b:"data:audio/mp3;base64,").concat(b),autoPlay:!0}),a==="video"&&j.a.createElement(j.a.Fragment,null,b!=null&&b.startsWith("/")?j.a.createElement("video",{controls:!0,src:"".concat(b),autoPlay:!0}):j.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(b),autoPlay:!0})),a==="html"&&j.a.createElement("iframe",{src:b+"&disposition=inline"}),a==="pdf"&&j.a.createElement("embed",{className:D.a.embed,src:b}),a==="image"&&j.a.createElement(j.a.Fragment,null,j.a.createElement("img",{src:"".concat(b!=null&&b.startsWith("/")||(b==null?void 0:b.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(b)})),a==="other"&&j.a.createElement("div",null,j.a.createElement($.a,{type:"primary",size:"large",onClick:I},j.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(a==="download"||a==="office")&&j.a.createElement($.a,{type:"primary",size:"large",onClick:I},j.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(ut,Ze,re){},rUJ1:function(ut,Ze){const re=/[&<>"']/,le=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},F=x=>Z[x];function P(x,p){if(p){if(re.test(x))return x.replace(le,F)}else if($.test(x))return x.replace(R,F);return x}const K=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function j(x){return x.replace(K,(p,f)=>(f=f.toLowerCase(),f==="colon"?":":f.charAt(0)==="#"?f.charAt(1)==="x"?String.fromCharCode(parseInt(f.substring(2),16)):String.fromCharCode(+f.substring(1)):""))}const N=/(^|[^\[])\^/g;function D(x,p){x=x.source||x,p=p||"";const f={replace:(h,o)=>(o=o.source||o,o=o.replace(N,"$1"),x=x.replace(h,o),f),getRegex:()=>new RegExp(x,p)};return f}const y=/[^\w:]/g,A=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(x,p,f){if(x){let h;try{h=decodeURIComponent(j(f)).replace(y,"").toLowerCase()}catch(o){return null}if(h.indexOf("javascript:")===0||h.indexOf("vbscript:")===0||h.indexOf("data:")===0)return null}p&&!A.test(f)&&(f=a(p,f));try{f=encodeURI(f).replace(/%25/g,"%")}catch(h){return null}return f}const T={},C=/^[^:]+:\/*[^/]*$/,b=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(x,p){T[" "+x]||(C.test(x)?T[" "+x]=x+"/":T[" "+x]=v(x,"/",!0)),x=T[" "+x];const f=x.indexOf(":")===-1;return p.substring(0,2)==="//"?f?p:x.replace(b,"$1")+p:p.charAt(0)==="/"?f?p:x.replace(u,"$1")+p:x+p}const l={exec:function(){}};function d(x){let p=1,f,h;for(;p<arguments.length;p++){f=arguments[p];for(h in f)Object.prototype.hasOwnProperty.call(f,h)&&(x[h]=f[h])}return x}function _(x,p){const f=x.replace(/\|/g,(E,g,S)=>{let M=!1,U=g;for(;--U>=0&&S[U]==="\\";)M=!M;return M?"|":" |"}),h=f.split(/ \|/);let o=0;if(h.length>p)h.splice(p);else for(;h.length<p;)h.push("");for(;o<h.length;o++)h[o]=h[o].trim().replace(/\\\|/g,"|");return h}function v(x,p,f){const h=x.length;if(h===0)return"";let o=0;for(;o<h;){const E=x.charAt(h-o-1);if(E===p&&!f)o++;else if(E!==p&&f)o++;else break}return x.substr(0,h-o)}function m(x,p){if(x.indexOf(p[1])===-1)return-1;const f=x.length;let h=0,o=0;for(;o<f;o++)if(x[o]==="\\")o++;else if(x[o]===p[0])h++;else if(x[o]===p[1]&&(h--,h<0))return o;return-1}function L(x){x&&x.sanitize&&!x.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}ut.exports={escape:P,unescape:j,edit:D,cleanUrl:k,resolveUrl:a,noopTest:l,merge:d,splitCells:_,rtrim:v,findClosingBracket:m,checkSanitizeDeprecation:L}},ttuQ:function(ut,Ze,re){ut.exports={bg:"bg___3F6Km",name:"name___1NsJT",member:"member___2pzzt"}},ulZh:function(ut,Ze,re){typeof window!="undefined"&&function($,R){ut.exports=R()}(this,function(){return function(le){var $={};function R(Z){if($[Z])return $[Z].exports;var F=$[Z]={i:Z,l:!1,exports:{}};return le[Z].call(F.exports,F,F.exports,R),F.l=!0,F.exports}return R.m=le,R.c=$,R.d=function(Z,F,P){R.o(Z,F)||Object.defineProperty(Z,F,{enumerable:!0,get:P})},R.r=function(Z){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Z,"__esModule",{value:!0})},R.t=function(Z,F){if(F&1&&(Z=R(Z)),F&8)return Z;if(F&4&&typeof Z=="object"&&Z&&Z.__esModule)return Z;var P=Object.create(null);if(R.r(P),Object.defineProperty(P,"default",{enumerable:!0,value:Z}),F&2&&typeof Z!="string")for(var K in Z)R.d(P,K,function(j){return Z[j]}.bind(null,K));return P},R.n=function(Z){var F=Z&&Z.__esModule?function(){return Z.default}:function(){return Z};return R.d(F,"a",F),F},R.o=function(Z,F){return Object.prototype.hasOwnProperty.call(Z,F)},R.p="/dist/",R(R.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(le,$,R){"use strict";var Z=Object.prototype.hasOwnProperty,F="~";function P(){}Object.create&&(P.prototype=Object.create(null),new P().__proto__||(F=!1));function K(y,A,k){this.fn=y,this.context=A,this.once=k||!1}function j(y,A,k,T,C){if(typeof k!="function")throw new TypeError("The listener must be a function");var b=new K(k,T||y,C),u=F?F+A:A;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],b]:y._events[u].push(b):(y._events[u]=b,y._eventsCount++),y}function N(y,A){--y._eventsCount===0?y._events=new P:delete y._events[A]}function D(){this._events=new P,this._eventsCount=0}D.prototype.eventNames=function(){var A=[],k,T;if(this._eventsCount===0)return A;for(T in k=this._events)Z.call(k,T)&&A.push(F?T.slice(1):T);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(k)):A},D.prototype.listeners=function(A){var k=F?F+A:A,T=this._events[k];if(!T)return[];if(T.fn)return[T.fn];for(var C=0,b=T.length,u=new Array(b);C<b;C++)u[C]=T[C].fn;return u},D.prototype.listenerCount=function(A){var k=F?F+A:A,T=this._events[k];return T?T.fn?1:T.length:0},D.prototype.emit=function(A,k,T,C,b,u){var a=F?F+A:A;if(!this._events[a])return!1;var l=this._events[a],d=arguments.length,_,v;if(l.fn){l.once&&this.removeListener(A,l.fn,void 0,!0);switch(d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,k),!0;case 3:return l.fn.call(l.context,k,T),!0;case 4:return l.fn.call(l.context,k,T,C),!0;case 5:return l.fn.call(l.context,k,T,C,b),!0;case 6:return l.fn.call(l.context,k,T,C,b,u),!0}for(v=1,_=new Array(d-1);v<d;v++)_[v-1]=arguments[v];l.fn.apply(l.context,_)}else{var m=l.length,L;for(v=0;v<m;v++){l[v].once&&this.removeListener(A,l[v].fn,void 0,!0);switch(d){case 1:l[v].fn.call(l[v].context);break;case 2:l[v].fn.call(l[v].context,k);break;case 3:l[v].fn.call(l[v].context,k,T);break;case 4:l[v].fn.call(l[v].context,k,T,C);break;default:if(!_)for(L=1,_=new Array(d-1);L<d;L++)_[L-1]=arguments[L];l[v].fn.apply(l[v].context,_)}}}return!0},D.prototype.on=function(A,k,T){return j(this,A,k,T,!1)},D.prototype.once=function(A,k,T){return j(this,A,k,T,!0)},D.prototype.removeListener=function(A,k,T,C){var b=F?F+A:A;if(!this._events[b])return this;if(!k)return N(this,b),this;var u=this._events[b];if(u.fn)u.fn===k&&(!C||u.once)&&(!T||u.context===T)&&N(this,b);else{for(var a=0,l=[],d=u.length;a<d;a++)(u[a].fn!==k||C&&!u[a].once||T&&u[a].context!==T)&&l.push(u[a]);l.length?this._events[b]=l.length===1?l[0]:l:N(this,b)}return this},D.prototype.removeAllListeners=function(A){var k;return A?(k=F?F+A:A,this._events[k]&&N(this,k)):(this._events=new P,this._eventsCount=0),this},D.prototype.off=D.prototype.removeListener,D.prototype.addListener=D.prototype.on,D.prefixed=F,D.EventEmitter=D,le.exports=D},"./node_modules/url-toolkit/src/url-toolkit.js":function(le,$,R){(function(Z){var F=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,P=/^([^\/?#]*)([^]*)$/,K=/(?:\/|^)\.(?=\/)/g,j=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,N={buildAbsoluteURL:function(D,y,A){if(A=A||{},D=D.trim(),y=y.trim(),!y){if(!A.alwaysNormalize)return D;var k=N.parseURL(D);if(!k)throw new Error("Error trying to parse base URL.");return k.path=N.normalizePath(k.path),N.buildURLFromParts(k)}var T=N.parseURL(y);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return A.alwaysNormalize?(T.path=N.normalizePath(T.path),N.buildURLFromParts(T)):y;var C=N.parseURL(D);if(!C)throw new Error("Error trying to parse base URL.");if(!C.netLoc&&C.path&&C.path[0]!=="/"){var b=P.exec(C.path);C.netLoc=b[1],C.path=b[2]}C.netLoc&&!C.path&&(C.path="/");var u={scheme:C.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(u.netLoc=C.netLoc,T.path[0]!=="/"))if(!T.path)u.path=C.path,T.params||(u.params=C.params,T.query||(u.query=C.query));else{var a=C.path,l=a.substring(0,a.lastIndexOf("/")+1)+T.path;u.path=N.normalizePath(l)}return u.path===null&&(u.path=A.alwaysNormalize?N.normalizePath(T.path):T.path),N.buildURLFromParts(u)},parseURL:function(D){var y=F.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(K,"");D.length!==(D=D.replace(j,"")).length;);return D.split("").reverse().join("")},buildURLFromParts:function(D){return D.scheme+D.netLoc+D.path+D.params+D.query+D.fragment}};le.exports=N})(this)},"./node_modules/webworkify-webpack/index.js":function(le,$,R){function Z(A){var k={};function T(b){if(k[b])return k[b].exports;var u=k[b]={i:b,l:!1,exports:{}};return A[b].call(u.exports,u,u.exports,T),u.l=!0,u.exports}T.m=A,T.c=k,T.i=function(b){return b},T.d=function(b,u,a){T.o(b,u)||Object.defineProperty(b,u,{configurable:!1,enumerable:!0,get:a})},T.r=function(b){Object.defineProperty(b,"__esModule",{value:!0})},T.n=function(b){var u=b&&b.__esModule?function(){return b.default}:function(){return b};return T.d(u,"a",u),u},T.o=function(b,u){return Object.prototype.hasOwnProperty.call(b,u)},T.p="/",T.oe=function(b){throw console.error(b),b};var C=T(T.s=ENTRY_MODULE);return C.default||C}var F="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+F+").*?\\)";function K(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function j(A){return!isNaN(1*A)}function N(A,k,T){var C={};C[T]=[];var b=k.toString(),u=b.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return C;for(var a=u[1],l=new RegExp("(\\\\n|\\W)"+K(a)+P,"g"),d;d=l.exec(b);){if(d[3]==="dll-reference")continue;C[T].push(d[3])}for(l=new RegExp("\\("+K(a)+'\\("(dll-reference\\s('+F+'))"\\)\\)'+P,"g");d=l.exec(b);)A[d[2]]||(C[T].push(d[1]),A[d[2]]=R(d[1]).m),C[d[2]]=C[d[2]]||[],C[d[2]].push(d[4]);for(var _=Object.keys(C),v=0;v<_.length;v++)for(var m=0;m<C[_[v]].length;m++)j(C[_[v]][m])&&(C[_[v]][m]=1*C[_[v]][m]);return C}function D(A){var k=Object.keys(A);return k.reduce(function(T,C){return T||A[C].length>0},!1)}function y(A,k){for(var T={main:[k]},C={main:[]},b={main:{}};D(T);)for(var u=Object.keys(T),a=0;a<u.length;a++){var l=u[a],d=T[l],_=d.pop();if(b[l]=b[l]||{},b[l][_]||!A[l][_])continue;b[l][_]=!0,C[l]=C[l]||[],C[l].push(_);for(var v=N(A,A[l][_],l),m=Object.keys(v),L=0;L<m.length;L++)T[m[L]]=T[m[L]]||[],T[m[L]]=T[m[L]].concat(v[m[L]])}return C}le.exports=function(A,k){k=k||{};var T={main:R.m},C=k.all?{main:Object.keys(T.main)}:y(T,A),b="";Object.keys(C).filter(function(_){return _!=="main"}).forEach(function(_){for(var v=0;C[_][v];)v++;C[_].push(v),T[_][v]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",b=b+"var "+_+" = ("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(v))+")({"+C[_].map(function(m){return""+JSON.stringify(m)+": "+T[_][m].toString()}).join(",")+`});
`}),b=b+"new (("+Z.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+C.main.map(function(_){return""+JSON.stringify(_)+": "+T.main[_].toString()}).join(",")+"}))(self);";var u=new window.Blob([b],{type:"text/javascript"});if(k.bare)return u;var a=window.URL||window.webkitURL||window.mozURL||window.msURL,l=a.createObjectURL(u),d=new window.Worker(l);return d.objectURL=l,d}},"./src/config.ts":function(le,$,R){"use strict";R.r($),R.d($,"hlsDefaultConfig",function(){return L}),R.d($,"mergeConfig",function(){return p}),R.d($,"enableStreamingMode",function(){return f});var Z=R("./src/controller/abr-controller.ts"),F=R("./src/controller/audio-stream-controller.ts"),P=R("./src/controller/audio-track-controller.ts"),K=R("./src/controller/subtitle-stream-controller.ts"),j=R("./src/controller/subtitle-track-controller.ts"),N=R("./src/controller/buffer-controller.ts"),D=R("./src/controller/timeline-controller.ts"),y=R("./src/controller/cap-level-controller.ts"),A=R("./src/controller/fps-controller.ts"),k=R("./src/controller/eme-controller.ts"),T=R("./src/controller/cmcd-controller.ts"),C=R("./src/utils/xhr-loader.ts"),b=R("./src/utils/fetch-loader.ts"),u=R("./src/utils/cues.ts"),a=R("./src/utils/mediakeys-helper.ts"),l=R("./src/utils/logger.ts");function d(){return d=Object.assign||function(h){for(var o=1;o<arguments.length;o++){var E=arguments[o];for(var g in E)Object.prototype.hasOwnProperty.call(E,g)&&(h[g]=E[g])}return h},d.apply(this,arguments)}function _(h,o){var E=Object.keys(h);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(h);o&&(g=g.filter(function(S){return Object.getOwnPropertyDescriptor(h,S).enumerable})),E.push.apply(E,g)}return E}function v(h){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?_(Object(E),!0).forEach(function(g){m(h,g,E[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(E)):_(Object(E)).forEach(function(g){Object.defineProperty(h,g,Object.getOwnPropertyDescriptor(E,g))})}return h}function m(h,o,E){return o in h?Object.defineProperty(h,o,{value:E,enumerable:!0,configurable:!0,writable:!0}):h[o]=E,h}var L=v(v({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:C.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Z.default,bufferController:N.default,capLevelController:y.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},x()),{},{subtitleStreamController:K.SubtitleStreamController,subtitleTrackController:j.default,timelineController:D.TimelineController,audioStreamController:F.default,audioTrackController:P.default,emeController:k.default,cmcdController:T.default});function x(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function p(h,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return d({},h,o)}function f(h){var o=h.loader;if(o!==b.default&&o!==C.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),h.progressive=!1;else{var E=Object(b.fetchSupported)();E&&(h.loader=b.default,h.progressive=!0,h.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/ewma-bandwidth-estimator.ts"),P=R("./src/events.ts"),K=R("./src/utils/buffer-helper.ts"),j=R("./src/errors.ts"),N=R("./src/types/loader.ts"),D=R("./src/utils/logger.ts");function y(T,C){for(var b=0;b<C.length;b++){var u=C[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function A(T,C,b){return C&&y(T.prototype,C),b&&y(T,b),T}var k=function(){function T(b){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=b;var u=b.config;this.bwEstimator=new F.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var C=T.prototype;return C.registerListeners=function(){var u=this.hls;u.on(P.Events.FRAG_LOADING,this.onFragLoading,this),u.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(P.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var u=this.hls;u.off(P.Events.FRAG_LOADING,this.onFragLoading,this),u.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(P.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},C.onFragLoading=function(u,a){var l=a.frag;if(l.type===N.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=l,this.partCurrent=(d=a.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},C.onLevelLoaded=function(u,a){var l=this.hls.config;a.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},C._abandonRulesCheck=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,d=l.autoLevelEnabled,_=l.config,v=l.media;if(!u||!v)return;var m=a?a.stats:u.stats,L=a?a.duration:u.duration;if(m.aborted){D.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||v.paused||!v.playbackRate||!v.readyState)return;var x=performance.now()-m.loading.start,p=Math.abs(v.playbackRate);if(x<=500*L/p)return;var f=l.levels,h=l.minAutoLevel,o=f[u.level],E=m.total||Math.max(m.loaded,Math.round(L*o.maxBitrate/8)),g=Math.max(1,m.bwEstimate?m.bwEstimate/8:m.loaded*1e3/x),S=(E-m.loaded)/g,M=v.currentTime,U=(K.BufferHelper.bufferInfo(v,M,_.maxBufferHole).end-M)/p;if(U>=2*L/p||S<=U)return;var G=Number.POSITIVE_INFINITY,V;for(V=u.level-1;V>h;V--){var O=f[V].maxBitrate;if(G=L*O/(8*.8*g),G<U)break}if(G>=S)return;var I=this.bwEstimator.getEstimate();D.logger.warn("Fragment "+u.sn+(a?" part "+a.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+V+`
Current BW estimate: `+(Object(Z.isFiniteNumber)(I)?(I/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+S.toFixed(3)+` s
Estimated load time for the next fragment: `+G.toFixed(3)+` s
Time to underbuffer: `+U.toFixed(3)+" s"),l.nextLoadLevel=V,this.bwEstimator.sample(x,m.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),l.trigger(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:a,stats:m})},C.onFragLoaded=function(u,a){var l=a.frag,d=a.part;if(l.type===N.PlaylistLevelType.MAIN&&Object(Z.isFiniteNumber)(l.sn)){var _=d?d.stats:l.stats,v=d?d.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[l.level],L=(m.loaded?m.loaded.bytes:0)+_.loaded,x=(m.loaded?m.loaded.duration:0)+v;m.loaded={bytes:L,duration:x},m.realBitrate=Math.round(8*L/x)}if(l.bitrateTest){var p={stats:_,frag:l,part:d,id:l.type};this.onFragBuffered(P.Events.FRAG_BUFFERED,p),l.bitrateTest=!1}}},C.onFragBuffered=function(u,a){var l=a.frag,d=a.part,_=d?d.stats:l.stats;if(_.aborted)return;if(l.type!==N.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var v=_.parsing.end-_.loading.start;this.bwEstimator.sample(v,_.loaded),_.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=v/1e3:this.bitrateTestDelay=0},C.onError=function(u,a){switch(a.details){case j.ErrorDetails.FRAG_LOAD_ERROR:case j.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},C.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},C.getNextABRAutoLevel=function(){var u=this.fragCurrent,a=this.partCurrent,l=this.hls,d=l.maxAutoLevel,_=l.config,v=l.minAutoLevel,m=l.media,L=a?a.duration:u?u.duration:0,x=m?m.currentTime:0,p=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():_.abrEwmaDefaultEstimate,h=(K.BufferHelper.bufferInfo(m,x,_.maxBufferHole).end-x)/p,o=this.findBestLevel(f,v,d,h,_.abrBandWidthFactor,_.abrBandWidthUpFactor);if(o>=0)return o;D.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=L?Math.min(L,_.maxStarvationDelay):_.maxStarvationDelay,g=_.abrBandWidthFactor,S=_.abrBandWidthUpFactor;if(!h){var M=this.bitrateTestDelay;if(M){var U=L?Math.min(L,_.maxLoadingDelay):_.maxLoadingDelay;E=U-M,D.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),g=S=1}}return o=this.findBestLevel(f,v,d,h+E,g,S),Math.max(o,0)},C.findBestLevel=function(u,a,l,d,_,v){for(var m,L=this.fragCurrent,x=this.partCurrent,p=this.lastLoadedFragLevel,f=this.hls.levels,h=f[p],o=!!(h!=null&&(m=h.details)!==null&&m!==void 0&&m.live),E=h==null?void 0:h.codecSet,g=x?x.duration:L?L.duration:0,S=l;S>=a;S--){var M=f[S];if(!M||E&&M.codecSet!==E)continue;var U=M.details,G=(x?U==null?void 0:U.partTarget:U==null?void 0:U.averagetargetduration)||g,V=void 0;S<=p?V=_*u:V=v*u;var O=f[S].maxBitrate,I=O*G/V;if(D.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(V)+"/"+O+"/"+G+"/"+d+"/"+I),V>O&&(!I||o&&!this.bitrateTestDelay||I<d))return S}return-1},A(T,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,a=this.bwEstimator;if(u!==-1&&(!a||!a.canEstimate()))return u;var l=this.getNextABRAutoLevel();return u!==-1&&(l=Math.min(u,l)),l},set:function(u){this._nextAutoLevel=u}}]),T}();$.default=k},"./src/controller/audio-stream-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/polyfills/number.ts"),F=R("./src/controller/base-stream-controller.ts"),P=R("./src/events.ts"),K=R("./src/utils/buffer-helper.ts"),j=R("./src/controller/fragment-tracker.ts"),N=R("./src/types/level.ts"),D=R("./src/types/loader.ts"),y=R("./src/loader/fragment.ts"),A=R("./src/demux/chunk-cache.ts"),k=R("./src/demux/transmuxer-interface.ts"),T=R("./src/types/transmuxer.ts"),C=R("./src/controller/fragment-finders.ts"),b=R("./src/utils/discontinuities.ts"),u=R("./src/errors.ts"),a=R("./src/utils/logger.ts");function l(){return l=Object.assign||function(L){for(var x=1;x<arguments.length;x++){var p=arguments[x];for(var f in p)Object.prototype.hasOwnProperty.call(p,f)&&(L[f]=p[f])}return L},l.apply(this,arguments)}function d(L,x){L.prototype=Object.create(x.prototype),L.prototype.constructor=L,_(L,x)}function _(L,x){return _=Object.setPrototypeOf||function(f,h){return f.__proto__=h,f},_(L,x)}var v=100,m=function(L){d(x,L);function x(f,h){var o;return o=L.call(this,f,h,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var p=x.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var h=this.hls;h.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(P.Events.ERROR,this.onError,this),h.on(P.Events.BUFFER_RESET,this.onBufferReset,this),h.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var h=this.hls;h.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(P.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(P.Events.ERROR,this.onError,this),h.off(P.Events.BUFFER_RESET,this.onBufferReset,this),h.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onInitPtsFound=function(h,o){var E=o.frag,g=o.id,S=o.initPTS;if(g==="main"){var M=E.cc;this.initPTS[E.cc]=S,this.log("InitPTS for cc: "+M+" found from main: "+S),this.videoTrackCC=M,this.state===F.State.WAITING_INIT_PTS&&this.tick()}},p.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=F.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(v),this.fragLoadError=0,o>0&&h===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=F.State.IDLE):(this.loadedmetadata=!1,this.state=F.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()},p.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_TRACK:{var h,o=this.levels,E=this.trackId,g=o==null||((h=o[E])===null||h===void 0)?void 0:h.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=F.State.WAITING_INIT_PTS}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var S,M=performance.now(),U=this.retryDate;(!U||M>=U||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=F.State.IDLE);break}case F.State.WAITING_INIT_PTS:{var G=this.waitingData;if(G){var V=G.frag,O=G.part,I=G.cache,X=G.complete;if(this.initPTS[V.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=F.State.FRAG_LOADING;var q=I.flush(),oe={frag:V,part:O,payload:q,networkDetails:null};this._handleFragmentLoadProgress(oe),X&&L.prototype._handleFragmentLoadComplete.call(this,oe)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+V.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ce=this.getLoadPosition(),Le=K.BufferHelper.bufferInfo(this.mediaBuffer,ce,this.config.maxBufferHole),Ee=Object(C.fragmentWithinToleranceTest)(Le.end,this.config.maxFragLookUpTolerance,V);Ee<0&&(a.logger.log("Waiting fragment cc ("+V.cc+") @ "+V.start+" cancelled because another fragment at "+Le.end+" is needed"),this.clearWaitingFragment())}}else this.state=F.State.IDLE}}this.onTickEnd()},p.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=F.State.IDLE)},p.onTickEnd=function(){var h=this.media;if(!h||!h.readyState)return;var o=this.mediaBuffer?this.mediaBuffer:h,E=o.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime},p.doTickIdle=function(){var h,o,E=this.hls,g=this.levels,S=this.media,M=this.trackId,U=E.config;if(!g||!g[M])return;if(!S&&(this.startFragRequested||!U.startFragPrefetch))return;var G=g[M],V=G.details;if(!V||V.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(V)){this.state=F.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,D.PlaylistLevelType.AUDIO));var O=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,D.PlaylistLevelType.AUDIO);if(O===null)return;var I=O.len,X=this.getMaxBufferLength(),q=this.audioSwitch;if(I>=X&&!q)return;if(!q&&this._streamEnded(O,V)){E.trigger(P.Events.BUFFER_EOS,{type:"audio"}),this.state=F.State.ENDED;return}var oe=V.fragments,ce=oe[0].start,Le=O.end;if(q){var Ee=this.getLoadPosition();Le=Ee,V.PTSKnown&&Ee<ce&&((O.end>ce||O.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),S.currentTime=ce+.05))}var we=this.getNextFragment(Le,V);if(!we){this.bufferFlushed=!0;return}((h=we.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((o=we.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(we,V):this.loadFragment(we,V,Le)},p.getMaxBufferLength=function(){var h=L.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,D.PlaylistLevelType.MAIN);return o===null?h:Math.max(h,o.len)},p.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},p.onAudioTracksUpdated=function(h,o){var E=o.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(g){return new N.Level(g)})},p.onAudioTrackSwitching=function(h,o){var E=!!o.url;this.trackId=o.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),E?this.setInterval(v):this.resetTransmuxer(),E?(this.audioSwitch=!0,this.state=F.State.IDLE):this.state=F.State.STOPPED,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},p.onLevelLoaded=function(h,o){this.mainDetails=o.details},p.onAudioTrackLoaded=function(h,o){var E,g=this.levels,S=o.details,M=o.id;if(!g){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+S.startSN+","+S.endSN+"],duration:"+S.totalduration);var U=g[M],G=0;if(S.live||(E=U.details)!==null&&E!==void 0&&E.live){var V=this.mainDetails;if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed||!V)return;!U.details&&S.hasProgramDateTime&&V.hasProgramDateTime?(Object(b.alignMediaPlaylistByPDT)(S,V),G=S.fragments[0].start):G=this.alignPlaylists(S,U.details)}U.details=S,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!S.live)&&this.setStartPosition(U.details,G),this.state===F.State.WAITING_TRACK&&!this.waitForCdnTuneIn(S)&&(this.state=F.State.IDLE),this.tick()},p._handleFragmentLoadProgress=function(h){var o,E=h.frag,g=h.part,S=h.payload,M=this.config,U=this.trackId,G=this.levels;if(!G){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+E.sn+" of level "+E.level+" will not be buffered");return}var V=G[U];console.assert(V,"Audio track is defined on fragment load progress");var O=V.details;console.assert(O,"Audio track details are defined on fragment load progress");var I=M.defaultAudioCodec||V.audioCodec||"mp4a.40.2",X=this.transmuxer;X||(X=this.transmuxer=new k.default(this.hls,D.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var q=this.initPTS[E.cc],oe=(o=E.initSegment)===null||o===void 0?void 0:o.data;if(q!==void 0){var ce=!1,Le=g?g.index:-1,Ee=Le!==-1,we=new T.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,S.byteLength,Le,Ee);X.push(S,oe,I,"",E,g,O.totalduration,ce,we,q)}else{a.logger.log("Unknown video PTS for cc "+E.cc+", waiting for video PTS before demuxing audio frag "+E.sn+" of ["+O.startSN+" ,"+O.endSN+"],track "+U);var Te=this.waitingData=this.waitingData||{frag:E,part:g,cache:new A.default,complete:!1},ye=Te.cache;ye.push(new Uint8Array(S)),this.waitingVideoCC=this.videoTrackCC,this.state=F.State.WAITING_INIT_PTS}},p._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}L.prototype._handleFragmentLoadComplete.call(this,h)},p.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},p.onBufferCreated=function(h,o){var E=o.tracks.audio;E&&(this.mediaBuffer=E.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},p.onFragBuffered=function(h,o){var E=o.frag,g=o.part;if(E.type!==D.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(g?" p: "+g.index:"")+" of level "+E.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}E.sn!=="initSegment"&&(this.fragPrevious=E,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,g)},p.onError=function(h,o){switch(o.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.AUDIO,o);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==F.State.ERROR&&this.state!==F.State.STOPPED&&(this.state=o.fatal?F.State.ERROR:F.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===F.State.PARSING||this.state===F.State.PARSED)){var E=!0,g=this.getFwdBufferInfo(this.mediaBuffer,D.PlaylistLevelType.AUDIO);g&&g.len>.5&&(E=!this.reduceMaxBufferLength(g.len)),E&&(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}},p.onBufferFlushed=function(h,o){var E=o.type;E===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},p._handleTransmuxComplete=function(h){var o,E="audio",g=this.hls,S=h.remuxResult,M=h.chunkMeta,U=this.getCurrentContext(M);if(!U){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(M.level);return}var G=U.frag,V=U.part,O=S.audio,I=S.text,X=S.id3,q=S.initSegment;if(this.fragContextChanged(G))return;if(this.state=F.State.PARSING,this.audioSwitch&&O&&this.completeAudioSwitch(),q!=null&&q.tracks&&(this._bufferInitSegment(q.tracks,G,M),g.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:E,tracks:q.tracks})),O){var oe=O.startPTS,ce=O.endPTS,Le=O.startDTS,Ee=O.endDTS;V&&(V.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:oe,endPTS:ce,startDTS:Le,endDTS:Ee}),G.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,oe,ce,Le,Ee),this.bufferFragmentData(O,G,V,M)}if(X!=null&&(o=X.samples)!==null&&o!==void 0&&o.length){var we=l({frag:G,id:E},X);g.trigger(P.Events.FRAG_PARSING_METADATA,we)}if(I){var Te=l({frag:G,id:E},I);g.trigger(P.Events.FRAG_PARSING_USERDATA,Te)}},p._bufferInitSegment=function(h,o,E){if(this.state!==F.State.PARSING)return;h.video&&delete h.video;var g=h.audio;if(!g)return;g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,h);var S=g.initSegment;if(S!=null&&S.byteLength){var M={type:"audio",frag:o,part:null,chunkMeta:E,parent:o.type,data:S};this.hls.trigger(P.Events.BUFFER_APPENDING,M)}this.tick()},p.loadFragment=function(h,o,E){var g=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||g===j.FragmentState.NOT_LOADED||g===j.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):o.live&&!Object(Z.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=F.State.WAITING_INIT_PTS):(this.startFragRequested=!0,L.prototype.loadFragment.call(this,h,o,E)))},p.completeAudioSwitch=function(){var h=this.hls,o=this.media,E=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:E})},x}(F.default);$.default=m},"./src/controller/audio-track-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts"),F=R("./src/errors.ts"),P=R("./src/controller/base-playlist-controller.ts"),K=R("./src/types/loader.ts");function j(k,T){for(var C=0;C<T.length;C++){var b=T[C];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(k,b.key,b)}}function N(k,T,C){return T&&j(k.prototype,T),C&&j(k,C),k}function D(k,T){k.prototype=Object.create(T.prototype),k.prototype.constructor=k,y(k,T)}function y(k,T){return y=Object.setPrototypeOf||function(b,u){return b.__proto__=u,b},y(k,T)}var A=function(k){D(T,k);function T(b){var u;return u=k.call(this,b,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var C=T.prototype;return C.registerListeners=function(){var u=this.hls;u.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(Z.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var u=this.hls;u.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(Z.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(Z.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,k.prototype.destroy.call(this)},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},C.onManifestParsed=function(u,a){this.tracks=a.audioTracks||[]},C.onAudioTrackLoaded=function(u,a){var l=a.id,d=a.details,_=this.tracksInGroup[l];if(!_){this.warn("Invalid audio track id "+l);return}var v=_.details;_.details=a.details,this.log("audioTrack "+l+" loaded ["+d.startSN+"-"+d.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,v))},C.onLevelLoading=function(u,a){this.switchLevel(a.level)},C.onLevelSwitching=function(u,a){this.switchLevel(a.level)},C.switchLevel=function(u){var a=this.hls.levels[u];if(!(a!=null&&a.audioGroupIds))return;var l=a.audioGroupIds[a.urlId];if(this.groupId!==l){this.groupId=l;var d=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!d.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var _={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(Z.Events.AUDIO_TRACKS_UPDATED,_),this.selectInitialTrack()}},C.onError=function(u,a){if(k.prototype.onError.call(this,u,a),a.fatal||!a.context)return;a.context.type===K.PlaylistContextType.AUDIO_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},C.setAudioTrack=function(u){var a=this.tracksInGroup;if(u<0||u>=a.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=a[this.trackId];this.log("Now switching to audio-track index "+u);var d=a[u],_=d.id,v=d.groupId,m=v===void 0?"":v,L=d.name,x=d.type,p=d.url;if(this.trackId=u,this.trackName=L,this.selectDefaultTrack=!1,this.hls.trigger(Z.Events.AUDIO_TRACK_SWITCHING,{id:_,groupId:m,name:L,type:x,url:p}),d.details&&!d.details.live)return;var f=this.switchParams(d.url,l==null?void 0:l.details);this.loadPlaylist(f)},C.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var a=this.trackName,l=this.findTrackId(a)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},C.findTrackId=function(u){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var d=a[l];if((!this.selectDefaultTrack||d.default)&&(!u||u===d.name))return d.id}return-1},C.loadPlaylist=function(u){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,d=a.groupId,_=a.url;if(u)try{_=u.addDirectives(_)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(Z.Events.AUDIO_TRACK_LOADING,{url:_,id:l,groupId:d,deliveryDirectives:u||null})}},N(T,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),T}(P.default);$.default=A},"./src/controller/base-playlist-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return N});var Z=R("./src/polyfills/number.ts"),F=R("./src/types/level.ts"),P=R("./src/controller/level-helper.ts"),K=R("./src/utils/logger.ts"),j=R("./src/errors.ts"),N=function(){function D(A,k){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=K.logger.log.bind(K.logger,k+":"),this.warn=K.logger.warn.bind(K.logger,k+":"),this.hls=A}var y=D.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(k,T){T.fatal&&T.type===j.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(k,T){var C=T==null?void 0:T.renditionReports;if(C)for(var b=0;b<C.length;b++){var u=C[b],a=""+u.URI;if(a===k.substr(-a.length)){var l=parseInt(u["LAST-MSN"]),d=parseInt(u["LAST-PART"]);if(T&&this.hls.config.lowLatencyMode){var _=Math.min(T.age-T.partTarget,T.targetduration);d!==void 0&&_>T.partTarget&&(d+=1)}if(Object(Z.isFiniteNumber)(l))return new F.HlsUrlParameters(l,Object(Z.isFiniteNumber)(d)?d:void 0,F.HlsSkip.No)}}},y.loadPlaylist=function(k){},y.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},y.playlistLoaded=function(k,T,C){var b=this,u=T.details,a=T.stats,l=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(u.advancedDateTime=Date.now()-l,u.live||C!=null&&C.live){if(u.reloaded(C),C&&this.log("live playlist "+k+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),C&&u.fragments.length>0&&Object(P.mergeDetails)(C,u),!this.canLoad||!u.live)return;var d,_=void 0,v=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var m=this.hls.config.lowLatencyMode,L=u.lastPartSn,x=u.endSN,p=u.lastPartIndex,f=p!==-1,h=L===x,o=m?0:p;f?(_=h?x+1:L,v=h?o:p+1):_=x+1;var E=u.age,g=E+u.ageHeader,S=Math.min(g-u.partTarget,u.targetduration*1.5);if(S>0){if(C&&S>C.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+C.tuneInGoal+" to: "+S+" with playlist age: "+u.age),S=0;else{var M=Math.floor(S/u.targetduration);if(_+=M,v!==void 0){var U=Math.round(S%u.targetduration/u.partTarget);v+=U}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+S+" skip sn "+M+" to part "+v)}u.tuneInGoal=S}if(d=this.getDeliveryDirectives(u,T.deliveryDirectives,_,v),m||!h){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(u,T.deliveryDirectives,_,v);var G=Object(P.computeReloadInterval)(u,a);_!==void 0&&u.canBlockReload&&(G-=u.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(G)+" ms"),this.timer=self.setTimeout(function(){return b.loadPlaylist(d)},G)}else this.clearTimer()},y.getDeliveryDirectives=function(k,T,C,b){var u=Object(F.getSkipValue)(k,C);return T!=null&&T.skip&&k.deltaUpdateFailed&&(C=T.msn,b=T.part,u=F.HlsSkip.No),new F.HlsUrlParameters(C,b,u)},y.retryLoadingOrFail=function(k){var T=this,C=this.hls.config,b=this.retryCount<C.levelLoadingMaxRetry;if(b){var u;if(this.retryCount++,k.details.indexOf("LoadTimeOut")>-1&&(u=k.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*C.levelLoadingRetryDelay,C.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return b},D}()},"./src/controller/base-stream-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"State",function(){return x}),R.d($,"default",function(){return p});var Z=R("./src/polyfills/number.ts"),F=R("./src/task-loop.ts"),P=R("./src/controller/fragment-tracker.ts"),K=R("./src/utils/buffer-helper.ts"),j=R("./src/utils/logger.ts"),N=R("./src/events.ts"),D=R("./src/errors.ts"),y=R("./src/types/transmuxer.ts"),A=R("./src/utils/mp4-tools.ts"),k=R("./src/utils/discontinuities.ts"),T=R("./src/controller/fragment-finders.ts"),C=R("./src/controller/level-helper.ts"),b=R("./src/loader/fragment-loader.ts"),u=R("./src/crypt/decrypter.ts"),a=R("./src/utils/time-ranges.ts"),l=R("./src/types/loader.ts");function d(f,h){for(var o=0;o<h.length;o++){var E=h[o];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(f,E.key,E)}}function _(f,h,o){return h&&d(f.prototype,h),o&&d(f,o),f}function v(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function m(f,h){f.prototype=Object.create(h.prototype),f.prototype.constructor=f,L(f,h)}function L(f,h){return L=Object.setPrototypeOf||function(E,g){return E.__proto__=g,E},L(f,h)}var x={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},p=function(f){m(h,f);function h(E,g,S){var M;return M=f.call(this)||this,M.hls=void 0,M.fragPrevious=null,M.fragCurrent=null,M.fragmentTracker=void 0,M.transmuxer=null,M._state=x.STOPPED,M.media=void 0,M.mediaBuffer=void 0,M.config=void 0,M.bitrateTest=!1,M.lastCurrentTime=0,M.nextLoadPosition=0,M.startPosition=0,M.loadedmetadata=!1,M.fragLoadError=0,M.retryDate=0,M.levels=null,M.fragmentLoader=void 0,M.levelLastLoaded=null,M.startFragRequested=!1,M.decrypter=void 0,M.initPTS=[],M.onvseeking=null,M.onvended=null,M.logPrefix="",M.log=void 0,M.warn=void 0,M.logPrefix=S,M.log=j.logger.log.bind(j.logger,S+":"),M.warn=j.logger.warn.bind(j.logger,S+":"),M.hls=E,M.fragmentLoader=new b.default(E.config),M.fragmentTracker=g,M.config=E.config,M.decrypter=new u.default(E,E.config),E.on(N.Events.KEY_LOADED,M.onKeyLoaded,v(M)),M}var o=h.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(g){},o.stopLoad=function(){this.fragmentLoader.abort();var g=this.fragCurrent;g&&this.fragmentTracker.removeFragment(g),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},o._streamEnded=function(g,S){var M=this.fragCurrent,U=this.fragmentTracker;if(!S.live&&M&&M.sn===S.endSN&&!g.nextStart){var G=U.getState(M);return G===P.FragmentState.PARTIAL||G===P.FragmentState.OK}return!1},o.onMediaAttached=function(g,S){var M=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),M.addEventListener("seeking",this.onvseeking),M.addEventListener("ended",this.onvended);var U=this.config;this.levels&&U.autoStartLoad&&this.state===x.STOPPED&&this.startLoad(U.startPosition)},o.onMediaDetaching=function(){var g=this.media;g!=null&&g.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),g&&(g.removeEventListener("seeking",this.onvseeking),g.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var g=this.config,S=this.fragCurrent,M=this.media,U=this.mediaBuffer,G=this.state,V=M?M.currentTime:0,O=K.BufferHelper.bufferInfo(U||M,V,g.maxBufferHole);if(this.log("media seeking to "+(Object(Z.isFiniteNumber)(V)?V.toFixed(3):V)+", state: "+G),G===x.ENDED)this.resetLoadingState();else if(S&&!O.len){var I=g.maxFragLookUpTolerance,X=S.start-I,q=S.start+S.duration+I,oe=V>q;(V<X||oe)&&(oe&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}M&&(this.lastCurrentTime=V),!this.loadedmetadata&&!O.len&&(this.nextLoadPosition=this.startPosition=V),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(g,S){if(this.state!==x.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)return;this.state=x.IDLE;var M=this.levels[S.frag.level].details;M&&this.loadFragment(S.frag,M,S.frag.start)},o.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=x.STOPPED,this.hls.off(N.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,f.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(g,S){this.log("Loading key for "+g.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level),this.state=x.KEY_LOADING,this.fragCurrent=g,this.hls.trigger(N.Events.KEY_LOADING,{frag:g})},o.loadFragment=function(g,S,M){this._loadFragForPlayback(g,S,M)},o._loadFragForPlayback=function(g,S,M){var U=this,G=function(O){if(U.fragContextChanged(g)){U.warn("Fragment "+g.sn+(O.part?" p: "+O.part.index:"")+" of level "+g.level+" was dropped during download."),U.fragmentTracker.removeFragment(g);return}g.stats.chunkCount++,U._handleFragmentLoadProgress(O)};this._doFragLoad(g,S,M,G).then(function(V){if(!V)return;U.fragLoadError=0;var O=U.state;if(U.fragContextChanged(g)){(O===x.FRAG_LOADING||O===x.BACKTRACKING||!U.fragCurrent&&O===x.PARSING)&&(U.fragmentTracker.removeFragment(g),U.state=x.IDLE);return}if("payload"in V&&(U.log("Loaded fragment "+g.sn+" of level "+g.level),U.hls.trigger(N.Events.FRAG_LOADED,V),U.state===x.BACKTRACKING)){U.fragmentTracker.backtrack(g,V),U.resetFragmentLoading(g);return}U._handleFragmentLoadComplete(V)}).catch(function(V){U.warn(V),U.resetFragmentLoading(g)})},o.flushMainBuffer=function(g,S,M){if(M===void 0&&(M=null),!(g-S))return;var U={startOffset:g,endOffset:S,type:M};this.fragLoadError=0,this.hls.trigger(N.Events.BUFFER_FLUSHING,U)},o._loadInitSegment=function(g){var S=this;this._doFragLoad(g).then(function(M){if(!M||S.fragContextChanged(g)||!S.levels)throw new Error("init load aborted");return M}).then(function(M){var U=S.hls,G=M.payload,V=g.decryptdata;if(G&&G.byteLength>0&&V&&V.key&&V.iv&&V.method==="AES-128"){var O=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(G),V.key.buffer,V.iv.buffer).then(function(I){var X=self.performance.now();return U.trigger(N.Events.FRAG_DECRYPTED,{frag:g,payload:I,stats:{tstart:O,tdecrypt:X}}),M.payload=I,M})}return M}).then(function(M){var U=S.fragCurrent,G=S.hls,V=S.levels;if(!V)throw new Error("init load aborted, missing levels");var O=V[g.level].details;console.assert(O,"Level details are defined when init segment is loaded");var I=g.stats;S.state=x.IDLE,S.fragLoadError=0,g.data=new Uint8Array(M.payload),I.parsing.start=I.buffering.start=self.performance.now(),I.parsing.end=I.buffering.end=self.performance.now(),M.frag===U&&G.trigger(N.Events.FRAG_BUFFERED,{stats:I,frag:U,part:null,id:g.type}),S.tick()}).catch(function(M){S.warn(M),S.resetFragmentLoading(g)})},o.fragContextChanged=function(g){var S=this.fragCurrent;return!g||!S||g.level!==S.level||g.sn!==S.sn||g.urlId!==S.urlId},o.fragBufferedComplete=function(g,S){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+a.default.toString(K.BufferHelper.getBuffered(M))),this.state=x.IDLE,this.tick()},o._handleFragmentLoadComplete=function(g){var S=this.transmuxer;if(!S)return;var M=g.frag,U=g.part,G=g.partsLoaded,V=!G||G.length===0||G.some(function(I){return!I}),O=new y.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,U?U.index:-1,!V);S.flush(O)},o._handleFragmentLoadProgress=function(g){},o._doFragLoad=function(g,S,M,U){var G=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(g.start,M||0),this.config.lowLatencyMode&&S){var V=S.partList;if(V&&U){M>g.end&&S.fragmentHint&&(g=S.fragmentHint);var O=this.getNextPart(V,g,M);if(O>-1){var I=V[O];return this.log("Loading part sn: "+g.sn+" p: "+I.index+" cc: "+g.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+O+"-"+(V.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=I.start+I.duration,this.state=x.FRAG_LOADING,this.hls.trigger(N.Events.FRAG_LOADING,{frag:g,part:V[O],targetBufferTime:M}),this.doFragPartsLoad(g,V,O,U).catch(function(X){return G.handleFragLoadError(X)})}else if(!g.url||this.loadedEndOfParts(V,M))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(M.toFixed(3))),Object(Z.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=x.FRAG_LOADING,this.hls.trigger(N.Events.FRAG_LOADING,{frag:g,targetBufferTime:M}),this.fragmentLoader.load(g,U).catch(function(X){return G.handleFragLoadError(X)})},o.doFragPartsLoad=function(g,S,M,U){var G=this;return new Promise(function(V,O){var I=[],X=function q(oe){var ce=S[oe];G.fragmentLoader.loadPart(g,ce,U).then(function(Le){I[ce.index]=Le;var Ee=Le.part;G.hls.trigger(N.Events.FRAG_LOADED,Le);var we=S[oe+1];if(we&&we.fragment===g)q(oe+1);else return V({frag:g,part:Ee,partsLoaded:I})}).catch(O)};X(M)})},o.handleFragLoadError=function(g){var S=g.data;return S&&S.details===D.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(N.Events.ERROR,S),null},o._handleTransmuxerFlush=function(g){var S=this.getCurrentContext(g);if(!S||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var M=S.frag,U=S.part,G=S.level,V=self.performance.now();M.stats.parsing.end=V,U&&(U.stats.parsing.end=V),this.updateLevelTiming(M,U,G,g.partial)},o.getCurrentContext=function(g){var S=this.levels,M=g.level,U=g.sn,G=g.part;if(!S||!S[M])return this.warn("Levels object was unset while buffering fragment "+U+" of level "+M+". The current chunk will not be buffered."),null;var V=S[M],O=G>-1?Object(C.getPartWith)(V,U,G):null,I=O?O.fragment:Object(C.getFragmentWithSN)(V,U,this.fragCurrent);return I?{frag:I,part:O,level:V}:null},o.bufferFragmentData=function(g,S,M,U){if(!g||this.state!==x.PARSING)return;var G=g.data1,V=g.data2,O=G;if(G&&V&&(O=Object(A.appendUint8Array)(G,V)),!O||!O.length)return;var I={type:g.type,frag:S,part:M,chunkMeta:U,parent:S.type,data:O};this.hls.trigger(N.Events.BUFFER_APPENDING,I),g.dropped&&g.independent&&!M&&this.flushBufferGap(S)},o.flushBufferGap=function(g){var S=this.media;if(!S)return;if(!K.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,g.start);return}var M=S.currentTime,U=K.BufferHelper.bufferInfo(S,M,0),G=g.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,G*.25),O=Math.max(Math.min(g.start-V,U.end-V),M+V);g.start-O>V&&this.flushMainBuffer(O,g.start)},o.getFwdBufferInfo=function(g,S){var M=this.config,U=this.getLoadPosition();if(!Object(Z.isFiniteNumber)(U))return null;var G=K.BufferHelper.bufferInfo(g,U,M.maxBufferHole);if(G.len===0&&G.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(U,S);if(V&&G.nextStart<V.end)return K.BufferHelper.bufferInfo(g,U,Math.max(G.nextStart,M.maxBufferHole))}return G},o.getMaxBufferLength=function(g){var S=this.config,M;return g?M=Math.max(8*S.maxBufferSize/g,S.maxBufferLength):M=S.maxBufferLength,Math.min(M,S.maxMaxBufferLength)},o.reduceMaxBufferLength=function(g){var S=this.config,M=g||S.maxBufferLength;return S.maxMaxBufferLength>=M?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(g,S){var M,U,G=S.fragments,V=G.length;if(!V)return null;var O=this.config,I=G[0].start,X;if(S.live){var q=O.initialLiveManifestSize;if(V<q)return this.warn("Not enough fragments to start playback (have: "+V+", need: "+q+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(X=this.getInitialLiveFragment(S,G),this.startPosition=X?this.hls.liveSyncPosition||X.start:g)}else g<=I&&(X=G[0]);if(!X){var oe=O.lowLatencyMode?S.partEnd:S.fragmentEnd;X=this.getFragmentAtPosition(g,oe,S)}return(M=X)!==null&&M!==void 0&&M.initSegment&&!((U=X)!==null&&U!==void 0&&U.initSegment.data)&&!this.bitrateTest&&(X=X.initSegment),X},o.getNextPart=function(g,S,M){for(var U=-1,G=!1,V=!0,O=0,I=g.length;O<I;O++){var X=g[O];if(V=V&&!X.independent,U>-1&&M<X.start)break;var q=X.loaded;!q&&(G||X.independent||V)&&X.fragment===S&&(U=O),G=q}return U},o.loadedEndOfParts=function(g,S){var M=g[g.length-1];return M&&S>M.start&&M.loaded},o.getInitialLiveFragment=function(g,S){var M=this.fragPrevious,U=null;if(M){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),U=Object(T.findFragmentByPDT)(S,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!U){var G=M.sn+1;if(G>=g.startSN&&G<=g.endSN){var V=S[G-g.startSN];M.cc===V.cc&&(U=V,this.log("Live playlist, switching playlist, load frag with next SN: "+U.sn))}U||(U=Object(T.findFragWithCC)(S,M.cc),U&&this.log("Live playlist, switching playlist, load frag with same CC: "+U.sn))}}else{var O=this.hls.liveSyncPosition;O!==null&&(U=this.getFragmentAtPosition(O,this.bitrateTest?g.fragmentEnd:g.edge,g))}return U},o.getFragmentAtPosition=function(g,S,M){var U=this.config,G=this.fragPrevious,V=M.fragments,O=M.endSN,I=M.fragmentHint,X=U.maxFragLookUpTolerance,q=!!(U.lowLatencyMode&&M.partList&&I);q&&I&&!this.bitrateTest&&(V=V.concat(I),O=I.sn);var oe;if(g<S){var ce=g>S-X?0:X;oe=Object(T.findFragmentByPTS)(G,V,g,ce)}else oe=V[V.length-1];if(oe){var Le=oe.sn-M.startSN,Ee=G&&oe.level===G.level,we=V[Le+1],Te=this.fragmentTracker.getState(oe);if(Te===P.FragmentState.BACKTRACKED){oe=null;for(var ye=Le;V[ye]&&this.fragmentTracker.getState(V[ye])===P.FragmentState.BACKTRACKED;)G?oe=V[ye--]:oe=V[--ye];oe||(oe=we)}else G&&oe.sn===G.sn&&!q&&(Ee&&(oe.sn<O&&this.fragmentTracker.getState(we)!==P.FragmentState.OK?(this.log("SN "+oe.sn+" just loaded, load next one: "+we.sn),oe=we):oe=null))}return oe},o.synchronizeToLiveEdge=function(g){var S=this.config,M=this.media;if(!M)return;var U=this.hls.liveSyncPosition,G=M.currentTime,V=g.fragments[0].start,O=g.edge,I=G>=V-S.maxFragLookUpTolerance&&G<=O;if(U!==null&&M.duration>U&&(G<U||!I)){var X=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*g.targetduration;(!I&&M.readyState<4||G<O-X)&&(this.loadedmetadata||(this.nextLoadPosition=U),M.readyState&&(this.warn("Playback: "+G.toFixed(3)+" is located too far from the end of live sliding playlist: "+O+", reset currentTime to : "+U.toFixed(3)),M.currentTime=U))}},o.alignPlaylists=function(g,S){var M=this.levels,U=this.levelLastLoaded,G=this.fragPrevious,V=U!==null?M[U]:null,O=g.fragments.length;if(!O)return this.warn("No fragments in live playlist"),0;var I=g.fragments[0].start,X=!S,q=g.alignedSliding&&Object(Z.isFiniteNumber)(I);if(X||!q&&!I){Object(k.alignStream)(G,V,g);var oe=g.fragments[0].start;return this.log("Live playlist sliding: "+oe.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+g.startSN+" prev-sn: "+(G?G.sn:"na")+" fragments: "+O),oe}return I},o.waitForCdnTuneIn=function(g){var S=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*S)},o.setStartPosition=function(g,S){var M=this.startPosition;if(M<S&&(M=-1),M===-1||this.lastCurrentTime===-1){var U=g.startTimeOffset;Object(Z.isFiniteNumber)(U)?(M=S+U,U<0&&(M+=g.totalduration),M=Math.min(Math.max(S,M),S+g.totalduration),this.log("Start time offset "+U+" found in playlist, adjust startPosition to "+M),this.startPosition=M):g.live?M=this.hls.liveSyncPosition||S:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},o.getLoadPosition=function(){var g=this.media,S=0;return this.loadedmetadata&&g?S=g.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},o.handleFragLoadAborted=function(g,S){this.transmuxer&&g.sn!=="initSegment"&&g.stats.aborted&&(this.warn("Fragment "+g.sn+(S?" part"+S.index:"")+" of level "+g.level+" was aborted"),this.resetFragmentLoading(g))},o.resetFragmentLoading=function(g){(!this.fragCurrent||!this.fragContextChanged(g))&&(this.state=x.IDLE)},o.onFragmentOrKeyLoadError=function(g,S){if(S.fatal)return;var M=S.frag;if(!M||M.type!==g)return;var U=this.fragCurrent;console.assert(U&&M.sn===U.sn&&M.level===U.level&&M.urlId===U.urlId,"Frag load error must match current frag to retry");var G=this.config;if(this.fragLoadError+1<=G.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(M.level))return;var V=Math.min(Math.pow(2,this.fragLoadError)*G.fragLoadingRetryDelay,G.fragLoadingMaxRetryTimeout);this.warn("Fragment "+M.sn+" of "+g+" "+M.level+" failed to load, retrying in "+V+"ms"),this.retryDate=self.performance.now()+V,this.fragLoadError++,this.state=x.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(g===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(j.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},o.afterBufferFlushed=function(g,S,M){if(!g)return;var U=K.BufferHelper.getBuffered(g);this.fragmentTracker.detectEvictedFragments(S,U,M),this.state===x.ENDED&&this.resetLoadingState()},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},o.resetLiveStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[g].details:null;if(S!=null&&S.live)return this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(g,S,M,U){var G=this,V=M.details;console.assert(!!V,"level.details must be defined");var O=Object.keys(g.elementaryStreams).reduce(function(I,X){var q=g.elementaryStreams[X];if(q){var oe=q.endPTS-q.startPTS;if(oe<=0)return G.warn("Could not parse fragment "+g.sn+" "+X+" duration reliably ("+oe+") resetting transmuxer to fallback to playlist timing"),G.resetTransmuxer(),I||!1;var ce=U?0:Object(C.updateFragPTSDTS)(V,g,q.startPTS,q.endPTS,q.startDTS,q.endDTS);return G.hls.trigger(N.Events.LEVEL_PTS_UPDATED,{details:V,level:M,drift:ce,type:X,frag:g,start:q.startPTS,end:q.endPTS}),!0}return I},!1);O?(this.state=x.PARSED,this.hls.trigger(N.Events.FRAG_PARSED,{frag:g,part:S})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},_(h,[{key:"state",get:function(){return this._state},set:function(g){var S=this._state;S!==g&&(this._state=g,this.log(S+"->"+g))}}]),h}(F.default)},"./src/controller/buffer-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var Z=R("./src/polyfills/number.ts"),F=R("./src/events.ts"),P=R("./src/utils/logger.ts"),K=R("./src/errors.ts"),j=R("./src/utils/buffer-helper.ts"),N=R("./src/utils/mediasource-helper.ts"),D=R("./src/loader/fragment.ts"),y=R("./src/controller/buffer-operation-queue.ts"),A=Object(N.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function C(u){var a=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var l=a.hls,d=a.media,_=a.mediaSource;P.logger.log("[buffer-controller]: Media source opened"),d&&(a.updateMediaElementDuration(),l.trigger(F.Events.MEDIA_ATTACHED,{media:d})),_&&_.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){P.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var b=C.prototype;return b.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},b.destroy=function(){this.unregisterListeners(),this.details=null},b.registerListeners=function(){var a=this.hls;a.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(F.Events.BUFFER_RESET,this.onBufferReset,this),a.on(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(F.Events.BUFFER_EOS,this.onBufferEos,this),a.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(F.Events.FRAG_PARSED,this.onFragParsed,this),a.on(F.Events.FRAG_CHANGED,this.onFragChanged,this)},b.unregisterListeners=function(){var a=this.hls;a.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(F.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(F.Events.BUFFER_RESET,this.onBufferReset,this),a.off(F.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(F.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(F.Events.BUFFER_EOS,this.onBufferEos,this),a.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(F.Events.FRAG_PARSED,this.onFragParsed,this),a.off(F.Events.FRAG_CHANGED,this.onFragChanged,this)},b._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},b.onManifestParsed=function(a,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")},b.onMediaAttaching=function(a,l){var d=this.media=l.media;if(d&&A){var _=this.mediaSource=new A;_.addEventListener("sourceopen",this._onMediaSourceOpen),_.addEventListener("sourceended",this._onMediaSourceEnded),_.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(_),this._objectUrl=d.src}},b.onMediaDetaching=function(){var a=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(_){P.logger.warn("[buffer-controller]: onMediaDetaching: "+_.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(d&&self.URL.revokeObjectURL(d),a.src===d?(a.removeAttribute("src"),a.load()):P.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(F.Events.MEDIA_DETACHED,void 0)},b.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(l){var d=a.sourceBuffer[l];try{d&&(a.removeBufferListeners(l),a.mediaSource&&a.mediaSource.removeSourceBuffer(d),a.sourceBuffer[l]=void 0)}catch(_){P.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",_)}}),this._initSourceBuffer()},b.onBufferCodecs=function(a,l){var d=this,_=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(v){if(_){var m=d.tracks[v];if(m&&typeof m.buffer.changeType=="function"){var L=l[v],x=L.codec,p=L.levelCodec,f=L.container,h=(m.levelCodec||m.codec).replace(k,"$1"),o=(p||x).replace(k,"$1");if(h!==o){var E=f+";codecs="+(p||x);d.appendChangeType(v,E)}}}else d.pendingTracks[v]=l[v]}),_)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},b.appendChangeType=function(a,l){var d=this,_=this.operationQueue,v={execute:function(){var L=d.sourceBuffer[a];L&&(P.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+l),L.changeType(l)),_.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(L){P.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",L)}};_.append(v,a)},b.onBufferAppending=function(a,l){var d=this,_=this.hls,v=this.operationQueue,m=this.tracks,L=l.data,x=l.type,p=l.frag,f=l.part,h=l.chunkMeta,o=h.buffering[x],E=self.performance.now();o.start=E;var g=p.stats.buffering,S=f?f.stats.buffering:null;g.start===0&&(g.start=E),S&&S.start===0&&(S.start=E);var M=m.audio,U=x==="audio"&&h.id===1&&(M==null?void 0:M.container)==="audio/mpeg",G={execute:function(){if(o.executeStart=self.performance.now(),U){var O=d.sourceBuffer[x];if(O){var I=p.start-O.timestampOffset;Math.abs(I)>=.1&&(P.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p.start+" (delta: "+I+") sn: "+p.sn+")"),O.timestampOffset=p.start)}}d.appendExecutor(L,x)},onStart:function(){},onComplete:function(){var O=self.performance.now();o.executeEnd=o.end=O,g.first===0&&(g.first=O),S&&S.first===0&&(S.first=O);var I=d.sourceBuffer,X={};for(var q in I)X[q]=j.BufferHelper.getBuffered(I[q]);d.appendError=0,d.hls.trigger(F.Events.BUFFER_APPENDED,{type:x,frag:p,part:f,chunkMeta:h,parent:p.type,timeRanges:X})},onError:function(O){P.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",O);var I={type:K.ErrorTypes.MEDIA_ERROR,parent:p.type,details:K.ErrorDetails.BUFFER_APPEND_ERROR,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=K.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,I.details=K.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>_.config.appendErrorMaxRetry&&(P.logger.error("[buffer-controller]: Failed "+_.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),I.fatal=!0)),_.trigger(F.Events.ERROR,I)}};v.append(G,x)},b.onBufferFlushing=function(a,l){var d=this,_=this.operationQueue,v=function(L){return{execute:d.removeExecutor.bind(d,L,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(F.Events.BUFFER_FLUSHED,{type:L})},onError:function(p){P.logger.warn("[buffer-controller]: Failed to remove from "+L+" SourceBuffer",p)}}};l.type?_.append(v(l.type),l.type):this.getSourceBufferTypes().forEach(function(m){_.append(v(m),m)})},b.onFragParsed=function(a,l){var d=this,_=l.frag,v=l.part,m=[],L=v?v.elementaryStreams:_.elementaryStreams;L[D.ElementaryStreamTypes.AUDIOVIDEO]?m.push("audiovideo"):(L[D.ElementaryStreamTypes.AUDIO]&&m.push("audio"),L[D.ElementaryStreamTypes.VIDEO]&&m.push("video"));var x=function(){var f=self.performance.now();_.stats.buffering.end=f,v&&(v.stats.buffering.end=f);var h=v?v.stats:_.stats;d.hls.trigger(F.Events.FRAG_BUFFERED,{frag:_,part:v,stats:h,id:_.type})};m.length===0&&P.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+_.type+" level: "+_.level+" sn: "+_.sn),this.blockBuffers(x,m)},b.onFragChanged=function(a,l){this.flushBackBuffer()},b.onBufferEos=function(a,l){var d=this,_=this.getSourceBufferTypes().reduce(function(v,m){var L=d.sourceBuffer[m];return(!l.type||l.type===m)&&(L&&!L.ended&&(L.ended=!0,P.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),v&&!!(!L||L.ended)},!0);_&&this.blockBuffers(function(){var v=d.mediaSource;if(!v||v.readyState!=="open")return;v.endOfStream()})},b.onLevelUpdated=function(a,l){var d=l.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},b.flushBackBuffer=function(){var a=this.hls,l=this.details,d=this.media,_=this.sourceBuffer;if(!d||l===null)return;var v=this.getSourceBufferTypes();if(!v.length)return;var m=l.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!Object(Z.isFiniteNumber)(m)||m<0)return;var L=d.currentTime,x=l.levelTargetDuration,p=Math.max(m,x),f=Math.floor(L/x)*x-p;v.forEach(function(h){var o=_[h];if(o){var E=j.BufferHelper.getBuffered(o);E.length>0&&f>E.start(0)&&(a.trigger(F.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),l.live&&a.trigger(F.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),a.trigger(F.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:h}))}})},b.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var a=this.details,l=this.hls,d=this.media,_=this.mediaSource,v=a.fragments[0].start+a.totalduration,m=d.duration,L=Object(Z.isFiniteNumber)(_.duration)?_.duration:0;a.live&&l.config.liveDurationInfinity?(P.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),_.duration=Infinity,this.updateSeekableRange(a)):(v>L&&v>m||!Object(Z.isFiniteNumber)(m))&&(P.logger.log("[buffer-controller]: Updating Media Source duration to "+v.toFixed(3)),_.duration=v)},b.updateSeekableRange=function(a){var l=this.mediaSource,d=a.fragments,_=d.length;if(_&&a.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var v=Math.max(0,d[0].start),m=Math.max(v,v+a.totalduration);l.setLiveSeekableRange(v,m)}},b.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,l=this.operationQueue,d=this.pendingTracks,_=Object.keys(d).length;if(_&&!a||_===2){this.createSourceBuffers(d),this.pendingTracks={};var v=this.getSourceBufferTypes();if(v.length===0){this.hls.trigger(F.Events.ERROR,{type:K.ErrorTypes.MEDIA_ERROR,details:K.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}v.forEach(function(m){l.executeNext(m)})}},b.createSourceBuffers=function(a){var l=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var _=0;for(var v in a)if(!l[v]){var m=a[v];if(!m)throw Error("source buffer exists for track "+v+", however track does not");var L=m.levelCodec||m.codec,x=m.container+";codecs="+L;P.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var p=l[v]=d.addSourceBuffer(x),f=v;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[v]={buffer:p,codec:L,container:m.container,levelCodec:m.levelCodec,id:m.id},_++}catch(h){P.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+h.message),this.hls.trigger(F.Events.ERROR,{type:K.ErrorTypes.MEDIA_ERROR,details:K.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,mimeType:x})}}_&&this.hls.trigger(F.Events.BUFFER_CREATED,{tracks:this.tracks})},b._onSBUpdateStart=function(a){var l=this.operationQueue,d=l.current(a);d.onStart()},b._onSBUpdateEnd=function(a){var l=this.operationQueue,d=l.current(a);d.onComplete(),l.shiftAndExecuteNext(a)},b._onSBUpdateError=function(a,l){P.logger.error("[buffer-controller]: "+a+" SourceBuffer error",l),this.hls.trigger(F.Events.ERROR,{type:K.ErrorTypes.MEDIA_ERROR,details:K.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(a);d&&d.onError(l)},b.removeExecutor=function(a,l,d){var _=this.media,v=this.mediaSource,m=this.operationQueue,L=this.sourceBuffer,x=L[a];if(!_||!v||!x){P.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(a);return}var p=Object(Z.isFiniteNumber)(_.duration)?_.duration:Infinity,f=Object(Z.isFiniteNumber)(v.duration)?v.duration:Infinity,h=Math.max(0,l),o=Math.min(d,p,f);o>h?(P.logger.log("[buffer-controller]: Removing ["+h+","+o+"] from the "+a+" SourceBuffer"),console.assert(!x.updating,a+" sourceBuffer must not be updating"),x.remove(h,o)):m.shiftAndExecuteNext(a)},b.appendExecutor=function(a,l){var d=this.operationQueue,_=this.sourceBuffer,v=_[l];if(!v){P.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(l);return}v.ended=!1,console.assert(!v.updating,l+" sourceBuffer must not be updating"),v.appendBuffer(a)},b.blockBuffers=function(a,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(a);return}var _=this.operationQueue,v=l.map(function(m){return _.appendBlocker(m)});Promise.all(v).then(function(){a(),l.forEach(function(m){var L=d.sourceBuffer[m];(!L||!L.updating)&&_.shiftAndExecuteNext(m)})})},b.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},b.addBufferListener=function(a,l,d){var _=this.sourceBuffer[a];if(!_)return;var v=d.bind(this,a);this.listeners[a].push({event:l,listener:v}),_.addEventListener(l,v)},b.removeBufferListeners=function(a){var l=this.sourceBuffer[a];if(!l)return;this.listeners[a].forEach(function(d){l.removeEventListener(d.event,d.listener)})},C}()},"./src/controller/buffer-operation-queue.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return F});var Z=R("./src/utils/logger.ts"),F=function(){function P(j){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=j}var K=P.prototype;return K.append=function(N,D){var y=this.queues[D];y.push(N),y.length===1&&this.buffers[D]&&this.executeNext(D)},K.insertAbort=function(N,D){var y=this.queues[D];y.unshift(N),this.executeNext(D)},K.appendBlocker=function(N){var D,y=new Promise(function(k){D=k}),A={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,N),y},K.executeNext=function(N){var D=this.buffers,y=this.queues,A=D[N],k=y[N];if(k.length){var T=k[0];try{T.execute()}catch(C){Z.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(C),(!A||!A.updating)&&(k.shift(),this.executeNext(N))}}},K.shiftAndExecuteNext=function(N){this.queues[N].shift(),this.executeNext(N)},K.current=function(N){return this.queues[N][0]},P}()},"./src/controller/cap-level-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts");function F(j,N){for(var D=0;D<N.length;D++){var y=N[D];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(j,y.key,y)}}function P(j,N,D){return N&&F(j.prototype,N),D&&F(j,D),j}var K=function(){function j(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 N=j.prototype;return N.setStreamController=function(y){this.streamController=y},N.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},N.registerListeners=function(){var 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)},N.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)},N.onFpsDropLevelCapping=function(y,A){j.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},N.onMediaAttaching=function(y,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},N.onManifestParsed=function(y,A){var k=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,k.config.capLevelToPlayerSize&&A.video&&this.startCapping()},N.onBufferCodecs=function(y,A){var k=this.hls;k.config.capLevelToPlayerSize&&A.video&&this.startCapping()},N.onMediaDetaching=function(){this.stopCapping()},N.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(y.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},N.getMaxLevel=function(y){var A=this,k=this.hls.levels;if(!k.length)return-1;var T=k.filter(function(C,b){return j.isLevelAllowed(b,A.restrictedLevels)&&b<=y});return this.clientRect=null,j.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},N.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},N.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},N.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,A={width:0,height:0};if(y){var k=y.getBoundingClientRect();A.width=k.width,A.height=k.height,!A.width&&!A.height&&(A.width=k.right-k.left||y.width||0,A.height=k.bottom-k.top||y.height||0)}return this.clientRect=A,A},j.isLevelAllowed=function(y,A){return A===void 0&&(A=[]),A.indexOf(y)===-1},j.getMaxLevelByMediaSize=function(y,A,k){if(!y||!y.length)return-1;for(var T=function(l,d){return d?l.width!==d.width||l.height!==d.height:!0},C=y.length-1,b=0;b<y.length;b+=1){var u=y[b];if((u.width>=A||u.height>=k)&&T(u,y[b+1])){C=b;break}}return C},P(j,[{key:"mediaWidth",get:function(){return this.getDimensions().width*j.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*j.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var y=1;try{y=self.devicePixelRatio}catch(A){}return y}}]),j}();$.default=K},"./src/controller/cmcd-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var Z=R("./src/events.ts"),F=R("./src/types/cmcd.ts"),P=R("./src/utils/buffer-helper.ts"),K=R("./src/utils/logger.ts");function j(C,b){for(var u=0;u<b.length;u++){var a=b[u];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(C,a.key,a)}}function N(C,b,u){return b&&j(C.prototype,b),u&&j(C,u),C}function D(C,b){var u=typeof Symbol!="undefined"&&C[Symbol.iterator]||C["@@iterator"];if(u)return(u=u.call(C)).next.bind(u);if(Array.isArray(C)||(u=y(C))||b&&C&&typeof C.length=="number"){u&&(C=u);var a=0;return function(){return a>=C.length?{done:!0}:{done:!1,value:C[a++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(C,b){if(!C)return;if(typeof C=="string")return A(C,b);var u=Object.prototype.toString.call(C).slice(8,-1);if(u==="Object"&&C.constructor&&(u=C.constructor.name),u==="Map"||u==="Set")return Array.from(C);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return A(C,b)}function A(C,b){(b==null||b>C.length)&&(b=C.length);for(var u=0,a=new Array(b);u<b;u++)a[u]=C[u];return a}function k(){return k=Object.assign||function(C){for(var b=1;b<arguments.length;b++){var u=arguments[b];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(C[a]=u[a])}return C},k.apply(this,arguments)}var T=function(){function C(u){var a=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){a.initialized&&(a.starved=!0),a.buffering=!0},this.onPlaying=function(){a.initialized||(a.initialized=!0),a.buffering=!1},this.applyPlaylistData=function(_){try{a.apply(_,{ot:F.CMCDObjectType.MANIFEST,su:!a.initialized})}catch(v){K.logger.warn("Could not generate manifest CMCD data.",v)}},this.applyFragmentData=function(_){try{var v=_.frag,m=a.hls.levels[v.level],L=a.getObjectType(v),x={d:v.duration*1e3,ot:L};(L===F.CMCDObjectType.VIDEO||L===F.CMCDObjectType.AUDIO||L==F.CMCDObjectType.MUXED)&&(x.br=m.bitrate/1e3,x.tb=a.getTopBandwidth(L),x.bl=a.getBufferLength(L)),a.apply(_,x)}catch(p){K.logger.warn("Could not generate segment CMCD data.",p)}},this.hls=u;var l=this.config=u.config,d=l.cmcd;d!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||C.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var b=C.prototype;return b.registerListeners=function(){var a=this.hls;a.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.on(Z.Events.BUFFER_CREATED,this.onBufferCreated,this)},b.unregisterListeners=function(){var a=this.hls;a.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(Z.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.off(Z.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},b.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},b.onMediaAttached=function(a,l){this.media=l.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},b.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},b.onBufferCreated=function(a,l){var d,_;this.audioBuffer=(d=l.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(_=l.tracks.video)===null||_===void 0?void 0:_.buffer},b.createData=function(){var a;return{v:F.CMCDVersion,sf:F.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(a=this.media)===null||a===void 0?void 0:a.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},b.apply=function(a,l){l===void 0&&(l={}),k(l,this.createData());var d=l.ot===F.CMCDObjectType.INIT||l.ot===F.CMCDObjectType.VIDEO||l.ot===F.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.toHeaders(l);if(!Object.keys(_).length)return;a.headers||(a.headers={}),k(a.headers,_)}else{var v=C.toQuery(l);if(!v)return;a.url=C.appendQueryToUri(a.url,v)}},b.getObjectType=function(a){var l=a.type;return l==="subtitle"?F.CMCDObjectType.TIMED_TEXT:a.sn==="initSegment"?F.CMCDObjectType.INIT:l==="audio"?F.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?F.CMCDObjectType.VIDEO:F.CMCDObjectType.MUXED:void 0},b.getTopBandwidth=function(a){for(var l=0,d=a===F.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,_=D(d),v;!(v=_()).done;){var m=v.value;m.bitrate>l&&(l=m.bitrate)}return l>0?l:NaN},b.getBufferLength=function(a){var l=this.hls.media,d=a===F.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!l)return NaN;var _=P.BufferHelper.bufferInfo(d,l.currentTime,this.config.maxBufferHole);return _.len*1e3},b.createPlaylistLoader=function(){var a=this.config.pLoader,l=this.applyPlaylistData,d=a||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var v=_.prototype;return v.destroy=function(){this.loader.destroy()},v.abort=function(){this.loader.abort()},v.load=function(L,x,p){l(L),this.loader.load(L,x,p)},N(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},b.createFragmentLoader=function(){var a=this.config.fLoader,l=this.applyFragmentData,d=a||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var v=_.prototype;return v.destroy=function(){this.loader.destroy()},v.abort=function(){this.loader.abort()},v.load=function(L,x,p){l(L),this.loader.load(L,x,p)},N(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},C.uuid=function(){var a=URL.createObjectURL(new Blob),l=a.toString();return URL.revokeObjectURL(a),l.substr(l.lastIndexOf("/")+1)},C.serialize=function(a){for(var l=[],d=function(U){return!Number.isNaN(U)&&U!=null&&U!==""&&U!==!1},_=function(U){return Math.round(U)},v=function(U){return _(U/100)*100},m=function(U){return encodeURIComponent(U)},L={br:_,d:_,bl:v,dl:v,mtp:v,nor:m,rtp:v,tb:_},x=Object.keys(a||{}).sort(),p=D(x),f;!(f=p()).done;){var h=f.value,o=a[h];if(!d(o))continue;if(h==="v"&&o===1)continue;if(h=="pr"&&o===1)continue;var E=L[h];E&&(o=E(o));var g=typeof o,S=void 0;h==="ot"||h==="sf"||h==="st"?S=h+"="+o:g==="boolean"?S=h:g==="number"?S=h+"="+o:S=h+"="+JSON.stringify(o),l.push(S)}return l.join(",")},C.toHeaders=function(a){for(var l=Object.keys(a),d={},_=["Object","Request","Session","Status"],v=[{},{},{},{}],m={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,x=l;L<x.length;L++){var p=x[L],f=m[p]!=null?m[p]:1;v[f][p]=a[p]}for(var h=0;h<v.length;h++){var o=C.serialize(v[h]);o&&(d["CMCD-"+_[h]]=o)}return d},C.toQuery=function(a){return"CMCD="+encodeURIComponent(C.serialize(a))},C.appendQueryToUri=function(a,l){if(!l)return a;var d=a.includes("?")?"&":"?";return""+a+d+l},C}()},"./src/controller/eme-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts"),F=R("./src/errors.ts"),P=R("./src/utils/logger.ts"),K=R("./src/utils/mediakeys-helper.ts");function j(T,C){for(var b=0;b<C.length;b++){var u=C[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function N(T,C,b){return C&&j(T.prototype,C),b&&j(T,b),T}var D=3,y=function(C,b,u){var a={audioCapabilities:[],videoCapabilities:[]};return C.forEach(function(l){a.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:u.audioRobustness||""})}),b.forEach(function(l){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:u.videoRobustness||""})}),[a]},A=function(C,b,u,a){switch(C){case K.KeySystems.WIDEVINE:return y(b,u,a);default:throw new Error("Unknown key-system: "+C)}},k=function(){function T(b){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=b,this._config=b.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var C=T.prototype;return C.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},C._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)},C._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)},C.getLicenseServerUrl=function(u){switch(u){case K.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},C._attemptKeySystemAccess=function(u,a,l){var d=this,_=A(u,a,l,this._drmSystemOptions);P.logger.log("Requesting encrypted media key-system access");var v=this.requestMediaKeySystemAccess(u,_);this.mediaKeysPromise=v.then(function(m){return d._onMediaKeySystemAccessObtained(u,m)}),v.catch(function(m){P.logger.error('Failed to obtain key-system "'+u+'" access:',m)})},C._onMediaKeySystemAccessObtained=function(u,a){var l=this;P.logger.log('Access for key-system "'+u+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:a,mediaKeySystemDomain:u};this._mediaKeysList.push(d);var _=Promise.resolve().then(function(){return a.createMediaKeys()}).then(function(v){return d.mediaKeys=v,P.logger.log('Media-keys created for key-system "'+u+'"'),l._onMediaKeysCreated(),v});return _.catch(function(v){P.logger.error("Failed to create media-keys:",v)}),_},C._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(a){a.mediaKeysSession||(a.mediaKeysSession=a.mediaKeys.createSession(),u._onNewMediaKeySession(a.mediaKeysSession))})},C._onNewMediaKeySession=function(u){var a=this;P.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(l){a._onKeySessionMessage(u,l.message)},!1)},C._onKeySessionMessage=function(u,a){P.logger.log("Got EME message event, creating license request"),this._requestLicense(a,function(l){P.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),u.update(l)})},C.onMediaEncrypted=function(u){var a=this;if(P.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(_){if(!a._media)return;a._attemptSetMediaKeys(_),a._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(l).catch(l)},C._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var a=this._mediaKeysList[0];if(!a||!a.mediaKeys){P.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}P.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(a.mediaKeys),this._hasSetMediaKeys=!0}},C._generateRequestWithPreferredKeySession=function(u,a){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:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){P.logger.warn("Key-Session already initialized but requested again");return}var _=d.mediaKeysSession;if(!_){P.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!a){P.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}P.logger.log('Generating key-session request for "'+u+'" init data type'),d.mediaKeysSessionInitialized=!0,_.generateRequest(u,a).then(function(){P.logger.debug("Key-session generation succeeded")}).catch(function(v){P.logger.error("Error generating key-session request:",v),l.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},C._createLicenseXhr=function(u,a,l){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,u,a,l);var _=this._licenseXhrSetup;if(_)try{_.call(this.hls,d,u),_=void 0}catch(v){P.logger.error(v)}try{d.readyState||d.open("POST",u,!0),_&&_.call(this.hls,d,u)}catch(v){throw new Error("issue setting up KeySystem license XHR "+v)}return d},C._onLicenseRequestReadyStageChange=function(u,a,l,d){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,P.logger.log("License request succeeded");var _=u.response,v=this._licenseResponseCallback;if(v)try{_=v.call(this.hls,u,a)}catch(L){P.logger.error(L)}d(_)}else{if(P.logger.error("License Request XHR failed ("+a+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>D){this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var m=D-this._requestLicenseFailureCount+1;P.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(l,d)}break}},C._generateLicenseRequestChallenge=function(u,a){switch(u.mediaKeySystemDomain){case K.KeySystems.WIDEVINE:return a}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},C._requestLicense=function(u,a){P.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){P.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(l.mediaKeySystemDomain),_=this._createLicenseXhr(d,u,a);P.logger.log("Sending license request to URL: "+d);var v=this._generateLicenseRequestChallenge(l,u);_.send(v)}catch(m){P.logger.error("Failure requesting DRM license: "+m),this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.KEY_SYSTEM_ERROR,details:F.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},C.onMediaAttached=function(u,a){if(!this._emeEnabled)return;var l=a.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},C.onMediaDetached=function(){var u=this._media,a=this._mediaKeysList;if(!u)return;u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(a.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){})},C.onManifestParsed=function(u,a){if(!this._emeEnabled)return;var l=a.levels.map(function(_){return _.audioCodec}).filter(function(_){return!!_}),d=a.levels.map(function(_){return _.videoCodec}).filter(function(_){return!!_});this._attemptKeySystemAccess(K.KeySystems.WIDEVINE,l,d)},N(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();$.default=k},"./src/controller/fps-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts"),F=R("./src/utils/logger.ts"),P=function(){function K(N){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=N,this.registerListeners()}var j=K.prototype;return j.setStreamController=function(D){this.streamController=D},j.registerListeners=function(){this.hls.on(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},j.unregisterListeners=function(){this.hls.off(Z.Events.MEDIA_ATTACHING,this.onMediaAttaching)},j.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},j.onMediaAttaching=function(D,y){var A=this.hls.config;if(A.capLevelOnFPSDrop){var k=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=k,k&&typeof k.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},j.checkFPS=function(D,y,A){var k=performance.now();if(y){if(this.lastTime){var T=k-this.lastTime,C=A-this.lastDroppedFrames,b=y-this.lastDecodedFrames,u=1e3*C/T,a=this.hls;if(a.trigger(Z.Events.FPS_DROP,{currentDropped:C,currentDecoded:b,totalDroppedFrames:A}),u>0&&C>a.config.fpsDroppedMonitoringThreshold*b){var l=a.currentLevel;F.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(a.autoLevelCapping===-1||a.autoLevelCapping>=l)&&(l=l-1,a.trigger(Z.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:a.currentLevel}),a.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=A,this.lastDecodedFrames=y}},j.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)},K}();$.default=P},"./src/controller/fragment-finders.ts":function(le,$,R){"use strict";R.r($),R.d($,"findFragmentByPDT",function(){return P}),R.d($,"findFragmentByPTS",function(){return K}),R.d($,"fragmentWithinToleranceTest",function(){return j}),R.d($,"pdtWithinToleranceTest",function(){return N}),R.d($,"findFragWithCC",function(){return D});var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/binary-search.ts");function P(y,A,k){if(A===null||!Array.isArray(y)||!y.length||!Object(Z.isFiniteNumber)(A))return null;var T=y[0].programDateTime;if(A<(T||0))return null;var C=y[y.length-1].endProgramDateTime;if(A>=(C||0))return null;k=k||0;for(var b=0;b<y.length;++b){var u=y[b];if(N(A,k,u))return u}return null}function K(y,A,k,T){k===void 0&&(k=0),T===void 0&&(T=0);var C=null;if(y?C=A[y.sn-A[0].sn+1]||null:k===0&&A[0].start===0&&(C=A[0]),C&&j(k,T,C)===0)return C;var b=F.default.search(A,j.bind(null,k,T));return b||C}function j(y,A,k){y===void 0&&(y=0),A===void 0&&(A=0);var T=Math.min(A,k.duration+(k.deltaPTS?k.deltaPTS:0));return k.start+k.duration-T<=y?1:k.start-T>y&&k.start?-1:0}function N(y,A,k){var T=Math.min(A,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,C=k.endProgramDateTime||0;return C-T>y}function D(y,A){return F.default.search(y,function(k){return k.cc<A?1:k.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(le,$,R){"use strict";R.r($),R.d($,"FragmentState",function(){return P}),R.d($,"FragmentTracker",function(){return K});var Z=R("./src/events.ts"),F=R("./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 K=function(){function D(A){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=A,this._registerListeners()}var y=D.prototype;return y._registerListeners=function(){var k=this.hls;k.on(Z.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(Z.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(Z.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var k=this.hls;k.off(Z.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(Z.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(Z.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(k,T){if(T===F.PlaylistLevelType.MAIN){var C=this.activeFragment,b=this.activeParts;if(!C)return null;if(b)for(var u=b.length;u--;){var a=b[u],l=a?a.end:C.appendedPTS;if(a.start<=k&&l!==void 0&&k<=l)return u>9&&(this.activeParts=b.slice(u-9)),a}else if(C.start<=k&&C.appendedPTS!==void 0&&k<=C.appendedPTS)return C}return this.getBufferedFrag(k,T)},y.getBufferedFrag=function(k,T){for(var C=this.fragments,b=Object.keys(C),u=b.length;u--;){var a=C[b[u]];if((a==null?void 0:a.body.type)===T&&a.buffered){var l=a.body;if(l.start<=k&&k<=l.end)return l}}return null},y.detectEvictedFragments=function(k,T,C){var b=this;Object.keys(this.fragments).forEach(function(u){var a=b.fragments[u];if(!a)return;if(!a.buffered){a.body.type===C&&b.removeFragment(a.body);return}var l=a.range[k];if(!l)return;l.time.some(function(d){var _=!b.isTimeBuffered(d.startPTS,d.endPTS,T);return _&&b.removeFragment(a.body),_})})},y.detectPartialFragments=function(k){var T=this,C=this.timeRanges,b=k.frag,u=k.part;if(!C||b.sn==="initSegment")return;var a=N(b),l=this.fragments[a];if(!l)return;Object.keys(C).forEach(function(d){var _=b.elementaryStreams[d];if(!_)return;var v=C[d],m=u!==null||_.partial===!0;l.range[d]=T.getBufferedTimes(b,u,m,v)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},y.fragBuffered=function(k){var T=N(k),C=this.fragments[T];C&&(C.backtrack=C.loaded=null,C.buffered=!0)},y.getBufferedTimes=function(k,T,C,b){for(var u={time:[],partial:C},a=T?T.start:k.start,l=T?T.end:k.end,d=k.minEndPTS||l,_=k.maxStartPTS||a,v=0;v<b.length;v++){var m=b.start(v)-this.bufferPadding,L=b.end(v)+this.bufferPadding;if(_>=m&&d<=L){u.time.push({startPTS:Math.max(a,b.start(v)),endPTS:Math.min(l,b.end(v))});break}else if(a<L&&l>m)u.partial=!0,u.time.push({startPTS:Math.max(a,b.start(v)),endPTS:Math.min(l,b.end(v))});else if(l<=m)break}return u},y.getPartialFragment=function(k){var T=null,C,b,u,a=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(_){var v=d[_];if(!v)return;j(v)&&(b=v.body.start-l,u=v.body.end+l,k>=b&&k<=u&&(C=Math.min(k-b,u-k),a<=C&&(T=v.body,a=C)))}),T},y.getState=function(k){var T=N(k),C=this.fragments[T];return C?C.buffered?j(C)?P.PARTIAL:P.OK:C.backtrack?P.BACKTRACKED:P.APPENDING:P.NOT_LOADED},y.backtrack=function(k,T){var C=N(k),b=this.fragments[C];if(!b||b.backtrack)return null;var u=b.backtrack=T||b.loaded;return b.loaded=null,u},y.getBacktrackData=function(k){var T=N(k),C=this.fragments[T];if(C){var b,u=C.backtrack;if(u!=null&&(b=u.payload)!==null&&b!==void 0&&b.byteLength)return u;this.removeFragment(k)}return null},y.isTimeBuffered=function(k,T,C){for(var b,u,a=0;a<C.length;a++){if(b=C.start(a)-this.bufferPadding,u=C.end(a)+this.bufferPadding,k>=b&&T<=u)return!0;if(T<=b)return!1}return!1},y.onFragLoaded=function(k,T){var C=T.frag,b=T.part;if(C.sn==="initSegment"||C.bitrateTest||b)return;var u=N(C);this.fragments[u]={body:C,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}},y.onBufferAppended=function(k,T){var C=this,b=T.frag,u=T.part,a=T.timeRanges;if(b.type===F.PlaylistLevelType.MAIN)if(this.activeFragment=b,u){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(u)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(d){var _=a[d];if(C.detectEvictedFragments(d,_),!u)for(var v=0;v<_.length;v++)b.appendedPTS=Math.max(_.end(v),b.appendedPTS||0)})},y.onFragBuffered=function(k,T){this.detectPartialFragments(T)},y.hasFragment=function(k){var T=N(k);return!!this.fragments[T]},y.removeFragmentsInRange=function(k,T,C){var b=this;Object.keys(this.fragments).forEach(function(u){var a=b.fragments[u];if(!a)return;if(a.buffered){var l=a.body;l.type===C&&l.start<T&&l.end>k&&b.removeFragment(l)}})},y.removeFragment=function(k){var T=N(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[T]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},D}();function j(D){var y,A;return D.buffered&&(((y=D.range.video)===null||y===void 0?void 0:y.partial)||((A=D.range.audio)===null||A===void 0?void 0:A.partial))}function N(D){return D.type+"_"+D.level+"_"+D.urlId+"_"+D.sn}},"./src/controller/gap-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"STALL_MINIMUM_DURATION_MS",function(){return j}),R.d($,"MAX_START_GAP_JUMP",function(){return N}),R.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return D}),R.d($,"SKIP_BUFFER_RANGE_START",function(){return y}),R.d($,"default",function(){return A});var Z=R("./src/utils/buffer-helper.ts"),F=R("./src/errors.ts"),P=R("./src/events.ts"),K=R("./src/utils/logger.ts"),j=250,N=2,D=.1,y=.05,A=function(){function k(C,b,u,a){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=C,this.media=b,this.fragmentTracker=u,this.hls=a}var T=k.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(b){var u=this.config,a=this.media,l=this.stalled,d=a.currentTime,_=a.seeking,v=this.seeking&&!_,m=!this.seeking&&_;if(this.seeking=_,d!==b){if(this.moved=!0,l!==null){if(this.stallReported){var L=self.performance.now()-l;K.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((m||v)&&(this.stalled=null),a.paused||a.ended||a.playbackRate===0||!Z.BufferHelper.getBuffered(a).length)return;var x=Z.BufferHelper.bufferInfo(a,d,0),p=x.len>0,f=x.nextStart||0;if(!p&&!f)return;if(_){var h=x.len>N,o=!f||f-d>N&&!this.fragmentTracker.getPartialFragment(d);if(h||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,g=Math.max(f,x.start||0)-d,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=S==null||((E=S.details)===null||E===void 0)?void 0:E.live,U=M?S.details.targetduration*2:N;if(g>0&&g<=U){this._trySkipBufferHole(null);return}}var G=self.performance.now();if(l===null){this.stalled=G;return}var V=G-l;!_&&V>=j&&this._reportStall(x.len);var O=Z.BufferHelper.bufferInfo(a,d,u.maxBufferHole);this._tryFixBufferStall(O,V)},T._tryFixBufferStall=function(b,u){var a=this.config,l=this.fragmentTracker,d=this.media,_=d.currentTime,v=l.getPartialFragment(_);if(v){var m=this._trySkipBufferHole(v);if(m)return}b.len>a.maxBufferHole&&u>a.highBufferWatchdogPeriod*1e3&&(K.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(b){var u=this.hls,a=this.media,l=this.stallReported;l||(this.stallReported=!0,K.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer (buffer="+b+")"),u.trigger(P.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:b}))},T._trySkipBufferHole=function(b){for(var u=this.config,a=this.hls,l=this.media,d=l.currentTime,_=0,v=Z.BufferHelper.getBuffered(l),m=0;m<v.length;m++){var L=v.start(m);if(d+u.maxBufferHole>=_&&d<L){var x=Math.max(L+y,l.currentTime+D);return K.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+x),this.moved=!0,this.stalled=null,l.currentTime=x,b&&a.trigger(P.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+x,frag:b}),x}_=v.end(m)}return 0},T._tryNudgeBuffer=function(){var b=this.config,u=this.hls,a=this.media,l=a.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<b.nudgeMaxRetry){var _=l+d*b.nudgeOffset;K.logger.warn("Nudging 'currentTime' from "+l+" to "+_),a.currentTime=_,u.trigger(P.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else K.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+b.nudgeMaxRetry+" nudges"),u.trigger(P.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},k}()},"./src/controller/id3-track-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts"),F=R("./src/utils/texttrack-utils.ts"),P=R("./src/demux/id3.ts"),K=.25,j=function(){function N(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var D=N.prototype;return D.destroy=function(){this._unregisterListeners()},D._registerListeners=function(){var A=this.hls;A.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D._unregisterListeners=function(){var A=this.hls;A.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(Z.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(Z.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D.onMediaAttached=function(A,k){this.media=k.media},D.onMediaDetaching=function(){if(!this.id3Track)return;Object(F.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},D.getID3Track=function(A){if(!this.media)return;for(var k=0;k<A.length;k++){var T=A[k];if(T.kind==="metadata"&&T.label==="id3")return Object(F.sendAddTrackEvent)(T,this.media),T}return this.media.addTextTrack("metadata","id3")},D.onFragParsingMetadata=function(A,k){if(!this.media)return;var T=k.frag,C=k.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var b=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<C.length;u++){var a=P.getID3Frames(C[u].data);if(a){var l=C[u].pts,d=u<C.length-1?C[u+1].pts:T.end,_=d-l;_<=0&&(d=l+K);for(var v=0;v<a.length;v++){var m=a[v];if(!P.isTimeStampFrame(m)){var L=new b(l,d,"");L.value=m,this.id3Track.addCue(L)}}}}},D.onBufferFlushing=function(A,k){var T=k.startOffset,C=k.endOffset,b=k.type;if(!b||b==="audio"){var u=this.id3Track;u&&Object(F.removeCuesInRange)(u,T,C)}},N}();$.default=j},"./src/controller/latency-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return N});var Z=R("./src/errors.ts"),F=R("./src/events.ts"),P=R("./src/utils/logger.ts");function K(D,y){for(var A=0;A<y.length;A++){var k=y[A];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(D,k.key,k)}}function j(D,y,A){return y&&K(D.prototype,y),A&&K(D,A),D}var N=function(){function D(A){var k=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return k.timeupdate()},this.hls=A,this.config=A.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(F.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(F.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(F.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(F.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(F.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(F.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(F.Events.ERROR,this.onError)},y.onMediaAttached=function(k,T){this.media=T.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(k,T){var C=T.details;this.levelDetails=C,C.advanced&&this.timeupdate(),!C.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(k,T){if(T.details!==Z.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,P.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},y.timeupdate=function(){var k=this.media,T=this.levelDetails;if(!k||!T)return;this.currentTime=k.currentTime;var C=this.computeLatency();if(C===null)return;this._latency=C;var b=this.config,u=b.lowLatencyMode,a=b.maxLiveSyncPlaybackRate;if(!u||a===1)return;var l=this.targetLatency;if(l===null)return;var d=C-l,_=Math.min(this.maxLatency,l+T.targetduration),v=d<_;if(T.live&&v&&d>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,a)),L=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;k.playbackRate=Math.min(m,Math.max(1,L))}else k.playbackRate!==1&&k.playbackRate!==0&&(k.playbackRate=1)},y.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},y.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},j(D,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var k=this.config,T=this.levelDetails;return k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:T?k.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var k=this.levelDetails;if(k===null)return null;var T=k.holdBack,C=k.partHoldBack,b=k.targetduration,u=this.config,a=u.liveSyncDuration,l=u.liveSyncDurationCount,d=u.lowLatencyMode,_=this.hls.userConfig,v=d&&C||T;(_.liveSyncDuration||_.liveSyncDurationCount||v===0)&&(v=a!==void 0?a:l*b);var m=b,L=1;return v+Math.min(this.stallCount*L,m)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),T=this.targetLatency,C=this.levelDetails;if(k===null||T===null||C===null)return null;var b=C.edge,u=k-T-this.edgeStalled,a=b-C.totalduration,l=b-(this.config.lowLatencyMode&&C.partTarget||C.targetduration);return Math.min(Math.max(a,u),l)}},{key:"drift",get:function(){var k=this.levelDetails;return k===null?1:k.drift}},{key:"edgeStalled",get:function(){var k=this.levelDetails;if(k===null)return 0;var T=(this.config.lowLatencyMode&&k.partTarget||k.targetduration)*3;return Math.max(k.age-T,0)}},{key:"forwardBufferLength",get:function(){var k=this.media,T=this.levelDetails;if(!k||!T)return 0;var C=k.buffered.length;return C?k.buffered.end(C-1):T.edge-this.currentTime}}]),D}()},"./src/controller/level-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return u});var Z=R("./src/types/level.ts"),F=R("./src/events.ts"),P=R("./src/errors.ts"),K=R("./src/utils/codecs.ts"),j=R("./src/controller/level-helper.ts"),N=R("./src/controller/base-playlist-controller.ts"),D=R("./src/types/loader.ts");function y(){return y=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var _ in d)Object.prototype.hasOwnProperty.call(d,_)&&(a[_]=d[_])}return a},y.apply(this,arguments)}function A(a,l){for(var d=0;d<l.length;d++){var _=l[d];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(a,_.key,_)}}function k(a,l,d){return l&&A(a.prototype,l),d&&A(a,d),a}function T(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,C(a,l)}function C(a,l){return C=Object.setPrototypeOf||function(_,v){return _.__proto__=v,_},C(a,l)}var b=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(a){T(l,a);function l(_){var v;return v=a.call(this,_,"[level-controller]")||this,v._levels=[],v._firstLevel=-1,v._startLevel=void 0,v.currentLevelIndex=-1,v.manualLevelIndex=-1,v.onParsedComplete=void 0,v._registerListeners(),v}var d=l.prototype;return d._registerListeners=function(){var v=this.hls;v.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.on(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),v.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),v.on(F.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var v=this.hls;v.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(F.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(F.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),v.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(F.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,a.prototype.destroy.call(this)},d.startLoad=function(){var v=this._levels;v.forEach(function(m){m.loadError=0}),a.prototype.startLoad.call(this)},d.onManifestLoaded=function(v,m){var L=[],x=[],p=[],f,h={},o,E=!1,g=!1,S=!1;if(m.levels.forEach(function(V){var O=V.attrs;E=E||!!(V.width&&V.height),g=g||!!V.videoCodec,S=S||!!V.audioCodec,b&&V.audioCodec&&V.audioCodec.indexOf("mp4a.40.34")!==-1&&(V.audioCodec=void 0);var I=V.bitrate+"-"+V.attrs.RESOLUTION+"-"+V.attrs.CODECS;o=h[I],o?o.url.push(V.url):(o=new Z.Level(V),h[I]=o,L.push(o)),O&&(O.AUDIO&&Object(j.addGroupId)(o,"audio",O.AUDIO),O.SUBTITLES&&Object(j.addGroupId)(o,"text",O.SUBTITLES))}),(E||g)&&S&&(L=L.filter(function(V){var O=V.videoCodec,I=V.width,X=V.height;return!!O||!!(I&&X)})),L=L.filter(function(V){var O=V.audioCodec,I=V.videoCodec;return(!O||Object(K.isCodecSupportedInMp4)(O,"audio"))&&(!I||Object(K.isCodecSupportedInMp4)(I,"video"))}),m.audioTracks&&(x=m.audioTracks.filter(function(V){return!V.audioCodec||Object(K.isCodecSupportedInMp4)(V.audioCodec,"audio")}),Object(j.assignTrackIdsByGroup)(x)),m.subtitles&&(p=m.subtitles,Object(j.assignTrackIdsByGroup)(p)),L.length>0){f=L[0].bitrate,L.sort(function(V,O){return V.bitrate-O.bitrate}),this._levels=L;for(var M=0;M<L.length;M++)if(L[M].bitrate===f){this._firstLevel=M,this.log("manifest loaded, "+L.length+" level(s) found, first bitrate: "+f);break}var U=S&&!g,G={levels:L,audioTracks:x,subtitleTracks:p,firstLevel:this._firstLevel,stats:m.stats,audio:S,video:g,altAudio:!U&&x.some(function(V){return!!V.url})};this.hls.trigger(F.Events.MANIFEST_PARSED,G),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(F.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:m.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(v,m){if(a.prototype.onError.call(this,v,m),m.fatal)return;var L=m.context,x=this._levels[this.currentLevelIndex];if(L&&(L.type===D.PlaylistContextType.AUDIO_TRACK&&x.audioGroupIds&&L.groupId===x.audioGroupIds[x.urlId]||L.type===D.PlaylistContextType.SUBTITLE_TRACK&&x.textGroupIds&&L.groupId===x.textGroupIds[x.urlId])){this.redundantFailover(this.currentLevelIndex);return}var p=!1,f=!0,h;switch(m.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(m.frag){var o=this._levels[m.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(h=m.frag.level)):h=m.frag.level}break;case P.ErrorDetails.LEVEL_LOAD_ERROR:case P.ErrorDetails.LEVEL_LOAD_TIMEOUT:L&&(L.deliveryDirectives&&(f=!1),h=L.level),p=!0;break;case P.ErrorDetails.REMUX_ALLOC_ERROR:h=m.level,p=!0;break}h!==void 0&&this.recoverLevel(m,h,p,f)},d.recoverLevel=function(v,m,L,x){var p=v.details,f=this._levels[m];if(f.loadError++,L){var h=this.retryLoadingOrFail(v);if(h)v.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var o=f.url.length;if(o>1&&f.loadError<o)v.levelRetry=!0,this.redundantFailover(m);else if(this.manualLevelIndex===-1){var E=m===0?this._levels.length-1:m-1;this.currentLevelIndex!==E&&this._levels[E].loadError===0&&(this.warn(p+": switch to "+E),v.levelRetry=!0,this.hls.nextAutoLevel=E)}}},d.redundantFailover=function(v){var m=this._levels[v],L=m.url.length;if(L>1){var x=(m.urlId+1)%L;this.warn("Switching to redundant URL-id "+x),this._levels.forEach(function(p){p.urlId=x}),this.level=v}},d.onFragLoaded=function(v,m){var L=m.frag;if(L!==void 0&&L.type===D.PlaylistLevelType.MAIN){var x=this._levels[L.level];x!==void 0&&(x.fragmentError=0,x.loadError=0)}},d.onLevelLoaded=function(v,m){var L,x=m.level,p=m.details,f=this._levels[x];if(!f){var h;this.warn("Invalid level index "+x),(h=m.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(p.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(x,m,f.details)):(L=m.deliveryDirectives)!==null&&L!==void 0&&L.skip&&(p.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(v,m){var L=this.hls.levels[this.currentLevelIndex];if(!L)return;if(L.audioGroupIds){for(var x=-1,p=this.hls.audioTracks[m.id].groupId,f=0;f<L.audioGroupIds.length;f++)if(L.audioGroupIds[f]===p){x=f;break}x!==L.urlId&&(L.urlId=x,this.startLoad())}},d.loadPlaylist=function(v){var m=this.currentLevelIndex,L=this._levels[m];if(this.canLoad&&L&&L.url.length>0){var x=L.urlId,p=L.url[x];if(v)try{p=v.addDirectives(p)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Attempt loading level index "+m+(v?" at sn "+v.msn+" part "+v.part:"")+" with URL-id "+x+" "+p),this.clearTimer(),this.hls.trigger(F.Events.LEVEL_LOADING,{url:p,level:m,id:x,deliveryDirectives:v||null})}},d.removeLevel=function(v,m){var L=function(f,h){return h!==m},x=this._levels.filter(function(p,f){return f!==v?!0:p.url.length>1&&m!==void 0?(p.url=p.url.filter(L),p.audioGroupIds&&(p.audioGroupIds=p.audioGroupIds.filter(L)),p.textGroupIds&&(p.textGroupIds=p.textGroupIds.filter(L)),p.urlId=0,!0):!1}).map(function(p,f){var h=p.details;return h!=null&&h.fragments&&h.fragments.forEach(function(o){o.level=f}),p});this._levels=x,this.hls.trigger(F.Events.LEVELS_UPDATED,{levels:x})},k(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(v){var m,L=this._levels;if(L.length===0)return;if(this.currentLevelIndex===v&&(m=L[v])!==null&&m!==void 0&&m.details)return;if(v<0||v>=L.length){var x=v<0;if(this.hls.trigger(F.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.LEVEL_SWITCH_ERROR,level:v,fatal:x,reason:"invalid level idx"}),x)return;v=Math.min(v,L.length-1)}this.clearTimer();var p=this.currentLevelIndex,f=L[p],h=L[v];this.log("switching to level "+v+" from "+p),this.currentLevelIndex=v;var o=y({},h,{level:v,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete o._urlId,this.hls.trigger(F.Events.LEVEL_SWITCHING,o);var E=h.details;if(!E||E.live){var g=this.switchParams(h.uri,f==null?void 0:f.details);this.loadPlaylist(g)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(v){this.manualLevelIndex=v,this._startLevel===void 0&&(this._startLevel=v),v!==-1&&(this.level=v)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(v){this._firstLevel=v}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var v=this.hls.config.startLevel;return v!==void 0?v:this._firstLevel}else return this._startLevel},set:function(v){this._startLevel=v}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(v){this.level=v,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=v)}}]),l}(N.default)},"./src/controller/level-helper.ts":function(le,$,R){"use strict";R.r($),R.d($,"addGroupId",function(){return P}),R.d($,"assignTrackIdsByGroup",function(){return K}),R.d($,"updatePTS",function(){return j}),R.d($,"updateFragPTSDTS",function(){return D}),R.d($,"mergeDetails",function(){return y}),R.d($,"mapPartIntersection",function(){return A}),R.d($,"mapFragmentIntersection",function(){return k}),R.d($,"adjustSliding",function(){return T}),R.d($,"addSliding",function(){return C}),R.d($,"computeReloadInterval",function(){return b}),R.d($,"getFragmentWithSN",function(){return u}),R.d($,"getPartWith",function(){return a});var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/logger.ts");function P(l,d,_){switch(d){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(_);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(_);break}}function K(l){var d={};l.forEach(function(_){var v=_.groupId||"";_.id=d[v]=d[v]||0,d[v]++})}function j(l,d,_){var v=l[d],m=l[_];N(v,m)}function N(l,d){var _=d.startPTS;if(Object(Z.isFiniteNumber)(_)){var v=0,m;d.sn>l.sn?(v=_-l.start,m=l):(v=l.start-_,m=d),m.duration!==v&&(m.duration=v)}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,_,v,m,L){var x=v-_;x<=0&&(F.logger.warn("Fragment should have a positive duration",d),v=_+d.duration,L=m+d.duration);var p=_,f=v,h=d.startPTS,o=d.endPTS;if(Object(Z.isFiniteNumber)(h)){var E=Math.abs(h-_);Object(Z.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(E,d.deltaPTS):d.deltaPTS=E,p=Math.max(_,h),_=Math.min(_,h),m=Math.min(m,d.startDTS),f=Math.min(v,o),v=Math.max(v,o),L=Math.max(L,d.endDTS)}d.duration=v-_;var g=_-d.start;d.appendedPTS=v,d.start=d.startPTS=_,d.maxStartPTS=p,d.startDTS=m,d.endPTS=v,d.minEndPTS=f,d.endDTS=L;var S=d.sn;if(!l||S<l.startSN||S>l.endSN)return 0;var M,U=S-l.startSN,G=l.fragments;for(G[U]=d,M=U;M>0;M--)N(G[M],G[M-1]);for(M=U;M<G.length-1;M++)N(G[M],G[M+1]);return l.fragmentHint&&N(G[G.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,g}function y(l,d){for(var _=null,v=l.fragments,m=v.length-1;m>=0;m--){var L=v[m].initSegment;if(L){_=L;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var x=0,p;if(k(l,d,function(M,U){M.relurl&&(x=M.cc-U.cc),Object(Z.isFiniteNumber)(M.startPTS)&&Object(Z.isFiniteNumber)(M.endPTS)&&(U.start=U.startPTS=M.startPTS,U.startDTS=M.startDTS,U.appendedPTS=M.appendedPTS,U.maxStartPTS=M.maxStartPTS,U.endPTS=M.endPTS,U.endDTS=M.endDTS,U.minEndPTS=M.minEndPTS,U.duration=M.endPTS-M.startPTS,U.duration&&(p=U),d.PTSKnown=d.alignedSliding=!0),U.elementaryStreams=M.elementaryStreams,U.loader=M.loader,U.stats=M.stats,U.urlId=M.urlId,M.initSegment&&(U.initSegment=M.initSegment,_=M.initSegment)}),_){var f=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;f.forEach(function(M){var U;(!M.initSegment||M.initSegment.relurl===((U=_)===null||U===void 0?void 0:U.relurl))&&(M.initSegment=_)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(M){return!M}),d.deltaUpdateFailed)){F.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=d.skippedSegments;h--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var o=d.fragments;if(x){F.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<o.length;E++)o[E].cc+=x}d.skippedSegments&&(d.startCC=d.fragments[0].cc),A(l.partList,d.partList,function(M,U){U.elementaryStreams=M.elementaryStreams,U.stats=M.stats}),p?D(d,p,p.startPTS,p.endPTS,p.startDTS,p.endDTS):T(l,d),o.length&&(d.totalduration=d.edge-o[0].start),d.driftStartTime=l.driftStartTime,d.driftStart=l.driftStart;var g=d.advancedDateTime;if(d.advanced&&g){var S=d.edge;d.driftStart||(d.driftStartTime=g,d.driftStart=S),d.driftEndTime=g,d.driftEnd=S}else d.driftEndTime=l.driftEndTime,d.driftEnd=l.driftEnd,d.advancedDateTime=l.advancedDateTime}function A(l,d,_){if(l&&d)for(var v=0,m=0,L=l.length;m<=L;m++){var x=l[m],p=d[m+v];x&&p&&x.index===p.index&&x.fragment.sn===p.fragment.sn?_(x,p):v--}}function k(l,d,_){for(var v=d.skippedSegments,m=Math.max(l.startSN,d.startSN)-d.startSN,L=(l.fragmentHint?1:0)+(v?d.endSN:Math.min(l.endSN,d.endSN))-d.startSN,x=d.startSN-l.startSN,p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,f=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,h=m;h<=L;h++){var o=f[x+h],E=p[h];v&&!E&&h<v&&(E=d.fragments[h]=o),o&&E&&_(o,E)}}function T(l,d){var _=d.startSN+d.skippedSegments-l.startSN,v=l.fragments;if(_<0||_>=v.length)return;C(d,v[_].start)}function C(l,d){if(d){for(var _=l.fragments,v=l.skippedSegments;v<_.length;v++)_[v].start+=d;l.fragmentHint&&(l.fragmentHint.start+=d)}}function b(l,d){var _=1e3*l.levelTargetDuration,v=_/2,m=l.age,L=m>0&&m<_*3,x=d.loading.end-d.loading.start,p,f=l.availabilityDelay;if(l.updated===!1)if(L){var h=333*l.misses;p=Math.max(Math.min(v,x*2),h),l.availabilityDelay=(l.availabilityDelay||0)+p}else p=v;else L?(f=Math.min(f||_/2,m),l.availabilityDelay=f,p=f+_-m):p=_-x;return Math.round(p)}function u(l,d,_){if(!l||!l.details)return null;var v=l.details,m=v.fragments[d-v.startSN];return m||(m=v.fragmentHint,m&&m.sn===d?m:d<v.startSN&&_&&_.sn===d?_:null)}function a(l,d,_){if(!l||!l.details)return null;var v=l.details.partList;if(v)for(var m=v.length;m--;){var L=v[m];if(L.index===_&&L.fragment.sn===d)return L}return null}},"./src/controller/stream-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return v});var Z=R("./src/polyfills/number.ts"),F=R("./src/controller/base-stream-controller.ts"),P=R("./src/is-supported.ts"),K=R("./src/events.ts"),j=R("./src/utils/buffer-helper.ts"),N=R("./src/controller/fragment-tracker.ts"),D=R("./src/types/loader.ts"),y=R("./src/loader/fragment.ts"),A=R("./src/demux/transmuxer-interface.ts"),k=R("./src/types/transmuxer.ts"),T=R("./src/controller/gap-controller.ts"),C=R("./src/errors.ts"),b=R("./src/utils/logger.ts");function u(m,L){for(var x=0;x<L.length;x++){var p=L[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(m,p.key,p)}}function a(m,L,x){return L&&u(m.prototype,L),x&&u(m,x),m}function l(m,L){m.prototype=Object.create(L.prototype),m.prototype.constructor=m,d(m,L)}function d(m,L){return d=Object.setPrototypeOf||function(p,f){return p.__proto__=f,p},d(m,L)}var _=100,v=function(m){l(L,m);function L(p,f){var h;return h=m.call(this,p,f,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.stalled=!1,h.couldBacktrack=!1,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var x=L.prototype;return x._registerListeners=function(){var f=this.hls;f.on(K.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(K.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(K.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(K.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(K.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(K.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.on(K.Events.ERROR,this.onError,this),f.on(K.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(K.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(K.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(K.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(K.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.on(K.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x._unregisterListeners=function(){var f=this.hls;f.off(K.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(K.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(K.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(K.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(K.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.off(K.Events.ERROR,this.onError,this),f.off(K.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(K.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(K.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(K.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(K.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.off(K.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},x.startLoad=function(f){if(this.levels){var h=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(_),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=o.startLevel;E===-1&&(o.config.testBandwidth?(E=0,this.bitrateTest=!0):E=o.nextAutoLevel),this.level=o.nextLoadLevel=E,this.loadedmetadata=!1}h>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),f=h),this.state=F.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=F.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case F.State.IDLE:this.doTickIdle();break;case F.State.WAITING_LEVEL:{var f,h=this.levels,o=this.level,E=h==null||((f=h[o])===null||f===void 0)?void 0:f.details;if(E&&(!E.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(E))break;this.state=F.State.IDLE;break}break}case F.State.FRAG_LOADING_WAITING_RETRY:{var g,S=self.performance.now(),M=this.retryDate;(!M||S>=M||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=F.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var f,h,o=this.hls,E=this.levelLastLoaded,g=this.levels,S=this.media,M=o.config,U=o.nextLoadLevel;if(E===null||!S&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!g||!g[U])return;var G=g[U];this.level=o.nextLoadLevel=U;var V=G.details;if(!V||this.state===F.State.WAITING_LEVEL||V.live&&this.levelLastLoaded!==U){this.state=F.State.WAITING_LEVEL;return}var O=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:S,D.PlaylistLevelType.MAIN);if(O===null)return;var I=O.len,X=this.getMaxBufferLength(G.maxBitrate);if(I>=X)return;if(this._streamEnded(O,V)){var q={};this.altAudio&&(q.type="video"),this.hls.trigger(K.Events.BUFFER_EOS,q),this.state=F.State.ENDED;return}var oe=O.end,ce=this.getNextFragment(oe,V);if(this.couldBacktrack&&!this.fragPrevious&&ce&&ce.sn!=="initSegment"){var Le=ce.sn-V.startSN;Le>1&&(ce=V.fragments[Le-1],this.fragmentTracker.removeFragment(ce))}if(ce&&this.fragmentTracker.getState(ce)===N.FragmentState.OK&&this.nextLoadPosition>oe){var Ee=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(S,Ee,D.PlaylistLevelType.MAIN),ce=this.getNextFragment(this.nextLoadPosition,V)}if(!ce)return;ce.initSegment&&!ce.initSegment.data&&!this.bitrateTest&&(ce=ce.initSegment),((f=ce.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((h=ce.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(ce,V):this.loadFragment(ce,V,oe)},x.loadFragment=function(f,h,o){var E,g=this.fragmentTracker.getState(f);if(this.fragCurrent=f,g===N.FragmentState.BACKTRACKED){var S=this.fragmentTracker.getBacktrackData(f);if(S){this._handleFragmentLoadProgress(S),this._handleFragmentLoadComplete(S);return}else g=N.FragmentState.NOT_LOADED}g===N.FragmentState.NOT_LOADED||g===N.FragmentState.PARTIAL?f.sn==="initSegment"?this._loadInitSegment(f):this.bitrateTest?(f.bitrateTest=!0,this.log("Fragment "+f.sn+" of level "+f.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(f)):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,f,h,o)):g===N.FragmentState.APPENDING?this.reduceMaxBufferLength(f.duration)&&this.fragmentTracker.removeFragment(f):((E=this.media)===null||E===void 0?void 0:E.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(f){var h=this.fragmentTracker.getAppendedFrag(f,D.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},x.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,D.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var f=this.levels,h=this.media;if(h!=null&&h.readyState){var o,E=this.getAppendedFrag(h.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!h.paused&&f){var g=this.hls.nextLoadLevel,S=f[g],M=this.fragLastKbps;M&&this.fragCurrent?o=this.fragCurrent.duration*S.maxBitrate/(1e3*M)+1:o=0}else o=0;var U=this.getBufferedFrag(h.currentTime+o);if(U){var G=this.followingBufferedFrag(U);if(G){this.abortCurrentFrag();var V=G.maxStartPTS?G.maxStartPTS:G.start,O=G.duration,I=Math.max(U.end,V+Math.min(Math.max(O-this.config.maxFragLookUpTolerance,O*.5),O*.75));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var f=this.fragCurrent;this.fragCurrent=null,f!=null&&f.loader&&f.loader.abort(),this.state===F.State.KEY_LOADING&&(this.state=F.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(f,h){m.prototype.flushMainBuffer.call(this,f,h,this.altAudio?"video":null)},x.onMediaAttached=function(f,h){m.prototype.onMediaAttached.call(this,f,h);var o=h.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,o,this.fragmentTracker,this.hls)},x.onMediaDetaching=function(){var f=this.media;f&&(f.removeEventListener("playing",this.onvplaying),f.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),m.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var f=this.media,h=f?f.currentTime:null;Object(Z.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},x.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(K.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},x.onManifestParsed=function(f,h){var o=!1,E=!1,g;h.levels.forEach(function(S){g=S.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(o=!0),g.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=o&&E&&!Object(P.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},x.onLevelLoading=function(f,h){var o=this.levels;if(!o||this.state!==F.State.IDLE)return;var E=o[h.level];(!E.details||E.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(E.details))&&(this.state=F.State.WAITING_LEVEL)},x.onLevelLoaded=function(f,h){var o,E=this.levels,g=h.level,S=h.details,M=S.totalduration;if(!E){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+S.startSN+","+S.endSN+"], cc ["+S.startCC+", "+S.endCC+"] duration:"+M);var U=this.fragCurrent;U&&(this.state===F.State.FRAG_LOADING||this.state===F.State.FRAG_LOADING_WAITING_RETRY)&&(U.level!==h.level&&U.loader&&(this.state=F.State.IDLE,U.loader.abort()));var G=E[g],V=0;if(S.live||(o=G.details)!==null&&o!==void 0&&o.live){if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed)return;V=this.alignPlaylists(S,G.details)}if(G.details=S,this.levelLastLoaded=g,this.hls.trigger(K.Events.LEVEL_UPDATED,{details:S,level:g}),this.state===F.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(S))return;this.state=F.State.IDLE}this.startFragRequested?S.live&&this.synchronizeToLiveEdge(S):this.setStartPosition(S,V),this.tick()},x._handleFragmentLoadProgress=function(f){var h,o=f.frag,E=f.part,g=f.payload,S=this.levels;if(!S){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var M=S[o.level],U=M.details;if(!U){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var G=M.videoCodec,V=U.PTSKnown||!U.live,O=(h=o.initSegment)===null||h===void 0?void 0:h.data,I=this._getAudioCodec(M),X=this.transmuxer=this.transmuxer||new A.default(this.hls,D.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),q=E?E.index:-1,oe=q!==-1,ce=new k.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,g.byteLength,q,oe),Le=this.initPTS[o.cc];X.push(g,O,I,G,o,E,U.totalduration,V,ce,Le)},x.onAudioTrackSwitching=function(f,h){var o=this.altAudio,E=!!h.url,g=h.id;if(!E){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var S=this.fragCurrent;S!=null&&S.loader&&(this.log("Switching to main audio track, cancel main fragment load"),S.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;o&&M.trigger(K.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(K.Events.AUDIO_TRACK_SWITCHED,{id:g})}},x.onAudioTrackSwitched=function(f,h){var o=h.id,E=!!this.hls.audioTracks[o].url;if(E){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=E,this.tick()},x.onBufferCreated=function(f,h){var o=h.tracks,E,g,S=!1;for(var M in o){var U=o[M];if(U.id==="main"){if(g=M,E=U,M==="video"){var G=o[M];G&&(this.videoBuffer=G.buffer)}}else S=!0}S&&E?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(f,h){var o=h.frag,E=h.part;if(o&&o.type!==D.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(E?" p: "+E.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===F.State.PARSED&&(this.state=F.State.IDLE);return}var g=E?E.stats:o.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,E)},x.onError=function(f,h){switch(h.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:case C.ErrorDetails.KEY_LOAD_ERROR:case C.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.MAIN,h);break;case C.ErrorDetails.LEVEL_LOAD_ERROR:case C.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==F.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=F.State.ERROR):!h.levelRetry&&this.state===F.State.WAITING_LEVEL&&(this.state=F.State.IDLE));break;case C.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===F.State.PARSING||this.state===F.State.PARSED)){var o=!0,E=this.getFwdBufferInfo(this.media,D.PlaylistLevelType.MAIN);E&&E.len>.5&&(o=!this.reduceMaxBufferLength(E.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var f=this.media,h=this.gapController;if(!f||!h||!f.readyState)return;var o=j.BufferHelper.getBuffered(f);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):h.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=F.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(f,h){var o=h.type;if(o!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(o===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,o,D.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(f,h){this.levels=h.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var f=this.media,h=f.currentTime,o=this.startPosition;if(o>=0&&h<o){if(f.seeking){b.logger.log("could not seek to "+o+", already seeking at "+h);return}var E=j.BufferHelper.getBuffered(f),g=E.length?E.start(0):0,S=g-o;S>0&&(S<this.config.maxBufferHole||S<this.config.maxFragLookUpTolerance)&&(b.logger.log("adjusting start position by "+S+" to match buffer start"),o+=S,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+h),f.currentTime=o}},x._getAudioCodec=function(f){var h=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},x._loadBitrateTestFrag=function(f){var h=this;this._doFragLoad(f).then(function(o){var E=h.hls;if(!o||E.nextLoadLevel||h.fragContextChanged(f))return;h.fragLoadError=0,h.state=F.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var g=f.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),E.trigger(K.Events.FRAG_LOADED,o)})},x._handleTransmuxComplete=function(f){var h,o="main",E=this.hls,g=f.remuxResult,S=f.chunkMeta,M=this.getCurrentContext(S);if(!M){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(S.level);return}var U=M.frag,G=M.part,V=M.level,O=g.video,I=g.text,X=g.id3,q=g.initSegment,oe=this.altAudio?void 0:g.audio;if(this.fragContextChanged(U))return;if(this.state=F.State.PARSING,q){q.tracks&&(this._bufferInitSegment(V,q.tracks,U,S),E.trigger(K.Events.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:o,tracks:q.tracks}));var ce=q.initPTS,Le=q.timescale;Object(Z.isFiniteNumber)(ce)&&(this.initPTS[U.cc]=ce,E.trigger(K.Events.INIT_PTS_FOUND,{frag:U,id:o,initPTS:ce,timescale:Le}))}if(O&&g.independent!==!1){if(V.details){var Ee=O.startPTS,we=O.endPTS,Te=O.startDTS,ye=O.endDTS;if(G)G.elementaryStreams[O.type]={startPTS:Ee,endPTS:we,startDTS:Te,endDTS:ye};else if(O.firstKeyFrame&&O.independent&&(this.couldBacktrack=!0),O.dropped&&O.independent){var fe=this.getLoadPosition()+this.config.maxBufferHole;if(fe<Ee){this.backtrack(U);return}U.setElementaryStreamInfo(O.type,U.start,we,U.start,ye,!0)}U.setElementaryStreamInfo(O.type,Ee,we,Te,ye),this.bufferFragmentData(O,U,G,S)}}else if(g.independent===!1){this.backtrack(U);return}if(oe){var se=oe.startPTS,te=oe.endPTS,ue=oe.startDTS,ne=oe.endDTS;G&&(G.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:te,startDTS:ue,endDTS:ne}),U.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,se,te,ue,ne),this.bufferFragmentData(oe,U,G,S)}if(X!=null&&(h=X.samples)!==null&&h!==void 0&&h.length){var _e={frag:U,id:o,samples:X.samples};E.trigger(K.Events.FRAG_PARSING_METADATA,_e)}if(I){var Re={frag:U,id:o,samples:I.samples};E.trigger(K.Events.FRAG_PARSING_USERDATA,Re)}},x._bufferInitSegment=function(f,h,o,E){var g=this;if(this.state!==F.State.PARSING)return;this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var S=h.audio,M=h.video,U=h.audiovideo;if(S){var G=f.audioCodec,V=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(G&&(G.indexOf("mp4a.40.5")!==-1?G="mp4a.40.2":G="mp4a.40.5"),S.metadata.channelCount!==1&&V.indexOf("firefox")===-1&&(G="mp4a.40.5")),V.indexOf("android")!==-1&&S.container!=="audio/mpeg"&&(G="mp4a.40.2",this.log("Android: force audio codec to "+G)),f.audioCodec&&f.audioCodec!==G&&this.log('Swapping manifest audio codec "'+f.audioCodec+'" for "'+G+'"'),S.levelCodec=G,S.id="main",this.log("Init audio buffer, container:"+S.container+", codecs[selected/level/parsed]=["+(G||"")+"/"+(f.audioCodec||"")+"/"+S.codec+"]")}M&&(M.levelCodec=f.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(f.videoCodec||"")+"/"+M.codec+"]")),U&&this.log("Init audiovideo buffer, container:"+U.container+", codecs[level/parsed]=["+(f.attrs.CODECS||"")+"/"+U.codec+"]"),this.hls.trigger(K.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(O){var I=h[O],X=I.initSegment;X!=null&&X.byteLength&&g.hls.trigger(K.Events.BUFFER_APPENDING,{type:O,data:X,frag:o,part:null,chunkMeta:E,parent:o.type})}),this.tick()},x.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var h=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,h?this.resetFragmentLoading(f):this.state=F.State.BACKTRACKING},x.checkFragmentChanged=function(){var f=this.media,h=null;if(f&&f.readyState>1&&f.seeking===!1){var o=f.currentTime;if(j.BufferHelper.isBuffered(f,o)?h=this.getAppendedFrag(o):j.BufferHelper.isBuffered(f,o+.1)&&(h=this.getAppendedFrag(o+.1)),h){var E=this.fragPlaying,g=h.level;(!E||h.sn!==E.sn||E.level!==g||h.urlId!==E.urlId)&&(this.hls.trigger(K.Events.FRAG_CHANGED,{frag:h}),(!E||E.level!==g)&&this.hls.trigger(K.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=h)}}},a(L,[{key:"nextLevel",get:function(){var f=this.nextBufferedFrag;return f?f.level:-1}},{key:"currentLevel",get:function(){var f=this.media;if(f){var h=this.getAppendedFrag(f.currentTime);if(h)return h.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var h=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(h)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),L}(F.default)},"./src/controller/subtitle-stream-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"SubtitleStreamController",function(){return l});var Z=R("./src/events.ts"),F=R("./src/utils/logger.ts"),P=R("./src/utils/buffer-helper.ts"),K=R("./src/controller/fragment-finders.ts"),j=R("./src/utils/discontinuities.ts"),N=R("./src/controller/level-helper.ts"),D=R("./src/controller/fragment-tracker.ts"),y=R("./src/controller/base-stream-controller.ts"),A=R("./src/types/loader.ts"),k=R("./src/types/level.ts");function T(d,_){for(var v=0;v<_.length;v++){var m=_[v];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(d,m.key,m)}}function C(d,_,v){return _&&T(d.prototype,_),v&&T(d,v),d}function b(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,u(d,_)}function u(d,_){return u=Object.setPrototypeOf||function(m,L){return m.__proto__=L,m},u(d,_)}var a=500,l=function(d){b(_,d);function _(m,L){var x;return x=d.call(this,m,L,"[subtitle-stream-controller]")||this,x.levels=[],x.currentTrackId=-1,x.tracksBuffered=[],x.mainDetails=null,x._registerListeners(),x}var v=_.prototype;return v.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},v._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)},v._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)},v.startLoad=function(){this.stopLoad(),this.state=y.State.IDLE,this.setInterval(a),this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},v.onLevelLoaded=function(L,x){this.mainDetails=x.details},v.onSubtitleFragProcessed=function(L,x){var p=x.frag,f=x.success;if(this.fragPrevious=p,this.state=y.State.IDLE,!f)return;var h=this.tracksBuffered[this.currentTrackId];if(!h)return;for(var o,E=p.start,g=0;g<h.length;g++)if(E>=h[g].start&&E<=h[g].end){o=h[g];break}var S=p.start+p.duration;o?o.end=S:(o={start:E,end:S},h.push(o)),this.fragmentTracker.fragBuffered(p)},v.onBufferFlushing=function(L,x){var p=x.startOffset,f=x.endOffset;if(p===0&&f!==Number.POSITIVE_INFINITY){var h=this.currentTrackId,o=this.levels;if(!o.length||!o[h]||!o[h].details)return;var E=o[h].details,g=E.targetduration,S=f-g;if(S<=0)return;x.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(M){for(var U=0;U<M.length;){if(M[U].end<=S){M.shift();continue}else if(M[U].start<S)M[U].start=S;else break;U++}}),this.fragmentTracker.removeFragmentsInRange(p,S,A.PlaylistLevelType.SUBTITLE)}},v.onError=function(L,x){var p,f=x.frag;if(!f||f.type!==A.PlaylistLevelType.SUBTITLE)return;(p=this.fragCurrent)!==null&&p!==void 0&&p.loader&&this.fragCurrent.loader.abort(),this.state=y.State.IDLE},v.onSubtitleTracksUpdated=function(L,x){var p=this,f=x.subtitleTracks;this.tracksBuffered=[],this.levels=f.map(function(h){return new k.Level(h)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(h){p.tracksBuffered[h.id]=[]}),this.mediaBuffer=null},v.onSubtitleTrackSwitch=function(L,x){if(this.currentTrackId=x.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var p=this.levels[this.currentTrackId];p!=null&&p.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,p&&this.setInterval(a)},v.onSubtitleTrackLoaded=function(L,x){var p,f=x.details,h=x.id,o=this.currentTrackId,E=this.levels;if(!E.length)return;var g=E[o];if(h>=E.length||h!==o||!g)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,f.live||(p=g.details)!==null&&p!==void 0&&p.live){var S=this.mainDetails;if(f.deltaUpdateFailed||!S)return;var M=S.fragments[0];if(!g.details)f.hasProgramDateTime&&S.hasProgramDateTime?Object(j.alignMediaPlaylistByPDT)(f,S):M&&Object(N.addSliding)(f,M.start);else{var U=this.alignPlaylists(f,g.details);U===0&&M&&Object(N.addSliding)(f,M.start)}}if(g.details=f,this.levelLastLoaded=h,this.tick(),f.live&&!this.fragCurrent&&this.media&&this.state===y.State.IDLE){var G=Object(K.findFragmentByPTS)(null,f.fragments,this.media.currentTime,0);G||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}},v._handleFragmentLoadComplete=function(L){var x=L.frag,p=L.payload,f=x.decryptdata,h=this.hls;if(this.fragContextChanged(x))return;if(p&&p.byteLength>0&&f&&f.key&&f.iv&&f.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(p),f.key.buffer,f.iv.buffer).then(function(E){var g=performance.now();h.trigger(Z.Events.FRAG_DECRYPTED,{frag:x,payload:E,stats:{tstart:o,tdecrypt:g}})})}},v.doTick=function(){if(!this.media){this.state=y.State.IDLE;return}if(this.state===y.State.IDLE){var L,x=this.currentTrackId,p=this.levels;if(!p.length||!p[x]||!p[x].details)return;var f=p[x].details,h=f.targetduration,o=this.config,E=this.media,g=P.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,E.currentTime-h,o.maxBufferHole),S=g.end,M=g.len,U=this.getMaxBufferLength()+h;if(M>U)return;console.assert(f,"Subtitle track details are defined on idle subtitle stream controller tick");var G=f.fragments,V=G.length,O=f.edge,I,X=this.fragPrevious;if(S<O){var q=o.maxFragLookUpTolerance;X&&f.hasProgramDateTime&&(I=Object(K.findFragmentByPDT)(G,X.endProgramDateTime,q)),I||(I=Object(K.findFragmentByPTS)(X,G,S,q),!I&&X&&X.start<G[0].start&&(I=G[0]))}else I=G[V-1];(L=I)!==null&&L!==void 0&&L.encrypted?(F.logger.log("Loading key for "+I.sn),this.state=y.State.KEY_LOADING,this.hls.trigger(Z.Events.KEY_LOADING,{frag:I})):I&&this.fragmentTracker.getState(I)===D.FragmentState.NOT_LOADED&&this.loadFragment(I,f,S)}},v.loadFragment=function(L,x,p){this.fragCurrent=L,d.prototype.loadFragment.call(this,L,x,p)},C(_,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),_}(y.default)},"./src/controller/subtitle-track-controller.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/events.ts"),F=R("./src/utils/texttrack-utils.ts"),P=R("./src/controller/base-playlist-controller.ts"),K=R("./src/types/loader.ts");function j(T,C){for(var b=0;b<C.length;b++){var u=C[b];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(T,u.key,u)}}function N(T,C,b){return C&&j(T.prototype,C),b&&j(T,b),T}function D(T,C){T.prototype=Object.create(C.prototype),T.prototype.constructor=T,y(T,C)}function y(T,C){return y=Object.setPrototypeOf||function(u,a){return u.__proto__=a,u},y(T,C)}var A=function(T){D(C,T);function C(u){var a;return a=T.call(this,u,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a.subtitleDisplay=!0,a.registerListeners(),a}var b=C.prototype;return b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},b.registerListeners=function(){var a=this.hls;a.on(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.on(Z.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var a=this.hls;a.off(Z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(Z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(Z.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(Z.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(Z.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(Z.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(Z.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.off(Z.Events.ERROR,this.onError,this)},b.onMediaAttached=function(a,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},b.pollTrackChange=function(a){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,a)},b.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var a=k(this.media.textTracks);a.forEach(function(l){Object(F.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},b.onManifestParsed=function(a,l){this.tracks=l.subtitleTracks},b.onSubtitleTrackLoaded=function(a,l){var d=l.id,_=l.details,v=this.trackId,m=this.tracksInGroup[v];if(!m){this.warn("Invalid subtitle track id "+d);return}var L=m.details;m.details=l.details,this.log("subtitle track "+d+" loaded ["+_.startSN+"-"+_.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,l,L))},b.onLevelLoading=function(a,l){this.switchLevel(l.level)},b.onLevelSwitching=function(a,l){this.switchLevel(l.level)},b.switchLevel=function(a){var l=this.hls.levels[a];if(!(l!=null&&l.textGroupIds))return;var d=l.textGroupIds[l.urlId];if(this.groupId!==d){var _=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,v=this.tracks.filter(function(x){return!d||x.groupId===d});this.tracksInGroup=v;var m=this.findTrackId(_==null?void 0:_.name)||this.findTrackId();this.groupId=d;var L={subtitleTracks:v};this.log("Updating subtitle tracks, "+v.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(Z.Events.SUBTITLE_TRACKS_UPDATED,L),m!==-1&&this.setSubtitleTrack(m,_)}},b.findTrackId=function(a){for(var l=this.tracksInGroup,d=0;d<l.length;d++){var _=l[d];if((!this.selectDefaultTrack||_.default)&&(!a||a===_.name))return _.id}return-1},b.onError=function(a,l){if(T.prototype.onError.call(this,a,l),l.fatal||!l.context)return;l.context.type===K.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},b.loadPlaylist=function(a){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var d=l.id,_=l.groupId,v=l.url;if(a)try{v=a.addDirectives(v)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger(Z.Events.SUBTITLE_TRACK_LOADING,{url:v,id:d,groupId:_,deliveryDirectives:a||null})}},b.toggleTrackModes=function(a){var l=this,d=this.media,_=this.subtitleDisplay,v=this.trackId;if(!d)return;var m=k(d.textTracks),L=m.filter(function(f){return f.groupId===l.groupId});if(a===-1)[].slice.call(m).forEach(function(f){f.mode="disabled"});else{var x=L[v];x&&(x.mode="disabled")}var p=L[a];p&&(p.mode=_?"showing":"hidden")},b.setSubtitleTrack=function(a,l){var d,_=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=a;return}if(this.trackId!==a&&this.toggleTrackModes(a),this.trackId===a&&(a===-1||(d=_[a])!==null&&d!==void 0&&d.details)||a<-1||a>=_.length)return;this.clearTimer();var v=_[a];if(this.log("Switching to subtitle track "+a),this.trackId=a,v){var m=v.id,L=v.groupId,x=L===void 0?"":L,p=v.name,f=v.type,h=v.url;this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:x,name:p,type:f,url:h});var o=this.switchParams(v.url,l==null?void 0:l.details);this.loadPlaylist(o)}else this.hls.trigger(Z.Events.SUBTITLE_TRACK_SWITCH,{id:a})},b.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var a=-1,l=k(this.media.textTracks),d=0;d<l.length;d++)if(l[d].mode==="hidden")a=d;else if(l[d].mode==="showing"){a=d;break}this.subtitleTrack!==a&&(this.subtitleTrack=a)},N(C,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(a,l)}}]),C}(P.default);function k(T){for(var C=[],b=0;b<T.length;b++){var u=T[b];u.kind==="subtitles"&&u.label&&C.push(T[b])}return C}$.default=A},"./src/controller/timeline-controller.ts":function(le,$,R){"use strict";R.r($),R.d($,"TimelineController",function(){return k});var Z=R("./src/polyfills/number.ts"),F=R("./src/events.ts"),P=R("./src/utils/cea-608-parser.ts"),K=R("./src/utils/output-filter.ts"),j=R("./src/utils/webvtt-parser.ts"),N=R("./src/utils/texttrack-utils.ts"),D=R("./src/utils/imsc1-ttml-parser.ts"),y=R("./src/types/loader.ts"),A=R("./src/utils/logger.ts"),k=function(){function u(l){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=b(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var d=new K.default(this,"textTrack1"),_=new K.default(this,"textTrack2"),v=new K.default(this,"textTrack3"),m=new K.default(this,"textTrack4");this.cea608Parser1=new P.default(1,d,_),this.cea608Parser2=new P.default(3,v,m)}l.on(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(F.Events.FRAG_LOADING,this.onFragLoading,this),l.on(F.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=u.prototype;return a.destroy=function(){var d=this.hls;d.off(F.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(F.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(F.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(F.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(F.Events.FRAG_LOADING,this.onFragLoading,this),d.off(F.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(F.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(F.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(F.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(F.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(F.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(d,_,v,m,L){for(var x=!1,p=L.length;p--;){var f=L[p],h=C(f[0],f[1],_,v);if(h>=0&&(f[0]=Math.min(f[0],_),f[1]=Math.max(f[1],v),x=!0,h/(v-_)>.5))return}if(x||L.push([_,v]),this.config.renderTextTracksNatively){var o=this.captionsTracks[d];this.Cues.newCue(o,_,v,m)}else{var E=this.Cues.newCue(null,_,v,m);this.hls.trigger(F.Events.CUES_PARSED,{type:"captions",cues:E,track:d})}},a.onInitPtsFound=function(d,_){var v=this,m=_.frag,L=_.id,x=_.initPTS,p=_.timescale,f=this.unparsedVttFrags;L==="main"&&(this.initPTS[m.cc]=x,this.timescale[m.cc]=p),f.length&&(this.unparsedVttFrags=[],f.forEach(function(h){v.onFragLoaded(F.Events.FRAG_LOADED,h)}))},a.getExistingTrack=function(d){var _=this.media;if(_)for(var v=0;v<_.textTracks.length;v++){var m=_.textTracks[v];if(m[d])return m}return null},a.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},a.createNativeTrack=function(d){if(this.captionsTracks[d])return;var _=this.captionsProperties,v=this.captionsTracks,m=this.media,L=_[d],x=L.label,p=L.languageCode,f=this.getExistingTrack(d);if(f)v[d]=f,Object(N.clearCurrentCues)(v[d]),Object(N.sendAddTrackEvent)(v[d],m);else{var h=this.createTextTrack("captions",x,p);h&&(h[d]=!0,v[d]=h)}},a.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var _=this.captionsProperties[d];if(!_)return;var v=_.label,m={_id:d,label:v,kind:"captions",default:_.media?!!_.media.default:!1,closedCaptions:_.media};this.nonNativeCaptionsTracks[d]=m,this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},a.createTextTrack=function(d,_,v){var m=this.media;return m?m.addTextTrack(d,_,v):void 0},a.onMediaAttaching=function(d,_){this.media=_.media,this._cleanTracks()},a.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(_){Object(N.clearCurrentCues)(d[_]),delete d[_]}),this.nonNativeCaptionsTracks={}},a.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=b(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},a._cleanTracks=function(){var d=this.media;if(!d)return;var _=d.textTracks;if(_)for(var v=0;v<_.length;v++)Object(N.clearCurrentCues)(_[v])},a.onSubtitleTracksUpdated=function(d,_){var v=this;this.textTracks=[];var m=_.subtitleTracks||[],L=m.some(function(h){return h.textCodec===D.IMSC1_CODEC});if(this.config.enableWebVTT||L&&this.config.enableIMSC1){var x=this.tracks&&m&&this.tracks.length===m.length;if(this.tracks=m||[],this.config.renderTextTracksNatively){var p=this.media?this.media.textTracks:[];this.tracks.forEach(function(h,o){var E;if(o<p.length){for(var g=null,S=0;S<p.length;S++)if(T(p[S],h)){g=p[S];break}g&&(E=g)}E?Object(N.clearCurrentCues)(E):(E=v.createTextTrack("subtitles",h.name,h.lang),E&&(E.mode="disabled")),E&&(E.groupId=h.groupId,v.textTracks.push(E))})}else if(!x&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(h){return{label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}});this.hls.trigger(F.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},a.onManifestLoaded=function(d,_){var v=this;this.config.enableCEA708Captions&&_.captions&&_.captions.forEach(function(m){var L=/(?:CC|SERVICE)([1-4])/.exec(m.instreamId);if(!L)return;var x="textTrack"+L[1],p=v.captionsProperties[x];if(!p)return;p.label=m.name,m.lang&&(p.languageCode=m.lang),p.media=m})},a.onFragLoading=function(d,_){var v=this.cea608Parser1,m=this.cea608Parser2,L=this.lastSn,x=this.lastPartIndex;if(!this.enabled||!(v&&m))return;if(_.frag.type===y.PlaylistLevelType.MAIN){var p,f,h=_.frag.sn,o=(p=_==null||((f=_.part)===null||f===void 0)?void 0:f.index)!=null?p:-1;h===L+1||h===L&&o===x+1||(v.reset(),m.reset()),this.lastSn=h,this.lastPartIndex=o}},a.onFragLoaded=function(d,_){var v=_.frag,m=_.payload,L=this.initPTS,x=this.unparsedVttFrags;if(v.type===y.PlaylistLevelType.SUBTITLE)if(m.byteLength){if(!Object(Z.isFiniteNumber)(L[v.cc])){x.push(_),L.length&&this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:new Error("Missing initial subtitle PTS")});return}var p=v.decryptdata;if(p==null||p.key==null||p.method!=="AES-128"){var f=this.tracks[v.level],h=this.vttCCs;h[v.cc]||(h[v.cc]={start:v.start,prevCC:this.prevCC,new:!0},this.prevCC=v.cc),f&&f.textCodec===D.IMSC1_CODEC?this._parseIMSC1(v,m):this._parseVTTs(v,m,h)}}else this.hls.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(d,_){var v=this,m=this.hls;Object(D.parseIMSC1)(_,this.initPTS[d.cc],this.timescale[d.cc],function(L){v._appendCues(L,d.level),m.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(L){A.logger.log("Failed to parse IMSC1: "+L),m.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:L})})},a._parseVTTs=function(d,_,v){var m=this,L=this.hls;Object(j.parseWebVTT)(_,this.initPTS[d.cc],this.timescale[d.cc],v,d.cc,d.start,function(x){m._appendCues(x,d.level),L.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(x){m._fallbackToIMSC1(d,_),A.logger.log("Failed to parse VTT cue: "+x),L.trigger(F.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:x})})},a._fallbackToIMSC1=function(d,_){var v=this,m=this.tracks[d.level];m.textCodec||Object(D.parseIMSC1)(_,this.initPTS[d.cc],this.timescale[d.cc],function(){m.textCodec=D.IMSC1_CODEC,v._parseIMSC1(d,_)},function(){m.textCodec="wvtt"})},a._appendCues=function(d,_){var v=this.hls;if(this.config.renderTextTracksNatively){var m=this.textTracks[_];if(m.mode==="disabled")return;d.forEach(function(p){return Object(N.addCueToTrack)(m,p)})}else{var L=this.tracks[_],x=L.default?"default":"subtitles"+_;v.trigger(F.Events.CUES_PARSED,{type:"subtitles",cues:d,track:x})}},a.onFragDecrypted=function(d,_){var v=_.frag;if(v.type===y.PlaylistLevelType.SUBTITLE){if(!Object(Z.isFiniteNumber)(this.initPTS[v.cc])){this.unparsedVttFrags.push(_);return}this.onFragLoaded(F.Events.FRAG_LOADED,_)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(d,_){var v=this.cea608Parser1,m=this.cea608Parser2;if(!this.enabled||!(v&&m))return;for(var L=0;L<_.samples.length;L++){var x=_.samples[L].bytes;if(x){var p=this.extractCea608Data(x);v.addData(_.samples[L].pts,p[0]),m.addData(_.samples[L].pts,p[1])}}},a.onBufferFlushing=function(d,_){var v=_.startOffset,m=_.endOffset,L=_.endOffsetSubtitles,x=_.type,p=this.media;if(!p||p.currentTime<m)return;if(!x||x==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(o){return Object(N.removeCuesInRange)(f[o],v,m)})}if(this.config.renderTextTracksNatively&&(v===0&&L!==void 0)){var h=this.textTracks;Object.keys(h).forEach(function(o){return Object(N.removeCuesInRange)(h[o],v,L)})}},a.extractCea608Data=function(d){for(var _=d[0]&31,v=2,m=[[],[]],L=0;L<_;L++){var x=d[v++],p=127&d[v++],f=127&d[v++],h=(4&x)!==0,o=3&x;if(p===0&&f===0)continue;h&&((o===0||o===1)&&(m[o].push(p),m[o].push(f)))}return m},u}();function T(u,a){return u&&u.label===a.name&&!(u.textTrack1||u.textTrack2)}function C(u,a,l,d){return Math.min(a,d)-Math.max(u,l)}function b(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return Z});var Z=function(){function F(K,j){this.subtle=void 0,this.aesIV=void 0,this.subtle=K,this.aesIV=j}var P=F.prototype;return P.decrypt=function(j,N){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},N,j)},F}()},"./src/crypt/aes-decryptor.ts":function(le,$,R){"use strict";R.r($),R.d($,"removePadding",function(){return F}),R.d($,"default",function(){return P});var Z=R("./src/utils/typed-array.ts");function F(K){var j=K.byteLength,N=j&&new DataView(K.buffer).getUint8(j-1);return N?Object(Z.sliceUint8)(K,0,j-N):K}var P=function(){function K(){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 j=K.prototype;return j.uint8ArrayToUint32Array_=function(D){for(var y=new DataView(D),A=new Uint32Array(4),k=0;k<4;k++)A[k]=y.getUint32(k*4);return A},j.initTable=function(){var D=this.sBox,y=this.invSBox,A=this.subMix,k=A[0],T=A[1],C=A[2],b=A[3],u=this.invSubMix,a=u[0],l=u[1],d=u[2],_=u[3],v=new Uint32Array(256),m=0,L=0,x=0;for(x=0;x<256;x++)x<128?v[x]=x<<1:v[x]=x<<1^283;for(x=0;x<256;x++){var p=L^L<<1^L<<2^L<<3^L<<4;p=p>>>8^p&255^99,D[m]=p,y[p]=m;var f=v[m],h=v[f],o=v[h],E=v[p]*257^p*16843008;k[m]=E<<24|E>>>8,T[m]=E<<16|E>>>16,C[m]=E<<8|E>>>24,b[m]=E,E=o*16843009^h*65537^f*257^m*16843008,a[p]=E<<24|E>>>8,l[p]=E<<16|E>>>16,d[p]=E<<8|E>>>24,_[p]=E,m?(m=f^v[v[v[o^f]]],L^=v[v[L]]):m=L=1}},j.expandKey=function(D){for(var y=this.uint8ArrayToUint32Array_(D),A=!0,k=0;k<y.length&&A;)A=y[k]===this.key[k],k++;if(A)return;this.key=y;var T=this.keySize=y.length;if(T!==4&&T!==6&&T!==8)throw new Error("Invalid aes key size="+T);var C=this.ksRows=(T+6+1)*4,b,u,a=this.keySchedule=new Uint32Array(C),l=this.invKeySchedule=new Uint32Array(C),d=this.sBox,_=this.rcon,v=this.invSubMix,m=v[0],L=v[1],x=v[2],p=v[3],f,h;for(b=0;b<C;b++){if(b<T){f=a[b]=y[b];continue}h=f,b%T===0?(h=h<<8|h>>>24,h=d[h>>>24]<<24|d[h>>>16&255]<<16|d[h>>>8&255]<<8|d[h&255],h^=_[b/T|0]<<24):T>6&&b%T===4&&(h=d[h>>>24]<<24|d[h>>>16&255]<<16|d[h>>>8&255]<<8|d[h&255]),a[b]=f=(a[b-T]^h)>>>0}for(u=0;u<C;u++)b=C-u,u&3?h=a[b]:h=a[b-4],u<4||b<=4?l[u]=h:l[u]=m[d[h>>>24]]^L[d[h>>>16&255]]^x[d[h>>>8&255]]^p[d[h&255]],l[u]=l[u]>>>0},j.networkToHostOrderSwap=function(D){return D<<24|(D&65280)<<8|(D&16711680)>>8|D>>>24},j.decrypt=function(D,y,A){for(var k=this.keySize+6,T=this.invKeySchedule,C=this.invSBox,b=this.invSubMix,u=b[0],a=b[1],l=b[2],d=b[3],_=this.uint8ArrayToUint32Array_(A),v=_[0],m=_[1],L=_[2],x=_[3],p=new Int32Array(D),f=new Int32Array(p.length),h,o,E,g,S,M,U,G,V,O,I,X,q,oe,ce=this.networkToHostOrderSwap;y<p.length;){for(V=ce(p[y]),O=ce(p[y+1]),I=ce(p[y+2]),X=ce(p[y+3]),S=V^T[0],M=X^T[1],U=I^T[2],G=O^T[3],q=4,oe=1;oe<k;oe++)h=u[S>>>24]^a[M>>16&255]^l[U>>8&255]^d[G&255]^T[q],o=u[M>>>24]^a[U>>16&255]^l[G>>8&255]^d[S&255]^T[q+1],E=u[U>>>24]^a[G>>16&255]^l[S>>8&255]^d[M&255]^T[q+2],g=u[G>>>24]^a[S>>16&255]^l[M>>8&255]^d[U&255]^T[q+3],S=h,M=o,U=E,G=g,q=q+4;h=C[S>>>24]<<24^C[M>>16&255]<<16^C[U>>8&255]<<8^C[G&255]^T[q],o=C[M>>>24]<<24^C[U>>16&255]<<16^C[G>>8&255]<<8^C[S&255]^T[q+1],E=C[U>>>24]<<24^C[G>>16&255]<<16^C[S>>8&255]<<8^C[M&255]^T[q+2],g=C[G>>>24]<<24^C[S>>16&255]<<16^C[M>>8&255]<<8^C[U&255]^T[q+3],f[y]=ce(h^v),f[y+1]=ce(g^m),f[y+2]=ce(E^L),f[y+3]=ce(o^x),v=V,m=O,L=I,x=X,y=y+4}return f.buffer},K}()},"./src/crypt/decrypter.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return y});var Z=R("./src/crypt/aes-crypto.ts"),F=R("./src/crypt/fast-aes-key.ts"),P=R("./src/crypt/aes-decryptor.ts"),K=R("./src/utils/logger.ts"),j=R("./src/utils/mp4-tools.ts"),N=R("./src/utils/typed-array.ts"),D=16,y=function(){function A(T,C,b){var u=b===void 0?{}:b,a=u.removePKCS7Padding,l=a===void 0?!0:a;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=T,this.config=C,this.removePKCS7Padding=l,l)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(_){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var k=A.prototype;return k.destroy=function(){this.observer=null},k.isSync=function(){return this.config.enableSoftwareAES},k.flush=function(){var C=this.currentResult;if(!C){this.reset();return}var b=new Uint8Array(C);return this.reset(),this.removePKCS7Padding?Object(P.removePadding)(b):b},k.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},k.decrypt=function(C,b,u,a){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(C),b,u);var l=this.flush();l&&a(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(C),b,u).then(a)},k.softwareDecrypt=function(C,b,u){var a=this.currentIV,l=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(C=Object(j.appendUint8Array)(d,C),this.remainderData=null);var _=this.getValidChunk(C);if(!_.length)return null;a&&(u=a);var v=this.softwareDecrypter;v||(v=this.softwareDecrypter=new P.default),v.expandKey(b);var m=l;return this.currentResult=v.decrypt(_.buffer,0,u),this.currentIV=Object(N.sliceUint8)(_,-16).buffer,m||null},k.webCryptoDecrypt=function(C,b,u){var a=this,l=this.subtle;return(this.key!==b||!this.fastAesKey)&&(this.key=b,this.fastAesKey=new F.default(l,b)),this.fastAesKey.expandKey().then(function(d){if(!l)return Promise.reject(new Error("web crypto not initialized"));var _=new Z.default(l,u);return _.decrypt(C.buffer,d)}).catch(function(d){return a.onWebCryptoError(d,C,b,u)})},k.onWebCryptoError=function(C,b,u,a){return K.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",C),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(b,u,a)},k.getValidChunk=function(C){var b=C,u=C.length-C.length%D;return u!==C.length&&(b=Object(N.sliceUint8)(C,0,u),this.remainderData=Object(N.sliceUint8)(C,u)),b},k.logOnce=function(C){if(!this.logEnabled)return;K.logger.log("[decrypter.ts]: "+C),this.logEnabled=!1},A}()},"./src/crypt/fast-aes-key.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return Z});var Z=function(){function F(K,j){this.subtle=void 0,this.key=void 0,this.subtle=K,this.key=j}var P=F.prototype;return P.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},F}()},"./src/demux/aacdemuxer.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/demux/base-audio-demuxer.ts"),F=R("./src/demux/adts.ts"),P=R("./src/utils/logger.ts"),K=R("./src/demux/id3.ts");function j(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,N(y,A)}function N(y,A){return N=Object.setPrototypeOf||function(T,C){return T.__proto__=C,T},N(y,A)}var D=function(y){j(A,y);function A(T,C){var b;return b=y.call(this)||this,b.observer=void 0,b.config=void 0,b.observer=T,b.config=C,b}var k=A.prototype;return k.resetInitSegment=function(C,b,u){y.prototype.resetInitSegment.call(this,C,b,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:C,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(C){if(!C)return!1;for(var b=K.getID3Data(C,0)||[],u=b.length,a=C.length;u<a;u++)if(F.probe(C,u))return P.logger.log("ADTS sync word found !"),!0;return!1},k.canParse=function(C,b){return F.canParse(C,b)},k.appendFrame=function(C,b,u){F.initTrackConfig(C,this.observer,b,u,C.manifestCodec);var a=F.appendFrame(C,b,u,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},A}(Z.default);D.minProbeByteLength=9,$.default=D},"./src/demux/adts.ts":function(le,$,R){"use strict";R.r($),R.d($,"getAudioConfig",function(){return K}),R.d($,"isHeaderPattern",function(){return j}),R.d($,"getHeaderLength",function(){return N}),R.d($,"getFullFrameLength",function(){return D}),R.d($,"canGetFrameLength",function(){return y}),R.d($,"isHeader",function(){return A}),R.d($,"canParse",function(){return k}),R.d($,"probe",function(){return T}),R.d($,"initTrackConfig",function(){return C}),R.d($,"getFrameDuration",function(){return b}),R.d($,"parseFrameHeader",function(){return u}),R.d($,"appendFrame",function(){return a});var Z=R("./src/utils/logger.ts"),F=R("./src/errors.ts"),P=R("./src/events.ts");function K(l,d,_,v){var m,L,x,p,f=navigator.userAgent.toLowerCase(),h=v,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((d[_+2]&192)>>>6)+1;var E=(d[_+2]&60)>>>2;if(E>o.length-1){l.trigger(P.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return x=(d[_+2]&1)<<2,x|=(d[_+3]&192)>>>6,Z.logger.log("manifest codec:"+v+", ADTS type:"+m+", samplingIndex:"+E),/firefox/i.test(f)?E>=6?(m=5,p=new Array(4),L=E-3):(m=2,p=new Array(2),L=E):f.indexOf("android")!==-1?(m=2,p=new Array(2),L=E):(m=5,p=new Array(4),v&&(v.indexOf("mp4a.40.29")!==-1||v.indexOf("mp4a.40.5")!==-1)||!v&&E>=6?L=E-3:((v&&v.indexOf("mp4a.40.2")!==-1&&(E>=6&&x===1||/vivaldi/i.test(f))||!v&&x===1)&&(m=2,p=new Array(2)),L=E)),p[0]=m<<3,p[0]|=(E&14)>>1,p[1]|=(E&1)<<7,p[1]|=x<<3,m===5&&(p[1]|=(L&14)>>1,p[2]=(L&1)<<7,p[2]|=2<<2,p[3]=0),{config:p,samplerate:o[E],channelCount:x,codec:"mp4a.40."+m,manifestCodec:h}}function j(l,d){return l[d]===255&&(l[d+1]&246)===240}function N(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 A(l,d){return d+1<l.length&&j(l,d)}function k(l,d){return y(l,d)&&j(l,d)&&D(l,d)<=l.length-d}function T(l,d){if(A(l,d)){var _=N(l,d);if(d+_>=l.length)return!1;var v=D(l,d);if(v<=_)return!1;var m=d+v;return m===l.length||A(l,m)}return!1}function C(l,d,_,v,m){if(!l.samplerate){var L=K(d,_,v,m);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 b(l){return 1024*9e4/l}function u(l,d,_,v,m){var L=N(l,d),x=D(l,d);if(x-=L,x>0){var p=_+v*m;return{headerLength:L,frameLength:x,stamp:p}}}function a(l,d,_,v,m){var L=b(l.samplerate),x=u(d,_,v,m,L);if(x){var p=x.frameLength,f=x.headerLength,h=x.stamp,o=f+p,E=Math.max(0,_+o-d.length),g;E?(g=new Uint8Array(o-f),g.set(d.subarray(_+f,d.length),0)):g=d.subarray(_+f,_+o);var S={unit:g,pts:h};return E||l.samples.push(S),{sample:S,length:o,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(le,$,R){"use strict";R.r($),R.d($,"initPTSFn",function(){return D});var Z=R("./src/polyfills/number.ts"),F=R("./src/demux/id3.ts"),P=R("./src/demux/dummy-demuxed-track.ts"),K=R("./src/utils/mp4-tools.ts"),j=R("./src/utils/typed-array.ts"),N=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=y.prototype;return A.resetInitSegment=function(T,C,b){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(T,C){return!1},A.appendFrame=function(T,C,b){},A.demux=function(T,C){this.cachedData&&(T=Object(K.appendUint8Array)(this.cachedData,T),this.cachedData=null);var b=F.getID3Data(T,0),u=b?b.length:0,a,l,d=this._audioTrack,_=this._id3Track,v=b?F.getTimeStamp(b):void 0,m=T.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=D(v,C)),b&&b.length>0&&_.samples.push({pts:this.initPTS,dts:this.initPTS,data:b}),l=this.initPTS;u<m;){if(this.canParse(T,u)){var L=this.appendFrame(d,T,u);L?(this.frameIndex++,l=L.sample.pts,u+=L.length,a=u):u=m}else F.canParse(T,u)?(b=F.getID3Data(T,u),_.samples.push({pts:l,dts:l,data:b}),u+=b.length,a=u):u++;if(u===m&&a!==m){var x=Object(j.sliceUint8)(T,a);this.cachedData?this.cachedData=Object(K.appendUint8Array)(this.cachedData,x):this.cachedData=x}}return{audioTrack:d,avcTrack:Object(P.dummyTrack)(),id3Track:_,textTrack:Object(P.dummyTrack)()}},A.demuxSampleAes=function(T,C,b){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(T){var C=this.cachedData;return C&&(this.cachedData=null,this.demux(C,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(P.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(P.dummyTrack)()}},A.destroy=function(){},y}(),D=function(A,k){return Object(Z.isFiniteNumber)(A)?A*90:k*9e4};$.default=N},"./src/demux/chunk-cache.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return Z});var Z=function(){function P(){this.chunks=[],this.dataLength=0}var K=P.prototype;return K.push=function(N){this.chunks.push(N),this.dataLength+=N.length},K.flush=function(){var N=this.chunks,D=this.dataLength,y;if(N.length)N.length===1?y=N[0]:y=F(N,D);else return new Uint8Array(0);return this.reset(),y},K.reset=function(){this.chunks.length=0,this.dataLength=0},P}();function F(P,K){for(var j=new Uint8Array(K),N=0,D=0;D<P.length;D++){var y=P[D];j.set(y,N),N+=y.length}return j}},"./src/demux/dummy-demuxed-track.ts":function(le,$,R){"use strict";R.r($),R.d($,"dummyTrack",function(){return Z});function Z(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/utils/logger.ts"),F=function(){function P(j){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=j,this.bytesAvailable=j.byteLength,this.word=0,this.bitsAvailable=0}var K=P.prototype;return K.loadWord=function(){var N=this.data,D=this.bytesAvailable,y=N.byteLength-D,A=new Uint8Array(4),k=Math.min(4,D);if(k===0)throw new Error("no bytes available");A.set(N.subarray(y,y+k)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=k*8,this.bytesAvailable-=k},K.skipBits=function(N){var D;this.bitsAvailable>N?(this.word<<=N,this.bitsAvailable-=N):(N-=this.bitsAvailable,D=N>>3,N-=D>>3,this.bytesAvailable-=D,this.loadWord(),this.word<<=N,this.bitsAvailable-=N)},K.readBits=function(N){var D=Math.min(this.bitsAvailable,N),y=this.word>>>32-D;return N>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=N-D,D>0&&this.bitsAvailable?y<<D|this.readBits(D):y},K.skipLZ=function(){var N;for(N=0;N<this.bitsAvailable;++N)if((this.word&2147483648>>>N)!==0)return this.word<<=N,this.bitsAvailable-=N,N;return this.loadWord(),N+this.skipLZ()},K.skipUEG=function(){this.skipBits(1+this.skipLZ())},K.skipEG=function(){this.skipBits(1+this.skipLZ())},K.readUEG=function(){var N=this.skipLZ();return this.readBits(N+1)-1},K.readEG=function(){var N=this.readUEG();return 1&N?1+N>>>1:-1*(N>>>1)},K.readBoolean=function(){return this.readBits(1)===1},K.readUByte=function(){return this.readBits(8)},K.readUShort=function(){return this.readBits(16)},K.readUInt=function(){return this.readBits(32)},K.skipScalingList=function(N){for(var D=8,y=8,A,k=0;k<N;k++)y!==0&&(A=this.readEG(),y=(D+A+256)%256),D=y===0?D:y},K.readSPS=function(){var N=0,D=0,y=0,A=0,k,T,C,b=this.readUByte.bind(this),u=this.readBits.bind(this),a=this.readUEG.bind(this),l=this.readBoolean.bind(this),d=this.skipBits.bind(this),_=this.skipEG.bind(this),v=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);b();var L=b();if(u(5),d(3),b(),v(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var x=a();if(x===3&&d(1),v(),v(),d(1),l())for(T=x!==3?8:12,C=0;C<T;C++)l()&&(C<6?m(16):m(64))}v();var p=a();if(p===0)a();else if(p===1)for(d(1),_(),_(),k=a(),C=0;C<k;C++)_();v(),d(1);var f=a(),h=a(),o=u(1);o===0&&d(1),d(1),l()&&(N=a(),D=a(),y=a(),A=a());var E=[1,1];if(l()&&l()){var g=b();switch(g){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[b()<<8|b(),b()<<8|b()];break}}}return{width:Math.ceil((f+1)*16-N*2-D*2),height:(2-o)*(h+1)*16-(o?2:4)*(y+A),pixelRatio:E}},K.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();$.default=F},"./src/demux/id3.ts":function(le,$,R){"use strict";R.r($),R.d($,"isHeader",function(){return Z}),R.d($,"isFooter",function(){return F}),R.d($,"getID3Data",function(){return P}),R.d($,"canParse",function(){return j}),R.d($,"getTimeStamp",function(){return N}),R.d($,"isTimeStampFrame",function(){return D}),R.d($,"getID3Frames",function(){return A}),R.d($,"decodeFrame",function(){return k}),R.d($,"utf8ArrayToStr",function(){return a}),R.d($,"testables",function(){return l});var Z=function(m,L){return L+10<=m.length&&(m[L]===73&&m[L+1]===68&&m[L+2]===51&&(m[L+3]<255&&m[L+4]<255&&(m[L+6]<128&&m[L+7]<128&&m[L+8]<128&&m[L+9]<128)))},F=function(m,L){return L+10<=m.length&&(m[L]===51&&m[L+1]===68&&m[L+2]===73&&(m[L+3]<255&&m[L+4]<255&&(m[L+6]<128&&m[L+7]<128&&m[L+8]<128&&m[L+9]<128)))},P=function(m,L){for(var x=L,p=0;Z(m,L);){p+=10;var f=K(m,L+6);p+=f,F(m,L+10)&&(p+=10),L+=p}return p>0?m.subarray(x,x+p):void 0},K=function(m,L){var x=0;return x=(m[L]&127)<<21,x|=(m[L+1]&127)<<14,x|=(m[L+2]&127)<<7,x|=m[L+3]&127,x},j=function(m,L){return Z(m,L)&&K(m,L+6)+10<=m.length-L},N=function(m){for(var L=A(m),x=0;x<L.length;x++){var p=L[x];if(D(p))return u(p)}return},D=function(m){return m&&m.key==="PRIV"&&m.info==="com.apple.streaming.transportStreamTimestamp"},y=function(m){var L=String.fromCharCode(m[0],m[1],m[2],m[3]),x=K(m,4),p=10;return{type:L,size:x,data:m.subarray(p,p+x)}},A=function(m){for(var L=0,x=[];Z(m,L);){var p=K(m,L+6);L+=10;for(var f=L+p;L+8<f;){var h=y(m.subarray(L)),o=k(h);o&&x.push(o),L+=h.size+10}F(m,L)&&(L+=10)}return x},k=function(m){return m.type==="PRIV"?T(m):m.type[0]==="W"?b(m):C(m)},T=function(m){if(m.size<2)return;var L=a(m.data,!0),x=new Uint8Array(m.data.subarray(L.length+1));return{key:m.type,info:L,data:x.buffer}},C=function(m){if(m.size<2)return;if(m.type==="TXXX"){var L=1,x=a(m.data.subarray(L),!0);L+=x.length+1;var p=a(m.data.subarray(L));return{key:m.type,info:x,data:p}}var f=a(m.data.subarray(1));return{key:m.type,data:f}},b=function(m){if(m.type==="WXXX"){if(m.size<2)return;var L=1,x=a(m.data.subarray(L),!0);L+=x.length+1;var p=a(m.data.subarray(L));return{key:m.type,info:x,data:p}}var f=a(m.data);return{key:m.type,data:f}},u=function(m){if(m.data.byteLength===8){var L=new Uint8Array(m.data),x=L[3]&1,p=(L[4]<<23)+(L[5]<<15)+(L[6]<<7)+L[7];return p/=45,x&&(p+=4772185884e-2),Math.round(p)}return},a=function(m,L){L===void 0&&(L=!1);var x=_();if(x){var p=x.decode(m);if(L){var f=p.indexOf("\0");return f!==-1?p.substring(0,f):p}return p.replace(/\0/g,"")}for(var h=m.length,o,E,g,S="",M=0;M<h;){if(o=m[M++],o===0&&L)return S;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(o);break;case 12:case 13:E=m[M++],S+=String.fromCharCode((o&31)<<6|E&63);break;case 14:E=m[M++],g=m[M++],S+=String.fromCharCode((o&15)<<12|(E&63)<<6|(g&63)<<0);break;default:}}return S},l={decodeTextFrame:C},d;function _(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/demux/base-audio-demuxer.ts"),F=R("./src/demux/id3.ts"),P=R("./src/utils/logger.ts"),K=R("./src/demux/mpegaudio.ts");function j(y,A){y.prototype=Object.create(A.prototype),y.prototype.constructor=y,N(y,A)}function N(y,A){return N=Object.setPrototypeOf||function(T,C){return T.__proto__=C,T},N(y,A)}var D=function(y){j(A,y);function A(){return y.apply(this,arguments)||this}var k=A.prototype;return k.resetInitSegment=function(C,b,u){y.prototype.resetInitSegment.call(this,C,b,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:C,duration:u,inputTimeScale:9e4,dropped:0}},A.probe=function(C){if(!C)return!1;for(var b=F.getID3Data(C,0)||[],u=b.length,a=C.length;u<a;u++)if(K.probe(C,u))return P.logger.log("MPEG Audio sync word found !"),!0;return!1},k.canParse=function(C,b){return K.canParse(C,b)},k.appendFrame=function(C,b,u){return this.initPTS===null?void 0:K.appendFrame(C,b,u,this.initPTS,this.frameIndex)},A}(Z.default);D.minProbeByteLength=4,$.default=D},"./src/demux/mp4demuxer.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/utils/mp4-tools.ts"),F=R("./src/demux/dummy-demuxed-track.ts"),P=function(){function K(N,D){this.remainderData=null,this.config=void 0,this.config=D}var j=K.prototype;return j.resetTimeStamp=function(){},j.resetInitSegment=function(){},j.resetContiguity=function(){},K.probe=function(D){return Object(Z.findBox)({data:D,start:0,end:Math.min(D.length,16384)},["moof"]).length>0},j.demux=function(D){var y=D,A=Object(F.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object(Z.appendUint8Array)(this.remainderData,D));var k=Object(Z.segmentValidRange)(y);this.remainderData=k.remainder,A.samples=k.valid||new Uint8Array}else A.samples=y;return{audioTrack:Object(F.dummyTrack)(),avcTrack:A,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},j.flush=function(){var D=Object(F.dummyTrack)();return D.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(F.dummyTrack)(),avcTrack:D,id3Track:Object(F.dummyTrack)(),textTrack:Object(F.dummyTrack)()}},j.demuxSampleAes=function(D,y,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},j.destroy=function(){},K}();P.minProbeByteLength=1024,$.default=P},"./src/demux/mpegaudio.ts":function(le,$,R){"use strict";R.r($),R.d($,"appendFrame",function(){return N}),R.d($,"parseHeader",function(){return D}),R.d($,"isHeaderPattern",function(){return y}),R.d($,"isHeader",function(){return A}),R.d($,"canParse",function(){return k}),R.d($,"probe",function(){return T});var Z=null,F=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],P=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],K=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],j=[0,1,1,4];function N(C,b,u,a,l){if(u+24>b.length)return;var d=D(b,u);if(d&&u+d.frameLength<=b.length){var _=d.samplesPerFrame*9e4/d.sampleRate,v=a+l*_,m={unit:b.subarray(u,u+d.frameLength),pts:v,dts:v};return C.config=[],C.channelCount=d.channelCount,C.samplerate=d.sampleRate,C.samples.push(m),{sample:m,length:d.frameLength,missing:0}}}function D(C,b){var u=C[b+1]>>3&3,a=C[b+1]>>1&3,l=C[b+2]>>4&15,d=C[b+2]>>2&3;if(u!==1&&l!==0&&l!==15&&d!==3){var _=C[b+2]>>1&1,v=C[b+3]>>6,m=u===3?3-a:a===3?3:4,L=F[m*14+l-1]*1e3,x=u===3?0:u===2?1:2,p=P[x*3+d],f=v===3?1:2,h=K[u][a],o=j[a],E=h*8*o,g=Math.floor(h*L/p+_)*o;if(Z===null){var S=navigator.userAgent||"",M=S.match(/Chrome\/(\d+)/i);Z=M?parseInt(M[1]):0}var U=!!Z&&Z<=87;return U&&a===2&&L>=224e3&&v===0&&(C[b+3]=C[b+3]|128),{sampleRate:p,channelCount:f,frameLength:g,samplesPerFrame:E}}}function y(C,b){return C[b]===255&&(C[b+1]&224)===224&&(C[b+1]&6)!==0}function A(C,b){return b+1<C.length&&y(C,b)}function k(C,b){var u=4;return y(C,b)&&u<=C.length-b}function T(C,b){if(b+1<C.length&&y(C,b)){var u=4,a=D(C,b),l=u;a!=null&&a.frameLength&&(l=a.frameLength);var d=b+l;return d===C.length||A(C,d)}return!1}},"./src/demux/sample-aes.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/crypt/decrypter.ts"),F=R("./src/demux/tsdemuxer.ts"),P=function(){function K(N,D,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new Z.default(N,D,{removePKCS7Padding:!1})}var j=K.prototype;return j.decryptBuffer=function(D,y){this.decrypter.decrypt(D,this.keyData.key.buffer,this.keyData.iv.buffer,y)},j.decryptAacSample=function(D,y,A,k){var T=D[y].unit,C=T.subarray(16,T.length-T.length%16),b=C.buffer.slice(C.byteOffset,C.byteOffset+C.length),u=this;this.decryptBuffer(b,function(a){var l=new Uint8Array(a);T.set(l,16),k||u.decryptAacSamples(D,y+1,A)})},j.decryptAacSamples=function(D,y,A){for(;;y++){if(y>=D.length){A();return}if(D[y].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(D,y,A,k),!k)return}},j.getAvcEncryptedData=function(D){for(var y=Math.floor((D.length-48)/160)*16+16,A=new Int8Array(y),k=0,T=32;T<=D.length-16;T+=160,k+=16)A.set(D.subarray(T,T+16),k);return A},j.getAvcDecryptedUnit=function(D,y){for(var A=new Uint8Array(y),k=0,T=32;T<=D.length-16;T+=160,k+=16)D.set(A.subarray(k,k+16),T);return D},j.decryptAvcSample=function(D,y,A,k,T,C){var b=Object(F.discardEPB)(T.data),u=this.getAvcEncryptedData(b),a=this;this.decryptBuffer(u.buffer,function(l){T.data=a.getAvcDecryptedUnit(b,l),C||a.decryptAvcSamples(D,y,A+1,k)})},j.decryptAvcSamples=function(D,y,A,k){if(D instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,A=0){if(y>=D.length){k();return}for(var T=D[y].units;!(A>=T.length);A++){var C=T[A];if(C.data.length<=48||C.type!==1&&C.type!==5)continue;var b=this.decrypter.isSync();if(this.decryptAvcSample(D,y,A,k,C,b),!b)return}}},K}();$.default=P},"./src/demux/transmuxer-interface.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var Z=R("./node_modules/webworkify-webpack/index.js"),F=R.n(Z),P=R("./src/events.ts"),K=R("./src/demux/transmuxer.ts"),j=R("./src/utils/logger.ts"),N=R("./src/errors.ts"),D=R("./src/utils/mediasource-helper.ts"),y=R("./node_modules/eventemitter3/index.js"),A=R.n(y),k=Object(D.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function C(u,a,l,d){var _=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=u,this.id=a,this.onTransmuxComplete=l,this.onFlush=d;var v=u.config,m=function(h,o){o=o||{},o.frag=_.frag,o.id=_.id,u.trigger(h,o)};this.observer=new y.EventEmitter,this.observer.on(P.Events.FRAG_DECRYPTED,m),this.observer.on(P.Events.ERROR,m);var L={mp4:k.isTypeSupported("video/mp4"),mpeg:k.isTypeSupported("audio/mpeg"),mp3:k.isTypeSupported('audio/mp4; codecs="mp3"')},x=navigator.vendor;if(v.enableWorker&&typeof Worker!="undefined"){j.logger.log("demuxing in webworker");var p;try{p=this.worker=Z("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(f){u.trigger(P.Events.ERROR,{type:N.ErrorTypes.OTHER_ERROR,details:N.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(f.message+" ("+f.filename+":"+f.lineno+")")})},p.postMessage({cmd:"init",typeSupported:L,vendor:x,id:a,config:JSON.stringify(v)})}catch(f){j.logger.warn("Error in worker:",f),j.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new K.default(this.observer,L,v,x,a),this.worker=null}}else this.transmuxer=new K.default(this.observer,L,v,x,a)}var b=C.prototype;return b.destroy=function(){var a=this.worker;if(a)a.removeEventListener("message",this.onwmsg),a.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var d=this.observer;d&&d.removeAllListeners(),this.observer=null},b.push=function(a,l,d,_,v,m,L,x,p,f){var h=this;p.transmuxing.start=self.performance.now();var o=this.transmuxer,E=this.worker,g=m?m.start:v.start,S=v.decryptdata,M=this.frag,U=!(M&&v.cc===M.cc),G=!(M&&p.level===M.level),V=M?p.sn-M.sn:-1,O=this.part?p.part-this.part.index:1,I=!G&&(V===1||V===0&&O===1),X=self.performance.now();(G||V||v.stats.parsing.start===0)&&(v.stats.parsing.start=X),m&&(O||!I)&&(m.stats.parsing.start=X);var q=new K.TransmuxState(U,I,x,G,g);if(!I||U){j.logger.log("[transmuxer-interface, "+v.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
discontinuity: `+U+`
trackSwitch: `+G+`
contiguous: `+I+`
accurateTimeOffset: `+x+`
timeOffset: `+g);var oe=new K.TransmuxConfig(d,_,l,L,f);this.configureTransmuxer(oe)}if(this.frag=v,this.part=m,E)E.postMessage({cmd:"demux",data:a,decryptdata:S,chunkMeta:p,state:q},a instanceof ArrayBuffer?[a]:[]);else if(o){var ce=o.push(a,S,p,q);Object(K.isPromise)(ce)?ce.then(function(Le){h.handleTransmuxComplete(Le)}):this.handleTransmuxComplete(ce)}},b.flush=function(a){var l=this;a.transmuxing.start=self.performance.now();var d=this.transmuxer,_=this.worker;if(_)_.postMessage({cmd:"flush",chunkMeta:a});else if(d){var v=d.flush(a);Object(K.isPromise)(v)?v.then(function(m){l.handleFlushResult(m,a)}):this.handleFlushResult(v,a)}},b.handleFlushResult=function(a,l){var d=this;a.forEach(function(_){d.handleTransmuxComplete(_)}),this.onFlush(l)},b.onWorkerMessage=function(a){var l=a.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}}},b.configureTransmuxer=function(a){var l=this.worker,d=this.transmuxer;l?l.postMessage({cmd:"configure",config:a}):d&&d.configure(a)},b.handleTransmuxComplete=function(a){a.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(a)},C}()},"./src/demux/transmuxer-worker.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return N});var Z=R("./src/demux/transmuxer.ts"),F=R("./src/events.ts"),P=R("./src/utils/logger.ts"),K=R("./node_modules/eventemitter3/index.js"),j=R.n(K);function N(T){var C=new K.EventEmitter,b=function(a,l){T.postMessage({event:a,data:l})};C.on(F.Events.FRAG_DECRYPTED,b),C.on(F.Events.ERROR,b),T.addEventListener("message",function(u){var a=u.data;switch(a.cmd){case"init":{var l=JSON.parse(a.config);T.transmuxer=new Z.default(C,a.typeSupported,l,a.vendor,a.id),Object(P.enableLogs)(l.debug),b("init",null);break}case"configure":{T.transmuxer.configure(a.config);break}case"demux":{var d=T.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(Z.isPromise)(d)?d.then(function(m){D(T,m)}):D(T,d);break}case"flush":{var _=a.chunkMeta,v=T.transmuxer.flush(_);Object(Z.isPromise)(v)?v.then(function(m){A(T,m,_)}):A(T,v,_);break}default:break}})}function D(T,C){if(k(C.remuxResult))return;var b=[],u=C.remuxResult,a=u.audio,l=u.video;a&&y(b,a),l&&y(b,l),T.postMessage({event:"transmuxComplete",data:C},b)}function y(T,C){C.data1&&T.push(C.data1.buffer),C.data2&&T.push(C.data2.buffer)}function A(T,C,b){C.forEach(function(u){D(T,u)}),T.postMessage({event:"flush",data:b})}function k(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return l}),R.d($,"isPromise",function(){return v}),R.d($,"TransmuxConfig",function(){return m}),R.d($,"TransmuxState",function(){return L});var Z=R("./src/events.ts"),F=R("./src/errors.ts"),P=R("./src/crypt/decrypter.ts"),K=R("./src/demux/aacdemuxer.ts"),j=R("./src/demux/mp4demuxer.ts"),N=R("./src/demux/tsdemuxer.ts"),D=R("./src/demux/mp3demuxer.ts"),y=R("./src/remux/mp4-remuxer.ts"),A=R("./src/remux/passthrough-remuxer.ts"),k=R("./src/demux/chunk-cache.ts"),T=R("./src/utils/mp4-tools.ts"),C=R("./src/utils/logger.ts"),b;try{b=self.performance.now.bind(self.performance)}catch(x){C.logger.debug("Unable to use Performance API on this environment"),b=self.Date.now}var u=[{demux:N.default,remux:y.default},{demux:j.default,remux:A.default},{demux:K.default,remux:y.default},{demux:D.default,remux:y.default}],a=1024;u.forEach(function(x){var p=x.demux;a=Math.max(a,p.minProbeByteLength)});var l=function(){function x(f,h,o,E,g){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new k.default,this.observer=f,this.typeSupported=h,this.config=o,this.vendor=E,this.id=g}var p=x.prototype;return p.configure=function(h){this.transmuxConfig=h,this.decrypter&&this.decrypter.reset()},p.push=function(h,o,E,g){var S=this,M=E.transmuxing;M.executeStart=b();var U=new Uint8Array(h),G=this.cache,V=this.config,O=this.currentTransmuxState,I=this.transmuxConfig;g&&(this.currentTransmuxState=g);var X=d(U,o);if(X&&X.method==="AES-128"){var q=this.getDecrypter();if(V.enableSoftwareAES){var oe=q.softwareDecrypt(U,X.key.buffer,X.iv.buffer);if(!oe)return M.executeEnd=b(),_(E);U=new Uint8Array(oe)}else return this.decryptionPromise=q.webCryptoDecrypt(U,X.key.buffer,X.iv.buffer).then(function(ke){var Ne=S.push(ke,null,E);return S.decryptionPromise=null,Ne}),this.decryptionPromise}var ce=g||O,Le=ce.contiguous,Ee=ce.discontinuity,we=ce.trackSwitch,Te=ce.accurateTimeOffset,ye=ce.timeOffset,fe=I.audioCodec,se=I.videoCodec,te=I.defaultInitPts,ue=I.duration,ne=I.initSegmentData;if((Ee||we)&&this.resetInitSegment(ne,fe,se,ue),Ee&&this.resetInitialTimestamp(te),Le||this.resetContiguity(),this.needsProbing(U,Ee,we)){if(G.dataLength){var _e=G.flush();U=Object(T.appendUint8Array)(_e,U)}this.configureTransmuxer(U,I)}var Re=this.transmux(U,X,ye,Te,E),xe=this.currentTransmuxState;return xe.contiguous=!0,xe.discontinuity=!1,xe.trackSwitch=!1,M.executeEnd=b(),Re},p.flush=function(h){var o=this,E=h.transmuxing;E.executeStart=b();var g=this.decrypter,S=this.cache,M=this.currentTransmuxState,U=this.decryptionPromise;if(U)return U.then(function(){return o.flush(h)});var G=[],V=M.timeOffset;if(g){var O=g.flush();O&&G.push(this.push(O,null,h))}var I=S.dataLength;S.reset();var X=this.demuxer,q=this.remuxer;if(!X||!q)return I>=a&&this.observer.emit(Z.Events.ERROR,Z.Events.ERROR,{type:F.ErrorTypes.MEDIA_ERROR,details:F.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=b(),[_(h)];var oe=X.flush(V);return v(oe)?oe.then(function(ce){return o.flushRemux(G,ce,h),G}):(this.flushRemux(G,oe,h),G)},p.flushRemux=function(h,o,E){var g=o.audioTrack,S=o.avcTrack,M=o.id3Track,U=o.textTrack,G=this.currentTransmuxState,V=G.accurateTimeOffset,O=G.timeOffset;C.logger.log("[transmuxer.ts]: Flushed fragment "+E.sn+(E.part>-1?" p: "+E.part:"")+" of level "+E.level);var I=this.remuxer.remux(g,S,M,U,O,V,!0,this.id);h.push({remuxResult:I,chunkMeta:E}),E.transmuxing.executeEnd=b()},p.resetInitialTimestamp=function(h){var o=this.demuxer,E=this.remuxer;if(!o||!E)return;o.resetTimeStamp(h),E.resetTimeStamp(h)},p.resetContiguity=function(){var h=this.demuxer,o=this.remuxer;if(!h||!o)return;h.resetContiguity(),o.resetNextTimestamp()},p.resetInitSegment=function(h,o,E,g){var S=this.demuxer,M=this.remuxer;if(!S||!M)return;S.resetInitSegment(o,E,g),M.resetInitSegment(h,o,E)},p.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},p.transmux=function(h,o,E,g,S){var M;return o&&o.method==="SAMPLE-AES"?M=this.transmuxSampleAes(h,o,E,g,S):M=this.transmuxUnencrypted(h,E,g,S),M},p.transmuxUnencrypted=function(h,o,E,g){var S=this.demuxer.demux(h,o,!1,!this.config.progressive),M=S.audioTrack,U=S.avcTrack,G=S.id3Track,V=S.textTrack,O=this.remuxer.remux(M,U,G,V,o,E,!1,this.id);return{remuxResult:O,chunkMeta:g}},p.transmuxSampleAes=function(h,o,E,g,S){var M=this;return this.demuxer.demuxSampleAes(h,o,E).then(function(U){var G=M.remuxer.remux(U.audioTrack,U.avcTrack,U.id3Track,U.textTrack,E,g,!1,M.id);return{remuxResult:G,chunkMeta:S}})},p.configureTransmuxer=function(h,o){for(var E=this.config,g=this.observer,S=this.typeSupported,M=this.vendor,U=o.audioCodec,G=o.defaultInitPts,V=o.duration,O=o.initSegmentData,I=o.videoCodec,X,q=0,oe=u.length;q<oe;q++)if(u[q].demux.probe(h)){X=u[q];break}X||(C.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),X={demux:j.default,remux:A.default});var ce=this.demuxer,Le=this.remuxer,Ee=X.remux,we=X.demux;(!Le||!(Le instanceof Ee))&&(this.remuxer=new Ee(g,E,S,M)),(!ce||!(ce instanceof we))&&(this.demuxer=new we(g,E,S),this.probe=we.probe),this.resetInitSegment(O,U,I,V),this.resetInitialTimestamp(G)},p.needsProbing=function(h,o,E){return!this.demuxer||!this.remuxer||o||E},p.getDecrypter=function(){var h=this.decrypter;return h||(h=this.decrypter=new P.default(this.observer,this.config)),h},x}();function d(x,p){var f=null;return x.byteLength>0&&p!=null&&p.key!=null&&p.iv!==null&&p.method!=null&&(f=p),f}var _=function(p){return{remuxResult:{},chunkMeta:p}};function v(x){return"then"in x&&x.then instanceof Function}var m=function(p,f,h,o,E){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=p,this.videoCodec=f,this.initSegmentData=h,this.duration=o,this.defaultInitPts=E},L=function(p,f,h,o,E){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=p,this.contiguous=f,this.accurateTimeOffset=h,this.trackSwitch=o,this.timeOffset=E}},"./src/demux/tsdemuxer.ts":function(le,$,R){"use strict";R.r($),R.d($,"discardEPB",function(){return _});var Z=R("./src/demux/adts.ts"),F=R("./src/demux/mpegaudio.ts"),P=R("./src/demux/exp-golomb.ts"),K=R("./src/demux/id3.ts"),j=R("./src/demux/sample-aes.ts"),N=R("./src/events.ts"),D=R("./src/utils/mp4-tools.ts"),y=R("./src/utils/logger.ts"),A=R("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},T=function(){function v(L,x,p){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=x,this.typeSupported=p}v.probe=function(x){var p=v.syncOffset(x);return p<0?!1:(p&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+p+", junk ahead ?"),!0)},v.syncOffset=function(x){for(var p=Math.min(1e3,x.length-3*188),f=0;f<p;){if(x[f]===71&&x[f+188]===71&&x[f+2*188]===71)return f;f++}return-1},v.createTrack=function(x,p){return{container:x==="video"||x==="audio"?"video/mp2t":void 0,type:x,id:k[x],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:x==="audio"?p:void 0}};var m=v.prototype;return m.resetInitSegment=function(x,p,f){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=v.createTrack("video",f),this._audioTrack=v.createTrack("audio",f),this._id3Track=v.createTrack("id3",f),this._txtTrack=v.createTrack("text",f),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=p,this._duration=f},m.resetTimeStamp=function(){},m.resetContiguity=function(){var x=this._audioTrack,p=this._avcTrack,f=this._id3Track;x&&(x.pesData=null),p&&(p.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},m.demux=function(x,p,f,h){f===void 0&&(f=!1),h===void 0&&(h=!1),f||(this.sampleAes=null);var o,E=this._avcTrack,g=this._audioTrack,S=this._id3Track,M=E.pid,U=E.pesData,G=g.pid,V=S.pid,O=g.pesData,I=S.pesData,X=!1,q=this.pmtParsed,oe=this._pmtId,ce=x.length;if(this.remainderData&&(x=Object(D.appendUint8Array)(this.remainderData,x),ce=x.length,this.remainderData=null),ce<188&&!h)return this.remainderData=x,{audioTrack:g,avcTrack:E,id3Track:S,textTrack:this._txtTrack};var Le=Math.max(0,v.syncOffset(x));ce-=(ce+Le)%188,ce<x.byteLength&&!h&&(this.remainderData=new Uint8Array(x.buffer,ce,x.buffer.byteLength-ce));for(var Ee=Le;Ee<ce;Ee+=188)if(x[Ee]===71){var we=!!(x[Ee+1]&64),Te=((x[Ee+1]&31)<<8)+x[Ee+2],ye=(x[Ee+3]&48)>>4,fe=void 0;if(ye>1){if(fe=Ee+5+x[Ee+4],fe===Ee+188)continue}else fe=Ee+4;switch(Te){case M:we&&(U&&(o=a(U))&&this.parseAVCPES(o,!1),U={data:[],size:0}),U&&(U.data.push(x.subarray(fe,Ee+188)),U.size+=Ee+188-fe);break;case G:we&&(O&&(o=a(O))&&(g.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),O={data:[],size:0}),O&&(O.data.push(x.subarray(fe,Ee+188)),O.size+=Ee+188-fe);break;case V:we&&(I&&(o=a(I))&&this.parseID3PES(o),I={data:[],size:0}),I&&(I.data.push(x.subarray(fe,Ee+188)),I.size+=Ee+188-fe);break;case 0:we&&(fe+=x[fe]+1),oe=this._pmtId=b(x,fe);break;case oe:{we&&(fe+=x[fe]+1);var se=u(x,fe,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);M=se.avc,M>0&&(E.pid=M),G=se.audio,G>0&&(g.pid=G,g.isAAC=se.isAAC),V=se.id3,V>0&&(S.pid=V),X&&!q&&(y.logger.log("reparse from beginning"),X=!1,Ee=Le-188),q=this.pmtParsed=!0;break}case 17:case 8191:break;default:X=!0;break}}else this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E.pesData=U,g.pesData=O,S.pesData=I;var te={audioTrack:g,avcTrack:E,id3Track:S,textTrack:this._txtTrack};return h&&this.extractRemainingSamples(te),te},m.flush=function(){var x=this.remainderData;this.remainderData=null;var p;return x?p=this.demux(x,-1,!1,!0):p={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},m.extractRemainingSamples=function(x){var p=x.audioTrack,f=x.avcTrack,h=x.id3Track,o=f.pesData,E=p.pesData,g=h.pesData,S;o&&(S=a(o))?(this.parseAVCPES(S,!0),f.pesData=null):f.pesData=o,E&&(S=a(E))?(p.isAAC?this.parseAACPES(S):this.parseMPEGPES(S),p.pesData=null):(E!=null&&E.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=E),g&&(S=a(g))?(this.parseID3PES(S),h.pesData=null):h.pesData=g},m.demuxSampleAes=function(x,p,f){var h=this.demux(x,f,!0,!this.config.progressive),o=this.sampleAes=new j.default(this.observer,this.config,p);return this.decrypt(h,o)},m.decrypt=function(x,p){return new Promise(function(f){var h=x.audioTrack,o=x.avcTrack;h.samples&&h.isAAC?p.decryptAacSamples(h.samples,0,function(){o.samples?p.decryptAvcSamples(o.samples,0,0,function(){f(x)}):f(x)}):o.samples&&p.decryptAvcSamples(o.samples,0,0,function(){f(x)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(x,p){var f=this,h=this._avcTrack,o=this.parseAVCNALu(x.data),E=!1,g=this.avcSample,S,M=!1;x.data=null,g&&o.length&&!h.audFound&&(l(g,h),g=this.avcSample=C(!1,x.pts,x.dts,"")),o.forEach(function(U){switch(U.type){case 1:{S=!0,g||(g=f.avcSample=C(!0,x.pts,x.dts,"")),E&&(g.debug+="NDR "),g.frame=!0;var G=U.data;if(M&&G.length>4){var V=new P.default(G).readSliceType();(V===2||V===4||V===7||V===9)&&(g.key=!0)}break}case 5:S=!0,g||(g=f.avcSample=C(!0,x.pts,x.dts,"")),E&&(g.debug+="IDR "),g.key=!0,g.frame=!0;break;case 6:{S=!0,E&&g&&(g.debug+="SEI ");var O=new P.default(_(U.data));O.readUByte();for(var I=0,X=0,q=!1,oe=0;!q&&O.bytesAvailable>1;){I=0;do oe=O.readUByte(),I+=oe;while(oe===255);X=0;do oe=O.readUByte(),X+=oe;while(oe===255);if(I===4&&O.bytesAvailable!==0){q=!0;var ce=O.readUByte();if(ce===181){var Le=O.readUShort();if(Le===49){var Ee=O.readUInt();if(Ee===1195456820){var we=O.readUByte();if(we===3){for(var Te=O.readUByte(),ye=O.readUByte(),fe=31&Te,se=[Te,ye],te=0;te<fe;te++)se.push(O.readUByte()),se.push(O.readUByte()),se.push(O.readUByte());d(f._txtTrack.samples,{type:3,pts:x.pts,bytes:se})}}}}}else if(I===5&&O.bytesAvailable!==0){if(q=!0,X>16){for(var ue=[],ne=0;ne<16;ne++)ue.push(O.readUByte().toString(16)),(ne===3||ne===5||ne===7||ne===9)&&ue.push("-");for(var _e=X-16,Re=new Uint8Array(_e),xe=0;xe<_e;xe++)Re[xe]=O.readUByte();d(f._txtTrack.samples,{pts:x.pts,payloadType:I,uuid:ue.join(""),userData:Object(K.utf8ArrayToStr)(Re),userDataBytes:Re})}}else if(X<O.bytesAvailable)for(var ke=0;ke<X;ke++)O.readUByte()}break}case 7:if(S=!0,M=!0,E&&g&&(g.debug+="SPS "),!h.sps){var Ne=new P.default(U.data),He=Ne.readSPS();h.width=He.width,h.height=He.height,h.pixelRatio=He.pixelRatio,h.sps=[U.data],h.duration=f._duration;for(var Be=U.data.subarray(1,4),Me="avc1.",Oe=0;Oe<3;Oe++){var Ye=Be[Oe].toString(16);Ye.length<2&&(Ye="0"+Ye),Me+=Ye}h.codec=Me}break;case 8:S=!0,E&&g&&(g.debug+="PPS "),h.pps||(h.pps=[U.data]);break;case 9:S=!1,h.audFound=!0,g&&l(g,h),g=f.avcSample=C(!1,x.pts,x.dts,E?"AUD ":"");break;case 12:S=!1;break;default:S=!1,g&&(g.debug+="unknown NAL "+U.type+" ");break}if(g&&S){var Je=g.units;Je.push(U)}}),p&&g&&(l(g,h),this.avcSample=null)},m.getLastNalUnit=function(){var x,p=this.avcSample,f;if(!p||p.units.length===0){var h=this._avcTrack.samples;p=h[h.length-1]}if((x=p)!==null&&x!==void 0&&x.units){var o=p.units;f=o[o.length-1]}return f},m.parseAVCNALu=function(x){var p=x.byteLength,f=this._avcTrack,h=f.naluState||0,o=h,E=[],g=0,S,M,U,G=-1,V=0;for(h===-1&&(G=0,V=x[0]&31,h=0,g=1);g<p;){if(S=x[g++],!h){h=S?0:1;continue}if(h===1){h=S?0:2;continue}if(!S)h=3;else if(S===1){if(G>=0){var O={data:x.subarray(G,g-h-1),type:V};E.push(O)}else{var I=this.getLastNalUnit();if(I&&(o&&g<=4-o&&(I.state&&(I.data=I.data.subarray(0,I.data.byteLength-o))),M=g-h-1,M>0)){var X=new Uint8Array(I.data.byteLength+M);X.set(I.data,0),X.set(x.subarray(0,M),I.data.byteLength),I.data=X,I.state=0}}g<p?(U=x[g]&31,G=g,V=U,h=0):h=-1}else h=0}if(G>=0&&h>=0){var q={data:x.subarray(G,p),type:V,state:h};E.push(q)}if(E.length===0){var oe=this.getLastNalUnit();if(oe){var ce=new Uint8Array(oe.data.byteLength+x.byteLength);ce.set(oe.data,0),ce.set(x,oe.data.byteLength),oe.data=ce}}return f.naluState=h,E},m.parseAACPES=function(x){var p=0,f=this._audioTrack,h=this.aacOverFlow,o=x.data;if(h){this.aacOverFlow=null;var E=h.sample.unit.byteLength,g=Math.min(h.missing,E),S=E-g;h.sample.unit.set(o.subarray(0,g),S),f.samples.push(h.sample),p=h.missing}var M,U;for(M=p,U=o.length;M<U-1&&!Z.isHeader(o,M);M++);if(M!==p){var G,V;if(M<U-1?(G="AAC PES did not start with ADTS header,offset:"+M,V=!1):(G="no ADTS header found in AAC PES",V=!0),y.logger.warn("parsing error:"+G),this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:G}),V)return}Z.initTrackConfig(f,this.observer,o,M,this.audioCodec);var O;if(x.pts!==void 0)O=x.pts;else if(h){var I=Z.getFrameDuration(f.samplerate);O=h.sample.pts+I}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var X=0;M<U;)if(Z.isHeader(o,M)){if(M+5<U){var q=Z.appendFrame(f,o,M,O,X);if(q)if(q.missing)this.aacOverFlow=q;else{M+=q.length,X++;continue}}break}else M++},m.parseMPEGPES=function(x){var p=x.data,f=p.length,h=0,o=0,E=x.pts;if(E===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<f;)if(F.isHeader(p,o)){var g=F.appendFrame(this._audioTrack,p,o,E,h);if(g)o+=g.length,h++;else break}else o++},m.parseID3PES=function(x){if(x.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(x)},v}();T.minProbeByteLength=188;function C(v,m,L,x){return{key:v,frame:!1,pts:m,dts:L,units:[],debug:x,length:0}}function b(v,m){return(v[m+10]&31)<<8|v[m+11]}function u(v,m,L,x){var p={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(v[m+1]&15)<<8|v[m+2],h=m+3+f-4,o=(v[m+10]&15)<<8|v[m+11];for(m+=12+o;m<h;){var E=(v[m+1]&31)<<8|v[m+2];switch(v[m]){case 207:if(!x){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:p.audio===-1&&(p.audio=E);break;case 21:p.id3===-1&&(p.id3=E);break;case 219:if(!x){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:p.avc===-1&&(p.avc=E);break;case 3:case 4:L?p.audio===-1&&(p.audio=E,p.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}m+=((v[m+3]&15)<<8|v[m+4])+5}return p}function a(v){var m=0,L,x,p,f,h,o=v.data;if(!v||v.size===0)return null;for(;o[0].length<19&&o.length>1;){var E=new Uint8Array(o[0].length+o[1].length);E.set(o[0]),E.set(o[1],o[0].length),o[0]=E,o.splice(1,1)}L=o[0];var g=(L[0]<<16)+(L[1]<<8)+L[2];if(g===1){if(x=(L[4]<<8)+L[5],x&&x>v.size-6)return null;var S=L[7];S&192&&(f=(L[9]&14)*536870912+(L[10]&255)*4194304+(L[11]&254)*16384+(L[12]&255)*128+(L[13]&254)/2,S&64?(h=(L[14]&14)*536870912+(L[15]&255)*4194304+(L[16]&254)*16384+(L[17]&255)*128+(L[18]&254)/2,f-h>60*9e4&&(y.logger.warn(Math.round((f-h)/9e4)+"s delta between PTS and DTS, align them"),f=h)):h=f),p=L[8];var M=p+9;if(v.size<=M)return null;v.size-=M;for(var U=new Uint8Array(v.size),G=0,V=o.length;G<V;G++){L=o[G];var O=L.byteLength;if(M)if(M>O){M-=O;continue}else L=L.subarray(M),O-=M,M=0;U.set(L,m),m+=O}return x&&(x-=p+3),{data:U,pts:f,dts:h,len:x}}return null}function l(v,m){if(v.units.length&&v.frame){if(v.pts===void 0){var L=m.samples,x=L.length;if(x){var p=L[x-1];v.pts=p.pts,v.dts=p.dts}else{m.dropped++;return}}m.samples.push(v)}v.debug.length&&y.logger.log(v.pts+"/"+v.dts+":"+v.debug)}function d(v,m){var L=v.length;if(L>0){if(m.pts>=v[L-1].pts)v.push(m);else for(var x=L-1;x>=0;x--)if(m.pts<v[x].pts){v.splice(x,0,m);break}}else v.push(m)}function _(v){for(var m=v.byteLength,L=[],x=1;x<m-2;)v[x]===0&&v[x+1]===0&&v[x+2]===3?(L.push(x+2),x+=2):x++;if(L.length===0)return v;var p=m-L.length,f=new Uint8Array(p),h=0;for(x=0;x<p;h++,x++)h===L[0]&&(h++,L.shift()),f[x]=v[h];return f}$.default=T},"./src/errors.ts":function(le,$,R){"use strict";R.r($),R.d($,"ErrorTypes",function(){return Z}),R.d($,"ErrorDetails",function(){return F});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 F;(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"})(F||(F={}))},"./src/events.ts":function(le,$,R){"use strict";R.r($),R.d($,"Events",function(){return Z});var Z;(function(F){F.MEDIA_ATTACHING="hlsMediaAttaching",F.MEDIA_ATTACHED="hlsMediaAttached",F.MEDIA_DETACHING="hlsMediaDetaching",F.MEDIA_DETACHED="hlsMediaDetached",F.BUFFER_RESET="hlsBufferReset",F.BUFFER_CODECS="hlsBufferCodecs",F.BUFFER_CREATED="hlsBufferCreated",F.BUFFER_APPENDING="hlsBufferAppending",F.BUFFER_APPENDED="hlsBufferAppended",F.BUFFER_EOS="hlsBufferEos",F.BUFFER_FLUSHING="hlsBufferFlushing",F.BUFFER_FLUSHED="hlsBufferFlushed",F.MANIFEST_LOADING="hlsManifestLoading",F.MANIFEST_LOADED="hlsManifestLoaded",F.MANIFEST_PARSED="hlsManifestParsed",F.LEVEL_SWITCHING="hlsLevelSwitching",F.LEVEL_SWITCHED="hlsLevelSwitched",F.LEVEL_LOADING="hlsLevelLoading",F.LEVEL_LOADED="hlsLevelLoaded",F.LEVEL_UPDATED="hlsLevelUpdated",F.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",F.LEVELS_UPDATED="hlsLevelsUpdated",F.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",F.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",F.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",F.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",F.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",F.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",F.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",F.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",F.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",F.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",F.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",F.CUES_PARSED="hlsCuesParsed",F.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",F.INIT_PTS_FOUND="hlsInitPtsFound",F.FRAG_LOADING="hlsFragLoading",F.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",F.FRAG_LOADED="hlsFragLoaded",F.FRAG_DECRYPTED="hlsFragDecrypted",F.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",F.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",F.FRAG_PARSING_METADATA="hlsFragParsingMetadata",F.FRAG_PARSED="hlsFragParsed",F.FRAG_BUFFERED="hlsFragBuffered",F.FRAG_CHANGED="hlsFragChanged",F.FPS_DROP="hlsFpsDrop",F.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",F.ERROR="hlsError",F.DESTROYING="hlsDestroying",F.KEY_LOADING="hlsKeyLoading",F.KEY_LOADED="hlsKeyLoaded",F.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",F.BACK_BUFFER_REACHED="hlsBackBufferReached"})(Z||(Z={}))},"./src/hls.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return v});var Z=R("./node_modules/url-toolkit/src/url-toolkit.js"),F=R.n(Z),P=R("./src/loader/playlist-loader.ts"),K=R("./src/loader/key-loader.ts"),j=R("./src/controller/id3-track-controller.ts"),N=R("./src/controller/latency-controller.ts"),D=R("./src/controller/level-controller.ts"),y=R("./src/controller/fragment-tracker.ts"),A=R("./src/controller/stream-controller.ts"),k=R("./src/is-supported.ts"),T=R("./src/utils/logger.ts"),C=R("./src/config.ts"),b=R("./node_modules/eventemitter3/index.js"),u=R.n(b),a=R("./src/events.ts"),l=R("./src/errors.ts");function d(m,L){for(var x=0;x<L.length;x++){var p=L[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(m,p.key,p)}}function _(m,L,x){return L&&d(m.prototype,L),x&&d(m,x),m}var v=function(){m.isSupported=function(){return Object(k.isSupported)()};function m(x){x===void 0&&(x={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var p=this.config=Object(C.mergeConfig)(m.DefaultConfig,x);this.userConfig=x,Object(T.enableLogs)(p.debug),this._autoLevelCapping=-1,p.progressive&&Object(C.enableStreamingMode)(p);var f=p.abrController,h=p.bufferController,o=p.capLevelController,E=p.fpsController,g=this.abrController=new f(this),S=this.bufferController=new h(this),M=this.capLevelController=new o(this),U=new E(this),G=new P.default(this),V=new K.default(this),O=new j.default(this),I=this.levelController=new D.default(this),X=new y.FragmentTracker(this),q=this.streamController=new A.default(this,X);M.setStreamController(q),U.setStreamController(q);var oe=[I,q];this.networkControllers=oe;var ce=[G,V,g,S,M,U,O,X];this.audioTrackController=this.createController(p.audioTrackController,null,oe),this.createController(p.audioStreamController,X,oe),this.subtitleTrackController=this.createController(p.subtitleTrackController,null,oe),this.createController(p.subtitleStreamController,X,oe),this.createController(p.timelineController,null,ce),this.emeController=this.createController(p.emeController,null,ce),this.cmcdController=this.createController(p.cmcdController,null,ce),this.latencyController=this.createController(N.default,null,ce),this.coreComponents=ce}var L=m.prototype;return L.createController=function(p,f,h){if(p){var o=f?new p(this,f):new p(this);return h&&h.push(o),o}return null},L.on=function(p,f,h){h===void 0&&(h=this),this._emitter.on(p,f,h)},L.once=function(p,f,h){h===void 0&&(h=this),this._emitter.once(p,f,h)},L.removeAllListeners=function(p){this._emitter.removeAllListeners(p)},L.off=function(p,f,h,o){h===void 0&&(h=this),this._emitter.off(p,f,h,o)},L.listeners=function(p){return this._emitter.listeners(p)},L.emit=function(p,f,h){return this._emitter.emit(p,f,h)},L.trigger=function(p,f){if(this.config.debug)return this.emit(p,p,f);try{return this.emit(p,p,f)}catch(h){T.logger.error("An internal error happened while handling event "+p+'. Error message: "'+h.message+'". Here is a stacktrace:',h),this.trigger(a.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:p,error:h})}return!1},L.listenerCount=function(p){return this._emitter.listenerCount(p)},L.destroy=function(){T.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(p){return p.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(p){return p.destroy()}),this.coreComponents.length=0},L.attachMedia=function(p){T.logger.log("attachMedia"),this._media=p,this.trigger(a.Events.MEDIA_ATTACHING,{media:p})},L.detachMedia=function(){T.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(p){this.stopLoad();var f=this.media,h=this.url,o=this.url=Z.buildAbsoluteURL(self.location.href,p,{alwaysNormalize:!0});T.logger.log("loadSource:"+o),f&&h&&h!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(f)),this.trigger(a.Events.MANIFEST_LOADING,{url:p})},L.startLoad=function(p){p===void 0&&(p=-1),T.logger.log("startLoad("+p+")"),this.networkControllers.forEach(function(f){f.startLoad(p)})},L.stopLoad=function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(p){p.stopLoad()})},L.swapAudioCodec=function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},L.recoverMediaError=function(){T.logger.log("recoverMediaError");var p=this._media;this.detachMedia(),p&&this.attachMedia(p)},L.removeLevel=function(p,f){f===void 0&&(f=0),this.levelController.removeLevel(p,f)},_(m,[{key:"levels",get:function(){var p=this.levelController.levels;return p||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(p){T.logger.log("set currentLevel:"+p),this.loadLevel=p,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(p){T.logger.log("set nextLevel:"+p),this.levelController.manualLevel=p,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(p){T.logger.log("set loadLevel:"+p),this.levelController.manualLevel=p}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(p){this.levelController.nextLoadLevel=p}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(p){T.logger.log("set firstLevel:"+p),this.levelController.firstLevel=p}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(p){T.logger.log("set startLevel:"+p),p!==-1&&(p=Math.max(p,this.minAutoLevel)),this.levelController.startLevel=p}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(p){var f=!!p;f!==this.config.capLevelToPlayerSize&&(f?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=f)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(p){this._autoLevelCapping!==p&&(T.logger.log("set autoLevelCapping:"+p),this._autoLevelCapping=p)}},{key:"bandwidthEstimate",get:function(){var p=this.abrController.bwEstimator;return p?p.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var p=this.levels,f=this.config.minAutoBitrate;if(!p)return 0;for(var h=p.length,o=0;o<h;o++)if(p[o].maxBitrate>f)return o;return 0}},{key:"maxAutoLevel",get:function(){var p=this.levels,f=this.autoLevelCapping,h;return f===-1&&p&&p.length?h=p.length-1:h=f,h}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(p){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,p)}},{key:"audioTracks",get:function(){var p=this.audioTrackController;return p?p.audioTracks:[]}},{key:"audioTrack",get:function(){var p=this.audioTrackController;return p?p.audioTrack:-1},set:function(p){var f=this.audioTrackController;f&&(f.audioTrack=p)}},{key:"subtitleTracks",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var p=this.subtitleTrackController;return p?p.subtitleTrack:-1},set:function(p){var f=this.subtitleTrackController;f&&(f.subtitleTrack=p)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var p=this.subtitleTrackController;return p?p.subtitleDisplay:!1},set:function(p){var f=this.subtitleTrackController;f&&(f.subtitleDisplay=p)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(p){this.config.lowLatencyMode=p}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return m.defaultConfig?m.defaultConfig:C.hlsDefaultConfig},set:function(p){m.defaultConfig=p}}]),m}();v.defaultConfig=void 0},"./src/is-supported.ts":function(le,$,R){"use strict";R.r($),R.d($,"isSupported",function(){return P}),R.d($,"changeTypeSupported",function(){return K});var Z=R("./src/utils/mediasource-helper.ts");function F(){return self.SourceBuffer||self.WebKitSourceBuffer}function P(){var j=Object(Z.getMediaSource)();if(!j)return!1;var N=F(),D=j&&typeof j.isTypeSupported=="function"&&j.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!N||N.prototype&&typeof N.prototype.appendBuffer=="function"&&typeof N.prototype.remove=="function";return!!D&&!!y}function K(){var j,N=F();return typeof(N==null||((j=N.prototype)===null||j===void 0)?void 0:j.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return T}),R.d($,"LoadError",function(){return b});var Z=R("./src/polyfills/number.ts"),F=R("./src/errors.ts");function P(u,a){u.prototype=Object.create(a.prototype),u.prototype.constructor=u,y(u,a)}function K(u){var a=typeof Map=="function"?new Map:void 0;return K=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 a!="undefined"){if(a.has(d))return a.get(d);a.set(d,_)}function _(){return j(d,arguments,A(this).constructor)}return _.prototype=Object.create(d.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),y(_,d)},K(u)}function j(u,a,l){return N()?j=Reflect.construct:j=function(_,v,m){var L=[null];L.push.apply(L,v);var x=Function.bind.apply(_,L),p=new x;return m&&y(p,m.prototype),p},j.apply(null,arguments)}function N(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(u){return!1}}function D(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,a){return y=Object.setPrototypeOf||function(d,_){return d.__proto__=_,d},y(u,a)}function A(u){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},A(u)}var k=Math.pow(2,17),T=function(){function u(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var a=u.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(d,_){var v=this,m=d.url;if(!m)return Promise.reject(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,networkDetails:null},"Fragment does not have a "+(m?"part list":"url")));this.abort();var L=this.config,x=L.fLoader,p=L.loader;return new Promise(function(f,h){v.loader&&v.loader.destroy();var o=v.loader=d.loader=x?new x(L):new p(L),E=C(d),g={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};d.stats=o.stats,o.load(E,g,{onSuccess:function(M,U,G,V){v.resetLoader(d,o),f({frag:d,part:null,payload:M.data,networkDetails:V})},onError:function(M,U,G){v.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:M,networkDetails:G}))},onAbort:function(M,U,G){v.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:G}))},onTimeout:function(M,U,G){v.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:G}))},onProgress:function(M,U,G,V){_&&_({frag:d,part:null,payload:G,networkDetails:V})}})})},a.loadPart=function(d,_,v){var m=this;this.abort();var L=this.config,x=L.fLoader,p=L.loader;return new Promise(function(f,h){m.loader&&m.loader.destroy();var o=m.loader=d.loader=x?new x(L):new p(L),E=C(d,_),g={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:k};_.stats=o.stats,o.load(E,g,{onSuccess:function(M,U,G,V){m.resetLoader(d,o),m.updateStatsFromPart(d,_);var O={frag:d,part:_,payload:M.data,networkDetails:V};v(O),f(O)},onError:function(M,U,G){m.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:_,response:M,networkDetails:G}))},onAbort:function(M,U,G){d.stats.aborted=_.stats.aborted,m.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:_,networkDetails:G}))},onTimeout:function(M,U,G){m.resetLoader(d,o),h(new b({type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:_,networkDetails:G}))}})})},a.updateStatsFromPart=function(d,_){var v=d.stats,m=_.stats,L=m.total;if(v.loaded+=m.loaded,L){var x=Math.round(d.duration/_.duration),p=Math.min(Math.round(v.loaded/L),x),f=x-p,h=f*Math.round(v.loaded/p);v.total=v.loaded+h}else v.total=Math.max(v.loaded,v.total);var o=v.loading,E=m.loading;o.start?o.first+=E.first-E.start:(o.start=E.start,o.first=E.first),o.end=E.end},a.resetLoader=function(d,_){d.loader=null,this.loader===_&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),_.destroy()},u}();function C(u,a){a===void 0&&(a=null);var l=a||u,d={frag:u,part:a,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},_=l.byteRangeStartOffset,v=l.byteRangeEndOffset;return Object(Z.isFiniteNumber)(_)&&Object(Z.isFiniteNumber)(v)&&(d.rangeStart=_,d.rangeEnd=v),d}var b=function(u){P(a,u);function a(l){for(var d,_=arguments.length,v=new Array(_>1?_-1:0),m=1;m<_;m++)v[m-1]=arguments[m];return d=u.call.apply(u,[this].concat(v))||this,d.data=void 0,d.data=l,d}return a}(K(Error))},"./src/loader/fragment.ts":function(le,$,R){"use strict";R.r($),R.d($,"ElementaryStreamTypes",function(){return T}),R.d($,"BaseSegment",function(){return C}),R.d($,"Fragment",function(){return b}),R.d($,"Part",function(){return u});var Z=R("./src/polyfills/number.ts"),F=R("./node_modules/url-toolkit/src/url-toolkit.js"),P=R.n(F),K=R("./src/utils/logger.ts"),j=R("./src/loader/level-key.ts"),N=R("./src/loader/load-stats.ts");function D(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,y(a,l)}function y(a,l){return y=Object.setPrototypeOf||function(_,v){return _.__proto__=v,_},y(a,l)}function A(a,l){for(var d=0;d<l.length;d++){var _=l[d];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(a,_.key,_)}}function k(a,l,d){return l&&A(a.prototype,l),d&&A(a,d),a}var T;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(T||(T={}));var C=function(){function a(d){var _;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(_={},_[T.AUDIO]=null,_[T.VIDEO]=null,_[T.AUDIOVIDEO]=null,_),this.baseurl=d}var l=a.prototype;return l.setByteRange=function(_,v){var m=_.split("@",2),L=[];m.length===1?L[0]=v?v.byteRangeEndOffset:0:L[0]=parseInt(m[1]),L[1]=parseInt(m[0])+L[0],this._byteRange=L},k(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(F.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(_){this._url=_}}]),a}(),b=function(a){D(l,a);function l(_,v){var m;return m=a.call(this,v)||this,m._decryptdata=null,m.rawProgramDateTime=null,m.programDateTime=null,m.tagList=[],m.duration=0,m.sn=0,m.levelkey=void 0,m.type=void 0,m.loader=null,m.level=-1,m.cc=0,m.startPTS=void 0,m.endPTS=void 0,m.appendedPTS=void 0,m.startDTS=void 0,m.endDTS=void 0,m.start=0,m.deltaPTS=void 0,m.maxStartPTS=void 0,m.minEndPTS=void 0,m.stats=new N.LoadStats,m.urlId=0,m.data=void 0,m.bitrateTest=!1,m.title=null,m.initSegment=null,m.type=_,m}var d=l.prototype;return d.createInitializationVector=function(v){for(var m=new Uint8Array(16),L=12;L<16;L++)m[L]=v>>8*(15-L)&255;return m},d.setDecryptDataFromLevelKey=function(v,m){var L=v;return(v==null?void 0:v.method)==="AES-128"&&v.uri&&!v.iv&&(L=j.LevelKey.fromURI(v.uri),L.method=v.method,L.iv=this.createInitializationVector(m),L.keyFormat="identity"),L},d.setElementaryStreamInfo=function(v,m,L,x,p,f){f===void 0&&(f=!1);var h=this.elementaryStreams,o=h[v];if(!o){h[v]={startPTS:m,endPTS:L,startDTS:x,endDTS:p,partial:f};return}o.startPTS=Math.min(o.startPTS,m),o.endPTS=Math.max(o.endPTS,L),o.startDTS=Math.min(o.startDTS,x),o.endDTS=Math.max(o.endDTS,p)},d.clearElementaryStreamInfo=function(){var v=this.elementaryStreams;v[T.AUDIO]=null,v[T.VIDEO]=null,v[T.AUDIOVIDEO]=null},k(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var v=this.sn;typeof v!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&K.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),v=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,v)}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 v=Object(Z.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+v*1e3}},{key:"encrypted",get:function(){var v;return!!((v=this.decryptdata)!==null&&v!==void 0&&v.keyFormat&&this.decryptdata.uri)}}]),l}(C),u=function(a){D(l,a);function l(d,_,v,m,L){var x;x=a.call(this,v)||this,x.fragOffset=0,x.duration=0,x.gap=!1,x.independent=!1,x.relurl=void 0,x.fragment=void 0,x.index=void 0,x.stats=new N.LoadStats,x.duration=d.decimalFloatingPoint("DURATION"),x.gap=d.bool("GAP"),x.independent=d.bool("INDEPENDENT"),x.relurl=d.enumeratedString("URI"),x.fragment=_,x.index=m;var p=d.enumeratedString("BYTERANGE");return p&&x.setByteRange(p,L),L&&(x.fragOffset=L.fragOffset+L.duration),x}return k(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var _=this.elementaryStreams;return!!(_.audio||_.video||_.audiovideo)}}]),l}(C)},"./src/loader/key-loader.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return K});var Z=R("./src/events.ts"),F=R("./src/errors.ts"),P=R("./src/utils/logger.ts"),K=function(){function j(D){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=D,this._registerListeners()}var N=j.prototype;return N._registerListeners=function(){this.hls.on(Z.Events.KEY_LOADING,this.onKeyLoading,this)},N._unregisterListeners=function(){this.hls.off(Z.Events.KEY_LOADING,this.onKeyLoading)},N.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var A=this.loaders[y];A&&A.destroy()}this.loaders={}},N.onKeyLoading=function(y,A){var k=A.frag,T=k.type,C=this.loaders[T];if(!k.decryptdata){P.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var b=k.decryptdata.uri;if(b!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(C&&(P.logger.warn("abort previous key loader for type:"+T),C.abort()),!b){P.logger.warn("key uri is falsy");return}var a=u.loader,l=k.loader=this.loaders[T]=new a(u);this.decrypturl=b,this.decryptkey=null;var d={url:b,frag:k,responseType:"arraybuffer"},_={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(d,_,v)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(Z.Events.KEY_LOADED,{frag:k}))},N.loadsuccess=function(y,A,k){var T=k.frag;if(!T.decryptdata){P.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(y.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(Z.Events.KEY_LOADED,{frag:T})},N.loaderror=function(y,A){var k=A.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:y})},N.loadtimeout=function(y,A){var k=A.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(Z.Events.ERROR,{type:F.ErrorTypes.NETWORK_ERROR,details:F.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},j}()},"./src/loader/level-details.ts":function(le,$,R){"use strict";R.r($),R.d($,"LevelDetails",function(){return j});var Z=R("./src/polyfills/number.ts");function F(N,D){for(var y=0;y<D.length;y++){var A=D[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(N,A.key,A)}}function P(N,D,y){return D&&F(N.prototype,D),y&&F(N,y),N}var K=10,j=function(){function N(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=N.prototype;return D.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var k=this.lastPartSn-A.lastPartSn,T=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!T||!!k,this.advanced=this.endSN>A.endSN||k>0||k===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},P(N,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(Z.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||K}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var k=this.driftEnd-this.driftStart;return k*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),N}()},"./src/loader/level-key.ts":function(le,$,R){"use strict";R.r($),R.d($,"LevelKey",function(){return j});var Z=R("./node_modules/url-toolkit/src/url-toolkit.js"),F=R.n(Z);function P(N,D){for(var y=0;y<D.length;y++){var A=D[y];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(N,A.key,A)}}function K(N,D,y){return D&&P(N.prototype,D),y&&P(N,y),N}var j=function(){N.fromURL=function(y,A){return new N(y,A)},N.fromURI=function(y){return new N(y)};function N(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 K(N,[{key:"uri",get:function(){return this._uri}}]),N}()},"./src/loader/load-stats.ts":function(le,$,R){"use strict";R.r($),R.d($,"LoadStats",function(){return Z});var Z=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return l});var Z=R("./src/polyfills/number.ts"),F=R("./node_modules/url-toolkit/src/url-toolkit.js"),P=R.n(F),K=R("./src/loader/fragment.ts"),j=R("./src/loader/level-details.ts"),N=R("./src/loader/level-key.ts"),D=R("./src/utils/attr-list.ts"),y=R("./src/utils/logger.ts"),A=R("./src/utils/codecs.ts"),k=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,T=/#EXT-X-MEDIA:(.*)/g,C=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),b=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function a(L){var x,p;return u.test((x=(p=F.parseURL(L))===null||p===void 0?void 0:p.path)!=null?x:"")}var l=function(){function L(){}return L.findGroup=function(p,f){for(var h=0;h<p.length;h++){var o=p[h];if(o.id===f)return o}},L.convertAVC1ToAVCOTI=function(p){var f=p.split(".");if(f.length>2){var h=f.shift()+".";return h+=parseInt(f.shift()).toString(16),h+=("000"+parseInt(f.shift()).toString(16)).substr(-4),h}return p},L.resolve=function(p,f){return F.buildAbsoluteURL(f,p,{alwaysNormalize:!0})},L.parseMasterPlaylist=function(p,f){var h=[],o={},E=!1;k.lastIndex=0;for(var g;(g=k.exec(p))!=null;)if(g[1]){var S=new D.AttrList(g[1]),M={attrs:S,bitrate:S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),name:S.NAME,url:L.resolve(g[2],f)},U=S.decimalResolution("RESOLUTION");U&&(M.width=U.width,M.height=U.height),d((S.CODECS||"").split(/[ ,]+/).filter(function(V){return V}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=L.convertAVC1ToAVCOTI(M.videoCodec)),h.push(M)}else if(g[3]){var G=new D.AttrList(g[3]);G["DATA-ID"]&&(E=!0,o[G["DATA-ID"]]=G)}return{levels:h,sessionData:E?o:null}},L.parseMasterPlaylistMedia=function(p,f,h,o){o===void 0&&(o=[]);var E,g=[],S=0;for(T.lastIndex=0;(E=T.exec(p))!==null;){var M=new D.AttrList(E[1]);if(M.TYPE===h){var U={attrs:M,bitrate:0,id:S++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:h,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?L.resolve(M.URI,f):""};if(o.length){var G=L.findGroup(o,U.groupId)||o[0];_(U,G,"audioCodec"),_(U,G,"textCodec")}g.push(U)}}return g},L.parseLevelPlaylist=function(p,f,h,o,E){var g=new j.LevelDetails(f),S=g.fragments,M=null,U=0,G=0,V=0,O=0,I=null,X=new K.Fragment(o,f),q,oe,ce,Le=-1,Ee=!1;for(C.lastIndex=0,g.m3u8=p;(q=C.exec(p))!==null;){Ee&&(Ee=!1,X=new K.Fragment(o,f),X.start=V,X.sn=U,X.cc=O,X.level=h,M&&(X.initSegment=M,X.rawProgramDateTime=M.rawProgramDateTime));var we=q[1];if(we){X.duration=parseFloat(we);var Te=(" "+q[2]).slice(1);X.title=Te||null,X.tagList.push(Te?["INF",we,Te]:["INF",we])}else if(q[3])Object(Z.isFiniteNumber)(X.duration)&&(X.start=V,ce&&(X.levelkey=ce),X.sn=U,X.level=h,X.cc=O,X.urlId=E,S.push(X),X.relurl=(" "+q[3]).slice(1),m(X,I),I=X,V+=X.duration,U++,G=0,Ee=!0);else if(q[4]){var ye=(" "+q[4]).slice(1);I?X.setByteRange(ye,I):X.setByteRange(ye)}else if(q[5])X.rawProgramDateTime=(" "+q[5]).slice(1),X.tagList.push(["PROGRAM-DATE-TIME",X.rawProgramDateTime]),Le===-1&&(Le=S.length);else{if(q=q[0].match(b),!q){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(oe=1;oe<q.length&&!(typeof q[oe]!="undefined");oe++);var fe=(" "+q[oe]).slice(1),se=(" "+q[oe+1]).slice(1),te=q[oe+2]?(" "+q[oe+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":g.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":U=g.startSN=parseInt(se);break;case"SKIP":{var ue=new D.AttrList(se),ne=ue.decimalInteger("SKIPPED-SEGMENTS");if(Object(Z.isFiniteNumber)(ne)){g.skippedSegments=ne;for(var _e=ne;_e--;)S.unshift(null);U+=ne}var Re=ue.enumeratedString("RECENTLY-REMOVED-DATERANGES");Re&&(g.recentlyRemovedDateranges=Re.split(" "));break}case"TARGETDURATION":g.targetduration=parseFloat(se);break;case"VERSION":g.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":g.live=!1;break;case"#":(se||te)&&X.tagList.push(te?[se,te]:[se]);break;case"DIS":O++;case"GAP":X.tagList.push([fe]);break;case"BITRATE":X.tagList.push([fe,se]);break;case"DISCONTINUITY-SEQ":O=parseInt(se);break;case"KEY":{var xe,ke=new D.AttrList(se),Ne=ke.enumeratedString("METHOD"),He=ke.URI,Be=ke.hexadecimalInteger("IV"),Me=ke.enumeratedString("KEYFORMATVERSIONS"),Oe=ke.enumeratedString("KEYID"),Ye=(xe=ke.enumeratedString("KEYFORMAT"))!=null?xe:"identity",Je=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Je.indexOf(Ye)>-1){y.logger.warn("Keyformat "+Ye+" is not supported from the manifest");continue}else if(Ye!=="identity")continue;Ne&&(ce=N.LevelKey.fromURL(f,He),He&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ne)>=0&&(ce.method=Ne,ce.keyFormat=Ye,Oe&&(ce.keyID=Oe),Me&&(ce.keyFormatVersions=Me),ce.iv=Be));break}case"START":{var Ve=new D.AttrList(se),je=Ve.decimalFloatingPoint("TIME-OFFSET");Object(Z.isFiniteNumber)(je)&&(g.startTimeOffset=je);break}case"MAP":{var rt=new D.AttrList(se);X.relurl=rt.URI,rt.BYTERANGE&&X.setByteRange(rt.BYTERANGE),X.level=h,X.sn="initSegment",ce&&(X.levelkey=ce),X.initSegment=null,M=X,Ee=!0;break}case"SERVER-CONTROL":{var Qe=new D.AttrList(se);g.canBlockReload=Qe.bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=Qe.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&Qe.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=Qe.optionalFloat("PART-HOLD-BACK",0),g.holdBack=Qe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var tt=new D.AttrList(se);g.partTarget=tt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Pe=g.partList;Pe||(Pe=g.partList=[]);var lt=G>0?Pe[Pe.length-1]:void 0,at=G++,Fe=new K.Part(new D.AttrList(se),X,f,at,lt);Pe.push(Fe),X.duration+=Fe.duration;break}case"PRELOAD-HINT":{var Xe=new D.AttrList(se);g.preloadHint=Xe;break}case"RENDITION-REPORT":{var Ce=new D.AttrList(se);g.renditionReports=g.renditionReports||[],g.renditionReports.push(Ce);break}default:y.logger.warn("line parsed but not handled: "+q);break}}}I&&!I.relurl?(S.pop(),V-=I.duration,g.partList&&(g.fragmentHint=I)):g.partList&&(m(X,I),X.cc=O,g.fragmentHint=X);var ve=S.length,be=S[0],ie=S[ve-1];if(V+=g.skippedSegments*g.targetduration,V>0&&ve&&ie){g.averagetargetduration=V/ve;var ae=ie.sn;g.endSN=ae!=="initSegment"?ae:0,be&&(g.startCC=be.cc,be.initSegment||g.fragments.every(function(de){return de.relurl&&a(de.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),X=new K.Fragment(o,f),X.relurl=ie.relurl,X.level=h,X.sn="initSegment",be.initSegment=X,g.needSidxRanges=!0))}else g.endSN=0,g.startCC=0;return g.fragmentHint&&(V+=g.fragmentHint.duration),g.totalduration=V,g.endCC=O,Le>0&&v(S,Le),g},L}();function d(L,x){["video","audio","text"].forEach(function(p){var f=L.filter(function(o){return Object(A.isCodecType)(o,p)});if(f.length){var h=f.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});x[p+"Codec"]=h.length>0?h[0]:f[0],L=L.filter(function(o){return f.indexOf(o)===-1})}}),x.unknownCodecs=L}function _(L,x,p){var f=x[p];f&&(L[p]=f)}function v(L,x){for(var p=L[x],f=x;f--;){var h=L[f];if(!h)return;h.programDateTime=p.programDateTime-h.duration*1e3,p=h}}function m(L,x){L.rawProgramDateTime?L.programDateTime=Date.parse(L.rawProgramDateTime):x!=null&&x.programDateTime&&(L.programDateTime=x.endProgramDateTime),Object(Z.isFiniteNumber)(L.programDateTime)||(L.programDateTime=null,L.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/polyfills/number.ts"),F=R("./src/events.ts"),P=R("./src/errors.ts"),K=R("./src/utils/logger.ts"),j=R("./src/utils/mp4-tools.ts"),N=R("./src/loader/m3u8-parser.ts"),D=R("./src/types/loader.ts"),y=R("./src/utils/attr-list.ts");function A(C){var b=C.type;switch(b){case D.PlaylistContextType.AUDIO_TRACK:return D.PlaylistLevelType.AUDIO;case D.PlaylistContextType.SUBTITLE_TRACK:return D.PlaylistLevelType.SUBTITLE;default:return D.PlaylistLevelType.MAIN}}function k(C,b){var u=C.url;return(u===void 0||u.indexOf("data:")===0)&&(u=b.url),u}var T=function(){function C(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var b=C.prototype;return b.registerListeners=function(){var a=this.hls;a.on(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(F.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.unregisterListeners=function(){var a=this.hls;a.off(F.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(F.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(F.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(F.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.createInternalLoader=function(a){var l=this.hls.config,d=l.pLoader,_=l.loader,v=d||_,m=new v(l);return a.loader=m,this.loaders[a.type]=m,m},b.getInternalLoader=function(a){return this.loaders[a.type]},b.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},b.destroyInternalLoaders=function(){for(var a in this.loaders){var l=this.loaders[a];l&&l.destroy(),this.resetInternalLoader(a)}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onManifestLoading=function(a,l){var d=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:D.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},b.onLevelLoading=function(a,l){var d=l.id,_=l.level,v=l.url,m=l.deliveryDirectives;this.load({id:d,groupId:null,level:_,responseType:"text",type:D.PlaylistContextType.LEVEL,url:v,deliveryDirectives:m})},b.onAudioTrackLoading=function(a,l){var d=l.id,_=l.groupId,v=l.url,m=l.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.AUDIO_TRACK,url:v,deliveryDirectives:m})},b.onSubtitleTrackLoading=function(a,l){var d=l.id,_=l.groupId,v=l.url,m=l.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.SUBTITLE_TRACK,url:v,deliveryDirectives:m})},b.load=function(a){var l,d=this.hls.config,_=this.getInternalLoader(a);if(_){var v=_.context;if(v&&v.url===a.url){K.logger.trace("[playlist-loader]: playlist request ongoing");return}K.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),_.abort()}var m,L,x,p;switch(a.type){case D.PlaylistContextType.MANIFEST:m=d.manifestLoadingMaxRetry,L=d.manifestLoadingTimeOut,x=d.manifestLoadingRetryDelay,p=d.manifestLoadingMaxRetryTimeout;break;case D.PlaylistContextType.LEVEL:case D.PlaylistContextType.AUDIO_TRACK:case D.PlaylistContextType.SUBTITLE_TRACK:m=0,L=d.levelLoadingTimeOut;break;default:m=d.levelLoadingMaxRetry,L=d.levelLoadingTimeOut,x=d.levelLoadingRetryDelay,p=d.levelLoadingMaxRetryTimeout;break}if(_=this.createInternalLoader(a),(l=a.deliveryDirectives)!==null&&l!==void 0&&l.part){var f;if(a.type===D.PlaylistContextType.LEVEL&&a.level!==null?f=this.hls.levels[a.level].details:a.type===D.PlaylistContextType.AUDIO_TRACK&&a.id!==null?f=this.hls.audioTracks[a.id].details:a.type===D.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(f=this.hls.subtitleTracks[a.id].details),f){var h=f.partTarget,o=f.targetduration;h&&o&&(L=Math.min(Math.max(h*3,o*.8)*1e3,L))}}var E={timeout:L,maxRetry:m,retryDelay:x,maxRetryDelay:p,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};_.load(a,E,g)},b.loadsuccess=function(a,l,d,_){if(_===void 0&&(_=null),d.isSidxRequest){this.handleSidxRequest(a,d),this.handlePlaylistLoaded(a,l,d,_);return}this.resetInternalLoader(d.type);var v=a.data;if(v.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,d,"no EXTM3U delimiter",_);return}l.parsing.start=performance.now(),v.indexOf("#EXTINF:")>0||v.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,l,d,_):this.handleMasterPlaylist(a,l,d,_)},b.loaderror=function(a,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!1,a)},b.loadtimeout=function(a,l,d){d===void 0&&(d=null),this.handleNetworkError(l,d,!0)},b.handleMasterPlaylist=function(a,l,d,_){var v=this.hls,m=a.data,L=k(a,d),x=N.default.parseMasterPlaylist(m,L),p=x.levels,f=x.sessionData;if(!p.length){this.handleManifestParsingError(a,d,"no level found in manifest",_);return}var h=p.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),o=p.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),E=N.default.parseMasterPlaylistMedia(m,L,"AUDIO",h),g=N.default.parseMasterPlaylistMedia(m,L,"SUBTITLES",o),S=N.default.parseMasterPlaylistMedia(m,L,"CLOSED-CAPTIONS");if(E.length){var M=E.some(function(U){return!U.url});!M&&p[0].audioCodec&&!p[0].attrs.AUDIO&&(K.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}v.trigger(F.Events.MANIFEST_LOADED,{levels:p,audioTracks:E,subtitles:g,captions:S,url:L,stats:l,networkDetails:_,sessionData:f})},b.handleTrackOrLevelPlaylist=function(a,l,d,_){var v=this.hls,m=d.id,L=d.level,x=d.type,p=k(a,d),f=Object(Z.isFiniteNumber)(m)?m:0,h=Object(Z.isFiniteNumber)(L)?L:f,o=A(d),E=N.default.parseLevelPlaylist(a.data,p,h,o,f);if(!E.fragments.length){v.trigger(F.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(x===D.PlaylistContextType.MANIFEST){var g={attrs:new y.AttrList({}),bitrate:0,details:E,name:"",url:p};v.trigger(F.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:p,stats:l,networkDetails:_,sessionData:null})}if(l.parsing.end=performance.now(),E.needSidxRanges){var S,M=(S=E.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:M,isSidxRequest:!0,type:x,level:L,levelDetails:E,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=E,this.handlePlaylistLoaded(a,l,d,_)},b.handleSidxRequest=function(a,l){var d=Object(j.parseSegmentIndex)(new Uint8Array(a.data));if(!d)return;var _=d.references,v=l.levelDetails;_.forEach(function(m,L){var x=m.info,p=v.fragments[L];p.byteRange.length===0&&p.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),p.initSegment&&p.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},b.handleManifestParsingError=function(a,l,d,_){this.hls.trigger(F.Events.ERROR,{type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===D.PlaylistContextType.MANIFEST,url:a.url,reason:d,response:a,context:l,networkDetails:_})},b.handleNetworkError=function(a,l,d,_){d===void 0&&(d=!1),K.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var v=P.ErrorDetails.UNKNOWN,m=!1,L=this.getInternalLoader(a);switch(a.type){case D.PlaylistContextType.MANIFEST:v=d?P.ErrorDetails.MANIFEST_LOAD_TIMEOUT:P.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case D.PlaylistContextType.LEVEL:v=d?P.ErrorDetails.LEVEL_LOAD_TIMEOUT:P.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.AUDIO_TRACK:v=d?P.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:P.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.SUBTITLE_TRACK:v=d?P.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:P.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}L&&this.resetInternalLoader(a.type);var x={type:P.ErrorTypes.NETWORK_ERROR,details:v,fatal:m,url:a.url,loader:L,context:a,networkDetails:l};_&&(x.response=_),this.hls.trigger(F.Events.ERROR,x)},b.handlePlaylistLoaded=function(a,l,d,_){var v=d.type,m=d.level,L=d.id,x=d.groupId,p=d.loader,f=d.levelDetails,h=d.deliveryDirectives;if(!(f!=null&&f.targetduration)){this.handleManifestParsingError(a,d,"invalid target duration",_);return}if(!p)return;f.live&&(p.getCacheAge&&(f.ageHeader=p.getCacheAge()||0),(!p.getCacheAge||isNaN(f.ageHeader))&&(f.ageHeader=0));switch(v){case D.PlaylistContextType.MANIFEST:case D.PlaylistContextType.LEVEL:this.hls.trigger(F.Events.LEVEL_LOADED,{details:f,level:m||0,id:L||0,stats:l,networkDetails:_,deliveryDirectives:h});break;case D.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(F.Events.AUDIO_TRACK_LOADED,{details:f,id:L||0,groupId:x||"",stats:l,networkDetails:_,deliveryDirectives:h});break;case D.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(F.Events.SUBTITLE_TRACK_LOADED,{details:f,id:L||0,groupId:x||"",stats:l,networkDetails:_,deliveryDirectives:h});break}},C}();$.default=T},"./src/polyfills/number.ts":function(le,$,R){"use strict";R.r($),R.d($,"isFiniteNumber",function(){return Z}),R.d($,"MAX_SAFE_INTEGER",function(){return F});var Z=Number.isFinite||function(P){return typeof P=="number"&&isFinite(P)},F=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(le,$,R){"use strict";R.r($);var Z=function(){function F(){}return F.getSilentFrame=function(K,j){switch(K){case"mp4a.40.2":if(j===1)return new Uint8Array([0,200,0,128,35,128]);if(j===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(j===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(j===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(j===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(j===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(j===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(j===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(j===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},F}();$.default=Z},"./src/remux/mp4-generator.ts":function(le,$,R){"use strict";R.r($);var Z=Math.pow(2,32)-1,F=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 j;for(j in P.types)P.types.hasOwnProperty(j)&&(P.types[j]=[j.charCodeAt(0),j.charCodeAt(1),j.charCodeAt(2),j.charCodeAt(3)]);var N=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),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:N,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]),A=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=A,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var k=new Uint8Array([105,115,111,109]),T=new Uint8Array([97,118,99,49]),C=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,k,C,k,T),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,y))},P.box=function(j){for(var N=8,D=arguments.length,y=new Array(D>1?D-1:0),A=1;A<D;A++)y[A-1]=arguments[A];for(var k=y.length,T=k;k--;)N+=y[k].byteLength;var C=new Uint8Array(N);for(C[0]=N>>24&255,C[1]=N>>16&255,C[2]=N>>8&255,C[3]=N&255,C.set(j,4),k=0,N=8;k<T;k++)C.set(y[k],N),N+=y[k].byteLength;return C},P.hdlr=function(j){return P.box(P.types.hdlr,P.HDLR_TYPES[j])},P.mdat=function(j){return P.box(P.types.mdat,j)},P.mdhd=function(j,N){N*=j;var D=Math.floor(N/(Z+1)),y=Math.floor(N%(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,j>>24&255,j>>16&255,j>>8&255,j&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(j){return P.box(P.types.mdia,P.mdhd(j.timescale,j.duration),P.hdlr(j.type),P.minf(j))},P.mfhd=function(j){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,j>>24,j>>16&255,j>>8&255,j&255]))},P.minf=function(j){return j.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(j)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(j))},P.moof=function(j,N,D){return P.box(P.types.moof,P.mfhd(j),P.traf(D,N))},P.moov=function(j){for(var N=j.length,D=[];N--;)D[N]=P.trak(j[N]);return P.box.apply(null,[P.types.moov,P.mvhd(j[0].timescale,j[0].duration)].concat(D).concat(P.mvex(j)))},P.mvex=function(j){for(var N=j.length,D=[];N--;)D[N]=P.trex(j[N]);return P.box.apply(null,[P.types.mvex].concat(D))},P.mvhd=function(j,N){N*=j;var D=Math.floor(N/(Z+1)),y=Math.floor(N%(Z+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,j>>24&255,j>>16&255,j>>8&255,j&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,A)},P.sdtp=function(j){var N=j.samples||[],D=new Uint8Array(4+N.length),y,A;for(y=0;y<N.length;y++)A=N[y].flags,D[y+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return P.box(P.types.sdtp,D)},P.stbl=function(j){return P.box(P.types.stbl,P.stsd(j),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(j){var N=[],D=[],y,A,k;for(y=0;y<j.sps.length;y++)A=j.sps[y],k=A.byteLength,N.push(k>>>8&255),N.push(k&255),N=N.concat(Array.prototype.slice.call(A));for(y=0;y<j.pps.length;y++)A=j.pps[y],k=A.byteLength,D.push(k>>>8&255),D.push(k&255),D=D.concat(Array.prototype.slice.call(A));var T=P.box(P.types.avcC,new Uint8Array([1,N[3],N[4],N[5],252|3,224|j.sps.length].concat(N).concat([j.pps.length]).concat(D))),C=j.width,b=j.height,u=j.pixelRatio[0],a=j.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,C>>8&255,C&255,b>>8&255,b&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),T,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255])))},P.esds=function(j){var N=j.config.length;return new Uint8Array([0,0,0,0,3,23+N,0,1,0,4,15+N,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([N]).concat(j.config).concat([6,1,2]))},P.mp4a=function(j){var N=j.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,j.channelCount,0,16,0,0,0,0,N>>8&255,N&255,0,0]),P.box(P.types.esds,P.esds(j)))},P.mp3=function(j){var N=j.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,j.channelCount,0,16,0,0,0,0,N>>8&255,N&255,0,0]))},P.stsd=function(j){return j.type==="audio"?!j.isAAC&&j.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(j)):P.box(P.types.stsd,P.STSD,P.mp4a(j)):P.box(P.types.stsd,P.STSD,P.avc1(j))},P.tkhd=function(j){var N=j.id,D=j.duration*j.timescale,y=j.width,A=j.height,k=Math.floor(D/(Z+1)),T=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,N>>24&255,N>>16&255,N>>8&255,N&255,0,0,0,0,k>>24,k>>16&255,k>>8&255,k&255,T>>24,T>>16&255,T>>8&255,T&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,A>>8&255,A&255,0,0]))},P.traf=function(j,N){var D=P.sdtp(j),y=j.id,A=Math.floor(N/(Z+1)),k=Math.floor(N%(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,A>>24,A>>16&255,A>>8&255,A&255,k>>24,k>>16&255,k>>8&255,k&255])),P.trun(j,D.length+16+20+8+16+8+8),D)},P.trak=function(j){return j.duration=j.duration||4294967295,P.box(P.types.trak,P.tkhd(j),P.mdia(j))},P.trex=function(j){var N=j.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,N>>24,N>>16&255,N>>8&255,N&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(j,N){var D=j.samples||[],y=D.length,A=12+16*y,k=new Uint8Array(A),T,C,b,u,a,l;for(N+=8+A,k.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255],0),T=0;T<y;T++)C=D[T],b=C.duration,u=C.size,a=C.flags,l=C.cts,k.set([b>>>24&255,b>>>16&255,b>>>8&255,b&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,a.degradPrio&240<<8,a.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*T);return P.box(P.types.trun,k)},P.initSegment=function(j){P.types||P.init();var N=P.moov(j),D=new Uint8Array(P.FTYP.byteLength+N.byteLength);return D.set(P.FTYP),D.set(N,P.FTYP.byteLength),D},P}();F.types=void 0,F.HDLR_TYPES=void 0,F.STTS=void 0,F.STSC=void 0,F.STCO=void 0,F.STSZ=void 0,F.VMHD=void 0,F.SMHD=void 0,F.STSD=void 0,F.FTYP=void 0,F.DINF=void 0,$.default=F},"./src/remux/mp4-remuxer.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return l}),R.d($,"normalizePts",function(){return d});var Z=R("./src/polyfills/number.ts"),F=R("./src/remux/aac-helper.ts"),P=R("./src/remux/mp4-generator.ts"),K=R("./src/events.ts"),j=R("./src/errors.ts"),N=R("./src/utils/logger.ts"),D=R("./src/types/loader.ts"),y=R("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(L){for(var x=1;x<arguments.length;x++){var p=arguments[x];for(var f in p)Object.prototype.hasOwnProperty.call(p,f)&&(L[f]=p[f])}return L},A.apply(this,arguments)}var k=10*1e3,T=1024,C=1152,b=null,u=null,a=!1,l=function(){function L(p,f,h,o){if(o===void 0&&(o=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=p,this.config=f,this.typeSupported=h,this.ISGenerated=!1,b===null){var E=navigator.userAgent||"",g=E.match(/Chrome\/(\d+)/i);b=g?parseInt(g[1]):0}if(u===null){var S=navigator.userAgent.match(/Safari\/(\d+)/i);u=S?parseInt(S[1]):0}a=!!b&&b<75||!!u&&u<600}var x=L.prototype;return x.destroy=function(){},x.resetTimeStamp=function(f){N.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},x.resetNextTimestamp=function(){N.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},x.resetInitSegment=function(){N.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},x.getVideoStartPts=function(f){var h=!1,o=f.reduce(function(E,g){var S=g.pts-E;return S<-4294967296?(h=!0,d(E,g.pts)):S>0?E:g.pts},f[0].pts);return h&&N.logger.debug("PTS rollover detected"),o},x.remux=function(f,h,o,E,g,S,M,U){var G,V,O,I,X,q,oe=g,ce=g,Le=f.pid>-1,Ee=h.pid>-1,we=h.samples.length,Te=f.samples.length>0,ye=we>1,fe=(!Le||Te)&&(!Ee||ye)||this.ISGenerated||M;if(fe){this.ISGenerated||(O=this.generateIS(f,h,g));var se=this.isVideoContiguous,te=-1;if(ye&&(te=_(h.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(q=!0,te>0){N.logger.warn("[mp4-remuxer]: Dropped "+te+" out of "+we+" video samples due to a missing keyframe");var ue=this.getVideoStartPts(h.samples);h.samples=h.samples.slice(te),h.dropped+=te,ce+=(h.samples[0].pts-ue)/(h.timescale||9e4)}else te===-1&&(N.logger.warn("[mp4-remuxer]: No keyframe found out of "+we+" video samples"),q=!1);if(this.ISGenerated){if(Te&&ye){var ne=this.getVideoStartPts(h.samples),_e=d(f.samples[0].pts,ne)-ne,Re=_e/h.inputTimeScale;oe+=Math.max(0,Re),ce+=Math.max(0,-Re)}if(Te){if(f.samplerate||(N.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),O=this.generateIS(f,h,g)),V=this.remuxAudio(f,oe,this.isAudioContiguous,S,Ee||ye||U===D.PlaylistLevelType.AUDIO?ce:void 0),ye){var xe=V?V.endPTS-V.startPTS:0;h.inputTimeScale||(N.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),O=this.generateIS(f,h,g)),G=this.remuxVideo(h,ce,se,xe)}}else ye&&(G=this.remuxVideo(h,ce,se,0));G&&(G.firstKeyFrame=te,G.independent=te!==-1)}}return this.ISGenerated&&(o.samples.length&&(X=this.remuxID3(o,g)),E.samples.length&&(I=this.remuxText(E,g))),{audio:V,video:G,initSegment:O,independent:q,text:I,id3:X}},x.generateIS=function(f,h,o){var E=f.samples,g=h.samples,S=this.typeSupported,M={},U=!Object(Z.isFiniteNumber)(this._initPTS),G="audio/mp4",V,O,I;if(U&&(V=O=Infinity),f.config&&E.length&&(f.timescale=f.samplerate,f.isAAC||(S.mpeg?(G="audio/mpeg",f.codec=""):S.mp3&&(f.codec="mp3")),M.audio={id:"audio",container:G,codec:f.codec,initSegment:!f.isAAC&&S.mpeg?new Uint8Array(0):P.default.initSegment([f]),metadata:{channelCount:f.channelCount}},U&&(I=f.inputTimeScale,V=O=E[0].pts-Math.round(I*o))),h.sps&&h.pps&&g.length&&(h.timescale=h.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:h.codec,initSegment:P.default.initSegment([h]),metadata:{width:h.width,height:h.height}},U)){I=h.inputTimeScale;var X=this.getVideoStartPts(g),q=Math.round(I*o);O=Math.min(O,d(g[0].dts,X)-q),V=Math.min(V,X-q)}if(Object.keys(M).length)return this.ISGenerated=!0,U&&(this._initPTS=V,this._initDTS=O),{tracks:M,initPTS:V,timescale:I}},x.remuxVideo=function(f,h,o,E){var g=f.inputTimeScale,S=f.samples,M=[],U=S.length,G=this._initPTS,V=this.nextAvcDts,O=8,I,X,q,oe=Number.POSITIVE_INFINITY,ce=Number.NEGATIVE_INFINITY,Le=0,Ee=!1;if(!o||V===null){var we=h*g,Te=S[0].pts-d(S[0].dts,S[0].pts);V=we-Te}for(var ye=0;ye<U;ye++){var fe=S[ye];if(fe.pts=d(fe.pts-G,V),fe.dts=d(fe.dts-G,V),fe.dts>fe.pts){var se=9e4*.2;Le=Math.max(Math.min(Le,fe.pts-fe.dts),-1*se)}fe.dts<S[ye>0?ye-1:ye].dts&&(Ee=!0)}Ee&&S.sort(function(wt,Ct){var ht=wt.dts-Ct.dts,Ft=wt.pts-Ct.pts;return ht||Ft}),X=S[0].dts,q=S[S.length-1].dts;var te=Math.round((q-X)/(U-1));if(Le<0){if(Le<te*-2){N.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-te,!0)+" ms");for(var ue=Le,ne=0;ne<U;ne++)S[ne].dts=ue=Math.max(ue,S[ne].pts-te),S[ne].pts=Math.max(ue,S[ne].pts)}else{N.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(Le,!0)+" ms to overcome this issue");for(var _e=0;_e<U;_e++)S[_e].dts=S[_e].dts+Le}X=S[0].dts}if(o){var Re=X-V,xe=Re>te,ke=Re<-1;if(xe||ke){xe?N.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms ("+Re+"dts) hole between fragments detected, filling it"):N.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-Re,!0)+" ms ("+Re+"dts) overlapping between fragments detected"),X=V;var Ne=S[0].pts-Re;S[0].dts=X,S[0].pts=Ne,N.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Ne,!0)+"/"+Object(y.toMsFromMpegTsClock)(X,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms")}}a&&(X=Math.max(0,X));for(var He=0,Be=0,Me=0;Me<U;Me++){for(var Oe=S[Me],Ye=Oe.units,Je=Ye.length,Ve=0,je=0;je<Je;je++)Ve+=Ye[je].data.length;Be+=Ve,He+=Je,Oe.length=Ve,Oe.dts=Math.max(Oe.dts,X),Oe.pts=Math.max(Oe.pts,Oe.dts,0),oe=Math.min(Oe.pts,oe),ce=Math.max(Oe.pts,ce)}q=S[U-1].dts;var rt=Be+4*He+8,Qe;try{Qe=new Uint8Array(rt)}catch(wt){this.observer.emit(K.Events.ERROR,K.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:rt,reason:"fail allocating video mdat "+rt});return}var tt=new DataView(Qe.buffer);tt.setUint32(0,rt),Qe.set(P.default.types.mdat,4);for(var Pe=0;Pe<U;Pe++){for(var lt=S[Pe],at=lt.units,Fe=0,Xe=0,Ce=at.length;Xe<Ce;Xe++){var ve=at[Xe],be=ve.data,ie=ve.data.byteLength;tt.setUint32(O,ie),O+=4,Qe.set(be,O),O+=ie,Fe+=4+ie}if(Pe<U-1)I=S[Pe+1].dts-lt.dts;else{var ae=this.config,de=lt.dts-S[Pe>0?Pe-1:Pe].dts;if(ae.stretchShortVideoTrack&&this.nextAudioPts!==null){var me=Math.floor(ae.maxBufferHole*g),Se=(E?oe+E*g:this.nextAudioPts)-lt.pts;Se>me?(I=Se-de,I<0&&(I=de),N.logger.log("[mp4-remuxer]: It is approximately "+Se/90+" ms to the next segment; using duration "+I/90+" ms for the last video frame.")):I=de}else I=de}var Ie=Math.round(lt.pts-lt.dts);M.push(new v(lt.key,I,Fe,Ie))}if(M.length&&b&&b<70){var ze=M[0].flags;ze.dependsOn=2,ze.isNonSync=0}console.assert(I!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=V=q+I,this.isVideoContiguous=!0;var ot=P.default.moof(f.sequenceNumber++,X,A({},f,{samples:M})),gt="video",pt={data1:ot,data2:Qe,startPTS:oe/g,endPTS:(ce+I)/g,startDTS:X/g,endDTS:V/g,type:gt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(Qe.length,"MDAT length must not be zero"),pt},x.remuxAudio=function(f,h,o,E,g){var S=f.inputTimeScale,M=f.samplerate?f.samplerate:S,U=S/M,G=f.isAAC?T:C,V=G*U,O=this._initPTS,I=!f.isAAC&&this.typeSupported.mpeg,X=[],q=f.samples,oe=I?0:8,ce=this.nextAudioPts||-1,Le=h*S;if(this.isAudioContiguous=o=o||q.length&&ce>0&&(E&&Math.abs(Le-ce)<9e3||Math.abs(d(q[0].pts-O,Le)-ce)<20*V),q.forEach(function(be){be.pts=d(be.pts-O,Le)}),!o||ce<0){if(q=q.filter(function(be){return be.pts>=0}),!q.length)return;g===0?ce=0:E?ce=Math.max(0,Le):ce=q[0].pts}if(f.isAAC)for(var Ee=g!==void 0,we=this.config.maxAudioFramesDrift,Te=0,ye=ce;Te<q.length;Te++){var fe=q[Te],se=fe.pts,te=se-ye,ue=Math.abs(1e3*te/S);if(te<=-we*V&&Ee)Te===0&&(N.logger.warn("Audio frame @ "+(se/S).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/S)+" ms."),this.nextAudioPts=ce=ye=se);else if(te>=we*V&&ue<k&&Ee){var ne=Math.round(te/V);ye=se-ne*V,ye<0&&(ne--,ye+=V),Te===0&&(this.nextAudioPts=ce=ye),N.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(ye/S).toFixed(3)+"s due to "+Math.round(1e3*te/S)+" ms gap.");for(var _e=0;_e<ne;_e++){var Re=Math.max(ye,0),xe=F.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);xe||(N.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),xe=fe.unit.subarray()),q.splice(Te,0,{unit:xe,pts:Re}),ye+=V,Te++}}fe.pts=ye,ye+=V}for(var ke=null,Ne=null,He,Be=0,Me=q.length;Me--;)Be+=q[Me].unit.byteLength;for(var Oe=0,Ye=q.length;Oe<Ye;Oe++){var Je=q[Oe],Ve=Je.unit,je=Je.pts;if(Ne!==null){var rt=X[Oe-1];rt.duration=Math.round((je-Ne)/U)}else if(o&&f.isAAC&&(je=ce),ke=je,Be>0){Be+=oe;try{He=new Uint8Array(Be)}catch(be){this.observer.emit(K.Events.ERROR,K.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Be,reason:"fail allocating audio mdat "+Be});return}if(!I){var Qe=new DataView(He.buffer);Qe.setUint32(0,Be),He.set(P.default.types.mdat,4)}}else return;He.set(Ve,oe);var tt=Ve.byteLength;oe+=tt,X.push(new v(!0,G,tt,0)),Ne=je}var Pe=X.length;if(!Pe)return;var lt=X[X.length-1];this.nextAudioPts=ce=Ne+U*lt.duration;var at=I?new Uint8Array(0):P.default.moof(f.sequenceNumber++,ke/U,A({},f,{samples:X}));f.samples=[];var Fe=ke/S,Xe=ce/S,Ce="audio",ve={data1:at,data2:He,startPTS:Fe,endPTS:Xe,startDTS:Fe,endDTS:Xe,type:Ce,hasAudio:!0,hasVideo:!1,nb:Pe};return this.isAudioContiguous=!0,console.assert(He.length,"MDAT length must not be zero"),ve},x.remuxEmptyAudio=function(f,h,o,E){var g=f.inputTimeScale,S=f.samplerate?f.samplerate:g,M=g/S,U=this.nextAudioPts,G=(U!==null?U:E.startDTS*g)+this._initDTS,V=E.endDTS*g+this._initDTS,O=M*T,I=Math.ceil((V-G)/O),X=F.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(N.logger.warn("[mp4-remuxer]: remux empty Audio"),!X){N.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var q=[],oe=0;oe<I;oe++){var ce=G+oe*O;q.push({unit:X,pts:ce,dts:ce})}return f.samples=q,this.remuxAudio(f,h,o,!1)},x.remuxID3=function(f,h){var o=f.samples.length;if(!o)return;for(var E=f.inputTimeScale,g=this._initPTS,S=this._initDTS,M=0;M<o;M++){var U=f.samples[M];U.pts=d(U.pts-g,h*E)/E,U.dts=d(U.dts-S,h*E)/E}var G=f.samples;return f.samples=[],{samples:G}},x.remuxText=function(f,h){var o=f.samples.length;if(!o)return;for(var E=f.inputTimeScale,g=this._initPTS,S=0;S<o;S++){var M=f.samples[S];M.pts=d(M.pts-g,h*E)/E}f.samples.sort(function(G,V){return G.pts-V.pts});var U=f.samples;return f.samples=[],{samples:U}},L}();function d(L,x){var p;if(x===null)return L;for(x<L?p=-8589934592:p=8589934592;Math.abs(L-x)>4294967296;)L+=p;return L}function _(L){for(var x=0;x<L.length;x++)if(L[x].key)return x;return-1}var v=function(x,p,f,h){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=p,this.size=f,this.cts=h,this.flags=new m(x)},m=function(x){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=x?2:1,this.isNonSync=x?0:1}},"./src/remux/passthrough-remuxer.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/mp4-tools.ts"),P=R("./src/loader/fragment.ts"),K=R("./src/utils/logger.ts"),j=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var A=y.prototype;return A.destroy=function(){},A.resetTimeStamp=function(T){this.initPTS=T,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(T,C,b){this.audioCodec=C,this.videoCodec=b,this.generateInitSegment(T),this.emitInitSegment=!0},A.generateInitSegment=function(T){var C=this.audioCodec,b=this.videoCodec;if(!T||!T.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(F.parseInitSegment)(T);C||(C=D(u.audio,P.ElementaryStreamTypes.AUDIO)),b||(b=D(u.video,P.ElementaryStreamTypes.VIDEO));var a={};u.audio&&u.video?a.audiovideo={container:"video/mp4",codec:C+","+b,initSegment:T,id:"main"}:u.audio?a.audio={container:"audio/mp4",codec:C,initSegment:T,id:"audio"}:u.video?a.video={container:"video/mp4",codec:b,initSegment:T,id:"main"}:K.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},A.remux=function(T,C,b,u,a){var l=this.initPTS,d=this.lastEndDTS,_={audio:void 0,video:void 0,text:u,id3:b,initSegment:void 0};Object(Z.isFiniteNumber)(d)||(d=this.lastEndDTS=a||0);var v=C.samples;if(!v||!v.length)return _;var m={initPTS:void 0,timescale:1},L=this.initData;if((!L||!L.length)&&(this.generateInitSegment(v),L=this.initData),!L||!L.length)return K.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),_;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1),Object(Z.isFiniteNumber)(l)||(this.initPTS=m.initPTS=l=N(L,v,d));var x=Object(F.getDuration)(v,L),p=d,f=x+p;Object(F.offsetStartDTS)(L,v,l),x>0?this.lastEndDTS=f:(K.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var h=!!L.audio,o=!!L.video,E="";h&&(E+="audio"),o&&(E+="video");var g={data1:v,startPTS:p,startDTS:p,endPTS:f,endDTS:f,type:E,hasAudio:h,hasVideo:o,nb:1,dropped:0};return _.audio=g.type==="audio"?g:void 0,_.video=g.type!=="audio"?g:void 0,_.text=u,_.id3=b,_.initSegment=m,_},y}(),N=function(A,k,T){return Object(F.getStartDTS)(A,k)-T};function D(y,A){var k=y==null?void 0:y.codec;return k&&k.length>4?k:k==="hvc1"?"hvc1.1.c.L120.90":k==="av01"?"av01.0.04M.08":k==="avc1"||A===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=j},"./src/task-loop.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return Z});var Z=function(){function F(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var P=F.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(j){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,j),!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(){},F}()},"./src/types/cmcd.ts":function(le,$,R){"use strict";R.r($),R.d($,"CMCDVersion",function(){return Z}),R.d($,"CMCDObjectType",function(){return F}),R.d($,"CMCDStreamingFormat",function(){return P}),R.d($,"CMCDStreamType",function(){return K});var Z=1,F;(function(j){j.MANIFEST="m",j.AUDIO="a",j.VIDEO="v",j.MUXED="av",j.INIT="i",j.CAPTION="c",j.TIMED_TEXT="tt",j.KEY="k",j.OTHER="o"})(F||(F={}));var P;(function(j){j.DASH="d",j.HLS="h",j.SMOOTH="s",j.OTHER="o"})(P||(P={}));var K;(function(j){j.VOD="v",j.LIVE="l"})(K||(K={}))},"./src/types/level.ts":function(le,$,R){"use strict";R.r($),R.d($,"HlsSkip",function(){return P}),R.d($,"getSkipValue",function(){return K}),R.d($,"HlsUrlParameters",function(){return j}),R.d($,"Level",function(){return N});function Z(D,y){for(var A=0;A<y.length;A++){var k=y[A];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(D,k.key,k)}}function F(D,y,A){return y&&Z(D.prototype,y),A&&Z(D,A),D}var P;(function(D){D.No="",D.Yes="YES",D.v2="v2"})(P||(P={}));function K(D,y){var A=D.canSkipUntil,k=D.canSkipDateRanges,T=D.endSN,C=y!==void 0?y-T:0;return A&&C<A?k?P.v2:P.Yes:P.No}var j=function(){function D(A,k,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=k,this.skip=T}var y=D.prototype;return y.addDirectives=function(k){var T=new self.URL(k);return this.msn!==void 0&&T.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&T.searchParams.set("_HLS_part",this.part.toString()),this.skip&&T.searchParams.set("_HLS_skip",this.skip),T.toString()},D}(),N=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(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return F(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(A){var k=A%this.url.length;this._urlId!==k&&(this.details=void 0,this._urlId=k)}}]),D}()},"./src/types/loader.ts":function(le,$,R){"use strict";R.r($),R.d($,"PlaylistContextType",function(){return Z}),R.d($,"PlaylistLevelType",function(){return F});var Z;(function(P){P.MANIFEST="manifest",P.LEVEL="level",P.AUDIO_TRACK="audioTrack",P.SUBTITLE_TRACK="subtitleTrack"})(Z||(Z={}));var F;(function(P){P.MAIN="main",P.AUDIO="audio",P.SUBTITLE="subtitle"})(F||(F={}))},"./src/types/transmuxer.ts":function(le,$,R){"use strict";R.r($),R.d($,"ChunkMetadata",function(){return Z});var Z=function(K,j,N,D,y,A){D===void 0&&(D=0),y===void 0&&(y=-1),A===void 0&&(A=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=F(),this.buffering={audio:F(),video:F(),audiovideo:F()},this.level=K,this.sn=j,this.id=N,this.size=D,this.part=y,this.partial=A};function F(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(le,$,R){"use strict";R.r($),R.d($,"AttrList",function(){return P});var Z=/^(\d+)x(\d+)$/,F=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,P=function(){function K(N){typeof N=="string"&&(N=K.parseAttrList(N));for(var D in N)N.hasOwnProperty(D)&&(this[D]=N[D])}var j=K.prototype;return j.decimalInteger=function(D){var y=parseInt(this[D],10);return y>Number.MAX_SAFE_INTEGER?Infinity:y},j.hexadecimalInteger=function(D){if(this[D]){var y=(this[D]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var A=new Uint8Array(y.length/2),k=0;k<y.length/2;k++)A[k]=parseInt(y.slice(k*2,k*2+2),16);return A}else return null},j.hexadecimalIntegerAsNumber=function(D){var y=parseInt(this[D],16);return y>Number.MAX_SAFE_INTEGER?Infinity:y},j.decimalFloatingPoint=function(D){return parseFloat(this[D])},j.optionalFloat=function(D,y){var A=this[D];return A?parseFloat(A):y},j.enumeratedString=function(D){return this[D]},j.bool=function(D){return this[D]==="YES"},j.decimalResolution=function(D){var y=Z.exec(this[D]);return y===null?void 0:{width:parseInt(y[1],10),height:parseInt(y[2],10)}},K.parseAttrList=function(D){var y,A={},k='"';for(F.lastIndex=0;(y=F.exec(D))!==null;){var T=y[2];T.indexOf(k)===0&&T.lastIndexOf(k)===T.length-1&&(T=T.slice(1,-1)),A[y[1]]=T}return A},K}()},"./src/utils/binary-search.ts":function(le,$,R){"use strict";R.r($);var Z={search:function(P,K){for(var j=0,N=P.length-1,D=null,y=null;j<=N;){D=(j+N)/2|0,y=P[D];var A=K(y);if(A>0)j=D+1;else if(A<0)N=D-1;else return y}return null}};$.default=Z},"./src/utils/buffer-helper.ts":function(le,$,R){"use strict";R.r($),R.d($,"BufferHelper",function(){return P});var Z=R("./src/utils/logger.ts"),F={length:0,start:function(){return 0},end:function(){return 0}},P=function(){function K(){}return K.isBuffered=function(N,D){try{if(N){for(var y=K.getBuffered(N),A=0;A<y.length;A++)if(D>=y.start(A)&&D<=y.end(A))return!0}}catch(k){}return!1},K.bufferInfo=function(N,D,y){try{if(N){var A=K.getBuffered(N),k=[],T;for(T=0;T<A.length;T++)k.push({start:A.start(T),end:A.end(T)});return this.bufferedInfo(k,D,y)}}catch(C){}return{len:0,start:D,end:D,nextStart:void 0}},K.bufferedInfo=function(N,D,y){D=Math.max(0,D),N.sort(function(m,L){var x=m.start-L.start;return x||L.end-m.end});var A=[];if(y)for(var k=0;k<N.length;k++){var T=A.length;if(T){var C=A[T-1].end;N[k].start-C<y?N[k].end>C&&(A[T-1].end=N[k].end):A.push(N[k])}else A.push(N[k])}else A=N;for(var b=0,u,a=D,l=D,d=0;d<A.length;d++){var _=A[d].start,v=A[d].end;if(D+y>=_&&D<v)a=_,l=v,b=l-D;else if(D+y<_){u=_;break}}return{len:b,start:a||0,end:l||0,nextStart:u}},K.getBuffered=function(N){try{return N.buffered}catch(D){return Z.logger.log("failed to get media.buffered",D),F}},K}()},"./src/utils/cea-608-parser.ts":function(le,$,R){"use strict";R.r($),R.d($,"Row",function(){return l}),R.d($,"CaptionScreen",function(){return d});var Z=R("./src/utils/logger.ts"),F={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},P=function(f){var h=f;return F.hasOwnProperty(f)&&(h=F[f]),String.fromCharCode(h)},K=15,j=100,N={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},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},k=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],T;(function(p){p[p.ERROR=0]="ERROR",p[p.TEXT=1]="TEXT",p[p.WARNING=2]="WARNING",p[p.INFO=2]="INFO",p[p.DEBUG=3]="DEBUG",p[p.DATA=3]="DATA"})(T||(T={}));var C=function(){function p(){this.time=null,this.verboseLevel=T.ERROR}var f=p.prototype;return f.log=function(o,E){this.verboseLevel>=o&&Z.logger.log(this.time+" ["+o+"] "+E)},p}(),b=function(f){for(var h=[],o=0;o<f.length;o++)h.push(f[o].toString(16));return h},u=function(){function p(h,o,E,g,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=h||"white",this.underline=o||!1,this.italics=E||!1,this.background=g||"black",this.flash=S||!1}var f=p.prototype;return f.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},f.setStyles=function(o){for(var E=["foreground","underline","italics","background","flash"],g=0;g<E.length;g++){var S=E[g];o.hasOwnProperty(S)&&(this[S]=o[S])}},f.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},f.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},f.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},f.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},p}(),a=function(){function p(h,o,E,g,S,M){this.uchar=void 0,this.penState=void 0,this.uchar=h||" ",this.penState=new u(o,E,g,S,M)}var f=p.prototype;return f.reset=function(){this.uchar=" ",this.penState.reset()},f.setChar=function(o,E){this.uchar=o,this.penState.copy(E)},f.setPenState=function(o){this.penState.copy(o)},f.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},f.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},f.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},p}(),l=function(){function p(h){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<j;o++)this.chars.push(new a);this.logger=h,this.pos=0,this.currPenState=new u}var f=p.prototype;return f.equals=function(o){for(var E=!0,g=0;g<j;g++)if(!this.chars[g].equals(o.chars[g])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<j;E++)this.chars[E].copy(o.chars[E])},f.isEmpty=function(){for(var o=!0,E=0;E<j;E++)if(!this.chars[E].isEmpty()){o=!1;break}return o},f.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(T.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>j&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=j)},f.moveCursor=function(o){var E=this.pos+o;if(o>1)for(var g=this.pos+1;g<E+1;g++)this.chars[g].setPenState(this.currPenState);this.setCursor(E)},f.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},f.insertChar=function(o){o>=144&&this.backSpace();var E=P(o);if(this.pos>=j){this.logger.log(T.ERROR,"Cannot insert "+o.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},f.clearFromPos=function(o){var E;for(E=o;E<j;E++)this.chars[E].reset()},f.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},f.clearToEndOfRow=function(){this.clearFromPos(this.pos)},f.getTextString=function(){for(var o=[],E=!0,g=0;g<j;g++){var S=this.chars[g].uchar;S!==" "&&(E=!1),o.push(S)}return E?"":o.join("")},f.setPenStyles=function(o){this.currPenState.setStyles(o);var E=this.chars[this.pos];E.setPenState(this.currPenState)},p}(),d=function(){function p(h){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<K;o++)this.rows.push(new l(h));this.logger=h,this.currRow=K-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var f=p.prototype;return f.reset=function(){for(var o=0;o<K;o++)this.rows[o].clear();this.currRow=K-1},f.equals=function(o){for(var E=!0,g=0;g<K;g++)if(!this.rows[g].equals(o.rows[g])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<K;E++)this.rows[E].copy(o.rows[E])},f.isEmpty=function(){for(var o=!0,E=0;E<K;E++)if(!this.rows[E].isEmpty()){o=!1;break}return o},f.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},f.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},f.insertChar=function(o){var E=this.rows[this.currRow];E.insertChar(o)},f.setPen=function(o){var E=this.rows[this.currRow];E.setPenStyles(o)},f.moveCursor=function(o){var E=this.rows[this.currRow];E.moveCursor(o)},f.setCursor=function(o){this.logger.log(T.INFO,"setCursor: "+o);var E=this.rows[this.currRow];E.setCursor(o)},f.setPAC=function(o){this.logger.log(T.INFO,"pacData = "+JSON.stringify(o));var E=o.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var g=0;g<K;g++)this.rows[g].clear();var S=this.currRow+1-this.nrRollUpRows,M=this.lastOutputScreen;if(M){var U=M.rows[S].cueStartTime,G=this.logger.time;if(U&&G!==null&&U<G)for(var V=0;V<this.nrRollUpRows;V++)this.rows[E-this.nrRollUpRows+V+1].copy(M.rows[S+V])}}this.currRow=E;var O=this.rows[this.currRow];if(o.indent!==null){var I=o.indent,X=Math.max(I-1,0);O.setCursor(o.indent),o.color=O.chars[X].penState.foreground}var q={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(q)},f.setBkgData=function(o){this.logger.log(T.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},f.setRollUpRows=function(o){this.nrRollUpRows=o},f.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(T.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(T.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(o,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(T.INFO,"Rolling up")},f.getDisplayText=function(o){o=o||!1;for(var E=[],g="",S=-1,M=0;M<K;M++){var U=this.rows[M].getTextString();U&&(S=M+1,o?E.push("Row "+S+": '"+U+"'"):E.push(U.trim()))}return E.length>0&&(o?g="["+E.join(" | ")+"]":g=E.join(`
`)),g},f.getTextAndFormat=function(){return this.rows},p}(),_=function(){function p(h,o,E){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=h,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new d(E),this.nonDisplayedMemory=new d(E),this.lastOutputScreen=new d(E),this.currRollUpRow=this.displayedMemory.rows[K-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=E}var f=p.prototype;return f.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[K-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},f.getHandler=function(){return this.outputFilter},f.setHandler=function(o){this.outputFilter=o},f.setPAC=function(o){this.writeScreen.setPAC(o)},f.setBkgData=function(o){this.writeScreen.setBkgData(o)},f.setMode=function(o){if(o===this.mode)return;this.mode=o,this.logger.log(T.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o},f.insertChars=function(o){for(var E=0;E<o.length;E++)this.writeScreen.insertChar(o[E]);var g=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(T.INFO,g+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(T.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},f.ccRCL=function(){this.logger.log(T.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},f.ccBS=function(){if(this.logger.log(T.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},f.ccAOF=function(){},f.ccAON=function(){},f.ccDER=function(){this.logger.log(T.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},f.ccRU=function(o){this.logger.log(T.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},f.ccFON=function(){this.logger.log(T.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},f.ccRDC=function(){this.logger.log(T.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},f.ccTR=function(){this.logger.log(T.INFO,"TR"),this.setMode("MODE_TEXT")},f.ccRTD=function(){this.logger.log(T.INFO,"RTD"),this.setMode("MODE_TEXT")},f.ccEDM=function(){this.logger.log(T.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},f.ccCR=function(){this.logger.log(T.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},f.ccENM=function(){this.logger.log(T.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},f.ccEOC=function(){if(this.logger.log(T.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(T.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},f.ccTO=function(o){this.logger.log(T.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},f.ccMIDROW=function(o){var E={flash:!1};if(E.underline=o%2===1,E.italics=o>=46,E.italics)E.foreground="white";else{var g=Math.floor(o/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=S[g]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},f.outputDataUpdate=function(o){o===void 0&&(o=!1);var E=this.logger.time;if(E===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=E:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,E,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},f.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},p}(),v=function(){function p(h,o,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new C;this.channels=[null,new _(h,o,g),new _(h+1,E,g)],this.cmdHistory=x(),this.logger=g}var f=p.prototype;return f.getHandler=function(o){return this.channels[o].getHandler()},f.setHandler=function(o,E){this.channels[o].setHandler(E)},f.addData=function(o,E){var g,S,M,U=!1;this.logger.time=o;for(var G=0;G<E.length;G+=2){if(S=E[G]&127,M=E[G+1]&127,S===0&&M===0)continue;if(this.logger.log(T.DATA,"["+b([E[G],E[G+1]])+"] -> ("+b([S,M])+")"),g=this.parseCmd(S,M),g||(g=this.parseMidrow(S,M)),g||(g=this.parsePAC(S,M)),g||(g=this.parseBackgroundAttributes(S,M)),!g&&(U=this.parseChars(S,M),U)){var V=this.currentChannel;if(V&&V>0){var O=this.channels[V];O.insertChars(U)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!U&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+b([S,M])+" orig: "+b([E[G],E[G+1]]))}},f.parseCmd=function(o,E){var g=this.cmdHistory,S=(o===20||o===28||o===21||o===29)&&E>=32&&E<=47,M=(o===23||o===31)&&E>=33&&E<=35;if(!(S||M))return!1;if(L(o,E,g))return m(null,null,g),this.logger.log(T.DEBUG,"Repeated command ("+b([o,E])+") is dropped"),!0;var U=o===20||o===21||o===23?1:2,G=this.channels[U];return o===20||o===21||o===28||o===29?E===32?G.ccRCL():E===33?G.ccBS():E===34?G.ccAOF():E===35?G.ccAON():E===36?G.ccDER():E===37?G.ccRU(2):E===38?G.ccRU(3):E===39?G.ccRU(4):E===40?G.ccFON():E===41?G.ccRDC():E===42?G.ccTR():E===43?G.ccRTD():E===44?G.ccEDM():E===45?G.ccCR():E===46?G.ccENM():E===47&&G.ccEOC():G.ccTO(E-32),m(o,E,g),this.currentChannel=U,!0},f.parseMidrow=function(o,E){var g=0;if((o===17||o===25)&&E>=32&&E<=47){if(o===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[g];return S?(S.ccMIDROW(E),this.logger.log(T.DEBUG,"MIDROW ("+b([o,E])+")"),!0):!1}return!1},f.parsePAC=function(o,E){var g,S=this.cmdHistory,M=(o>=17&&o<=23||o>=25&&o<=31)&&E>=64&&E<=127,U=(o===16||o===24)&&E>=64&&E<=95;if(!(M||U))return!1;if(L(o,E,S))return m(null,null,S),!0;var G=o<=23?1:2;E>=64&&E<=95?g=G===1?N[o]:y[o]:g=G===1?D[o]:A[o];var V=this.channels[G];return V?(V.setPAC(this.interpretPAC(g,E)),m(o,E,S),this.currentChannel=G,!0):!1},f.interpretPAC=function(o,E){var g,S={color:null,italics:!1,indent:null,underline:!1,row:o};return E>95?g=E-96:g=E-64,S.underline=(g&1)===1,g<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((g-16)/2)*4,S},f.parseChars=function(o,E){var g,S=null,M=null;if(o>=25?(g=2,M=o-8):(g=1,M=o),M>=17&&M<=19){var U;M===17?U=E+80:M===18?U=E+112:U=E+144,this.logger.log(T.INFO,"Special char '"+P(U)+"' in channel "+g),S=[U]}else o>=32&&o<=127&&(S=E===0?[o]:[o,E]);if(S){var G=b(S);this.logger.log(T.DEBUG,"Char codes = "+G.join(",")),m(o,E,this.cmdHistory)}return S},f.parseBackgroundAttributes=function(o,E){var g=(o===16||o===24)&&E>=32&&E<=47,S=(o===23||o===31)&&E>=45&&E<=47;if(!(g||S))return!1;var M,U={};o===16||o===24?(M=Math.floor((E-32)/2),U.background=k[M],E%2===1&&(U.background=U.background+"_semi")):E===45?U.background="transparent":(U.foreground="black",E===47&&(U.underline=!0));var G=o<=23?1:2,V=this.channels[G];return V.setBkgData(U),m(o,E,this.cmdHistory),!0},f.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var E=this.channels[o];E&&E.reset()}this.cmdHistory=x()},f.cueSplitAtTime=function(o){for(var E=0;E<this.channels.length;E++){var g=this.channels[E];g&&g.cueSplitAtTime(o)}},p}();function m(p,f,h){h.a=p,h.b=f}function L(p,f,h){return h.a===p&&h.b===f}function x(){return{a:null,b:null}}$.default=v},"./src/utils/codecs.ts":function(le,$,R){"use strict";R.r($),R.d($,"isCodecType",function(){return F}),R.d($,"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 F(K,j){var N=Z[j];return!!N&&N[K.slice(0,4)]===!0}function P(K,j){return MediaSource.isTypeSupported((j||"video")+'/mp4;codecs="'+K+'"')}},"./src/utils/cues.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/utils/vttparser.ts"),F=R("./src/utils/webvtt-parser.ts"),P=R("./src/utils/texttrack-utils.ts"),K=/\s/,j={newCue:function(D,y,A,k){for(var T=[],C,b,u,a,l,d=self.VTTCue||self.TextTrackCue,_=0;_<k.rows.length;_++)if(C=k.rows[_],u=!0,a=0,l="",!C.isEmpty()){for(var v=0;v<C.chars.length;v++)K.test(C.chars[v].uchar)&&u?a++:(l+=C.chars[v].uchar,u=!1);C.cueStartTime=y,y===A&&(A+=1e-4),a>=16?a--:a++;var m=Object(Z.fixLineBreaks)(l.trim()),L=Object(F.generateCueId)(y,A,m);(!D||!D.cues||!D.cues.getCueById(L))&&(b=new d(y,A,m),b.id=L,b.line=_+1,b.align="left",b.position=10+Math.min(80,Math.floor(a*8/32)*10),T.push(b))}return D&&T.length&&(T.sort(function(x,p){return x.line==="auto"||p.line==="auto"?0:x.line>8&&p.line>8?p.line-x.line:x.line-p.line}),T.forEach(function(x){return Object(P.addCueToTrack)(D,x)})),T}};$.default=j},"./src/utils/discontinuities.ts":function(le,$,R){"use strict";R.r($),R.d($,"findFirstFragWithCC",function(){return K}),R.d($,"shouldAlignOnDiscontinuities",function(){return j}),R.d($,"findDiscontinuousReferenceFrag",function(){return N}),R.d($,"adjustSlidingStart",function(){return y}),R.d($,"alignStream",function(){return A}),R.d($,"alignPDT",function(){return T}),R.d($,"alignFragmentByPDTDelta",function(){return C}),R.d($,"alignMediaPlaylistByPDT",function(){return b});var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/logger.ts"),P=R("./src/controller/level-helper.ts");function K(u,a){for(var l=null,d=0,_=u.length;d<_;d++){var v=u[d];if(v&&v.cc===a){l=v;break}}return l}function j(u,a,l){return!!(a.details&&(l.endCC>l.startCC||u&&u.cc<l.startCC))}function N(u,a){var l=u.fragments,d=a.fragments;if(!d.length||!l.length){F.logger.log("No fragments to align");return}var _=K(l,d[0].cc);if(!_||_&&!_.startPTS){F.logger.log("No frag in previous level to align on");return}return _}function D(u,a){if(u){var l=u.start+a;u.start=u.startPTS=l,u.endPTS=l+u.duration}}function y(u,a){for(var l=a.fragments,d=0,_=l.length;d<_;d++)D(l[d],u);a.fragmentHint&&D(a.fragmentHint,u),a.alignedSliding=!0}function A(u,a,l){if(!a)return;k(u,l,a),!l.alignedSliding&&a.details&&T(l,a.details),!l.alignedSliding&&a.details&&!l.skippedSegments&&Object(P.adjustSliding)(a.details,l)}function k(u,a,l){if(j(u,l,a)){var d=N(l.details,a);d&&Object(Z.isFiniteNumber)(d.start)&&(F.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),y(d.start,a))}}function T(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,d=u.fragments[0].programDateTime,_=(d-l)/1e3+a.fragments[0].start;_&&Object(Z.isFiniteNumber)(_)&&(F.logger.log("Adjusting PTS using programDateTime delta "+(d-l)+"ms, sliding:"+_.toFixed(3)+" "+u.url+" "),y(_,u))}function C(u,a){var l=u.programDateTime;if(!l)return;var d=(l-a)/1e3;u.start=u.startPTS=d,u.endPTS=d+u.duration}function b(u,a){if(!a.fragments.length||!u.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,d=a.fragments[0].start,_=l-d*1e3;u.fragments.forEach(function(v){C(v,_)}),u.fragmentHint&&C(u.fragmentHint,_),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/utils/ewma.ts"),F=function(){function P(j,N,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(j),this.fast_=new Z.default(N)}var K=P.prototype;return K.update=function(N,D){var y=this.slow_,A=this.fast_;this.slow_.halfLife!==N&&(this.slow_=new Z.default(N,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==D&&(this.fast_=new Z.default(D,A.getEstimate(),A.getTotalWeight()))},K.sample=function(N,D){N=Math.max(N,this.minDelayMs_);var y=8*D,A=N/1e3,k=y/A;this.fast_.sample(A,k),this.slow_.sample(A,k)},K.canEstimate=function(){var N=this.fast_;return N&&N.getTotalWeight()>=this.minWeight_},K.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},K.destroy=function(){},P}();$.default=F},"./src/utils/ewma.ts":function(le,$,R){"use strict";R.r($);var Z=function(){function F(K,j,N){j===void 0&&(j=0),N===void 0&&(N=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=K,this.alpha_=K?Math.exp(Math.log(.5)/K):0,this.estimate_=j,this.totalWeight_=N}var P=F.prototype;return P.sample=function(j,N){var D=Math.pow(this.alpha_,j);this.estimate_=N*(1-D)+D*this.estimate_,this.totalWeight_+=j},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var j=1-Math.pow(this.alpha_,this.totalWeight_);if(j)return this.estimate_/j}return this.estimate_},F}();$.default=Z},"./src/utils/fetch-loader.ts":function(le,$,R){"use strict";R.r($),R.d($,"fetchSupported",function(){return C});var Z=R("./src/polyfills/number.ts"),F=R("./src/loader/load-stats.ts"),P=R("./src/demux/chunk-cache.ts");function K(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,A(d,_)}function j(d){var _=typeof Map=="function"?new Map:void 0;return j=function(m){if(m===null||!y(m))return m;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(typeof _!="undefined"){if(_.has(m))return _.get(m);_.set(m,L)}function L(){return N(m,arguments,k(this).constructor)}return L.prototype=Object.create(m.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),A(L,m)},j(d)}function N(d,_,v){return D()?N=Reflect.construct:N=function(L,x,p){var f=[null];f.push.apply(f,x);var h=Function.bind.apply(L,f),o=new h;return p&&A(o,p.prototype),o},N.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 A(d,_){return A=Object.setPrototypeOf||function(m,L){return m.__proto__=L,m},A(d,_)}function k(d){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},k(d)}function T(){return T=Object.assign||function(d){for(var _=1;_<arguments.length;_++){var v=arguments[_];for(var m in v)Object.prototype.hasOwnProperty.call(v,m)&&(d[m]=v[m])}return d},T.apply(this,arguments)}function C(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var b=function(){function d(v){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=v.fetchSetup||a,this.controller=new self.AbortController,this.stats=new F.LoadStats}var _=d.prototype;return _.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},_.abortInternal=function(){var m=this.response;(!m||!m.ok)&&(this.stats.aborted=!0,this.controller.abort())},_.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},_.load=function(m,L,x){var p=this,f=this.stats;if(f.loading.start)throw new Error("Loader can only be used once.");f.loading.start=self.performance.now();var h=u(m,this.controller.signal),o=x.onProgress,E=m.responseType==="arraybuffer",g=E?"byteLength":"length";this.context=m,this.config=L,this.callbacks=x,this.request=this.fetchSetup(m,h),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){p.abortInternal(),x.onTimeout(f,m,p.response)},L.timeout),self.fetch(this.request).then(function(S){if(p.response=p.loader=S,!S.ok){var M=S.status,U=S.statusText;throw new l(U||"fetch, bad network response",M,S)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(S.headers.get("Content-Length")||"0"),o&&Object(Z.isFiniteNumber)(L.highWaterMark)?p.loadProgressively(S,f,m,L.highWaterMark,o):E?S.arrayBuffer():S.text()}).then(function(S){var M=p.response;self.clearTimeout(p.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=S[g];var U={url:M.url,data:S};o&&!Object(Z.isFiniteNumber)(L.highWaterMark)&&o(f,m,S,M),x.onSuccess(U,f,m,M)}).catch(function(S){if(self.clearTimeout(p.requestTimeout),f.aborted)return;var M=S.code||0;x.onError({code:M,text:S.message},m,S.details)})},_.getCacheAge=function(){var m=null;if(this.response){var L=this.response.headers.get("age");m=L?parseFloat(L):null}return m},_.loadProgressively=function(m,L,x,p,f){p===void 0&&(p=0);var h=new P.default,o=m.body.getReader(),E=function g(){return o.read().then(function(S){if(S.done)return h.dataLength&&f(L,x,h.flush(),m),Promise.resolve(new ArrayBuffer(0));var M=S.value,U=M.length;return L.loaded+=U,U<p||h.dataLength?(h.push(M),h.dataLength>=p&&f(L,x,h.flush(),m)):f(L,x,M,m),g()}).catch(function(){return Promise.reject()})};return E()},d}();function u(d,_){var v={method:"GET",mode:"cors",credentials:"same-origin",signal:_,headers:new self.Headers(T({},d.headers))};return d.rangeEnd&&v.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),v}function a(d,_){return new self.Request(d.url,_)}var l=function(d){K(_,d);function _(v,m,L){var x;return x=d.call(this,v)||this,x.code=void 0,x.details=void 0,x.code=m,x.details=L,x}return _}(j(Error));$.default=b},"./src/utils/imsc1-ttml-parser.ts":function(le,$,R){"use strict";R.r($),R.d($,"IMSC1_CODEC",function(){return y}),R.d($,"parseIMSC1",function(){return C});var Z=R("./src/utils/mp4-tools.ts"),F=R("./src/utils/vttparser.ts"),P=R("./src/utils/vttcue.ts"),K=R("./src/demux/id3.ts"),j=R("./src/utils/timescale-conversion.ts"),N=R("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign||function(p){for(var f=1;f<arguments.length;f++){var h=arguments[f];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(p[o]=h[o])}return p},D.apply(this,arguments)}var y="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,k=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,T={left:"start",center:"center",right:"end",start:"start",end:"end"};function C(p,f,h,o,E){var g=Object(Z.findBox)(new Uint8Array(p),["mdat"]);if(g.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var S=g[0],M=Object(K.utf8ArrayToStr)(new Uint8Array(p,S.start,S.end-S.start)),U=Object(j.toTimescaleFromScale)(f,1,h);try{o(b(M,U))}catch(G){E(G)}}function b(p,f){var h=new DOMParser,o=h.parseFromString(p,"text/xml"),E=o.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var g={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(g).reduce(function(O,I){return O[I]=E.getAttribute("ttp:"+I)||g[I],O},{}),M=E.getAttribute("xml:space")!=="preserve",U=a(u(E,"styling","style")),G=a(u(E,"layout","region")),V=u(E,"body","[begin]");return[].map.call(V,function(O){var I=l(O,M);if(!I||!O.hasAttribute("begin"))return null;var X=m(O.getAttribute("begin"),S),q=m(O.getAttribute("dur"),S),oe=m(O.getAttribute("end"),S);if(X===null)throw v(O);if(oe===null){if(q===null)throw v(O);oe=X+q}var ce=new P.default(X-f,oe-f,I);ce.id=Object(N.generateCueId)(ce.startTime,ce.endTime,ce.text);var Le=G[O.getAttribute("region")],Ee=U[O.getAttribute("style")];ce.position=10,ce.size=80;var we=d(Le,Ee),Te=we.textAlign;if(Te){var ye=T[Te];ye&&(ce.lineAlign=ye),ce.align=Te}return D(ce,we),ce}).filter(function(O){return O!==null})}function u(p,f,h){var o=p.getElementsByTagName(f)[0];return o?[].slice.call(o.querySelectorAll(h)):[]}function a(p){return p.reduce(function(f,h){var o=h.getAttribute("xml:id");return o&&(f[o]=h),f},{})}function l(p,f){return[].slice.call(p.childNodes).reduce(function(h,o,E){var g;return o.nodeName==="br"&&E?h+`
`:(g=o.childNodes)!==null&&g!==void 0&&g.length?l(o,f):f?h+o.textContent.trim().replace(/\s+/g," "):h+o.textContent},"")}function d(p,f){var h="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(E,g){var S=_(f,h,g)||_(p,h,g);return S&&(E[g]=S),E},{})}function _(p,f,h){return p.hasAttributeNS(f,h)?p.getAttributeNS(f,h):null}function v(p){return new Error("Could not parse ttml timestamp "+p)}function m(p,f){if(!p)return null;var h=Object(F.parseTimeStamp)(p);return h===null&&(A.test(p)?h=L(p,f):k.test(p)&&(h=x(p,f))),h}function L(p,f){var h=A.exec(p),o=(h[4]|0)+(h[5]|0)/f.subFrameRate;return(h[1]|0)*3600+(h[2]|0)*60+(h[3]|0)+o/f.frameRate}function x(p,f){var h=k.exec(p),o=Number(h[1]),E=h[2];switch(E){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/f.frameRate;case"t":return o/f.tickRate}return o}},"./src/utils/logger.ts":function(le,$,R){"use strict";R.r($),R.d($,"enableLogs",function(){return N}),R.d($,"logger",function(){return D});var Z=function(){},F={trace:Z,debug:Z,log:Z,warn:Z,info:Z,error:Z},P=F;function K(y){var A=self.console[y];return A?A.bind(self.console,"["+y+"] >"):Z}function j(y){for(var A=arguments.length,k=new Array(A>1?A-1:0),T=1;T<A;T++)k[T-1]=arguments[T];k.forEach(function(C){P[C]=y[C]?y[C].bind(y):K(C)})}function N(y){if(self.console&&y===!0||typeof y=="object"){j(y,"debug","log","info","warn","error");try{P.log()}catch(A){P=F}}else P=F}var D=P},"./src/utils/mediakeys-helper.ts":function(le,$,R){"use strict";R.r($),R.d($,"KeySystems",function(){return Z}),R.d($,"requestMediaKeySystemAccess",function(){return F});var Z;(function(P){P.WIDEVINE="com.widevine.alpha",P.PLAYREADY="com.microsoft.playready"})(Z||(Z={}));var F=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(le,$,R){"use strict";R.r($),R.d($,"getMediaSource",function(){return Z});function Z(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(le,$,R){"use strict";R.r($),R.d($,"bin2str",function(){return j}),R.d($,"readUint16",function(){return N}),R.d($,"readUint32",function(){return D}),R.d($,"writeUint32",function(){return y}),R.d($,"findBox",function(){return A}),R.d($,"parseSegmentIndex",function(){return k}),R.d($,"parseInitSegment",function(){return T}),R.d($,"getStartDTS",function(){return C}),R.d($,"getDuration",function(){return b}),R.d($,"computeRawDurationFromSamples",function(){return u}),R.d($,"offsetStartDTS",function(){return a}),R.d($,"segmentValidRange",function(){return l}),R.d($,"appendUint8Array",function(){return d});var Z=R("./src/utils/typed-array.ts"),F=R("./src/loader/fragment.ts"),P=Math.pow(2,32)-1,K=[].push;function j(_){return String.fromCharCode.apply(null,_)}function N(_,v){"data"in _&&(v+=_.start,_=_.data);var m=_[v]<<8|_[v+1];return m<0?65536+m:m}function D(_,v){"data"in _&&(v+=_.start,_=_.data);var m=_[v]<<24|_[v+1]<<16|_[v+2]<<8|_[v+3];return m<0?4294967296+m:m}function y(_,v,m){"data"in _&&(v+=_.start,_=_.data),_[v]=m>>24,_[v+1]=m>>16&255,_[v+2]=m>>8&255,_[v+3]=m&255}function A(_,v){var m=[];if(!v.length)return m;var L,x,p;"data"in _?(L=_.data,x=_.start,p=_.end):(L=_,x=0,p=L.byteLength);for(var f=x;f<p;){var h=D(L,f),o=j(L.subarray(f+4,f+8)),E=h>1?f+h:p;if(o===v[0])if(v.length===1)m.push({data:L,start:f+8,end:E});else{var g=A({data:L,start:f+8,end:E},v.slice(1));g.length&&K.apply(m,g)}f=E}return m}function k(_){var v=A(_,["moov"]),m=v[0],L=m?m.end:null,x=A(_,["sidx"]);if(!x||!x[0])return null;var p=[],f=x[0],h=f.data[0],o=h===0?8:16,E=D(f,o);o+=4;var g=0,S=0;h===0?o+=8:o+=16,o+=2;var M=f.end+S,U=N(f,o);o+=2;for(var G=0;G<U;G++){var V=o,O=D(f,V);V+=4;var I=O&2147483647,X=(O&2147483648)>>>31;if(X===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var q=D(f,V);V+=4,p.push({referenceSize:I,subsegmentDuration:q,info:{duration:q/E,start:M,end:M+I-1}}),M+=I,V+=4,o=V}return{earliestPresentationTime:g,timescale:E,version:h,referencesCount:U,references:p,moovEndOffset:L}}function T(_){for(var v=[],m=A(_,["moov","trak"]),L=0;L<m.length;L++){var x=m[L],p=A(x,["tkhd"])[0];if(p){var f=p.data[p.start],h=f===0?12:20,o=D(p,h),E=A(x,["mdia","mdhd"])[0];if(E){f=E.data[E.start],h=f===0?12:20;var g=D(E,h),S=A(x,["mdia","hdlr"])[0];if(S){var M=j(S.data.subarray(S.start+8,S.start+12)),U={soun:F.ElementaryStreamTypes.AUDIO,vide:F.ElementaryStreamTypes.VIDEO}[M];if(U){var G=A(x,["mdia","minf","stbl","stsd"])[0],V=void 0;G&&(V=j(G.data.subarray(G.start+12,G.start+16))),v[o]={timescale:g,type:U},v[U]={timescale:g,id:o,codec:V}}}}}}var O=A(_,["moov","mvex","trex"]);return O.forEach(function(I){var X=D(I,4),q=v[X];q&&(q.default={duration:D(I,12),flags:D(I,20)})}),v}function C(_,v){return A(v,["moof","traf"]).reduce(function(m,L){var x=A(L,["tfdt"])[0],p=x.data[x.start],f=A(L,["tfhd"]).reduce(function(h,o){var E=D(o,4),g=_[E];if(g){var S=D(x,4);p===1&&(S*=Math.pow(2,32),S+=D(x,8));var M=g.timescale||9e4,U=S/M;if(isFinite(U)&&(h===null||U<h))return U}return h},null);return f!==null&&isFinite(f)&&(m===null||f<m)?f:m},null)||0}function b(_,v){for(var m=0,L=0,x=0,p=A(_,["moof","traf"]),f=0;f<p.length;f++){var h=p[f],o=A(h,["tfhd"])[0],E=D(o,4),g=v[E];if(!g)continue;var S=g.default,M=D(o,0)|(S==null?void 0:S.flags),U=S==null?void 0:S.duration;M&8&&(M&2?U=D(o,12):U=D(o,8));for(var G=g.timescale||9e4,V=A(h,["trun"]),O=0;O<V.length;O++){if(U){var I=D(V[O],4);m=U*I}else m=u(V[O]);g.type===F.ElementaryStreamTypes.VIDEO?L+=m/G:g.type===F.ElementaryStreamTypes.AUDIO&&(x+=m/G)}}if(L===0&&x===0){var X=k(_);if(X!=null&&X.references)return X.references.reduce(function(q,oe){return q+oe.info.duration||0},0)}return L||x}function u(_){var v=D(_,0),m=8;v&1&&(m+=4),v&4&&(m+=4);for(var L=0,x=D(_,4),p=0;p<x;p++){if(v&256){var f=D(_,m);L+=f,m+=4}v&512&&(m+=4),v&1024&&(m+=4),v&2048&&(m+=4)}return L}function a(_,v,m){A(v,["moof","traf"]).forEach(function(L){A(L,["tfhd"]).forEach(function(x){var p=D(x,4),f=_[p];if(!f)return;var h=f.timescale||9e4;A(L,["tfdt"]).forEach(function(o){var E=o.data[o.start],g=D(o,4);if(E===0)y(o,4,g-m*h);else{g*=Math.pow(2,32),g+=D(o,8),g-=m*h,g=Math.max(g,0);var S=Math.floor(g/(P+1)),M=Math.floor(g%(P+1));y(o,4,S),y(o,8,M)}})})})}function l(_){var v={valid:null,remainder:null},m=A(_,["moof"]);if(m){if(m.length<2)return v.remainder=_,v}else return v;var L=m[m.length-1];return v.valid=Object(Z.sliceUint8)(_,0,L.start-8),v.remainder=Object(Z.sliceUint8)(_,L.start-8),v}function d(_,v){var m=new Uint8Array(_.length+v.length);return m.set(_),m.set(v,_.length),m}},"./src/utils/output-filter.ts":function(le,$,R){"use strict";R.r($),R.d($,"default",function(){return Z});var Z=function(){function F(K,j){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=K,this.trackName=j}var P=F.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(j,N,D){(this.startTime===null||this.startTime>j)&&(this.startTime=j),this.endTime=N,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},P.reset=function(){this.cueRanges=[]},F}()},"./src/utils/texttrack-utils.ts":function(le,$,R){"use strict";R.r($),R.d($,"sendAddTrackEvent",function(){return F}),R.d($,"addCueToTrack",function(){return P}),R.d($,"clearCurrentCues",function(){return K}),R.d($,"removeCuesInRange",function(){return j}),R.d($,"getCuesInRange",function(){return D});var Z=R("./src/utils/logger.ts");function F(y,A){var k;try{k=new Event("addtrack")}catch(T){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=y,A.dispatchEvent(k)}function P(y,A){var k=y.mode;if(k==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(A.id))try{if(y.addCue(A),!y.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(C){Z.logger.debug("[texttrack-utils]: "+C);var T=new self.TextTrackCue(A.startTime,A.endTime,A.text);T.id=A.id,y.addCue(T)}k==="disabled"&&(y.mode=k)}function K(y){var A=y.mode;if(A==="disabled"&&(y.mode="hidden"),y.cues)for(var k=y.cues.length;k--;)y.removeCue(y.cues[k]);A==="disabled"&&(y.mode=A)}function j(y,A,k){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var C=D(y.cues,A,k),b=0;b<C.length;b++)y.removeCue(C[b]);T==="disabled"&&(y.mode=T)}function N(y,A){if(A<y[0].startTime)return 0;var k=y.length-1;if(A>y[k].endTime)return-1;for(var T=0,C=k;T<=C;){var b=Math.floor((C+T)/2);if(A<y[b].startTime)C=b-1;else if(A>y[b].startTime&&T<k)T=b+1;else return b}return y[T].startTime-A<A-y[C].startTime?T:C}function D(y,A,k){var T=[],C=N(y,A);if(C>-1)for(var b=C,u=y.length;b<u;b++){var a=y[b];if(a.startTime>=A&&a.endTime<=k)T.push(a);else if(a.startTime>k)return T}return T}},"./src/utils/time-ranges.ts":function(le,$,R){"use strict";R.r($);var Z={toString:function(P){for(var K="",j=P.length,N=0;N<j;N++)K+="["+P.start(N).toFixed(3)+","+P.end(N).toFixed(3)+"]";return K}};$.default=Z},"./src/utils/timescale-conversion.ts":function(le,$,R){"use strict";R.r($),R.d($,"toTimescaleFromBase",function(){return F}),R.d($,"toTimescaleFromScale",function(){return P}),R.d($,"toMsFromMpegTsClock",function(){return K}),R.d($,"toMpegTsClockFromTimescale",function(){return j});var Z=9e4;function F(N,D,y,A){y===void 0&&(y=1),A===void 0&&(A=!1);var k=N*D*y;return A?Math.round(k):k}function P(N,D,y,A){return y===void 0&&(y=1),A===void 0&&(A=!1),F(N,D,1/y,A)}function K(N,D){return D===void 0&&(D=!1),F(N,1e3,1/Z,D)}function j(N,D){return D===void 0&&(D=1),F(N,Z,1/D)}},"./src/utils/typed-array.ts":function(le,$,R){"use strict";R.r($),R.d($,"sliceUint8",function(){return Z});function Z(F,P,K){return Uint8Array.prototype.slice?F.slice(P,K):new Uint8Array(Array.prototype.slice.call(F,P,K))}},"./src/utils/vttcue.ts":function(le,$,R){"use strict";R.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var Z=["","lr","rl"],F=["start","middle","end","left","right"];function P(y,A){if(typeof A!="string")return!1;if(!Array.isArray(y))return!1;var k=A.toLowerCase();return~y.indexOf(k)?k:!1}function K(y){return P(Z,y)}function j(y){return P(F,y)}function N(y){for(var A=arguments.length,k=new Array(A>1?A-1:0),T=1;T<A;T++)k[T-1]=arguments[T];for(var C=1;C<arguments.length;C++){var b=arguments[C];for(var u in b)y[u]=b[u]}return y}function D(y,A,k){var T=this,C={enumerable:!0};T.hasBeenReset=!1;var b="",u=!1,a=y,l=A,d=k,_=null,v="",m=!0,L="auto",x="start",p=50,f="middle",h=50,o="middle";Object.defineProperty(T,"id",N({},C,{get:function(){return b},set:function(g){b=""+g}})),Object.defineProperty(T,"pauseOnExit",N({},C,{get:function(){return u},set:function(g){u=!!g}})),Object.defineProperty(T,"startTime",N({},C,{get:function(){return a},set:function(g){if(typeof g!="number")throw new TypeError("Start time must be set to a number.");a=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"endTime",N({},C,{get:function(){return l},set:function(g){if(typeof g!="number")throw new TypeError("End time must be set to a number.");l=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",N({},C,{get:function(){return d},set:function(g){d=""+g,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",N({},C,{get:function(){return _},set:function(g){_=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",N({},C,{get:function(){return v},set:function(g){var S=K(g);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"snapToLines",N({},C,{get:function(){return m},set:function(g){m=!!g,this.hasBeenReset=!0}})),Object.defineProperty(T,"line",N({},C,{get:function(){return L},set:function(g){if(typeof g!="number"&&g!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"lineAlign",N({},C,{get:function(){return x},set:function(g){var S=j(g);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");x=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"position",N({},C,{get:function(){return p},set:function(g){if(g<0||g>100)throw new Error("Position must be between 0 and 100.");p=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",N({},C,{get:function(){return f},set:function(g){var S=j(g);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");f=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",N({},C,{get:function(){return h},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");h=g,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",N({},C,{get:function(){return o},set:function(g){var S=j(g);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");o=S,this.hasBeenReset=!0}})),T.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,$,R){"use strict";R.r($),R.d($,"parseTimeStamp",function(){return P}),R.d($,"fixLineBreaks",function(){return A}),R.d($,"VTTParser",function(){return k});var Z=R("./src/utils/vttcue.ts"),F=function(){function T(){}var C=T.prototype;return C.decode=function(u,a){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},T}();function P(T){function C(u,a,l,d){return(u|0)*3600+(a|0)*60+(l|0)+parseFloat(d||0)}var b=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return b?parseFloat(b[2])>59?C(b[2],b[3],0,b[4]):C(b[1],b[2],b[3],b[4]):null}var K=function(){function T(){this.values=Object.create(null)}var C=T.prototype;return C.set=function(u,a){!this.get(u)&&a!==""&&(this.values[u]=a)},C.get=function(u,a,l){return l?this.has(u)?this.values[u]:a[l]:this.has(u)?this.values[u]:a},C.has=function(u){return u in this.values},C.alt=function(u,a,l){for(var d=0;d<l.length;++d)if(a===l[d]){this.set(u,a);break}},C.integer=function(u,a){/^-?\d+$/.test(a)&&this.set(u,parseInt(a,10))},C.percent=function(u,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var l=parseFloat(a);if(l>=0&&l<=100)return this.set(u,l),!0}return!1},T}();function j(T,C,b,u){var a=u?T.split(u):[T];for(var l in a){if(typeof a[l]!="string")continue;var d=a[l].split(b);if(d.length!==2)continue;var _=d[0],v=d[1];C(_,v)}}var N=new Z.default(0,0,""),D=N.align==="middle"?"middle":"center";function y(T,C,b){var u=T;function a(){var _=P(T);if(_===null)throw new Error("Malformed timestamp: "+u);return T=T.replace(/^[^\sa-zA-Z-]+/,""),_}function l(_,v){var m=new K;j(_,function(p,f){var h;switch(p){case"region":for(var o=b.length-1;o>=0;o--)if(b[o].id===f){m.set(p,b[o].region);break}break;case"vertical":m.alt(p,f,["rl","lr"]);break;case"line":h=f.split(","),m.integer(p,h[0]),m.percent(p,h[0])&&m.set("snapToLines",!1),m.alt(p,h[0],["auto"]),h.length===2&&m.alt("lineAlign",h[1],["start",D,"end"]);break;case"position":h=f.split(","),m.percent(p,h[0]),h.length===2&&m.alt("positionAlign",h[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":m.percent(p,f);break;case"align":m.alt(p,f,["start",D,"end","left","right"]);break}},/:/,/\s/),v.region=m.get("region",null),v.vertical=m.get("vertical","");var L=m.get("line","auto");L==="auto"&&N.line===-1&&(L=-1),v.line=L,v.lineAlign=m.get("lineAlign","start"),v.snapToLines=m.get("snapToLines",!0),v.size=m.get("size",100),v.align=m.get("align",D);var x=m.get("position","auto");x==="auto"&&N.position===50&&(x=v.align==="start"||v.align==="left"?0:v.align==="end"||v.align==="right"?100:50),v.position=x}function d(){T=T.replace(/^\s+/,"")}if(d(),C.startTime=a(),d(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);T=T.substr(3),d(),C.endTime=a(),d(),l(T,C)}function A(T){return T.replace(/<br(?: \/)?>/gi,`
`)}var k=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new F,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var C=T.prototype;return C.parse=function(u){var a=this;u&&(a.buffer+=a.decoder.decode(u,{stream:!0}));function l(){var x=a.buffer,p=0;for(x=A(x);p<x.length&&x[p]!=="\r"&&x[p]!==`
`;)++p;var f=x.substr(0,p);return x[p]==="\r"&&++p,x[p]===`
`&&++p,a.buffer=x.substr(p),f}function d(x){j(x,function(p,f){},/:/)}try{var _="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;_=l();var v=_.match(/^()?WEBVTT([ \t].*)?$/);if(!v||!v[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var m=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;m?m=!1:_=l();switch(a.state){case"HEADER":/:/.test(_)?d(_):_||(a.state="ID");continue;case"NOTE":_||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(_)){a.state="NOTE";break}if(!_)continue;if(a.cue=new Z.default(0,0,""),a.state="CUE",_.indexOf("-->")===-1){a.cue.id=_;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{y(_,a.cue,a.regionList)}catch(x){a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var L=_.indexOf("-->")!==-1;if(!_||L&&(m=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
`),a.cue.text+=_}continue;case"BADCUE":_||(a.state="ID")}}}catch(x){a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},C.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){u.onparsingerror&&u.onparsingerror(a)}return u.onflush&&u.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(le,$,R){"use strict";R.r($),R.d($,"generateCueId",function(){return k}),R.d($,"parseWebVTT",function(){return C});var Z=R("./src/polyfills/number.ts"),F=R("./src/utils/vttparser.ts"),P=R("./src/demux/id3.ts"),K=R("./src/utils/timescale-conversion.ts"),j=R("./src/remux/mp4-remuxer.ts"),N=/\r\n|\n\r|\n|\r/g,D=function(u,a,l){return l===void 0&&(l=0),u.substr(l,a.length)===a},y=function(u){var a=parseInt(u.substr(-3)),l=parseInt(u.substr(-6,2)),d=parseInt(u.substr(-9,2)),_=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(Z.isFiniteNumber)(a)||!Object(Z.isFiniteNumber)(l)||!Object(Z.isFiniteNumber)(d)||!Object(Z.isFiniteNumber)(_))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return a+=1e3*l,a+=60*1e3*d,a+=60*60*1e3*_,a},A=function(u){for(var a=5381,l=u.length;l;)a=a*33^u.charCodeAt(--l);return(a>>>0).toString()};function k(b,u,a){return A(b.toString())+A(u.toString())+A(a)}var T=function(u,a,l){var d=u[a],_=u[d.prevCC];if(!_||!_.new&&d.new){u.ccOffset=u.presentationOffset=d.start,d.new=!1;return}for(;(v=_)!==null&&v!==void 0&&v.new;){var v;u.ccOffset+=d.start-_.start,d.new=!1,d=_,_=u[d.prevCC]}u.presentationOffset=l};function C(b,u,a,l,d,_,v,m){var L=new F.VTTParser,x=Object(P.utf8ArrayToStr)(new Uint8Array(b)).trim().replace(N,`
`).split(`
`),p=[],f=Object(K.toMpegTsClockFromTimescale)(u,a),h="00:00.000",o=0,E=0,g,S=!0,M=!1;L.oncue=function(U){var G=l[d],V=l.ccOffset,O=(o-f)/9e4;if(G!=null&&G.new&&(E!==void 0?V=l.ccOffset=G.start:T(l,d,O)),O&&(V=O-l.presentationOffset),M){var I=U.endTime-U.startTime,X=Object(j.normalizePts)((U.startTime+V-E)*9e4,_*9e4)/9e4;U.startTime=X,U.endTime=X+I}var q=U.text.trim();U.text=decodeURIComponent(encodeURIComponent(q)),U.id||(U.id=k(U.startTime,U.endTime,q)),U.endTime>0&&p.push(U)},L.onparsingerror=function(U){g=U},L.onflush=function(){if(g){m(g);return}v(p)},x.forEach(function(U){if(S)if(D(U,"X-TIMESTAMP-MAP=")){S=!1,M=!0,U.substr(16).split(",").forEach(function(G){D(G,"LOCAL:")?h=G.substr(6):D(G,"MPEGTS:")&&(o=parseInt(G.substr(7)))});try{E=y(h)/1e3}catch(G){M=!1,g=G}return}else U===""&&(S=!1);L.parse(U+`
`)}),L.flush()}},"./src/utils/xhr-loader.ts":function(le,$,R){"use strict";R.r($);var Z=R("./src/utils/logger.ts"),F=R("./src/loader/load-stats.ts"),P=/^age:\s*[\d.]+\s*$/m,K=function(){function j(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 F.LoadStats,this.retryDelay=0}var N=j.prototype;return N.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},N.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()))},N.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},N.load=function(y,A,k){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=A,this.callbacks=k,this.retryDelay=A.retryDelay,this.loadInternal()},N.loadInternal=function(){var y=this.config,A=this.context;if(!y)return;var k=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var C=this.xhrSetup;try{if(C)try{C(k,A.url)}catch(a){k.open("GET",A.url,!0),C(k,A.url)}k.readyState||k.open("GET",A.url,!0);var b=this.context.headers;if(b)for(var u in b)k.setRequestHeader(u,b[u])}catch(a){this.callbacks.onError({code:k.status,text:a.message},A,k);return}A.rangeEnd&&k.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),k.onreadystatechange=this.readystatechange.bind(this),k.onprogress=this.loadprogress.bind(this),k.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),k.send()},N.readystatechange=function(){var y=this.context,A=this.loader,k=this.stats;if(!y||!A)return;var T=A.readyState,C=this.config;if(k.aborted)return;if(T>=2)if(self.clearTimeout(this.requestTimeout),k.loading.first===0&&(k.loading.first=Math.max(self.performance.now(),k.loading.start)),T===4){A.onreadystatechange=null,A.onprogress=null;var b=A.status;if(b>=200&&b<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var u,a;if(y.responseType==="arraybuffer"?(u=A.response,a=u.byteLength):(u=A.responseText,a=u.length),k.loaded=k.total=a,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(k,y,u,A),!this.callbacks)return;var d={url:A.responseURL,data:u};this.callbacks.onSuccess(d,k,y,A)}else k.retry>=C.maxRetry||b>=400&&b<499?(Z.logger.error(b+" while loading "+y.url),this.callbacks.onError({code:b,text:A.statusText},y,A)):(Z.logger.warn(b+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,C.maxRetryDelay),k.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),C.timeout)},N.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))},N.loadprogress=function(y){var A=this.stats;A.loaded=y.loaded,y.lengthComputable&&(A.total=y.total)},N.getCacheAge=function(){var y=null;if(this.loader&&P.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");y=A?parseFloat(A):null}return y},j}();$.default=K}}).default})},vHTk:function(ut,Ze,re){ut.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},wzkS:function(ut,Ze,re){"use strict";re.d(Ze,"c",function(){return F}),re.d(Ze,"b",function(){return P}),re.d(Ze,"d",function(){return K}),re.d(Ze,"a",function(){return N}),re.d(Ze,"e",function(){return D});var le=re("9og8"),$=re("WmNS"),R=re.n($),Z=re("ErOA");function F(y){return Object(Z.c)("libraries/".concat(y,".json"))}function P(){return Object(Z.c)("library_tags.json")}function K(y){return j.apply(this,arguments)}function j(){return j=Object(le.a)(R.a.mark(function y(A){var k;return R.a.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,Object(Z.b)("attachments/".concat(A,".json"));case 2:return k=C.sent,C.abrupt("return",k.status===0);case 4:case"end":return C.stop()}},y)})),j.apply(this,arguments)}function N(y){return Object(Z.f)("libraries.json",y)}function D(y,A){return Object(Z.g)("libraries/".concat(y,".json"),A)}},y5JW:function(ut,Ze,re){"use strict";re.d(Ze,"c",function(){return b}),re.d(Ze,"a",function(){return u});var le=re("DZo9"),$=re("8z0m"),R=re("+L6B"),Z=re("2/Rp"),F=re("9og8"),P=re("miYZ"),K=re("tsqr"),j=re("k1fw"),N=re("oBTY"),D=re("WmNS"),y=re.n(D),A=re("cDcd"),k=re.n(A),T=re("m3rI"),C=re("wzkS"),b="\u3000\u3000";function u(a){var l=["Bytes","KB","MB","GB","TB"];if(a==0)return"0 Byte";var d=parseInt(""+Math.floor(Math.log(a)/Math.log(1024)),10);return(a/Math.pow(1024,d)).toFixed(1)+" "+l[d]}Ze.b=function(a){var l=a.value,d=l===void 0?[]:l,_=a.action,v=a.onChange,m=a.className,L=a.maxSize,x=L===void 0?150:L,p=a.title,f=p===void 0?"\u6587\u4EF6\u4E0A\u4F20":p,h=a.accept,o=h===void 0?null:h,E={multiple:!1,fileList:d,accept:o,withCredentials:!0,beforeUpload:function(M){var U=M.size/1024/1024;return!0},action:"".concat(T.a.API_SERVER,"/api/attachments.json"),onChange:function(M){var U,G,V=Object(N.a)(M.fileList);if(V=V.map(function(X){return X.name.indexOf(b)===-1&&(X.name="".concat(X.name).concat(b).concat(u(X.size))),Object(j.a)({},X)}),M.file.status==="done"&&((U=M.file)===null||U===void 0||((G=U.response)===null||G===void 0)?void 0:G.status)===-1){var O,I;K.b.error((O=M.file)===null||O===void 0||((I=O.response)===null||I===void 0)?void 0:I.message),v([]);return}v(V)},onRemove:function(){var S=Object(F.a)(y.a.mark(function U(G){var V,O,I;return y.a.wrap(function(q){for(;;)switch(q.prev=q.next){case 0:if(V=G.size/1024/1024,!(G.status==="uploading")){q.next=3;break}return q.abrupt("return",!0);case 3:if(V<x){q.next=7;break}return q.abrupt("return",!0);case 7:if(O=G.response?G.response.id:G.uid,!O){q.next=15;break}return q.next=11,Object(C.d)(G.response?G.response.id:G.id);case 11:return I=q.sent,q.abrupt("return",I);case 15:return q.abrupt("return",!0);case 16:case"end":return q.stop()}},U)}));function M(U){return S.apply(this,arguments)}return M}()};function g(S){S.preventDefault(),S.stopPropagation()}return k.a.createElement("div",{className:"single-upload ".concat(m||"")},k.a.createElement($.a,E,k.a.createElement(Z.a,{type:"primary",title:d.length>0?"\u6BCF\u6B21\u53EA\u80FD\u4E0A\u4F20\u4E00\u4E2A\u8D44\u6E90\uFF0C \u5220\u9664\u4E0B\u9762\u8D44\u6E90\u53EF\u91CD\u65B0\u4E0A\u4F20 ":"",disabled:d.length>0,ghost:!0},f),k.a.createElement("span",{onClick:g,style:{marginLeft:10}},"(\u5355\u4E2A\u6587\u4EF6\u6700\u5927",x,"M)"," ")))}},"yTi+":function(ut,Ze,re){ut.exports=re.p+"static/AssistantCode3.fdd8db3c.jpeg"}}]);