You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
361 lines
964 KiB
361 lines
964 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[198,7,8],{"+NIl":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";ae.defineMode("stex",function($,R){"use strict";function X(T,A){T.cmdState.push(A)}function N(T){return T.cmdState.length>0?T.cmdState[T.cmdState.length-1]:null}function I(T){var A=T.cmdState.pop();A&&A.closeBracket()}function z(T){for(var A=T.cmdState,C=A.length-1;C>=0;C--){var h=A[C];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function B(T,A,C){return function(){this.name=T,this.bracketNo=0,this.style=A,this.styles=C,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var O={};O.importmodule=B("importmodule","tag",["string","builtin"]),O.documentclass=B("documentclass","tag",["","atom"]),O.usepackage=B("usepackage","tag",["atom"]),O.begin=B("begin","tag",["atom"]),O.end=B("end","tag",["atom"]),O.label=B("label","tag",["atom"]),O.ref=B("ref","tag",["atom"]),O.eqref=B("eqref","tag",["atom"]),O.cite=B("cite","tag",["atom"]),O.bibitem=B("bibitem","tag",["atom"]),O.Bibitem=B("Bibitem","tag",["atom"]),O.RBibitem=B("RBibitem","tag",["atom"]),O.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function D(T,A){T.f=A}function E(T,A){var C;if(T.match(/^\\[a-zA-Z@]+/)){var h=T.current().slice(1);return C=O.hasOwnProperty(h)?O[h]:O.DEFAULT,C=new C,X(A,C),D(A,k),C.style}if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/\\]/))return"tag";if(T.match("\\["))return D(A,function(c,d){return L(c,d,"\\]")}),"keyword";if(T.match("\\("))return D(A,function(c,d){return L(c,d,"\\)")}),"keyword";if(T.match("$$"))return D(A,function(c,d){return L(c,d,"$$")}),"keyword";if(T.match("$"))return D(A,function(c,d){return L(c,d,"$")}),"keyword";var o=T.next();if(o=="%")return T.skipToEnd(),"comment";if(o=="}"||o=="]"){if(C=N(A),C)C.closeBracket(o),D(A,k);else return"error";return"bracket"}else return o=="{"||o=="["?(C=O.DEFAULT,C=new C,X(A,C),"bracket"):/\d/.test(o)?(T.eatWhile(/[\w.%]/),"atom"):(T.eatWhile(/[\w\-_]/),C=z(A),C.name=="begin"&&(C.argument=T.current()),C.styleIdentifier())}function L(T,A,C){if(T.eatSpace())return null;if(C&&T.match(C))return D(A,E),"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 h=T.next();return h=="{"||h=="}"||h=="["||h=="]"||h=="("||h==")"?"bracket":h=="%"?(T.skipToEnd(),"comment"):"error"}function k(T,A){var C=T.peek(),h;return C=="{"||C=="["?(h=N(A),h.openBracket(C),T.eat(C),D(A,E),"bracket"):/[ \t\r]/.test(C)?(T.eat(C),null):(D(A,E),I(A),E(T,A))}return{startState:function(){var T=R.inMathMode?function(A,C){return L(A,C)}:E;return{cmdState:[],f:T}},copyState:function(T){return{cmdState:T.cmdState.slice(),f:T.f}},token:function(T,A){return A.f(T,A)},blankLine:function(T){T.f=E,T.cmdState.length=0},lineComment:"%"}}),ae.defineMIME("text/x-stex","stex"),ae.defineMIME("text/x-latex","stex")})},"+yhJ":function(At,ht,re){At.exports=re.p+"static/xixi.d492fb65.svg"},"0eGx":function(At,ht,re){At.exports=re.p+"static/zhong.c1924b73.svg"},"19Vz":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){ae.defineOption("placeholder","",function(B,O,D){var E=D&&D!=ae.Init;if(O&&!E)B.on("blur",N),B.on("change",I),B.on("swapDoc",I),ae.on(B.getInputField(),"compositionupdate",B.state.placeholderCompose=function(){X(B)}),I(B);else if(!O&&E){B.off("blur",N),B.off("change",I),B.off("swapDoc",I),ae.off(B.getInputField(),"compositionupdate",B.state.placeholderCompose),$(B);var L=B.getWrapperElement();L.className=L.className.replace(" CodeMirror-empty","")}O&&!B.hasFocus()&&N(B)});function $(B){B.state.placeholder&&(B.state.placeholder.parentNode.removeChild(B.state.placeholder),B.state.placeholder=null)}function R(B){$(B);var O=B.state.placeholder=document.createElement("pre");O.style.cssText="height: 0; overflow: visible",O.style.direction=B.getOption("direction"),O.className="CodeMirror-placeholder CodeMirror-line-like";var D=B.getOption("placeholder");typeof D=="string"&&(D=document.createTextNode(D)),O.appendChild(D),B.display.lineSpace.insertBefore(O,B.display.lineSpace.firstChild)}function X(B){setTimeout(function(){var O=!1,D=B.getInputField();D.nodeName=="TEXTAREA"?O=!D.value:B.lineCount()==1&&(O=!/[^\u200b]/.test(D.querySelector(".CodeMirror-line").textContent)),O?R(B):$(B)},20)}function N(B){z(B)&&R(B)}function I(B){var O=B.getWrapperElement(),D=z(B);O.className=O.className.replace(" CodeMirror-empty","")+(D?" CodeMirror-empty":""),D?R(B):$(B)}function z(B){return B.lineCount()===1&&B.getLine(0)===""}})},"1eCo":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"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};ae.defineMode("xml",function(X,N){var I=X.indentUnit,z={},B=N.htmlMode?$:R;for(var O in B)z[O]=B[O];for(var O in N)z[O]=N[O];var D,E;function L(a,b){function v(H){return b.tokenize=H,H(a,b)}var S=a.next();if(S=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?v(A("atom","]]>")):null:a.match("--")?v(A("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),v(C(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=A("meta","?>"),"meta"):(D=a.eat("/")?"closeTag":"openTag",b.tokenize=k,"tag bracket");if(S=="&"){var M;return a.eat("#")?a.eat("x")?M=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):M=a.eatWhile(/[\d]/)&&a.eat(";"):M=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),M?"atom":"error"}else return a.eatWhile(/[^&<]/),null}L.isInText=!0;function k(a,b){var v=a.next();if(v==">"||v=="/"&&a.eat(">"))return b.tokenize=L,D=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return D="equals",null;if(v=="<"){b.tokenize=L,b.state=d,b.tagName=b.tagStart=null;var S=b.tokenize(a,b);return S?S+" tag error":"tag error"}else return/[\'\"]/.test(v)?(b.tokenize=T(v),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function T(a){var b=function(v,S){for(;!v.eol();)if(v.next()==a){S.tokenize=k;break}return"string"};return b.isInAttribute=!0,b}function A(a,b){return function(v,S){for(;!v.eol();){if(v.match(b)){S.tokenize=L;break}v.next()}return a}}function C(a){return function(b,v){for(var S;(S=b.next())!=null;){if(S=="<")return v.tokenize=C(a+1),v.tokenize(b,v);if(S==">")if(a==1){v.tokenize=L;break}else return v.tokenize=C(a-1),v.tokenize(b,v)}return"meta"}}function h(a,b,v){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=v,(z.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function c(a,b){for(var v;;){if(!a.context)return;if(v=a.context.tagName,!z.contextGrabbers.hasOwnProperty(v)||!z.contextGrabbers[v].hasOwnProperty(b))return;o(a)}}function d(a,b,v){return a=="openTag"?(v.tagStart=b.column(),_):a=="closeTag"?y:d}function _(a,b,v){return a=="word"?(v.tagName=b.current(),E="tag",x):z.allowMissingTagName&&a=="endTag"?(E="tag bracket",x(a,b,v)):(E="error",_)}function y(a,b,v){if(a=="word"){var S=b.current();return v.context&&v.context.tagName!=S&&z.implicitlyClosed.hasOwnProperty(v.context.tagName)&&o(v),v.context&&v.context.tagName==S||z.matchClosing===!1?(E="tag",m):(E="tag error",l)}else return z.allowMissingTagName&&a=="endTag"?(E="tag bracket",m(a,b,v)):(E="error",l)}function m(a,b,v){return a!="endTag"?(E="error",m):(o(v),d)}function l(a,b,v){return E="error",m(a,b,v)}function x(a,b,v){if(a=="word")return E="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var S=v.tagName,M=v.tagStart;return v.tagName=v.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(S)?c(v,S):(c(v,S),v.context=new h(v,S,M==v.indented)),d}return E="error",x}function f(a,b,v){return a=="equals"?p:(z.allowMissing||(E="error"),x(a,b,v))}function p(a,b,v){return a=="string"?s:a=="word"&&z.allowUnquoted?(E="string",x):(E="error",x(a,b,v))}function s(a,b,v){return a=="string"?s:x(a,b,v)}return{startState:function(a){var b={tokenize:L,state:d,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;D=null;var v=b.tokenize(a,b);return(v||D)&&v!="comment"&&(E=null,b.state=b.state(D||v,a,b),E&&(v=E=="error"?v+" error":E)),v},indent:function(a,b,v){var S=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+I;if(S&&S.noIndent)return ae.Pass;if(a.tokenize!=k&&a.tokenize!=L)return v?v.match(/^(\s*)/)[0].length:0;if(a.tagName)return z.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+I*(z.multilineTagIndentFactor||1);if(z.alignCDATA&&/<!\[CDATA\[/.test(b))return 0;var M=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);if(M&&M[1])for(;S;)if(S.tagName==M[2]){S=S.prev;break}else if(z.implicitlyClosed.hasOwnProperty(S.tagName))S=S.prev;else break;else if(M)for(;S;){var H=z.contextGrabbers[S.tagName];if(H&&H.hasOwnProperty(M[2]))S=S.prev;else break}for(;S&&S.prev&&!S.startOfLine;)S=S.prev;return S?S.indent+I:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:z.htmlMode?"html":"xml",helperType:z.htmlMode?"html":"xml",skipAttribute:function(a){a.state==p&&(a.state=x)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],v=a.context;v;v=v.prev)v.tagName&&b.push(v.tagName);return b.reverse()}}}),ae.defineMIME("text/xml","xml"),ae.defineMIME("application/xml","xml"),ae.mimeModes.hasOwnProperty("text/html")||ae.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"6+eU":function(At,ht,re){"use strict";re.d(ht,"a",function(){return m});var ae=re("wx14"),$=re("rePB"),R=re("VTBJ"),X=re("1OyB"),N=re("vuIU"),I=re("Ji7U"),z=re("LK+K"),B=re("q1tI"),O=re.n(B),D=re("TSYQ"),E=re.n(D),L=function(x){var f,p="".concat(x.rootPrefixCls,"-item"),s=E()(p,"".concat(p,"-").concat(x.page),(f={},Object($.a)(f,"".concat(p,"-active"),x.active),Object($.a)(f,x.className,!!x.className),Object($.a)(f,"".concat(p,"-disabled"),!x.page),f)),a=function(){x.onClick(x.page)},b=function(S){x.onKeyPress(S,x.onClick,x.page)};return O.a.createElement("li",{title:x.showTitle?x.page:null,className:s,onClick:a,onKeyPress:b,tabIndex:"0"},x.itemRender(x.page,"page",O.a.createElement("a",{rel:"nofollow"},x.page)))},k=L,T={ZERO:48,NINE:57,NUMPAD_ZERO:96,NUMPAD_NINE:105,BACKSPACE:8,DELETE:46,ENTER:13,ARROW_UP:38,ARROW_DOWN:40},A=function(l){Object(I.a)(f,l);var x=Object(z.a)(f);function f(){var p;Object(X.a)(this,f);for(var s=arguments.length,a=new Array(s),b=0;b<s;b++)a[b]=arguments[b];return p=x.call.apply(x,[this].concat(a)),p.state={goInputText:""},p.buildOptionText=function(v){return"".concat(v," ").concat(p.props.locale.items_per_page)},p.changeSize=function(v){p.props.changeSize(Number(v))},p.handleChange=function(v){p.setState({goInputText:v.target.value})},p.handleBlur=function(v){var S=p.props,M=S.goButton,H=S.quickGo,V=S.rootPrefixCls,Q=p.state.goInputText;if(M||Q==="")return;if(v.relatedTarget&&(v.relatedTarget.className.indexOf("".concat(V,"-prev"))>=0||v.relatedTarget.className.indexOf("".concat(V,"-next"))>=0))return;p.setState({goInputText:""}),H(p.getValidValue())},p.go=function(v){var S=p.state.goInputText;if(S==="")return;(v.keyCode===T.ENTER||v.type==="click")&&(p.setState({goInputText:""}),p.props.quickGo(p.getValidValue()))},p}return Object(N.a)(f,[{key:"getValidValue",value:function(){var s=this.state,a=s.goInputText,b=s.current;return!a||isNaN(a)?b:Number(a)}},{key:"getPageSizeOptions",value:function(){var s=this.props,a=s.pageSize,b=s.pageSizeOptions;return b.some(function(v){return v.toString()===a.toString()})?b:b.concat([a.toString()]).sort(function(v,S){var M=isNaN(Number(v))?0:Number(v),H=isNaN(Number(S))?0:Number(S);return M-H})}},{key:"render",value:function(){var s=this,a=this.props,b=a.pageSize,v=a.locale,S=a.rootPrefixCls,M=a.changeSize,H=a.quickGo,V=a.goButton,Q=a.selectComponentClass,G=a.buildOptionText,W=a.selectPrefixCls,q=a.disabled,oe=this.state.goInputText,fe="".concat(S,"-options"),ve=Q,De=null,Ee=null,_e=null;if(!M&&!H)return null;var Te=this.getPageSizeOptions();if(M&&ve){var Ce=Te.map(function(me,ne){return O.a.createElement(ve.Option,{key:ne,value:me.toString()},(G||s.buildOptionText)(me))});De=O.a.createElement(ve,{disabled:q,prefixCls:W,showSearch:!1,className:"".concat(fe,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(b||Te[0]).toString(),onChange:this.changeSize,getPopupContainer:function(ne){return ne.parentNode}},Ce)}return H&&(V&&(_e=typeof V=="boolean"?O.a.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:q,className:"".concat(fe,"-quick-jumper-button")},v.jump_to_confirm):O.a.createElement("span",{onClick:this.go,onKeyUp:this.go},V)),Ee=O.a.createElement("div",{className:"".concat(fe,"-quick-jumper")},v.jump_to,O.a.createElement("input",{disabled:q,type:"text",value:oe,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur}),v.page,_e)),O.a.createElement("li",{className:"".concat(fe)},De,Ee)}}]),f}(O.a.Component);A.defaultProps={pageSizeOptions:["10","20","50","100"]};var C=A,h=re("N2Kk");function o(){}function c(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}function d(l,x,f){return f}function _(l,x,f){var p=typeof l=="undefined"?x.pageSize:l;return Math.floor((f.total-1)/p)+1}var y=function(l){Object(I.a)(f,l);var x=Object(z.a)(f);function f(p){var s;Object(X.a)(this,f),s=x.call(this,p),s.getJumpPrevPage=function(){return Math.max(1,s.state.current-(s.props.showLessItems?3:5))},s.getJumpNextPage=function(){return Math.min(_(void 0,s.state,s.props),s.state.current+(s.props.showLessItems?3:5))},s.getItemIcon=function(M,H){var V=s.props.prefixCls,Q=M||O.a.createElement("button",{type:"button","aria-label":H,className:"".concat(V,"-item-link")});return typeof M=="function"&&(Q=O.a.createElement(M,Object(R.a)({},s.props))),Q},s.savePaginationNode=function(M){s.paginationNode=M},s.isValid=function(M){return c(M)&&M!==s.state.current},s.shouldDisplayQuickJumper=function(){var M=s.props,H=M.showQuickJumper,V=M.pageSize,Q=M.total;return Q<=V?!1:H},s.handleKeyDown=function(M){(M.keyCode===T.ARROW_UP||M.keyCode===T.ARROW_DOWN)&&M.preventDefault()},s.handleKeyUp=function(M){var H=s.getValidValue(M),V=s.state.currentInputValue;H!==V&&s.setState({currentInputValue:H}),M.keyCode===T.ENTER?s.handleChange(H):M.keyCode===T.ARROW_UP?s.handleChange(H-1):M.keyCode===T.ARROW_DOWN&&s.handleChange(H+1)},s.changePageSize=function(M){var H=s.state.current,V=_(M,s.state,s.props);H=H>V?V:H,V===0&&(H=s.state.current),typeof M=="number"&&("pageSize"in s.props||s.setState({pageSize:M}),"current"in s.props||s.setState({current:H,currentInputValue:H})),s.props.onShowSizeChange(H,M),"onChange"in s.props&&s.props.onChange&&s.props.onChange(H,M)},s.handleChange=function(M){var H=s.props.disabled,V=M;if(s.isValid(V)&&!H){var Q=_(void 0,s.state,s.props);V>Q?V=Q:V<1&&(V=1),"current"in s.props||s.setState({current:V,currentInputValue:V});var G=s.state.pageSize;return s.props.onChange(V,G),V}return s.state.current},s.prev=function(){s.hasPrev()&&s.handleChange(s.state.current-1)},s.next=function(){s.hasNext()&&s.handleChange(s.state.current+1)},s.jumpPrev=function(){s.handleChange(s.getJumpPrevPage())},s.jumpNext=function(){s.handleChange(s.getJumpNextPage())},s.hasPrev=function(){return s.state.current>1},s.hasNext=function(){return s.state.current<_(void 0,s.state,s.props)},s.runIfEnter=function(M,H){if(M.key==="Enter"||M.charCode===13){for(var V=arguments.length,Q=new Array(V>2?V-2:0),G=2;G<V;G++)Q[G-2]=arguments[G];H.apply(void 0,Q)}},s.runIfEnterPrev=function(M){s.runIfEnter(M,s.prev)},s.runIfEnterNext=function(M){s.runIfEnter(M,s.next)},s.runIfEnterJumpPrev=function(M){s.runIfEnter(M,s.jumpPrev)},s.runIfEnterJumpNext=function(M){s.runIfEnter(M,s.jumpNext)},s.handleGoTO=function(M){(M.keyCode===T.ENTER||M.type==="click")&&s.handleChange(s.state.currentInputValue)};var a=p.onChange!==o,b="current"in p;b&&!a&&console.warn("Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.");var v=p.defaultCurrent;"current"in p&&(v=p.current);var S=p.defaultPageSize;return"pageSize"in p&&(S=p.pageSize),v=Math.min(v,_(S,void 0,p)),s.state={current:v,currentInputValue:v,pageSize:S},s}return Object(N.a)(f,[{key:"componentDidUpdate",value:function(s,a){var b=this.props.prefixCls;if(a.current!==this.state.current&&this.paginationNode){var v=this.paginationNode.querySelector(".".concat(b,"-item-").concat(a.current));v&&document.activeElement===v&&v.blur()}}},{key:"getValidValue",value:function(s){var a=s.target.value,b=_(void 0,this.state,this.props),v=this.state.currentInputValue,S;return a===""?S=a:isNaN(Number(a))?S=v:a>=b?S=b:S=Number(a),S}},{key:"getShowSizeChanger",value:function(){var s=this.props,a=s.showSizeChanger,b=s.total,v=s.totalBoundaryShowSizeChanger;return typeof a!="undefined"?a:b>v}},{key:"renderPrev",value:function(s){var a=this.props,b=a.prevIcon,v=a.itemRender,S=v(s,"prev",this.getItemIcon(b,"prev page")),M=!this.hasPrev();return Object(B.isValidElement)(S)?Object(B.cloneElement)(S,{disabled:M}):S}},{key:"renderNext",value:function(s){var a=this.props,b=a.nextIcon,v=a.itemRender,S=v(s,"next",this.getItemIcon(b,"next page")),M=!this.hasNext();return Object(B.isValidElement)(S)?Object(B.cloneElement)(S,{disabled:M}):S}},{key:"render",value:function(){var s=this,a=this.props,b=a.prefixCls,v=a.className,S=a.style,M=a.disabled,H=a.hideOnSinglePage,V=a.total,Q=a.locale,G=a.showQuickJumper,W=a.showLessItems,q=a.showTitle,oe=a.showTotal,fe=a.simple,ve=a.itemRender,De=a.showPrevNextJumpers,Ee=a.jumpPrevIcon,_e=a.jumpNextIcon,Te=a.selectComponentClass,Ce=a.selectPrefixCls,me=a.pageSizeOptions,ne=this.state,Ae=ne.current,rt=ne.pageSize,$e=ne.currentInputValue;if(H===!0&&V<=rt)return null;var Xe=_(void 0,this.state,this.props),Ve=[],Le=null,Me=null,ze=null,Ge=null,He=null,Be=G&&G.goButton,Pe=W?1:2,pt=Ae-1>0?Ae-1:0,it=Ae+1<Xe?Ae+1:Xe,et=Object.keys(this.props).reduce(function(ee,te){return(te.substr(0,5)==="data-"||te.substr(0,5)==="aria-"||te==="role")&&(ee[te]=s.props[te]),ee},{});if(fe)return Be&&(typeof Be=="boolean"?He=O.a.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Q.jump_to_confirm):He=O.a.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Be),He=O.a.createElement("li",{title:q?"".concat(Q.jump_to).concat(Ae,"/").concat(Xe):null,className:"".concat(b,"-simple-pager")},He)),O.a.createElement("ul",Object(ae.a)({className:E()(b,"".concat(b,"-simple"),Object($.a)({},"".concat(b,"-disabled"),M),v),style:S,ref:this.savePaginationNode},et),O.a.createElement("li",{title:q?Q.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:E()("".concat(b,"-prev"),Object($.a)({},"".concat(b,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(pt)),O.a.createElement("li",{title:q?"".concat(Ae,"/").concat(Xe):null,className:"".concat(b,"-simple-pager")},O.a.createElement("input",{type:"text",value:$e,disabled:M,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,size:"3"}),O.a.createElement("span",{className:"".concat(b,"-slash")},"/"),Xe),O.a.createElement("li",{title:q?Q.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:E()("".concat(b,"-next"),Object($.a)({},"".concat(b,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(it)),He);if(Xe<=3+Pe*2){var at={locale:Q,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:q,itemRender:ve};Xe||Ve.push(O.a.createElement(k,Object(ae.a)({},at,{key:"noPager",page:Xe,className:"".concat(b,"-disabled")})));for(var Et=1;Et<=Xe;Et+=1){var ct=Ae===Et;Ve.push(O.a.createElement(k,Object(ae.a)({},at,{key:Et,page:Et,active:ct})))}}else{var dt=W?Q.prev_3:Q.prev_5,we=W?Q.next_3:Q.next_5;De&&(Le=O.a.createElement("li",{title:q?dt:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:E()("".concat(b,"-jump-prev"),Object($.a)({},"".concat(b,"-jump-prev-custom-icon"),!!Ee))},ve(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(Ee,"prev page"))),Me=O.a.createElement("li",{title:q?we:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:E()("".concat(b,"-jump-next"),Object($.a)({},"".concat(b,"-jump-next-custom-icon"),!!_e))},ve(this.getJumpNextPage(),"jump-next",this.getItemIcon(_e,"next page")))),Ge=O.a.createElement(k,{locale:Q,last:!0,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Xe,page:Xe,active:!1,showTitle:q,itemRender:ve}),ze=O.a.createElement(k,{locale:Q,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:q,itemRender:ve});var gt=Math.max(1,Ae-Pe),lt=Math.min(Ae+Pe,Xe);Ae-1<=Pe&&(lt=1+Pe*2),Xe-Ae<=Pe&&(gt=Xe-Pe*2);for(var Re=gt;Re<=lt;Re+=1){var je=Ae===Re;Ve.push(O.a.createElement(k,{locale:Q,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Re,page:Re,active:je,showTitle:q,itemRender:ve}))}Ae-1>=Pe*2&&Ae!==1+2&&(Ve[0]=Object(B.cloneElement)(Ve[0],{className:"".concat(b,"-item-after-jump-prev")}),Ve.unshift(Le)),Xe-Ae>=Pe*2&&Ae!==Xe-2&&(Ve[Ve.length-1]=Object(B.cloneElement)(Ve[Ve.length-1],{className:"".concat(b,"-item-before-jump-next")}),Ve.push(Me)),gt!==1&&Ve.unshift(ze),lt!==Xe&&Ve.push(Ge)}var ge=null;oe&&(ge=O.a.createElement("li",{className:"".concat(b,"-total-text")},oe(V,[V===0?0:(Ae-1)*rt+1,Ae*rt>V?V:Ae*rt])));var de=!this.hasPrev()||!Xe,pe=!this.hasNext()||!Xe;return O.a.createElement("ul",Object(ae.a)({className:E()(b,v,Object($.a)({},"".concat(b,"-disabled"),M)),style:S,unselectable:"unselectable",ref:this.savePaginationNode},et),ge,O.a.createElement("li",{title:q?Q.prev_page:null,onClick:this.prev,tabIndex:de?null:0,onKeyPress:this.runIfEnterPrev,className:E()("".concat(b,"-prev"),Object($.a)({},"".concat(b,"-disabled"),de)),"aria-disabled":de},this.renderPrev(pt)),Ve,O.a.createElement("li",{title:q?Q.next_page:null,onClick:this.next,tabIndex:pe?null:0,onKeyPress:this.runIfEnterNext,className:E()("".concat(b,"-next"),Object($.a)({},"".concat(b,"-disabled"),pe)),"aria-disabled":pe},this.renderNext(it)),O.a.createElement(C,{disabled:M,locale:Q,rootPrefixCls:b,selectComponentClass:Te,selectPrefixCls:Ce,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:Ae,pageSize:rt,pageSizeOptions:me,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:Be}))}}],[{key:"getDerivedStateFromProps",value:function(s,a){var b={};if("current"in s&&(b.current=s.current,s.current!==a.current&&(b.currentInputValue=b.current)),"pageSize"in s&&s.pageSize!==a.pageSize){var v=a.current,S=_(s.pageSize,a,s);v=v>S?S:v,"current"in s||(b.current=v,b.currentInputValue=v),b.pageSize=s.pageSize}return b}}]),f}(O.a.Component);y.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:o,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:o,locale:h.a,style:{},itemRender:d,totalBoundaryShowSizeChanger:50};var m=y},"6K3P":function(At,ht,re){At.exports=re.p+"static/jinshi.9b74f304.svg"},"7Cbv":function(At,ht,re){"use strict";var ae=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(!ae)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ae($)}var X=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function N(k){return typeof k=="string"&&X.test(k)}for(var I=N,z=[],B=0;B<256;++B)z.push((B+256).toString(16).substr(1));function O(k){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(z[k[T+0]]+z[k[T+1]]+z[k[T+2]]+z[k[T+3]]+"-"+z[k[T+4]]+z[k[T+5]]+"-"+z[k[T+6]]+z[k[T+7]]+"-"+z[k[T+8]]+z[k[T+9]]+"-"+z[k[T+10]]+z[k[T+11]]+z[k[T+12]]+z[k[T+13]]+z[k[T+14]]+z[k[T+15]]).toLowerCase();if(!I(A))throw TypeError("Stringified UUID is invalid");return A}var D=O;function E(k,T,A){k=k||{};var C=k.random||(k.rng||R)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,T){A=A||0;for(var h=0;h<16;++h)T[A+h]=C[h];return T}return D(C)}var L=ht.a=E},"7ahc":function(At,ht,re){"use strict";re.d(ht,"a",function(){return _});var ae=re("k1fw"),$=re("0Owb"),R=re("+L6B"),X=re("2/Rp"),N=re("y8nQ"),I=re("Vl3Y"),z=re("tJVT"),B=re("OaEy"),O=re("2fM7"),D=re("q1tI"),E=re.n(D),L=re("VrN/"),k=re.n(L),T=re("p77/"),A=re.n(T),C=re("c5Ni"),h=re.n(C),o=O.a.Option,c={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"]};ht.b=function(y){var m=y.callback,l=y.onCancel,x=Object(D.useState)("python"),f=Object(z.a)(x,2),p=f[0],s=f[1];function a(v){s(d[v][1])}function b(v){m(v)}return E.a.createElement(I.a,Object($.a)({},c,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),E.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},E.a.createElement(O.a,{onChange:a},Object.keys(d).map(function(v){return E.a.createElement(o,{key:v,value:v},d[v][0])}))),E.a.createElement(I.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},E.a.createElement(_,{mode:p})),E.a.createElement("div",{className:"flex-container flex-end"},E.a.createElement(X.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),E.a.createElement(X.a,{type:"ghost",onClick:l},"\u53D6\u6D88")))};function _(y){var m=y.value,l=y.onChange,x=y.mode,f=y.options,p=f===void 0?{}:f,s=Object(D.useRef)(),a=Object(D.useState)(),b=Object(z.a)(a,2),v=b[0],S=b[1];return Object(D.useEffect)(function(){if(v){function M(H){var V=H.getValue();l&&l(V)}return v.on("change",M),function(){v.off("change",M)}}},[v,l]),Object(D.useEffect)(function(){v&&v.setOption("mode",x)},[v,x]),Object(D.useEffect)(function(){v&&((m!==v.getValue()||m==="")&&setTimeout(function(){v.setValue(m||" ")},300))},[v,m]),Object(D.useEffect)(function(){if(s.current&&!v){var M=k.a.fromTextArea(s.current,Object(ae.a)({mode:x,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));S(M)}},[s.current,v]),E.a.createElement("div",{className:"my-codemirror-container"},E.a.createElement("textarea",{ref:s}))}},"7ixt":function(At,ht,re){"use strict";re.d(ht,"a",function(){return R});var ae={adjustX:1,adjustY:1},$=[0,0],R={left:{points:["cr","cl"],overflow:ae,offset:[-4,0],targetOffset:$},right:{points:["cl","cr"],overflow:ae,offset:[4,0],targetOffset:$},top:{points:["bc","tc"],overflow:ae,offset:[0,-4],targetOffset:$},bottom:{points:["tc","bc"],overflow:ae,offset:[0,4],targetOffset:$},topLeft:{points:["bl","tl"],overflow:ae,offset:[0,-4],targetOffset:$},leftTop:{points:["tr","tl"],overflow:ae,offset:[-4,0],targetOffset:$},topRight:{points:["br","tr"],overflow:ae,offset:[0,-4],targetOffset:$},rightTop:{points:["tl","tr"],overflow:ae,offset:[4,0],targetOffset:$},bottomRight:{points:["tr","br"],overflow:ae,offset:[0,4],targetOffset:$},rightBottom:{points:["bl","br"],overflow:ae,offset:[4,0],targetOffset:$},bottomLeft:{points:["tl","bl"],overflow:ae,offset:[0,4],targetOffset:$},leftBottom:{points:["br","bl"],overflow:ae,offset:[-4,0],targetOffset:$}},X=R},"7qnI":function(At,ht,re){"use strict";var ae=re("5Dmo"),$=re("3S7+"),R=re("fWQN"),X=re("mtLc"),N=re("yKVA"),I=re("879j"),z=re("5NDa"),B=re("5rEg"),O=re("q1tI"),D=re.n(O),E=re("O2Wb"),L=re.n(E),k=B.a.TextArea,T=function(A){Object(N.a)(h,A);var C=Object(I.a)(h);function h(){return Object(R.a)(this,h),C.apply(this,arguments)}return Object(X.a)(h,[{key:"render",value:function(){var c=this,d=this.props,_=d.index,y=d.onAnswerChange,m=d.addChildAnswer,l=d.exerciseIsPublish,x=d.answers,f=d.activeOptionErrorIndex,p=d.flex,s=p===void 0?"0 0 1000px":p;return D.a.createElement("div",{className:L.a.flex},D.a.createElement("div",{className:"".concat(L.a.color666," mb5 mt6"),style:{flex:"0 0 90px"}},"\u7B54\u6848(\u586B\u7A7A",_+1,"):"),D.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),style:{flexDirection:"column"}},x.map(function(a,b){var v="".concat(_,"-").concat(b);return D.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),key:b},D.a.createElement("div",{className:L.a.flex1,style:{flex:s}},D.a.createElement("div",null,D.a.createElement(k,{className:v===f?L.a.error:"",spellCheck:!1,rows:4,value:a||"",defaultValue:"\u8BF7\u8F93\u5165\u53C2\u8003\u7B54\u6848".concat(b==0?"":"(\u53EF\u9009)"),onChange:function(M){return y(_,b,M.target.value)},style:{minHeight:95}}))),!l&&D.a.createElement(D.a.Fragment,null,b!=0&&D.a.createElement($.a,{title:"\u5220\u9664"},D.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return c.props.deleteChildAnswer(_,b)},style:{float:"right"}})),b===0&&D.a.createElement($.a,{title:"\u5220\u9664"},D.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return c.props.deleteChildAnswermain(_,b)},style:{float:"right"}})),D.a.createElement($.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},D.a.createElement("i",{className:"".concat(L.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return m(_)},style:{float:"right",visibility:b==x.length-1?"":"hidden"}}))))})))}}]),h}(O.Component);ht.a=T},"8EBN":function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";ae.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;$<ae.modeInfo.length;$++){var R=ae.modeInfo[$];R.mimes&&(R.mime=R.mimes[0])}ae.findModeByMIME=function(X){X=X.toLowerCase();for(var N=0;N<ae.modeInfo.length;N++){var I=ae.modeInfo[N];if(I.mime==X)return I;if(I.mimes){for(var z=0;z<I.mimes.length;z++)if(I.mimes[z]==X)return I}}if(/\+xml$/.test(X))return ae.findModeByMIME("application/xml");if(/\+json$/.test(X))return ae.findModeByMIME("application/json")},ae.findModeByExtension=function(X){X=X.toLowerCase();for(var N=0;N<ae.modeInfo.length;N++){var I=ae.modeInfo[N];if(I.ext){for(var z=0;z<I.ext.length;z++)if(I.ext[z]==X)return I}}},ae.findModeByFileName=function(X){for(var N=0;N<ae.modeInfo.length;N++){var I=ae.modeInfo[N];if(I.file&&I.file.test(X))return I}var z=X.lastIndexOf("."),B=z>-1&&X.substring(z+1,X.length);if(B)return ae.findModeByExtension(B)},ae.findModeByName=function(X){X=X.toLowerCase();for(var N=0;N<ae.modeInfo.length;N++){var I=ae.modeInfo[N];if(I.name.toLowerCase()==X)return I;if(I.alias){for(var z=0;z<I.alias.length;z++)if(I.alias[z].toLowerCase()==X)return I}}}})},"8hTe":function(At,ht,re){At.exports={button:"button___1wy9m"}},"9Bee":function(At,ht,re){"use strict";var ae=re("DYRE"),$=re("zeV3"),R=re("+L6B"),X=re("2/Rp"),N=re("k1fw"),I=re("9og8"),z=re("tJVT"),B=re("WmNS"),O=re.n(B),D=re("q1tI"),E=re.n(D),L=re("vg9a"),k=re("DlQD"),T=re.n(k),A=re("rUJ1");function C(U,u){var g=U.match(/^(\s+)(?:```)/);if(g===null)return u;var P=g[1];return u.split(`
|
|
`).map(function(J){var j=J.match(/^\s+/);if(j===null)return J;var ce=Object(z.a)(j,1),Ne=ce[0];return Ne.length>=P.length?J.slice(P.length):J}).join(`
|
|
`)}var h=[],o=["<ul>"],c=new T.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function _(){h.length=0,o=["<ul>"]}var y={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(U,u,g,P){if(u>=U.length||U[u].level<=g)return u;var J=U[u];P.push("<li><a href='#"+J.anchor+"'>"+J.text+"</a>"),u++;var j=[];return u=m(U,u,J.level,j),j.length>0&&(P.push("<ul>"),j.forEach(function(ce){P.push(ce)}),P.push("</ul>")),P.push("</li>"),u=m(U,u,g,P),u}function l(){return m(h,0,0,o),o.push("</ul>"),o.join("")}var x={heading:function(u){var g=d.exec(u);if(g)return{type:"heading",raw:g[0],depth:g[1].length,text:g[2]}},fences:function(u){var g=this.rules.block.fences.exec(u);if(g){var P=g[0],J=C(P,g[3]||""),j=g[2]?g[2].trim():g[2];if(["latex","katex","math"].indexOf(j)>=0){var ce=s(),Ne=J;J=ce,a[ce]={type:"block",expression:Ne}}return{type:"code",raw:P,lang:j,text:J}}}},f=/(?:\${2})([^\n`]+?)(?:\${2})/gi,p=0,s=function(){return"__special_katext_id_".concat(p++,"__")},a={};function b(){return a}function v(){p=0,a={}}function S(U){return U=U.replace(f,function(u,g){var P=s();return a[P]={type:"inline",expression:g},P}),U}var M=c.listitem;c.listitem=function(U){return M(S(U))};var H=c.paragraph;c.paragraph=function(U){return H(S(U))};var V=c.tablecell;c.tablecell=function(U,u){return V(S(U),u)},c.code=function(U,u,g){var P=(u||"").match(/\S*/)[0];return P?["latex","katex","math"].indexOf(P)>=0?"<p class='editormd-tex'>".concat(U,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(u,'">').concat(g?U:Object(A.escape)(U,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(g?U:Object(A.escape)(U,!0))+"</code></pre>"},c.heading=function(U,u,g){var P=this.options.headerPrefix+g.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:P,level:u,text:U}),"<h"+u+' id="'+P+'">'+U+"</h"+u+">"},T.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),T.a.use({tokenizer:x,renderer:c});var Q=T.a,G=re("SJMd"),W=re("ulZh"),q=re.n(W),oe=re("m3rI"),fe=re("Oy/b"),ve=re("p5ED"),De=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(U,u){return(Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,P){g.__proto__=P}||function(g,P){for(var J in P)Object.prototype.hasOwnProperty.call(P,J)&&(g[J]=P[J])})(U,u)};function _e(U,u){function g(){this.constructor=U}Ee(U,u),U.prototype=u===null?Object.create(u):(g.prototype=u.prototype,new g)}function Te(U,u,g,P){return new(g||(g=Promise))(function(J,j){function ce(Tt){try{qe(P.next(Tt))}catch(Ue){j(Ue)}}function Ne(Tt){try{qe(P.throw(Tt))}catch(Ue){j(Ue)}}function qe(Tt){var Ue;Tt.done?J(Tt.value):(Ue=Tt.value,Ue instanceof g?Ue:new g(function(Pt){Pt(Ue)})).then(ce,Ne)}qe((P=P.apply(U,u||[])).next())})}function Ce(U,u){var g,P,J,j,ce={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return j={next:Ne(0),throw:Ne(1),return:Ne(2)},typeof Symbol=="function"&&(j[Symbol.iterator]=function(){return this}),j;function Ne(qe){return function(Tt){return function(Ue){if(g)throw new TypeError("Generator is already executing.");for(;ce;)try{if(g=1,P&&(J=2&Ue[0]?P.return:Ue[0]?P.throw||((J=P.return)&&J.call(P),0):P.next)&&!(J=J.call(P,Ue[1])).done)return J;switch(P=0,J&&(Ue=[2&Ue[0],J.value]),Ue[0]){case 0:case 1:J=Ue;break;case 4:return ce.label++,{value:Ue[1],done:!1};case 5:ce.label++,P=Ue[1],Ue=[0];continue;case 7:Ue=ce.ops.pop(),ce.trys.pop();continue;default:if(!(J=ce.trys,(J=J.length>0&&J[J.length-1])||Ue[0]!==6&&Ue[0]!==2)){ce=0;continue}if(Ue[0]===3&&(!J||Ue[1]>J[0]&&Ue[1]<J[3])){ce.label=Ue[1];break}if(Ue[0]===6&&ce.label<J[1]){ce.label=J[1],J=Ue;break}if(J&&ce.label<J[2]){ce.label=J[2],ce.ops.push(Ue);break}J[2]&&ce.ops.pop(),ce.trys.pop();continue}Ue=u.call(U,ce)}catch(Pt){Ue=[6,Pt],P=0}finally{g=J=0}if(5&Ue[0])throw Ue[1];return{value:Ue[0]?Ue[1]:void 0,done:!0}}([qe,Tt])}}}function me(){for(var U=0,u=0,g=arguments.length;u<g;u++)U+=arguments[u].length;var P=Array(U),J=0;for(u=0;u<g;u++)for(var j=arguments[u],ce=0,Ne=j.length;ce<Ne;ce++,J++)P[J]=j[ce];return P}var ne=function(){function U(){}return U.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},U.setAttributes=function(u,g){for(var P=0,J=g;P<J.length;P++){var j=J[P],ce=j[0],Ne=j[1];u.setAttribute(ce,Ne)}},U.createRect=function(u,g,P){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",u.toString()),J.setAttribute("height",g.toString()),P&&U.setAttributes(J,P),J},U.createLine=function(u,g,P,J,j){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",u.toString()),ce.setAttribute("y1",g.toString()),ce.setAttribute("x2",P.toString()),ce.setAttribute("y2",J.toString()),j&&U.setAttributes(ce,j),ce},U.createPolygon=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","polygon");return P.setAttribute("points",u),g&&U.setAttributes(P,g),P},U.createCircle=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","circle");return P.setAttribute("cx",(u/2).toString()),P.setAttribute("cy",(u/2).toString()),P.setAttribute("r",u.toString()),g&&U.setAttributes(P,g),P},U.createEllipse=function(u,g,P){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(u/2).toString()),J.setAttribute("cy",(g/2).toString()),J.setAttribute("rx",(u/2).toString()),J.setAttribute("ry",(g/2).toString()),P&&U.setAttributes(J,P),J},U.createGroup=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","g");return u&&U.setAttributes(g,u),g},U.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},U.createMarker=function(u,g,P,J,j,ce,Ne){var qe=document.createElementNS("http://www.w3.org/2000/svg","marker");return U.setAttributes(qe,[["id",u],["orient",g],["markerWidth",P.toString()],["markerHeight",J.toString()],["refX",j.toString()],["refY",ce.toString()]]),qe.appendChild(Ne),qe},U.createText=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","text");return g.setAttribute("x","0"),g.setAttribute("y","0"),u&&U.setAttributes(g,u),g},U.createTSpan=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","tspan");return P.textContent=u,g&&U.setAttributes(P,g),P},U.createImage=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","image");return u&&U.setAttributes(g,u),g},U.createPoint=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return P.x=u,P.y=g,P},U.createPath=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","path");return P.setAttribute("d",u),g&&U.setAttributes(P,g),P},U}(),Ae=function(){function U(){}return U.addKey=function(u){U.key=u},Object.defineProperty(U,"isLicensed",{get:function(){return!!U.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(U.key)},enumerable:!1,configurable:!0}),U}(),rt=function(){function U(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return U.prototype.rasterize=function(u,g,P){var J=this;return new Promise(function(j){var ce=P!==void 0?P:document.createElement("canvas");u===null&&(J.markersOnly=!0,J.naturalSize=!1);var Ne=document.createElementNS("http://www.w3.org/2000/svg","svg");Ne.setAttribute("xmlns","http://www.w3.org/2000/svg"),Ne.setAttribute("width",g.width.baseVal.valueAsString),Ne.setAttribute("height",g.height.baseVal.valueAsString),Ne.setAttribute("viewBox","0 0 "+g.viewBox.baseVal.width.toString()+" "+g.viewBox.baseVal.height.toString()),Ne.innerHTML=g.innerHTML,J.naturalSize===!0?(Ne.width.baseVal.value=u.naturalWidth,Ne.height.baseVal.value=u.naturalHeight):J.width!==void 0&&J.height!==void 0&&(Ne.width.baseVal.value=J.width,Ne.height.baseVal.value=J.height),ce.width=Ne.width.baseVal.value,ce.height=Ne.height.baseVal.value;var qe=Ne.outerHTML,Tt=ce.getContext("2d");J.markersOnly!==!0&&Tt.drawImage(u,0,0,ce.width,ce.height);var Ue=window.URL,Pt=new Image(ce.width,ce.height);Pt.setAttribute("crossOrigin","anonymous");var er=new Blob([qe],{type:"image/svg+xml"}),fr=Ue.createObjectURL(er);Pt.onload=function(){Tt.drawImage(Pt,0,0),Ue.revokeObjectURL(fr);var Gr=ce.toDataURL(J.imageType,J.imageQuality);j(Gr)},Pt.src=fr})},U}(),$e=function(){},Xe=function(){function U(u){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+u+"_"}return Object.defineProperty(U.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(U.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(U.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),U.prototype.addClass=function(u){return this.styleSheet===void 0&&this.addStyleSheet(),u.name=""+this.classNamePrefix+u.localName,this.classes.push(u),this.styleSheet.sheet.insertRule("."+u.name+" {"+u.style+"}",this.styleSheet.sheet.cssRules.length),u},U.prototype.addRule=function(u){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(u),this.styleSheet.sheet.insertRule(u.selector+" {"+u.style+"}",this.styleSheet.sheet.cssRules.length)},U.prototype.addStyleSheet=function(){var u;this.styleSheet=document.createElement("style"),((u=this.styleSheetRoot)!==null&&u!==void 0?u:document.head).appendChild(this.styleSheet),this.addRule(new Ve("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ve("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Ve("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Le("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Le("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},U.prototype.removeStyleSheet=function(){var u;this.styleSheet&&(((u=this.styleSheetRoot)!==null&&u!==void 0?u:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},U}(),Ve=function(U,u){this.selector=U,this.style=u},Le=function(U,u){this.localName=U,this.style=u},Me=function(){function U(u,g,P,J,j){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=u,this.displayMode=g,this.markerItems=P,this.uiStyleSettings=J,this.styles=j,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return U.prototype.show=function(u){var g=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=u,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var P=document.createElement("div");P.className=this.toolbarBlockStyleClass.name,P.style.whiteSpace="nowrap",this.uiContainer.appendChild(P),this.addActionButton(P,'<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(P,'<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(P,'<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(P,'<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(P,'<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(P,'<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(P,'<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(P,'<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(j){var ce=document.createElement("div");ce.className=""+g.toolbarButtonStyleClass.name,ce.setAttribute("data-type-name",j.typeName),ce.innerHTML=j.icon,ce.addEventListener("click",function(){g.markerToolbarButtonClicked(ce,j)}),g.buttons.push(ce),g.markerButtons.push(ce)}),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 J=document.createElement("div");J.className=this.toolbarBlockStyleClass.name,J.style.whiteSpace="nowrap",J.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(J),this.addActionButton(J,'<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(J,'<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()},U.prototype.addButtonClickListener=function(u){this.buttonClickListeners.push(u)},U.prototype.removeButtonClickListener=function(u){this.buttonClickListeners.indexOf(u)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(u),1)},U.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},U.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var u=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var g=0;g<this.markerButtons.length;g++)g<u||g===u&&this.markerButtons.length-1===u?this.markerButtonBlock.appendChild(this.markerButtons[g]):(g===u&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[g]))}},U.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")},U.prototype.resetButtonStyles=function(){var u=this;this.buttons.forEach(function(g){g.className=g.className.replace(u.uiStyleSettings.toolbarButtonStyleColorsClassName?u.uiStyleSettings.toolbarButtonStyleColorsClassName:u.toolbarButtonStyleColorsClass.name,"").trim(),g.className=g.className.replace(u.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?u.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:u.toolbarActiveButtonStyleColorsClass.name,"").trim(),g.className+=" "+(u.uiStyleSettings.toolbarButtonStyleColorsClassName?u.uiStyleSettings.toolbarButtonStyleColorsClassName:u.toolbarButtonStyleColorsClass.name)})},U.prototype.addActionButton=function(u,g,P){var J=this,j=document.createElement("div");switch(j.className=""+this.toolbarButtonStyleClass.name,j.innerHTML=g,j.setAttribute("data-action",P),j.addEventListener("click",function(){J.actionToolbarButtonClicked(j,P)}),P){case"select":j.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":j.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":j.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":j.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":j.style.fill=this.uiStyleSettings.closeButtonColor}u.appendChild(j),this.buttons.push(j)},U.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Le("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 Le("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Le("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new Le("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 Le("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var u=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Le("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*u)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*u)+`px;
|
|
padding: `+u+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Le("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Le("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ve("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Ve("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},U.prototype.markerToolbarButtonClicked=function(u,g){this.setActiveButton(u),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(P){return P("marker",g)}),this.markerButtonOverflowBlock.style.display="none"},U.prototype.actionToolbarButtonClicked=function(u,g){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(P){return P("action",g)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},U.prototype.setActiveButton=function(u){this.resetButtonStyles(),u.className=u.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),u.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},U.prototype.setActiveMarkerButton=function(u){var g=this.markerButtons.find(function(P){return P.getAttribute("data-type-name")===u});g&&this.setActiveButton(g)},U.prototype.setCurrentMarker=function(u){var g=this;this.currentMarker=u,this.buttons.filter(function(P){return/delete|notes/.test(P.getAttribute("data-action"))}).forEach(function(P){g.currentMarker===void 0?(P.style.fillOpacity="0.4",P.style.pointerEvents="none"):(P.style.fillOpacity="1",P.style.pointerEvents="all")})},U}(),ze=function(){function U(u,g,P,J){this.panels=[],this.panelButtons=[],this.markerjsContainer=u,this.displayMode=g,this.uiStyleSettings=P,this.styles=J,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return U.prototype.addStyles=function(){var u;this.toolboxStyleClass=this.styles.addClass(new Le("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 Le("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var g=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new Le("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new Le("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new Le("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 Le("toolbox-panel-row_colors",`
|
|
background-color: `+((u=this.uiStyleSettings.toolboxBackgroundColor)!==null&&u!==void 0?u:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new Le("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*g)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*g)+`px;
|
|
padding: `+g+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new Le("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new Le("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Ve("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Ve("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},U.prototype.show=function(u){var g;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=u,this.uiContainer.className=this.toolboxStyleClass.name+" "+((g=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&g!==void 0?g:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},U.prototype.setPanelButtons=function(u){var g,P,J=this;this.panels=u,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((g=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&g!==void 0?g:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((P=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&P!==void 0?P:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(j){var ce;j.uiStyleSettings=J.uiStyleSettings;var Ne=document.createElement("div");Ne.className=J.toolboxButtonStyleClass.name+" "+((ce=J.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ce!==void 0?ce:J.toolboxButtonStyleColorsClass.name),Ne.innerHTML=j.icon,Ne.title=j.title,Ne.addEventListener("click",function(){J.panelButtonClick(j)}),J.panelButtons.push(Ne),J.buttonRow.appendChild(Ne)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},U.prototype.panelButtonClick=function(u){var g=this,P=-1;if(u!==this.activePanel){P=this.panels.indexOf(u),this.panelRow.innerHTML="";var J=u.getUi();J.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(J),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=u}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){g.displayMode==="inline"?g.panelRow.style.display="none":g.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(j,ce){var Ne,qe;j.className=g.toolboxButtonStyleClass.name+" "+(ce===P?""+((Ne=g.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Ne!==void 0?Ne:g.toolboxActiveButtonStyleColorsClass.name):""+((qe=g.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&qe!==void 0?qe:g.toolboxButtonStyleColorsClass.name))})},U}(),Ge=function(U,u){this.title=U,this.icon=u},He=function(U){function u(g,P,J,j){var ce=U.call(this,g,j||'<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 ce.colors=[],ce.addTransparent=!1,ce.colorBoxes=[],ce.colors=P,ce.currentColor=J,ce.setCurrentColor=ce.setCurrentColor.bind(ce),ce.getColorBox=ce.getColorBox.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");return P.style.overflow="hidden",P.style.whiteSpace="nowrap",this.colors.forEach(function(J){var j=g.getColorBox(J);P.appendChild(j),g.colorBoxes.push(j)}),P},u.prototype.getColorBox=function(g){var P=this,J=this.uiStyleSettings.toolbarHeight/4,j=this.uiStyleSettings.toolbarHeight-J,ce=document.createElement("div");ce.style.display="inline-block",ce.style.boxSizing="content-box",ce.style.width=j-2+"px",ce.style.height=j-2+"px",ce.style.padding="1px",ce.style.marginRight="2px",ce.style.marginBottom="2px",ce.style.borderWidth="2px",ce.style.borderStyle="solid",ce.style.borderRadius=(j+2)/2+"px",ce.style.borderColor=g===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ce.addEventListener("click",function(){P.setCurrentColor(g,ce)});var Ne=document.createElement("div");return Ne.style.display="inline-block",Ne.style.width=j-2+"px",Ne.style.height=j-2+"px",Ne.style.backgroundColor=g,Ne.style.borderRadius=j/2+"px",g==="transparent"&&(Ne.style.fill=this.uiStyleSettings.toolboxAccentColor,Ne.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>`),ce.appendChild(Ne),ce},u.prototype.setCurrentColor=function(g,P){var J=this;this.currentColor=g,this.colorBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(g)},u}(Ge),Be=function(){function U(u,g,P){this._state="new",this._isSelected=!1,this._container=u,this._overlayContainer=g,this.globalSettings=P,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(U.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),U.prototype.ownsTarget=function(u){return!1},Object.defineProperty(U.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),U.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},U.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},U.prototype.pointerDown=function(u,g){},U.prototype.dblClick=function(u,g){},U.prototype.manipulate=function(u){},U.prototype.pointerUp=function(u){this.stateChanged()},U.prototype.dispose=function(){},U.prototype.addMarkerVisualToContainer=function(u){this.container.childNodes.length>0?this.container.insertBefore(u,this.container.childNodes[0]):this.container.appendChild(u)},U.prototype.getState=function(){return{typeName:U.typeName,state:this.state,notes:this.notes}},U.prototype.restoreState=function(u){this._state=u.state,this.notes=u.notes},U.prototype.scale=function(u,g){},U.prototype.colorChanged=function(u){this.onColorChanged&&this.onColorChanged(u),this.stateChanged()},U.prototype.fillColorChanged=function(u){this.onFillColorChanged&&this.onFillColorChanged(u),this.stateChanged()},U.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var u=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),u.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(u)&&this.onStateChanged(this)}},U.typeName="MarkerBase",U}(),Pe=function(){function U(){this.findGripByVisual=this.findGripByVisual.bind(this)}return U.prototype.findGripByVisual=function(u){return this.topLeft.ownsTarget(u)?this.topLeft:this.topCenter.ownsTarget(u)?this.topCenter:this.topRight.ownsTarget(u)?this.topRight:this.centerLeft.ownsTarget(u)?this.centerLeft:this.centerRight.ownsTarget(u)?this.centerRight:this.bottomLeft.ownsTarget(u)?this.bottomLeft:this.bottomCenter.ownsTarget(u)?this.bottomCenter:this.bottomRight.ownsTarget(u)?this.bottomRight:void 0},U}(),pt=function(){function U(){this.GRIP_SIZE=10,this.visual=ne.createGroup(),this.visual.appendChild(ne.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(ne.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return U.prototype.ownsTarget=function(u){return u===this.visual||u===this.visual.childNodes[0]||u===this.visual.childNodes[1]},U}(),it=function(){function U(){}return U.toITransformMatrix=function(u){return{a:u.a,b:u.b,c:u.c,d:u.d,e:u.e,f:u.f}},U.toSVGMatrix=function(u,g){return u.a=g.a,u.b=g.b,u.c=g.c,u.d=g.d,u.e=g.e,u.f=g.f,u},U}(),et=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.left=0,j.top=0,j.width=0,j.height=0,j.defaultSize={x:50,y:20},j.offsetX=0,j.offsetY=0,j.rotationAngle=0,j.CB_DISTANCE=10,j._suppressMarkerCreateEvent=!1,j.container.transform.baseVal.appendItem(ne.createTransform()),j.setupControlBox(),j}return _e(u,U),Object.defineProperty(u.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"visual",{get:function(){return this._visual},set:function(g){this._visual=g;var P=ne.createTransform();this._visual.transform.baseVal.appendItem(P)},enumerable:!1,configurable:!0}),u.prototype.ownsTarget=function(g){return!!U.prototype.ownsTarget.call(this,g)||!!(this.controlGrips.findGripByVisual(g)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(g))},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="new"&&(this.left=g.x,this.top=g.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var J=this.unrotatePoint(g);if(this.manipulationStartX=J.x,this.manipulationStartY=J.y,this.offsetX=J.x-this.left,this.offsetY=J.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(P),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(P)){this.activeGrip=this.rotatorGrip;var j=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=j.x-this.width/2,this.top=j.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ce=this.container.transform.baseVal.getItem(0);ce.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ce,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},u.prototype.pointerUp=function(g){var P=this.state;U.prototype.pointerUp.call(this,g),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(g),this._state="select",P==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},u.prototype.moveVisual=function(g){this.visual.style.transform="translate("+g.x+"px, "+g.y+"px)"},u.prototype.manipulate=function(g){var P=this.unrotatePoint(g);this.state==="creating"?this.resize(g):this.state==="move"?(this.left=this.manipulationStartLeft+(P.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(P.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(P):this.state==="rotate"&&this.rotate(g)},u.prototype.resize=function(g){var P=this.manipulationStartLeft,J=this.manipulationStartWidth,j=this.manipulationStartTop,ce=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:P=this.manipulationStartLeft+g.x-this.manipulationStartX,J=this.manipulationStartWidth+this.manipulationStartLeft-P;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:J=this.manipulationStartWidth+g.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:j=this.manipulationStartTop+g.y-this.manipulationStartY,ce=this.manipulationStartHeight+this.manipulationStartTop-j;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ce=this.manipulationStartHeight+g.y-this.manipulationStartY}J>=0?(this.left=P,this.width=J):(this.left=P+J,this.width=-J),ce>=0?(this.top=j,this.height=ce):(this.top=j+ce,this.height=-ce),this.setSize()},u.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},u.prototype.rotate=function(g){if(Math.abs(g.x-this.centerX)>.1){var P=Math.sign(g.x-this.centerX);this.rotationAngle=180*Math.atan((g.y-this.centerY)/(g.x-this.centerX))/Math.PI+90*P,this.applyRotation()}},u.prototype.applyRotation=function(){var g=this.container.transform.baseVal.getItem(0);g.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(g,0)},u.prototype.rotatePoint=function(g){if(this.rotationAngle===0)return g;var P=this.container.getCTM(),J=ne.createPoint(g.x,g.y);return{x:(J=J.matrixTransform(P)).x,y:J.y}},u.prototype.unrotatePoint=function(g){if(this.rotationAngle===0)return g;var P=this.container.getCTM();P=P.inverse();var J=ne.createPoint(g.x,g.y);return{x:(J=J.matrixTransform(P)).x,y:J.y}},u.prototype.select=function(){U.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},u.prototype.deselect=function(){U.prototype.deselect.call(this),this.controlBox.style.display="none"},u.prototype.setupControlBox=function(){this.controlBox=ne.createGroup();var g=ne.createTransform();g.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(g),this.container.appendChild(this.controlBox),this.controlRect=ne.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=ne.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 Pe,this.addControlGrips(),this.controlBox.style.display="none"},u.prototype.adjustControlBox=function(){var g=this.controlBox.transform.baseVal.getItem(0);g.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(g,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()},u.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()},u.prototype.createGrip=function(){var g=new pt;return g.visual.transform.baseVal.appendItem(ne.createTransform()),this.controlBox.appendChild(g.visual),g},u.prototype.positionGrips=function(){var g=this.controlGrips.topLeft.GRIP_SIZE,P=-g/2,J=P,j=(this.width+this.CB_DISTANCE)/2-g/2,ce=(this.height+this.CB_DISTANCE)/2-g/2,Ne=this.height+this.CB_DISTANCE-g/2,qe=this.width+this.CB_DISTANCE-g/2;this.positionGrip(this.controlGrips.topLeft.visual,P,J),this.positionGrip(this.controlGrips.topCenter.visual,j,J),this.positionGrip(this.controlGrips.topRight.visual,qe,J),this.positionGrip(this.controlGrips.centerLeft.visual,P,ce),this.positionGrip(this.controlGrips.centerRight.visual,qe,ce),this.positionGrip(this.controlGrips.bottomLeft.visual,P,Ne),this.positionGrip(this.controlGrips.bottomCenter.visual,j,Ne),this.positionGrip(this.controlGrips.bottomRight.visual,qe,Ne),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,j,J-3*this.CB_DISTANCE)},u.prototype.positionGrip=function(g,P,J){var j=g.transform.baseVal.getItem(0);j.setTranslate(P,J),g.transform.baseVal.replaceItem(j,0)},u.prototype.hideControlBox=function(){this.controlBox.style.display="none"},u.prototype.showControlBox=function(){this.controlBox.style.display=""},u.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:it.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:it.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},U.prototype.getState.call(this))},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g);var P=g;this.left=P.left,this.top=P.top,this.width=P.width,this.height=P.height,this.rotationAngle=P.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(it.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,P.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(it.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,P.containerTransformMatrix))},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P);var J=this.rotatePoint({x:this.left,y:this.top}),j=this.unrotatePoint({x:J.x*g,y:J.y*P});this.left=j.x,this.top=j.y,this.width=this.width*g,this.height=this.height*P,this.adjustControlBox()},u}(Be),at=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.fillColor="transparent",j.strokeColor="transparent",j.strokeWidth=0,j.strokeDasharray="",j.opacity=1,j.setStrokeColor=j.setStrokeColor.bind(j),j.setFillColor=j.setFillColor.bind(j),j.setStrokeWidth=j.setStrokeWidth.bind(j),j.setStrokeDasharray=j.setStrokeDasharray.bind(j),j.createVisual=j.createVisual.bind(j),j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.visual)},u.prototype.createVisual=function(){this.visual=ne.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)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="new"&&(this.createVisual(),this.moveVisual(g),this._state="creating")},u.prototype.manipulate=function(g){U.prototype.manipulate.call(this,g)},u.prototype.resize=function(g){U.prototype.resize.call(this,g),this.setSize()},u.prototype.setSize=function(){U.prototype.setSize.call(this),ne.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},u.prototype.pointerUp=function(g){U.prototype.pointerUp.call(this,g),this.setSize()},u.prototype.setStrokeColor=function(g){this.strokeColor=g,this.visual&&ne.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(g),this.stateChanged()},u.prototype.setFillColor=function(g){this.fillColor=g,this.visual&&ne.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},u.prototype.setStrokeWidth=function(g){this.strokeWidth=g,this.visual&&ne.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},u.prototype.setStrokeDasharray=function(g){this.strokeDasharray=g,this.visual&&ne.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},u.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},U.prototype.getState.call(this))},u.prototype.restoreState=function(g){var P=g;this.fillColor=P.fillColor,this.strokeColor=P.strokeColor,this.strokeWidth=P.strokeWidth,this.strokeDasharray=P.strokeDasharray,this.opacity=P.opacity,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.setSize()},u.title="Rectangle marker",u}(et),Et=function(U){function u(g,P,J,j){var ce=U.call(this,g,j||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ce.widths=[],ce.widthBoxes=[],ce.widths=P,ce.currentWidth=J,ce.setCurrentWidth=ce.setCurrentWidth.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");return P.style.display="flex",P.style.overflow="hidden",P.style.flexGrow="2",this.widths.forEach(function(J){var j=document.createElement("div");j.style.display="flex",j.style.flexGrow="2",j.style.alignItems="center",j.style.justifyContent="space-between",j.style.padding="5px",j.style.borderWidth="2px",j.style.borderStyle="solid",j.style.borderColor=J===g.currentWidth?g.uiStyleSettings.toolboxAccentColor:"transparent",j.addEventListener("click",function(){g.setCurrentWidth(J,j)}),P.appendChild(j);var ce=document.createElement("div");ce.innerText=J.toString(),ce.style.marginRight="5px",j.appendChild(ce);var Ne=document.createElement("div");Ne.style.minHeight="20px",Ne.style.flexGrow="2",Ne.style.display="flex",Ne.style.alignItems="center";var qe=document.createElement("hr");qe.style.minWidth="20px",qe.style.border="0px",qe.style.borderTop=J+"px solid "+g.uiStyleSettings.toolboxColor,qe.style.flexGrow="2",Ne.appendChild(qe),j.appendChild(Ne),g.widthBoxes.push(j)}),P},u.prototype.setCurrentWidth=function(g,P){var J=this;this.currentWidth=g,this.widthBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},u}(Ge),ct=function(U){function u(g,P,J,j){var ce=U.call(this,g,j||'<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 ce.styles=[],ce.styleBoxes=[],ce.styles=P,ce.currentStyle=J,ce.setCurrentStyle=ce.setCurrentStyle.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");return P.style.display="flex",P.style.overflow="hidden",P.style.flexGrow="2",this.styles.forEach(function(J){var j=document.createElement("div");j.style.display="flex",j.style.alignItems="center",j.style.justifyContent="space-between",j.style.padding="5px",j.style.borderWidth="2px",j.style.borderStyle="solid",j.style.overflow="hidden",j.style.maxWidth=100/g.styles.length-5+"%",j.style.borderColor=J===g.currentStyle?g.uiStyleSettings.toolboxAccentColor:"transparent",j.addEventListener("click",function(){g.setCurrentStyle(J,j)}),P.appendChild(j);var ce=document.createElement("div");ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.overflow="hidden";var Ne=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+g.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(J!==""?'stroke-dasharray="'+J+'"':"")+` />
|
|
</svg>`;ce.innerHTML=Ne,j.appendChild(ce),g.styleBoxes.push(j)}),P},u.prototype.setCurrentStyle=function(g,P){var J=this;this.currentStyle=g,this.styleBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},u}(Ge),dt=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.strokeColor=J.defaultColor,j.strokeWidth=J.defaultStrokeWidth,j.strokeDasharray=J.defaultStrokeDasharray,j.strokePanel=new He("Line color",J.defaultColorSet,J.defaultColor),j.strokePanel.onColorChanged=j.setStrokeColor,j.strokeWidthPanel=new Et("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),j.strokeWidthPanel.onWidthChanged=j.setStrokeWidth,j.strokeStylePanel=new ct("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),j.strokeStylePanel.onStyleChanged=j.setStrokeDasharray,j}return _e(u,U),Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=U.prototype.getState.call(this);return g.typeName=u.typeName,g},u.typeName="FrameMarker",u.title="Frame marker",u.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',u}(at),we=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},gt=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.x1=0,j.y1=0,j.x2=0,j.y2=0,j.defaultLength=50,j.manipulationStartX=0,j.manipulationStartY=0,j.manipulationStartX1=0,j.manipulationStartY1=0,j.manipulationStartX2=0,j.manipulationStartY2=0,j.setupControlBox(),j}return _e(u,U),u.prototype.ownsTarget=function(g){return!!U.prototype.ownsTarget.call(this,g)||!(!this.grip1.ownsTarget(g)&&!this.grip2.ownsTarget(g))},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.manipulationStartX=g.x,this.manipulationStartY=g.y,this.state==="new"&&(this.x1=g.x,this.y1=g.y,this.x2=g.x,this.y2=g.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(P)?this.activeGrip=this.grip1:this.grip2.ownsTarget(P)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},u.prototype.pointerUp=function(g){var P=this.state;U.prototype.pointerUp.call(this,g),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(g),this._state="select",P==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},u.prototype.adjustVisual=function(){},u.prototype.manipulate=function(g){this.state==="creating"?this.resize(g):this.state==="move"?(this.x1=this.manipulationStartX1+g.x-this.manipulationStartX,this.y1=this.manipulationStartY1+g.y-this.manipulationStartY,this.x2=this.manipulationStartX2+g.x-this.manipulationStartX,this.y2=this.manipulationStartY2+g.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(g)},u.prototype.resize=function(g){switch(this.activeGrip){case this.grip1:this.x1=g.x,this.y1=g.y;break;case this.grip2:case void 0:this.x2=g.x,this.y2=g.y}this.adjustVisual(),this.adjustControlBox()},u.prototype.select=function(){U.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},u.prototype.deselect=function(){U.prototype.deselect.call(this),this.controlBox.style.display="none"},u.prototype.setupControlBox=function(){this.controlBox=ne.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},u.prototype.adjustControlBox=function(){this.positionGrips()},u.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},u.prototype.createGrip=function(){var g=new pt;return g.visual.transform.baseVal.appendItem(ne.createTransform()),this.controlBox.appendChild(g.visual),g},u.prototype.positionGrips=function(){var g=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-g/2,this.y1-g/2),this.positionGrip(this.grip2.visual,this.x2-g/2,this.y2-g/2)},u.prototype.positionGrip=function(g,P,J){var j=g.transform.baseVal.getItem(0);j.setTranslate(P,J),g.transform.baseVal.replaceItem(j,0)},u.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},U.prototype.getState.call(this))},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g);var P=g;this.x1=P.x1,this.y1=P.y1,this.x2=P.x2,this.y2=P.y2},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.x1=this.x1*g,this.y1=this.y1*P,this.x2=this.x2*g,this.y2=this.y2*P,this.adjustVisual(),this.adjustControlBox()},u}(Be),lt=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.strokeColor="transparent",j.strokeWidth=0,j.strokeDasharray="",j.setStrokeColor=j.setStrokeColor.bind(j),j.setStrokeWidth=j.setStrokeWidth.bind(j),j.setStrokeDasharray=j.setStrokeDasharray.bind(j),j.strokeColor=J.defaultColor,j.strokeWidth=J.defaultStrokeWidth,j.strokeDasharray=J.defaultStrokeDasharray,j.strokePanel=new He("Line color",J.defaultColorSet,J.defaultColor),j.strokePanel.onColorChanged=j.setStrokeColor,j.strokeWidthPanel=new Et("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),j.strokeWidthPanel.onWidthChanged=j.setStrokeWidth,j.strokeStylePanel=new ct("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),j.strokeStylePanel.onStyleChanged=j.setStrokeDasharray,j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.visual&&g!==this.selectorLine&&g!==this.visibleLine)},u.prototype.createVisual=function(){this.visual=ne.createGroup(),this.selectorLine=ne.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=ne.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)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},u.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()),ne.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),ne.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),ne.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},u.prototype.setStrokeColor=function(g){this.strokeColor=g,this.adjustVisual(),this.colorChanged(g)},u.prototype.setStrokeWidth=function(g){this.strokeWidth=g,this.adjustVisual()},u.prototype.setStrokeDasharray=function(g){this.strokeDasharray=g,this.adjustVisual(),this.stateChanged()},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g);var P=g;this.strokeColor=P.strokeColor,this.strokeWidth=P.strokeWidth,this.strokeDasharray=P.strokeDasharray,this.createVisual(),this.adjustVisual()},u.typeName="LineMarker",u.title="Line marker",u.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',u}(gt),Re=function(U){function u(g,P,J,j){var ce=U.call(this,g,j||'<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 ce.fonts=[],ce.fontBoxes=[],ce.fonts=P,ce.currentFont=J,ce.setCurrentFont=ce.setCurrentFont.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");return P.style.overflow="hidden",P.style.flexGrow="2",this.fonts.forEach(function(J){var j=document.createElement("div");j.style.display="inline-block",j.style.alignItems="center",j.style.justifyContent="space-between",j.style.padding="5px",j.style.borderWidth="2px",j.style.borderStyle="solid",j.style.overflow="hidden",j.style.maxWidth=100/g.fonts.length-5+"%",j.style.borderColor=J===g.currentFont?g.uiStyleSettings.toolboxAccentColor:"transparent",j.addEventListener("click",function(){g.setCurrentFont(J,j)}),P.appendChild(j);var ce=document.createElement("div");ce.style.display="flex",ce.style.minHeight="20px",ce.style.flexGrow="2",ce.style.fontFamily=J,ce.style.overflow="hidden";var Ne=document.createElement("div");Ne.style.whiteSpace="nowrap",Ne.style.overflow="hidden",Ne.style.textOverflow="ellipsis",Ne.innerHTML="The quick brown fox jumps over the lazy dog",ce.appendChild(Ne),j.appendChild(ce),g.fontBoxes.push(j)}),P},u.prototype.setCurrentFont=function(g,P){var J=this;this.currentFont=g,this.fontBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},u}(Ge),je=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.color="transparent",j.padding=5,j.DEFAULT_TEXT="your text here",j.text=j.DEFAULT_TEXT,j.isMoved=!1,j.color=J.defaultColor,j.fontFamily=J.defaultFontFamily,j.defaultSize={x:100,y:30},j.setColor=j.setColor.bind(j),j.setFont=j.setFont.bind(j),j.renderText=j.renderText.bind(j),j.sizeText=j.sizeText.bind(j),j.textEditDivClicked=j.textEditDivClicked.bind(j),j.showTextEditor=j.showTextEditor.bind(j),j.setSize=j.setSize.bind(j),j.positionTextEditor=j.positionTextEditor.bind(j),j.colorPanel=new He("Color",J.defaultColorSet,J.defaultColor),j.colorPanel.onColorChanged=j.setColor,j.fontFamilyPanel=new Re("Font",J.defaultFontFamilies,J.defaultFontFamily),j.fontFamilyPanel.onFontChanged=j.setFont,j}return _e(u,U),u.prototype.ownsTarget=function(g){if(U.prototype.ownsTarget.call(this,g)||g===this.visual||g===this.textElement||g===this.bgRectangle)return!0;var P=!1;return this.textElement.childNodes.forEach(function(J){J===g&&(P=!0)}),P},u.prototype.createVisual=function(){this.visual=ne.createGroup(),this.bgRectangle=ne.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=ne.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(ne.createTransform()),this.textElement.transform.baseVal.appendItem(ne.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.isMoved=!1,this.pointerDownPoint=g,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(g),this._state="creating")},u.prototype.renderText=function(){var g=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(P){g.textElement.appendChild(ne.createTSpan(P.trim()===""?" ":P.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},u.prototype.getTextScale=function(){var g=this.textElement.getBBox(),P=1;if(g.width>0&&g.height>0){var J=(1*this.width-this.width*this.padding*2/100)/g.width,j=(1*this.height-this.height*this.padding*2/100)/g.height;P=Math.min(J,j)}return P},u.prototype.getTextPosition=function(g){var P=this.textElement.getBBox(),J=0,j=0;return P.width>0&&P.height>0&&(J=(this.width-P.width*g)/2,j=this.height/2-P.height*g/2),{x:J,y:j}},u.prototype.sizeText=function(){var g=this.textElement.getBBox(),P=this.getTextScale(),J=this.getTextPosition(P);J.y-=g.y*P,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+J.x+"px, "+J.y+"px) scale("+P+", "+P+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(J.x,J.y),this.textElement.transform.baseVal.getItem(1).setScale(P,P))},u.prototype.manipulate=function(g){U.prototype.manipulate.call(this,g),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(g.x-this.pointerDownPoint.x)>5||Math.abs(g.y-this.pointerDownPoint.y)>5)},u.prototype.resize=function(g){U.prototype.resize.call(this,g),this.isMoved=!0,this.setSize(),this.sizeText()},u.prototype.setSize=function(){U.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(ne.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),ne.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},u.prototype.pointerUp=function(g){var P=this.state;P==="creating"&&(this._suppressMarkerCreateEvent=!0),U.prototype.pointerUp.call(this,g),this.setSize(),(P==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},u.prototype.showTextEditor=function(){var g=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(P){P.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var P=Number.parseFloat(g.textEditor.style.fontSize);g.textEditor.clientWidth>=Number.parseInt(g.textEditor.style.maxWidth)&&P>.9;)P-=.1,g.textEditor.style.fontSize=Math.max(P,.9)+"em"}),this.textEditor.addEventListener("keyup",function(P){P.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(P){if(P.clipboardData){var J=P.clipboardData.getData("text"),j=window.getSelection();if(!j.rangeCount)return!1;j.deleteFromDocument(),j.getRangeAt(0).insertNode(document.createTextNode(J)),P.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){g.textEditDivClicked(g.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},u.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var g=this.getTextScale(),P=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),J=this.textElement.getBBox(),j={x:J.width*g,y:J.height*g};P.x-=j.x/2,P.y-=j.y/2,this.textEditor.style.top=P.y+"px",this.textEditor.style.left=P.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-P.x+"px",this.textEditor.style.fontSize=Math.max(16*g,12)+"px",this.textElement.style.display="none"}},u.prototype.textEditDivClicked=function(g){this.text=g.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},u.prototype.select=function(){U.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},u.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),U.prototype.deselect.call(this)},u.prototype.dblClick=function(g,P){U.prototype.dblClick.call(this,g,P),this.showTextEditor()},u.prototype.setColor=function(g){this.textElement&&ne.setAttributes(this.textElement,[["fill",g]]),this.color=g,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(g)},u.prototype.setFont=function(g){this.textElement&&ne.setAttributes(this.textElement,[["font-family",g]]),this.fontFamily=g,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},u.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},u.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){var P=g;this.color=P.color,this.fontFamily=P.fontFamily,this.padding=P.padding,this.text=P.text,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.setSize(),this.sizeText(),this.positionTextEditor()},u.typeName="TextMarker",u.title="Text marker",u.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>',u}(et),ge=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.color="transparent",j.lineWidth=3,j.drawing=!1,j.pixelRatio=1,j.color=J.defaultColor,j.lineWidth=J.defaultStrokeWidth,j.pixelRatio=J.freehandPixelRatio,j.setColor=j.setColor.bind(j),j.addCanvas=j.addCanvas.bind(j),j.finishCreation=j.finishCreation.bind(j),j.setLineWidth=j.setLineWidth.bind(j),j.colorPanel=new He("Color",J.defaultColorSet,J.defaultColor),j.colorPanel.onColorChanged=j.setColor,j.lineWidthPanel=new Et("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),j.lineWidthPanel.onWidthChanged=j.setLineWidth,j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.visual&&g!==this.drawingImage)},u.prototype.createVisual=function(){this.visual=ne.createGroup(),this.drawingImage=ne.createImage(),this.visual.appendChild(this.drawingImage);var g=ne.createTransform();this.visual.transform.baseVal.appendItem(g),this.addMarkerVisualToContainer(this.visual)},u.prototype.pointerDown=function(g,P){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(g.x,g.y),this.drawing=!0):U.prototype.pointerDown.call(this,g,P)},u.prototype.manipulate=function(g){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(g.x,g.y),this.canvasContext.stroke()):U.prototype.manipulate.call(this,g)},u.prototype.resize=function(g){U.prototype.resize.call(this,g),ne.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),ne.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},u.prototype.pointerUp=function(g){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):U.prototype.pointerUp.call(this,g)},u.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)},u.prototype.select=function(){this.state==="creating"&&this.finishCreation(),U.prototype.select.call(this)},u.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),U.prototype.deselect.call(this)},u.prototype.finishCreation=function(){for(var g=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),P=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],J=P[0],j=P[1],ce=P[2],Ne=P[3],qe=!1,Tt=0;Tt<this.canvasElement.height;Tt++)for(var Ue=0;Ue<this.canvasElement.width;Ue++)g.data[Tt*this.canvasElement.width*4+4*Ue+3]>0&&(qe=!0,Tt<j&&(j=Tt),Ue<J&&(J=Ue),Tt>Ne&&(Ne=Tt),Ue>ce&&(ce=Ue));if(qe){this.left=J/this.pixelRatio,this.top=j/this.pixelRatio,this.width=(ce-J)/this.pixelRatio,this.height=(Ne-j)/this.pixelRatio;var Pt=document.createElement("canvas");Pt.width=ce-J,Pt.height=Ne-j,Pt.getContext("2d").putImageData(this.canvasContext.getImageData(J,j,ce-J,Ne-j),0,0),this.drawingImgUrl=Pt.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},u.prototype.setDrawingImage=function(){ne.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),ne.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},u.prototype.setColor=function(g){this.color=g,this.colorChanged(g)},u.prototype.setLineWidth=function(g){this.lineWidth=g},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({drawingImgUrl:this.drawingImgUrl},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){this.createVisual(),U.prototype.restoreState.call(this,g),this.drawingImgUrl=g.drawingImgUrl,this.setDrawingImage()},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.setDrawingImage()},u.typeName="FreehandMarker",u.title="Freehand marker",u.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>',u}(et),de=function(U){function u(g,P,J){var j=U.call(this,g,J||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return j.typeBoxes=[],j.currentType=P,j.setCurrentType=j.setCurrentType.bind(j),j}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");P.style.display="flex",P.style.overflow="hidden",P.style.flexGrow="2";for(var J=function(Ne){var qe="both";switch(Ne){case 0:qe="both";break;case 1:qe="start";break;case 2:qe="end";break;case 3:qe="none"}var Tt=document.createElement("div");if(Tt.style.display="flex",Tt.style.flexGrow="2",Tt.style.alignItems="center",Tt.style.justifyContent="space-between",Tt.style.padding="5px",Tt.style.borderWidth="2px",Tt.style.borderStyle="solid",Tt.style.borderColor=qe===j.currentType?j.uiStyleSettings.toolboxAccentColor:"transparent",Tt.addEventListener("click",function(){g.setCurrentType(qe,Tt)}),P.appendChild(Tt),qe==="both"||qe==="start"){var Ue=document.createElement("div");Ue.style.display="flex",Ue.style.alignItems="center",Ue.style.minHeight="20px",Ue.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="`+(j.uiStyleSettings!==void 0?j.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Ue.style.marginLeft="5px",Tt.appendChild(Ue)}var Pt=document.createElement("div");Pt.style.display="flex",Pt.style.alignItems="center",Pt.style.minHeight="20px",Pt.style.flexGrow="2";var er=document.createElement("hr");if(er.style.minWidth="20px",er.style.border="0px",er.style.borderTop="3px solid "+(j.uiStyleSettings!==void 0?j.uiStyleSettings.toolboxColor:"#eeeeee"),er.style.flexGrow="2",Pt.appendChild(er),Tt.appendChild(Pt),qe==="both"||qe==="end"){var fr=document.createElement("div");fr.style.display="flex",fr.style.alignItems="center",fr.style.minHeight="20px",fr.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="`+(j.uiStyleSettings!==void 0?j.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,fr.style.marginRight="5px",Tt.appendChild(fr)}j.typeBoxes.push(Tt)},j=this,ce=0;ce<4;ce++)J(ce);return P},u.prototype.setCurrentType=function(g,P){var J=this;this.currentType=g,this.typeBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings!==void 0?J.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},u}(Ge),pe=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.arrowType="end",j.arrowBaseHeight=10,j.arrowBaseWidth=10,j.getArrowPoints=j.getArrowPoints.bind(j),j.setArrowType=j.setArrowType.bind(j),j.arrowTypePanel=new de("Arrow type","end"),j.arrowTypePanel.onArrowTypeChanged=j.setArrowType,j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.arrow1&&g!==this.arrow2)},u.prototype.getArrowPoints=function(g,P){var J=this.arrowBaseWidth+2*this.strokeWidth,j=this.arrowBaseHeight+2*this.strokeWidth;return g-J/2+","+(P+j/2)+" "+g+","+(P-j/2)+" "+(g+J/2)+","+(P+j/2)},u.prototype.createTips=function(){this.arrow1=ne.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(ne.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=ne.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(ne.createTransform()),this.visual.appendChild(this.arrow2)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="creating"&&this.createTips()},u.prototype.adjustVisual=function(){if(U.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",ne.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),ne.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var g=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),P=this.arrow1.transform.baseVal.getItem(0);P.setRotate(g,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(P,0);var J=this.arrow2.transform.baseVal.getItem(0);J.setRotate(g+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(J,0)}},u.prototype.setArrowType=function(g){this.arrowType=g,this.adjustVisual(),this.stateChanged()},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({arrowType:this.arrowType},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g);var P=g;this.arrowType=P.arrowType,this.createTips(),this.adjustVisual()},u.typeName="ArrowMarker",u.title="Arrow marker",u.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',u}(lt),ee=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.fillColor=J.defaultFillColor,j.strokeWidth=0,j.fillPanel=new He("Color",J.defaultColorSet,J.defaultFillColor),j.fillPanel.onColorChanged=j.setFillColor,j}return _e(u,U),Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=U.prototype.getState.call(this);return g.typeName=u.typeName,g},u.typeName="CoverMarker",u.title="Cover marker",u.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',u}(at),te=function(U){function u(g,P,J,j){var ce=U.call(this,g,j||'<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 ce.opacities=[],ce.opacityBoxes=[],ce.opacities=P,ce.currentOpacity=J,ce.setCurrentOpacity=ce.setCurrentOpacity.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,P=document.createElement("div");return P.style.display="flex",P.style.overflow="hidden",P.style.flexGrow="2",P.style.justifyContent="space-between",this.opacities.forEach(function(J){var j=document.createElement("div");j.style.display="flex",j.style.alignItems="center",j.style.justifyContent="center",j.style.padding="5px",j.style.borderWidth="2px",j.style.borderStyle="solid",j.style.borderColor=J===g.currentOpacity?g.uiStyleSettings.toolboxAccentColor:"transparent",j.addEventListener("click",function(){g.setCurrentOpacity(J,j)}),P.appendChild(j);var ce=document.createElement("div");ce.innerText=100*J+"%",j.appendChild(ce),g.opacityBoxes.push(j)}),P},u.prototype.setCurrentOpacity=function(g,P){var J=this;this.currentOpacity=g,this.opacityBoxes.forEach(function(j){j.style.borderColor=j===P?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},u}(Ge),ie=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.setOpacity=j.setOpacity.bind(j),j.fillColor=J.defaultHighlightColor,j.strokeWidth=0,j.opacity=J.defaultHighlightOpacity,j.fillPanel=new He("Color",J.defaultColorSet,j.fillColor),j.fillPanel.onColorChanged=j.setFillColor,j.opacityPanel=new te("Opacity",J.defaultOpacitySteps,j.opacity),j.opacityPanel.onOpacityChanged=j.setOpacity,j}return _e(u,U),u.prototype.setOpacity=function(g){this.opacity=g,this.visual&&ne.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=U.prototype.getState.call(this);return g.typeName=u.typeName,g},u.typeName="HighlightMarker",u.title="Highlight marker",u.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>',u}(ee),se='<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>',ue=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.bgColor="transparent",j.tipPosition={x:0,y:0},j.tipBase1Position={x:0,y:0},j.tipBase2Position={x:0,y:0},j.tipMoving=!1,j.color=J.defaultStrokeColor,j.bgColor=J.defaultFillColor,j.fontFamily=J.defaultFontFamily,j.defaultSize={x:100,y:30},j.setBgColor=j.setBgColor.bind(j),j.getTipPoints=j.getTipPoints.bind(j),j.positionTip=j.positionTip.bind(j),j.setTipPoints=j.setTipPoints.bind(j),j.colorPanel=new He("Text color",J.defaultColorSet,j.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>'),j.colorPanel.onColorChanged=j.setColor,j.bgColorPanel=new He("Fill color",J.defaultColorSet,j.bgColor,se),j.bgColorPanel.onColorChanged=j.setBgColor,j.fontFamilyPanel=new Re("Font",J.defaultFontFamilies,J.defaultFontFamily),j.fontFamilyPanel.onFontChanged=j.setFont,j.tipGrip=new pt,j.tipGrip.visual.transform.baseVal.appendItem(ne.createTransform()),j.controlBox.appendChild(j.tipGrip.visual),j}return _e(u,U),u.prototype.ownsTarget=function(g){return U.prototype.ownsTarget.call(this,g)||this.tipGrip.ownsTarget(g)||this.tip===g},u.prototype.createTip=function(){ne.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=ne.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},u.prototype.pointerDown=function(g,P){this.state==="new"&&U.prototype.pointerDown.call(this,g,P),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(P)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):U.prototype.pointerDown.call(this,g,P)},u.prototype.pointerUp=function(g){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,U.prototype.pointerUp.call(this,g);else{var P=this.state==="creating";U.prototype.pointerUp.call(this,g),this.setTipPoints(P),this.positionTip()}},u.prototype.manipulate=function(g){if(this.tipMoving){var P=this.unrotatePoint(g);this.tipPosition={x:P.x-this.manipulationStartLeft,y:P.y-this.manipulationStartTop},this.positionTip()}else U.prototype.manipulate.call(this,g)},u.prototype.setBgColor=function(g){this.bgRectangle&&this.tip&&(ne.setAttributes(this.bgRectangle,[["fill",g]]),ne.setAttributes(this.tip,[["fill",g]])),this.bgColor=g,this.fillColorChanged(g)},u.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},u.prototype.setTipPoints=function(g){g===void 0&&(g=!1);var P=Math.min(this.height/2,15),J=this.height/5;g&&(this.tipPosition={x:P+J/2,y:this.height+20});var j=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?j<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(J=this.width/5,P=Math.min(this.width/2,15),this.tipBase1Position={x:P,y:0},this.tipBase2Position={x:P+J,y:0}):(this.tipBase1Position={x:0,y:P},this.tipBase2Position={x:0,y:P+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?j<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(J=this.width/5,P=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-P-J,y:0},this.tipBase2Position={x:this.width-P,y:0}):(this.tipBase1Position={x:this.width,y:P},this.tipBase2Position={x:this.width,y:P+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?j<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(J=this.width/5,P=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-P-J,y:this.height},this.tipBase2Position={x:this.width-P,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-P-J},this.tipBase2Position={x:this.width,y:this.height-P}):j<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(J=this.width/5,P=Math.min(this.width/2,15),this.tipBase1Position={x:P,y:this.height},this.tipBase2Position={x:P+J,y:this.height}):(this.tipBase1Position={x:0,y:this.height-P},this.tipBase2Position={x:0,y:this.height-P-J})},u.prototype.resize=function(g){U.prototype.resize.call(this,g),this.positionTip()},u.prototype.positionTip=function(){ne.setAttributes(this.tip,[["points",this.getTipPoints()]]);var g=this.tipGrip.visual.transform.baseVal.getItem(0);g.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(g,0)},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),u.prototype.select=function(){this.positionTip(),U.prototype.select.call(this)},u.prototype.getState=function(){var g=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){var P=g;this.bgColor=P.bgColor,this.tipPosition=P.tipPosition,U.prototype.restoreState.call(this,g),this.createTip(),this.setTipPoints()},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.tipPosition={x:this.tipPosition.x*g,y:this.tipPosition.y*P},this.positionTip()},u.typeName="CalloutMarker",u.title="Callout marker",u.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>',u}(je),Se=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.fillColor="transparent",j.strokeColor="transparent",j.strokeWidth=0,j.strokeDasharray="",j.opacity=1,j.strokeColor=J.defaultColor,j.strokeWidth=J.defaultStrokeWidth,j.strokeDasharray=J.defaultStrokeDasharray,j.fillColor=J.defaultFillColor,j.setStrokeColor=j.setStrokeColor.bind(j),j.setFillColor=j.setFillColor.bind(j),j.setStrokeWidth=j.setStrokeWidth.bind(j),j.setStrokeDasharray=j.setStrokeDasharray.bind(j),j.setOpacity=j.setOpacity.bind(j),j.createVisual=j.createVisual.bind(j),j.strokePanel=new He("Line color",me(J.defaultColorSet,["transparent"]),J.defaultColor),j.strokePanel.onColorChanged=j.setStrokeColor,j.fillPanel=new He("Fill color",me(J.defaultColorSet,["transparent"]),j.fillColor,se),j.fillPanel.onColorChanged=j.setFillColor,j.strokeWidthPanel=new Et("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),j.strokeWidthPanel.onWidthChanged=j.setStrokeWidth,j.strokeStylePanel=new ct("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),j.strokeStylePanel.onStyleChanged=j.setStrokeDasharray,j.opacityPanel=new te("Opacity",J.defaultOpacitySteps,j.opacity),j.opacityPanel.onOpacityChanged=j.setOpacity,j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.visual)},u.prototype.createVisual=function(){this.visual=ne.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)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="new"&&(this.createVisual(),this.moveVisual(g),this._state="creating")},u.prototype.manipulate=function(g){U.prototype.manipulate.call(this,g)},u.prototype.resize=function(g){U.prototype.resize.call(this,g),this.setSize()},u.prototype.setSize=function(){U.prototype.setSize.call(this),ne.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},u.prototype.pointerUp=function(g){U.prototype.pointerUp.call(this,g),this.setSize()},u.prototype.setStrokeColor=function(g){this.strokeColor=g,this.visual&&ne.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(g),this.stateChanged()},u.prototype.setFillColor=function(g){this.fillColor=g,this.visual&&ne.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(g),this.stateChanged()},u.prototype.setStrokeWidth=function(g){this.strokeWidth=g,this.visual&&ne.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},u.prototype.setStrokeDasharray=function(g){this.strokeDasharray=g,this.visual&&ne.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},u.prototype.setOpacity=function(g){this.opacity=g,this.visual&&ne.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){var P=g;this.fillColor=P.fillColor,this.strokeColor=P.strokeColor,this.strokeWidth=P.strokeWidth,this.strokeDasharray=P.strokeDasharray,this.opacity=P.opacity,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,P){U.prototype.scale.call(this,g,P),this.setSize()},u.typeName="EllipseMarker",u.title="Ellipse marker",u.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>',u}(et),ke=function(U){function u(g,P,J){return U.call(this,g,P,J)||this}return _e(u,U),Object.defineProperty(u.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.tip1&&g!==this.tip2)},u.prototype.createTips=function(){this.tip1=ne.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(ne.createTransform()),this.visual.appendChild(this.tip1),this.tip2=ne.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(ne.createTransform()),this.visual.appendChild(this.tip2)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.state==="creating"&&this.createTips()},u.prototype.adjustVisual=function(){if(U.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(ne.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()]]),ne.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 g=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),P=this.tip1.transform.baseVal.getItem(0);P.setRotate(g,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(P,0);var J=this.tip2.transform.baseVal.getItem(0);J.setRotate(g+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(J,0)}},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=U.prototype.getState.call(this);return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g),this.createTips(),this.adjustVisual()},u.typeName="MeasurementMarker",u.title="Measurement marker",u.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>',u}(lt),Je=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.strokePanel.colors=J.defaultColorSet,j.fillColor="transparent",j}return _e(u,U),Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=U.prototype.getState.call(this);return g.typeName=u.typeName,g},u.typeName="EllipseFrameMarker",u.title="Ellipse frame marker",u.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>',u}(Se),Qe=function(){function U(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(U.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),U.prototype.addUndoStep=function(u){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(u)||(this.undoStack.push(u),JSON.stringify(this.lastRedoStep)!==JSON.stringify(u)&&this.redoStack.splice(0,this.redoStack.length))},U.prototype.replaceLastUndoStep=function(u){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=u)},U.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},U.prototype.undo=function(){if(this.undoStack.length>1){var u=this.undoStack.pop();return u!==void 0&&this.redoStack.push(u),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},U.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},U}(),bt=function(U){function u(g,P,J){var j=U.call(this,g,P,J)||this;return j.strokeColor="transparent",j.strokeWidth=0,j.strokeDasharray="",j.curveX=0,j.curveY=0,j.manipulationStartCurveX=0,j.manipulationStartCurveY=0,j.setStrokeColor=j.setStrokeColor.bind(j),j.setStrokeWidth=j.setStrokeWidth.bind(j),j.setStrokeDasharray=j.setStrokeDasharray.bind(j),j.positionGrips=j.positionGrips.bind(j),j.addControlGrips=j.addControlGrips.bind(j),j.adjustVisual=j.adjustVisual.bind(j),j.setupControlBox=j.setupControlBox.bind(j),j.resize=j.resize.bind(j),j.strokeColor=J.defaultColor,j.strokeWidth=J.defaultStrokeWidth,j.strokeDasharray=J.defaultStrokeDasharray,j.strokePanel=new He("Line color",J.defaultColorSet,J.defaultColor),j.strokePanel.onColorChanged=j.setStrokeColor,j.strokeWidthPanel=new Et("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),j.strokeWidthPanel.onWidthChanged=j.setStrokeWidth,j.strokeStylePanel=new ct("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),j.strokeStylePanel.onStyleChanged=j.setStrokeDasharray,j}return _e(u,U),u.prototype.ownsTarget=function(g){return!(!U.prototype.ownsTarget.call(this,g)&&g!==this.visual&&g!==this.selectorCurve&&g!==this.visibleCurve&&!this.curveGrip.ownsTarget(g))},u.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},u.prototype.createVisual=function(){this.visual=ne.createGroup(),this.selectorCurve=ne.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=ne.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)},u.prototype.pointerDown=function(g,P){U.prototype.pointerDown.call(this,g,P),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=g.x,this.curveY=g.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(P)&&(this.activeGrip=this.curveGrip,this._state="resize")},u.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),ne.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),ne.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),ne.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},u.prototype.setupControlBox=function(){U.prototype.setupControlBox.call(this),this.curveControlLine1=ne.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=ne.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)},u.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,U.prototype.addControlGrips.call(this)},u.prototype.positionGrips=function(){U.prototype.positionGrips.call(this);var g=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-g/2,this.curveY-g/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()))},u.prototype.manipulate=function(g){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+g.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+g.y-this.manipulationStartY),U.prototype.manipulate.call(this,g)},u.prototype.resize=function(g){this.activeGrip===this.curveGrip&&(this.curveX=g.x,this.curveY=g.y),U.prototype.resize.call(this,g),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},u.prototype.setStrokeColor=function(g){this.strokeColor=g,this.adjustVisual(),this.colorChanged(g)},u.prototype.setStrokeWidth=function(g){this.strokeWidth=g,this.adjustVisual()},u.prototype.setStrokeDasharray=function(g){this.strokeDasharray=g,this.adjustVisual()},u.prototype.scale=function(g,P){this.curveX=this.curveX*g,this.curveY=this.curveY*P,U.prototype.scale.call(this,g,P)},Object.defineProperty(u.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),u.prototype.getState=function(){var g=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},U.prototype.getState.call(this));return g.typeName=u.typeName,g},u.prototype.restoreState=function(g){U.prototype.restoreState.call(this,g);var P=g;this.strokeColor=P.strokeColor,this.strokeWidth=P.strokeWidth,this.strokeDasharray=P.strokeDasharray,this.curveX=P.curveX,this.curveY=P.curveY,this.createVisual(),this.adjustVisual()},u.typeName="CurveMarker",u.title="Curve marker",u.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>',u}(gt),Dt=function(){function U(u,g){g===void 0&&(g=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=u,this.cancelable=g}return Object.defineProperty(U.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),U.prototype.preventDefault=function(){this._defaultPrevented=!0},U}(),Ze=function(U){function u(g,P,J){var j=U.call(this,g,!1)||this;return j.dataUrl=P,j.state=J,j}return _e(u,U),u}(Dt),ut=function(U){function u(g,P,J){J===void 0&&(J=!1);var j=U.call(this,g,J)||this;return j.marker=P,j}return _e(u,U),u}(Dt),Ft=function(){function U(){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 U.prototype.addEventListener=function(u,g){this[u].push(g)},U.prototype.removeEventListener=function(u,g){var P=this[u].indexOf(g);P>-1&&this[u].splice(P,1)},U}(),Ct=function(){function U(u){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new Qe,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=U.instanceCounter++,this.styles=new Xe(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=u,this.targetRoot=document.body,this.width=u.clientWidth,this.height=u.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(U.prototype,"ALL_MARKER_TYPES",{get:function(){return[dt,ge,pe,je,Je,Se,ie,ue,ke,ee,lt,bt]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[dt,ge,pe,je,Se,ie,ue]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"BASIC_MARKER_TYPES",{get:function(){return[dt,ge,pe,je,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(u){var g=this;this._availableMarkerTypes.splice(0),u.forEach(function(P){if(typeof P=="string"){var J=g.ALL_MARKER_TYPES.find(function(j){return j.typeName===P});J!==void 0&&g._availableMarkerTypes.push(J)}else g._availableMarkerTypes.push(P)})},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(u){this._zoomLevel=u,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(U.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),U.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Ae.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},U.prototype.show=function(){var u=this;this.styles.styleSheetRoot===void 0&&$e.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=$e.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(g){return g(new Dt(u))})},U.prototype.render=function(){return Te(this,void 0,void 0,function(){var u;return Ce(this,function(g){switch(g.label){case 0:return this.setCurrentMarker(),(u=new rt).naturalSize=this.renderAtNaturalSize,u.imageType=this.renderImageType,u.imageQuality=this.renderImageQuality,u.markersOnly=this.renderMarkersOnly,u.width=this.renderWidth,u.height=this.renderHeight,[4,u.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return g.sent(),[4,u.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,g.sent()]}})})},U.prototype.close=function(u){var g=this;if(u===void 0&&(u=!1),this.isOpen){var P=!1;u||this.eventListeners.beforeclose.forEach(function(J){var j=new Dt(g,!0);J(j),j.defaultPrevented&&(P=!0)}),P||(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(J){return J(new Dt(g))}),this.detachEvents(),this._isOpen=!1)}},U.prototype.addMarkersToToolbar=function(){for(var u,g=[],P=0;P<arguments.length;P++)g[P]=arguments[P];(u=this._availableMarkerTypes).push.apply(u,g)},U.prototype.addRenderEventListener=function(u){this.addEventListener("render",function(g){u(g.dataUrl,g.state)})},U.prototype.removeRenderEventListener=function(u){},U.prototype.addCloseEventListener=function(u){this.addEventListener("close",function(){u()})},U.prototype.removeCloseEventListener=function(u){},U.prototype.setupResizeObserver=function(){var u=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){u.resize(u.target.clientWidth,u.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return u.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},U.prototype.onPopupTargetResize=function(){var u=1*this.target.clientWidth/this.target.clientHeight,g=this.editorCanvas.clientWidth/u>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*u:this.editorCanvas.clientWidth,P=g<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/u;this.resize(g,P)},U.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},U.prototype.resize=function(u,g){this._isResizing=!0;var P=u/this.imageWidth,J=g/this.imageHeight;this.imageWidth=Math.round(u),this.imageHeight=Math.round(g),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(P,J),this._isResizing=!1},U.prototype.scaleMarkers=function(u,g){var P,J=this;this._currentMarker&&this._currentMarker instanceof je?this._currentMarker.scale(u,g):(P=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(j){j!==J._currentMarker&&j.scale(u,g)}),P!==void 0&&this.setCurrentMarker(P)},U.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"},U.prototype.setTopLeft=function(){var u=this.editingTarget.getBoundingClientRect(),g=this.editorCanvas.getBoundingClientRect();this.left=u.left-g.left,this.top=u.top-g.top},U.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)},U.prototype.addDefs=function(){for(var u,g=[],P=0;P<arguments.length;P++)g[P]=arguments[P];this.defs=ne.createDefs(),this.addDefsToImage(),(u=this.defs).append.apply(u,g)},U.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},U.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)},U.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},U.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},U.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)},U.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},U.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)},U.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 u=document.createElement("a");u.href="https://markerjs.com/",u.target="_blank",u.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>',u.title="Powered by marker.js",u.style.display="grid",u.style.alignItems="center",u.style.justifyItems="center",u.style.padding="3px",u.style.width="20px",u.style.height="20px",this.logoUI.appendChild(u),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},U.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")},U.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"},U.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},U.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 u=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=u+"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 Me(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 ze(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},U.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},U.prototype.removeMarker=function(u){this.markerImage.removeChild(u.container),this.markers.indexOf(u)>-1&&this.markers.splice(this.markers.indexOf(u),1),u.dispose()},U.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())},U.prototype.toolbarButtonClicked=function(u,g){if(u==="marker"&&g!==void 0)this.createNewMarker(g);else if(u==="action")switch(g){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()}},U.prototype.deleteSelectedMarker=function(){var u=this;if(this._currentMarker!==void 0){var g=!1;if(this.eventListeners.markerbeforedelete.forEach(function(J){var j=new ut(u,u._currentMarker,!0);J(j),j.defaultPrevented&&(g=!0)}),!g){var P=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(J){return J(new ut(u,P))})}}},U.prototype.clear=function(){var u=this,g=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ce){var Ne=new ut(u,void 0,!0);ce(Ne),Ne.defaultPrevented&&(g=!0)}),!g)){this.setCurrentMarker();for(var P=function(ce){var Ne=J.markers[ce];J.setCurrentMarker(J.markers[ce]),J._currentMarker.dispose(),J.markerImage.removeChild(J._currentMarker.container),J.markers.splice(J.markers.indexOf(J._currentMarker),1),J.eventListeners.markerdelete.forEach(function(qe){return qe(new ut(u,Ne))})},J=this,j=this.markers.length-1;j>=0;j--)P(j);this.addUndoStep()}},Object.defineProperty(U.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),U.prototype.showNotesEditor=function(){var u;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=(u=this._currentMarker.notes)!==null&&u!==void 0?u:"",this.overlayContainer.appendChild(this.notesArea))},U.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)},U.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},U.prototype.addUndoStep=function(){var u=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var g=this.getState(),P=this.undoRedoManager.getLastUndoStep();if(!P||P.width===g.width&&P.height===g.height){var J=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(g),J<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(j){return j(new Dt(u))})}else this.undoRedoManager.replaceLastUndoStep(g),this.eventListeners.statechange.forEach(function(j){return j(new Dt(u))})}},U.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},U.prototype.undoStep=function(){var u=this,g=this.undoRedoManager.undo();g!==void 0&&(this.restoreState(g),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(P){return P(new Dt(u))}))},U.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},U.prototype.redoStep=function(){var u=this,g=this.undoRedoManager.redo();g!==void 0&&(this.restoreState(g),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(P){return P(new Dt(u))}))},U.prototype.stepZoom=function(){var u=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=u<this.zoomSteps.length-1?this.zoomSteps[u+1]:this.zoomSteps[0]},U.prototype.panTo=function(u){this.contentDiv.scrollBy({left:this.prevPanPoint.x-u.x,top:this.prevPanPoint.y-u.y}),this.prevPanPoint=u},U.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var u,g,P=this;return Ce(this,function(J){switch(J.label){case 0:return[4,this.render()];case 1:return u=J.sent(),g=this.getState(),this.eventListeners.render.forEach(function(j){return j(new Ze(P,u,g))}),this.close(!0),[2]}})})},U.prototype.getState=function(u){u===!0&&this.setCurrentMarker();var g={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(P){return g.markers.push(P.getState())}),g},U.prototype.restoreState=function(u){var g=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);u.markers.forEach(function(P){var J=g._availableMarkerTypes.find(function(ce){return ce.typeName===P.typeName});if(J!==void 0){var j=g.addNewMarker(J);j.restoreState(P),g.markers.push(j)}}),u.width&&u.height&&(u.width!==this.imageWidth||u.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/u.width,this.imageHeight/u.height),this.eventListeners.restorestate.forEach(function(P){return P(new Dt(g))})},U.prototype.addNewMarker=function(u){var g=ne.createGroup();return this.markerImage.appendChild(g),new u(g,this.overlayContainer,this.settings)},U.prototype.createNewMarker=function(u){var g,P=this;(g=typeof u=="string"?this._availableMarkerTypes.find(function(J){return J.typeName===u}):u)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(g),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(g.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(J){return J(new ut(P,P._currentMarker))}))},U.prototype.markerCreated=function(u){var g=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(u),this.setCurrentMarker(u),u instanceof ge&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(ge):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(P){return P(new ut(g,g._currentMarker))})},U.prototype.colorChanged=function(u){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=u,this.settings.defaultStrokeColor=u)},U.prototype.fillColorChanged=function(u){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=u)},U.prototype.markerStateChanged=function(u){var g=this;this.eventListeners.markerchange.forEach(function(P){return P(new ut(g,u))})},U.prototype.setCurrentMarker=function(u){var g=this;this._currentMarker!==u&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(P){return P(new ut(g,g._currentMarker))})),this._currentMarker=u,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(P){return P(new ut(g,g._currentMarker))}))},U.prototype.onPointerDown=function(u){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||u.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var g=this.markers.find(function(P){return P.ownsTarget(u.target)});g!==void 0?(this.setCurrentMarker(g),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(u.clientX,u.clientY),u.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:u.clientX,y:u.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(u.clientX,u.clientY))},U.prototype.onDblClick=function(u){if(this._isFocused||this.focus(),this.mode==="select"){var g=this.markers.find(function(P){return P.ownsTarget(u.target)});g!==void 0&&g!==this._currentMarker&&this.setCurrentMarker(g),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(u.clientX,u.clientY),u.target):this.setCurrentMarker()}},U.prototype.onPointerMove=function(u){this.touchPoints!==1&&u.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||u.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(u.clientX,u.clientY)):this.zoomLevel>1&&this.panTo({x:u.clientX,y:u.clientY}))},U.prototype.onPointerUp=function(u){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(u.clientX,u.clientY)),this.isDragging=!1,this.addUndoStep()},U.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},U.prototype.onKeyUp=function(u){this._currentMarker===void 0||this.notesArea!==void 0||u.key!=="Delete"&&u.key!=="Backspace"||this.deleteSelectedMarker()},U.prototype.clientToLocalCoordinates=function(u,g){var P=this.markerImage.getBoundingClientRect();return{x:(u-P.left)/this.zoomLevel,y:(g-P.top)/this.zoomLevel}},U.prototype.onWindowResize=function(){this.positionUI()},U.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var u=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=u+"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()},U.prototype.addLicenseKey=function(u){Ae.addKey(u)},U.prototype.addEventListener=function(u,g){this.eventListeners.addEventListener(u,g)},U.prototype.removeEventListener=function(u,g){this.eventListeners.removeEventListener(u,g)},U.prototype.renderState=function(u){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(u),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(U.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),U.prototype.focus=function(){var u=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(g){return g(new Dt(u))}))},U.prototype.blur=function(){var u=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(g){return g(new Dt(u))}))},U.instanceCounter=0,U}();/* **********************************
|
|
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 jt=function(U,u){return(jt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,P){g.__proto__=P}||function(g,P){for(var J in P)Object.prototype.hasOwnProperty.call(P,J)&&(g[J]=P[J])})(U,u)};function $t(U,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");function g(){this.constructor=U}jt(U,u),U.prototype=u===null?Object.create(u):(g.prototype=u.prototype,new g)}function Lt(U,u,g,P){return new(g||(g=Promise))(function(J,j){function ce(Tt){try{qe(P.next(Tt))}catch(Ue){j(Ue)}}function Ne(Tt){try{qe(P.throw(Tt))}catch(Ue){j(Ue)}}function qe(Tt){var Ue;Tt.done?J(Tt.value):(Ue=Tt.value,Ue instanceof g?Ue:new g(function(Pt){Pt(Ue)})).then(ce,Ne)}qe((P=P.apply(U,u||[])).next())})}function Qt(U,u){var g,P,J,j,ce={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return j={next:Ne(0),throw:Ne(1),return:Ne(2)},typeof Symbol=="function"&&(j[Symbol.iterator]=function(){return this}),j;function Ne(qe){return function(Tt){return function(Ue){if(g)throw new TypeError("Generator is already executing.");for(;ce;)try{if(g=1,P&&(J=2&Ue[0]?P.return:Ue[0]?P.throw||((J=P.return)&&J.call(P),0):P.next)&&!(J=J.call(P,Ue[1])).done)return J;switch(P=0,J&&(Ue=[2&Ue[0],J.value]),Ue[0]){case 0:case 1:J=Ue;break;case 4:return ce.label++,{value:Ue[1],done:!1};case 5:ce.label++,P=Ue[1],Ue=[0];continue;case 7:Ue=ce.ops.pop(),ce.trys.pop();continue;default:if(!(J=ce.trys,(J=J.length>0&&J[J.length-1])||Ue[0]!==6&&Ue[0]!==2)){ce=0;continue}if(Ue[0]===3&&(!J||Ue[1]>J[0]&&Ue[1]<J[3])){ce.label=Ue[1];break}if(Ue[0]===6&&ce.label<J[1]){ce.label=J[1],J=Ue;break}if(J&&ce.label<J[2]){ce.label=J[2],ce.ops.push(Ue);break}J[2]&&ce.ops.pop(),ce.trys.pop();continue}Ue=u.call(U,ce)}catch(Pt){Ue=[6,Pt],P=0}finally{g=J=0}if(5&Ue[0])throw Ue[1];return{value:Ue[0]?Ue[1]:void 0,done:!0}}([qe,Tt])}}}var Zt=function(){function U(){}return U.addKey=function(u){U.key=u},Object.defineProperty(U,"isLicensed",{get:function(){return!!U.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(U.key)},enumerable:!1,configurable:!0}),U}(),ft=function(){function U(){}return U.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},U.setAttributes=function(u,g){for(var P=0,J=g;P<J.length;P++){var j=J[P],ce=j[0],Ne=j[1];u.setAttribute(ce,Ne)}},U.createRect=function(u,g,P){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",u.toString()),J.setAttribute("height",g.toString()),P&&U.setAttributes(J,P),J},U.createLine=function(u,g,P,J,j){var ce=document.createElementNS("http://www.w3.org/2000/svg","line");return ce.setAttribute("x1",u.toString()),ce.setAttribute("y1",g.toString()),ce.setAttribute("x2",P.toString()),ce.setAttribute("y2",J.toString()),j&&U.setAttributes(ce,j),ce},U.createPolygon=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","polygon");return P.setAttribute("points",u),g&&U.setAttributes(P,g),P},U.createCircle=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","circle");return P.setAttribute("cx",(u/2).toString()),P.setAttribute("cy",(u/2).toString()),P.setAttribute("r",u.toString()),g&&U.setAttributes(P,g),P},U.createEllipse=function(u,g,P){var J=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return J.setAttribute("cx",(u/2).toString()),J.setAttribute("cy",(g/2).toString()),J.setAttribute("rx",(u/2).toString()),J.setAttribute("ry",(g/2).toString()),P&&U.setAttributes(J,P),J},U.createGroup=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","g");return u&&U.setAttributes(g,u),g},U.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},U.createMarker=function(u,g,P,J,j,ce,Ne){var qe=document.createElementNS("http://www.w3.org/2000/svg","marker");return U.setAttributes(qe,[["id",u],["orient",g],["markerWidth",P.toString()],["markerHeight",J.toString()],["refX",j.toString()],["refY",ce.toString()]]),qe.appendChild(Ne),qe},U.createText=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","text");return g.setAttribute("x","0"),g.setAttribute("y","0"),u&&U.setAttributes(g,u),g},U.createTSpan=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","tspan");return P.textContent=u,g&&U.setAttributes(P,g),P},U.createImage=function(u){var g=document.createElementNS("http://www.w3.org/2000/svg","image");return u&&U.setAttributes(g,u),g},U.createPoint=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return P.x=u,P.y=g,P},U.createPath=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg","path");return P.setAttribute("d",u),g&&U.setAttributes(P,g),P},U.createElement=function(u,g){var P=document.createElementNS("http://www.w3.org/2000/svg",u);return g&&U.setAttributes(P,g),P},U.getHollowRectanglePath=function(u,g,P,J,j,ce,Ne,qe){return"M"+u+","+g+"V"+(g+J)+"H"+(u+P)+"V"+g+"H"+j+"V"+ce+"H"+(j+Ne)+"V"+(ce+qe)+"H"+j+"V"+g+"Z"},U}(),Xt=function(){function U(u){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+u+"_"}return Object.defineProperty(U.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(U.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(U.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),U.prototype.addClass=function(u){return this.styleSheet===void 0&&this.addStyleSheet(),u.name=""+this.classNamePrefix+u.localName,this.classes.push(u),this.styleSheet.sheet.insertRule("."+u.name+" {"+u.style+"}",this.styleSheet.sheet.cssRules.length),u},U.prototype.addRule=function(u){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(u),this.styleSheet.sheet.insertRule(u.selector+" {"+u.style+"}",this.styleSheet.sheet.cssRules.length)},U.prototype.addStyleSheet=function(){var u;this.styleSheet=document.createElement("style"),((u=this.styleSheetRoot)!==null&&u!==void 0?u:document.head).appendChild(this.styleSheet),this.addRule(new zt("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new zt("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new zt("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new Gt("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new Gt("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},U.prototype.removeStyleSheet=function(){var u;this.styleSheet&&(((u=this.styleSheetRoot)!==null&&u!==void 0?u:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},U}(),zt=function(U,u){this.selector=U,this.style=u},Gt=function(U,u){this.localName=U,this.style=u},Ut=function(){function U(){this.blocks=[],this.display=""}return U.prototype.addButtonBlock=function(u){u.className=this.blockClassName,u.buttonClassName=this.buttonClassName,u.buttonColorsClassName=this.buttonColorsClassName,u.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(u)},U.prototype.addElementBlock=function(u){u.className===void 0&&(u.className=this.blockClassName),this.blocks.push(u)},U.prototype.getUI=function(){var u=document.createElement("div");return u.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,u.style.display=this.display,this.blocks.forEach(function(g){return u.appendChild(g.getUI())}),u},U}(),Mt=function(){function U(){}return U.prototype.getUI=function(){var u=document.createElement("div");if(u.className=this.className,this.minWidth!==void 0&&(u.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":u.style.justifyContent="flex-start";break;case"center":u.style.justifyContent="center";break;case"end":u.style.justifyContent="flex-end"}return u.style.whiteSpace="nowrap",u},U}(),St=function(U){function u(){var g=U!==null&&U.apply(this,arguments)||this;return g.buttons=[],g}return $t(u,U),u.prototype.addButton=function(g){g.className=this.buttonClassName,g.colorsClassName=this.buttonColorsClassName,g.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(g)},u.prototype.getUI=function(){var g=U.prototype.getUI.call(this);return this.buttons.forEach(function(P){return g.appendChild(P.getUI())}),g},u}(Mt),tt=function(){function U(u,g){this._isActive=!1,this._isHidden=!1,this._icon=u,this.title=g,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(U.prototype,"icon",{get:function(){return this._icon},set:function(u){this._icon=u,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isActive",{get:function(){return this._isActive},set:function(u){this._isActive=u,this.adjustClassName()},enumerable:!1,configurable:!0}),U.prototype.getUI=function(){var u=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 u.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},U.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,"")))},U.prototype.hide=function(){this._isHidden=!0},U}(),Fe=function(U){function u(){var g=U!==null&&U.apply(this,arguments)||this;return g.elements=[],g}return $t(u,U),u.prototype.addElement=function(g){this.elements.push(g)},u.prototype.getUI=function(){var g=U.prototype.getUI.call(this);return this.elements.forEach(function(P){return g.appendChild(P)}),g},u}(Mt),nr=function(){function U(u,g){this.horizontal=u,this.vertical=g}return Object.defineProperty(U.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),U.prototype.getVerticalLength=function(u){return u/this.ratio},U.prototype.getHorizontalLength=function(u){return u*this.ratio},U}(),Vt=function(){function U(){}return U.getIcon=function(u,g){if(u>0&&g>0){var P=new nr(u,g),J=P.ratio>=1?20:P.getHorizontalLength(20),j=P.ratio<1?20:P.getVerticalLength(20),ce=document.createElementNS("http://www.w3.org/2000/svg","svg");ce.setAttribute("xmlns","http://www.w3.org/2000/svg"),ce.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ce);var Ne=ft.createDefs();ce.appendChild(Ne);var qe=ft.createElement("clipPath",[["id","text-bg-clip"]]);Ne.appendChild(qe);var Tt=ft.createPath(ft.getHollowRectanglePath((24-J)/2,(24-j)/2,J,j,(24-J)/2+2,(24-j)/2+2,J-4,j-4));ce.appendChild(Tt);var Ue=ft.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ue.appendChild(ft.createTSpan(u+":"+g)),ce.appendChild(Ue);var Pt=Ue.getBBox();ft.setAttributes(Ue,[["x",((24-Pt.width)/2).toString()],["y",((24-Pt.height)/2-Pt.y).toString()]]);var er=ft.createPath(ft.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Pt.width))/2,(24-Math.ceil(Pt.height))/2,Math.ceil(Pt.width),Math.ceil(Pt.height)));return qe.appendChild(er),ft.setAttributes(Tt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ce),ce.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>'},U}(),qt=function(U){function u(g,P,J){var j=U.call(this,g,P)||this;return j.isDropdownOpen=!1,j.onClick=j.dropdownButtonClicked,j.dropdownButtons=J,j}return $t(u,U),u.prototype.setupDropdown=function(){var g=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(P){P.className=g.className,P.colorsClassName=g.colorsClassName,g.dropdownBlock.appendChild(P.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},u.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},u.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},u.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},u.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},u.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},u}(tt),Wt=function(){function U(u,g){this.GRIP_SIZE=10,this.color=u,this.fillColor=g,this.visual=ft.createGroup(),this.visual.appendChild(ft.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(ft.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return U.prototype.ownsTarget=function(u){return u===this.visual||u===this.visual.childNodes[0]||u===this.visual.childNodes[1]},U.prototype.setCenter=function(u,g){this.visual.childNodes.forEach(function(P){return ft.setAttributes(P,[["cx",u.toString()],["cy",g.toString()]])})},U}(),Tr=function(){function U(u,g,P,J){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=u,this.canvasHeight=g,this.margin=P,this.container=J,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(U.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(u){this._aspectRatio=u,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(u){this._isGridVisible=u,this.gridContainer&&ft.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(u){this._zoomFactor=u,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),U.prototype.open=function(){var u=this;this.cropShadeElement=ft.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=ft.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var g=0;g<this.numberOfGridLines;g++)this.horizontalGridLines.push(ft.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(ft.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(P){return u.gridContainer.appendChild(P)}),this.verticalGridLines.forEach(function(P){return u.gridContainer.appendChild(P)}),this.cropRectElement=ft.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Wt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},U.prototype.setCropRectangle=function(u){this.cropRect=u;var g=Object.assign({},this.cropRect);this.zoomFactor!==1&&(g.width=this.cropRect.width*this.zoomFactor,g.height=this.cropRect.height*this.zoomFactor,g.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-g.width/2,g.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-g.height/2),ft.setAttributes(this.cropRectElement,[["x",g.x.toString()],["y",g.y.toString()],["width",g.width.toString()],["height",g.height.toString()]]);var P=g.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(j,ce){var Ne=g.y+P*(ce+1);ft.setAttributes(j,[["x1",""+g.x],["y1",""+Ne],["x2",""+(g.x+g.width)],["y2",""+Ne]])});var J=g.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(j,ce){var Ne=g.x+J*(ce+1);ft.setAttributes(j,[["x1",""+Ne],["y1",""+g.y],["x2",""+Ne],["y2",""+(g.y+g.height)]])}),ft.setAttributes(this.cropShadeElement,[["d",ft.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,g.x,g.y,g.width,g.height)]]),this.topLeftGrip.setCenter(g.x,g.y),this.topRightGrip.setCenter(g.x+g.width,g.y),this.bottomLeftGrip.setCenter(g.x,g.y+g.height),this.bottomRightGrip.setCenter(g.x+g.width,g.y+g.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},U.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)},U.prototype.clientToLocalCoordinates=function(u,g){var P=this.container.getBoundingClientRect();return{x:u-P.left+this.margin,y:g-P.top+this.margin}},U.prototype.onPointerDown=function(u){this.container.setPointerCapture(u.pointerId),this.previousPoint=this.clientToLocalCoordinates(u.clientX,u.clientY),this.cropRectElement===u.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(u.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(u.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(u.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(u.target)&&(this.activeGrip=this.bottomRightGrip)},U.prototype.onPointerMove=function(u){if(this.isMoving)this.move(this.clientToLocalCoordinates(u.clientX,u.clientY));else if(this.activeGrip){var g=this.clientToLocalCoordinates(u.clientX,u.clientY);this.resize(g)}u.preventDefault()},U.prototype.onPointerUp=function(u){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(u.pointerId)},U.prototype.move=function(u){var g=u.x-this.previousPoint.x,P=u.y-this.previousPoint.y;this.zoomFactor!==1&&(g=-g/this.zoomFactor,P=-P/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+g),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+P),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=u},U.prototype.resize=function(u){var g=Object.assign({},this.cropRect),P=u.x-this.previousPoint.x,J=u.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:g.x+P<this.margin&&(P=this.margin-g.x),g.x+=P,g.width=this.cropRect.x+this.cropRect.width-g.x;break;case this.bottomRightGrip:case this.topRightGrip:g.width+P>this.canvasWidth*this.zoomFactor&&(P=this.canvasWidth*this.zoomFactor-g.width),g.width+=P}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(g.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(P),g.height=this.aspectRatio.getVerticalLength(g.width)):(g.y+=J,g.height=this.cropRect.y+this.cropRect.height-g.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?g.height=this.aspectRatio.getVerticalLength(g.width):g.height+=J}g.width<10&&(g.x=this.cropRect.x,g.width=10),g.height<10&&(g.y=this.cropRect.y,g.height=10),this.previousPoint=u,g.x>=this.margin&&g.y>=this.margin&&g.x-this.margin+g.width<=this.canvasWidth&&g.y-this.margin+g.height<=this.canvasHeight&&(this.cropRect=g,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},U.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var u=this.cropRect.x+this.cropRect.width/2,g=this.cropRect.y+this.cropRect.height/2,P=this.aspectRatio.getHorizontalLength(this.cropRect.height),J=this.aspectRatio.getVerticalLength(this.cropRect.width);P/this.canvasWidth<J/this.canvasHeight?this.cropRect.width=P:this.cropRect.height=J,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=u-this.cropRect.width/2,this.cropRect.y=g-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)}},U.prototype.getRescaledRect=function(u,g,P,J,j,ce){var Ne=P/u,qe=J/g;return{x:(j.x-ce)*Ne+ce,y:(j.y-ce)*qe+ce,width:j.width*Ne,height:j.height*qe}},U.prototype.scaleCanvas=function(u,g){var P=this.getRescaledRect(this.canvasWidth,this.canvasHeight,u,g,this.cropRect,this.margin);this.canvasWidth=u,this.canvasHeight=g,this.onCropChange&&this.onCropChange(P),this.setCropRectangle(P)},U}(),ir=function(){function U(u){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=u,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(U.prototype,"angle",{get:function(){return this._angle},set:function(u){this._angle=u,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),U.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},U.prototype.onPointerDown=function(u){this.controlContainer.setPointerCapture(u.pointerId),this.isDragging=!0,this.previousPoint={x:u.clientX,y:u.clientY}},U.prototype.onPointerMove=function(u){this.isDragging&&(this.onAngleChange&&this.onAngleChange((u.clientX-this.previousPoint.x)/5),this.previousPoint.x=u.clientX)},U.prototype.onPointerUp=function(u){this.isDragging&&this.onAngleChange&&this.onAngleChange((u.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(u.pointerId)},U.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var u=this.angleLabelText.getBBox();ft.setAttributes(this.angleLabelElement,[["x",((this.width-u.width)/2).toString()],["y",(this.height/2).toString()]])}},U.prototype.positionScaleShape=function(){if(this.scaleShape){var u=this.scaleShape.transform.baseVal.getItem(0);u.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(u,0)}},U.prototype.getVisual=function(){var u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("xmlns","http://www.w3.org/2000/svg"),u.setAttribute("width",this.width+"px"),u.setAttribute("height",this.height+"px"),u.setAttribute("viewBox","0 0 "+this.width+" "+this.height),u.style.flexShrink="0",document.body.appendChild(u);for(var g="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,P=1;P<=this.width/5+10;P++){var J=P%5==0?this.height/3:this.height/6;g+="h4v"+-J+"h1v"+J}g+="v1H0Z",this.scaleShape=ft.createPath(g);var j=ft.createTransform();this.scaleShape.transform.baseVal.appendItem(j),u.appendChild(this.scaleShape),this.angleLabelElement=ft.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=ft.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ce=ft.createTSpan("");return ce.innerHTML="°",this.angleLabelElement.appendChild(ce),u.appendChild(this.angleLabelElement),document.body.removeChild(u),u},U}(),Rt=function(){function U(){this.naturalSize=!1,this.imageType="image/png"}return U.prototype.rasterize=function(u,g,P,J,j,ce,Ne){var qe=this;return new Promise(function(Tt){var Ue=document.createElement("canvas");Ue.width=u.width.baseVal.value-2*J,Ue.height=u.height.baseVal.value-2*J;var Pt=1,er=1;qe.naturalSize===!0?(Pt=g.naturalWidth/(u.width.baseVal.value-2*J)/ce,er=g.naturalHeight/(u.height.baseVal.value-2*J)/Ne,Ue.width=g.naturalWidth/ce,Ue.height=g.naturalHeight/Ne):qe.width!==void 0&&qe.height!==void 0&&(Pt=qe.width/P.width,er=qe.height/P.height,Ue.width*=Pt,Ue.height*=er);var fr=Ue.getContext("2d");fr.translate(Ue.width/2,Ue.height/2),fr.rotate(j*Math.PI/180),fr.scale(ce,Ne),fr.translate(-Ue.width/2,-Ue.height/2),fr.drawImage(g,0,0,Ue.width,Ue.height);var Gr=document.createElement("canvas");Gr.width=P.width*Pt,Gr.height=P.height*er,Gr.getContext("2d").putImageData(fr.getImageData((P.x-J)*Pt,(P.y-J)*er,P.width*Pt,P.height*er),0,0),Tt(Gr.toDataURL(qe.imageType,qe.imageQuality))})},U}(),Ie=function(){function U(u){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=U.instanceCounter++,this.styles=new Xt(this.instanceNo),this.target=u,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(U.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(u){this._zoomToCropEnabled=u,u?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(u){this._isGridVisible=u,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"gridLines",{get:function(){return this._gridLines},set:function(u){this._gridLines=u,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(u){this._rotationAngle=u,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"aspectRatio",{get:function(){var u;return(u=this._aspectRatio)!==null&&u!==void 0?u:this.aspectRatios[0]},set:function(u){this._aspectRatio=u},enumerable:!1,configurable:!0}),U.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},U.prototype.show=function(){this.showUI(),this.open()},U.prototype.close=function(u){u===void 0&&(u=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),u||this.closeEventListeners.forEach(function(g){return g()}),this._isOpen=!1)},U.prototype.addRenderEventListener=function(u){this.renderEventListeners.push(u)},U.prototype.removeRenderEventListener=function(u){this.renderEventListeners.indexOf(u)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(u),1)},U.prototype.addCloseEventListener=function(u){this.closeEventListeners.push(u)},U.prototype.removeCloseEventListener=function(u){this.closeEventListeners.indexOf(u)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(u),1)},U.prototype.setupResizeObserver=function(){var u=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){u.resize(u.target.clientWidth,u.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))},U.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var u=1*this.target.clientWidth/this.target.clientHeight,g=this.contentDiv.clientWidth/u>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*u:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,P=g+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/u;this.resize(g,P)}},U.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},U.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",ft.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},U.prototype.resize=function(u,g){this.imageWidth=Math.round(u),this.imageHeight=Math.round(g),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()},U.prototype.setEditingTarget=function(){var u=document.createElement("canvas");u.width=this.target.naturalWidth,u.height=this.target.naturalHeight,u.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var g=u.toDataURL();ft.setAttributes(this.editingTarget,[["href",g]]),this.setEditingTargetSize()},U.prototype.setTopLeft=function(){var u=this.target.getBoundingClientRect(),g=this.editorCanvas.getBoundingClientRect();this.left=u.left-g.left-this.CANVAS_MARGIN,this.top=u.top-g.top-this.CANVAS_MARGIN},U.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=ft.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=ft.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=ft.createGroup(),this.editingTargetRotationScaleContainer=ft.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var u=ft.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(u);var g=ft.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(g),this.editingTargetContainer=ft.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)},U.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},U.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=ft.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Tr(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()},U.prototype.zoomToCrop=function(){if(this.cropRect){var u=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,g=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=u+"px "+g+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-u+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-g+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},U.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)},U.prototype.cropRectChanged=function(u){this.cropRect=u,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},U.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},U.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"},U.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},U.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 u=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,g=this.target.offsetTop>u+this.CANVAS_MARGIN?this.target.offsetTop-(u+this.CANVAS_MARGIN):0;this.coverDiv.style.top=g+"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},U.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},U.prototype.addTopToolbar=function(){var u=this;this.topToolbar=new Ut,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 g=new St;g.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(g);var P=[];this.aspectRatios.forEach(function(er){var fr=new tt(Vt.getIcon(er.horizontal,er.vertical),er.horizontal===0&&er.vertical===0?"FREE":er.horizontal+":"+er.vertical);fr.onClick=function(){return u.ratioButtonClicked(er)},P.push(fr)}),this.aspectRatioButton=new qt(Vt.getIcon(0,0),"Aspect ratio",P),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,g.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var J=new tt('<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");J.isActive=this.isGridVisible,J.onClick=function(){u.isGridVisible=!u.isGridVisible,J.isActive=u.isGridVisible},g.addButton(J);var j=new tt('<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(j.isActive=this.zoomToCropEnabled,j.onClick=function(){u.zoomToCropEnabled=!u.zoomToCropEnabled,j.isActive=u.zoomToCropEnabled},g.addButton(j),!Zt.isLicensed){var ce=new Fe;this.topToolbar.addElementBlock(ce);var Ne=document.createElement("div");Ne.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var qe=document.createElement("a");qe.style.color="currentColor",qe.href="https://markerjs.com/products/cropro",qe.target="_blank",qe.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>',Ne.appendChild(qe),ce.addElement(Ne)}var Tt=new St;Tt.minWidth=3*this.toolbarHeight+"px",Tt.contentAlign="end",this.topToolbar.addButtonBlock(Tt);var Ue=new tt('<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");Ue.onClick=this.startRenderAndClose,Tt.addButton(Ue),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ue.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Pt=new tt('<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");Pt.onClick=this.close,Tt.addButton(Pt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Pt.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},U.prototype.addBottomToolbar=function(){var u=this;this.bottomToolbar=new Ut,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 g=new St;g.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(g);var P=new tt('<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");P.onClick=this.rotateLeftButtonClicked,g.addButton(P);var J=new tt('<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");J.onClick=this.rotateRightButtonClicked,g.addButton(J);var j=new Fe;j.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(j),this.straightener=new ir("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(Tt){u.rotateBy(Tt),u.straightener.angle=u.rotationAngle},j.addElement(this.straightener.getUI());var ce=new St;ce.minWidth=2*this.toolbarHeight+"px",ce.contentAlign="end",this.bottomToolbar.addButtonBlock(ce);var Ne=new tt('<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");Ne.onClick=this.flipHorizontallyButtonClicked,ce.addButton(Ne);var qe=new tt('<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");qe.onClick=this.flipVerticallyButtonClicked,ce.addButton(qe)},U.prototype.ratioButtonClicked=function(u){this.aspectRatio=u,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},U.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Vt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},U.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new nr(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},U.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},U.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},U.prototype.restoreState=function(u){if(u){var g=this.cropLayer.getRescaledRect(u.width,u.height,this.imageWidth,this.imageHeight,u.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(g),this.cropRectChanged(g),this.flippedHorizontally=u.flippedHorizontally,this.flippedVertically=u.flippedVertically,this.applyFlip(),this.rotationAngle=u.rotationAngle,this.applyRotation()}},U.prototype.clientToLocalCoordinates=function(u,g){var P=this.cropImage.getBoundingClientRect();return{x:u-P.left,y:g-P.top}},U.prototype.onWindowResize=function(){this.positionUI()},U.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var u=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=u+"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()},U.prototype.rotateLeftButtonClicked=function(){var u=this.rotationAngle-90;this.rotationAngle%90!=0&&(u+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(u)},U.prototype.rotateRightButtonClicked=function(){var u=this.rotationAngle+90;this.rotationAngle%90!=0&&(u-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(u)},U.prototype.rotateTo=function(u){u=(u=u>180?u-360:u)<=-180?u+360:u,this.rotationAngle=u,this.applyRotation()},U.prototype.rotateBy=function(u){this.rotateTo((this.rotationAngle+u)%360)},U.prototype.applyRotation=function(){var u=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var g=this.editingTargetRotationContainer.transform.baseVal.getItem(0);g.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(g,0);var P=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/P.width,this.imageHeight/P.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=u},U.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},U.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},U.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},U.prototype.startRenderAndClose=function(){return Lt(this,void 0,void 0,function(){var u,g;return Qt(this,function(P){switch(P.label){case 0:return[4,this.render()];case 1:return u=P.sent(),g=this.getState(),this.renderEventListeners.forEach(function(J){return J(u,g)}),this.close(!0),[2]}})})},U.prototype.render=function(){return Lt(this,void 0,void 0,function(){var u;return Qt(this,function(g){switch(g.label){case 0:return(u=new Rt).naturalSize=this.renderAtNaturalSize,u.imageType=this.renderImageType,u.imageQuality=this.renderImageQuality,u.width=this.renderWidth,u.height=this.renderHeight,this.unzoomFromCrop(),ft.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,u.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 g.sent(),[4,u.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,g.sent()]}})})},U.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Gt("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 Gt("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new Gt("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var u=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Gt("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*u)+`px;
|
|
height: `+(this.toolbarHeight-2*u)+`px;
|
|
padding: `+u+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Gt("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Gt("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new zt("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new zt("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new Gt("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 Gt("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Gt("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 Gt("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*u)+`px;
|
|
padding: `+u+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Gt("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},U.instanceCounter=0,U}(),xt=re("8hTe"),Dr=re.n(xt),un=/<pre[^>]*>/g;function dn(U){var u=document.createElement("div");return u.innerHTML=U,u.childNodes.length===0?"":u.childNodes[0].nodeValue}var xr=ht.a=function(U){var u=U.value,g=u===void 0?"":u,P=U.edit,J=P===void 0?!1:P,j=U.className,ce=U.showTextOnly,Ne=U.showLines,qe=U.replaces,Tt=U.zoomImg,Ue=U.hasMask,Pt=U.style,er=Pt===void 0?{}:Pt,fr=U.stylesPrev,Gr=fr===void 0?{}:fr,Mr=String(g),Ir=Object(D.useRef)(),cn=Object(D.useRef)(),Sn=Object(D.useState)(""),wr=Object(z.a)(Sn,2),nt=wr[0],be=wr[1],Ke=Object(D.useState)("office"),wt=Object(z.a)(Ke,2),mt=wt[0],vt=wt[1],It=function(){var tr=new Ie(cn.current);tr.displayMode="popup",tr.addRenderEventListener(function(){var pr=Object(I.a)(O.a.mark(function Ht(br){var lr;return O.a.wrap(function(Nr){for(;;)switch(Nr.prev=Nr.next){case 0:return Ir.current.style.display="none",Nr.next=3,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:br}});case 3:lr=Nr.sent,lr!=null&&lr.id&&qe(cn.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(lr==null?void 0:lr.id,"?type=").concat(lr.content_type));case 5:case"end":return Nr.stop()}},Ht)}));return function(Ht){return pr.apply(this,arguments)}}()),tr.show()},gr=function(){var tr=new Ct(cn.current);tr.settings.displayMode="popup",tr.addEventListener("render",function(){var pr=Object(I.a)(O.a.mark(function Ht(br){var lr;return O.a.wrap(function(Nr){for(;;)switch(Nr.prev=Nr.next){case 0:if(Ir.current.style.display="none",!cn.current){Nr.next=6;break}return Nr.next=4,Object(De.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:br.dataUrl}});case 4:lr=Nr.sent,lr!=null&&lr.id&&qe(cn.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(lr==null?void 0:lr.id,"?type=").concat(lr.content_type));case 6:case"end":return Nr.stop()}},Ht)}));return function(Ht){return pr.apply(this,arguments)}}()),tr.show(),window.markerArea=tr},cr=Object(D.useMemo)(function(){Ir.current&&(Ir.current.style.zIndex=-1);try{var or=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,tr=/\"\/api\/attachments\/|\"\/attachments\/download\//g,pr=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Mr=Mr.replace(or,"("+oe.a.API_SERVER+"/api/attachments/").replace(tr,'"'+oe.a.API_SERVER+"/api/attachments/").replace(pr,'"'+oe.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(vn){}var Ht=Q(Mr),br=b();if(Mr.match(/\[TOC\]/)&&(Ht=Ht.replace("<p>[TOC]</p>",l()),_()),Ht=Ht.replace(/(__special_katext_id_\d+__)/g,function(vn,Nr){var Yr=br[Nr],Yn=Yr.type,An=Yr.expression;return Object(fe.renderToString)(dn(An)||"",{displayMode:Yn==="block",throwOnError:!1,output:"html"})}),Ht=Ht.replace(/▁/g,"\u2581\u2581\u2581"),v(),ce){var lr=document.createElement("div");return lr.innerHTML=Ht,lr.innerText}return setTimeout(function(){return Sr()},500),Ht},[Mr]),hr=Object(D.useRef)();y.WebkitLineClamp=Ne,Ne&&(er=Object(N.a)(Object(N.a)({},er),y));function Lr(or){var tr=or.target;if(tr.tagName.toUpperCase()==="IMG"){if(Tt){var pr=tr.getAttribute("src");be(pr),vt("image")}}else if(tr.tagName.toUpperCase()==="A"){var Ht=tr.getAttribute("href");if(Ht.indexOf("office")>-1)or.preventDefault(),be(Ht),vt("office");else if(Ht.indexOf("application/pdf")>-1)or.preventDefault(),be(Ht),vt("pdf");else if(Ht.indexOf("text/html")>-1)or.preventDefault(),be(Ht),vt("html");else if(Ht.startsWith("#")){or.preventDefault();var br=document.getElementById(Ht.replace("#",""));br&&br.scrollIntoView(!0)}}}var Sr=function(){var tr,pr=(tr=hr.current)===null||tr===void 0?void 0:tr.querySelectorAll("video");pr==null||pr.forEach(function(Ht){if(Ht.oncontextmenu=function(){return!1},Ht.src.indexOf(".m3u8")>-1&&!Ht.canPlayType("application/vnd.apple.mpegurl")){if(q.a.isSupported()){var br=new q.a;br.loadSource(Ht.src),br.attachMedia(Ht)}}})};Object(D.useEffect)(function(){if(hr.current&&cr&&(cr.match(un)&&window.PR.prettyPrint()),hr.current)return hr.current.addEventListener("click",Lr),function(){hr.current.removeEventListener("click",Lr),v(),_()}},[cr,hr.current,Lr]);var Wr=function(tr){if(!J)return;tr.target.nodeName==="IMG"?(Ir.current.style.zIndex=1,Ir.current.style.display="flex",Ir.current.style.width=tr.target.clientWidth+"px",Ir.current.style.height=tr.target.clientHeight+"px",Ir.current.style.top=tr.target.offsetTop+"px",Ir.current.style.left=tr.target.offsetLeft+"px",cn.current.src=tr.target.getAttribute("src")):Ir.current.style.display="none"};return E.a.createElement("div",{style:{position:"relative"}},E.a.createElement("div",{ref:hr,style:Object(N.a)({},er),className:"".concat(j||""," markdown-body ").concat(Dr.a.mdBody),onMouseOver:Wr,dangerouslySetInnerHTML:{__html:cr}}),E.a.createElement("div",{ref:Ir,className:Dr.a.button},E.a.createElement($.a,null,E.a.createElement(X.a,{onClick:function(){return It()}},"\u88C1\u526A"),E.a.createElement(X.a,{onClick:function(){return gr()}},"\u7F16\u8F91"))),E.a.createElement("img",{ref:cn,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),E.a.createElement(ve.a,{close:!0,data:nt,type:nt!=null&&nt.length?mt:"",style:Object(N.a)({},Gr),onClose:function(){return be("")}}))}},"9VGf":function(At,ht,re){"use strict";re.d(ht,"a",function(){return R});var ae=re("q1tI"),$=re.n(ae);function R(X,N){var I=Object(ae.useRef)();Object(ae.useEffect)(function(){I.current=X}),Object(ae.useEffect)(function(){function z(){I.current()}if(N!==null){var B=setInterval(z,N);return function(){return clearInterval(B)}}},[N])}},Bd2K:function(At,ht,re){(function(ae){ae(re("VrN/"),re("osHv"))})(function(ae){ae.defineOption("autoCloseTags",!1,function(O,D,E){if(E!=ae.Init&&E&&O.removeKeyMap("autoCloseTags"),!D)return;var L={name:"autoCloseTags"};(typeof D!="object"||D.whenClosing!==!1)&&(L["'/'"]=function(k){return I(k)}),(typeof D!="object"||D.whenOpening!==!1)&&(L["'>'"]=function(k){return X(k)}),O.addKeyMap(L)});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 X(O){if(O.getOption("disableInput"))return ae.Pass;for(var D=O.listSelections(),E=[],L=O.getOption("autoCloseTags"),k=0;k<D.length;k++){if(!D[k].empty())return ae.Pass;var T=D[k].head,A=O.getTokenAt(T),C=ae.innerMode(O.getMode(),A.state),h=C.state,o=C.mode.xmlCurrentTag&&C.mode.xmlCurrentTag(h),c=o&&o.name;if(!c)return ae.Pass;var d=C.mode.configuration=="html",_=typeof L=="object"&&L.dontCloseTags||d&&$,y=typeof L=="object"&&L.indentTags||d&&R;A.end>T.ch&&(c=c.slice(0,c.length-A.end+T.ch));var m=c.toLowerCase();if(!c||A.type=="string"&&(A.end!=T.ch||!/[\"\']/.test(A.string.charAt(A.string.length-1))||A.string.length==1)||A.type=="tag"&&o.close||A.string.indexOf("/")==T.ch-A.start-1||_&&z(_,m)>-1||B(O,C.mode.xmlCurrentContext&&C.mode.xmlCurrentContext(h)||[],c,T,!0))return ae.Pass;var l=typeof L=="object"&&L.emptyTags;if(l&&z(l,c)>-1){E[k]={text:"/>",newPos:ae.Pos(T.line,T.ch+2)};continue}var x=y&&z(y,m)>-1;E[k]={indent:x,text:">"+(x?`
|
|
|
|
`:"")+"</"+c+">",newPos:x?ae.Pos(T.line+1,0):ae.Pos(T.line,T.ch+1)}}for(var f=typeof L=="object"&&L.dontIndentOnAutoClose,k=D.length-1;k>=0;k--){var p=E[k];O.replaceRange(p.text,D[k].head,D[k].anchor,"+insert");var s=O.listSelections().slice(0);s[k]={head:p.newPos,anchor:p.newPos},O.setSelections(s),!f&&p.indent&&(O.indentLine(p.newPos.line,null,!0),O.indentLine(p.newPos.line+1,null,!0))}}function N(O,D){for(var E=O.listSelections(),L=[],k=D?"/":"</",T=O.getOption("autoCloseTags"),A=typeof T=="object"&&T.dontIndentOnSlash,C=0;C<E.length;C++){if(!E[C].empty())return ae.Pass;var h=E[C].head,o=O.getTokenAt(h),c=ae.innerMode(O.getMode(),o.state),d=c.state;if(D&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=h.ch-1))return ae.Pass;var _,y=c.mode.name!="xml"&&O.getMode().name=="htmlmixed";if(y&&c.mode.name=="javascript")_=k+"script";else if(y&&c.mode.name=="css")_=k+"style";else{var m=c.mode.xmlCurrentContext&&c.mode.xmlCurrentContext(d);if(!m||m.length&&B(O,m,m[m.length-1],h))return ae.Pass;_=k+m[m.length-1]}O.getLine(h.line).charAt(o.end)!=">"&&(_+=">"),L[C]=_}if(O.replaceSelections(L),E=O.listSelections(),!A)for(var C=0;C<E.length;C++)(C==E.length-1||E[C].head.line<E[C+1].head.line)&&O.indentLine(E[C].head.line)}function I(O){return O.getOption("disableInput")?ae.Pass:N(O,!0)}ae.commands.closeTag=function(O){return N(O)};function z(O,D){if(O.indexOf)return O.indexOf(D);for(var E=0,L=O.length;E<L;++E)if(O[E]==D)return E;return-1}function B(O,D,E,L,k){if(!ae.scanForClosingTag)return!1;var T=Math.min(O.lastLine()+1,L.line+500),A=ae.scanForClosingTag(O,L,null,T);if(!A||A.tag!=E)return!1;for(var C=k?1:0,h=D.length-1;h>=0&&D[h]==E;h--)++C;L=A.to;for(var h=1;h<C;h++){var o=ae.scanForClosingTag(O,L,null,T);if(!o||o.tag!=E)return!1;L=o.to}return!0}})},BjJ7:function(At,ht,re){"use strict";re.d(ht,"d",function(){return $}),re.d(ht,"c",function(){return R}),re.d(ht,"e",function(){return X}),re.d(ht,"b",function(){return N}),re.d(ht,"a",function(){return z});var ae=re("m3rI");function $(B){var O=!0;if(B.length>0){for(var D=0;D<B.length;D++)if(B[D].compile_success==0||!B[D].compile_success){O=!1;break}}else O=!1;return O}function R(B){for(var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",D=[],E=0;E<B.length;E++){var L=B[E],k=O?"".concat(O,"/").concat(L.name):"".concat(L.name);D.push({title:L.name,isLeaf:!(L.type==="tree"),key:k})}return D}function X(B,O,D){for(var E=0;E<B.length;E++){var L=B[E];if(L.key===O){L.children=D;break}L.children&&X(L.children,O,D)}return B}function N(B,O,D){var E;return function(){var L=this,k=arguments,T=function(){E=null,D||B.apply(L,k)},A=D&&!E;clearTimeout(E),E=setTimeout(T,O),A&&B.apply(L,k)}}var I=!0,z=ae.a.API_SERVER},"C+DQ":function(At,ht,re){},DlQD:function(At,ht,re){(function(ae,$){At.exports=$()})(this,function(){"use strict";function ae(ge,de){for(var pe=0;pe<de.length;pe++){var ee=de[pe];ee.enumerable=ee.enumerable||!1,ee.configurable=!0,"value"in ee&&(ee.writable=!0),Object.defineProperty(ge,ee.key,ee)}}function $(ge,de,pe){return de&&ae(ge.prototype,de),pe&&ae(ge,pe),ge}function R(ge,de){if(!ge)return;if(typeof ge=="string")return X(ge,de);var pe=Object.prototype.toString.call(ge).slice(8,-1);if(pe==="Object"&&ge.constructor&&(pe=ge.constructor.name),pe==="Map"||pe==="Set")return Array.from(ge);if(pe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(pe))return X(ge,de)}function X(ge,de){(de==null||de>ge.length)&&(de=ge.length);for(var pe=0,ee=new Array(de);pe<de;pe++)ee[pe]=ge[pe];return ee}function N(ge,de){var pe;if(typeof Symbol=="undefined"||ge[Symbol.iterator]==null){if(Array.isArray(ge)||(pe=R(ge))||de&&ge&&typeof ge.length=="number"){pe&&(ge=pe);var ee=0;return function(){return ee>=ge.length?{done:!0}:{done:!1,value:ge[ee++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return pe=ge[Symbol.iterator](),pe.next.bind(pe)}function I(ge,de){return de={exports:{}},ge(de,de.exports),de.exports}var z=I(function(ge){function de(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function pe(ee){ge.exports.defaults=ee}ge.exports={defaults:de(),getDefaults:de,changeDefaults:pe}}),B=z.defaults,O=z.getDefaults,D=z.changeDefaults,E=/[&<>"']/,L=/[&<>"']/g,k=/[<>"']|&(?!#?\w+;)/,T=/[<>"']|&(?!#?\w+;)/g,A={"&":"&","<":"<",">":">",'"':""","'":"'"},C=function(de){return A[de]};function h(ge,de){if(de){if(E.test(ge))return ge.replace(L,C)}else if(k.test(ge))return ge.replace(T,C);return ge}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function c(ge){return ge.replace(o,function(de,pe){return pe=pe.toLowerCase(),pe==="colon"?":":pe.charAt(0)==="#"?pe.charAt(1)==="x"?String.fromCharCode(parseInt(pe.substring(2),16)):String.fromCharCode(+pe.substring(1)):""})}var d=/(^|[^\[])\^/g;function _(ge,de){ge=ge.source||ge,de=de||"";var pe={replace:function(te,ie){return ie=ie.source||ie,ie=ie.replace(d,"$1"),ge=ge.replace(te,ie),pe},getRegex:function(){return new RegExp(ge,de)}};return pe}var y=/[^\w:]/g,m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function l(ge,de,pe){if(ge){var ee;try{ee=decodeURIComponent(c(pe)).replace(y,"").toLowerCase()}catch(te){return null}if(ee.indexOf("javascript:")===0||ee.indexOf("vbscript:")===0||ee.indexOf("data:")===0)return null}de&&!m.test(pe)&&(pe=a(de,pe));try{pe=encodeURI(pe).replace(/%25/g,"%")}catch(te){return null}return pe}var x={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,s=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(ge,de){x[" "+ge]||(f.test(ge)?x[" "+ge]=ge+"/":x[" "+ge]=M(ge,"/",!0)),ge=x[" "+ge];var pe=ge.indexOf(":")===-1;return de.substring(0,2)==="//"?pe?de:ge.replace(p,"$1")+de:de.charAt(0)==="/"?pe?de:ge.replace(s,"$1")+de:ge+de}var b={exec:function(){}};function v(ge){for(var de=1,pe,ee;de<arguments.length;de++){pe=arguments[de];for(ee in pe)Object.prototype.hasOwnProperty.call(pe,ee)&&(ge[ee]=pe[ee])}return ge}function S(ge,de){var pe=ge.replace(/\|/g,function(ie,se,ue){for(var Se=!1,ke=se;--ke>=0&&ue[ke]==="\\";)Se=!Se;return Se?"|":" |"}),ee=pe.split(/ \|/),te=0;if(ee.length>de)ee.splice(de);else for(;ee.length<de;)ee.push("");for(;te<ee.length;te++)ee[te]=ee[te].trim().replace(/\\\|/g,"|");return ee}function M(ge,de,pe){var ee=ge.length;if(ee===0)return"";for(var te=0;te<ee;){var ie=ge.charAt(ee-te-1);if(ie===de&&!pe)te++;else if(ie!==de&&pe)te++;else break}return ge.substr(0,ee-te)}function H(ge,de){if(ge.indexOf(de[1])===-1)return-1;for(var pe=ge.length,ee=0,te=0;te<pe;te++)if(ge[te]==="\\")te++;else if(ge[te]===de[0])ee++;else if(ge[te]===de[1]&&(ee--,ee<0))return te;return-1}function V(ge){ge&&ge.sanitize&&!ge.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var Q={escape:h,unescape:c,edit:_,cleanUrl:l,resolveUrl:a,noopTest:b,merge:v,splitCells:S,rtrim:M,findClosingBracket:H,checkSanitizeDeprecation:V},G=z.defaults,W=Q.rtrim,q=Q.splitCells,oe=Q.escape,fe=Q.findClosingBracket;function ve(ge,de,pe){var ee=de.href,te=de.title?oe(de.title):null,ie=ge[1].replace(/\\([\[\]])/g,"$1");return ge[0].charAt(0)!=="!"?{type:"link",raw:pe,href:ee,title:te,text:ie}:{type:"image",raw:pe,href:ee,title:te,text:oe(ie)}}function De(ge,de){var pe=ge.match(/^(\s+)(?:```)/);if(pe===null)return de;var ee=pe[1];return de.split(`
|
|
`).map(function(te){var ie=te.match(/^\s+/);if(ie===null)return te;var se=ie[0];return se.length>=ee.length?te.slice(ee.length):te}).join(`
|
|
`)}var Ee=function(){function ge(pe){this.options=pe||G}var de=ge.prototype;return de.space=function(ee){var te=this.rules.block.newline.exec(ee);if(te)return te[0].length>1?{type:"space",raw:te[0]}:{raw:`
|
|
`}},de.code=function(ee,te){var ie=this.rules.block.code.exec(ee);if(ie){var se=te[te.length-1];if(se&&se.type==="paragraph")return{raw:ie[0],text:ie[0].trimRight()};var ue=ie[0].replace(/^ {4}/gm,"");return{type:"code",raw:ie[0],codeBlockStyle:"indented",text:this.options.pedantic?ue:W(ue,`
|
|
`)}}},de.fences=function(ee){var te=this.rules.block.fences.exec(ee);if(te){var ie=te[0],se=De(ie,te[3]||"");return{type:"code",raw:ie,lang:te[2]?te[2].trim():te[2],text:se}}},de.heading=function(ee){var te=this.rules.block.heading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[1].length,text:te[2]}},de.nptable=function(ee){var te=this.rules.block.nptable.exec(ee);if(te){var ie={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[],raw:te[0]};if(ie.header.length===ie.align.length){var se=ie.align.length,ue;for(ue=0;ue<se;ue++)/^ *-+: *$/.test(ie.align[ue])?ie.align[ue]="right":/^ *:-+: *$/.test(ie.align[ue])?ie.align[ue]="center":/^ *:-+ *$/.test(ie.align[ue])?ie.align[ue]="left":ie.align[ue]=null;for(se=ie.cells.length,ue=0;ue<se;ue++)ie.cells[ue]=q(ie.cells[ue],ie.header.length);return ie}}},de.hr=function(ee){var te=this.rules.block.hr.exec(ee);if(te)return{type:"hr",raw:te[0]}},de.blockquote=function(ee){var te=this.rules.block.blockquote.exec(ee);if(te){var ie=te[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:te[0],text:ie}}},de.list=function(ee){var te=this.rules.block.list.exec(ee);if(te){for(var ie=te[0],se=te[2],ue=se.length>1,Se=se[se.length-1]===")",ke={type:"list",raw:ie,ordered:ue,start:ue?+se.slice(0,-1):"",loose:!1,items:[]},Je=te[0].match(this.rules.block.item),Qe=!1,bt,Dt,Ze,ut,Ft,Ct,jt,$t=Je.length,Lt=0;Lt<$t;Lt++)bt=Je[Lt],ie=bt,Dt=bt.length,bt=bt.replace(/^ *([*+-]|\d+[.)]) */,""),~bt.indexOf(`
|
|
`)&&(Dt-=bt.length,bt=this.options.pedantic?bt.replace(/^ {1,4}/gm,""):bt.replace(new RegExp("^ {1,"+Dt+"}","gm"),"")),Lt!==$t-1&&(Ze=this.rules.block.bullet.exec(Je[Lt+1])[0],(ue?Ze.length===1||!Se&&Ze[Ze.length-1]===")":Ze.length>1||this.options.smartLists&&Ze!==se)&&(ut=Je.slice(Lt+1).join(`
|
|
`),ke.raw=ke.raw.substring(0,ke.raw.length-ut.length),Lt=$t-1)),Ft=Qe||/\n\n(?!\s*$)/.test(bt),Lt!==$t-1&&(Qe=bt.charAt(bt.length-1)===`
|
|
`,Ft||(Ft=Qe)),Ft&&(ke.loose=!0),Ct=/^\[[ xX]\] /.test(bt),jt=void 0,Ct&&(jt=bt[1]!==" ",bt=bt.replace(/^\[[ xX]\] +/,"")),ke.items.push({type:"list_item",raw:ie,task:Ct,checked:jt,loose:Ft,text:bt});return ke}},de.html=function(ee){var te=this.rules.block.html.exec(ee);if(te)return{type:this.options.sanitize?"paragraph":"html",raw:te[0],pre:!this.options.sanitizer&&(te[1]==="pre"||te[1]==="script"||te[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(te[0]):oe(te[0]):te[0]}},de.def=function(ee){var te=this.rules.block.def.exec(ee);if(te){te[3]&&(te[3]=te[3].substring(1,te[3].length-1));var ie=te[1].toLowerCase().replace(/\s+/g," ");return{tag:ie,raw:te[0],href:te[2],title:te[3]}}},de.table=function(ee){var te=this.rules.block.table.exec(ee);if(te){var ie={type:"table",header:q(te[1].replace(/^ *| *\| *$/g,"")),align:te[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:te[3]?te[3].replace(/\n$/,"").split(`
|
|
`):[]};if(ie.header.length===ie.align.length){ie.raw=te[0];var se=ie.align.length,ue;for(ue=0;ue<se;ue++)/^ *-+: *$/.test(ie.align[ue])?ie.align[ue]="right":/^ *:-+: *$/.test(ie.align[ue])?ie.align[ue]="center":/^ *:-+ *$/.test(ie.align[ue])?ie.align[ue]="left":ie.align[ue]=null;for(se=ie.cells.length,ue=0;ue<se;ue++)ie.cells[ue]=q(ie.cells[ue].replace(/^ *\| *| *\| *$/g,""),ie.header.length);return ie}}},de.lheading=function(ee){var te=this.rules.block.lheading.exec(ee);if(te)return{type:"heading",raw:te[0],depth:te[2].charAt(0)==="="?1:2,text:te[1]}},de.paragraph=function(ee){var te=this.rules.block.paragraph.exec(ee);if(te)return{type:"paragraph",raw:te[0],text:te[1].charAt(te[1].length-1)===`
|
|
`?te[1].slice(0,-1):te[1]}},de.text=function(ee,te){var ie=this.rules.block.text.exec(ee);if(ie){var se=te[te.length-1];return se&&se.type==="text"?{raw:ie[0],text:ie[0]}:{type:"text",raw:ie[0],text:ie[0]}}},de.escape=function(ee){var te=this.rules.inline.escape.exec(ee);if(te)return{type:"escape",raw:te[0],text:oe(te[1])}},de.tag=function(ee,te,ie){var se=this.rules.inline.tag.exec(ee);if(se)return!te&&/^<a /i.test(se[0])?te=!0:te&&/^<\/a>/i.test(se[0])&&(te=!1),!ie&&/^<(pre|code|kbd|script)(\s|>)/i.test(se[0])?ie=!0:ie&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(se[0])&&(ie=!1),{type:this.options.sanitize?"text":"html",raw:se[0],inLink:te,inRawBlock:ie,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(se[0]):oe(se[0]):se[0]}},de.link=function(ee){var te=this.rules.inline.link.exec(ee);if(te){var ie=fe(te[2],"()");if(ie>-1){var se=te[0].indexOf("!")===0?5:4,ue=se+te[1].length+ie;te[2]=te[2].substring(0,ie),te[0]=te[0].substring(0,ue).trim(),te[3]=""}var Se=te[2],ke="";if(this.options.pedantic){var Je=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Se);Je?(Se=Je[1],ke=Je[3]):ke=""}else ke=te[3]?te[3].slice(1,-1):"";Se=Se.trim().replace(/^<([\s\S]*)>$/,"$1");var Qe=ve(te,{href:Se&&Se.replace(this.rules.inline._escapes,"$1"),title:ke&&ke.replace(this.rules.inline._escapes,"$1")},te[0]);return Qe}},de.reflink=function(ee,te){var ie;if((ie=this.rules.inline.reflink.exec(ee))||(ie=this.rules.inline.nolink.exec(ee))){var se=(ie[2]||ie[1]).replace(/\s+/g," ");if(se=te[se.toLowerCase()],!se||!se.href){var ue=ie[0].charAt(0);return{type:"text",raw:ue,text:ue}}var Se=ve(ie,se,ie[0]);return Se}},de.strong=function(ee,te,ie){ie===void 0&&(ie="");var se=this.rules.inline.strong.start.exec(ee);if(se&&(!se[1]||se[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var ue=se[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ue.lastIndex=0;for(var Se;(se=ue.exec(te))!=null;)if(Se=this.rules.inline.strong.middle.exec(te.slice(0,se.index+3)),Se)return{type:"strong",raw:ee.slice(0,Se[0].length),text:ee.slice(2,Se[0].length-2)}}},de.em=function(ee,te,ie){ie===void 0&&(ie="");var se=this.rules.inline.em.start.exec(ee);if(se&&(!se[1]||se[1]&&(ie===""||this.rules.inline.punctuation.exec(ie)))){te=te.slice(-1*ee.length);var ue=se[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ue.lastIndex=0;for(var Se;(se=ue.exec(te))!=null;)if(Se=this.rules.inline.em.middle.exec(te.slice(0,se.index+2)),Se)return{type:"em",raw:ee.slice(0,Se[0].length),text:ee.slice(1,Se[0].length-1)}}},de.codespan=function(ee){var te=this.rules.inline.code.exec(ee);if(te){var ie=te[2].replace(/\n/g," "),se=/[^ ]/.test(ie),ue=ie.startsWith(" ")&&ie.endsWith(" ");return se&&ue&&(ie=ie.substring(1,ie.length-1)),ie=oe(ie,!0),{type:"codespan",raw:te[0],text:ie}}},de.br=function(ee){var te=this.rules.inline.br.exec(ee);if(te)return{type:"br",raw:te[0]}},de.del=function(ee){var te=this.rules.inline.del.exec(ee);if(te)return{type:"del",raw:te[0],text:te[1]}},de.autolink=function(ee,te){var ie=this.rules.inline.autolink.exec(ee);if(ie){var se,ue;return ie[2]==="@"?(se=oe(this.options.mangle?te(ie[1]):ie[1]),ue="mailto:"+se):(se=oe(ie[1]),ue=se),{type:"link",raw:ie[0],text:se,href:ue,tokens:[{type:"text",raw:se,text:se}]}}},de.url=function(ee,te){var ie;if(ie=this.rules.inline.url.exec(ee)){var se,ue;if(ie[2]==="@")se=oe(this.options.mangle?te(ie[0]):ie[0]),ue="mailto:"+se;else{var Se;do Se=ie[0],ie[0]=this.rules.inline._backpedal.exec(ie[0])[0];while(Se!==ie[0]);se=oe(ie[0]),ie[1]==="www."?ue="http://"+se:ue=se}return{type:"link",raw:ie[0],text:se,href:ue,tokens:[{type:"text",raw:se,text:se}]}}},de.inlineText=function(ee,te,ie){var se=this.rules.inline.text.exec(ee);if(se){var ue;return te?ue=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(se[0]):oe(se[0]):se[0]:ue=oe(this.options.smartypants?ie(se[0]):se[0]),{type:"text",raw:se[0],text:ue}}},ge}(),_e=Q.noopTest,Te=Q.edit,Ce=Q.merge,me={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:_e,table:_e,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Te(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=Te(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=Te(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",me._comment=/<!--(?!-?>)[\s\S]*?-->/,me.html=Te(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Te(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.blockquote=Te(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Ce({},me),me.gfm=Ce({},me.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),me.gfm.nptable=Te(me.gfm.nptable).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.gfm.table=Te(me.gfm.table).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",me._tag).getRegex(),me.pedantic=Ce({},me.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:_e,paragraph:Te(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var ne={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:_e,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:_e,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};ne._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ne.punctuation=Te(ne.punctuation).replace(/punctuation/g,ne._punctuation).getRegex(),ne._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",ne._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",ne.em.start=Te(ne.em.start).replace(/punctuation/g,ne._punctuation).getRegex(),ne.em.middle=Te(ne.em.middle).replace(/punctuation/g,ne._punctuation).replace(/overlapSkip/g,ne._overlapSkip).getRegex(),ne.em.endAst=Te(ne.em.endAst,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.em.endUnd=Te(ne.em.endUnd,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.start=Te(ne.strong.start).replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.middle=Te(ne.strong.middle).replace(/punctuation/g,ne._punctuation).replace(/blockSkip/g,ne._blockSkip).getRegex(),ne.strong.endAst=Te(ne.strong.endAst,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.strong.endUnd=Te(ne.strong.endUnd,"g").replace(/punctuation/g,ne._punctuation).getRegex(),ne.blockSkip=Te(ne._blockSkip,"g").getRegex(),ne.overlapSkip=Te(ne._overlapSkip,"g").getRegex(),ne._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ne._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ne._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])?)+(?![-_])/,ne.autolink=Te(ne.autolink).replace("scheme",ne._scheme).replace("email",ne._email).getRegex(),ne._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ne.tag=Te(ne.tag).replace("comment",me._comment).replace("attribute",ne._attribute).getRegex(),ne._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ne._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,ne._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ne.link=Te(ne.link).replace("label",ne._label).replace("href",ne._href).replace("title",ne._title).getRegex(),ne.reflink=Te(ne.reflink).replace("label",ne._label).getRegex(),ne.reflinkSearch=Te(ne.reflinkSearch,"g").replace("reflink",ne.reflink).replace("nolink",ne.nolink).getRegex(),ne.normal=Ce({},ne),ne.pedantic=Ce({},ne.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",ne._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ne._label).getRegex()}),ne.gfm=Ce({},ne.normal,{escape:Te(ne.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),ne.gfm.url=Te(ne.gfm.url,"i").replace("email",ne.gfm._extended_email).getRegex(),ne.breaks=Ce({},ne.gfm,{br:Te(ne.br).replace("{2,}","*").getRegex(),text:Te(ne.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Ae={block:me,inline:ne},rt=z.defaults,$e=Ae.block,Xe=Ae.inline;function Ve(ge){return ge.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function Le(ge){var de="",pe,ee,te=ge.length;for(pe=0;pe<te;pe++)ee=ge.charCodeAt(pe),Math.random()>.5&&(ee="x"+ee.toString(16)),de+="&#"+ee+";";return de}var Me=function(){function ge(pe){this.tokens=[],this.tokens.links=Object.create(null),this.options=pe||rt,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:$e.normal,inline:Xe.normal};this.options.pedantic?(ee.block=$e.pedantic,ee.inline=Xe.pedantic):this.options.gfm&&(ee.block=$e.gfm,this.options.breaks?ee.inline=Xe.breaks:ee.inline=Xe.gfm),this.tokenizer.rules=ee}ge.lex=function(ee,te){var ie=new ge(te);return ie.lex(ee)};var de=ge.prototype;return de.lex=function(ee){return ee=ee.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(ee,this.tokens,!0),this.inline(this.tokens),this.tokens},de.blockTokens=function(ee,te,ie){te===void 0&&(te=[]),ie===void 0&&(ie=!0),ee=ee.replace(/^ +$/gm,"");for(var se,ue,Se,ke;ee;){if(se=this.tokenizer.space(ee)){ee=ee.substring(se.raw.length),se.type&&te.push(se);continue}if(se=this.tokenizer.code(ee,te)){ee=ee.substring(se.raw.length),se.type?te.push(se):(ke=te[te.length-1],ke.raw+=`
|
|
`+se.raw,ke.text+=`
|
|
`+se.text);continue}if(se=this.tokenizer.fences(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.heading(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.nptable(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.hr(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.blockquote(ee)){ee=ee.substring(se.raw.length),se.tokens=this.blockTokens(se.text,[],ie),te.push(se);continue}if(se=this.tokenizer.list(ee)){for(ee=ee.substring(se.raw.length),Se=se.items.length,ue=0;ue<Se;ue++)se.items[ue].tokens=this.blockTokens(se.items[ue].text,[],!1);te.push(se);continue}if(se=this.tokenizer.html(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(ie&&(se=this.tokenizer.def(ee))){ee=ee.substring(se.raw.length),this.tokens.links[se.tag]||(this.tokens.links[se.tag]={href:se.href,title:se.title});continue}if(se=this.tokenizer.table(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.lheading(ee)){ee=ee.substring(se.raw.length),te.push(se);continue}if(ie&&(se=this.tokenizer.paragraph(ee))){ee=ee.substring(se.raw.length),te.push(se);continue}if(se=this.tokenizer.text(ee,te)){ee=ee.substring(se.raw.length),se.type?te.push(se):(ke=te[te.length-1],ke.raw+=`
|
|
`+se.raw,ke.text+=`
|
|
`+se.text);continue}if(ee){var Je="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(Je);break}else throw new Error(Je)}}return te},de.inline=function(ee){var te,ie,se,ue,Se,ke,Je=ee.length;for(te=0;te<Je;te++){ke=ee[te];switch(ke.type){case"paragraph":case"text":case"heading":{ke.tokens=[],this.inlineTokens(ke.text,ke.tokens);break}case"table":{for(ke.tokens={header:[],cells:[]},ue=ke.header.length,ie=0;ie<ue;ie++)ke.tokens.header[ie]=[],this.inlineTokens(ke.header[ie],ke.tokens.header[ie]);for(ue=ke.cells.length,ie=0;ie<ue;ie++)for(Se=ke.cells[ie],ke.tokens.cells[ie]=[],se=0;se<Se.length;se++)ke.tokens.cells[ie][se]=[],this.inlineTokens(Se[se],ke.tokens.cells[ie][se]);break}case"blockquote":{this.inline(ke.tokens);break}case"list":{for(ue=ke.items.length,ie=0;ie<ue;ie++)this.inline(ke.items[ie].tokens);break}}}return ee},de.inlineTokens=function(ee,te,ie,se,ue){te===void 0&&(te=[]),ie===void 0&&(ie=!1),se===void 0&&(se=!1),ue===void 0&&(ue="");var Se,ke=ee,Je;if(this.tokens.links){var Qe=Object.keys(this.tokens.links);if(Qe.length>0)for(;(Je=this.tokenizer.rules.inline.reflinkSearch.exec(ke))!=null;)Qe.includes(Je[0].slice(Je[0].lastIndexOf("[")+1,-1))&&(ke=ke.slice(0,Je.index)+"["+"a".repeat(Je[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Je=this.tokenizer.rules.inline.blockSkip.exec(ke))!=null;)ke=ke.slice(0,Je.index)+"["+"a".repeat(Je[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;ee;){if(Se=this.tokenizer.escape(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.tag(ee,ie,se)){ee=ee.substring(Se.raw.length),ie=Se.inLink,se=Se.inRawBlock,te.push(Se);continue}if(Se=this.tokenizer.link(ee)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,se)),te.push(Se);continue}if(Se=this.tokenizer.reflink(ee,this.tokens.links)){ee=ee.substring(Se.raw.length),Se.type==="link"&&(Se.tokens=this.inlineTokens(Se.text,[],!0,se)),te.push(Se);continue}if(Se=this.tokenizer.strong(ee,ke,ue)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ie,se),te.push(Se);continue}if(Se=this.tokenizer.em(ee,ke,ue)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ie,se),te.push(Se);continue}if(Se=this.tokenizer.codespan(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.br(ee)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.del(ee)){ee=ee.substring(Se.raw.length),Se.tokens=this.inlineTokens(Se.text,[],ie,se),te.push(Se);continue}if(Se=this.tokenizer.autolink(ee,Le)){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(!ie&&(Se=this.tokenizer.url(ee,Le))){ee=ee.substring(Se.raw.length),te.push(Se);continue}if(Se=this.tokenizer.inlineText(ee,se,Ve)){ee=ee.substring(Se.raw.length),ue=Se.raw.slice(-1),te.push(Se);continue}if(ee){var bt="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(bt);break}else throw new Error(bt)}}return te},$(ge,null,[{key:"rules",get:function(){return{block:$e,inline:Xe}}}]),ge}(),ze=z.defaults,Ge=Q.cleanUrl,He=Q.escape,Be=function(){function ge(pe){this.options=pe||ze}var de=ge.prototype;return de.code=function(ee,te,ie){var se=(te||"").match(/\S*/)[0];if(this.options.highlight){var ue=this.options.highlight(ee,se);ue!=null&&ue!==ee&&(ie=!0,ee=ue)}return se?'<pre><code class="'+this.options.langPrefix+He(se,!0)+'">'+(ie?ee:He(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ie?ee:He(ee,!0))+`</code></pre>
|
|
`},de.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},de.html=function(ee){return ee},de.heading=function(ee,te,ie,se){return this.options.headerIds?"<h"+te+' id="'+this.options.headerPrefix+se.slug(ie)+'">'+ee+"</h"+te+`>
|
|
`:"<h"+te+">"+ee+"</h"+te+`>
|
|
`},de.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},de.list=function(ee,te,ie){var se=te?"ol":"ul",ue=te&&ie!==1?' start="'+ie+'"':"";return"<"+se+ue+`>
|
|
`+ee+"</"+se+`>
|
|
`},de.listitem=function(ee){return"<li>"+ee+`</li>
|
|
`},de.checkbox=function(ee){return"<input "+(ee?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},de.paragraph=function(ee){return"<p>"+ee+`</p>
|
|
`},de.table=function(ee,te){return te&&(te="<tbody>"+te+"</tbody>"),`<table>
|
|
<thead>
|
|
`+ee+`</thead>
|
|
`+te+`</table>
|
|
`},de.tablerow=function(ee){return`<tr>
|
|
`+ee+`</tr>
|
|
`},de.tablecell=function(ee,te){var ie=te.header?"th":"td",se=te.align?"<"+ie+' align="'+te.align+'">':"<"+ie+">";return se+ee+"</"+ie+`>
|
|
`},de.strong=function(ee){return"<strong>"+ee+"</strong>"},de.em=function(ee){return"<em>"+ee+"</em>"},de.codespan=function(ee){return"<code>"+ee+"</code>"},de.br=function(){return this.options.xhtml?"<br/>":"<br>"},de.del=function(ee){return"<del>"+ee+"</del>"},de.link=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var se='<a href="'+He(ee)+'"';return te&&(se+=' title="'+te+'"'),se+=">"+ie+"</a>",se},de.image=function(ee,te,ie){if(ee=Ge(this.options.sanitize,this.options.baseUrl,ee),ee===null)return ie;var se='<img src="'+ee+'" alt="'+ie+'"';return te&&(se+=' title="'+te+'"'),se+=this.options.xhtml?"/>":">",se},de.text=function(ee){return ee},ge}(),Pe=function(){function ge(){}var de=ge.prototype;return de.strong=function(ee){return ee},de.em=function(ee){return ee},de.codespan=function(ee){return ee},de.del=function(ee){return ee},de.html=function(ee){return ee},de.text=function(ee){return ee},de.link=function(ee,te,ie){return""+ie},de.image=function(ee,te,ie){return""+ie},de.br=function(){return""},ge}(),pt=function(){function ge(){this.seen={}}var de=ge.prototype;return de.slug=function(ee){var te=ee.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(te)){var ie=te;do this.seen[ie]++,te=ie+"-"+this.seen[ie];while(this.seen.hasOwnProperty(te))}return this.seen[te]=0,te},ge}(),it=z.defaults,et=Q.unescape,at=function(){function ge(pe){this.options=pe||it,this.options.renderer=this.options.renderer||new Be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pe,this.slugger=new pt}ge.parse=function(ee,te){var ie=new ge(te);return ie.parse(ee)};var de=ge.prototype;return de.parse=function(ee,te){te===void 0&&(te=!0);var ie="",se,ue,Se,ke,Je,Qe,bt,Dt,Ze,ut,Ft,Ct,jt,$t,Lt,Qt,Zt,ft,Xt=ee.length;for(se=0;se<Xt;se++){ut=ee[se];switch(ut.type){case"space":continue;case"hr":{ie+=this.renderer.hr();continue}case"heading":{ie+=this.renderer.heading(this.parseInline(ut.tokens),ut.depth,et(this.parseInline(ut.tokens,this.textRenderer)),this.slugger);continue}case"code":{ie+=this.renderer.code(ut.text,ut.lang,ut.escaped);continue}case"table":{for(Dt="",bt="",ke=ut.header.length,ue=0;ue<ke;ue++)bt+=this.renderer.tablecell(this.parseInline(ut.tokens.header[ue]),{header:!0,align:ut.align[ue]});for(Dt+=this.renderer.tablerow(bt),Ze="",ke=ut.cells.length,ue=0;ue<ke;ue++){for(Qe=ut.tokens.cells[ue],bt="",Je=Qe.length,Se=0;Se<Je;Se++)bt+=this.renderer.tablecell(this.parseInline(Qe[Se]),{header:!1,align:ut.align[Se]});Ze+=this.renderer.tablerow(bt)}ie+=this.renderer.table(Dt,Ze);continue}case"blockquote":{Ze=this.parse(ut.tokens),ie+=this.renderer.blockquote(Ze);continue}case"list":{for(Ft=ut.ordered,Ct=ut.start,jt=ut.loose,ke=ut.items.length,Ze="",ue=0;ue<ke;ue++)Lt=ut.items[ue],Qt=Lt.checked,Zt=Lt.task,$t="",Lt.task&&(ft=this.renderer.checkbox(Qt),jt?Lt.tokens.length>0&&Lt.tokens[0].type==="text"?(Lt.tokens[0].text=ft+" "+Lt.tokens[0].text,Lt.tokens[0].tokens&&Lt.tokens[0].tokens.length>0&&Lt.tokens[0].tokens[0].type==="text"&&(Lt.tokens[0].tokens[0].text=ft+" "+Lt.tokens[0].tokens[0].text)):Lt.tokens.unshift({type:"text",text:ft}):$t+=ft),$t+=this.parse(Lt.tokens,jt),Ze+=this.renderer.listitem($t,Zt,Qt);ie+=this.renderer.list(Ze,Ft,Ct);continue}case"html":{ie+=this.renderer.html(ut.text);continue}case"paragraph":{ie+=this.renderer.paragraph(this.parseInline(ut.tokens));continue}case"text":{for(Ze=ut.tokens?this.parseInline(ut.tokens):ut.text;se+1<Xt&&ee[se+1].type==="text";)ut=ee[++se],Ze+=`
|
|
`+(ut.tokens?this.parseInline(ut.tokens):ut.text);ie+=te?this.renderer.paragraph(Ze):Ze;continue}default:{var zt='Token with "'+ut.type+'" type was not found.';if(this.options.silent){console.error(zt);return}else throw new Error(zt)}}}return ie},de.parseInline=function(ee,te){te=te||this.renderer;var ie="",se,ue,Se=ee.length;for(se=0;se<Se;se++){ue=ee[se];switch(ue.type){case"escape":{ie+=te.text(ue.text);break}case"html":{ie+=te.html(ue.text);break}case"link":{ie+=te.link(ue.href,ue.title,this.parseInline(ue.tokens,te));break}case"image":{ie+=te.image(ue.href,ue.title,ue.text);break}case"strong":{ie+=te.strong(this.parseInline(ue.tokens,te));break}case"em":{ie+=te.em(this.parseInline(ue.tokens,te));break}case"codespan":{ie+=te.codespan(ue.text);break}case"br":{ie+=te.br();break}case"del":{ie+=te.del(this.parseInline(ue.tokens,te));break}case"text":{ie+=te.text(ue.text);break}default:{var ke='Token with "'+ue.type+'" type was not found.';if(this.options.silent){console.error(ke);return}else throw new Error(ke)}}}return ie},ge}(),Et=Q.merge,ct=Q.checkSanitizeDeprecation,dt=Q.escape,we=z.getDefaults,gt=z.changeDefaults,lt=z.defaults;function Re(ge,de,pe){if(typeof ge=="undefined"||ge===null)throw new Error("marked(): input parameter is undefined or null");if(typeof ge!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(ge)+", string expected");if(typeof de=="function"&&(pe=de,de=null),de=Et({},Re.defaults,de||{}),ct(de),pe){var ee=de.highlight,te;try{te=Me.lex(ge,de)}catch(Se){return pe(Se)}var ie=function(ke){var Je;if(!ke)try{Je=at.parse(te,de)}catch(Qe){ke=Qe}return de.highlight=ee,ke?pe(ke):pe(null,Je)};if(!ee||ee.length<3)return ie();if(delete de.highlight,!te.length)return ie();var se=0;Re.walkTokens(te,function(Se){Se.type==="code"&&(se++,setTimeout(function(){ee(Se.text,Se.lang,function(ke,Je){if(ke)return ie(ke);Je!=null&&Je!==Se.text&&(Se.text=Je,Se.escaped=!0),se--,se===0&&ie()})},0))}),se===0&&ie();return}try{var ue=Me.lex(ge,de);return de.walkTokens&&Re.walkTokens(ue,de.walkTokens),at.parse(ue,de)}catch(Se){if(Se.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+dt(Se.message+"",!0)+"</pre>";throw Se}}Re.options=Re.setOptions=function(ge){return Et(Re.defaults,ge),gt(Re.defaults),Re},Re.getDefaults=we,Re.defaults=lt,Re.use=function(ge){var de=Et({},ge);if(ge.renderer&&function(){var ee=Re.defaults.renderer||new Be,te=function(ue){var Se=ee[ue];ee[ue]=function(){for(var ke=arguments.length,Je=new Array(ke),Qe=0;Qe<ke;Qe++)Je[Qe]=arguments[Qe];var bt=ge.renderer[ue].apply(ee,Je);return bt===!1&&(bt=Se.apply(ee,Je)),bt}};for(var ie in ge.renderer)te(ie);de.renderer=ee}(),ge.tokenizer&&function(){var ee=Re.defaults.tokenizer||new Ee,te=function(ue){var Se=ee[ue];ee[ue]=function(){for(var ke=arguments.length,Je=new Array(ke),Qe=0;Qe<ke;Qe++)Je[Qe]=arguments[Qe];var bt=ge.tokenizer[ue].apply(ee,Je);return bt===!1&&(bt=Se.apply(ee,Je)),bt}};for(var ie in ge.tokenizer)te(ie);de.tokenizer=ee}(),ge.walkTokens){var pe=Re.defaults.walkTokens;de.walkTokens=function(ee){ge.walkTokens(ee),pe&&pe(ee)}}Re.setOptions(de)},Re.walkTokens=function(ge,de){for(var pe=N(ge),ee;!(ee=pe()).done;){var te=ee.value;de(te);switch(te.type){case"table":{for(var ie=N(te.tokens.header),se;!(se=ie()).done;){var ue=se.value;Re.walkTokens(ue,de)}for(var Se=N(te.tokens.cells),ke;!(ke=Se()).done;)for(var Je=ke.value,Qe=N(Je),bt;!(bt=Qe()).done;){var Dt=bt.value;Re.walkTokens(Dt,de)}break}case"list":{Re.walkTokens(te.items,de);break}default:te.tokens&&Re.walkTokens(te.tokens,de)}}},Re.Parser=at,Re.parser=at.parse,Re.Renderer=Be,Re.TextRenderer=Pe,Re.Lexer=Me,Re.lexer=Me.lex,Re.Tokenizer=Ee,Re.Slugger=pt,Re.parse=Re;var je=Re;return je})},ELLl:function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},R=ae.Pos;ae.defineOption("autoCloseBrackets",!1,function(A,C,h){h&&h!=ae.Init&&(A.removeKeyMap(N),A.state.closeBrackets=null),C&&(I(X(C,"pairs")),A.state.closeBrackets=C,A.addKeyMap(N))});function X(A,C){return C=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[C]!=null?A[C]:$[C]}var N={Backspace:O,Enter:D};function I(A){for(var C=0;C<A.length;C++){var h=A.charAt(C),o="'"+h+"'";N[o]||(N[o]=z(h))}}I($.pairs+"`");function z(A){return function(C){return L(C,A)}}function B(A){var C=A.state.closeBrackets;if(!C||C.override)return C;var h=A.getModeAt(A.getCursor());return h.closeBrackets||C}function O(A){var C=B(A);if(!C||A.getOption("disableInput"))return ae.Pass;for(var h=X(C,"pairs"),o=A.listSelections(),c=0;c<o.length;c++){if(!o[c].empty())return ae.Pass;var d=k(A,o[c].head);if(!d||h.indexOf(d)%2!=0)return ae.Pass}for(var c=o.length-1;c>=0;c--){var _=o[c].head;A.replaceRange("",R(_.line,_.ch-1),R(_.line,_.ch+1),"+delete")}}function D(A){var C=B(A),h=C&&X(C,"explode");if(!h||A.getOption("disableInput"))return ae.Pass;for(var o=A.listSelections(),c=0;c<o.length;c++){if(!o[c].empty())return ae.Pass;var d=k(A,o[c].head);if(!d||h.indexOf(d)%2!=0)return ae.Pass}A.operation(function(){var _=A.lineSeparator()||`
|
|
`;A.replaceSelection(_+_,null),A.execCommand("goCharLeft"),o=A.listSelections();for(var y=0;y<o.length;y++){var m=o[y].head.line;A.indentLine(m,null,!0),A.indentLine(m+1,null,!0)}})}function E(A){var C=ae.cmpPos(A.anchor,A.head)>0;return{anchor:new R(A.anchor.line,A.anchor.ch+(C?-1:1)),head:new R(A.head.line,A.head.ch+(C?1:-1))}}function L(A,C){var h=B(A);if(!h||A.getOption("disableInput"))return ae.Pass;var o=X(h,"pairs"),c=o.indexOf(C);if(c==-1)return ae.Pass;for(var d=X(h,"closeBefore"),_=X(h,"triples"),y=o.charAt(c+1)==C,m=A.listSelections(),l=c%2==0,x,f=0;f<m.length;f++){var p=m[f],s=p.head,a,b=A.getRange(s,R(s.line,s.ch+1));if(l&&!p.empty())a="surround";else if((y||!l)&&b==C)y&&T(A,s)?a="both":_.indexOf(C)>=0&&A.getRange(s,R(s.line,s.ch+3))==C+C+C?a="skipThree":a="skip";else if(y&&s.ch>1&&_.indexOf(C)>=0&&A.getRange(R(s.line,s.ch-2),s)==C+C){if(s.ch>2&&/\bstring/.test(A.getTokenTypeAt(R(s.line,s.ch-2))))return ae.Pass;a="addFour"}else if(y){var v=s.ch==0?" ":A.getRange(R(s.line,s.ch-1),s);if(!ae.isWordChar(b)&&v!=C&&!ae.isWordChar(v))a="both";else return ae.Pass}else if(l&&(b.length===0||/\s/.test(b)||d.indexOf(b)>-1))a="both";else return ae.Pass;if(!x)x=a;else if(x!=a)return ae.Pass}var S=c%2?o.charAt(c-1):C,M=c%2?C:o.charAt(c+1);A.operation(function(){if(x=="skip")A.execCommand("goCharRight");else if(x=="skipThree")for(var H=0;H<3;H++)A.execCommand("goCharRight");else if(x=="surround"){for(var V=A.getSelections(),H=0;H<V.length;H++)V[H]=S+V[H]+M;A.replaceSelections(V,"around"),V=A.listSelections().slice();for(var H=0;H<V.length;H++)V[H]=E(V[H]);A.setSelections(V)}else x=="both"?(A.replaceSelection(S+M,null),A.triggerElectric(S+M),A.execCommand("goCharLeft")):x=="addFour"&&(A.replaceSelection(S+S+S+S,"before"),A.execCommand("goCharRight"))})}function k(A,C){var h=A.getRange(R(C.line,C.ch-1),R(C.line,C.ch+1));return h.length==2?h:null}function T(A,C){var h=A.getTokenAt(R(C.line,C.ch+1));return/\bstring/.test(h.type)&&h.start==C.ch&&(C.ch==0||!/\bstring/.test(A.getTokenTypeAt(C)))}})},FIWC:function(At,ht,re){At.exports={flex_box_center:"flex_box_center___gdHkq",flex_space_between:"flex_space_between___lk_Gv",flex_box_vertical_center:"flex_box_vertical_center___2WNVo",flex_box_center_end:"flex_box_center_end___13O11",flex_box_column:"flex_box_column___kMb8L",wrap:"wrap___1y6rg",crumbs:"crumbs___1vKDo"}},Gytx:function(At,ht){At.exports=function(ae,$,R,X){var N=R?R.call(X,ae,$):void 0;if(N!==void 0)return!!N;if(ae===$)return!0;if(typeof ae!="object"||!ae||typeof $!="object"||!$)return!1;var I=Object.keys(ae),z=Object.keys($);if(I.length!==z.length)return!1;for(var B=Object.prototype.hasOwnProperty.bind($),O=0;O<I.length;O++){var D=I[O];if(!B(D))return!1;var E=ae[D],L=$[D];if(N=R?R.call(X,E,L,D):void 0,N===!1||N===void 0&&E!==L)return!1}return!0}},HmJG:function(At,ht,re){},LdHM:function(At,ht,re){"use strict";re.d(ht,"b",function(){return d}),re.d(ht,"a",function(){return y});var ae=re("1OyB"),$=re("vuIU"),R=re("Ji7U"),X=re("LK+K"),N=re("q1tI"),I=re("rePB"),z=re("Ff2n"),B=re("ODXe"),O=re("4IlW"),D=re("bX4T"),E=re("YrtM"),L=re("TSYQ"),k=re.n(L),T=re("+nKL"),A=re("8OUc"),C=function(q,oe){var fe=q.prefixCls,ve=q.id,De=q.flattenOptions,Ee=q.childrenAsData,_e=q.values,Te=q.searchValue,Ce=q.multiple,me=q.defaultActiveFirstOption,ne=q.height,Ae=q.itemHeight,rt=q.notFoundContent,$e=q.open,Xe=q.menuItemSelectedIcon,Ve=q.virtual,Le=q.onSelect,Me=q.onToggleOpen,ze=q.onActiveValue,Ge=q.onScroll,He=q.onMouseEnter,Be="".concat(fe,"-item"),Pe=Object(E.a)(function(){return De},[$e,De],function(je,ge){return ge[0]&&je[1]!==ge[1]}),pt=N.useRef(null),it=function(ge){ge.preventDefault()},et=function(ge){pt.current&&pt.current.scrollTo({index:ge})},at=function(ge){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,pe=Pe.length,ee=0;ee<pe;ee+=1){var te=(ge+ee*de+pe)%pe,ie=Pe[te],se=ie.group,ue=ie.data;if(!se&&!ue.disabled)return te}return-1},Et=N.useState(function(){return at(0)}),ct=Object(B.a)(Et,2),dt=ct[0],we=ct[1],gt=function(ge){we(ge);var de=Pe[ge];if(!de){ze(null,-1);return}ze(de.data.value,ge)};N.useEffect(function(){gt(me!==!1?at(0):-1)},[Pe.length,Te]),N.useEffect(function(){var je=setTimeout(function(){if(!Ce&&$e&&_e.size===1){var ge=Array.from(_e)[0],de=Pe.findIndex(function(pe){var ee=pe.data;return ee.value===ge});gt(de),et(de)}});return function(){return clearTimeout(je)}},[$e]);var lt=function(ge){ge!==void 0&&Le(ge,{selected:!_e.has(ge)}),Ce||Me(!1)};if(N.useImperativeHandle(oe,function(){return{onKeyDown:function(ge){var de=ge.which;switch(de){case O.a.UP:case O.a.DOWN:{var pe=0;if(de===O.a.UP?pe=-1:de===O.a.DOWN&&(pe=1),pe!==0){var ee=at(dt+pe,pe);et(ee),gt(ee)}break}case O.a.ENTER:{var te=Pe[dt];te&&!te.data.disabled?lt(te.data.value):lt(void 0),$e&&ge.preventDefault();break}case O.a.ESC:Me(!1)}},onKeyUp:function(){},scrollTo:function(ge){et(ge)}}}),Pe.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Be,"-empty"),onMouseDown:it},rt);function Re(je){var ge=Pe[je];if(!ge)return null;var de=ge.data||{},pe=de.value,ee=de.label,te=de.children,ie=Object(D.a)(de,!0),se=Ee?te:ee;return ge?N.createElement("div",Object.assign({"aria-label":typeof se=="string"?se:null},ie,{key:je,role:"option",id:"".concat(ve,"_list_").concat(je),"aria-selected":_e.has(pe)}),pe):null}return N.createElement(N.Fragment,null,N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),style:{height:0,width:0,overflow:"hidden"}},Re(dt-1),Re(dt),Re(dt+1)),N.createElement(T.a,{itemKey:"key",ref:pt,data:Pe,height:ne,itemHeight:Ae,fullHeight:!1,onMouseDown:it,onScroll:Ge,virtual:Ve,onMouseEnter:He},function(je,ge){var de,pe=je.group,ee=je.groupOption,te=je.data,ie=te.label,se=te.key;if(pe)return N.createElement("div",{className:k()(Be,"".concat(Be,"-group"))},ie!==void 0?ie:se);var ue=te.disabled,Se=te.value,ke=te.title,Je=te.children,Qe=te.style,bt=te.className,Dt=Object(z.a)(te,["disabled","value","title","children","style","className"]),Ze=_e.has(Se),ut="".concat(Be,"-option"),Ft=k()(Be,ut,bt,(de={},Object(I.a)(de,"".concat(ut,"-grouped"),ee),Object(I.a)(de,"".concat(ut,"-active"),dt===ge&&!ue),Object(I.a)(de,"".concat(ut,"-disabled"),ue),Object(I.a)(de,"".concat(ut,"-selected"),Ze),de)),Ct=Ee?Je:ie,jt=!Xe||typeof Xe=="function"||Ze;return N.createElement("div",Object.assign({},Dt,{"aria-selected":Ze,className:Ft,title:ke,onMouseMove:function(){if(dt===ge||ue)return;gt(ge)},onClick:function(){ue||lt(Se)},style:Qe}),N.createElement("div",{className:"".concat(ut,"-content")},Ct||Se),N.isValidElement(Xe)||Ze,jt&&N.createElement(A.a,{className:"".concat(Be,"-option-state"),customizeIcon:Xe,customizeIconProps:{isSelected:Ze}},Ze?"\u2713":null))}))},h=N.forwardRef(C);h.displayName="OptionList";var o=h,c=function(){return null};c.isSelectOption=!0;var d=c,_=function(){return null};_.isSelectOptGroup=!0;var y=_,m=re("VTBJ"),l=re("Zm9Q");function x(W){var q=W.key,oe=W.props,fe=oe.children,ve=oe.value,De=Object(z.a)(oe,["children","value"]);return Object(m.a)({key:q,value:ve!==void 0?ve:q,children:fe},De)}function f(W){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(l.a)(W).map(function(oe,fe){if(!N.isValidElement(oe)||!oe.type)return null;var ve=oe.type.isSelectOptGroup,De=oe.key,Ee=oe.props,_e=Ee.children,Te=Object(z.a)(Ee,["children"]);return q||!ve?x(oe):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(De===null?fe:De,"__"),label:De},Te),{},{options:f(_e)})}).filter(function(oe){return oe})}var p=re("2Qr1"),s=re("qNPg"),a=re("U8pU"),b=re("Kwbf"),v=re("WKfj");function S(W){var q=W.mode,oe=W.options,fe=W.children,ve=W.backfill,De=W.allowClear,Ee=W.placeholder,_e=W.getInputElement,Te=W.showSearch,Ce=W.onSearch,me=W.defaultOpen,ne=W.autoFocus,Ae=W.labelInValue,rt=W.value,$e=W.inputValue,Xe=W.optionLabelProp,Ve=q==="multiple"||q==="tags",Le=Te!==void 0?Te:Ve||q==="combobox",Me=oe||f(fe);if(Object(b.a)(q!=="tags"||Me.every(function(Be){return!Be.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var ze=Me.some(function(Be){return Be.options?Be.options.some(function(Pe){return typeof("value"in Pe?Pe.value:Pe.key)=="number"}):typeof("value"in Be?Be.value:Be.key)=="number"});Object(b.a)(!ze,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(q!=="combobox"||!Xe,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(q==="combobox"||!ve,"`backfill` only works with `combobox` mode."),Object(b.a)(q==="combobox"||!_e,"`getInputElement` only work with `combobox` mode."),Object(b.b)(q!=="combobox"||!_e||!De||!Ee,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ce&&!Le&&q!=="combobox"&&q!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!me||ne,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),rt!=null){var Ge=Object(v.d)(rt);Object(b.a)(!Ae||Ge.every(function(Be){return Object(a.a)(Be)==="object"&&("key"in Be||"value"in Be)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Ve||Array.isArray(rt),"`value` should be array when `mode` is `multiple` or `tags`")}if(fe){var He=null;Object(l.a)(fe).some(function(Be){if(!N.isValidElement(Be)||!Be.type)return!1;var Pe=Be.type;if(Pe.isSelectOption)return!1;if(Pe.isSelectOptGroup){var pt=Object(l.a)(Be.props.children).every(function(it){return!N.isValidElement(it)||!Be.type||it.type.isSelectOption?!0:(He=it.type,!1)});return!pt}return He=Pe,!0}),He&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(He.displayName||He.name||He,"`.")),Object(b.a)($e===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=S,H=Object(s.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:f,flattenOptions:p.d,getLabeledValue:p.e,filterOptions:p.b,isValueDisabled:p.g,findValueOption:p.c,warningProps:M,fillOptionsWithMissingValue:p.a}),V=function(W){Object(R.a)(oe,W);var q=Object(X.a)(oe);function oe(){var fe;return Object(ae.a)(this,oe),fe=q.apply(this,arguments),fe.selectRef=N.createRef(),fe.focus=function(){fe.selectRef.current.focus()},fe.blur=function(){fe.selectRef.current.blur()},fe}return Object($.a)(oe,[{key:"render",value:function(){return N.createElement(H,Object.assign({ref:this.selectRef},this.props))}}]),oe}(N.Component);V.Option=d,V.OptGroup=y;var Q=V,G=ht.c=Q},M8RZ:function(At,ht,re){"use strict";re.d(ht,"a",function(){return O});var ae=re("fWQN"),$=re("mtLc"),R=re("yKVA"),X=re("879j"),N=re("q1tI"),I=re.n(N),z=re("i8i4"),B=re.n(z),O=function(D){Object(R.a)(L,D);var E=Object(X.a)(L);function L(k){var T;Object(ae.a)(this,L),T=E.call(this,k);var A=window.document;return T.node=A.createElement("div"),A.body.appendChild(T.node),T}return Object($.a)(L,[{key:"render",value:function(){var T=this.props.children;return Object(z.createPortal)(T,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),L}(I.a.Component)},O2Wb:function(At,ht,re){At.exports={flex:"flex___2gmSR",flex1:"flex1___3Tu1g",color666:"color666___2uyGL",error:"error___yJ86W",deleteIcon:"deleteIcon___1D2tg",addIcon:"addIcon___2VIYB"}},OLES:function(At,ht,re){"use strict";var ae=re("U8pU"),$=re("VTBJ"),R=re("Ff2n"),X=re("q1tI"),N=re("uciX"),I=re("7ixt"),z=function(k){var T=k.overlay,A=k.prefixCls,C=k.id,h=k.overlayInnerStyle;return X.createElement("div",{className:"".concat(A,"-inner"),id:C,role:"tooltip",style:h},typeof T=="function"?T():T)},B=z,O=function(k,T){var A=k.overlayClassName,C=k.trigger,h=C===void 0?["hover"]:C,o=k.mouseEnterDelay,c=o===void 0?0:o,d=k.mouseLeaveDelay,_=d===void 0?.1:d,y=k.overlayStyle,m=k.prefixCls,l=m===void 0?"rc-tooltip":m,x=k.children,f=k.onVisibleChange,p=k.afterVisibleChange,s=k.transitionName,a=k.animation,b=k.placement,v=b===void 0?"right":b,S=k.align,M=S===void 0?{}:S,H=k.destroyTooltipOnHide,V=H===void 0?!1:H,Q=k.defaultVisible,G=k.getTooltipContainer,W=k.overlayInnerStyle,q=Object(R.a)(k,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),oe=Object(X.useRef)(null);Object(X.useImperativeHandle)(T,function(){return oe.current});var fe=Object($.a)({},q);"visible"in k&&(fe.popupVisible=k.visible);var ve=function(){var Ce=k.arrowContent,me=Ce===void 0?null:Ce,ne=k.overlay,Ae=k.id;return[X.createElement("div",{className:"".concat(l,"-arrow"),key:"arrow"},me),X.createElement(B,{key:"content",prefixCls:l,id:Ae,overlay:ne,overlayInnerStyle:W})]},De=!1,Ee=!1;if(typeof V=="boolean")De=V;else if(V&&Object(ae.a)(V)==="object"){var _e=V.keepParent;De=_e===!0,Ee=_e===!1}return X.createElement(N.a,Object.assign({popupClassName:A,prefixCls:l,popup:ve,action:h,builtinPlacements:I.a,popupPlacement:v,ref:oe,popupAlign:M,getPopupContainer:G,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:s,popupAnimation:a,defaultPopupVisible:Q,destroyPopupOnHide:De,autoDestroy:Ee,mouseLeaveDelay:_,popupStyle:y,mouseEnterDelay:c},fe),x)},D=Object(X.forwardRef)(O),E=ht.a=D},Ot1p:function(At,ht,re){"use strict";var ae=re("2qtc"),$=re("kLXV"),R=re("rAM+"),X=re("miYZ"),N=re("tsqr"),I=re("9og8"),z=re("tJVT"),B=re("jrin"),O=re("WmNS"),D=re.n(O),E=re("q1tI"),L=re.n(E),k=re("VrN/"),T=re.n(k),A=re("bdgK"),C=re("p77/"),h=re("Bd2K"),o=re("ELLl"),c=re("19Vz"),d=re("lZu9"),_=re("+NIl"),y=re("kSUc"),m=re("9Bee"),l=function(ue){var Se=ue.value,ke=Se===void 0?"":Se,Je=ue.className,Qe=ue.showTextOnly,bt=ue.showLines,Dt=ue.style,Ze=Dt===void 0?{}:Dt,ut=Object(E.useMemo)(function(){return""},[ke]);return L.a.createElement(L.a.Fragment,null,L.a.createElement("div",{dangerouslySetInnerHTML:{__html:ut}}))},x=re("0Owb"),f=re("dejd"),p=re("C+DQ"),s=re("1vsH"),a=re("m3rI"),b=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function v(ue){var Se=ue.onActionCallback,ke=ue.title,Je=ue.icon,Qe=ue.actionName,bt=ue.className,Dt=bt===void 0?"":bt,Ze=ue.children;function ut(){Se(Qe)}return L.a.createElement("a",{title:ke,className:Dt,onClick:ut},L.a.createElement("i",{className:"md-iconfont ".concat(Je)}),Ze)}var S=function(ue){var Se=ue.watch,ke=ue.showNullButton,Je=ue.onActionCallback,Qe=ue.fullScreen,bt=ue.insertTemp,Dt=ue.hidetoolBar,Ze=ue.uuid,ut=ue.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(s.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(s.F)("_educoder_session"),"&key=").concat(Ze,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Ft=[].concat(b,[{title:"".concat(Se?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(Se?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return L.a.createElement("ul",{className:"markdown-toolbar-container"},!Dt&&Ft.map(function(Ct,jt){return L.a.createElement("li",{key:jt},Ct.actionName?L.a.createElement(v,Object(x.a)({},Ct,{onActionCallback:Je})):L.a.createElement("span",{className:"v-line"}))}),ke?L.a.createElement("li",null,L.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:Je},L.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,bt&&L.a.createElement("li",null,L.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(bt),onActionCallback:Je},L.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),L.a.createElement("li",{className:"btn-full-screen"},L.a.createElement(v,{icon:"".concat(Qe?"icon-shrink":"icon-enlarge"),title:Qe?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:Je})))},M=re("M8RZ"),H=re("+L6B"),V=re("2/Rp"),Q=re("y8nQ"),G=re("Vl3Y"),W=re("5NDa"),q=re("5rEg"),oe={labelCol:{span:4},wrapperCol:{span:20}},fe=function(ue){var Se=ue.callback,ke=ue.onCancel;function Je(Qe){Se(Qe)}return L.a.createElement(G.a,Object(x.a)({},oe,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Je}),L.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},L.a.createElement(q.a,null)),L.a.createElement(G.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},L.a.createElement(q.a,null)),L.a.createElement("div",{className:"flex-container flex-end"},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},ve=re("7ahc"),De=re("HmJG"),Ee=re("BjJ7"),_e=G.a.useForm,Te={width:280,marginRight:10},Ce={labelCol:{span:5},wrapperCol:{span:19}},me=function(ue){var Se=ue.callback,ke=ue.onCancel,Je=_e(),Qe=Object(z.a)(Je,1),bt=Qe[0];function Dt(Ft){Se(Ft)}function Ze(Ft,Ct){if(Ft.status===-1){N.b.error(Ft.message);return}bt.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:Ct.type})}function ut(Ft){var Ct=Ft.target.files[0];Ae(Ct,Ze)}return L.a.createElement(G.a,Object(x.a)({form:bt},Ce,{className:"upload-image-panel",onFinish:Dt}),L.a.createElement(G.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},L.a.createElement("div",{className:"flex-container"},L.a.createElement(G.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},L.a.createElement(q.a,{style:Te})),L.a.createElement(ne,{onFileChange:ut}))),L.a.createElement(G.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},L.a.createElement(q.a,{style:{width:264}})),L.a.createElement(G.a.Item,{style:{textAlign:"right"}},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))};function ne(ue){var Se=ue.onFileChange;return L.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",L.a.createElement("input",{type:"file",onChange:Se}))}function Ae(ue,Se){if(!ue)throw new String("\u6CA1\u6709\u6587\u4EF6");var ke=new FormData;ke.append("editormd-image-file",ue),ke.append("file_param_name","editormd-image-file"),ke.append("byxhr","true");var Je=new window.XMLHttpRequest;Je.withCredentials=!0,Je.addEventListener("load",function(Qe){Se(JSON.parse(Qe.target.responseText),ue)},!1),Je.addEventListener("error",function(Qe){console.error(Qe)},!1),Je.open("POST","".concat(Ee.a,"/api/attachments.json")),Je.send(ke)}var rt=re("giR+"),$e=re("fyUT"),Xe=re("7Kak"),Ve=re("9yH6"),Le=Ve.a.Group,Me={margin:"0 8px"},ze=function(ue){var Se=ue.callback,ke=ue.onCancel;function Je(Qe){Se(Qe)}return L.a.createElement(G.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Je},L.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},L.a.createElement("span",{style:Me},"\u5355\u5143\u683C\u6570\uFF1A"),L.a.createElement("span",{style:Me},"\u884C\u6570"),L.a.createElement(G.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},L.a.createElement($e.a,null)),L.a.createElement("span",{style:Me},"\u5217\u6570"),L.a.createElement(G.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},L.a.createElement($e.a,null))),L.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},L.a.createElement("span",{style:Me},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),L.a.createElement(G.a.Item,{name:"align"},L.a.createElement(Le,null,L.a.createElement(Ve.a,{value:"default"},L.a.createElement("i",{className:"fa fa-align-justify"})),L.a.createElement(Ve.a,{value:"left"},L.a.createElement("i",{className:"fa fa-align-left"})),L.a.createElement(Ve.a,{value:"center"},L.a.createElement("i",{className:"fa fa-align-center"})),L.a.createElement(Ve.a,{value:"right"},L.a.createElement("i",{className:"fa fa-align-right"}))))),L.a.createElement("div",{className:"flex-container flex-end"},L.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),L.a.createElement(V.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},Ge=re("ErOA"),He=re("7Cbv"),Be="link",Pe="upload-image",pt="code-block",it="add-table",et="------------",at={default:et,left:":".concat(et),center:":".concat(et,":"),right:"".concat(et,":")},Et=re("9VGf"),ct,dt;function we(){}var gt=0,lt=1e4,Re="\u2581",je=`
|
|
**\u6A21\u677F\u6807\u9898**
|
|
\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C`;function ge(ue){return/^\d+$/.test(ue)?"".concat(ue,"px"):ue}var de=navigator.platform.toUpperCase().indexOf("MAC")>=0,pe=de?"Cmd":"Ctrl",ee=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],te=(ct={},Object(B.a)(ct,pe+"-B","bold"),Object(B.a)(ct,pe+"-I","italic"),ct),ie=(dt={},Object(B.a)(dt,Be,"\u6DFB\u52A0\u94FE\u63A5"),Object(B.a)(dt,pt,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(B.a)(dt,Pe,"\u6DFB\u52A0\u6587\u4EF6"),Object(B.a)(dt,it,"\u6DFB\u52A0\u8868\u683C"),dt),se=ht.a=function(ue){var Se=ue.defaultValue,ke=Se===void 0?"":Se,Je=ue.onChange,Qe=ue.width,bt=Qe===void 0?"100%":Qe,Dt=ue.height,Ze=Dt===void 0?400:Dt,ut=ue.miniToolbar,Ft=ut===void 0?!1:ut,Ct=ue.isFocus,jt=Ct===void 0?!1:Ct,$t=ue.watch,Lt=ue.insertTemp,Qt=ue.mode,Zt=Qt===void 0?"markdown":Qt,ft=ue.id,Xt=ft===void 0?"markdown-editor-id":ft,zt=ue.showResizeBar,Gt=zt===void 0?!1:zt,Ut=ue.noStorage,Mt=Ut===void 0?!1:Ut,St=ue.showNullButton,tt=St===void 0?!1:St,Fe=ue.hidetoolBar,nr=Fe===void 0?!1:Fe,Vt=ue.fullScreen,qt=Vt===void 0?!1:Vt,Wt=ue.onBlur,Tr=ue.onCMBeforeChange,ir=ue.onFullScreen,Rt=ue.className,Ie=Rt===void 0?"":Rt,xt=ue.disablePaste,Dr=xt===void 0?!1:xt,un=ue.placeholder,dn=un===void 0?"":un,xr=ue.values,U=xr===void 0?"":xr,u=Object(E.useState)(null),g=Object(z.a)(u,2),P=g[0],J=g[1],j=Object(E.useState)(ke),ce=Object(z.a)(j,2),Ne=ce[0],qe=ce[1],Tt=Object(E.useState)($t),Ue=Object(z.a)(Tt,2),Pt=Ue[0],er=Ue[1],fr=Object(E.useState)(qt),Gr=Object(z.a)(fr,2),Mr=Gr[0],Ir=Gr[1],cn=Object(E.useState)(""),Sn=Object(z.a)(cn,2),wr=Sn[0],nt=Sn[1],be=Object(E.useState)(0),Ke=Object(z.a)(be,2),wt=Ke[0],mt=Ke[1],vt=Object(E.useState)(Ze),It=Object(z.a)(vt,2),gr=It[0],cr=It[1],hr=Object(E.useState)(!1),Lr=Object(z.a)(hr,2),Sr=Lr[0],Wr=Lr[1],or=Object(E.useRef)(Object(He.a)()),tr=Object(E.useRef)(!1),pr=Object(E.useRef)(),Ht=Object(E.useRef)(),br=Object(E.useRef)(),lr=Object(E.useRef)(),vn=Object(E.useRef)(),Nr=function(){var kt=Object(I.a)(D.a.mark(function Kt(){var Nt,Jt;return D.a.wrap(function(vr){for(;;)switch(vr.prev=vr.next){case 0:return vr.next=2,Object(Ge.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:or.current}});case 2:Jt=vr.sent,Jt!=null&&(Nt=Jt.attachments)!==null&&Nt!==void 0&&Nt.length&&(console.log("cm:",P,Ht),Jt.attachments.map(function(ar){ar.content_type.indexOf("image")>-1?P.replaceSelection(".concat(ar.content_type,")")):ar.content_type.indexOf("video")>-1?P.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):ar.content_type.indexOf("pdf")>-1?P.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ar.id,"?type=").concat(ar.content_type,'&disposition=inline" target="_blank">').concat(ar.name,"</a>")):P.replaceSelection("[".concat(ar.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ar.id,"?type=").concat(ar.content_type,")"))}));case 4:case"end":return vr.stop()}},Kt)}));return function(){return kt.apply(this,arguments)}}();Object(E.useEffect)(function(){qe(U),P==null||P.setValue(U)},[U]),Object(E.useEffect)(function(){ir==null||ir(Mr)},[Mr]),Object(E.useEffect)(function(){if(Ht.current){var kt=T.a.fromTextArea(Ht.current,{mode:Zt,lineNumbers:!Ft,lineWrapping:!0,value:ke,autoCloseTags:!0,autoCloseBrackets:!0});jt&&kt.focus();function Kt(Nt,Jt){if(Dr){Jt.preventDefault();return}var sr=Jt.clipboardData;if(sr){var vr=sr.types.toString(),ar=sr.items;if(vr==="Files"||sr.types.indexOf("Files")>-1){if(Jt.preventDefault(),Zt=="stex")return;try{var Pr,Qr=ar[1];((Pr=ar[0])===null||Pr===void 0?void 0:Pr.kind)==="file"&&(Qr=ar[0]);var rr=Qr.getAsFile(),Cn=rr.name.split(".").pop();Ae(rr,function(ur){if(ur.id){var Zr,Kr,hn;(rr==null||((Zr=rr.type)===null||Zr===void 0)?void 0:Zr.indexOf("image"))>-1?kt.replaceSelection(".concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?kt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'"></video>')):(rr==null||((hn=rr.type)===null||hn===void 0)?void 0:hn.indexOf("pdf"))>-1?kt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(rr.type,'&disposition=inline" target="_blank">').concat(rr.name,"</a>")):ee.includes(Cn)?kt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'?type=office&disposition=inline" target="_blank">').concat(rr.name,"</a>")):kt.replaceSelection("[".concat(rr.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(ur.content_type,")"))}else(ur==null?void 0:ur.status)===401&&(document.location.href="/user/login")})}catch(ur){N.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return kt.on("paste",Kt),kt.on("dragleave",function(Nt,Jt){br.current.classList.remove("mouse-hover-md")}),kt.on("dragover",function(Nt,Jt){br.current.classList.add("mouse-hover-md")}),kt.on("drop",function(Nt,Jt){br.current.classList.add("mouse-hover-md");var sr;if(sr=Jt.dataTransfer.files,sr.length>0){Jt.preventDefault(),Jt.stopPropagation();for(var vr=function(Qr){var rr=sr[Qr],Cn=rr.name.split(".").pop();Ae(rr,function(ur){if(ur.id){var Zr,Kr,hn;(rr==null||((Zr=rr.type)===null||Zr===void 0)?void 0:Zr.indexOf("image"))>-1?kt.replaceSelection(".concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?kt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'"></video>')):(rr==null||((hn=rr.type)===null||hn===void 0)?void 0:hn.indexOf("pdf"))>-1?kt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(rr.type,'&disposition=inline" target="_blank">').concat(rr.name,"</a>")):ee.includes(Cn)?kt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'?type=office&disposition=inline" target="_blank">').concat(rr.name,"</a>")):kt.replaceSelection("[".concat(rr.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,"?type=").concat(ur.content_type,")"))}else(ur==null?void 0:ur.status)===401&&(document.location.href="/user/login")})},ar=0;ar<sr.length;ar++)vr(ar)}}),J(kt),function(){kt.off("paste",Kt)}}},[]);var Yr=Object(E.useCallback)(function(){if(br.current)try{}catch(kt){console.log(kt,"---- to set md editor body height")}},[gr,br,Mr]);Object(E.useEffect)(function(){function kt(){var Nt=new A.default(function(Jt){var sr=Object(R.a)(Jt),vr;try{for(sr.s();!(vr=sr.n()).done;){var ar=vr.value;(ar.target.offsetHeight>0||ar.target.offsetWidth>0)&&(Yr(),P.setSize("100%","100%"),P.refresh())}}catch(Pr){sr.e(Pr)}finally{sr.f()}});return Nt.observe(Ht.current.parentElement),Nt}if(P){var Kt=kt();return function(){Kt.unobserve(Ht.current.parentElement)}}},[P,Yr]),Object(E.useEffect)(function(){if(P){for(var kt=[],Kt=function(){var ar=Jt[Nt];sr=Object(z.a)(ar,2);var Pr=sr[0],Qr=sr[1],rr=Object(B.a)({},Pr,function(){Yn(Qr)});kt.push(rr),P.addKeyMap(rr)},Nt=0,Jt=Object.entries(te);Nt<Jt.length;Nt++){var sr;Kt()}return pr.current=setInterval(function(){tr.current&&Nr()},4e3),function(){clearInterval(pr.current);var vr=Object(R.a)(kt),ar;try{for(vr.s();!(ar=vr.n()).done;){var Pr=ar.value;P.removeKeyMap(Pr)}}catch(Qr){vr.e(Qr)}finally{vr.f()}}}},[P]),Object(E.useEffect)(function(){qt!==Mr&&Ir(qt)},[qt]),Object(Et.a)(function(){if(!Mt&&wt>0){var kt=new Date().getTime(),Kt=window.sessionStorage.getItem(Xt);kt>=wt+lt&&(!Kt||Kt!==Ne)&&(window.sessionStorage.setItem(Xt,Ne),Wr(!0))}},lt),Object(E.useEffect)(function(){er($t)},[P,$t]),Object(E.useEffect)(function(){P&&(jt&&P.focus())},[P,jt]),Object(E.useEffect)(function(){if(Pt&&P){var kt=P.getScrollerElement();function Kt(Nt){var Jt=Nt.target;if(vn.current){var sr=Jt.scrollTop/Jt.scrollHeight;vn.current.scrollTop=vn.current.scrollHeight*sr}}return kt.addEventListener("scroll",Kt),function(){kt.removeEventListener("scroll",Kt)}}},[P,Pt]),Object(E.useEffect)(function(){if(P&&Tr){function kt(Kt,Nt){Tr(Kt,Nt)}return P.on("beforeChange",kt),function(){P.off("beforeChange",kt)}}},[P,Tr]),Object(E.useEffect)(function(){if(P&&Wt){function kt(){Wt(P.getValue())}return P.on("blur",kt),function(){P.off("blur",kt)}}},[P,Wt]),Object(E.useEffect)(function(){if(P){function kt(Kt){var Nt=Kt.getValue();qe(Nt),mt(new Date().getTime()),Kt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Je&&Je(Nt)}return P.on("change",kt),function(){P.off("change",kt)}}},[P,Je]),Object(E.useEffect)(function(){P&&(ke==null?(P.setValue(""),qe("")):ke!==P.getValue()&&(P.setValue(ke),qe(ke),P.setCursor(P.lineCount(),0)))},[P,ke]);var Yn=Object(E.useCallback)(function(kt){var Kt=P.getCursor(),Nt=P.getSelection(),Jt=Nt.split(`
|
|
`);switch(kt){case"bold":return P.replaceSelection("**"+Nt+"**"),Nt===""&&P.setCursor(Kt.line,Kt.ch+2),P.focus();case"italic":return P.replaceSelection("*"+Nt+"*"),Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.focus();case"code":return P.replaceSelection("`"+Nt+"`"),Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.focus();case"inline-latex":return P.replaceSelection("`$$"+Nt+"$$`"),Nt===""&&P.setCursor(Kt.line,Kt.ch+3),P.focus();case"latex":return P.replaceSelection("```latex\n"+Nt+"\n```"),P.setCursor(Kt.line+1,Nt.length+1),P.focus();case"line-break":return P.replaceSelection(`<br/>
|
|
`),P.focus();case"list-ul":return Nt===""?P.replaceSelection("- "+Nt):P.replaceSelection(Jt.map(function(sr){return sr===""?"":"- ".concat(sr)}).join(`
|
|
`)),P.focus();case"list-ol":return Nt===""?P.replaceSelection("1. "+Nt):P.replaceSelection(Jt.map(function(sr,vr){return sr===""?"":"".concat(vr+1,". ").concat(sr)}).join(`
|
|
`)),P.focus();case"add-null-ch":return Nt===""&&P.setCursor(Kt.line,Kt.ch+1),P.replaceSelection(Re),P.focus();case"inster-template-1":return Nt===""&&P.setCursor(Kt.line,Kt.ch),P.replaceSelection(je),P.focus();case"eraser":return P.setValue(""),P.focus();case"trigger-watch":return er(!Pt),P.focus();case"trigger-full-screen":return Ir(!Mr),P.focus();case Be:nt(Be);return;case pt:nt(pt);return;case Pe:nt(Pe);return;case it:nt(it);return;default:throw new Error}},[P,Pt,Mr]),An=Object(E.useCallback)(function(kt){nt("");switch(wr){case Be:var Kt=kt.title,Nt=kt.link;return P.replaceSelection("[".concat(Kt,"](").concat(Nt,")")),P.focus();case pt:var Jt=kt.language,sr=kt.content;return P.replaceSelection(["```"+Jt,sr,"```"].join(`
|
|
`)),P.focus();case Pe:var vr=kt.src,ar=kt.alt;return ar?P.replaceSelection(".concat(vr,' "').concat(ar,'" )')):P.replaceSelection("")),P.focus();case it:for(var Pr=kt.row,Qr=kt.col,rr=kt.align,Cn=`
|
|
`,ur=0;ur<Pr;ur++){for(var Zr=[],Kr=[],hn=0;hn<Qr;hn++)ur===1&&Kr.push(at[rr]),Zr.push(" ");ur===1&&(Cn+="| ".concat(Kr.join(" | "),` |
|
|
`)),Cn+="| ".concat(Zr.join(Qr===1?"":" | "),` |
|
|
`)}return P.replaceSelection(Cn+`
|
|
`),P.focus();default:throw new Error}},[P,wr]),hi=Object(E.useMemo)(function(){switch(wr){case Be:return L.a.createElement(fe,{callback:An,onCancel:Ln});case pt:return L.a.createElement(ve.b,{callback:An,onCancel:Ln});case Pe:return L.a.createElement(me,{callback:An,onCancel:Ln});case it:return L.a.createElement(ze,{callback:An,onCancel:Ln});default:return null}},[wr]);function Ln(){nt("")}Object(E.useEffect)(function(){if(lr.current){var kt=lr.current,Kt=!1,Nt=0;function Jt(ar){Kt=!0,Nt=ar.pageY}function sr(){Kt=!1}function vr(ar){if(Kt){var Pr=ar.pageY-Nt;Pr<0&&(Pr=0),Pr>300&&(Pr=300);var Qr=Ze+Pr+"px";cr(Qr)}}return kt.addEventListener("mousedown",Jt),document.addEventListener("mousemove",vr),document.addEventListener("mouseup",sr),function(){kt.removeEventListener("mousedown",Jt),document.removeEventListener("mousemove",vr),document.removeEventListener("mouseup",sr)}}},[P,lr]),Object(E.useEffect)(function(){cr(Ze)},[Ze]);var yn=ge(bt),fi=ge(gr),fn={width:yn,height:fi},pi=Object(E.useMemo)(function(){if(wt){var kt=new Date(wt),Kt=kt.getHours(),Nt=kt.getMinutes(),Jt=kt.getSeconds();return Kt=Kt<10?"0"+Kt:Kt,Nt=Nt<10?"0"+Nt:Nt,Jt=Jt<10?"0"+Jt:Jt,"".concat(Kt,":").concat(Nt,":").concat(Jt)}return 0},[wt]);function ji(){window.sessionStorage.removeItem(Xt),Wr(!1),mt(0)}function Un(){Wr(!1),mt(0),P.setValue(window.sessionStorage.getItem(Xt))}function ua(kt,Kt){var Nt=P.getValue();Nt=Nt.replace(kt,Kt),qe(Nt),P==null||P.setValue(Nt)}return L.a.createElement(E.Fragment,null,L.a.createElement("div",{className:"markdown-editor-wrapper",ref:br},L.a.createElement("div",{className:"markdown-editor-container ".concat(Ie," ").concat(Pt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(Mr?"full-screen":""),style:fn},L.a.createElement(S,{insertTemp:Lt,watch:Pt,fullScreen:Mr,showNullButton:tt,onActionCallback:Yn,hidetoolBar:nr,uuid:or.current,setOpenPhones:function(){tr.current=!0}}),L.a.createElement("div",{className:"markdown-editor-body"},L.a.createElement("div",{className:"codemirror-container"},L.a.createElement("textarea",{ref:Ht,placeholder:dn})),Pt?L.a.createElement("div",{ref:vn,className:"preview-container"},Zt==="stex"&&L.a.createElement(l,{value:Ne}),Zt!=="stex"&&L.a.createElement(m.a,{edit:!0,value:Ne,replaces:ua})):null))),Gt?L.a.createElement("a",{ref:lr,className:"editor-resize"}):null,L.a.createElement(M.a,null,ie[wr]?L.a.createElement($.a,{centered:!0,title:ie[wr],visible:!0,onCancel:Ln,footer:null,className:"markdown-popup-form"},hi):null))}},PGNT:function(At,ht,re){At.exports={wrap:"wrap___orWmH",modal:"modal___142IN",titleWrap:"titleWrap___2UWGN",required:"required___lXOtq",title:"title___2wqMf",colorGray:"colorGray___3FkLm",choiceWrap:"choiceWrap___3pbic",answer:"answer___30LSv",activeAnswer:"activeAnswer___3ayAN",deleteIcon:"deleteIcon___2HHly",addIcon:"addIcon___29vcx",editorWrap:"editorWrap___ANVP6",htmlWrap:"htmlWrap___38sLf",radio:"radio___15wok",color333:"color333___sNPjh",color999:"color999___1ofkl",fold:"fold___6rnoE",head:"head___2muph"}},PsQE:function(At,ht,re){At.exports={flex_box_center:"flex_box_center___2PkN_",flex_space_between:"flex_space_between___36cDA",flex_box_vertical_center:"flex_box_vertical_center___2c88u",flex_box_center_end:"flex_box_center_end___14cXO",flex_box_column:"flex_box_column___3nalt",wrap:"wrap___3xZrs",left:"left___19hOK",title:"title___3Ti2k",total:"total___3MRC5",list:"list___3pdfL",name:"name___2IcTs",b:"b___2W0Sn",r:"r___2Tpj8",l:"l___1rMKQ",tag:"tag___jj2X5",right:"right___16831",examName:"examName___2TmgX",t:"t___1CJZd",num:"num___1qX6C",topWarp:"topWarp___3WuSr",head:"head___3z9Hq",so:"so___m2B6Z",btn:"btn___20VL7",content:"content___2tTuo",titleWrap:"titleWrap___1cYdQ",single:"single___1BKtz",analysis:"analysis___1qm4Y",text:"text___1JQUf",btnsElse:"btnsElse___2IzAs",btnsWrap:"btnsWrap___3ib37",btns:"btns___2DbBT",modalColumn:"modalColumn___1zs36",modalRow:"modalRow___14b2N",sup:"sup___1CIjI",popover:"popover___Mmcvb"}},"RZ/O":function(At,ht,re){At.exports=re.p+"static/bi.9c9b0364.svg"},SJMd:function(At,ht){/**
|
|
* @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,ae,$,R=!1,X,N;window.PR_SHOULD_USE_CONTINUATION=!0;var I,z;(function(){var B=window,O=["break,continue,do,else,for,if,return,while"],D=[O,"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"],E=[D,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],L=[E,"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=[E,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],T=[E,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],A="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",C=[E,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",o=[O,"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"],c=[O,"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=[O,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],_=[L,T,k,C,h,o,c,d],y=/^(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",f="typ",p="lit",s="pun",a="pln",b="tag",v="dec",S="src",M="atn",H="atv",V="nocode",Q="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function G(Le){for(var Me=0,ze=!1,Ge=!1,He=0,Be=Le.length;He<Be;++He){var Pe=Le[He];if(Pe.ignoreCase)Ge=!0;else if(/[a-z]/i.test(Pe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){ze=!0,Ge=!1;break}}var pt={b:8,t:9,n:10,v:11,f:12,r:13};function it(dt){var we=dt.charCodeAt(0);if(we!==92)return we;var gt=dt.charAt(1);return we=pt[gt],we||("0"<=gt&><="7"?parseInt(dt.substring(1),8):gt==="u"||gt==="x"?parseInt(dt.substring(2),16):dt.charCodeAt(1))}function et(dt){if(dt<32)return(dt<16?"\\x0":"\\x")+dt.toString(16);var we=String.fromCharCode(dt);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function at(dt){var we=dt.substring(1,dt.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")),gt=[],lt=we[0]==="^",Re=["["];lt&&Re.push("^");for(var je=lt?1:0,ge=we.length;je<ge;++je){var de=we[je];if(/\\[bdsw]/i.test(de))Re.push(de);else{var pe=it(de),ee;je+2<ge&&we[je+1]==="-"?(ee=it(we[je+2]),je+=2):ee=pe,gt.push([pe,ee]),ee<65||pe>122||(ee<65||pe>90||gt.push([Math.max(65,pe)|32,Math.min(ee,90)|32]),ee<97||pe>122||gt.push([Math.max(97,pe)&~32,Math.min(ee,122)&~32]))}}gt.sort(function(ue,Se){return ue[0]-Se[0]||Se[1]-ue[1]});for(var te=[],ie=[],je=0;je<gt.length;++je){var se=gt[je];se[0]<=ie[1]+1?ie[1]=Math.max(ie[1],se[1]):te.push(ie=se)}for(var je=0;je<te.length;++je){var se=te[je];Re.push(et(se[0])),se[1]>se[0]&&(se[1]+1>se[0]&&Re.push("-"),Re.push(et(se[1])))}return Re.push("]"),Re.join("")}function Et(dt){for(var we=dt.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")),gt=we.length,lt=[],Re=0,je=0;Re<gt;++Re){var ge=we[Re];if(ge==="(")++je;else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&(de<=je?lt[de]=-1:we[Re]=et(de))}}for(var Re=1;Re<lt.length;++Re)lt[Re]===-1&&(lt[Re]=++Me);for(var Re=0,je=0;Re<gt;++Re){var ge=we[Re];if(ge==="(")++je,lt[je]||(we[Re]="(?:");else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&de<=je&&(we[Re]="\\"+lt[de])}}for(var Re=0;Re<gt;++Re)we[Re]==="^"&&we[Re+1]!=="^"&&(we[Re]="");if(dt.ignoreCase&&ze)for(var Re=0;Re<gt;++Re){var ge=we[Re],pe=ge.charAt(0);ge.length>=2&&pe==="["?we[Re]=at(ge):pe!=="\\"&&(we[Re]=ge.replace(/[a-zA-Z]/g,function(ie){var se=ie.charCodeAt(0);return"["+String.fromCharCode(se&~32,se|32)+"]"}))}return we.join("")}for(var ct=[],He=0,Be=Le.length;He<Be;++He){var Pe=Le[He];if(Pe.global||Pe.multiline)throw new Error(""+Pe);ct.push("(?:"+Et(Pe)+")")}return new RegExp(ct.join("|"),Ge?"gi":"g")}function W(Le,Me){var ze=/(?:^|\s)nocode(?:\s|$)/,Ge=[],He=0,Be=[],Pe=0;function pt(it){var et=it.nodeType;if(et==1){if(ze.test(it.className))return;for(var at=it.firstChild;at;at=at.nextSibling)pt(at);var Et=it.nodeName.toLowerCase();(Et==="br"||Et==="li")&&(Ge[Pe]=`
|
|
`,Be[Pe<<1]=He++,Be[Pe++<<1|1]=it)}else if(et==3||et==4){var ct=it.nodeValue;ct.length&&(Me?ct=ct.replace(/\r\n?/g,`
|
|
`):ct=ct.replace(/[ \t\r\n]+/g," "),Ge[Pe]=ct,Be[Pe<<1]=He,He+=ct.length,Be[Pe++<<1|1]=it)}}return pt(Le),{sourceCode:Ge.join("").replace(/\n$/,""),spans:Be}}function q(Le,Me,ze,Ge,He){if(!ze)return;var Be={sourceNode:Le,pre:1,langExtension:null,numberLines:null,sourceCode:ze,spans:null,basePos:Me,decorations:null};Ge(Be),He.push.apply(He,Be.decorations)}var oe=/\S/;function fe(Le){for(var Me=void 0,ze=Le.firstChild;ze;ze=ze.nextSibling){var Ge=ze.nodeType;Me=Ge===1?Me?Le:ze:Ge===3&&oe.test(ze.nodeValue)?Le:Me}return Me===Le?void 0:Me}function ve(Le,Me){var ze={},Ge;(function(){for(var Pe=Le.concat(Me),pt=[],it={},et=0,at=Pe.length;et<at;++et){var Et=Pe[et],ct=Et[3];if(ct)for(var dt=ct.length;--dt>=0;)ze[ct.charAt(dt)]=Et;var we=Et[1],gt=""+we;it.hasOwnProperty(gt)||(pt.push(we),it[gt]=null)}pt.push(/[\0-\uffff]/),Ge=G(pt)})();var He=Me.length,Be=function(Pe){for(var pt=Pe.sourceCode,it=Pe.basePos,et=Pe.sourceNode,at=[it,a],Et=0,ct=pt.match(Ge)||[],dt={},we=0,gt=ct.length;we<gt;++we){var lt=ct[we],Re=dt[lt],je=void 0,ge;if(typeof Re=="string")ge=!1;else{var de=ze[lt.charAt(0)];if(de)je=lt.match(de[1]),Re=de[0];else{for(var pe=0;pe<He;++pe)if(de=Me[pe],je=lt.match(de[1]),je){Re=de[0];break}je||(Re=a)}ge=Re.length>=5&&Re.substring(0,5)==="lang-",ge&&!(je&&typeof je[1]=="string")&&(ge=!1,Re=S),ge||(dt[lt]=Re)}var ee=Et;if(Et+=lt.length,!ge)at.push(it+ee,Re);else{var te=je[1],ie=lt.indexOf(te),se=ie+te.length;je[2]&&(se=lt.length-je[2].length,ie=se-te.length);var ue=Re.substring(5);q(et,it+ee,lt.substring(0,ie),Be,at),q(et,it+ee+ie,te,ne(ue,te),at),q(et,it+ee+se,lt.substring(se),Be,at)}}Pe.decorations=at};return Be}function De(Le){var Me=[],ze=[];Le.tripleQuotedStrings?Me.push([m,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):Le.multiLineStrings?Me.push([m,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Me.push([m,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),Le.verbatimStrings&&ze.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ge=Le.hashComments;Ge&&(Le.cStyleComments?(Ge>1?Me.push([x,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([x,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),ze.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([x,/^#[^\r\n]*/,null,"#"])),Le.cStyleComments&&(ze.push([x,/^\/\/[^\r\n]*/,null]),ze.push([x,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var He=Le.regexLiterals;if(He){var Be=He>1?"":`
|
|
\r`,Pe=Be?".":"[\\S\\s]",pt="/(?=[^/*"+Be+"])(?:[^/\\x5B\\x5C"+Be+"]|\\x5C"+Pe+"|\\x5B(?:[^\\x5C\\x5D"+Be+"]|\\x5C"+Pe+")*(?:\\x5D|$))+/";ze.push(["lang-regex",RegExp("^"+Q+"("+pt+")")])}var it=Le.types;it&&ze.push([f,it]);var et=(""+Le.keywords).replace(/^ | $/g,"");et.length&&ze.push([l,new RegExp("^(?:"+et.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var at="^.[^\\s\\w.$@'\"`/\\\\]*";return Le.regexLiterals&&(at+="(?!s*/)"),ze.push([p,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[p,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[s,new RegExp(at),null]),ve(Me,ze)}var Ee=De({keywords:_,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function _e(Le,Me,ze){for(var Ge=/(?:^|\s)nocode(?:\s|$)/,He=/\r\n?|\n/,Be=Le.ownerDocument,Pe=Be.createElement("li");Le.firstChild;)Pe.appendChild(Le.firstChild);var pt=[Pe];function it(we){var gt=we.nodeType;if(gt==1&&!Ge.test(we.className))if(we.nodeName==="br")et(we),we.parentNode&&we.parentNode.removeChild(we);else for(var lt=we.firstChild;lt;lt=lt.nextSibling)it(lt);else if((gt==3||gt==4)&&ze){var Re=we.nodeValue,je=Re.match(He);if(je){var ge=Re.substring(0,je.index);we.nodeValue=ge;var de=Re.substring(je.index+je[0].length);if(de){var pe=we.parentNode;pe.insertBefore(Be.createTextNode(de),we.nextSibling)}et(we),ge||we.parentNode.removeChild(we)}}}function et(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function gt(je,ge){var de=ge?je.cloneNode(!1):je,pe=je.parentNode;if(pe){var ee=gt(pe,1),te=je.nextSibling;ee.appendChild(de);for(var ie=te;ie;ie=te)te=ie.nextSibling,ee.appendChild(ie)}return de}for(var lt=gt(we.nextSibling,0),Re;(Re=lt.parentNode)&&Re.nodeType===1;)lt=Re;pt.push(lt)}for(var at=0;at<pt.length;++at)it(pt[at]);Me===(Me|0)&&pt[0].setAttribute("value",Me);var Et=Be.createElement("ol");Et.className="linenums";for(var ct=Math.max(0,Me-1|0)||0,at=0,dt=pt.length;at<dt;++at)Pe=pt[at],Pe.className="L"+(at+ct)%10,Pe.firstChild||Pe.appendChild(Be.createTextNode("\xA0")),Et.appendChild(Pe);Le.appendChild(Et)}function Te(Le){var Me=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Me=Me&&+Me[1]<=8;var ze=/\n/g,Ge=Le.sourceCode,He=Ge.length,Be=0,Pe=Le.spans,pt=Pe.length,it=0,et=Le.decorations,at=et.length,Et=0;et[at]=He;var ct,dt;for(dt=ct=0;dt<at;)et[dt]!==et[dt+2]?(et[ct++]=et[dt++],et[ct++]=et[dt++]):dt+=2;for(at=ct,dt=ct=0;dt<at;){for(var we=et[dt],gt=et[dt+1],lt=dt+2;lt+2<=at&&et[lt+1]===gt;)lt+=2;et[ct++]=we,et[ct++]=gt,dt=lt}at=et.length=ct;var Re=Le.sourceNode,je="";Re&&(je=Re.style.display,Re.style.display="none");try{for(var ge=null;it<pt;){var de=Pe[it],pe=Pe[it+2]||He,ee=et[Et+2]||He,lt=Math.min(pe,ee),te=Pe[it+1],ie;if(te.nodeType!==1&&(ie=Ge.substring(Be,lt))){Me&&(ie=ie.replace(ze,"\r")),te.nodeValue=ie;var se=te.ownerDocument,ue=se.createElement("span");ue.className=et[Et+1];var Se=te.parentNode;Se.replaceChild(ue,te),ue.appendChild(te),Be<pe&&(Pe[it+1]=te=se.createTextNode(Ge.substring(lt,pe)),Se.insertBefore(te,ue.nextSibling))}Be=lt,Be>=pe&&(it+=2),Be>=ee&&(Et+=2)}}finally{Re&&(Re.style.display=je)}}var Ce={};function me(Le,Me){for(var ze=Me.length;--ze>=0;){var Ge=Me[ze];Ce.hasOwnProperty(Ge)?B.console&&console.warn("cannot override language handler %s",Ge):Ce[Ge]=Le}}function ne(Le,Me){return Le&&Ce.hasOwnProperty(Le)||(Le=/^\s*</.test(Me)?"default-markup":"default-code"),Ce[Le]}me(Ee,["default-code"]),me(ve([],[[a,/^[^<?]+/],[v,/^<!\w[^>]*(?:>|$)/],[x,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[s,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),me(ve([[a,/^[\s]+/,null,` \r
|
|
`],[H,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[s,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),me(ve([],[[H,/^[\s\S]+/]]),["uq.val"]),me(De({keywords:L,hashComments:!0,cStyleComments:!0,types:y}),["c","cc","cpp","cxx","cyc","m"]),me(De({keywords:"null,true,false"}),["json"]),me(De({keywords:T,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:y}),["cs"]),me(De({keywords:k,cStyleComments:!0}),["java"]),me(De({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(De({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(De({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(De({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(De({keywords:C,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(De({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[m,/^[\s\S]+/]]),["regex"]);function Ae(Le){var Me=Le.langExtension;try{var ze=W(Le.sourceNode,Le.pre),Ge=ze.sourceCode;Le.sourceCode=Ge,Le.spans=ze.spans,Le.basePos=0,ne(Me,Ge)(Le),Te(Le)}catch(He){B.console&&console.log(He&&He.stack||He)}}function rt(Le,Me,ze){var Ge=ze||!1,He=Me||null,Be=document.createElement("div");Be.innerHTML="<pre>"+Le+"</pre>",Be=Be.firstChild,Ge&&_e(Be,Ge,!0);var Pe={langExtension:He,numberLines:Ge,sourceNode:Be,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Ae(Pe),Be.innerHTML}function $e(Le,Me){var ze=Me||document.body,Ge=ze.ownerDocument||document;function He(de){return ze.getElementsByTagName(de)}for(var Be=[He("pre"),He("code"),He("xmp")],Pe=[],pt=0;pt<Be.length;++pt)for(var it=0,et=Be[pt].length;it<et;++it)Pe.push(Be[pt][it]);Be=null;var at=Date;at.now||(at={now:function(){return+new Date}});var Et=0,ct=/\blang(?:uage)?-([\w.]+)(?!\S)/,dt=/\bprettyprint\b/,we=/\bprettyprinted\b/,gt=/pre|xmp/i,lt=/^code$/i,Re=/^(?:pre|code|xmp)$/i,je={};function ge(){for(var de=B.PR_SHOULD_USE_CONTINUATION?at.now()+250:Infinity;Et<Pe.length&&at.now()<de;Et++){for(var pe=Pe[Et],ee=je,te=pe;te=te.previousSibling;){var ie=te.nodeType,se=(ie===7||ie===8)&&te.nodeValue;if(se?!/^\??prettify\b/.test(se):ie!==3||/\S/.test(te.nodeValue))break;if(se){ee={},se.replace(/\b(\w+)=([\w:.%+-]+)/g,function($t,Lt,Qt){ee[Lt]=Qt});break}}var ue=pe.className;if((ee!==je||dt.test(ue))&&!we.test(ue)){for(var Se=!1,ke=pe.parentNode;ke;ke=ke.parentNode){var Je=ke.tagName;if(Re.test(Je)&&ke.className&&dt.test(ke.className)){Se=!0;break}}if(!Se){pe.className+=" prettyprinted";var Qe=ee.lang;if(!Qe){Qe=ue.match(ct);var bt;!Qe&&(bt=fe(pe))&<.test(bt.tagName)&&(Qe=bt.className.match(ct)),Qe&&(Qe=Qe[1])}var Dt;if(gt.test(pe.tagName))Dt=1;else{var Ze=pe.currentStyle,ut=Ge.defaultView,Ft=Ze?Ze.whiteSpace:ut&&ut.getComputedStyle?ut.getComputedStyle(pe,null).getPropertyValue("white-space"):0;Dt=Ft&&Ft.substring(0,3)==="pre"}var Ct=ee.linenums;(Ct=Ct==="true"||+Ct)||(Ct=ue.match(/\blinenums\b(?::(\d+))?/),Ct=Ct?Ct[1]&&Ct[1].length?+Ct[1]:!0:!1),Ct&&_e(pe,Ct,Dt);var jt={langExtension:Qe,sourceNode:pe,numberLines:Ct,pre:Dt,sourceCode:null,basePos:null,spans:null,decorations:null};Ae(jt)}}}Et<Pe.length?B.setTimeout(ge,250):typeof Le=="function"&&Le()}ge()}var Xe=B.PR={createSimpleLexer:ve,registerLangHandler:me,sourceDecorator:De,PR_ATTRIB_NAME:M,PR_ATTRIB_VALUE:H,PR_COMMENT:x,PR_DECLARATION:v,PR_KEYWORD:l,PR_LITERAL:p,PR_NOCODE:V,PR_PLAIN:a,PR_PUNCTUATION:s,PR_SOURCE:S,PR_STRING:m,PR_TAG:b,PR_TYPE:f,prettyPrintOne:R?B.prettyPrintOne=rt:I=rt,prettyPrint:z=R?B.prettyPrint=$e:z=$e},Ve=B.define;typeof Ve=="function"&&Ve.amd&&Ve("google-code-prettify",[],function(){return Xe})})()},"VrN/":function(At,ht,re){(function(ae,$){At.exports=$()})(this,function(){"use strict";var ae=navigator.userAgent,$=navigator.platform,R=/gecko\/\d/i.test(ae),X=/MSIE \d/.test(ae),N=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ae),I=/Edge\/(\d+)/.exec(ae),z=X||N||I,B=z&&(X?document.documentMode||6:+(I||N)[1]),O=!I&&/WebKit\//.test(ae),D=O&&/Qt\/\d+\.\d+/.test(ae),E=!I&&/Chrome\//.test(ae),L=/Opera\//.test(ae),k=/Apple Computer/.test(navigator.vendor),T=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ae),A=/PhantomJS/.test(ae),C=!I&&/AppleWebKit/.test(ae)&&/Mobile\/\w+/.test(ae),h=/Android/.test(ae),o=C||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ae),c=C||/Mac/.test($),d=/\bCrOS\b/.test(ae),_=/win/i.test($),y=L&&ae.match(/Version\/(\d*\.\d*)/);y&&(y=Number(y[1])),y&&y>=15&&(L=!1,O=!0);var m=c&&(D||L&&(y==null||y<12.11)),l=R||z&&B>=9;function x(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var n=e.className,r=x(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function p(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function s(e,t){return p(e).appendChild(t)}function a(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var w=0;w<t.length;++w)i.appendChild(t[w]);return i}function b(e,t,n,r){var i=a(e,t,n,r);return i.setAttribute("role","presentation"),i}var v;document.createRange?v=function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:v=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),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 H(e,t){var n=e.className;x(t).test(n)||(e.className+=(n?" ":"")+t)}function V(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!x(n[r]).test(t)&&(t+=" "+n[r]);return t}var Q=function(e){e.select()};C?Q=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:z&&(Q=function(e){try{e.select()}catch(t){}});function G(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function W(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function q(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var w=r||0,F=i||0;;){var K=e.indexOf(" ",w);if(K<0||K>=t)return F+(t-w);F+=K-w,F+=n-F%n,w=K+1}}var oe=function(){this.id=null,this.f=null,this.time=0,this.handler=G(this.onTimeout,this)};oe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},oe.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};function fe(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}var ve=50,De={toString:function(){return"CodeMirror.Pass"}},Ee={scroll:!1},_e={origin:"*mouse"},Te={origin:"+move"};function Ce(e,t,n){for(var r=0,i=0;;){var w=e.indexOf(" ",r);w==-1&&(w=e.length);var F=w-r;if(w==e.length||i+F>=t)return r+Math.min(F,t-i);if(i+=w-r,i+=n-i%n,r=w+1,i>=t)return r}}var me=[""];function ne(e){for(;me.length<=e;)me.push(Ae(me)+" ");return me[e]}function Ae(e){return e[e.length-1]}function rt(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function $e(e,t,n){for(var r=0,i=n(t);r<e.length&&n(e[r])<=i;)r++;e.splice(r,0,t)}function Xe(){}function Ve(e,t){var n;return Object.create?n=Object.create(e):(Xe.prototype=e,n=new Xe),t&&W(t,n),n}var Le=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Me(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Le.test(e))}function ze(e,t){return t?t.source.indexOf("\\w")>-1&&Me(e)?!0:t.test(e):Me(e)}function Ge(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var He=/[\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 Be(e){return e.charCodeAt(0)>=768&&He.test(e)}function Pe(e,t,n){for(;(n<0?t>0:t<e.length)&&Be(e.charAt(t));)t+=n;return t}function pt(e,t,n){for(var r=t>n?-1:1;;){if(t==n)return t;var i=(t+n)/2,w=r<0?Math.ceil(i):Math.floor(i);if(w==t)return e(w)?t:n;e(w)?n=w:t=w+r}}function it(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,w=0;w<e.length;++w){var F=e[w];(F.from<n&&F.to>t||t==n&&F.to==t)&&(r(Math.max(F.from,t),Math.min(F.to,n),F.level==1?"rtl":"ltr",w),i=!0)}i||r(t,n,"ltr")}var et=null;function at(e,t,n){var r;et=null;for(var i=0;i<e.length;++i){var w=e[i];if(w.from<t&&w.to>t)return i;w.to==t&&(w.from!=w.to&&n=="before"?r=i:et=i),w.from==t&&(w.from!=w.to&&n!="before"?r=i:et=i)}return r!=null?r:et}var Et=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(Z){return Z<=247?e.charAt(Z):1424<=Z&&Z<=1524?"R":1536<=Z&&Z<=1785?t.charAt(Z-1536):1774<=Z&&Z<=2220?"r":8192<=Z&&Z<=8203?"w":Z==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,w=/[LRr]/,F=/[Lb1n]/,K=/[1n]/;function Y(Z,le,he){this.level=Z,this.from=le,this.to=he}return function(Z,le){var he=le=="ltr"?"L":"R";if(Z.length==0||le=="ltr"&&!r.test(Z))return!1;for(var xe=Z.length,ye=[],Oe=0;Oe<xe;++Oe)ye.push(n(Z.charCodeAt(Oe)));for(var We=0,Ye=he;We<xe;++We){var ot=ye[We];ot=="m"?ye[We]=Ye:Ye=ot}for(var yt=0,st=he;yt<xe;++yt){var _t=ye[yt];_t=="1"&&st=="r"?ye[yt]="n":w.test(_t)&&(st=_t,_t=="r"&&(ye[yt]="R"))}for(var Bt=1,Ot=ye[0];Bt<xe-1;++Bt){var Yt=ye[Bt];Yt=="+"&&Ot=="1"&&ye[Bt+1]=="1"?ye[Bt]="1":Yt==","&&Ot==ye[Bt+1]&&(Ot=="1"||Ot=="n")&&(ye[Bt]=Ot),Ot=Yt}for(var yr=0;yr<xe;++yr){var Fr=ye[yr];if(Fr==",")ye[yr]="N";else if(Fr=="%"){var Cr=void 0;for(Cr=yr+1;Cr<xe&&ye[Cr]=="%";++Cr);for(var on=yr&&ye[yr-1]=="!"||Cr<xe&&ye[Cr]=="1"?"1":"N",tn=yr;tn<Cr;++tn)ye[tn]=on;yr=Cr-1}}for(var Rr=0,rn=he;Rr<xe;++Rr){var zr=ye[Rr];rn=="L"&&zr=="1"?ye[Rr]="L":w.test(zr)&&(rn=zr)}for(var Or=0;Or<xe;++Or)if(i.test(ye[Or])){var kr=void 0;for(kr=Or+1;kr<xe&&i.test(ye[kr]);++kr);for(var _r=(Or?ye[Or-1]:he)=="L",nn=(kr<xe?ye[kr]:he)=="L",di=_r==nn?_r?"L":"R":he,Nn=Or;Nn<kr;++Nn)ye[Nn]=di;Or=kr-1}for(var Xr=[],xn,jr=0;jr<xe;)if(F.test(ye[jr])){var Va=jr;for(++jr;jr<xe&&F.test(ye[jr]);++jr);Xr.push(new Y(0,Va,jr))}else{var wn=jr,Vn=Xr.length,Xn=le=="rtl"?1:0;for(++jr;jr<xe&&ye[jr]!="L";++jr);for(var Jr=wn;Jr<jr;)if(K.test(ye[Jr])){wn<Jr&&(Xr.splice(Vn,0,new Y(1,wn,Jr)),Vn+=Xn);var ci=Jr;for(++Jr;Jr<jr&&K.test(ye[Jr]);++Jr);Xr.splice(Vn,0,new Y(2,ci,Jr)),Vn+=Xn,wn=Jr}else++Jr;wn<jr&&Xr.splice(Vn,0,new Y(1,wn,jr))}return le=="ltr"&&(Xr[0].level==1&&(xn=Z.match(/^\s+/))&&(Xr[0].from=xn[0].length,Xr.unshift(new Y(0,0,xn[0].length))),Ae(Xr).level==1&&(xn=Z.match(/\s+$/))&&(Ae(Xr).to-=xn[0].length,Xr.push(new Y(0,xe-xn[0].length,xe)))),le=="rtl"?Xr.reverse():Xr}}();function ct(e,t){var n=e.order;return n==null&&(n=e.order=Et(e.text,t)),n}var dt=[],we=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||dt).concat(n)}};function gt(e,t){return e._handlers&&e._handlers[t]||dt}function lt(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers,i=r&&r[t];if(i){var w=fe(i,n);w>-1&&(r[t]=i.slice(0,w).concat(i.slice(w+1)))}}}function Re(e,t){var n=gt(e,t);if(!n.length)return;for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function je(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Re(e,n||t.type,e,t),ie(t)||t.codemirrorIgnore}function ge(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)fe(n,t[r])==-1&&n.push(t[r])}function de(e,t){return gt(e,t).length>0}function pe(e){e.prototype.on=function(t,n){we(this,t,n)},e.prototype.off=function(t,n){lt(this,t,n)}}function ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ie(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function se(e){ee(e),te(e)}function ue(e){return e.target||e.srcElement}function Se(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),c&&e.ctrlKey&&t==1&&(t=3),t}var ke=function(){if(z&&B<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Je;function Qe(e){if(Je==null){var t=a("span","\u200B");s(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Je=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&B<8))}var n=Je?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var bt;function Dt(e){if(bt!=null)return bt;var t=s(e,document.createTextNode("A\u062EA")),n=v(t,0,1).getBoundingClientRect(),r=v(t,1,2).getBoundingClientRect();return p(e),!n||n.left==n.right?!1:bt=r.right-n.right<3}var Ze=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf(`
|
|
`,t);i==-1&&(i=e.length);var w=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),F=w.indexOf("\r");F!=-1?(n.push(w.slice(0,F)),t+=F+1):(n.push(w),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},ut=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(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Ft=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Ct=null;function jt(e){if(Ct!=null)return Ct;var t=s(e,a("span","x")),n=t.getBoundingClientRect(),r=v(t,0,1).getBoundingClientRect();return Ct=Math.abs(n.left-r.left)>1}var $t={},Lt={};function Qt(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),$t[e]=t}function Zt(e,t){Lt[e]=t}function ft(e){if(typeof e=="string"&&Lt.hasOwnProperty(e))e=Lt[e];else if(e&&typeof e.name=="string"&&Lt.hasOwnProperty(e.name)){var t=Lt[e.name];typeof t=="string"&&(t={name:t}),e=Ve(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return ft("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return ft("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Xt(e,t){t=ft(t);var n=$t[t.name];if(!n)return Xt(e,"text/plain");var r=n(e,t);if(zt.hasOwnProperty(t.name)){var i=zt[t.name];for(var w in i){if(!i.hasOwnProperty(w))continue;r.hasOwnProperty(w)&&(r["_"+w]=r[w]),r[w]=i[w]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var F in t.modeProps)r[F]=t.modeProps[F];return r}var zt={};function Gt(e,t){var n=zt.hasOwnProperty(e)?zt[e]:zt[e]={};W(t,n)}function Ut(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function Mt(e,t){for(var n;e.innerMode&&!(n=e.innerMode(t),!n||n.mode==e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function St(e,t,n){return e.startState?e.startState(t,n):!0}var tt=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};tt.prototype.eol=function(){return this.pos>=this.string.length},tt.prototype.sol=function(){return this.pos==this.lineStart},tt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},tt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},tt.prototype.eat=function(e){var t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e.test?e.test(t):e(t)),n)return++this.pos,t},tt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},tt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},tt.prototype.skipToEnd=function(){this.pos=this.string.length},tt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},tt.prototype.backUp=function(e){this.pos-=e},tt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},tt.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},tt.prototype.match=function(e,t,n){if(typeof e=="string"){var r=function(F){return n?F.toLowerCase():F},i=this.string.substr(this.pos,e.length);if(r(i)==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)}},tt.prototype.current=function(){return this.string.slice(this.start,this.pos)},tt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},tt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},tt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function Fe(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 n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],w=i.chunkSize();if(t<w){n=i;break}t-=w}return n.lines[t]}function nr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(w){var F=w.text;i==n.line&&(F=F.slice(0,n.ch)),i==t.line&&(F=F.slice(t.ch)),r.push(F),++i}),r}function Vt(e,t,n){var r=[];return e.iter(t,n,function(i){r.push(i.text)}),r}function qt(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Wt(e){if(e.parent==null)return null;for(var t=e.parent,n=fe(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;!(r.children[i]==t);++i)n+=r.children[i].chunkSize();return n+t.first}function Tr(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],w=i.height;if(t<w){e=i;continue e}t-=w,n+=i.chunkSize()}return n}while(!e.lines);for(var F=0;F<e.lines.length;++F){var K=e.lines[F],Y=K.height;if(t<Y)break;t-=Y}return n+F}function ir(e,t){return t>=e.first&&t<e.first+e.size}function Rt(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Ie(e,t,n){if(n===void 0&&(n=null),!(this instanceof Ie))return new Ie(e,t,n);this.line=e,this.ch=t,this.sticky=n}function xt(e,t){return e.line-t.line||e.ch-t.ch}function Dr(e,t){return e.sticky==t.sticky&&xt(e,t)==0}function un(e){return Ie(e.line,e.ch)}function dn(e,t){return xt(e,t)<0?t:e}function xr(e,t){return xt(e,t)<0?e:t}function U(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function u(e,t){if(t.line<e.first)return Ie(e.first,0);var n=e.first+e.size-1;return t.line>n?Ie(n,Fe(e,n).text.length):g(t,Fe(e,t.line).text.length)}function g(e,t){var n=e.ch;return n==null||n>t?Ie(e.line,t):n<0?Ie(e.line,0):e}function P(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=u(e,t[r]);return n}var J=function(e,t){this.state=e,this.lookAhead=t},j=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};j.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},j.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}},j.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},j.fromSaved=function(e,t,n){return t instanceof J?new j(e,Ut(e.mode,t.state),n,t.lookAhead):new j(e,Ut(e.mode,t),n)},j.prototype.save=function(e){var t=e!==!1?Ut(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new J(t,this.maxLookAhead):t};function ce(e,t,n,r){var i=[e.state.modeGen],w={};Mr(e,t.text,e.doc.mode,n,function(Z,le){return i.push(Z,le)},w,r);for(var F=n.state,K=function(Z){n.baseTokens=i;var le=e.state.overlays[Z],he=1,xe=0;n.state=!0,Mr(e,t.text,le.mode,n,function(ye,Oe){for(var We=he;xe<ye;){var Ye=i[he];Ye>ye&&i.splice(he,1,ye,i[he+1],Ye),he+=2,xe=Math.min(ye,Ye)}if(!Oe)return;if(le.opaque)i.splice(We,he-We,ye,"overlay "+Oe),he=We+2;else for(;We<he;We+=2){var ot=i[We+1];i[We+1]=(ot?ot+" ":"")+"overlay "+Oe}},w),n.state=F,n.baseTokens=null,n.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:i,classes:w.bgClass||w.textClass?w:null}}function Ne(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=qe(e,Wt(t)),i=t.text.length>e.options.maxHighlightLength&&Ut(e.doc.mode,r.state),w=ce(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=w.styles,w.classes?t.styleClasses=w.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function qe(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new j(r,!0,t);var w=Ir(e,t,n),F=w>r.first&&Fe(r,w-1).stateAfter,K=F?j.fromSaved(r,F,w):new j(r,St(r.mode),w);return r.iter(w,t,function(Y){Tt(e,Y.text,K);var Z=K.line;Y.stateAfter=Z==t-1||Z%5==0||Z>=i.viewFrom&&Z<i.viewTo?K.save():null,K.nextLine()}),n&&(r.modeFrontier=K.line),K}function Tt(e,t,n,r){var i=e.doc.mode,w=new tt(t,e.options.tabSize,n);for(w.start=w.pos=r||0,t==""&&Ue(i,n.state);!w.eol();)Pt(i,w,n.state),w.start=w.pos}function Ue(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=Mt(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function Pt(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=Mt(e,n).mode);var w=e.token(t,n);if(t.pos>t.start)return w}throw new Error("Mode "+e.name+" failed to advance stream.")}var er=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function fr(e,t,n,r){var i=e.doc,w=i.mode,F;t=u(i,t);var K=Fe(i,t.line),Y=qe(e,t.line,n),Z=new tt(K.text,e.options.tabSize,Y),le;for(r&&(le=[]);(r||Z.pos<t.ch)&&!Z.eol();)Z.start=Z.pos,F=Pt(w,Z,Y.state),r&&le.push(new er(Z,F,Ut(i.mode,Y.state)));return r?le:new er(Z,F,Y.state)}function Gr(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function Mr(e,t,n,r,i,w,F){var K=n.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,Z=null,le=new tt(t,e.options.tabSize,r),he,xe=e.options.addModeClass&&[null];for(t==""&&Gr(Ue(n,r.state),w);!le.eol();){if(le.pos>e.options.maxHighlightLength?(K=!1,F&&Tt(e,t,r,le.pos),le.pos=t.length,he=null):he=Gr(Pt(n,le,r.state,xe),w),xe){var ye=xe[0].name;ye&&(he="m-"+(he?ye+" "+he:ye))}if(!K||Z!=he){for(;Y<le.start;)Y=Math.min(le.start,Y+5e3),i(Y,Z);Z=he}le.start=le.pos}for(;Y<le.pos;){var Oe=Math.min(le.pos,Y+5e3);i(Oe,Z),Y=Oe}}function Ir(e,t,n){for(var r,i,w=e.doc,F=n?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>F;--K){if(K<=w.first)return w.first;var Y=Fe(w,K-1),Z=Y.stateAfter;if(Z&&(!n||K+(Z instanceof J?Z.lookAhead:0)<=w.modeFrontier))return K;var le=q(Y.text,null,e.options.tabSize);(i==null||r>le)&&(i=K-1,r=le)}return i}function cn(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var n=e.first,r=t-1;r>n;r--){var i=Fe(e,r).stateAfter;if(i&&(!(i instanceof J)||r+i.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}var Sn=!1,wr=!1;function nt(){Sn=!0}function be(){wr=!0}function Ke(e,t,n){this.marker=e,this.from=t,this.to=n}function wt(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function mt(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function vt(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function It(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var w=e[i],F=w.marker,K=w.from==null||(F.inclusiveLeft?w.from<=t:w.from<t);if(K||w.from==t&&F.type=="bookmark"&&(!n||!w.marker.insertLeft)){var Y=w.to==null||(F.inclusiveRight?w.to>=t:w.to>t);(r||(r=[])).push(new Ke(F,w.from,Y?null:w.to))}}return r}function gr(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var w=e[i],F=w.marker,K=w.to==null||(F.inclusiveRight?w.to>=t:w.to>t);if(K||w.from==t&&F.type=="bookmark"&&(!n||w.marker.insertLeft)){var Y=w.from==null||(F.inclusiveLeft?w.from<=t:w.from<t);(r||(r=[])).push(new Ke(F,Y?null:w.from-t,w.to==null?null:w.to-t))}}return r}function cr(e,t){if(t.full)return null;var n=ir(e,t.from.line)&&Fe(e,t.from.line).markedSpans,r=ir(e,t.to.line)&&Fe(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,w=t.to.ch,F=xt(t.from,t.to)==0,K=It(n,i,F),Y=gr(r,w,F),Z=t.text.length==1,le=Ae(t.text).length+(Z?i:0);if(K)for(var he=0;he<K.length;++he){var xe=K[he];if(xe.to==null){var ye=wt(Y,xe.marker);ye?Z&&(xe.to=ye.to==null?null:ye.to+le):xe.to=i}}if(Y)for(var Oe=0;Oe<Y.length;++Oe){var We=Y[Oe];if(We.to!=null&&(We.to+=le),We.from==null){var Ye=wt(K,We.marker);Ye||(We.from=le,Z&&(K||(K=[])).push(We))}else We.from+=le,Z&&(K||(K=[])).push(We)}K&&(K=hr(K)),Y&&Y!=K&&(Y=hr(Y));var ot=[K];if(!Z){var yt=t.text.length-2,st;if(yt>0&&K)for(var _t=0;_t<K.length;++_t)K[_t].to==null&&(st||(st=[])).push(new Ke(K[_t].marker,null,null));for(var Bt=0;Bt<yt;++Bt)ot.push(st);ot.push(Y)}return ot}function hr(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Lr(e,t,n){var r=null;if(e.iter(t.line,n.line+1,function(ye){if(ye.markedSpans)for(var Oe=0;Oe<ye.markedSpans.length;++Oe){var We=ye.markedSpans[Oe].marker;We.readOnly&&(!r||fe(r,We)==-1)&&(r||(r=[])).push(We)}}),!r)return null;for(var i=[{from:t,to:n}],w=0;w<r.length;++w)for(var F=r[w],K=F.find(0),Y=0;Y<i.length;++Y){var Z=i[Y];if(xt(Z.to,K.from)<0||xt(Z.from,K.to)>0)continue;var le=[Y,1],he=xt(Z.from,K.from),xe=xt(Z.to,K.to);(he<0||!F.inclusiveLeft&&!he)&&le.push({from:Z.from,to:K.from}),(xe>0||!F.inclusiveRight&&!xe)&&le.push({from:K.to,to:Z.to}),i.splice.apply(i,le),Y+=le.length-3}return i}function Sr(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function Wr(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function or(e){return e.inclusiveLeft?-1:0}function tr(e){return e.inclusiveRight?1:0}function pr(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),w=xt(r.from,i.from)||or(e)-or(t);if(w)return-w;var F=xt(r.to,i.to)||tr(e)-tr(t);return F||t.id-e.id}function Ht(e,t){var n=wr&&e.markedSpans,r;if(n)for(var i=void 0,w=0;w<n.length;++w)i=n[w],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||pr(r,i.marker)<0)&&(r=i.marker);return r}function br(e){return Ht(e,!0)}function lr(e){return Ht(e,!1)}function vn(e,t){var n=wr&&e.markedSpans,r;if(n)for(var i=0;i<n.length;++i){var w=n[i];w.marker.collapsed&&(w.from==null||w.from<t)&&(w.to==null||w.to>t)&&(!r||pr(r,w.marker)<0)&&(r=w.marker)}return r}function Nr(e,t,n,r,i){var w=Fe(e,t),F=wr&&w.markedSpans;if(F)for(var K=0;K<F.length;++K){var Y=F[K];if(!Y.marker.collapsed)continue;var Z=Y.marker.find(0),le=xt(Z.from,n)||or(Y.marker)-or(i),he=xt(Z.to,r)||tr(Y.marker)-tr(i);if(le>=0&&he<=0||le<=0&&he>=0)continue;if(le<=0&&(Y.marker.inclusiveRight&&i.inclusiveLeft?xt(Z.to,n)>=0:xt(Z.to,n)>0)||le>=0&&(Y.marker.inclusiveRight&&i.inclusiveLeft?xt(Z.from,r)<=0:xt(Z.from,r)<0))return!0}}function Yr(e){for(var t;t=br(e);)e=t.find(-1,!0).line;return e}function Yn(e){for(var t;t=lr(e);)e=t.find(1,!0).line;return e}function An(e){for(var t,n;t=lr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function hi(e,t){var n=Fe(e,t),r=Yr(n);return n==r?t:Wt(r)}function Ln(e,t){if(t>e.lastLine())return t;var n=Fe(e,t),r;if(!yn(e,n))return t;for(;r=lr(n);)n=r.find(1,!0).line;return Wt(n)+1}function yn(e,t){var n=wr&&t.markedSpans;if(n)for(var r=void 0,i=0;i<n.length;++i){if(r=n[i],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&fi(e,t,r))return!0}}function fi(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return fi(e,r.line,wt(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i=void 0,w=0;w<t.markedSpans.length;++w)if(i=t.markedSpans[w],i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&fi(e,t,i))return!0}function fn(e){e=Yr(e);for(var t=0,n=e.parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var w=n.parent;w;n=w,w=n.parent)for(var F=0;F<w.children.length;++F){var K=w.children[F];if(K==n)break;t+=K.height}return t}function pi(e){if(e.height==0)return 0;for(var t=e.text.length,n,r=e;n=br(r);){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}for(r=e;n=lr(r);){var w=n.find(0,!0);t-=r.text.length-w.from.ch,r=w.to.line,t+=r.text.length-w.to.ch}return t}function ji(e){var t=e.display,n=e.doc;t.maxLine=Fe(n,n.first),t.maxLineLength=pi(t.maxLine),t.maxLineChanged=!0,n.iter(function(r){var i=pi(r);i>t.maxLineLength&&(t.maxLineLength=i,t.maxLine=r)})}var Un=function(e,t,n){this.text=e,Wr(this,t),this.height=n?n(this):1};Un.prototype.lineNo=function(){return Wt(this)},pe(Un);function ua(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Sr(e),Wr(e,n);var i=r?r(e):1;i!=e.height&&qt(e,i)}function kt(e){e.parent=null,Sr(e)}var Kt={},Nt={};function Jt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Nt:Kt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function sr(e,t){var n=b("span",null,null,O?"padding-right: .1px":null),r={pre:b("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var w=i?t.rest[i-1]:t.line,F=void 0;r.pos=0,r.addToken=ar,Dt(e.display.measure)&&(F=ct(w,e.doc.direction))&&(r.addToken=Qr(r.addToken,F)),r.map=[];var K=t!=e.display.externalMeasured&&Wt(w);Cn(w,r,Ne(e,w,K)),w.styleClasses&&(w.styleClasses.bgClass&&(r.bgClass=V(w.styleClasses.bgClass,r.bgClass||"")),w.styleClasses.textClass&&(r.textClass=V(w.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(Qe(e.display.measure))),i==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(O){var Y=r.content.lastChild;(/\bcm-tab\b/.test(Y.className)||Y.querySelector&&Y.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Re(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=V(r.pre.className,r.textClass||"")),r}function vr(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function ar(e,t,n,r,i,w,F){if(!t)return;var K=e.splitSpaces?Pr(t,e.trailingSpace):t,Y=e.cm.state.specialChars,Z=!1,le;if(!Y.test(t))e.col+=t.length,le=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,le),z&&B<9&&(Z=!0),e.pos+=t.length;else{le=document.createDocumentFragment();for(var he=0;;){Y.lastIndex=he;var xe=Y.exec(t),ye=xe?xe.index-he:t.length-he;if(ye){var Oe=document.createTextNode(K.slice(he,he+ye));z&&B<9?le.appendChild(a("span",[Oe])):le.appendChild(Oe),e.map.push(e.pos,e.pos+ye,Oe),e.col+=ye,e.pos+=ye}if(!xe)break;he+=ye+1;var We=void 0;if(xe[0]==" "){var Ye=e.cm.options.tabSize,ot=Ye-e.col%Ye;We=le.appendChild(a("span",ne(ot),"cm-tab")),We.setAttribute("role","presentation"),We.setAttribute("cm-text"," "),e.col+=ot}else xe[0]=="\r"||xe[0]==`
|
|
`?(We=le.appendChild(a("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),We.setAttribute("cm-text",xe[0]),e.col+=1):(We=e.cm.options.specialCharPlaceholder(xe[0]),We.setAttribute("cm-text",xe[0]),z&&B<9?le.appendChild(a("span",[We])):le.appendChild(We),e.col+=1);e.map.push(e.pos,e.pos+1,We),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,n||r||i||Z||w||F){var yt=n||"";r&&(yt+=r),i&&(yt+=i);var st=a("span",[le],yt,w);if(F)for(var _t in F)F.hasOwnProperty(_t)&&_t!="style"&&_t!="class"&&st.setAttribute(_t,F[_t]);return e.content.appendChild(st)}e.content.appendChild(le)}function Pr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var w=e.charAt(i);w==" "&&n&&(i==e.length-1||e.charCodeAt(i+1)==32)&&(w="\xA0"),r+=w,n=w==" "}return r}function Qr(e,t){return function(n,r,i,w,F,K,Y){i=i?i+" cm-force-border":"cm-force-border";for(var Z=n.pos,le=Z+r.length;;){for(var he=void 0,xe=0;xe<t.length&&!(he=t[xe],he.to>Z&&he.from<=Z);xe++);if(he.to>=le)return e(n,r,i,w,F,K,Y);e(n,r.slice(0,he.to-Z),i,w,null,K,Y),w=null,r=r.slice(he.to-Z),Z=he.to}}}function rr(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function Cn(e,t,n){var r=e.markedSpans,i=e.text,w=0;if(!r){for(var F=1;F<n.length;F+=2)t.addToken(t,i.slice(w,w=n[F]),Jt(n[F+1],t.cm.options));return}for(var K=i.length,Y=0,Z=1,le="",he,xe,ye=0,Oe,We,Ye,ot,yt;;){if(ye==Y){Oe=We=Ye=xe="",yt=null,ot=null,ye=Infinity;for(var st=[],_t=void 0,Bt=0;Bt<r.length;++Bt){var Ot=r[Bt],Yt=Ot.marker;if(Yt.type=="bookmark"&&Ot.from==Y&&Yt.widgetNode)st.push(Yt);else if(Ot.from<=Y&&(Ot.to==null||Ot.to>Y||Yt.collapsed&&Ot.to==Y&&Ot.from==Y)){if(Ot.to!=null&&Ot.to!=Y&&ye>Ot.to&&(ye=Ot.to,We=""),Yt.className&&(Oe+=" "+Yt.className),Yt.css&&(xe=(xe?xe+";":"")+Yt.css),Yt.startStyle&&Ot.from==Y&&(Ye+=" "+Yt.startStyle),Yt.endStyle&&Ot.to==ye&&(_t||(_t=[])).push(Yt.endStyle,Ot.to),Yt.title&&((yt||(yt={})).title=Yt.title),Yt.attributes)for(var yr in Yt.attributes)(yt||(yt={}))[yr]=Yt.attributes[yr];Yt.collapsed&&(!ot||pr(ot.marker,Yt)<0)&&(ot=Ot)}else Ot.from>Y&&ye>Ot.from&&(ye=Ot.from)}if(_t)for(var Fr=0;Fr<_t.length;Fr+=2)_t[Fr+1]==ye&&(We+=" "+_t[Fr]);if(!ot||ot.from==Y)for(var Cr=0;Cr<st.length;++Cr)rr(t,0,st[Cr]);if(ot&&(ot.from||0)==Y){if(rr(t,(ot.to==null?K+1:ot.to)-Y,ot.marker,ot.from==null),ot.to==null)return;ot.to==Y&&(ot=!1)}}if(Y>=K)break;for(var on=Math.min(K,ye);;){if(le){var tn=Y+le.length;if(!ot){var Rr=tn>on?le.slice(0,on-Y):le;t.addToken(t,Rr,he?he+Oe:Oe,Ye,Y+Rr.length==ye?We:"",xe,yt)}if(tn>=on){le=le.slice(on-Y),Y=on;break}Y=tn,Ye=""}le=i.slice(w,w=n[Z++]),he=Jt(n[Z++],t.cm.options)}}}function ur(e,t,n){this.line=t,this.rest=An(t),this.size=this.rest?Wt(Ae(this.rest))-n+1:1,this.node=this.text=null,this.hidden=yn(e,t)}function Zr(e,t,n){for(var r=[],i,w=t;w<n;w=i){var F=new ur(e.doc,Fe(e.doc,w),w);i=w+F.size,r.push(F)}return r}var Kr=null;function hn(e){Kr?Kr.ops.push(e):e.ownsGroup=Kr={ops:[e],delayedCallbacks:[]}}function ks(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}function Ds(e,t){var n=e.ownsGroup;if(!n)return;try{ks(n)}finally{Kr=null,t(n)}}var mi=null;function Hr(e,t){var n=gt(e,t);if(!n.length)return;var r=Array.prototype.slice.call(arguments,2),i;Kr?i=Kr.delayedCallbacks:mi?i=mi:(i=mi=[],setTimeout(Ps,0));for(var w=function(K){i.push(function(){return n[K].apply(null,r)})},F=0;F<n.length;++F)w(F)}function Ps(){var e=mi;mi=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,n,r){for(var i=0;i<t.changes.length;i++){var w=t.changes[i];w=="text"?Ms(e,t):w=="gutter"?Ja(e,t,n,r):w=="class"?da(e,t):w=="widget"&&Is(e,t,r)}t.changes=null}function gi(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),z&&B<8&&(e.node.style.zIndex=2)),e.node}function Os(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=gi(t);t.background=r.insertBefore(a("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):sr(e,t)}function Ms(e,t){var n=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)):n&&(t.text.className=n)}function da(e,t){Os(e,t),t.line.wrapClass?gi(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function Ja(e,t,n,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 i=gi(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),i.insertBefore(t.gutterBackground,t.text)}var w=t.line.gutterMarkers;if(e.options.lineNumbers||w){var F=gi(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),F.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!w||!w["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",Rt(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),w)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Z=e.display.gutterSpecs[Y].className,le=w.hasOwnProperty(Z)&&w[Z];le&&K.appendChild(a("div",[le],"CodeMirror-gutter-elt","left: "+r.gutterLeft[Z]+"px; width: "+r.gutterWidth[Z]+"px"))}}}function Is(e,t,n){t.alignable&&(t.alignable=null);for(var r=x("CodeMirror-linewidget"),i=t.node.firstChild,w=void 0;i;i=w)w=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);Qa(e,t,n)}function Ns(e,t,n,r){var i=$a(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),da(e,t),Ja(e,t,n,r),Qa(e,t,r),t.node}function Qa(e,t,n){if(Za(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)Za(e,t.rest[r],t,n,!1)}function Za(e,t,n,r,i){if(!t.widgets)return;for(var w=gi(n),F=0,K=t.widgets;F<K.length;++F){var Y=K[F],Z=a("div",[Y.node],"CodeMirror-linewidget"+(Y.className?" "+Y.className:""));Y.handleMouseEvents||Z.setAttribute("cm-ignore-events","true"),Us(Y,Z,n,r),e.display.input.setUneditable(Z),i&&Y.above?w.insertBefore(Z,n.gutter||n.text):w.appendChild(Z),Hr(Y,"redraw")}}function Us(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function vi(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!S(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),s(t.display.measure,a("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function _n(e,t){for(var n=ue(t);n!=e.wrapper;n=n.parentNode)if(!n||n.nodeType==1&&n.getAttribute("cm-ignore-events")=="true"||n.parentNode==e.sizer&&n!=e.mover)return!0}function Wi(e){return e.lineSpace.offsetTop}function ca(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=s(e.measure,a("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function bn(e){return ve-e.display.nativeBarWidth}function Bn(e){return e.display.scroller.clientWidth-bn(e)-e.display.barWidth}function ha(e){return e.display.scroller.clientHeight-bn(e)-e.display.barHeight}function Bs(e,t,n){var r=e.options.lineWrapping,i=r&&Bn(e);if(!t.measure.heights||r&&t.measure.width!=i){var w=t.measure.heights=[];if(r){t.measure.width=i;for(var F=t.text.firstChild.getClientRects(),K=0;K<F.length-1;K++){var Y=F[K],Z=F[K+1];Math.abs(Y.bottom-Z.bottom)>2&&w.push((Y.bottom+Z.top)/2-n.top)}}w.push(n.bottom-n.top)}}function eo(e,t,n){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 i=0;i<e.rest.length;i++)if(Wt(e.rest[i])>n)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Fs(e,t){t=Yr(t);var n=Wt(t),r=e.display.externalMeasured=new ur(e.doc,t,n);r.lineN=n;var i=r.built=sr(e,r);return r.text=i.pre,s(e.display.lineMeasure,i.pre),r}function to(e,t,n,r){return En(e,$n(e,t),n,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Wn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function $n(e,t){var n=Wt(t),r=fa(e,n);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,n,ba(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var i=eo(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function En(e,t,n,r,i){t.before&&(n=-1);var w=n+(r||""),F;return t.cache.hasOwnProperty(w)?F=t.cache[w]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Bs(e,t.view,t.rect),t.hasHeights=!0),F=Ws(e,t,n,r),F.bogus||(t.cache[w]=F)),{left:F.left,right:F.right,top:i?F.rtop:F.top,bottom:i?F.rbottom:F.bottom}}var ro={left:0,right:0,top:0,bottom:0};function no(e,t,n){for(var r,i,w,F,K,Y,Z=0;Z<e.length;Z+=3)if(K=e[Z],Y=e[Z+1],t<K?(i=0,w=1,F="left"):t<Y?(i=t-K,w=i+1):(Z==e.length-3||t==Y&&e[Z+3]>t)&&(w=Y-K,i=w-1,t>=Y&&(F="right")),i!=null){if(r=e[Z+2],K==Y&&n==(r.insertLeft?"left":"right")&&(F=n),n=="left"&&i==0)for(;Z&&e[Z-2]==e[Z-3]&&e[Z-1].insertLeft;)r=e[(Z-=3)+2],F="left";if(n=="right"&&i==Y-K)for(;Z<e.length-3&&e[Z+3]==e[Z+4]&&!e[Z+5].insertLeft;)r=e[(Z+=3)+2],F="right";break}return{node:r,start:i,end:w,collapse:F,coverStart:K,coverEnd:Y}}function js(e,t){var n=ro;if(t=="left")for(var r=0;r<e.length&&!((n=e[r]).left!=n.right);r++);else for(var i=e.length-1;i>=0&&!((n=e[i]).left!=n.right);i--);return n}function Ws(e,t,n,r){var i=no(t.map,n,r),w=i.node,F=i.start,K=i.end,Y=i.collapse,Z;if(w.nodeType==3){for(var le=0;le<4;le++){for(;F&&Be(t.line.text.charAt(i.coverStart+F));)--F;for(;i.coverStart+K<i.coverEnd&&Be(t.line.text.charAt(i.coverStart+K));)++K;if(z&&B<9&&F==0&&K==i.coverEnd-i.coverStart?Z=w.parentNode.getBoundingClientRect():Z=js(v(w,F,K).getClientRects(),r),Z.left||Z.right||F==0)break;K=F,F=F-1,Y="right"}z&&B<11&&(Z=Hs(e.display.measure,Z))}else{F>0&&(Y=r="right");var he;e.options.lineWrapping&&(he=w.getClientRects()).length>1?Z=he[r=="right"?he.length-1:0]:Z=w.getBoundingClientRect()}if(z&&B<9&&!F&&(!Z||!Z.left&&!Z.right)){var xe=w.parentNode.getClientRects()[0];xe?Z={left:xe.left,right:xe.left+Qn(e.display),top:xe.top,bottom:xe.bottom}:Z=ro}for(var ye=Z.top-t.rect.top,Oe=Z.bottom-t.rect.top,We=(ye+Oe)/2,Ye=t.view.measure.heights,ot=0;ot<Ye.length-1&&!(We<Ye[ot]);ot++);var yt=ot?Ye[ot-1]:0,st=Ye[ot],_t={left:(Y=="right"?Z.right:Z.left)-t.rect.left,right:(Y=="left"?Z.left:Z.right)-t.rect.left,top:yt,bottom:st};return!Z.left&&!Z.right&&(_t.bogus=!0),e.options.singleCursorHeightPerLine||(_t.rtop=ye,_t.rbottom=Oe),_t}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!jt(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function io(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,p(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)io(e.display.view[t])}function yi(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 E&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return E&&h?-(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 n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=vi(e.widgets[n]));return t}function Hi(e,t,n,r,i){if(!i){var w=pa(t);n.top+=w,n.bottom+=w}if(r=="line")return n;r||(r="local");var F=fn(t);if(r=="local"?F+=Wi(e.display):F-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();F+=K.top+(r=="window"?0:so());var Y=K.left+(r=="window"?0:oo());n.left+=Y,n.right+=Y}return n.top+=F,n.bottom+=F,n}function lo(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=oo(),i-=so();else if(n=="local"||!n){var w=e.display.sizer.getBoundingClientRect();r+=w.left,i+=w.top}var F=e.display.lineSpace.getBoundingClientRect();return{left:r-F.left,top:i-F.top}}function ma(e,t,n,r,i){return r||(r=Fe(e.doc,t.line)),Hi(e,r,to(e,r,t.ch,i),n)}function pn(e,t,n,r,i,w){r=r||Fe(e.doc,t.line),i||(i=$n(e,r));function F(Oe,We){var Ye=En(e,i,Oe,We?"right":"left",w);return We?Ye.left=Ye.right:Ye.right=Ye.left,Hi(e,r,Ye,n)}var K=ct(r,e.doc.direction),Y=t.ch,Z=t.sticky;if(Y>=r.text.length?(Y=r.text.length,Z="before"):Y<=0&&(Y=0,Z="after"),!K)return F(Z=="before"?Y-1:Y,Z=="before");function le(Oe,We,Ye){var ot=K[We],yt=ot.level==1;return F(Ye?Oe-1:Oe,yt!=Ye)}var he=at(K,Y,Z),xe=et,ye=le(Y,he,Z=="before");return xe!=null&&(ye.other=le(Y,xe,Z!="before")),ye}function uo(e,t){var n=0;t=u(e.doc,t),e.options.lineWrapping||(n=Qn(e.display)*t.ch);var r=Fe(e.doc,t.line),i=fn(r)+Wi(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function ga(e,t,n,r,i){var w=Ie(e,t,n);return w.xRel=i,r&&(w.outside=r),w}function va(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,n<0)return ga(r.first,0,null,-1,-1);var i=Tr(r,n),w=r.first+r.size-1;if(i>w)return ga(r.first+r.size-1,Fe(r,w).text.length,null,1,1);t<0&&(t=0);for(var F=Fe(r,i);;){var K=zs(e,F,i,t,n),Y=vn(F,K.ch+(K.xRel>0||K.outside>0?1:0));if(!Y)return K;var Z=Y.find(1);if(Z.line==i)return Z;F=Fe(r,i=Z.line)}}function co(e,t,n,r){r-=pa(t);var i=t.text.length,w=pt(function(F){return En(e,n,F-1).bottom<=r},i,0);return i=pt(function(F){return En(e,n,F).top>r},w,i),{begin:w,end:i}}function ho(e,t,n,r){n||(n=$n(e,t));var i=Hi(e,t,En(e,n,r),"line").top;return co(e,t,n,i)}function ya(e,t,n,r){return e.bottom<=n?!1:e.top>n?!0:(r?e.left:e.right)>t}function zs(e,t,n,r,i){i-=fn(t);var w=$n(e,t),F=pa(t),K=0,Y=t.text.length,Z=!0,le=ct(t,e.doc.direction);if(le){var he=(e.options.lineWrapping?Ks:Gs)(e,t,n,w,le,r,i);Z=he.level!=1,K=Z?he.from:he.to-1,Y=Z?he.to:he.from-1}var xe=null,ye=null,Oe=pt(function(Bt){var Ot=En(e,w,Bt);return Ot.top+=F,Ot.bottom+=F,ya(Ot,r,i,!1)?(Ot.top<=i&&Ot.left<=r&&(xe=Bt,ye=Ot),!0):!1},K,Y),We,Ye,ot=!1;if(ye){var yt=r-ye.left<ye.right-r,st=yt==Z;Oe=xe+(st?0:1),Ye=st?"after":"before",We=yt?ye.left:ye.right}else{!Z&&(Oe==Y||Oe==K)&&Oe++,Ye=Oe==0?"after":Oe==t.text.length?"before":En(e,w,Oe-(Z?1:0)).bottom+F<=i==Z?"after":"before";var _t=pn(e,Ie(n,Oe,Ye),"line",t,w);We=_t.left,ot=i<_t.top?-1:i>=_t.bottom?1:0}return Oe=Pe(t.text,Oe,1),ga(n,Oe,Ye,ot,r-We)}function Gs(e,t,n,r,i,w,F){var K=pt(function(he){var xe=i[he],ye=xe.level!=1;return ya(pn(e,Ie(n,ye?xe.to:xe.from,ye?"before":"after"),"line",t,r),w,F,!0)},0,i.length-1),Y=i[K];if(K>0){var Z=Y.level!=1,le=pn(e,Ie(n,Z?Y.from:Y.to,Z?"after":"before"),"line",t,r);ya(le,w,F,!0)&&le.top>F&&(Y=i[K-1])}return Y}function Ks(e,t,n,r,i,w,F){var K=co(e,t,r,F),Y=K.begin,Z=K.end;/\s/.test(t.text.charAt(Z-1))&&Z--;for(var le=null,he=null,xe=0;xe<i.length;xe++){var ye=i[xe];if(ye.from>=Z||ye.to<=Y)continue;var Oe=ye.level!=1,We=En(e,r,Oe?Math.min(Z,ye.to)-1:Math.max(Y,ye.from)).right,Ye=We<w?w-We+1e9:We-w;(!le||he>Ye)&&(le=ye,he=Ye)}return le||(le=i[i.length-1]),le.from<Y&&(le={from:Y,to:le.to,level:le.level}),le.to>Z&&(le={from:le.from,to:Z,level:le.level}),le}var Fn;function Jn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Fn==null){Fn=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Fn.appendChild(document.createTextNode("x")),Fn.appendChild(a("br"));Fn.appendChild(document.createTextNode("x"))}s(e.measure,Fn);var n=Fn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),p(e.measure),n||1}function Qn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),n=a("pre",[t],"CodeMirror-line-like");s(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function ba(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,w=t.gutters.firstChild,F=0;w;w=w.nextSibling,++F){var K=e.display.gutterSpecs[F].className;n[K]=w.offsetLeft+w.clientLeft+i,r[K]=w.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=Jn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Qn(e.display)-3);return function(i){if(yn(e.doc,i))return 0;var w=0;if(i.widgets)for(var F=0;F<i.widgets.length;F++)i.widgets[F].height&&(w+=i.widgets[F].height);return n?w+(Math.ceil(i.text.length/r)||1)*t:w+t}}function xa(e){var t=e.doc,n=fo(e);t.iter(function(r){var i=n(r);i!=r.height&&qt(r,i)})}function jn(e,t,n,r){var i=e.display;if(!n&&ue(t).getAttribute("cm-not-content")=="true")return null;var w,F,K=i.lineSpace.getBoundingClientRect();try{w=t.clientX-K.left,F=t.clientY-K.top}catch(he){return null}var Y=va(e,w,F),Z;if(r&&Y.xRel>0&&(Z=Fe(e.doc,Y.line).text).length==Y.ch){var le=q(Z,Z.length,e.options.tabSize)-Z.length;Y=Ie(Y.line,Math.max(0,Math.round((w-qa(e.display).left)/Qn(e.display))-le))}return Y}function Wn(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var n=e.display.view,r=0;r<n.length;r++)if(t-=n[r].size,t<0)return r}function qr(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)wr&&hi(e.doc,t)<i.viewTo&&kn(e);else if(n<=i.viewFrom)wr&&Ln(e.doc,n+r)>i.viewFrom?kn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)kn(e);else if(t<=i.viewFrom){var w=zi(e,n,n+r,1);w?(i.view=i.view.slice(w.index),i.viewFrom=w.lineN,i.viewTo+=r):kn(e)}else if(n>=i.viewTo){var F=zi(e,t,t,-1);F?(i.view=i.view.slice(0,F.index),i.viewTo=F.lineN):kn(e)}else{var K=zi(e,t,t,-1),Y=zi(e,n,n+r,1);K&&Y?(i.view=i.view.slice(0,K.index).concat(Zr(e,K.lineN,Y.lineN)).concat(i.view.slice(Y.index)),i.viewTo+=r):kn(e)}var Z=i.externalMeasured;Z&&(n<Z.lineN?Z.lineN+=r:t<Z.lineN+Z.size&&(i.externalMeasured=null))}function Rn(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var w=r.view[Wn(e,t)];if(w.node==null)return;var F=w.changes||(w.changes=[]);fe(F,n)==-1&&F.push(n)}function kn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zi(e,t,n,r){var i=Wn(e,t),w,F=e.display.view;if(!wr||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var K=e.display.viewFrom,Y=0;Y<i;Y++)K+=F[Y].size;if(K!=t){if(r>0){if(i==F.length-1)return null;w=K+F[i].size-t,i++}else w=K-t;t+=w,n+=w}for(;hi(e.doc,n)!=n;){if(i==(r<0?0:F.length-1))return null;n+=r*F[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function Vs(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Zr(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Zr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Wn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Zr(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Wn(e,n)))),r.viewTo=n}function po(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function bi(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),w=r.selection=document.createDocumentFragment(),F=0;F<n.sel.ranges.length;F++){if(!t&&F==n.sel.primIndex)continue;var K=n.sel.ranges[F];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var Y=K.empty();(Y||e.options.showCursorWhenSelecting)&&go(e,K.head,i),Y||Xs(e,K,w)}return r}function go(e,t,n){var r=pn(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(a("div","\xA0","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var w=n.appendChild(a("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 Gi(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,n){var r=e.display,i=e.doc,w=document.createDocumentFragment(),F=qa(e.display),K=F.left,Y=Math.max(r.sizerWidth,Bn(e)-r.sizer.offsetLeft)-F.right,Z=i.direction=="ltr";function le(st,_t,Bt,Ot){_t<0&&(_t=0),_t=Math.round(_t),Ot=Math.round(Ot),w.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+st+`px;
|
|
top: `+_t+"px; width: "+(Bt==null?Y-st:Bt)+`px;
|
|
height: `+(Ot-_t)+"px"))}function he(st,_t,Bt){var Ot=Fe(i,st),Yt=Ot.text.length,yr,Fr;function Cr(Rr,rn){return ma(e,Ie(st,Rr),"div",Ot,rn)}function on(Rr,rn,zr){var Or=ho(e,Ot,null,Rr),kr=rn=="ltr"==(zr=="after")?"left":"right",_r=zr=="after"?Or.begin:Or.end-(/\s/.test(Ot.text.charAt(Or.end-1))?2:1);return Cr(_r,kr)[kr]}var tn=ct(Ot,i.direction);return it(tn,_t||0,Bt==null?Yt:Bt,function(Rr,rn,zr,Or){var kr=zr=="ltr",_r=Cr(Rr,kr?"left":"right"),nn=Cr(rn-1,kr?"right":"left"),di=_t==null&&Rr==0,Nn=Bt==null&&rn==Yt,Xr=Or==0,xn=!tn||Or==tn.length-1;if(nn.top-_r.top<=3){var jr=(Z?di:Nn)&&Xr,Va=(Z?Nn:di)&&xn,wn=jr?K:(kr?_r:nn).left,Vn=Va?Y:(kr?nn:_r).right;le(wn,_r.top,Vn-wn,_r.bottom)}else{var Xn,Jr,ci,Xa;kr?(Xn=Z&&di&&Xr?K:_r.left,Jr=Z?Y:on(Rr,zr,"before"),ci=Z?K:on(rn,zr,"after"),Xa=Z&&Nn&&xn?Y:nn.right):(Xn=Z?on(Rr,zr,"before"):K,Jr=!Z&&di&&Xr?Y:_r.right,ci=!Z&&Nn&&xn?K:nn.left,Xa=Z?on(rn,zr,"after"):Y),le(Xn,_r.top,Jr-Xn,_r.bottom),_r.bottom<nn.top&&le(K,_r.bottom,null,nn.top),le(ci,nn.top,Xa-ci,nn.bottom)}(!yr||Gi(_r,yr)<0)&&(yr=_r),Gi(nn,yr)<0&&(yr=nn),(!Fr||Gi(_r,Fr)<0)&&(Fr=_r),Gi(nn,Fr)<0&&(Fr=nn)}),{start:yr,end:Fr}}var xe=t.from(),ye=t.to();if(xe.line==ye.line)he(xe.line,xe.ch,ye.ch);else{var Oe=Fe(i,xe.line),We=Fe(i,ye.line),Ye=Yr(Oe)==Yr(We),ot=he(xe.line,xe.ch,Ye?Oe.text.length+1:null).end,yt=he(ye.line,Ye?0:null,ye.ch).start;Ye&&(ot.top<yt.top-2?(le(ot.right,ot.top,null,ot.bottom),le(K,yt.top,yt.left,yt.bottom)):le(ot.right,ot.top,yt.left-ot.right,ot.bottom)),ot.bottom<yt.top&&le(K,ot.bottom,null,yt.top)}n.appendChild(w)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Zn(e),t.cursorDiv.style.visibility=(n=!n)?"":"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,Zn(e))},100)}function Ca(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(Re(e,"focus",e,t),e.state.focused=!0,H(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),O&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Zn(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Re(e,"blur",e,t),e.state.focused=!1,f(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Ki(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i=t.view[r],w=e.options.lineWrapping,F=void 0,K=0;if(i.hidden)continue;if(z&&B<8){var Y=i.node.offsetTop+i.node.offsetHeight;F=Y-n,n=Y}else{var Z=i.node.getBoundingClientRect();F=Z.bottom-Z.top,!w&&i.text.firstChild&&(K=i.text.firstChild.getBoundingClientRect().right-Z.left-1)}var le=i.line.height-F;if((le>.005||le<-.005)&&(qt(i.line,F),bo(i.line),i.rest))for(var he=0;he<i.rest.length;he++)bo(i.rest[he]);if(K>e.display.sizerWidth){var xe=Math.ceil(K/Qn(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function Vi(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Wi(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,w=Tr(t,r),F=Tr(t,i);if(n&&n.ensure){var K=n.ensure.from.line,Y=n.ensure.to.line;K<w?(w=K,F=Tr(t,fn(Fe(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=F&&(w=Tr(t,fn(Fe(t,Y))-e.wrapper.clientHeight),F=Y)}return{from:w,to:Math.max(F,w+1)}}function Ys(e,t){if(je(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),i!=null&&!A){var w=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-n.viewOffset-Wi(e.display))+`px;
|
|
height: `+(t.bottom-t.top+bn(e)+n.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(w),w.scrollIntoView(i),e.display.lineSpace.removeChild(w)}}function $s(e,t,n,r){r==null&&(r=0);var i;!e.options.lineWrapping&&t==n&&(t=t.ch?Ie(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,n=t.sticky=="before"?Ie(t.line,t.ch+1,"before"):t);for(var w=0;w<5;w++){var F=!1,K=pn(e,t),Y=!n||n==t?K:pn(e,n);i={left:Math.min(K.left,Y.left),top:Math.min(K.top,Y.top)-r,right:Math.max(K.left,Y.left),bottom:Math.max(K.bottom,Y.bottom)+r};var Z=_a(e,i),le=e.doc.scrollTop,he=e.doc.scrollLeft;if(Z.scrollTop!=null&&(xi(e,Z.scrollTop),Math.abs(e.doc.scrollTop-le)>1&&(F=!0)),Z.scrollLeft!=null&&(Hn(e,Z.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(F=!0)),!F)break}return i}function Js(e,t){var n=_a(e,t);n.scrollTop!=null&&xi(e,n.scrollTop),n.scrollLeft!=null&&Hn(e,n.scrollLeft)}function _a(e,t){var n=e.display,r=Jn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:n.scroller.scrollTop,w=ha(e),F={};t.bottom-t.top>w&&(t.bottom=t.top+w);var K=e.doc.height+ca(n),Y=t.top<r,Z=t.bottom>K-r;if(t.top<i)F.scrollTop=Y?0:t.top;else if(t.bottom>i+w){var le=Math.min(t.top,(Z?K:t.bottom)-w);le!=i&&(F.scrollTop=le)}var he=e.options.fixedGutter?0:n.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:n.scroller.scrollLeft-he,ye=Bn(e)-n.gutters.offsetWidth,Oe=t.right-t.left>ye;return Oe&&(t.right=t.left+ye),t.left<10?F.scrollLeft=0:t.left<xe?F.scrollLeft=Math.max(0,t.left+he-(Oe?0:10)):t.right>ye+xe-3&&(F.scrollLeft=t.right+(Oe?0:10)-ye),F}function Ta(e,t){if(t==null)return;Xi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function qn(e){Xi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ei(e,t,n){(t!=null||n!=null)&&Xi(e),t!=null&&(e.curOp.scrollLeft=t),n!=null&&(e.curOp.scrollTop=n)}function Qs(e,t){Xi(e),e.curOp.scrollToPos=t}function Xi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=uo(e,t.from),r=uo(e,t.to);Eo(e,n,r,t.margin)}}function Eo(e,t,n,r){var i=_a(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Ei(e,i.scrollLeft,i.scrollTop)}function xi(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;R||Aa(e,{top:t}),xo(e,t,!0),R&&Aa(e),_i(e,100)}function xo(e,t,n){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function Hn(e,t,n,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,wo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function Si(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+bn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var zn=function(e,t,n){this.cm=n;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&B<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};zn.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var w=e.viewWidth-e.barLeft-(n?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:n?r:0,bottom:t?r:0}},zn.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},zn.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},zn.prototype.zeroWidthHack=function(){var e=c&&!T?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new oe,this.disableVert=new oe},zn.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto";function r(){var i=e.getBoundingClientRect(),w=n=="vert"?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);w!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},zn.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Ci=function(){};Ci.prototype.update=function(){return{bottom:0,right:0}},Ci.prototype.setScrollLeft=function(){},Ci.prototype.setScrollTop=function(){},Ci.prototype.clear=function(){};function ei(e,t){t||(t=Si(e));var n=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&Ki(e),So(e,Si(e)),n=e.display.barWidth,r=e.display.barHeight}function So(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}var Co={native:zn,null:Ci};function _o(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&f(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),we(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){n=="horizontal"?Hn(e,t):xi(e,t)},e),e.display.scrollbars.addClass&&H(e.display.wrapper,e.display.scrollbars.addClass)}var Zs=0;function Gn(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:++Zs},hn(e.curOp)}function Kn(e){var t=e.curOp;t&&Ds(t,function(n){for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;qs(n)})}function qs(e){for(var t=e.ops,n=0;n<t.length;n++)el(t[n]);for(var r=0;r<t.length;r++)tl(t[r]);for(var i=0;i<t.length;i++)rl(t[i]);for(var w=0;w<t.length;w++)nl(t[w]);for(var F=0;F<t.length;F++)il(t[F])}function el(e){var t=e.cm,n=t.display;ol(t),e.updateMaxLine&&ji(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Yi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&wa(e.cm,e.update)}function rl(e){var t=e.cm,n=t.display;e.updatedDisplay&&Ki(t),e.barMeasure=Si(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+bn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Bn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function nl(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Hn(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==M();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&ei(t,e.barMeasure),e.updatedDisplay&&Ra(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&vo(e.cm)}function il(e){var t=e.cm,n=t.display,r=t.doc;if(e.updatedDisplay&&To(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null),e.scrollTop!=null&&xo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Hn(t,e.scrollLeft,!0,!0),e.scrollToPos){var i=$s(t,u(r,e.scrollToPos.from),u(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,i)}var w=e.maybeHiddenMarkers,F=e.maybeUnhiddenMarkers;if(w)for(var K=0;K<w.length;++K)w[K].lines.length||Re(w[K],"hide");if(F)for(var Y=0;Y<F.length;++Y)F[Y].lines.length&&Re(F[Y],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Re(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function an(e,t){if(e.curOp)return t();Gn(e);try{return t()}finally{Kn(e)}}function Ur(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Gn(e);try{return t.apply(e,arguments)}finally{Kn(e)}}}function $r(e){return function(){if(this.curOp)return e.apply(this,arguments);Gn(this);try{return e.apply(this,arguments)}finally{Kn(this)}}}function Br(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Gn(t);try{return e.apply(this,arguments)}finally{Kn(t)}}}function _i(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,G(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var n=+new Date+e.options.workTime,r=qe(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(w){if(r.line>=e.display.viewFrom){var F=w.styles,K=w.text.length>e.options.maxHighlightLength?Ut(t.mode,r.state):null,Y=ce(e,w,r,!0);K&&(r.state=K),w.styles=Y.styles;var Z=w.styleClasses,le=Y.classes;le?w.styleClasses=le:Z&&(w.styleClasses=null);for(var he=!F||F.length!=w.styles.length||Z!=le&&(!Z||!le||Z.bgClass!=le.bgClass||Z.textClass!=le.textClass),xe=0;!he&&xe<F.length;++xe)he=F[xe]!=w.styles[xe];he&&i.push(r.line),w.stateAfter=r.save(),r.nextLine()}else w.text.length<=e.options.maxHighlightLength&&Tt(e,w.text,r),w.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return _i(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&an(e,function(){for(var w=0;w<i.length;w++)Rn(e,i[w],"text")})}var Yi=function(e,t,n){var r=e.display;this.viewport=t,this.visible=Vi(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Bn(e),this.force=n,this.dims=ba(e),this.events=[]};Yi.prototype.signal=function(e,t){de(e,t)&&this.events.push(arguments)},Yi.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Re.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=bn(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=bn(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 n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&S(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}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(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}function wa(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return kn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&po(e)==0)return!1;Ao(e)&&(kn(e),t.dims=ba(e));var i=r.first+r.size,w=Math.max(t.visible.from-e.options.viewportMargin,r.first),F=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<w&&w-n.viewFrom<20&&(w=Math.max(r.first,n.viewFrom)),n.viewTo>F&&n.viewTo-F<20&&(F=Math.min(i,n.viewTo)),wr&&(w=hi(e.doc,w),F=Ln(e.doc,F));var K=w!=n.viewFrom||F!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Vs(e,w,F),n.viewOffset=fn(Fe(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var Y=po(e);if(!K&&Y==0&&!t.force&&n.renderedView==n.view&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var Z=sl(e);return Y>4&&(n.lineDiv.style.display="none"),ul(e,n.updateLineNumbers,t.dims),Y>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,ll(Z),p(n.cursorDiv),p(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,K&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,_i(e,400)),n.updateLineNumbers=null,!0}function To(e,t){for(var n=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Bn(e)){if(n&&n.top!=null&&(n={top:Math.min(e.doc.height+ca(e.display)-ha(e),n.top)}),t.visible=Vi(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vi(e.display,e.doc,n));if(!wa(e,t))break;Ki(e);var i=Si(e);bi(e),ei(e,i),Ra(e,i),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 n=new Yi(e,t);if(wa(e,n)){Ki(e),To(e,n);var r=Si(e);bi(e),ei(e,r),Ra(e,r),n.finish()}}function ul(e,t,n){var r=e.display,i=e.options.lineNumbers,w=r.lineDiv,F=w.firstChild;function K(Oe){var We=Oe.nextSibling;return O&&c&&e.display.currentWheelTarget==Oe?Oe.style.display="none":Oe.parentNode.removeChild(Oe),We}for(var Y=r.view,Z=r.viewFrom,le=0;le<Y.length;le++){var he=Y[le];if(!he.hidden)if(!he.node||he.node.parentNode!=w){var xe=Ns(e,he,Z,n);w.insertBefore(xe,F)}else{for(;F!=he.node;)F=K(F);var ye=i&&t!=null&&t<=Z&&he.lineNumber;he.changes&&(fe(he.changes,"gutter")>-1&&(ye=!1),Ya(e,he,Z,n)),ye&&(p(he.lineNumber),he.lineNumber.appendChild(document.createTextNode(Rt(e.options,Z)))),F=he.node.nextSibling}Z+=he.size}for(;F;)F=K(F)}function La(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Ra(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+bn(e)+"px"}function wo(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,w=r+"px",F=0;F<n.length;F++)if(!n[F].hidden){e.options.fixedGutter&&(n[F].gutter&&(n[F].gutter.style.left=w),n[F].gutterBackground&&(n[F].gutterBackground.style.left=w));var K=n[F].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=w}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=Rt(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(a("div",[a("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),w=i.firstChild.offsetWidth,F=i.offsetWidth-w;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(w,r.lineGutter.offsetWidth-F)+1,r.lineNumWidth=r.lineNumInnerWidth+F,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",La(e.display),!0}return!1}function ka(e,t){for(var n=[],r=!1,i=0;i<e.length;i++){var w=e[i],F=null;if(typeof w!="string"&&(F=w.style,w=w.className),w=="CodeMirror-linenumbers")if(t)r=!0;else continue;n.push({className:w,style:F})}return t&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function Lo(e){var t=e.gutters,n=e.gutterSpecs;p(t),e.lineGutter=null;for(var r=0;r<n.length;++r){var i=n[r],w=i.className,F=i.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+w));F&&(K.style.cssText=F),w=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",La(e)}function Ti(e){Lo(e.display),qr(e),wo(e)}function dl(e,t,n,r){var i=this;this.input=n,i.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=b("div",null,"CodeMirror-code"),i.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=a("div",null,"CodeMirror-cursors"),i.measure=a("div",null,"CodeMirror-measure"),i.lineMeasure=a("div",null,"CodeMirror-measure"),i.lineSpace=b("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var w=b("div",[i.lineSpace],"CodeMirror-lines");i.mover=a("div",[w],null,"position: relative"),i.sizer=a("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=a("div",null,null,"position: absolute; height: "+ve+"px; width: 1px;"),i.gutters=a("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=a("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=a("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),z&&B<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),!O&&!(R&&o)&&(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,i.gutterSpecs=ka(r.gutters,r.lineNumbers),Lo(i),n.init(i)}var $i=0,sn=null;z?sn=-.53:R?sn=15:E?sn=-.7:k&&(sn=-1/3);function Ro(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),n==null&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:n==null&&(n=e.wheelDelta),{x:t,y:n}}function cl(e){var t=Ro(e);return t.x*=sn,t.y*=sn,t}function ko(e,t){var n=Ro(t),r=n.x,i=n.y,w=e.display,F=w.scroller,K=F.scrollWidth>F.clientWidth,Y=F.scrollHeight>F.clientHeight;if(!(r&&K||i&&Y))return;if(i&&c&&O){e:for(var Z=t.target,le=w.view;Z!=F;Z=Z.parentNode)for(var he=0;he<le.length;he++)if(le[he].node==Z){e.display.currentWheelTarget=Z;break e}}if(r&&!R&&!L&&sn!=null){i&&Y&&xi(e,Math.max(0,F.scrollTop+i*sn)),Hn(e,Math.max(0,F.scrollLeft+r*sn)),(!i||i&&Y)&&ee(t),w.wheelStartX=null;return}if(i&&sn!=null){var xe=i*sn,ye=e.doc.scrollTop,Oe=ye+w.wrapper.clientHeight;xe<0?ye=Math.max(0,ye+xe-50):Oe=Math.min(e.doc.height,Oe+xe+50),Aa(e,{top:ye,bottom:Oe})}$i<20&&(w.wheelStartX==null?(w.wheelStartX=F.scrollLeft,w.wheelStartY=F.scrollTop,w.wheelDX=r,w.wheelDY=i,setTimeout(function(){if(w.wheelStartX==null)return;var We=F.scrollLeft-w.wheelStartX,Ye=F.scrollTop-w.wheelStartY,ot=Ye&&w.wheelDY&&Ye/w.wheelDY||We&&w.wheelDX&&We/w.wheelDX;if(w.wheelStartX=w.wheelStartY=null,!ot)return;sn=(sn*$i+ot)/($i+1),++$i},200)):(w.wheelDX+=r,w.wheelDY+=i))}var ln=function(e,t){this.ranges=e,this.primIndex=t};ln.prototype.primary=function(){return this.ranges[this.primIndex]},ln.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 n=this.ranges[t],r=e.ranges[t];if(!Dr(n.anchor,r.anchor)||!Dr(n.head,r.head))return!1}return!0},ln.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new dr(un(this.ranges[t].anchor),un(this.ranges[t].head));return new ln(e,this.primIndex)},ln.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},ln.prototype.contains=function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(xt(t,r.from())>=0&&xt(e,r.to())<=0)return n}return-1};var dr=function(e,t){this.anchor=e,this.head=t};dr.prototype.from=function(){return xr(this.anchor,this.head)},dr.prototype.to=function(){return dn(this.anchor,this.head)},dr.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function mn(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort(function(xe,ye){return xt(xe.from(),ye.from())}),n=fe(t,i);for(var w=1;w<t.length;w++){var F=t[w],K=t[w-1],Y=xt(K.to(),F.from());if(r&&!F.empty()?Y>0:Y>=0){var Z=xr(K.from(),F.from()),le=dn(K.to(),F.to()),he=K.empty()?F.from()==F.head:K.from()==K.head;w<=n&&--n,t.splice(--w,2,new dr(he?le:Z,he?Z:le))}}return new ln(t,n)}function Dn(e,t){return new ln([new dr(e,t||e)],0)}function Pn(e){return e.text?Ie(e.from.line+e.text.length-1,Ae(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Do(e,t){if(xt(e,t.from)<0)return e;if(xt(e,t.to)<=0)return Pn(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Pn(t).ch-t.to.ch),Ie(n,r)}function Da(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new dr(Do(i.anchor,t),Do(i.head,t)))}return mn(e.cm,n,e.sel.primIndex)}function Po(e,t,n){return e.line==t.line?Ie(n.line,e.ch-t.ch+n.ch):Ie(n.line+(e.line-t.line),e.ch)}function hl(e,t,n){for(var r=[],i=Ie(e.first,0),w=i,F=0;F<t.length;F++){var K=t[F],Y=Po(K.from,i,w),Z=Po(Pn(K),i,w);if(i=K.to,w=Z,n=="around"){var le=e.sel.ranges[F],he=xt(le.head,le.anchor)<0;r[F]=new dr(he?Z:Y,he?Y:Z)}else r[F]=new dr(Y,Y)}return new ln(r,e.sel.primIndex)}function Pa(e){e.doc.mode=Xt(e.options,e.doc.modeOption),wi(e)}function wi(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,_i(e,100),e.state.modeGen++,e.curOp&&qr(e)}function Oo(e,t){return t.from.ch==0&&t.to.ch==0&&Ae(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Oa(e,t,n,r){function i(yt){return n?n[yt]:null}function w(yt,st,_t){ua(yt,st,_t,r),Hr(yt,"change",yt,t)}function F(yt,st){for(var _t=[],Bt=yt;Bt<st;++Bt)_t.push(new Un(Z[Bt],i(Bt),r));return _t}var K=t.from,Y=t.to,Z=t.text,le=Fe(e,K.line),he=Fe(e,Y.line),xe=Ae(Z),ye=i(Z.length-1),Oe=Y.line-K.line;if(t.full)e.insert(0,F(0,Z.length)),e.remove(Z.length,e.size-Z.length);else if(Oo(e,t)){var We=F(0,Z.length-1);w(he,he.text,ye),Oe&&e.remove(K.line,Oe),We.length&&e.insert(K.line,We)}else if(le==he)if(Z.length==1)w(le,le.text.slice(0,K.ch)+xe+le.text.slice(Y.ch),ye);else{var Ye=F(1,Z.length-1);Ye.push(new Un(xe+le.text.slice(Y.ch),ye,r)),w(le,le.text.slice(0,K.ch)+Z[0],i(0)),e.insert(K.line+1,Ye)}else if(Z.length==1)w(le,le.text.slice(0,K.ch)+Z[0]+he.text.slice(Y.ch),i(0)),e.remove(K.line+1,Oe);else{w(le,le.text.slice(0,K.ch)+Z[0],i(0)),w(he,xe+he.text.slice(Y.ch),ye);var ot=F(1,Z.length-1);Oe>1&&e.remove(K.line+1,Oe-1),e.insert(K.line+1,ot)}Hr(e,"change",e,t)}function On(e,t,n){function r(i,w,F){if(i.linked)for(var K=0;K<i.linked.length;++K){var Y=i.linked[K];if(Y.doc==w)continue;var Z=F&&Y.sharedHist;if(n&&!Z)continue;t(Y.doc,Z),r(Y.doc,i,Z)}}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),Pa(e),Io(e),e.options.lineWrapping||ji(e),e.options.mode=t.modeOption,qr(e)}function Io(e){(e.doc.direction=="rtl"?H:f)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){an(e,function(){Io(e),qr(e)})}function Ji(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 n={from:un(t.from),to:Pn(t),text:nr(e,t.from,t.to)};return Bo(e,n,t.from.line,t.to.line+1),On(e,function(r){return Bo(r,n,t.from.line,t.to.line+1)},!0),n}function No(e){for(;e.length;){var t=Ae(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),Ae(e.done);if(e.done.length&&!Ae(e.done).ranges)return Ae(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Ae(e.done)}function Uo(e,t,n,r){var i=e.history;i.undone.length=0;var w=+new Date,F,K;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&i.lastModTime>w-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(F=pl(i,i.lastOp==r)))K=Ae(F.changes),xt(t.from,t.to)==0&&xt(t.from,K.to)==0?K.to=Pn(t):F.changes.push(Ma(e,t));else{var Y=Ae(i.done);for((!Y||!Y.ranges)&&Qi(e.sel,i.done),F={changes:[Ma(e,t)],generation:i.generation},i.done.push(F);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=w,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,K||Re(e,"historyAdded")}function ml(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,n,r){var i=e.history,w=r&&r.origin;n==i.lastSelOp||w&&i.lastSelOrigin==w&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==w||ml(e,w,Ae(i.done),t))?i.done[i.done.length-1]=t:Qi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=w,i.lastSelOp=n,r&&r.clearRedo!==!1&&No(i.undone)}function Qi(e,t){var n=Ae(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Bo(e,t,n,r){var i=t["spans_"+e.id],w=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(F){F.markedSpans&&((i||(i=t["spans_"+e.id]={}))[w]=F.markedSpans),++w})}function vl(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function yl(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i<t.text.length;++i)r.push(vl(n[i]));return r}function Fo(e,t){var n=yl(e,t),r=cr(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var w=n[i],F=r[i];if(w&&F){e:for(var K=0;K<F.length;++K){for(var Y=F[K],Z=0;Z<w.length;++Z)if(w[Z].marker==Y.marker)continue e;w.push(Y)}}else F&&(n[i]=F)}return n}function ti(e,t,n){for(var r=[],i=0;i<e.length;++i){var w=e[i];if(w.ranges){r.push(n?ln.prototype.deepCopy.call(w):w);continue}var F=w.changes,K=[];r.push({changes:K});for(var Y=0;Y<F.length;++Y){var Z=F[Y],le=void 0;if(K.push({from:Z.from,to:Z.to,text:Z.text}),t)for(var he in Z)(le=he.match(/^spans_(\d+)$/))&&(fe(t,Number(le[1]))>-1&&(Ae(K)[he]=Z[he],delete Z[he]))}}return r}function Ia(e,t,n,r){if(r){var i=e.anchor;if(n){var w=xt(t,i)<0;w!=xt(n,i)<0?(i=t,t=n):w!=xt(t,n)<0&&(t=n)}return new dr(i,t)}else return new dr(n||t,t)}function Zi(e,t,n,r,i){i==null&&(i=e.cm&&(e.cm.display.shift||e.extend)),Vr(e,new ln([Ia(e.sel.primary(),t,n,i)],0),r)}function jo(e,t,n){for(var r=[],i=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,i);var F=mn(e.cm,r,e.sel.primIndex);Vr(e,F,n)}function Na(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Vr(e,mn(e.cm,i,e.sel.primIndex),r)}function Wo(e,t,n,r){Vr(e,Dn(t,n),r)}function bl(e,t,n){var r={ranges:t.ranges,update:function(i){this.ranges=[];for(var w=0;w<i.length;w++)this.ranges[w]=new dr(u(e,i[w].anchor),u(e,i[w].head))},origin:n&&n.origin};return Re(e,"beforeSelectionChange",e,r),e.cm&&Re(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?mn(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,n){var r=e.history.done,i=Ae(r);i&&i.ranges?(r[r.length-1]=t,qi(e,t,n)):Vr(e,t,n)}function Vr(e,t,n){qi(e,t,n),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function qi(e,t,n){(de(e,"beforeSelectionChange")||e.cm&&de(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,n));var r=n&&n.bias||(xt(t.primary().head,e.sel.primary().head)<0?-1:1);zo(e,Ko(e,t,r,!0)),!(n&&n.scroll===!1)&&e.cm&&qn(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,ge(e.cm)),Hr(e,"cursorActivity",e)}function Go(e){zo(e,Ko(e,e.sel,null,!1))}function Ko(e,t,n,r){for(var i,w=0;w<t.ranges.length;w++){var F=t.ranges[w],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[w],Y=ea(e,F.anchor,K&&K.anchor,n,r),Z=ea(e,F.head,K&&K.head,n,r);(i||Y!=F.anchor||Z!=F.head)&&(i||(i=t.ranges.slice(0,w)),i[w]=new dr(Y,Z))}return i?mn(e.cm,i,t.primIndex):t}function ri(e,t,n,r,i){var w=Fe(e,t.line);if(w.markedSpans)for(var F=0;F<w.markedSpans.length;++F){var K=w.markedSpans[F],Y=K.marker,Z="selectLeft"in Y?!Y.selectLeft:Y.inclusiveLeft,le="selectRight"in Y?!Y.selectRight:Y.inclusiveRight;if((K.from==null||(Z?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(le?K.to>=t.ch:K.to>t.ch))){if(i&&(Re(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(w.markedSpans){--F;continue}else break;if(!Y.atomic)continue;if(n){var he=Y.find(r<0?1:-1),xe=void 0;if((r<0?le:Z)&&(he=Vo(e,he,-r,he&&he.line==t.line?w:null)),he&&he.line==t.line&&(xe=xt(he,n))&&(r<0?xe<0:xe>0))return ri(e,he,t,r,i)}var ye=Y.find(r<0?-1:1);return(r<0?Z:le)&&(ye=Vo(e,ye,r,ye.line==t.line?w:null)),ye?ri(e,ye,t,r,i):null}}return t}function ea(e,t,n,r,i){var w=r||1,F=ri(e,t,n,w,i)||!i&&ri(e,t,n,w,!0)||ri(e,t,n,-w,i)||!i&&ri(e,t,n,-w,!0);return F||(e.cantEdit=!0,Ie(e.first,0))}function Vo(e,t,n,r){return n<0&&t.ch==0?t.line>e.first?u(e,Ie(t.line-1)):null:n>0&&t.ch==(r||Fe(e,t.line)).text.length?t.line<e.first+e.size-1?Ie(t.line+1,0):null:new Ie(t.line,t.ch+n)}function Xo(e){e.setSelection(Ie(e.firstLine(),0),Ie(e.lastLine()),Ee)}function Yo(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return n&&(r.update=function(i,w,F,K){i&&(r.from=u(e,i)),w&&(r.to=u(e,w)),F&&(r.text=F),K!==void 0&&(r.origin=K)}),Re(e,"beforeChange",e,r),e.cm&&Re(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function ni(e,t,n){if(e.cm){if(!e.cm.curOp)return Ur(e.cm,ni)(e,t,n);if(e.cm.state.suppressEdits)return}if((de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Sn&&!n&&Lr(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)$o(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&xt(t.from,t.to)==0)return;var n=Da(e,t);Uo(e,t,n,e.cm?e.cm.curOp.id:NaN),Ai(e,t,n,cr(e,t));var r=[];On(e,function(i,w){!w&&fe(r,i.history)==-1&&(qo(i.history,t),r.push(i.history)),Ai(i,t,null,cr(i,t))})}function ta(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!n)return;for(var i=e.history,w,F=e.sel,K=t=="undo"?i.done:i.undone,Y=t=="undo"?i.undone:i.done,Z=0;Z<K.length&&!(w=K[Z],n?w.ranges&&!w.equals(e.sel):!w.ranges);Z++);if(Z==K.length)return;for(i.lastOrigin=i.lastSelOrigin=null;;)if(w=K.pop(),w.ranges){if(Qi(w,Y),n&&!w.equals(e.sel)){Vr(e,w,{clearRedo:!1});return}F=w}else if(r){K.push(w);return}else break;var le=[];Qi(F,Y),Y.push({changes:le,generation:i.generation}),i.generation=w.generation||++i.maxGeneration;for(var he=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),xe=function(We){var Ye=w.changes[We];if(Ye.origin=t,he&&!Yo(e,Ye,!1))return K.length=0,{};le.push(Ma(e,Ye));var ot=We?Da(e,Ye):Ae(K);Ai(e,Ye,ot,Fo(e,Ye)),!We&&e.cm&&e.cm.scrollIntoView({from:Ye.from,to:Pn(Ye)});var yt=[];On(e,function(st,_t){!_t&&fe(yt,st.history)==-1&&(qo(st.history,Ye),yt.push(st.history)),Ai(st,Ye,null,Fo(st,Ye))})},ye=w.changes.length-1;ye>=0;--ye){var Oe=xe(ye);if(Oe)return Oe.v}}function Jo(e,t){if(t==0)return;if(e.first+=t,e.sel=new ln(rt(e.sel.ranges,function(i){return new dr(Ie(i.anchor.line+t,i.anchor.ch),Ie(i.head.line+t,i.head.ch))}),e.sel.primIndex),e.cm){qr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)Rn(e.cm,r,"gutter")}}function Ai(e,t,n,r){if(e.cm&&!e.cm.curOp)return Ur(e.cm,Ai)(e,t,n,r);if(t.to.line<e.first){Jo(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 i=t.text.length-1-(e.first-t.from.line);Jo(e,i),t={from:Ie(e.first,0),to:Ie(t.to.line+i,t.to.ch),text:[Ae(t.text)],origin:t.origin}}var w=e.lastLine();t.to.line>w&&(t={from:t.from,to:Ie(w,Fe(e,w).text.length),text:[t.text[0]],origin:t.origin}),t.removed=nr(e,t.from,t.to),n||(n=Da(e,t)),e.cm?El(e.cm,t,r):Oa(e,t,r),qi(e,n,Ee),e.cantEdit&&ea(e,Ie(e.firstLine(),0))&&(e.cantEdit=!1)}function El(e,t,n){var r=e.doc,i=e.display,w=t.from,F=t.to,K=!1,Y=w.line;e.options.lineWrapping||(Y=Wt(Yr(Fe(r,w.line))),r.iter(Y,F.line+1,function(ye){if(ye==i.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&ge(e),Oa(r,t,n,fo(e)),e.options.lineWrapping||(r.iter(Y,w.line+t.text.length,function(ye){var Oe=pi(ye);Oe>i.maxLineLength&&(i.maxLine=ye,i.maxLineLength=Oe,i.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),cn(r,w.line),_i(e,400);var Z=t.text.length-(F.line-w.line)-1;t.full?qr(e):w.line==F.line&&t.text.length==1&&!Oo(e.doc,t)?Rn(e,w.line,"text"):qr(e,w.line,F.line+1,Z);var le=de(e,"changes"),he=de(e,"change");if(he||le){var xe={from:w,to:F,text:t.text,removed:t.removed,origin:t.origin};he&&Hr(e,"change",e,xe),le&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function ii(e,t,n,r,i){var w;r||(r=n),xt(r,n)<0&&(w=[r,n],n=w[0],r=w[1]),typeof t=="string"&&(t=e.splitLines(t)),ni(e,{from:n,to:r,text:t,origin:i})}function Qo(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Zo(e,t,n,r){for(var i=0;i<e.length;++i){var w=e[i],F=!0;if(w.ranges){w.copied||(w=e[i]=w.deepCopy(),w.copied=!0);for(var K=0;K<w.ranges.length;K++)Qo(w.ranges[K].anchor,t,n,r),Qo(w.ranges[K].head,t,n,r);continue}for(var Y=0;Y<w.changes.length;++Y){var Z=w.changes[Y];if(n<Z.from.line)Z.from=Ie(Z.from.line+r,Z.from.ch),Z.to=Ie(Z.to.line+r,Z.to.ch);else if(t<=Z.to.line){F=!1;break}}F||(e.splice(0,i+1),i=0)}}function qo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;Zo(e.done,n,r,i),Zo(e.undone,n,r,i)}function Li(e,t,n,r){var i=t,w=t;return typeof t=="number"?w=Fe(e,U(e,t)):i=Wt(t),i==null?null:(r(w,i)&&e.cm&&Rn(e.cm,i,n),w)}function Ri(e){this.lines=e,this.parent=null;for(var t=0,n=0;n<e.length;++n)e[n].parent=this,t+=e[n].height;this.height=t}Ri.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,kt(i),Hr(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,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,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}};function ki(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}ki.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var w=Math.min(t,i-e),F=r.height;if(r.removeInner(e,w),this.height-=F-r.height,i==w&&(this.children.splice(n--,1),r.parent=null),(t-=w)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Ri))){var K=[];this.collapse(K),this.children=[new Ri(K)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],w=i.chunkSize();if(e<=w){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var F=i.lines.length%25+25,K=F;K<i.lines.length;){var Y=new Ri(i.lines.slice(K,K+=25));i.height-=Y.height,this.children.splice(++r,0,Y),Y.parent=this}i.lines=i.lines.slice(0,F),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),n=new ki(t);if(e.parent){e.size-=n.size,e.height-=n.height;var i=fe(e.parent.children,e);e.parent.children.splice(i+1,0,n)}else{var r=new ki(e.children);r.parent=e,e.children=[r,n],e=r}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],w=i.chunkSize();if(e<w){var F=Math.min(t,w-e);if(i.iterN(e,F,n))return!0;if((t-=F)==0)break;e=0}else e-=w}}};var Di=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};Di.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=Wt(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var w=vi(this);qt(n,Math.max(0,n.height-w)),e&&(an(e,function(){es(e,n,-w),Rn(e,r,"widget")}),Hr(e,"lineWidgetCleared",e,this,r))},Di.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=vi(this)-t;if(!i)return;yn(this.doc,r)||qt(r,r.height+i),n&&an(n,function(){n.curOp.forceUpdate=!0,es(n,r,i),Hr(n,"lineWidgetChanged",n,e,Wt(r))})},pe(Di);function es(e,t,n){fn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ta(e,n)}function xl(e,t,n,r){var i=new Di(e,n,r),w=e.cm;return w&&i.noHScroll&&(w.display.alignWidgets=!0),Li(e,t,"widget",function(F){var K=F.widgets||(F.widgets=[]);if(i.insertAt==null?K.push(i):K.splice(Math.min(K.length-1,Math.max(0,i.insertAt)),0,i),i.line=F,w&&!yn(e,F)){var Y=fn(F)<e.scrollTop;qt(F,F.height+vi(i)),Y&&Ta(w,i.height),w.curOp.forceUpdate=!0}return!0}),w&&Hr(w,"lineWidgetAdded",w,i,typeof t=="number"?t:Wt(t)),i}var ts=0,Mn=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};Mn.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Gn(e),de(this,"clear")){var n=this.find();n&&Hr(this,"clear",n.from,n.to)}for(var r=null,i=null,w=0;w<this.lines.length;++w){var F=this.lines[w],K=wt(F.markedSpans,this);e&&!this.collapsed?Rn(e,Wt(F),"text"):e&&(K.to!=null&&(i=Wt(F)),K.from!=null&&(r=Wt(F))),F.markedSpans=mt(F.markedSpans,K),K.from==null&&this.collapsed&&!yn(this.doc,F)&&e&&qt(F,Jn(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var Y=0;Y<this.lines.length;++Y){var Z=Yr(this.lines[Y]),le=pi(Z);le>e.display.maxLineLength&&(e.display.maxLine=Z,e.display.maxLineLength=le,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&qr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Go(e.doc)),e&&Hr(e,"markerCleared",e,this,r,i),t&&Kn(e),this.parent&&this.parent.clear()},Mn.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var n,r,i=0;i<this.lines.length;++i){var w=this.lines[i],F=wt(w.markedSpans,this);if(F.from!=null&&(n=Ie(t?w:Wt(w),F.from),e==-1))return n;if(F.to!=null&&(r=Ie(t?w:Wt(w),F.to),e==1))return r}return n&&{from:n,to:r}},Mn.prototype.changed=function(){var e=this,t=this.find(-1,!0),n=this,r=this.doc.cm;if(!t||!r)return;an(r,function(){var i=t.line,w=Wt(t.line),F=fa(r,w);if(F&&(io(F),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!yn(n.doc,i)&&n.height!=null){var K=n.height;n.height=null;var Y=vi(n)-K;Y&&qt(i,i.height+Y)}Hr(r,"markerChanged",r,e)})},Mn.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||fe(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Mn.prototype.detachLine=function(e){if(this.lines.splice(fe(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},pe(Mn);function ai(e,t,n,r,i){if(r&&r.shared)return Sl(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return Ur(e.cm,ai)(e,t,n,r,i);var w=new Mn(e,i),F=xt(t,n);if(r&&W(r,w,!1),F>0||F==0&&w.clearWhenEmpty!==!1)return w;if(w.replacedWith&&(w.collapsed=!0,w.widgetNode=b("span",[w.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||w.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(w.widgetNode.insertLeft=!0)),w.collapsed){if(Nr(e,t.line,t,n,w)||t.line!=n.line&&Nr(e,n.line,t,n,w))throw new Error("Inserting collapsed marker partially overlapping an existing one");be()}w.addToHistory&&Uo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var K=t.line,Y=e.cm,Z;if(e.iter(K,n.line+1,function(he){Y&&w.collapsed&&!Y.options.lineWrapping&&Yr(he)==Y.display.maxLine&&(Z=!0),w.collapsed&&K!=t.line&&qt(he,0),vt(he,new Ke(w,K==t.line?t.ch:null,K==n.line?n.ch:null)),++K}),w.collapsed&&e.iter(t.line,n.line+1,function(he){yn(e,he)&&qt(he,0)}),w.clearOnEnter&&we(w,"beforeCursorEnter",function(){return w.clear()}),w.readOnly&&(nt(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),w.collapsed&&(w.id=++ts,w.atomic=!0),Y){if(Z&&(Y.curOp.updateMaxLine=!0),w.collapsed)qr(Y,t.line,n.line+1);else if(w.className||w.startStyle||w.endStyle||w.css||w.attributes||w.title)for(var le=t.line;le<=n.line;le++)Rn(Y,le,"text");w.atomic&&Go(Y.doc),Hr(Y,"markerAdded",Y,w)}return w}var Pi=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};Pi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Hr(this,"clear")},Pi.prototype.find=function(e,t){return this.primary.find(e,t)},pe(Pi);function Sl(e,t,n,r,i){r=W(r),r.shared=!1;var w=[ai(e,t,n,r,i)],F=w[0],K=r.widgetNode;return On(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),w.push(ai(Y,u(Y,t),u(Y,n),r,i));for(var Z=0;Z<Y.linked.length;++Z)if(Y.linked[Z].isParent)return;F=Ae(w)}),new Pi(w,F)}function rs(e){return e.findMarks(Ie(e.first,0),e.clipPos(Ie(e.lastLine())),function(t){return t.parent})}function Cl(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),w=e.clipPos(i.from),F=e.clipPos(i.to);if(xt(w,F)){var K=ai(e,w,F,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function _l(e){for(var t=function(r){var i=e[r],w=[i.primary.doc];On(i.primary.doc,function(Y){return w.push(Y)});for(var F=0;F<i.markers.length;F++){var K=i.markers[F];fe(w,K.doc)==-1&&(K.parent=null,i.markers.splice(F--,1))}},n=0;n<e.length;n++)t(n)}var Tl=0,en=function(e,t,n,r,i){if(!(this instanceof en))return new en(e,t,n,r,i);n==null&&(n=0),ki.call(this,[new Ri([new Un("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var w=Ie(n,0);this.sel=Dn(w),this.history=new Ji(null),this.id=++Tl,this.modeOption=t,this.lineSep=r,this.direction=i=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Oa(this,{from:w,to:w,text:e}),Vr(this,Dn(w),Ee)};en.prototype=Ve(ki.prototype,{constructor:en,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Vt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Br(function(e){var t=Ie(this.first,0),n=this.first+this.size-1;ni(this,{from:t,to:Ie(n,Fe(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&Ei(this.cm,0,0),Vr(this,Dn(t),Ee)}),replaceRange:function(e,t,n,r){t=u(this,t),n=n?u(this,n):t,ii(this,e,t,n,r)},getRange:function(e,t,n){var r=nr(this,u(this,e),u(this,t));return n===!1?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(ir(this,e))return Fe(this,e)},getLineNumber:function(e){return Wt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Fe(this,e)),Yr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return u(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Br(function(e,t,n){Wo(this,u(this,typeof e=="number"?Ie(e,t||0):e),null,n)}),setSelection:Br(function(e,t,n){Wo(this,u(this,e),u(this,t||e),n)}),extendSelection:Br(function(e,t,n){Zi(this,u(this,e),t&&u(this,t),n)}),extendSelections:Br(function(e,t){jo(this,P(this,e),t)}),extendSelectionsBy:Br(function(e,t){var n=rt(this.sel.ranges,e);jo(this,P(this,n),t)}),setSelections:Br(function(e,t,n){if(!e.length)return;for(var r=[],i=0;i<e.length;i++)r[i]=new dr(u(this,e[i].anchor),u(this,e[i].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Vr(this,mn(this.cm,r,t),n)}),addSelection:Br(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new dr(u(this,e),u(this,t||e))),Vr(this,mn(this.cm,r,r.length-1),n)}),getSelection:function(e){for(var t=this.sel.ranges,n,r=0;r<t.length;r++){var i=nr(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=nr(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||this.lineSeparator())),t[r]=i}return t},replaceSelection:function(e,t,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:Br(function(e,t,n){for(var r=[],i=this.sel,w=0;w<i.ranges.length;w++){var F=i.ranges[w];r[w]={from:F.from(),to:F.to(),text:this.splitLines(e[w]),origin:n}}for(var K=t&&t!="end"&&hl(this,r,t),Y=r.length-1;Y>=0;Y--)ni(this,r[Y]);K?Ho(this,K):this.cm&&qn(this.cm)}),undo:Br(function(){ta(this,"undo")}),redo:Br(function(){ta(this,"redo")}),undoSelection:Br(function(){ta(this,"undo",!0)}),redoSelection:Br(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,n=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var i=0;i<e.undone.length;i++)e.undone[i].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){var e=this;this.history=new Ji(this.history.maxGeneration),On(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:ti(this.history.done),undone:ti(this.history.undone)}},setHistory:function(e){var t=this.history=new Ji(this.history.maxGeneration);t.done=ti(e.done.slice(0),null,!0),t.undone=ti(e.undone.slice(0),null,!0)},setGutterMarker:Br(function(e,t,n){return Li(this,e,"gutter",function(r){var i=r.gutterMarkers||(r.gutterMarkers={});return i[t]=n,!n&&Ge(i)&&(r.gutterMarkers=null),!0})}),clearGutter:Br(function(e){var t=this;this.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&Li(t,n,"gutter",function(){return n.gutterMarkers[e]=null,Ge(n.gutterMarkers)&&(n.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!ir(this,e))return null;if(t=e,e=Fe(this,e),!e)return null}else if(t=Wt(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:Br(function(e,t,n){return Li(this,e,t=="gutter"?"gutter":"class",function(r){var i=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[i])r[i]=n;else{if(x(n).test(r[i]))return!1;r[i]+=" "+n}return!0})}),removeLineClass:Br(function(e,t,n){return Li(this,e,t=="gutter"?"gutter":"class",function(r){var i=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",w=r[i];if(w)if(n==null)r[i]=null;else{var F=w.match(x(n));if(!F)return!1;var K=F.index+F[0].length;r[i]=w.slice(0,F.index)+(!F.index||K==w.length?"":" ")+w.slice(K)||null}else return!1;return!0})}),addLineWidget:Br(function(e,t,n){return xl(this,e,t,n)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return ai(this,u(this,e),u(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=u(this,e),ai(this,e,e,n,"bookmark")},findMarksAt:function(e){e=u(this,e);var t=[],n=Fe(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=u(this,e),t=u(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(w){var F=w.markedSpans;if(F)for(var K=0;K<F.length;K++){var Y=F[K];!(Y.to!=null&&i==e.line&&e.ch>=Y.to||Y.from==null&&i!=e.line||Y.from!=null&&i==t.line&&Y.from>=t.ch)&&(!n||n(Y.marker))&&r.push(Y.marker.parent||Y.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first,r=this.lineSeparator().length;return this.iter(function(i){var w=i.text.length+r;if(w>e)return t=e,!0;e-=w,++n}),u(this,Ie(n,t))},indexFromPos:function(e){e=u(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+n}),t},copy:function(e){var t=new en(Vt(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,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new en(Vt(this,t,n),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 Er&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),_l(rs(this));break}if(e.history==this.history){var r=[e.id];On(e,function(i){return r.push(i.id)},!0),e.history=new Ji(null),e.history.done=ti(this.history.done,r),e.history.undone=ti(this.history.undone,r)}},iterLinkedDocs:function(e){On(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Ze(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:Br(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)})}),en.prototype.eachLine=en.prototype.iter;var ns=0;function wl(e){var t=this;if(is(t),je(t,e)||_n(t.display,e))return;ee(e),z&&(ns=+new Date);var n=jn(t,e,!0),r=e.dataTransfer.files;if(!n||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,w=Array(i),F=0,K=function(){++F==i&&Ur(t,function(){n=u(t.doc,n);var ye={from:n,to:n,text:t.doc.splitLines(w.filter(function(Oe){return Oe!=null}).join(t.doc.lineSeparator())),origin:"paste"};ni(t.doc,ye),Ho(t.doc,Dn(u(t.doc,n),u(t.doc,Pn(ye))))})()},Y=function(ye,Oe){if(t.options.allowDropFileTypes&&fe(t.options.allowDropFileTypes,ye.type)==-1){K();return}var We=new FileReader;We.onerror=function(){return K()},We.onload=function(){var Ye=We.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ye)){K();return}w[Oe]=Ye,K()},We.readAsText(ye)},Z=0;Z<r.length;Z++)Y(r[Z],Z);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var le=e.dataTransfer.getData("Text");if(le){var he;if(t.state.draggingText&&!t.state.draggingText.copy&&(he=t.listSelections()),qi(t.doc,Dn(n,n)),he)for(var xe=0;xe<he.length;++xe)ii(t.doc,"",he[xe].anchor,he[xe].head,"drag");t.replaceSelection(le,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Al(e,t){if(z&&(!e.state.draggingText||+new Date-ns<100)){se(t);return}if(je(e,t)||_n(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!k){var n=a("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",L&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),L&&n.parentNode.removeChild(n)}}function Ll(e,t){var n=jn(e,t);if(!n)return;var r=document.createDocumentFragment();go(e,n,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),s(e.display.dragCursor,r)}function is(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"),n=[],r=0;r<t.length;r++){var i=t[r].CodeMirror;i&&n.push(i)}n.length&&n[0].operation(function(){for(var w=0;w<n.length;w++)e(n[w])})}var os=!1;function Rl(){if(os)return;kl(),os=!0}function kl(){var e;we(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Dl)},100))}),we(window,"blur",function(){return as(Zn)})}function Dl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var In={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"},Oi=0;Oi<10;Oi++)In[Oi+48]=In[Oi+96]=String(Oi);for(var ra=65;ra<=90;ra++)In[ra]=String.fromCharCode(ra);for(var Mi=1;Mi<=12;Mi++)In[Mi+111]=In[Mi+63235]="F"+Mi;var Tn={};Tn.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"},Tn.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"},Tn.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"},Tn.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"]},Tn.default=c?Tn.macDefault:Tn.pcDefault;function Pl(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,r,i,w,F=0;F<t.length-1;F++){var K=t[F];if(/^(cmd|meta|m)$/i.test(K))w=!0;else if(/^a(lt)?$/i.test(K))n=!0;else if(/^(c|ctrl|control)$/i.test(K))r=!0;else if(/^s(hift)?$/i.test(K))i=!0;else throw new Error("Unrecognized modifier name: "+K)}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),w&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ol(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}for(var i=rt(n.split(" "),Pl),w=0;w<i.length;w++){var F=void 0,K=void 0;w==i.length-1?(K=i.join(" "),F=r):(K=i.slice(0,w+1).join(" "),F="...");var Y=t[K];if(!Y)t[K]=F;else if(Y!=F)throw new Error("Inconsistent bindings for "+K)}delete e[n]}for(var Z in t)e[Z]=t[Z];return e}function oi(e,t,n,r){t=na(t);var i=t.call?t.call(e,r):t[e];if(i===!1)return"nothing";if(i==="...")return"multi";if(i!=null&&n(i))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return oi(e,t.fallthrough,n,r);for(var w=0;w<t.fallthrough.length;w++){var F=oi(e,t.fallthrough[w],n,r);if(F)return F}}}function ss(e){var t=typeof e=="string"?e:In[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,n){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),!n&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(L&&e.keyCode==34&&e.char)return!1;var n=In[e.keyCode];return n==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(n=e.code),ls(n,e,t))}function na(e){return typeof e=="string"?Tn[e]:e}function si(e,t){for(var n=e.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var w=t(n[i]);r.length&&xt(w.from,Ae(r).to)<=0;){var F=r.pop();if(xt(F.from,w.from)<0){w.from=F.from;break}}r.push(w)}an(e,function(){for(var K=r.length-1;K>=0;K--)ii(e.doc,"",r[K].from,r[K].to,"+delete");qn(e)})}function Ua(e,t,n){var r=Pe(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Ba(e,t,n){var r=Ua(e,t.ch,n);return r==null?null:new Ie(t.line,r,n<0?"after":"before")}function Fa(e,t,n,r,i){if(e){t.doc.direction=="rtl"&&(i=-i);var w=ct(n,t.doc.direction);if(w){var F=i<0?Ae(w):w[0],K=i<0==(F.level==1),Y=K?"after":"before",Z;if(F.level>0||t.doc.direction=="rtl"){var le=$n(t,n);Z=i<0?n.text.length-1:0;var he=En(t,le,Z).top;Z=pt(function(xe){return En(t,le,xe).top==he},i<0==(F.level==1)?F.from:F.to-1,Z),Y=="before"&&(Z=Ua(n,Z,1))}else Z=i<0?F.to:F.from;return new Ie(r,Z,Y)}}return new Ie(r,i<0?n.text.length:0,i<0?"before":"after")}function Ml(e,t,n,r){var i=ct(t,e.doc.direction);if(!i)return Ba(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var w=at(i,n.ch,n.sticky),F=i[w];if(e.doc.direction=="ltr"&&F.level%2==0&&(r>0?F.to>n.ch:F.from<n.ch))return Ba(t,n,r);var K=function(ot,yt){return Ua(t,ot instanceof Ie?ot.ch:ot,yt)},Y,Z=function(ot){return e.options.lineWrapping?(Y=Y||$n(e,t),ho(e,t,Y,ot)):{begin:0,end:t.text.length}},le=Z(n.sticky=="before"?K(n,-1):n.ch);if(e.doc.direction=="rtl"||F.level==1){var he=F.level==1==r<0,xe=K(n,he?1:-1);if(xe!=null&&(he?xe<=F.to&&xe<=le.end:xe>=F.from&&xe>=le.begin)){var ye=he?"before":"after";return new Ie(n.line,xe,ye)}}var Oe=function(ot,yt,st){for(var _t=function(yr,Fr){return Fr?new Ie(n.line,K(yr,1),"before"):new Ie(n.line,yr,"after")};ot>=0&&ot<i.length;ot+=yt){var Bt=i[ot],Ot=yt>0==(Bt.level!=1),Yt=Ot?st.begin:K(st.end,-1);if(Bt.from<=Yt&&Yt<Bt.to)return _t(Yt,Ot);if(Yt=Ot?Bt.from:K(Bt.to,-1),st.begin<=Yt&&Yt<st.end)return _t(Yt,Ot)}},We=Oe(w+r,r,le);if(We)return We;var Ye=r>0?le.end:K(le.begin,-1);return Ye!=null&&!(r>0&&Ye==t.text.length)&&(We=Oe(r>0?0:i.length-1,r,Z(Ye)),We)?We:null}var Ii={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ee)},killLine:function(e){return si(e,function(t){if(t.empty()){var n=Fe(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Ie(t.head.line+1,0)}:{from:t.head,to:Ie(t.head.line,n)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return si(e,function(t){return{from:Ie(t.from().line,0),to:u(e.doc,Ie(t.to().line+1,0))}})},delLineLeft:function(e){return si(e,function(t){return{from:Ie(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return si(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return si(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"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(Ie(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Ie(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 cs(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 n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},Te)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},Te)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?cs(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=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var w=n[i].from(),F=q(e.getLine(w.line),w.ch,r);t.push(ne(r-F%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return an(e,function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var i=t[r].head,w=Fe(e.doc,i.line).text;if(w){if(i.ch==w.length&&(i=new Ie(i.line,i.ch-1)),i.ch>0)i=new Ie(i.line,i.ch+1),e.replaceRange(w.charAt(i.ch-1)+w.charAt(i.ch-2),Ie(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var F=Fe(e.doc,i.line-1).text;F&&(i=new Ie(i.line,1),e.replaceRange(w.charAt(0)+e.doc.lineSeparator()+F.charAt(F.length-1),Ie(i.line-1,F.length-1),i,"+transpose"))}}n.push(new dr(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return an(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);qn(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function ds(e,t){var n=Fe(e.doc,t),r=Yr(n);return r!=n&&(t=Wt(r)),Fa(!0,e,r,t,1)}function Il(e,t){var n=Fe(e.doc,t),r=Yn(n);return r!=n&&(t=Wt(r)),Fa(!0,e,n,t,-1)}function cs(e,t){var n=ds(e,t.line),r=Fe(e.doc,n.line),i=ct(r,e.doc.direction);if(!i||i[0].level==0){var w=Math.max(n.ch,r.text.search(/\S/)),F=t.line==n.line&&t.ch<=w&&t.ch;return Ie(n.line,F?0:w,n.sticky)}return n}function ia(e,t,n){if(typeof t=="string"&&(t=Ii[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=De}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Nl(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=oi(t,e.state.keyMaps[r],n,e);if(i)return i}return e.options.extraKeys&&oi(t,e.options.extraKeys,n,e)||oi(t,e.options.keyMap,n,e)}var Ul=new oe;function Ni(e,t,n,r){var i=e.state.keySeq;if(i){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Ul.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),hs(e,i+" "+t,n,r))return!0}return hs(e,t,n,r)}function hs(e,t,n,r){var i=Nl(e,t,r);return i=="multi"&&(e.state.keySeq=t),i=="handled"&&Hr(e,"keyHandled",e,t,n),(i=="handled"||i=="multi")&&(ee(n),Sa(e)),!!i}function fs(e,t){var n=us(t,!0);return n?t.shiftKey&&!e.state.keySeq?Ni(e,"Shift-"+n,t,function(r){return ia(e,r,!0)})||Ni(e,n,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return ia(e,r)}):Ni(e,n,t,function(r){return ia(e,r)}):!1}function Bl(e,t,n){return Ni(e,"'"+n+"'",t,function(r){return ia(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(),je(t,e))return;z&&B<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var r=fs(t,e);L&&(ja=r?n:null,!r&&n==88&&!Ft&&(c?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),R&&!c&&!r&&n==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;H(t,"CodeMirror-crosshair");function n(r){(r.keyCode==18||!r.altKey)&&(f(t,"CodeMirror-crosshair"),lt(document,"keyup",n),lt(document,"mouseover",n))}we(document,"keyup",n),we(document,"mouseover",n)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),je(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(_n(t.display,e)||je(t,e)||e.ctrlKey&&!e.altKey||c&&e.metaKey)return;var n=e.keyCode,r=e.charCode;if(L&&n==ja){ja=null,ee(e);return}if(L&&(!e.which||e.which<10)&&fs(t,e))return;var i=String.fromCharCode(r==null?n:r);if(i=="\b")return;if(Bl(t,e,i))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,n){this.time=e,this.pos=t,this.button=n};Wa.prototype.compare=function(e,t,n){return this.time+jl>e&&xt(t,this.pos)==0&&n==this.button};var Ui,Bi;function Wl(e,t){var n=+new Date;return Bi&&Bi.compare(n,e,t)?(Ui=Bi=null,"triple"):Ui&&Ui.compare(n,e,t)?(Bi=new Wa(n,e,t),Ui=null,"double"):(Ui=new Wa(n,e,t),Bi=null,"single")}function vs(e){var t=this,n=t.display;if(je(t,e)||n.activeTouch&&n.input.supportsTouch())return;if(n.input.ensurePolled(),n.shift=e.shiftKey,_n(n,e)){O||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=jn(t,e),i=Se(e),w=r?Wl(r,i):"single";if(window.focus(),i==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,i,r,w,e))return;i==1?r?Gl(t,r,w,e):ue(e)==n.scroller&&ee(e):i==2?(r&&Zi(t.doc,r),setTimeout(function(){return n.input.focus()},20)):i==3&&(l?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,n,r,i){var w="Click";return r=="double"?w="Double"+w:r=="triple"&&(w="Triple"+w),w=(t==1?"Left":t==2?"Middle":"Right")+w,Ni(e,ls(w,i),i,function(F){if(typeof F=="string"&&(F=Ii[F]),!F)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=F(e,n)!=De}finally{e.state.suppressEdits=!1}return K})}function zl(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};if(i.unit==null){var w=d?n.shiftKey&&n.metaKey:n.altKey;i.unit=w?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(i.extend==null||e.doc.extend)&&(i.extend=e.doc.extend||n.shiftKey),i.addNew==null&&(i.addNew=c?n.metaKey:n.ctrlKey),i.moveOnDrag==null&&(i.moveOnDrag=!(c?n.altKey:n.ctrlKey)),i}function Gl(e,t,n,r){z?setTimeout(G(vo,e),0):e.curOp.focus=M();var i=zl(e,n,r),w=e.doc.sel,F;e.options.dragDrop&&ke&&!e.isReadOnly()&&n=="single"&&(F=w.contains(t))>-1&&(xt((F=w.ranges[F]).from(),t)<0||t.xRel>0)&&(xt(F.to(),t)>0||t.xRel<0)?Kl(e,r,t,i):Vl(e,r,t,i)}function Kl(e,t,n,r){var i=e.display,w=!1,F=Ur(e,function(Z){O&&(i.scroller.draggable=!1),e.state.draggingText=!1,lt(i.wrapper.ownerDocument,"mouseup",F),lt(i.wrapper.ownerDocument,"mousemove",K),lt(i.scroller,"dragstart",Y),lt(i.scroller,"drop",F),w||(ee(Z),r.addNew||Zi(e.doc,n,null,null,r.extend),O&&!k||z&&B==9?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),K=function(Z){w=w||Math.abs(t.clientX-Z.clientX)+Math.abs(t.clientY-Z.clientY)>=10},Y=function(){return w=!0};O&&(i.scroller.draggable=!0),e.state.draggingText=F,F.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),we(i.wrapper.ownerDocument,"mouseup",F),we(i.wrapper.ownerDocument,"mousemove",K),we(i.scroller,"dragstart",Y),we(i.scroller,"drop",F),yo(e),setTimeout(function(){return i.input.focus()},20)}function ys(e,t,n){if(n=="char")return new dr(t,t);if(n=="word")return e.findWordAt(t);if(n=="line")return new dr(Ie(t.line,0),u(e.doc,Ie(t.line+1,0)));var r=n(e,t);return new dr(r.from,r.to)}function Vl(e,t,n,r){var i=e.display,w=e.doc;ee(t);var F,K,Y=w.sel,Z=Y.ranges;if(r.addNew&&!r.extend?(K=w.sel.contains(n),K>-1?F=Z[K]:F=new dr(n,n)):(F=w.sel.primary(),K=w.sel.primIndex),r.unit=="rectangle")r.addNew||(F=new dr(n,n)),n=jn(e,t,!0,!0),K=-1;else{var le=ys(e,n,r.unit);r.extend?F=Ia(F,le.anchor,le.head,r.extend):F=le}r.addNew?K==-1?(K=Z.length,Vr(w,mn(e,Z.concat([F]),K),{scroll:!1,origin:"*mouse"})):Z.length>1&&Z[K].empty()&&r.unit=="char"&&!r.extend?(Vr(w,mn(e,Z.slice(0,K).concat(Z.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=w.sel):Na(w,K,F,_e):(K=0,Vr(w,new ln([F],0),_e),Y=w.sel);var he=n;function xe(st){if(xt(he,st)==0)return;if(he=st,r.unit=="rectangle"){for(var _t=[],Bt=e.options.tabSize,Ot=q(Fe(w,n.line).text,n.ch,Bt),Yt=q(Fe(w,st.line).text,st.ch,Bt),yr=Math.min(Ot,Yt),Fr=Math.max(Ot,Yt),Cr=Math.min(n.line,st.line),on=Math.min(e.lastLine(),Math.max(n.line,st.line));Cr<=on;Cr++){var tn=Fe(w,Cr).text,Rr=Ce(tn,yr,Bt);yr==Fr?_t.push(new dr(Ie(Cr,Rr),Ie(Cr,Rr))):tn.length>Rr&&_t.push(new dr(Ie(Cr,Rr),Ie(Cr,Ce(tn,Fr,Bt))))}_t.length||_t.push(new dr(n,n)),Vr(w,mn(e,Y.ranges.slice(0,K).concat(_t),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(st)}else{var rn=F,zr=ys(e,st,r.unit),Or=rn.anchor,kr;xt(zr.anchor,Or)>0?(kr=zr.head,Or=xr(rn.from(),zr.anchor)):(kr=zr.anchor,Or=dn(rn.to(),zr.head));var _r=Y.ranges.slice(0);_r[K]=Xl(e,new dr(u(w,Or),kr)),Vr(w,mn(e,_r,K),_e)}}var ye=i.wrapper.getBoundingClientRect(),Oe=0;function We(st){var _t=++Oe,Bt=jn(e,st,!0,r.unit=="rectangle");if(!Bt)return;if(xt(Bt,he)!=0){e.curOp.focus=M(),xe(Bt);var Ot=Vi(i,w);(Bt.line>=Ot.to||Bt.line<Ot.from)&&setTimeout(Ur(e,function(){Oe==_t&&We(st)}),150)}else{var Yt=st.clientY<ye.top?-20:st.clientY>ye.bottom?20:0;Yt&&setTimeout(Ur(e,function(){if(Oe!=_t)return;i.scroller.scrollTop+=Yt,We(st)}),50)}}function Ye(st){e.state.selectingText=!1,Oe=Infinity,st&&(ee(st),i.input.focus()),lt(i.wrapper.ownerDocument,"mousemove",ot),lt(i.wrapper.ownerDocument,"mouseup",yt),w.history.lastSelOrigin=null}var ot=Ur(e,function(st){st.buttons===0||!Se(st)?Ye(st):We(st)}),yt=Ur(e,Ye);e.state.selectingText=yt,we(i.wrapper.ownerDocument,"mousemove",ot),we(i.wrapper.ownerDocument,"mouseup",yt)}function Xl(e,t){var n=t.anchor,r=t.head,i=Fe(e.doc,n.line);if(xt(n,r)==0&&n.sticky==r.sticky)return t;var w=ct(i);if(!w)return t;var F=at(w,n.ch,n.sticky),K=w[F];if(K.from!=n.ch&&K.to!=n.ch)return t;var Y=F+(K.from==n.ch==(K.level!=1)?0:1);if(Y==0||Y==w.length)return t;var Z;if(r.line!=n.line)Z=(r.line-n.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var le=at(w,r.ch,r.sticky),he=le-F||(r.ch-n.ch)*(K.level==1?-1:1);le==Y-1||le==Y?Z=he<0:Z=he>0}var xe=w[Y+(Z?-1:0)],ye=Z==(xe.level==1),Oe=ye?xe.from:xe.to,We=ye?"after":"before";return n.ch==Oe&&n.sticky==We?t:new dr(new Ie(n.line,Oe,We),r)}function bs(e,t,n,r){var i,w;if(t.touches)i=t.touches[0].clientX,w=t.touches[0].clientY;else try{i=t.clientX,w=t.clientY}catch(xe){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var F=e.display,K=F.lineDiv.getBoundingClientRect();if(w>K.bottom||!de(e,n))return ie(t);w-=K.top-F.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Z=F.gutters.childNodes[Y];if(Z&&Z.getBoundingClientRect().right>=i){var le=Tr(e.doc,w),he=e.display.gutterSpecs[Y];return Re(e,n,e,le,he.className,t),ie(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function Es(e,t){if(_n(e.display,t)||Yl(e,t))return;if(je(e,t,"contextmenu"))return;l||e.display.input.onContextMenu(t)}function Yl(e,t){return de(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-"),yi(e)}var li={toString:function(){return"CodeMirror.Init"}},Ss={},aa={};function $l(e){var t=e.optionHandlers;function n(r,i,w,F){e.defaults[r]=i,w&&(t[r]=F?function(K,Y,Z){Z!=li&&w(K,Y,Z)}:w)}e.defineOption=n,e.Init=li,n("value","",function(r,i){return r.setValue(i)},!0),n("mode",null,function(r,i){r.doc.modeOption=i,Pa(r)},!0),n("indentUnit",2,Pa,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,function(r){wi(r),yi(r),qr(r)},!0),n("lineSeparator",null,function(r,i){if(r.doc.lineSep=i,!i)return;var w=[],F=r.doc.first;r.doc.iter(function(Y){for(var Z=0;;){var le=Y.text.indexOf(i,Z);if(le==-1)break;Z=le+i.length,w.push(Ie(F,le))}F++});for(var K=w.length-1;K>=0;K--)ii(r.doc,i,w[K],Ie(w[K].line,w[K].ch+i.length))}),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,i,w){r.state.specialChars=new RegExp(i.source+(i.test(" ")?"":"| "),"g"),w!=li&&r.refresh()}),n("specialCharPlaceholder",vr,function(r){return r.refresh()},!0),n("electricChars",!0),n("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),n("spellcheck",!1,function(r,i){return r.getInputField().spellcheck=i},!0),n("autocorrect",!1,function(r,i){return r.getInputField().autocorrect=i},!0),n("autocapitalize",!1,function(r,i){return r.getInputField().autocapitalize=i},!0),n("rtlMoveVisually",!_),n("wholeLineUpdateBefore",!0),n("theme","default",function(r){xs(r),Ti(r)},!0),n("keyMap","default",function(r,i,w){var F=na(i),K=w!=li&&na(w);K&&K.detach&&K.detach(r,F),F.attach&&F.attach(r,K||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Ql,!0),n("gutters",[],function(r,i){r.display.gutterSpecs=ka(i,r.options.lineNumbers),Ti(r)},!0),n("fixedGutter",!0,function(r,i){r.display.gutters.style.left=i?Ea(r.display)+"px":"0",r.refresh()},!0),n("coverGutterNextToScrollbar",!1,function(r){return ei(r)},!0),n("scrollbarStyle","native",function(r){_o(r),ei(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),n("lineNumbers",!1,function(r,i){r.display.gutterSpecs=ka(r.options.gutters,i),Ti(r)},!0),n("firstLineNumber",1,Ti,!0),n("lineNumberFormatter",function(r){return r},Ti,!0),n("showCursorWhenSelecting",!1,bi,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,function(r,i){i=="nocursor"&&(Zn(r),r.display.input.blur()),r.display.input.readOnlyChanged(i)}),n("screenReaderLabel",null,function(r,i){i=i===""?null:i,r.display.input.screenReaderLabelChanged(i)}),n("disableInput",!1,function(r,i){i||r.display.input.reset()},!0),n("dragDrop",!0,Jl),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,bi,!0),n("singleCursorHeightPerLine",!0,bi,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,wi,!0),n("addModeClass",!1,wi,!0),n("pollInterval",100),n("undoDepth",200,function(r,i){return r.doc.history.undoDepth=i}),n("historyEventDelay",1250),n("viewportMargin",10,function(r){return r.refresh()},!0),n("maxHighlightLength",1e4,wi,!0),n("moveInputWithCursor",!0,function(r,i){i||r.display.input.resetPosition()}),n("tabindex",null,function(r,i){return r.display.input.getField().tabIndex=i||""}),n("autofocus",null),n("direction","ltr",function(r,i){return r.doc.setDirection(i)},!0),n("phrases",null)}function Jl(e,t,n){var r=n&&n!=li;if(!t!=!r){var i=e.display.dragFunctions,w=t?we:lt;w(e.display.scroller,"dragstart",i.start),w(e.display.scroller,"dragenter",i.enter),w(e.display.scroller,"dragover",i.over),w(e.display.scroller,"dragleave",i.leave),w(e.display.scroller,"drop",i.drop)}}function Ql(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(f(e.display.wrapper,"CodeMirror-wrap"),ji(e)),xa(e),qr(e),yi(e),setTimeout(function(){return ei(e)},100)}function Er(e,t){var n=this;if(!(this instanceof Er))return new Er(e,t);this.options=t=t?W(t):{},W(Ss,t,!1);var r=t.value;typeof r=="string"?r=new en(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new Er.inputStyles[t.inputStyle](this),w=this.display=new dl(e,r,i,t);w.wrapper.CodeMirror=this,xs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),_o(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 oe,keySeq:null,specialChars:null},t.autofocus&&!o&&w.input.focus(),z&&B<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Zl(this),Rl(),Gn(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&Ca(n)},20):Zn(this);for(var F in aa)aa.hasOwnProperty(F)&&aa[F](this,t[F],li);Ao(this),t.finishInit&&t.finishInit(this);for(var K=0;K<za.length;++K)za[K](this);Kn(this),O&&t.lineWrapping&&getComputedStyle(w.lineDiv).textRendering=="optimizelegibility"&&(w.lineDiv.style.textRendering="auto")}Er.defaults=Ss,Er.optionHandlers=aa;function Zl(e){var t=e.display;we(t.scroller,"mousedown",Ur(e,vs)),z&&B<11?we(t.scroller,"dblclick",Ur(e,function(Y){if(je(e,Y))return;var Z=jn(e,Y);if(!Z||Ha(e,Y)||_n(e.display,Y))return;ee(Y);var le=e.findWordAt(Z);Zi(e.doc,le.anchor,le.head)})):we(t.scroller,"dblclick",function(Y){return je(e,Y)||ee(Y)}),we(t.scroller,"contextmenu",function(Y){return Es(e,Y)}),we(t.input.getField(),"contextmenu",function(Y){t.scroller.contains(Y.target)||Es(e,Y)});var n,r={end:0};function i(){t.activeTouch&&(n=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function w(Y){if(Y.touches.length!=1)return!1;var Z=Y.touches[0];return Z.radiusX<=1&&Z.radiusY<=1}function F(Y,Z){if(Z.left==null)return!0;var le=Z.left-Y.left,he=Z.top-Y.top;return le*le+he*he>20*20}we(t.scroller,"touchstart",function(Y){if(!je(e,Y)&&!w(Y)&&!Ha(e,Y)){t.input.ensurePolled(),clearTimeout(n);var Z=+new Date;t.activeTouch={start:Z,moved:!1,prev:Z-r.end<=300?r:null},Y.touches.length==1&&(t.activeTouch.left=Y.touches[0].pageX,t.activeTouch.top=Y.touches[0].pageY)}}),we(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),we(t.scroller,"touchend",function(Y){var Z=t.activeTouch;if(Z&&!_n(t,Y)&&Z.left!=null&&!Z.moved&&new Date-Z.start<300){var le=e.coordsChar(t.activeTouch,"page"),he;!Z.prev||F(Z,Z.prev)?he=new dr(le,le):!Z.prev.prev||F(Z,Z.prev.prev)?he=e.findWordAt(le):he=new dr(Ie(le.line,0),u(e.doc,Ie(le.line+1,0))),e.setSelection(he.anchor,he.head),e.focus(),ee(Y)}i()}),we(t.scroller,"touchcancel",i),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xi(e,t.scroller.scrollTop),Hn(e,t.scroller.scrollLeft,!0),Re(e,"scroll",e))}),we(t.scroller,"mousewheel",function(Y){return ko(e,Y)}),we(t.scroller,"DOMMouseScroll",function(Y){return ko(e,Y)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){je(e,Y)||se(Y)},over:function(Y){je(e,Y)||(Ll(e,Y),se(Y))},start:function(Y){return Al(e,Y)},drop:Ur(e,wl),leave:function(Y){je(e,Y)||is(e)}};var K=t.input.getField();we(K,"keyup",function(Y){return ms.call(e,Y)}),we(K,"keydown",Ur(e,ps)),we(K,"keypress",Ur(e,gs)),we(K,"focus",function(Y){return Ca(e,Y)}),we(K,"blur",function(Y){return Zn(e,Y)})}var za=[];Er.defineInitHook=function(e){return za.push(e)};function Fi(e,t,n,r){var i=e.doc,w;n==null&&(n="add"),n=="smart"&&(i.mode.indent?w=qe(e,t).state:n="prev");var F=e.options.tabSize,K=Fe(i,t),Y=q(K.text,null,F);K.stateAfter&&(K.stateAfter=null);var Z=K.text.match(/^\s*/)[0],le;if(!r&&!/\S/.test(K.text))le=0,n="not";else if(n=="smart"&&(le=i.mode.indent(w,K.text.slice(Z.length),K.text),le==De||le>150)){if(!r)return;n="prev"}n=="prev"?t>i.first?le=q(Fe(i,t-1).text,null,F):le=0:n=="add"?le=Y+e.options.indentUnit:n=="subtract"?le=Y-e.options.indentUnit:typeof n=="number"&&(le=Y+n),le=Math.max(0,le);var he="",xe=0;if(e.options.indentWithTabs)for(var ye=Math.floor(le/F);ye;--ye)xe+=F,he+=" ";if(xe<le&&(he+=ne(le-xe)),he!=Z)return ii(i,he,Ie(t,0),Ie(t,Z.length),"+input"),K.stateAfter=null,!0;for(var Oe=0;Oe<i.sel.ranges.length;Oe++){var We=i.sel.ranges[Oe];if(We.head.line==t&&We.head.ch<Z.length){var Ye=Ie(t,Z.length);Na(i,Oe,new dr(Ye,Ye));break}}}var gn=null;function oa(e){gn=e}function Ga(e,t,n,r,i){var w=e.doc;e.display.shift=!1,r||(r=w.sel);var F=+new Date-200,K=i=="paste"||e.state.pasteIncoming>F,Y=Ze(t),Z=null;if(K&&r.ranges.length>1)if(gn&&gn.text.join(`
|
|
`)==t){if(r.ranges.length%gn.text.length==0){Z=[];for(var le=0;le<gn.text.length;le++)Z.push(w.splitLines(gn.text[le]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Z=rt(Y,function(ot){return[ot]}));for(var he=e.curOp.updateInput,xe=r.ranges.length-1;xe>=0;xe--){var ye=r.ranges[xe],Oe=ye.from(),We=ye.to();ye.empty()&&(n&&n>0?Oe=Ie(Oe.line,Oe.ch-n):e.state.overwrite&&!K?We=Ie(We.line,Math.min(Fe(w,We.line).text.length,We.ch+Ae(Y).length)):K&&gn&&gn.lineWise&&gn.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(Oe=We=Ie(Oe.line,0)));var Ye={from:Oe,to:We,text:Z?Z[xe%Z.length]:Y,origin:i||(K?"paste":e.state.cutIncoming>F?"cut":"+input")};ni(e.doc,Ye),Hr(e,"inputRead",e,Ye)}t&&!K&&_s(e,t),qn(e),e.curOp.updateInput<2&&(e.curOp.updateInput=he),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Cs(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&an(t,function(){return Ga(t,n,0,null,"paste")}),!0}function _s(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)continue;var w=e.getModeAt(i.head),F=!1;if(w.electricChars){for(var K=0;K<w.electricChars.length;K++)if(t.indexOf(w.electricChars.charAt(K))>-1){F=Fi(e,i.head.line,"smart");break}}else w.electricInput&&(w.electricInput.test(Fe(e.doc,i.head.line).text.slice(0,i.head.ch))&&(F=Fi(e,i.head.line,"smart")));F&&Hr(e,"electricInput",e,i.head.line)}}function Ts(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var i=e.doc.sel.ranges[r].head.line,w={anchor:Ie(i,0),head:Ie(i+1,0)};n.push(w),t.push(e.getRange(w.anchor,w.head))}return{text:t,ranges:n}}function ws(e,t,n,r){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return O?e.style.width="1000px":e.setAttribute("wrap","off"),C&&(e.style.border="1px solid black"),ws(e),t}function ql(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,i){var w=this.options,F=w[r];if(w[r]==i&&r!="mode")return;w[r]=i,t.hasOwnProperty(r)&&Ur(this,t[r])(this,i,F),Re(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,i){this.state.keyMaps[i?"push":"unshift"](na(r))},removeKeyMap:function(r){for(var i=this.state.keyMaps,w=0;w<i.length;++w)if(i[w]==r||i[w].name==r)return i.splice(w,1),!0},addOverlay:$r(function(r,i){var w=r.token?r:e.getMode(this.options,r);if(w.startState)throw new Error("Overlays may not be stateful.");$e(this.state.overlays,{mode:w,modeSpec:r,opaque:i&&i.opaque,priority:i&&i.priority||0},function(F){return F.priority}),this.state.modeGen++,qr(this)}),removeOverlay:$r(function(r){for(var i=this.state.overlays,w=0;w<i.length;++w){var F=i[w].modeSpec;if(F==r||typeof r=="string"&&F.name==r){i.splice(w,1),this.state.modeGen++,qr(this);return}}}),indentLine:$r(function(r,i,w){typeof i!="string"&&typeof i!="number"&&(i==null?i=this.options.smartIndent?"smart":"prev":i=i?"add":"subtract"),ir(this.doc,r)&&Fi(this,r,i,w)}),indentSelection:$r(function(r){for(var i=this.doc.sel.ranges,w=-1,F=0;F<i.length;F++){var K=i[F];if(K.empty())K.head.line>w&&(Fi(this,K.head.line,r,!0),w=K.head.line,F==this.doc.sel.primIndex&&qn(this));else{var Y=K.from(),Z=K.to(),le=Math.max(w,Y.line);w=Math.min(this.lastLine(),Z.line-(Z.ch?0:1))+1;for(var he=le;he<w;++he)Fi(this,he,r);var xe=this.doc.sel.ranges;Y.ch==0&&i.length==xe.length&&xe[F].from().ch>0&&Na(this.doc,F,new dr(Y,xe[F].to()),Ee)}}}),getTokenAt:function(r,i){return fr(this,r,i)},getLineTokens:function(r,i){return fr(this,Ie(r),i,!0)},getTokenTypeAt:function(r){r=u(this.doc,r);var i=Ne(this,Fe(this.doc,r.line)),w=0,F=(i.length-1)/2,K=r.ch,Y;if(K==0)Y=i[2];else for(;;){var Z=w+F>>1;if((Z?i[Z*2-1]:0)>=K)F=Z;else if(i[Z*2+1]<K)w=Z+1;else{Y=i[Z*2+2];break}}var le=Y?Y.indexOf("overlay "):-1;return le<0?Y:le==0?null:Y.slice(0,le-1)},getModeAt:function(r){var i=this.doc.mode;return i.innerMode?e.innerMode(i,this.getTokenAt(r).state).mode:i},getHelper:function(r,i){return this.getHelpers(r,i)[0]},getHelpers:function(r,i){var w=[];if(!n.hasOwnProperty(i))return w;var F=n[i],K=this.getModeAt(r);if(typeof K[i]=="string")F[K[i]]&&w.push(F[K[i]]);else if(K[i])for(var Y=0;Y<K[i].length;Y++){var Z=F[K[i][Y]];Z&&w.push(Z)}else K.helperType&&F[K.helperType]?w.push(F[K.helperType]):F[K.name]&&w.push(F[K.name]);for(var le=0;le<F._global.length;le++){var he=F._global[le];he.pred(K,this)&&fe(w,he.val)==-1&&w.push(he.val)}return w},getStateAfter:function(r,i){var w=this.doc;return r=U(w,r==null?w.first+w.size-1:r),qe(this,r+1,i).state},cursorCoords:function(r,i){var w,F=this.doc.sel.primary();return r==null?w=F.head:typeof r=="object"?w=u(this.doc,r):w=r?F.from():F.to(),pn(this,w,i||"page")},charCoords:function(r,i){return ma(this,u(this.doc,r),i||"page")},coordsChar:function(r,i){return r=lo(this,r,i||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,i){return r=lo(this,{top:r,left:0},i||"page").top,Tr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,i,w){var F=!1,K;if(typeof r=="number"){var Y=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>Y&&(r=Y,F=!0),K=Fe(this.doc,r)}else K=r;return Hi(this,K,{top:0,left:0},i||"page",w||F).top+(F?this.doc.height-fn(K):0)},defaultTextHeight:function(){return Jn(this.display)},defaultCharWidth:function(){return Qn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,i,w,F,K){var Y=this.display;r=pn(this,u(this.doc,r));var Z=r.bottom,le=r.left;if(i.style.position="absolute",i.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(i),Y.sizer.appendChild(i),F=="over")Z=r.top;else if(F=="above"||F=="near"){var he=Math.max(Y.wrapper.clientHeight,this.doc.height),xe=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(F=="above"||r.bottom+i.offsetHeight>he)&&r.top>i.offsetHeight?Z=r.top-i.offsetHeight:r.bottom+i.offsetHeight<=he&&(Z=r.bottom),le+i.offsetWidth>xe&&(le=xe-i.offsetWidth)}i.style.top=Z+"px",i.style.left=i.style.right="",K=="right"?(le=Y.sizer.clientWidth-i.offsetWidth,i.style.right="0px"):(K=="left"?le=0:K=="middle"&&(le=(Y.sizer.clientWidth-i.offsetWidth)/2),i.style.left=le+"px"),w&&Js(this,{left:le,top:Z,right:le+i.offsetWidth,bottom:Z+i.offsetHeight})},triggerOnKeyDown:$r(ps),triggerOnKeyPress:$r(gs),triggerOnKeyUp:ms,triggerOnMouseDown:$r(vs),execCommand:function(r){if(Ii.hasOwnProperty(r))return Ii[r].call(null,this)},triggerElectric:$r(function(r){_s(this,r)}),findPosH:function(r,i,w,F){var K=1;i<0&&(K=-1,i=-i);for(var Y=u(this.doc,r),Z=0;Z<i&&!(Y=Ka(this.doc,Y,K,w,F),Y.hitSide);++Z);return Y},moveH:$r(function(r,i){var w=this;this.extendSelectionsBy(function(F){return w.display.shift||w.doc.extend||F.empty()?Ka(w.doc,F.head,r,i,w.options.rtlMoveVisually):r<0?F.from():F.to()},Te)}),deleteH:$r(function(r,i){var w=this.doc.sel,F=this.doc;w.somethingSelected()?F.replaceSelection("",null,"+delete"):si(this,function(K){var Y=Ka(F,K.head,r,i,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,i,w,F){var K=1,Y=F;i<0&&(K=-1,i=-i);for(var Z=u(this.doc,r),le=0;le<i;++le){var he=pn(this,Z,"div");if(Y==null?Y=he.left:he.left=Y,Z=Ls(this,he,K,w),Z.hitSide)break}return Z},moveV:$r(function(r,i){var w=this,F=this.doc,K=[],Y=!this.display.shift&&!F.extend&&F.sel.somethingSelected();if(F.extendSelectionsBy(function(le){if(Y)return r<0?le.from():le.to();var he=pn(w,le.head,"div");le.goalColumn!=null&&(he.left=le.goalColumn),K.push(he.left);var xe=Ls(w,he,r,i);return i=="page"&&le==F.sel.primary()&&Ta(w,ma(w,xe,"div").top-he.top),xe},Te),K.length)for(var Z=0;Z<F.sel.ranges.length;Z++)F.sel.ranges[Z].goalColumn=K[Z]}),findWordAt:function(r){var i=this.doc,w=Fe(i,r.line).text,F=r.ch,K=r.ch;if(w){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==w.length)&&F?--F:++K;for(var Z=w.charAt(F),le=ze(Z,Y)?function(he){return ze(he,Y)}:/\s/.test(Z)?function(he){return/\s/.test(he)}:function(he){return!/\s/.test(he)&&!ze(he)};F>0&&le(w.charAt(F-1));)--F;for(;K<w.length&&le(w.charAt(K));)++K}return new dr(Ie(r.line,F),Ie(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?H(this.display.cursorDiv,"CodeMirror-overwrite"):f(this.display.cursorDiv,"CodeMirror-overwrite"),Re(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==M()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:$r(function(r,i){Ei(this,r,i)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-bn(this)-this.display.barHeight,width:r.scrollWidth-bn(this)-this.display.barWidth,clientHeight:ha(this),clientWidth:Bn(this)}},scrollIntoView:$r(function(r,i){r==null?(r={from:this.doc.sel.primary().head,to:null},i==null&&(i=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Ie(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=i||0,r.from.line!=null?Qs(this,r):Eo(this,r.from,r.to,r.margin)}),setSize:$r(function(r,i){var w=this,F=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=F(r)),i!=null&&(this.display.wrapper.style.height=F(i)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(Y){if(Y.widgets){for(var Z=0;Z<Y.widgets.length;Z++)if(Y.widgets[Z].noHScroll){Rn(w,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,Re(this,"refresh",this)}),operation:function(r){return an(this,r)},startOperation:function(){return Gn(this)},endOperation:function(){return Kn(this)},refresh:$r(function(){var r=this.display.cachedTextHeight;qr(this),this.curOp.forceUpdate=!0,yi(this),Ei(this,this.doc.scrollLeft,this.doc.scrollTop),La(this.display),(r==null||Math.abs(r-Jn(this.display))>.5||this.options.lineWrapping)&&xa(this),Re(this,"refresh",this)}),swapDoc:$r(function(r){var i=this.doc;return i.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),yi(this),this.display.input.reset(),Ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Hr(this,"swapDoc",this,i),i}),phrase:function(r){var i=this.options.phrases;return i&&Object.prototype.hasOwnProperty.call(i,r)?i[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}},pe(e),e.registerHelper=function(r,i,w){n.hasOwnProperty(r)||(n[r]=e[r]={_global:[]}),n[r][i]=w},e.registerGlobalHelper=function(r,i,w,F){e.registerHelper(r,i,F),n[r]._global.push({pred:w,val:F})}}function Ka(e,t,n,r,i){var w=t,F=n,K=Fe(e,t.line),Y=i&&e.direction=="rtl"?-n:n;function Z(){var yt=t.line+Y;return yt<e.first||yt>=e.first+e.size?!1:(t=new Ie(yt,t.ch,t.sticky),K=Fe(e,yt))}function le(yt){var st;if(r=="codepoint"){var _t=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(_t)?st=null:st=new Ie(t.line,Math.max(0,Math.min(K.text.length,t.ch+n*(_t>=55296&&_t<56320?2:1))),-n)}else i?st=Ml(e.cm,K,t,n):st=Ba(K,t,n);if(st==null)if(!yt&&Z())t=Fa(i,e.cm,K,t.line,Y);else return!1;else t=st;return!0}if(r=="char"||r=="codepoint")le();else if(r=="column")le(!0);else if(r=="word"||r=="group")for(var he=null,xe=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),Oe=!0;!(n<0&&!le(!Oe));Oe=!1){var We=K.text.charAt(t.ch)||`
|
|
`,Ye=ze(We,ye)?"w":xe&&We==`
|
|
`?"n":!xe||/\s/.test(We)?null:"p";if(xe&&!Oe&&!Ye&&(Ye="s"),he&&he!=Ye){n<0&&(n=1,le(),t.sticky="after");break}if(Ye&&(he=Ye),n>0&&!le(!Oe))break}var ot=ea(e,t,w,F,!0);return Dr(w,ot)&&(ot.hitSide=!0),ot}function Ls(e,t,n,r){var i=e.doc,w=t.left,F;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),Y=Math.max(K-.5*Jn(e.display),3);F=(n>0?t.bottom:t.top)+n*Y}else r=="line"&&(F=n>0?t.bottom+3:t.top-3);for(var Z;!(Z=va(e,w,F),!Z.outside);){if(n<0?F<=0:F>=i.height){Z.hitSide=!0;break}F+=n*5}return Z}var mr=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new oe,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};mr.prototype.init=function(e){var t=this,n=this,r=n.cm,i=n.div=e.lineDiv;ws(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function w(K){for(var Y=K.target;Y;Y=Y.parentNode){if(Y==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(Y.className))break}return!1}we(i,"paste",function(K){if(!w(K)||je(r,K)||Cs(K,r))return;B<=11&&setTimeout(Ur(r,function(){return t.updateFromDOM()}),20)}),we(i,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),we(i,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),we(i,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(i,"touchstart",function(){return n.forceCompositionEnd()}),we(i,"input",function(){t.composing||t.readFromDOMSoon()});function F(K){if(!w(K)||je(r,K))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var Y=Ts(r);oa({lineWise:!0,text:Y.text}),K.type=="cut"&&r.operation(function(){r.setSelections(Y.ranges,0,Ee),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var Z=gn.text.join(`
|
|
`);if(K.clipboardData.setData("Text",Z),K.clipboardData.getData("Text")==Z){K.preventDefault();return}}var le=As(),he=le.firstChild;r.display.lineSpace.insertBefore(le,r.display.lineSpace.firstChild),he.value=gn.text.join(`
|
|
`);var xe=document.activeElement;Q(he),setTimeout(function(){r.display.lineSpace.removeChild(le),xe.focus(),xe==i&&n.showPrimarySelection()},50)}we(i,"copy",F),we(i,"cut",F)},mr.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},mr.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},mr.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},mr.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},mr.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),r=n.from(),i=n.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||i.line<t.display.viewFrom){e.removeAllRanges();return}var w=sa(t,e.anchorNode,e.anchorOffset),F=sa(t,e.focusNode,e.focusOffset);if(w&&!w.bad&&F&&!F.bad&&xt(xr(w,F),r)==0&&xt(dn(w,F),i)==0)return;var K=t.display.view,Y=r.line>=t.display.viewFrom&&Rs(t,r)||{node:K[0].measure.map[2],offset:0},Z=i.line<t.display.viewTo&&Rs(t,i);if(!Z){var le=K[K.length-1].measure,he=le.maps?le.maps[le.maps.length-1]:le.map;Z={node:he[he.length-1],offset:he[he.length-2]-he[he.length-3]}}if(!Y||!Z){e.removeAllRanges();return}var xe=e.rangeCount&&e.getRangeAt(0),ye;try{ye=v(Y.node,Y.offset,Z.offset,Z.node)}catch(Oe){}ye&&(!R&&t.state.focused?(e.collapse(Y.node,Y.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),xe&&e.anchorNode==null?e.addRange(xe):R&&this.startGracePeriod()),this.rememberSelection()},mr.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)},mr.prototype.showMultipleSelections=function(e){s(this.cm.display.cursorDiv,e.cursors),s(this.cm.display.selectionDiv,e.selection)},mr.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},mr.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return S(this.div,t)},mr.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},mr.prototype.blur=function(){this.div.blur()},mr.prototype.getField=function(){return this.div},mr.prototype.supportsTouch=function(){return!0},mr.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():an(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)},mr.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},mr.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(h&&E&&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 n=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);n&&r&&an(t,function(){Vr(t.doc,Dn(n,r),Ee),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},mr.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.ch==0&&r.line>e.firstLine()&&(r=Ie(r.line-1,Fe(e.doc,r.line-1).length)),i.ch==Fe(e.doc,i.line).text.length&&i.line<e.lastLine()&&(i=Ie(i.line+1,0)),r.line<t.viewFrom||i.line>t.viewTo-1)return!1;var w,F,K;r.line==t.viewFrom||(w=Wn(e,r.line))==0?(F=Wt(t.view[0].line),K=t.view[0].node):(F=Wt(t.view[w].line),K=t.view[w-1].node.nextSibling);var Y=Wn(e,i.line),Z,le;if(Y==t.view.length-1?(Z=t.viewTo-1,le=t.lineDiv.lastChild):(Z=Wt(t.view[Y+1].line)-1,le=t.view[Y+1].node.previousSibling),!K)return!1;for(var he=e.doc.splitLines(tu(e,K,le,F,Z)),xe=nr(e.doc,Ie(F,0),Ie(Z,Fe(e.doc,Z).text.length));he.length>1&&xe.length>1;)if(Ae(he)==Ae(xe))he.pop(),xe.pop(),Z--;else if(he[0]==xe[0])he.shift(),xe.shift(),F++;else break;for(var ye=0,Oe=0,We=he[0],Ye=xe[0],ot=Math.min(We.length,Ye.length);ye<ot&&We.charCodeAt(ye)==Ye.charCodeAt(ye);)++ye;for(var yt=Ae(he),st=Ae(xe),_t=Math.min(yt.length-(he.length==1?ye:0),st.length-(xe.length==1?ye:0));Oe<_t&&yt.charCodeAt(yt.length-Oe-1)==st.charCodeAt(st.length-Oe-1);)++Oe;if(he.length==1&&xe.length==1&&F==r.line)for(;ye&&ye>r.ch&&yt.charCodeAt(yt.length-Oe-1)==st.charCodeAt(st.length-Oe-1);)ye--,Oe++;he[he.length-1]=yt.slice(0,yt.length-Oe).replace(/^\u200b+/,""),he[0]=he[0].slice(ye).replace(/\u200b+$/,"");var Bt=Ie(F,ye),Ot=Ie(Z,xe.length?Ae(xe).length-Oe:0);if(he.length>1||he[0]||xt(Bt,Ot))return ii(e.doc,he,Bt,Ot,"+input"),!0},mr.prototype.ensurePolled=function(){this.forceCompositionEnd()},mr.prototype.reset=function(){this.forceCompositionEnd()},mr.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},mr.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)},mr.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&an(this.cm,function(){return qr(e.cm)})},mr.prototype.setUneditable=function(e){e.contentEditable="false"},mr.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||Ur(this.cm,Ga)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},mr.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},mr.prototype.onContextMenu=function(){},mr.prototype.resetPosition=function(){},mr.prototype.needsContentAttribute=!0;function Rs(e,t){var n=fa(e,t.line);if(!n||n.hidden)return null;var r=Fe(e.doc,t.line),i=eo(n,r,t.line),w=ct(r,e.doc.direction),F="left";if(w){var K=at(w,t.ch);F=K%2?"right":"left"}var Y=no(i.map,t.ch,F);return Y.offset=Y.collapse=="right"?Y.end:Y.start,Y}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function ui(e,t){return t&&(e.bad=!0),e}function tu(e,t,n,r,i){var w="",F=!1,K=e.doc.lineSeparator(),Y=!1;function Z(ye){return function(Oe){return Oe.id==ye}}function le(){F&&(w+=K,Y&&(w+=K),F=Y=!1)}function he(ye){ye&&(le(),w+=ye)}function xe(ye){if(ye.nodeType==1){var Oe=ye.getAttribute("cm-text");if(Oe){he(Oe);return}var We=ye.getAttribute("cm-marker"),Ye;if(We){var ot=e.findMarks(Ie(r,0),Ie(i+1,0),Z(+We));ot.length&&(Ye=ot[0].find(0))&&he(nr(e.doc,Ye.from,Ye.to).join(K));return}if(ye.getAttribute("contenteditable")=="false")return;var yt=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;yt&&le();for(var st=0;st<ye.childNodes.length;st++)xe(ye.childNodes[st]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),yt&&(F=!0)}else ye.nodeType==3&&he(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(xe(t),t==n);)t=t.nextSibling,Y=!1;return w}function sa(e,t,n){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[n],!r)return ui(e.clipPos(Ie(e.display.viewTo-1)),!0);t=null,n=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 i=0;i<e.display.view.length;i++){var w=e.display.view[i];if(w.node==r)return ru(w,t,n)}}function ru(e,t,n){var r=e.text.firstChild,i=!1;if(!t||!S(r,t))return ui(Ie(Wt(e.line),0),!0);if(t==r&&(i=!0,t=r.childNodes[n],n=0,!t)){var w=e.rest?Ae(e.rest):e.line;return ui(Ie(Wt(w),w.text.length),i)}var F=t.nodeType==3?t:null,K=t;for(!F&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(F=t.firstChild,n&&(n=F.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,Z=Y.maps;function le(Ye,ot,yt){for(var st=-1;st<(Z?Z.length:0);st++)for(var _t=st<0?Y.map:Z[st],Bt=0;Bt<_t.length;Bt+=3){var Ot=_t[Bt+2];if(Ot==Ye||Ot==ot){var Yt=Wt(st<0?e.line:e.rest[st]),yr=_t[Bt]+yt;return(yt<0||Ot!=Ye)&&(yr=_t[Bt+(yt?1:0)]),Ie(Yt,yr)}}}var he=le(F,K,n);if(he)return ui(he,i);for(var xe=K.nextSibling,ye=F?F.nodeValue.length-n:0;xe;xe=xe.nextSibling){if(he=le(xe,xe.firstChild,0),he)return ui(Ie(he.line,he.ch-ye),i);ye+=xe.textContent.length}for(var Oe=K.previousSibling,We=n;Oe;Oe=Oe.previousSibling){if(he=le(Oe,Oe.firstChild,-1),he)return ui(Ie(he.line,he.ch+We),i);We+=Oe.textContent.length}}var Ar=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new oe,this.hasSelection=!1,this.composing=null};Ar.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),C&&(i.style.width="0px"),we(i,"input",function(){z&&B>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),we(i,"paste",function(F){if(je(r,F)||Cs(F,r))return;r.state.pasteIncoming=+new Date,n.fastPoll()});function w(F){if(je(r,F))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=Ts(r);oa({lineWise:!0,text:K.text}),F.type=="cut"?r.setSelections(K.ranges,null,Ee):(n.prevInput="",i.value=K.text.join(`
|
|
`),Q(i))}else return;F.type=="cut"&&(r.state.cutIncoming=+new Date)}we(i,"cut",w),we(i,"copy",w),we(e.scroller,"paste",function(F){if(_n(e,F)||je(r,F))return;if(!i.dispatchEvent){r.state.pasteIncoming=+new Date,n.focus();return}var K=new Event("paste");K.clipboardData=F.clipboardData,i.dispatchEvent(K)}),we(e.lineSpace,"selectstart",function(F){_n(e,F)||ee(F)}),we(i,"compositionstart",function(){var F=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:F,range:r.markText(F,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(i,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Ar.prototype.createField=function(e){this.wrapper=As(),this.textarea=this.wrapper.firstChild},Ar.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Ar.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var i=pn(e,n.sel.primary().head,"div"),w=t.wrapper.getBoundingClientRect(),F=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+F.top-w.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+F.left-w.left))}return r},Ar.prototype.showSelection=function(e){var t=this.cm,n=t.display;s(n.cursorDiv,e.cursors),s(n.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ar.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&Q(this.textarea),z&&B>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",z&&B>=9&&(this.hasSelection=null))},Ar.prototype.getField=function(){return this.textarea},Ar.prototype.supportsTouch=function(){return!1},Ar.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||M()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ar.prototype.blur=function(){this.textarea.blur()},Ar.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ar.prototype.receivedFocus=function(){this.slowPoll()},Ar.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()})},Ar.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function n(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,n)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,n)},Ar.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ut(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(z&&B>=9&&this.hasSelection===i||c&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var w=i.charCodeAt(0);if(w==8203&&!r&&(r="\u200B"),w==8666)return this.reset(),this.cm.execCommand("undo")}for(var F=0,K=Math.min(r.length,i.length);F<K&&r.charCodeAt(F)==i.charCodeAt(F);)++F;return an(t,function(){Ga(t,i.slice(F),r.length-F,null,e.composing?"*compose":null),i.length>1e3||i.indexOf(`
|
|
`)>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Ar.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ar.prototype.onKeyPress=function(){z&&B>=9&&(this.hasSelection=null),this.fastPoll()},Ar.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var w=jn(n,e),F=r.scroller.scrollTop;if(!w||L)return;var K=n.options.resetSelectionOnContextMenu;K&&n.doc.sel.contains(w)==-1&&Ur(n,Vr)(n.doc,Dn(w),Ee);var Y=i.style.cssText,Z=t.wrapper.style.cssText,le=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",i.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-le.top-5)+"px; left: "+(e.clientX-le.left-5)+`px;
|
|
z-index: 1000; background: `+(z?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var he;O&&(he=window.scrollY),r.input.focus(),O&&window.scrollTo(null,he),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(i.selectionStart!=null){var We=n.somethingSelected(),Ye="\u200B"+(We?i.value:"");i.value="\u21DA",i.value=Ye,t.prevInput=We?"":"\u200B",i.selectionStart=1,i.selectionEnd=Ye.length,r.selForContextMenu=n.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Z,i.style.cssText=Y,z&&B<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=F),i.selectionStart!=null){(!z||z&&B<9)&&xe();var We=0,Ye=function(){r.selForContextMenu==n.doc.sel&&i.selectionStart==0&&i.selectionEnd>0&&t.prevInput=="\u200B"?Ur(n,Xo)(n):We++<10?r.detectingSelectAll=setTimeout(Ye,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ye,200)}}if(z&&B>=9&&xe(),l){se(e);var Oe=function(){lt(window,"mouseup",Oe),setTimeout(ye,20)};we(window,"mouseup",Oe)}else setTimeout(ye,50)},Ar.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Ar.prototype.setUneditable=function(){},Ar.prototype.needsContentAttribute=!1;function nu(e,t){if(t=t?W(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 n=M();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function r(){e.value=K.getValue()}var i;if(e.form&&(we(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var w=e.form;i=w.submit;try{var F=w.submit=function(){r(),w.submit=i,w.submit(),w.submit=F}}catch(Y){}}t.finishInit=function(Y){Y.save=r,Y.getTextArea=function(){return e},Y.toTextArea=function(){Y.toTextArea=isNaN,r(),e.parentNode.removeChild(Y.getWrapperElement()),e.style.display="",e.form&&(lt(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=i))}},e.style.display="none";var K=Er(function(Y){return e.parentNode.insertBefore(Y,e.nextSibling)},t);return K}function iu(e){e.off=lt,e.on=we,e.wheelEventPixels=cl,e.Doc=en,e.splitLines=Ze,e.countColumn=q,e.findColumn=Ce,e.isWordChar=Me,e.Pass=De,e.signal=Re,e.Line=Un,e.changeEnd=Pn,e.scrollbarModel=Co,e.Pos=Ie,e.cmpPos=xt,e.modes=$t,e.mimeModes=Lt,e.resolveMode=ft,e.getMode=Xt,e.modeExtensions=zt,e.extendMode=Gt,e.copyState=Ut,e.startState=St,e.innerMode=Mt,e.commands=Ii,e.keyMap=Tn,e.keyName=us,e.isModifierKey=ss,e.lookupKey=oi,e.normalizeKeyMap=Ol,e.StringStream=tt,e.SharedTextMarker=Pi,e.TextMarker=Mn,e.LineWidget=Di,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=se,e.addClass=H,e.contains=S,e.rmClass=f,e.keyNames=In}$l(Er),ql(Er);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in en.prototype)en.prototype.hasOwnProperty(la)&&fe(au,la)<0&&(Er.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(en.prototype[la]));return pe(en),Er.inputStyles={textarea:Ar,contenteditable:mr},Er.defineMode=function(e){!Er.defaults.mode&&e!="null"&&(Er.defaults.mode=e),Qt.apply(this,arguments)},Er.defineMIME=Zt,Er.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Er.defineMIME("text/plain","null"),Er.defineExtension=function(e,t){Er.prototype[e]=t},Er.defineDocExtension=function(e,t){en.prototype[e]=t},Er.fromTextArea=nu,iu(Er),Er.version="5.58.2",Er})},Y1PL:function(At,ht,re){"use strict";re.r(ht),re.d(ht,"ResizableTextArea",function(){return fe});var ae=re("wx14"),$=re("1OyB"),R=re("vuIU"),X=re("Ji7U"),N=re("LK+K"),I=re("q1tI"),z=re("VTBJ"),B=re("rePB"),O=re("Zm9Q"),D=re("Kwbf"),E=re("c+Xe"),L=re("m+aA"),k=re("bdgK"),T=new Map;function A(Ee){Ee.forEach(function(_e){var Te,Ce=_e.target;(Te=T.get(Ce))===null||Te===void 0||Te.forEach(function(me){return me(Ce)})})}var C=new k.default(A),h=null,o=null;function c(Ee,_e){T.has(Ee)||(T.set(Ee,new Set),C.observe(Ee)),T.get(Ee).add(_e)}function d(Ee,_e){T.has(Ee)&&(T.get(Ee).delete(_e),T.get(Ee).size||(C.unobserve(Ee),T.delete(Ee)))}var _=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(){return Object($.a)(this,Te),_e.apply(this,arguments)}return Object(R.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(I.Component),y=I.createContext(null);function m(Ee){var _e=Ee.children,Te=Ee.onBatchResize,Ce=I.useRef(0),me=I.useRef([]),ne=I.useContext(y),Ae=I.useCallback(function(rt,$e,Xe){Ce.current+=1;var Ve=Ce.current;me.current.push({size:rt,element:$e,data:Xe}),Promise.resolve().then(function(){Ve===Ce.current&&(Te==null||Te(me.current),me.current=[])}),ne==null||ne(rt,$e,Xe)},[Te,ne]);return I.createElement(y.Provider,{value:Ae},_e)}function l(Ee){var _e=Ee.children,Te=Ee.disabled,Ce=I.useRef(null),me=I.useRef(null),ne=I.useContext(y),Ae=I.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),rt=I.isValidElement(_e)&&Object(E.c)(_e),$e=rt?_e.ref:null,Xe=I.useMemo(function(){return Object(E.a)($e,Ce)},[$e,Ce]),Ve=I.useRef(Ee);Ve.current=Ee;var Le=I.useCallback(function(Me){var ze=Ve.current,Ge=ze.onResize,He=ze.data,Be=Me.getBoundingClientRect(),Pe=Be.width,pt=Be.height,it=Me.offsetWidth,et=Me.offsetHeight,at=Math.floor(Pe),Et=Math.floor(pt);if(Ae.current.width!==at||Ae.current.height!==Et||Ae.current.offsetWidth!==it||Ae.current.offsetHeight!==et){var ct={width:at,height:Et,offsetWidth:it,offsetHeight:et};Ae.current=ct;var dt=it===Math.round(Pe)?Pe:it,we=et===Math.round(pt)?pt:et,gt=Object(z.a)(Object(z.a)({},ct),{},{offsetWidth:dt,offsetHeight:we});ne==null||ne(gt,Me,He),Ge&&Promise.resolve().then(function(){Ge(gt,Me)})}},[]);return I.useEffect(function(){var Me=Object(L.a)(Ce.current)||Object(L.a)(me.current);return Me&&!Te&&c(Me,Le),function(){return d(Me,Le)}},[Ce.current,Te]),I.createElement(_,{ref:me},rt?I.cloneElement(_e,{ref:Xe}):_e)}var x="rc-observer-key";function f(Ee){var _e=Ee.children,Te=Object(O.a)(_e);return Te.map(function(Ce,me){var ne=(Ce==null?void 0:Ce.key)||"".concat(x,"-").concat(me);return I.createElement(l,Object(ae.a)({},Ee,{key:ne}),Ce)})}f.Collection=m;var p=f,s=re("bT9E"),a=re("TSYQ"),b=re.n(a),v=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,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={},H;function V(Ee){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=Ee.getAttribute("id")||Ee.getAttribute("data-reactid")||Ee.getAttribute("name");if(_e&&M[Te])return M[Te];var Ce=window.getComputedStyle(Ee),me=Ce.getPropertyValue("box-sizing")||Ce.getPropertyValue("-moz-box-sizing")||Ce.getPropertyValue("-webkit-box-sizing"),ne=parseFloat(Ce.getPropertyValue("padding-bottom"))+parseFloat(Ce.getPropertyValue("padding-top")),Ae=parseFloat(Ce.getPropertyValue("border-bottom-width"))+parseFloat(Ce.getPropertyValue("border-top-width")),rt=S.map(function(Xe){return"".concat(Xe,":").concat(Ce.getPropertyValue(Xe))}).join(";"),$e={sizingStyle:rt,paddingSize:ne,borderSize:Ae,boxSizing:me};return _e&&Te&&(M[Te]=$e),$e}function Q(Ee){var _e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;H||(H=document.createElement("textarea"),H.setAttribute("tab-index","-1"),H.setAttribute("aria-hidden","true"),document.body.appendChild(H)),Ee.getAttribute("wrap")?H.setAttribute("wrap",Ee.getAttribute("wrap")):H.removeAttribute("wrap");var me=V(Ee,_e),ne=me.paddingSize,Ae=me.borderSize,rt=me.boxSizing,$e=me.sizingStyle;H.setAttribute("style","".concat($e,";").concat(v)),H.value=Ee.value||Ee.placeholder||"";var Xe=Number.MIN_SAFE_INTEGER,Ve=Number.MAX_SAFE_INTEGER,Le=H.scrollHeight,Me;if(rt==="border-box"?Le+=Ae:rt==="content-box"&&(Le-=ne),Te!==null||Ce!==null){H.value=" ";var ze=H.scrollHeight-ne;Te!==null&&(Xe=ze*Te,rt==="border-box"&&(Xe=Xe+ne+Ae),Le=Math.max(Xe,Le)),Ce!==null&&(Ve=ze*Ce,rt==="border-box"&&(Ve=Ve+ne+Ae),Me=Le>Ve?"":"hidden",Le=Math.min(Ve,Le))}return{height:Le,minHeight:Xe,maxHeight:Ve,overflowY:Me,resize:"none"}}var G=re("Gytx"),W=re.n(G),q;(function(Ee){Ee[Ee.NONE=0]="NONE",Ee[Ee.RESIZING=1]="RESIZING",Ee[Ee.RESIZED=2]="RESIZED"})(q||(q={}));var oe=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(Ce){var me;return Object($.a)(this,Te),me=_e.call(this,Ce),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(ne){me.textArea=ne},me.handleResize=function(ne){var Ae=me.state.resizeStatus,rt=me.props,$e=rt.autoSize,Xe=rt.onResize;if(Ae!==q.NONE)return;typeof Xe=="function"&&Xe(ne),$e&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var ne=me.props.autoSize;if(!ne||!me.textArea)return;var Ae=ne.minRows,rt=ne.maxRows,$e=Q(me.textArea,!1,Ae,rt);me.setState({textareaStyles:$e,resizeStatus:q.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:q.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var ne=me.props,Ae=ne.prefixCls,rt=Ae===void 0?"rc-textarea":Ae,$e=ne.autoSize,Xe=ne.onResize,Ve=ne.className,Le=ne.disabled,Me=me.state,ze=Me.textareaStyles,Ge=Me.resizeStatus,He=Object(s.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Be=b()(rt,Ve,Object(B.a)({},"".concat(rt,"-disabled"),Le));"value"in He&&(He.value=He.value||"");var Pe=Object(z.a)(Object(z.a)(Object(z.a)({},me.props.style),ze),Ge===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return I.createElement(p,{onResize:me.handleResize,disabled:!($e||Xe)},I.createElement("textarea",Object(ae.a)({},He,{className:Be,style:Pe,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:q.NONE},me}return Object(R.a)(Te,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!W()(me.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var me=this.textArea.selectionStart,ne=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,ne)}}catch(Ae){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(I.Component),fe=oe,ve=function(Ee){Object(X.a)(Te,Ee);var _e=Object(N.a)(Te);function Te(Ce){var me;Object($.a)(this,Te),me=_e.call(this,Ce),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(Ae){me.resizableTextArea=Ae},me.handleChange=function(Ae){var rt=me.props.onChange;me.setValue(Ae.target.value,function(){me.resizableTextArea.resizeTextarea()}),rt&&rt(Ae)},me.handleKeyDown=function(Ae){var rt=me.props,$e=rt.onPressEnter,Xe=rt.onKeyDown;Ae.keyCode===13&&$e&&$e(Ae),Xe&&Xe(Ae)};var ne=typeof Ce.value=="undefined"||Ce.value===null?Ce.defaultValue:Ce.value;return me.state={value:ne},me}return Object(R.a)(Te,[{key:"setValue",value:function(me,ne){"value"in this.props||this.setState({value:me},ne)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return I.createElement(fe,Object(ae.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(me){return"value"in me?{value:me.value}:null}}]),Te}(I.Component),De=ht.default=ve},ZWs3:function(At,ht,re){"use strict";re.d(ht,"a",function(){return E});var ae=re("+L6B"),$=re("2/Rp"),R=re("0Owb"),X=re("9og8"),N=re("tJVT"),I=re("PpiC"),z=re("WmNS"),B=re.n(z),O=re("q1tI"),D=re.n(O),E=function(k){var T=k.children,A=Object(I.a)(k,["children"]),C=Object(O.useState)(!1),h=Object(N.a)(C,2),o=h[0],c=h[1];return D.a.createElement($.a,Object(R.a)({},A,{loading:o,onClick:function(){var d=Object(X.a)(B.a.mark(function _(y){return B.a.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,c(!0),l.next=4,A.onClick(y);case 4:c(!1),l.next=10;break;case 7:l.prev=7,l.t0=l.catch(0),c(!1);case 10:case"end":return l.stop()}},_,null,[[0,7]])}));return function(_){return d.apply(this,arguments)}}()}),T)}},ZpRC:function(At,ht,re){"use strict";function ae(E){return typeof E=="object"&&E!=null&&E.nodeType===1}function $(E,L){return(!L||E!=="hidden")&&E!=="visible"&&E!=="clip"}function R(E,L){if(E.clientHeight<E.scrollHeight||E.clientWidth<E.scrollWidth){var k=getComputedStyle(E,null);return $(k.overflowY,L)||$(k.overflowX,L)||function(T){var A=function(C){if(!C.ownerDocument||!C.ownerDocument.defaultView)return null;try{return C.ownerDocument.defaultView.frameElement}catch(h){return null}}(T);return!!A&&(A.clientHeight<T.scrollHeight||A.clientWidth<T.scrollWidth)}(E)}return!1}function X(E,L,k,T,A,C,h,o){return C<E&&h>L||C>E&&h<L?0:C<=E&&o<=k||h>=L&&o>=k?C-E-T:h>L&&o<k||C<E&&o>k?h-L+A:0}var N=function(E,L){var k=window,T=L.scrollMode,A=L.block,C=L.inline,h=L.boundary,o=L.skipOverflowHiddenElements,c=typeof h=="function"?h:function(ze){return ze!==h};if(!ae(E))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,_=[],y=E;ae(y)&&c(y);){if((y=y.parentElement)===d){_.push(y);break}y!=null&&y===document.body&&R(y)&&!R(document.documentElement)||y!=null&&R(y,o)&&_.push(y)}for(var m=k.visualViewport?k.visualViewport.width:innerWidth,l=k.visualViewport?k.visualViewport.height:innerHeight,x=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=E.getBoundingClientRect(),s=p.height,a=p.width,b=p.top,v=p.right,S=p.bottom,M=p.left,H=A==="start"||A==="nearest"?b:A==="end"?S:b+s/2,V=C==="center"?M+a/2:C==="end"?v:M,Q=[],G=0;G<_.length;G++){var W=_[G],q=W.getBoundingClientRect(),oe=q.height,fe=q.width,ve=q.top,De=q.right,Ee=q.bottom,_e=q.left;if(T==="if-needed"&&b>=0&&M>=0&&S<=l&&v<=m&&b>=ve&&S<=Ee&&M>=_e&&v<=De)return Q;var Te=getComputedStyle(W),Ce=parseInt(Te.borderLeftWidth,10),me=parseInt(Te.borderTopWidth,10),ne=parseInt(Te.borderRightWidth,10),Ae=parseInt(Te.borderBottomWidth,10),rt=0,$e=0,Xe="offsetWidth"in W?W.offsetWidth-W.clientWidth-Ce-ne:0,Ve="offsetHeight"in W?W.offsetHeight-W.clientHeight-me-Ae:0;if(d===W)rt=A==="start"?H:A==="end"?H-l:A==="nearest"?X(f,f+l,l,me,Ae,f+H,f+H+s,s):H-l/2,$e=C==="start"?V:C==="center"?V-m/2:C==="end"?V-m:X(x,x+m,m,Ce,ne,x+V,x+V+a,a),rt=Math.max(0,rt+f),$e=Math.max(0,$e+x);else{rt=A==="start"?H-ve-me:A==="end"?H-Ee+Ae+Ve:A==="nearest"?X(ve,Ee,oe,me,Ae+Ve,H,H+s,s):H-(ve+oe/2)+Ve/2,$e=C==="start"?V-_e-Ce:C==="center"?V-(_e+fe/2)+Xe/2:C==="end"?V-De+ne+Xe:X(_e,De,fe,Ce,ne+Xe,V,V+a,a);var Le=W.scrollLeft,Me=W.scrollTop;H+=Me-(rt=Math.max(0,Math.min(Me+rt,W.scrollHeight-oe+Ve))),V+=Le-($e=Math.max(0,Math.min(Le+$e,W.scrollWidth-fe+Xe)))}Q.push({el:W,top:rt,left:$e})}return Q};function I(E){return E===Object(E)&&Object.keys(E).length!==0}function z(E,L){L===void 0&&(L="auto");var k="scrollBehavior"in document.body.style;E.forEach(function(T){var A=T.el,C=T.top,h=T.left;A.scroll&&k?A.scroll({top:C,left:h,behavior:L}):(A.scrollTop=C,A.scrollLeft=h)})}function B(E){return E===!1?{block:"end",inline:"nearest"}:I(E)?E:{block:"start",inline:"nearest"}}function O(E,L){var k=!E.ownerDocument.documentElement.contains(E);if(I(L)&&typeof L.behavior=="function")return L.behavior(k?[]:N(E,L));if(k)return;var T=B(L);return z(N(E,T),T.behavior)}var D=ht.a=O},bT9E:function(At,ht,re){"use strict";re.d(ht,"a",function(){return $});var ae=re("VTBJ");function $(R,X){var N=Object(ae.a)({},R);return Array.isArray(X)&&X.forEach(function(I){delete N[I]}),N}},c5Ni:function(At,ht,re){},dejd:function(At,ht,re){},dmUQ:function(At,ht,re){"use strict";var ae=re("Ff2n"),$=re("rePB"),R=re("1OyB"),X=re("vuIU"),N=re("Ji7U"),I=re("md7G"),z=re("foSv"),B=re("q1tI"),O=re.n(B),D=re("TSYQ"),E=re.n(D),L=re("4IlW");function k(s,a){var b=Object.keys(s);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(s);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(s,S).enumerable})),b.push.apply(b,v)}return b}function T(s){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?k(Object(b),!0).forEach(function(v){Object($.a)(s,v,b[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(b)):k(Object(b)).forEach(function(v){Object.defineProperty(s,v,Object.getOwnPropertyDescriptor(b,v))})}return s}function A(s){var a=C();return function(){var v=Object(z.a)(s),S;if(a){var M=Object(z.a)(this).constructor;S=Reflect.construct(v,arguments,M)}else S=v.apply(this,arguments);return Object(I.a)(this,S)}}function C(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(s){return!1}}function h(){}function o(s){s.preventDefault()}var c=function(a){return a.replace(/[^\w.-]+/g,"")},d=200,_=600,y=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,m=function(a){return a!=null},l=function(a,b){return b===a||typeof b=="number"&&typeof a=="number"&&isNaN(b)&&isNaN(a)},x=function(s){Object(N.a)(b,s);var a=A(b);function b(v){var S;Object(R.a)(this,b),S=a.call(this,v),S.onKeyDown=function(V){var Q=S.props,G=Q.onKeyDown,W=Q.onPressEnter;if(V.keyCode===L.a.UP){var q=S.getRatio(V);S.up(V,q,null),S.stop()}else if(V.keyCode===L.a.DOWN){var oe=S.getRatio(V);S.down(V,oe,null),S.stop()}else V.keyCode===L.a.ENTER&&W&&W(V);if(S.recordCursorPosition(),S.lastKeyCode=V.keyCode,G){for(var fe=arguments.length,ve=new Array(fe>1?fe-1:0),De=1;De<fe;De++)ve[De-1]=arguments[De];G.apply(void 0,[V].concat(ve))}},S.onKeyUp=function(V){var Q=S.props.onKeyUp;if(S.stop(),S.recordCursorPosition(),Q){for(var G=arguments.length,W=new Array(G>1?G-1:0),q=1;q<G;q++)W[q-1]=arguments[q];Q.apply(void 0,[V].concat(W))}},S.onChange=function(V){var Q=S.props.onChange;S.state.focused&&(S.inputting=!0),S.rawInput=S.props.parser(S.getValueFromEvent(V)),S.setState({inputValue:S.rawInput}),Q(S.toNumber(S.rawInput))},S.onMouseUp=function(){var V=S.props.onMouseUp;S.recordCursorPosition(),V&&V.apply(void 0,arguments)},S.onFocus=function(){var V;S.setState({focused:!0}),(V=S.props).onFocus.apply(V,arguments)},S.onBlur=function(){var V=S.props.onBlur;S.inputting=!1,S.setState({focused:!1});var Q=S.getCurrentValidValue(S.state.inputValue),G=S.setValue(Q,h);if(V){var W=S.input.value,q=S.getInputDisplayValue({focus:!1,value:G});S.input.value=q&&Number(q),V.apply(void 0,arguments),S.input.value=W}},S.getRatio=function(V){var Q=1;return V.metaKey||V.ctrlKey?Q=.1:V.shiftKey&&(Q=10),Q},S.getFullNum=function(V){return isNaN(V)?V:/e/i.test(String(V))?Number(V).toFixed(18).replace(/\.?0+$/,""):V},S.getPrecision=function(V){if(m(S.props.precision))return S.props.precision;var Q=String(V);if(Q.indexOf("e-")>=0)return parseInt(Q.slice(Q.indexOf("e-")+2),10);var G=0;return Q.indexOf(".")>=0&&(G=Q.length-Q.indexOf(".")-1),G},S.getInputDisplayValue=function(V){var Q=V||S.state,G=Q.focused,W=Q.inputValue,q=Q.value,oe;G?oe=W:oe=S.toPrecisionAsStep(q),oe==null&&(oe="");var fe=S.formatWrapper(oe);return m(S.props.decimalSeparator)&&(fe=fe.toString().replace(".",S.props.decimalSeparator)),fe},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(V){}},S.restoreByAfter=function(V){if(V===void 0)return!1;var Q=S.input.value,G=Q.lastIndexOf(V);if(G===-1)return!1;var W=S.cursorBefore.length;return S.lastKeyCode===L.a.DELETE&&S.cursorBefore.charAt(W-1)===V[0]?(S.fixCaret(W,W),!0):G+V.length===Q.length?(S.fixCaret(G,G),!0):!1},S.partRestoreByAfter=function(V){return V===void 0?!1:Array.prototype.some.call(V,function(Q,G){var W=V.substring(G);return S.restoreByAfter(W)})},S.isNotCompleteNumber=function(V){return isNaN(V)||V===""||V===null||V&&V.toString().indexOf(".")===V.toString().length-1},S.stop=function(){S.autoStepTimer&&clearTimeout(S.autoStepTimer)},S.down=function(V,Q,G){S.pressingUpOrDown=!0,S.step("down",V,Q,G)},S.up=function(V,Q,G){S.pressingUpOrDown=!0,S.step("up",V,Q,G)},S.saveInput=function(V){S.input=V};var M=v.value;M===void 0&&(M=v.defaultValue),S.state={focused:v.autoFocus};var H=S.getValidValue(S.toNumber(M));return S.state=T(T({},S.state),{},{inputValue:S.toPrecisionAsStep(H),value:H}),S}return Object(X.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(S){var M=this.props,H=M.value,V=M.onChange,Q=M.max,G=M.min,W=this.state.focused;if(S){if(!l(S.value,H)||!l(S.max,Q)||!l(S.min,G)){var q=W?H:this.getValidValue(H),oe;this.pressingUpOrDown?oe=q:this.inputting?oe=this.rawInput:oe=this.toPrecisionAsStep(q),this.setState({value:q,inputValue:oe})}var fe="value"in this.props?H:this.state.value;"max"in this.props&&S.max!==Q&&typeof fe=="number"&&fe>Q&&V&&V(Q),"min"in this.props&&S.min!==G&&typeof fe=="number"&&fe<G&&V&&V(G)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ve=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===L.a.BACKSPACE?ve=this.cursorStart-1:this.lastKeyCode===L.a.DELETE&&(ve=this.cursorStart):ve=this.input.value.length,this.fixCaret(ve,ve)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case L.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case L.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(De){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(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,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,V=parseFloat(S);return isNaN(V)?S:(V<M&&(V=M),V>H&&(V=H),V)}},{key:"setValue",value:function(S,M){var H=this.props.precision,V=this.isNotCompleteNumber(parseFloat(S))?null:parseFloat(S),Q=this.state.value,G=Q===void 0?null:Q,W=this.state.inputValue,q=W===void 0?null:W,oe=typeof V=="number"?V.toFixed(H):"".concat(V),fe=V!==G||oe!=="".concat(q);return"value"in this.props?(q=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:q},M)):this.setState({value:V,inputValue:this.toPrecisionAsStep(S)},M),fe&&this.props.onChange(V),V}},{key:"getMaxPrecision",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.props,V=H.precision,Q=H.step;if(m(V))return V;var G=this.getPrecision(M),W=this.getPrecision(Q),q=this.getPrecision(S);return S?Math.max(q,G+W):G+W}},{key:"getPrecisionFactor",value:function(S){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.getMaxPrecision(S,M);return Math.pow(10,H)}},{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,H=this.state.focused,V=S&&S.length>16&&H;return this.isNotCompleteNumber(S)||V?S:m(M)?Math.round(S*Math.pow(10,M))/Math.pow(10,M):Number(S)}},{key:"upStep",value:function(S,M){var H=this.props.step,V=this.getPrecisionFactor(S,M),Q=Math.abs(this.getMaxPrecision(S,M)),G=((V*S+V*H*M)/V).toFixed(Q);return this.toNumber(G)}},{key:"downStep",value:function(S,M){var H=this.props.step,V=this.getPrecisionFactor(S,M),Q=Math.abs(this.getMaxPrecision(S,M)),G=((V*S-V*H*M)/V).toFixed(Q);return this.toNumber(G)}},{key:"step",value:function(S,M){var H=this,V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var G=this.props;if(G.disabled)return;var W=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(W))return;var q=this["".concat(S,"Step")](W,V),oe=q>G.max||q<G.min;if(q>G.max?q=G.max:q<G.min&&(q=G.min),this.setValue(q,null),this.setState({focused:!0},function(){H.pressingUpOrDown=!1}),oe)return;this.autoStepTimer=setTimeout(function(){H[S](M,V,!0)},Q?d:_)}},{key:"fixCaret",value:function(S,M){if(S===void 0||M===void 0||!this.input||!this.input.value)return;try{var H=this.input.selectionStart,V=this.input.selectionEnd;(S!==H||M!==V)&&this.input.setSelectionRange(S,M)}catch(Q){}}},{key:"render",value:function(){var S,M=this.props,H=M.prefixCls,V=M.disabled,Q=M.readOnly,G=M.useTouch,W=M.autoComplete,q=M.upHandler,oe=M.downHandler,fe=M.className,ve=M.max,De=M.min,Ee=M.style,_e=M.title,Te=M.onMouseEnter,Ce=M.onMouseLeave,me=M.onMouseOver,ne=M.onMouseOut,Ae=M.required,rt=M.onClick,$e=M.tabIndex,Xe=M.type,Ve=M.placeholder,Le=M.id,Me=M.inputMode,ze=M.pattern,Ge=M.step,He=M.maxLength,Be=M.autoFocus,Pe=M.name,pt=M.onPaste,it=M.onInput,et=Object(ae.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"]),at=this.state,Et=at.value,ct=at.focused,dt=E()(H,(S={},Object($.a)(S,fe,!!fe),Object($.a)(S,"".concat(H,"-disabled"),V),Object($.a)(S,"".concat(H,"-focused"),ct),S)),we={};Object.keys(et).forEach(function(se){(se.substr(0,5)==="data-"||se.substr(0,5)==="aria-"||se==="role")&&(we[se]=et[se])});var gt=!Q&&!V,lt=this.getInputDisplayValue(null),Re=(Et||Et===0)&&(isNaN(Et)||Number(Et)>=ve),je=(Et||Et===0)&&(isNaN(Et)||Number(Et)<=De),ge=Re||V||Q,de=je||V||Q,pe=E()("".concat(H,"-handler"),"".concat(H,"-handler-up"),Object($.a)({},"".concat(H,"-handler-up-disabled"),ge)),ee=E()("".concat(H,"-handler"),"".concat(H,"-handler-down"),Object($.a)({},"".concat(H,"-handler-down-disabled"),de)),te=G?{onTouchStart:ge?h:this.up,onTouchEnd:this.stop}:{onMouseDown:ge?h:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ie=G?{onTouchStart:de?h:this.down,onTouchEnd:this.stop}:{onMouseDown:de?h:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return O.a.createElement("div",{className:dt,style:Ee,title:_e,onMouseEnter:Te,onMouseLeave:Ce,onMouseOver:me,onMouseOut:ne,onFocus:function(){return null},onBlur:function(){return null}},O.a.createElement("div",{className:"".concat(H,"-handler-wrap")},O.a.createElement("span",Object.assign({unselectable:"on"},te,{role:"button","aria-label":"Increase Value","aria-disabled":ge,className:pe}),q||O.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-up-inner"),onClick:o})),O.a.createElement("span",Object.assign({unselectable:"on"},ie,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:ee}),oe||O.a.createElement("span",{unselectable:"on",className:"".concat(H,"-handler-down-inner"),onClick:o}))),O.a.createElement("div",{className:"".concat(H,"-input-wrap")},O.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":De,"aria-valuemax":ve,"aria-valuenow":Et,required:Ae,type:Xe,placeholder:Ve,onPaste:pt,onClick:rt,onMouseUp:this.onMouseUp,className:"".concat(H,"-input"),tabIndex:$e,autoComplete:W,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:gt?this.onKeyDown:h,onKeyUp:gt?this.onKeyUp:h,autoFocus:Be,maxLength:He,readOnly:Q,disabled:V,max:ve,min:De,step:Ge,name:Pe,title:_e,id:Le,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(lt),pattern:ze,inputMode:Me,onInput:it},we))))}}]),b}(O.a.Component);x.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:y,min:-y,step:1,style:{},onChange:h,onKeyDown:h,onPressEnter:h,onFocus:h,onBlur:h,parser:c,required:!1,autoComplete:"off"};var f=x,p=ht.a=f},kSUc:function(At,ht,re){},kqOp:function(At,ht,re){"use strict";re.d(ht,"a",function(){return D});var ae=re("0Owb"),$=re("fWQN"),R=re("mtLc"),X=re("yKVA"),N=re("879j"),I=re("q1tI"),z=re.n(I),B=re("Ot1p"),O="\u2581",D=function(E){Object(X.a)(k,E);var L=Object(N.a)(k);function k(){var T;Object($.a)(this,k);for(var A=arguments.length,C=new Array(A),h=0;h<A;h++)C[h]=arguments[h];return T=L.call.apply(L,[this].concat(C)),T.getChCountBeforeCursor=function(o,c){for(var d=c.line,_=0,y=0;y<d;y++)_+=o.getLine(y).split(O).length-1;var m=o.getLine(d).substring(0,c.ch);return _+=m.split(O).length-1,_},T.onCMBeforeChange=function(o,c){var d=o.getRange(c.from,c.to),_=0;if(c.text.forEach(function(x){_+=x.split(O).length-1}),d&&d.indexOf(O)!=-1){var y=d.split(O).length-1,m=T.getChCountBeforeCursor(o,c.from);console.log("\u5220\u9664".concat(y,"\u4E2A\uFF0C \u4E4B\u524D\u6709").concat(m,"\u4E2A\uFF0C\u65B0\u589E").concat(_,"\u4E2A")),T.props.deleteEmptyDisabled?c.cancel():T.props.onPlaceholderChange&&T.props.onPlaceholderChange(m,y,_)}else if(_){var l=T.getChCountBeforeCursor(o,c.from);console.log("\u65B0\u589E".concat(_,"\u4E2A\uFF0C\u4E4B\u524D\u6709").concat(l,"\u4E2A")),T.props.onPlaceholderChange&&T.props.onPlaceholderChange(l,0,_)}},T}return Object(R.a)(k,[{key:"render",value:function(){return z.a.createElement(B.a,Object(ae.a)({},this.props,{onCMBeforeChange:this.onCMBeforeChange}))}}]),k}(I.Component)},lZu9:function(At,ht,re){(function(ae){ae(re("VrN/"),re("1eCo"),re("8EBN"))})(function(ae){"use strict";ae.defineMode("markdown",function($,R){var X=ae.getMode($,"text/html"),N=X.name=="null";function I(G){if(ae.findModeByName){var W=ae.findModeByName(G);W&&(G=W.mime||W.mimes[0])}var q=ae.getMode($,G);return q.name=="null"?null:q}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 z={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var B in z)z.hasOwnProperty(B)&&R.tokenTypeOverrides[B]&&(z[B]=R.tokenTypeOverrides[B]);var O=/^([*\-_])(?:\s*\1){2,}\s*$/,D=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,E=/^\[(x| )\](?=\s)/i,L=R.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,k=/^ {0,3}(?:\={1,}|-{2,})\s*$/,T=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,C=/^\s*\[[^\]]+?\]:.*$/,h=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function c(G,W,q){return W.f=W.inline=q,q(G,W)}function d(G,W,q){return W.f=W.block=q,q(G,W)}function _(G){return!G||!/\S/.test(G.string)}function y(G){if(G.linkTitle=!1,G.linkHref=!1,G.linkText=!1,G.em=!1,G.strong=!1,G.strikethrough=!1,G.quote=0,G.indentedCode=!1,G.f==l){var W=N;if(!W){var q=ae.innerMode(X,G.htmlState);W=q.mode.name=="xml"&&q.state.tagStart===null&&!q.state.context&&q.state.tokenize.isInText}W&&(G.f=s,G.block=m,G.htmlState=null)}return G.trailingSpace=0,G.trailingSpaceNewLine=!1,G.prevLine=G.thisLine,G.thisLine={stream:null},null}function m(G,W){var q=G.column()===W.indentation,oe=_(W.prevLine.stream),fe=W.indentedCode,ve=W.prevLine.hr,De=W.list!==!1,Ee=(W.listStack[W.listStack.length-1]||0)+3;W.indentedCode=!1;var _e=W.indentation;if(W.indentationDiff===null&&(W.indentationDiff=W.indentation,De)){for(W.list=null;_e<W.listStack[W.listStack.length-1];)W.listStack.pop(),W.listStack.length?W.indentation=W.listStack[W.listStack.length-1]:W.list=!1;W.list!==!1&&(W.indentationDiff=_e-W.listStack[W.listStack.length-1])}var Te=!oe&&!ve&&!W.prevLine.header&&(!De||!fe)&&!W.prevLine.fencedCodeEnd,Ce=(W.list===!1||ve||oe)&&W.indentation<=Ee&&G.match(O),me=null;if(W.indentationDiff>=4&&(fe||W.prevLine.fencedCodeEnd||W.prevLine.header||oe))return G.skipToEnd(),W.indentedCode=!0,z.code;if(G.eatSpace())return null;if(q&&W.indentation<=Ee&&(me=G.match(L))&&me[1].length<=6)return W.quote=0,W.header=me[1].length,W.thisLine.header=!0,R.highlightFormatting&&(W.formatting="header"),W.f=W.inline,f(W);if(W.indentation<=Ee&&G.eat(">"))return W.quote=q?1:W.quote+1,R.highlightFormatting&&(W.formatting="quote"),G.eatSpace(),f(W);if(!Ce&&!W.setext&&q&&W.indentation<=Ee&&(me=G.match(D))){var ne=me[1]?"ol":"ul";return W.indentation=_e+G.current().length,W.list=!0,W.quote=0,W.listStack.push(W.indentation),W.em=!1,W.strong=!1,W.code=!1,W.strikethrough=!1,R.taskLists&&G.match(E,!1)&&(W.taskList=!0),W.f=W.inline,R.highlightFormatting&&(W.formatting=["list","list-"+ne]),f(W)}else{if(q&&W.indentation<=Ee&&(me=G.match(A,!0)))return W.quote=0,W.fencedEndRE=new RegExp(me[1]+"+ *$"),W.localMode=R.fencedCodeBlockHighlighting&&I(me[2]||R.fencedCodeBlockDefaultMode),W.localMode&&(W.localState=ae.startState(W.localMode)),W.f=W.block=x,R.highlightFormatting&&(W.formatting="code-block"),W.code=-1,f(W);if(W.setext||(!Te||!De)&&!W.quote&&W.list===!1&&!W.code&&!Ce&&!C.test(G.string)&&(me=G.lookAhead(1))&&(me=me.match(k)))return W.setext?(W.header=W.setext,W.setext=0,G.skipToEnd(),R.highlightFormatting&&(W.formatting="header")):(W.header=me[0].charAt(0)=="="?1:2,W.setext=W.header),W.thisLine.header=!0,W.f=W.inline,f(W);if(Ce)return G.skipToEnd(),W.hr=!0,W.thisLine.hr=!0,z.hr;if(G.peek()==="[")return c(G,W,M)}return c(G,W,W.inline)}function l(G,W){var q=X.token(G,W.htmlState);if(!N){var oe=ae.innerMode(X,W.htmlState);(oe.mode.name=="xml"&&oe.state.tagStart===null&&!oe.state.context&&oe.state.tokenize.isInText||W.md_inside&&G.current().indexOf(">")>-1)&&(W.f=s,W.block=m,W.htmlState=null)}return q}function x(G,W){var q=W.listStack[W.listStack.length-1]||0,oe=W.indentation<q,fe=q+3;if(W.fencedEndRE&&W.indentation<=fe&&(oe||G.match(W.fencedEndRE))){R.highlightFormatting&&(W.formatting="code-block");var ve;return oe||(ve=f(W)),W.localMode=W.localState=null,W.block=m,W.f=s,W.fencedEndRE=null,W.code=0,W.thisLine.fencedCodeEnd=!0,oe?d(G,W,W.block):ve}else return W.localMode?W.localMode.token(G,W.localState):(G.skipToEnd(),z.code)}function f(G){var W=[];if(G.formatting){W.push(z.formatting),typeof G.formatting=="string"&&(G.formatting=[G.formatting]);for(var q=0;q<G.formatting.length;q++)W.push(z.formatting+"-"+G.formatting[q]),G.formatting[q]==="header"&&W.push(z.formatting+"-"+G.formatting[q]+"-"+G.header),G.formatting[q]==="quote"&&(!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=G.quote?W.push(z.formatting+"-"+G.formatting[q]+"-"+G.quote):W.push("error"))}if(G.taskOpen)return W.push("meta"),W.length?W.join(" "):null;if(G.taskClosed)return W.push("property"),W.length?W.join(" "):null;if(G.linkHref?W.push(z.linkHref,"url"):(G.strong&&W.push(z.strong),G.em&&W.push(z.em),G.strikethrough&&W.push(z.strikethrough),G.emoji&&W.push(z.emoji),G.linkText&&W.push(z.linkText),G.code&&W.push(z.code),G.image&&W.push(z.image),G.imageAltText&&W.push(z.imageAltText,"link"),G.imageMarker&&W.push(z.imageMarker)),G.header&&W.push(z.header,z.header+"-"+G.header),G.quote&&(W.push(z.quote),!R.maxBlockquoteDepth||R.maxBlockquoteDepth>=G.quote?W.push(z.quote+"-"+G.quote):W.push(z.quote+"-"+R.maxBlockquoteDepth)),G.list!==!1){var oe=(G.listStack.length-1)%3;oe?oe===1?W.push(z.list2):W.push(z.list3):W.push(z.list1)}return G.trailingSpaceNewLine?W.push("trailing-space-new-line"):G.trailingSpace&&W.push("trailing-space-"+(G.trailingSpace%2?"a":"b")),W.length?W.join(" "):null}function p(G,W){return G.match(T,!0)?f(W):void 0}function s(G,W){var q=W.text(G,W);if(typeof q!="undefined")return q;if(W.list)return W.list=null,f(W);if(W.taskList){var oe=G.match(E,!0)[1]===" ";return oe?W.taskOpen=!0:W.taskClosed=!0,R.highlightFormatting&&(W.formatting="task"),W.taskList=!1,f(W)}if(W.taskOpen=!1,W.taskClosed=!1,W.header&&G.match(/^#+$/,!0))return R.highlightFormatting&&(W.formatting="header"),f(W);var fe=G.next();if(W.linkTitle){W.linkTitle=!1;var ve=fe;fe==="("&&(ve=")"),ve=(ve+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var De="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(G.match(new RegExp(De),!0))return z.linkHref}if(fe==="`"){var Ee=W.formatting;R.highlightFormatting&&(W.formatting="code"),G.eatWhile("`");var _e=G.current().length;if(W.code==0&&(!W.quote||_e==1))return W.code=_e,f(W);if(_e==W.code){var Te=f(W);return W.code=0,Te}else return W.formatting=Ee,f(W)}else if(W.code)return f(W);if(fe==="\\"&&(G.next(),R.highlightFormatting)){var Ce=f(W),me=z.formatting+"-escape";return Ce?Ce+" "+me:me}if(fe==="!"&&G.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return W.imageMarker=!0,W.image=!0,R.highlightFormatting&&(W.formatting="image"),f(W);if(fe==="["&&W.imageMarker&&G.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return W.imageMarker=!1,W.imageAltText=!0,R.highlightFormatting&&(W.formatting="image"),f(W);if(fe==="]"&&W.imageAltText){R.highlightFormatting&&(W.formatting="image");var Ce=f(W);return W.imageAltText=!1,W.image=!1,W.inline=W.f=b,Ce}if(fe==="["&&!W.image)return W.linkText&&G.match(/^.*?\]/)||(W.linkText=!0,R.highlightFormatting&&(W.formatting="link")),f(W);if(fe==="]"&&W.linkText){R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return W.linkText=!1,W.inline=W.f=G.match(/\(.*?\)| ?\[.*?\]/,!1)?b:s,Ce}if(fe==="<"&&G.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=a,R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return Ce?Ce+=" ":Ce="",Ce+z.linkInline}if(fe==="<"&&G.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){W.f=W.inline=a,R.highlightFormatting&&(W.formatting="link");var Ce=f(W);return Ce?Ce+=" ":Ce="",Ce+z.linkEmail}if(R.xml&&fe==="<"&&G.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var ne=G.string.indexOf(">",G.pos);if(ne!=-1){var Ae=G.string.substring(G.start,ne);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Ae)&&(W.md_inside=!0)}return G.backUp(1),W.htmlState=ae.startState(X),d(G,W,l)}if(R.xml&&fe==="<"&&G.match(/^\/\w*?>/))return W.md_inside=!1,"tag";if(fe==="*"||fe==="_"){for(var rt=1,$e=G.pos==1?" ":G.string.charAt(G.pos-2);rt<3&&G.eat(fe);)rt++;var Xe=G.peek()||" ",Ve=!/\s/.test(Xe)&&(!h.test(Xe)||/\s/.test($e)||h.test($e)),Le=!/\s/.test($e)&&(!h.test($e)||/\s/.test(Xe)||h.test(Xe)),Me=null,ze=null;if(rt%2&&(!W.em&&Ve&&(fe==="*"||!Le||h.test($e))?Me=!0:W.em==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(Me=!1)),rt>1&&(!W.strong&&Ve&&(fe==="*"||!Le||h.test($e))?ze=!0:W.strong==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(ze=!1)),ze!=null||Me!=null){R.highlightFormatting&&(W.formatting=Me==null?"strong":ze==null?"em":"strong em"),Me===!0&&(W.em=fe),ze===!0&&(W.strong=fe);var Te=f(W);return Me===!1&&(W.em=!1),ze===!1&&(W.strong=!1),Te}}else if(fe===" "&&(G.eat("*")||G.eat("_"))){if(G.peek()===" ")return f(W);G.backUp(1)}if(R.strikethrough){if(fe==="~"&&G.eatWhile(fe)){if(W.strikethrough){R.highlightFormatting&&(W.formatting="strikethrough");var Te=f(W);return W.strikethrough=!1,Te}else if(G.match(/^[^\s]/,!1))return W.strikethrough=!0,R.highlightFormatting&&(W.formatting="strikethrough"),f(W)}else if(fe===" "&&G.match(/^~~/,!0)){if(G.peek()===" ")return f(W);G.backUp(2)}}if(R.emoji&&fe===":"&&G.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){W.emoji=!0,R.highlightFormatting&&(W.formatting="emoji");var Ge=f(W);return W.emoji=!1,Ge}return fe===" "&&(G.match(/^ +$/,!1)?W.trailingSpace++:W.trailingSpace&&(W.trailingSpaceNewLine=!0)),f(W)}function a(G,W){var q=G.next();if(q===">"){W.f=W.inline=s,R.highlightFormatting&&(W.formatting="link");var oe=f(W);return oe?oe+=" ":oe="",oe+z.linkInline}return G.match(/^[^>]+/,!0),z.linkInline}function b(G,W){if(G.eatSpace())return null;var q=G.next();return q==="("||q==="["?(W.f=W.inline=S(q==="("?")":"]"),R.highlightFormatting&&(W.formatting="link-string"),W.linkHref=!0,f(W)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function S(G){return function(W,q){var oe=W.next();if(oe===G){q.f=q.inline=s,R.highlightFormatting&&(q.formatting="link-string");var fe=f(q);return q.linkHref=!1,fe}return W.match(v[G]),q.linkHref=!0,f(q)}}function M(G,W){return G.match(/^([^\]\\]|\\.)*\]:/,!1)?(W.f=H,G.next(),R.highlightFormatting&&(W.formatting="link"),W.linkText=!0,f(W)):c(G,W,s)}function H(G,W){if(G.match(/^\]:/,!0)){W.f=W.inline=V,R.highlightFormatting&&(W.formatting="link");var q=f(W);return W.linkText=!1,q}return G.match(/^([^\]\\]|\\.)+/,!0),z.linkText}function V(G,W){return G.eatSpace()?null:(G.match(/^[^\s]+/,!0),G.peek()===void 0?W.linkTitle=!0:G.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),W.f=W.inline=s,z.linkHref+" url")}var Q={startState:function(){return{f:m,prevLine:{stream:null},thisLine:{stream:null},block:m,htmlState:null,indentation:0,inline:s,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(G){return{f:G.f,prevLine:G.prevLine,thisLine:G.thisLine,block:G.block,htmlState:G.htmlState&&ae.copyState(X,G.htmlState),indentation:G.indentation,localMode:G.localMode,localState:G.localMode?ae.copyState(G.localMode,G.localState):null,inline:G.inline,text:G.text,formatting:!1,linkText:G.linkText,linkTitle:G.linkTitle,linkHref:G.linkHref,code:G.code,em:G.em,strong:G.strong,strikethrough:G.strikethrough,emoji:G.emoji,header:G.header,setext:G.setext,hr:G.hr,taskList:G.taskList,list:G.list,listStack:G.listStack.slice(0),quote:G.quote,indentedCode:G.indentedCode,trailingSpace:G.trailingSpace,trailingSpaceNewLine:G.trailingSpaceNewLine,md_inside:G.md_inside,fencedEndRE:G.fencedEndRE}},token:function(G,W){if(W.formatting=!1,G!=W.thisLine.stream){if(W.header=0,W.hr=!1,G.match(/^\s*$/,!0))return y(W),null;if(W.prevLine=W.thisLine,W.thisLine={stream:G},W.taskList=!1,W.trailingSpace=0,W.trailingSpaceNewLine=!1,!W.localState&&(W.f=W.block,W.f!=l)){var q=G.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(W.indentation=q,W.indentationDiff=null,q>0)return null}}return W.f(G,W)},innerMode:function(G){return G.block==l?{state:G.htmlState,mode:X}:G.localState?{state:G.localState,mode:G.localMode}:{state:G,mode:Q}},indent:function(G,W,q){return G.block==l&&X.indent?X.indent(G.htmlState,W,q):G.localState&&G.localMode.indent?G.localMode.indent(G.localState,W,q):ae.Pass},blankLine:y,getType:f,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return Q},"xml"),ae.defineMIME("text/markdown","markdown"),ae.defineMIME("text/x-markdown","markdown")})},osHv:function(At,ht,re){(function(ae){ae(re("VrN/"))})(function(ae){"use strict";var $=ae.Pos;function R(h,o){return h.line-o.line||h.ch-o.ch}var X="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",N=X+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",I=new RegExp("<(/?)(["+X+"]["+N+"]*)","g");function z(h,o,c,d){this.line=o,this.ch=c,this.cm=h,this.text=h.getLine(o),this.min=d?Math.max(d.from,h.firstLine()):h.firstLine(),this.max=d?Math.min(d.to-1,h.lastLine()):h.lastLine()}function B(h,o){var c=h.cm.getTokenTypeAt($(h.line,o));return c&&/\btag\b/.test(c)}function O(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function D(h){return h.line<=h.min?void 0:(h.text=h.cm.getLine(--h.line),h.ch=h.text.length,!0)}function E(h){for(;;){var o=h.text.indexOf(">",h.ch);if(o==-1){if(O(h))continue;return}if(!B(h,o+1)){h.ch=o+1;continue}var c=h.text.lastIndexOf("/",o),d=c>-1&&!/\S/.test(h.text.slice(c+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function L(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!B(h,o+1)){h.ch=o;continue}I.lastIndex=o,h.ch=o;var c=I.exec(h.text);if(c&&c.index==o)return c}}function k(h){for(;;){I.lastIndex=h.ch;var o=I.exec(h.text);if(!o){if(O(h))continue;return}if(!B(h,o.index+1)){h.ch=o.index+1;continue}return h.ch=o.index+o[0].length,o}}function T(h){for(;;){var o=h.ch?h.text.lastIndexOf(">",h.ch-1):-1;if(o==-1){if(D(h))continue;return}if(!B(h,o+1)){h.ch=o;continue}var c=h.text.lastIndexOf("/",o),d=c>-1&&!/\S/.test(h.text.slice(c+1,o));return h.ch=o+1,d?"selfClose":"regular"}}function A(h,o){for(var c=[];;){var d=k(h),_,y=h.line,m=h.ch-(d?d[0].length:0);if(!d||!(_=E(h)))return;if(_=="selfClose")continue;if(d[1]){for(var l=c.length-1;l>=0;--l)if(c[l]==d[2]){c.length=l;break}if(l<0&&(!o||o==d[2]))return{tag:d[2],from:$(y,m),to:$(h.line,h.ch)}}else c.push(d[2])}}function C(h,o){for(var c=[];;){var d=T(h);if(!d)return;if(d=="selfClose"){L(h);continue}var _=h.line,y=h.ch,m=L(h);if(!m)return;if(m[1])c.push(m[2]);else{for(var l=c.length-1;l>=0;--l)if(c[l]==m[2]){c.length=l;break}if(l<0&&(!o||o==m[2]))return{tag:m[2],from:$(h.line,h.ch),to:$(_,y)}}}}ae.registerHelper("fold","xml",function(h,o){for(var c=new z(h,o.line,0);;){var d=k(c);if(!d||c.line!=o.line)return;var _=E(c);if(!_)return;if(!d[1]&&_!="selfClose"){var y=$(c.line,c.ch),m=A(c,d[2]);return m&&R(m.from,y)>0?{from:y,to:m.from}:null}}}),ae.findMatchingTag=function(h,o,c){var d=new z(h,o.line,o.ch,c);if(d.text.indexOf(">")==-1&&d.text.indexOf("<")==-1)return;var _=E(d),y=_&&$(d.line,d.ch),m=_&&L(d);if(!_||!m||R(d,o)>0)return;var l={from:$(d.line,d.ch),to:y,tag:m[2]};return _=="selfClose"?{open:l,close:null,at:"open"}:m[1]?{open:C(d,m[2]),close:l,at:"close"}:(d=new z(h,y.line,y.ch,c),{open:l,close:A(d,m[2]),at:"open"})},ae.findEnclosingTag=function(h,o,c,d){for(var _=new z(h,o.line,o.ch,c);;){var y=C(_,d);if(!y)break;var m=new z(h,o.line,o.ch,c),l=A(m,y.tag);if(l)return{open:y,close:l}}},ae.scanForClosingTag=function(h,o,c,d){var _=new z(h,o.line,o.ch,d?{from:0,to:d}:null);return A(_,c)}})},p5ED:function(At,ht,re){"use strict";var ae=re("+L6B"),$=re("2/Rp"),R=re("5Dmo"),X=re("3S7+"),N=re("k1fw"),I=re("tJVT"),z=re("q1tI"),B=re.n(z),O=re("vHTk"),D=re.n(O),E=re("yEEn"),L=re("ZW9T"),k=re("1vsH");ht.a=function(T){var A=T.name,C=T.data,h=T.theme,o=T.type,c=T.filename,d=T.monacoEditor,_=T.className,y=T.style,m=T.close,l=T.onClose,x=T.hasMask,f=Object(z.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),p=Object(I.a)(f,2),s=p[0],a=p[1],b=Object(z.useState)(""),v=Object(I.a)(b,2),S=v[0],M=v[1],H,V=1024*1024,Q=10*V,G=Object(z.useRef)();o==="office"&&(H=Object(k.T)(C).filesize,H>Q&&(o="other")),c&&(d.filename=c),Object(z.useEffect)(function(){var oe,fe,ve=(oe=document.cookie)===null||oe===void 0||((fe=oe.replace(/\s/g,""))===null||fe===void 0)?void 0:fe.split(";");ve==null||ve.map(function(De){var Ee=De.split("=");Ee[0]==="_educoder_session"&&M(Ee[1])})},[]);var W=function(){if(C.startsWith("http")||C.startsWith("/")){q();return}Object(k.z)(c||"educoder",C,c)},q=function(){Object(k.x)(c||A,C)};return console.log("data:",C,"fileanme:",c," name:",A),B.a.createElement("div",{style:Object(N.a)({},y||{}),className:"".concat(x&&D.a.bgBlack," ").concat(o?D.a.wrp:"hide")},m&&B.a.createElement("div",{className:D.a.close,ref:G},B.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return G.current}},B.a.createElement("span",{onClick:q},B.a.createElement("i",{className:"icon-quxiaozhiding"}))),B.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return G.current}},B.a.createElement("span",{className:"",onClick:l},B.a.createElement("i",{className:"icon-guanbi1"})))),B.a.createElement("div",{className:"".concat(D.a[_]," ").concat(_," ").concat(D.a.monaco," ").concat(o==="txt"?"show":"hide")},o==="txt"&&B.a.createElement(L.b,d)),o==="audio"&&B.a.createElement("audio",{src:"".concat(C!=null&&C.startsWith("/")||(C==null?void 0:C.indexOf("https://"))>-1?C:"data:audio/mp3;base64,").concat(C),autoPlay:!0}),o==="video"&&B.a.createElement(B.a.Fragment,null,C!=null&&C.startsWith("/")?B.a.createElement("video",{controls:!0,src:"".concat(C),autoPlay:!0}):B.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(C),autoPlay:!0})),o==="html"&&B.a.createElement("iframe",{src:C+"&disposition=inline"}),o==="pdf"&&B.a.createElement("embed",{className:D.a.embed,src:C}),o==="image"&&B.a.createElement(B.a.Fragment,null,B.a.createElement("img",{src:"".concat(C!=null&&C.startsWith("/")||(C==null?void 0:C.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(C)})),o==="other"&&B.a.createElement("div",null,B.a.createElement($.a,{type:"primary",size:"large",onClick:W},B.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(o==="download"||o==="office")&&B.a.createElement($.a,{type:"primary",size:"large",onClick:W},B.a.createElement(E.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(At,ht,re){},rUJ1:function(At,ht){const re=/[&<>"']/,ae=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},N=x=>X[x];function I(x,f){if(f){if(re.test(x))return x.replace(ae,N)}else if($.test(x))return x.replace(R,N);return x}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function B(x){return x.replace(z,(f,p)=>(p=p.toLowerCase(),p==="colon"?":":p.charAt(0)==="#"?p.charAt(1)==="x"?String.fromCharCode(parseInt(p.substring(2),16)):String.fromCharCode(+p.substring(1)):""))}const O=/(^|[^\[])\^/g;function D(x,f){x=x.source||x,f=f||"";const p={replace:(s,a)=>(a=a.source||a,a=a.replace(O,"$1"),x=x.replace(s,a),p),getRegex:()=>new RegExp(x,f)};return p}const E=/[^\w:]/g,L=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function k(x,f,p){if(x){let s;try{s=decodeURIComponent(B(p)).replace(E,"").toLowerCase()}catch(a){return null}if(s.indexOf("javascript:")===0||s.indexOf("vbscript:")===0||s.indexOf("data:")===0)return null}f&&!L.test(p)&&(p=o(f,p));try{p=encodeURI(p).replace(/%25/g,"%")}catch(s){return null}return p}const T={},A=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(x,f){T[" "+x]||(A.test(x)?T[" "+x]=x+"/":T[" "+x]=y(x,"/",!0)),x=T[" "+x];const p=x.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:x.replace(C,"$1")+f:f.charAt(0)==="/"?p?f:x.replace(h,"$1")+f:x+f}const c={exec:function(){}};function d(x){let f=1,p,s;for(;f<arguments.length;f++){p=arguments[f];for(s in p)Object.prototype.hasOwnProperty.call(p,s)&&(x[s]=p[s])}return x}function _(x,f){const p=x.replace(/\|/g,(b,v,S)=>{let M=!1,H=v;for(;--H>=0&&S[H]==="\\";)M=!M;return M?"|":" |"}),s=p.split(/ \|/);let a=0;if(s.length>f)s.splice(f);else for(;s.length<f;)s.push("");for(;a<s.length;a++)s[a]=s[a].trim().replace(/\\\|/g,"|");return s}function y(x,f,p){const s=x.length;if(s===0)return"";let a=0;for(;a<s;){const b=x.charAt(s-a-1);if(b===f&&!p)a++;else if(b!==f&&p)a++;else break}return x.substr(0,s-a)}function m(x,f){if(x.indexOf(f[1])===-1)return-1;const p=x.length;let s=0,a=0;for(;a<p;a++)if(x[a]==="\\")a++;else if(x[a]===f[0])s++;else if(x[a]===f[1]&&(s--,s<0))return a;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")}At.exports={escape:I,unescape:B,edit:D,cleanUrl:k,resolveUrl:o,noopTest:c,merge:d,splitCells:_,rtrim:y,findClosingBracket:m,checkSanitizeDeprecation:l}},sDPU:function(At,ht,re){"use strict";re.r(ht);var ae=re("cWXX"),$=re("/ezw"),R=re("k1fw"),X=re("9og8"),N=re("tJVT"),I=re("WmNS"),z=re.n(I),B=re("q1tI"),O=re.n(B),D=re("Ty5D"),E=re("9kvl"),L=re("FIWC"),k=re.n(L),T=re("sbIO"),A=re("ErOA"),C=re("LvDl"),h=re.n(C),o=function(d){var _,y,m,l,x=d.paperlibrary,f=d.user,p=d.globalSetting,s=d.dispatch,a=d.location,b=(a==null||((_=a.query)===null||_===void 0)?void 0:_.select)||0,v=Object(B.useState)(!1),S=Object(N.a)(v,2),M=S[0],H=S[1],V=Object(B.useState)(!0),Q=Object(N.a)(V,2),G=Q[0],W=Q[1],q=Object(B.useState)(Number(b)),oe=Object(N.a)(q,2),fe=oe[0],ve=oe[1],De=Object(B.useState)({}),Ee=Object(N.a)(De,2),_e=Ee[0],Te=Ee[1],Ce=Object(D.i)(),me=f.userInfo;Object(B.useEffect)(function(){return s({type:"globalSetting/footerToggle",payload:!1}),function(){s({type:"globalSetting/footerToggle",payload:!0})}},[]),Object(B.useEffect)(function(){return s({type:"globalSetting/onlyShowBackTopToggle",payload:!1}),s({type:"globalSetting/onlyShowBackTopIconToggle",payload:!1}),function(){s({type:"globalSetting/onlyShowBackTopToggle",payload:!0}),s({type:"globalSetting/onlyShowBackTopIconToggle",payload:!0})}},[]),Object(B.useEffect)(function(){return document.body.setAttribute("data-custom","initial"),function(){document.body.removeAttribute("data-custom")}},[]),Object(B.useEffect)(function(){ne(fe)},[]);var ne=function(){var Le=Object(X.a)(z.a.mark(function Me(){var ze,Ge,He=arguments;return z.a.wrap(function(Pe){for(;;)switch(Pe.prev=Pe.next){case 0:return ze=He.length>0&&He[0]!==void 0?He[0]:0,console.log(Ce),Pe.next=4,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/preview_random_exercise.json"),{method:"get",params:{num:ze}});case 4:Ge=Pe.sent,W(!1),Te(Ae(Ge));case 7:case"end":return Pe.stop()}},Me)}));return function(){return Le.apply(this,arguments)}}(),Ae=function(Me){var ze={1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D",7:"\u4E03"};if(!Me)return;var Ge=Me||{},He=Ge.exam,Be=Ge.single_questions,Pe=Ge.multiple_questions,pt=Ge.judgement_questions,it=Ge.program_questions,et=Ge.completion_questions,at=Ge.subjective_questions,Et=Ge.practical_questions,ct=Ge.combination_questions,dt=[Object(R.a)({type:"SINGLE",name:"\u5355\u9009\u9898"},Be),Object(R.a)({type:"MULTIPLE",name:"\u591A\u9009\u9898"},Pe),Object(R.a)({type:"COMPLETION",name:"\u586B\u7A7A\u9898"},et),Object(R.a)({type:"JUDGMENT",name:"\u5224\u65AD\u9898"},pt),Object(R.a)({type:"SUBJECTIVE",name:"\u7B80\u7B54\u9898"},at),Object(R.a)({type:"PROGRAM",name:"\u7F16\u7A0B\u9898"},it),Object(R.a)({type:"PRACTICAL",name:"\u5B9E\u8BAD\u9898"},Et),Object(R.a)({type:"COMBINATION",name:"\u7EC4\u5408\u9898"},ct)],we=[],gt=0,lt=0,Re=dt.filter(function(je){return je.questions_count>0}).map(function(je,ge){var de;return(de=je.questions)===null||de===void 0||de.forEach(function(pe){we.push(pe.id),gt=gt+pe.score,lt=lt+1}),Object(R.a)(Object(R.a)({},je),{number:ze[ge+1]})});return{all_questions_count:lt,all_score:gt,questionList:Re,ids:we,exam:He}},rt=function(){E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))},$e=function(){alert("\u4FDD\u5B58")},Xe=function(){var Le=Object(X.a)(z.a.mark(function Me(ze,Ge){var He,Be,Pe;return z.a.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return it.next=2,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/toggle_random_question.json"),{method:"post",body:{question_id:ze==null?void 0:ze.single_question_id}});case 2:He=it.sent,He!=null&&He.question&&(Pe=Object(C.cloneDeep)(_e),Pe.questionList=Pe==null||((Be=Pe.questionList)===null||Be===void 0)?void 0:Be.map(function(et){if(et.type===Ge.type){var at=Object(C.cloneDeep)(et==null?void 0:et.questions);return at.splice(Ge.index,1,He==null?void 0:He.question),Object(R.a)(Object(R.a)({},et),{},{questions:at})}return et}),Te(Pe));case 4:case"end":return it.stop()}},Me)}));return function(ze,Ge){return Le.apply(this,arguments)}}(),Ve=function(){var Le=Object(X.a)(z.a.mark(function Me(ze){return z.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:document.body.scrollIntoView(),ne(ze),ve(ze);case 3:case"end":return He.stop()}},Me)}));return function(ze){return Le.apply(this,arguments)}}();return console.log(Object(D.h)(),"location333"),O.a.createElement("section",{className:k.a.wrap},O.a.createElement($.a,{loading:G,active:!0,paragraph:{rows:5}},((y=Object(D.h)())===null||y===void 0||((m=y.pathname)===null||m===void 0)?void 0:m.includes("preview"))&&O.a.createElement("div",{className:k.a.crumbs},O.a.createElement("b",null),O.a.createElement("span",{className:"current",onClick:function(){return E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))}},"".concat(me==null||((l=me.course)===null||l===void 0)?void 0:l.course_name,">")),O.a.createElement("span",{className:"current",onClick:function(){return E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))}},"\u8BD5\u5377\u5217\u8868>"),O.a.createElement("span",{style:{color:"#bebebe"}},"\u9884\u89C8")),O.a.createElement(T.a,{loading:M,submit:$e,goBack:rt,data:_e,selectValue:fe,editPreview:!0,onExchange:Xe,onSkipExamination:Ve})))};ht.default=Object(E.a)(function(c){var d=c.paperlibrary,_=c.user,y=c.globalSetting;return{paperlibrary:d,user:_,globalSetting:y}})(o)},sbIO:function(At,ht,re){"use strict";var ae=re("DjyN"),$=re("NUBc"),R=re("5Dmo"),X=re("3S7+"),N=re("/zsF"),I=re("PArb"),z=re("Q9mQ"),B=re("diRs"),O=re("+L6B"),D=re("2/Rp"),E=re("5NDa"),L=re("5rEg"),k=re("miYZ"),T=re("tsqr"),A=re("9og8"),C=re("giR+"),h=re("fyUT"),o=re("2qtc"),c=re("kLXV"),d=re("tJVT"),_=re("WmNS"),y=re.n(_),m=re("q1tI"),l=re.n(m),x=re("PsQE"),f=re.n(x),p=re("0eGx"),s=re.n(p),a=re("9Bee"),b=re("Ty5D"),v=re("9kvl"),S=re("ErOA"),M=re("+yhJ"),H=re.n(M),V=re("RZ/O"),Q=re.n(V),G=re("LvDl"),W=re("6K3P"),q=re.n(W),oe=re("sRBo"),fe=re("kaz8"),ve=re("oBTY"),De=re("PpiC"),Ee=re("Ot1p"),_e=re("kqOp"),Te=re("7qnI"),Ce=re("1vsH"),me=re("PGNT"),ne=re.n(me),Ae=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],rt=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.dispatch,Je=ie.isEdit,Qe=ie.editData,bt=Object(De.a)(ie,["globalSetting","loading","dispatch","isEdit","editData"]),Dt=Object(m.useState)(""),Ze=Object(d.a)(Dt,2),ut=Ze[0],Ft=Ze[1],Ct=Object(m.useState)(""),jt=Object(d.a)(Ct,2),$t=jt[0],Lt=jt[1],Qt=Object(m.useState)([]),Zt=Object(d.a)(Qt,2),ft=Zt[0],Xt=Zt[1],zt=Object(m.useState)(""),Gt=Object(d.a)(zt,2),Ut=Gt[0],Mt=Gt[1],St=Object(m.useState)(),tt=Object(d.a)(St,2),Fe=tt[0],nr=tt[1],Vt=Object(m.useState)(!1),qt=Object(d.a)(Vt,2),Wt=qt[0],Tr=qt[1];Object(m.useEffect)(function(){if(!Qe||!Je)return;Ft(Qe==null?void 0:Qe.name),Lt(Qe==null?void 0:Qe.analysis),nr(Qe==null?void 0:Qe.is_ordered),Tr(!0)},[Qe]),Object(m.useEffect)(function(){if(!Wt)return;var xr=Qe==null?void 0:Qe.standard_answer.map(function(U){return U.answer_text});Xt(xr),Tr(!1)},[Wt]),Object(m.useImperativeHandle)(se,function(){return{onSave:ir,Clear:Rt}});var ir=function(){var U=[],u=!1;return ut?(ft.forEach(function(g,P){U.push({position:P+1,answer_text:[]}),g.forEach(function(J,j){U[P].answer_text.push(J),(!J||!Object(Ce.db)(J,1e4))&&(Mt("".concat(P,"-").concat(j)),T.b.info(J?"\u7B54\u6848\u4E0D\u80FD\u8D85\u8FC710000\u5B57\u7B26":"\u7B54\u6848\uFF1A\u4E0D\u80FD\u4E3A\u7A7A"),u=!0)})}),u?!1:(U==null?void 0:U.length)>20?(T.b.warn("\u586B\u7A7A\u9898\u6807\u51C6\u7B54\u6848\u4E0D\u80FD\u4E3A\u7A7A/\u4E0D\u80FD\u8D85\u8FC720\u4E2A\uFF01"),!1):{name:ut,analysis:$t,standard_answers:U,is_ordered:Fe}):(T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1)},Rt=function(){Ft(""),Lt(""),Xt([]),nr(!1)},Ie=function(U,u,g){var P=ft.slice();if(u&&P.splice(U,u),g)for(var J=0;J<g;J++)P.splice(U+J,0,[""]);Xt(P)},xt=function(U,u,g){Mt("");var P=ft.slice();P[U][u]=g,Xt(P)},Dr=function(U){var u=ft.slice();u[U]=[].concat(Object(ve.a)(u[U]),[""]),Xt(u)},un=function(U,u){var g=ft.slice();if(!g[U][u]){g[U]=g[U].filter(function(P,J){return J!==u}),Xt(g);return}c.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:"\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u53C2\u8003\u7B54\u6848\u5417\uFF1F",className:ne.a.modal,onOk:function(){g[U]=g[U].filter(function(J,j){return j!==u}),Xt(g)}})},dn=function(U){c.a.confirm({centered:!0,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:"\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u53C2\u8003\u7B54\u6848\u5417\uFF1F",className:ne.a.modal,onOk:function(){var g=ft.slice();g=ft.filter(function(P,J){return U!==J}),Xt(g)}})};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement("div",null,l.a.createElement(_e.a,{id:"completion-question-tittle",placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE",height:155,defaultValue:ut,onChange:function(U){return Ft(U)},showNullButton:!0,onPlaceholderChange:Ie})),l.a.createElement("div",{className:"mt20"},ft.map(function(xr,U){return l.a.createElement(Te.a,{key:U,answers:xr,index:U,flex:1,is_md:!0,activeOptionErrorIndex:Ut,onAnswerChange:xt,addChildAnswer:Dr,deleteChildAnswer:un,deleteChildAnswermain:dn})})),l.a.createElement("div",{className:"mt20"},ft.length>1&&l.a.createElement("span",null,l.a.createElement(fe.a,{checked:Fe,onChange:function(U){return nr(U.target.checked)},className:"".concat(ne.a.color333," font14")},"\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42"),l.a.createElement("span",{className:"".concat(ne.a.color999," font12")},"\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09"))),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:$t,onChange:function(U){return Lt(U)}}))},$e=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(rt)),Xe=re("7Kak"),Ve=re("9yH6"),Le=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Me=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.editData,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["globalSetting","loading","editData","dispatch","onRef","isEdit"]),ut=Object(m.useState)(),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(""),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){if(!ke||!Dt)return;Zt(ke==null?void 0:ke.name),Gt(ke==null?void 0:ke.analysis);var St=ke==null?void 0:ke.choices.find(function(tt){return tt.is_answer});jt(St.choice_text==="\u6B63\u786E"?"0":"1")},[ke]),Object(m.useImperativeHandle)(se,function(){return{onSave:Ut,Clear:Mt}});var Ut=function(){if(!Qt)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;if(!Ct)return T.b.info("\u8BF7\u5148\u70B9\u51FB\u9009\u62E9\u672C\u9009\u62E9\u9898\u7684\u6B63\u786E\u9009\u9879"),!1;var tt=[{choice_text:"\u6B63\u786E",is_answer:Ct==="0"?1:0},{choice_text:"\u9519\u8BEF",is_answer:Ct==="1"?1:0}];return{name:Qt,choices:tt,analysis:zt}},Mt=function(){Zt(""),Gt(""),jt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Qt,onChange:function(tt){return Zt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),l.a.createElement(Ve.a.Group,{buttonStyle:"solid",value:Ct,onChange:function(tt){return jt(tt.target.value)}},l.a.createElement(Ve.a.Button,{value:"0",className:"".concat(ne.a.radio," mr40")},"\u6B63\u786E"),l.a.createElement(Ve.a.Button,{value:"1",className:ne.a.radio},"\u9519\u8BEF")),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:zt,onChange:function(tt){return Gt(tt)}}))},ze=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(Me)),Ge=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],He=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)([]),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)([]),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(d.a)(Ut,2),St=Mt[0],tt=Mt[1],Fe=Object(m.useState)(""),nr=Object(d.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Dt)return;tt(ue==null?void 0:ue.name),qt(ue==null?void 0:ue.analysis),jt(ue==null?void 0:ue.choices.map(function(Rt){return Rt.choice_text}));var ir=[];ue==null||ue.choices.map(function(Rt,Ie){Rt.is_answer&&ir.push(Ie)}),Gt(ir)},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Wt,Clear:Tr}});var Wt=function(){if(!St)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;var Rt=Ct.findIndex(function(xt){return!xt});if(Rt>-1)return T.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(Ge[Rt]," \u9009\u9879\u7684\u5185\u5BB9")),!1;if(!zt.length)return T.b.info("\u8BF7\u8BBE\u7F6E\u672C\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E"),!1;if(zt.length<2)return T.b.info("\u591A\u9009\u9898\u6700\u5C0F\u6B63\u786E\u9009\u9879\u4E3A2\u4E2A"),!1;var Ie=Ct.map(function(xt,Dr){return{choice_text:xt,is_answer:zt.includes(Dr)?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),tt(""),qt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:St,onChange:function(Rt){return tt(Rt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ct.map(function(ir,Rt){return l.a.createElement("div",{className:ne.a.choiceWrap,key:Rt},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(zt.includes(Rt)?ne.a.activeAnswer:""),onClick:function(){zt.includes(Rt)?Gt(zt.filter(function(xt){return xt!==Rt})):Gt([].concat(Object(ve.a)(zt),[Rt]))}},Ge[Rt])),l.a.createElement("div",{className:ne.a.editorWrap},Qt===Rt?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Rt),watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:ir,onChange:function(xt){Ct[Rt]=xt,jt(Ct)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Zt(Rt)}},l.a.createElement(a.a,{value:ir}))),Rt>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){jt(Ct.filter(function(xt,Dr){return Dr!==Rt})),zt.includes(Rt)?Gt(zt.filter(function(xt){return xt!==Rt})):Gt([].concat(Object(ve.a)(zt),[Rt]))}})),Rt<7&&Rt===Ct.length-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return jt([].concat(Object(ve.a)(Ct),[""]))}})))}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Vt,onChange:function(Rt){return qt(Rt)}}))},Be=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(He)),Pe=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],pt=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)([]),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(d.a)(Ut,2),St=Mt[0],tt=Mt[1],Fe=Object(m.useState)(""),nr=Object(d.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Dt)return;tt(ue==null?void 0:ue.name),qt(ue==null?void 0:ue.analysis),jt(ue==null?void 0:ue.choices.map(function(ir){return ir.choice_text})),Gt(ue==null?void 0:ue.choices.findIndex(function(ir){return ir.is_answer}))},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Wt,Clear:Tr}});var Wt=function(){if(!St)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;var Rt=Ct.findIndex(function(xt){return!xt});if(Rt>-1)return T.b.info("\u8BF7\u5148\u8F93\u5165 ".concat(Pe[Rt]," \u9009\u9879\u7684\u5185\u5BB9")),!1;if(console.log("activeAnswer: ",zt),!(typeof zt=="number"))return T.b.info("\u8BF7\u8BBE\u7F6E\u672C\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E"),!1;var Ie=Ct.map(function(xt,Dr){return{choice_text:xt,is_answer:zt===Dr?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),tt(""),qt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:St,onChange:function(Rt){return tt(Rt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ct.map(function(ir,Rt){return l.a.createElement("div",{className:ne.a.choiceWrap,key:Rt},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(zt===Rt?ne.a.activeAnswer:""),onClick:function(){return Gt(Rt)}},Pe[Rt])),l.a.createElement("div",{className:ne.a.editorWrap},Qt===Rt?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Rt),watch:!0,height:155,isFocus:!0,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:ir,onChange:function(xt){Ct[Rt]=xt,jt(Ct)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Zt(Rt)}},l.a.createElement(a.a,{value:ir}))),Rt>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){jt(Ct.filter(function(xt,Dr){return Dr!==Rt})),Rt===zt&&Gt(null)}})),Rt<7&&Rt===Ct.length-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return jt([].concat(Object(ve.a)(Ct),[""]))}})))}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Vt,onChange:function(Rt){return qt(Rt)}}))},it=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(pt)),et=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],at=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,ke=ie.loading,Je=ie.dispatch,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ut=Object(m.useState)(""),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1],ft=Object(m.useState)(""),Xt=Object(d.a)(ft,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){var St;if(!ue||!Dt)return;jt(ue==null?void 0:ue.name),Zt(ue==null?void 0:ue.analysis),Gt(ue==null||((St=ue.answer_texts)===null||St===void 0)?void 0:St[0])},[ue]),Object(m.useImperativeHandle)(se,function(){return{onSave:Ut,Clear:Mt}});var Ut=function(){return Ct?zt?{name:Ct,answer_texts:[zt],analysis:Qt}:(T.b.info("\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848"),!1):(T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1)},Mt=function(){jt(""),Zt(""),Gt("")};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ct,onChange:function(tt){return jt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u53C2\u8003\u7B54\u6848\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-reference-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848",defaultValue:zt,onChange:function(tt){return Gt(tt)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Qt,onChange:function(tt){return Zt(tt)}}))},Et=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(at)),ct=re("k1fw"),dt=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],we=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,ke=ie.dispatch,Je=ie.editData,Qe=ie.onRef,bt=Qe===void 0?function(){}:Qe,Dt=ie.isEdit,Ze=Object(De.a)(ie,["globalSetting","loading","dispatch","editData","onRef","isEdit"]),ut=Object(m.useState)(""),Ft=Object(d.a)(ut,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)([]),Lt=Object(d.a)($t,2),Qt=Lt[0],Zt=Lt[1];console.log(Qt),Object(m.useEffect)(function(){var Ut;if(!Je||!Dt)return;jt(Je==null?void 0:Je.name);var Mt=Je==null||((Ut=Je.sub_item_banks)===null||Ut===void 0)?void 0:Ut.map(function(St){var tt,Fe,nr;return Object(ct.a)(Object(ct.a)({},St),{},{id:St.id,open:!1,qusList:St==null||((tt=St.choices)===null||tt===void 0)?void 0:tt.map(function(Vt){return Vt.choice_text}),activeQusEditor:null,qusAnswer:(Fe=[St==null||((nr=St.choices)===null||nr===void 0)?void 0:nr.findIndex(function(Vt){return Vt.is_answer})])===null||Fe===void 0?void 0:Fe.filter(function(Vt){return Vt!==-1})})});Zt(Mt)},[Je]),Object(m.useImperativeHandle)(se,function(){return{onSave:ft,Clear:Xt}});var ft=function(){if(!Ct)return T.b.info("\u8BF7\u60A8\u8F93\u5165\u9898\u5E72"),!1;if(Qt.length===0)return T.b.info("\u8BF7\u60A8\u6DFB\u52A0\u5C0F\u9898"),!1;for(var Mt=0;Mt<Qt.length;Mt++){var St,tt=Qt[Mt];if(!(tt!=null&&tt.name))return T.b.info("\u8BF7\u60A8\u8F93\u5165\u7B2C".concat(Mt+1,"\u5C0F\u9898\u9898\u5E72")),!1;var Fe=tt==null||((St=tt.qusList)===null||St===void 0)?void 0:St.findIndex(function(Vt){return!Vt});if(Fe>-1)return T.b.info("\u8BF7\u5148\u8F93\u5165\u7B2C".concat(Mt+1,"\u5C0F\u9898").concat(dt[Fe],"\u9009\u9879\u7684\u5185\u5BB9")),!1;if(!(tt!=null&&tt.qusAnswer.length))return T.b.info("\u8BF7\u8BBE\u7F6E\u7B2C".concat(Mt+1,"\u5C0F\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E")),!1}var nr=Qt.map(function(Vt){return{id:Vt.id>1?Vt.id:null,name:Vt.name,item_type:Vt.item_type,analysis:Vt.analysis,choices:Vt.qusList.map(function(qt,Wt){return{choice_text:qt,is_answer:Vt.qusAnswer[0]===Wt?1:0}})}});return{name:Ct,sub_item_banks:nr}},Xt=function(){jt(""),Zt([])},zt=function(){var Mt={id:Math.random(),item_type:"SINGLE",open:!1,name:"",qusList:["","","",""],activeQusEditor:null,qusAnswer:[],analysis:""};Zt(Qt.concat(Mt))},Gt=function(Mt,St,tt){var Fe=Object(G.cloneDeep)(Qt);if(Mt==="open"&&(Fe[St].open=!Fe[St].open),Mt==="delete"&&Fe.splice(St,1),Mt==="value"&&(Fe[St].name=tt),Mt==="answer"&&(Fe[St].qusAnswer=[tt]),Mt==="edit"&&(Fe[St].activeQusEditor=tt),Mt==="details"&&(Fe[St].qusList[Fe[St].activeQusEditor]=tt),Mt==="addQus"&&(Fe[St].qusList=Fe[St].qusList.concat("")),Mt==="deleteQus"){var nr;Fe[St].qusList=Fe[St].qusList.filter(function(Vt,qt){return qt!==tt}),Fe[St].qusAnswer=(nr=Fe[St].qusAnswer)===null||nr===void 0?void 0:nr.filter(function(Vt){return Vt!==tt})}Mt==="analysis"&&(Fe[St].analysis=tt),Zt(Fe)};return l.a.createElement("section",{className:ne.a.wrap},l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u9898\u5E72\uFF1A")),l.a.createElement(Ee.a,{id:"combination-question-title",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ct,onChange:function(Mt){return jt(Mt)}}),Qt==null?void 0:Qt.map(function(Ut,Mt){var St;return l.a.createElement("div",{className:ne.a.fold,key:Ut.id},l.a.createElement("div",{onClick:function(){return Gt("open",Mt)},className:ne.a.head},l.a.createElement("i",{className:"iconfont icon-sanjiaoxing",style:{transform:Ut.open?"initial":"rotate(270deg) translate(2px, 4px)"}}),l.a.createElement("span",null,"\u7B2C",Mt+1,"\u5C0F\u9898\uFF08\u5355\u9009\u9898\uFF09"),l.a.createElement("b",{style:{visibility:"hidden"},onClick:function(Fe){Fe.stopPropagation(),Gt("delete",Mt)},className:"iconfont icon-shanchu8"})),l.a.createElement("div",{className:"mb10",style:{display:Ut.open?"block":"none"}},l.a.createElement(Ee.a,{watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",defaultValue:Ut==null?void 0:Ut.name,onChange:function(Fe){return Gt("value",Mt,Fe)}}),l.a.createElement("p",{className:ne.a.titleWrap},l.a.createElement("span",{className:ne.a.required},"*"),l.a.createElement("span",{className:ne.a.title},"\u7B54\u6848\u9009\u9879\uFF1A",l.a.createElement("span",{className:ne.a.colorGray},"\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"))),Ut==null||((St=Ut.qusList)===null||St===void 0)?void 0:St.map(function(tt,Fe){var nr,Vt;return l.a.createElement("div",{className:ne.a.choiceWrap,key:Fe},l.a.createElement(X.a,{title:"\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",placement:"left"},l.a.createElement("div",{className:"".concat(ne.a.answer," ").concat(Ut!=null&&(nr=Ut.qusAnswer)!==null&&nr!==void 0&&nr.includes(Fe)?ne.a.activeAnswer:""),onClick:function(){return Gt("answer",Mt,Fe)}},dt[Fe])),l.a.createElement("div",{className:ne.a.editorWrap},(Ut==null?void 0:Ut.activeQusEditor)===Fe?l.a.createElement(Ee.a,{id:"single-question-option-".concat(Fe),watch:!0,height:155,isFocus:!0,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9009\u9879",defaultValue:tt,onChange:function(Wt){return Gt("details",Mt,Wt)}}):l.a.createElement("div",{className:ne.a.htmlWrap,onClick:function(){return Gt("edit",Mt,Fe)}},l.a.createElement(a.a,{value:tt}))),Fe>1&&l.a.createElement(X.a,{title:"\u5220\u9664"},l.a.createElement("i",{className:"".concat(ne.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return Gt("deleteQus",Mt,Fe)}})),Fe<7&&Fe===(Ut==null||((Vt=Ut.qusList)===null||Vt===void 0)?void 0:Vt.length)-1&&l.a.createElement(X.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},l.a.createElement("i",{className:"".concat(ne.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return Gt("addQus",Mt)}})))}),l.a.createElement("p",{className:"mb10 mt10"},l.a.createElement("span",{className:ne.a.title},"\u9898\u76EE\u89E3\u6790\uFF1A")),l.a.createElement(Ee.a,{id:"single-question-answer",watch:!0,height:155,placeholder:"\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790",defaultValue:Ut.analysis,onChange:function(Fe){return Gt("analysis",Mt,Fe)}})))}))},gt=Object(v.a)(function(te){var ie=te.loading,se=te.globalSetting;return{globalSetting:se,loading:ie.effects}},null,null,{forwardRef:!0})(Object(m.forwardRef)(we)),lt=re("14J3"),Re=re("BMrR"),je=re("ZWs3"),ge=function(ie){var se=ie.visible,ue=ie.onCancel,Se=ie.onRandomExchange,ke=ie.selectFromProblemSet;return l.a.createElement(c.a,{title:"\u8BF7\u9009\u62E9\u66FF\u6362\u65B9\u5F0F",visible:se,onCancel:ue,centered:!0,maskClosable:!0,footer:null},l.a.createElement(Re.a,{justify:"center"},l.a.createElement(je.a,{onClick:Se},"\u968F\u673A\u66F4\u6362"),l.a.createElement(D.a,{style:{marginLeft:24},onClick:ke},"\u4ECE\u9898\u5E93\u4E2D\u9009\u62E9")))},de=ge,pe=function(ie){var se,ue,Se,ke,Je,Qe,bt,Dt,Ze=ie.data,ut=ie.submit,Ft=ie.goBack,Ct=ie.loading,jt=ie.onTypeScore,$t=ie.editPreview,Lt=$t===void 0?!1:$t,Qt=ie.onSkipExamination,Zt=ie.selectValue,ft=ie.onExchange,Xt=Object(m.useRef)(),zt=Object(m.useRef)(Object(G.debounce)(function(){return xr()},100,{leading:!0,trailing:!0})),Gt=Object(m.useState)(null),Ut=Object(d.a)(Gt,2),Mt=Ut[0],St=Ut[1],tt=Object(m.useState)(!1),Fe=Object(d.a)(tt,2),nr=Fe[0],Vt=Fe[1],qt=Object(m.useState)(!1),Wt=Object(d.a)(qt,2),Tr=Wt[0],ir=Wt[1],Rt=Object(m.useRef)(),Ie=Object(b.i)();Object(m.useEffect)(function(){return window.addEventListener("scroll",zt==null?void 0:zt.current),function(){window.removeEventListener("scroll",zt==null?void 0:zt.current)}},[]),Object(m.useEffect)(function(){Vt(!0)},[]),Object(m.useEffect)(function(){var nt,be,Ke,wt,mt=(nt=document.getElementById("examName"))===null||nt===void 0||((be=nt.getElementsByClassName("ant-pagination-options-quick-jumper"))===null||be===void 0||((Ke=be[0])===null||Ke===void 0||((wt=Ke.childNodes)===null||wt===void 0)))?void 0:wt[2];mt&&(mt.nodeValue="\u4EFD")},[Ze]);var xt=function(be){var Ke=parseInt(be);return isNaN(Ke)?"":Ke};function Dr(){var nt=0,be=0,Ke=0;return document.body&&(be=document.body.scrollTop),document.documentElement&&(Ke=document.documentElement.scrollTop),nt=be-Ke>0?be:Ke,nt}function un(){var nt=0,be=0,Ke=0;return document.body&&(be=document.body.scrollHeight),document.documentElement&&(Ke=document.documentElement.scrollHeight),nt=be-Ke>0?be:Ke,nt}function dn(){var nt=0;return document.compatMode=="CSS1Compat"?nt=document.documentElement.clientHeight:nt=document.body.clientHeight,nt}var xr=function(){var be=document.getElementById("preview_btns"),Ke=document.getElementById("preview_btns_else");Dr()+dn()>=un()-68?(be.style.visibility="hidden",Ke.style.visibility="visible"):(be.style.visibility="visible",Ke.style.visibility="hidden")},U=["\u5BB9\u6613","\u7B80\u5355","\u9002\u4E2D","\u56F0\u96BE"],u=function(be){var Ke,wt=[];return l.a.createElement(l.a.Fragment,null,l.a.createElement("aside",{className:f.a.single},be==null||((Ke=be.choices)===null||Ke===void 0)?void 0:Ke.map(function(mt,vt){return mt.is_answer&&wt.push(ce[vt]),l.a.createElement("ul",{key:vt},l.a.createElement("li",null,ce[vt],"\u3001"),l.a.createElement("li",null,l.a.createElement(a.a,{value:mt.choice_text})))})),l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",wt.join(""),l.a.createElement("span",{className:"ml30"},"\u96BE\u5EA6\uFF1A",U[be.difficulty])),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))},g=function(be){var Ke,wt=be==null||((Ke=be.standard_answer)===null||Ke===void 0)?void 0:Ke.map(function(mt){var vt;return"\u7B54\u6848\uFF08\u586B\u7A7A".concat(mt.position,"\uFF09\uFF1A").concat(mt==null||((vt=mt.answer_text)===null||vt===void 0)?void 0:vt.join("\u3001"))});return l.a.createElement(l.a.Fragment,null,l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",wt),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))},P=function(be){var Ke;return l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",be==null||((Ke=be.answer_texts)===null||Ke===void 0)?void 0:Ke[0]),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:be.analysis?be.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name)))},J=function(be){var Ke;return l.a.createElement("div",{className:f.a.analysis},l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u9884\u671F\u8F93\u51FA:"),l.a.createElement(a.a,{value:be==null||((Ke=be.program_attr)===null||Ke===void 0)?void 0:Ke.description})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name)))},j=function(be,Ke){var wt;return l.a.createElement("div",null,be==null||((wt=be.sub_item_banks)===null||wt===void 0)?void 0:wt.map(function(mt,vt){var It,gr=[];return l.a.createElement(l.a.Fragment,null,l.a.createElement("div",{style:{marginLeft:25,fontSize:"16px",color:"#333"}},Ke+1+"."+(vt+1),"\uFF08\u5355\u9009\u9898\uFF09",mt.name),l.a.createElement("aside",{className:f.a.single},mt==null||((It=mt.choices)===null||It===void 0)?void 0:It.map(function(cr,hr){return cr.is_answer&&gr.push(ce[hr]),l.a.createElement("ul",{key:hr},l.a.createElement("li",null,ce[hr],"\u3001"),l.a.createElement("li",null,l.a.createElement(a.a,{value:cr.choice_text})))})),l.a.createElement("div",{className:f.a.analysis},l.a.createElement("div",null,"\u6B63\u786E\u7B54\u6848\uFF1A",gr.join(""),l.a.createElement("span",{className:"ml30"},"\u96BE\u5EA6\uFF1A",U[mt.difficulty])),l.a.createElement("aside",null,l.a.createElement("span",{className:f.a.text},"\u89E3\u6790:"),l.a.createElement(a.a,{value:mt.analysis?mt.analysis:"\u6682\u65E0\u89E3\u6790"})),l.a.createElement("ul",null,l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#007AFF",marginRight:10}},"\u65B9\u5411&\u8BFE\u7A0B:"),"".concat(be==null?void 0:be.discipline_name,"/").concat(be==null?void 0:be.sub_discipline_name)),l.a.createElement("li",null,l.a.createElement("span",{style:{color:"#5AB891",marginRight:10}},"\u77E5\u8BC6\u70B9:"),be==null?void 0:be.tag_discipline_name))))}))},ce=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Ne=function(be){var Ke,wt=[];be==null||((Ke=be.questions)===null||Ke===void 0)||Ke.map(function(vt){var It;return vt==null||((It=vt.sub_item_banks)===null||It===void 0)?void 0:It.map(function(gr){wt.push(gr)})});var mt=0;be.type==="COMBINATION"?mt=be.questions_score/wt.length:mt=be.questions_score/be.questions_count,c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u5206\u6570\u8BBE\u7F6E",content:l.a.createElement("div",{className:f.a.modalColumn},l.a.createElement("div",{className:f.a.modalRow,style:{justifyContent:"flex-start"}},l.a.createElement("sup",{className:f.a.sup},"*"),l.a.createElement("span",null,be==null?void 0:be.name,(be==null?void 0:be.type)==="COMBINATION"&&"\u4E2D\u7684\u6BCF\u5C0F\u9898","\uFF1A"),l.a.createElement(h.a,{min:1,parser:xt,defaultValue:mt,onChange:function(It){mt=It}}),l.a.createElement("span",{className:"ml5"},"\u5206/\u9898"))),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var vt=Object(A.a)(y.a.mark(function gr(){var cr,hr;return y.a.wrap(function(Sr){for(;;)switch(Sr.prev=Sr.next){case 0:if(mt){Sr.next=3;break}return T.b.warn("\u5206\u6570\u4E0D\u80FD\u4E3A\u7A7A\u6216\u4E3A0"),Sr.abrupt("return",Promise.reject());case 3:be.type==="COMBINATION"?(cr={type:be==null?void 0:be.type,score:mt,scoreTotal:mt*(wt==null?void 0:wt.length)},jt(cr)):(hr={type:be==null?void 0:be.type,score:mt,scoreTotal:mt*be.questions_count},jt(hr));case 4:case"end":return Sr.stop()}},gr)}));function It(){return vt.apply(this,arguments)}return It}()})},qe=function(){var be="";c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u4FDD\u5B58\u8BD5\u5377",content:l.a.createElement("div",{className:f.a.modalColumn},l.a.createElement("div",{style:{color:"#676A6C",display:"flex"},className:"font14 mt20"},l.a.createElement("img",{style:{marginRight:5},src:q.a}),"\u4FDD\u5B58\u540E\u5355\u72EC\u751F\u6210\u4E00\u4EFD\u4EBA\u5DE5\u7EC4\u5377\u7C7B\u578B\u7684\u56FA\u5B9A\u8BD5\u5377\u3002"),l.a.createElement("div",{className:f.a.modalRow,style:{marginTop:20}},l.a.createElement("sup",{className:f.a.sup},"*"),l.a.createElement("span",{style:{flexShrink:0}},"\u8BD5\u5377\u540D\u79F0\uFF1A"),l.a.createElement(L.a,{placeholder:"\u8BF7\u8F93\u5165\u8BD5\u5377\u540D\u79F0",min:0,maxLength:60,defaultValue:be,onChange:function(wt){be=wt.target.value}}))),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var Ke=Object(A.a)(y.a.mark(function mt(){var vt,It,gr,cr,hr;return y.a.wrap(function(Sr){for(;;)switch(Sr.prev=Sr.next){case 0:if(be){Sr.next=3;break}return T.b.warn("\u8BD5\u5377\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A"),Sr.abrupt("return",Promise.reject());case 3:return It=[],gr=[],cr=[],Ze==null||((vt=Ze.questionList)===null||vt===void 0)||vt.forEach(function(Wr){var or;(or=Wr.questions)===null||or===void 0||or.forEach(function(tr){It.push(tr.id),gr.push(Wr.questions_score/Wr.questions_count),Wr.type==="COMBINATION"&&cr.push({id:tr.id,sub_item_bank_ids:tr.sub_item_banks.map(function(pr){return pr.id})})})}),console.log("-----",cr),hr={item_bank_ids:It,item_bank_scores:gr,name:be,combination_item_banks:cr},Sr.next=11,ut(hr);case 11:case"end":return Sr.stop()}},mt)}));function wt(){return Ke.apply(this,arguments)}return wt}()})},Tt=function(be,Ke,wt,mt){var vt,It="".concat(location.pathname).concat(location.search),gr=(vt=mt.questions)===null||vt===void 0?void 0:vt.map(function(hr){return hr.id});if(It.includes("exercise"))Rt.current={id:be,ids:gr,type:Ke,index:wt},ir(!0);else var cr=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u8981\u66F4\u6362\u8BE5\u8BD5\u9898\u5417\uFF1F",cancelButtonProps:{disabled:!1},maskClosable:!0,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var hr=Object(A.a)(y.a.mark(function Sr(){return y.a.wrap(function(or){for(;;)switch(or.prev=or.next){case 0:return cr.update({cancelButtonProps:{disabled:!0}}),or.next=3,ft({single_question_id:be,seleted_item_bank_ids:gr},{type:Ke,index:wt});case 3:cr.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210\u8BD5\u9898");case 5:case"end":return or.stop()}},Sr)}));function Lr(){return hr.apply(this,arguments)}return Lr}()})},Ue=function(be){var Ke,wt=(Ke=be.questions)===null||Ke===void 0?void 0:Ke.map(function(It){return It.id}),mt=be.name,vt=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u66F4\u6362".concat(mt,"\u4E2D\u7684\u6240\u6709\u8BD5\u9898\u5417\uFF1F"),cancelButtonProps:{disabled:!1},maskClosable:!1,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var It=Object(A.a)(y.a.mark(function cr(){return y.a.wrap(function(Lr){for(;;)switch(Lr.prev=Lr.next){case 0:return vt.update({cancelButtonProps:{disabled:!0}}),Lr.next=3,ft({seleted_item_bank_ids:wt},{type:be.type});case 3:vt.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210".concat(mt,"\u8BD5\u9898"));case 5:case"end":return Lr.stop()}},cr)}));function gr(){return It.apply(this,arguments)}return gr}()})},Pt=function(){var be=c.a.confirm({icon:null,className:"custom-modal-divider",centered:!0,title:"\u6E29\u99A8\u63D0\u793A",content:"\u786E\u8BA4\u66F4\u6362\u9884\u89C8\u4E2D\u7684\u6240\u6709\u8BD5\u9898\u5417\uFF1F",cancelButtonProps:{disabled:!1},maskClosable:!1,keyboard:!1,okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",onOk:function(){var Ke=Object(A.a)(y.a.mark(function mt(){return y.a.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return be.update({cancelButtonProps:{disabled:!0}}),It.next=3,ft();case 3:be.update({cancelButtonProps:{disabled:!1}}),T.b.success("\u5DF2\u91CD\u65B0\u968F\u673A\u751F\u6210\u6574\u5F20\u8BD5\u9898");case 5:case"end":return It.stop()}},mt)}));function wt(){return Ke.apply(this,arguments)}return wt}()})},er=function(be){console.log(be,"key"),Qt(be-1)},fr=function(){return l.a.createElement(l.a.Fragment,null,l.a.createElement(B.a,{color:"#55575D",overlayClassName:f.a.popover,visible:nr,getPopupContainer:function(Ke){return Ke==null?void 0:Ke.parentNode},content:"\u5982\u60A8\u5BF9\u6B64\u4EFD\u8BD5\u9898\u6EE1\u610F\uFF0C\u53EF\u5C06\u6B64\u4EFD\u8BD5\u9898\u4FDD\u5B58\u4E3A\u56FA\u5B9A\u8BD5\u5377"},l.a.createElement(D.a,{onMouseEnter:function(){return Vt(!0)},onMouseLeave:function(){return Vt(!1)},onClick:function(){qe()}},"\u4FDD\u5B58")),l.a.createElement(D.a,{onClick:function(){document.body.scrollIntoView(),Ft()}},"\u8FD4\u56DE"),l.a.createElement(D.a,{loading:Ct,onClick:function(){return ut()},type:"primary"},"\u63D0\u4EA4"))},Gr=function(){var be;return l.a.createElement(l.a.Fragment,null,l.a.createElement(D.a,{onClick:Ft},"\u8FD4\u56DE"),Zt>0&&l.a.createElement(D.a,{onClick:function(){return er(Zt)},type:"primary"},"\u4E0A\u4E00\u4EFD"),Zt<(Ze==null||((be=Ze.exam)===null||be===void 0)?void 0:be.total_num)-1&&l.a.createElement(D.a,{onClick:function(){return er(Zt+2)}},"\u4E0B\u4E00\u4EFD"))},Mr=function(be,Ke){if(Ke==="SINGLE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(it,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="MULTIPLE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(Be,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="JUDGMENT")return l.a.createElement(l.a.Fragment,null,l.a.createElement(ze,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="COMPLETION")return l.a.createElement(l.a.Fragment,null,l.a.createElement($e,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="SUBJECTIVE")return l.a.createElement(l.a.Fragment,null,l.a.createElement(Et,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="COMBINATION")return l.a.createElement(l.a.Fragment,null,l.a.createElement(gt,{ref:Xt,editData:be,isEdit:!0}),l.a.createElement(I.a,null));if(Ke==="PROGRAM"){var wt;v.d.push("/problems/".concat(be==null||((wt=be.program_attr)===null||wt===void 0)?void 0:wt.identifier,"/edit?type=exercises&express_id=").concat(Ie.categoryId,"&question_id=").concat(be==null?void 0:be.id,"&score=").concat(be==null?void 0:be.score,"&callback_url=").concat(location.pathname,"&select=").concat(Zt,"&exercise=true"))}},Ir=function(){var nt=Object(A.a)(y.a.mark(function be(Ke,wt){var mt,vt,It,gr,cr,hr,Lr,Sr,Wr,or;return y.a.wrap(function(pr){for(;;)switch(pr.prev=pr.next){case 0:return pr.next=2,(mt=Xt.current)===null||mt===void 0?void 0:mt.onSave();case 2:if(vt=pr.sent,vt){pr.next=5;break}return pr.abrupt("return");case 5:return It={question_score:wt.score,analysis:vt.analysis},(Ke==="SINGLE"||Ke==="MULTIPLE"||Ke==="JUDGMENT")&&(cr=[],hr=[],It.question_type=Ke==="JUDGMENT"?2:1,It.question_title=vt==null?void 0:vt.name,vt==null||((gr=vt.choices)===null||gr===void 0)||gr.forEach(function(Ht,br){cr.push(Ht.choice_text),Ht!=null&&Ht.is_answer&&hr.push(br+1)}),It.question_choices=cr,It.standard_answers=hr),Ke==="COMPLETION"&&(It.is_ordered=vt.is_ordered,It.question_title=vt==null?void 0:vt.name,It.question_type=3,Sr=[],vt==null||((Lr=vt.standard_answers)===null||Lr===void 0)||Lr.forEach(function(Ht,br){Sr.push({choice_id:Ht.position,answer_text:Ht.answer_text})}),It.standard_answers=Sr),Ke==="SUBJECTIVE"&&(It.question_title=vt==null?void 0:vt.name,It.question_type=3,It.standard_answers=vt==null?void 0:vt.answer_texts),Ke==="COMBINATION"&&(It.question_title=vt==null?void 0:vt.name,It.question_type=7,It.sub_questions=vt==null||((Wr=vt.sub_item_banks)===null||Wr===void 0)?void 0:Wr.map(function(Ht,br){return{id:Ht.id,question_title:Ht.name,question_type:1,question_choices:Ht.choices.map(function(lr){return lr.choice_text}),standard_answers:[Ht.choices.findIndex(function(lr){return lr.is_answer})+1],analysis:Ht.analysis}}),delete It.analysis),pr.next=12,Object(S.a)("/api/exercise_questions/".concat(wt.id,".json"),{method:"put",body:It});case 12:or=pr.sent,(or==null?void 0:or.status)===0&&(T.b.success("\u7F16\u8F91\u6210\u529F"),er(Zt+1)),St(null);case 15:case"end":return pr.stop()}},be)}));return function(Ke,wt){return nt.apply(this,arguments)}}(),cn=function(){for(var be=[],Ke=0;Ke<(Ze==null||((wt=Ze.exam)===null||wt===void 0)?void 0:wt.total_num);Ke++){var wt;be.push({})}return be},Sn=Ze==null||((se=Ze.questionList)===null||se===void 0)?void 0:se.reduce(function(nt,be){return nt+be.questions_score},0),wr=Lt&&(Ze==null||((ue=Ze.exam)===null||ue===void 0)?void 0:ue.exercise_status)!==1;return l.a.createElement("section",{className:f.a.wrap},l.a.createElement("div",{id:"id_left_preview",className:f.a.left,onMouseEnter:function(be){var Ke=document.getElementById("id_left_preview");Ke.style.overflowY="auto"},onMouseLeave:function(be){var Ke=document.getElementById("id_left_preview");Ke.style.overflowY="hidden"}},l.a.createElement("div",{className:f.a.title},l.a.createElement("div",null,l.a.createElement("b",null),l.a.createElement("span",null,"\u7B54\u9898\u5361"))),l.a.createElement("div",{className:f.a.total},l.a.createElement("div",null,l.a.createElement("img",{src:H.a}),l.a.createElement("span",null,"\u9898\u6570(\u9053)"),l.a.createElement("aside",null,Ze==null?void 0:Ze.all_questions_count)),l.a.createElement("div",{className:"mr30 ml30"},l.a.createElement("img",{src:Q.a}),l.a.createElement("span",null,"\u603B\u5206(\u5206)"),l.a.createElement("aside",null,Sn)),l.a.createElement("div",null,l.a.createElement("img",{src:s.a}),l.a.createElement("span",null,"\u65F6\u957F(\u5206)"),l.a.createElement("aside",null,Ze==null||((Se=Ze.exam)===null||Se===void 0)?void 0:Se.time))),Ze==null||((ke=Ze.questionList)===null||ke===void 0)?void 0:ke.map(function(nt,be){var Ke;return l.a.createElement("div",{className:f.a.list,key:be},l.a.createElement("div",{className:f.a.name},l.a.createElement("b",null),l.a.createElement("span",null,nt.name)),l.a.createElement("aside",null,l.a.createElement("div",null,"\u5171",l.a.createElement("span",{className:f.a.b},nt.questions_count),"\u9898"," ",l.a.createElement("span",{className:f.a.l},"|"),"\u5171",l.a.createElement("span",{className:f.a.r},nt.questions_score),"\u5206"),l.a.createElement("div",{className:f.a.answerSheet},nt==null||((Ke=nt.questions)===null||Ke===void 0)?void 0:Ke.map(function(wt,mt){return l.a.createElement("div",{onClick:function(){var It="Anchor_".concat(wt.id),gr=document.getElementById(It);gr&&setTimeout(function(){return gr.scrollIntoView({block:"center",behavior:"smooth"})})},key:wt.id,className:f.a.tag},mt+1)}))))})),l.a.createElement("div",{className:f.a.right},l.a.createElement("div",{className:f.a.examName,id:"examName"},l.a.createElement("div",{className:f.a.name},l.a.createElement(X.a,{title:Ze==null||((Je=Ze.exam)===null||Je===void 0)?void 0:Je.name,getPopupContainer:function(be){return be.parentNode}},l.a.createElement("span",{className:f.a.t},Ze==null||((Qe=Ze.exam)===null||Qe===void 0)?void 0:Qe.name))),Lt?l.a.createElement($.a,{showTotal:function(be){return l.a.createElement("span",{style:{color:"#656F87",fontSize:14}},"\u5171\u8BA1",l.a.createElement("span",{className:"c-light-primary"},be),"\u4EFD\u8BD5\u5377")},total:Ze==null||((bt=Ze.exam)===null||bt===void 0)?void 0:bt.total_num,pageSize:1,current:Zt+1,showSizeChanger:!1,onChange:er,showQuickJumper:!0,hideOnSinglePage:!1}):l.a.createElement(D.a,{onClick:Pt,type:"primary"},"\u968F\u673A\u66F4\u6362")),l.a.createElement("div",{className:f.a.topWarp},Ze==null||((Dt=Ze.questionList)===null||Dt===void 0)?void 0:Dt.map(function(nt,be){var Ke,wt;return l.a.createElement(l.a.Fragment,{key:be},l.a.createElement("div",{className:f.a.head,style:be===0?{border:0,marginTop:-16}:{}},l.a.createElement("div",{className:f.a.name},l.a.createElement("b",null),l.a.createElement("span",null,nt.name)),l.a.createElement("div",{className:f.a.so},"\u5171",l.a.createElement("span",{className:f.a.b},nt.questions_count," "),"\u9898"," ",nt.type==="COMBINATION"&&"\uFF08\u5305\u542B".concat(nt==null||((Ke=nt.questions)===null||Ke===void 0)?void 0:Ke.map(function(mt){var vt;return mt==null||((vt=mt.sub_item_banks)===null||vt===void 0)?void 0:vt.length}).reduce(function(mt,vt){return mt+vt}),"\u5C0F\u9898\uFF09"),l.a.createElement("span",{className:f.a.l},"|"),"\u5171",l.a.createElement("span",{className:f.a.r},nt.questions_score),"\u5206"),!Lt&&l.a.createElement("div",{className:f.a.btn},l.a.createElement(D.a,{onClick:function(){Ne(nt)},type:"primary",ghost:!0,className:"mr20"},"\u8BBE\u7F6E\u5F97\u5206"),l.a.createElement(D.a,{onClick:function(){return Ue(nt)},type:"primary",ghost:!0},"\u968F\u673A\u66F4\u6362"))),nt==null||((wt=nt.questions)===null||wt===void 0)?void 0:wt.map(function(mt,vt){return Mt===mt.id?l.a.createElement("div",{id:"Anchor_".concat(mt.id),className:f.a.content,style:{padding:0,marginTop:10},key:mt.id},l.a.createElement("div",{style:{float:"right",marginTop:-6}},l.a.createElement(D.a,{onClick:function(){return St(null)},className:"mr20",type:"primary",ghost:!0},"\u53D6\u6D88"),l.a.createElement(D.a,{onClick:function(){return Ir(nt==null?void 0:nt.type,mt)},type:"primary"},"\u4FDD\u5B58")),Mr(mt,nt.type)):l.a.createElement("div",{id:"Anchor_".concat(mt.id),className:f.a.content,key:mt.id},l.a.createElement("div",{className:f.a.titleWrap},l.a.createElement(a.a,{style:{paddingRight:10},className:f.a.titleHtml,value:vt+1+"\u3001"+"".concat((mt==null?void 0:mt.item_type)==="combination"?"\uFF08\u9898\u5E72\uFF09":"")+mt.name}),Lt&&l.a.createElement(D.a,{disabled:wr,onClick:function(){if(Mt){T.b.warn("\u5148\u4FDD\u5B58\u6216\u53D6\u6D88\u5F53\u524D\u6B63\u5728\u7F16\u8F91\u7684\u8BD5\u9898");return}St(mt.id)},type:"primary",className:"mr20",style:{marginLeft:"auto"},ghost:!0},"\u7F16\u8F91"),l.a.createElement(D.a,{disabled:wr,onClick:function(){return Tt(mt.id,nt.type,vt,nt)},type:"primary",ghost:!0},"\u6362\u4E00\u9898")),(nt.type==="SINGLE"||nt.type==="JUDGMENT"||nt.type==="MULTIPLE")&&u(mt),nt.type==="COMPLETION"&&g(mt),nt.type==="SUBJECTIVE"&&P(mt),nt.type==="PROGRAM"&&J(mt),nt.type==="COMBINATION"&&j(mt,vt),l.a.createElement("div",null))}))})),l.a.createElement("div",{className:f.a.btnsElse,id:"preview_btns_else"},Lt?Gr():fr()),l.a.createElement("div",{className:f.a.btnsWrap,id:"preview_btns"},l.a.createElement("div",{className:f.a.btns},Lt?Gr():fr()))),l.a.createElement(de,{visible:Tr,onRandomExchange:Object(A.a)(y.a.mark(function nt(){var be;return y.a.wrap(function(wt){for(;;)switch(wt.prev=wt.next){case 0:return be=Rt.current,wt.next=3,ft({single_question_id:be.id,seleted_item_bank_ids:be.ids},{type:be.type,index:be.index});case 3:ir(!1);case 4:case"end":return wt.stop()}},nt)})),selectFromProblemSet:function(){var be=Rt.current,Ke="".concat(location.pathname).concat(location.search);Ke.includes("exercise")&&v.d.push("/paperlibrary/exchangequestion?type=exercise&qid=".concat(be.id,"&qtype=").concat(be.type,"&exerciseid=").concat(Ie.categoryId,"&from=").concat(Ke))},onCancel:function(){ir(!1)}}))},ee=ht.a=pe},ulZh:function(At,ht,re){typeof window!="undefined"&&function($,R){At.exports=R()}(this,function(){return function(ae){var $={};function R(X){if($[X])return $[X].exports;var N=$[X]={i:X,l:!1,exports:{}};return ae[X].call(N.exports,N,N.exports,R),N.l=!0,N.exports}return R.m=ae,R.c=$,R.d=function(X,N,I){R.o(X,N)||Object.defineProperty(X,N,{enumerable:!0,get:I})},R.r=function(X){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(X,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(X,"__esModule",{value:!0})},R.t=function(X,N){if(N&1&&(X=R(X)),N&8)return X;if(N&4&&typeof X=="object"&&X&&X.__esModule)return X;var I=Object.create(null);if(R.r(I),Object.defineProperty(I,"default",{enumerable:!0,value:X}),N&2&&typeof X!="string")for(var z in X)R.d(I,z,function(B){return X[B]}.bind(null,z));return I},R.n=function(X){var N=X&&X.__esModule?function(){return X.default}:function(){return X};return R.d(N,"a",N),N},R.o=function(X,N){return Object.prototype.hasOwnProperty.call(X,N)},R.p="/dist/",R(R.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ae,$,R){"use strict";var X=Object.prototype.hasOwnProperty,N="~";function I(){}Object.create&&(I.prototype=Object.create(null),new I().__proto__||(N=!1));function z(E,L,k){this.fn=E,this.context=L,this.once=k||!1}function B(E,L,k,T,A){if(typeof k!="function")throw new TypeError("The listener must be a function");var C=new z(k,T||E,A),h=N?N+L:L;return E._events[h]?E._events[h].fn?E._events[h]=[E._events[h],C]:E._events[h].push(C):(E._events[h]=C,E._eventsCount++),E}function O(E,L){--E._eventsCount===0?E._events=new I:delete E._events[L]}function D(){this._events=new I,this._eventsCount=0}D.prototype.eventNames=function(){var L=[],k,T;if(this._eventsCount===0)return L;for(T in k=this._events)X.call(k,T)&&L.push(N?T.slice(1):T);return Object.getOwnPropertySymbols?L.concat(Object.getOwnPropertySymbols(k)):L},D.prototype.listeners=function(L){var k=N?N+L:L,T=this._events[k];if(!T)return[];if(T.fn)return[T.fn];for(var A=0,C=T.length,h=new Array(C);A<C;A++)h[A]=T[A].fn;return h},D.prototype.listenerCount=function(L){var k=N?N+L:L,T=this._events[k];return T?T.fn?1:T.length:0},D.prototype.emit=function(L,k,T,A,C,h){var o=N?N+L:L;if(!this._events[o])return!1;var c=this._events[o],d=arguments.length,_,y;if(c.fn){c.once&&this.removeListener(L,c.fn,void 0,!0);switch(d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,k),!0;case 3:return c.fn.call(c.context,k,T),!0;case 4:return c.fn.call(c.context,k,T,A),!0;case 5:return c.fn.call(c.context,k,T,A,C),!0;case 6:return c.fn.call(c.context,k,T,A,C,h),!0}for(y=1,_=new Array(d-1);y<d;y++)_[y-1]=arguments[y];c.fn.apply(c.context,_)}else{var m=c.length,l;for(y=0;y<m;y++){c[y].once&&this.removeListener(L,c[y].fn,void 0,!0);switch(d){case 1:c[y].fn.call(c[y].context);break;case 2:c[y].fn.call(c[y].context,k);break;case 3:c[y].fn.call(c[y].context,k,T);break;case 4:c[y].fn.call(c[y].context,k,T,A);break;default:if(!_)for(l=1,_=new Array(d-1);l<d;l++)_[l-1]=arguments[l];c[y].fn.apply(c[y].context,_)}}}return!0},D.prototype.on=function(L,k,T){return B(this,L,k,T,!1)},D.prototype.once=function(L,k,T){return B(this,L,k,T,!0)},D.prototype.removeListener=function(L,k,T,A){var C=N?N+L:L;if(!this._events[C])return this;if(!k)return O(this,C),this;var h=this._events[C];if(h.fn)h.fn===k&&(!A||h.once)&&(!T||h.context===T)&&O(this,C);else{for(var o=0,c=[],d=h.length;o<d;o++)(h[o].fn!==k||A&&!h[o].once||T&&h[o].context!==T)&&c.push(h[o]);c.length?this._events[C]=c.length===1?c[0]:c:O(this,C)}return this},D.prototype.removeAllListeners=function(L){var k;return L?(k=N?N+L:L,this._events[k]&&O(this,k)):(this._events=new I,this._eventsCount=0),this},D.prototype.off=D.prototype.removeListener,D.prototype.addListener=D.prototype.on,D.prefixed=N,D.EventEmitter=D,ae.exports=D},"./node_modules/url-toolkit/src/url-toolkit.js":function(ae,$,R){(function(X){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,I=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,B=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(D,E,L){if(L=L||{},D=D.trim(),E=E.trim(),!E){if(!L.alwaysNormalize)return D;var k=O.parseURL(D);if(!k)throw new Error("Error trying to parse base URL.");return k.path=O.normalizePath(k.path),O.buildURLFromParts(k)}var T=O.parseURL(E);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return L.alwaysNormalize?(T.path=O.normalizePath(T.path),O.buildURLFromParts(T)):E;var A=O.parseURL(D);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var C=I.exec(A.path);A.netLoc=C[1],A.path=C[2]}A.netLoc&&!A.path&&(A.path="/");var h={scheme:A.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(h.netLoc=A.netLoc,T.path[0]!=="/"))if(!T.path)h.path=A.path,T.params||(h.params=A.params,T.query||(h.query=A.query));else{var o=A.path,c=o.substring(0,o.lastIndexOf("/")+1)+T.path;h.path=O.normalizePath(c)}return h.path===null&&(h.path=L.alwaysNormalize?O.normalizePath(T.path):T.path),O.buildURLFromParts(h)},parseURL:function(D){var E=N.exec(D);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(D){for(D=D.split("").reverse().join("").replace(z,"");D.length!==(D=D.replace(B,"")).length;);return D.split("").reverse().join("")},buildURLFromParts:function(D){return D.scheme+D.netLoc+D.path+D.params+D.query+D.fragment}};ae.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(ae,$,R){function X(L){var k={};function T(C){if(k[C])return k[C].exports;var h=k[C]={i:C,l:!1,exports:{}};return L[C].call(h.exports,h,h.exports,T),h.l=!0,h.exports}T.m=L,T.c=k,T.i=function(C){return C},T.d=function(C,h,o){T.o(C,h)||Object.defineProperty(C,h,{configurable:!1,enumerable:!0,get:o})},T.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},T.n=function(C){var h=C&&C.__esModule?function(){return C.default}:function(){return C};return T.d(h,"a",h),h},T.o=function(C,h){return Object.prototype.hasOwnProperty.call(C,h)},T.p="/",T.oe=function(C){throw console.error(C),C};var A=T(T.s=ENTRY_MODULE);return A.default||A}var N="[\\.|\\-|\\+|\\w|/|@]+",I="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function z(L){return(L+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function B(L){return!isNaN(1*L)}function O(L,k,T){var A={};A[T]=[];var C=k.toString(),h=C.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return A;for(var o=h[1],c=new RegExp("(\\\\n|\\W)"+z(o)+I,"g"),d;d=c.exec(C);){if(d[3]==="dll-reference")continue;A[T].push(d[3])}for(c=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+I,"g");d=c.exec(C);)L[d[2]]||(A[T].push(d[1]),L[d[2]]=R(d[1]).m),A[d[2]]=A[d[2]]||[],A[d[2]].push(d[4]);for(var _=Object.keys(A),y=0;y<_.length;y++)for(var m=0;m<A[_[y]].length;m++)B(A[_[y]][m])&&(A[_[y]][m]=1*A[_[y]][m]);return A}function D(L){var k=Object.keys(L);return k.reduce(function(T,A){return T||L[A].length>0},!1)}function E(L,k){for(var T={main:[k]},A={main:[]},C={main:{}};D(T);)for(var h=Object.keys(T),o=0;o<h.length;o++){var c=h[o],d=T[c],_=d.pop();if(C[c]=C[c]||{},C[c][_]||!L[c][_])continue;C[c][_]=!0,A[c]=A[c]||[],A[c].push(_);for(var y=O(L,L[c][_],c),m=Object.keys(y),l=0;l<m.length;l++)T[m[l]]=T[m[l]]||[],T[m[l]]=T[m[l]].concat(y[m[l]])}return A}ae.exports=function(L,k){k=k||{};var T={main:R.m},A=k.all?{main:Object.keys(T.main)}:E(T,L),C="";Object.keys(A).filter(function(_){return _!=="main"}).forEach(function(_){for(var y=0;A[_][y];)y++;A[_].push(y),T[_][y]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+_+" = ("+X.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+A[_].map(function(m){return""+JSON.stringify(m)+": "+T[_][m].toString()}).join(",")+`});
|
|
`}),C=C+"new (("+X.toString().replace("ENTRY_MODULE",JSON.stringify(L))+")({"+A.main.map(function(_){return""+JSON.stringify(_)+": "+T.main[_].toString()}).join(",")+"}))(self);";var h=new window.Blob([C],{type:"text/javascript"});if(k.bare)return h;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,c=o.createObjectURL(h),d=new window.Worker(c);return d.objectURL=c,d}},"./src/config.ts":function(ae,$,R){"use strict";R.r($),R.d($,"hlsDefaultConfig",function(){return l}),R.d($,"mergeConfig",function(){return f}),R.d($,"enableStreamingMode",function(){return p});var X=R("./src/controller/abr-controller.ts"),N=R("./src/controller/audio-stream-controller.ts"),I=R("./src/controller/audio-track-controller.ts"),z=R("./src/controller/subtitle-stream-controller.ts"),B=R("./src/controller/subtitle-track-controller.ts"),O=R("./src/controller/buffer-controller.ts"),D=R("./src/controller/timeline-controller.ts"),E=R("./src/controller/cap-level-controller.ts"),L=R("./src/controller/fps-controller.ts"),k=R("./src/controller/eme-controller.ts"),T=R("./src/controller/cmcd-controller.ts"),A=R("./src/utils/xhr-loader.ts"),C=R("./src/utils/fetch-loader.ts"),h=R("./src/utils/cues.ts"),o=R("./src/utils/mediakeys-helper.ts"),c=R("./src/utils/logger.ts");function d(){return d=Object.assign||function(s){for(var a=1;a<arguments.length;a++){var b=arguments[a];for(var v in b)Object.prototype.hasOwnProperty.call(b,v)&&(s[v]=b[v])}return s},d.apply(this,arguments)}function _(s,a){var b=Object.keys(s);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(s);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(s,S).enumerable})),b.push.apply(b,v)}return b}function y(s){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?_(Object(b),!0).forEach(function(v){m(s,v,b[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(b)):_(Object(b)).forEach(function(v){Object.defineProperty(s,v,Object.getOwnPropertyDescriptor(b,v))})}return s}function m(s,a,b){return a in s?Object.defineProperty(s,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):s[a]=b,s}var l=y(y({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:A.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:X.default,bufferController:O.default,capLevelController:E.default,fpsController:L.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},x()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:B.default,timelineController:D.TimelineController,audioStreamController:N.default,audioTrackController:I.default,emeController:k.default,cmcdController:T.default});function x(){return{cueHandler:h.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function f(s,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return d({},s,a)}function p(s){var a=s.loader;if(a!==C.default&&a!==A.default)c.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var b=Object(C.fetchSupported)();b&&(s.loader=C.default,s.progressive=!0,s.enableSoftwareAES=!0,c.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/polyfills/number.ts"),N=R("./src/utils/ewma-bandwidth-estimator.ts"),I=R("./src/events.ts"),z=R("./src/utils/buffer-helper.ts"),B=R("./src/errors.ts"),O=R("./src/types/loader.ts"),D=R("./src/utils/logger.ts");function E(T,A){for(var C=0;C<A.length;C++){var h=A[C];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function L(T,A,C){return A&&E(T.prototype,A),C&&E(T,C),T}var k=function(){function T(C){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=C;var h=C.config;this.bwEstimator=new N.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var A=T.prototype;return A.registerListeners=function(){var h=this.hls;h.on(I.Events.FRAG_LOADING,this.onFragLoading,this),h.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(I.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var h=this.hls;h.off(I.Events.FRAG_LOADING,this.onFragLoading,this),h.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(I.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},A.onFragLoading=function(h,o){var c=o.frag;if(c.type===O.PlaylistLevelType.MAIN&&!this.timer){var d;this.fragCurrent=c,this.partCurrent=(d=o.part)!=null?d:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(h,o){var c=this.hls.config;o.details.live?this.bwEstimator.update(c.abrEwmaSlowLive,c.abrEwmaFastLive):this.bwEstimator.update(c.abrEwmaSlowVoD,c.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var h=this.fragCurrent,o=this.partCurrent,c=this.hls,d=c.autoLevelEnabled,_=c.config,y=c.media;if(!h||!y)return;var m=o?o.stats:h.stats,l=o?o.duration:h.duration;if(m.aborted){D.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!d||y.paused||!y.playbackRate||!y.readyState)return;var x=performance.now()-m.loading.start,f=Math.abs(y.playbackRate);if(x<=500*l/f)return;var p=c.levels,s=c.minAutoLevel,a=p[h.level],b=m.total||Math.max(m.loaded,Math.round(l*a.maxBitrate/8)),v=Math.max(1,m.bwEstimate?m.bwEstimate/8:m.loaded*1e3/x),S=(b-m.loaded)/v,M=y.currentTime,H=(z.BufferHelper.bufferInfo(y,M,_.maxBufferHole).end-M)/f;if(H>=2*l/f||S<=H)return;var V=Number.POSITIVE_INFINITY,Q;for(Q=h.level-1;Q>s;Q--){var G=p[Q].maxBitrate;if(V=l*G/(8*.8*v),V<H)break}if(V>=S)return;var W=this.bwEstimator.getEstimate();D.logger.warn("Fragment "+h.sn+(o?" part "+o.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Q+`
|
|
Current BW estimate: `+(Object(X.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+S.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+V.toFixed(3)+` s
|
|
Time to underbuffer: `+H.toFixed(3)+" s"),c.nextLoadLevel=Q,this.bwEstimator.sample(x,m.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),c.trigger(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:m})},A.onFragLoaded=function(h,o){var c=o.frag,d=o.part;if(c.type===O.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(c.sn)){var _=d?d.stats:c.stats,y=d?d.duration:c.duration;if(this.clearTimer(),this.lastLoadedFragLevel=c.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[c.level],l=(m.loaded?m.loaded.bytes:0)+_.loaded,x=(m.loaded?m.loaded.duration:0)+y;m.loaded={bytes:l,duration:x},m.realBitrate=Math.round(8*l/x)}if(c.bitrateTest){var f={stats:_,frag:c,part:d,id:c.type};this.onFragBuffered(I.Events.FRAG_BUFFERED,f),c.bitrateTest=!1}}},A.onFragBuffered=function(h,o){var c=o.frag,d=o.part,_=d?d.stats:c.stats;if(_.aborted)return;if(c.type!==O.PlaylistLevelType.MAIN||c.sn==="initSegment")return;var y=_.parsing.end-_.loading.start;this.bwEstimator.sample(y,_.loaded),_.bwEstimate=this.bwEstimator.getEstimate(),c.bitrateTest?this.bitrateTestDelay=y/1e3:this.bitrateTestDelay=0},A.onError=function(h,o){switch(o.details){case B.ErrorDetails.FRAG_LOAD_ERROR:case B.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,c=this.hls,d=c.maxAutoLevel,_=c.config,y=c.minAutoLevel,m=c.media,l=o?o.duration:h?h.duration:0,x=m?m.currentTime:0,f=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():_.abrEwmaDefaultEstimate,s=(z.BufferHelper.bufferInfo(m,x,_.maxBufferHole).end-x)/f,a=this.findBestLevel(p,y,d,s,_.abrBandWidthFactor,_.abrBandWidthUpFactor);if(a>=0)return a;D.logger.trace((s?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=l?Math.min(l,_.maxStarvationDelay):_.maxStarvationDelay,v=_.abrBandWidthFactor,S=_.abrBandWidthUpFactor;if(!s){var M=this.bitrateTestDelay;if(M){var H=l?Math.min(l,_.maxLoadingDelay):_.maxLoadingDelay;b=H-M,D.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),v=S=1}}return a=this.findBestLevel(p,y,d,s+b,v,S),Math.max(a,0)},A.findBestLevel=function(h,o,c,d,_,y){for(var m,l=this.fragCurrent,x=this.partCurrent,f=this.lastLoadedFragLevel,p=this.hls.levels,s=p[f],a=!!(s!=null&&(m=s.details)!==null&&m!==void 0&&m.live),b=s==null?void 0:s.codecSet,v=x?x.duration:l?l.duration:0,S=c;S>=o;S--){var M=p[S];if(!M||b&&M.codecSet!==b)continue;var H=M.details,V=(x?H==null?void 0:H.partTarget:H==null?void 0:H.averagetargetduration)||v,Q=void 0;S<=f?Q=_*h:Q=y*h;var G=p[S].maxBitrate,W=G*V/Q;if(D.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(Q)+"/"+G+"/"+V+"/"+d+"/"+W),Q>G&&(!W||a&&!this.bitrateTestDelay||W<d))return S}return-1},L(T,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&(!o||!o.canEstimate()))return h;var c=this.getNextABRAutoLevel();return h!==-1&&(c=Math.min(h,c)),c},set:function(h){this._nextAutoLevel=h}}]),T}();$.default=k},"./src/controller/audio-stream-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/polyfills/number.ts"),N=R("./src/controller/base-stream-controller.ts"),I=R("./src/events.ts"),z=R("./src/utils/buffer-helper.ts"),B=R("./src/controller/fragment-tracker.ts"),O=R("./src/types/level.ts"),D=R("./src/types/loader.ts"),E=R("./src/loader/fragment.ts"),L=R("./src/demux/chunk-cache.ts"),k=R("./src/demux/transmuxer-interface.ts"),T=R("./src/types/transmuxer.ts"),A=R("./src/controller/fragment-finders.ts"),C=R("./src/utils/discontinuities.ts"),h=R("./src/errors.ts"),o=R("./src/utils/logger.ts");function c(){return c=Object.assign||function(l){for(var x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(l[p]=f[p])}return l},c.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(p,s){return p.__proto__=s,p},_(l,x)}var y=100,m=function(l){d(x,l);function x(p,s){var a;return a=l.call(this,p,s,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var f=x.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var s=this.hls;s.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),s.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),s.on(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(I.Events.ERROR,this.onError,this),s.on(I.Events.BUFFER_RESET,this.onBufferReset,this),s.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),s.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),s.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f._unregisterListeners=function(){var s=this.hls;s.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(I.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),s.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),s.off(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(I.Events.ERROR,this.onError,this),s.off(I.Events.BUFFER_RESET,this.onBufferReset,this),s.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),s.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),s.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},f.onInitPtsFound=function(s,a){var b=a.frag,v=a.id,S=a.initPTS;if(v==="main"){var M=b.cc;this.initPTS[b.cc]=S,this.log("InitPTS for cc: "+M+" found from main: "+S),this.videoTrackCC=M,this.state===N.State.WAITING_INIT_PTS&&this.tick()}},f.startLoad=function(s){if(!this.levels){this.startPosition=s,this.state=N.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(y),this.fragLoadError=0,a>0&&s===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=N.State.IDLE):(this.loadedmetadata=!1,this.state=N.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=s,this.tick()},f.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_TRACK:{var s,a=this.levels,b=this.trackId,v=a==null||((s=a[b])===null||s===void 0)?void 0:s.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=N.State.WAITING_INIT_PTS}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var S,M=performance.now(),H=this.retryDate;(!H||M>=H||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=N.State.IDLE);break}case N.State.WAITING_INIT_PTS:{var V=this.waitingData;if(V){var Q=V.frag,G=V.part,W=V.cache,q=V.complete;if(this.initPTS[Q.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.FRAG_LOADING;var oe=W.flush(),fe={frag:Q,part:G,payload:oe,networkDetails:null};this._handleFragmentLoadProgress(fe),q&&l.prototype._handleFragmentLoadComplete.call(this,fe)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+Q.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ve=this.getLoadPosition(),De=z.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),Ee=Object(A.fragmentWithinToleranceTest)(De.end,this.config.maxFragLookUpTolerance,Q);Ee<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+De.end+" is needed"),this.clearWaitingFragment())}}else this.state=N.State.IDLE}}this.onTickEnd()},f.clearWaitingFragment=function(){var s=this.waitingData;s&&(this.fragmentTracker.removeFragment(s.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.State.IDLE)},f.onTickEnd=function(){var s=this.media;if(!s||!s.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:s,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=s.currentTime},f.doTickIdle=function(){var s,a,b=this.hls,v=this.levels,S=this.media,M=this.trackId,H=b.config;if(!v||!v[M])return;if(!S&&(this.startFragRequested||!H.startFragPrefetch))return;var V=v[M],Q=V.details;if(!Q||Q.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(Q)){this.state=N.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,E.ElementaryStreamTypes.AUDIO,D.PlaylistLevelType.AUDIO));var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,D.PlaylistLevelType.AUDIO);if(G===null)return;var W=G.len,q=this.getMaxBufferLength(),oe=this.audioSwitch;if(W>=q&&!oe)return;if(!oe&&this._streamEnded(G,Q)){b.trigger(I.Events.BUFFER_EOS,{type:"audio"}),this.state=N.State.ENDED;return}var fe=Q.fragments,ve=fe[0].start,De=G.end;if(oe){var Ee=this.getLoadPosition();De=Ee,Q.PTSKnown&&Ee<ve&&((G.end>ve||G.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),S.currentTime=ve+.05))}var _e=this.getNextFragment(De,Q);if(!_e){this.bufferFlushed=!0;return}((s=_e.decryptdata)===null||s===void 0?void 0:s.keyFormat)==="identity"&&!((a=_e.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(_e,Q):this.loadFragment(_e,Q,De)},f.getMaxBufferLength=function(){var s=l.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,D.PlaylistLevelType.MAIN);return a===null?s:Math.max(s,a.len)},f.onMediaDetaching=function(){this.videoBuffer=null,l.prototype.onMediaDetaching.call(this)},f.onAudioTracksUpdated=function(s,a){var b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(v){return new O.Level(v)})},f.onAudioTrackSwitching=function(s,a){var b=!!a.url;this.trackId=a.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(y):this.resetTransmuxer(),b?(this.audioSwitch=!0,this.state=N.State.IDLE):this.state=N.State.STOPPED,this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},f.onLevelLoaded=function(s,a){this.mainDetails=a.details},f.onAudioTrackLoaded=function(s,a){var b,v=this.levels,S=a.details,M=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+S.startSN+","+S.endSN+"],duration:"+S.totalduration);var H=v[M],V=0;if(S.live||(b=H.details)!==null&&b!==void 0&&b.live){var Q=this.mainDetails;if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed||!Q)return;!H.details&&S.hasProgramDateTime&&Q.hasProgramDateTime?(Object(C.alignMediaPlaylistByPDT)(S,Q),V=S.fragments[0].start):V=this.alignPlaylists(S,H.details)}H.details=S,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!S.live)&&this.setStartPosition(H.details,V),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(S)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(s){var a,b=s.frag,v=s.part,S=s.payload,M=this.config,H=this.trackId,V=this.levels;if(!V){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+b.sn+" of level "+b.level+" will not be buffered");return}var Q=V[H];console.assert(Q,"Audio track is defined on fragment load progress");var G=Q.details;console.assert(G,"Audio track details are defined on fragment load progress");var W=M.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new k.default(this.hls,D.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var oe=this.initPTS[b.cc],fe=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(oe!==void 0){var ve=!1,De=v?v.index:-1,Ee=De!==-1,_e=new T.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,S.byteLength,De,Ee);q.push(S,fe,W,"",b,v,G.totalduration,ve,_e,oe)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+G.startSN+" ,"+G.endSN+"],track "+H);var Te=this.waitingData=this.waitingData||{frag:b,part:v,cache:new L.default,complete:!1},Ce=Te.cache;Ce.push(new Uint8Array(S)),this.waitingVideoCC=this.videoTrackCC,this.state=N.State.WAITING_INIT_PTS}},f._handleFragmentLoadComplete=function(s){if(this.waitingData){this.waitingData.complete=!0;return}l.prototype._handleFragmentLoadComplete.call(this,s)},f.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},f.onBufferCreated=function(s,a){var b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},f.onFragBuffered=function(s,a){var b=a.frag,v=a.part;if(b.type!==D.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(v?" p: "+v.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,v)},f.onError=function(s,a){switch(a.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.AUDIO,a);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==N.State.ERROR&&this.state!==N.State.STOPPED&&(this.state=a.fatal?N.State.ERROR:N.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var b=!0,v=this.getFwdBufferInfo(this.mediaBuffer,D.PlaylistLevelType.AUDIO);v&&v.len>.5&&(b=!this.reduceMaxBufferLength(v.len)),b&&(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}},f.onBufferFlushed=function(s,a){var b=a.type;b===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},f._handleTransmuxComplete=function(s){var a,b="audio",v=this.hls,S=s.remuxResult,M=s.chunkMeta,H=this.getCurrentContext(M);if(!H){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 V=H.frag,Q=H.part,G=S.audio,W=S.text,q=S.id3,oe=S.initSegment;if(this.fragContextChanged(V))return;if(this.state=N.State.PARSING,this.audioSwitch&&G&&this.completeAudioSwitch(),oe!=null&&oe.tracks&&(this._bufferInitSegment(oe.tracks,V,M),v.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:V,id:b,tracks:oe.tracks})),G){var fe=G.startPTS,ve=G.endPTS,De=G.startDTS,Ee=G.endDTS;Q&&(Q.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:fe,endPTS:ve,startDTS:De,endDTS:Ee}),V.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,fe,ve,De,Ee),this.bufferFragmentData(G,V,Q,M)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var _e=c({frag:V,id:b},q);v.trigger(I.Events.FRAG_PARSING_METADATA,_e)}if(W){var Te=c({frag:V,id:b},W);v.trigger(I.Events.FRAG_PARSING_USERDATA,Te)}},f._bufferInitSegment=function(s,a,b){if(this.state!==N.State.PARSING)return;s.video&&delete s.video;var v=s.audio;if(!v)return;v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,s);var S=v.initSegment;if(S!=null&&S.byteLength){var M={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:S};this.hls.trigger(I.Events.BUFFER_APPENDING,M)}this.tick()},f.loadFragment=function(s,a,b){var v=this.fragmentTracker.getState(s);this.fragCurrent=s,(this.audioSwitch||v===B.FragmentState.NOT_LOADED||v===B.FragmentState.PARTIAL)&&(s.sn==="initSegment"?this._loadInitSegment(s):a.live&&!Object(X.isFiniteNumber)(this.initPTS[s.cc])?(this.log("Waiting for video PTS in continuity counter "+s.cc+" of live stream before loading audio fragment "+s.sn+" of level "+this.trackId),this.state=N.State.WAITING_INIT_PTS):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,s,a,b)))},f.completeAudioSwitch=function(){var s=this.hls,a=this.media,b=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),l.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,s.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:b})},x}(N.default);$.default=m},"./src/controller/audio-track-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/controller/base-playlist-controller.ts"),z=R("./src/types/loader.ts");function B(k,T){for(var A=0;A<T.length;A++){var C=T[A];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(k,C.key,C)}}function O(k,T,A){return T&&B(k.prototype,T),A&&B(k,A),k}function D(k,T){k.prototype=Object.create(T.prototype),k.prototype.constructor=k,E(k,T)}function E(k,T){return E=Object.setPrototypeOf||function(C,h){return C.__proto__=h,C},E(k,T)}var L=function(k){D(T,k);function T(C){var h;return h=k.call(this,C,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var A=T.prototype;return A.registerListeners=function(){var h=this.hls;h.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(X.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var h=this.hls;h.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off(X.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(X.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,k.prototype.destroy.call(this)},A.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},A.onManifestParsed=function(h,o){this.tracks=o.audioTracks||[]},A.onAudioTrackLoaded=function(h,o){var c=o.id,d=o.details,_=this.tracksInGroup[c];if(!_){this.warn("Invalid audio track id "+c);return}var y=_.details;_.details=o.details,this.log("audioTrack "+c+" loaded ["+d.startSN+"-"+d.endSN+"]"),c===this.trackId&&(this.retryCount=0,this.playlistLoaded(c,o,y))},A.onLevelLoading=function(h,o){this.switchLevel(o.level)},A.onLevelSwitching=function(h,o){this.switchLevel(o.level)},A.switchLevel=function(h){var o=this.hls.levels[h];if(!(o!=null&&o.audioGroupIds))return;var c=o.audioGroupIds[o.urlId];if(this.groupId!==c){this.groupId=c;var d=this.tracks.filter(function(y){return!c||y.groupId===c});this.selectDefaultTrack&&!d.some(function(y){return y.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var _={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+c+'" group-id'),this.hls.trigger(X.Events.AUDIO_TRACKS_UPDATED,_),this.selectInitialTrack()}},A.onError=function(h,o){if(k.prototype.onError.call(this,h,o),o.fatal||!o.context)return;o.context.type===z.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},A.setAudioTrack=function(h){var o=this.tracksInGroup;if(h<0||h>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var c=o[this.trackId];this.log("Now switching to audio-track index "+h);var d=o[h],_=d.id,y=d.groupId,m=y===void 0?"":y,l=d.name,x=d.type,f=d.url;if(this.trackId=h,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:_,groupId:m,name:l,type:x,url:f}),d.details&&!d.details.live)return;var p=this.switchParams(d.url,c==null?void 0:c.details);this.loadPlaylist(p)},A.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,c=this.findTrackId(o)||this.findTrackId();c!==-1?this.setAudioTrack(c):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(h){for(var o=this.tracksInGroup,c=0;c<o.length;c++){var d=o[c];if((!this.selectDefaultTrack||d.default)&&(!h||h===d.name))return d.id}return-1},A.loadPlaylist=function(h){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var c=o.id,d=o.groupId,_=o.url;if(h)try{_=h.addDirectives(_)}catch(y){this.warn("Could not construct new URL with HLS Delivery Directives: "+y)}this.log("loading audio-track playlist for id: "+c),this.clearTimer(),this.hls.trigger(X.Events.AUDIO_TRACK_LOADING,{url:_,id:c,groupId:d,deliveryDirectives:h||null})}},O(T,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),T}(I.default);$.default=L},"./src/controller/base-playlist-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return O});var X=R("./src/polyfills/number.ts"),N=R("./src/types/level.ts"),I=R("./src/controller/level-helper.ts"),z=R("./src/utils/logger.ts"),B=R("./src/errors.ts"),O=function(){function D(L,k){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=z.logger.log.bind(z.logger,k+":"),this.warn=z.logger.warn.bind(z.logger,k+":"),this.hls=L}var E=D.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(k,T){T.fatal&&T.type===B.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},E.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},E.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},E.stopLoad=function(){this.canLoad=!1,this.clearTimer()},E.switchParams=function(k,T){var A=T==null?void 0:T.renditionReports;if(A)for(var C=0;C<A.length;C++){var h=A[C],o=""+h.URI;if(o===k.substr(-o.length)){var c=parseInt(h["LAST-MSN"]),d=parseInt(h["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(X.isFiniteNumber)(c))return new N.HlsUrlParameters(c,Object(X.isFiniteNumber)(d)?d:void 0,N.HlsSkip.No)}}},E.loadPlaylist=function(k){},E.shouldLoadTrack=function(k){return this.canLoad&&k&&!!k.url&&(!k.details||k.details.live)},E.playlistLoaded=function(k,T,A){var C=this,h=T.details,o=T.stats,c=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-c,h.live||A!=null&&A.live){if(h.reloaded(A),A&&this.log("live playlist "+k+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),A&&h.fragments.length>0&&Object(I.mergeDetails)(A,h),!this.canLoad||!h.live)return;var d,_=void 0,y=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var m=this.hls.config.lowLatencyMode,l=h.lastPartSn,x=h.endSN,f=h.lastPartIndex,p=f!==-1,s=l===x,a=m?0:f;p?(_=s?x+1:l,y=s?a:f+1):_=x+1;var b=h.age,v=b+h.ageHeader,S=Math.min(v-h.partTarget,h.targetduration*1.5);if(S>0){if(A&&S>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+S+" with playlist age: "+h.age),S=0;else{var M=Math.floor(S/h.targetduration);if(_+=M,y!==void 0){var H=Math.round(S%h.targetduration/h.partTarget);y+=H}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+S+" skip sn "+M+" to part "+y)}h.tuneInGoal=S}if(d=this.getDeliveryDirectives(h,T.deliveryDirectives,_,y),m||!s){this.loadPlaylist(d);return}}else d=this.getDeliveryDirectives(h,T.deliveryDirectives,_,y);var V=Object(I.computeReloadInterval)(h,o);_!==void 0&&h.canBlockReload&&(V-=h.partTarget||1),this.log("reload live playlist "+k+" in "+Math.round(V)+" ms"),this.timer=self.setTimeout(function(){return C.loadPlaylist(d)},V)}else this.clearTimer()},E.getDeliveryDirectives=function(k,T,A,C){var h=Object(N.getSkipValue)(k,A);return T!=null&&T.skip&&k.deltaUpdateFailed&&(A=T.msn,C=T.part,h=N.HlsSkip.No),new N.HlsUrlParameters(A,C,h)},E.retryLoadingOrFail=function(k){var T=this,A=this.hls.config,C=this.retryCount<A.levelLoadingMaxRetry;if(C){var h;if(this.retryCount++,k.details.indexOf("LoadTimeOut")>-1&&(h=k.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+k.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+k.details+'"')}}else this.warn('cannot recover from error "'+k.details+'"'),this.clearTimer(),k.fatal=!0;return C},D}()},"./src/controller/base-stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"State",function(){return x}),R.d($,"default",function(){return f});var X=R("./src/polyfills/number.ts"),N=R("./src/task-loop.ts"),I=R("./src/controller/fragment-tracker.ts"),z=R("./src/utils/buffer-helper.ts"),B=R("./src/utils/logger.ts"),O=R("./src/events.ts"),D=R("./src/errors.ts"),E=R("./src/types/transmuxer.ts"),L=R("./src/utils/mp4-tools.ts"),k=R("./src/utils/discontinuities.ts"),T=R("./src/controller/fragment-finders.ts"),A=R("./src/controller/level-helper.ts"),C=R("./src/loader/fragment-loader.ts"),h=R("./src/crypt/decrypter.ts"),o=R("./src/utils/time-ranges.ts"),c=R("./src/types/loader.ts");function d(p,s){for(var a=0;a<s.length;a++){var b=s[a];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function _(p,s,a){return s&&d(p.prototype,s),a&&d(p,a),p}function y(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function m(p,s){p.prototype=Object.create(s.prototype),p.prototype.constructor=p,l(p,s)}function l(p,s){return l=Object.setPrototypeOf||function(b,v){return b.__proto__=v,b},l(p,s)}var x={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},f=function(p){m(s,p);function s(b,v,S){var M;return M=p.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=B.logger.log.bind(B.logger,S+":"),M.warn=B.logger.warn.bind(B.logger,S+":"),M.hls=b,M.fragmentLoader=new C.default(b.config),M.fragmentTracker=v,M.config=b.config,M.decrypter=new h.default(b,b.config),b.on(O.Events.KEY_LOADED,M.onKeyLoaded,y(M)),M}var a=s.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=x.STOPPED},a._streamEnded=function(v,S){var M=this.fragCurrent,H=this.fragmentTracker;if(!S.live&&M&&M.sn===S.endSN&&!v.nextStart){var V=H.getState(M);return V===I.FragmentState.PARTIAL||V===I.FragmentState.OK}return!1},a.onMediaAttached=function(v,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 H=this.config;this.levels&&H.autoStartLoad&&this.state===x.STOPPED&&this.startLoad(H.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,M=this.media,H=this.mediaBuffer,V=this.state,Q=M?M.currentTime:0,G=z.BufferHelper.bufferInfo(H||M,Q,v.maxBufferHole);if(this.log("media seeking to "+(Object(X.isFiniteNumber)(Q)?Q.toFixed(3):Q)+", state: "+V),V===x.ENDED)this.resetLoadingState();else if(S&&!G.len){var W=v.maxFragLookUpTolerance,q=S.start-W,oe=S.start+S.duration+W,fe=Q>oe;(Q<q||fe)&&(fe&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}M&&(this.lastCurrentTime=Q),!this.loadedmetadata&&!G.len&&(this.nextLoadPosition=this.startPosition=Q),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,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)},a.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=x.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,p.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=x.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(O.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,S,M){this._loadFragForPlayback(v,S,M)},a._loadFragForPlayback=function(v,S,M){var H=this,V=function(G){if(H.fragContextChanged(v)){H.warn("Fragment "+v.sn+(G.part?" p: "+G.part.index:"")+" of level "+v.level+" was dropped during download."),H.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,H._handleFragmentLoadProgress(G)};this._doFragLoad(v,S,M,V).then(function(Q){if(!Q)return;H.fragLoadError=0;var G=H.state;if(H.fragContextChanged(v)){(G===x.FRAG_LOADING||G===x.BACKTRACKING||!H.fragCurrent&&G===x.PARSING)&&(H.fragmentTracker.removeFragment(v),H.state=x.IDLE);return}if("payload"in Q&&(H.log("Loaded fragment "+v.sn+" of level "+v.level),H.hls.trigger(O.Events.FRAG_LOADED,Q),H.state===x.BACKTRACKING)){H.fragmentTracker.backtrack(v,Q),H.resetFragmentLoading(v);return}H._handleFragmentLoadComplete(Q)}).catch(function(Q){H.warn(Q),H.resetFragmentLoading(v)})},a.flushMainBuffer=function(v,S,M){if(M===void 0&&(M=null),!(v-S))return;var H={startOffset:v,endOffset:S,type:M};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,H)},a._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(M){if(!M||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return M}).then(function(M){var H=S.hls,V=M.payload,Q=v.decryptdata;if(V&&V.byteLength>0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var G=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(V),Q.key.buffer,Q.iv.buffer).then(function(W){var q=self.performance.now();return H.trigger(O.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:G,tdecrypt:q}}),M.payload=W,M})}return M}).then(function(M){var H=S.fragCurrent,V=S.hls,Q=S.levels;if(!Q)throw new Error("init load aborted, missing levels");var G=Q[v.level].details;console.assert(G,"Level details are defined when init segment is loaded");var W=v.stats;S.state=x.IDLE,S.fragLoadError=0,v.data=new Uint8Array(M.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),M.frag===H&&V.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:H,part:null,id:v.type}),S.tick()}).catch(function(M){S.warn(M),S.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},a.fragBufferedComplete=function(v,S){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+o.default.toString(z.BufferHelper.getBuffered(M))),this.state=x.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!S)return;var M=v.frag,H=v.part,V=v.partsLoaded,Q=!V||V.length===0||V.some(function(W){return!W}),G=new E.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,H?H.index:-1,!Q);S.flush(G)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,S,M,H){var V=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(v.start,M||0),this.config.lowLatencyMode&&S){var Q=S.partList;if(Q&&H){M>v.end&&S.fragmentHint&&(v=S.fragmentHint);var G=this.getNextPart(Q,v,M);if(G>-1){var W=Q[G];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+G+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=x.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:Q[G],targetBufferTime:M}),this.doFragPartsLoad(v,Q,G,H).catch(function(q){return V.handleFragLoadError(q)})}else if(!v.url||this.loadedEndOfParts(Q,M))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(M.toFixed(3))),Object(X.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=x.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:M}),this.fragmentLoader.load(v,H).catch(function(q){return V.handleFragLoadError(q)})},a.doFragPartsLoad=function(v,S,M,H){var V=this;return new Promise(function(Q,G){var W=[],q=function oe(fe){var ve=S[fe];V.fragmentLoader.loadPart(v,ve,H).then(function(De){W[ve.index]=De;var Ee=De.part;V.hls.trigger(O.Events.FRAG_LOADED,De);var _e=S[fe+1];if(_e&&_e.fragment===v)oe(fe+1);else return Q({frag:v,part:Ee,partsLoaded:W})}).catch(G)};q(M)})},a.handleFragLoadError=function(v){var S=v.data;return S&&S.details===D.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},a._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==x.PARSING){this.fragCurrent||(this.state=x.IDLE);return}var M=S.frag,H=S.part,V=S.level,Q=self.performance.now();M.stats.parsing.end=Q,H&&(H.stats.parsing.end=Q),this.updateLevelTiming(M,H,V,v.partial)},a.getCurrentContext=function(v){var S=this.levels,M=v.level,H=v.sn,V=v.part;if(!S||!S[M])return this.warn("Levels object was unset while buffering fragment "+H+" of level "+M+". The current chunk will not be buffered."),null;var Q=S[M],G=V>-1?Object(A.getPartWith)(Q,H,V):null,W=G?G.fragment:Object(A.getFragmentWithSN)(Q,H,this.fragCurrent);return W?{frag:W,part:G,level:Q}:null},a.bufferFragmentData=function(v,S,M,H){if(!v||this.state!==x.PARSING)return;var V=v.data1,Q=v.data2,G=V;if(V&&Q&&(G=Object(L.appendUint8Array)(V,Q)),!G||!G.length)return;var W={type:v.type,frag:S,part:M,chunkMeta:H,parent:S.type,data:G};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!M&&this.flushBufferGap(S)},a.flushBufferGap=function(v){var S=this.media;if(!S)return;if(!z.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var M=S.currentTime,H=z.BufferHelper.bufferInfo(S,M,0),V=v.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,V*.25),G=Math.max(Math.min(v.start-Q,H.end-Q),M+Q);v.start-G>Q&&this.flushMainBuffer(G,v.start)},a.getFwdBufferInfo=function(v,S){var M=this.config,H=this.getLoadPosition();if(!Object(X.isFiniteNumber)(H))return null;var V=z.BufferHelper.bufferInfo(v,H,M.maxBufferHole);if(V.len===0&&V.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(H,S);if(Q&&V.nextStart<Q.end)return z.BufferHelper.bufferInfo(v,H,Math.max(V.nextStart,M.maxBufferHole))}return V},a.getMaxBufferLength=function(v){var S=this.config,M;return v?M=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):M=S.maxBufferLength,Math.min(M,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var S=this.config,M=v||S.maxBufferLength;return S.maxMaxBufferLength>=M?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,S){var M,H,V=S.fragments,Q=V.length;if(!Q)return null;var G=this.config,W=V[0].start,q;if(S.live){var oe=G.initialLiveManifestSize;if(Q<oe)return this.warn("Not enough fragments to start playback (have: "+Q+", need: "+oe+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(S,V),this.startPosition=q?this.hls.liveSyncPosition||q.start:v)}else v<=W&&(q=V[0]);if(!q){var fe=G.lowLatencyMode?S.partEnd:S.fragmentEnd;q=this.getFragmentAtPosition(v,fe,S)}return(M=q)!==null&&M!==void 0&&M.initSegment&&!((H=q)!==null&&H!==void 0&&H.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},a.getNextPart=function(v,S,M){for(var H=-1,V=!1,Q=!0,G=0,W=v.length;G<W;G++){var q=v[G];if(Q=Q&&!q.independent,H>-1&&M<q.start)break;var oe=q.loaded;!oe&&(V||q.independent||Q)&&q.fragment===S&&(H=G),V=oe}return H},a.loadedEndOfParts=function(v,S){var M=v[v.length-1];return M&&S>M.start&&M.loaded},a.getInitialLiveFragment=function(v,S){var M=this.fragPrevious,H=null;if(M){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),H=Object(T.findFragmentByPDT)(S,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!H){var V=M.sn+1;if(V>=v.startSN&&V<=v.endSN){var Q=S[V-v.startSN];M.cc===Q.cc&&(H=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+H.sn))}H||(H=Object(T.findFragWithCC)(S,M.cc),H&&this.log("Live playlist, switching playlist, load frag with same CC: "+H.sn))}}else{var G=this.hls.liveSyncPosition;G!==null&&(H=this.getFragmentAtPosition(G,this.bitrateTest?v.fragmentEnd:v.edge,v))}return H},a.getFragmentAtPosition=function(v,S,M){var H=this.config,V=this.fragPrevious,Q=M.fragments,G=M.endSN,W=M.fragmentHint,q=H.maxFragLookUpTolerance,oe=!!(H.lowLatencyMode&&M.partList&&W);oe&&W&&!this.bitrateTest&&(Q=Q.concat(W),G=W.sn);var fe;if(v<S){var ve=v>S-q?0:q;fe=Object(T.findFragmentByPTS)(V,Q,v,ve)}else fe=Q[Q.length-1];if(fe){var De=fe.sn-M.startSN,Ee=V&&fe.level===V.level,_e=Q[De+1],Te=this.fragmentTracker.getState(fe);if(Te===I.FragmentState.BACKTRACKED){fe=null;for(var Ce=De;Q[Ce]&&this.fragmentTracker.getState(Q[Ce])===I.FragmentState.BACKTRACKED;)V?fe=Q[Ce--]:fe=Q[--Ce];fe||(fe=_e)}else V&&fe.sn===V.sn&&!oe&&(Ee&&(fe.sn<G&&this.fragmentTracker.getState(_e)!==I.FragmentState.OK?(this.log("SN "+fe.sn+" just loaded, load next one: "+_e.sn),fe=_e):fe=null))}return fe},a.synchronizeToLiveEdge=function(v){var S=this.config,M=this.media;if(!M)return;var H=this.hls.liveSyncPosition,V=M.currentTime,Q=v.fragments[0].start,G=v.edge,W=V>=Q-S.maxFragLookUpTolerance&&V<=G;if(H!==null&&M.duration>H&&(V<H||!W)){var q=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&M.readyState<4||V<G-q)&&(this.loadedmetadata||(this.nextLoadPosition=H),M.readyState&&(this.warn("Playback: "+V.toFixed(3)+" is located too far from the end of live sliding playlist: "+G+", reset currentTime to : "+H.toFixed(3)),M.currentTime=H))}},a.alignPlaylists=function(v,S){var M=this.levels,H=this.levelLastLoaded,V=this.fragPrevious,Q=H!==null?M[H]:null,G=v.fragments.length;if(!G)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,q=!S,oe=v.alignedSliding&&Object(X.isFiniteNumber)(W);if(q||!oe&&!W){Object(k.alignStream)(V,Q,v);var fe=v.fragments[0].start;return this.log("Live playlist sliding: "+fe.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(V?V.sn:"na")+" fragments: "+G),fe}return W},a.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},a.setStartPosition=function(v,S){var M=this.startPosition;if(M<S&&(M=-1),M===-1||this.lastCurrentTime===-1){var H=v.startTimeOffset;Object(X.isFiniteNumber)(H)?(M=S+H,H<0&&(M+=v.totalduration),M=Math.min(Math.max(S,M),S+v.totalduration),this.log("Start time offset "+H+" found in playlist, adjust startPosition to "+M),this.startPosition=M):v.live?M=this.hls.liveSyncPosition||S:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},a.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=x.IDLE)},a.onFragmentOrKeyLoadError=function(v,S){if(S.fatal)return;var M=S.frag;if(!M||M.type!==v)return;var H=this.fragCurrent;console.assert(H&&M.sn===H.sn&&M.level===H.level&&M.urlId===H.urlId,"Frag load error must match current frag to retry");var V=this.config;if(this.fragLoadError+1<=V.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(M.level))return;var Q=Math.min(Math.pow(2,this.fragLoadError)*V.fragLoadingRetryDelay,V.fragLoadingMaxRetryTimeout);this.warn("Fragment "+M.sn+" of "+v+" "+M.level+" failed to load, retrying in "+Q+"ms"),this.retryDate=self.performance.now()+Q,this.fragLoadError++,this.state=x.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===c.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=x.IDLE):(B.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=x.ERROR)},a.afterBufferFlushed=function(v,S,M){if(!v)return;var H=z.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,H,M),this.state===x.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=x.IDLE},a.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;if(S!=null&&S.live)return this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(v,S,M,H){var V=this,Q=M.details;console.assert(!!Q,"level.details must be defined");var G=Object.keys(v.elementaryStreams).reduce(function(W,q){var oe=v.elementaryStreams[q];if(oe){var fe=oe.endPTS-oe.startPTS;if(fe<=0)return V.warn("Could not parse fragment "+v.sn+" "+q+" duration reliably ("+fe+") resetting transmuxer to fallback to playlist timing"),V.resetTransmuxer(),W||!1;var ve=H?0:Object(A.updateFragPTSDTS)(Q,v,oe.startPTS,oe.endPTS,oe.startDTS,oe.endDTS);return V.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:Q,level:M,drift:ve,type:q,frag:v,start:oe.startPTS,end:oe.endPTS}),!0}return W},!1);G?(this.state=x.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:v,part:S})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},_(s,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),s}(N.default)},"./src/controller/buffer-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./src/polyfills/number.ts"),N=R("./src/events.ts"),I=R("./src/utils/logger.ts"),z=R("./src/errors.ts"),B=R("./src/utils/buffer-helper.ts"),O=R("./src/utils/mediasource-helper.ts"),D=R("./src/loader/fragment.ts"),E=R("./src/controller/buffer-operation-queue.ts"),L=Object(O.getMediaSource)(),k=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function A(h){var o=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var c=o.hls,d=o.media,_=o.mediaSource;I.logger.log("[buffer-controller]: Media source opened"),d&&(o.updateMediaElementDuration(),c.trigger(N.Events.MEDIA_ATTACHED,{media:d})),_&&_.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){I.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){I.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var C=A.prototype;return C.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},C.destroy=function(){this.unregisterListeners(),this.details=null},C.registerListeners=function(){var o=this.hls;o.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(N.Events.BUFFER_RESET,this.onBufferReset,this),o.on(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(N.Events.BUFFER_EOS,this.onBufferEos,this),o.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(N.Events.FRAG_PARSED,this.onFragParsed,this),o.on(N.Events.FRAG_CHANGED,this.onFragChanged,this)},C.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(N.Events.BUFFER_RESET,this.onBufferReset,this),o.off(N.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(N.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(N.Events.BUFFER_EOS,this.onBufferEos,this),o.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(N.Events.FRAG_PARSED,this.onFragParsed,this),o.off(N.Events.FRAG_CHANGED,this.onFragChanged,this)},C._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},C.onManifestParsed=function(o,c){var d=2;(c.audio&&!c.video||!c.altAudio)&&(d=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=d,this.details=null,I.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},C.onMediaAttaching=function(o,c){var d=this.media=c.media;if(d&&L){var _=this.mediaSource=new L;_.addEventListener("sourceopen",this._onMediaSourceOpen),_.addEventListener("sourceended",this._onMediaSourceEnded),_.addEventListener("sourceclose",this._onMediaSourceClose),d.src=self.URL.createObjectURL(_),this._objectUrl=d.src}},C.onMediaDetaching=function(){var o=this.media,c=this.mediaSource,d=this._objectUrl;if(c){if(I.logger.log("[buffer-controller]: media source detaching"),c.readyState==="open")try{c.endOfStream()}catch(_){I.logger.warn("[buffer-controller]: onMediaDetaching: "+_.message+" while calling endOfStream")}this.onBufferReset(),c.removeEventListener("sourceopen",this._onMediaSourceOpen),c.removeEventListener("sourceended",this._onMediaSourceEnded),c.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(d&&self.URL.revokeObjectURL(d),o.src===d?(o.removeAttribute("src"),o.load()):I.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(N.Events.MEDIA_DETACHED,void 0)},C.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(c){var d=o.sourceBuffer[c];try{d&&(o.removeBufferListeners(c),o.mediaSource&&o.mediaSource.removeSourceBuffer(d),o.sourceBuffer[c]=void 0)}catch(_){I.logger.warn("[buffer-controller]: Failed to reset the "+c+" buffer",_)}}),this._initSourceBuffer()},C.onBufferCodecs=function(o,c){var d=this,_=this.getSourceBufferTypes().length;if(Object.keys(c).forEach(function(y){if(_){var m=d.tracks[y];if(m&&typeof m.buffer.changeType=="function"){var l=c[y],x=l.codec,f=l.levelCodec,p=l.container,s=(m.levelCodec||m.codec).replace(k,"$1"),a=(f||x).replace(k,"$1");if(s!==a){var b=p+";codecs="+(f||x);d.appendChangeType(y,b)}}}else d.pendingTracks[y]=c[y]}),_)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},C.appendChangeType=function(o,c){var d=this,_=this.operationQueue,y={execute:function(){var l=d.sourceBuffer[o];l&&(I.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+c),l.changeType(c)),_.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(l){I.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",l)}};_.append(y,o)},C.onBufferAppending=function(o,c){var d=this,_=this.hls,y=this.operationQueue,m=this.tracks,l=c.data,x=c.type,f=c.frag,p=c.part,s=c.chunkMeta,a=s.buffering[x],b=self.performance.now();a.start=b;var v=f.stats.buffering,S=p?p.stats.buffering:null;v.start===0&&(v.start=b),S&&S.start===0&&(S.start=b);var M=m.audio,H=x==="audio"&&s.id===1&&(M==null?void 0:M.container)==="audio/mpeg",V={execute:function(){if(a.executeStart=self.performance.now(),H){var G=d.sourceBuffer[x];if(G){var W=f.start-G.timestampOffset;Math.abs(W)>=.1&&(I.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+W+") sn: "+f.sn+")"),G.timestampOffset=f.start)}}d.appendExecutor(l,x)},onStart:function(){},onComplete:function(){var G=self.performance.now();a.executeEnd=a.end=G,v.first===0&&(v.first=G),S&&S.first===0&&(S.first=G);var W=d.sourceBuffer,q={};for(var oe in W)q[oe]=B.BufferHelper.getBuffered(W[oe]);d.appendError=0,d.hls.trigger(N.Events.BUFFER_APPENDED,{type:x,frag:f,part:p,chunkMeta:s,parent:f.type,timeRanges:q})},onError:function(G){I.logger.error("[buffer-controller]: Error encountered while trying to append to the "+x+" SourceBuffer",G);var W={type:z.ErrorTypes.MEDIA_ERROR,parent:f.type,details:z.ErrorDetails.BUFFER_APPEND_ERROR,err:G,fatal:!1};G.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=z.ErrorDetails.BUFFER_FULL_ERROR:(d.appendError++,W.details=z.ErrorDetails.BUFFER_APPEND_ERROR,d.appendError>_.config.appendErrorMaxRetry&&(I.logger.error("[buffer-controller]: Failed "+_.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0)),_.trigger(N.Events.ERROR,W)}};y.append(V,x)},C.onBufferFlushing=function(o,c){var d=this,_=this.operationQueue,y=function(l){return{execute:d.removeExecutor.bind(d,l,c.startOffset,c.endOffset),onStart:function(){},onComplete:function(){d.hls.trigger(N.Events.BUFFER_FLUSHED,{type:l})},onError:function(f){I.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",f)}}};c.type?_.append(y(c.type),c.type):this.getSourceBufferTypes().forEach(function(m){_.append(y(m),m)})},C.onFragParsed=function(o,c){var d=this,_=c.frag,y=c.part,m=[],l=y?y.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 p=self.performance.now();_.stats.buffering.end=p,y&&(y.stats.buffering.end=p);var s=y?y.stats:_.stats;d.hls.trigger(N.Events.FRAG_BUFFERED,{frag:_,part:y,stats:s,id:_.type})};m.length===0&&I.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+_.type+" level: "+_.level+" sn: "+_.sn),this.blockBuffers(x,m)},C.onFragChanged=function(o,c){this.flushBackBuffer()},C.onBufferEos=function(o,c){var d=this,_=this.getSourceBufferTypes().reduce(function(y,m){var l=d.sourceBuffer[m];return(!c.type||c.type===m)&&(l&&!l.ended&&(l.ended=!0,I.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),y&&!!(!l||l.ended)},!0);_&&this.blockBuffers(function(){var y=d.mediaSource;if(!y||y.readyState!=="open")return;y.endOfStream()})},C.onLevelUpdated=function(o,c){var d=c.details;if(!d.fragments.length)return;this.details=d,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},C.flushBackBuffer=function(){var o=this.hls,c=this.details,d=this.media,_=this.sourceBuffer;if(!d||c===null)return;var y=this.getSourceBufferTypes();if(!y.length)return;var m=c.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(m)||m<0)return;var l=d.currentTime,x=c.levelTargetDuration,f=Math.max(m,x),p=Math.floor(l/x)*x-f;y.forEach(function(s){var a=_[s];if(a){var b=B.BufferHelper.getBuffered(a);b.length>0&&p>b.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),c.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:s}))}})},C.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,c=this.hls,d=this.media,_=this.mediaSource,y=o.fragments[0].start+o.totalduration,m=d.duration,l=Object(X.isFiniteNumber)(_.duration)?_.duration:0;o.live&&c.config.liveDurationInfinity?(I.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),_.duration=Infinity,this.updateSeekableRange(o)):(y>l&&y>m||!Object(X.isFiniteNumber)(m))&&(I.logger.log("[buffer-controller]: Updating Media Source duration to "+y.toFixed(3)),_.duration=y)},C.updateSeekableRange=function(o){var c=this.mediaSource,d=o.fragments,_=d.length;if(_&&o.live&&c!==null&&c!==void 0&&c.setLiveSeekableRange){var y=Math.max(0,d[0].start),m=Math.max(y,y+o.totalduration);c.setLiveSeekableRange(y,m)}},C.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,c=this.operationQueue,d=this.pendingTracks,_=Object.keys(d).length;if(_&&!o||_===2){this.createSourceBuffers(d),this.pendingTracks={};var y=this.getSourceBufferTypes();if(y.length===0){this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}y.forEach(function(m){c.executeNext(m)})}},C.createSourceBuffers=function(o){var c=this.sourceBuffer,d=this.mediaSource;if(!d)throw Error("createSourceBuffers called when mediaSource was null");var _=0;for(var y in o)if(!c[y]){var m=o[y];if(!m)throw Error("source buffer exists for track "+y+", however track does not");var l=m.levelCodec||m.codec,x=m.container+";codecs="+l;I.logger.log("[buffer-controller]: creating sourceBuffer("+x+")");try{var f=c[y]=d.addSourceBuffer(x),p=y;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[y]={buffer:f,codec:l,container:m.container,levelCodec:m.levelCodec,id:m.id},_++}catch(s){I.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+s.message),this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:s,mimeType:x})}}_&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},C._onSBUpdateStart=function(o){var c=this.operationQueue,d=c.current(o);d.onStart()},C._onSBUpdateEnd=function(o){var c=this.operationQueue,d=c.current(o);d.onComplete(),c.shiftAndExecuteNext(o)},C._onSBUpdateError=function(o,c){I.logger.error("[buffer-controller]: "+o+" SourceBuffer error",c),this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var d=this.operationQueue.current(o);d&&d.onError(c)},C.removeExecutor=function(o,c,d){var _=this.media,y=this.mediaSource,m=this.operationQueue,l=this.sourceBuffer,x=l[o];if(!_||!y||!x){I.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),m.shiftAndExecuteNext(o);return}var f=Object(X.isFiniteNumber)(_.duration)?_.duration:Infinity,p=Object(X.isFiniteNumber)(y.duration)?y.duration:Infinity,s=Math.max(0,c),a=Math.min(d,f,p);a>s?(I.logger.log("[buffer-controller]: Removing ["+s+","+a+"] from the "+o+" SourceBuffer"),console.assert(!x.updating,o+" sourceBuffer must not be updating"),x.remove(s,a)):m.shiftAndExecuteNext(o)},C.appendExecutor=function(o,c){var d=this.operationQueue,_=this.sourceBuffer,y=_[c];if(!y){I.logger.warn("[buffer-controller]: Attempting to append to the "+c+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(c);return}y.ended=!1,console.assert(!y.updating,c+" sourceBuffer must not be updating"),y.appendBuffer(o)},C.blockBuffers=function(o,c){var d=this;if(c===void 0&&(c=this.getSourceBufferTypes()),!c.length){I.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var _=this.operationQueue,y=c.map(function(m){return _.appendBlocker(m)});Promise.all(y).then(function(){o(),c.forEach(function(m){var l=d.sourceBuffer[m];(!l||!l.updating)&&_.shiftAndExecuteNext(m)})})},C.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},C.addBufferListener=function(o,c,d){var _=this.sourceBuffer[o];if(!_)return;var y=d.bind(this,o);this.listeners[o].push({event:c,listener:y}),_.addEventListener(c,y)},C.removeBufferListeners=function(o){var c=this.sourceBuffer[o];if(!c)return;this.listeners[o].forEach(function(d){c.removeEventListener(d.event,d.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return N});var X=R("./src/utils/logger.ts"),N=function(){function I(B){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=B}var z=I.prototype;return z.append=function(O,D){var E=this.queues[D];E.push(O),E.length===1&&this.buffers[D]&&this.executeNext(D)},z.insertAbort=function(O,D){var E=this.queues[D];E.unshift(O),this.executeNext(D)},z.appendBlocker=function(O){var D,E=new Promise(function(k){D=k}),L={execute:D,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,O),E},z.executeNext=function(O){var D=this.buffers,E=this.queues,L=D[O],k=E[O];if(k.length){var T=k[0];try{T.execute()}catch(A){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(A),(!L||!L.updating)&&(k.shift(),this.executeNext(O))}}},z.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},z.current=function(O){return this.queues[O][0]},I}()},"./src/controller/cap-level-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts");function N(B,O){for(var D=0;D<O.length;D++){var E=O[D];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(B,E.key,E)}}function I(B,O,D){return O&&N(B.prototype,O),D&&N(B,D),B}var z=function(){function B(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 O=B.prototype;return O.setStreamController=function(E){this.streamController=E},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var E=this.hls;E.on(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var E=this.hls;E.off(X.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(X.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(E,L){B.isLevelAllowed(L.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(L.droppedLevel)},O.onMediaAttaching=function(E,L){this.media=L.media instanceof HTMLVideoElement?L.media:null},O.onManifestParsed=function(E,L){var k=this.hls;this.restrictedLevels=[],this.firstLevel=L.firstLevel,k.config.capLevelToPlayerSize&&L.video&&this.startCapping()},O.onBufferCodecs=function(E,L){var k=this.hls;k.config.capLevelToPlayerSize&&L.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var L=this.hls;L.autoLevelCapping=this.getMaxLevel(E.length-1),L.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=L.autoLevelCapping}}},O.getMaxLevel=function(E){var L=this,k=this.hls.levels;if(!k.length)return-1;var T=k.filter(function(A,C){return B.isLevelAllowed(C,L.restrictedLevels)&&C<=E});return this.clientRect=null,B.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},O.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()},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var E=this.media,L={width:0,height:0};if(E){var k=E.getBoundingClientRect();L.width=k.width,L.height=k.height,!L.width&&!L.height&&(L.width=k.right-k.left||E.width||0,L.height=k.bottom-k.top||E.height||0)}return this.clientRect=L,L},B.isLevelAllowed=function(E,L){return L===void 0&&(L=[]),L.indexOf(E)===-1},B.getMaxLevelByMediaSize=function(E,L,k){if(!E||!E.length)return-1;for(var T=function(c,d){return d?c.width!==d.width||c.height!==d.height:!0},A=E.length-1,C=0;C<E.length;C+=1){var h=E[C];if((h.width>=L||h.height>=k)&&T(h,E[C+1])){A=C;break}}return A},I(B,[{key:"mediaWidth",get:function(){return this.getDimensions().width*B.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*B.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var E=1;try{E=self.devicePixelRatio}catch(L){}return E}}]),B}();$.default=z},"./src/controller/cmcd-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./src/events.ts"),N=R("./src/types/cmcd.ts"),I=R("./src/utils/buffer-helper.ts"),z=R("./src/utils/logger.ts");function B(A,C){for(var h=0;h<C.length;h++){var o=C[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(A,o.key,o)}}function O(A,C,h){return C&&B(A.prototype,C),h&&B(A,h),A}function D(A,C){var h=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(h)return(h=h.call(A)).next.bind(h);if(Array.isArray(A)||(h=E(A))||C&&A&&typeof A.length=="number"){h&&(A=h);var o=0;return function(){return o>=A.length?{done:!0}:{done:!1,value:A[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function E(A,C){if(!A)return;if(typeof A=="string")return L(A,C);var h=Object.prototype.toString.call(A).slice(8,-1);if(h==="Object"&&A.constructor&&(h=A.constructor.name),h==="Map"||h==="Set")return Array.from(A);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return L(A,C)}function L(A,C){(C==null||C>A.length)&&(C=A.length);for(var h=0,o=new Array(C);h<C;h++)o[h]=A[h];return o}function k(){return k=Object.assign||function(A){for(var C=1;C<arguments.length;C++){var h=arguments[C];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(A[o]=h[o])}return A},k.apply(this,arguments)}var T=function(){function A(h){var o=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(_){try{o.apply(_,{ot:N.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(y){z.logger.warn("Could not generate manifest CMCD data.",y)}},this.applyFragmentData=function(_){try{var y=_.frag,m=o.hls.levels[y.level],l=o.getObjectType(y),x={d:y.duration*1e3,ot:l};(l===N.CMCDObjectType.VIDEO||l===N.CMCDObjectType.AUDIO||l==N.CMCDObjectType.MUXED)&&(x.br=m.bitrate/1e3,x.tb=o.getTopBandwidth(l),x.bl=o.getBufferLength(l)),o.apply(_,x)}catch(f){z.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=h;var c=this.config=h.config,d=c.cmcd;d!=null&&(c.pLoader=this.createPlaylistLoader(),c.fLoader=this.createFragmentLoader(),this.sid=d.sessionId||A.uuid(),this.cid=d.contentId,this.useHeaders=d.useHeaders===!0,this.registerListeners())}var C=A.prototype;return C.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(X.Events.BUFFER_CREATED,this.onBufferCreated,this)},C.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(X.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},C.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},C.onMediaAttached=function(o,c){this.media=c.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},C.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},C.onBufferCreated=function(o,c){var d,_;this.audioBuffer=(d=c.tracks.audio)===null||d===void 0?void 0:d.buffer,this.videoBuffer=(_=c.tracks.video)===null||_===void 0?void 0:_.buffer},C.createData=function(){var o;return{v:N.CMCDVersion,sf:N.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},C.apply=function(o,c){c===void 0&&(c={}),k(c,this.createData());var d=c.ot===N.CMCDObjectType.INIT||c.ot===N.CMCDObjectType.VIDEO||c.ot===N.CMCDObjectType.MUXED;if(this.starved&&d&&(c.bs=!0,c.su=!0,this.starved=!1),c.su==null&&(c.su=this.buffering),this.useHeaders){var _=A.toHeaders(c);if(!Object.keys(_).length)return;o.headers||(o.headers={}),k(o.headers,_)}else{var y=A.toQuery(c);if(!y)return;o.url=A.appendQueryToUri(o.url,y)}},C.getObjectType=function(o){var c=o.type;return c==="subtitle"?N.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?N.CMCDObjectType.INIT:c==="audio"?N.CMCDObjectType.AUDIO:c==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},C.getTopBandwidth=function(o){for(var c=0,d=o===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,_=D(d),y;!(y=_()).done;){var m=y.value;m.bitrate>c&&(c=m.bitrate)}return c>0?c:NaN},C.getBufferLength=function(o){var c=this.hls.media,d=o===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!d||!c)return NaN;var _=I.BufferHelper.bufferInfo(d,c.currentTime,this.config.maxBufferHole);return _.len*1e3},C.createPlaylistLoader=function(){var o=this.config.pLoader,c=this.applyPlaylistData,d=o||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var y=_.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,x,f){c(l),this.loader.load(l,x,f)},O(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},C.createFragmentLoader=function(){var o=this.config.fLoader,c=this.applyFragmentData,d=o||this.config.loader;return function(){function _(m){this.loader=void 0,this.loader=new d(m)}var y=_.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,x,f){c(l),this.loader.load(l,x,f)},O(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},A.uuid=function(){var o=URL.createObjectURL(new Blob),c=o.toString();return URL.revokeObjectURL(o),c.substr(c.lastIndexOf("/")+1)},A.serialize=function(o){for(var c=[],d=function(H){return!Number.isNaN(H)&&H!=null&&H!==""&&H!==!1},_=function(H){return Math.round(H)},y=function(H){return _(H/100)*100},m=function(H){return encodeURIComponent(H)},l={br:_,d:_,bl:y,dl:y,mtp:y,nor:m,rtp:y,tb:_},x=Object.keys(o||{}).sort(),f=D(x),p;!(p=f()).done;){var s=p.value,a=o[s];if(!d(a))continue;if(s==="v"&&a===1)continue;if(s=="pr"&&a===1)continue;var b=l[s];b&&(a=b(a));var v=typeof a,S=void 0;s==="ot"||s==="sf"||s==="st"?S=s+"="+a:v==="boolean"?S=s:v==="number"?S=s+"="+a:S=s+"="+JSON.stringify(a),c.push(S)}return c.join(",")},A.toHeaders=function(o){for(var c=Object.keys(o),d={},_=["Object","Request","Session","Status"],y=[{},{},{},{}],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=c;l<x.length;l++){var f=x[l],p=m[f]!=null?m[f]:1;y[p][f]=o[f]}for(var s=0;s<y.length;s++){var a=A.serialize(y[s]);a&&(d["CMCD-"+_[s]]=a)}return d},A.toQuery=function(o){return"CMCD="+encodeURIComponent(A.serialize(o))},A.appendQueryToUri=function(o,c){if(!c)return o;var d=o.includes("?")?"&":"?";return""+o+d+c},A}()},"./src/controller/eme-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/utils/logger.ts"),z=R("./src/utils/mediakeys-helper.ts");function B(T,A){for(var C=0;C<A.length;C++){var h=A[C];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function O(T,A,C){return A&&B(T.prototype,A),C&&B(T,C),T}var D=3,E=function(A,C,h){var o={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(c){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+c+'"',robustness:h.audioRobustness||""})}),C.forEach(function(c){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+c+'"',robustness:h.videoRobustness||""})}),[o]},L=function(A,C,h,o){switch(A){case z.KeySystems.WIDEVINE:return E(C,h,o);default:throw new Error("Unknown key-system: "+A)}},k=function(){function T(C){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=C,this._config=C.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var A=T.prototype;return A.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},A._registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A._unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(X.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A.getLicenseServerUrl=function(h){switch(h){case z.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},A._attemptKeySystemAccess=function(h,o,c){var d=this,_=L(h,o,c,this._drmSystemOptions);I.logger.log("Requesting encrypted media key-system access");var y=this.requestMediaKeySystemAccess(h,_);this.mediaKeysPromise=y.then(function(m){return d._onMediaKeySystemAccessObtained(h,m)}),y.catch(function(m){I.logger.error('Failed to obtain key-system "'+h+'" access:',m)})},A._onMediaKeySystemAccessObtained=function(h,o){var c=this;I.logger.log('Access for key-system "'+h+'" obtained');var d={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:h};this._mediaKeysList.push(d);var _=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(y){return d.mediaKeys=y,I.logger.log('Media-keys created for key-system "'+h+'"'),c._onMediaKeysCreated(),y});return _.catch(function(y){I.logger.error("Failed to create media-keys:",y)}),_},A._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),h._onNewMediaKeySession(o.mediaKeysSession))})},A._onNewMediaKeySession=function(h){var o=this;I.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(c){o._onKeySessionMessage(h,c.message)},!1)},A._onKeySessionMessage=function(h,o){I.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(c){I.logger.log("Received license data (length: "+(c&&c.byteLength)+"), updating key-session"),h.update(c)})},A.onMediaEncrypted=function(h){var o=this;if(I.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var c=function(_){if(!o._media)return;o._attemptSetMediaKeys(_),o._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(c).catch(c)},A._attemptSetMediaKeys=function(h){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){I.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}I.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(h,o){var c=this,d=this._mediaKeysList[0];if(!d){I.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(d.mediaKeysSessionInitialized){I.logger.warn("Key-Session already initialized but requested again");return}var _=d.mediaKeysSession;if(!_){I.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){I.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}I.logger.log('Generating key-session request for "'+h+'" init data type'),d.mediaKeysSessionInitialized=!0,_.generateRequest(h,o).then(function(){I.logger.debug("Key-session generation succeeded")}).catch(function(y){I.logger.error("Error generating key-session request:",y),c.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(h,o,c){var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,d,h,o,c);var _=this._licenseXhrSetup;if(_)try{_.call(this.hls,d,h),_=void 0}catch(y){I.logger.error(y)}try{d.readyState||d.open("POST",h,!0),_&&_.call(this.hls,d,h)}catch(y){throw new Error("issue setting up KeySystem license XHR "+y)}return d},A._onLicenseRequestReadyStageChange=function(h,o,c,d){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,I.logger.log("License request succeeded");var _=h.response,y=this._licenseResponseCallback;if(y)try{_=y.call(this.hls,h,o)}catch(l){I.logger.error(l)}d(_)}else{if(I.logger.error("License Request XHR failed ("+o+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>D){this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var m=D-this._requestLicenseFailureCount+1;I.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(c,d)}break}},A._generateLicenseRequestChallenge=function(h,o){switch(h.mediaKeySystemDomain){case z.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},A._requestLicense=function(h,o){I.logger.log("Requesting content license for key-system");var c=this._mediaKeysList[0];if(!c){I.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var d=this.getLicenseServerUrl(c.mediaKeySystemDomain),_=this._createLicenseXhr(d,h,o);I.logger.log("Sending license request to URL: "+d);var y=this._generateLicenseRequestChallenge(c,h);_.send(y)}catch(m){I.logger.error("Failure requesting DRM license: "+m),this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.KEY_SYSTEM_ERROR,details:N.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(h,o){if(!this._emeEnabled)return;var c=o.media;this._media=c,c.addEventListener("encrypted",this._onMediaEncrypted)},A.onMediaDetached=function(){var h=this._media,o=this._mediaKeysList;if(!h)return;h.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(c){if(c.mediaKeysSession)return c.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var c=o.levels.map(function(_){return _.audioCodec}).filter(function(_){return!!_}),d=o.levels.map(function(_){return _.videoCodec}).filter(function(_){return!!_});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,c,d)},O(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(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/utils/logger.ts"),I=function(){function z(O){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=O,this.registerListeners()}var B=z.prototype;return B.setStreamController=function(D){this.streamController=D},B.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},B.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},B.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},B.onMediaAttaching=function(D,E){var L=this.hls.config;if(L.capLevelOnFPSDrop){var k=E.media instanceof self.HTMLVideoElement?E.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),L.fpsDroppedMonitoringPeriod)}},B.checkFPS=function(D,E,L){var k=performance.now();if(E){if(this.lastTime){var T=k-this.lastTime,A=L-this.lastDroppedFrames,C=E-this.lastDecodedFrames,h=1e3*A/T,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:A,currentDecoded:C,totalDroppedFrames:L}),h>0&&A>o.config.fpsDroppedMonitoringThreshold*C){var c=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=c)&&(c=c-1,o.trigger(X.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:o.currentLevel}),o.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=k,this.lastDroppedFrames=L,this.lastDecodedFrames=E}},B.checkFPSInterval=function(){var D=this.media;if(D)if(this.isVideoPlaybackQualityAvailable){var E=D.getVideoPlaybackQuality();this.checkFPS(D,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(D,D.webkitDecodedFrameCount,D.webkitDroppedFrameCount)},z}();$.default=I},"./src/controller/fragment-finders.ts":function(ae,$,R){"use strict";R.r($),R.d($,"findFragmentByPDT",function(){return I}),R.d($,"findFragmentByPTS",function(){return z}),R.d($,"fragmentWithinToleranceTest",function(){return B}),R.d($,"pdtWithinToleranceTest",function(){return O}),R.d($,"findFragWithCC",function(){return D});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/binary-search.ts");function I(E,L,k){if(L===null||!Array.isArray(E)||!E.length||!Object(X.isFiniteNumber)(L))return null;var T=E[0].programDateTime;if(L<(T||0))return null;var A=E[E.length-1].endProgramDateTime;if(L>=(A||0))return null;k=k||0;for(var C=0;C<E.length;++C){var h=E[C];if(O(L,k,h))return h}return null}function z(E,L,k,T){k===void 0&&(k=0),T===void 0&&(T=0);var A=null;if(E?A=L[E.sn-L[0].sn+1]||null:k===0&&L[0].start===0&&(A=L[0]),A&&B(k,T,A)===0)return A;var C=N.default.search(L,B.bind(null,k,T));return C||A}function B(E,L,k){E===void 0&&(E=0),L===void 0&&(L=0);var T=Math.min(L,k.duration+(k.deltaPTS?k.deltaPTS:0));return k.start+k.duration-T<=E?1:k.start-T>E&&k.start?-1:0}function O(E,L,k){var T=Math.min(L,k.duration+(k.deltaPTS?k.deltaPTS:0))*1e3,A=k.endProgramDateTime||0;return A-T>E}function D(E,L){return N.default.search(E,function(k){return k.cc<L?1:k.cc>L?-1:0})}},"./src/controller/fragment-tracker.ts":function(ae,$,R){"use strict";R.r($),R.d($,"FragmentState",function(){return I}),R.d($,"FragmentTracker",function(){return z});var X=R("./src/events.ts"),N=R("./src/types/loader.ts"),I;(function(D){D.NOT_LOADED="NOT_LOADED",D.BACKTRACKED="BACKTRACKED",D.APPENDING="APPENDING",D.PARTIAL="PARTIAL",D.OK="OK"})(I||(I={}));var z=function(){function D(L){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=L,this._registerListeners()}var E=D.prototype;return E._registerListeners=function(){var k=this.hls;k.on(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E._unregisterListeners=function(){var k=this.hls;k.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),k.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),k.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(k,T){if(T===N.PlaylistLevelType.MAIN){var A=this.activeFragment,C=this.activeParts;if(!A)return null;if(C)for(var h=C.length;h--;){var o=C[h],c=o?o.end:A.appendedPTS;if(o.start<=k&&c!==void 0&&k<=c)return h>9&&(this.activeParts=C.slice(h-9)),o}else if(A.start<=k&&A.appendedPTS!==void 0&&k<=A.appendedPTS)return A}return this.getBufferedFrag(k,T)},E.getBufferedFrag=function(k,T){for(var A=this.fragments,C=Object.keys(A),h=C.length;h--;){var o=A[C[h]];if((o==null?void 0:o.body.type)===T&&o.buffered){var c=o.body;if(c.start<=k&&k<=c.end)return c}}return null},E.detectEvictedFragments=function(k,T,A){var C=this;Object.keys(this.fragments).forEach(function(h){var o=C.fragments[h];if(!o)return;if(!o.buffered){o.body.type===A&&C.removeFragment(o.body);return}var c=o.range[k];if(!c)return;c.time.some(function(d){var _=!C.isTimeBuffered(d.startPTS,d.endPTS,T);return _&&C.removeFragment(o.body),_})})},E.detectPartialFragments=function(k){var T=this,A=this.timeRanges,C=k.frag,h=k.part;if(!A||C.sn==="initSegment")return;var o=O(C),c=this.fragments[o];if(!c)return;Object.keys(A).forEach(function(d){var _=C.elementaryStreams[d];if(!_)return;var y=A[d],m=h!==null||_.partial===!0;c.range[d]=T.getBufferedTimes(C,h,m,y)}),c.backtrack=c.loaded=null,Object.keys(c.range).length?c.buffered=!0:this.removeFragment(c.body)},E.fragBuffered=function(k){var T=O(k),A=this.fragments[T];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},E.getBufferedTimes=function(k,T,A,C){for(var h={time:[],partial:A},o=T?T.start:k.start,c=T?T.end:k.end,d=k.minEndPTS||c,_=k.maxStartPTS||o,y=0;y<C.length;y++){var m=C.start(y)-this.bufferPadding,l=C.end(y)+this.bufferPadding;if(_>=m&&d<=l){h.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(c,C.end(y))});break}else if(o<l&&c>m)h.partial=!0,h.time.push({startPTS:Math.max(o,C.start(y)),endPTS:Math.min(c,C.end(y))});else if(c<=m)break}return h},E.getPartialFragment=function(k){var T=null,A,C,h,o=0,c=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(_){var y=d[_];if(!y)return;B(y)&&(C=y.body.start-c,h=y.body.end+c,k>=C&&k<=h&&(A=Math.min(k-C,h-k),o<=A&&(T=y.body,o=A)))}),T},E.getState=function(k){var T=O(k),A=this.fragments[T];return A?A.buffered?B(A)?I.PARTIAL:I.OK:A.backtrack?I.BACKTRACKED:I.APPENDING:I.NOT_LOADED},E.backtrack=function(k,T){var A=O(k),C=this.fragments[A];if(!C||C.backtrack)return null;var h=C.backtrack=T||C.loaded;return C.loaded=null,h},E.getBacktrackData=function(k){var T=O(k),A=this.fragments[T];if(A){var C,h=A.backtrack;if(h!=null&&(C=h.payload)!==null&&C!==void 0&&C.byteLength)return h;this.removeFragment(k)}return null},E.isTimeBuffered=function(k,T,A){for(var C,h,o=0;o<A.length;o++){if(C=A.start(o)-this.bufferPadding,h=A.end(o)+this.bufferPadding,k>=C&&T<=h)return!0;if(T<=C)return!1}return!1},E.onFragLoaded=function(k,T){var A=T.frag,C=T.part;if(A.sn==="initSegment"||A.bitrateTest||C)return;var h=O(A);this.fragments[h]={body:A,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}},E.onBufferAppended=function(k,T){var A=this,C=T.frag,h=T.part,o=T.timeRanges;if(C.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=C,h){var c=this.activeParts;c||(this.activeParts=c=[]),c.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(d){var _=o[d];if(A.detectEvictedFragments(d,_),!h)for(var y=0;y<_.length;y++)C.appendedPTS=Math.max(_.end(y),C.appendedPTS||0)})},E.onFragBuffered=function(k,T){this.detectPartialFragments(T)},E.hasFragment=function(k){var T=O(k);return!!this.fragments[T]},E.removeFragmentsInRange=function(k,T,A){var C=this;Object.keys(this.fragments).forEach(function(h){var o=C.fragments[h];if(!o)return;if(o.buffered){var c=o.body;c.type===A&&c.start<T&&c.end>k&&C.removeFragment(c)}})},E.removeFragment=function(k){var T=O(k);k.stats.loaded=0,k.clearElementaryStreamInfo(),delete this.fragments[T]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},D}();function B(D){var E,L;return D.buffered&&(((E=D.range.video)===null||E===void 0?void 0:E.partial)||((L=D.range.audio)===null||L===void 0?void 0:L.partial))}function O(D){return D.type+"_"+D.level+"_"+D.urlId+"_"+D.sn}},"./src/controller/gap-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"STALL_MINIMUM_DURATION_MS",function(){return B}),R.d($,"MAX_START_GAP_JUMP",function(){return O}),R.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return D}),R.d($,"SKIP_BUFFER_RANGE_START",function(){return E}),R.d($,"default",function(){return L});var X=R("./src/utils/buffer-helper.ts"),N=R("./src/errors.ts"),I=R("./src/events.ts"),z=R("./src/utils/logger.ts"),B=250,O=2,D=.1,E=.05,L=function(){function k(A,C,h,o){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=A,this.media=C,this.fragmentTracker=h,this.hls=o}var T=k.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(C){var h=this.config,o=this.media,c=this.stalled,d=o.currentTime,_=o.seeking,y=this.seeking&&!_,m=!this.seeking&&_;if(this.seeking=_,d!==C){if(this.moved=!0,c!==null){if(this.stallReported){var l=self.performance.now()-c;z.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(l)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((m||y)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!X.BufferHelper.getBuffered(o).length)return;var x=X.BufferHelper.bufferInfo(o,d,0),f=x.len>0,p=x.nextStart||0;if(!f&&!p)return;if(_){var s=x.len>O,a=!p||p-d>O&&!this.fragmentTracker.getPartialFragment(d);if(s||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,v=Math.max(p,x.start||0)-d,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=S==null||((b=S.details)===null||b===void 0)?void 0:b.live,H=M?S.details.targetduration*2:O;if(v>0&&v<=H){this._trySkipBufferHole(null);return}}var V=self.performance.now();if(c===null){this.stalled=V;return}var Q=V-c;!_&&Q>=B&&this._reportStall(x.len);var G=X.BufferHelper.bufferInfo(o,d,h.maxBufferHole);this._tryFixBufferStall(G,Q)},T._tryFixBufferStall=function(C,h){var o=this.config,c=this.fragmentTracker,d=this.media,_=d.currentTime,y=c.getPartialFragment(_);if(y){var m=this._trySkipBufferHole(y);if(m)return}C.len>o.maxBufferHole&&h>o.highBufferWatchdogPeriod*1e3&&(z.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(C){var h=this.hls,o=this.media,c=this.stallReported;c||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+C+")"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:C}))},T._trySkipBufferHole=function(C){for(var h=this.config,o=this.hls,c=this.media,d=c.currentTime,_=0,y=X.BufferHelper.getBuffered(c),m=0;m<y.length;m++){var l=y.start(m);if(d+h.maxBufferHole>=_&&d<l){var x=Math.max(l+E,c.currentTime+D);return z.logger.warn("skipping hole, adjusting currentTime from "+d+" to "+x),this.moved=!0,this.stalled=null,c.currentTime=x,C&&o.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+d+" to "+x,frag:C}),x}_=y.end(m)}return 0},T._tryNudgeBuffer=function(){var C=this.config,h=this.hls,o=this.media,c=o.currentTime,d=(this.nudgeRetry||0)+1;if(this.nudgeRetry=d,d<C.nudgeMaxRetry){var _=c+d*C.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+c+" to "+_),o.currentTime=_,h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else z.logger.error("Playhead still not moving while enough data buffered @"+c+" after "+C.nudgeMaxRetry+" nudges"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},k}()},"./src/controller/id3-track-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/utils/texttrack-utils.ts"),I=R("./src/demux/id3.ts"),z=.25,B=function(){function O(E){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=E,this._registerListeners()}var D=O.prototype;return D.destroy=function(){this._unregisterListeners()},D._registerListeners=function(){var L=this.hls;L.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.on(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),L.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D._unregisterListeners=function(){var L=this.hls;L.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.off(X.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),L.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},D.onMediaAttached=function(L,k){this.media=k.media},D.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},D.getID3Track=function(L){if(!this.media)return;for(var k=0;k<L.length;k++){var T=L[k];if(T.kind==="metadata"&&T.label==="id3")return Object(N.sendAddTrackEvent)(T,this.media),T}return this.media.addTextTrack("metadata","id3")},D.onFragParsingMetadata=function(L,k){if(!this.media)return;var T=k.frag,A=k.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var C=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<A.length;h++){var o=I.getID3Frames(A[h].data);if(o){var c=A[h].pts,d=h<A.length-1?A[h+1].pts:T.end,_=d-c;_<=0&&(d=c+z);for(var y=0;y<o.length;y++){var m=o[y];if(!I.isTimeStampFrame(m)){var l=new C(c,d,"");l.value=m,this.id3Track.addCue(l)}}}}},D.onBufferFlushing=function(L,k){var T=k.startOffset,A=k.endOffset,C=k.type;if(!C||C==="audio"){var h=this.id3Track;h&&Object(N.removeCuesInRange)(h,T,A)}},O}();$.default=B},"./src/controller/latency-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return O});var X=R("./src/errors.ts"),N=R("./src/events.ts"),I=R("./src/utils/logger.ts");function z(D,E){for(var L=0;L<E.length;L++){var k=E[L];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(D,k.key,k)}}function B(D,E,L){return E&&z(D.prototype,E),L&&z(D,L),D}var O=function(){function D(L){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=L,this.config=L.config,this.registerListeners()}var E=D.prototype;return E.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},E.registerListeners=function(){this.hls.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(N.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(N.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){this.hls.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(N.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(N.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(N.Events.ERROR,this.onError)},E.onMediaAttached=function(k,T){this.media=T.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},E.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},E.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},E.onLevelUpdated=function(k,T){var A=T.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},E.onError=function(k,T){if(T.details!==X.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,I.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},E.timeupdate=function(){var k=this.media,T=this.levelDetails;if(!k||!T)return;this.currentTime=k.currentTime;var A=this.computeLatency();if(A===null)return;this._latency=A;var C=this.config,h=C.lowLatencyMode,o=C.maxLiveSyncPlaybackRate;if(!h||o===1)return;var c=this.targetLatency;if(c===null)return;var d=A-c,_=Math.min(this.maxLatency,c+T.targetduration),y=d<_;if(T.live&&y&&d>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,o)),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)},E.estimateLiveEdge=function(){var k=this.levelDetails;return k===null?null:k.edge+k.age},E.computeLatency=function(){var k=this.estimateLiveEdge();return k===null?null:k-this.currentTime},B(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,A=k.partHoldBack,C=k.targetduration,h=this.config,o=h.liveSyncDuration,c=h.liveSyncDurationCount,d=h.lowLatencyMode,_=this.hls.userConfig,y=d&&A||T;(_.liveSyncDuration||_.liveSyncDurationCount||y===0)&&(y=o!==void 0?o:c*C);var m=C,l=1;return y+Math.min(this.stallCount*l,m)}},{key:"liveSyncPosition",get:function(){var k=this.estimateLiveEdge(),T=this.targetLatency,A=this.levelDetails;if(k===null||T===null||A===null)return null;var C=A.edge,h=k-T-this.edgeStalled,o=C-A.totalduration,c=C-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,h),c)}},{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 A=k.buffered.length;return A?k.buffered.end(A-1):T.edge-this.currentTime}}]),D}()},"./src/controller/level-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return h});var X=R("./src/types/level.ts"),N=R("./src/events.ts"),I=R("./src/errors.ts"),z=R("./src/utils/codecs.ts"),B=R("./src/controller/level-helper.ts"),O=R("./src/controller/base-playlist-controller.ts"),D=R("./src/types/loader.ts");function E(){return E=Object.assign||function(o){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var _ in d)Object.prototype.hasOwnProperty.call(d,_)&&(o[_]=d[_])}return o},E.apply(this,arguments)}function L(o,c){for(var d=0;d<c.length;d++){var _=c[d];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(o,_.key,_)}}function k(o,c,d){return c&&L(o.prototype,c),d&&L(o,d),o}function T(o,c){o.prototype=Object.create(c.prototype),o.prototype.constructor=o,A(o,c)}function A(o,c){return A=Object.setPrototypeOf||function(_,y){return _.__proto__=y,_},A(o,c)}var C=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){T(c,o);function c(_){var y;return y=o.call(this,_,"[level-controller]")||this,y._levels=[],y._firstLevel=-1,y._startLevel=void 0,y.currentLevelIndex=-1,y.manualLevelIndex=-1,y.onParsedComplete=void 0,y._registerListeners(),y}var d=c.prototype;return d._registerListeners=function(){var y=this.hls;y.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),y.on(N.Events.ERROR,this.onError,this)},d._unregisterListeners=function(){var y=this.hls;y.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),y.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),y.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),y.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),y.off(N.Events.ERROR,this.onError,this)},d.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},d.startLoad=function(){var y=this._levels;y.forEach(function(m){m.loadError=0}),o.prototype.startLoad.call(this)},d.onManifestLoaded=function(y,m){var l=[],x=[],f=[],p,s={},a,b=!1,v=!1,S=!1;if(m.levels.forEach(function(Q){var G=Q.attrs;b=b||!!(Q.width&&Q.height),v=v||!!Q.videoCodec,S=S||!!Q.audioCodec,C&&Q.audioCodec&&Q.audioCodec.indexOf("mp4a.40.34")!==-1&&(Q.audioCodec=void 0);var W=Q.bitrate+"-"+Q.attrs.RESOLUTION+"-"+Q.attrs.CODECS;a=s[W],a?a.url.push(Q.url):(a=new X.Level(Q),s[W]=a,l.push(a)),G&&(G.AUDIO&&Object(B.addGroupId)(a,"audio",G.AUDIO),G.SUBTITLES&&Object(B.addGroupId)(a,"text",G.SUBTITLES))}),(b||v)&&S&&(l=l.filter(function(Q){var G=Q.videoCodec,W=Q.width,q=Q.height;return!!G||!!(W&&q)})),l=l.filter(function(Q){var G=Q.audioCodec,W=Q.videoCodec;return(!G||Object(z.isCodecSupportedInMp4)(G,"audio"))&&(!W||Object(z.isCodecSupportedInMp4)(W,"video"))}),m.audioTracks&&(x=m.audioTracks.filter(function(Q){return!Q.audioCodec||Object(z.isCodecSupportedInMp4)(Q.audioCodec,"audio")}),Object(B.assignTrackIdsByGroup)(x)),m.subtitles&&(f=m.subtitles,Object(B.assignTrackIdsByGroup)(f)),l.length>0){p=l[0].bitrate,l.sort(function(Q,G){return Q.bitrate-G.bitrate}),this._levels=l;for(var M=0;M<l.length;M++)if(l[M].bitrate===p){this._firstLevel=M,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+p);break}var H=S&&!v,V={levels:l,audioTracks:x,subtitleTracks:f,firstLevel:this._firstLevel,stats:m.stats,audio:S,video:v,altAudio:!H&&x.some(function(Q){return!!Q.url})};this.hls.trigger(N.Events.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:m.url,reason:"no level with compatible codecs found in manifest"})},d.onError=function(y,m){if(o.prototype.onError.call(this,y,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 f=!1,p=!0,s;switch(m.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:case I.ErrorDetails.KEY_LOAD_ERROR:case I.ErrorDetails.KEY_LOAD_TIMEOUT:if(m.frag){var a=this._levels[m.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=m.frag.level)):s=m.frag.level}break;case I.ErrorDetails.LEVEL_LOAD_ERROR:case I.ErrorDetails.LEVEL_LOAD_TIMEOUT:l&&(l.deliveryDirectives&&(p=!1),s=l.level),f=!0;break;case I.ErrorDetails.REMUX_ALLOC_ERROR:s=m.level,f=!0;break}s!==void 0&&this.recoverLevel(m,s,f,p)},d.recoverLevel=function(y,m,l,x){var f=y.details,p=this._levels[m];if(p.loadError++,l){var s=this.retryLoadingOrFail(y);if(s)y.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(x){var a=p.url.length;if(a>1&&p.loadError<a)y.levelRetry=!0,this.redundantFailover(m);else if(this.manualLevelIndex===-1){var b=m===0?this._levels.length-1:m-1;this.currentLevelIndex!==b&&this._levels[b].loadError===0&&(this.warn(f+": switch to "+b),y.levelRetry=!0,this.hls.nextAutoLevel=b)}}},d.redundantFailover=function(y){var m=this._levels[y],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(f){f.urlId=x}),this.level=y}},d.onFragLoaded=function(y,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(y,m){var l,x=m.level,f=m.details,p=this._levels[x];if(!p){var s;this.warn("Invalid level index "+x),(s=m.deliveryDirectives)!==null&&s!==void 0&&s.skip&&(f.deltaUpdateFailed=!0);return}x===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(x,m,p.details)):(l=m.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(f.deltaUpdateFailed=!0)},d.onAudioTrackSwitched=function(y,m){var l=this.hls.levels[this.currentLevelIndex];if(!l)return;if(l.audioGroupIds){for(var x=-1,f=this.hls.audioTracks[m.id].groupId,p=0;p<l.audioGroupIds.length;p++)if(l.audioGroupIds[p]===f){x=p;break}x!==l.urlId&&(l.urlId=x,this.startLoad())}},d.loadPlaylist=function(y){var m=this.currentLevelIndex,l=this._levels[m];if(this.canLoad&&l&&l.url.length>0){var x=l.urlId,f=l.url[x];if(y)try{f=y.addDirectives(f)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+m+(y?" at sn "+y.msn+" part "+y.part:"")+" with URL-id "+x+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:m,id:x,deliveryDirectives:y||null})}},d.removeLevel=function(y,m){var l=function(p,s){return s!==m},x=this._levels.filter(function(f,p){return p!==y?!0:f.url.length>1&&m!==void 0?(f.url=f.url.filter(l),f.audioGroupIds&&(f.audioGroupIds=f.audioGroupIds.filter(l)),f.textGroupIds&&(f.textGroupIds=f.textGroupIds.filter(l)),f.urlId=0,!0):!1}).map(function(f,p){var s=f.details;return s!=null&&s.fragments&&s.fragments.forEach(function(a){a.level=p}),f});this._levels=x,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:x})},k(c,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(y){var m,l=this._levels;if(l.length===0)return;if(this.currentLevelIndex===y&&(m=l[y])!==null&&m!==void 0&&m.details)return;if(y<0||y>=l.length){var x=y<0;if(this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.LEVEL_SWITCH_ERROR,level:y,fatal:x,reason:"invalid level idx"}),x)return;y=Math.min(y,l.length-1)}this.clearTimer();var f=this.currentLevelIndex,p=l[f],s=l[y];this.log("switching to level "+y+" from "+f),this.currentLevelIndex=y;var a=E({},s,{level:y,maxBitrate:s.maxBitrate,uri:s.uri,urlId:s.urlId});delete a._urlId,this.hls.trigger(N.Events.LEVEL_SWITCHING,a);var b=s.details;if(!b||b.live){var v=this.switchParams(s.uri,p==null?void 0:p.details);this.loadPlaylist(v)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(y){this.manualLevelIndex=y,this._startLevel===void 0&&(this._startLevel=y),y!==-1&&(this.level=y)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(y){this._firstLevel=y}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var y=this.hls.config.startLevel;return y!==void 0?y:this._firstLevel}else return this._startLevel},set:function(y){this._startLevel=y}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(y){this.level=y,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=y)}}]),c}(O.default)},"./src/controller/level-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"addGroupId",function(){return I}),R.d($,"assignTrackIdsByGroup",function(){return z}),R.d($,"updatePTS",function(){return B}),R.d($,"updateFragPTSDTS",function(){return D}),R.d($,"mergeDetails",function(){return E}),R.d($,"mapPartIntersection",function(){return L}),R.d($,"mapFragmentIntersection",function(){return k}),R.d($,"adjustSliding",function(){return T}),R.d($,"addSliding",function(){return A}),R.d($,"computeReloadInterval",function(){return C}),R.d($,"getFragmentWithSN",function(){return h}),R.d($,"getPartWith",function(){return o});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/logger.ts");function I(c,d,_){switch(d){case"audio":c.audioGroupIds||(c.audioGroupIds=[]),c.audioGroupIds.push(_);break;case"text":c.textGroupIds||(c.textGroupIds=[]),c.textGroupIds.push(_);break}}function z(c){var d={};c.forEach(function(_){var y=_.groupId||"";_.id=d[y]=d[y]||0,d[y]++})}function B(c,d,_){var y=c[d],m=c[_];O(y,m)}function O(c,d){var _=d.startPTS;if(Object(X.isFiniteNumber)(_)){var y=0,m;d.sn>c.sn?(y=_-c.start,m=c):(y=c.start-_,m=d),m.duration!==y&&(m.duration=y)}else if(d.sn>c.sn){var l=c.cc===d.cc;l&&c.minEndPTS?d.start=c.start+(c.minEndPTS-c.start):d.start=c.start+c.duration}else d.start=Math.max(c.start-d.duration,0)}function D(c,d,_,y,m,l){var x=y-_;x<=0&&(N.logger.warn("Fragment should have a positive duration",d),y=_+d.duration,l=m+d.duration);var f=_,p=y,s=d.startPTS,a=d.endPTS;if(Object(X.isFiniteNumber)(s)){var b=Math.abs(s-_);Object(X.isFiniteNumber)(d.deltaPTS)?d.deltaPTS=Math.max(b,d.deltaPTS):d.deltaPTS=b,f=Math.max(_,s),_=Math.min(_,s),m=Math.min(m,d.startDTS),p=Math.min(y,a),y=Math.max(y,a),l=Math.max(l,d.endDTS)}d.duration=y-_;var v=_-d.start;d.appendedPTS=y,d.start=d.startPTS=_,d.maxStartPTS=f,d.startDTS=m,d.endPTS=y,d.minEndPTS=p,d.endDTS=l;var S=d.sn;if(!c||S<c.startSN||S>c.endSN)return 0;var M,H=S-c.startSN,V=c.fragments;for(V[H]=d,M=H;M>0;M--)O(V[M],V[M-1]);for(M=H;M<V.length-1;M++)O(V[M],V[M+1]);return c.fragmentHint&&O(V[V.length-1],c.fragmentHint),c.PTSKnown=c.alignedSliding=!0,v}function E(c,d){for(var _=null,y=c.fragments,m=y.length-1;m>=0;m--){var l=y[m].initSegment;if(l){_=l;break}}c.fragmentHint&&delete c.fragmentHint.endPTS;var x=0,f;if(k(c,d,function(M,H){M.relurl&&(x=M.cc-H.cc),Object(X.isFiniteNumber)(M.startPTS)&&Object(X.isFiniteNumber)(M.endPTS)&&(H.start=H.startPTS=M.startPTS,H.startDTS=M.startDTS,H.appendedPTS=M.appendedPTS,H.maxStartPTS=M.maxStartPTS,H.endPTS=M.endPTS,H.endDTS=M.endDTS,H.minEndPTS=M.minEndPTS,H.duration=M.endPTS-M.startPTS,H.duration&&(f=H),d.PTSKnown=d.alignedSliding=!0),H.elementaryStreams=M.elementaryStreams,H.loader=M.loader,H.stats=M.stats,H.urlId=M.urlId,M.initSegment&&(H.initSegment=M.initSegment,_=M.initSegment)}),_){var p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments;p.forEach(function(M){var H;(!M.initSegment||M.initSegment.relurl===((H=_)===null||H===void 0?void 0:H.relurl))&&(M.initSegment=_)})}if(d.skippedSegments&&(d.deltaUpdateFailed=d.fragments.some(function(M){return!M}),d.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var s=d.skippedSegments;s--;)d.fragments.shift();d.startSN=d.fragments[0].sn,d.startCC=d.fragments[0].cc}var a=d.fragments;if(x){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].cc+=x}d.skippedSegments&&(d.startCC=d.fragments[0].cc),L(c.partList,d.partList,function(M,H){H.elementaryStreams=M.elementaryStreams,H.stats=M.stats}),f?D(d,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):T(c,d),a.length&&(d.totalduration=d.edge-a[0].start),d.driftStartTime=c.driftStartTime,d.driftStart=c.driftStart;var v=d.advancedDateTime;if(d.advanced&&v){var S=d.edge;d.driftStart||(d.driftStartTime=v,d.driftStart=S),d.driftEndTime=v,d.driftEnd=S}else d.driftEndTime=c.driftEndTime,d.driftEnd=c.driftEnd,d.advancedDateTime=c.advancedDateTime}function L(c,d,_){if(c&&d)for(var y=0,m=0,l=c.length;m<=l;m++){var x=c[m],f=d[m+y];x&&f&&x.index===f.index&&x.fragment.sn===f.fragment.sn?_(x,f):y--}}function k(c,d,_){for(var y=d.skippedSegments,m=Math.max(c.startSN,d.startSN)-d.startSN,l=(c.fragmentHint?1:0)+(y?d.endSN:Math.min(c.endSN,d.endSN))-d.startSN,x=d.startSN-c.startSN,f=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,p=c.fragmentHint?c.fragments.concat(c.fragmentHint):c.fragments,s=m;s<=l;s++){var a=p[x+s],b=f[s];y&&!b&&s<y&&(b=d.fragments[s]=a),a&&b&&_(a,b)}}function T(c,d){var _=d.startSN+d.skippedSegments-c.startSN,y=c.fragments;if(_<0||_>=y.length)return;A(d,y[_].start)}function A(c,d){if(d){for(var _=c.fragments,y=c.skippedSegments;y<_.length;y++)_[y].start+=d;c.fragmentHint&&(c.fragmentHint.start+=d)}}function C(c,d){var _=1e3*c.levelTargetDuration,y=_/2,m=c.age,l=m>0&&m<_*3,x=d.loading.end-d.loading.start,f,p=c.availabilityDelay;if(c.updated===!1)if(l){var s=333*c.misses;f=Math.max(Math.min(y,x*2),s),c.availabilityDelay=(c.availabilityDelay||0)+f}else f=y;else l?(p=Math.min(p||_/2,m),c.availabilityDelay=p,f=p+_-m):f=_-x;return Math.round(f)}function h(c,d,_){if(!c||!c.details)return null;var y=c.details,m=y.fragments[d-y.startSN];return m||(m=y.fragmentHint,m&&m.sn===d?m:d<y.startSN&&_&&_.sn===d?_:null)}function o(c,d,_){if(!c||!c.details)return null;var y=c.details.partList;if(y)for(var m=y.length;m--;){var l=y[m];if(l.index===_&&l.fragment.sn===d)return l}return null}},"./src/controller/stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return y});var X=R("./src/polyfills/number.ts"),N=R("./src/controller/base-stream-controller.ts"),I=R("./src/is-supported.ts"),z=R("./src/events.ts"),B=R("./src/utils/buffer-helper.ts"),O=R("./src/controller/fragment-tracker.ts"),D=R("./src/types/loader.ts"),E=R("./src/loader/fragment.ts"),L=R("./src/demux/transmuxer-interface.ts"),k=R("./src/types/transmuxer.ts"),T=R("./src/controller/gap-controller.ts"),A=R("./src/errors.ts"),C=R("./src/utils/logger.ts");function h(m,l){for(var x=0;x<l.length;x++){var f=l[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function o(m,l,x){return l&&h(m.prototype,l),x&&h(m,x),m}function c(m,l){m.prototype=Object.create(l.prototype),m.prototype.constructor=m,d(m,l)}function d(m,l){return d=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},d(m,l)}var _=100,y=function(m){c(l,m);function l(f,p){var s;return s=m.call(this,f,p,"[stream-controller]")||this,s.audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.onvplaying=null,s.onvseeked=null,s.fragLastKbps=0,s.stalled=!1,s.couldBacktrack=!1,s.audioCodecSwitch=!1,s.videoBuffer=null,s._registerListeners(),s}var x=l.prototype;return x._registerListeners=function(){var p=this.hls;p.on(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(z.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(z.Events.ERROR,this.onError,this),p.on(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(z.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x._unregisterListeners=function(){var p=this.hls;p.off(z.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(z.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(z.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(z.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(z.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(z.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(z.Events.ERROR,this.onError,this),p.off(z.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(z.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(z.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(z.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(z.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(z.Events.FRAG_BUFFERED,this.onFragBuffered,this)},x.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},x.startLoad=function(p){if(this.levels){var s=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(_),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=a.startLevel;b===-1&&(a.config.testBandwidth?(b=0,this.bitrateTest=!0):b=a.nextAutoLevel),this.level=a.nextLoadLevel=b,this.loadedmetadata=!1}s>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),p=s),this.state=N.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=N.State.STOPPED},x.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},x.doTick=function(){switch(this.state){case N.State.IDLE:this.doTickIdle();break;case N.State.WAITING_LEVEL:{var p,s=this.levels,a=this.level,b=s==null||((p=s[a])===null||p===void 0)?void 0:p.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=N.State.IDLE;break}break}case N.State.FRAG_LOADING_WAITING_RETRY:{var v,S=self.performance.now(),M=this.retryDate;(!M||S>=M||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=N.State.IDLE)}break;default:break}this.onTickEnd()},x.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},x.doTickIdle=function(){var p,s,a=this.hls,b=this.levelLastLoaded,v=this.levels,S=this.media,M=a.config,H=a.nextLoadLevel;if(b===null||!S&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!v||!v[H])return;var V=v[H];this.level=a.nextLoadLevel=H;var Q=V.details;if(!Q||this.state===N.State.WAITING_LEVEL||Q.live&&this.levelLastLoaded!==H){this.state=N.State.WAITING_LEVEL;return}var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:S,D.PlaylistLevelType.MAIN);if(G===null)return;var W=G.len,q=this.getMaxBufferLength(V.maxBitrate);if(W>=q)return;if(this._streamEnded(G,Q)){var oe={};this.altAudio&&(oe.type="video"),this.hls.trigger(z.Events.BUFFER_EOS,oe),this.state=N.State.ENDED;return}var fe=G.end,ve=this.getNextFragment(fe,Q);if(this.couldBacktrack&&!this.fragPrevious&&ve&&ve.sn!=="initSegment"){var De=ve.sn-Q.startSN;De>1&&(ve=Q.fragments[De-1],this.fragmentTracker.removeFragment(ve))}if(ve&&this.fragmentTracker.getState(ve)===O.FragmentState.OK&&this.nextLoadPosition>fe){var Ee=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(S,Ee,D.PlaylistLevelType.MAIN),ve=this.getNextFragment(this.nextLoadPosition,Q)}if(!ve)return;ve.initSegment&&!ve.initSegment.data&&!this.bitrateTest&&(ve=ve.initSegment),((p=ve.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((s=ve.decryptdata)!==null&&s!==void 0&&s.key)?this.loadKey(ve,Q):this.loadFragment(ve,Q,fe)},x.loadFragment=function(p,s,a){var b,v=this.fragmentTracker.getState(p);if(this.fragCurrent=p,v===O.FragmentState.BACKTRACKED){var S=this.fragmentTracker.getBacktrackData(p);if(S){this._handleFragmentLoadProgress(S),this._handleFragmentLoadComplete(S);return}else v=O.FragmentState.NOT_LOADED}v===O.FragmentState.NOT_LOADED||v===O.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,m.prototype.loadFragment.call(this,p,s,a)):v===O.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((b=this.media)===null||b===void 0?void 0:b.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},x.getAppendedFrag=function(p){var s=this.fragmentTracker.getAppendedFrag(p,D.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},x.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,D.PlaylistLevelType.MAIN)},x.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},x.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},x.nextLevelSwitch=function(){var p=this.levels,s=this.media;if(s!=null&&s.readyState){var a,b=this.getAppendedFrag(s.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!s.paused&&p){var v=this.hls.nextLoadLevel,S=p[v],M=this.fragLastKbps;M&&this.fragCurrent?a=this.fragCurrent.duration*S.maxBitrate/(1e3*M)+1:a=0}else a=0;var H=this.getBufferedFrag(s.currentTime+a);if(H){var V=this.followingBufferedFrag(H);if(V){this.abortCurrentFrag();var Q=V.maxStartPTS?V.maxStartPTS:V.start,G=V.duration,W=Math.max(H.end,Q+Math.min(Math.max(G-this.config.maxFragLookUpTolerance,G*.5),G*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},x.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===N.State.KEY_LOADING&&(this.state=N.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},x.flushMainBuffer=function(p,s){m.prototype.flushMainBuffer.call(this,p,s,this.altAudio?"video":null)},x.onMediaAttached=function(p,s){m.prototype.onMediaAttached.call(this,p,s);var a=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,a,this.fragmentTracker,this.hls)},x.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),m.prototype.onMediaDetaching.call(this)},x.onMediaPlaying=function(){this.tick()},x.onMediaSeeked=function(){var p=this.media,s=p?p.currentTime:null;Object(X.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},x.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(z.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},x.onManifestParsed=function(p,s){var a=!1,b=!1,v;s.levels.forEach(function(S){v=S.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(a=!0),v.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!Object(I.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},x.onLevelLoading=function(p,s){var a=this.levels;if(!a||this.state!==N.State.IDLE)return;var b=a[s.level];(!b.details||b.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(b.details))&&(this.state=N.State.WAITING_LEVEL)},x.onLevelLoaded=function(p,s){var a,b=this.levels,v=s.level,S=s.details,M=S.totalduration;if(!b){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+S.startSN+","+S.endSN+"], cc ["+S.startCC+", "+S.endCC+"] duration:"+M);var H=this.fragCurrent;H&&(this.state===N.State.FRAG_LOADING||this.state===N.State.FRAG_LOADING_WAITING_RETRY)&&(H.level!==s.level&&H.loader&&(this.state=N.State.IDLE,H.loader.abort()));var V=b[v],Q=0;if(S.live||(a=V.details)!==null&&a!==void 0&&a.live){if(S.fragments[0]||(S.deltaUpdateFailed=!0),S.deltaUpdateFailed)return;Q=this.alignPlaylists(S,V.details)}if(V.details=S,this.levelLastLoaded=v,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:S,level:v}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(S))return;this.state=N.State.IDLE}this.startFragRequested?S.live&&this.synchronizeToLiveEdge(S):this.setStartPosition(S,Q),this.tick()},x._handleFragmentLoadProgress=function(p){var s,a=p.frag,b=p.part,v=p.payload,S=this.levels;if(!S){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var M=S[a.level],H=M.details;if(!H){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var V=M.videoCodec,Q=H.PTSKnown||!H.live,G=(s=a.initSegment)===null||s===void 0?void 0:s.data,W=this._getAudioCodec(M),q=this.transmuxer=this.transmuxer||new L.default(this.hls,D.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=b?b.index:-1,fe=oe!==-1,ve=new k.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,oe,fe),De=this.initPTS[a.cc];q.push(v,G,W,V,a,b,H.totalduration,Q,ve,De)},x.onAudioTrackSwitching=function(p,s){var a=this.altAudio,b=!!s.url,v=s.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var 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;a&&M.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:v})}},x.onAudioTrackSwitched=function(p,s){var a=s.id,b=!!this.hls.audioTracks[a].url;if(b){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=b,this.tick()},x.onBufferCreated=function(p,s){var a=s.tracks,b,v,S=!1;for(var M in a){var H=a[M];if(H.id==="main"){if(v=M,b=H,M==="video"){var V=a[M];V&&(this.videoBuffer=V.buffer)}}else S=!0}S&&b?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},x.onFragBuffered=function(p,s){var a=s.frag,b=s.part;if(a&&a.type!==D.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===N.State.PARSED&&(this.state=N.State.IDLE);return}var v=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},x.onError=function(p,s){switch(s.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(D.PlaylistLevelType.MAIN,s);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==N.State.ERROR&&(s.fatal?(this.warn(""+s.details),this.state=N.State.ERROR):!s.levelRetry&&this.state===N.State.WAITING_LEVEL&&(this.state=N.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===N.State.PARSING||this.state===N.State.PARSED)){var a=!0,b=this.getFwdBufferInfo(this.media,D.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},x.checkBuffer=function(){var p=this.media,s=this.gapController;if(!p||!s||!p.readyState)return;var a=B.BufferHelper.getBuffered(p);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):s.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},x.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},x.onBufferFlushed=function(p,s){var a=s.type;if(a!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,D.PlaylistLevelType.MAIN)}},x.onLevelsUpdated=function(p,s){this.levels=s.levels},x.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},x.seekToStartPos=function(){var p=this.media,s=p.currentTime,a=this.startPosition;if(a>=0&&s<a){if(p.seeking){C.logger.log("could not seek to "+a+", already seeking at "+s);return}var b=B.BufferHelper.getBuffered(p),v=b.length?b.start(0):0,S=v-a;S>0&&(S<this.config.maxBufferHole||S<this.config.maxFragLookUpTolerance)&&(C.logger.log("adjusting start position by "+S+" to match buffer start"),a+=S,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+s),p.currentTime=a}},x._getAudioCodec=function(p){var s=this.config.defaultAudioCodec||p.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s.indexOf("mp4a.40.5")!==-1?s="mp4a.40.2":s="mp4a.40.5"),s},x._loadBitrateTestFrag=function(p){var s=this;this._doFragLoad(p).then(function(a){var b=s.hls;if(!a||b.nextLoadLevel||s.fragContextChanged(p))return;s.fragLoadError=0,s.state=N.State.IDLE,s.startFragRequested=!1,s.bitrateTest=!1;var v=p.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),b.trigger(z.Events.FRAG_LOADED,a)})},x._handleTransmuxComplete=function(p){var s,a="main",b=this.hls,v=p.remuxResult,S=p.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 H=M.frag,V=M.part,Q=M.level,G=v.video,W=v.text,q=v.id3,oe=v.initSegment,fe=this.altAudio?void 0:v.audio;if(this.fragContextChanged(H))return;if(this.state=N.State.PARSING,oe){oe.tracks&&(this._bufferInitSegment(Q,oe.tracks,H,S),b.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:H,id:a,tracks:oe.tracks}));var ve=oe.initPTS,De=oe.timescale;Object(X.isFiniteNumber)(ve)&&(this.initPTS[H.cc]=ve,b.trigger(z.Events.INIT_PTS_FOUND,{frag:H,id:a,initPTS:ve,timescale:De}))}if(G&&v.independent!==!1){if(Q.details){var Ee=G.startPTS,_e=G.endPTS,Te=G.startDTS,Ce=G.endDTS;if(V)V.elementaryStreams[G.type]={startPTS:Ee,endPTS:_e,startDTS:Te,endDTS:Ce};else if(G.firstKeyFrame&&G.independent&&(this.couldBacktrack=!0),G.dropped&&G.independent){var me=this.getLoadPosition()+this.config.maxBufferHole;if(me<Ee){this.backtrack(H);return}H.setElementaryStreamInfo(G.type,H.start,_e,H.start,Ce,!0)}H.setElementaryStreamInfo(G.type,Ee,_e,Te,Ce),this.bufferFragmentData(G,H,V,S)}}else if(v.independent===!1){this.backtrack(H);return}if(fe){var ne=fe.startPTS,Ae=fe.endPTS,rt=fe.startDTS,$e=fe.endDTS;V&&(V.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:ne,endPTS:Ae,startDTS:rt,endDTS:$e}),H.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,ne,Ae,rt,$e),this.bufferFragmentData(fe,H,V,S)}if(q!=null&&(s=q.samples)!==null&&s!==void 0&&s.length){var Xe={frag:H,id:a,samples:q.samples};b.trigger(z.Events.FRAG_PARSING_METADATA,Xe)}if(W){var Ve={frag:H,id:a,samples:W.samples};b.trigger(z.Events.FRAG_PARSING_USERDATA,Ve)}},x._bufferInitSegment=function(p,s,a,b){var v=this;if(this.state!==N.State.PARSING)return;this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var S=s.audio,M=s.video,H=s.audiovideo;if(S){var V=p.audioCodec,Q=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(V&&(V.indexOf("mp4a.40.5")!==-1?V="mp4a.40.2":V="mp4a.40.5"),S.metadata.channelCount!==1&&Q.indexOf("firefox")===-1&&(V="mp4a.40.5")),Q.indexOf("android")!==-1&&S.container!=="audio/mpeg"&&(V="mp4a.40.2",this.log("Android: force audio codec to "+V)),p.audioCodec&&p.audioCodec!==V&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+V+'"'),S.levelCodec=V,S.id="main",this.log("Init audio buffer, container:"+S.container+", codecs[selected/level/parsed]=["+(V||"")+"/"+(p.audioCodec||"")+"/"+S.codec+"]")}M&&(M.levelCodec=p.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+M.codec+"]")),H&&this.log("Init audiovideo buffer, container:"+H.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+H.codec+"]"),this.hls.trigger(z.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(G){var W=s[G],q=W.initSegment;q!=null&&q.byteLength&&v.hls.trigger(z.Events.BUFFER_APPENDING,{type:G,data:q,frag:a,part:null,chunkMeta:b,parent:a.type})}),this.tick()},x.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var s=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,s?this.resetFragmentLoading(p):this.state=N.State.BACKTRACKING},x.checkFragmentChanged=function(){var p=this.media,s=null;if(p&&p.readyState>1&&p.seeking===!1){var a=p.currentTime;if(B.BufferHelper.isBuffered(p,a)?s=this.getAppendedFrag(a):B.BufferHelper.isBuffered(p,a+.1)&&(s=this.getAppendedFrag(a+.1)),s){var b=this.fragPlaying,v=s.level;(!b||s.sn!==b.sn||b.level!==v||s.urlId!==b.urlId)&&(this.hls.trigger(z.Events.FRAG_CHANGED,{frag:s}),(!b||b.level!==v)&&this.hls.trigger(z.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=s)}}},o(l,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var s=this.getAppendedFrag(p.currentTime);if(s)return s.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var s=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(s)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),l}(N.default)},"./src/controller/subtitle-stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"SubtitleStreamController",function(){return c});var X=R("./src/events.ts"),N=R("./src/utils/logger.ts"),I=R("./src/utils/buffer-helper.ts"),z=R("./src/controller/fragment-finders.ts"),B=R("./src/utils/discontinuities.ts"),O=R("./src/controller/level-helper.ts"),D=R("./src/controller/fragment-tracker.ts"),E=R("./src/controller/base-stream-controller.ts"),L=R("./src/types/loader.ts"),k=R("./src/types/level.ts");function T(d,_){for(var y=0;y<_.length;y++){var m=_[y];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(d,m.key,m)}}function A(d,_,y){return _&&T(d.prototype,_),y&&T(d,y),d}function C(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,h(d,_)}function h(d,_){return h=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},h(d,_)}var o=500,c=function(d){C(_,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 y=_.prototype;return y.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},y._registerListeners=function(){var l=this.hls;l.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(X.Events.ERROR,this.onError,this),l.on(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y._unregisterListeners=function(){var l=this.hls;l.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(X.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(X.Events.ERROR,this.onError,this),l.off(X.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(X.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(X.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(X.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},y.startLoad=function(){this.stopLoad(),this.state=E.State.IDLE,this.setInterval(o),this.tick()},y.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},y.onLevelLoaded=function(l,x){this.mainDetails=x.details},y.onSubtitleFragProcessed=function(l,x){var f=x.frag,p=x.success;if(this.fragPrevious=f,this.state=E.State.IDLE,!p)return;var s=this.tracksBuffered[this.currentTrackId];if(!s)return;for(var a,b=f.start,v=0;v<s.length;v++)if(b>=s[v].start&&b<=s[v].end){a=s[v];break}var S=f.start+f.duration;a?a.end=S:(a={start:b,end:S},s.push(a)),this.fragmentTracker.fragBuffered(f)},y.onBufferFlushing=function(l,x){var f=x.startOffset,p=x.endOffset;if(f===0&&p!==Number.POSITIVE_INFINITY){var s=this.currentTrackId,a=this.levels;if(!a.length||!a[s]||!a[s].details)return;var b=a[s].details,v=b.targetduration,S=p-v;if(S<=0)return;x.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(M){for(var H=0;H<M.length;){if(M[H].end<=S){M.shift();continue}else if(M[H].start<S)M[H].start=S;else break;H++}}),this.fragmentTracker.removeFragmentsInRange(f,S,L.PlaylistLevelType.SUBTITLE)}},y.onError=function(l,x){var f,p=x.frag;if(!p||p.type!==L.PlaylistLevelType.SUBTITLE)return;(f=this.fragCurrent)!==null&&f!==void 0&&f.loader&&this.fragCurrent.loader.abort(),this.state=E.State.IDLE},y.onSubtitleTracksUpdated=function(l,x){var f=this,p=x.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(s){return new k.Level(s)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(s){f.tracksBuffered[s.id]=[]}),this.mediaBuffer=null},y.onSubtitleTrackSwitch=function(l,x){if(this.currentTrackId=x.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var f=this.levels[this.currentTrackId];f!=null&&f.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,f&&this.setInterval(o)},y.onSubtitleTrackLoaded=function(l,x){var f,p=x.details,s=x.id,a=this.currentTrackId,b=this.levels;if(!b.length)return;var v=b[a];if(s>=b.length||s!==a||!v)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,p.live||(f=v.details)!==null&&f!==void 0&&f.live){var S=this.mainDetails;if(p.deltaUpdateFailed||!S)return;var M=S.fragments[0];if(!v.details)p.hasProgramDateTime&&S.hasProgramDateTime?Object(B.alignMediaPlaylistByPDT)(p,S):M&&Object(O.addSliding)(p,M.start);else{var H=this.alignPlaylists(p,v.details);H===0&&M&&Object(O.addSliding)(p,M.start)}}if(v.details=p,this.levelLastLoaded=s,this.tick(),p.live&&!this.fragCurrent&&this.media&&this.state===E.State.IDLE){var V=Object(z.findFragmentByPTS)(null,p.fragments,this.media.currentTime,0);V||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}},y._handleFragmentLoadComplete=function(l){var x=l.frag,f=l.payload,p=x.decryptdata,s=this.hls;if(this.fragContextChanged(x))return;if(f&&f.byteLength>0&&p&&p.key&&p.iv&&p.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(f),p.key.buffer,p.iv.buffer).then(function(b){var v=performance.now();s.trigger(X.Events.FRAG_DECRYPTED,{frag:x,payload:b,stats:{tstart:a,tdecrypt:v}})})}},y.doTick=function(){if(!this.media){this.state=E.State.IDLE;return}if(this.state===E.State.IDLE){var l,x=this.currentTrackId,f=this.levels;if(!f.length||!f[x]||!f[x].details)return;var p=f[x].details,s=p.targetduration,a=this.config,b=this.media,v=I.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-s,a.maxBufferHole),S=v.end,M=v.len,H=this.getMaxBufferLength()+s;if(M>H)return;console.assert(p,"Subtitle track details are defined on idle subtitle stream controller tick");var V=p.fragments,Q=V.length,G=p.edge,W,q=this.fragPrevious;if(S<G){var oe=a.maxFragLookUpTolerance;q&&p.hasProgramDateTime&&(W=Object(z.findFragmentByPDT)(V,q.endProgramDateTime,oe)),W||(W=Object(z.findFragmentByPTS)(q,V,S,oe),!W&&q&&q.start<V[0].start&&(W=V[0]))}else W=V[Q-1];(l=W)!==null&&l!==void 0&&l.encrypted?(N.logger.log("Loading key for "+W.sn),this.state=E.State.KEY_LOADING,this.hls.trigger(X.Events.KEY_LOADING,{frag:W})):W&&this.fragmentTracker.getState(W)===D.FragmentState.NOT_LOADED&&this.loadFragment(W,p,S)}},y.loadFragment=function(l,x,f){this.fragCurrent=l,d.prototype.loadFragment.call(this,l,x,f)},A(_,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),_}(E.default)},"./src/controller/subtitle-track-controller.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/events.ts"),N=R("./src/utils/texttrack-utils.ts"),I=R("./src/controller/base-playlist-controller.ts"),z=R("./src/types/loader.ts");function B(T,A){for(var C=0;C<A.length;C++){var h=A[C];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function O(T,A,C){return A&&B(T.prototype,A),C&&B(T,C),T}function D(T,A){T.prototype=Object.create(A.prototype),T.prototype.constructor=T,E(T,A)}function E(T,A){return E=Object.setPrototypeOf||function(h,o){return h.__proto__=o,h},E(T,A)}var L=function(T){D(A,T);function A(h){var o;return o=T.call(this,h,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var C=A.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},C.registerListeners=function(){var o=this.hls;o.on(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(X.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var o=this.hls;o.off(X.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(X.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(X.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(X.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(X.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(X.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(X.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(X.Events.ERROR,this.onError,this)},C.onMediaAttached=function(o,c){if(this.media=c.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},C.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},C.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var o=k(this.media.textTracks);o.forEach(function(c){Object(N.clearCurrentCues)(c)}),this.subtitleTrack=-1,this.media=null},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(o,c){this.tracks=c.subtitleTracks},C.onSubtitleTrackLoaded=function(o,c){var d=c.id,_=c.details,y=this.trackId,m=this.tracksInGroup[y];if(!m){this.warn("Invalid subtitle track id "+d);return}var l=m.details;m.details=c.details,this.log("subtitle track "+d+" loaded ["+_.startSN+"-"+_.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,c,l))},C.onLevelLoading=function(o,c){this.switchLevel(c.level)},C.onLevelSwitching=function(o,c){this.switchLevel(c.level)},C.switchLevel=function(o){var c=this.hls.levels[o];if(!(c!=null&&c.textGroupIds))return;var d=c.textGroupIds[c.urlId];if(this.groupId!==d){var _=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,y=this.tracks.filter(function(x){return!d||x.groupId===d});this.tracksInGroup=y;var m=this.findTrackId(_==null?void 0:_.name)||this.findTrackId();this.groupId=d;var l={subtitleTracks:y};this.log("Updating subtitle tracks, "+y.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,l),m!==-1&&this.setSubtitleTrack(m,_)}},C.findTrackId=function(o){for(var c=this.tracksInGroup,d=0;d<c.length;d++){var _=c[d];if((!this.selectDefaultTrack||_.default)&&(!o||o===_.name))return _.id}return-1},C.onError=function(o,c){if(T.prototype.onError.call(this,o,c),c.fatal||!c.context)return;c.context.type===z.PlaylistContextType.SUBTITLE_TRACK&&c.context.id===this.trackId&&c.context.groupId===this.groupId&&this.retryLoadingOrFail(c)},C.loadPlaylist=function(o){var c=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(c)){var d=c.id,_=c.groupId,y=c.url;if(o)try{y=o.addDirectives(y)}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(X.Events.SUBTITLE_TRACK_LOADING,{url:y,id:d,groupId:_,deliveryDirectives:o||null})}},C.toggleTrackModes=function(o){var c=this,d=this.media,_=this.subtitleDisplay,y=this.trackId;if(!d)return;var m=k(d.textTracks),l=m.filter(function(p){return p.groupId===c.groupId});if(o===-1)[].slice.call(m).forEach(function(p){p.mode="disabled"});else{var x=l[y];x&&(x.mode="disabled")}var f=l[o];f&&(f.mode=_?"showing":"hidden")},C.setSubtitleTrack=function(o,c){var d,_=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(d=_[o])!==null&&d!==void 0&&d.details)||o<-1||o>=_.length)return;this.clearTimer();var y=_[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,y){var m=y.id,l=y.groupId,x=l===void 0?"":l,f=y.name,p=y.type,s=y.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:x,name:f,type:p,url:s});var a=this.switchParams(y.url,c==null?void 0:c.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,c=k(this.media.textTracks),d=0;d<c.length;d++)if(c[d].mode==="hidden")o=d;else if(c[d].mode==="showing"){o=d;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},O(A,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var c=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,c)}}]),A}(I.default);function k(T){for(var A=[],C=0;C<T.length;C++){var h=T[C];h.kind==="subtitles"&&h.label&&A.push(T[C])}return A}$.default=L},"./src/controller/timeline-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"TimelineController",function(){return k});var X=R("./src/polyfills/number.ts"),N=R("./src/events.ts"),I=R("./src/utils/cea-608-parser.ts"),z=R("./src/utils/output-filter.ts"),B=R("./src/utils/webvtt-parser.ts"),O=R("./src/utils/texttrack-utils.ts"),D=R("./src/utils/imsc1-ttml-parser.ts"),E=R("./src/types/loader.ts"),L=R("./src/utils/logger.ts"),k=function(){function h(c){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this.captionsProperties=void 0,this.hls=c,this.config=c.config,this.Cues=c.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var d=new z.default(this,"textTrack1"),_=new z.default(this,"textTrack2"),y=new z.default(this,"textTrack3"),m=new z.default(this,"textTrack4");this.cea608Parser1=new I.default(1,d,_),this.cea608Parser2=new I.default(3,y,m)}c.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),c.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),c.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(N.Events.FRAG_LOADING,this.onFragLoading,this),c.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),c.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),c.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),c.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),c.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=h.prototype;return o.destroy=function(){var d=this.hls;d.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(N.Events.FRAG_LOADING,this.onFragLoading,this),d.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(d,_,y,m,l){for(var x=!1,f=l.length;f--;){var p=l[f],s=A(p[0],p[1],_,y);if(s>=0&&(p[0]=Math.min(p[0],_),p[1]=Math.max(p[1],y),x=!0,s/(y-_)>.5))return}if(x||l.push([_,y]),this.config.renderTextTracksNatively){var a=this.captionsTracks[d];this.Cues.newCue(a,_,y,m)}else{var b=this.Cues.newCue(null,_,y,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:b,track:d})}},o.onInitPtsFound=function(d,_){var y=this,m=_.frag,l=_.id,x=_.initPTS,f=_.timescale,p=this.unparsedVttFrags;l==="main"&&(this.initPTS[m.cc]=x,this.timescale[m.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(s){y.onFragLoaded(N.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(d){var _=this.media;if(_)for(var y=0;y<_.textTracks.length;y++){var m=_.textTracks[y];if(m[d])return m}return null},o.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},o.createNativeTrack=function(d){if(this.captionsTracks[d])return;var _=this.captionsProperties,y=this.captionsTracks,m=this.media,l=_[d],x=l.label,f=l.languageCode,p=this.getExistingTrack(d);if(p)y[d]=p,Object(O.clearCurrentCues)(y[d]),Object(O.sendAddTrackEvent)(y[d],m);else{var s=this.createTextTrack("captions",x,f);s&&(s[d]=!0,y[d]=s)}},o.createNonNativeTrack=function(d){if(this.nonNativeCaptionsTracks[d])return;var _=this.captionsProperties[d];if(!_)return;var y=_.label,m={_id:d,label:y,kind:"captions",default:_.media?!!_.media.default:!1,closedCaptions:_.media};this.nonNativeCaptionsTracks[d]=m,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},o.createTextTrack=function(d,_,y){var m=this.media;return m?m.addTextTrack(d,_,y):void 0},o.onMediaAttaching=function(d,_){this.media=_.media,this._cleanTracks()},o.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(_){Object(O.clearCurrentCues)(d[_]),delete d[_]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=C(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var d=this.media;if(!d)return;var _=d.textTracks;if(_)for(var y=0;y<_.length;y++)Object(O.clearCurrentCues)(_[y])},o.onSubtitleTracksUpdated=function(d,_){var y=this;this.textTracks=[];var m=_.subtitleTracks||[],l=m.some(function(s){return s.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 f=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,a){var b;if(a<f.length){for(var v=null,S=0;S<f.length;S++)if(T(f[S],s)){v=f[S];break}v&&(b=v)}b?Object(O.clearCurrentCues)(b):(b=y.createTextTrack("subtitles",s.name,s.lang),b&&(b.mode="disabled")),b&&(b.groupId=s.groupId,y.textTracks.push(b))})}else if(!x&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(s){return{label:s.name,kind:s.type.toLowerCase(),default:s.default,subtitleTrack:s}});this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},o.onManifestLoaded=function(d,_){var y=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],f=y.captionsProperties[x];if(!f)return;f.label=m.name,m.lang&&(f.languageCode=m.lang),f.media=m})},o.onFragLoading=function(d,_){var y=this.cea608Parser1,m=this.cea608Parser2,l=this.lastSn,x=this.lastPartIndex;if(!this.enabled||!(y&&m))return;if(_.frag.type===E.PlaylistLevelType.MAIN){var f,p,s=_.frag.sn,a=(f=_==null||((p=_.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;s===l+1||s===l&&a===x+1||(y.reset(),m.reset()),this.lastSn=s,this.lastPartIndex=a}},o.onFragLoaded=function(d,_){var y=_.frag,m=_.payload,l=this.initPTS,x=this.unparsedVttFrags;if(y.type===E.PlaylistLevelType.SUBTITLE)if(m.byteLength){if(!Object(X.isFiniteNumber)(l[y.cc])){x.push(_),l.length&&this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Missing initial subtitle PTS")});return}var f=y.decryptdata;if(f==null||f.key==null||f.method!=="AES-128"){var p=this.tracks[y.level],s=this.vttCCs;s[y.cc]||(s[y.cc]={start:y.start,prevCC:this.prevCC,new:!0},this.prevCC=y.cc),p&&p.textCodec===D.IMSC1_CODEC?this._parseIMSC1(y,m):this._parseVTTs(y,m,s)}}else this.hls.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(d,_){var y=this,m=this.hls;Object(D.parseIMSC1)(_,this.initPTS[d.cc],this.timescale[d.cc],function(l){y._appendCues(l,d.level),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(l){L.logger.log("Failed to parse IMSC1: "+l),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:l})})},o._parseVTTs=function(d,_,y){var m=this,l=this.hls;Object(B.parseWebVTT)(_,this.initPTS[d.cc],this.timescale[d.cc],y,d.cc,d.start,function(x){m._appendCues(x,d.level),l.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(x){m._fallbackToIMSC1(d,_),L.logger.log("Failed to parse VTT cue: "+x),l.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:x})})},o._fallbackToIMSC1=function(d,_){var y=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,y._parseIMSC1(d,_)},function(){m.textCodec="wvtt"})},o._appendCues=function(d,_){var y=this.hls;if(this.config.renderTextTracksNatively){var m=this.textTracks[_];if(m.mode==="disabled")return;d.forEach(function(f){return Object(O.addCueToTrack)(m,f)})}else{var l=this.tracks[_],x=l.default?"default":"subtitles"+_;y.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:d,track:x})}},o.onFragDecrypted=function(d,_){var y=_.frag;if(y.type===E.PlaylistLevelType.SUBTITLE){if(!Object(X.isFiniteNumber)(this.initPTS[y.cc])){this.unparsedVttFrags.push(_);return}this.onFragLoaded(N.Events.FRAG_LOADED,_)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(d,_){var y=this.cea608Parser1,m=this.cea608Parser2;if(!this.enabled||!(y&&m))return;for(var l=0;l<_.samples.length;l++){var x=_.samples[l].bytes;if(x){var f=this.extractCea608Data(x);y.addData(_.samples[l].pts,f[0]),m.addData(_.samples[l].pts,f[1])}}},o.onBufferFlushing=function(d,_){var y=_.startOffset,m=_.endOffset,l=_.endOffsetSubtitles,x=_.type,f=this.media;if(!f||f.currentTime<m)return;if(!x||x==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(a){return Object(O.removeCuesInRange)(p[a],y,m)})}if(this.config.renderTextTracksNatively&&(y===0&&l!==void 0)){var s=this.textTracks;Object.keys(s).forEach(function(a){return Object(O.removeCuesInRange)(s[a],y,l)})}},o.extractCea608Data=function(d){for(var _=d[0]&31,y=2,m=[[],[]],l=0;l<_;l++){var x=d[y++],f=127&d[y++],p=127&d[y++],s=(4&x)!==0,a=3&x;if(f===0&&p===0)continue;s&&((a===0||a===1)&&(m[a].push(f),m[a].push(p)))}return m},h}();function T(h,o){return h&&h.label===o.name&&!(h.textTrack1||h.textTrack2)}function A(h,o,c,d){return Math.min(o,d)-Math.max(h,c)}function C(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return X});var X=function(){function N(z,B){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=B}var I=N.prototype;return I.decrypt=function(B,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,B)},N}()},"./src/crypt/aes-decryptor.ts":function(ae,$,R){"use strict";R.r($),R.d($,"removePadding",function(){return N}),R.d($,"default",function(){return I});var X=R("./src/utils/typed-array.ts");function N(z){var B=z.byteLength,O=B&&new DataView(z.buffer).getUint8(B-1);return O?Object(X.sliceUint8)(z,0,B-O):z}var I=function(){function z(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var B=z.prototype;return B.uint8ArrayToUint32Array_=function(D){for(var E=new DataView(D),L=new Uint32Array(4),k=0;k<4;k++)L[k]=E.getUint32(k*4);return L},B.initTable=function(){var D=this.sBox,E=this.invSBox,L=this.subMix,k=L[0],T=L[1],A=L[2],C=L[3],h=this.invSubMix,o=h[0],c=h[1],d=h[2],_=h[3],y=new Uint32Array(256),m=0,l=0,x=0;for(x=0;x<256;x++)x<128?y[x]=x<<1:y[x]=x<<1^283;for(x=0;x<256;x++){var f=l^l<<1^l<<2^l<<3^l<<4;f=f>>>8^f&255^99,D[m]=f,E[f]=m;var p=y[m],s=y[p],a=y[s],b=y[f]*257^f*16843008;k[m]=b<<24|b>>>8,T[m]=b<<16|b>>>16,A[m]=b<<8|b>>>24,C[m]=b,b=a*16843009^s*65537^p*257^m*16843008,o[f]=b<<24|b>>>8,c[f]=b<<16|b>>>16,d[f]=b<<8|b>>>24,_[f]=b,m?(m=p^y[y[y[a^p]]],l^=y[y[l]]):m=l=1}},B.expandKey=function(D){for(var E=this.uint8ArrayToUint32Array_(D),L=!0,k=0;k<E.length&&L;)L=E[k]===this.key[k],k++;if(L)return;this.key=E;var T=this.keySize=E.length;if(T!==4&&T!==6&&T!==8)throw new Error("Invalid aes key size="+T);var A=this.ksRows=(T+6+1)*4,C,h,o=this.keySchedule=new Uint32Array(A),c=this.invKeySchedule=new Uint32Array(A),d=this.sBox,_=this.rcon,y=this.invSubMix,m=y[0],l=y[1],x=y[2],f=y[3],p,s;for(C=0;C<A;C++){if(C<T){p=o[C]=E[C];continue}s=p,C%T===0?(s=s<<8|s>>>24,s=d[s>>>24]<<24|d[s>>>16&255]<<16|d[s>>>8&255]<<8|d[s&255],s^=_[C/T|0]<<24):T>6&&C%T===4&&(s=d[s>>>24]<<24|d[s>>>16&255]<<16|d[s>>>8&255]<<8|d[s&255]),o[C]=p=(o[C-T]^s)>>>0}for(h=0;h<A;h++)C=A-h,h&3?s=o[C]:s=o[C-4],h<4||C<=4?c[h]=s:c[h]=m[d[s>>>24]]^l[d[s>>>16&255]]^x[d[s>>>8&255]]^f[d[s&255]],c[h]=c[h]>>>0},B.networkToHostOrderSwap=function(D){return D<<24|(D&65280)<<8|(D&16711680)>>8|D>>>24},B.decrypt=function(D,E,L){for(var k=this.keySize+6,T=this.invKeySchedule,A=this.invSBox,C=this.invSubMix,h=C[0],o=C[1],c=C[2],d=C[3],_=this.uint8ArrayToUint32Array_(L),y=_[0],m=_[1],l=_[2],x=_[3],f=new Int32Array(D),p=new Int32Array(f.length),s,a,b,v,S,M,H,V,Q,G,W,q,oe,fe,ve=this.networkToHostOrderSwap;E<f.length;){for(Q=ve(f[E]),G=ve(f[E+1]),W=ve(f[E+2]),q=ve(f[E+3]),S=Q^T[0],M=q^T[1],H=W^T[2],V=G^T[3],oe=4,fe=1;fe<k;fe++)s=h[S>>>24]^o[M>>16&255]^c[H>>8&255]^d[V&255]^T[oe],a=h[M>>>24]^o[H>>16&255]^c[V>>8&255]^d[S&255]^T[oe+1],b=h[H>>>24]^o[V>>16&255]^c[S>>8&255]^d[M&255]^T[oe+2],v=h[V>>>24]^o[S>>16&255]^c[M>>8&255]^d[H&255]^T[oe+3],S=s,M=a,H=b,V=v,oe=oe+4;s=A[S>>>24]<<24^A[M>>16&255]<<16^A[H>>8&255]<<8^A[V&255]^T[oe],a=A[M>>>24]<<24^A[H>>16&255]<<16^A[V>>8&255]<<8^A[S&255]^T[oe+1],b=A[H>>>24]<<24^A[V>>16&255]<<16^A[S>>8&255]<<8^A[M&255]^T[oe+2],v=A[V>>>24]<<24^A[S>>16&255]<<16^A[M>>8&255]<<8^A[H&255]^T[oe+3],p[E]=ve(s^y),p[E+1]=ve(v^m),p[E+2]=ve(b^l),p[E+3]=ve(a^x),y=Q,m=G,l=W,x=q,E=E+4}return p.buffer},z}()},"./src/crypt/decrypter.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return E});var X=R("./src/crypt/aes-crypto.ts"),N=R("./src/crypt/fast-aes-key.ts"),I=R("./src/crypt/aes-decryptor.ts"),z=R("./src/utils/logger.ts"),B=R("./src/utils/mp4-tools.ts"),O=R("./src/utils/typed-array.ts"),D=16,E=function(){function L(T,A,C){var h=C===void 0?{}:C,o=h.removePKCS7Padding,c=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=T,this.config=A,this.removePKCS7Padding=c,c)try{var d=self.crypto;d&&(this.subtle=d.subtle||d.webkitSubtle)}catch(_){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var k=L.prototype;return k.destroy=function(){this.observer=null},k.isSync=function(){return this.config.enableSoftwareAES},k.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var C=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(I.removePadding)(C):C},k.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},k.decrypt=function(A,C,h,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),C,h);var c=this.flush();c&&o(c.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),C,h).then(o)},k.softwareDecrypt=function(A,C,h){var o=this.currentIV,c=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(A=Object(B.appendUint8Array)(d,A),this.remainderData=null);var _=this.getValidChunk(A);if(!_.length)return null;o&&(h=o);var y=this.softwareDecrypter;y||(y=this.softwareDecrypter=new I.default),y.expandKey(C);var m=c;return this.currentResult=y.decrypt(_.buffer,0,h),this.currentIV=Object(O.sliceUint8)(_,-16).buffer,m||null},k.webCryptoDecrypt=function(A,C,h){var o=this,c=this.subtle;return(this.key!==C||!this.fastAesKey)&&(this.key=C,this.fastAesKey=new N.default(c,C)),this.fastAesKey.expandKey().then(function(d){if(!c)return Promise.reject(new Error("web crypto not initialized"));var _=new X.default(c,h);return _.decrypt(A.buffer,d)}).catch(function(d){return o.onWebCryptoError(d,A,C,h)})},k.onWebCryptoError=function(A,C,h,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(C,h,o)},k.getValidChunk=function(A){var C=A,h=A.length-A.length%D;return h!==A.length&&(C=Object(O.sliceUint8)(A,0,h),this.remainderData=Object(O.sliceUint8)(A,h)),C},k.logOnce=function(A){if(!this.logEnabled)return;z.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1},L}()},"./src/crypt/fast-aes-key.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return X});var X=function(){function N(z,B){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=B}var I=N.prototype;return I.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},N}()},"./src/demux/aacdemuxer.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/demux/base-audio-demuxer.ts"),N=R("./src/demux/adts.ts"),I=R("./src/utils/logger.ts"),z=R("./src/demux/id3.ts");function B(E,L){E.prototype=Object.create(L.prototype),E.prototype.constructor=E,O(E,L)}function O(E,L){return O=Object.setPrototypeOf||function(T,A){return T.__proto__=A,T},O(E,L)}var D=function(E){B(L,E);function L(T,A){var C;return C=E.call(this)||this,C.observer=void 0,C.config=void 0,C.observer=T,C.config=A,C}var k=L.prototype;return k.resetInitSegment=function(A,C,h){E.prototype.resetInitSegment.call(this,A,C,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:A,duration:h,inputTimeScale:9e4,dropped:0}},L.probe=function(A){if(!A)return!1;for(var C=z.getID3Data(A,0)||[],h=C.length,o=A.length;h<o;h++)if(N.probe(A,h))return I.logger.log("ADTS sync word found !"),!0;return!1},k.canParse=function(A,C){return N.canParse(A,C)},k.appendFrame=function(A,C,h){N.initTrackConfig(A,this.observer,C,h,A.manifestCodec);var o=N.appendFrame(A,C,h,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},L}(X.default);D.minProbeByteLength=9,$.default=D},"./src/demux/adts.ts":function(ae,$,R){"use strict";R.r($),R.d($,"getAudioConfig",function(){return z}),R.d($,"isHeaderPattern",function(){return B}),R.d($,"getHeaderLength",function(){return O}),R.d($,"getFullFrameLength",function(){return D}),R.d($,"canGetFrameLength",function(){return E}),R.d($,"isHeader",function(){return L}),R.d($,"canParse",function(){return k}),R.d($,"probe",function(){return T}),R.d($,"initTrackConfig",function(){return A}),R.d($,"getFrameDuration",function(){return C}),R.d($,"parseFrameHeader",function(){return h}),R.d($,"appendFrame",function(){return o});var X=R("./src/utils/logger.ts"),N=R("./src/errors.ts"),I=R("./src/events.ts");function z(c,d,_,y){var m,l,x,f,p=navigator.userAgent.toLowerCase(),s=y,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((d[_+2]&192)>>>6)+1;var b=(d[_+2]&60)>>>2;if(b>a.length-1){c.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b});return}return x=(d[_+2]&1)<<2,x|=(d[_+3]&192)>>>6,X.logger.log("manifest codec:"+y+", ADTS type:"+m+", samplingIndex:"+b),/firefox/i.test(p)?b>=6?(m=5,f=new Array(4),l=b-3):(m=2,f=new Array(2),l=b):p.indexOf("android")!==-1?(m=2,f=new Array(2),l=b):(m=5,f=new Array(4),y&&(y.indexOf("mp4a.40.29")!==-1||y.indexOf("mp4a.40.5")!==-1)||!y&&b>=6?l=b-3:((y&&y.indexOf("mp4a.40.2")!==-1&&(b>=6&&x===1||/vivaldi/i.test(p))||!y&&x===1)&&(m=2,f=new Array(2)),l=b)),f[0]=m<<3,f[0]|=(b&14)>>1,f[1]|=(b&1)<<7,f[1]|=x<<3,m===5&&(f[1]|=(l&14)>>1,f[2]=(l&1)<<7,f[2]|=2<<2,f[3]=0),{config:f,samplerate:a[b],channelCount:x,codec:"mp4a.40."+m,manifestCodec:s}}function B(c,d){return c[d]===255&&(c[d+1]&246)===240}function O(c,d){return c[d+1]&1?7:9}function D(c,d){return(c[d+3]&3)<<11|c[d+4]<<3|(c[d+5]&224)>>>5}function E(c,d){return d+5<c.length}function L(c,d){return d+1<c.length&&B(c,d)}function k(c,d){return E(c,d)&&B(c,d)&&D(c,d)<=c.length-d}function T(c,d){if(L(c,d)){var _=O(c,d);if(d+_>=c.length)return!1;var y=D(c,d);if(y<=_)return!1;var m=d+y;return m===c.length||L(c,m)}return!1}function A(c,d,_,y,m){if(!c.samplerate){var l=z(d,_,y,m);if(!l)return;c.config=l.config,c.samplerate=l.samplerate,c.channelCount=l.channelCount,c.codec=l.codec,c.manifestCodec=l.manifestCodec,X.logger.log("parsed codec:"+c.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function C(c){return 1024*9e4/c}function h(c,d,_,y,m){var l=O(c,d),x=D(c,d);if(x-=l,x>0){var f=_+y*m;return{headerLength:l,frameLength:x,stamp:f}}}function o(c,d,_,y,m){var l=C(c.samplerate),x=h(d,_,y,m,l);if(x){var f=x.frameLength,p=x.headerLength,s=x.stamp,a=p+f,b=Math.max(0,_+a-d.length),v;b?(v=new Uint8Array(a-p),v.set(d.subarray(_+p,d.length),0)):v=d.subarray(_+p,_+a);var S={unit:v,pts:s};return b||c.samples.push(S),{sample:S,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"initPTSFn",function(){return D});var X=R("./src/polyfills/number.ts"),N=R("./src/demux/id3.ts"),I=R("./src/demux/dummy-demuxed-track.ts"),z=R("./src/utils/mp4-tools.ts"),B=R("./src/utils/typed-array.ts"),O=function(){function E(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var L=E.prototype;return L.resetInitSegment=function(T,A,C){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},L.resetTimeStamp=function(){},L.resetContiguity=function(){},L.canParse=function(T,A){return!1},L.appendFrame=function(T,A,C){},L.demux=function(T,A){this.cachedData&&(T=Object(z.appendUint8Array)(this.cachedData,T),this.cachedData=null);var C=N.getID3Data(T,0),h=C?C.length:0,o,c,d=this._audioTrack,_=this._id3Track,y=C?N.getTimeStamp(C):void 0,m=T.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=D(y,A)),C&&C.length>0&&_.samples.push({pts:this.initPTS,dts:this.initPTS,data:C}),c=this.initPTS;h<m;){if(this.canParse(T,h)){var l=this.appendFrame(d,T,h);l?(this.frameIndex++,c=l.sample.pts,h+=l.length,o=h):h=m}else N.canParse(T,h)?(C=N.getID3Data(T,h),_.samples.push({pts:c,dts:c,data:C}),h+=C.length,o=h):h++;if(h===m&&o!==m){var x=Object(B.sliceUint8)(T,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,x):this.cachedData=x}}return{audioTrack:d,avcTrack:Object(I.dummyTrack)(),id3Track:_,textTrack:Object(I.dummyTrack)()}},L.demuxSampleAes=function(T,A,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},L.flush=function(T){var A=this.cachedData;return A&&(this.cachedData=null,this.demux(A,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},L.destroy=function(){},E}(),D=function(L,k){return Object(X.isFiniteNumber)(L)?L*90:k*9e4};$.default=O},"./src/demux/chunk-cache.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return X});var X=function(){function I(){this.chunks=[],this.dataLength=0}var z=I.prototype;return z.push=function(O){this.chunks.push(O),this.dataLength+=O.length},z.flush=function(){var O=this.chunks,D=this.dataLength,E;if(O.length)O.length===1?E=O[0]:E=N(O,D);else return new Uint8Array(0);return this.reset(),E},z.reset=function(){this.chunks.length=0,this.dataLength=0},I}();function N(I,z){for(var B=new Uint8Array(z),O=0,D=0;D<I.length;D++){var E=I[D];B.set(E,O),O+=E.length}return B}},"./src/demux/dummy-demuxed-track.ts":function(ae,$,R){"use strict";R.r($),R.d($,"dummyTrack",function(){return X});function X(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/logger.ts"),N=function(){function I(B){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=B,this.bytesAvailable=B.byteLength,this.word=0,this.bitsAvailable=0}var z=I.prototype;return z.loadWord=function(){var O=this.data,D=this.bytesAvailable,E=O.byteLength-D,L=new Uint8Array(4),k=Math.min(4,D);if(k===0)throw new Error("no bytes available");L.set(O.subarray(E,E+k)),this.word=new DataView(L.buffer).getUint32(0),this.bitsAvailable=k*8,this.bytesAvailable-=k},z.skipBits=function(O){var D;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,D=O>>3,O-=D>>3,this.bytesAvailable-=D,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},z.readBits=function(O){var D=Math.min(this.bitsAvailable,O),E=this.word>>>32-D;return O>32&&X.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=O-D,D>0&&this.bitsAvailable?E<<D|this.readBits(D):E},z.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},z.skipUEG=function(){this.skipBits(1+this.skipLZ())},z.skipEG=function(){this.skipBits(1+this.skipLZ())},z.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},z.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},z.readBoolean=function(){return this.readBits(1)===1},z.readUByte=function(){return this.readBits(8)},z.readUShort=function(){return this.readBits(16)},z.readUInt=function(){return this.readBits(32)},z.skipScalingList=function(O){for(var D=8,E=8,L,k=0;k<O;k++)E!==0&&(L=this.readEG(),E=(D+L+256)%256),D=E===0?D:E},z.readSPS=function(){var O=0,D=0,E=0,L=0,k,T,A,C=this.readUByte.bind(this),h=this.readBits.bind(this),o=this.readUEG.bind(this),c=this.readBoolean.bind(this),d=this.skipBits.bind(this),_=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);C();var l=C();if(h(5),d(3),C(),y(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var x=o();if(x===3&&d(1),y(),y(),d(1),c())for(T=x!==3?8:12,A=0;A<T;A++)c()&&(A<6?m(16):m(64))}y();var f=o();if(f===0)o();else if(f===1)for(d(1),_(),_(),k=o(),A=0;A<k;A++)_();y(),d(1);var p=o(),s=o(),a=h(1);a===0&&d(1),d(1),c()&&(O=o(),D=o(),E=o(),L=o());var b=[1,1];if(c()&&c()){var v=C();switch(v){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[C()<<8|C(),C()<<8|C()];break}}}return{width:Math.ceil((p+1)*16-O*2-D*2),height:(2-a)*(s+1)*16-(a?2:4)*(E+L),pixelRatio:b}},z.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},I}();$.default=N},"./src/demux/id3.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isHeader",function(){return X}),R.d($,"isFooter",function(){return N}),R.d($,"getID3Data",function(){return I}),R.d($,"canParse",function(){return B}),R.d($,"getTimeStamp",function(){return O}),R.d($,"isTimeStampFrame",function(){return D}),R.d($,"getID3Frames",function(){return L}),R.d($,"decodeFrame",function(){return k}),R.d($,"utf8ArrayToStr",function(){return o}),R.d($,"testables",function(){return c});var X=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)))},N=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)))},I=function(m,l){for(var x=l,f=0;X(m,l);){f+=10;var p=z(m,l+6);f+=p,N(m,l+10)&&(f+=10),l+=f}return f>0?m.subarray(x,x+f):void 0},z=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},B=function(m,l){return X(m,l)&&z(m,l+6)+10<=m.length-l},O=function(m){for(var l=L(m),x=0;x<l.length;x++){var f=l[x];if(D(f))return h(f)}return},D=function(m){return m&&m.key==="PRIV"&&m.info==="com.apple.streaming.transportStreamTimestamp"},E=function(m){var l=String.fromCharCode(m[0],m[1],m[2],m[3]),x=z(m,4),f=10;return{type:l,size:x,data:m.subarray(f,f+x)}},L=function(m){for(var l=0,x=[];X(m,l);){var f=z(m,l+6);l+=10;for(var p=l+f;l+8<p;){var s=E(m.subarray(l)),a=k(s);a&&x.push(a),l+=s.size+10}N(m,l)&&(l+=10)}return x},k=function(m){return m.type==="PRIV"?T(m):m.type[0]==="W"?C(m):A(m)},T=function(m){if(m.size<2)return;var l=o(m.data,!0),x=new Uint8Array(m.data.subarray(l.length+1));return{key:m.type,info:l,data:x.buffer}},A=function(m){if(m.size<2)return;if(m.type==="TXXX"){var l=1,x=o(m.data.subarray(l),!0);l+=x.length+1;var f=o(m.data.subarray(l));return{key:m.type,info:x,data:f}}var p=o(m.data.subarray(1));return{key:m.type,data:p}},C=function(m){if(m.type==="WXXX"){if(m.size<2)return;var l=1,x=o(m.data.subarray(l),!0);l+=x.length+1;var f=o(m.data.subarray(l));return{key:m.type,info:x,data:f}}var p=o(m.data);return{key:m.type,data:p}},h=function(m){if(m.data.byteLength===8){var l=new Uint8Array(m.data),x=l[3]&1,f=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return f/=45,x&&(f+=4772185884e-2),Math.round(f)}return},o=function(m,l){l===void 0&&(l=!1);var x=_();if(x){var f=x.decode(m);if(l){var p=f.indexOf("\0");return p!==-1?f.substring(0,p):f}return f.replace(/\0/g,"")}for(var s=m.length,a,b,v,S="",M=0;M<s;){if(a=m[M++],a===0&&l)return S;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:b=m[M++],S+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=m[M++],v=m[M++],S+=String.fromCharCode((a&15)<<12|(b&63)<<6|(v&63)<<0);break;default:}}return S},c={decodeTextFrame:A},d;function _(){return!d&&typeof self.TextDecoder!="undefined"&&(d=new self.TextDecoder("utf-8")),d}},"./src/demux/mp3demuxer.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/demux/base-audio-demuxer.ts"),N=R("./src/demux/id3.ts"),I=R("./src/utils/logger.ts"),z=R("./src/demux/mpegaudio.ts");function B(E,L){E.prototype=Object.create(L.prototype),E.prototype.constructor=E,O(E,L)}function O(E,L){return O=Object.setPrototypeOf||function(T,A){return T.__proto__=A,T},O(E,L)}var D=function(E){B(L,E);function L(){return E.apply(this,arguments)||this}var k=L.prototype;return k.resetInitSegment=function(A,C,h){E.prototype.resetInitSegment.call(this,A,C,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:A,duration:h,inputTimeScale:9e4,dropped:0}},L.probe=function(A){if(!A)return!1;for(var C=N.getID3Data(A,0)||[],h=C.length,o=A.length;h<o;h++)if(z.probe(A,h))return I.logger.log("MPEG Audio sync word found !"),!0;return!1},k.canParse=function(A,C){return z.canParse(A,C)},k.appendFrame=function(A,C,h){return this.initPTS===null?void 0:z.appendFrame(A,C,h,this.initPTS,this.frameIndex)},L}(X.default);D.minProbeByteLength=4,$.default=D},"./src/demux/mp4demuxer.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/mp4-tools.ts"),N=R("./src/demux/dummy-demuxed-track.ts"),I=function(){function z(O,D){this.remainderData=null,this.config=void 0,this.config=D}var B=z.prototype;return B.resetTimeStamp=function(){},B.resetInitSegment=function(){},B.resetContiguity=function(){},z.probe=function(D){return Object(X.findBox)({data:D,start:0,end:Math.min(D.length,16384)},["moof"]).length>0},B.demux=function(D){var E=D,L=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(E=Object(X.appendUint8Array)(this.remainderData,D));var k=Object(X.segmentValidRange)(E);this.remainderData=k.remainder,L.samples=k.valid||new Uint8Array}else L.samples=E;return{audioTrack:Object(N.dummyTrack)(),avcTrack:L,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},B.flush=function(){var D=Object(N.dummyTrack)();return D.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:D,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},B.demuxSampleAes=function(D,E,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},B.destroy=function(){},z}();I.minProbeByteLength=1024,$.default=I},"./src/demux/mpegaudio.ts":function(ae,$,R){"use strict";R.r($),R.d($,"appendFrame",function(){return O}),R.d($,"parseHeader",function(){return D}),R.d($,"isHeaderPattern",function(){return E}),R.d($,"isHeader",function(){return L}),R.d($,"canParse",function(){return k}),R.d($,"probe",function(){return T});var X=null,N=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],I=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],z=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],B=[0,1,1,4];function O(A,C,h,o,c){if(h+24>C.length)return;var d=D(C,h);if(d&&h+d.frameLength<=C.length){var _=d.samplesPerFrame*9e4/d.sampleRate,y=o+c*_,m={unit:C.subarray(h,h+d.frameLength),pts:y,dts:y};return A.config=[],A.channelCount=d.channelCount,A.samplerate=d.sampleRate,A.samples.push(m),{sample:m,length:d.frameLength,missing:0}}}function D(A,C){var h=A[C+1]>>3&3,o=A[C+1]>>1&3,c=A[C+2]>>4&15,d=A[C+2]>>2&3;if(h!==1&&c!==0&&c!==15&&d!==3){var _=A[C+2]>>1&1,y=A[C+3]>>6,m=h===3?3-o:o===3?3:4,l=N[m*14+c-1]*1e3,x=h===3?0:h===2?1:2,f=I[x*3+d],p=y===3?1:2,s=z[h][o],a=B[o],b=s*8*a,v=Math.floor(s*l/f+_)*a;if(X===null){var S=navigator.userAgent||"",M=S.match(/Chrome\/(\d+)/i);X=M?parseInt(M[1]):0}var H=!!X&&X<=87;return H&&o===2&&l>=224e3&&y===0&&(A[C+3]=A[C+3]|128),{sampleRate:f,channelCount:p,frameLength:v,samplesPerFrame:b}}}function E(A,C){return A[C]===255&&(A[C+1]&224)===224&&(A[C+1]&6)!==0}function L(A,C){return C+1<A.length&&E(A,C)}function k(A,C){var h=4;return E(A,C)&&h<=A.length-C}function T(A,C){if(C+1<A.length&&E(A,C)){var h=4,o=D(A,C),c=h;o!=null&&o.frameLength&&(c=o.frameLength);var d=C+c;return d===A.length||L(A,d)}return!1}},"./src/demux/sample-aes.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/crypt/decrypter.ts"),N=R("./src/demux/tsdemuxer.ts"),I=function(){function z(O,D,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new X.default(O,D,{removePKCS7Padding:!1})}var B=z.prototype;return B.decryptBuffer=function(D,E){this.decrypter.decrypt(D,this.keyData.key.buffer,this.keyData.iv.buffer,E)},B.decryptAacSample=function(D,E,L,k){var T=D[E].unit,A=T.subarray(16,T.length-T.length%16),C=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),h=this;this.decryptBuffer(C,function(o){var c=new Uint8Array(o);T.set(c,16),k||h.decryptAacSamples(D,E+1,L)})},B.decryptAacSamples=function(D,E,L){for(;;E++){if(E>=D.length){L();return}if(D[E].unit.length<32)continue;var k=this.decrypter.isSync();if(this.decryptAacSample(D,E,L,k),!k)return}},B.getAvcEncryptedData=function(D){for(var E=Math.floor((D.length-48)/160)*16+16,L=new Int8Array(E),k=0,T=32;T<=D.length-16;T+=160,k+=16)L.set(D.subarray(T,T+16),k);return L},B.getAvcDecryptedUnit=function(D,E){for(var L=new Uint8Array(E),k=0,T=32;T<=D.length-16;T+=160,k+=16)D.set(L.subarray(k,k+16),T);return D},B.decryptAvcSample=function(D,E,L,k,T,A){var C=Object(N.discardEPB)(T.data),h=this.getAvcEncryptedData(C),o=this;this.decryptBuffer(h.buffer,function(c){T.data=o.getAvcDecryptedUnit(C,c),A||o.decryptAvcSamples(D,E,L+1,k)})},B.decryptAvcSamples=function(D,E,L,k){if(D instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,L=0){if(E>=D.length){k();return}for(var T=D[E].units;!(L>=T.length);L++){var A=T[L];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var C=this.decrypter.isSync();if(this.decryptAvcSample(D,E,L,k,A,C),!C)return}}},z}();$.default=I},"./src/demux/transmuxer-interface.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T});var X=R("./node_modules/webworkify-webpack/index.js"),N=R.n(X),I=R("./src/events.ts"),z=R("./src/demux/transmuxer.ts"),B=R("./src/utils/logger.ts"),O=R("./src/errors.ts"),D=R("./src/utils/mediasource-helper.ts"),E=R("./node_modules/eventemitter3/index.js"),L=R.n(E),k=Object(D.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function A(h,o,c,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=h,this.id=o,this.onTransmuxComplete=c,this.onFlush=d;var y=h.config,m=function(s,a){a=a||{},a.frag=_.frag,a.id=_.id,h.trigger(s,a)};this.observer=new E.EventEmitter,this.observer.on(I.Events.FRAG_DECRYPTED,m),this.observer.on(I.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(y.enableWorker&&typeof Worker!="undefined"){B.logger.log("demuxing in webworker");var f;try{f=this.worker=X("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),f.addEventListener("message",this.onwmsg),f.onerror=function(p){h.trigger(I.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},f.postMessage({cmd:"init",typeSupported:l,vendor:x,id:o,config:JSON.stringify(y)})}catch(p){B.logger.warn("Error in worker:",p),B.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new z.default(this.observer,l,y,x,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,l,y,x,o)}var C=A.prototype;return C.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var c=this.transmuxer;c&&(c.destroy(),this.transmuxer=null)}var d=this.observer;d&&d.removeAllListeners(),this.observer=null},C.push=function(o,c,d,_,y,m,l,x,f,p){var s=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,v=m?m.start:y.start,S=y.decryptdata,M=this.frag,H=!(M&&y.cc===M.cc),V=!(M&&f.level===M.level),Q=M?f.sn-M.sn:-1,G=this.part?f.part-this.part.index:1,W=!V&&(Q===1||Q===0&&G===1),q=self.performance.now();(V||Q||y.stats.parsing.start===0)&&(y.stats.parsing.start=q),m&&(G||!W)&&(m.stats.parsing.start=q);var oe=new z.TransmuxState(H,W,x,V,v);if(!W||H){B.logger.log("[transmuxer-interface, "+y.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
|
discontinuity: `+H+`
|
|
trackSwitch: `+V+`
|
|
contiguous: `+W+`
|
|
accurateTimeOffset: `+x+`
|
|
timeOffset: `+v);var fe=new z.TransmuxConfig(d,_,c,l,p);this.configureTransmuxer(fe)}if(this.frag=y,this.part=m,b)b.postMessage({cmd:"demux",data:o,decryptdata:S,chunkMeta:f,state:oe},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,S,f,oe);Object(z.isPromise)(ve)?ve.then(function(De){s.handleTransmuxComplete(De)}):this.handleTransmuxComplete(ve)}},C.flush=function(o){var c=this;o.transmuxing.start=self.performance.now();var d=this.transmuxer,_=this.worker;if(_)_.postMessage({cmd:"flush",chunkMeta:o});else if(d){var y=d.flush(o);Object(z.isPromise)(y)?y.then(function(m){c.handleFlushResult(m,o)}):this.handleFlushResult(y,o)}},C.handleFlushResult=function(o,c){var d=this;o.forEach(function(_){d.handleTransmuxComplete(_)}),this.onFlush(c)},C.onWorkerMessage=function(o){var c=o.data,d=this.hls;switch(c.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(c.data);break}case"flush":{this.onFlush(c.data);break}default:{c.data=c.data||{},c.data.frag=this.frag,c.data.id=this.id,d.trigger(c.event,c.data);break}}},C.configureTransmuxer=function(o){var c=this.worker,d=this.transmuxer;c?c.postMessage({cmd:"configure",config:o}):d&&d.configure(o)},C.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},A}()},"./src/demux/transmuxer-worker.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return O});var X=R("./src/demux/transmuxer.ts"),N=R("./src/events.ts"),I=R("./src/utils/logger.ts"),z=R("./node_modules/eventemitter3/index.js"),B=R.n(z);function O(T){var A=new z.EventEmitter,C=function(o,c){T.postMessage({event:o,data:c})};A.on(N.Events.FRAG_DECRYPTED,C),A.on(N.Events.ERROR,C),T.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var c=JSON.parse(o.config);T.transmuxer=new X.default(A,o.typeSupported,c,o.vendor,o.id),Object(I.enableLogs)(c.debug),C("init",null);break}case"configure":{T.transmuxer.configure(o.config);break}case"demux":{var d=T.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(d)?d.then(function(m){D(T,m)}):D(T,d);break}case"flush":{var _=o.chunkMeta,y=T.transmuxer.flush(_);Object(X.isPromise)(y)?y.then(function(m){L(T,m,_)}):L(T,y,_);break}default:break}})}function D(T,A){if(k(A.remuxResult))return;var C=[],h=A.remuxResult,o=h.audio,c=h.video;o&&E(C,o),c&&E(C,c),T.postMessage({event:"transmuxComplete",data:A},C)}function E(T,A){A.data1&&T.push(A.data1.buffer),A.data2&&T.push(A.data2.buffer)}function L(T,A,C){A.forEach(function(h){D(T,h)}),T.postMessage({event:"flush",data:C})}function k(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return c}),R.d($,"isPromise",function(){return y}),R.d($,"TransmuxConfig",function(){return m}),R.d($,"TransmuxState",function(){return l});var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/crypt/decrypter.ts"),z=R("./src/demux/aacdemuxer.ts"),B=R("./src/demux/mp4demuxer.ts"),O=R("./src/demux/tsdemuxer.ts"),D=R("./src/demux/mp3demuxer.ts"),E=R("./src/remux/mp4-remuxer.ts"),L=R("./src/remux/passthrough-remuxer.ts"),k=R("./src/demux/chunk-cache.ts"),T=R("./src/utils/mp4-tools.ts"),A=R("./src/utils/logger.ts"),C;try{C=self.performance.now.bind(self.performance)}catch(x){A.logger.debug("Unable to use Performance API on this environment"),C=self.Date.now}var h=[{demux:O.default,remux:E.default},{demux:B.default,remux:L.default},{demux:z.default,remux:E.default},{demux:D.default,remux:E.default}],o=1024;h.forEach(function(x){var f=x.demux;o=Math.max(o,f.minProbeByteLength)});var c=function(){function x(p,s,a,b,v){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new k.default,this.observer=p,this.typeSupported=s,this.config=a,this.vendor=b,this.id=v}var f=x.prototype;return f.configure=function(s){this.transmuxConfig=s,this.decrypter&&this.decrypter.reset()},f.push=function(s,a,b,v){var S=this,M=b.transmuxing;M.executeStart=C();var H=new Uint8Array(s),V=this.cache,Q=this.config,G=this.currentTransmuxState,W=this.transmuxConfig;v&&(this.currentTransmuxState=v);var q=d(H,a);if(q&&q.method==="AES-128"){var oe=this.getDecrypter();if(Q.enableSoftwareAES){var fe=oe.softwareDecrypt(H,q.key.buffer,q.iv.buffer);if(!fe)return M.executeEnd=C(),_(b);H=new Uint8Array(fe)}else return this.decryptionPromise=oe.webCryptoDecrypt(H,q.key.buffer,q.iv.buffer).then(function(Me){var ze=S.push(Me,null,b);return S.decryptionPromise=null,ze}),this.decryptionPromise}var ve=v||G,De=ve.contiguous,Ee=ve.discontinuity,_e=ve.trackSwitch,Te=ve.accurateTimeOffset,Ce=ve.timeOffset,me=W.audioCodec,ne=W.videoCodec,Ae=W.defaultInitPts,rt=W.duration,$e=W.initSegmentData;if((Ee||_e)&&this.resetInitSegment($e,me,ne,rt),Ee&&this.resetInitialTimestamp(Ae),De||this.resetContiguity(),this.needsProbing(H,Ee,_e)){if(V.dataLength){var Xe=V.flush();H=Object(T.appendUint8Array)(Xe,H)}this.configureTransmuxer(H,W)}var Ve=this.transmux(H,q,Ce,Te,b),Le=this.currentTransmuxState;return Le.contiguous=!0,Le.discontinuity=!1,Le.trackSwitch=!1,M.executeEnd=C(),Ve},f.flush=function(s){var a=this,b=s.transmuxing;b.executeStart=C();var v=this.decrypter,S=this.cache,M=this.currentTransmuxState,H=this.decryptionPromise;if(H)return H.then(function(){return a.flush(s)});var V=[],Q=M.timeOffset;if(v){var G=v.flush();G&&V.push(this.push(G,null,s))}var W=S.dataLength;S.reset();var q=this.demuxer,oe=this.remuxer;if(!q||!oe)return W>=o&&this.observer.emit(X.Events.ERROR,X.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),b.executeEnd=C(),[_(s)];var fe=q.flush(Q);return y(fe)?fe.then(function(ve){return a.flushRemux(V,ve,s),V}):(this.flushRemux(V,fe,s),V)},f.flushRemux=function(s,a,b){var v=a.audioTrack,S=a.avcTrack,M=a.id3Track,H=a.textTrack,V=this.currentTransmuxState,Q=V.accurateTimeOffset,G=V.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var W=this.remuxer.remux(v,S,M,H,G,Q,!0,this.id);s.push({remuxResult:W,chunkMeta:b}),b.transmuxing.executeEnd=C()},f.resetInitialTimestamp=function(s){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(s),b.resetTimeStamp(s)},f.resetContiguity=function(){var s=this.demuxer,a=this.remuxer;if(!s||!a)return;s.resetContiguity(),a.resetNextTimestamp()},f.resetInitSegment=function(s,a,b,v){var S=this.demuxer,M=this.remuxer;if(!S||!M)return;S.resetInitSegment(a,b,v),M.resetInitSegment(s,a,b)},f.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},f.transmux=function(s,a,b,v,S){var M;return a&&a.method==="SAMPLE-AES"?M=this.transmuxSampleAes(s,a,b,v,S):M=this.transmuxUnencrypted(s,b,v,S),M},f.transmuxUnencrypted=function(s,a,b,v){var S=this.demuxer.demux(s,a,!1,!this.config.progressive),M=S.audioTrack,H=S.avcTrack,V=S.id3Track,Q=S.textTrack,G=this.remuxer.remux(M,H,V,Q,a,b,!1,this.id);return{remuxResult:G,chunkMeta:v}},f.transmuxSampleAes=function(s,a,b,v,S){var M=this;return this.demuxer.demuxSampleAes(s,a,b).then(function(H){var V=M.remuxer.remux(H.audioTrack,H.avcTrack,H.id3Track,H.textTrack,b,v,!1,M.id);return{remuxResult:V,chunkMeta:S}})},f.configureTransmuxer=function(s,a){for(var b=this.config,v=this.observer,S=this.typeSupported,M=this.vendor,H=a.audioCodec,V=a.defaultInitPts,Q=a.duration,G=a.initSegmentData,W=a.videoCodec,q,oe=0,fe=h.length;oe<fe;oe++)if(h[oe].demux.probe(s)){q=h[oe];break}q||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),q={demux:B.default,remux:L.default});var ve=this.demuxer,De=this.remuxer,Ee=q.remux,_e=q.demux;(!De||!(De instanceof Ee))&&(this.remuxer=new Ee(v,b,S,M)),(!ve||!(ve instanceof _e))&&(this.demuxer=new _e(v,b,S),this.probe=_e.probe),this.resetInitSegment(G,H,W,Q),this.resetInitialTimestamp(V)},f.needsProbing=function(s,a,b){return!this.demuxer||!this.remuxer||a||b},f.getDecrypter=function(){var s=this.decrypter;return s||(s=this.decrypter=new I.default(this.observer,this.config)),s},x}();function d(x,f){var p=null;return x.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var _=function(f){return{remuxResult:{},chunkMeta:f}};function y(x){return"then"in x&&x.then instanceof Function}var m=function(f,p,s,a,b){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=f,this.videoCodec=p,this.initSegmentData=s,this.duration=a,this.defaultInitPts=b},l=function(f,p,s,a,b){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=f,this.contiguous=p,this.accurateTimeOffset=s,this.trackSwitch=a,this.timeOffset=b}},"./src/demux/tsdemuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"discardEPB",function(){return _});var X=R("./src/demux/adts.ts"),N=R("./src/demux/mpegaudio.ts"),I=R("./src/demux/exp-golomb.ts"),z=R("./src/demux/id3.ts"),B=R("./src/demux/sample-aes.ts"),O=R("./src/events.ts"),D=R("./src/utils/mp4-tools.ts"),E=R("./src/utils/logger.ts"),L=R("./src/errors.ts"),k={video:1,audio:2,id3:3,text:4},T=function(){function y(l,x,f){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=l,this.config=x,this.typeSupported=f}y.probe=function(x){var f=y.syncOffset(x);return f<0?!1:(f&&E.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},y.syncOffset=function(x){for(var f=Math.min(1e3,x.length-3*188),p=0;p<f;){if(x[p]===71&&x[p+188]===71&&x[p+2*188]===71)return p;p++}return-1},y.createTrack=function(x,f){return{container:x==="video"||x==="audio"?"video/mp2t":void 0,type:x,id:k[x],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:x==="audio"?f:void 0}};var m=y.prototype;return m.resetInitSegment=function(x,f,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=y.createTrack("video",p),this._audioTrack=y.createTrack("audio",p),this._id3Track=y.createTrack("id3",p),this._txtTrack=y.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=f,this._duration=p},m.resetTimeStamp=function(){},m.resetContiguity=function(){var x=this._audioTrack,f=this._avcTrack,p=this._id3Track;x&&(x.pesData=null),f&&(f.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},m.demux=function(x,f,p,s){p===void 0&&(p=!1),s===void 0&&(s=!1),p||(this.sampleAes=null);var a,b=this._avcTrack,v=this._audioTrack,S=this._id3Track,M=b.pid,H=b.pesData,V=v.pid,Q=S.pid,G=v.pesData,W=S.pesData,q=!1,oe=this.pmtParsed,fe=this._pmtId,ve=x.length;if(this.remainderData&&(x=Object(D.appendUint8Array)(this.remainderData,x),ve=x.length,this.remainderData=null),ve<188&&!s)return this.remainderData=x,{audioTrack:v,avcTrack:b,id3Track:S,textTrack:this._txtTrack};var De=Math.max(0,y.syncOffset(x));ve-=(ve+De)%188,ve<x.byteLength&&!s&&(this.remainderData=new Uint8Array(x.buffer,ve,x.buffer.byteLength-ve));for(var Ee=De;Ee<ve;Ee+=188)if(x[Ee]===71){var _e=!!(x[Ee+1]&64),Te=((x[Ee+1]&31)<<8)+x[Ee+2],Ce=(x[Ee+3]&48)>>4,me=void 0;if(Ce>1){if(me=Ee+5+x[Ee+4],me===Ee+188)continue}else me=Ee+4;switch(Te){case M:_e&&(H&&(a=o(H))&&this.parseAVCPES(a,!1),H={data:[],size:0}),H&&(H.data.push(x.subarray(me,Ee+188)),H.size+=Ee+188-me);break;case V:_e&&(G&&(a=o(G))&&(v.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),G={data:[],size:0}),G&&(G.data.push(x.subarray(me,Ee+188)),G.size+=Ee+188-me);break;case Q:_e&&(W&&(a=o(W))&&this.parseID3PES(a),W={data:[],size:0}),W&&(W.data.push(x.subarray(me,Ee+188)),W.size+=Ee+188-me);break;case 0:_e&&(me+=x[me]+1),fe=this._pmtId=C(x,me);break;case fe:{_e&&(me+=x[me]+1);var ne=h(x,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);M=ne.avc,M>0&&(b.pid=M),V=ne.audio,V>0&&(v.pid=V,v.isAAC=ne.isAAC),Q=ne.id3,Q>0&&(S.pid=Q),q&&!oe&&(E.logger.log("reparse from beginning"),q=!1,Ee=De-188),oe=this.pmtParsed=!0;break}case 17:case 8191:break;default:q=!0;break}}else this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b.pesData=H,v.pesData=G,S.pesData=W;var Ae={audioTrack:v,avcTrack:b,id3Track:S,textTrack:this._txtTrack};return s&&this.extractRemainingSamples(Ae),Ae},m.flush=function(){var x=this.remainderData;this.remainderData=null;var f;return x?f=this.demux(x,-1,!1,!0):f={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(f),this.sampleAes?this.decrypt(f,this.sampleAes):f},m.extractRemainingSamples=function(x){var f=x.audioTrack,p=x.avcTrack,s=x.id3Track,a=p.pesData,b=f.pesData,v=s.pesData,S;a&&(S=o(a))?(this.parseAVCPES(S,!0),p.pesData=null):p.pesData=a,b&&(S=o(b))?(f.isAAC?this.parseAACPES(S):this.parseMPEGPES(S),f.pesData=null):(b!=null&&b.size&&E.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=b),v&&(S=o(v))?(this.parseID3PES(S),s.pesData=null):s.pesData=v},m.demuxSampleAes=function(x,f,p){var s=this.demux(x,p,!0,!this.config.progressive),a=this.sampleAes=new B.default(this.observer,this.config,f);return this.decrypt(s,a)},m.decrypt=function(x,f){return new Promise(function(p){var s=x.audioTrack,a=x.avcTrack;s.samples&&s.isAAC?f.decryptAacSamples(s.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){p(x)}):p(x)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){p(x)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(x,f){var p=this,s=this._avcTrack,a=this.parseAVCNALu(x.data),b=!1,v=this.avcSample,S,M=!1;x.data=null,v&&a.length&&!s.audFound&&(c(v,s),v=this.avcSample=A(!1,x.pts,x.dts,"")),a.forEach(function(H){switch(H.type){case 1:{S=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(v.debug+="NDR "),v.frame=!0;var V=H.data;if(M&&V.length>4){var Q=new I.default(V).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=p.avcSample=A(!0,x.pts,x.dts,"")),b&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,b&&v&&(v.debug+="SEI ");var G=new I.default(_(H.data));G.readUByte();for(var W=0,q=0,oe=!1,fe=0;!oe&&G.bytesAvailable>1;){W=0;do fe=G.readUByte(),W+=fe;while(fe===255);q=0;do fe=G.readUByte(),q+=fe;while(fe===255);if(W===4&&G.bytesAvailable!==0){oe=!0;var ve=G.readUByte();if(ve===181){var De=G.readUShort();if(De===49){var Ee=G.readUInt();if(Ee===1195456820){var _e=G.readUByte();if(_e===3){for(var Te=G.readUByte(),Ce=G.readUByte(),me=31&Te,ne=[Te,Ce],Ae=0;Ae<me;Ae++)ne.push(G.readUByte()),ne.push(G.readUByte()),ne.push(G.readUByte());d(p._txtTrack.samples,{type:3,pts:x.pts,bytes:ne})}}}}}else if(W===5&&G.bytesAvailable!==0){if(oe=!0,q>16){for(var rt=[],$e=0;$e<16;$e++)rt.push(G.readUByte().toString(16)),($e===3||$e===5||$e===7||$e===9)&&rt.push("-");for(var Xe=q-16,Ve=new Uint8Array(Xe),Le=0;Le<Xe;Le++)Ve[Le]=G.readUByte();d(p._txtTrack.samples,{pts:x.pts,payloadType:W,uuid:rt.join(""),userData:Object(z.utf8ArrayToStr)(Ve),userDataBytes:Ve})}}else if(q<G.bytesAvailable)for(var Me=0;Me<q;Me++)G.readUByte()}break}case 7:if(S=!0,M=!0,b&&v&&(v.debug+="SPS "),!s.sps){var ze=new I.default(H.data),Ge=ze.readSPS();s.width=Ge.width,s.height=Ge.height,s.pixelRatio=Ge.pixelRatio,s.sps=[H.data],s.duration=p._duration;for(var He=H.data.subarray(1,4),Be="avc1.",Pe=0;Pe<3;Pe++){var pt=He[Pe].toString(16);pt.length<2&&(pt="0"+pt),Be+=pt}s.codec=Be}break;case 8:S=!0,b&&v&&(v.debug+="PPS "),s.pps||(s.pps=[H.data]);break;case 9:S=!1,s.audFound=!0,v&&c(v,s),v=p.avcSample=A(!1,x.pts,x.dts,b?"AUD ":"");break;case 12:S=!1;break;default:S=!1,v&&(v.debug+="unknown NAL "+H.type+" ");break}if(v&&S){var it=v.units;it.push(H)}}),f&&v&&(c(v,s),this.avcSample=null)},m.getLastNalUnit=function(){var x,f=this.avcSample,p;if(!f||f.units.length===0){var s=this._avcTrack.samples;f=s[s.length-1]}if((x=f)!==null&&x!==void 0&&x.units){var a=f.units;p=a[a.length-1]}return p},m.parseAVCNALu=function(x){var f=x.byteLength,p=this._avcTrack,s=p.naluState||0,a=s,b=[],v=0,S,M,H,V=-1,Q=0;for(s===-1&&(V=0,Q=x[0]&31,s=0,v=1);v<f;){if(S=x[v++],!s){s=S?0:1;continue}if(s===1){s=S?0:2;continue}if(!S)s=3;else if(S===1){if(V>=0){var G={data:x.subarray(V,v-s-1),type:Q};b.push(G)}else{var W=this.getLastNalUnit();if(W&&(a&&v<=4-a&&(W.state&&(W.data=W.data.subarray(0,W.data.byteLength-a))),M=v-s-1,M>0)){var q=new Uint8Array(W.data.byteLength+M);q.set(W.data,0),q.set(x.subarray(0,M),W.data.byteLength),W.data=q,W.state=0}}v<f?(H=x[v]&31,V=v,Q=H,s=0):s=-1}else s=0}if(V>=0&&s>=0){var oe={data:x.subarray(V,f),type:Q,state:s};b.push(oe)}if(b.length===0){var fe=this.getLastNalUnit();if(fe){var ve=new Uint8Array(fe.data.byteLength+x.byteLength);ve.set(fe.data,0),ve.set(x,fe.data.byteLength),fe.data=ve}}return p.naluState=s,b},m.parseAACPES=function(x){var f=0,p=this._audioTrack,s=this.aacOverFlow,a=x.data;if(s){this.aacOverFlow=null;var b=s.sample.unit.byteLength,v=Math.min(s.missing,b),S=b-v;s.sample.unit.set(a.subarray(0,v),S),p.samples.push(s.sample),f=s.missing}var M,H;for(M=f,H=a.length;M<H-1&&!X.isHeader(a,M);M++);if(M!==f){var V,Q;if(M<H-1?(V="AAC PES did not start with ADTS header,offset:"+M,Q=!1):(V="no ADTS header found in AAC PES",Q=!0),E.logger.warn("parsing error:"+V),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:Q,reason:V}),Q)return}X.initTrackConfig(p,this.observer,a,M,this.audioCodec);var G;if(x.pts!==void 0)G=x.pts;else if(s){var W=X.getFrameDuration(p.samplerate);G=s.sample.pts+W}else{E.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var q=0;M<H;)if(X.isHeader(a,M)){if(M+5<H){var oe=X.appendFrame(p,a,M,G,q);if(oe)if(oe.missing)this.aacOverFlow=oe;else{M+=oe.length,q++;continue}}break}else M++},m.parseMPEGPES=function(x){var f=x.data,p=f.length,s=0,a=0,b=x.pts;if(b===void 0){E.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<p;)if(N.isHeader(f,a)){var v=N.appendFrame(this._audioTrack,f,a,b,s);if(v)a+=v.length,s++;else break}else a++},m.parseID3PES=function(x){if(x.pts===void 0){E.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(x)},y}();T.minProbeByteLength=188;function A(y,m,l,x){return{key:y,frame:!1,pts:m,dts:l,units:[],debug:x,length:0}}function C(y,m){return(y[m+10]&31)<<8|y[m+11]}function h(y,m,l,x){var f={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(y[m+1]&15)<<8|y[m+2],s=m+3+p-4,a=(y[m+10]&15)<<8|y[m+11];for(m+=12+a;m<s;){var b=(y[m+1]&31)<<8|y[m+2];switch(y[m]){case 207:if(!x){E.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:f.audio===-1&&(f.audio=b);break;case 21:f.id3===-1&&(f.id3=b);break;case 219:if(!x){E.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:f.avc===-1&&(f.avc=b);break;case 3:case 4:l?f.audio===-1&&(f.audio=b,f.isAAC=!1):E.logger.log("MPEG audio found, not supported in this browser");break;case 36:E.logger.warn("Unsupported HEVC stream type found");break;default:break}m+=((y[m+3]&15)<<8|y[m+4])+5}return f}function o(y){var m=0,l,x,f,p,s,a=y.data;if(!y||y.size===0)return null;for(;a[0].length<19&&a.length>1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}l=a[0];var v=(l[0]<<16)+(l[1]<<8)+l[2];if(v===1){if(x=(l[4]<<8)+l[5],x&&x>y.size-6)return null;var S=l[7];S&192&&(p=(l[9]&14)*536870912+(l[10]&255)*4194304+(l[11]&254)*16384+(l[12]&255)*128+(l[13]&254)/2,S&64?(s=(l[14]&14)*536870912+(l[15]&255)*4194304+(l[16]&254)*16384+(l[17]&255)*128+(l[18]&254)/2,p-s>60*9e4&&(E.logger.warn(Math.round((p-s)/9e4)+"s delta between PTS and DTS, align them"),p=s)):s=p),f=l[8];var M=f+9;if(y.size<=M)return null;y.size-=M;for(var H=new Uint8Array(y.size),V=0,Q=a.length;V<Q;V++){l=a[V];var G=l.byteLength;if(M)if(M>G){M-=G;continue}else l=l.subarray(M),G-=M,M=0;H.set(l,m),m+=G}return x&&(x-=f+3),{data:H,pts:p,dts:s,len:x}}return null}function c(y,m){if(y.units.length&&y.frame){if(y.pts===void 0){var l=m.samples,x=l.length;if(x){var f=l[x-1];y.pts=f.pts,y.dts=f.dts}else{m.dropped++;return}}m.samples.push(y)}y.debug.length&&E.logger.log(y.pts+"/"+y.dts+":"+y.debug)}function d(y,m){var l=y.length;if(l>0){if(m.pts>=y[l-1].pts)y.push(m);else for(var x=l-1;x>=0;x--)if(m.pts<y[x].pts){y.splice(x,0,m);break}}else y.push(m)}function _(y){for(var m=y.byteLength,l=[],x=1;x<m-2;)y[x]===0&&y[x+1]===0&&y[x+2]===3?(l.push(x+2),x+=2):x++;if(l.length===0)return y;var f=m-l.length,p=new Uint8Array(f),s=0;for(x=0;x<f;s++,x++)s===l[0]&&(s++,l.shift()),p[x]=y[s];return p}$.default=T},"./src/errors.ts":function(ae,$,R){"use strict";R.r($),R.d($,"ErrorTypes",function(){return X}),R.d($,"ErrorDetails",function(){return N});var X;(function(I){I.NETWORK_ERROR="networkError",I.MEDIA_ERROR="mediaError",I.KEY_SYSTEM_ERROR="keySystemError",I.MUX_ERROR="muxError",I.OTHER_ERROR="otherError"})(X||(X={}));var N;(function(I){I.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",I.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",I.KEY_SYSTEM_NO_SESSION="keySystemNoSession",I.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",I.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",I.MANIFEST_LOAD_ERROR="manifestLoadError",I.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",I.MANIFEST_PARSING_ERROR="manifestParsingError",I.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",I.LEVEL_EMPTY_ERROR="levelEmptyError",I.LEVEL_LOAD_ERROR="levelLoadError",I.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",I.LEVEL_SWITCH_ERROR="levelSwitchError",I.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",I.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",I.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",I.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",I.FRAG_LOAD_ERROR="fragLoadError",I.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",I.FRAG_DECRYPT_ERROR="fragDecryptError",I.FRAG_PARSING_ERROR="fragParsingError",I.REMUX_ALLOC_ERROR="remuxAllocError",I.KEY_LOAD_ERROR="keyLoadError",I.KEY_LOAD_TIMEOUT="keyLoadTimeOut",I.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",I.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",I.BUFFER_APPEND_ERROR="bufferAppendError",I.BUFFER_APPENDING_ERROR="bufferAppendingError",I.BUFFER_STALLED_ERROR="bufferStalledError",I.BUFFER_FULL_ERROR="bufferFullError",I.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",I.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",I.INTERNAL_EXCEPTION="internalException",I.INTERNAL_ABORTED="aborted",I.UNKNOWN="unknown"})(N||(N={}))},"./src/events.ts":function(ae,$,R){"use strict";R.r($),R.d($,"Events",function(){return X});var X;(function(N){N.MEDIA_ATTACHING="hlsMediaAttaching",N.MEDIA_ATTACHED="hlsMediaAttached",N.MEDIA_DETACHING="hlsMediaDetaching",N.MEDIA_DETACHED="hlsMediaDetached",N.BUFFER_RESET="hlsBufferReset",N.BUFFER_CODECS="hlsBufferCodecs",N.BUFFER_CREATED="hlsBufferCreated",N.BUFFER_APPENDING="hlsBufferAppending",N.BUFFER_APPENDED="hlsBufferAppended",N.BUFFER_EOS="hlsBufferEos",N.BUFFER_FLUSHING="hlsBufferFlushing",N.BUFFER_FLUSHED="hlsBufferFlushed",N.MANIFEST_LOADING="hlsManifestLoading",N.MANIFEST_LOADED="hlsManifestLoaded",N.MANIFEST_PARSED="hlsManifestParsed",N.LEVEL_SWITCHING="hlsLevelSwitching",N.LEVEL_SWITCHED="hlsLevelSwitched",N.LEVEL_LOADING="hlsLevelLoading",N.LEVEL_LOADED="hlsLevelLoaded",N.LEVEL_UPDATED="hlsLevelUpdated",N.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",N.LEVELS_UPDATED="hlsLevelsUpdated",N.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",N.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",N.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",N.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",N.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",N.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",N.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",N.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",N.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",N.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",N.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",N.CUES_PARSED="hlsCuesParsed",N.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",N.INIT_PTS_FOUND="hlsInitPtsFound",N.FRAG_LOADING="hlsFragLoading",N.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",N.FRAG_LOADED="hlsFragLoaded",N.FRAG_DECRYPTED="hlsFragDecrypted",N.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",N.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",N.FRAG_PARSING_METADATA="hlsFragParsingMetadata",N.FRAG_PARSED="hlsFragParsed",N.FRAG_BUFFERED="hlsFragBuffered",N.FRAG_CHANGED="hlsFragChanged",N.FPS_DROP="hlsFpsDrop",N.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",N.ERROR="hlsError",N.DESTROYING="hlsDestroying",N.KEY_LOADING="hlsKeyLoading",N.KEY_LOADED="hlsKeyLoaded",N.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",N.BACK_BUFFER_REACHED="hlsBackBufferReached"})(X||(X={}))},"./src/hls.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return y});var X=R("./node_modules/url-toolkit/src/url-toolkit.js"),N=R.n(X),I=R("./src/loader/playlist-loader.ts"),z=R("./src/loader/key-loader.ts"),B=R("./src/controller/id3-track-controller.ts"),O=R("./src/controller/latency-controller.ts"),D=R("./src/controller/level-controller.ts"),E=R("./src/controller/fragment-tracker.ts"),L=R("./src/controller/stream-controller.ts"),k=R("./src/is-supported.ts"),T=R("./src/utils/logger.ts"),A=R("./src/config.ts"),C=R("./node_modules/eventemitter3/index.js"),h=R.n(C),o=R("./src/events.ts"),c=R("./src/errors.ts");function d(m,l){for(var x=0;x<l.length;x++){var f=l[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function _(m,l,x){return l&&d(m.prototype,l),x&&d(m,x),m}var y=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 C.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var f=this.config=Object(A.mergeConfig)(m.DefaultConfig,x);this.userConfig=x,Object(T.enableLogs)(f.debug),this._autoLevelCapping=-1,f.progressive&&Object(A.enableStreamingMode)(f);var p=f.abrController,s=f.bufferController,a=f.capLevelController,b=f.fpsController,v=this.abrController=new p(this),S=this.bufferController=new s(this),M=this.capLevelController=new a(this),H=new b(this),V=new I.default(this),Q=new z.default(this),G=new B.default(this),W=this.levelController=new D.default(this),q=new E.FragmentTracker(this),oe=this.streamController=new L.default(this,q);M.setStreamController(oe),H.setStreamController(oe);var fe=[W,oe];this.networkControllers=fe;var ve=[V,Q,v,S,M,H,G,q];this.audioTrackController=this.createController(f.audioTrackController,null,fe),this.createController(f.audioStreamController,q,fe),this.subtitleTrackController=this.createController(f.subtitleTrackController,null,fe),this.createController(f.subtitleStreamController,q,fe),this.createController(f.timelineController,null,ve),this.emeController=this.createController(f.emeController,null,ve),this.cmcdController=this.createController(f.cmcdController,null,ve),this.latencyController=this.createController(O.default,null,ve),this.coreComponents=ve}var l=m.prototype;return l.createController=function(f,p,s){if(f){var a=p?new f(this,p):new f(this);return s&&s.push(a),a}return null},l.on=function(f,p,s){s===void 0&&(s=this),this._emitter.on(f,p,s)},l.once=function(f,p,s){s===void 0&&(s=this),this._emitter.once(f,p,s)},l.removeAllListeners=function(f){this._emitter.removeAllListeners(f)},l.off=function(f,p,s,a){s===void 0&&(s=this),this._emitter.off(f,p,s,a)},l.listeners=function(f){return this._emitter.listeners(f)},l.emit=function(f,p,s){return this._emitter.emit(f,p,s)},l.trigger=function(f,p){if(this.config.debug)return this.emit(f,f,p);try{return this.emit(f,f,p)}catch(s){T.logger.error("An internal error happened while handling event "+f+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(o.Events.ERROR,{type:c.ErrorTypes.OTHER_ERROR,details:c.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:f,error:s})}return!1},l.listenerCount=function(f){return this._emitter.listenerCount(f)},l.destroy=function(){T.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(f){return f.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(f){return f.destroy()}),this.coreComponents.length=0},l.attachMedia=function(f){T.logger.log("attachMedia"),this._media=f,this.trigger(o.Events.MEDIA_ATTACHING,{media:f})},l.detachMedia=function(){T.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(f){this.stopLoad();var p=this.media,s=this.url,a=this.url=X.buildAbsoluteURL(self.location.href,f,{alwaysNormalize:!0});T.logger.log("loadSource:"+a),p&&s&&s!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(o.Events.MANIFEST_LOADING,{url:f})},l.startLoad=function(f){f===void 0&&(f=-1),T.logger.log("startLoad("+f+")"),this.networkControllers.forEach(function(p){p.startLoad(f)})},l.stopLoad=function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(f){f.stopLoad()})},l.swapAudioCodec=function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){T.logger.log("recoverMediaError");var f=this._media;this.detachMedia(),f&&this.attachMedia(f)},l.removeLevel=function(f,p){p===void 0&&(p=0),this.levelController.removeLevel(f,p)},_(m,[{key:"levels",get:function(){var f=this.levelController.levels;return f||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(f){T.logger.log("set currentLevel:"+f),this.loadLevel=f,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(f){T.logger.log("set nextLevel:"+f),this.levelController.manualLevel=f,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(f){T.logger.log("set loadLevel:"+f),this.levelController.manualLevel=f}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(f){this.levelController.nextLoadLevel=f}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(f){T.logger.log("set firstLevel:"+f),this.levelController.firstLevel=f}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(f){T.logger.log("set startLevel:"+f),f!==-1&&(f=Math.max(f,this.minAutoLevel)),this.levelController.startLevel=f}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(f){var p=!!f;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(f){this._autoLevelCapping!==f&&(T.logger.log("set autoLevelCapping:"+f),this._autoLevelCapping=f)}},{key:"bandwidthEstimate",get:function(){var f=this.abrController.bwEstimator;return f?f.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var f=this.levels,p=this.config.minAutoBitrate;if(!f)return 0;for(var s=f.length,a=0;a<s;a++)if(f[a].maxBitrate>p)return a;return 0}},{key:"maxAutoLevel",get:function(){var f=this.levels,p=this.autoLevelCapping,s;return p===-1&&f&&f.length?s=f.length-1:s=p,s}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(f){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,f)}},{key:"audioTracks",get:function(){var f=this.audioTrackController;return f?f.audioTracks:[]}},{key:"audioTrack",get:function(){var f=this.audioTrackController;return f?f.audioTrack:-1},set:function(f){var p=this.audioTrackController;p&&(p.audioTrack=f)}},{key:"subtitleTracks",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var f=this.subtitleTrackController;return f?f.subtitleTrack:-1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleTrack=f)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var f=this.subtitleTrackController;return f?f.subtitleDisplay:!1},set:function(f){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=f)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(f){this.config.lowLatencyMode=f}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return c.ErrorTypes}},{key:"ErrorDetails",get:function(){return c.ErrorDetails}},{key:"DefaultConfig",get:function(){return m.defaultConfig?m.defaultConfig:A.hlsDefaultConfig},set:function(f){m.defaultConfig=f}}]),m}();y.defaultConfig=void 0},"./src/is-supported.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isSupported",function(){return I}),R.d($,"changeTypeSupported",function(){return z});var X=R("./src/utils/mediasource-helper.ts");function N(){return self.SourceBuffer||self.WebKitSourceBuffer}function I(){var B=Object(X.getMediaSource)();if(!B)return!1;var O=N(),D=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!D&&!!E}function z(){var B,O=N();return typeof(O==null||((B=O.prototype)===null||B===void 0)?void 0:B.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return T}),R.d($,"LoadError",function(){return C});var X=R("./src/polyfills/number.ts"),N=R("./src/errors.ts");function I(h,o){h.prototype=Object.create(o.prototype),h.prototype.constructor=h,E(h,o)}function z(h){var o=typeof Map=="function"?new Map:void 0;return z=function(d){if(d===null||!D(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(d))return o.get(d);o.set(d,_)}function _(){return B(d,arguments,L(this).constructor)}return _.prototype=Object.create(d.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),E(_,d)},z(h)}function B(h,o,c){return O()?B=Reflect.construct:B=function(_,y,m){var l=[null];l.push.apply(l,y);var x=Function.bind.apply(_,l),f=new x;return m&&E(f,m.prototype),f},B.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function D(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function E(h,o){return E=Object.setPrototypeOf||function(d,_){return d.__proto__=_,d},E(h,o)}function L(h){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)},L(h)}var k=Math.pow(2,17),T=function(){function h(c){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=c}var o=h.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(d,_){var y=this,m=d.url;if(!m)return Promise.reject(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.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,f=l.loader;return new Promise(function(p,s){y.loader&&y.loader.destroy();var a=y.loader=d.loader=x?new x(l):new f(l),b=A(d),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:k};d.stats=a.stats,a.load(b,v,{onSuccess:function(M,H,V,Q){y.resetLoader(d,a),p({frag:d,part:null,payload:M.data,networkDetails:Q})},onError:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,response:M,networkDetails:V}))},onAbort:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,networkDetails:V}))},onTimeout:function(M,H,V){y.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,networkDetails:V}))},onProgress:function(M,H,V,Q){_&&_({frag:d,part:null,payload:V,networkDetails:Q})}})})},o.loadPart=function(d,_,y){var m=this;this.abort();var l=this.config,x=l.fLoader,f=l.loader;return new Promise(function(p,s){m.loader&&m.loader.destroy();var a=m.loader=d.loader=x?new x(l):new f(l),b=A(d,_),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:k};_.stats=a.stats,a.load(b,v,{onSuccess:function(M,H,V,Q){m.resetLoader(d,a),m.updateStatsFromPart(d,_);var G={frag:d,part:_,payload:M.data,networkDetails:Q};y(G),p(G)},onError:function(M,H,V){m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:d,part:_,response:M,networkDetails:V}))},onAbort:function(M,H,V){d.stats.aborted=_.stats.aborted,m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:d,part:_,networkDetails:V}))},onTimeout:function(M,H,V){m.resetLoader(d,a),s(new C({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:d,part:_,networkDetails:V}))}})})},o.updateStatsFromPart=function(d,_){var y=d.stats,m=_.stats,l=m.total;if(y.loaded+=m.loaded,l){var x=Math.round(d.duration/_.duration),f=Math.min(Math.round(y.loaded/l),x),p=x-f,s=p*Math.round(y.loaded/f);y.total=y.loaded+s}else y.total=Math.max(y.loaded,y.total);var a=y.loading,b=m.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(d,_){d.loader=null,this.loader===_&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),_.destroy()},h}();function A(h,o){o===void 0&&(o=null);var c=o||h,d={frag:h,part:o,responseType:"arraybuffer",url:c.url,headers:{},rangeStart:0,rangeEnd:0},_=c.byteRangeStartOffset,y=c.byteRangeEndOffset;return Object(X.isFiniteNumber)(_)&&Object(X.isFiniteNumber)(y)&&(d.rangeStart=_,d.rangeEnd=y),d}var C=function(h){I(o,h);function o(c){for(var d,_=arguments.length,y=new Array(_>1?_-1:0),m=1;m<_;m++)y[m-1]=arguments[m];return d=h.call.apply(h,[this].concat(y))||this,d.data=void 0,d.data=c,d}return o}(z(Error))},"./src/loader/fragment.ts":function(ae,$,R){"use strict";R.r($),R.d($,"ElementaryStreamTypes",function(){return T}),R.d($,"BaseSegment",function(){return A}),R.d($,"Fragment",function(){return C}),R.d($,"Part",function(){return h});var X=R("./src/polyfills/number.ts"),N=R("./node_modules/url-toolkit/src/url-toolkit.js"),I=R.n(N),z=R("./src/utils/logger.ts"),B=R("./src/loader/level-key.ts"),O=R("./src/loader/load-stats.ts");function D(o,c){o.prototype=Object.create(c.prototype),o.prototype.constructor=o,E(o,c)}function E(o,c){return E=Object.setPrototypeOf||function(_,y){return _.__proto__=y,_},E(o,c)}function L(o,c){for(var d=0;d<c.length;d++){var _=c[d];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(o,_.key,_)}}function k(o,c,d){return c&&L(o.prototype,c),d&&L(o,d),o}var T;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(T||(T={}));var A=function(){function o(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 c=o.prototype;return c.setByteRange=function(_,y){var m=_.split("@",2),l=[];m.length===1?l[0]=y?y.byteRangeEndOffset:0:l[0]=parseInt(m[1]),l[1]=parseInt(m[0])+l[0],this._byteRange=l},k(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(_){this._url=_}}]),o}(),C=function(o){D(c,o);function c(_,y){var m;return m=o.call(this,y)||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 O.LoadStats,m.urlId=0,m.data=void 0,m.bitrateTest=!1,m.title=null,m.initSegment=null,m.type=_,m}var d=c.prototype;return d.createInitializationVector=function(y){for(var m=new Uint8Array(16),l=12;l<16;l++)m[l]=y>>8*(15-l)&255;return m},d.setDecryptDataFromLevelKey=function(y,m){var l=y;return(y==null?void 0:y.method)==="AES-128"&&y.uri&&!y.iv&&(l=B.LevelKey.fromURI(y.uri),l.method=y.method,l.iv=this.createInitializationVector(m),l.keyFormat="identity"),l},d.setElementaryStreamInfo=function(y,m,l,x,f,p){p===void 0&&(p=!1);var s=this.elementaryStreams,a=s[y];if(!a){s[y]={startPTS:m,endPTS:l,startDTS:x,endDTS:f,partial:p};return}a.startPTS=Math.min(a.startPTS,m),a.endPTS=Math.max(a.endPTS,l),a.startDTS=Math.min(a.startDTS,x),a.endDTS=Math.max(a.endDTS,f)},d.clearElementaryStreamInfo=function(){var y=this.elementaryStreams;y[T.AUDIO]=null,y[T.VIDEO]=null,y[T.AUDIOVIDEO]=null},k(c,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var y=this.sn;typeof y!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&z.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),y=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,y)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(X.isFiniteNumber)(this.programDateTime))return null;var y=Object(X.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+y*1e3}},{key:"encrypted",get:function(){var y;return!!((y=this.decryptdata)!==null&&y!==void 0&&y.keyFormat&&this.decryptdata.uri)}}]),c}(A),h=function(o){D(c,o);function c(d,_,y,m,l){var x;x=o.call(this,y)||this,x.fragOffset=0,x.duration=0,x.gap=!1,x.independent=!1,x.relurl=void 0,x.fragment=void 0,x.index=void 0,x.stats=new O.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 f=d.enumeratedString("BYTERANGE");return f&&x.setByteRange(f,l),l&&(x.fragOffset=l.fragOffset+l.duration),x}return k(c,[{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)}}]),c}(A)},"./src/loader/key-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return z});var X=R("./src/events.ts"),N=R("./src/errors.ts"),I=R("./src/utils/logger.ts"),z=function(){function B(D){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=D,this._registerListeners()}var O=B.prototype;return O._registerListeners=function(){this.hls.on(X.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(X.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var E in this.loaders){var L=this.loaders[E];L&&L.destroy()}this.loaders={}},O.onKeyLoading=function(E,L){var k=L.frag,T=k.type,A=this.loaders[T];if(!k.decryptdata){I.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var C=k.decryptdata.uri;if(C!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(A&&(I.logger.warn("abort previous key loader for type:"+T),A.abort()),!C){I.logger.warn("key uri is falsy");return}var o=h.loader,c=k.loader=this.loaders[T]=new o(h);this.decrypturl=C,this.decryptkey=null;var d={url:C,frag:k,responseType:"arraybuffer"},_={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(d,_,y)}else this.decryptkey&&(k.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:k}))},O.loadsuccess=function(E,L,k){var T=k.frag;if(!T.decryptdata){I.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(E.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(X.Events.KEY_LOADED,{frag:T})},O.loaderror=function(E,L){var k=L.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:k,response:E})},O.loadtimeout=function(E,L){var k=L.frag,T=k.loader;T&&T.abort(),delete this.loaders[k.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:k})},B}()},"./src/loader/level-details.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LevelDetails",function(){return B});var X=R("./src/polyfills/number.ts");function N(O,D){for(var E=0;E<D.length;E++){var L=D[E];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(O,L.key,L)}}function I(O,D,E){return D&&N(O.prototype,D),E&&N(O,E),O}var z=10,B=function(){function O(E){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=E}var D=O.prototype;return D.reloaded=function(L){if(!L){this.advanced=!0,this.updated=!0;return}var k=this.lastPartSn-L.lastPartSn,T=this.lastPartIndex-L.lastPartIndex;this.updated=this.endSN!==L.endSN||!!T||!!k,this.advanced=this.endSN>L.endSN||k>0||k===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(L.misses*.6):this.misses=L.misses+1,this.availabilityDelay=L.availabilityDelay},I(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(X.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||z}},{key:"drift",get:function(){var L=this.driftEndTime-this.driftStartTime;if(L>0){var k=this.driftEnd-this.driftStart;return k*1e3/L}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var L;return(L=this.fragments)!==null&&L!==void 0&&L.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 L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var L;return(L=this.partList)!==null&&L!==void 0&&L.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LevelKey",function(){return B});var X=R("./node_modules/url-toolkit/src/url-toolkit.js"),N=R.n(X);function I(O,D){for(var E=0;E<D.length;E++){var L=D[E];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(O,L.key,L)}}function z(O,D,E){return D&&I(O.prototype,D),E&&I(O,E),O}var B=function(){O.fromURL=function(E,L){return new O(E,L)},O.fromURI=function(E){return new O(E)};function O(D,E){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,E?this._uri=Object(X.buildAbsoluteURL)(D,E,{alwaysNormalize:!0}):this._uri=D}return z(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LoadStats",function(){return X});var X=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(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return c});var X=R("./src/polyfills/number.ts"),N=R("./node_modules/url-toolkit/src/url-toolkit.js"),I=R.n(N),z=R("./src/loader/fragment.ts"),B=R("./src/loader/level-details.ts"),O=R("./src/loader/level-key.ts"),D=R("./src/utils/attr-list.ts"),E=R("./src/utils/logger.ts"),L=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,A=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),C=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function o(l){var x,f;return h.test((x=(f=N.parseURL(l))===null||f===void 0?void 0:f.path)!=null?x:"")}var c=function(){function l(){}return l.findGroup=function(f,p){for(var s=0;s<f.length;s++){var a=f[s];if(a.id===p)return a}},l.convertAVC1ToAVCOTI=function(f){var p=f.split(".");if(p.length>2){var s=p.shift()+".";return s+=parseInt(p.shift()).toString(16),s+=("000"+parseInt(p.shift()).toString(16)).substr(-4),s}return f},l.resolve=function(f,p){return N.buildAbsoluteURL(p,f,{alwaysNormalize:!0})},l.parseMasterPlaylist=function(f,p){var s=[],a={},b=!1;k.lastIndex=0;for(var v;(v=k.exec(f))!=null;)if(v[1]){var S=new D.AttrList(v[1]),M={attrs:S,bitrate:S.decimalInteger("AVERAGE-BANDWIDTH")||S.decimalInteger("BANDWIDTH"),name:S.NAME,url:l.resolve(v[2],p)},H=S.decimalResolution("RESOLUTION");H&&(M.width=H.width,M.height=H.height),d((S.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=l.convertAVC1ToAVCOTI(M.videoCodec)),s.push(M)}else if(v[3]){var V=new D.AttrList(v[3]);V["DATA-ID"]&&(b=!0,a[V["DATA-ID"]]=V)}return{levels:s,sessionData:b?a:null}},l.parseMasterPlaylistMedia=function(f,p,s,a){a===void 0&&(a=[]);var b,v=[],S=0;for(T.lastIndex=0;(b=T.exec(f))!==null;){var M=new D.AttrList(b[1]);if(M.TYPE===s){var H={attrs:M,bitrate:0,id:S++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:s,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?l.resolve(M.URI,p):""};if(a.length){var V=l.findGroup(a,H.groupId)||a[0];_(H,V,"audioCodec"),_(H,V,"textCodec")}v.push(H)}}return v},l.parseLevelPlaylist=function(f,p,s,a,b){var v=new B.LevelDetails(p),S=v.fragments,M=null,H=0,V=0,Q=0,G=0,W=null,q=new z.Fragment(a,p),oe,fe,ve,De=-1,Ee=!1;for(A.lastIndex=0,v.m3u8=f;(oe=A.exec(f))!==null;){Ee&&(Ee=!1,q=new z.Fragment(a,p),q.start=Q,q.sn=H,q.cc=G,q.level=s,M&&(q.initSegment=M,q.rawProgramDateTime=M.rawProgramDateTime));var _e=oe[1];if(_e){q.duration=parseFloat(_e);var Te=(" "+oe[2]).slice(1);q.title=Te||null,q.tagList.push(Te?["INF",_e,Te]:["INF",_e])}else if(oe[3])Object(X.isFiniteNumber)(q.duration)&&(q.start=Q,ve&&(q.levelkey=ve),q.sn=H,q.level=s,q.cc=G,q.urlId=b,S.push(q),q.relurl=(" "+oe[3]).slice(1),m(q,W),W=q,Q+=q.duration,H++,V=0,Ee=!0);else if(oe[4]){var Ce=(" "+oe[4]).slice(1);W?q.setByteRange(Ce,W):q.setByteRange(Ce)}else if(oe[5])q.rawProgramDateTime=(" "+oe[5]).slice(1),q.tagList.push(["PROGRAM-DATE-TIME",q.rawProgramDateTime]),De===-1&&(De=S.length);else{if(oe=oe[0].match(C),!oe){E.logger.warn("No matches on slow regex match for level playlist!");continue}for(fe=1;fe<oe.length&&!(typeof oe[fe]!="undefined");fe++);var me=(" "+oe[fe]).slice(1),ne=(" "+oe[fe+1]).slice(1),Ae=oe[fe+2]?(" "+oe[fe+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":v.type=ne.toUpperCase();break;case"MEDIA-SEQUENCE":H=v.startSN=parseInt(ne);break;case"SKIP":{var rt=new D.AttrList(ne),$e=rt.decimalInteger("SKIPPED-SEGMENTS");if(Object(X.isFiniteNumber)($e)){v.skippedSegments=$e;for(var Xe=$e;Xe--;)S.unshift(null);H+=$e}var Ve=rt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ve&&(v.recentlyRemovedDateranges=Ve.split(" "));break}case"TARGETDURATION":v.targetduration=parseFloat(ne);break;case"VERSION":v.version=parseInt(ne);break;case"EXTM3U":break;case"ENDLIST":v.live=!1;break;case"#":(ne||Ae)&&q.tagList.push(Ae?[ne,Ae]:[ne]);break;case"DIS":G++;case"GAP":q.tagList.push([me]);break;case"BITRATE":q.tagList.push([me,ne]);break;case"DISCONTINUITY-SEQ":G=parseInt(ne);break;case"KEY":{var Le,Me=new D.AttrList(ne),ze=Me.enumeratedString("METHOD"),Ge=Me.URI,He=Me.hexadecimalInteger("IV"),Be=Me.enumeratedString("KEYFORMATVERSIONS"),Pe=Me.enumeratedString("KEYID"),pt=(Le=Me.enumeratedString("KEYFORMAT"))!=null?Le:"identity",it=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(it.indexOf(pt)>-1){E.logger.warn("Keyformat "+pt+" is not supported from the manifest");continue}else if(pt!=="identity")continue;ze&&(ve=O.LevelKey.fromURL(p,Ge),Ge&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ze)>=0&&(ve.method=ze,ve.keyFormat=pt,Pe&&(ve.keyID=Pe),Be&&(ve.keyFormatVersions=Be),ve.iv=He));break}case"START":{var et=new D.AttrList(ne),at=et.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(at)&&(v.startTimeOffset=at);break}case"MAP":{var Et=new D.AttrList(ne);q.relurl=Et.URI,Et.BYTERANGE&&q.setByteRange(Et.BYTERANGE),q.level=s,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,M=q,Ee=!0;break}case"SERVER-CONTROL":{var ct=new D.AttrList(ne);v.canBlockReload=ct.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=ct.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&ct.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=ct.optionalFloat("PART-HOLD-BACK",0),v.holdBack=ct.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var dt=new D.AttrList(ne);v.partTarget=dt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=v.partList;we||(we=v.partList=[]);var gt=V>0?we[we.length-1]:void 0,lt=V++,Re=new z.Part(new D.AttrList(ne),q,p,lt,gt);we.push(Re),q.duration+=Re.duration;break}case"PRELOAD-HINT":{var je=new D.AttrList(ne);v.preloadHint=je;break}case"RENDITION-REPORT":{var ge=new D.AttrList(ne);v.renditionReports=v.renditionReports||[],v.renditionReports.push(ge);break}default:E.logger.warn("line parsed but not handled: "+oe);break}}}W&&!W.relurl?(S.pop(),Q-=W.duration,v.partList&&(v.fragmentHint=W)):v.partList&&(m(q,W),q.cc=G,v.fragmentHint=q);var de=S.length,pe=S[0],ee=S[de-1];if(Q+=v.skippedSegments*v.targetduration,Q>0&&de&&ee){v.averagetargetduration=Q/de;var te=ee.sn;v.endSN=te!=="initSegment"?te:0,pe&&(v.startCC=pe.cc,pe.initSegment||v.fragments.every(function(ie){return ie.relurl&&o(ie.relurl)})&&(E.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),q=new z.Fragment(a,p),q.relurl=ee.relurl,q.level=s,q.sn="initSegment",pe.initSegment=q,v.needSidxRanges=!0))}else v.endSN=0,v.startCC=0;return v.fragmentHint&&(Q+=v.fragmentHint.duration),v.totalduration=Q,v.endCC=G,De>0&&y(S,De),v},l}();function d(l,x){["video","audio","text"].forEach(function(f){var p=l.filter(function(a){return Object(L.isCodecType)(a,f)});if(p.length){var s=p.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});x[f+"Codec"]=s.length>0?s[0]:p[0],l=l.filter(function(a){return p.indexOf(a)===-1})}}),x.unknownCodecs=l}function _(l,x,f){var p=x[f];p&&(l[f]=p)}function y(l,x){for(var f=l[x],p=x;p--;){var s=l[p];if(!s)return;s.programDateTime=f.programDateTime-s.duration*1e3,f=s}}function m(l,x){l.rawProgramDateTime?l.programDateTime=Date.parse(l.rawProgramDateTime):x!=null&&x.programDateTime&&(l.programDateTime=x.endProgramDateTime),Object(X.isFiniteNumber)(l.programDateTime)||(l.programDateTime=null,l.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/polyfills/number.ts"),N=R("./src/events.ts"),I=R("./src/errors.ts"),z=R("./src/utils/logger.ts"),B=R("./src/utils/mp4-tools.ts"),O=R("./src/loader/m3u8-parser.ts"),D=R("./src/types/loader.ts"),E=R("./src/utils/attr-list.ts");function L(A){var C=A.type;switch(C){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(A,C){var h=A.url;return(h===void 0||h.indexOf("data:")===0)&&(h=C.url),h}var T=function(){function A(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var C=A.prototype;return C.registerListeners=function(){var o=this.hls;o.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.unregisterListeners=function(){var o=this.hls;o.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(N.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(N.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(N.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},C.createInternalLoader=function(o){var c=this.hls.config,d=c.pLoader,_=c.loader,y=d||_,m=new y(c);return o.loader=m,this.loaders[o.type]=m,m},C.getInternalLoader=function(o){return this.loaders[o.type]},C.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},C.destroyInternalLoaders=function(){for(var o in this.loaders){var c=this.loaders[o];c&&c.destroy(),this.resetInternalLoader(o)}},C.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},C.onManifestLoading=function(o,c){var d=c.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:D.PlaylistContextType.MANIFEST,url:d,deliveryDirectives:null})},C.onLevelLoading=function(o,c){var d=c.id,_=c.level,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:null,level:_,responseType:"text",type:D.PlaylistContextType.LEVEL,url:y,deliveryDirectives:m})},C.onAudioTrackLoading=function(o,c){var d=c.id,_=c.groupId,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.AUDIO_TRACK,url:y,deliveryDirectives:m})},C.onSubtitleTrackLoading=function(o,c){var d=c.id,_=c.groupId,y=c.url,m=c.deliveryDirectives;this.load({id:d,groupId:_,level:null,responseType:"text",type:D.PlaylistContextType.SUBTITLE_TRACK,url:y,deliveryDirectives:m})},C.load=function(o){var c,d=this.hls.config,_=this.getInternalLoader(o);if(_){var y=_.context;if(y&&y.url===o.url){z.logger.trace("[playlist-loader]: playlist request ongoing");return}z.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),_.abort()}var m,l,x,f;switch(o.type){case D.PlaylistContextType.MANIFEST:m=d.manifestLoadingMaxRetry,l=d.manifestLoadingTimeOut,x=d.manifestLoadingRetryDelay,f=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,f=d.levelLoadingMaxRetryTimeout;break}if(_=this.createInternalLoader(o),(c=o.deliveryDirectives)!==null&&c!==void 0&&c.part){var p;if(o.type===D.PlaylistContextType.LEVEL&&o.level!==null?p=this.hls.levels[o.level].details:o.type===D.PlaylistContextType.AUDIO_TRACK&&o.id!==null?p=this.hls.audioTracks[o.id].details:o.type===D.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(p=this.hls.subtitleTracks[o.id].details),p){var s=p.partTarget,a=p.targetduration;s&&a&&(l=Math.min(Math.max(s*3,a*.8)*1e3,l))}}var b={timeout:l,maxRetry:m,retryDelay:x,maxRetryDelay:f,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};_.load(o,b,v)},C.loadsuccess=function(o,c,d,_){if(_===void 0&&(_=null),d.isSidxRequest){this.handleSidxRequest(o,d),this.handlePlaylistLoaded(o,c,d,_);return}this.resetInternalLoader(d.type);var y=o.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,d,"no EXTM3U delimiter",_);return}c.parsing.start=performance.now(),y.indexOf("#EXTINF:")>0||y.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,c,d,_):this.handleMasterPlaylist(o,c,d,_)},C.loaderror=function(o,c,d){d===void 0&&(d=null),this.handleNetworkError(c,d,!1,o)},C.loadtimeout=function(o,c,d){d===void 0&&(d=null),this.handleNetworkError(c,d,!0)},C.handleMasterPlaylist=function(o,c,d,_){var y=this.hls,m=o.data,l=k(o,d),x=O.default.parseMasterPlaylist(m,l),f=x.levels,p=x.sessionData;if(!f.length){this.handleManifestParsingError(o,d,"no level found in manifest",_);return}var s=f.map(function(H){return{id:H.attrs.AUDIO,audioCodec:H.audioCodec}}),a=f.map(function(H){return{id:H.attrs.SUBTITLES,textCodec:H.textCodec}}),b=O.default.parseMasterPlaylistMedia(m,l,"AUDIO",s),v=O.default.parseMasterPlaylistMedia(m,l,"SUBTITLES",a),S=O.default.parseMasterPlaylistMedia(m,l,"CLOSED-CAPTIONS");if(b.length){var M=b.some(function(H){return!H.url});!M&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(z.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new E.AttrList({}),bitrate:0,url:""}))}y.trigger(N.Events.MANIFEST_LOADED,{levels:f,audioTracks:b,subtitles:v,captions:S,url:l,stats:c,networkDetails:_,sessionData:p})},C.handleTrackOrLevelPlaylist=function(o,c,d,_){var y=this.hls,m=d.id,l=d.level,x=d.type,f=k(o,d),p=Object(X.isFiniteNumber)(m)?m:0,s=Object(X.isFiniteNumber)(l)?l:p,a=L(d),b=O.default.parseLevelPlaylist(o.data,f,s,a,p);if(!b.fragments.length){y.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:typeof d.level=="number"?d.level:void 0});return}if(x===D.PlaylistContextType.MANIFEST){var v={attrs:new E.AttrList({}),bitrate:0,details:b,name:"",url:f};y.trigger(N.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:f,stats:c,networkDetails:_,sessionData:null})}if(c.parsing.end=performance.now(),b.needSidxRanges){var S,M=(S=b.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:M,isSidxRequest:!0,type:x,level:l,levelDetails:b,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}d.levelDetails=b,this.handlePlaylistLoaded(o,c,d,_)},C.handleSidxRequest=function(o,c){var d=Object(B.parseSegmentIndex)(new Uint8Array(o.data));if(!d)return;var _=d.references,y=c.levelDetails;_.forEach(function(m,l){var x=m.info,f=y.fragments[l];f.byteRange.length===0&&f.setByteRange(String(1+x.end-x.start)+"@"+String(x.start)),f.initSegment&&f.initSegment.setByteRange(String(d.moovEndOffset)+"@0")})},C.handleManifestParsingError=function(o,c,d,_){this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:c.type===D.PlaylistContextType.MANIFEST,url:o.url,reason:d,response:o,context:c,networkDetails:_})},C.handleNetworkError=function(o,c,d,_){d===void 0&&(d=!1),z.logger.warn("[playlist-loader]: A network "+(d?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var y=I.ErrorDetails.UNKNOWN,m=!1,l=this.getInternalLoader(o);switch(o.type){case D.PlaylistContextType.MANIFEST:y=d?I.ErrorDetails.MANIFEST_LOAD_TIMEOUT:I.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case D.PlaylistContextType.LEVEL:y=d?I.ErrorDetails.LEVEL_LOAD_TIMEOUT:I.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.AUDIO_TRACK:y=d?I.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case D.PlaylistContextType.SUBTITLE_TRACK:y=d?I.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:I.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}l&&this.resetInternalLoader(o.type);var x={type:I.ErrorTypes.NETWORK_ERROR,details:y,fatal:m,url:o.url,loader:l,context:o,networkDetails:c};_&&(x.response=_),this.hls.trigger(N.Events.ERROR,x)},C.handlePlaylistLoaded=function(o,c,d,_){var y=d.type,m=d.level,l=d.id,x=d.groupId,f=d.loader,p=d.levelDetails,s=d.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(o,d,"invalid target duration",_);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(y){case D.PlaylistContextType.MANIFEST:case D.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:p,level:m||0,id:l||0,stats:c,networkDetails:_,deliveryDirectives:s});break;case D.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:p,id:l||0,groupId:x||"",stats:c,networkDetails:_,deliveryDirectives:s});break;case D.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:p,id:l||0,groupId:x||"",stats:c,networkDetails:_,deliveryDirectives:s});break}},A}();$.default=T},"./src/polyfills/number.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isFiniteNumber",function(){return X}),R.d($,"MAX_SAFE_INTEGER",function(){return N});var X=Number.isFinite||function(I){return typeof I=="number"&&isFinite(I)},N=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ae,$,R){"use strict";R.r($);var X=function(){function N(){}return N.getSilentFrame=function(z,B){switch(z){case"mp4a.40.2":if(B===1)return new Uint8Array([0,200,0,128,35,128]);if(B===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(B===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(B===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(B===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(B===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(B===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(B===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(B===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},N}();$.default=X},"./src/remux/mp4-generator.ts":function(ae,$,R){"use strict";R.r($);var X=Math.pow(2,32)-1,N=function(){function I(){}return I.init=function(){I.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var B;for(B in I.types)I.types.hasOwnProperty(B)&&(I.types[B]=[B.charCodeAt(0),B.charCodeAt(1),B.charCodeAt(2),B.charCodeAt(3)]);var O=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]);I.HDLR_TYPES={video:O,audio:D};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);I.STTS=I.STSC=I.STCO=L,I.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),I.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),I.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),I.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]),A=new Uint8Array([0,0,0,1]);I.FTYP=I.box(I.types.ftyp,k,A,k,T),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,E))},I.box=function(B){for(var O=8,D=arguments.length,E=new Array(D>1?D-1:0),L=1;L<D;L++)E[L-1]=arguments[L];for(var k=E.length,T=k;k--;)O+=E[k].byteLength;var A=new Uint8Array(O);for(A[0]=O>>24&255,A[1]=O>>16&255,A[2]=O>>8&255,A[3]=O&255,A.set(B,4),k=0,O=8;k<T;k++)A.set(E[k],O),O+=E[k].byteLength;return A},I.hdlr=function(B){return I.box(I.types.hdlr,I.HDLR_TYPES[B])},I.mdat=function(B){return I.box(I.types.mdat,B)},I.mdhd=function(B,O){O*=B;var D=Math.floor(O/(X+1)),E=Math.floor(O%(X+1));return I.box(I.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,B>>24&255,B>>16&255,B>>8&255,B&255,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},I.mdia=function(B){return I.box(I.types.mdia,I.mdhd(B.timescale,B.duration),I.hdlr(B.type),I.minf(B))},I.mfhd=function(B){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,B>>24,B>>16&255,B>>8&255,B&255]))},I.minf=function(B){return B.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(B)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(B))},I.moof=function(B,O,D){return I.box(I.types.moof,I.mfhd(B),I.traf(D,O))},I.moov=function(B){for(var O=B.length,D=[];O--;)D[O]=I.trak(B[O]);return I.box.apply(null,[I.types.moov,I.mvhd(B[0].timescale,B[0].duration)].concat(D).concat(I.mvex(B)))},I.mvex=function(B){for(var O=B.length,D=[];O--;)D[O]=I.trex(B[O]);return I.box.apply(null,[I.types.mvex].concat(D))},I.mvhd=function(B,O){O*=B;var D=Math.floor(O/(X+1)),E=Math.floor(O%(X+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,B>>24&255,B>>16&255,B>>8&255,B&255,D>>24,D>>16&255,D>>8&255,D&255,E>>24,E>>16&255,E>>8&255,E&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 I.box(I.types.mvhd,L)},I.sdtp=function(B){var O=B.samples||[],D=new Uint8Array(4+O.length),E,L;for(E=0;E<O.length;E++)L=O[E].flags,D[E+4]=L.dependsOn<<4|L.isDependedOn<<2|L.hasRedundancy;return I.box(I.types.sdtp,D)},I.stbl=function(B){return I.box(I.types.stbl,I.stsd(B),I.box(I.types.stts,I.STTS),I.box(I.types.stsc,I.STSC),I.box(I.types.stsz,I.STSZ),I.box(I.types.stco,I.STCO))},I.avc1=function(B){var O=[],D=[],E,L,k;for(E=0;E<B.sps.length;E++)L=B.sps[E],k=L.byteLength,O.push(k>>>8&255),O.push(k&255),O=O.concat(Array.prototype.slice.call(L));for(E=0;E<B.pps.length;E++)L=B.pps[E],k=L.byteLength,D.push(k>>>8&255),D.push(k&255),D=D.concat(Array.prototype.slice.call(L));var T=I.box(I.types.avcC,new Uint8Array([1,O[3],O[4],O[5],252|3,224|B.sps.length].concat(O).concat([B.pps.length]).concat(D))),A=B.width,C=B.height,h=B.pixelRatio[0],o=B.pixelRatio[1];return I.box(I.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A>>8&255,A&255,C>>8&255,C&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),T,I.box(I.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),I.box(I.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,o>>24,o>>16&255,o>>8&255,o&255])))},I.esds=function(B){var O=B.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(B.config).concat([6,1,2]))},I.mp4a=function(B){var O=B.samplerate;return I.box(I.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,B.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),I.box(I.types.esds,I.esds(B)))},I.mp3=function(B){var O=B.samplerate;return I.box(I.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,B.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},I.stsd=function(B){return B.type==="audio"?!B.isAAC&&B.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(B)):I.box(I.types.stsd,I.STSD,I.mp4a(B)):I.box(I.types.stsd,I.STSD,I.avc1(B))},I.tkhd=function(B){var O=B.id,D=B.duration*B.timescale,E=B.width,L=B.height,k=Math.floor(D/(X+1)),T=Math.floor(D%(X+1));return I.box(I.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&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,E>>8&255,E&255,0,0,L>>8&255,L&255,0,0]))},I.traf=function(B,O){var D=I.sdtp(B),E=B.id,L=Math.floor(O/(X+1)),k=Math.floor(O%(X+1));return I.box(I.types.traf,I.box(I.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),I.box(I.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,k>>24,k>>16&255,k>>8&255,k&255])),I.trun(B,D.length+16+20+8+16+8+8),D)},I.trak=function(B){return B.duration=B.duration||4294967295,I.box(I.types.trak,I.tkhd(B),I.mdia(B))},I.trex=function(B){var O=B.id;return I.box(I.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},I.trun=function(B,O){var D=B.samples||[],E=D.length,L=12+16*E,k=new Uint8Array(L),T,A,C,h,o,c;for(O+=8+L,k.set([0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),T=0;T<E;T++)A=D[T],C=A.duration,h=A.size,o=A.flags,c=A.cts,k.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*T);return I.box(I.types.trun,k)},I.initSegment=function(B){I.types||I.init();var O=I.moov(B),D=new Uint8Array(I.FTYP.byteLength+O.byteLength);return D.set(I.FTYP),D.set(O,I.FTYP.byteLength),D},I}();N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0,$.default=N},"./src/remux/mp4-remuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return c}),R.d($,"normalizePts",function(){return d});var X=R("./src/polyfills/number.ts"),N=R("./src/remux/aac-helper.ts"),I=R("./src/remux/mp4-generator.ts"),z=R("./src/events.ts"),B=R("./src/errors.ts"),O=R("./src/utils/logger.ts"),D=R("./src/types/loader.ts"),E=R("./src/utils/timescale-conversion.ts");function L(){return L=Object.assign||function(l){for(var x=1;x<arguments.length;x++){var f=arguments[x];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(l[p]=f[p])}return l},L.apply(this,arguments)}var k=10*1e3,T=1024,A=1152,C=null,h=null,o=!1,c=function(){function l(f,p,s,a){if(a===void 0&&(a=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=f,this.config=p,this.typeSupported=s,this.ISGenerated=!1,C===null){var b=navigator.userAgent||"",v=b.match(/Chrome\/(\d+)/i);C=v?parseInt(v[1]):0}if(h===null){var S=navigator.userAgent.match(/Safari\/(\d+)/i);h=S?parseInt(S[1]):0}o=!!C&&C<75||!!h&&h<600}var x=l.prototype;return x.destroy=function(){},x.resetTimeStamp=function(p){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},x.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},x.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},x.getVideoStartPts=function(p){var s=!1,a=p.reduce(function(b,v){var S=v.pts-b;return S<-4294967296?(s=!0,d(b,v.pts)):S>0?b:v.pts},p[0].pts);return s&&O.logger.debug("PTS rollover detected"),a},x.remux=function(p,s,a,b,v,S,M,H){var V,Q,G,W,q,oe,fe=v,ve=v,De=p.pid>-1,Ee=s.pid>-1,_e=s.samples.length,Te=p.samples.length>0,Ce=_e>1,me=(!De||Te)&&(!Ee||Ce)||this.ISGenerated||M;if(me){this.ISGenerated||(G=this.generateIS(p,s,v));var ne=this.isVideoContiguous,Ae=-1;if(Ce&&(Ae=_(s.samples),!ne&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,Ae>0){O.logger.warn("[mp4-remuxer]: Dropped "+Ae+" out of "+_e+" video samples due to a missing keyframe");var rt=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(Ae),s.dropped+=Ae,ve+=(s.samples[0].pts-rt)/(s.timescale||9e4)}else Ae===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+_e+" video samples"),oe=!1);if(this.ISGenerated){if(Te&&Ce){var $e=this.getVideoStartPts(s.samples),Xe=d(p.samples[0].pts,$e)-$e,Ve=Xe/s.inputTimeScale;fe+=Math.max(0,Ve),ve+=Math.max(0,-Ve)}if(Te){if(p.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),G=this.generateIS(p,s,v)),Q=this.remuxAudio(p,fe,this.isAudioContiguous,S,Ee||Ce||H===D.PlaylistLevelType.AUDIO?ve:void 0),Ce){var Le=Q?Q.endPTS-Q.startPTS:0;s.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),G=this.generateIS(p,s,v)),V=this.remuxVideo(s,ve,ne,Le)}}else Ce&&(V=this.remuxVideo(s,ve,ne,0));V&&(V.firstKeyFrame=Ae,V.independent=Ae!==-1)}}return this.ISGenerated&&(a.samples.length&&(q=this.remuxID3(a,v)),b.samples.length&&(W=this.remuxText(b,v))),{audio:Q,video:V,initSegment:G,independent:oe,text:W,id3:q}},x.generateIS=function(p,s,a){var b=p.samples,v=s.samples,S=this.typeSupported,M={},H=!Object(X.isFiniteNumber)(this._initPTS),V="audio/mp4",Q,G,W;if(H&&(Q=G=Infinity),p.config&&b.length&&(p.timescale=p.samplerate,p.isAAC||(S.mpeg?(V="audio/mpeg",p.codec=""):S.mp3&&(p.codec="mp3")),M.audio={id:"audio",container:V,codec:p.codec,initSegment:!p.isAAC&&S.mpeg?new Uint8Array(0):I.default.initSegment([p]),metadata:{channelCount:p.channelCount}},H&&(W=p.inputTimeScale,Q=G=b[0].pts-Math.round(W*a))),s.sps&&s.pps&&v.length&&(s.timescale=s.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:I.default.initSegment([s]),metadata:{width:s.width,height:s.height}},H)){W=s.inputTimeScale;var q=this.getVideoStartPts(v),oe=Math.round(W*a);G=Math.min(G,d(v[0].dts,q)-oe),Q=Math.min(Q,q-oe)}if(Object.keys(M).length)return this.ISGenerated=!0,H&&(this._initPTS=Q,this._initDTS=G),{tracks:M,initPTS:Q,timescale:W}},x.remuxVideo=function(p,s,a,b){var v=p.inputTimeScale,S=p.samples,M=[],H=S.length,V=this._initPTS,Q=this.nextAvcDts,G=8,W,q,oe,fe=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,De=0,Ee=!1;if(!a||Q===null){var _e=s*v,Te=S[0].pts-d(S[0].dts,S[0].pts);Q=_e-Te}for(var Ce=0;Ce<H;Ce++){var me=S[Ce];if(me.pts=d(me.pts-V,Q),me.dts=d(me.dts-V,Q),me.dts>me.pts){var ne=9e4*.2;De=Math.max(Math.min(De,me.pts-me.dts),-1*ne)}me.dts<S[Ce>0?Ce-1:Ce].dts&&(Ee=!0)}Ee&&S.sort(function(Dt,Ze){var ut=Dt.dts-Ze.dts,Ft=Dt.pts-Ze.pts;return ut||Ft}),q=S[0].dts,oe=S[S.length-1].dts;var Ae=Math.round((oe-q)/(H-1));if(De<0){if(De<Ae*-2){O.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(E.toMsFromMpegTsClock)(-Ae,!0)+" ms");for(var rt=De,$e=0;$e<H;$e++)S[$e].dts=rt=Math.max(rt,S[$e].pts-Ae),S[$e].pts=Math.max(rt,S[$e].pts)}else{O.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(E.toMsFromMpegTsClock)(De,!0)+" ms to overcome this issue");for(var Xe=0;Xe<H;Xe++)S[Xe].dts=S[Xe].dts+De}q=S[0].dts}if(a){var Ve=q-Q,Le=Ve>Ae,Me=Ve<-1;if(Le||Me){Le?O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(Ve,!0)+" ms ("+Ve+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-Ve,!0)+" ms ("+Ve+"dts) overlapping between fragments detected"),q=Q;var ze=S[0].pts-Ve;S[0].dts=q,S[0].pts=ze,O.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(ze,!0)+"/"+Object(E.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Ve,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Ge=0,He=0,Be=0;Be<H;Be++){for(var Pe=S[Be],pt=Pe.units,it=pt.length,et=0,at=0;at<it;at++)et+=pt[at].data.length;He+=et,Ge+=it,Pe.length=et,Pe.dts=Math.max(Pe.dts,q),Pe.pts=Math.max(Pe.pts,Pe.dts,0),fe=Math.min(Pe.pts,fe),ve=Math.max(Pe.pts,ve)}oe=S[H-1].dts;var Et=He+4*Ge+8,ct;try{ct=new Uint8Array(Et)}catch(Dt){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Et,reason:"fail allocating video mdat "+Et});return}var dt=new DataView(ct.buffer);dt.setUint32(0,Et),ct.set(I.default.types.mdat,4);for(var we=0;we<H;we++){for(var gt=S[we],lt=gt.units,Re=0,je=0,ge=lt.length;je<ge;je++){var de=lt[je],pe=de.data,ee=de.data.byteLength;dt.setUint32(G,ee),G+=4,ct.set(pe,G),G+=ee,Re+=4+ee}if(we<H-1)W=S[we+1].dts-gt.dts;else{var te=this.config,ie=gt.dts-S[we>0?we-1:we].dts;if(te.stretchShortVideoTrack&&this.nextAudioPts!==null){var se=Math.floor(te.maxBufferHole*v),ue=(b?fe+b*v:this.nextAudioPts)-gt.pts;ue>se?(W=ue-ie,W<0&&(W=ie),O.logger.log("[mp4-remuxer]: It is approximately "+ue/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=ie}else W=ie}var Se=Math.round(gt.pts-gt.dts);M.push(new y(gt.key,W,Re,Se))}if(M.length&&C&&C<70){var ke=M[0].flags;ke.dependsOn=2,ke.isNonSync=0}console.assert(W!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=oe+W,this.isVideoContiguous=!0;var Je=I.default.moof(p.sequenceNumber++,q,L({},p,{samples:M})),Qe="video",bt={data1:Je,data2:ct,startPTS:fe/v,endPTS:(ve+W)/v,startDTS:q/v,endDTS:Q/v,type:Qe,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(ct.length,"MDAT length must not be zero"),bt},x.remuxAudio=function(p,s,a,b,v){var S=p.inputTimeScale,M=p.samplerate?p.samplerate:S,H=S/M,V=p.isAAC?T:A,Q=V*H,G=this._initPTS,W=!p.isAAC&&this.typeSupported.mpeg,q=[],oe=p.samples,fe=W?0:8,ve=this.nextAudioPts||-1,De=s*S;if(this.isAudioContiguous=a=a||oe.length&&ve>0&&(b&&Math.abs(De-ve)<9e3||Math.abs(d(oe[0].pts-G,De)-ve)<20*Q),oe.forEach(function(pe){pe.pts=d(pe.pts-G,De)}),!a||ve<0){if(oe=oe.filter(function(pe){return pe.pts>=0}),!oe.length)return;v===0?ve=0:b?ve=Math.max(0,De):ve=oe[0].pts}if(p.isAAC)for(var Ee=v!==void 0,_e=this.config.maxAudioFramesDrift,Te=0,Ce=ve;Te<oe.length;Te++){var me=oe[Te],ne=me.pts,Ae=ne-Ce,rt=Math.abs(1e3*Ae/S);if(Ae<=-_e*Q&&Ee)Te===0&&(O.logger.warn("Audio frame @ "+(ne/S).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Ae/S)+" ms."),this.nextAudioPts=ve=Ce=ne);else if(Ae>=_e*Q&&rt<k&&Ee){var $e=Math.round(Ae/Q);Ce=ne-$e*Q,Ce<0&&($e--,Ce+=Q),Te===0&&(this.nextAudioPts=ve=Ce),O.logger.warn("[mp4-remuxer]: Injecting "+$e+" audio frame @ "+(Ce/S).toFixed(3)+"s due to "+Math.round(1e3*Ae/S)+" ms gap.");for(var Xe=0;Xe<$e;Xe++){var Ve=Math.max(Ce,0),Le=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);Le||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=me.unit.subarray()),oe.splice(Te,0,{unit:Le,pts:Ve}),Ce+=Q,Te++}}me.pts=Ce,Ce+=Q}for(var Me=null,ze=null,Ge,He=0,Be=oe.length;Be--;)He+=oe[Be].unit.byteLength;for(var Pe=0,pt=oe.length;Pe<pt;Pe++){var it=oe[Pe],et=it.unit,at=it.pts;if(ze!==null){var Et=q[Pe-1];Et.duration=Math.round((at-ze)/H)}else if(a&&p.isAAC&&(at=ve),Me=at,He>0){He+=fe;try{Ge=new Uint8Array(He)}catch(pe){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:He,reason:"fail allocating audio mdat "+He});return}if(!W){var ct=new DataView(Ge.buffer);ct.setUint32(0,He),Ge.set(I.default.types.mdat,4)}}else return;Ge.set(et,fe);var dt=et.byteLength;fe+=dt,q.push(new y(!0,V,dt,0)),ze=at}var we=q.length;if(!we)return;var gt=q[q.length-1];this.nextAudioPts=ve=ze+H*gt.duration;var lt=W?new Uint8Array(0):I.default.moof(p.sequenceNumber++,Me/H,L({},p,{samples:q}));p.samples=[];var Re=Me/S,je=ve/S,ge="audio",de={data1:lt,data2:Ge,startPTS:Re,endPTS:je,startDTS:Re,endDTS:je,type:ge,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(Ge.length,"MDAT length must not be zero"),de},x.remuxEmptyAudio=function(p,s,a,b){var v=p.inputTimeScale,S=p.samplerate?p.samplerate:v,M=v/S,H=this.nextAudioPts,V=(H!==null?H:b.startDTS*v)+this._initDTS,Q=b.endDTS*v+this._initDTS,G=M*T,W=Math.ceil((Q-V)/G),q=N.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!q){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var oe=[],fe=0;fe<W;fe++){var ve=V+fe*G;oe.push({unit:q,pts:ve,dts:ve})}return p.samples=oe,this.remuxAudio(p,s,a,!1)},x.remuxID3=function(p,s){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,v=this._initPTS,S=this._initDTS,M=0;M<a;M++){var H=p.samples[M];H.pts=d(H.pts-v,s*b)/b,H.dts=d(H.dts-S,s*b)/b}var V=p.samples;return p.samples=[],{samples:V}},x.remuxText=function(p,s){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,v=this._initPTS,S=0;S<a;S++){var M=p.samples[S];M.pts=d(M.pts-v,s*b)/b}p.samples.sort(function(V,Q){return V.pts-Q.pts});var H=p.samples;return p.samples=[],{samples:H}},l}();function d(l,x){var f;if(x===null)return l;for(x<l?f=-8589934592:f=8589934592;Math.abs(l-x)>4294967296;)l+=f;return l}function _(l){for(var x=0;x<l.length;x++)if(l[x].key)return x;return-1}var y=function(x,f,p,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=f,this.size=p,this.cts=s,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(ae,$,R){"use strict";R.r($);var X=R("./src/polyfills/number.ts"),N=R("./src/utils/mp4-tools.ts"),I=R("./src/loader/fragment.ts"),z=R("./src/utils/logger.ts"),B=function(){function E(){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 L=E.prototype;return L.destroy=function(){},L.resetTimeStamp=function(T){this.initPTS=T,this.lastEndDTS=null},L.resetNextTimestamp=function(){this.lastEndDTS=null},L.resetInitSegment=function(T,A,C){this.audioCodec=A,this.videoCodec=C,this.generateInitSegment(T),this.emitInitSegment=!0},L.generateInitSegment=function(T){var A=this.audioCodec,C=this.videoCodec;if(!T||!T.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(N.parseInitSegment)(T);A||(A=D(h.audio,I.ElementaryStreamTypes.AUDIO)),C||(C=D(h.video,I.ElementaryStreamTypes.VIDEO));var o={};h.audio&&h.video?o.audiovideo={container:"video/mp4",codec:A+","+C,initSegment:T,id:"main"}:h.audio?o.audio={container:"audio/mp4",codec:A,initSegment:T,id:"audio"}:h.video?o.video={container:"video/mp4",codec:C,initSegment:T,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},L.remux=function(T,A,C,h,o){var c=this.initPTS,d=this.lastEndDTS,_={audio:void 0,video:void 0,text:h,id3:C,initSegment:void 0};Object(X.isFiniteNumber)(d)||(d=this.lastEndDTS=o||0);var y=A.samples;if(!y||!y.length)return _;var m={initPTS:void 0,timescale:1},l=this.initData;if((!l||!l.length)&&(this.generateInitSegment(y),l=this.initData),!l||!l.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),_;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1),Object(X.isFiniteNumber)(c)||(this.initPTS=m.initPTS=c=O(l,y,d));var x=Object(N.getDuration)(y,l),f=d,p=x+f;Object(N.offsetStartDTS)(l,y,c),x>0?this.lastEndDTS=p:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!l.audio,a=!!l.video,b="";s&&(b+="audio"),a&&(b+="video");var v={data1:y,startPTS:f,startDTS:f,endPTS:p,endDTS:p,type:b,hasAudio:s,hasVideo:a,nb:1,dropped:0};return _.audio=v.type==="audio"?v:void 0,_.video=v.type!=="audio"?v:void 0,_.text=h,_.id3=C,_.initSegment=m,_},E}(),O=function(L,k,T){return Object(N.getStartDTS)(L,k)-T};function D(E,L){var k=E==null?void 0:E.codec;return k&&k.length>4?k:k==="hvc1"?"hvc1.1.c.L120.90":k==="av01"?"av01.0.04M.08":k==="avc1"||L===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=B},"./src/task-loop.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return X});var X=function(){function N(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var I=N.prototype;return I.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},I.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},I.onHandlerDestroyed=function(){},I.hasInterval=function(){return!!this._tickInterval},I.hasNextTick=function(){return!!this._tickTimer},I.setInterval=function(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!0)},I.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},I.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},I.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},I.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},I.doTick=function(){},N}()},"./src/types/cmcd.ts":function(ae,$,R){"use strict";R.r($),R.d($,"CMCDVersion",function(){return X}),R.d($,"CMCDObjectType",function(){return N}),R.d($,"CMCDStreamingFormat",function(){return I}),R.d($,"CMCDStreamType",function(){return z});var X=1,N;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(N||(N={}));var I;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(I||(I={}));var z;(function(B){B.VOD="v",B.LIVE="l"})(z||(z={}))},"./src/types/level.ts":function(ae,$,R){"use strict";R.r($),R.d($,"HlsSkip",function(){return I}),R.d($,"getSkipValue",function(){return z}),R.d($,"HlsUrlParameters",function(){return B}),R.d($,"Level",function(){return O});function X(D,E){for(var L=0;L<E.length;L++){var k=E[L];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(D,k.key,k)}}function N(D,E,L){return E&&X(D.prototype,E),L&&X(D,L),D}var I;(function(D){D.No="",D.Yes="YES",D.v2="v2"})(I||(I={}));function z(D,E){var L=D.canSkipUntil,k=D.canSkipDateRanges,T=D.endSN,A=E!==void 0?E-T:0;return L&&A<L?k?I.v2:I.Yes:I.No}var B=function(){function D(L,k,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=L,this.part=k,this.skip=T}var E=D.prototype;return E.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}(),O=function(){function D(E){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=[E.url],this.attrs=E.attrs,this.bitrate=E.bitrate,E.details&&(this.details=E.details),this.id=E.id||0,this.name=E.name,this.width=E.width||0,this.height=E.height||0,this.audioCodec=E.audioCodec,this.videoCodec=E.videoCodec,this.unknownCodecs=E.unknownCodecs,this.codecSet=[E.videoCodec,E.audioCodec].filter(function(L){return L}).join(",").replace(/\.[^.,]+/g,"")}return N(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(L){var k=L%this.url.length;this._urlId!==k&&(this.details=void 0,this._urlId=k)}}]),D}()},"./src/types/loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"PlaylistContextType",function(){return X}),R.d($,"PlaylistLevelType",function(){return N});var X;(function(I){I.MANIFEST="manifest",I.LEVEL="level",I.AUDIO_TRACK="audioTrack",I.SUBTITLE_TRACK="subtitleTrack"})(X||(X={}));var N;(function(I){I.MAIN="main",I.AUDIO="audio",I.SUBTITLE="subtitle"})(N||(N={}))},"./src/types/transmuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"ChunkMetadata",function(){return X});var X=function(z,B,O,D,E,L){D===void 0&&(D=0),E===void 0&&(E=-1),L===void 0&&(L=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=N(),this.buffering={audio:N(),video:N(),audiovideo:N()},this.level=z,this.sn=B,this.id=O,this.size=D,this.part=E,this.partial=L};function N(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ae,$,R){"use strict";R.r($),R.d($,"AttrList",function(){return I});var X=/^(\d+)x(\d+)$/,N=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,I=function(){function z(O){typeof O=="string"&&(O=z.parseAttrList(O));for(var D in O)O.hasOwnProperty(D)&&(this[D]=O[D])}var B=z.prototype;return B.decimalInteger=function(D){var E=parseInt(this[D],10);return E>Number.MAX_SAFE_INTEGER?Infinity:E},B.hexadecimalInteger=function(D){if(this[D]){var E=(this[D]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var L=new Uint8Array(E.length/2),k=0;k<E.length/2;k++)L[k]=parseInt(E.slice(k*2,k*2+2),16);return L}else return null},B.hexadecimalIntegerAsNumber=function(D){var E=parseInt(this[D],16);return E>Number.MAX_SAFE_INTEGER?Infinity:E},B.decimalFloatingPoint=function(D){return parseFloat(this[D])},B.optionalFloat=function(D,E){var L=this[D];return L?parseFloat(L):E},B.enumeratedString=function(D){return this[D]},B.bool=function(D){return this[D]==="YES"},B.decimalResolution=function(D){var E=X.exec(this[D]);return E===null?void 0:{width:parseInt(E[1],10),height:parseInt(E[2],10)}},z.parseAttrList=function(D){var E,L={},k='"';for(N.lastIndex=0;(E=N.exec(D))!==null;){var T=E[2];T.indexOf(k)===0&&T.lastIndexOf(k)===T.length-1&&(T=T.slice(1,-1)),L[E[1]]=T}return L},z}()},"./src/utils/binary-search.ts":function(ae,$,R){"use strict";R.r($);var X={search:function(I,z){for(var B=0,O=I.length-1,D=null,E=null;B<=O;){D=(B+O)/2|0,E=I[D];var L=z(E);if(L>0)B=D+1;else if(L<0)O=D-1;else return E}return null}};$.default=X},"./src/utils/buffer-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"BufferHelper",function(){return I});var X=R("./src/utils/logger.ts"),N={length:0,start:function(){return 0},end:function(){return 0}},I=function(){function z(){}return z.isBuffered=function(O,D){try{if(O){for(var E=z.getBuffered(O),L=0;L<E.length;L++)if(D>=E.start(L)&&D<=E.end(L))return!0}}catch(k){}return!1},z.bufferInfo=function(O,D,E){try{if(O){var L=z.getBuffered(O),k=[],T;for(T=0;T<L.length;T++)k.push({start:L.start(T),end:L.end(T)});return this.bufferedInfo(k,D,E)}}catch(A){}return{len:0,start:D,end:D,nextStart:void 0}},z.bufferedInfo=function(O,D,E){D=Math.max(0,D),O.sort(function(m,l){var x=m.start-l.start;return x||l.end-m.end});var L=[];if(E)for(var k=0;k<O.length;k++){var T=L.length;if(T){var A=L[T-1].end;O[k].start-A<E?O[k].end>A&&(L[T-1].end=O[k].end):L.push(O[k])}else L.push(O[k])}else L=O;for(var C=0,h,o=D,c=D,d=0;d<L.length;d++){var _=L[d].start,y=L[d].end;if(D+E>=_&&D<y)o=_,c=y,C=c-D;else if(D+E<_){h=_;break}}return{len:C,start:o||0,end:c||0,nextStart:h}},z.getBuffered=function(O){try{return O.buffered}catch(D){return X.logger.log("failed to get media.buffered",D),N}},z}()},"./src/utils/cea-608-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"Row",function(){return c}),R.d($,"CaptionScreen",function(){return d});var X=R("./src/utils/logger.ts"),N={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},I=function(p){var s=p;return N.hasOwnProperty(p)&&(s=N[p]),String.fromCharCode(s)},z=15,B=100,O={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},E={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},L={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(f){f[f.ERROR=0]="ERROR",f[f.TEXT=1]="TEXT",f[f.WARNING=2]="WARNING",f[f.INFO=2]="INFO",f[f.DEBUG=3]="DEBUG",f[f.DATA=3]="DATA"})(T||(T={}));var A=function(){function f(){this.time=null,this.verboseLevel=T.ERROR}var p=f.prototype;return p.log=function(a,b){this.verboseLevel>=a&&X.logger.log(this.time+" ["+a+"] "+b)},f}(),C=function(p){for(var s=[],a=0;a<p.length;a++)s.push(p[a].toString(16));return s},h=function(){function f(s,a,b,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=s||"white",this.underline=a||!1,this.italics=b||!1,this.background=v||"black",this.flash=S||!1}var p=f.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(a){for(var b=["foreground","underline","italics","background","flash"],v=0;v<b.length;v++){var S=b[v];a.hasOwnProperty(S)&&(this[S]=a[S])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},p.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},f}(),o=function(){function f(s,a,b,v,S,M){this.uchar=void 0,this.penState=void 0,this.uchar=s||" ",this.penState=new h(a,b,v,S,M)}var p=f.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(a,b){this.uchar=a,this.penState.copy(b)},p.setPenState=function(a){this.penState.copy(a)},p.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},p.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},p.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},f}(),c=function(){function f(s){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<B;a++)this.chars.push(new o);this.logger=s,this.pos=0,this.currPenState=new h}var p=f.prototype;return p.equals=function(a){for(var b=!0,v=0;v<B;v++)if(!this.chars[v].equals(a.chars[v])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<B;b++)this.chars[b].copy(a.chars[b])},p.isEmpty=function(){for(var a=!0,b=0;b<B;b++)if(!this.chars[b].isEmpty()){a=!1;break}return a},p.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(T.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>B&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},p.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var v=this.pos+1;v<b+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(b)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(a){a>=144&&this.backSpace();var b=I(a);if(this.pos>=B){this.logger.log(T.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(a){var b;for(b=a;b<B;b++)this.chars[b].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var a=[],b=!0,v=0;v<B;v++){var S=this.chars[v].uchar;S!==" "&&(b=!1),a.push(S)}return b?"":a.join("")},p.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.setPenState(this.currPenState)},f}(),d=function(){function f(s){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<z;a++)this.rows.push(new c(s));this.logger=s,this.currRow=z-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=f.prototype;return p.reset=function(){for(var a=0;a<z;a++)this.rows[a].clear();this.currRow=z-1},p.equals=function(a){for(var b=!0,v=0;v<z;v++)if(!this.rows[v].equals(a.rows[v])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<z;b++)this.rows[b].copy(a.rows[b])},p.isEmpty=function(){for(var a=!0,b=0;b<z;b++)if(!this.rows[b].isEmpty()){a=!1;break}return a},p.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},p.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},p.insertChar=function(a){var b=this.rows[this.currRow];b.insertChar(a)},p.setPen=function(a){var b=this.rows[this.currRow];b.setPenStyles(a)},p.moveCursor=function(a){var b=this.rows[this.currRow];b.moveCursor(a)},p.setCursor=function(a){this.logger.log(T.INFO,"setCursor: "+a);var b=this.rows[this.currRow];b.setCursor(a)},p.setPAC=function(a){this.logger.log(T.INFO,"pacData = "+JSON.stringify(a));var b=a.row-1;if(this.nrRollUpRows&&b<this.nrRollUpRows-1&&(b=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==b){for(var v=0;v<z;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,M=this.lastOutputScreen;if(M){var H=M.rows[S].cueStartTime,V=this.logger.time;if(H&&V!==null&&H<V)for(var Q=0;Q<this.nrRollUpRows;Q++)this.rows[b-this.nrRollUpRows+Q+1].copy(M.rows[S+Q])}}this.currRow=b;var G=this.rows[this.currRow];if(a.indent!==null){var W=a.indent,q=Math.max(W-1,0);G.setCursor(a.indent),a.color=G.chars[q].penState.foreground}var oe={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(oe)},p.setBkgData=function(a){this.logger.log(T.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},p.setRollUpRows=function(a){this.nrRollUpRows=a},p.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(T.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(T.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,b=this.rows.splice(a,1)[0];b.clear(),this.rows.splice(this.currRow,0,b),this.logger.log(T.INFO,"Rolling up")},p.getDisplayText=function(a){a=a||!1;for(var b=[],v="",S=-1,M=0;M<z;M++){var H=this.rows[M].getTextString();H&&(S=M+1,a?b.push("Row "+S+": '"+H+"'"):b.push(H.trim()))}return b.length>0&&(a?v="["+b.join(" | ")+"]":v=b.join(`
|
|
`)),v},p.getTextAndFormat=function(){return this.rows},f}(),_=function(){function f(s,a,b){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=s,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new d(b),this.nonDisplayedMemory=new d(b),this.lastOutputScreen=new d(b),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}var p=f.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[z-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(a){this.outputFilter=a},p.setPAC=function(a){this.writeScreen.setPAC(a)},p.setBkgData=function(a){this.writeScreen.setBkgData(a)},p.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(T.INFO,"MODE="+a),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=a},p.insertChars=function(a){for(var b=0;b<a.length;b++)this.writeScreen.insertChar(a[b]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(T.INFO,v+": "+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())},p.ccRCL=function(){this.logger.log(T.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){if(this.logger.log(T.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(T.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.ccRU=function(a){this.logger.log(T.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},p.ccFON=function(){this.logger.log(T.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(T.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(T.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(T.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(T.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(T.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(T.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.ccEOC=function(){if(this.logger.log(T.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(T.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(a){this.logger.log(T.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},p.ccMIDROW=function(a){var b={flash:!1};if(b.underline=a%2===1,b.italics=a>=46,b.italics)b.foreground="white";else{var v=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=S[v]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},p.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},f}(),y=function(){function f(s,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new A;this.channels=[null,new _(s,a,v),new _(s+1,b,v)],this.cmdHistory=x(),this.logger=v}var p=f.prototype;return p.getHandler=function(a){return this.channels[a].getHandler()},p.setHandler=function(a,b){this.channels[a].setHandler(b)},p.addData=function(a,b){var v,S,M,H=!1;this.logger.time=a;for(var V=0;V<b.length;V+=2){if(S=b[V]&127,M=b[V+1]&127,S===0&&M===0)continue;if(this.logger.log(T.DATA,"["+C([b[V],b[V+1]])+"] -> ("+C([S,M])+")"),v=this.parseCmd(S,M),v||(v=this.parseMidrow(S,M)),v||(v=this.parsePAC(S,M)),v||(v=this.parseBackgroundAttributes(S,M)),!v&&(H=this.parseChars(S,M),H)){var Q=this.currentChannel;if(Q&&Q>0){var G=this.channels[Q];G.insertChars(H)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!H&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+C([S,M])+" orig: "+C([b[V],b[V+1]]))}},p.parseCmd=function(a,b){var v=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,M=(a===23||a===31)&&b>=33&&b<=35;if(!(S||M))return!1;if(l(a,b,v))return m(null,null,v),this.logger.log(T.DEBUG,"Repeated command ("+C([a,b])+") is dropped"),!0;var H=a===20||a===21||a===23?1:2,V=this.channels[H];return a===20||a===21||a===28||a===29?b===32?V.ccRCL():b===33?V.ccBS():b===34?V.ccAOF():b===35?V.ccAON():b===36?V.ccDER():b===37?V.ccRU(2):b===38?V.ccRU(3):b===39?V.ccRU(4):b===40?V.ccFON():b===41?V.ccRDC():b===42?V.ccTR():b===43?V.ccRTD():b===44?V.ccEDM():b===45?V.ccCR():b===46?V.ccENM():b===47&&V.ccEOC():V.ccTO(b-32),m(a,b,v),this.currentChannel=H,!0},p.parseMidrow=function(a,b){var v=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(b),this.logger.log(T.DEBUG,"MIDROW ("+C([a,b])+")"),!0):!1}return!1},p.parsePAC=function(a,b){var v,S=this.cmdHistory,M=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,H=(a===16||a===24)&&b>=64&&b<=95;if(!(M||H))return!1;if(l(a,b,S))return m(null,null,S),!0;var V=a<=23?1:2;b>=64&&b<=95?v=V===1?O[a]:E[a]:v=V===1?D[a]:L[a];var Q=this.channels[V];return Q?(Q.setPAC(this.interpretPAC(v,b)),m(a,b,S),this.currentChannel=V,!0):!1},p.interpretPAC=function(a,b){var v,S={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?v=b-96:v=b-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},p.parseChars=function(a,b){var v,S=null,M=null;if(a>=25?(v=2,M=a-8):(v=1,M=a),M>=17&&M<=19){var H;M===17?H=b+80:M===18?H=b+112:H=b+144,this.logger.log(T.INFO,"Special char '"+I(H)+"' in channel "+v),S=[H]}else a>=32&&a<=127&&(S=b===0?[a]:[a,b]);if(S){var V=C(S);this.logger.log(T.DEBUG,"Char codes = "+V.join(",")),m(a,b,this.cmdHistory)}return S},p.parseBackgroundAttributes=function(a,b){var v=(a===16||a===24)&&b>=32&&b<=47,S=(a===23||a===31)&&b>=45&&b<=47;if(!(v||S))return!1;var M,H={};a===16||a===24?(M=Math.floor((b-32)/2),H.background=k[M],b%2===1&&(H.background=H.background+"_semi")):b===45?H.background="transparent":(H.foreground="black",b===47&&(H.underline=!0));var V=a<=23?1:2,Q=this.channels[V];return Q.setBkgData(H),m(a,b,this.cmdHistory),!0},p.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var b=this.channels[a];b&&b.reset()}this.cmdHistory=x()},p.cueSplitAtTime=function(a){for(var b=0;b<this.channels.length;b++){var v=this.channels[b];v&&v.cueSplitAtTime(a)}},f}();function m(f,p,s){s.a=f,s.b=p}function l(f,p,s){return s.a===f&&s.b===p}function x(){return{a:null,b:null}}$.default=y},"./src/utils/codecs.ts":function(ae,$,R){"use strict";R.r($),R.d($,"isCodecType",function(){return N}),R.d($,"isCodecSupportedInMp4",function(){return I});var X={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function N(z,B){var O=X[B];return!!O&&O[z.slice(0,4)]===!0}function I(z,B){return MediaSource.isTypeSupported((B||"video")+'/mp4;codecs="'+z+'"')}},"./src/utils/cues.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/vttparser.ts"),N=R("./src/utils/webvtt-parser.ts"),I=R("./src/utils/texttrack-utils.ts"),z=/\s/,B={newCue:function(D,E,L,k){for(var T=[],A,C,h,o,c,d=self.VTTCue||self.TextTrackCue,_=0;_<k.rows.length;_++)if(A=k.rows[_],h=!0,o=0,c="",!A.isEmpty()){for(var y=0;y<A.chars.length;y++)z.test(A.chars[y].uchar)&&h?o++:(c+=A.chars[y].uchar,h=!1);A.cueStartTime=E,E===L&&(L+=1e-4),o>=16?o--:o++;var m=Object(X.fixLineBreaks)(c.trim()),l=Object(N.generateCueId)(E,L,m);(!D||!D.cues||!D.cues.getCueById(l))&&(C=new d(E,L,m),C.id=l,C.line=_+1,C.align="left",C.position=10+Math.min(80,Math.floor(o*8/32)*10),T.push(C))}return D&&T.length&&(T.sort(function(x,f){return x.line==="auto"||f.line==="auto"?0:x.line>8&&f.line>8?f.line-x.line:x.line-f.line}),T.forEach(function(x){return Object(I.addCueToTrack)(D,x)})),T}};$.default=B},"./src/utils/discontinuities.ts":function(ae,$,R){"use strict";R.r($),R.d($,"findFirstFragWithCC",function(){return z}),R.d($,"shouldAlignOnDiscontinuities",function(){return B}),R.d($,"findDiscontinuousReferenceFrag",function(){return O}),R.d($,"adjustSlidingStart",function(){return E}),R.d($,"alignStream",function(){return L}),R.d($,"alignPDT",function(){return T}),R.d($,"alignFragmentByPDTDelta",function(){return A}),R.d($,"alignMediaPlaylistByPDT",function(){return C});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/logger.ts"),I=R("./src/controller/level-helper.ts");function z(h,o){for(var c=null,d=0,_=h.length;d<_;d++){var y=h[d];if(y&&y.cc===o){c=y;break}}return c}function B(h,o,c){return!!(o.details&&(c.endCC>c.startCC||h&&h.cc<c.startCC))}function O(h,o){var c=h.fragments,d=o.fragments;if(!d.length||!c.length){N.logger.log("No fragments to align");return}var _=z(c,d[0].cc);if(!_||_&&!_.startPTS){N.logger.log("No frag in previous level to align on");return}return _}function D(h,o){if(h){var c=h.start+o;h.start=h.startPTS=c,h.endPTS=c+h.duration}}function E(h,o){for(var c=o.fragments,d=0,_=c.length;d<_;d++)D(c[d],h);o.fragmentHint&&D(o.fragmentHint,h),o.alignedSliding=!0}function L(h,o,c){if(!o)return;k(h,c,o),!c.alignedSliding&&o.details&&T(c,o.details),!c.alignedSliding&&o.details&&!c.skippedSegments&&Object(I.adjustSliding)(o.details,c)}function k(h,o,c){if(B(h,c,o)){var d=O(c.details,o);d&&Object(X.isFiniteNumber)(d.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),E(d.start,o))}}function T(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var c=o.fragments[0].programDateTime,d=h.fragments[0].programDateTime,_=(d-c)/1e3+o.fragments[0].start;_&&Object(X.isFiniteNumber)(_)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(d-c)+"ms, sliding:"+_.toFixed(3)+" "+h.url+" "),E(_,h))}function A(h,o){var c=h.programDateTime;if(!c)return;var d=(c-o)/1e3;h.start=h.startPTS=d,h.endPTS=d+h.duration}function C(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var c=o.fragments[0].programDateTime,d=o.fragments[0].start,_=c-d*1e3;h.fragments.forEach(function(y){A(y,_)}),h.fragmentHint&&A(h.fragmentHint,_),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/ewma.ts"),N=function(){function I(B,O,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 X.default(B),this.fast_=new X.default(O)}var z=I.prototype;return z.update=function(O,D){var E=this.slow_,L=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new X.default(O,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==D&&(this.fast_=new X.default(D,L.getEstimate(),L.getTotalWeight()))},z.sample=function(O,D){O=Math.max(O,this.minDelayMs_);var E=8*D,L=O/1e3,k=E/L;this.fast_.sample(L,k),this.slow_.sample(L,k)},z.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},z.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},z.destroy=function(){},I}();$.default=N},"./src/utils/ewma.ts":function(ae,$,R){"use strict";R.r($);var X=function(){function N(z,B,O){B===void 0&&(B=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=z,this.alpha_=z?Math.exp(Math.log(.5)/z):0,this.estimate_=B,this.totalWeight_=O}var I=N.prototype;return I.sample=function(B,O){var D=Math.pow(this.alpha_,B);this.estimate_=O*(1-D)+D*this.estimate_,this.totalWeight_+=B},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var B=1-Math.pow(this.alpha_,this.totalWeight_);if(B)return this.estimate_/B}return this.estimate_},N}();$.default=X},"./src/utils/fetch-loader.ts":function(ae,$,R){"use strict";R.r($),R.d($,"fetchSupported",function(){return A});var X=R("./src/polyfills/number.ts"),N=R("./src/loader/load-stats.ts"),I=R("./src/demux/chunk-cache.ts");function z(d,_){d.prototype=Object.create(_.prototype),d.prototype.constructor=d,L(d,_)}function B(d){var _=typeof Map=="function"?new Map:void 0;return B=function(m){if(m===null||!E(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 O(m,arguments,k(this).constructor)}return l.prototype=Object.create(m.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),L(l,m)},B(d)}function O(d,_,y){return D()?O=Reflect.construct:O=function(l,x,f){var p=[null];p.push.apply(p,x);var s=Function.bind.apply(l,p),a=new s;return f&&L(a,f.prototype),a},O.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 E(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function L(d,_){return L=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},L(d,_)}function k(d){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(y){return y.__proto__||Object.getPrototypeOf(y)},k(d)}function T(){return T=Object.assign||function(d){for(var _=1;_<arguments.length;_++){var y=arguments[_];for(var m in y)Object.prototype.hasOwnProperty.call(y,m)&&(d[m]=y[m])}return d},T.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(d){}return!1}var C=function(){function d(y){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=y.fetchSetup||o,this.controller=new self.AbortController,this.stats=new N.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 f=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var s=h(m,this.controller.signal),a=x.onProgress,b=m.responseType==="arraybuffer",v=b?"byteLength":"length";this.context=m,this.config=l,this.callbacks=x,this.request=this.fetchSetup(m,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),x.onTimeout(p,m,f.response)},l.timeout),self.fetch(this.request).then(function(S){if(f.response=f.loader=S,!S.ok){var M=S.status,H=S.statusText;throw new c(H||"fetch, bad network response",M,S)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(X.isFiniteNumber)(l.highWaterMark)?f.loadProgressively(S,p,m,l.highWaterMark,a):b?S.arrayBuffer():S.text()}).then(function(S){var M=f.response;self.clearTimeout(f.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=S[v];var H={url:M.url,data:S};a&&!Object(X.isFiniteNumber)(l.highWaterMark)&&a(p,m,S,M),x.onSuccess(H,p,m,M)}).catch(function(S){if(self.clearTimeout(f.requestTimeout),p.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,f,p){f===void 0&&(f=0);var s=new I.default,a=m.body.getReader(),b=function v(){return a.read().then(function(S){if(S.done)return s.dataLength&&p(l,x,s.flush(),m),Promise.resolve(new ArrayBuffer(0));var M=S.value,H=M.length;return l.loaded+=H,H<f||s.dataLength?(s.push(M),s.dataLength>=f&&p(l,x,s.flush(),m)):p(l,x,M,m),v()}).catch(function(){return Promise.reject()})};return b()},d}();function h(d,_){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:_,headers:new self.Headers(T({},d.headers))};return d.rangeEnd&&y.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),y}function o(d,_){return new self.Request(d.url,_)}var c=function(d){z(_,d);function _(y,m,l){var x;return x=d.call(this,y)||this,x.code=void 0,x.details=void 0,x.code=m,x.details=l,x}return _}(B(Error));$.default=C},"./src/utils/imsc1-ttml-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"IMSC1_CODEC",function(){return E}),R.d($,"parseIMSC1",function(){return A});var X=R("./src/utils/mp4-tools.ts"),N=R("./src/utils/vttparser.ts"),I=R("./src/utils/vttcue.ts"),z=R("./src/demux/id3.ts"),B=R("./src/utils/timescale-conversion.ts"),O=R("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign||function(f){for(var p=1;p<arguments.length;p++){var s=arguments[p];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(f[a]=s[a])}return f},D.apply(this,arguments)}var E="stpp.ttml.im1t",L=/^(\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 A(f,p,s,a,b){var v=Object(X.findBox)(new Uint8Array(f),["mdat"]);if(v.length===0){b(new Error("Could not parse IMSC1 mdat"));return}var S=v[0],M=Object(z.utf8ArrayToStr)(new Uint8Array(f,S.start,S.end-S.start)),H=Object(B.toTimescaleFromScale)(p,1,s);try{a(C(M,H))}catch(V){b(V)}}function C(f,p){var s=new DOMParser,a=s.parseFromString(f,"text/xml"),b=a.getElementsByTagName("tt")[0];if(!b)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(G,W){return G[W]=b.getAttribute("ttp:"+W)||v[W],G},{}),M=b.getAttribute("xml:space")!=="preserve",H=o(h(b,"styling","style")),V=o(h(b,"layout","region")),Q=h(b,"body","[begin]");return[].map.call(Q,function(G){var W=c(G,M);if(!W||!G.hasAttribute("begin"))return null;var q=m(G.getAttribute("begin"),S),oe=m(G.getAttribute("dur"),S),fe=m(G.getAttribute("end"),S);if(q===null)throw y(G);if(fe===null){if(oe===null)throw y(G);fe=q+oe}var ve=new I.default(q-p,fe-p,W);ve.id=Object(O.generateCueId)(ve.startTime,ve.endTime,ve.text);var De=V[G.getAttribute("region")],Ee=H[G.getAttribute("style")];ve.position=10,ve.size=80;var _e=d(De,Ee),Te=_e.textAlign;if(Te){var Ce=T[Te];Ce&&(ve.lineAlign=Ce),ve.align=Te}return D(ve,_e),ve}).filter(function(G){return G!==null})}function h(f,p,s){var a=f.getElementsByTagName(p)[0];return a?[].slice.call(a.querySelectorAll(s)):[]}function o(f){return f.reduce(function(p,s){var a=s.getAttribute("xml:id");return a&&(p[a]=s),p},{})}function c(f,p){return[].slice.call(f.childNodes).reduce(function(s,a,b){var v;return a.nodeName==="br"&&b?s+`
|
|
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?c(a,p):p?s+a.textContent.trim().replace(/\s+/g," "):s+a.textContent},"")}function d(f,p){var s="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(b,v){var S=_(p,s,v)||_(f,s,v);return S&&(b[v]=S),b},{})}function _(f,p,s){return f.hasAttributeNS(p,s)?f.getAttributeNS(p,s):null}function y(f){return new Error("Could not parse ttml timestamp "+f)}function m(f,p){if(!f)return null;var s=Object(N.parseTimeStamp)(f);return s===null&&(L.test(f)?s=l(f,p):k.test(f)&&(s=x(f,p))),s}function l(f,p){var s=L.exec(f),a=(s[4]|0)+(s[5]|0)/p.subFrameRate;return(s[1]|0)*3600+(s[2]|0)*60+(s[3]|0)+a/p.frameRate}function x(f,p){var s=k.exec(f),a=Number(s[1]),b=s[2];switch(b){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/p.frameRate;case"t":return a/p.tickRate}return a}},"./src/utils/logger.ts":function(ae,$,R){"use strict";R.r($),R.d($,"enableLogs",function(){return O}),R.d($,"logger",function(){return D});var X=function(){},N={trace:X,debug:X,log:X,warn:X,info:X,error:X},I=N;function z(E){var L=self.console[E];return L?L.bind(self.console,"["+E+"] >"):X}function B(E){for(var L=arguments.length,k=new Array(L>1?L-1:0),T=1;T<L;T++)k[T-1]=arguments[T];k.forEach(function(A){I[A]=E[A]?E[A].bind(E):z(A)})}function O(E){if(self.console&&E===!0||typeof E=="object"){B(E,"debug","log","info","warn","error");try{I.log()}catch(L){I=N}}else I=N}var D=I},"./src/utils/mediakeys-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"KeySystems",function(){return X}),R.d($,"requestMediaKeySystemAccess",function(){return N});var X;(function(I){I.WIDEVINE="com.widevine.alpha",I.PLAYREADY="com.microsoft.playready"})(X||(X={}));var N=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ae,$,R){"use strict";R.r($),R.d($,"getMediaSource",function(){return X});function X(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ae,$,R){"use strict";R.r($),R.d($,"bin2str",function(){return B}),R.d($,"readUint16",function(){return O}),R.d($,"readUint32",function(){return D}),R.d($,"writeUint32",function(){return E}),R.d($,"findBox",function(){return L}),R.d($,"parseSegmentIndex",function(){return k}),R.d($,"parseInitSegment",function(){return T}),R.d($,"getStartDTS",function(){return A}),R.d($,"getDuration",function(){return C}),R.d($,"computeRawDurationFromSamples",function(){return h}),R.d($,"offsetStartDTS",function(){return o}),R.d($,"segmentValidRange",function(){return c}),R.d($,"appendUint8Array",function(){return d});var X=R("./src/utils/typed-array.ts"),N=R("./src/loader/fragment.ts"),I=Math.pow(2,32)-1,z=[].push;function B(_){return String.fromCharCode.apply(null,_)}function O(_,y){"data"in _&&(y+=_.start,_=_.data);var m=_[y]<<8|_[y+1];return m<0?65536+m:m}function D(_,y){"data"in _&&(y+=_.start,_=_.data);var m=_[y]<<24|_[y+1]<<16|_[y+2]<<8|_[y+3];return m<0?4294967296+m:m}function E(_,y,m){"data"in _&&(y+=_.start,_=_.data),_[y]=m>>24,_[y+1]=m>>16&255,_[y+2]=m>>8&255,_[y+3]=m&255}function L(_,y){var m=[];if(!y.length)return m;var l,x,f;"data"in _?(l=_.data,x=_.start,f=_.end):(l=_,x=0,f=l.byteLength);for(var p=x;p<f;){var s=D(l,p),a=B(l.subarray(p+4,p+8)),b=s>1?p+s:f;if(a===y[0])if(y.length===1)m.push({data:l,start:p+8,end:b});else{var v=L({data:l,start:p+8,end:b},y.slice(1));v.length&&z.apply(m,v)}p=b}return m}function k(_){var y=L(_,["moov"]),m=y[0],l=m?m.end:null,x=L(_,["sidx"]);if(!x||!x[0])return null;var f=[],p=x[0],s=p.data[0],a=s===0?8:16,b=D(p,a);a+=4;var v=0,S=0;s===0?a+=8:a+=16,a+=2;var M=p.end+S,H=O(p,a);a+=2;for(var V=0;V<H;V++){var Q=a,G=D(p,Q);Q+=4;var W=G&2147483647,q=(G&2147483648)>>>31;if(q===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var oe=D(p,Q);Q+=4,f.push({referenceSize:W,subsegmentDuration:oe,info:{duration:oe/b,start:M,end:M+W-1}}),M+=W,Q+=4,a=Q}return{earliestPresentationTime:v,timescale:b,version:s,referencesCount:H,references:f,moovEndOffset:l}}function T(_){for(var y=[],m=L(_,["moov","trak"]),l=0;l<m.length;l++){var x=m[l],f=L(x,["tkhd"])[0];if(f){var p=f.data[f.start],s=p===0?12:20,a=D(f,s),b=L(x,["mdia","mdhd"])[0];if(b){p=b.data[b.start],s=p===0?12:20;var v=D(b,s),S=L(x,["mdia","hdlr"])[0];if(S){var M=B(S.data.subarray(S.start+8,S.start+12)),H={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[M];if(H){var V=L(x,["mdia","minf","stbl","stsd"])[0],Q=void 0;V&&(Q=B(V.data.subarray(V.start+12,V.start+16))),y[a]={timescale:v,type:H},y[H]={timescale:v,id:a,codec:Q}}}}}}var G=L(_,["moov","mvex","trex"]);return G.forEach(function(W){var q=D(W,4),oe=y[q];oe&&(oe.default={duration:D(W,12),flags:D(W,20)})}),y}function A(_,y){return L(y,["moof","traf"]).reduce(function(m,l){var x=L(l,["tfdt"])[0],f=x.data[x.start],p=L(l,["tfhd"]).reduce(function(s,a){var b=D(a,4),v=_[b];if(v){var S=D(x,4);f===1&&(S*=Math.pow(2,32),S+=D(x,8));var M=v.timescale||9e4,H=S/M;if(isFinite(H)&&(s===null||H<s))return H}return s},null);return p!==null&&isFinite(p)&&(m===null||p<m)?p:m},null)||0}function C(_,y){for(var m=0,l=0,x=0,f=L(_,["moof","traf"]),p=0;p<f.length;p++){var s=f[p],a=L(s,["tfhd"])[0],b=D(a,4),v=y[b];if(!v)continue;var S=v.default,M=D(a,0)|(S==null?void 0:S.flags),H=S==null?void 0:S.duration;M&8&&(M&2?H=D(a,12):H=D(a,8));for(var V=v.timescale||9e4,Q=L(s,["trun"]),G=0;G<Q.length;G++){if(H){var W=D(Q[G],4);m=H*W}else m=h(Q[G]);v.type===N.ElementaryStreamTypes.VIDEO?l+=m/V:v.type===N.ElementaryStreamTypes.AUDIO&&(x+=m/V)}}if(l===0&&x===0){var q=k(_);if(q!=null&&q.references)return q.references.reduce(function(oe,fe){return oe+fe.info.duration||0},0)}return l||x}function h(_){var y=D(_,0),m=8;y&1&&(m+=4),y&4&&(m+=4);for(var l=0,x=D(_,4),f=0;f<x;f++){if(y&256){var p=D(_,m);l+=p,m+=4}y&512&&(m+=4),y&1024&&(m+=4),y&2048&&(m+=4)}return l}function o(_,y,m){L(y,["moof","traf"]).forEach(function(l){L(l,["tfhd"]).forEach(function(x){var f=D(x,4),p=_[f];if(!p)return;var s=p.timescale||9e4;L(l,["tfdt"]).forEach(function(a){var b=a.data[a.start],v=D(a,4);if(b===0)E(a,4,v-m*s);else{v*=Math.pow(2,32),v+=D(a,8),v-=m*s,v=Math.max(v,0);var S=Math.floor(v/(I+1)),M=Math.floor(v%(I+1));E(a,4,S),E(a,8,M)}})})})}function c(_){var y={valid:null,remainder:null},m=L(_,["moof"]);if(m){if(m.length<2)return y.remainder=_,y}else return y;var l=m[m.length-1];return y.valid=Object(X.sliceUint8)(_,0,l.start-8),y.remainder=Object(X.sliceUint8)(_,l.start-8),y}function d(_,y){var m=new Uint8Array(_.length+y.length);return m.set(_),m.set(y,_.length),m}},"./src/utils/output-filter.ts":function(ae,$,R){"use strict";R.r($),R.d($,"default",function(){return X});var X=function(){function N(z,B){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=B}var I=N.prototype;return I.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},I.newCue=function(B,O,D){(this.startTime===null||this.startTime>B)&&(this.startTime=B),this.endTime=O,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[]},N}()},"./src/utils/texttrack-utils.ts":function(ae,$,R){"use strict";R.r($),R.d($,"sendAddTrackEvent",function(){return N}),R.d($,"addCueToTrack",function(){return I}),R.d($,"clearCurrentCues",function(){return z}),R.d($,"removeCuesInRange",function(){return B}),R.d($,"getCuesInRange",function(){return D});var X=R("./src/utils/logger.ts");function N(E,L){var k;try{k=new Event("addtrack")}catch(T){k=document.createEvent("Event"),k.initEvent("addtrack",!1,!1)}k.track=E,L.dispatchEvent(k)}function I(E,L){var k=E.mode;if(k==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(L.id))try{if(E.addCue(L),!E.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(A){X.logger.debug("[texttrack-utils]: "+A);var T=new self.TextTrackCue(L.startTime,L.endTime,L.text);T.id=L.id,E.addCue(T)}k==="disabled"&&(E.mode=k)}function z(E){var L=E.mode;if(L==="disabled"&&(E.mode="hidden"),E.cues)for(var k=E.cues.length;k--;)E.removeCue(E.cues[k]);L==="disabled"&&(E.mode=L)}function B(E,L,k){var T=E.mode;if(T==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var A=D(E.cues,L,k),C=0;C<A.length;C++)E.removeCue(A[C]);T==="disabled"&&(E.mode=T)}function O(E,L){if(L<E[0].startTime)return 0;var k=E.length-1;if(L>E[k].endTime)return-1;for(var T=0,A=k;T<=A;){var C=Math.floor((A+T)/2);if(L<E[C].startTime)A=C-1;else if(L>E[C].startTime&&T<k)T=C+1;else return C}return E[T].startTime-L<L-E[A].startTime?T:A}function D(E,L,k){var T=[],A=O(E,L);if(A>-1)for(var C=A,h=E.length;C<h;C++){var o=E[C];if(o.startTime>=L&&o.endTime<=k)T.push(o);else if(o.startTime>k)return T}return T}},"./src/utils/time-ranges.ts":function(ae,$,R){"use strict";R.r($);var X={toString:function(I){for(var z="",B=I.length,O=0;O<B;O++)z+="["+I.start(O).toFixed(3)+","+I.end(O).toFixed(3)+"]";return z}};$.default=X},"./src/utils/timescale-conversion.ts":function(ae,$,R){"use strict";R.r($),R.d($,"toTimescaleFromBase",function(){return N}),R.d($,"toTimescaleFromScale",function(){return I}),R.d($,"toMsFromMpegTsClock",function(){return z}),R.d($,"toMpegTsClockFromTimescale",function(){return B});var X=9e4;function N(O,D,E,L){E===void 0&&(E=1),L===void 0&&(L=!1);var k=O*D*E;return L?Math.round(k):k}function I(O,D,E,L){return E===void 0&&(E=1),L===void 0&&(L=!1),N(O,D,1/E,L)}function z(O,D){return D===void 0&&(D=!1),N(O,1e3,1/X,D)}function B(O,D){return D===void 0&&(D=1),N(O,X,1/D)}},"./src/utils/typed-array.ts":function(ae,$,R){"use strict";R.r($),R.d($,"sliceUint8",function(){return X});function X(N,I,z){return Uint8Array.prototype.slice?N.slice(I,z):new Uint8Array(Array.prototype.slice.call(N,I,z))}},"./src/utils/vttcue.ts":function(ae,$,R){"use strict";R.r($),$.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var X=["","lr","rl"],N=["start","middle","end","left","right"];function I(E,L){if(typeof L!="string")return!1;if(!Array.isArray(E))return!1;var k=L.toLowerCase();return~E.indexOf(k)?k:!1}function z(E){return I(X,E)}function B(E){return I(N,E)}function O(E){for(var L=arguments.length,k=new Array(L>1?L-1:0),T=1;T<L;T++)k[T-1]=arguments[T];for(var A=1;A<arguments.length;A++){var C=arguments[A];for(var h in C)E[h]=C[h]}return E}function D(E,L,k){var T=this,A={enumerable:!0};T.hasBeenReset=!1;var C="",h=!1,o=E,c=L,d=k,_=null,y="",m=!0,l="auto",x="start",f=50,p="middle",s=50,a="middle";Object.defineProperty(T,"id",O({},A,{get:function(){return C},set:function(v){C=""+v}})),Object.defineProperty(T,"pauseOnExit",O({},A,{get:function(){return h},set:function(v){h=!!v}})),Object.defineProperty(T,"startTime",O({},A,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"endTime",O({},A,{get:function(){return c},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");c=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",O({},A,{get:function(){return d},set:function(v){d=""+v,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",O({},A,{get:function(){return _},set:function(v){_=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",O({},A,{get:function(){return y},set:function(v){var S=z(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"snapToLines",O({},A,{get:function(){return m},set:function(v){m=!!v,this.hasBeenReset=!0}})),Object.defineProperty(T,"line",O({},A,{get:function(){return l},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"lineAlign",O({},A,{get:function(){return x},set:function(v){var S=B(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");x=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"position",O({},A,{get:function(){return f},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");f=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",O({},A,{get:function(){return p},set:function(v){var S=B(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");p=S,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",O({},A,{get:function(){return s},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",O({},A,{get:function(){return a},set:function(v){var S=B(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),T.displayState=void 0}return D.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},D}()},"./src/utils/vttparser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"parseTimeStamp",function(){return I}),R.d($,"fixLineBreaks",function(){return L}),R.d($,"VTTParser",function(){return k});var X=R("./src/utils/vttcue.ts"),N=function(){function T(){}var A=T.prototype;return A.decode=function(h,o){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},T}();function I(T){function A(h,o,c,d){return(h|0)*3600+(o|0)*60+(c|0)+parseFloat(d||0)}var C=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?A(C[2],C[3],0,C[4]):A(C[1],C[2],C[3],C[4]):null}var z=function(){function T(){this.values=Object.create(null)}var A=T.prototype;return A.set=function(h,o){!this.get(h)&&o!==""&&(this.values[h]=o)},A.get=function(h,o,c){return c?this.has(h)?this.values[h]:o[c]:this.has(h)?this.values[h]:o},A.has=function(h){return h in this.values},A.alt=function(h,o,c){for(var d=0;d<c.length;++d)if(o===c[d]){this.set(h,o);break}},A.integer=function(h,o){/^-?\d+$/.test(o)&&this.set(h,parseInt(o,10))},A.percent=function(h,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var c=parseFloat(o);if(c>=0&&c<=100)return this.set(h,c),!0}return!1},T}();function B(T,A,C,h){var o=h?T.split(h):[T];for(var c in o){if(typeof o[c]!="string")continue;var d=o[c].split(C);if(d.length!==2)continue;var _=d[0],y=d[1];A(_,y)}}var O=new X.default(0,0,""),D=O.align==="middle"?"middle":"center";function E(T,A,C){var h=T;function o(){var _=I(T);if(_===null)throw new Error("Malformed timestamp: "+h);return T=T.replace(/^[^\sa-zA-Z-]+/,""),_}function c(_,y){var m=new z;B(_,function(f,p){var s;switch(f){case"region":for(var a=C.length-1;a>=0;a--)if(C[a].id===p){m.set(f,C[a].region);break}break;case"vertical":m.alt(f,p,["rl","lr"]);break;case"line":s=p.split(","),m.integer(f,s[0]),m.percent(f,s[0])&&m.set("snapToLines",!1),m.alt(f,s[0],["auto"]),s.length===2&&m.alt("lineAlign",s[1],["start",D,"end"]);break;case"position":s=p.split(","),m.percent(f,s[0]),s.length===2&&m.alt("positionAlign",s[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":m.percent(f,p);break;case"align":m.alt(f,p,["start",D,"end","left","right"]);break}},/:/,/\s/),y.region=m.get("region",null),y.vertical=m.get("vertical","");var l=m.get("line","auto");l==="auto"&&O.line===-1&&(l=-1),y.line=l,y.lineAlign=m.get("lineAlign","start"),y.snapToLines=m.get("snapToLines",!0),y.size=m.get("size",100),y.align=m.get("align",D);var x=m.get("position","auto");x==="auto"&&O.position===50&&(x=y.align==="start"||y.align==="left"?0:y.align==="end"||y.align==="right"?100:50),y.position=x}function d(){T=T.replace(/^\s+/,"")}if(d(),A.startTime=o(),d(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);T=T.substr(3),d(),A.endTime=o(),d(),c(T,A)}function L(T){return T.replace(/<br(?: \/)?>/gi,`
|
|
`)}var k=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new N,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=T.prototype;return A.parse=function(h){var o=this;h&&(o.buffer+=o.decoder.decode(h,{stream:!0}));function c(){var x=o.buffer,f=0;for(x=L(x);f<x.length&&x[f]!=="\r"&&x[f]!==`
|
|
`;)++f;var p=x.substr(0,f);return x[f]==="\r"&&++f,x[f]===`
|
|
`&&++f,o.buffer=x.substr(f),p}function d(x){B(x,function(f,p){},/:/)}try{var _="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;_=c();var y=_.match(/^()?WEBVTT([ \t].*)?$/);if(!y||!y[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var m=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;m?m=!1:_=c();switch(o.state){case"HEADER":/:/.test(_)?d(_):_||(o.state="ID");continue;case"NOTE":_||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(_)){o.state="NOTE";break}if(!_)continue;if(o.cue=new X.default(0,0,""),o.state="CUE",_.indexOf("-->")===-1){o.cue.id=_;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{E(_,o.cue,o.regionList)}catch(x){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var l=_.indexOf("-->")!==-1;if(!_||l&&(m=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=_}continue;case"BADCUE":_||(o.state="ID")}}}catch(x){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},A.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
|
|
|
|
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){h.onparsingerror&&h.onparsingerror(o)}return h.onflush&&h.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"generateCueId",function(){return k}),R.d($,"parseWebVTT",function(){return A});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/vttparser.ts"),I=R("./src/demux/id3.ts"),z=R("./src/utils/timescale-conversion.ts"),B=R("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,D=function(h,o,c){return c===void 0&&(c=0),h.substr(c,o.length)===o},E=function(h){var o=parseInt(h.substr(-3)),c=parseInt(h.substr(-6,2)),d=parseInt(h.substr(-9,2)),_=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(c)||!Object(X.isFiniteNumber)(d)||!Object(X.isFiniteNumber)(_))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*c,o+=60*1e3*d,o+=60*60*1e3*_,o},L=function(h){for(var o=5381,c=h.length;c;)o=o*33^h.charCodeAt(--c);return(o>>>0).toString()};function k(C,h,o){return L(C.toString())+L(h.toString())+L(o)}var T=function(h,o,c){var d=h[o],_=h[d.prevCC];if(!_||!_.new&&d.new){h.ccOffset=h.presentationOffset=d.start,d.new=!1;return}for(;(y=_)!==null&&y!==void 0&&y.new;){var y;h.ccOffset+=d.start-_.start,d.new=!1,d=_,_=h[d.prevCC]}h.presentationOffset=c};function A(C,h,o,c,d,_,y,m){var l=new N.VTTParser,x=Object(I.utf8ArrayToStr)(new Uint8Array(C)).trim().replace(O,`
|
|
`).split(`
|
|
`),f=[],p=Object(z.toMpegTsClockFromTimescale)(h,o),s="00:00.000",a=0,b=0,v,S=!0,M=!1;l.oncue=function(H){var V=c[d],Q=c.ccOffset,G=(a-p)/9e4;if(V!=null&&V.new&&(b!==void 0?Q=c.ccOffset=V.start:T(c,d,G)),G&&(Q=G-c.presentationOffset),M){var W=H.endTime-H.startTime,q=Object(B.normalizePts)((H.startTime+Q-b)*9e4,_*9e4)/9e4;H.startTime=q,H.endTime=q+W}var oe=H.text.trim();H.text=decodeURIComponent(encodeURIComponent(oe)),H.id||(H.id=k(H.startTime,H.endTime,oe)),H.endTime>0&&f.push(H)},l.onparsingerror=function(H){v=H},l.onflush=function(){if(v){m(v);return}y(f)},x.forEach(function(H){if(S)if(D(H,"X-TIMESTAMP-MAP=")){S=!1,M=!0,H.substr(16).split(",").forEach(function(V){D(V,"LOCAL:")?s=V.substr(6):D(V,"MPEGTS:")&&(a=parseInt(V.substr(7)))});try{b=E(s)/1e3}catch(V){M=!1,v=V}return}else H===""&&(S=!1);l.parse(H+`
|
|
`)}),l.flush()}},"./src/utils/xhr-loader.ts":function(ae,$,R){"use strict";R.r($);var X=R("./src/utils/logger.ts"),N=R("./src/loader/load-stats.ts"),I=/^age:\s*[\d.]+\s*$/m,z=function(){function B(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 N.LoadStats,this.retryDelay=0}var O=B.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},O.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(E,L,k){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=E,this.config=L,this.callbacks=k,this.retryDelay=L.retryDelay,this.loadInternal()},O.loadInternal=function(){var E=this.config,L=this.context;if(!E)return;var k=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var A=this.xhrSetup;try{if(A)try{A(k,L.url)}catch(o){k.open("GET",L.url,!0),A(k,L.url)}k.readyState||k.open("GET",L.url,!0);var C=this.context.headers;if(C)for(var h in C)k.setRequestHeader(h,C[h])}catch(o){this.callbacks.onError({code:k.status,text:o.message},L,k);return}L.rangeEnd&&k.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),k.onreadystatechange=this.readystatechange.bind(this),k.onprogress=this.loadprogress.bind(this),k.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),k.send()},O.readystatechange=function(){var E=this.context,L=this.loader,k=this.stats;if(!E||!L)return;var T=L.readyState,A=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){L.onreadystatechange=null,L.onprogress=null;var C=L.status;if(C>=200&&C<300){k.loading.end=Math.max(self.performance.now(),k.loading.first);var h,o;if(E.responseType==="arraybuffer"?(h=L.response,o=h.byteLength):(h=L.responseText,o=h.length),k.loaded=k.total=o,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(k,E,h,L),!this.callbacks)return;var d={url:L.responseURL,data:h};this.callbacks.onSuccess(d,k,E,L)}else k.retry>=A.maxRetry||C>=400&&C<499?(X.logger.error(C+" while loading "+E.url),this.callbacks.onError({code:C,text:L.statusText},E,L)):(X.logger.warn(C+" while loading "+E.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,A.maxRetryDelay),k.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)},O.loadtimeout=function(){X.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(E){var L=this.stats;L.loaded=E.loaded,E.lengthComputable&&(L.total=E.total)},O.getCacheAge=function(){var E=null;if(this.loader&&I.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");E=L?parseFloat(L):null}return E},B}();$.default=z}}).default})},vHTk:function(At,ht,re){At.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|