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
965 KiB
361 lines
965 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[199,7,8],{"+NIl":function(At,ft,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,w=A.length-1;w>=0;w--){var h=A[w];if(h.name=="DEFAULT")continue;return h}return{styleIdentifier:function(){return null}}}function j(T,A,w){return function(){this.name=T,this.bracketNo=0,this.style=A,this.styles=w,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=j("importmodule","tag",["string","builtin"]),O.documentclass=j("documentclass","tag",["","atom"]),O.usepackage=j("usepackage","tag",["atom"]),O.begin=j("begin","tag",["atom"]),O.end=j("end","tag",["atom"]),O.label=j("label","tag",["atom"]),O.ref=j("ref","tag",["atom"]),O.eqref=j("eqref","tag",["atom"]),O.cite=j("cite","tag",["atom"]),O.bibitem=j("bibitem","tag",["atom"]),O.Bibitem=j("Bibitem","tag",["atom"]),O.RBibitem=j("RBibitem","tag",["atom"]),O.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function P(T,A){T.f=A}function E(T,A){var w;if(T.match(/^\\[a-zA-Z@]+/)){var h=T.current().slice(1);return w=O.hasOwnProperty(h)?O[h]:O.DEFAULT,w=new w,X(A,w),P(A,D),w.style}if(T.match(/^\\[$&%#{}_]/))return"tag";if(T.match(/^\\[,;!\/\\]/))return"tag";if(T.match("\\["))return P(A,function(d,c){return L(d,c,"\\]")}),"keyword";if(T.match("\\("))return P(A,function(d,c){return L(d,c,"\\)")}),"keyword";if(T.match("$$"))return P(A,function(d,c){return L(d,c,"$$")}),"keyword";if(T.match("$"))return P(A,function(d,c){return L(d,c,"$")}),"keyword";var o=T.next();if(o=="%")return T.skipToEnd(),"comment";if(o=="}"||o=="]"){if(w=N(A),w)w.closeBracket(o),P(A,D);else return"error";return"bracket"}else return o=="{"||o=="["?(w=O.DEFAULT,w=new w,X(A,w),"bracket"):/\d/.test(o)?(T.eatWhile(/[\w.%]/),"atom"):(T.eatWhile(/[\w\-_]/),w=z(A),w.name=="begin"&&(w.argument=T.current()),w.styleIdentifier())}function L(T,A,w){if(T.eatSpace())return null;if(w&&T.match(w))return P(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 D(T,A){var w=T.peek(),h;return w=="{"||w=="["?(h=N(A),h.openBracket(w),T.eat(w),P(A,E),"bracket"):/[ \t\r]/.test(w)?(T.eat(w),null):(P(A,E),I(A),E(T,A))}return{startState:function(){var T=R.inMathMode?function(A,w){return L(A,w)}: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,ft,re){At.exports=re.p+"static/xixi.e1179cb8.svg"},"0eGx":function(At,ft,re){At.exports=re.p+"static/zhong.e01397e1.svg"},"19Vz":function(At,ft,re){(function(ae){ae(re("VrN/"))})(function(ae){ae.defineOption("placeholder","",function(j,O,P){var E=P&&P!=ae.Init;if(O&&!E)j.on("blur",N),j.on("change",I),j.on("swapDoc",I),ae.on(j.getInputField(),"compositionupdate",j.state.placeholderCompose=function(){X(j)}),I(j);else if(!O&&E){j.off("blur",N),j.off("change",I),j.off("swapDoc",I),ae.off(j.getInputField(),"compositionupdate",j.state.placeholderCompose),$(j);var L=j.getWrapperElement();L.className=L.className.replace(" CodeMirror-empty","")}O&&!j.hasFocus()&&N(j)});function $(j){j.state.placeholder&&(j.state.placeholder.parentNode.removeChild(j.state.placeholder),j.state.placeholder=null)}function R(j){$(j);var O=j.state.placeholder=document.createElement("pre");O.style.cssText="height: 0; overflow: visible",O.style.direction=j.getOption("direction"),O.className="CodeMirror-placeholder CodeMirror-line-like";var P=j.getOption("placeholder");typeof P=="string"&&(P=document.createTextNode(P)),O.appendChild(P),j.display.lineSpace.insertBefore(O,j.display.lineSpace.firstChild)}function X(j){setTimeout(function(){var O=!1,P=j.getInputField();P.nodeName=="TEXTAREA"?O=!P.value:j.lineCount()==1&&(O=!/[^\u200b]/.test(P.querySelector(".CodeMirror-line").textContent)),O?R(j):$(j)},20)}function N(j){z(j)&&R(j)}function I(j){var O=j.getWrapperElement(),P=z(j);O.className=O.className.replace(" CodeMirror-empty","")+(P?" CodeMirror-empty":""),P?R(j):$(j)}function z(j){return j.lineCount()===1&&j.getLine(0)===""}})},"1eCo":function(At,ft,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={},j=N.htmlMode?$:R;for(var O in j)z[O]=j[O];for(var O in N)z[O]=N[O];var P,E;function L(a,b){function v(H){return b.tokenize=H,H(a,b)}var x=a.next();if(x=="<")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(w(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=A("meta","?>"),"meta"):(P=a.eat("/")?"closeTag":"openTag",b.tokenize=D,"tag bracket");if(x=="&"){var k;return a.eat("#")?a.eat("x")?k=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):k=a.eatWhile(/[\d]/)&&a.eat(";"):k=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),k?"atom":"error"}else return a.eatWhile(/[^&<]/),null}L.isInText=!0;function D(a,b){var v=a.next();if(v==">"||v=="/"&&a.eat(">"))return b.tokenize=L,P=v==">"?"endTag":"selfcloseTag","tag bracket";if(v=="=")return P="equals",null;if(v=="<"){b.tokenize=L,b.state=c,b.tagName=b.tagStart=null;var x=b.tokenize(a,b);return x?x+" 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,x){for(;!v.eol();)if(v.next()==a){x.tokenize=D;break}return"string"};return b.isInAttribute=!0,b}function A(a,b){return function(v,x){for(;!v.eol();){if(v.match(b)){x.tokenize=L;break}v.next()}return a}}function w(a){return function(b,v){for(var x;(x=b.next())!=null;){if(x=="<")return v.tokenize=w(a+1),v.tokenize(b,v);if(x==">")if(a==1){v.tokenize=L;break}else return v.tokenize=w(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 d(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 c(a,b,v){return a=="openTag"?(v.tagStart=b.column(),C):a=="closeTag"?y:c}function C(a,b,v){return a=="word"?(v.tagName=b.current(),E="tag",S):z.allowMissingTagName&&a=="endTag"?(E="tag bracket",S(a,b,v)):(E="error",C)}function y(a,b,v){if(a=="word"){var x=b.current();return v.context&&v.context.tagName!=x&&z.implicitlyClosed.hasOwnProperty(v.context.tagName)&&o(v),v.context&&v.context.tagName==x||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),c)}function l(a,b,v){return E="error",m(a,b,v)}function S(a,b,v){if(a=="word")return E="attribute",f;if(a=="endTag"||a=="selfcloseTag"){var x=v.tagName,k=v.tagStart;return v.tagName=v.tagStart=null,a=="selfcloseTag"||z.autoSelfClosers.hasOwnProperty(x)?d(v,x):(d(v,x),v.context=new h(v,x,k==v.indented)),c}return E="error",S}function f(a,b,v){return a=="equals"?p:(z.allowMissing||(E="error"),S(a,b,v))}function p(a,b,v){return a=="string"?s:a=="word"&&z.allowUnquoted?(E="string",S):(E="error",S(a,b,v))}function s(a,b,v){return a=="string"?s:S(a,b,v)}return{startState:function(a){var b={tokenize:L,state:c,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;P=null;var v=b.tokenize(a,b);return(v||P)&&v!="comment"&&(E=null,b.state=b.state(P||v,a,b),E&&(v=E=="error"?v+" error":E)),v},indent:function(a,b,v){var x=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+I;if(x&&x.noIndent)return ae.Pass;if(a.tokenize!=D&&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 k=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);if(k&&k[1])for(;x;)if(x.tagName==k[2]){x=x.prev;break}else if(z.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(k)for(;x;){var H=z.contextGrabbers[x.tagName];if(H&&H.hasOwnProperty(k[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.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=S)},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,ft,re){"use strict";re.d(ft,"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"),j=re("q1tI"),O=re.n(j),P=re("TSYQ"),E=re.n(P),L=function(S){var f,p="".concat(S.rootPrefixCls,"-item"),s=E()(p,"".concat(p,"-").concat(S.page),(f={},Object($.a)(f,"".concat(p,"-active"),S.active),Object($.a)(f,S.className,!!S.className),Object($.a)(f,"".concat(p,"-disabled"),!S.page),f)),a=function(){S.onClick(S.page)},b=function(x){S.onKeyPress(x,S.onClick,S.page)};return O.a.createElement("li",{title:S.showTitle?S.page:null,className:s,onClick:a,onKeyPress:b,tabIndex:"0"},S.itemRender(S.page,"page",O.a.createElement("a",{rel:"nofollow"},S.page)))},D=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 S=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=S.call.apply(S,[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 x=p.props,k=x.goButton,H=x.quickGo,V=x.rootPrefixCls,Q=p.state.goInputText;if(k||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 x=p.state.goInputText;if(x==="")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,x){var k=isNaN(Number(v))?0:Number(v),H=isNaN(Number(x))?0:Number(x);return k-H})}},{key:"render",value:function(){var s=this,a=this.props,b=a.pageSize,v=a.locale,x=a.rootPrefixCls,k=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(x,"-options"),ve=Q,ke=null,Ee=null,_e=null;if(!k&&!H)return null;var Te=this.getPageSizeOptions();if(k&&ve){var Ce=Te.map(function(me,ne){return O.a.createElement(ve.Option,{key:ne,value:me.toString()},(G||s.buildOptionText)(me))});ke=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)},ke,Ee)}}]),f}(O.a.Component);A.defaultProps={pageSizeOptions:["10","20","50","100"]};var w=A,h=re("N2Kk");function o(){}function d(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}function c(l,S,f){return f}function C(l,S,f){var p=typeof l=="undefined"?S.pageSize:l;return Math.floor((f.total-1)/p)+1}var y=function(l){Object(I.a)(f,l);var S=Object(z.a)(f);function f(p){var s;Object(X.a)(this,f),s=S.call(this,p),s.getJumpPrevPage=function(){return Math.max(1,s.state.current-(s.props.showLessItems?3:5))},s.getJumpNextPage=function(){return Math.min(C(void 0,s.state,s.props),s.state.current+(s.props.showLessItems?3:5))},s.getItemIcon=function(k,H){var V=s.props.prefixCls,Q=k||O.a.createElement("button",{type:"button","aria-label":H,className:"".concat(V,"-item-link")});return typeof k=="function"&&(Q=O.a.createElement(k,Object(R.a)({},s.props))),Q},s.savePaginationNode=function(k){s.paginationNode=k},s.isValid=function(k){return d(k)&&k!==s.state.current},s.shouldDisplayQuickJumper=function(){var k=s.props,H=k.showQuickJumper,V=k.pageSize,Q=k.total;return Q<=V?!1:H},s.handleKeyDown=function(k){(k.keyCode===T.ARROW_UP||k.keyCode===T.ARROW_DOWN)&&k.preventDefault()},s.handleKeyUp=function(k){var H=s.getValidValue(k),V=s.state.currentInputValue;H!==V&&s.setState({currentInputValue:H}),k.keyCode===T.ENTER?s.handleChange(H):k.keyCode===T.ARROW_UP?s.handleChange(H-1):k.keyCode===T.ARROW_DOWN&&s.handleChange(H+1)},s.changePageSize=function(k){var H=s.state.current,V=C(k,s.state,s.props);H=H>V?V:H,V===0&&(H=s.state.current),typeof k=="number"&&("pageSize"in s.props||s.setState({pageSize:k}),"current"in s.props||s.setState({current:H,currentInputValue:H})),s.props.onShowSizeChange(H,k),"onChange"in s.props&&s.props.onChange&&s.props.onChange(H,k)},s.handleChange=function(k){var H=s.props.disabled,V=k;if(s.isValid(V)&&!H){var Q=C(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<C(void 0,s.state,s.props)},s.runIfEnter=function(k,H){if(k.key==="Enter"||k.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(k){s.runIfEnter(k,s.prev)},s.runIfEnterNext=function(k){s.runIfEnter(k,s.next)},s.runIfEnterJumpPrev=function(k){s.runIfEnter(k,s.jumpPrev)},s.runIfEnterJumpNext=function(k){s.runIfEnter(k,s.jumpNext)},s.handleGoTO=function(k){(k.keyCode===T.ENTER||k.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 x=p.defaultPageSize;return"pageSize"in p&&(x=p.pageSize),v=Math.min(v,C(x,void 0,p)),s.state={current:v,currentInputValue:v,pageSize:x},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=C(void 0,this.state,this.props),v=this.state.currentInputValue,x;return a===""?x=a:isNaN(Number(a))?x=v:a>=b?x=b:x=Number(a),x}},{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,x=v(s,"prev",this.getItemIcon(b,"prev page")),k=!this.hasPrev();return Object(j.isValidElement)(x)?Object(j.cloneElement)(x,{disabled:k}):x}},{key:"renderNext",value:function(s){var a=this.props,b=a.nextIcon,v=a.itemRender,x=v(s,"next",this.getItemIcon(b,"next page")),k=!this.hasNext();return Object(j.isValidElement)(x)?Object(j.cloneElement)(x,{disabled:k}):x}},{key:"render",value:function(){var s=this,a=this.props,b=a.prefixCls,v=a.className,x=a.style,k=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,ke=a.showPrevNextJumpers,Ee=a.jumpPrevIcon,_e=a.jumpNextIcon,Te=a.selectComponentClass,Ce=a.selectPrefixCls,me=a.pageSizeOptions,ne=this.state,we=ne.current,tt=ne.pageSize,Ye=ne.currentInputValue;if(H===!0&&V<=tt)return null;var Xe=C(void 0,this.state,this.props),Ve=[],Le=null,Me=null,He=null,Ge=null,je=null,Ue=G&&G.goButton,Re=W?1:2,st=we-1>0?we-1:0,Je=we+1<Xe?we+1:Xe,Qe=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 Ue&&(typeof Ue=="boolean"?je=O.a.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Q.jump_to_confirm):je=O.a.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},Ue),je=O.a.createElement("li",{title:q?"".concat(Q.jump_to).concat(we,"/").concat(Xe):null,className:"".concat(b,"-simple-pager")},je)),O.a.createElement("ul",Object(ae.a)({className:E()(b,"".concat(b,"-simple"),Object($.a)({},"".concat(b,"-disabled"),k),v),style:x,ref:this.savePaginationNode},Qe),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(st)),O.a.createElement("li",{title:q?"".concat(we,"/").concat(Xe):null,className:"".concat(b,"-simple-pager")},O.a.createElement("input",{type:"text",value:Ye,disabled:k,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(Je)),je);if(Xe<=3+Re*2){var nt={locale:Q,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:q,itemRender:ve};Xe||Ve.push(O.a.createElement(D,Object(ae.a)({},nt,{key:"noPager",page:Xe,className:"".concat(b,"-disabled")})));for(var bt=1;bt<=Xe;bt+=1){var at=we===bt;Ve.push(O.a.createElement(D,Object(ae.a)({},nt,{key:bt,page:bt,active:at})))}}else{var ht=W?Q.prev_3:Q.prev_5,Ae=W?Q.next_3:Q.next_5;ke&&(Le=O.a.createElement("li",{title:q?ht: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?Ae: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(D,{locale:Q,last:!0,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:Xe,page:Xe,active:!1,showTitle:q,itemRender:ve}),He=O.a.createElement(D,{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,we-Re),dt=Math.min(we+Re,Xe);we-1<=Re&&(dt=1+Re*2),Xe-we<=Re&&(gt=Xe-Re*2);for(var De=gt;De<=dt;De+=1){var We=we===De;Ve.push(O.a.createElement(D,{locale:Q,rootPrefixCls:b,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:De,page:De,active:We,showTitle:q,itemRender:ve}))}we-1>=Re*2&&we!==1+2&&(Ve[0]=Object(j.cloneElement)(Ve[0],{className:"".concat(b,"-item-after-jump-prev")}),Ve.unshift(Le)),Xe-we>=Re*2&&we!==Xe-2&&(Ve[Ve.length-1]=Object(j.cloneElement)(Ve[Ve.length-1],{className:"".concat(b,"-item-before-jump-next")}),Ve.push(Me)),gt!==1&&Ve.unshift(He),dt!==Xe&&Ve.push(Ge)}var ge=null;oe&&(ge=O.a.createElement("li",{className:"".concat(b,"-total-text")},oe(V,[V===0?0:(we-1)*tt+1,we*tt>V?V:we*tt])));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"),k)),style:x,unselectable:"unselectable",ref:this.savePaginationNode},Qe),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(st)),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(Je)),O.a.createElement(w,{disabled:k,locale:Q,rootPrefixCls:b,selectComponentClass:Te,selectPrefixCls:Ce,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:we,pageSize:tt,pageSizeOptions:me,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:Ue}))}}],[{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,x=C(s.pageSize,a,s);v=v>x?x: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:c,totalBoundaryShowSizeChanger:50};var m=y},"6K3P":function(At,ft,re){At.exports=re.p+"static/jinshi.4887ef37.svg"},"7Cbv":function(At,ft,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(D){return typeof D=="string"&&X.test(D)}for(var I=N,z=[],j=0;j<256;++j)z.push((j+256).toString(16).substr(1));function O(D){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,A=(z[D[T+0]]+z[D[T+1]]+z[D[T+2]]+z[D[T+3]]+"-"+z[D[T+4]]+z[D[T+5]]+"-"+z[D[T+6]]+z[D[T+7]]+"-"+z[D[T+8]]+z[D[T+9]]+"-"+z[D[T+10]]+z[D[T+11]]+z[D[T+12]]+z[D[T+13]]+z[D[T+14]]+z[D[T+15]]).toLowerCase();if(!I(A))throw TypeError("Stringified UUID is invalid");return A}var P=O;function E(D,T,A){D=D||{};var w=D.random||(D.rng||R)();if(w[6]=w[6]&15|64,w[8]=w[8]&63|128,T){A=A||0;for(var h=0;h<16;++h)T[A+h]=w[h];return T}return P(w)}var L=ft.a=E},"7ahc":function(At,ft,re){"use strict";re.d(ft,"a",function(){return C});var ae=re("k1fw"),$=re("0Owb"),R=re("+L6B"),X=re("2/Rp"),N=re("y8nQ"),I=re("Vl3Y"),z=re("tJVT"),j=re("OaEy"),O=re("2fM7"),P=re("q1tI"),E=re.n(P),L=re("VrN/"),D=re.n(L),T=re("p77/"),A=re.n(T),w=re("c5Ni"),h=re.n(w),o=O.a.Option,d={labelCol:{span:4},wrapperCol:{span:20}},c={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"]};ft.b=function(y){var m=y.callback,l=y.onCancel,S=Object(P.useState)("python"),f=Object(z.a)(S,2),p=f[0],s=f[1];function a(v){s(c[v][1])}function b(v){m(v)}return E.a.createElement(I.a,Object($.a)({},d,{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(c).map(function(v){return E.a.createElement(o,{key:v,value:v},c[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(C,{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 C(y){var m=y.value,l=y.onChange,S=y.mode,f=y.options,p=f===void 0?{}:f,s=Object(P.useRef)(),a=Object(P.useState)(),b=Object(z.a)(a,2),v=b[0],x=b[1];return Object(P.useEffect)(function(){if(v){function k(H){var V=H.getValue();l&&l(V)}return v.on("change",k),function(){v.off("change",k)}}},[v,l]),Object(P.useEffect)(function(){v&&v.setOption("mode",S)},[v,S]),Object(P.useEffect)(function(){v&&((m!==v.getValue()||m==="")&&setTimeout(function(){v.setValue(m||" ")},300))},[v,m]),Object(P.useEffect)(function(){if(s.current&&!v){var k=D.a.fromTextArea(s.current,Object(ae.a)({mode:S,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},p));x(k)}},[s.current,v]),E.a.createElement("div",{className:"my-codemirror-container"},E.a.createElement("textarea",{ref:s}))}},"7ixt":function(At,ft,re){"use strict";re.d(ft,"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,ft,re){"use strict";var ae=re("5Dmo"),$=re("3S7+"),R=re("fWQN"),X=re("mtLc"),N=re("yKVA"),I=re("879j"),z=re("5NDa"),j=re("5rEg"),O=re("q1tI"),P=re.n(O),E=re("O2Wb"),L=re.n(E),D=j.a.TextArea,T=function(A){Object(N.a)(h,A);var w=Object(I.a)(h);function h(){return Object(R.a)(this,h),w.apply(this,arguments)}return Object(X.a)(h,[{key:"render",value:function(){var d=this,c=this.props,C=c.index,y=c.onAnswerChange,m=c.addChildAnswer,l=c.exerciseIsPublish,S=c.answers,f=c.activeOptionErrorIndex,p=c.flex,s=p===void 0?"0 0 1000px":p;return P.a.createElement("div",{className:L.a.flex},P.a.createElement("div",{className:"".concat(L.a.color666," mb5 mt6"),style:{flex:"0 0 90px"}},"\u7B54\u6848(\u586B\u7A7A",C+1,"):"),P.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),style:{flexDirection:"column"}},S.map(function(a,b){var v="".concat(C,"-").concat(b);return P.a.createElement("div",{className:"".concat(L.a.flex," ").concat(L.a.flex1),key:b},P.a.createElement("div",{className:L.a.flex1,style:{flex:s}},P.a.createElement("div",null,P.a.createElement(D,{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(k){return y(C,b,k.target.value)},style:{minHeight:95}}))),!l&&P.a.createElement(P.a.Fragment,null,b!=0&&P.a.createElement($.a,{title:"\u5220\u9664"},P.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return d.props.deleteChildAnswer(C,b)},style:{float:"right"}})),b===0&&P.a.createElement($.a,{title:"\u5220\u9664"},P.a.createElement("i",{className:"".concat(L.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return d.props.deleteChildAnswermain(C,b)},style:{float:"right"}})),P.a.createElement($.a,{title:"\u65B0\u589E\u53C2\u8003\u7B54\u6848"},P.a.createElement("i",{className:"".concat(L.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return m(C)},style:{float:"right",visibility:b==S.length-1?"":"hidden"}}))))})))}}]),h}(O.Component);ft.a=T},"8EBN":function(At,ft,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("."),j=z>-1&&X.substring(z+1,X.length);if(j)return ae.findModeByExtension(j)},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,ft,re){At.exports={button:"button___1wy9m"}},"9Bee":function(At,ft,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"),j=re("WmNS"),O=re.n(j),P=re("q1tI"),E=re.n(P),L=re("vg9a"),D=re("DlQD"),T=re.n(D),A=re("rUJ1");function w(U,u){var g=U.match(/^(\s+)(?:```)/);if(g===null)return u;var M=g[1];return u.split(`
|
|
`).map(function(J){var F=J.match(/^\s+/);if(F===null)return J;var ce=Object(z.a)(F,1),Ne=ce[0];return Ne.length>=M.length?J.slice(M.length):J}).join(`
|
|
`)}var h=[],o=["<ul>"],d=new T.a.Renderer,c=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function C(){h.length=0,o=["<ul>"]}var y={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function m(U,u,g,M){if(u>=U.length||U[u].level<=g)return u;var J=U[u];M.push("<li><a href='#"+J.anchor+"'>"+J.text+"</a>"),u++;var F=[];return u=m(U,u,J.level,F),F.length>0&&(M.push("<ul>"),F.forEach(function(ce){M.push(ce)}),M.push("</ul>")),M.push("</li>"),u=m(U,u,g,M),u}function l(){return m(h,0,0,o),o.push("</ul>"),o.join("")}var S={heading:function(u){var g=c.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 M=g[0],J=w(M,g[3]||""),F=g[2]?g[2].trim():g[2];if(["latex","katex","math"].indexOf(F)>=0){var ce=s(),Ne=J;J=ce,a[ce]={type:"block",expression:Ne}}return{type:"code",raw:M,lang:F,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 x(U){return U=U.replace(f,function(u,g){var M=s();return a[M]={type:"inline",expression:g},M}),U}var k=d.listitem;d.listitem=function(U){return k(x(U))};var H=d.paragraph;d.paragraph=function(U){return H(x(U))};var V=d.tablecell;d.tablecell=function(U,u){return V(x(U),u)},d.code=function(U,u,g){var M=(u||"").match(/\S*/)[0];return M?["latex","katex","math"].indexOf(M)>=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>"},d.heading=function(U,u,g){var M=this.options.headerPrefix+g.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:M,level:u,text:U}),"<h"+u+' id="'+M+'">'+U+"</h"+u+">"},T.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),T.a.use({tokenizer:S,renderer:d});var Q=T.a,G=re("SJMd"),W=re("ulZh"),q=re.n(W),oe=re("m3rI"),fe=re("Oy/b"),ve=re("p5ED"),ke=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,M){g.__proto__=M}||function(g,M){for(var J in M)Object.prototype.hasOwnProperty.call(M,J)&&(g[J]=M[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,M){return new(g||(g=Promise))(function(J,F){function ce(Tt){try{rt(M.next(Tt))}catch(Be){F(Be)}}function Ne(Tt){try{rt(M.throw(Tt))}catch(Be){F(Be)}}function rt(Tt){var Be;Tt.done?J(Tt.value):(Be=Tt.value,Be instanceof g?Be:new g(function(kt){kt(Be)})).then(ce,Ne)}rt((M=M.apply(U,u||[])).next())})}function Ce(U,u){var g,M,J,F,ce={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return F={next:Ne(0),throw:Ne(1),return:Ne(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function Ne(rt){return function(Tt){return function(Be){if(g)throw new TypeError("Generator is already executing.");for(;ce;)try{if(g=1,M&&(J=2&Be[0]?M.return:Be[0]?M.throw||((J=M.return)&&J.call(M),0):M.next)&&!(J=J.call(M,Be[1])).done)return J;switch(M=0,J&&(Be=[2&Be[0],J.value]),Be[0]){case 0:case 1:J=Be;break;case 4:return ce.label++,{value:Be[1],done:!1};case 5:ce.label++,M=Be[1],Be=[0];continue;case 7:Be=ce.ops.pop(),ce.trys.pop();continue;default:if(!(J=ce.trys,(J=J.length>0&&J[J.length-1])||Be[0]!==6&&Be[0]!==2)){ce=0;continue}if(Be[0]===3&&(!J||Be[1]>J[0]&&Be[1]<J[3])){ce.label=Be[1];break}if(Be[0]===6&&ce.label<J[1]){ce.label=J[1],J=Be;break}if(J&&ce.label<J[2]){ce.label=J[2],ce.ops.push(Be);break}J[2]&&ce.ops.pop(),ce.trys.pop();continue}Be=u.call(U,ce)}catch(kt){Be=[6,kt],M=0}finally{g=J=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([rt,Tt])}}}function me(){for(var U=0,u=0,g=arguments.length;u<g;u++)U+=arguments[u].length;var M=Array(U),J=0;for(u=0;u<g;u++)for(var F=arguments[u],ce=0,Ne=F.length;ce<Ne;ce++,J++)M[J]=F[ce];return M}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 M=0,J=g;M<J.length;M++){var F=J[M],ce=F[0],Ne=F[1];u.setAttribute(ce,Ne)}},U.createRect=function(u,g,M){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",u.toString()),J.setAttribute("height",g.toString()),M&&U.setAttributes(J,M),J},U.createLine=function(u,g,M,J,F){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",M.toString()),ce.setAttribute("y2",J.toString()),F&&U.setAttributes(ce,F),ce},U.createPolygon=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","polygon");return M.setAttribute("points",u),g&&U.setAttributes(M,g),M},U.createCircle=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","circle");return M.setAttribute("cx",(u/2).toString()),M.setAttribute("cy",(u/2).toString()),M.setAttribute("r",u.toString()),g&&U.setAttributes(M,g),M},U.createEllipse=function(u,g,M){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()),M&&U.setAttributes(J,M),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,M,J,F,ce,Ne){var rt=document.createElementNS("http://www.w3.org/2000/svg","marker");return U.setAttributes(rt,[["id",u],["orient",g],["markerWidth",M.toString()],["markerHeight",J.toString()],["refX",F.toString()],["refY",ce.toString()]]),rt.appendChild(Ne),rt},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 M=document.createElementNS("http://www.w3.org/2000/svg","tspan");return M.textContent=u,g&&U.setAttributes(M,g),M},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 M=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return M.x=u,M.y=g,M},U.createPath=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","path");return M.setAttribute("d",u),g&&U.setAttributes(M,g),M},U}(),we=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}(),tt=function(){function U(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return U.prototype.rasterize=function(u,g,M){var J=this;return new Promise(function(F){var ce=M!==void 0?M: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 rt=Ne.outerHTML,Tt=ce.getContext("2d");J.markersOnly!==!0&&Tt.drawImage(u,0,0,ce.width,ce.height);var Be=window.URL,kt=new Image(ce.width,ce.height);kt.setAttribute("crossOrigin","anonymous");var er=new Blob([rt],{type:"image/svg+xml"}),fr=Be.createObjectURL(er);kt.onload=function(){Tt.drawImage(kt,0,0),Be.revokeObjectURL(fr);var Gr=ce.toDataURL(J.imageType,J.imageQuality);F(Gr)},kt.src=fr})},U}(),Ye=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,M,J,F){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=u,this.displayMode=g,this.markerItems=M,this.uiStyleSettings=J,this.styles=F,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 M=document.createElement("div");M.className=this.toolbarBlockStyleClass.name,M.style.whiteSpace="nowrap",this.uiContainer.appendChild(M),this.addActionButton(M,'<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(M,'<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(M,'<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(M,'<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(M,'<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(M,'<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(M,'<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(M,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(F){var ce=document.createElement("div");ce.className=""+g.toolbarButtonStyleClass.name,ce.setAttribute("data-type-name",F.typeName),ce.innerHTML=F.icon,ce.addEventListener("click",function(){g.markerToolbarButtonClicked(ce,F)}),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,M){var J=this,F=document.createElement("div");switch(F.className=""+this.toolbarButtonStyleClass.name,F.innerHTML=g,F.setAttribute("data-action",M),F.addEventListener("click",function(){J.actionToolbarButtonClicked(F,M)}),M){case"select":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":F.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":F.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":F.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":F.style.fill=this.uiStyleSettings.closeButtonColor}u.appendChild(F),this.buttons.push(F)},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(M){return M("marker",g)}),this.markerButtonOverflowBlock.style.display="none"},U.prototype.actionToolbarButtonClicked=function(u,g){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(M){return M("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(M){return M.getAttribute("data-type-name")===u});g&&this.setActiveButton(g)},U.prototype.setCurrentMarker=function(u){var g=this;this.currentMarker=u,this.buttons.filter(function(M){return/delete|notes/.test(M.getAttribute("data-action"))}).forEach(function(M){g.currentMarker===void 0?(M.style.fillOpacity="0.4",M.style.pointerEvents="none"):(M.style.fillOpacity="1",M.style.pointerEvents="all")})},U}(),He=function(){function U(u,g,M,J){this.panels=[],this.panelButtons=[],this.markerjsContainer=u,this.displayMode=g,this.uiStyleSettings=M,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,M,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+" "+((M=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&M!==void 0?M:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(F){var ce;F.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=F.icon,Ne.title=F.title,Ne.addEventListener("click",function(){J.panelButtonClick(F)}),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,M=-1;if(u!==this.activePanel){M=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(F,ce){var Ne,rt;F.className=g.toolboxButtonStyleClass.name+" "+(ce===M?""+((Ne=g.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Ne!==void 0?Ne:g.toolboxActiveButtonStyleColorsClass.name):""+((rt=g.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&rt!==void 0?rt:g.toolboxButtonStyleColorsClass.name))})},U}(),Ge=function(U,u){this.title=U,this.icon=u},je=function(U){function u(g,M,J,F){var ce=U.call(this,g,F||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return ce.colors=[],ce.addTransparent=!1,ce.colorBoxes=[],ce.colors=M,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,M=document.createElement("div");return M.style.overflow="hidden",M.style.whiteSpace="nowrap",this.colors.forEach(function(J){var F=g.getColorBox(J);M.appendChild(F),g.colorBoxes.push(F)}),M},u.prototype.getColorBox=function(g){var M=this,J=this.uiStyleSettings.toolbarHeight/4,F=this.uiStyleSettings.toolbarHeight-J,ce=document.createElement("div");ce.style.display="inline-block",ce.style.boxSizing="content-box",ce.style.width=F-2+"px",ce.style.height=F-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=(F+2)/2+"px",ce.style.borderColor=g===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ce.addEventListener("click",function(){M.setCurrentColor(g,ce)});var Ne=document.createElement("div");return Ne.style.display="inline-block",Ne.style.width=F-2+"px",Ne.style.height=F-2+"px",Ne.style.backgroundColor=g,Ne.style.borderRadius=F/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,M){var J=this;this.currentColor=g,this.colorBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(g)},u}(Ge),Ue=function(){function U(u,g,M){this._state="new",this._isSelected=!1,this._container=u,this._overlayContainer=g,this.globalSettings=M,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}(),Re=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}(),st=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}(),Je=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}(),Qe=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.left=0,F.top=0,F.width=0,F.height=0,F.defaultSize={x:50,y:20},F.offsetX=0,F.offsetY=0,F.rotationAngle=0,F.CB_DISTANCE=10,F._suppressMarkerCreateEvent=!1,F.container.transform.baseVal.appendItem(ne.createTransform()),F.setupControlBox(),F}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 M=ne.createTransform();this._visual.transform.baseVal.appendItem(M)},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,M){U.prototype.pointerDown.call(this,g,M),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(M),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(M)){this.activeGrip=this.rotatorGrip;var F=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=F.x-this.width/2,this.top=F.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var 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 M=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",M==="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 M=this.unrotatePoint(g);this.state==="creating"?this.resize(g):this.state==="move"?(this.left=this.manipulationStartLeft+(M.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(M.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(M):this.state==="rotate"&&this.rotate(g)},u.prototype.resize=function(g){var M=this.manipulationStartLeft,J=this.manipulationStartWidth,F=this.manipulationStartTop,ce=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:M=this.manipulationStartLeft+g.x-this.manipulationStartX,J=this.manipulationStartWidth+this.manipulationStartLeft-M;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:F=this.manipulationStartTop+g.y-this.manipulationStartY,ce=this.manipulationStartHeight+this.manipulationStartTop-F;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=M,this.width=J):(this.left=M+J,this.width=-J),ce>=0?(this.top=F,this.height=ce):(this.top=F+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 M=Math.sign(g.x-this.centerX);this.rotationAngle=180*Math.atan((g.y-this.centerY)/(g.x-this.centerX))/Math.PI+90*M,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 M=this.container.getCTM(),J=ne.createPoint(g.x,g.y);return{x:(J=J.matrixTransform(M)).x,y:J.y}},u.prototype.unrotatePoint=function(g){if(this.rotationAngle===0)return g;var M=this.container.getCTM();M=M.inverse();var J=ne.createPoint(g.x,g.y);return{x:(J=J.matrixTransform(M)).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 Re,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 st;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,M=-g/2,J=M,F=(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,rt=this.width+this.CB_DISTANCE-g/2;this.positionGrip(this.controlGrips.topLeft.visual,M,J),this.positionGrip(this.controlGrips.topCenter.visual,F,J),this.positionGrip(this.controlGrips.topRight.visual,rt,J),this.positionGrip(this.controlGrips.centerLeft.visual,M,ce),this.positionGrip(this.controlGrips.centerRight.visual,rt,ce),this.positionGrip(this.controlGrips.bottomLeft.visual,M,Ne),this.positionGrip(this.controlGrips.bottomCenter.visual,F,Ne),this.positionGrip(this.controlGrips.bottomRight.visual,rt,Ne),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,F,J-3*this.CB_DISTANCE)},u.prototype.positionGrip=function(g,M,J){var F=g.transform.baseVal.getItem(0);F.setTranslate(M,J),g.transform.baseVal.replaceItem(F,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:Je.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Je.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 M=g;this.left=M.left,this.top=M.top,this.width=M.width,this.height=M.height,this.rotationAngle=M.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Je.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,M.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Je.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,M.containerTransformMatrix))},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M);var J=this.rotatePoint({x:this.left,y:this.top}),F=this.unrotatePoint({x:J.x*g,y:J.y*M});this.left=F.x,this.top=F.y,this.width=this.width*g,this.height=this.height*M,this.adjustControlBox()},u}(Ue),nt=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.createVisual=F.createVisual.bind(F),F}return _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,M){U.prototype.pointerDown.call(this,g,M),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 M=g;this.fillColor=M.fillColor,this.strokeColor=M.strokeColor,this.strokeWidth=M.strokeWidth,this.strokeDasharray=M.strokeDasharray,this.opacity=M.opacity,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M),this.setSize()},u.title="Rectangle marker",u}(Qe),bt=function(U){function u(g,M,J,F){var ce=U.call(this,g,F||'<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=M,ce.currentWidth=J,ce.setCurrentWidth=ce.setCurrentWidth.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,M=document.createElement("div");return M.style.display="flex",M.style.overflow="hidden",M.style.flexGrow="2",this.widths.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.flexGrow="2",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=J===g.currentWidth?g.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){g.setCurrentWidth(J,F)}),M.appendChild(F);var ce=document.createElement("div");ce.innerText=J.toString(),ce.style.marginRight="5px",F.appendChild(ce);var Ne=document.createElement("div");Ne.style.minHeight="20px",Ne.style.flexGrow="2",Ne.style.display="flex",Ne.style.alignItems="center";var rt=document.createElement("hr");rt.style.minWidth="20px",rt.style.border="0px",rt.style.borderTop=J+"px solid "+g.uiStyleSettings.toolboxColor,rt.style.flexGrow="2",Ne.appendChild(rt),F.appendChild(Ne),g.widthBoxes.push(F)}),M},u.prototype.setCurrentWidth=function(g,M){var J=this;this.currentWidth=g,this.widthBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},u}(Ge),at=function(U){function u(g,M,J,F){var ce=U.call(this,g,F||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return ce.styles=[],ce.styleBoxes=[],ce.styles=M,ce.currentStyle=J,ce.setCurrentStyle=ce.setCurrentStyle.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,M=document.createElement("div");return M.style.display="flex",M.style.overflow="hidden",M.style.flexGrow="2",this.styles.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/g.styles.length-5+"%",F.style.borderColor=J===g.currentStyle?g.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){g.setCurrentStyle(J,F)}),M.appendChild(F);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,F.appendChild(ce),g.styleBoxes.push(F)}),M},u.prototype.setCurrentStyle=function(g,M){var J=this;this.currentStyle=g,this.styleBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},u}(Ge),ht=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new je("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new bt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new at("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}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}(nt),Ae=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,M,J){var F=U.call(this,g,M,J)||this;return F.x1=0,F.y1=0,F.x2=0,F.y2=0,F.defaultLength=50,F.manipulationStartX=0,F.manipulationStartY=0,F.manipulationStartX1=0,F.manipulationStartY1=0,F.manipulationStartX2=0,F.manipulationStartY2=0,F.setupControlBox(),F}return _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,M){U.prototype.pointerDown.call(this,g,M),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(M)?this.activeGrip=this.grip1:this.grip2.ownsTarget(M)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},u.prototype.pointerUp=function(g){var M=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",M==="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 st;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,M,J){var F=g.transform.baseVal.getItem(0);F.setTranslate(M,J),g.transform.baseVal.replaceItem(F,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 M=g;this.x1=M.x1,this.y1=M.y1,this.x2=M.x2,this.y2=M.y2},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M),this.x1=this.x1*g,this.y1=this.y1*M,this.x2=this.x2*g,this.y2=this.y2*M,this.adjustVisual(),this.adjustControlBox()},u}(Ue),dt=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new je("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new bt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new at("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}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,M){U.prototype.pointerDown.call(this,g,M),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 M=g;this.strokeColor=M.strokeColor,this.strokeWidth=M.strokeWidth,this.strokeDasharray=M.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),De=function(U){function u(g,M,J,F){var ce=U.call(this,g,F||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return ce.fonts=[],ce.fontBoxes=[],ce.fonts=M,ce.currentFont=J,ce.setCurrentFont=ce.setCurrentFont.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,M=document.createElement("div");return M.style.overflow="hidden",M.style.flexGrow="2",this.fonts.forEach(function(J){var F=document.createElement("div");F.style.display="inline-block",F.style.alignItems="center",F.style.justifyContent="space-between",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.overflow="hidden",F.style.maxWidth=100/g.fonts.length-5+"%",F.style.borderColor=J===g.currentFont?g.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){g.setCurrentFont(J,F)}),M.appendChild(F);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),F.appendChild(ce),g.fontBoxes.push(F)}),M},u.prototype.setCurrentFont=function(g,M){var J=this;this.currentFont=g,this.fontBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},u}(Ge),We=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.color="transparent",F.padding=5,F.DEFAULT_TEXT="your text here",F.text=F.DEFAULT_TEXT,F.isMoved=!1,F.color=J.defaultColor,F.fontFamily=J.defaultFontFamily,F.defaultSize={x:100,y:30},F.setColor=F.setColor.bind(F),F.setFont=F.setFont.bind(F),F.renderText=F.renderText.bind(F),F.sizeText=F.sizeText.bind(F),F.textEditDivClicked=F.textEditDivClicked.bind(F),F.showTextEditor=F.showTextEditor.bind(F),F.setSize=F.setSize.bind(F),F.positionTextEditor=F.positionTextEditor.bind(F),F.colorPanel=new je("Color",J.defaultColorSet,J.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.fontFamilyPanel=new De("Font",J.defaultFontFamilies,J.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F}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 M=!1;return this.textElement.childNodes.forEach(function(J){J===g&&(M=!0)}),M},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,M){U.prototype.pointerDown.call(this,g,M),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(M){g.textElement.appendChild(ne.createTSpan(M.trim()===""?" ":M.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},u.prototype.getTextScale=function(){var g=this.textElement.getBBox(),M=1;if(g.width>0&&g.height>0){var J=(1*this.width-this.width*this.padding*2/100)/g.width,F=(1*this.height-this.height*this.padding*2/100)/g.height;M=Math.min(J,F)}return M},u.prototype.getTextPosition=function(g){var M=this.textElement.getBBox(),J=0,F=0;return M.width>0&&M.height>0&&(J=(this.width-M.width*g)/2,F=this.height/2-M.height*g/2),{x:J,y:F}},u.prototype.sizeText=function(){var g=this.textElement.getBBox(),M=this.getTextScale(),J=this.getTextPosition(M);J.y-=g.y*M,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+J.x+"px, "+J.y+"px) scale("+M+", "+M+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(J.x,J.y),this.textElement.transform.baseVal.getItem(1).setScale(M,M))},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 M=this.state;M==="creating"&&(this._suppressMarkerCreateEvent=!0),U.prototype.pointerUp.call(this,g),this.setSize(),(M==="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(M){M.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var M=Number.parseFloat(g.textEditor.style.fontSize);g.textEditor.clientWidth>=Number.parseInt(g.textEditor.style.maxWidth)&&M>.9;)M-=.1,g.textEditor.style.fontSize=Math.max(M,.9)+"em"}),this.textEditor.addEventListener("keyup",function(M){M.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(M){if(M.clipboardData){var J=M.clipboardData.getData("text"),F=window.getSelection();if(!F.rangeCount)return!1;F.deleteFromDocument(),F.getRangeAt(0).insertNode(document.createTextNode(J)),M.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(),M=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),J=this.textElement.getBBox(),F={x:J.width*g,y:J.height*g};M.x-=F.x/2,M.y-=F.y/2,this.textEditor.style.top=M.y+"px",this.textEditor.style.left=M.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-M.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,M){U.prototype.dblClick.call(this,g,M),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 M=g;this.color=M.color,this.fontFamily=M.fontFamily,this.padding=M.padding,this.text=M.text,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M),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}(Qe),ge=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.color="transparent",F.lineWidth=3,F.drawing=!1,F.pixelRatio=1,F.color=J.defaultColor,F.lineWidth=J.defaultStrokeWidth,F.pixelRatio=J.freehandPixelRatio,F.setColor=F.setColor.bind(F),F.addCanvas=F.addCanvas.bind(F),F.finishCreation=F.finishCreation.bind(F),F.setLineWidth=F.setLineWidth.bind(F),F.colorPanel=new je("Color",J.defaultColorSet,J.defaultColor),F.colorPanel.onColorChanged=F.setColor,F.lineWidthPanel=new bt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.lineWidthPanel.onWidthChanged=F.setLineWidth,F}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,M){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,M)},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),M=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],J=M[0],F=M[1],ce=M[2],Ne=M[3],rt=!1,Tt=0;Tt<this.canvasElement.height;Tt++)for(var Be=0;Be<this.canvasElement.width;Be++)g.data[Tt*this.canvasElement.width*4+4*Be+3]>0&&(rt=!0,Tt<F&&(F=Tt),Be<J&&(J=Be),Tt>Ne&&(Ne=Tt),Be>ce&&(ce=Be));if(rt){this.left=J/this.pixelRatio,this.top=F/this.pixelRatio,this.width=(ce-J)/this.pixelRatio,this.height=(Ne-F)/this.pixelRatio;var kt=document.createElement("canvas");kt.width=ce-J,kt.height=Ne-F,kt.getContext("2d").putImageData(this.canvasContext.getImageData(J,F,ce-J,Ne-F),0,0),this.drawingImgUrl=kt.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,M){U.prototype.scale.call(this,g,M),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}(Qe),de=function(U){function u(g,M,J){var F=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 F.typeBoxes=[],F.currentType=M,F.setCurrentType=F.setCurrentType.bind(F),F}return _e(u,U),u.prototype.getUi=function(){var g=this,M=document.createElement("div");M.style.display="flex",M.style.overflow="hidden",M.style.flexGrow="2";for(var J=function(Ne){var rt="both";switch(Ne){case 0:rt="both";break;case 1:rt="start";break;case 2:rt="end";break;case 3:rt="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=rt===F.currentType?F.uiStyleSettings.toolboxAccentColor:"transparent",Tt.addEventListener("click",function(){g.setCurrentType(rt,Tt)}),M.appendChild(Tt),rt==="both"||rt==="start"){var Be=document.createElement("div");Be.style.display="flex",Be.style.alignItems="center",Be.style.minHeight="20px",Be.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Be.style.marginLeft="5px",Tt.appendChild(Be)}var kt=document.createElement("div");kt.style.display="flex",kt.style.alignItems="center",kt.style.minHeight="20px",kt.style.flexGrow="2";var er=document.createElement("hr");if(er.style.minWidth="20px",er.style.border="0px",er.style.borderTop="3px solid "+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee"),er.style.flexGrow="2",kt.appendChild(er),Tt.appendChild(kt),rt==="both"||rt==="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="`+(F.uiStyleSettings!==void 0?F.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,fr.style.marginRight="5px",Tt.appendChild(fr)}F.typeBoxes.push(Tt)},F=this,ce=0;ce<4;ce++)J(ce);return M},u.prototype.setCurrentType=function(g,M){var J=this;this.currentType=g,this.typeBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings!==void 0?J.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},u}(Ge),pe=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.arrowType="end",F.arrowBaseHeight=10,F.arrowBaseWidth=10,F.getArrowPoints=F.getArrowPoints.bind(F),F.setArrowType=F.setArrowType.bind(F),F.arrowTypePanel=new de("Arrow type","end"),F.arrowTypePanel.onArrowTypeChanged=F.setArrowType,F}return _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,M){var J=this.arrowBaseWidth+2*this.strokeWidth,F=this.arrowBaseHeight+2*this.strokeWidth;return g-J/2+","+(M+F/2)+" "+g+","+(M-F/2)+" "+(g+J/2)+","+(M+F/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,M){U.prototype.pointerDown.call(this,g,M),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),M=this.arrow1.transform.baseVal.getItem(0);M.setRotate(g,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(M,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 M=g;this.arrowType=M.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}(dt),ee=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.fillColor=J.defaultFillColor,F.strokeWidth=0,F.fillPanel=new je("Color",J.defaultColorSet,J.defaultFillColor),F.fillPanel.onColorChanged=F.setFillColor,F}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}(nt),te=function(U){function u(g,M,J,F){var ce=U.call(this,g,F||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return ce.opacities=[],ce.opacityBoxes=[],ce.opacities=M,ce.currentOpacity=J,ce.setCurrentOpacity=ce.setCurrentOpacity.bind(ce),ce}return _e(u,U),u.prototype.getUi=function(){var g=this,M=document.createElement("div");return M.style.display="flex",M.style.overflow="hidden",M.style.flexGrow="2",M.style.justifyContent="space-between",this.opacities.forEach(function(J){var F=document.createElement("div");F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="center",F.style.padding="5px",F.style.borderWidth="2px",F.style.borderStyle="solid",F.style.borderColor=J===g.currentOpacity?g.uiStyleSettings.toolboxAccentColor:"transparent",F.addEventListener("click",function(){g.setCurrentOpacity(J,F)}),M.appendChild(F);var ce=document.createElement("div");ce.innerText=100*J+"%",F.appendChild(ce),g.opacityBoxes.push(F)}),M},u.prototype.setCurrentOpacity=function(g,M){var J=this;this.currentOpacity=g,this.opacityBoxes.forEach(function(F){F.style.borderColor=F===M?J.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},u}(Ge),ie=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.setOpacity=F.setOpacity.bind(F),F.fillColor=J.defaultHighlightColor,F.strokeWidth=0,F.opacity=J.defaultHighlightOpacity,F.fillPanel=new je("Color",J.defaultColorSet,F.fillColor),F.fillPanel.onColorChanged=F.setFillColor,F.opacityPanel=new te("Opacity",J.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}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,M,J){var F=U.call(this,g,M,J)||this;return F.bgColor="transparent",F.tipPosition={x:0,y:0},F.tipBase1Position={x:0,y:0},F.tipBase2Position={x:0,y:0},F.tipMoving=!1,F.color=J.defaultStrokeColor,F.bgColor=J.defaultFillColor,F.fontFamily=J.defaultFontFamily,F.defaultSize={x:100,y:30},F.setBgColor=F.setBgColor.bind(F),F.getTipPoints=F.getTipPoints.bind(F),F.positionTip=F.positionTip.bind(F),F.setTipPoints=F.setTipPoints.bind(F),F.colorPanel=new je("Text color",J.defaultColorSet,F.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),F.colorPanel.onColorChanged=F.setColor,F.bgColorPanel=new je("Fill color",J.defaultColorSet,F.bgColor,se),F.bgColorPanel.onColorChanged=F.setBgColor,F.fontFamilyPanel=new De("Font",J.defaultFontFamilies,J.defaultFontFamily),F.fontFamilyPanel.onFontChanged=F.setFont,F.tipGrip=new st,F.tipGrip.visual.transform.baseVal.appendItem(ne.createTransform()),F.controlBox.appendChild(F.tipGrip.visual),F}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,M){this.state==="new"&&U.prototype.pointerDown.call(this,g,M),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(M)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):U.prototype.pointerDown.call(this,g,M)},u.prototype.pointerUp=function(g){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,U.prototype.pointerUp.call(this,g);else{var M=this.state==="creating";U.prototype.pointerUp.call(this,g),this.setTipPoints(M),this.positionTip()}},u.prototype.manipulate=function(g){if(this.tipMoving){var M=this.unrotatePoint(g);this.tipPosition={x:M.x-this.manipulationStartLeft,y:M.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 M=Math.min(this.height/2,15),J=this.height/5;g&&(this.tipPosition={x:M+J/2,y:this.height+20});var F=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(J=this.width/5,M=Math.min(this.width/2,15),this.tipBase1Position={x:M,y:0},this.tipBase2Position={x:M+J,y:0}):(this.tipBase1Position={x:0,y:M},this.tipBase2Position={x:0,y:M+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?F<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(J=this.width/5,M=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-M-J,y:0},this.tipBase2Position={x:this.width-M,y:0}):(this.tipBase1Position={x:this.width,y:M},this.tipBase2Position={x:this.width,y:M+J}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?F<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(J=this.width/5,M=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-M-J,y:this.height},this.tipBase2Position={x:this.width-M,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-M-J},this.tipBase2Position={x:this.width,y:this.height-M}):F<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(J=this.width/5,M=Math.min(this.width/2,15),this.tipBase1Position={x:M,y:this.height},this.tipBase2Position={x:M+J,y:this.height}):(this.tipBase1Position={x:0,y:this.height-M},this.tipBase2Position={x:0,y:this.height-M-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 M=g;this.bgColor=M.bgColor,this.tipPosition=M.tipPosition,U.prototype.restoreState.call(this,g),this.createTip(),this.setTipPoints()},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M),this.tipPosition={x:this.tipPosition.x*g,y:this.tipPosition.y*M},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}(We),Se=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.fillColor="transparent",F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.opacity=1,F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.fillColor=J.defaultFillColor,F.setStrokeColor=F.setStrokeColor.bind(F),F.setFillColor=F.setFillColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.setOpacity=F.setOpacity.bind(F),F.createVisual=F.createVisual.bind(F),F.strokePanel=new je("Line color",me(J.defaultColorSet,["transparent"]),J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.fillPanel=new je("Fill color",me(J.defaultColorSet,["transparent"]),F.fillColor,se),F.fillPanel.onColorChanged=F.setFillColor,F.strokeWidthPanel=new bt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new at("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F.opacityPanel=new te("Opacity",J.defaultOpacitySteps,F.opacity),F.opacityPanel.onOpacityChanged=F.setOpacity,F}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,M){U.prototype.pointerDown.call(this,g,M),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 M=g;this.fillColor=M.fillColor,this.strokeColor=M.strokeColor,this.strokeWidth=M.strokeWidth,this.strokeDasharray=M.strokeDasharray,this.opacity=M.opacity,this.createVisual(),U.prototype.restoreState.call(this,g),this.setSize()},u.prototype.scale=function(g,M){U.prototype.scale.call(this,g,M),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}(Qe),Pe=function(U){function u(g,M,J){return U.call(this,g,M,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,M){U.prototype.pointerDown.call(this,g,M),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),M=this.tip1.transform.baseVal.getItem(0);M.setRotate(g,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(M,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}(dt),Ze=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.strokePanel.colors=J.defaultColorSet,F.fillColor="transparent",F}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}(),Et=function(U){function u(g,M,J){var F=U.call(this,g,M,J)||this;return F.strokeColor="transparent",F.strokeWidth=0,F.strokeDasharray="",F.curveX=0,F.curveY=0,F.manipulationStartCurveX=0,F.manipulationStartCurveY=0,F.setStrokeColor=F.setStrokeColor.bind(F),F.setStrokeWidth=F.setStrokeWidth.bind(F),F.setStrokeDasharray=F.setStrokeDasharray.bind(F),F.positionGrips=F.positionGrips.bind(F),F.addControlGrips=F.addControlGrips.bind(F),F.adjustVisual=F.adjustVisual.bind(F),F.setupControlBox=F.setupControlBox.bind(F),F.resize=F.resize.bind(F),F.strokeColor=J.defaultColor,F.strokeWidth=J.defaultStrokeWidth,F.strokeDasharray=J.defaultStrokeDasharray,F.strokePanel=new je("Line color",J.defaultColorSet,J.defaultColor),F.strokePanel.onColorChanged=F.setStrokeColor,F.strokeWidthPanel=new bt("Line width",J.defaultStrokeWidths,J.defaultStrokeWidth),F.strokeWidthPanel.onWidthChanged=F.setStrokeWidth,F.strokeStylePanel=new at("Line style",J.defaultStrokeDasharrays,J.defaultStrokeDasharray),F.strokeStylePanel.onStyleChanged=F.setStrokeDasharray,F}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,M){U.prototype.pointerDown.call(this,g,M),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(M)&&(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,M){this.curveX=this.curveX*g,this.curveY=this.curveY*M,U.prototype.scale.call(this,g,M)},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 M=g;this.strokeColor=M.strokeColor,this.strokeWidth=M.strokeWidth,this.strokeDasharray=M.strokeDasharray,this.curveX=M.curveX,this.curveY=M.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),Pt=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}(),et=function(U){function u(g,M,J){var F=U.call(this,g,!1)||this;return F.dataUrl=M,F.state=J,F}return _e(u,U),u}(Pt),ct=function(U){function u(g,M,J){J===void 0&&(J=!1);var F=U.call(this,g,J)||this;return F.marker=M,F}return _e(u,U),u}(Pt),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 M=this[u].indexOf(g);M>-1&&this[u].splice(M,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 Ae,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[ht,ge,pe,We,Ze,Se,ie,ue,Pe,ee,dt,Et]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[ht,ge,pe,We,Se,ie,ue]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"BASIC_MARKER_TYPES",{get:function(){return[ht,ge,pe,We,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(M){if(typeof M=="string"){var J=g.ALL_MARKER_TYPES.find(function(F){return F.typeName===M});J!==void 0&&g._availableMarkerTypes.push(J)}else g._availableMarkerTypes.push(M)})},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(),we.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},U.prototype.show=function(){var u=this;this.styles.styleSheetRoot===void 0&&Ye.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ye.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(g){return g(new Pt(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 tt).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 M=!1;u||this.eventListeners.beforeclose.forEach(function(J){var F=new Pt(g,!0);J(F),F.defaultPrevented&&(M=!0)}),M||(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 Pt(g))}),this.detachEvents(),this._isOpen=!1)}},U.prototype.addMarkersToToolbar=function(){for(var u,g=[],M=0;M<arguments.length;M++)g[M]=arguments[M];(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,M=g<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/u;this.resize(g,M)},U.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},U.prototype.resize=function(u,g){this._isResizing=!0;var M=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(M,J),this._isResizing=!1},U.prototype.scaleMarkers=function(u,g){var M,J=this;this._currentMarker&&this._currentMarker instanceof We?this._currentMarker.scale(u,g):(M=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(F){F!==J._currentMarker&&F.scale(u,g)}),M!==void 0&&this.setCurrentMarker(M)},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=[],M=0;M<arguments.length;M++)g[M]=arguments[M];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 He(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 F=new ct(u,u._currentMarker,!0);J(F),F.defaultPrevented&&(g=!0)}),!g){var M=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 ct(u,M))})}}},U.prototype.clear=function(){var u=this,g=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ce){var Ne=new ct(u,void 0,!0);ce(Ne),Ne.defaultPrevented&&(g=!0)}),!g)){this.setCurrentMarker();for(var M=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(rt){return rt(new ct(u,Ne))})},J=this,F=this.markers.length-1;F>=0;F--)M(F);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(),M=this.undoRedoManager.getLastUndoStep();if(!M||M.width===g.width&&M.height===g.height){var J=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(g),J<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(F){return F(new Pt(u))})}else this.undoRedoManager.replaceLastUndoStep(g),this.eventListeners.statechange.forEach(function(F){return F(new Pt(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(M){return M(new Pt(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(M){return M(new Pt(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,M=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(F){return F(new et(M,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(M){return g.markers.push(M.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(M){var J=g._availableMarkerTypes.find(function(ce){return ce.typeName===M.typeName});if(J!==void 0){var F=g.addNewMarker(J);F.restoreState(M),g.markers.push(F)}}),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(M){return M(new Pt(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,M=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 ct(M,M._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(M){return M(new ct(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(M){return M(new ct(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(M){return M(new ct(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(M){return M(new ct(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(M){return M.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(M){return M.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 M=this.markerImage.getBoundingClientRect();return{x:(u-M.left)/this.zoomLevel,y:(g-M.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){we.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 Pt(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 Pt(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,M){g.__proto__=M}||function(g,M){for(var J in M)Object.prototype.hasOwnProperty.call(M,J)&&(g[J]=M[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,M){return new(g||(g=Promise))(function(J,F){function ce(Tt){try{rt(M.next(Tt))}catch(Be){F(Be)}}function Ne(Tt){try{rt(M.throw(Tt))}catch(Be){F(Be)}}function rt(Tt){var Be;Tt.done?J(Tt.value):(Be=Tt.value,Be instanceof g?Be:new g(function(kt){kt(Be)})).then(ce,Ne)}rt((M=M.apply(U,u||[])).next())})}function Qt(U,u){var g,M,J,F,ce={label:0,sent:function(){if(1&J[0])throw J[1];return J[1]},trys:[],ops:[]};return F={next:Ne(0),throw:Ne(1),return:Ne(2)},typeof Symbol=="function"&&(F[Symbol.iterator]=function(){return this}),F;function Ne(rt){return function(Tt){return function(Be){if(g)throw new TypeError("Generator is already executing.");for(;ce;)try{if(g=1,M&&(J=2&Be[0]?M.return:Be[0]?M.throw||((J=M.return)&&J.call(M),0):M.next)&&!(J=J.call(M,Be[1])).done)return J;switch(M=0,J&&(Be=[2&Be[0],J.value]),Be[0]){case 0:case 1:J=Be;break;case 4:return ce.label++,{value:Be[1],done:!1};case 5:ce.label++,M=Be[1],Be=[0];continue;case 7:Be=ce.ops.pop(),ce.trys.pop();continue;default:if(!(J=ce.trys,(J=J.length>0&&J[J.length-1])||Be[0]!==6&&Be[0]!==2)){ce=0;continue}if(Be[0]===3&&(!J||Be[1]>J[0]&&Be[1]<J[3])){ce.label=Be[1];break}if(Be[0]===6&&ce.label<J[1]){ce.label=J[1],J=Be;break}if(J&&ce.label<J[2]){ce.label=J[2],ce.ops.push(Be);break}J[2]&&ce.ops.pop(),ce.trys.pop();continue}Be=u.call(U,ce)}catch(kt){Be=[6,kt],M=0}finally{g=J=0}if(5&Be[0])throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}([rt,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}(),pt=function(){function U(){}return U.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},U.setAttributes=function(u,g){for(var M=0,J=g;M<J.length;M++){var F=J[M],ce=F[0],Ne=F[1];u.setAttribute(ce,Ne)}},U.createRect=function(u,g,M){var J=document.createElementNS("http://www.w3.org/2000/svg","rect");return J.setAttribute("width",u.toString()),J.setAttribute("height",g.toString()),M&&U.setAttributes(J,M),J},U.createLine=function(u,g,M,J,F){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",M.toString()),ce.setAttribute("y2",J.toString()),F&&U.setAttributes(ce,F),ce},U.createPolygon=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","polygon");return M.setAttribute("points",u),g&&U.setAttributes(M,g),M},U.createCircle=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","circle");return M.setAttribute("cx",(u/2).toString()),M.setAttribute("cy",(u/2).toString()),M.setAttribute("r",u.toString()),g&&U.setAttributes(M,g),M},U.createEllipse=function(u,g,M){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()),M&&U.setAttributes(J,M),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,M,J,F,ce,Ne){var rt=document.createElementNS("http://www.w3.org/2000/svg","marker");return U.setAttributes(rt,[["id",u],["orient",g],["markerWidth",M.toString()],["markerHeight",J.toString()],["refX",F.toString()],["refY",ce.toString()]]),rt.appendChild(Ne),rt},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 M=document.createElementNS("http://www.w3.org/2000/svg","tspan");return M.textContent=u,g&&U.setAttributes(M,g),M},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 M=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return M.x=u,M.y=g,M},U.createPath=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg","path");return M.setAttribute("d",u),g&&U.setAttributes(M,g),M},U.createElement=function(u,g){var M=document.createElementNS("http://www.w3.org/2000/svg",u);return g&&U.setAttributes(M,g),M},U.getHollowRectanglePath=function(u,g,M,J,F,ce,Ne,rt){return"M"+u+","+g+"V"+(g+J)+"H"+(u+M)+"V"+g+"H"+F+"V"+ce+"H"+(F+Ne)+"V"+(ce+rt)+"H"+F+"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(M){return g.appendChild(M.getUI())}),g},u}(Mt),it=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(M){return g.appendChild(M)}),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 M=new nr(u,g),J=M.ratio>=1?20:M.getHorizontalLength(20),F=M.ratio<1?20:M.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=pt.createDefs();ce.appendChild(Ne);var rt=pt.createElement("clipPath",[["id","text-bg-clip"]]);Ne.appendChild(rt);var Tt=pt.createPath(pt.getHollowRectanglePath((24-J)/2,(24-F)/2,J,F,(24-J)/2+2,(24-F)/2+2,J-4,F-4));ce.appendChild(Tt);var Be=pt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Be.appendChild(pt.createTSpan(u+":"+g)),ce.appendChild(Be);var kt=Be.getBBox();pt.setAttributes(Be,[["x",((24-kt.width)/2).toString()],["y",((24-kt.height)/2-kt.y).toString()]]);var er=pt.createPath(pt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(kt.width))/2,(24-Math.ceil(kt.height))/2,Math.ceil(kt.width),Math.ceil(kt.height)));return rt.appendChild(er),pt.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,M,J){var F=U.call(this,g,M)||this;return F.isDropdownOpen=!1,F.onClick=F.dropdownButtonClicked,F.dropdownButtons=J,F}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(M){M.className=g.className,M.colorsClassName=g.colorsClassName,g.dropdownBlock.appendChild(M.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}(it),Wt=function(){function U(u,g){this.GRIP_SIZE=10,this.color=u,this.fillColor=g,this.visual=pt.createGroup(),this.visual.appendChild(pt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(pt.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(M){return pt.setAttributes(M,[["cx",u.toString()],["cy",g.toString()]])})},U}(),Tr=function(){function U(u,g,M,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=M,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&&pt.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=pt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=pt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var g=0;g<this.numberOfGridLines;g++)this.horizontalGridLines.push(pt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(pt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(M){return u.gridContainer.appendChild(M)}),this.verticalGridLines.forEach(function(M){return u.gridContainer.appendChild(M)}),this.cropRectElement=pt.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),pt.setAttributes(this.cropRectElement,[["x",g.x.toString()],["y",g.y.toString()],["width",g.width.toString()],["height",g.height.toString()]]);var M=g.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(F,ce){var Ne=g.y+M*(ce+1);pt.setAttributes(F,[["x1",""+g.x],["y1",""+Ne],["x2",""+(g.x+g.width)],["y2",""+Ne]])});var J=g.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(F,ce){var Ne=g.x+J*(ce+1);pt.setAttributes(F,[["x1",""+Ne],["y1",""+g.y],["x2",""+Ne],["y2",""+(g.y+g.height)]])}),pt.setAttributes(this.cropShadeElement,[["d",pt.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 M=this.container.getBoundingClientRect();return{x:u-M.left+this.margin,y:g-M.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,M=u.y-this.previousPoint.y;this.zoomFactor!==1&&(g=-g/this.zoomFactor,M=-M/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+M),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),M=u.x-this.previousPoint.x,J=u.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:g.x+M<this.margin&&(M=this.margin-g.x),g.x+=M,g.width=this.cropRect.x+this.cropRect.width-g.x;break;case this.bottomRightGrip:case this.topRightGrip:g.width+M>this.canvasWidth*this.zoomFactor&&(M=this.canvasWidth*this.zoomFactor-g.width),g.width+=M}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(M),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,M=this.aspectRatio.getHorizontalLength(this.cropRect.height),J=this.aspectRatio.getVerticalLength(this.cropRect.width);M/this.canvasWidth<J/this.canvasHeight?this.cropRect.width=M: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,M,J,F,ce){var Ne=M/u,rt=J/g;return{x:(F.x-ce)*Ne+ce,y:(F.y-ce)*rt+ce,width:F.width*Ne,height:F.height*rt}},U.prototype.scaleCanvas=function(u,g){var M=this.getRescaledRect(this.canvasWidth,this.canvasHeight,u,g,this.cropRect,this.margin);this.canvasWidth=u,this.canvasHeight=g,this.onCropChange&&this.onCropChange(M),this.setCropRectangle(M)},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();pt.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,M=1;M<=this.width/5+10;M++){var J=M%5==0?this.height/3:this.height/6;g+="h4v"+-J+"h1v"+J}g+="v1H0Z",this.scaleShape=pt.createPath(g);var F=pt.createTransform();this.scaleShape.transform.baseVal.appendItem(F),u.appendChild(this.scaleShape),this.angleLabelElement=pt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=pt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ce=pt.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,M,J,F,ce,Ne){var rt=this;return new Promise(function(Tt){var Be=document.createElement("canvas");Be.width=u.width.baseVal.value-2*J,Be.height=u.height.baseVal.value-2*J;var kt=1,er=1;rt.naturalSize===!0?(kt=g.naturalWidth/(u.width.baseVal.value-2*J)/ce,er=g.naturalHeight/(u.height.baseVal.value-2*J)/Ne,Be.width=g.naturalWidth/ce,Be.height=g.naturalHeight/Ne):rt.width!==void 0&&rt.height!==void 0&&(kt=rt.width/M.width,er=rt.height/M.height,Be.width*=kt,Be.height*=er);var fr=Be.getContext("2d");fr.translate(Be.width/2,Be.height/2),fr.rotate(F*Math.PI/180),fr.scale(ce,Ne),fr.translate(-Be.width/2,-Be.height/2),fr.drawImage(g,0,0,Be.width,Be.height);var Gr=document.createElement("canvas");Gr.width=M.width*kt,Gr.height=M.height*er,Gr.getContext("2d").putImageData(fr.getImageData((M.x-J)*kt,(M.y-J)*er,M.width*kt,M.height*er),0,0),Tt(Gr.toDataURL(rt.imageType,rt.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,M=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,M)}},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",pt.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();pt.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=pt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=pt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=pt.createGroup(),this.editingTargetRotationScaleContainer=pt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var u=pt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(u);var g=pt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(g),this.editingTargetContainer=pt.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=pt.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 M=[];this.aspectRatios.forEach(function(er){var fr=new it(Vt.getIcon(er.horizontal,er.vertical),er.horizontal===0&&er.vertical===0?"FREE":er.horizontal+":"+er.vertical);fr.onClick=function(){return u.ratioButtonClicked(er)},M.push(fr)}),this.aspectRatioButton=new qt(Vt.getIcon(0,0),"Aspect ratio",M),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 it('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");J.isActive=this.isGridVisible,J.onClick=function(){u.isGridVisible=!u.isGridVisible,J.isActive=u.isGridVisible},g.addButton(J);var F=new it('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(F.isActive=this.zoomToCropEnabled,F.onClick=function(){u.zoomToCropEnabled=!u.zoomToCropEnabled,F.isActive=u.zoomToCropEnabled},g.addButton(F),!Zt.isLicensed){var ce=new Fe;this.topToolbar.addElementBlock(ce);var Ne=document.createElement("div");Ne.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var rt=document.createElement("a");rt.style.color="currentColor",rt.href="https://markerjs.com/products/cropro",rt.target="_blank",rt.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(rt),ce.addElement(Ne)}var Tt=new St;Tt.minWidth=3*this.toolbarHeight+"px",Tt.contentAlign="end",this.topToolbar.addButtonBlock(Tt);var Be=new it('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");Be.onClick=this.startRenderAndClose,Tt.addButton(Be),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Be.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var kt=new it('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");kt.onClick=this.close,Tt.addButton(kt),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(kt.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 M=new it('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");M.onClick=this.rotateLeftButtonClicked,g.addButton(M);var J=new it('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");J.onClick=this.rotateRightButtonClicked,g.addButton(J);var F=new Fe;F.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(F),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},F.addElement(this.straightener.getUI());var ce=new St;ce.minWidth=2*this.toolbarHeight+"px",ce.contentAlign="end",this.bottomToolbar.addButtonBlock(ce);var Ne=new it('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");Ne.onClick=this.flipHorizontallyButtonClicked,ce.addButton(Ne);var rt=new it('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");rt.onClick=this.flipVerticallyButtonClicked,ce.addButton(rt)},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 M=this.cropImage.getBoundingClientRect();return{x:u-M.left,y:g-M.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 M=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/M.width,this.imageHeight/M.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(M){switch(M.label){case 0:return[4,this.render()];case 1:return u=M.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(),pt.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"),Pr=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=ft.a=function(U){var u=U.value,g=u===void 0?"":u,M=U.edit,J=M===void 0?!1:M,F=U.className,ce=U.showTextOnly,Ne=U.showLines,rt=U.replaces,Tt=U.zoomImg,Be=U.hasMask,kt=U.style,er=kt===void 0?{}:kt,fr=U.stylesPrev,Gr=fr===void 0?{}:fr,Mr=String(g),Ir=Object(P.useRef)(),cn=Object(P.useRef)(),Sn=Object(P.useState)(""),wr=Object(z.a)(Sn,2),ot=wr[0],be=wr[1],Ke=Object(P.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(ke.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&&rt(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(ke.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&&rt(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(P.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()),C()),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(P.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(P.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(),C()}},[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(F||""," markdown-body ").concat(Pr.a.mdBody),onMouseOver:Wr,dangerouslySetInnerHTML:{__html:cr}}),E.a.createElement("div",{ref:Ir,className:Pr.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:ot,type:ot!=null&&ot.length?mt:"",style:Object(N.a)({},Gr),onClose:function(){return be("")}}))}},"9VGf":function(At,ft,re){"use strict";re.d(ft,"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 j=setInterval(z,N);return function(){return clearInterval(j)}}},[N])}},Bd2K:function(At,ft,re){(function(ae){ae(re("VrN/"),re("osHv"))})(function(ae){ae.defineOption("autoCloseTags",!1,function(O,P,E){if(E!=ae.Init&&E&&O.removeKeyMap("autoCloseTags"),!P)return;var L={name:"autoCloseTags"};(typeof P!="object"||P.whenClosing!==!1)&&(L["'/'"]=function(D){return I(D)}),(typeof P!="object"||P.whenOpening!==!1)&&(L["'>'"]=function(D){return X(D)}),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 P=O.listSelections(),E=[],L=O.getOption("autoCloseTags"),D=0;D<P.length;D++){if(!P[D].empty())return ae.Pass;var T=P[D].head,A=O.getTokenAt(T),w=ae.innerMode(O.getMode(),A.state),h=w.state,o=w.mode.xmlCurrentTag&&w.mode.xmlCurrentTag(h),d=o&&o.name;if(!d)return ae.Pass;var c=w.mode.configuration=="html",C=typeof L=="object"&&L.dontCloseTags||c&&$,y=typeof L=="object"&&L.indentTags||c&&R;A.end>T.ch&&(d=d.slice(0,d.length-A.end+T.ch));var m=d.toLowerCase();if(!d||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||C&&z(C,m)>-1||j(O,w.mode.xmlCurrentContext&&w.mode.xmlCurrentContext(h)||[],d,T,!0))return ae.Pass;var l=typeof L=="object"&&L.emptyTags;if(l&&z(l,d)>-1){E[D]={text:"/>",newPos:ae.Pos(T.line,T.ch+2)};continue}var S=y&&z(y,m)>-1;E[D]={indent:S,text:">"+(S?`
|
|
|
|
`:"")+"</"+d+">",newPos:S?ae.Pos(T.line+1,0):ae.Pos(T.line,T.ch+1)}}for(var f=typeof L=="object"&&L.dontIndentOnAutoClose,D=P.length-1;D>=0;D--){var p=E[D];O.replaceRange(p.text,P[D].head,P[D].anchor,"+insert");var s=O.listSelections().slice(0);s[D]={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,P){for(var E=O.listSelections(),L=[],D=P?"/":"</",T=O.getOption("autoCloseTags"),A=typeof T=="object"&&T.dontIndentOnSlash,w=0;w<E.length;w++){if(!E[w].empty())return ae.Pass;var h=E[w].head,o=O.getTokenAt(h),d=ae.innerMode(O.getMode(),o.state),c=d.state;if(P&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=h.ch-1))return ae.Pass;var C,y=d.mode.name!="xml"&&O.getMode().name=="htmlmixed";if(y&&d.mode.name=="javascript")C=D+"script";else if(y&&d.mode.name=="css")C=D+"style";else{var m=d.mode.xmlCurrentContext&&d.mode.xmlCurrentContext(c);if(!m||m.length&&j(O,m,m[m.length-1],h))return ae.Pass;C=D+m[m.length-1]}O.getLine(h.line).charAt(o.end)!=">"&&(C+=">"),L[w]=C}if(O.replaceSelections(L),E=O.listSelections(),!A)for(var w=0;w<E.length;w++)(w==E.length-1||E[w].head.line<E[w+1].head.line)&&O.indentLine(E[w].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,P){if(O.indexOf)return O.indexOf(P);for(var E=0,L=O.length;E<L;++E)if(O[E]==P)return E;return-1}function j(O,P,E,L,D){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 w=D?1:0,h=P.length-1;h>=0&&P[h]==E;h--)++w;L=A.to;for(var h=1;h<w;h++){var o=ae.scanForClosingTag(O,L,null,T);if(!o||o.tag!=E)return!1;L=o.to}return!0}})},BjJ7:function(At,ft,re){"use strict";re.d(ft,"d",function(){return $}),re.d(ft,"c",function(){return R}),re.d(ft,"e",function(){return X}),re.d(ft,"b",function(){return N}),re.d(ft,"a",function(){return z});var ae=re("m3rI");function $(j){var O=!0;if(j.length>0){for(var P=0;P<j.length;P++)if(j[P].compile_success==0||!j[P].compile_success){O=!1;break}}else O=!1;return O}function R(j){for(var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",P=[],E=0;E<j.length;E++){var L=j[E],D=O?"".concat(O,"/").concat(L.name):"".concat(L.name);P.push({title:L.name,isLeaf:!(L.type==="tree"),key:D})}return P}function X(j,O,P){for(var E=0;E<j.length;E++){var L=j[E];if(L.key===O){L.children=P;break}L.children&&X(L.children,O,P)}return j}function N(j,O,P){var E;return function(){var L=this,D=arguments,T=function(){E=null,P||j.apply(L,D)},A=P&&!E;clearTimeout(E),E=setTimeout(T,O),A&&j.apply(L,D)}}var I=!0,z=ae.a.API_SERVER},"C+DQ":function(At,ft,re){},DlQD:function(At,ft,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}}),j=z.defaults,O=z.getDefaults,P=z.changeDefaults,E=/[&<>"']/,L=/[&<>"']/g,D=/[<>"']|&(?!#?\w+;)/,T=/[<>"']|&(?!#?\w+;)/g,A={"&":"&","<":"<",">":">",'"':""","'":"'"},w=function(de){return A[de]};function h(ge,de){if(de){if(E.test(ge))return ge.replace(L,w)}else if(D.test(ge))return ge.replace(T,w);return ge}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function d(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 c=/(^|[^\[])\^/g;function C(ge,de){ge=ge.source||ge,de=de||"";var pe={replace:function(te,ie){return ie=ie.source||ie,ie=ie.replace(c,"$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(d(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 S={},f=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,s=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(ge,de){S[" "+ge]||(f.test(ge)?S[" "+ge]=ge+"/":S[" "+ge]=k(ge,"/",!0)),ge=S[" "+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 x(ge,de){var pe=ge.replace(/\|/g,function(ie,se,ue){for(var Se=!1,Pe=se;--Pe>=0&&ue[Pe]==="\\";)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 k(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:d,edit:C,cleanUrl:l,resolveUrl:a,noopTest:b,merge:v,splitCells:x,rtrim:k,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 ke(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=ke(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]===")",Pe={type:"list",raw:ie,ordered:ue,start:ue?+se.slice(0,-1):"",loose:!1,items:[]},Ze=te[0].match(this.rules.block.item),qe=!1,Et,Pt,et,ct,Ft,Ct,jt,$t=Ze.length,Lt=0;Lt<$t;Lt++)Et=Ze[Lt],ie=Et,Pt=Et.length,Et=Et.replace(/^ *([*+-]|\d+[.)]) */,""),~Et.indexOf(`
|
|
`)&&(Pt-=Et.length,Et=this.options.pedantic?Et.replace(/^ {1,4}/gm,""):Et.replace(new RegExp("^ {1,"+Pt+"}","gm"),"")),Lt!==$t-1&&(et=this.rules.block.bullet.exec(Ze[Lt+1])[0],(ue?et.length===1||!Se&&et[et.length-1]===")":et.length>1||this.options.smartLists&&et!==se)&&(ct=Ze.slice(Lt+1).join(`
|
|
`),Pe.raw=Pe.raw.substring(0,Pe.raw.length-ct.length),Lt=$t-1)),Ft=qe||/\n\n(?!\s*$)/.test(Et),Lt!==$t-1&&(qe=Et.charAt(Et.length-1)===`
|
|
`,Ft||(Ft=qe)),Ft&&(Pe.loose=!0),Ct=/^\[[ xX]\] /.test(Et),jt=void 0,Ct&&(jt=Et[1]!==" ",Et=Et.replace(/^\[[ xX]\] +/,"")),Pe.items.push({type:"list_item",raw:ie,task:Ct,checked:jt,loose:Ft,text:Et});return Pe}},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],Pe="";if(this.options.pedantic){var Ze=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Se);Ze?(Se=Ze[1],Pe=Ze[3]):Pe=""}else Pe=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:Pe&&Pe.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 we={block:me,inline:ne},tt=z.defaults,Ye=we.block,Xe=we.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||tt,this.options.tokenizer=this.options.tokenizer||new Ee,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var ee={block:Ye.normal,inline:Xe.normal};this.options.pedantic?(ee.block=Ye.pedantic,ee.inline=Xe.pedantic):this.options.gfm&&(ee.block=Ye.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,Pe;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):(Pe=te[te.length-1],Pe.raw+=`
|
|
`+se.raw,Pe.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):(Pe=te[te.length-1],Pe.raw+=`
|
|
`+se.raw,Pe.text+=`
|
|
`+se.text);continue}if(ee){var Ze="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(Ze);break}else throw new Error(Ze)}}return te},de.inline=function(ee){var te,ie,se,ue,Se,Pe,Ze=ee.length;for(te=0;te<Ze;te++){Pe=ee[te];switch(Pe.type){case"paragraph":case"text":case"heading":{Pe.tokens=[],this.inlineTokens(Pe.text,Pe.tokens);break}case"table":{for(Pe.tokens={header:[],cells:[]},ue=Pe.header.length,ie=0;ie<ue;ie++)Pe.tokens.header[ie]=[],this.inlineTokens(Pe.header[ie],Pe.tokens.header[ie]);for(ue=Pe.cells.length,ie=0;ie<ue;ie++)for(Se=Pe.cells[ie],Pe.tokens.cells[ie]=[],se=0;se<Se.length;se++)Pe.tokens.cells[ie][se]=[],this.inlineTokens(Se[se],Pe.tokens.cells[ie][se]);break}case"blockquote":{this.inline(Pe.tokens);break}case"list":{for(ue=Pe.items.length,ie=0;ie<ue;ie++)this.inline(Pe.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,Pe=ee,Ze;if(this.tokens.links){var qe=Object.keys(this.tokens.links);if(qe.length>0)for(;(Ze=this.tokenizer.rules.inline.reflinkSearch.exec(Pe))!=null;)qe.includes(Ze[0].slice(Ze[0].lastIndexOf("[")+1,-1))&&(Pe=Pe.slice(0,Ze.index)+"["+"a".repeat(Ze[0].length-2)+"]"+Pe.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Ze=this.tokenizer.rules.inline.blockSkip.exec(Pe))!=null;)Pe=Pe.slice(0,Ze.index)+"["+"a".repeat(Ze[0].length-2)+"]"+Pe.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,Pe,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,Pe,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 Et="Infinite loop on byte: "+ee.charCodeAt(0);if(this.options.silent){console.error(Et);break}else throw new Error(Et)}}return te},$(ge,null,[{key:"rules",get:function(){return{block:Ye,inline:Xe}}}]),ge}(),He=z.defaults,Ge=Q.cleanUrl,je=Q.escape,Ue=function(){function ge(pe){this.options=pe||He}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+je(se,!0)+'">'+(ie?ee:je(ee,!0))+`</code></pre>
|
|
`:"<pre><code>"+(ie?ee:je(ee,!0))+`</code></pre>
|
|
`},de.blockquote=function(ee){return`<blockquote>
|
|
`+ee+`</blockquote>
|
|
`},de.html=function(ee){return ee},de.heading=function(ee,te,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="'+je(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}(),Re=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}(),st=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}(),Je=z.defaults,Qe=Q.unescape,nt=function(){function ge(pe){this.options=pe||Je,this.options.renderer=this.options.renderer||new Ue,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Re,this.slugger=new st}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,Pe,Ze,qe,Et,Pt,et,ct,Ft,Ct,jt,$t,Lt,Qt,Zt,pt,Xt=ee.length;for(se=0;se<Xt;se++){ct=ee[se];switch(ct.type){case"space":continue;case"hr":{ie+=this.renderer.hr();continue}case"heading":{ie+=this.renderer.heading(this.parseInline(ct.tokens),ct.depth,Qe(this.parseInline(ct.tokens,this.textRenderer)),this.slugger);continue}case"code":{ie+=this.renderer.code(ct.text,ct.lang,ct.escaped);continue}case"table":{for(Pt="",Et="",Pe=ct.header.length,ue=0;ue<Pe;ue++)Et+=this.renderer.tablecell(this.parseInline(ct.tokens.header[ue]),{header:!0,align:ct.align[ue]});for(Pt+=this.renderer.tablerow(Et),et="",Pe=ct.cells.length,ue=0;ue<Pe;ue++){for(qe=ct.tokens.cells[ue],Et="",Ze=qe.length,Se=0;Se<Ze;Se++)Et+=this.renderer.tablecell(this.parseInline(qe[Se]),{header:!1,align:ct.align[Se]});et+=this.renderer.tablerow(Et)}ie+=this.renderer.table(Pt,et);continue}case"blockquote":{et=this.parse(ct.tokens),ie+=this.renderer.blockquote(et);continue}case"list":{for(Ft=ct.ordered,Ct=ct.start,jt=ct.loose,Pe=ct.items.length,et="",ue=0;ue<Pe;ue++)Lt=ct.items[ue],Qt=Lt.checked,Zt=Lt.task,$t="",Lt.task&&(pt=this.renderer.checkbox(Qt),jt?Lt.tokens.length>0&&Lt.tokens[0].type==="text"?(Lt.tokens[0].text=pt+" "+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=pt+" "+Lt.tokens[0].tokens[0].text)):Lt.tokens.unshift({type:"text",text:pt}):$t+=pt),$t+=this.parse(Lt.tokens,jt),et+=this.renderer.listitem($t,Zt,Qt);ie+=this.renderer.list(et,Ft,Ct);continue}case"html":{ie+=this.renderer.html(ct.text);continue}case"paragraph":{ie+=this.renderer.paragraph(this.parseInline(ct.tokens));continue}case"text":{for(et=ct.tokens?this.parseInline(ct.tokens):ct.text;se+1<Xt&&ee[se+1].type==="text";)ct=ee[++se],et+=`
|
|
`+(ct.tokens?this.parseInline(ct.tokens):ct.text);ie+=te?this.renderer.paragraph(et):et;continue}default:{var zt='Token with "'+ct.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 Pe='Token with "'+ue.type+'" type was not found.';if(this.options.silent){console.error(Pe);return}else throw new Error(Pe)}}}return ie},ge}(),bt=Q.merge,at=Q.checkSanitizeDeprecation,ht=Q.escape,Ae=z.getDefaults,gt=z.changeDefaults,dt=z.defaults;function De(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=bt({},De.defaults,de||{}),at(de),pe){var ee=de.highlight,te;try{te=Me.lex(ge,de)}catch(Se){return pe(Se)}var ie=function(Pe){var Ze;if(!Pe)try{Ze=nt.parse(te,de)}catch(qe){Pe=qe}return de.highlight=ee,Pe?pe(Pe):pe(null,Ze)};if(!ee||ee.length<3)return ie();if(delete de.highlight,!te.length)return ie();var se=0;De.walkTokens(te,function(Se){Se.type==="code"&&(se++,setTimeout(function(){ee(Se.text,Se.lang,function(Pe,Ze){if(Pe)return ie(Pe);Ze!=null&&Ze!==Se.text&&(Se.text=Ze,Se.escaped=!0),se--,se===0&&ie()})},0))}),se===0&&ie();return}try{var ue=Me.lex(ge,de);return de.walkTokens&&De.walkTokens(ue,de.walkTokens),nt.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>"+ht(Se.message+"",!0)+"</pre>";throw Se}}De.options=De.setOptions=function(ge){return bt(De.defaults,ge),gt(De.defaults),De},De.getDefaults=Ae,De.defaults=dt,De.use=function(ge){var de=bt({},ge);if(ge.renderer&&function(){var ee=De.defaults.renderer||new Ue,te=function(ue){var Se=ee[ue];ee[ue]=function(){for(var Pe=arguments.length,Ze=new Array(Pe),qe=0;qe<Pe;qe++)Ze[qe]=arguments[qe];var Et=ge.renderer[ue].apply(ee,Ze);return Et===!1&&(Et=Se.apply(ee,Ze)),Et}};for(var ie in ge.renderer)te(ie);de.renderer=ee}(),ge.tokenizer&&function(){var ee=De.defaults.tokenizer||new Ee,te=function(ue){var Se=ee[ue];ee[ue]=function(){for(var Pe=arguments.length,Ze=new Array(Pe),qe=0;qe<Pe;qe++)Ze[qe]=arguments[qe];var Et=ge.tokenizer[ue].apply(ee,Ze);return Et===!1&&(Et=Se.apply(ee,Ze)),Et}};for(var ie in ge.tokenizer)te(ie);de.tokenizer=ee}(),ge.walkTokens){var pe=De.defaults.walkTokens;de.walkTokens=function(ee){ge.walkTokens(ee),pe&&pe(ee)}}De.setOptions(de)},De.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;De.walkTokens(ue,de)}for(var Se=N(te.tokens.cells),Pe;!(Pe=Se()).done;)for(var Ze=Pe.value,qe=N(Ze),Et;!(Et=qe()).done;){var Pt=Et.value;De.walkTokens(Pt,de)}break}case"list":{De.walkTokens(te.items,de);break}default:te.tokens&&De.walkTokens(te.tokens,de)}}},De.Parser=nt,De.parser=nt.parse,De.Renderer=Ue,De.TextRenderer=Re,De.Lexer=Me,De.lexer=Me.lex,De.Tokenizer=Ee,De.Slugger=st,De.parse=De;var We=De;return We})},ELLl:function(At,ft,re){(function(ae){ae(re("VrN/"))})(function(ae){var $={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},R=ae.Pos;ae.defineOption("autoCloseBrackets",!1,function(A,w,h){h&&h!=ae.Init&&(A.removeKeyMap(N),A.state.closeBrackets=null),w&&(I(X(w,"pairs")),A.state.closeBrackets=w,A.addKeyMap(N))});function X(A,w){return w=="pairs"&&typeof A=="string"?A:typeof A=="object"&&A[w]!=null?A[w]:$[w]}var N={Backspace:O,Enter:P};function I(A){for(var w=0;w<A.length;w++){var h=A.charAt(w),o="'"+h+"'";N[o]||(N[o]=z(h))}}I($.pairs+"`");function z(A){return function(w){return L(w,A)}}function j(A){var w=A.state.closeBrackets;if(!w||w.override)return w;var h=A.getModeAt(A.getCursor());return h.closeBrackets||w}function O(A){var w=j(A);if(!w||A.getOption("disableInput"))return ae.Pass;for(var h=X(w,"pairs"),o=A.listSelections(),d=0;d<o.length;d++){if(!o[d].empty())return ae.Pass;var c=D(A,o[d].head);if(!c||h.indexOf(c)%2!=0)return ae.Pass}for(var d=o.length-1;d>=0;d--){var C=o[d].head;A.replaceRange("",R(C.line,C.ch-1),R(C.line,C.ch+1),"+delete")}}function P(A){var w=j(A),h=w&&X(w,"explode");if(!h||A.getOption("disableInput"))return ae.Pass;for(var o=A.listSelections(),d=0;d<o.length;d++){if(!o[d].empty())return ae.Pass;var c=D(A,o[d].head);if(!c||h.indexOf(c)%2!=0)return ae.Pass}A.operation(function(){var C=A.lineSeparator()||`
|
|
`;A.replaceSelection(C+C,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 w=ae.cmpPos(A.anchor,A.head)>0;return{anchor:new R(A.anchor.line,A.anchor.ch+(w?-1:1)),head:new R(A.head.line,A.head.ch+(w?1:-1))}}function L(A,w){var h=j(A);if(!h||A.getOption("disableInput"))return ae.Pass;var o=X(h,"pairs"),d=o.indexOf(w);if(d==-1)return ae.Pass;for(var c=X(h,"closeBefore"),C=X(h,"triples"),y=o.charAt(d+1)==w,m=A.listSelections(),l=d%2==0,S,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==w)y&&T(A,s)?a="both":C.indexOf(w)>=0&&A.getRange(s,R(s.line,s.ch+3))==w+w+w?a="skipThree":a="skip";else if(y&&s.ch>1&&C.indexOf(w)>=0&&A.getRange(R(s.line,s.ch-2),s)==w+w){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!=w&&!ae.isWordChar(v))a="both";else return ae.Pass}else if(l&&(b.length===0||/\s/.test(b)||c.indexOf(b)>-1))a="both";else return ae.Pass;if(!S)S=a;else if(S!=a)return ae.Pass}var x=d%2?o.charAt(d-1):w,k=d%2?w:o.charAt(d+1);A.operation(function(){if(S=="skip")A.execCommand("goCharRight");else if(S=="skipThree")for(var H=0;H<3;H++)A.execCommand("goCharRight");else if(S=="surround"){for(var V=A.getSelections(),H=0;H<V.length;H++)V[H]=x+V[H]+k;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 S=="both"?(A.replaceSelection(x+k,null),A.triggerElectric(x+k),A.execCommand("goCharLeft")):S=="addFour"&&(A.replaceSelection(x+x+x+x,"before"),A.execCommand("goCharRight"))})}function D(A,w){var h=A.getRange(R(w.line,w.ch-1),R(w.line,w.ch+1));return h.length==2?h:null}function T(A,w){var h=A.getTokenAt(R(w.line,w.ch+1));return/\bstring/.test(h.type)&&h.start==w.ch&&(w.ch==0||!/\bstring/.test(A.getTokenTypeAt(w)))}})},FIWC:function(At,ft,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,ft){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 j=Object.prototype.hasOwnProperty.bind($),O=0;O<I.length;O++){var P=I[O];if(!j(P))return!1;var E=ae[P],L=$[P];if(N=R?R.call(X,E,L,P):void 0,N===!1||N===void 0&&E!==L)return!1}return!0}},HmJG:function(At,ft,re){},LdHM:function(At,ft,re){"use strict";re.d(ft,"b",function(){return c}),re.d(ft,"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"),j=re("ODXe"),O=re("4IlW"),P=re("bX4T"),E=re("YrtM"),L=re("TSYQ"),D=re.n(L),T=re("+nKL"),A=re("8OUc"),w=function(q,oe){var fe=q.prefixCls,ve=q.id,ke=q.flattenOptions,Ee=q.childrenAsData,_e=q.values,Te=q.searchValue,Ce=q.multiple,me=q.defaultActiveFirstOption,ne=q.height,we=q.itemHeight,tt=q.notFoundContent,Ye=q.open,Xe=q.menuItemSelectedIcon,Ve=q.virtual,Le=q.onSelect,Me=q.onToggleOpen,He=q.onActiveValue,Ge=q.onScroll,je=q.onMouseEnter,Ue="".concat(fe,"-item"),Re=Object(E.a)(function(){return ke},[Ye,ke],function(We,ge){return ge[0]&&We[1]!==ge[1]}),st=N.useRef(null),Je=function(ge){ge.preventDefault()},Qe=function(ge){st.current&&st.current.scrollTo({index:ge})},nt=function(ge){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,pe=Re.length,ee=0;ee<pe;ee+=1){var te=(ge+ee*de+pe)%pe,ie=Re[te],se=ie.group,ue=ie.data;if(!se&&!ue.disabled)return te}return-1},bt=N.useState(function(){return nt(0)}),at=Object(j.a)(bt,2),ht=at[0],Ae=at[1],gt=function(ge){Ae(ge);var de=Re[ge];if(!de){He(null,-1);return}He(de.data.value,ge)};N.useEffect(function(){gt(me!==!1?nt(0):-1)},[Re.length,Te]),N.useEffect(function(){var We=setTimeout(function(){if(!Ce&&Ye&&_e.size===1){var ge=Array.from(_e)[0],de=Re.findIndex(function(pe){var ee=pe.data;return ee.value===ge});gt(de),Qe(de)}});return function(){return clearTimeout(We)}},[Ye]);var dt=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=nt(ht+pe,pe);Qe(ee),gt(ee)}break}case O.a.ENTER:{var te=Re[ht];te&&!te.data.disabled?dt(te.data.value):dt(void 0),Ye&&ge.preventDefault();break}case O.a.ESC:Me(!1)}},onKeyUp:function(){},scrollTo:function(ge){Qe(ge)}}}),Re.length===0)return N.createElement("div",{role:"listbox",id:"".concat(ve,"_list"),className:"".concat(Ue,"-empty"),onMouseDown:Je},tt);function De(We){var ge=Re[We];if(!ge)return null;var de=ge.data||{},pe=de.value,ee=de.label,te=de.children,ie=Object(P.a)(de,!0),se=Ee?te:ee;return ge?N.createElement("div",Object.assign({"aria-label":typeof se=="string"?se:null},ie,{key:We,role:"option",id:"".concat(ve,"_list_").concat(We),"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"}},De(ht-1),De(ht),De(ht+1)),N.createElement(T.a,{itemKey:"key",ref:st,data:Re,height:ne,itemHeight:we,fullHeight:!1,onMouseDown:Je,onScroll:Ge,virtual:Ve,onMouseEnter:je},function(We,ge){var de,pe=We.group,ee=We.groupOption,te=We.data,ie=te.label,se=te.key;if(pe)return N.createElement("div",{className:D()(Ue,"".concat(Ue,"-group"))},ie!==void 0?ie:se);var ue=te.disabled,Se=te.value,Pe=te.title,Ze=te.children,qe=te.style,Et=te.className,Pt=Object(z.a)(te,["disabled","value","title","children","style","className"]),et=_e.has(Se),ct="".concat(Ue,"-option"),Ft=D()(Ue,ct,Et,(de={},Object(I.a)(de,"".concat(ct,"-grouped"),ee),Object(I.a)(de,"".concat(ct,"-active"),ht===ge&&!ue),Object(I.a)(de,"".concat(ct,"-disabled"),ue),Object(I.a)(de,"".concat(ct,"-selected"),et),de)),Ct=Ee?Ze:ie,jt=!Xe||typeof Xe=="function"||et;return N.createElement("div",Object.assign({},Pt,{"aria-selected":et,className:Ft,title:Pe,onMouseMove:function(){if(ht===ge||ue)return;gt(ge)},onClick:function(){ue||dt(Se)},style:qe}),N.createElement("div",{className:"".concat(ct,"-content")},Ct||Se),N.isValidElement(Xe)||et,jt&&N.createElement(A.a,{className:"".concat(Ue,"-option-state"),customizeIcon:Xe,customizeIconProps:{isSelected:et}},et?"\u2713":null))}))},h=N.forwardRef(w);h.displayName="OptionList";var o=h,d=function(){return null};d.isSelectOption=!0;var c=d,C=function(){return null};C.isSelectOptGroup=!0;var y=C,m=re("VTBJ"),l=re("Zm9Q");function S(W){var q=W.key,oe=W.props,fe=oe.children,ve=oe.value,ke=Object(z.a)(oe,["children","value"]);return Object(m.a)({key:q,value:ve!==void 0?ve:q,children:fe},ke)}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,ke=oe.key,Ee=oe.props,_e=Ee.children,Te=Object(z.a)(Ee,["children"]);return q||!ve?S(oe):Object(m.a)(Object(m.a)({key:"__RC_SELECT_GRP__".concat(ke===null?fe:ke,"__"),label:ke},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 x(W){var q=W.mode,oe=W.options,fe=W.children,ve=W.backfill,ke=W.allowClear,Ee=W.placeholder,_e=W.getInputElement,Te=W.showSearch,Ce=W.onSearch,me=W.defaultOpen,ne=W.autoFocus,we=W.labelInValue,tt=W.value,Ye=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(Ue){return!Ue.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),q==="tags"||q==="combobox"){var He=Me.some(function(Ue){return Ue.options?Ue.options.some(function(Re){return typeof("value"in Re?Re.value:Re.key)=="number"}):typeof("value"in Ue?Ue.value:Ue.key)=="number"});Object(b.a)(!He,"`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||!ke||!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."),tt!=null){var Ge=Object(v.d)(tt);Object(b.a)(!we||Ge.every(function(Ue){return Object(a.a)(Ue)==="object"&&("key"in Ue||"value"in Ue)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Ve||Array.isArray(tt),"`value` should be array when `mode` is `multiple` or `tags`")}if(fe){var je=null;Object(l.a)(fe).some(function(Ue){if(!N.isValidElement(Ue)||!Ue.type)return!1;var Re=Ue.type;if(Re.isSelectOption)return!1;if(Re.isSelectOptGroup){var st=Object(l.a)(Ue.props.children).every(function(Je){return!N.isValidElement(Je)||!Ue.type||Je.type.isSelectOption?!0:(je=Je.type,!1)});return!st}return je=Re,!0}),je&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(je.displayName||je.name||je,"`.")),Object(b.a)(Ye===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var k=x,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:k,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=c,V.OptGroup=y;var Q=V,G=ft.c=Q},M8RZ:function(At,ft,re){"use strict";re.d(ft,"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"),j=re.n(z),O=function(P){Object(R.a)(L,P);var E=Object(X.a)(L);function L(D){var T;Object(ae.a)(this,L),T=E.call(this,D);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,ft,re){At.exports={flex:"flex___2gmSR",flex1:"flex1___3Tu1g",color666:"color666___2uyGL",error:"error___yJ86W",deleteIcon:"deleteIcon___1D2tg",addIcon:"addIcon___2VIYB"}},OLES:function(At,ft,re){"use strict";var ae=re("U8pU"),$=re("VTBJ"),R=re("Ff2n"),X=re("q1tI"),N=re("uciX"),I=re("7ixt"),z=function(D){var T=D.overlay,A=D.prefixCls,w=D.id,h=D.overlayInnerStyle;return X.createElement("div",{className:"".concat(A,"-inner"),id:w,role:"tooltip",style:h},typeof T=="function"?T():T)},j=z,O=function(D,T){var A=D.overlayClassName,w=D.trigger,h=w===void 0?["hover"]:w,o=D.mouseEnterDelay,d=o===void 0?0:o,c=D.mouseLeaveDelay,C=c===void 0?.1:c,y=D.overlayStyle,m=D.prefixCls,l=m===void 0?"rc-tooltip":m,S=D.children,f=D.onVisibleChange,p=D.afterVisibleChange,s=D.transitionName,a=D.animation,b=D.placement,v=b===void 0?"right":b,x=D.align,k=x===void 0?{}:x,H=D.destroyTooltipOnHide,V=H===void 0?!1:H,Q=D.defaultVisible,G=D.getTooltipContainer,W=D.overlayInnerStyle,q=Object(R.a)(D,["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 D&&(fe.popupVisible=D.visible);var ve=function(){var Ce=D.arrowContent,me=Ce===void 0?null:Ce,ne=D.overlay,we=D.id;return[X.createElement("div",{className:"".concat(l,"-arrow"),key:"arrow"},me),X.createElement(j,{key:"content",prefixCls:l,id:we,overlay:ne,overlayInnerStyle:W})]},ke=!1,Ee=!1;if(typeof V=="boolean")ke=V;else if(V&&Object(ae.a)(V)==="object"){var _e=V.keepParent;ke=_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:k,getPopupContainer:G,onPopupVisibleChange:f,afterPopupVisibleChange:p,popupTransitionName:s,popupAnimation:a,defaultPopupVisible:Q,destroyPopupOnHide:ke,autoDestroy:Ee,mouseLeaveDelay:C,popupStyle:y,mouseEnterDelay:d},fe),S)},P=Object(X.forwardRef)(O),E=ft.a=P},Ot1p:function(At,ft,re){"use strict";var ae=re("2qtc"),$=re("kLXV"),R=re("rAM+"),X=re("miYZ"),N=re("tsqr"),I=re("9og8"),z=re("tJVT"),j=re("jrin"),O=re("WmNS"),P=re.n(O),E=re("q1tI"),L=re.n(E),D=re("VrN/"),T=re.n(D),A=re("bdgK"),w=re("p77/"),h=re("Bd2K"),o=re("ELLl"),d=re("19Vz"),c=re("lZu9"),C=re("+NIl"),y=re("kSUc"),m=re("9Bee"),l=function(ue){var Se=ue.value,Pe=Se===void 0?"":Se,Ze=ue.className,qe=ue.showTextOnly,Et=ue.showLines,Pt=ue.style,et=Pt===void 0?{}:Pt,ct=Object(E.useMemo)(function(){return""},[Pe]);return L.a.createElement(L.a.Fragment,null,L.a.createElement("div",{dangerouslySetInnerHTML:{__html:ct}}))},S=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,Pe=ue.title,Ze=ue.icon,qe=ue.actionName,Et=ue.className,Pt=Et===void 0?"":Et,et=ue.children;function ct(){Se(qe)}return L.a.createElement("a",{title:Pe,className:Pt,onClick:ct},L.a.createElement("i",{className:"md-iconfont ".concat(Ze)}),et)}var x=function(ue){var Se=ue.watch,Pe=ue.showNullButton,Ze=ue.onActionCallback,qe=ue.fullScreen,Et=ue.insertTemp,Pt=ue.hidetoolBar,et=ue.uuid,ct=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(et,"&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"},!Pt&&Ft.map(function(Ct,jt){return L.a.createElement("li",{key:jt},Ct.actionName?L.a.createElement(v,Object(S.a)({},Ct,{onActionCallback:Ze})):L.a.createElement("span",{className:"v-line"}))}),Pe?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:Ze},L.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,Et&&L.a.createElement("li",null,L.a.createElement(v,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(Et),onActionCallback:Ze},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:Ze})))},k=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,Pe=ue.onCancel;function Ze(qe){Se(qe)}return L.a.createElement(G.a,Object(S.a)({},oe,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:Ze}),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:Pe},"\u53D6\u6D88")))},ve=re("7ahc"),ke=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,Pe=ue.onCancel,Ze=_e(),qe=Object(z.a)(Ze,1),Et=qe[0];function Pt(Ft){Se(Ft)}function et(Ft,Ct){if(Ft.status===-1){N.b.error(Ft.message);return}Et.setFieldsValue({src:"/api/attachments/".concat(Ft.id),type:Ct.type})}function ct(Ft){var Ct=Ft.target.files[0];we(Ct,et)}return L.a.createElement(G.a,Object(S.a)({form:Et},Ce,{className:"upload-image-panel",onFinish:Pt}),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:ct}))),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:Pe},"\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 we(ue,Se){if(!ue)throw new String("\u6CA1\u6709\u6587\u4EF6");var Pe=new FormData;Pe.append("editormd-image-file",ue),Pe.append("file_param_name","editormd-image-file"),Pe.append("byxhr","true");var Ze=new window.XMLHttpRequest;Ze.withCredentials=!0,Ze.addEventListener("load",function(qe){Se(JSON.parse(qe.target.responseText),ue)},!1),Ze.addEventListener("error",function(qe){console.error(qe)},!1),Ze.open("POST","".concat(Ee.a,"/api/attachments.json")),Ze.send(Pe)}var tt=re("giR+"),Ye=re("fyUT"),Xe=re("7Kak"),Ve=re("9yH6"),Le=Ve.a.Group,Me={margin:"0 8px"},He=function(ue){var Se=ue.callback,Pe=ue.onCancel;function Ze(qe){Se(qe)}return L.a.createElement(G.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:Ze},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(Ye.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(Ye.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:Pe},"\u53D6\u6D88")))},Ge=re("ErOA"),je=re("7Cbv"),Ue="link",Re="upload-image",st="code-block",Je="add-table",Qe="------------",nt={default:Qe,left:":".concat(Qe),center:":".concat(Qe,":"),right:"".concat(Qe,":")},bt=re("9VGf"),at,ht;function Ae(){}var gt=0,dt=1e4,De="\u2581",We=`
|
|
**\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=(at={},Object(j.a)(at,pe+"-B","bold"),Object(j.a)(at,pe+"-I","italic"),at),ie=(ht={},Object(j.a)(ht,Ue,"\u6DFB\u52A0\u94FE\u63A5"),Object(j.a)(ht,st,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(j.a)(ht,Re,"\u6DFB\u52A0\u6587\u4EF6"),Object(j.a)(ht,Je,"\u6DFB\u52A0\u8868\u683C"),ht),se=ft.a=function(ue){var Se=ue.defaultValue,Pe=Se===void 0?"":Se,Ze=ue.onChange,qe=ue.width,Et=qe===void 0?"100%":qe,Pt=ue.height,et=Pt===void 0?400:Pt,ct=ue.miniToolbar,Ft=ct===void 0?!1:ct,Ct=ue.isFocus,jt=Ct===void 0?!1:Ct,$t=ue.watch,Lt=ue.insertTemp,Qt=ue.mode,Zt=Qt===void 0?"markdown":Qt,pt=ue.id,Xt=pt===void 0?"markdown-editor-id":pt,zt=ue.showResizeBar,Gt=zt===void 0?!1:zt,Ut=ue.noStorage,Mt=Ut===void 0?!1:Ut,St=ue.showNullButton,it=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,Pr=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),M=g[0],J=g[1],F=Object(E.useState)(Pe),ce=Object(z.a)(F,2),Ne=ce[0],rt=ce[1],Tt=Object(E.useState)($t),Be=Object(z.a)(Tt,2),kt=Be[0],er=Be[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],ot=Sn[1],be=Object(E.useState)(0),Ke=Object(z.a)(be,2),wt=Ke[0],mt=Ke[1],vt=Object(E.useState)(et),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(je.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 Dt=Object(I.a)(P.a.mark(function Kt(){var Nt,Jt;return P.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:",M,Ht),Jt.attachments.map(function(ar){ar.content_type.indexOf("image")>-1?M.replaceSelection(".concat(ar.content_type,")")):ar.content_type.indexOf("video")>-1?M.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):ar.content_type.indexOf("pdf")>-1?M.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>")):M.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 Dt.apply(this,arguments)}}();Object(E.useEffect)(function(){rt(U),M==null||M.setValue(U)},[U]),Object(E.useEffect)(function(){ir==null||ir(Mr)},[Mr]),Object(E.useEffect)(function(){if(Ht.current){var Dt=T.a.fromTextArea(Ht.current,{mode:Zt,lineNumbers:!Ft,lineWrapping:!0,value:Pe,autoCloseTags:!0,autoCloseBrackets:!0});jt&&Dt.focus();function Kt(Nt,Jt){if(Pr){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 kr,Qr=ar[1];((kr=ar[0])===null||kr===void 0?void 0:kr.kind)==="file"&&(Qr=ar[0]);var rr=Qr.getAsFile(),Cn=rr.name.split(".").pop();we(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?Dt.replaceSelection(".concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?Dt.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?Dt.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)?Dt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'?type=office&disposition=inline" target="_blank">').concat(rr.name,"</a>")):Dt.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 Dt.on("paste",Kt),Dt.on("dragleave",function(Nt,Jt){br.current.classList.remove("mouse-hover-md")}),Dt.on("dragover",function(Nt,Jt){br.current.classList.add("mouse-hover-md")}),Dt.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();we(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?Dt.replaceSelection(".concat(ur.content_type,")")):(rr==null||((Kr=rr.type)===null||Kr===void 0)?void 0:Kr.indexOf("video"))>-1?Dt.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?Dt.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)?Dt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(ur.id,'?type=office&disposition=inline" target="_blank">').concat(rr.name,"</a>")):Dt.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(Dt),function(){Dt.off("paste",Kt)}}},[]);var Yr=Object(E.useCallback)(function(){if(br.current)try{}catch(Dt){console.log(Dt,"---- to set md editor body height")}},[gr,br,Mr]);Object(E.useEffect)(function(){function Dt(){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(),M.setSize("100%","100%"),M.refresh())}}catch(kr){sr.e(kr)}finally{sr.f()}});return Nt.observe(Ht.current.parentElement),Nt}if(M){var Kt=Dt();return function(){Kt.unobserve(Ht.current.parentElement)}}},[M,Yr]),Object(E.useEffect)(function(){if(M){for(var Dt=[],Kt=function(){var ar=Jt[Nt];sr=Object(z.a)(ar,2);var kr=sr[0],Qr=sr[1],rr=Object(j.a)({},kr,function(){Yn(Qr)});Dt.push(rr),M.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)(Dt),ar;try{for(vr.s();!(ar=vr.n()).done;){var kr=ar.value;M.removeKeyMap(kr)}}catch(Qr){vr.e(Qr)}finally{vr.f()}}}},[M]),Object(E.useEffect)(function(){qt!==Mr&&Ir(qt)},[qt]),Object(bt.a)(function(){if(!Mt&&wt>0){var Dt=new Date().getTime(),Kt=window.sessionStorage.getItem(Xt);Dt>=wt+dt&&(!Kt||Kt!==Ne)&&(window.sessionStorage.setItem(Xt,Ne),Wr(!0))}},dt),Object(E.useEffect)(function(){er($t)},[M,$t]),Object(E.useEffect)(function(){M&&(jt&&M.focus())},[M,jt]),Object(E.useEffect)(function(){if(kt&&M){var Dt=M.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 Dt.addEventListener("scroll",Kt),function(){Dt.removeEventListener("scroll",Kt)}}},[M,kt]),Object(E.useEffect)(function(){if(M&&Tr){function Dt(Kt,Nt){Tr(Kt,Nt)}return M.on("beforeChange",Dt),function(){M.off("beforeChange",Dt)}}},[M,Tr]),Object(E.useEffect)(function(){if(M&&Wt){function Dt(){Wt(M.getValue())}return M.on("blur",Dt),function(){M.off("blur",Dt)}}},[M,Wt]),Object(E.useEffect)(function(){if(M){function Dt(Kt){var Nt=Kt.getValue();rt(Nt),mt(new Date().getTime()),Kt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),Ze&&Ze(Nt)}return M.on("change",Dt),function(){M.off("change",Dt)}}},[M,Ze]),Object(E.useEffect)(function(){M&&(Pe==null?(M.setValue(""),rt("")):Pe!==M.getValue()&&(M.setValue(Pe),rt(Pe),M.setCursor(M.lineCount(),0)))},[M,Pe]);var Yn=Object(E.useCallback)(function(Dt){var Kt=M.getCursor(),Nt=M.getSelection(),Jt=Nt.split(`
|
|
`);switch(Dt){case"bold":return M.replaceSelection("**"+Nt+"**"),Nt===""&&M.setCursor(Kt.line,Kt.ch+2),M.focus();case"italic":return M.replaceSelection("*"+Nt+"*"),Nt===""&&M.setCursor(Kt.line,Kt.ch+1),M.focus();case"code":return M.replaceSelection("`"+Nt+"`"),Nt===""&&M.setCursor(Kt.line,Kt.ch+1),M.focus();case"inline-latex":return M.replaceSelection("`$$"+Nt+"$$`"),Nt===""&&M.setCursor(Kt.line,Kt.ch+3),M.focus();case"latex":return M.replaceSelection("```latex\n"+Nt+"\n```"),M.setCursor(Kt.line+1,Nt.length+1),M.focus();case"line-break":return M.replaceSelection(`<br/>
|
|
`),M.focus();case"list-ul":return Nt===""?M.replaceSelection("- "+Nt):M.replaceSelection(Jt.map(function(sr){return sr===""?"":"- ".concat(sr)}).join(`
|
|
`)),M.focus();case"list-ol":return Nt===""?M.replaceSelection("1. "+Nt):M.replaceSelection(Jt.map(function(sr,vr){return sr===""?"":"".concat(vr+1,". ").concat(sr)}).join(`
|
|
`)),M.focus();case"add-null-ch":return Nt===""&&M.setCursor(Kt.line,Kt.ch+1),M.replaceSelection(De),M.focus();case"inster-template-1":return Nt===""&&M.setCursor(Kt.line,Kt.ch),M.replaceSelection(We),M.focus();case"eraser":return M.setValue(""),M.focus();case"trigger-watch":return er(!kt),M.focus();case"trigger-full-screen":return Ir(!Mr),M.focus();case Ue:ot(Ue);return;case st:ot(st);return;case Re:ot(Re);return;case Je:ot(Je);return;default:throw new Error}},[M,kt,Mr]),An=Object(E.useCallback)(function(Dt){ot("");switch(wr){case Ue:var Kt=Dt.title,Nt=Dt.link;return M.replaceSelection("[".concat(Kt,"](").concat(Nt,")")),M.focus();case st:var Jt=Dt.language,sr=Dt.content;return M.replaceSelection(["```"+Jt,sr,"```"].join(`
|
|
`)),M.focus();case Re:var vr=Dt.src,ar=Dt.alt;return ar?M.replaceSelection(".concat(vr,' "').concat(ar,'" )')):M.replaceSelection("")),M.focus();case Je:for(var kr=Dt.row,Qr=Dt.col,rr=Dt.align,Cn=`
|
|
`,ur=0;ur<kr;ur++){for(var Zr=[],Kr=[],hn=0;hn<Qr;hn++)ur===1&&Kr.push(nt[rr]),Zr.push(" ");ur===1&&(Cn+="| ".concat(Kr.join(" | "),` |
|
|
`)),Cn+="| ".concat(Zr.join(Qr===1?"":" | "),` |
|
|
`)}return M.replaceSelection(Cn+`
|
|
`),M.focus();default:throw new Error}},[M,wr]),hi=Object(E.useMemo)(function(){switch(wr){case Ue:return L.a.createElement(fe,{callback:An,onCancel:Ln});case st:return L.a.createElement(ve.b,{callback:An,onCancel:Ln});case Re:return L.a.createElement(me,{callback:An,onCancel:Ln});case Je:return L.a.createElement(He,{callback:An,onCancel:Ln});default:return null}},[wr]);function Ln(){ot("")}Object(E.useEffect)(function(){if(lr.current){var Dt=lr.current,Kt=!1,Nt=0;function Jt(ar){Kt=!0,Nt=ar.pageY}function sr(){Kt=!1}function vr(ar){if(Kt){var kr=ar.pageY-Nt;kr<0&&(kr=0),kr>300&&(kr=300);var Qr=et+kr+"px";cr(Qr)}}return Dt.addEventListener("mousedown",Jt),document.addEventListener("mousemove",vr),document.addEventListener("mouseup",sr),function(){Dt.removeEventListener("mousedown",Jt),document.removeEventListener("mousemove",vr),document.removeEventListener("mouseup",sr)}}},[M,lr]),Object(E.useEffect)(function(){cr(et)},[et]);var yn=ge(Et),fi=ge(gr),fn={width:yn,height:fi},pi=Object(E.useMemo)(function(){if(wt){var Dt=new Date(wt),Kt=Dt.getHours(),Nt=Dt.getMinutes(),Jt=Dt.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),M.setValue(window.sessionStorage.getItem(Xt))}function ua(Dt,Kt){var Nt=M.getValue();Nt=Nt.replace(Dt,Kt),rt(Nt),M==null||M.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(kt?"on-preview":""," ").concat(Ft?"mini":""," ").concat(Mr?"full-screen":""),style:fn},L.a.createElement(x,{insertTemp:Lt,watch:kt,fullScreen:Mr,showNullButton:it,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})),kt?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(k.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,ft,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,ft,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,ft,re){At.exports=re.p+"static/bi.c00a7d71.svg"},SJMd:function(At,ft){/**
|
|
* @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 j=window,O=["break,continue,do,else,for,if,return,while"],P=[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=[P,"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"],D=[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",w=[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"],d=[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"],c=[O,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],C=[L,T,D,w,h,o,d,c],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",S="com",f="typ",p="lit",s="pun",a="pln",b="tag",v="dec",x="src",k="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,He=!1,Ge=!1,je=0,Ue=Le.length;je<Ue;++je){var Re=Le[je];if(Re.ignoreCase)Ge=!0;else if(/[a-z]/i.test(Re.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){He=!0,Ge=!1;break}}var st={b:8,t:9,n:10,v:11,f:12,r:13};function Je(ht){var Ae=ht.charCodeAt(0);if(Ae!==92)return Ae;var gt=ht.charAt(1);return Ae=st[gt],Ae||("0"<=gt&><="7"?parseInt(ht.substring(1),8):gt==="u"||gt==="x"?parseInt(ht.substring(2),16):ht.charCodeAt(1))}function Qe(ht){if(ht<32)return(ht<16?"\\x0":"\\x")+ht.toString(16);var Ae=String.fromCharCode(ht);return Ae==="\\"||Ae==="-"||Ae==="]"||Ae==="^"?"\\"+Ae:Ae}function nt(ht){var Ae=ht.substring(1,ht.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=[],dt=Ae[0]==="^",De=["["];dt&&De.push("^");for(var We=dt?1:0,ge=Ae.length;We<ge;++We){var de=Ae[We];if(/\\[bdsw]/i.test(de))De.push(de);else{var pe=Je(de),ee;We+2<ge&&Ae[We+1]==="-"?(ee=Je(Ae[We+2]),We+=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=[],We=0;We<gt.length;++We){var se=gt[We];se[0]<=ie[1]+1?ie[1]=Math.max(ie[1],se[1]):te.push(ie=se)}for(var We=0;We<te.length;++We){var se=te[We];De.push(Qe(se[0])),se[1]>se[0]&&(se[1]+1>se[0]&&De.push("-"),De.push(Qe(se[1])))}return De.push("]"),De.join("")}function bt(ht){for(var Ae=ht.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=Ae.length,dt=[],De=0,We=0;De<gt;++De){var ge=Ae[De];if(ge==="(")++We;else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&(de<=We?dt[de]=-1:Ae[De]=Qe(de))}}for(var De=1;De<dt.length;++De)dt[De]===-1&&(dt[De]=++Me);for(var De=0,We=0;De<gt;++De){var ge=Ae[De];if(ge==="(")++We,dt[We]||(Ae[De]="(?:");else if(ge.charAt(0)==="\\"){var de=+ge.substring(1);de&&de<=We&&(Ae[De]="\\"+dt[de])}}for(var De=0;De<gt;++De)Ae[De]==="^"&&Ae[De+1]!=="^"&&(Ae[De]="");if(ht.ignoreCase&&He)for(var De=0;De<gt;++De){var ge=Ae[De],pe=ge.charAt(0);ge.length>=2&&pe==="["?Ae[De]=nt(ge):pe!=="\\"&&(Ae[De]=ge.replace(/[a-zA-Z]/g,function(ie){var se=ie.charCodeAt(0);return"["+String.fromCharCode(se&~32,se|32)+"]"}))}return Ae.join("")}for(var at=[],je=0,Ue=Le.length;je<Ue;++je){var Re=Le[je];if(Re.global||Re.multiline)throw new Error(""+Re);at.push("(?:"+bt(Re)+")")}return new RegExp(at.join("|"),Ge?"gi":"g")}function W(Le,Me){var He=/(?:^|\s)nocode(?:\s|$)/,Ge=[],je=0,Ue=[],Re=0;function st(Je){var Qe=Je.nodeType;if(Qe==1){if(He.test(Je.className))return;for(var nt=Je.firstChild;nt;nt=nt.nextSibling)st(nt);var bt=Je.nodeName.toLowerCase();(bt==="br"||bt==="li")&&(Ge[Re]=`
|
|
`,Ue[Re<<1]=je++,Ue[Re++<<1|1]=Je)}else if(Qe==3||Qe==4){var at=Je.nodeValue;at.length&&(Me?at=at.replace(/\r\n?/g,`
|
|
`):at=at.replace(/[ \t\r\n]+/g," "),Ge[Re]=at,Ue[Re<<1]=je,je+=at.length,Ue[Re++<<1|1]=Je)}}return st(Le),{sourceCode:Ge.join("").replace(/\n$/,""),spans:Ue}}function q(Le,Me,He,Ge,je){if(!He)return;var Ue={sourceNode:Le,pre:1,langExtension:null,numberLines:null,sourceCode:He,spans:null,basePos:Me,decorations:null};Ge(Ue),je.push.apply(je,Ue.decorations)}var oe=/\S/;function fe(Le){for(var Me=void 0,He=Le.firstChild;He;He=He.nextSibling){var Ge=He.nodeType;Me=Ge===1?Me?Le:He:Ge===3&&oe.test(He.nodeValue)?Le:Me}return Me===Le?void 0:Me}function ve(Le,Me){var He={},Ge;(function(){for(var Re=Le.concat(Me),st=[],Je={},Qe=0,nt=Re.length;Qe<nt;++Qe){var bt=Re[Qe],at=bt[3];if(at)for(var ht=at.length;--ht>=0;)He[at.charAt(ht)]=bt;var Ae=bt[1],gt=""+Ae;Je.hasOwnProperty(gt)||(st.push(Ae),Je[gt]=null)}st.push(/[\0-\uffff]/),Ge=G(st)})();var je=Me.length,Ue=function(Re){for(var st=Re.sourceCode,Je=Re.basePos,Qe=Re.sourceNode,nt=[Je,a],bt=0,at=st.match(Ge)||[],ht={},Ae=0,gt=at.length;Ae<gt;++Ae){var dt=at[Ae],De=ht[dt],We=void 0,ge;if(typeof De=="string")ge=!1;else{var de=He[dt.charAt(0)];if(de)We=dt.match(de[1]),De=de[0];else{for(var pe=0;pe<je;++pe)if(de=Me[pe],We=dt.match(de[1]),We){De=de[0];break}We||(De=a)}ge=De.length>=5&&De.substring(0,5)==="lang-",ge&&!(We&&typeof We[1]=="string")&&(ge=!1,De=x),ge||(ht[dt]=De)}var ee=bt;if(bt+=dt.length,!ge)nt.push(Je+ee,De);else{var te=We[1],ie=dt.indexOf(te),se=ie+te.length;We[2]&&(se=dt.length-We[2].length,ie=se-te.length);var ue=De.substring(5);q(Qe,Je+ee,dt.substring(0,ie),Ue,nt),q(Qe,Je+ee+ie,te,ne(ue,te),nt),q(Qe,Je+ee+se,dt.substring(se),Ue,nt)}}Re.decorations=nt};return Ue}function ke(Le){var Me=[],He=[];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&&He.push([m,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ge=Le.hashComments;Ge&&(Le.cStyleComments?(Ge>1?Me.push([S,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Me.push([S,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),He.push([m,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Me.push([S,/^#[^\r\n]*/,null,"#"])),Le.cStyleComments&&(He.push([S,/^\/\/[^\r\n]*/,null]),He.push([S,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var je=Le.regexLiterals;if(je){var Ue=je>1?"":`
|
|
\r`,Re=Ue?".":"[\\S\\s]",st="/(?=[^/*"+Ue+"])(?:[^/\\x5B\\x5C"+Ue+"]|\\x5C"+Re+"|\\x5B(?:[^\\x5C\\x5D"+Ue+"]|\\x5C"+Re+")*(?:\\x5D|$))+/";He.push(["lang-regex",RegExp("^"+Q+"("+st+")")])}var Je=Le.types;Je&&He.push([f,Je]);var Qe=(""+Le.keywords).replace(/^ | $/g,"");Qe.length&&He.push([l,new RegExp("^(?:"+Qe.replace(/[\s,]+/g,"|")+")\\b"),null]),Me.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var nt="^.[^\\s\\w.$@'\"`/\\\\]*";return Le.regexLiterals&&(nt+="(?!s*/)"),He.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(nt),null]),ve(Me,He)}var Ee=ke({keywords:C,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function _e(Le,Me,He){for(var Ge=/(?:^|\s)nocode(?:\s|$)/,je=/\r\n?|\n/,Ue=Le.ownerDocument,Re=Ue.createElement("li");Le.firstChild;)Re.appendChild(Le.firstChild);var st=[Re];function Je(Ae){var gt=Ae.nodeType;if(gt==1&&!Ge.test(Ae.className))if(Ae.nodeName==="br")Qe(Ae),Ae.parentNode&&Ae.parentNode.removeChild(Ae);else for(var dt=Ae.firstChild;dt;dt=dt.nextSibling)Je(dt);else if((gt==3||gt==4)&&He){var De=Ae.nodeValue,We=De.match(je);if(We){var ge=De.substring(0,We.index);Ae.nodeValue=ge;var de=De.substring(We.index+We[0].length);if(de){var pe=Ae.parentNode;pe.insertBefore(Ue.createTextNode(de),Ae.nextSibling)}Qe(Ae),ge||Ae.parentNode.removeChild(Ae)}}}function Qe(Ae){for(;!Ae.nextSibling;)if(Ae=Ae.parentNode,!Ae)return;function gt(We,ge){var de=ge?We.cloneNode(!1):We,pe=We.parentNode;if(pe){var ee=gt(pe,1),te=We.nextSibling;ee.appendChild(de);for(var ie=te;ie;ie=te)te=ie.nextSibling,ee.appendChild(ie)}return de}for(var dt=gt(Ae.nextSibling,0),De;(De=dt.parentNode)&&De.nodeType===1;)dt=De;st.push(dt)}for(var nt=0;nt<st.length;++nt)Je(st[nt]);Me===(Me|0)&&st[0].setAttribute("value",Me);var bt=Ue.createElement("ol");bt.className="linenums";for(var at=Math.max(0,Me-1|0)||0,nt=0,ht=st.length;nt<ht;++nt)Re=st[nt],Re.className="L"+(nt+at)%10,Re.firstChild||Re.appendChild(Ue.createTextNode("\xA0")),bt.appendChild(Re);Le.appendChild(bt)}function Te(Le){var Me=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Me=Me&&+Me[1]<=8;var He=/\n/g,Ge=Le.sourceCode,je=Ge.length,Ue=0,Re=Le.spans,st=Re.length,Je=0,Qe=Le.decorations,nt=Qe.length,bt=0;Qe[nt]=je;var at,ht;for(ht=at=0;ht<nt;)Qe[ht]!==Qe[ht+2]?(Qe[at++]=Qe[ht++],Qe[at++]=Qe[ht++]):ht+=2;for(nt=at,ht=at=0;ht<nt;){for(var Ae=Qe[ht],gt=Qe[ht+1],dt=ht+2;dt+2<=nt&&Qe[dt+1]===gt;)dt+=2;Qe[at++]=Ae,Qe[at++]=gt,ht=dt}nt=Qe.length=at;var De=Le.sourceNode,We="";De&&(We=De.style.display,De.style.display="none");try{for(var ge=null;Je<st;){var de=Re[Je],pe=Re[Je+2]||je,ee=Qe[bt+2]||je,dt=Math.min(pe,ee),te=Re[Je+1],ie;if(te.nodeType!==1&&(ie=Ge.substring(Ue,dt))){Me&&(ie=ie.replace(He,"\r")),te.nodeValue=ie;var se=te.ownerDocument,ue=se.createElement("span");ue.className=Qe[bt+1];var Se=te.parentNode;Se.replaceChild(ue,te),ue.appendChild(te),Ue<pe&&(Re[Je+1]=te=se.createTextNode(Ge.substring(dt,pe)),Se.insertBefore(te,ue.nextSibling))}Ue=dt,Ue>=pe&&(Je+=2),Ue>=ee&&(bt+=2)}}finally{De&&(De.style.display=We)}}var Ce={};function me(Le,Me){for(var He=Me.length;--He>=0;){var Ge=Me[He];Ce.hasOwnProperty(Ge)?j.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[^>]*(?:>|$)/],[S,/^<\!--[\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],[k,/^(?!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(ke({keywords:L,hashComments:!0,cStyleComments:!0,types:y}),["c","cc","cpp","cxx","cyc","m"]),me(ke({keywords:"null,true,false"}),["json"]),me(ke({keywords:T,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:y}),["cs"]),me(ke({keywords:D,cStyleComments:!0}),["java"]),me(ke({keywords:c,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(ke({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(ke({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(ke({keywords:d,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(ke({keywords:w,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(ke({keywords:A,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ve([],[[m,/^[\s\S]+/]]),["regex"]);function we(Le){var Me=Le.langExtension;try{var He=W(Le.sourceNode,Le.pre),Ge=He.sourceCode;Le.sourceCode=Ge,Le.spans=He.spans,Le.basePos=0,ne(Me,Ge)(Le),Te(Le)}catch(je){j.console&&console.log(je&&je.stack||je)}}function tt(Le,Me,He){var Ge=He||!1,je=Me||null,Ue=document.createElement("div");Ue.innerHTML="<pre>"+Le+"</pre>",Ue=Ue.firstChild,Ge&&_e(Ue,Ge,!0);var Re={langExtension:je,numberLines:Ge,sourceNode:Ue,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return we(Re),Ue.innerHTML}function Ye(Le,Me){var He=Me||document.body,Ge=He.ownerDocument||document;function je(de){return He.getElementsByTagName(de)}for(var Ue=[je("pre"),je("code"),je("xmp")],Re=[],st=0;st<Ue.length;++st)for(var Je=0,Qe=Ue[st].length;Je<Qe;++Je)Re.push(Ue[st][Je]);Ue=null;var nt=Date;nt.now||(nt={now:function(){return+new Date}});var bt=0,at=/\blang(?:uage)?-([\w.]+)(?!\S)/,ht=/\bprettyprint\b/,Ae=/\bprettyprinted\b/,gt=/pre|xmp/i,dt=/^code$/i,De=/^(?:pre|code|xmp)$/i,We={};function ge(){for(var de=j.PR_SHOULD_USE_CONTINUATION?nt.now()+250:Infinity;bt<Re.length&&nt.now()<de;bt++){for(var pe=Re[bt],ee=We,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!==We||ht.test(ue))&&!Ae.test(ue)){for(var Se=!1,Pe=pe.parentNode;Pe;Pe=Pe.parentNode){var Ze=Pe.tagName;if(De.test(Ze)&&Pe.className&&ht.test(Pe.className)){Se=!0;break}}if(!Se){pe.className+=" prettyprinted";var qe=ee.lang;if(!qe){qe=ue.match(at);var Et;!qe&&(Et=fe(pe))&&dt.test(Et.tagName)&&(qe=Et.className.match(at)),qe&&(qe=qe[1])}var Pt;if(gt.test(pe.tagName))Pt=1;else{var et=pe.currentStyle,ct=Ge.defaultView,Ft=et?et.whiteSpace:ct&&ct.getComputedStyle?ct.getComputedStyle(pe,null).getPropertyValue("white-space"):0;Pt=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,Pt);var jt={langExtension:qe,sourceNode:pe,numberLines:Ct,pre:Pt,sourceCode:null,basePos:null,spans:null,decorations:null};we(jt)}}}bt<Re.length?j.setTimeout(ge,250):typeof Le=="function"&&Le()}ge()}var Xe=j.PR={createSimpleLexer:ve,registerLangHandler:me,sourceDecorator:ke,PR_ATTRIB_NAME:k,PR_ATTRIB_VALUE:H,PR_COMMENT:S,PR_DECLARATION:v,PR_KEYWORD:l,PR_LITERAL:p,PR_NOCODE:V,PR_PLAIN:a,PR_PUNCTUATION:s,PR_SOURCE:x,PR_STRING:m,PR_TAG:b,PR_TYPE:f,prettyPrintOne:R?j.prettyPrintOne=tt:I=tt,prettyPrint:z=R?j.prettyPrint=Ye:z=Ye},Ve=j.define;typeof Ve=="function"&&Ve.amd&&Ve("google-code-prettify",[],function(){return Xe})})()},"VrN/":function(At,ft,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,j=z&&(X?document.documentMode||6:+(I||N)[1]),O=!I&&/WebKit\//.test(ae),P=O&&/Qt\/\d+\.\d+/.test(ae),E=!I&&/Chrome\//.test(ae),L=/Opera\//.test(ae),D=/Apple Computer/.test(navigator.vendor),T=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ae),A=/PhantomJS/.test(ae),w=!I&&/AppleWebKit/.test(ae)&&/Mobile\/\w+/.test(ae),h=/Android/.test(ae),o=w||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ae),d=w||/Mac/.test($),c=/\bCrOS\b/.test(ae),C=/win/i.test($),y=L&&ae.match(/Version\/(\d*\.\d*)/);y&&(y=Number(y[1])),y&&y>=15&&(L=!1,O=!0);var m=d&&(P||L&&(y==null||y<12.11)),l=R||z&&j>=9;function S(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var f=function(e,t){var n=e.className,r=S(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 _=0;_<t.length;++_)i.appendChild(t[_]);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 x(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 k(){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;S(t).test(n)||(e.className+=(n?" ":"")+t)}function V(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!S(n[r]).test(t)&&(t+=" "+n[r]);return t}var Q=function(e){e.select()};w?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 _=r||0,B=i||0;;){var K=e.indexOf(" ",_);if(K<0||K>=t)return B+(t-_);B+=K-_,B+=n-B%n,_=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,ke={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 _=e.indexOf(" ",r);_==-1&&(_=e.length);var B=_-r;if(_==e.length||i+B>=t)return r+Math.min(B,t-i);if(i+=_-r,i+=n-i%n,r=_+1,i>=t)return r}}var me=[""];function ne(e){for(;me.length<=e;)me.push(we(me)+" ");return me[e]}function we(e){return e[e.length-1]}function tt(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Ye(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 He(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 je=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function Ue(e){return e.charCodeAt(0)>=768&&je.test(e)}function Re(e,t,n){for(;(n<0?t>0:t<e.length)&&Ue(e.charAt(t));)t+=n;return t}function st(e,t,n){for(var r=t>n?-1:1;;){if(t==n)return t;var i=(t+n)/2,_=r<0?Math.ceil(i):Math.floor(i);if(_==t)return e(_)?t:n;e(_)?n=_:t=_+r}}function Je(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,_=0;_<e.length;++_){var B=e[_];(B.from<n&&B.to>t||t==n&&B.to==t)&&(r(Math.max(B.from,t),Math.min(B.to,n),B.level==1?"rtl":"ltr",_),i=!0)}i||r(t,n,"ltr")}var Qe=null;function nt(e,t,n){var r;Qe=null;for(var i=0;i<e.length;++i){var _=e[i];if(_.from<t&&_.to>t)return i;_.to==t&&(_.from!=_.to&&n=="before"?r=i:Qe=i),_.from==t&&(_.from!=_.to&&n!="before"?r=i:Qe=i)}return r!=null?r:Qe}var bt=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]/,_=/[LRr]/,B=/[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 ze=0,$e=he;ze<xe;++ze){var lt=ye[ze];lt=="m"?ye[ze]=$e:$e=lt}for(var yt=0,ut=he;yt<xe;++yt){var _t=ye[yt];_t=="1"&&ut=="r"?ye[yt]="n":_.test(_t)&&(ut=_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":_.test(zr)&&(rn=zr)}for(var Or=0;Or<xe;++Or)if(i.test(ye[Or])){var Dr=void 0;for(Dr=Or+1;Dr<xe&&i.test(ye[Dr]);++Dr);for(var _r=(Or?ye[Or-1]:he)=="L",nn=(Dr<xe?ye[Dr]:he)=="L",di=_r==nn?_r?"L":"R":he,Nn=Or;Nn<Dr;++Nn)ye[Nn]=di;Or=Dr-1}for(var Xr=[],xn,jr=0;jr<xe;)if(B.test(ye[jr])){var Va=jr;for(++jr;jr<xe&&B.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))),we(Xr).level==1&&(xn=Z.match(/\s+$/))&&(we(Xr).to-=xn[0].length,Xr.push(new Y(0,xe-xn[0].length,xe)))),le=="rtl"?Xr.reverse():Xr}}();function at(e,t){var n=e.order;return n==null&&(n=e.order=bt(e.text,t)),n}var ht=[],Ae=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]||ht).concat(n)}};function gt(e,t){return e._handlers&&e._handlers[t]||ht}function dt(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 _=fe(i,n);_>-1&&(r[t]=i.slice(0,_).concat(i.slice(_+1)))}}}function De(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 We(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),De(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){Ae(this,t,n)},e.prototype.off=function(t,n){dt(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)),d&&e.ctrlKey&&t==1&&(t=3),t}var Pe=function(){if(z&&j<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),Ze;function qe(e){if(Ze==null){var t=a("span","\u200B");s(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Ze=t.offsetWidth<=1&&t.offsetHeight>2&&!(z&&j<8))}var n=Ze?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var Et;function Pt(e){if(Et!=null)return Et;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:Et=r.right-n.right<3}var et=`
|
|
|
|
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 _=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),B=_.indexOf("\r");B!=-1?(n.push(_.slice(0,B)),t+=B+1):(n.push(_),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},ct=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 pt(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 pt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return pt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Xt(e,t){t=pt(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 _ in i){if(!i.hasOwnProperty(_))continue;r.hasOwnProperty(_)&&(r["_"+_]=r[_]),r[_]=i[_]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var B in t.modeProps)r[B]=t.modeProps[B];return r}var 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 it=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};it.prototype.eol=function(){return this.pos>=this.string.length},it.prototype.sol=function(){return this.pos==this.lineStart},it.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},it.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},it.prototype.eat=function(e){var t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e.test?e.test(t):e(t)),n)return++this.pos,t},it.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},it.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},it.prototype.skipToEnd=function(){this.pos=this.string.length},it.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},it.prototype.backUp=function(e){this.pos-=e},it.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},it.prototype.indentation=function(){return q(this.string,null,this.tabSize)-(this.lineStart?q(this.string,this.lineStart,this.tabSize):0)},it.prototype.match=function(e,t,n){if(typeof e=="string"){var r=function(B){return n?B.toLowerCase():B},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var _=this.string.slice(this.pos).match(e);return _&&_.index>0?null:(_&&t!==!1&&(this.pos+=_[0].length),_)}},it.prototype.current=function(){return this.string.slice(this.start,this.pos)},it.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},it.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},it.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function 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],_=i.chunkSize();if(t<_){n=i;break}t-=_}return n.lines[t]}function nr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(_){var B=_.text;i==n.line&&(B=B.slice(0,n.ch)),i==t.line&&(B=B.slice(t.ch)),r.push(B),++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],_=i.height;if(t<_){e=i;continue e}t-=_,n+=i.chunkSize()}return n}while(!e.lines);for(var B=0;B<e.lines.length;++B){var K=e.lines[B],Y=K.height;if(t<Y)break;t-=Y}return n+B}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 Pr(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 M(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},F=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};F.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},F.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},F.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},F.fromSaved=function(e,t,n){return t instanceof J?new F(e,Ut(e.mode,t.state),n,t.lookAhead):new F(e,Ut(e.mode,t),n)},F.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],_={};Mr(e,t.text,e.doc.mode,n,function(Z,le){return i.push(Z,le)},_,r);for(var B=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 ze=he;xe<ye;){var $e=i[he];$e>ye&&i.splice(he,1,ye,i[he+1],$e),he+=2,xe=Math.min(ye,$e)}if(!Oe)return;if(le.opaque)i.splice(ze,he-ze,ye,"overlay "+Oe),he=ze+2;else for(;ze<he;ze+=2){var lt=i[ze+1];i[ze+1]=(lt?lt+" ":"")+"overlay "+Oe}},_),n.state=B,n.baseTokens=null,n.baseTokenPos=1},Y=0;Y<e.state.overlays.length;++Y)K(Y);return{styles:i,classes:_.bgClass||_.textClass?_:null}}function Ne(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=rt(e,Wt(t)),i=t.text.length>e.options.maxHighlightLength&&Ut(e.doc.mode,r.state),_=ce(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=_.styles,_.classes?t.styleClasses=_.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 rt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new F(r,!0,t);var _=Ir(e,t,n),B=_>r.first&&Fe(r,_-1).stateAfter,K=B?F.fromSaved(r,B,_):new F(r,St(r.mode),_);return r.iter(_,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,_=new it(t,e.options.tabSize,n);for(_.start=_.pos=r||0,t==""&&Be(i,n.state);!_.eol();)kt(i,_,n.state),_.start=_.pos}function Be(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 kt(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=Mt(e,n).mode);var _=e.token(t,n);if(t.pos>t.start)return _}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,_=i.mode,B;t=u(i,t);var K=Fe(i,t.line),Y=rt(e,t.line,n),Z=new it(K.text,e.options.tabSize,Y),le;for(r&&(le=[]);(r||Z.pos<t.ch)&&!Z.eol();)Z.start=Z.pos,B=kt(_,Z,Y.state),r&&le.push(new er(Z,B,Ut(i.mode,Y.state)));return r?le:new er(Z,B,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,_,B){var K=n.flattenSpans;K==null&&(K=e.options.flattenSpans);var Y=0,Z=null,le=new it(t,e.options.tabSize,r),he,xe=e.options.addModeClass&&[null];for(t==""&&Gr(Be(n,r.state),_);!le.eol();){if(le.pos>e.options.maxHighlightLength?(K=!1,B&&Tt(e,t,r,le.pos),le.pos=t.length,he=null):he=Gr(kt(n,le,r.state,xe),_),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,_=e.doc,B=n?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>B;--K){if(K<=_.first)return _.first;var Y=Fe(_,K-1),Z=Y.stateAfter;if(Z&&(!n||K+(Z instanceof J?Z.lookAhead:0)<=_.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 ot(){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 _=e[i],B=_.marker,K=_.from==null||(B.inclusiveLeft?_.from<=t:_.from<t);if(K||_.from==t&&B.type=="bookmark"&&(!n||!_.marker.insertLeft)){var Y=_.to==null||(B.inclusiveRight?_.to>=t:_.to>t);(r||(r=[])).push(new Ke(B,_.from,Y?null:_.to))}}return r}function gr(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var _=e[i],B=_.marker,K=_.to==null||(B.inclusiveRight?_.to>=t:_.to>t);if(K||_.from==t&&B.type=="bookmark"&&(!n||_.marker.insertLeft)){var Y=_.from==null||(B.inclusiveLeft?_.from<=t:_.from<t);(r||(r=[])).push(new Ke(B,Y?null:_.from-t,_.to==null?null:_.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,_=t.to.ch,B=xt(t.from,t.to)==0,K=It(n,i,B),Y=gr(r,_,B),Z=t.text.length==1,le=we(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 ze=Y[Oe];if(ze.to!=null&&(ze.to+=le),ze.from==null){var $e=wt(K,ze.marker);$e||(ze.from=le,Z&&(K||(K=[])).push(ze))}else ze.from+=le,Z&&(K||(K=[])).push(ze)}K&&(K=hr(K)),Y&&Y!=K&&(Y=hr(Y));var lt=[K];if(!Z){var yt=t.text.length-2,ut;if(yt>0&&K)for(var _t=0;_t<K.length;++_t)K[_t].to==null&&(ut||(ut=[])).push(new Ke(K[_t].marker,null,null));for(var Bt=0;Bt<yt;++Bt)lt.push(ut);lt.push(Y)}return lt}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 ze=ye.markedSpans[Oe].marker;ze.readOnly&&(!r||fe(r,ze)==-1)&&(r||(r=[])).push(ze)}}),!r)return null;for(var i=[{from:t,to:n}],_=0;_<r.length;++_)for(var B=r[_],K=B.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||!B.inclusiveLeft&&!he)&&le.push({from:Z.from,to:K.from}),(xe>0||!B.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(),_=xt(r.from,i.from)||or(e)-or(t);if(_)return-_;var B=xt(r.to,i.to)||tr(e)-tr(t);return B||t.id-e.id}function Ht(e,t){var n=wr&&e.markedSpans,r;if(n)for(var i=void 0,_=0;_<n.length;++_)i=n[_],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 _=n[i];_.marker.collapsed&&(_.from==null||_.from<t)&&(_.to==null||_.to>t)&&(!r||pr(r,_.marker)<0)&&(r=_.marker)}return r}function Nr(e,t,n,r,i){var _=Fe(e,t),B=wr&&_.markedSpans;if(B)for(var K=0;K<B.length;++K){var Y=B[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,_=0;_<t.markedSpans.length;++_)if(i=t.markedSpans[_],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 _=n.parent;_;n=_,_=n.parent)for(var B=0;B<_.children.length;++B){var K=_.children[B];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 _=n.find(0,!0);t-=r.text.length-_.from.ch,r=_.to.line,t+=r.text.length-_.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 Dt(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 _=i?t.rest[i-1]:t.line,B=void 0;r.pos=0,r.addToken=ar,Pt(e.display.measure)&&(B=at(_,e.doc.direction))&&(r.addToken=Qr(r.addToken,B)),r.map=[];var K=t!=e.display.externalMeasured&&Wt(_);Cn(_,r,Ne(e,_,K)),_.styleClasses&&(_.styleClasses.bgClass&&(r.bgClass=V(_.styleClasses.bgClass,r.bgClass||"")),_.styleClasses.textClass&&(r.textClass=V(_.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 De(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,_,B){if(!t)return;var K=e.splitSpaces?kr(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&&j<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&&j<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 ze=void 0;if(xe[0]==" "){var $e=e.cm.options.tabSize,lt=$e-e.col%$e;ze=le.appendChild(a("span",ne(lt),"cm-tab")),ze.setAttribute("role","presentation"),ze.setAttribute("cm-text"," "),e.col+=lt}else xe[0]=="\r"||xe[0]==`
|
|
`?(ze=le.appendChild(a("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),ze.setAttribute("cm-text",xe[0]),e.col+=1):(ze=e.cm.options.specialCharPlaceholder(xe[0]),ze.setAttribute("cm-text",xe[0]),z&&j<9?le.appendChild(a("span",[ze])):le.appendChild(ze),e.col+=1);e.map.push(e.pos,e.pos+1,ze),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,n||r||i||Z||_||B){var yt=n||"";r&&(yt+=r),i&&(yt+=i);var ut=a("span",[le],yt,_);if(B)for(var _t in B)B.hasOwnProperty(_t)&&_t!="style"&&_t!="class"&&ut.setAttribute(_t,B[_t]);return e.content.appendChild(ut)}e.content.appendChild(le)}function kr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var _=e.charAt(i);_==" "&&n&&(i==e.length-1||e.charCodeAt(i+1)==32)&&(_="\xA0"),r+=_,n=_==" "}return r}function Qr(e,t){return function(n,r,i,_,B,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,_,B,K,Y);e(n,r.slice(0,he.to-Z),i,_,null,K,Y),_=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,_=0;if(!r){for(var B=1;B<n.length;B+=2)t.addToken(t,i.slice(_,_=n[B]),Jt(n[B+1],t.cm.options));return}for(var K=i.length,Y=0,Z=1,le="",he,xe,ye=0,Oe,ze,$e,lt,yt;;){if(ye==Y){Oe=ze=$e=xe="",yt=null,lt=null,ye=Infinity;for(var ut=[],_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)ut.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,ze=""),Yt.className&&(Oe+=" "+Yt.className),Yt.css&&(xe=(xe?xe+";":"")+Yt.css),Yt.startStyle&&Ot.from==Y&&($e+=" "+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&&(!lt||pr(lt.marker,Yt)<0)&&(lt=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&&(ze+=" "+_t[Fr]);if(!lt||lt.from==Y)for(var Cr=0;Cr<ut.length;++Cr)rr(t,0,ut[Cr]);if(lt&&(lt.from||0)==Y){if(rr(t,(lt.to==null?K+1:lt.to)-Y,lt.marker,lt.from==null),lt.to==null)return;lt.to==Y&&(lt=!1)}}if(Y>=K)break;for(var on=Math.min(K,ye);;){if(le){var tn=Y+le.length;if(!lt){var Rr=tn>on?le.slice(0,on-Y):le;t.addToken(t,Rr,he?he+Oe:Oe,$e,Y+Rr.length==ye?ze:"",xe,yt)}if(tn>=on){le=le.slice(on-Y),Y=on;break}Y=tn,$e=""}le=i.slice(_,_=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(we(this.rest))-n+1:1,this.node=this.text=null,this.hidden=yn(e,t)}function Zr(e,t,n){for(var r=[],i,_=t;_<n;_=i){var B=new ur(e.doc,Fe(e.doc,_),_);i=_+B.size,r.push(B)}return r}var Kr=null;function hn(e){Kr?Kr.ops.push(e):e.ownsGroup=Kr={ops:[e],delayedCallbacks:[]}}function Ds(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 Ps(e,t){var n=e.ownsGroup;if(!n)return;try{Ds(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(ks,0));for(var _=function(K){i.push(function(){return n[K].apply(null,r)})},B=0;B<n.length;++B)_(B)}function ks(){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 _=t.changes[i];_=="text"?Ms(e,t):_=="gutter"?Ja(e,t,n,r):_=="class"?da(e,t):_=="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&&j<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 _=t.line.gutterMarkers;if(e.options.lineNumbers||_){var B=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),B.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!_||!_["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"))),_)for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Z=e.display.gutterSpecs[Y].className,le=_.hasOwnProperty(Z)&&_[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=S("CodeMirror-linewidget"),i=t.node.firstChild,_=void 0;i;i=_)_=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 _=gi(n),B=0,K=t.widgets;B<K.length;++B){var Y=K[B],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?_.insertBefore(Z,n.gutter||n.text):_.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(!x(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 _=t.measure.heights=[];if(r){t.measure.width=i;for(var B=t.text.firstChild.getClientRects(),K=0;K<B.length-1;K++){var Y=B[K],Z=B[K+1];Math.abs(Y.bottom-Z.bottom)>2&&_.push((Y.bottom+Z.top)/2-n.top)}}_.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 _=n+(r||""),B;return t.cache.hasOwnProperty(_)?B=t.cache[_]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Bs(e,t.view,t.rect),t.hasHeights=!0),B=Ws(e,t,n,r),B.bogus||(t.cache[_]=B)),{left:B.left,right:B.right,top:i?B.rtop:B.top,bottom:i?B.rbottom:B.bottom}}var ro={left:0,right:0,top:0,bottom:0};function no(e,t,n){for(var r,i,_,B,K,Y,Z=0;Z<e.length;Z+=3)if(K=e[Z],Y=e[Z+1],t<K?(i=0,_=1,B="left"):t<Y?(i=t-K,_=i+1):(Z==e.length-3||t==Y&&e[Z+3]>t)&&(_=Y-K,i=_-1,t>=Y&&(B="right")),i!=null){if(r=e[Z+2],K==Y&&n==(r.insertLeft?"left":"right")&&(B=n),n=="left"&&i==0)for(;Z&&e[Z-2]==e[Z-3]&&e[Z-1].insertLeft;)r=e[(Z-=3)+2],B="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],B="right";break}return{node:r,start:i,end:_,collapse:B,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),_=i.node,B=i.start,K=i.end,Y=i.collapse,Z;if(_.nodeType==3){for(var le=0;le<4;le++){for(;B&&Ue(t.line.text.charAt(i.coverStart+B));)--B;for(;i.coverStart+K<i.coverEnd&&Ue(t.line.text.charAt(i.coverStart+K));)++K;if(z&&j<9&&B==0&&K==i.coverEnd-i.coverStart?Z=_.parentNode.getBoundingClientRect():Z=js(v(_,B,K).getClientRects(),r),Z.left||Z.right||B==0)break;K=B,B=B-1,Y="right"}z&&j<11&&(Z=Hs(e.display.measure,Z))}else{B>0&&(Y=r="right");var he;e.options.lineWrapping&&(he=_.getClientRects()).length>1?Z=he[r=="right"?he.length-1:0]:Z=_.getBoundingClientRect()}if(z&&j<9&&!B&&(!Z||!Z.left&&!Z.right)){var xe=_.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,ze=(ye+Oe)/2,$e=t.view.measure.heights,lt=0;lt<$e.length-1&&!(ze<$e[lt]);lt++);var yt=lt?$e[lt-1]:0,ut=$e[lt],_t={left:(Y=="right"?Z.right:Z.left)-t.rect.left,right:(Y=="left"?Z.left:Z.right)-t.rect.left,top:yt,bottom:ut};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 _=pa(t);n.top+=_,n.bottom+=_}if(r=="line")return n;r||(r="local");var B=fn(t);if(r=="local"?B+=Wi(e.display):B-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();B+=K.top+(r=="window"?0:so());var Y=K.left+(r=="window"?0:oo());n.left+=Y,n.right+=Y}return n.top+=B,n.bottom+=B,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 _=e.display.sizer.getBoundingClientRect();r+=_.left,i+=_.top}var B=e.display.lineSpace.getBoundingClientRect();return{left:r-B.left,top:i-B.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,_){r=r||Fe(e.doc,t.line),i||(i=$n(e,r));function B(Oe,ze){var $e=En(e,i,Oe,ze?"right":"left",_);return ze?$e.left=$e.right:$e.right=$e.left,Hi(e,r,$e,n)}var K=at(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 B(Z=="before"?Y-1:Y,Z=="before");function le(Oe,ze,$e){var lt=K[ze],yt=lt.level==1;return B($e?Oe-1:Oe,yt!=$e)}var he=nt(K,Y,Z),xe=Qe,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 _=Ie(e,t,n);return _.xRel=i,r&&(_.outside=r),_}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),_=r.first+r.size-1;if(i>_)return ga(r.first+r.size-1,Fe(r,_).text.length,null,1,1);t<0&&(t=0);for(var B=Fe(r,i);;){var K=zs(e,B,i,t,n),Y=vn(B,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;B=Fe(r,i=Z.line)}}function co(e,t,n,r){r-=pa(t);var i=t.text.length,_=st(function(B){return En(e,n,B-1).bottom<=r},i,0);return i=st(function(B){return En(e,n,B).top>r},_,i),{begin:_,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 _=$n(e,t),B=pa(t),K=0,Y=t.text.length,Z=!0,le=at(t,e.doc.direction);if(le){var he=(e.options.lineWrapping?Ks:Gs)(e,t,n,_,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=st(function(Bt){var Ot=En(e,_,Bt);return Ot.top+=B,Ot.bottom+=B,ya(Ot,r,i,!1)?(Ot.top<=i&&Ot.left<=r&&(xe=Bt,ye=Ot),!0):!1},K,Y),ze,$e,lt=!1;if(ye){var yt=r-ye.left<ye.right-r,ut=yt==Z;Oe=xe+(ut?0:1),$e=ut?"after":"before",ze=yt?ye.left:ye.right}else{!Z&&(Oe==Y||Oe==K)&&Oe++,$e=Oe==0?"after":Oe==t.text.length?"before":En(e,_,Oe-(Z?1:0)).bottom+B<=i==Z?"after":"before";var _t=pn(e,Ie(n,Oe,$e),"line",t,_);ze=_t.left,lt=i<_t.top?-1:i>=_t.bottom?1:0}return Oe=Re(t.text,Oe,1),ga(n,Oe,$e,lt,r-ze)}function Gs(e,t,n,r,i,_,B){var K=st(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),_,B,!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,_,B,!0)&&le.top>B&&(Y=i[K-1])}return Y}function Ks(e,t,n,r,i,_,B){var K=co(e,t,r,B),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,ze=En(e,r,Oe?Math.min(Z,ye.to)-1:Math.max(Y,ye.from)).right,$e=ze<_?_-ze+1e9:ze-_;(!le||he>$e)&&(le=ye,he=$e)}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,_=t.gutters.firstChild,B=0;_;_=_.nextSibling,++B){var K=e.display.gutterSpecs[B].className;n[K]=_.offsetLeft+_.clientLeft+i,r[K]=_.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 _=0;if(i.widgets)for(var B=0;B<i.widgets.length;B++)i.widgets[B].height&&(_+=i.widgets[B].height);return n?_+(Math.ceil(i.text.length/r)||1)*t:_+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 _,B,K=i.lineSpace.getBoundingClientRect();try{_=t.clientX-K.left,B=t.clientY-K.top}catch(he){return null}var Y=va(e,_,B),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((_-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&&Dn(e);else if(n<=i.viewFrom)wr&&Ln(e.doc,n+r)>i.viewFrom?Dn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Dn(e);else if(t<=i.viewFrom){var _=zi(e,n,n+r,1);_?(i.view=i.view.slice(_.index),i.viewFrom=_.lineN,i.viewTo+=r):Dn(e)}else if(n>=i.viewTo){var B=zi(e,t,t,-1);B?(i.view=i.view.slice(0,B.index),i.viewTo=B.lineN):Dn(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):Dn(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 _=r.view[Wn(e,t)];if(_.node==null)return;var B=_.changes||(_.changes=[]);fe(B,n)==-1&&B.push(n)}function Dn(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),_,B=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+=B[Y].size;if(K!=t){if(r>0){if(i==B.length-1)return null;_=K+B[i].size-t,i++}else _=K-t;t+=_,n+=_}for(;hi(e.doc,n)!=n;){if(i==(r<0?0:B.length-1))return null;n+=r*B[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(),_=r.selection=document.createDocumentFragment(),B=0;B<n.sel.ranges.length;B++){if(!t&&B==n.sel.primIndex)continue;var K=n.sel.ranges[B];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,_)}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 _=n.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));_.style.display="",_.style.left=r.other.left+"px",_.style.top=r.other.top+"px",_.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,_=document.createDocumentFragment(),B=qa(e.display),K=B.left,Y=Math.max(r.sizerWidth,Bn(e)-r.sizer.offsetLeft)-B.right,Z=i.direction=="ltr";function le(ut,_t,Bt,Ot){_t<0&&(_t=0),_t=Math.round(_t),Ot=Math.round(Ot),_.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+ut+`px;
|
|
top: `+_t+"px; width: "+(Bt==null?Y-ut:Bt)+`px;
|
|
height: `+(Ot-_t)+"px"))}function he(ut,_t,Bt){var Ot=Fe(i,ut),Yt=Ot.text.length,yr,Fr;function Cr(Rr,rn){return ma(e,Ie(ut,Rr),"div",Ot,rn)}function on(Rr,rn,zr){var Or=ho(e,Ot,null,Rr),Dr=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,Dr)[Dr]}var tn=at(Ot,i.direction);return Je(tn,_t||0,Bt==null?Yt:Bt,function(Rr,rn,zr,Or){var Dr=zr=="ltr",_r=Cr(Rr,Dr?"left":"right"),nn=Cr(rn-1,Dr?"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:(Dr?_r:nn).left,Vn=Va?Y:(Dr?nn:_r).right;le(wn,_r.top,Vn-wn,_r.bottom)}else{var Xn,Jr,ci,Xa;Dr?(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),ze=Fe(i,ye.line),$e=Yr(Oe)==Yr(ze),lt=he(xe.line,xe.ch,$e?Oe.text.length+1:null).end,yt=he(ye.line,$e?0:null,ye.ch).start;$e&&(lt.top<yt.top-2?(le(lt.right,lt.top,null,lt.bottom),le(K,yt.top,yt.left,yt.bottom)):le(lt.right,lt.top,yt.left-lt.right,lt.bottom)),lt.bottom<yt.top&&le(K,lt.bottom,null,yt.top)}n.appendChild(_)}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||(De(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&&(De(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],_=e.options.lineWrapping,B=void 0,K=0;if(i.hidden)continue;if(z&&j<8){var Y=i.node.offsetTop+i.node.offsetHeight;B=Y-n,n=Y}else{var Z=i.node.getBoundingClientRect();B=Z.bottom-Z.top,!_&&i.text.firstChild&&(K=i.text.firstChild.getBoundingClientRect().right-Z.left-1)}var le=i.line.height-B;if((le>.005||le<-.005)&&(qt(i.line,B),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,_=Tr(t,r),B=Tr(t,i);if(n&&n.ensure){var K=n.ensure.from.line,Y=n.ensure.to.line;K<_?(_=K,B=Tr(t,fn(Fe(t,K))+e.wrapper.clientHeight)):Math.min(Y,t.lastLine())>=B&&(_=Tr(t,fn(Fe(t,Y))-e.wrapper.clientHeight),B=Y)}return{from:_,to:Math.max(B,_+1)}}function Ys(e,t){if(We(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 _=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(_),_.scrollIntoView(i),e.display.lineSpace.removeChild(_)}}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 _=0;_<5;_++){var B=!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&&(B=!0)),Z.scrollLeft!=null&&(Hn(e,Z.scrollLeft),Math.abs(e.doc.scrollLeft-he)>1&&(B=!0)),!B)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,_=ha(e),B={};t.bottom-t.top>_&&(t.bottom=t.top+_);var K=e.doc.height+ca(n),Y=t.top<r,Z=t.bottom>K-r;if(t.top<i)B.scrollTop=Y?0:t.top;else if(t.bottom>i+_){var le=Math.min(t.top,(Z?K:t.bottom)-_);le!=i&&(B.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?B.scrollLeft=0:t.left<xe?B.scrollLeft=Math.max(0,t.left+he-(Oe?0:10)):t.right>ye+xe-3&&(B.scrollLeft=t.right+(Oe?0:10)-ye),B}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),Ae(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ae(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,z&&j<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 _=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+_)+"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=d&&!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(),_=n=="vert"?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);_!=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),Ae(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&&Ps(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 _=0;_<t.length;_++)nl(t[_]);for(var B=0;B<t.length;B++)il(t[B])}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==k();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 _=e.maybeHiddenMarkers,B=e.maybeUnhiddenMarkers;if(_)for(var K=0;K<_.length;++K)_[K].lines.length||De(_[K],"hide");if(B)for(var Y=0;Y<B.length;++Y)B[Y].lines.length&&De(B[Y],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&De(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=rt(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(_){if(r.line>=e.display.viewFrom){var B=_.styles,K=_.text.length>e.options.maxHighlightLength?Ut(t.mode,r.state):null,Y=ce(e,_,r,!0);K&&(r.state=K),_.styles=Y.styles;var Z=_.styleClasses,le=Y.classes;le?_.styleClasses=le:Z&&(_.styleClasses=null);for(var he=!B||B.length!=_.styles.length||Z!=le&&(!Z||!le||Z.bgClass!=le.bgClass||Z.textClass!=le.textClass),xe=0;!he&&xe<B.length;++xe)he=B[xe]!=_.styles[xe];he&&i.push(r.line),_.stateAfter=r.save(),r.nextLine()}else _.text.length<=e.options.maxHighlightLength&&Tt(e,_.text,r),_.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 _=0;_<i.length;_++)Rn(e,i[_],"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++)De.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=k();if(!t||!x(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&x(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==k())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&x(document.body,e.anchorNode)&&x(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 Dn(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)&&(Dn(e),t.dims=ba(e));var i=r.first+r.size,_=Math.max(t.visible.from-e.options.viewportMargin,r.first),B=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<_&&_-n.viewFrom<20&&(_=Math.max(r.first,n.viewFrom)),n.viewTo>B&&n.viewTo-B<20&&(B=Math.min(i,n.viewTo)),wr&&(_=hi(e.doc,_),B=Ln(e.doc,B));var K=_!=n.viewFrom||B!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Vs(e,_,B),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,_=r.lineDiv,B=_.firstChild;function K(Oe){var ze=Oe.nextSibling;return O&&d&&e.display.currentWheelTarget==Oe?Oe.style.display="none":Oe.parentNode.removeChild(Oe),ze}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!=_){var xe=Ns(e,he,Z,n);_.insertBefore(xe,B)}else{for(;B!=he.node;)B=K(B);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)))),B=he.node.nextSibling}Z+=he.size}for(;B;)B=K(B)}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,_=r+"px",B=0;B<n.length;B++)if(!n[B].hidden){e.options.fixedGutter&&(n[B].gutter&&(n[B].gutter.style.left=_),n[B].gutterBackground&&(n[B].gutterBackground.style.left=_));var K=n[B].alignable;if(K)for(var Y=0;Y<K.length;Y++)K[Y].style.left=_}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")),_=i.firstChild.offsetWidth,B=i.offsetWidth-_;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(_,r.lineGutter.offsetWidth-B)+1,r.lineNumWidth=r.lineNumInnerWidth+B,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",La(e.display),!0}return!1}function Da(e,t){for(var n=[],r=!1,i=0;i<e.length;i++){var _=e[i],B=null;if(typeof _!="string"&&(B=_.style,_=_.className),_=="CodeMirror-linenumbers")if(t)r=!0;else continue;n.push({className:_,style:B})}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],_=i.className,B=i.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+_));B&&(K.style.cssText=B),_=="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 _=b("div",[i.lineSpace],"CodeMirror-lines");i.mover=a("div",[_],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&&j<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=Da(r.gutters,r.lineNumbers),Lo(i),n.init(i)}var $i=0,sn=null;z?sn=-.53:R?sn=15:E?sn=-.7:D&&(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 Do(e,t){var n=Ro(t),r=n.x,i=n.y,_=e.display,B=_.scroller,K=B.scrollWidth>B.clientWidth,Y=B.scrollHeight>B.clientHeight;if(!(r&&K||i&&Y))return;if(i&&d&&O){e:for(var Z=t.target,le=_.view;Z!=B;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,B.scrollTop+i*sn)),Hn(e,Math.max(0,B.scrollLeft+r*sn)),(!i||i&&Y)&&ee(t),_.wheelStartX=null;return}if(i&&sn!=null){var xe=i*sn,ye=e.doc.scrollTop,Oe=ye+_.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&&(_.wheelStartX==null?(_.wheelStartX=B.scrollLeft,_.wheelStartY=B.scrollTop,_.wheelDX=r,_.wheelDY=i,setTimeout(function(){if(_.wheelStartX==null)return;var ze=B.scrollLeft-_.wheelStartX,$e=B.scrollTop-_.wheelStartY,lt=$e&&_.wheelDY&&$e/_.wheelDY||ze&&_.wheelDX&&ze/_.wheelDX;if(_.wheelStartX=_.wheelStartY=null,!lt)return;sn=(sn*$i+lt)/($i+1),++$i},200)):(_.wheelDX+=r,_.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(!Pr(n.anchor,r.anchor)||!Pr(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 _=1;_<t.length;_++){var B=t[_],K=t[_-1],Y=xt(K.to(),B.from());if(r&&!B.empty()?Y>0:Y>=0){var Z=xr(K.from(),B.from()),le=dn(K.to(),B.to()),he=K.empty()?B.from()==B.head:K.from()==K.head;_<=n&&--n,t.splice(--_,2,new dr(he?le:Z,he?Z:le))}}return new ln(t,n)}function Pn(e,t){return new ln([new dr(e,t||e)],0)}function kn(e){return e.text?Ie(e.from.line+e.text.length-1,we(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Po(e,t){if(xt(e,t.from)<0)return e;if(xt(e,t.to)<=0)return kn(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+=kn(t).ch-t.to.ch),Ie(n,r)}function Pa(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new dr(Po(i.anchor,t),Po(i.head,t)))}return mn(e.cm,n,e.sel.primIndex)}function ko(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),_=i,B=0;B<t.length;B++){var K=t[B],Y=ko(K.from,i,_),Z=ko(kn(K),i,_);if(i=K.to,_=Z,n=="around"){var le=e.sel.ranges[B],he=xt(le.head,le.anchor)<0;r[B]=new dr(he?Z:Y,he?Y:Z)}else r[B]=new dr(Y,Y)}return new ln(r,e.sel.primIndex)}function ka(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&&we(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Oa(e,t,n,r){function i(yt){return n?n[yt]:null}function _(yt,ut,_t){ua(yt,ut,_t,r),Hr(yt,"change",yt,t)}function B(yt,ut){for(var _t=[],Bt=yt;Bt<ut;++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=we(Z),ye=i(Z.length-1),Oe=Y.line-K.line;if(t.full)e.insert(0,B(0,Z.length)),e.remove(Z.length,e.size-Z.length);else if(Oo(e,t)){var ze=B(0,Z.length-1);_(he,he.text,ye),Oe&&e.remove(K.line,Oe),ze.length&&e.insert(K.line,ze)}else if(le==he)if(Z.length==1)_(le,le.text.slice(0,K.ch)+xe+le.text.slice(Y.ch),ye);else{var $e=B(1,Z.length-1);$e.push(new Un(xe+le.text.slice(Y.ch),ye,r)),_(le,le.text.slice(0,K.ch)+Z[0],i(0)),e.insert(K.line+1,$e)}else if(Z.length==1)_(le,le.text.slice(0,K.ch)+Z[0]+he.text.slice(Y.ch),i(0)),e.remove(K.line+1,Oe);else{_(le,le.text.slice(0,K.ch)+Z[0],i(0)),_(he,xe+he.text.slice(Y.ch),ye);var lt=B(1,Z.length-1);Oe>1&&e.remove(K.line+1,Oe-1),e.insert(K.line+1,lt)}Hr(e,"change",e,t)}function On(e,t,n){function r(i,_,B){if(i.linked)for(var K=0;K<i.linked.length;++K){var Y=i.linked[K];if(Y.doc==_)continue;var Z=B&&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),ka(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:kn(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=we(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),we(e.done);if(e.done.length&&!we(e.done).ranges)return we(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),we(e.done)}function Uo(e,t,n,r){var i=e.history;i.undone.length=0;var _=+new Date,B,K;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&i.lastModTime>_-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(B=pl(i,i.lastOp==r)))K=we(B.changes),xt(t.from,t.to)==0&&xt(t.from,K.to)==0?K.to=kn(t):B.changes.push(Ma(e,t));else{var Y=we(i.done);for((!Y||!Y.ranges)&&Qi(e.sel,i.done),B={changes:[Ma(e,t)],generation:i.generation},i.done.push(B);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=_,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,K||De(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,_=r&&r.origin;n==i.lastSelOp||_&&i.lastSelOrigin==_&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==_||ml(e,_,we(i.done),t))?i.done[i.done.length-1]=t:Qi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=_,i.lastSelOp=n,r&&r.clearRedo!==!1&&No(i.undone)}function Qi(e,t){var n=we(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Bo(e,t,n,r){var i=t["spans_"+e.id],_=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(B){B.markedSpans&&((i||(i=t["spans_"+e.id]={}))[_]=B.markedSpans),++_})}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 _=n[i],B=r[i];if(_&&B){e:for(var K=0;K<B.length;++K){for(var Y=B[K],Z=0;Z<_.length;++Z)if(_[Z].marker==Y.marker)continue e;_.push(Y)}}else B&&(n[i]=B)}return n}function ti(e,t,n){for(var r=[],i=0;i<e.length;++i){var _=e[i];if(_.ranges){r.push(n?ln.prototype.deepCopy.call(_):_);continue}var B=_.changes,K=[];r.push({changes:K});for(var Y=0;Y<B.length;++Y){var Z=B[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&&(we(K)[he]=Z[he],delete Z[he]))}}return r}function Ia(e,t,n,r){if(r){var i=e.anchor;if(n){var _=xt(t,i)<0;_!=xt(n,i)<0?(i=t,t=n):_!=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),_=0;_<e.sel.ranges.length;_++)r[_]=Ia(e.sel.ranges[_],t[_],null,i);var B=mn(e.cm,r,e.sel.primIndex);Vr(e,B,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,Pn(t,n),r)}function bl(e,t,n){var r={ranges:t.ranges,update:function(i){this.ranges=[];for(var _=0;_<i.length;_++)this.ranges[_]=new dr(u(e,i[_].anchor),u(e,i[_].head))},origin:n&&n.origin};return De(e,"beforeSelectionChange",e,r),e.cm&&De(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=we(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,_=0;_<t.ranges.length;_++){var B=t.ranges[_],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[_],Y=ea(e,B.anchor,K&&K.anchor,n,r),Z=ea(e,B.head,K&&K.head,n,r);(i||Y!=B.anchor||Z!=B.head)&&(i||(i=t.ranges.slice(0,_)),i[_]=new dr(Y,Z))}return i?mn(e.cm,i,t.primIndex):t}function ri(e,t,n,r,i){var _=Fe(e,t.line);if(_.markedSpans)for(var B=0;B<_.markedSpans.length;++B){var K=_.markedSpans[B],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&&(De(Y,"beforeCursorEnter"),Y.explicitlyCleared))if(_.markedSpans){--B;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?_: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?_:null)),ye?ri(e,ye,t,r,i):null}}return t}function ea(e,t,n,r,i){var _=r||1,B=ri(e,t,n,_,i)||!i&&ri(e,t,n,_,!0)||ri(e,t,n,-_,i)||!i&&ri(e,t,n,-_,!0);return B||(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,_,B,K){i&&(r.from=u(e,i)),_&&(r.to=u(e,_)),B&&(r.text=B),K!==void 0&&(r.origin=K)}),De(e,"beforeChange",e,r),e.cm&&De(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=Pa(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,_){!_&&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,_,B=e.sel,K=t=="undo"?i.done:i.undone,Y=t=="undo"?i.undone:i.done,Z=0;Z<K.length&&!(_=K[Z],n?_.ranges&&!_.equals(e.sel):!_.ranges);Z++);if(Z==K.length)return;for(i.lastOrigin=i.lastSelOrigin=null;;)if(_=K.pop(),_.ranges){if(Qi(_,Y),n&&!_.equals(e.sel)){Vr(e,_,{clearRedo:!1});return}B=_}else if(r){K.push(_);return}else break;var le=[];Qi(B,Y),Y.push({changes:le,generation:i.generation}),i.generation=_.generation||++i.maxGeneration;for(var he=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),xe=function(ze){var $e=_.changes[ze];if($e.origin=t,he&&!Yo(e,$e,!1))return K.length=0,{};le.push(Ma(e,$e));var lt=ze?Pa(e,$e):we(K);Ai(e,$e,lt,Fo(e,$e)),!ze&&e.cm&&e.cm.scrollIntoView({from:$e.from,to:kn($e)});var yt=[];On(e,function(ut,_t){!_t&&fe(yt,ut.history)==-1&&(qo(ut.history,$e),yt.push(ut.history)),Ai(ut,$e,null,Fo(ut,$e))})},ye=_.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(tt(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:[we(t.text)],origin:t.origin}}var _=e.lastLine();t.to.line>_&&(t={from:t.from,to:Ie(_,Fe(e,_).text.length),text:[t.text[0]],origin:t.origin}),t.removed=nr(e,t.from,t.to),n||(n=Pa(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,_=t.from,B=t.to,K=!1,Y=_.line;e.options.lineWrapping||(Y=Wt(Yr(Fe(r,_.line))),r.iter(Y,B.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,_.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,_.line),_i(e,400);var Z=t.text.length-(B.line-_.line)-1;t.full?qr(e):_.line==B.line&&t.text.length==1&&!Oo(e.doc,t)?Rn(e,_.line,"text"):qr(e,_.line,B.line+1,Z);var le=de(e,"changes"),he=de(e,"change");if(he||le){var xe={from:_,to:B,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 _;r||(r=n),xt(r,n)<0&&(_=[r,n],n=_[0],r=_[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 _=e[i],B=!0;if(_.ranges){_.copied||(_=e[i]=_.deepCopy(),_.copied=!0);for(var K=0;K<_.ranges.length;K++)Qo(_.ranges[K].anchor,t,n,r),Qo(_.ranges[K].head,t,n,r);continue}for(var Y=0;Y<_.changes.length;++Y){var Z=_.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){B=!1;break}}B||(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,_=t;return typeof t=="number"?_=Fe(e,U(e,t)):i=Wt(t),i==null?null:(r(_,i)&&e.cm&&Rn(e.cm,i,n),_)}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,Dt(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 Di(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}Di.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 _=Math.min(t,i-e),B=r.height;if(r.removeInner(e,_),this.height-=B-r.height,i==_&&(this.children.splice(n--,1),r.parent=null),(t-=_)==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],_=i.chunkSize();if(e<=_){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var B=i.lines.length%25+25,K=B;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,B),this.maybeSpill()}break}e-=_}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Di(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 Di(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],_=i.chunkSize();if(e<_){var B=Math.min(t,_-e);if(i.iterN(e,B,n))return!0;if((t-=B)==0)break;e=0}else e-=_}}};var Pi=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};Pi.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 _=vi(this);qt(n,Math.max(0,n.height-_)),e&&(an(e,function(){es(e,n,-_),Rn(e,r,"widget")}),Hr(e,"lineWidgetCleared",e,this,r))},Pi.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(Pi);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 Pi(e,n,r),_=e.cm;return _&&i.noHScroll&&(_.display.alignWidgets=!0),Li(e,t,"widget",function(B){var K=B.widgets||(B.widgets=[]);if(i.insertAt==null?K.push(i):K.splice(Math.min(K.length-1,Math.max(0,i.insertAt)),0,i),i.line=B,_&&!yn(e,B)){var Y=fn(B)<e.scrollTop;qt(B,B.height+vi(i)),Y&&Ta(_,i.height),_.curOp.forceUpdate=!0}return!0}),_&&Hr(_,"lineWidgetAdded",_,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,_=0;_<this.lines.length;++_){var B=this.lines[_],K=wt(B.markedSpans,this);e&&!this.collapsed?Rn(e,Wt(B),"text"):e&&(K.to!=null&&(i=Wt(B)),K.from!=null&&(r=Wt(B))),B.markedSpans=mt(B.markedSpans,K),K.from==null&&this.collapsed&&!yn(this.doc,B)&&e&&qt(B,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 _=this.lines[i],B=wt(_.markedSpans,this);if(B.from!=null&&(n=Ie(t?_:Wt(_),B.from),e==-1))return n;if(B.to!=null&&(r=Ie(t?_:Wt(_),B.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,_=Wt(t.line),B=fa(r,_);if(B&&(io(B),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 _=new Mn(e,i),B=xt(t,n);if(r&&W(r,_,!1),B>0||B==0&&_.clearWhenEmpty!==!1)return _;if(_.replacedWith&&(_.collapsed=!0,_.widgetNode=b("span",[_.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||_.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(_.widgetNode.insertLeft=!0)),_.collapsed){if(Nr(e,t.line,t,n,_)||t.line!=n.line&&Nr(e,n.line,t,n,_))throw new Error("Inserting collapsed marker partially overlapping an existing one");be()}_.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&&_.collapsed&&!Y.options.lineWrapping&&Yr(he)==Y.display.maxLine&&(Z=!0),_.collapsed&&K!=t.line&&qt(he,0),vt(he,new Ke(_,K==t.line?t.ch:null,K==n.line?n.ch:null)),++K}),_.collapsed&&e.iter(t.line,n.line+1,function(he){yn(e,he)&&qt(he,0)}),_.clearOnEnter&&Ae(_,"beforeCursorEnter",function(){return _.clear()}),_.readOnly&&(ot(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),_.collapsed&&(_.id=++ts,_.atomic=!0),Y){if(Z&&(Y.curOp.updateMaxLine=!0),_.collapsed)qr(Y,t.line,n.line+1);else if(_.className||_.startStyle||_.endStyle||_.css||_.attributes||_.title)for(var le=t.line;le<=n.line;le++)Rn(Y,le,"text");_.atomic&&Go(Y.doc),Hr(Y,"markerAdded",Y,_)}return _}var ki=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};ki.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")},ki.prototype.find=function(e,t){return this.primary.find(e,t)},pe(ki);function Sl(e,t,n,r,i){r=W(r),r.shared=!1;var _=[ai(e,t,n,r,i)],B=_[0],K=r.widgetNode;return On(e,function(Y){K&&(r.widgetNode=K.cloneNode(!0)),_.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;B=we(_)}),new ki(_,B)}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(),_=e.clipPos(i.from),B=e.clipPos(i.to);if(xt(_,B)){var K=ai(e,_,B,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function _l(e){for(var t=function(r){var i=e[r],_=[i.primary.doc];On(i.primary.doc,function(Y){return _.push(Y)});for(var B=0;B<i.markers.length;B++){var K=i.markers[B];fe(_,K.doc)==-1&&(K.parent=null,i.markers.splice(B--,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),Di.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 _=Ie(n,0);this.sel=Pn(_),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:_,to:_,text:e}),Vr(this,Pn(_),Ee)};en.prototype=Ve(Di.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,Pn(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,M(this,e),t)}),extendSelectionsBy:Br(function(e,t){var n=tt(this.sel.ranges,e);jo(this,M(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,_=0;_<i.ranges.length;_++){var B=i.ranges[_];r[_]={from:B.from(),to:B.to(),text:this.splitLines(e[_]),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(S(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",_=r[i];if(_)if(n==null)r[i]=null;else{var B=_.match(S(n));if(!B)return!1;var K=B.index+B[0].length;r[i]=_.slice(0,B.index)+(!B.index||K==_.length?"":" ")+_.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(_){var B=_.markedSpans;if(B)for(var K=0;K<B.length;K++){var Y=B[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 _=i.text.length+r;if(_>e)return t=e,!0;e-=_,++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):et(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),We(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,_=Array(i),B=0,K=function(){++B==i&&Ur(t,function(){n=u(t.doc,n);var ye={from:n,to:n,text:t.doc.splitLines(_.filter(function(Oe){return Oe!=null}).join(t.doc.lineSeparator())),origin:"paste"};ni(t.doc,ye),Ho(t.doc,Pn(u(t.doc,n),u(t.doc,kn(ye))))})()},Y=function(ye,Oe){if(t.options.allowDropFileTypes&&fe(t.options.allowDropFileTypes,ye.type)==-1){K();return}var ze=new FileReader;ze.onerror=function(){return K()},ze.onload=function(){var $e=ze.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test($e)){K();return}_[Oe]=$e,K()},ze.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,Pn(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(We(e,t)||_n(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!D){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 _=0;_<n.length;_++)e(n[_])})}var os=!1;function Rl(){if(os)return;Dl(),os=!0}function Dl(){var e;Ae(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Pl)},100))}),Ae(window,"blur",function(){return as(Zn)})}function Pl(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=d?Tn.macDefault:Tn.pcDefault;function kl(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,r,i,_,B=0;B<t.length-1;B++){var K=t[B];if(/^(cmd|meta|m)$/i.test(K))_=!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),_&&(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=tt(n.split(" "),kl),_=0;_<i.length;_++){var B=void 0,K=void 0;_==i.length-1?(K=i.join(" "),B=r):(K=i.slice(0,_+1).join(" "),B="...");var Y=t[K];if(!Y)t[K]=B;else if(Y!=B)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 _=0;_<t.fallthrough.length;_++){var B=oi(e,t.fallthrough[_],n,r);if(B)return B}}}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 _=t(n[i]);r.length&&xt(_.from,we(r).to)<=0;){var B=r.pop();if(xt(B.from,_.from)<0){_.from=B.from;break}}r.push(_)}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=Re(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 _=at(n,t.doc.direction);if(_){var B=i<0?we(_):_[0],K=i<0==(B.level==1),Y=K?"after":"before",Z;if(B.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=st(function(xe){return En(t,le,xe).top==he},i<0==(B.level==1)?B.from:B.to-1,Z),Y=="before"&&(Z=Ua(n,Z,1))}else Z=i<0?B.to:B.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=at(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 _=nt(i,n.ch,n.sticky),B=i[_];if(e.doc.direction=="ltr"&&B.level%2==0&&(r>0?B.to>n.ch:B.from<n.ch))return Ba(t,n,r);var K=function(lt,yt){return Ua(t,lt instanceof Ie?lt.ch:lt,yt)},Y,Z=function(lt){return e.options.lineWrapping?(Y=Y||$n(e,t),ho(e,t,Y,lt)):{begin:0,end:t.text.length}},le=Z(n.sticky=="before"?K(n,-1):n.ch);if(e.doc.direction=="rtl"||B.level==1){var he=B.level==1==r<0,xe=K(n,he?1:-1);if(xe!=null&&(he?xe<=B.to&&xe<=le.end:xe>=B.from&&xe>=le.begin)){var ye=he?"before":"after";return new Ie(n.line,xe,ye)}}var Oe=function(lt,yt,ut){for(var _t=function(yr,Fr){return Fr?new Ie(n.line,K(yr,1),"before"):new Ie(n.line,yr,"after")};lt>=0&<<i.length;lt+=yt){var Bt=i[lt],Ot=yt>0==(Bt.level!=1),Yt=Ot?ut.begin:K(ut.end,-1);if(Bt.from<=Yt&&Yt<Bt.to)return _t(Yt,Ot);if(Yt=Ot?Bt.from:K(Bt.to,-1),ut.begin<=Yt&&Yt<ut.end)return _t(Yt,Ot)}},ze=Oe(_+r,r,le);if(ze)return ze;var $e=r>0?le.end:K(le.begin,-1);return $e!=null&&!(r>0&&$e==t.text.length)&&(ze=Oe(r>0?0:i.length-1,r,Z($e)),ze)?ze: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 _=n[i].from(),B=q(e.getLine(_.line),_.ch,r);t.push(ne(r-B%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,_=Fe(e.doc,i.line).text;if(_){if(i.ch==_.length&&(i=new Ie(i.line,i.ch-1)),i.ch>0)i=new Ie(i.line,i.ch+1),e.replaceRange(_.charAt(i.ch-1)+_.charAt(i.ch-2),Ie(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var B=Fe(e.doc,i.line-1).text;B&&(i=new Ie(i.line,1),e.replaceRange(_.charAt(0)+e.doc.lineSeparator()+B.charAt(B.length-1),Ie(i.line-1,B.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=at(r,e.doc.direction);if(!i||i[0].level==0){var _=Math.max(n.ch,r.text.search(/\S/)),B=t.line==n.line&&t.ch<=_&&t.ch;return Ie(n.line,B?0:_,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)!=ke}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=k(),We(t,e))return;z&&j<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&&(d?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),R&&!d&&!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"),dt(document,"keyup",n),dt(document,"mouseover",n))}Ae(document,"keyup",n),Ae(document,"mouseover",n)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),We(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(_n(t.display,e)||We(t,e)||e.ctrlKey&&!e.altKey||d&&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(We(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),_=r?Wl(r,i):"single";if(window.focus(),i==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,i,r,_,e))return;i==1?r?Gl(t,r,_,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 _="Click";return r=="double"?_="Double"+_:r=="triple"&&(_="Triple"+_),_=(t==1?"Left":t==2?"Middle":"Right")+_,Ni(e,ls(_,i),i,function(B){if(typeof B=="string"&&(B=Ii[B]),!B)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=B(e,n)!=ke}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 _=c?n.shiftKey&&n.metaKey:n.altKey;i.unit=_?"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=d?n.metaKey:n.ctrlKey),i.moveOnDrag==null&&(i.moveOnDrag=!(d?n.altKey:n.ctrlKey)),i}function Gl(e,t,n,r){z?setTimeout(G(vo,e),0):e.curOp.focus=k();var i=zl(e,n,r),_=e.doc.sel,B;e.options.dragDrop&&Pe&&!e.isReadOnly()&&n=="single"&&(B=_.contains(t))>-1&&(xt((B=_.ranges[B]).from(),t)<0||t.xRel>0)&&(xt(B.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,_=!1,B=Ur(e,function(Z){O&&(i.scroller.draggable=!1),e.state.draggingText=!1,dt(i.wrapper.ownerDocument,"mouseup",B),dt(i.wrapper.ownerDocument,"mousemove",K),dt(i.scroller,"dragstart",Y),dt(i.scroller,"drop",B),_||(ee(Z),r.addNew||Zi(e.doc,n,null,null,r.extend),O&&!D||z&&j==9?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),K=function(Z){_=_||Math.abs(t.clientX-Z.clientX)+Math.abs(t.clientY-Z.clientY)>=10},Y=function(){return _=!0};O&&(i.scroller.draggable=!0),e.state.draggingText=B,B.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),Ae(i.wrapper.ownerDocument,"mouseup",B),Ae(i.wrapper.ownerDocument,"mousemove",K),Ae(i.scroller,"dragstart",Y),Ae(i.scroller,"drop",B),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,_=e.doc;ee(t);var B,K,Y=_.sel,Z=Y.ranges;if(r.addNew&&!r.extend?(K=_.sel.contains(n),K>-1?B=Z[K]:B=new dr(n,n)):(B=_.sel.primary(),K=_.sel.primIndex),r.unit=="rectangle")r.addNew||(B=new dr(n,n)),n=jn(e,t,!0,!0),K=-1;else{var le=ys(e,n,r.unit);r.extend?B=Ia(B,le.anchor,le.head,r.extend):B=le}r.addNew?K==-1?(K=Z.length,Vr(_,mn(e,Z.concat([B]),K),{scroll:!1,origin:"*mouse"})):Z.length>1&&Z[K].empty()&&r.unit=="char"&&!r.extend?(Vr(_,mn(e,Z.slice(0,K).concat(Z.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),Y=_.sel):Na(_,K,B,_e):(K=0,Vr(_,new ln([B],0),_e),Y=_.sel);var he=n;function xe(ut){if(xt(he,ut)==0)return;if(he=ut,r.unit=="rectangle"){for(var _t=[],Bt=e.options.tabSize,Ot=q(Fe(_,n.line).text,n.ch,Bt),Yt=q(Fe(_,ut.line).text,ut.ch,Bt),yr=Math.min(Ot,Yt),Fr=Math.max(Ot,Yt),Cr=Math.min(n.line,ut.line),on=Math.min(e.lastLine(),Math.max(n.line,ut.line));Cr<=on;Cr++){var tn=Fe(_,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(_,mn(e,Y.ranges.slice(0,K).concat(_t),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(ut)}else{var rn=B,zr=ys(e,ut,r.unit),Or=rn.anchor,Dr;xt(zr.anchor,Or)>0?(Dr=zr.head,Or=xr(rn.from(),zr.anchor)):(Dr=zr.anchor,Or=dn(rn.to(),zr.head));var _r=Y.ranges.slice(0);_r[K]=Xl(e,new dr(u(_,Or),Dr)),Vr(_,mn(e,_r,K),_e)}}var ye=i.wrapper.getBoundingClientRect(),Oe=0;function ze(ut){var _t=++Oe,Bt=jn(e,ut,!0,r.unit=="rectangle");if(!Bt)return;if(xt(Bt,he)!=0){e.curOp.focus=k(),xe(Bt);var Ot=Vi(i,_);(Bt.line>=Ot.to||Bt.line<Ot.from)&&setTimeout(Ur(e,function(){Oe==_t&&ze(ut)}),150)}else{var Yt=ut.clientY<ye.top?-20:ut.clientY>ye.bottom?20:0;Yt&&setTimeout(Ur(e,function(){if(Oe!=_t)return;i.scroller.scrollTop+=Yt,ze(ut)}),50)}}function $e(ut){e.state.selectingText=!1,Oe=Infinity,ut&&(ee(ut),i.input.focus()),dt(i.wrapper.ownerDocument,"mousemove",lt),dt(i.wrapper.ownerDocument,"mouseup",yt),_.history.lastSelOrigin=null}var lt=Ur(e,function(ut){ut.buttons===0||!Se(ut)?$e(ut):ze(ut)}),yt=Ur(e,$e);e.state.selectingText=yt,Ae(i.wrapper.ownerDocument,"mousemove",lt),Ae(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 _=at(i);if(!_)return t;var B=nt(_,n.ch,n.sticky),K=_[B];if(K.from!=n.ch&&K.to!=n.ch)return t;var Y=B+(K.from==n.ch==(K.level!=1)?0:1);if(Y==0||Y==_.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=nt(_,r.ch,r.sticky),he=le-B||(r.ch-n.ch)*(K.level==1?-1:1);le==Y-1||le==Y?Z=he<0:Z=he>0}var xe=_[Y+(Z?-1:0)],ye=Z==(xe.level==1),Oe=ye?xe.from:xe.to,ze=ye?"after":"before";return n.ch==Oe&&n.sticky==ze?t:new dr(new Ie(n.line,Oe,ze),r)}function bs(e,t,n,r){var i,_;if(t.touches)i=t.touches[0].clientX,_=t.touches[0].clientY;else try{i=t.clientX,_=t.clientY}catch(xe){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ee(t);var B=e.display,K=B.lineDiv.getBoundingClientRect();if(_>K.bottom||!de(e,n))return ie(t);_-=K.top-B.viewOffset;for(var Y=0;Y<e.display.gutterSpecs.length;++Y){var Z=B.gutters.childNodes[Y];if(Z&&Z.getBoundingClientRect().right>=i){var le=Tr(e.doc,_),he=e.display.gutterSpecs[Y];return De(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(We(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,_,B){e.defaults[r]=i,_&&(t[r]=B?function(K,Y,Z){Z!=li&&_(K,Y,Z)}:_)}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,ka(r)},!0),n("indentUnit",2,ka,!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 _=[],B=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,_.push(Ie(B,le))}B++});for(var K=_.length-1;K>=0;K--)ii(r.doc,i,_[K],Ie(_[K].line,_[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,_){r.state.specialChars=new RegExp(i.source+(i.test(" ")?"":"| "),"g"),_!=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",!C),n("wholeLineUpdateBefore",!0),n("theme","default",function(r){xs(r),Ti(r)},!0),n("keyMap","default",function(r,i,_){var B=na(i),K=_!=li&&na(_);K&&K.detach&&K.detach(r,B),B.attach&&B.attach(r,K||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Ql,!0),n("gutters",[],function(r,i){r.display.gutterSpecs=Da(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=Da(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,_=t?Ae:dt;_(e.display.scroller,"dragstart",i.start),_(e.display.scroller,"dragenter",i.enter),_(e.display.scroller,"dragover",i.over),_(e.display.scroller,"dragleave",i.leave),_(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),_=this.display=new dl(e,r,i,t);_.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&&_.input.focus(),z&&j<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 B in aa)aa.hasOwnProperty(B)&&aa[B](this,t[B],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(_.lineDiv).textRendering=="optimizelegibility"&&(_.lineDiv.style.textRendering="auto")}Er.defaults=Ss,Er.optionHandlers=aa;function Zl(e){var t=e.display;Ae(t.scroller,"mousedown",Ur(e,vs)),z&&j<11?Ae(t.scroller,"dblclick",Ur(e,function(Y){if(We(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)})):Ae(t.scroller,"dblclick",function(Y){return We(e,Y)||ee(Y)}),Ae(t.scroller,"contextmenu",function(Y){return Es(e,Y)}),Ae(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 _(Y){if(Y.touches.length!=1)return!1;var Z=Y.touches[0];return Z.radiusX<=1&&Z.radiusY<=1}function B(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}Ae(t.scroller,"touchstart",function(Y){if(!We(e,Y)&&!_(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)}}),Ae(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ae(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||B(Z,Z.prev)?he=new dr(le,le):!Z.prev.prev||B(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()}),Ae(t.scroller,"touchcancel",i),Ae(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xi(e,t.scroller.scrollTop),Hn(e,t.scroller.scrollLeft,!0),De(e,"scroll",e))}),Ae(t.scroller,"mousewheel",function(Y){return Do(e,Y)}),Ae(t.scroller,"DOMMouseScroll",function(Y){return Do(e,Y)}),Ae(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(Y){We(e,Y)||se(Y)},over:function(Y){We(e,Y)||(Ll(e,Y),se(Y))},start:function(Y){return Al(e,Y)},drop:Ur(e,wl),leave:function(Y){We(e,Y)||is(e)}};var K=t.input.getField();Ae(K,"keyup",function(Y){return ms.call(e,Y)}),Ae(K,"keydown",Ur(e,ps)),Ae(K,"keypress",Ur(e,gs)),Ae(K,"focus",function(Y){return Ca(e,Y)}),Ae(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,_;n==null&&(n="add"),n=="smart"&&(i.mode.indent?_=rt(e,t).state:n="prev");var B=e.options.tabSize,K=Fe(i,t),Y=q(K.text,null,B);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(_,K.text.slice(Z.length),K.text),le==ke||le>150)){if(!r)return;n="prev"}n=="prev"?t>i.first?le=q(Fe(i,t-1).text,null,B):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/B);ye;--ye)xe+=B,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 ze=i.sel.ranges[Oe];if(ze.head.line==t&&ze.head.ch<Z.length){var $e=Ie(t,Z.length);Na(i,Oe,new dr($e,$e));break}}}var gn=null;function oa(e){gn=e}function Ga(e,t,n,r,i){var _=e.doc;e.display.shift=!1,r||(r=_.sel);var B=+new Date-200,K=i=="paste"||e.state.pasteIncoming>B,Y=et(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(_.splitLines(gn.text[le]))}}else Y.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Z=tt(Y,function(lt){return[lt]}));for(var he=e.curOp.updateInput,xe=r.ranges.length-1;xe>=0;xe--){var ye=r.ranges[xe],Oe=ye.from(),ze=ye.to();ye.empty()&&(n&&n>0?Oe=Ie(Oe.line,Oe.ch-n):e.state.overwrite&&!K?ze=Ie(ze.line,Math.min(Fe(_,ze.line).text.length,ze.ch+we(Y).length)):K&&gn&&gn.lineWise&&gn.text.join(`
|
|
`)==Y.join(`
|
|
`)&&(Oe=ze=Ie(Oe.line,0)));var $e={from:Oe,to:ze,text:Z?Z[xe%Z.length]:Y,origin:i||(K?"paste":e.state.cutIncoming>B?"cut":"+input")};ni(e.doc,$e),Hr(e,"inputRead",e,$e)}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 _=e.getModeAt(i.head),B=!1;if(_.electricChars){for(var K=0;K<_.electricChars.length;K++)if(t.indexOf(_.electricChars.charAt(K))>-1){B=Fi(e,i.head.line,"smart");break}}else _.electricInput&&(_.electricInput.test(Fe(e.doc,i.head.line).text.slice(0,i.head.ch))&&(B=Fi(e,i.head.line,"smart")));B&&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,_={anchor:Ie(i,0),head:Ie(i+1,0)};n.push(_),t.push(e.getRange(_.anchor,_.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"),w&&(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 _=this.options,B=_[r];if(_[r]==i&&r!="mode")return;_[r]=i,t.hasOwnProperty(r)&&Ur(this,t[r])(this,i,B),De(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,_=0;_<i.length;++_)if(i[_]==r||i[_].name==r)return i.splice(_,1),!0},addOverlay:$r(function(r,i){var _=r.token?r:e.getMode(this.options,r);if(_.startState)throw new Error("Overlays may not be stateful.");Ye(this.state.overlays,{mode:_,modeSpec:r,opaque:i&&i.opaque,priority:i&&i.priority||0},function(B){return B.priority}),this.state.modeGen++,qr(this)}),removeOverlay:$r(function(r){for(var i=this.state.overlays,_=0;_<i.length;++_){var B=i[_].modeSpec;if(B==r||typeof r=="string"&&B.name==r){i.splice(_,1),this.state.modeGen++,qr(this);return}}}),indentLine:$r(function(r,i,_){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,_)}),indentSelection:$r(function(r){for(var i=this.doc.sel.ranges,_=-1,B=0;B<i.length;B++){var K=i[B];if(K.empty())K.head.line>_&&(Fi(this,K.head.line,r,!0),_=K.head.line,B==this.doc.sel.primIndex&&qn(this));else{var Y=K.from(),Z=K.to(),le=Math.max(_,Y.line);_=Math.min(this.lastLine(),Z.line-(Z.ch?0:1))+1;for(var he=le;he<_;++he)Fi(this,he,r);var xe=this.doc.sel.ranges;Y.ch==0&&i.length==xe.length&&xe[B].from().ch>0&&Na(this.doc,B,new dr(Y,xe[B].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)),_=0,B=(i.length-1)/2,K=r.ch,Y;if(K==0)Y=i[2];else for(;;){var Z=_+B>>1;if((Z?i[Z*2-1]:0)>=K)B=Z;else if(i[Z*2+1]<K)_=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 _=[];if(!n.hasOwnProperty(i))return _;var B=n[i],K=this.getModeAt(r);if(typeof K[i]=="string")B[K[i]]&&_.push(B[K[i]]);else if(K[i])for(var Y=0;Y<K[i].length;Y++){var Z=B[K[i][Y]];Z&&_.push(Z)}else K.helperType&&B[K.helperType]?_.push(B[K.helperType]):B[K.name]&&_.push(B[K.name]);for(var le=0;le<B._global.length;le++){var he=B._global[le];he.pred(K,this)&&fe(_,he.val)==-1&&_.push(he.val)}return _},getStateAfter:function(r,i){var _=this.doc;return r=U(_,r==null?_.first+_.size-1:r),rt(this,r+1,i).state},cursorCoords:function(r,i){var _,B=this.doc.sel.primary();return r==null?_=B.head:typeof r=="object"?_=u(this.doc,r):_=r?B.from():B.to(),pn(this,_,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,_){var B=!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,B=!0),K=Fe(this.doc,r)}else K=r;return Hi(this,K,{top:0,left:0},i||"page",_||B).top+(B?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,_,B,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),B=="over")Z=r.top;else if(B=="above"||B=="near"){var he=Math.max(Y.wrapper.clientHeight,this.doc.height),xe=Math.max(Y.sizer.clientWidth,Y.lineSpace.clientWidth);(B=="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"),_&&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,_,B){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,_,B),Y.hitSide);++Z);return Y},moveH:$r(function(r,i){var _=this;this.extendSelectionsBy(function(B){return _.display.shift||_.doc.extend||B.empty()?Ka(_.doc,B.head,r,i,_.options.rtlMoveVisually):r<0?B.from():B.to()},Te)}),deleteH:$r(function(r,i){var _=this.doc.sel,B=this.doc;_.somethingSelected()?B.replaceSelection("",null,"+delete"):si(this,function(K){var Y=Ka(B,K.head,r,i,!1);return r<0?{from:Y,to:K.head}:{from:K.head,to:Y}})}),findPosV:function(r,i,_,B){var K=1,Y=B;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,_),Z.hitSide)break}return Z},moveV:$r(function(r,i){var _=this,B=this.doc,K=[],Y=!this.display.shift&&!B.extend&&B.sel.somethingSelected();if(B.extendSelectionsBy(function(le){if(Y)return r<0?le.from():le.to();var he=pn(_,le.head,"div");le.goalColumn!=null&&(he.left=le.goalColumn),K.push(he.left);var xe=Ls(_,he,r,i);return i=="page"&&le==B.sel.primary()&&Ta(_,ma(_,xe,"div").top-he.top),xe},Te),K.length)for(var Z=0;Z<B.sel.ranges.length;Z++)B.sel.ranges[Z].goalColumn=K[Z]}),findWordAt:function(r){var i=this.doc,_=Fe(i,r.line).text,B=r.ch,K=r.ch;if(_){var Y=this.getHelper(r,"wordChars");(r.sticky=="before"||K==_.length)&&B?--B:++K;for(var Z=_.charAt(B),le=He(Z,Y)?function(he){return He(he,Y)}:/\s/.test(Z)?function(he){return/\s/.test(he)}:function(he){return!/\s/.test(he)&&!He(he)};B>0&&le(_.charAt(B-1));)--B;for(;K<_.length&&le(_.charAt(K));)++K}return new dr(Ie(r.line,B),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"),De(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==k()},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 _=this,B=function(Y){return typeof Y=="number"||/^\d+$/.test(String(Y))?Y+"px":Y};r!=null&&(this.display.wrapper.style.width=B(r)),i!=null&&(this.display.wrapper.style.height=B(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(_,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,De(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),De(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,_){n.hasOwnProperty(r)||(n[r]=e[r]={_global:[]}),n[r][i]=_},e.registerGlobalHelper=function(r,i,_,B){e.registerHelper(r,i,B),n[r]._global.push({pred:_,val:B})}}function Ka(e,t,n,r,i){var _=t,B=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 ut;if(r=="codepoint"){var _t=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(_t)?ut=null:ut=new Ie(t.line,Math.max(0,Math.min(K.text.length,t.ch+n*(_t>=55296&&_t<56320?2:1))),-n)}else i?ut=Ml(e.cm,K,t,n):ut=Ba(K,t,n);if(ut==null)if(!yt&&Z())t=Fa(i,e.cm,K,t.line,Y);else return!1;else t=ut;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 ze=K.text.charAt(t.ch)||`
|
|
`,$e=He(ze,ye)?"w":xe&&ze==`
|
|
`?"n":!xe||/\s/.test(ze)?null:"p";if(xe&&!Oe&&!$e&&($e="s"),he&&he!=$e){n<0&&(n=1,le(),t.sticky="after");break}if($e&&(he=$e),n>0&&!le(!Oe))break}var lt=ea(e,t,_,B,!0);return Pr(_,lt)&&(lt.hitSide=!0),lt}function Ls(e,t,n,r){var i=e.doc,_=t.left,B;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);B=(n>0?t.bottom:t.top)+n*Y}else r=="line"&&(B=n>0?t.bottom+3:t.top-3);for(var Z;!(Z=va(e,_,B),!Z.outside);){if(n<0?B<=0:B>=i.height){Z.hitSide=!0;break}B+=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 _(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}Ae(i,"paste",function(K){if(!_(K)||We(r,K)||Cs(K,r))return;j<=11&&setTimeout(Ur(r,function(){return t.updateFromDOM()}),20)}),Ae(i,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),Ae(i,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),Ae(i,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ae(i,"touchstart",function(){return n.forceCompositionEnd()}),Ae(i,"input",function(){t.composing||t.readFromDOMSoon()});function B(K){if(!_(K)||We(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)}Ae(i,"copy",B),Ae(i,"cut",B)},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 _=sa(t,e.anchorNode,e.anchorOffset),B=sa(t,e.focusNode,e.focusOffset);if(_&&!_.bad&&B&&!B.bad&&xt(xr(_,B),r)==0&&xt(dn(_,B),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 x(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,Pn(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 _,B,K;r.line==t.viewFrom||(_=Wn(e,r.line))==0?(B=Wt(t.view[0].line),K=t.view[0].node):(B=Wt(t.view[_].line),K=t.view[_-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,B,Z)),xe=nr(e.doc,Ie(B,0),Ie(Z,Fe(e.doc,Z).text.length));he.length>1&&xe.length>1;)if(we(he)==we(xe))he.pop(),xe.pop(),Z--;else if(he[0]==xe[0])he.shift(),xe.shift(),B++;else break;for(var ye=0,Oe=0,ze=he[0],$e=xe[0],lt=Math.min(ze.length,$e.length);ye<lt&&ze.charCodeAt(ye)==$e.charCodeAt(ye);)++ye;for(var yt=we(he),ut=we(xe),_t=Math.min(yt.length-(he.length==1?ye:0),ut.length-(xe.length==1?ye:0));Oe<_t&&yt.charCodeAt(yt.length-Oe-1)==ut.charCodeAt(ut.length-Oe-1);)++Oe;if(he.length==1&&xe.length==1&&B==r.line)for(;ye&&ye>r.ch&&yt.charCodeAt(yt.length-Oe-1)==ut.charCodeAt(ut.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(B,ye),Ot=Ie(Z,xe.length?we(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),_=at(r,e.doc.direction),B="left";if(_){var K=nt(_,t.ch);B=K%2?"right":"left"}var Y=no(i.map,t.ch,B);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 _="",B=!1,K=e.doc.lineSeparator(),Y=!1;function Z(ye){return function(Oe){return Oe.id==ye}}function le(){B&&(_+=K,Y&&(_+=K),B=Y=!1)}function he(ye){ye&&(le(),_+=ye)}function xe(ye){if(ye.nodeType==1){var Oe=ye.getAttribute("cm-text");if(Oe){he(Oe);return}var ze=ye.getAttribute("cm-marker"),$e;if(ze){var lt=e.findMarks(Ie(r,0),Ie(i+1,0),Z(+ze));lt.length&&($e=lt[0].find(0))&&he(nr(e.doc,$e.from,$e.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 ut=0;ut<ye.childNodes.length;ut++)xe(ye.childNodes[ut]);/^(pre|p)$/i.test(ye.nodeName)&&(Y=!0),yt&&(B=!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 _}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 _=e.display.view[i];if(_.node==r)return ru(_,t,n)}}function ru(e,t,n){var r=e.text.firstChild,i=!1;if(!t||!x(r,t))return ui(Ie(Wt(e.line),0),!0);if(t==r&&(i=!0,t=r.childNodes[n],n=0,!t)){var _=e.rest?we(e.rest):e.line;return ui(Ie(Wt(_),_.text.length),i)}var B=t.nodeType==3?t:null,K=t;for(!B&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(B=t.firstChild,n&&(n=B.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var Y=e.measure,Z=Y.maps;function le($e,lt,yt){for(var ut=-1;ut<(Z?Z.length:0);ut++)for(var _t=ut<0?Y.map:Z[ut],Bt=0;Bt<_t.length;Bt+=3){var Ot=_t[Bt+2];if(Ot==$e||Ot==lt){var Yt=Wt(ut<0?e.line:e.rest[ut]),yr=_t[Bt]+yt;return(yt<0||Ot!=$e)&&(yr=_t[Bt+(yt?1:0)]),Ie(Yt,yr)}}}var he=le(B,K,n);if(he)return ui(he,i);for(var xe=K.nextSibling,ye=B?B.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,ze=n;Oe;Oe=Oe.previousSibling){if(he=le(Oe,Oe.firstChild,-1),he)return ui(Ie(he.line,he.ch+ze),i);ze+=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),w&&(i.style.width="0px"),Ae(i,"input",function(){z&&j>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),Ae(i,"paste",function(B){if(We(r,B)||Cs(B,r))return;r.state.pasteIncoming=+new Date,n.fastPoll()});function _(B){if(We(r,B))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}),B.type=="cut"?r.setSelections(K.ranges,null,Ee):(n.prevInput="",i.value=K.text.join(`
|
|
`),Q(i))}else return;B.type=="cut"&&(r.state.cutIncoming=+new Date)}Ae(i,"cut",_),Ae(i,"copy",_),Ae(e.scroller,"paste",function(B){if(_n(e,B)||We(r,B))return;if(!i.dispatchEvent){r.state.pasteIncoming=+new Date,n.focus();return}var K=new Event("paste");K.clipboardData=B.clipboardData,i.dispatchEvent(K)}),Ae(e.lineSpace,"selectstart",function(B){_n(e,B)||ee(B)}),Ae(i,"compositionstart",function(){var B=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:B,range:r.markText(B,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ae(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"),_=t.wrapper.getBoundingClientRect(),B=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+B.top-_.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+B.left-_.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&&j>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",z&&j>=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||k()!=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||ct(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&&j>=9&&this.hasSelection===i||d&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var _=i.charCodeAt(0);if(_==8203&&!r&&(r="\u200B"),_==8666)return this.reset(),this.cm.execCommand("undo")}for(var B=0,K=Math.min(r.length,i.length);B<K&&r.charCodeAt(B)==i.charCodeAt(B);)++B;return an(t,function(){Ga(t,i.slice(B),r.length-B,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&&j>=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 _=jn(n,e),B=r.scroller.scrollTop;if(!_||L)return;var K=n.options.resetSelectionOnContextMenu;K&&n.doc.sel.contains(_)==-1&&Ur(n,Vr)(n.doc,Pn(_),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 ze=n.somethingSelected(),$e="\u200B"+(ze?i.value:"");i.value="\u21DA",i.value=$e,t.prevInput=ze?"":"\u200B",i.selectionStart=1,i.selectionEnd=$e.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&&j<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=B),i.selectionStart!=null){(!z||z&&j<9)&&xe();var ze=0,$e=function(){r.selForContextMenu==n.doc.sel&&i.selectionStart==0&&i.selectionEnd>0&&t.prevInput=="\u200B"?Ur(n,Xo)(n):ze++<10?r.detectingSelectAll=setTimeout($e,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout($e,200)}}if(z&&j>=9&&xe(),l){se(e);var Oe=function(){dt(window,"mouseup",Oe),setTimeout(ye,20)};Ae(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=k();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function r(){e.value=K.getValue()}var i;if(e.form&&(Ae(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var _=e.form;i=_.submit;try{var B=_.submit=function(){r(),_.submit=i,_.submit(),_.submit=B}}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&&(dt(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=dt,e.on=Ae,e.wheelEventPixels=cl,e.Doc=en,e.splitLines=et,e.countColumn=q,e.findColumn=Ce,e.isWordChar=Me,e.Pass=ke,e.signal=De,e.Line=Un,e.changeEnd=kn,e.scrollbarModel=Co,e.Pos=Ie,e.cmpPos=xt,e.modes=$t,e.mimeModes=Lt,e.resolveMode=pt,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=it,e.SharedTextMarker=ki,e.TextMarker=Mn,e.LineWidget=Pi,e.e_preventDefault=ee,e.e_stopPropagation=te,e.e_stop=se,e.addClass=H,e.contains=x,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,ft,re){"use strict";re.r(ft),re.d(ft,"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"),j=re("rePB"),O=re("Zm9Q"),P=re("Kwbf"),E=re("c+Xe"),L=re("m+aA"),D=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 w=new D.default(A),h=null,o=null;function d(Ee,_e){T.has(Ee)||(T.set(Ee,new Set),w.observe(Ee)),T.get(Ee).add(_e)}function c(Ee,_e){T.has(Ee)&&(T.get(Ee).delete(_e),T.get(Ee).size||(w.unobserve(Ee),T.delete(Ee)))}var C=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),we=I.useCallback(function(tt,Ye,Xe){Ce.current+=1;var Ve=Ce.current;me.current.push({size:tt,element:Ye,data:Xe}),Promise.resolve().then(function(){Ve===Ce.current&&(Te==null||Te(me.current),me.current=[])}),ne==null||ne(tt,Ye,Xe)},[Te,ne]);return I.createElement(y.Provider,{value:we},_e)}function l(Ee){var _e=Ee.children,Te=Ee.disabled,Ce=I.useRef(null),me=I.useRef(null),ne=I.useContext(y),we=I.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),tt=I.isValidElement(_e)&&Object(E.c)(_e),Ye=tt?_e.ref:null,Xe=I.useMemo(function(){return Object(E.a)(Ye,Ce)},[Ye,Ce]),Ve=I.useRef(Ee);Ve.current=Ee;var Le=I.useCallback(function(Me){var He=Ve.current,Ge=He.onResize,je=He.data,Ue=Me.getBoundingClientRect(),Re=Ue.width,st=Ue.height,Je=Me.offsetWidth,Qe=Me.offsetHeight,nt=Math.floor(Re),bt=Math.floor(st);if(we.current.width!==nt||we.current.height!==bt||we.current.offsetWidth!==Je||we.current.offsetHeight!==Qe){var at={width:nt,height:bt,offsetWidth:Je,offsetHeight:Qe};we.current=at;var ht=Je===Math.round(Re)?Re:Je,Ae=Qe===Math.round(st)?st:Qe,gt=Object(z.a)(Object(z.a)({},at),{},{offsetWidth:ht,offsetHeight:Ae});ne==null||ne(gt,Me,je),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&&d(Me,Le),function(){return c(Me,Le)}},[Ce.current,Te]),I.createElement(C,{ref:me},tt?I.cloneElement(_e,{ref:Xe}):_e)}var S="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(S,"-").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
|
|
`,x=["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"],k={},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&&k[Te])return k[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")),we=parseFloat(Ce.getPropertyValue("border-bottom-width"))+parseFloat(Ce.getPropertyValue("border-top-width")),tt=x.map(function(Xe){return"".concat(Xe,":").concat(Ce.getPropertyValue(Xe))}).join(";"),Ye={sizingStyle:tt,paddingSize:ne,borderSize:we,boxSizing:me};return _e&&Te&&(k[Te]=Ye),Ye}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,we=me.borderSize,tt=me.boxSizing,Ye=me.sizingStyle;H.setAttribute("style","".concat(Ye,";").concat(v)),H.value=Ee.value||Ee.placeholder||"";var Xe=Number.MIN_SAFE_INTEGER,Ve=Number.MAX_SAFE_INTEGER,Le=H.scrollHeight,Me;if(tt==="border-box"?Le+=we:tt==="content-box"&&(Le-=ne),Te!==null||Ce!==null){H.value=" ";var He=H.scrollHeight-ne;Te!==null&&(Xe=He*Te,tt==="border-box"&&(Xe=Xe+ne+we),Le=Math.max(Xe,Le)),Ce!==null&&(Ve=He*Ce,tt==="border-box"&&(Ve=Ve+ne+we),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 we=me.state.resizeStatus,tt=me.props,Ye=tt.autoSize,Xe=tt.onResize;if(we!==q.NONE)return;typeof Xe=="function"&&Xe(ne),Ye&&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 we=ne.minRows,tt=ne.maxRows,Ye=Q(me.textArea,!1,we,tt);me.setState({textareaStyles:Ye,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,we=ne.prefixCls,tt=we===void 0?"rc-textarea":we,Ye=ne.autoSize,Xe=ne.onResize,Ve=ne.className,Le=ne.disabled,Me=me.state,He=Me.textareaStyles,Ge=Me.resizeStatus,je=Object(s.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Ue=b()(tt,Ve,Object(j.a)({},"".concat(tt,"-disabled"),Le));"value"in je&&(je.value=je.value||"");var Re=Object(z.a)(Object(z.a)(Object(z.a)({},me.props.style),He),Ge===q.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return I.createElement(p,{onResize:me.handleResize,disabled:!(Ye||Xe)},I.createElement("textarea",Object(ae.a)({},je,{className:Ue,style:Re,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(we){}}},{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(we){me.resizableTextArea=we},me.handleChange=function(we){var tt=me.props.onChange;me.setValue(we.target.value,function(){me.resizableTextArea.resizeTextarea()}),tt&&tt(we)},me.handleKeyDown=function(we){var tt=me.props,Ye=tt.onPressEnter,Xe=tt.onKeyDown;we.keyCode===13&&Ye&&Ye(we),Xe&&Xe(we)};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),ke=ft.default=ve},ZWs3:function(At,ft,re){"use strict";re.d(ft,"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"),j=re.n(z),O=re("q1tI"),P=re.n(O),E=function(D){var T=D.children,A=Object(I.a)(D,["children"]),w=Object(O.useState)(!1),h=Object(N.a)(w,2),o=h[0],d=h[1];return P.a.createElement($.a,Object(R.a)({},A,{loading:o,onClick:function(){var c=Object(X.a)(j.a.mark(function C(y){return j.a.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,d(!0),l.next=4,A.onClick(y);case 4:d(!1),l.next=10;break;case 7:l.prev=7,l.t0=l.catch(0),d(!1);case 10:case"end":return l.stop()}},C,null,[[0,7]])}));return function(C){return c.apply(this,arguments)}}()}),T)}},ZpRC:function(At,ft,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 D=getComputedStyle(E,null);return $(D.overflowY,L)||$(D.overflowX,L)||function(T){var A=function(w){if(!w.ownerDocument||!w.ownerDocument.defaultView)return null;try{return w.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,D,T,A,w,h,o){return w<E&&h>L||w>E&&h<L?0:w<=E&&o<=D||h>=L&&o>=D?w-E-T:h>L&&o<D||w<E&&o>D?h-L+A:0}var N=function(E,L){var D=window,T=L.scrollMode,A=L.block,w=L.inline,h=L.boundary,o=L.skipOverflowHiddenElements,d=typeof h=="function"?h:function(He){return He!==h};if(!ae(E))throw new TypeError("Invalid target");for(var c=document.scrollingElement||document.documentElement,C=[],y=E;ae(y)&&d(y);){if((y=y.parentElement)===c){C.push(y);break}y!=null&&y===document.body&&R(y)&&!R(document.documentElement)||y!=null&&R(y,o)&&C.push(y)}for(var m=D.visualViewport?D.visualViewport.width:innerWidth,l=D.visualViewport?D.visualViewport.height:innerHeight,S=window.scrollX||pageXOffset,f=window.scrollY||pageYOffset,p=E.getBoundingClientRect(),s=p.height,a=p.width,b=p.top,v=p.right,x=p.bottom,k=p.left,H=A==="start"||A==="nearest"?b:A==="end"?x:b+s/2,V=w==="center"?k+a/2:w==="end"?v:k,Q=[],G=0;G<C.length;G++){var W=C[G],q=W.getBoundingClientRect(),oe=q.height,fe=q.width,ve=q.top,ke=q.right,Ee=q.bottom,_e=q.left;if(T==="if-needed"&&b>=0&&k>=0&&x<=l&&v<=m&&b>=ve&&x<=Ee&&k>=_e&&v<=ke)return Q;var Te=getComputedStyle(W),Ce=parseInt(Te.borderLeftWidth,10),me=parseInt(Te.borderTopWidth,10),ne=parseInt(Te.borderRightWidth,10),we=parseInt(Te.borderBottomWidth,10),tt=0,Ye=0,Xe="offsetWidth"in W?W.offsetWidth-W.clientWidth-Ce-ne:0,Ve="offsetHeight"in W?W.offsetHeight-W.clientHeight-me-we:0;if(c===W)tt=A==="start"?H:A==="end"?H-l:A==="nearest"?X(f,f+l,l,me,we,f+H,f+H+s,s):H-l/2,Ye=w==="start"?V:w==="center"?V-m/2:w==="end"?V-m:X(S,S+m,m,Ce,ne,S+V,S+V+a,a),tt=Math.max(0,tt+f),Ye=Math.max(0,Ye+S);else{tt=A==="start"?H-ve-me:A==="end"?H-Ee+we+Ve:A==="nearest"?X(ve,Ee,oe,me,we+Ve,H,H+s,s):H-(ve+oe/2)+Ve/2,Ye=w==="start"?V-_e-Ce:w==="center"?V-(_e+fe/2)+Xe/2:w==="end"?V-ke+ne+Xe:X(_e,ke,fe,Ce,ne+Xe,V,V+a,a);var Le=W.scrollLeft,Me=W.scrollTop;H+=Me-(tt=Math.max(0,Math.min(Me+tt,W.scrollHeight-oe+Ve))),V+=Le-(Ye=Math.max(0,Math.min(Le+Ye,W.scrollWidth-fe+Xe)))}Q.push({el:W,top:tt,left:Ye})}return Q};function I(E){return E===Object(E)&&Object.keys(E).length!==0}function z(E,L){L===void 0&&(L="auto");var D="scrollBehavior"in document.body.style;E.forEach(function(T){var A=T.el,w=T.top,h=T.left;A.scroll&&D?A.scroll({top:w,left:h,behavior:L}):(A.scrollTop=w,A.scrollLeft=h)})}function j(E){return E===!1?{block:"end",inline:"nearest"}:I(E)?E:{block:"start",inline:"nearest"}}function O(E,L){var D=!E.ownerDocument.documentElement.contains(E);if(I(L)&&typeof L.behavior=="function")return L.behavior(D?[]:N(E,L));if(D)return;var T=j(L);return z(N(E,T),T.behavior)}var P=ft.a=O},bT9E:function(At,ft,re){"use strict";re.d(ft,"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,ft,re){},dejd:function(At,ft,re){},dmUQ:function(At,ft,re){"use strict";var ae=re("Ff2n"),$=re("rePB"),R=re("1OyB"),X=re("vuIU"),N=re("Ji7U"),I=re("md7G"),z=re("foSv"),j=re("q1tI"),O=re.n(j),P=re("TSYQ"),E=re.n(P),L=re("4IlW");function D(s,a){var b=Object.keys(s);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(s);a&&(v=v.filter(function(x){return Object.getOwnPropertyDescriptor(s,x).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?D(Object(b),!0).forEach(function(v){Object($.a)(s,v,b[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(b)):D(Object(b)).forEach(function(v){Object.defineProperty(s,v,Object.getOwnPropertyDescriptor(b,v))})}return s}function A(s){var a=w();return function(){var v=Object(z.a)(s),x;if(a){var k=Object(z.a)(this).constructor;x=Reflect.construct(v,arguments,k)}else x=v.apply(this,arguments);return Object(I.a)(this,x)}}function w(){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 d=function(a){return a.replace(/[^\w.-]+/g,"")},c=200,C=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)},S=function(s){Object(N.a)(b,s);var a=A(b);function b(v){var x;Object(R.a)(this,b),x=a.call(this,v),x.onKeyDown=function(V){var Q=x.props,G=Q.onKeyDown,W=Q.onPressEnter;if(V.keyCode===L.a.UP){var q=x.getRatio(V);x.up(V,q,null),x.stop()}else if(V.keyCode===L.a.DOWN){var oe=x.getRatio(V);x.down(V,oe,null),x.stop()}else V.keyCode===L.a.ENTER&&W&&W(V);if(x.recordCursorPosition(),x.lastKeyCode=V.keyCode,G){for(var fe=arguments.length,ve=new Array(fe>1?fe-1:0),ke=1;ke<fe;ke++)ve[ke-1]=arguments[ke];G.apply(void 0,[V].concat(ve))}},x.onKeyUp=function(V){var Q=x.props.onKeyUp;if(x.stop(),x.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))}},x.onChange=function(V){var Q=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent(V)),x.setState({inputValue:x.rawInput}),Q(x.toNumber(x.rawInput))},x.onMouseUp=function(){var V=x.props.onMouseUp;x.recordCursorPosition(),V&&V.apply(void 0,arguments)},x.onFocus=function(){var V;x.setState({focused:!0}),(V=x.props).onFocus.apply(V,arguments)},x.onBlur=function(){var V=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var Q=x.getCurrentValidValue(x.state.inputValue),G=x.setValue(Q,h);if(V){var W=x.input.value,q=x.getInputDisplayValue({focus:!1,value:G});x.input.value=q&&Number(q),V.apply(void 0,arguments),x.input.value=W}},x.getRatio=function(V){var Q=1;return V.metaKey||V.ctrlKey?Q=.1:V.shiftKey&&(Q=10),Q},x.getFullNum=function(V){return isNaN(V)?V:/e/i.test(String(V))?Number(V).toFixed(18).replace(/\.?0+$/,""):V},x.getPrecision=function(V){if(m(x.props.precision))return x.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},x.getInputDisplayValue=function(V){var Q=V||x.state,G=Q.focused,W=Q.inputValue,q=Q.value,oe;G?oe=W:oe=x.toPrecisionAsStep(q),oe==null&&(oe="");var fe=x.formatWrapper(oe);return m(x.props.decimalSeparator)&&(fe=fe.toString().replace(".",x.props.decimalSeparator)),fe},x.recordCursorPosition=function(){try{x.cursorStart=x.input.selectionStart,x.cursorEnd=x.input.selectionEnd,x.currentValue=x.input.value,x.cursorBefore=x.input.value.substring(0,x.cursorStart),x.cursorAfter=x.input.value.substring(x.cursorEnd)}catch(V){}},x.restoreByAfter=function(V){if(V===void 0)return!1;var Q=x.input.value,G=Q.lastIndexOf(V);if(G===-1)return!1;var W=x.cursorBefore.length;return x.lastKeyCode===L.a.DELETE&&x.cursorBefore.charAt(W-1)===V[0]?(x.fixCaret(W,W),!0):G+V.length===Q.length?(x.fixCaret(G,G),!0):!1},x.partRestoreByAfter=function(V){return V===void 0?!1:Array.prototype.some.call(V,function(Q,G){var W=V.substring(G);return x.restoreByAfter(W)})},x.isNotCompleteNumber=function(V){return isNaN(V)||V===""||V===null||V&&V.toString().indexOf(".")===V.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function(V,Q,G){x.pressingUpOrDown=!0,x.step("down",V,Q,G)},x.up=function(V,Q,G){x.pressingUpOrDown=!0,x.step("up",V,Q,G)},x.saveInput=function(V){x.input=V};var k=v.value;k===void 0&&(k=v.defaultValue),x.state={focused:v.autoFocus};var H=x.getValidValue(x.toNumber(k));return x.state=T(T({},x.state),{},{inputValue:x.toPrecisionAsStep(H),value:H}),x}return Object(X.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var k=this.props,H=k.value,V=k.onChange,Q=k.max,G=k.min,W=this.state.focused;if(x){if(!l(x.value,H)||!l(x.max,Q)||!l(x.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&&x.max!==Q&&typeof fe=="number"&&fe>Q&&V&&V(Q),"min"in this.props&&x.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(ke){}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(x){var k=x;return k===""?k="":this.isNotCompleteNumber(parseFloat(k))?k=this.state.value:k=this.getValidValue(k),this.toNumber(k)}},{key:"getValueFromEvent",value:function(x){var k=x.target.value.trim().replace(/。/g,".");return m(this.props.decimalSeparator)&&(k=k.replace(this.props.decimalSeparator,".")),k}},{key:"getValidValue",value:function(x){var k=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(x);return isNaN(V)?x:(V<k&&(V=k),V>H&&(V=H),V)}},{key:"setValue",value:function(x,k){var H=this.props.precision,V=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),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},k)):this.setState({value:V,inputValue:this.toPrecisionAsStep(x)},k),fe&&this.props.onChange(V),V}},{key:"getMaxPrecision",value:function(x){var k=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(k),W=this.getPrecision(Q),q=this.getPrecision(x);return x?Math.max(q,G+W):G+W}},{key:"getPrecisionFactor",value:function(x){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,H=this.getMaxPrecision(x,k);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(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var k=Math.abs(this.getMaxPrecision(x));return isNaN(k)?x.toString():Number(x).toFixed(k)}},{key:"toNumber",value:function(x){var k=this.props.precision,H=this.state.focused,V=x&&x.length>16&&H;return this.isNotCompleteNumber(x)||V?x:m(k)?Math.round(x*Math.pow(10,k))/Math.pow(10,k):Number(x)}},{key:"upStep",value:function(x,k){var H=this.props.step,V=this.getPrecisionFactor(x,k),Q=Math.abs(this.getMaxPrecision(x,k)),G=((V*x+V*H*k)/V).toFixed(Q);return this.toNumber(G)}},{key:"downStep",value:function(x,k){var H=this.props.step,V=this.getPrecisionFactor(x,k),Q=Math.abs(this.getMaxPrecision(x,k)),G=((V*x-V*H*k)/V).toFixed(Q);return this.toNumber(G)}},{key:"step",value:function(x,k){var H=this,V=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,Q=arguments.length>3?arguments[3]:void 0;this.stop(),k&&(k.persist(),k.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(x,"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[x](k,V,!0)},Q?c:C)}},{key:"fixCaret",value:function(x,k){if(x===void 0||k===void 0||!this.input||!this.input.value)return;try{var H=this.input.selectionStart,V=this.input.selectionEnd;(x!==H||k!==V)&&this.input.setSelectionRange(x,k)}catch(Q){}}},{key:"render",value:function(){var x,k=this.props,H=k.prefixCls,V=k.disabled,Q=k.readOnly,G=k.useTouch,W=k.autoComplete,q=k.upHandler,oe=k.downHandler,fe=k.className,ve=k.max,ke=k.min,Ee=k.style,_e=k.title,Te=k.onMouseEnter,Ce=k.onMouseLeave,me=k.onMouseOver,ne=k.onMouseOut,we=k.required,tt=k.onClick,Ye=k.tabIndex,Xe=k.type,Ve=k.placeholder,Le=k.id,Me=k.inputMode,He=k.pattern,Ge=k.step,je=k.maxLength,Ue=k.autoFocus,Re=k.name,st=k.onPaste,Je=k.onInput,Qe=Object(ae.a)(k,["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"]),nt=this.state,bt=nt.value,at=nt.focused,ht=E()(H,(x={},Object($.a)(x,fe,!!fe),Object($.a)(x,"".concat(H,"-disabled"),V),Object($.a)(x,"".concat(H,"-focused"),at),x)),Ae={};Object.keys(Qe).forEach(function(se){(se.substr(0,5)==="data-"||se.substr(0,5)==="aria-"||se==="role")&&(Ae[se]=Qe[se])});var gt=!Q&&!V,dt=this.getInputDisplayValue(null),De=(bt||bt===0)&&(isNaN(bt)||Number(bt)>=ve),We=(bt||bt===0)&&(isNaN(bt)||Number(bt)<=ke),ge=De||V||Q,de=We||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:ht,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":ke,"aria-valuemax":ve,"aria-valuenow":bt,required:we,type:Xe,placeholder:Ve,onPaste:st,onClick:tt,onMouseUp:this.onMouseUp,className:"".concat(H,"-input"),tabIndex:Ye,autoComplete:W,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:gt?this.onKeyDown:h,onKeyUp:gt?this.onKeyUp:h,autoFocus:Ue,maxLength:je,readOnly:Q,disabled:V,max:ve,min:ke,step:Ge,name:Re,title:_e,id:Le,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(dt),pattern:He,inputMode:Me,onInput:Je},Ae))))}}]),b}(O.a.Component);S.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:d,required:!1,autoComplete:"off"};var f=S,p=ft.a=f},kSUc:function(At,ft,re){},kqOp:function(At,ft,re){"use strict";re.d(ft,"a",function(){return P});var ae=re("0Owb"),$=re("fWQN"),R=re("mtLc"),X=re("yKVA"),N=re("879j"),I=re("q1tI"),z=re.n(I),j=re("Ot1p"),O="\u2581",P=function(E){Object(X.a)(D,E);var L=Object(N.a)(D);function D(){var T;Object($.a)(this,D);for(var A=arguments.length,w=new Array(A),h=0;h<A;h++)w[h]=arguments[h];return T=L.call.apply(L,[this].concat(w)),T.getChCountBeforeCursor=function(o,d){for(var c=d.line,C=0,y=0;y<c;y++)C+=o.getLine(y).split(O).length-1;var m=o.getLine(c).substring(0,d.ch);return C+=m.split(O).length-1,C},T.onCMBeforeChange=function(o,d){var c=o.getRange(d.from,d.to),C=0;if(d.text.forEach(function(S){C+=S.split(O).length-1}),c&&c.indexOf(O)!=-1){var y=c.split(O).length-1,m=T.getChCountBeforeCursor(o,d.from);console.log("\u5220\u9664".concat(y,"\u4E2A\uFF0C \u4E4B\u524D\u6709").concat(m,"\u4E2A\uFF0C\u65B0\u589E").concat(C,"\u4E2A")),T.props.deleteEmptyDisabled?d.cancel():T.props.onPlaceholderChange&&T.props.onPlaceholderChange(m,y,C)}else if(C){var l=T.getChCountBeforeCursor(o,d.from);console.log("\u65B0\u589E".concat(C,"\u4E2A\uFF0C\u4E4B\u524D\u6709").concat(l,"\u4E2A")),T.props.onPlaceholderChange&&T.props.onPlaceholderChange(l,0,C)}},T}return Object(R.a)(D,[{key:"render",value:function(){return z.a.createElement(j.a,Object(ae.a)({},this.props,{onCMBeforeChange:this.onCMBeforeChange}))}}]),D}(I.Component)},lZu9:function(At,ft,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 j in z)z.hasOwnProperty(j)&&R.tokenTypeOverrides[j]&&(z[j]=R.tokenTypeOverrides[j]);var O=/^([*\-_])(?:\s*\1){2,}\s*$/,P=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,E=/^\[(x| )\](?=\s)/i,L=R.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,D=/^ {0,3}(?:\={1,}|-{2,})\s*$/,T=/^[^#!\[\]*_\\<>` "'(~:]+/,A=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,w=/^\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 d(G,W,q){return W.f=W.inline=q,q(G,W)}function c(G,W,q){return W.f=W.block=q,q(G,W)}function C(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=C(W.prevLine.stream),fe=W.indentedCode,ve=W.prevLine.hr,ke=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,ke)){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&&(!ke||!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(P))){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=S,R.highlightFormatting&&(W.formatting="code-block"),W.code=-1,f(W);if(W.setext||(!Te||!ke)&&!W.quote&&W.list===!1&&!W.code&&!Ce&&!w.test(G.string)&&(me=G.lookAhead(1))&&(me=me.match(D)))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 d(G,W,k)}return d(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 S(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?c(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 ke="^\\s*(?:[^"+ve+"\\\\]+|\\\\\\\\|\\\\.)"+ve;if(G.match(new RegExp(ke),!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 we=G.string.substring(G.start,ne);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(we)&&(W.md_inside=!0)}return G.backUp(1),W.htmlState=ae.startState(X),c(G,W,l)}if(R.xml&&fe==="<"&&G.match(/^\/\w*?>/))return W.md_inside=!1,"tag";if(fe==="*"||fe==="_"){for(var tt=1,Ye=G.pos==1?" ":G.string.charAt(G.pos-2);tt<3&&G.eat(fe);)tt++;var Xe=G.peek()||" ",Ve=!/\s/.test(Xe)&&(!h.test(Xe)||/\s/.test(Ye)||h.test(Ye)),Le=!/\s/.test(Ye)&&(!h.test(Ye)||/\s/.test(Xe)||h.test(Xe)),Me=null,He=null;if(tt%2&&(!W.em&&Ve&&(fe==="*"||!Le||h.test(Ye))?Me=!0:W.em==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(Me=!1)),tt>1&&(!W.strong&&Ve&&(fe==="*"||!Le||h.test(Ye))?He=!0:W.strong==fe&&Le&&(fe==="*"||!Ve||h.test(Xe))&&(He=!1)),He!=null||Me!=null){R.highlightFormatting&&(W.formatting=Me==null?"strong":He==null?"em":"strong em"),Me===!0&&(W.em=fe),He===!0&&(W.strong=fe);var Te=f(W);return Me===!1&&(W.em=!1),He===!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=x(q==="("?")":"]"),R.highlightFormatting&&(W.formatting="link-string"),W.linkHref=!0,f(W)):"error"}var v={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(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 k(G,W){return G.match(/^([^\]\\]|\\.)*\]:/,!1)?(W.f=H,G.next(),R.highlightFormatting&&(W.formatting="link"),W.linkText=!0,f(W)):d(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,ft,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,d,c){this.line=o,this.ch=d,this.cm=h,this.text=h.getLine(o),this.min=c?Math.max(c.from,h.firstLine()):h.firstLine(),this.max=c?Math.min(c.to-1,h.lastLine()):h.lastLine()}function j(h,o){var d=h.cm.getTokenTypeAt($(h.line,o));return d&&/\btag\b/.test(d)}function O(h){return h.line>=h.max?void 0:(h.ch=0,h.text=h.cm.getLine(++h.line),!0)}function P(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(!j(h,o+1)){h.ch=o+1;continue}var d=h.text.lastIndexOf("/",o),c=d>-1&&!/\S/.test(h.text.slice(d+1,o));return h.ch=o+1,c?"selfClose":"regular"}}function L(h){for(;;){var o=h.ch?h.text.lastIndexOf("<",h.ch-1):-1;if(o==-1){if(P(h))continue;return}if(!j(h,o+1)){h.ch=o;continue}I.lastIndex=o,h.ch=o;var d=I.exec(h.text);if(d&&d.index==o)return d}}function D(h){for(;;){I.lastIndex=h.ch;var o=I.exec(h.text);if(!o){if(O(h))continue;return}if(!j(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(P(h))continue;return}if(!j(h,o+1)){h.ch=o;continue}var d=h.text.lastIndexOf("/",o),c=d>-1&&!/\S/.test(h.text.slice(d+1,o));return h.ch=o+1,c?"selfClose":"regular"}}function A(h,o){for(var d=[];;){var c=D(h),C,y=h.line,m=h.ch-(c?c[0].length:0);if(!c||!(C=E(h)))return;if(C=="selfClose")continue;if(c[1]){for(var l=d.length-1;l>=0;--l)if(d[l]==c[2]){d.length=l;break}if(l<0&&(!o||o==c[2]))return{tag:c[2],from:$(y,m),to:$(h.line,h.ch)}}else d.push(c[2])}}function w(h,o){for(var d=[];;){var c=T(h);if(!c)return;if(c=="selfClose"){L(h);continue}var C=h.line,y=h.ch,m=L(h);if(!m)return;if(m[1])d.push(m[2]);else{for(var l=d.length-1;l>=0;--l)if(d[l]==m[2]){d.length=l;break}if(l<0&&(!o||o==m[2]))return{tag:m[2],from:$(h.line,h.ch),to:$(C,y)}}}}ae.registerHelper("fold","xml",function(h,o){for(var d=new z(h,o.line,0);;){var c=D(d);if(!c||d.line!=o.line)return;var C=E(d);if(!C)return;if(!c[1]&&C!="selfClose"){var y=$(d.line,d.ch),m=A(d,c[2]);return m&&R(m.from,y)>0?{from:y,to:m.from}:null}}}),ae.findMatchingTag=function(h,o,d){var c=new z(h,o.line,o.ch,d);if(c.text.indexOf(">")==-1&&c.text.indexOf("<")==-1)return;var C=E(c),y=C&&$(c.line,c.ch),m=C&&L(c);if(!C||!m||R(c,o)>0)return;var l={from:$(c.line,c.ch),to:y,tag:m[2]};return C=="selfClose"?{open:l,close:null,at:"open"}:m[1]?{open:w(c,m[2]),close:l,at:"close"}:(c=new z(h,y.line,y.ch,d),{open:l,close:A(c,m[2]),at:"open"})},ae.findEnclosingTag=function(h,o,d,c){for(var C=new z(h,o.line,o.ch,d);;){var y=w(C,c);if(!y)break;var m=new z(h,o.line,o.ch,d),l=A(m,y.tag);if(l)return{open:y,close:l}}},ae.scanForClosingTag=function(h,o,d,c){var C=new z(h,o.line,o.ch,c?{from:0,to:c}:null);return A(C,d)}})},p5ED:function(At,ft,re){"use strict";var ae=re("+L6B"),$=re("2/Rp"),R=re("5Dmo"),X=re("3S7+"),N=re("k1fw"),I=re("9og8"),z=re("tJVT"),j=re("WmNS"),O=re.n(j),P=re("q1tI"),E=re.n(P),L=re("vHTk"),D=re.n(L),T=re("yEEn"),A=re("ZW9T"),w=re("1vsH"),h=re("V0Rq"),o=re("m3rI");ft.a=function(d){var c,C,y,m,l,S,f,p=d.editOffice,s=p===void 0?"view":p,a=d.data,b=d.theme,v=d.type,x=d.filename,k=d.monacoEditor,H=d.className,V=d.style,Q=d.close,G=d.onClose,W=d.hasMask,q=d.disabledDownload,oe=Object(P.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),fe=Object(z.a)(oe,2),ve=fe[0],ke=fe[1],Ee=Object(P.useState)(""),_e=Object(z.a)(Ee,2),Te=_e[0],Ce=_e[1],me=Object(P.useState)(),ne=Object(z.a)(me,2),we=ne[0],tt=ne[1],Ye=window.ENV==="build"?"/react/build":"",Xe=o.a.PROXY_SERVER||location.origin,Ve,Le=1024*1024,Me=10*Le,He=Object(P.useRef)();(c=a)!==null&&c!==void 0&&c.startsWith("/api")&&v!=="txt"&&(a=o.a.API_SERVER+a),v==="office"&&(Ve=Object(w.T)(a).filesize,Ve>Me&&(v="other")),x&&k&&(k.filename=x),Object(P.useEffect)(function(){var Re,st,Je=(Re=document.cookie)===null||Re===void 0||((st=Re.replace(/\s/g,""))===null||st===void 0)?void 0:st.split(";");Je==null||Je.map(function(Qe){var nt=Qe.split("=");nt[0]==="_educoder_session"&&Ce(nt[1])})},[]),Object(P.useEffect)(function(){v==="office"&&Ge()},[v,a]);var Ge=function(){var Re=Object(I.a)(O.a.mark(function st(){var Je,Qe,nt;return O.a.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return console.log("data:",a),Je=a,a.startsWith("http")||(Je=location.origin+Je),Qe=new URL(Je).pathname.split("/").pop(),at.next=6,Object(h.V)({attachment_id:Qe});case 6:nt=at.sent,tt(nt);case 8:case"end":return at.stop()}},st)}));return function(){return Re.apply(this,arguments)}}(),je=function(){if(a.startsWith("http")||a.startsWith("blob:")){Ue();return}Object(w.z)(x||"educoder",a,x)},Ue=function(){Object(w.x)(x||"educoder",decodeURIComponent(a))};return E.a.createElement("div",{style:Object(N.a)({},V||{}),className:"".concat(W&&D.a.bgBlack," ").concat(v?D.a.wrp:"hide")},Q&&E.a.createElement("div",{className:D.a.close,ref:He},!q&&E.a.createElement(X.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return He.current}},E.a.createElement("span",{onClick:Ue},E.a.createElement("i",{className:"icon-quxiaozhiding"}))),E.a.createElement(X.a,{title:"\u5173\u95ED",getPopupContainer:function(){return He.current}},E.a.createElement("span",{className:"",onClick:G},E.a.createElement("i",{className:"icon-guanbi1"})))),E.a.createElement("div",{className:"".concat(D.a[H]," ").concat(H," ").concat(D.a.monaco," ").concat(v==="txt"?"show":"hide")},v==="txt"&&E.a.createElement(A.b,k)),v==="audio"&&E.a.createElement("audio",{src:"".concat(((C=a)===null||C===void 0?void 0:C.indexOf("http://"))>-1||((y=a)===null||y===void 0?void 0:y.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),v==="video"&&E.a.createElement(E.a.Fragment,null,((m=a)===null||m===void 0?void 0:m.indexOf("http"))>-1?E.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):E.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),v==="office"&&we&&E.a.createElement("iframe",{src:"".concat(Ye,"/office.html?key=").concat(we.key,"&url=").concat(Xe+we.url,"&callbackUrl=").concat(Xe+we.callbackUrl,"&fileType=").concat(we.fileType,"&title=").concat(we.title,"&model=").concat(s,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!q)}),v==="html"&&E.a.createElement("iframe",{src:a+"&disposition=inline"}),v==="pdf"&&E.a.createElement("iframe",{src:"".concat(Ye,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!q)}),v==="image"&&E.a.createElement("img",{src:"".concat(((l=a)===null||l===void 0?void 0:l.indexOf("http://"))>-1||((S=a)===null||S===void 0?void 0:S.indexOf("https://"))>-1||(f=a)!==null&&f!==void 0&&f.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),v==="other"&&E.a.createElement("div",null,E.a.createElement($.a,{type:"primary",size:"large",onClick:je},E.a.createElement(T.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),v==="download"&&E.a.createElement($.a,{type:"primary",size:"large",onClick:je},E.a.createElement(T.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(At,ft,re){},rUJ1:function(At,ft){const re=/[&<>"']/,ae=/[&<>"']/g,$=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,X={"&":"&","<":"<",">":">",'"':""","'":"'"},N=S=>X[S];function I(S,f){if(f){if(re.test(S))return S.replace(ae,N)}else if($.test(S))return S.replace(R,N);return S}const z=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function j(S){return S.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 P(S,f){S=S.source||S,f=f||"";const p={replace:(s,a)=>(a=a.source||a,a=a.replace(O,"$1"),S=S.replace(s,a),p),getRegex:()=>new RegExp(S,f)};return p}const E=/[^\w:]/g,L=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function D(S,f,p){if(S){let s;try{s=decodeURIComponent(j(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=/^[^:]+:\/*[^/]*$/,w=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(S,f){T[" "+S]||(A.test(S)?T[" "+S]=S+"/":T[" "+S]=y(S,"/",!0)),S=T[" "+S];const p=S.indexOf(":")===-1;return f.substring(0,2)==="//"?p?f:S.replace(w,"$1")+f:f.charAt(0)==="/"?p?f:S.replace(h,"$1")+f:S+f}const d={exec:function(){}};function c(S){let f=1,p,s;for(;f<arguments.length;f++){p=arguments[f];for(s in p)Object.prototype.hasOwnProperty.call(p,s)&&(S[s]=p[s])}return S}function C(S,f){const p=S.replace(/\|/g,(b,v,x)=>{let k=!1,H=v;for(;--H>=0&&x[H]==="\\";)k=!k;return k?"|":" |"}),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(S,f,p){const s=S.length;if(s===0)return"";let a=0;for(;a<s;){const b=S.charAt(s-a-1);if(b===f&&!p)a++;else if(b!==f&&p)a++;else break}return S.substr(0,s-a)}function m(S,f){if(S.indexOf(f[1])===-1)return-1;const p=S.length;let s=0,a=0;for(;a<p;a++)if(S[a]==="\\")a++;else if(S[a]===f[0])s++;else if(S[a]===f[1]&&(s--,s<0))return a;return-1}function l(S){S&&S.sanitize&&!S.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:j,edit:P,cleanUrl:D,resolveUrl:o,noopTest:d,merge:c,splitCells:C,rtrim:y,findClosingBracket:m,checkSanitizeDeprecation:l}},sDPU:function(At,ft,re){"use strict";re.r(ft);var ae=re("cWXX"),$=re("/ezw"),R=re("k1fw"),X=re("9og8"),N=re("tJVT"),I=re("WmNS"),z=re.n(I),j=re("q1tI"),O=re.n(j),P=re("Ty5D"),E=re("9kvl"),L=re("FIWC"),D=re.n(L),T=re("sbIO"),A=re("ErOA"),w=re("LvDl"),h=re.n(w),o=function(c){var C,y,m,l,S=c.paperlibrary,f=c.user,p=c.globalSetting,s=c.dispatch,a=c.location,b=(a==null||((C=a.query)===null||C===void 0)?void 0:C.select)||0,v=Object(j.useState)(!1),x=Object(N.a)(v,2),k=x[0],H=x[1],V=Object(j.useState)(!0),Q=Object(N.a)(V,2),G=Q[0],W=Q[1],q=Object(j.useState)(Number(b)),oe=Object(N.a)(q,2),fe=oe[0],ve=oe[1],ke=Object(j.useState)({}),Ee=Object(N.a)(ke,2),_e=Ee[0],Te=Ee[1],Ce=Object(P.i)(),me=f.userInfo;Object(j.useEffect)(function(){return s({type:"globalSetting/footerToggle",payload:!1}),function(){s({type:"globalSetting/footerToggle",payload:!0})}},[]),Object(j.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(j.useEffect)(function(){return document.body.setAttribute("data-custom","initial"),function(){document.body.removeAttribute("data-custom")}},[]),Object(j.useEffect)(function(){ne(fe)},[]);var ne=function(){var Le=Object(X.a)(z.a.mark(function Me(){var He,Ge,je=arguments;return z.a.wrap(function(Re){for(;;)switch(Re.prev=Re.next){case 0:return He=je.length>0&&je[0]!==void 0?je[0]:0,console.log(Ce),Re.next=4,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/preview_random_exercise.json"),{method:"get",params:{num:He}});case 4:Ge=Re.sent,W(!1),Te(we(Ge));case 7:case"end":return Re.stop()}},Me)}));return function(){return Le.apply(this,arguments)}}(),we=function(Me){var He={1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D",7:"\u4E03"};if(!Me)return;var Ge=Me||{},je=Ge.exam,Ue=Ge.single_questions,Re=Ge.multiple_questions,st=Ge.judgement_questions,Je=Ge.program_questions,Qe=Ge.completion_questions,nt=Ge.subjective_questions,bt=Ge.practical_questions,at=Ge.combination_questions,ht=[Object(R.a)({type:"SINGLE",name:"\u5355\u9009\u9898"},Ue),Object(R.a)({type:"MULTIPLE",name:"\u591A\u9009\u9898"},Re),Object(R.a)({type:"COMPLETION",name:"\u586B\u7A7A\u9898"},Qe),Object(R.a)({type:"JUDGMENT",name:"\u5224\u65AD\u9898"},st),Object(R.a)({type:"SUBJECTIVE",name:"\u7B80\u7B54\u9898"},nt),Object(R.a)({type:"PROGRAM",name:"\u7F16\u7A0B\u9898"},Je),Object(R.a)({type:"PRACTICAL",name:"\u5B9E\u8BAD\u9898"},bt),Object(R.a)({type:"COMBINATION",name:"\u7EC4\u5408\u9898"},at)],Ae=[],gt=0,dt=0,De=ht.filter(function(We){return We.questions_count>0}).map(function(We,ge){var de;return(de=We.questions)===null||de===void 0||de.forEach(function(pe){Ae.push(pe.id),gt=gt+pe.score,dt=dt+1}),Object(R.a)(Object(R.a)({},We),{number:He[ge+1]})});return{all_questions_count:dt,all_score:gt,questionList:De,ids:Ae,exam:je}},tt=function(){E.d.push("/classrooms/".concat(Ce.coursesId,"/exercise"))},Ye=function(){alert("\u4FDD\u5B58")},Xe=function(){var Le=Object(X.a)(z.a.mark(function Me(He,Ge){var je,Ue,Re;return z.a.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:return Je.next=2,Object(A.a)("/api/exercises/".concat(Ce.categoryId,"/toggle_random_question.json"),{method:"post",body:{question_id:He==null?void 0:He.single_question_id}});case 2:je=Je.sent,je!=null&&je.question&&(Re=Object(w.cloneDeep)(_e),Re.questionList=Re==null||((Ue=Re.questionList)===null||Ue===void 0)?void 0:Ue.map(function(Qe){if(Qe.type===Ge.type){var nt=Object(w.cloneDeep)(Qe==null?void 0:Qe.questions);return nt.splice(Ge.index,1,je==null?void 0:je.question),Object(R.a)(Object(R.a)({},Qe),{},{questions:nt})}return Qe}),Te(Re));case 4:case"end":return Je.stop()}},Me)}));return function(He,Ge){return Le.apply(this,arguments)}}(),Ve=function(){var Le=Object(X.a)(z.a.mark(function Me(He){return z.a.wrap(function(je){for(;;)switch(je.prev=je.next){case 0:document.body.scrollIntoView(),ne(He),ve(He);case 3:case"end":return je.stop()}},Me)}));return function(He){return Le.apply(this,arguments)}}();return console.log(Object(P.h)(),"location333"),O.a.createElement("section",{className:D.a.wrap},O.a.createElement($.a,{loading:G,active:!0,paragraph:{rows:5}},((y=Object(P.h)())===null||y===void 0||((m=y.pathname)===null||m===void 0)?void 0:m.includes("preview"))&&O.a.createElement("div",{className:D.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:k,submit:Ye,goBack:tt,data:_e,selectValue:fe,editPreview:!0,onExchange:Xe,onSkipExamination:Ve})))};ft.default=Object(E.a)(function(d){var c=d.paperlibrary,C=d.user,y=d.globalSetting;return{paperlibrary:c,user:C,globalSetting:y}})(o)},sbIO:function(At,ft,re){"use strict";var ae=re("DjyN"),$=re("NUBc"),R=re("5Dmo"),X=re("3S7+"),N=re("/zsF"),I=re("PArb"),z=re("Q9mQ"),j=re("diRs"),O=re("+L6B"),P=re("2/Rp"),E=re("5NDa"),L=re("5rEg"),D=re("miYZ"),T=re("tsqr"),A=re("9og8"),w=re("giR+"),h=re("fyUT"),o=re("2qtc"),d=re("kLXV"),c=re("tJVT"),C=re("WmNS"),y=re.n(C),m=re("q1tI"),l=re.n(m),S=re("PsQE"),f=re.n(S),p=re("0eGx"),s=re.n(p),a=re("9Bee"),b=re("Ty5D"),v=re("9kvl"),x=re("ErOA"),k=re("+yhJ"),H=re.n(k),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"),ke=re("PpiC"),Ee=re("Ot1p"),_e=re("kqOp"),Te=re("7qnI"),Ce=re("1vsH"),me=re("PGNT"),ne=re.n(me),we=["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"],tt=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,Pe=ie.dispatch,Ze=ie.isEdit,qe=ie.editData,Et=Object(ke.a)(ie,["globalSetting","loading","dispatch","isEdit","editData"]),Pt=Object(m.useState)(""),et=Object(c.a)(Pt,2),ct=et[0],Ft=et[1],Ct=Object(m.useState)(""),jt=Object(c.a)(Ct,2),$t=jt[0],Lt=jt[1],Qt=Object(m.useState)([]),Zt=Object(c.a)(Qt,2),pt=Zt[0],Xt=Zt[1],zt=Object(m.useState)(""),Gt=Object(c.a)(zt,2),Ut=Gt[0],Mt=Gt[1],St=Object(m.useState)(),it=Object(c.a)(St,2),Fe=it[0],nr=it[1],Vt=Object(m.useState)(!1),qt=Object(c.a)(Vt,2),Wt=qt[0],Tr=qt[1];Object(m.useEffect)(function(){if(!qe||!Ze)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 ct?(pt.forEach(function(g,M){U.push({position:M+1,answer_text:[]}),g.forEach(function(J,F){U[M].answer_text.push(J),(!J||!Object(Ce.db)(J,1e4))&&(Mt("".concat(M,"-").concat(F)),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:ct,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 M=pt.slice();if(u&&M.splice(U,u),g)for(var J=0;J<g;J++)M.splice(U+J,0,[""]);Xt(M)},xt=function(U,u,g){Mt("");var M=pt.slice();M[U][u]=g,Xt(M)},Pr=function(U){var u=pt.slice();u[U]=[].concat(Object(ve.a)(u[U]),[""]),Xt(u)},un=function(U,u){var g=pt.slice();if(!g[U][u]){g[U]=g[U].filter(function(M,J){return J!==u}),Xt(g);return}d.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,F){return F!==u}),Xt(g)}})},dn=function(U){d.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=pt.slice();g=pt.filter(function(M,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:ct,onChange:function(U){return Ft(U)},showNullButton:!0,onPlaceholderChange:Ie})),l.a.createElement("div",{className:"mt20"},pt.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:Pr,deleteChildAnswer:un,deleteChildAnswermain:dn})})),l.a.createElement("div",{className:"mt20"},pt.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)}}))},Ye=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)(tt)),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,Pe=ie.editData,Ze=ie.dispatch,qe=ie.onRef,Et=qe===void 0?function(){}:qe,Pt=ie.isEdit,et=Object(ke.a)(ie,["globalSetting","loading","editData","dispatch","onRef","isEdit"]),ct=Object(m.useState)(),Ft=Object(c.a)(ct,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(c.a)($t,2),Qt=Lt[0],Zt=Lt[1],pt=Object(m.useState)(""),Xt=Object(c.a)(pt,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){if(!Pe||!Pt)return;Zt(Pe==null?void 0:Pe.name),Gt(Pe==null?void 0:Pe.analysis);var St=Pe==null?void 0:Pe.choices.find(function(it){return it.is_answer});jt(St.choice_text==="\u6B63\u786E"?"0":"1")},[Pe]),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 it=[{choice_text:"\u6B63\u786E",is_answer:Ct==="0"?1:0},{choice_text:"\u9519\u8BEF",is_answer:Ct==="1"?1:0}];return{name:Qt,choices:it,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(it){return Zt(it)}}),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(it){return jt(it.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(it){return Gt(it)}}))},He=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"],je=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,Pe=ie.loading,Ze=ie.dispatch,qe=ie.onRef,Et=qe===void 0?function(){}:qe,Pt=ie.isEdit,et=Object(ke.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ct=Object(m.useState)([]),Ft=Object(c.a)(ct,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(c.a)($t,2),Qt=Lt[0],Zt=Lt[1],pt=Object(m.useState)([]),Xt=Object(c.a)(pt,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(c.a)(Ut,2),St=Mt[0],it=Mt[1],Fe=Object(m.useState)(""),nr=Object(c.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Pt)return;it(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,Pr){return{choice_text:xt,is_answer:zt.includes(Pr)?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),it(""),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 it(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,Pr){return Pr!==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)}}))},Ue=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)(je)),Re=["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"],st=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,Pe=ie.loading,Ze=ie.dispatch,qe=ie.onRef,Et=qe===void 0?function(){}:qe,Pt=ie.isEdit,et=Object(ke.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ct=Object(m.useState)([]),Ft=Object(c.a)(ct,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(),Lt=Object(c.a)($t,2),Qt=Lt[0],Zt=Lt[1],pt=Object(m.useState)(),Xt=Object(c.a)(pt,2),zt=Xt[0],Gt=Xt[1],Ut=Object(m.useState)(""),Mt=Object(c.a)(Ut,2),St=Mt[0],it=Mt[1],Fe=Object(m.useState)(""),nr=Object(c.a)(Fe,2),Vt=nr[0],qt=nr[1];Object(m.useEffect)(function(){jt(["","","",""])},[]),Object(m.useEffect)(function(){if(!ue||!Pt)return;it(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(Re[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,Pr){return{choice_text:xt,is_answer:zt===Pr?1:0}});return{name:St,choices:Ie,analysis:Vt}},Tr=function(){jt(["","","",""]),it(""),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 it(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)}},Re[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,Pr){return Pr!==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)}}))},Je=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)(st)),Qe=["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"],nt=function(ie,se){var ue=ie.editData,Se=ie.globalSetting,Pe=ie.loading,Ze=ie.dispatch,qe=ie.onRef,Et=qe===void 0?function(){}:qe,Pt=ie.isEdit,et=Object(ke.a)(ie,["editData","globalSetting","loading","dispatch","onRef","isEdit"]),ct=Object(m.useState)(""),Ft=Object(c.a)(ct,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)(""),Lt=Object(c.a)($t,2),Qt=Lt[0],Zt=Lt[1],pt=Object(m.useState)(""),Xt=Object(c.a)(pt,2),zt=Xt[0],Gt=Xt[1];Object(m.useEffect)(function(){var St;if(!ue||!Pt)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(it){return jt(it)}}),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(it){return Gt(it)}}),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(it){return Zt(it)}}))},bt=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)(nt)),at=re("k1fw"),ht=["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"],Ae=function(ie,se){var ue=ie.globalSetting,Se=ie.loading,Pe=ie.dispatch,Ze=ie.editData,qe=ie.onRef,Et=qe===void 0?function(){}:qe,Pt=ie.isEdit,et=Object(ke.a)(ie,["globalSetting","loading","dispatch","editData","onRef","isEdit"]),ct=Object(m.useState)(""),Ft=Object(c.a)(ct,2),Ct=Ft[0],jt=Ft[1],$t=Object(m.useState)([]),Lt=Object(c.a)($t,2),Qt=Lt[0],Zt=Lt[1];console.log(Qt),Object(m.useEffect)(function(){var Ut;if(!Ze||!Pt)return;jt(Ze==null?void 0:Ze.name);var Mt=Ze==null||((Ut=Ze.sub_item_banks)===null||Ut===void 0)?void 0:Ut.map(function(St){var it,Fe,nr;return Object(at.a)(Object(at.a)({},St),{},{id:St.id,open:!1,qusList:St==null||((it=St.choices)===null||it===void 0)?void 0:it.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)},[Ze]),Object(m.useImperativeHandle)(se,function(){return{onSave:pt,Clear:Xt}});var pt=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,it=Qt[Mt];if(!(it!=null&&it.name))return T.b.info("\u8BF7\u60A8\u8F93\u5165\u7B2C".concat(Mt+1,"\u5C0F\u9898\u9898\u5E72")),!1;var Fe=it==null||((St=it.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(ht[Fe],"\u9009\u9879\u7684\u5185\u5BB9")),!1;if(!(it!=null&&it.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,it){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=it),Mt==="answer"&&(Fe[St].qusAnswer=[it]),Mt==="edit"&&(Fe[St].activeQusEditor=it),Mt==="details"&&(Fe[St].qusList[Fe[St].activeQusEditor]=it),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!==it}),Fe[St].qusAnswer=(nr=Fe[St].qusAnswer)===null||nr===void 0?void 0:nr.filter(function(Vt){return Vt!==it})}Mt==="analysis"&&(Fe[St].analysis=it),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(it,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)}},ht[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:it,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:it}))),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)(Ae)),dt=re("14J3"),De=re("BMrR"),We=re("ZWs3"),ge=function(ie){var se=ie.visible,ue=ie.onCancel,Se=ie.onRandomExchange,Pe=ie.selectFromProblemSet;return l.a.createElement(d.a,{title:"\u8BF7\u9009\u62E9\u66FF\u6362\u65B9\u5F0F",visible:se,onCancel:ue,centered:!0,maskClosable:!0,footer:null},l.a.createElement(De.a,{justify:"center"},l.a.createElement(We.a,{onClick:Se},"\u968F\u673A\u66F4\u6362"),l.a.createElement(P.a,{style:{marginLeft:24},onClick:Pe},"\u4ECE\u9898\u5E93\u4E2D\u9009\u62E9")))},de=ge,pe=function(ie){var se,ue,Se,Pe,Ze,qe,Et,Pt,et=ie.data,ct=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,pt=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(c.a)(Gt,2),Mt=Ut[0],St=Ut[1],it=Object(m.useState)(!1),Fe=Object(c.a)(it,2),nr=Fe[0],Vt=Fe[1],qt=Object(m.useState)(!1),Wt=Object(c.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 ot,be,Ke,wt,mt=(ot=document.getElementById("examName"))===null||ot===void 0||((be=ot.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")},[et]);var xt=function(be){var Ke=parseInt(be);return isNaN(Ke)?"":Ke};function Pr(){var ot=0,be=0,Ke=0;return document.body&&(be=document.body.scrollTop),document.documentElement&&(Ke=document.documentElement.scrollTop),ot=be-Ke>0?be:Ke,ot}function un(){var ot=0,be=0,Ke=0;return document.body&&(be=document.body.scrollHeight),document.documentElement&&(Ke=document.documentElement.scrollHeight),ot=be-Ke>0?be:Ke,ot}function dn(){var ot=0;return document.compatMode=="CSS1Compat"?ot=document.documentElement.clientHeight:ot=document.body.clientHeight,ot}var xr=function(){var be=document.getElementById("preview_btns"),Ke=document.getElementById("preview_btns_else");Pr()+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))))},M=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)))},F=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,d.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}()})},rt=function(){var be="";d.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=[],et==null||((vt=et.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,ct(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=d.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,pt({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}()})},Be=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=d.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,pt({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}()})},kt=function(){var be=d.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,pt();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(j.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(P.a,{onMouseEnter:function(){return Vt(!0)},onMouseLeave:function(){return Vt(!1)},onClick:function(){rt()}},"\u4FDD\u5B58")),l.a.createElement(P.a,{onClick:function(){document.body.scrollIntoView(),Ft()}},"\u8FD4\u56DE"),l.a.createElement(P.a,{loading:Ct,onClick:function(){return ct()},type:"primary"},"\u63D0\u4EA4"))},Gr=function(){var be;return l.a.createElement(l.a.Fragment,null,l.a.createElement(P.a,{onClick:Ft},"\u8FD4\u56DE"),Zt>0&&l.a.createElement(P.a,{onClick:function(){return er(Zt)},type:"primary"},"\u4E0A\u4E00\u4EFD"),Zt<(et==null||((be=et.exam)===null||be===void 0)?void 0:be.total_num)-1&&l.a.createElement(P.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(Je,{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(Ue,{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(He,{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(Ye,{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(bt,{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 ot=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(x.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 ot.apply(this,arguments)}}(),cn=function(){for(var be=[],Ke=0;Ke<(et==null||((wt=et.exam)===null||wt===void 0)?void 0:wt.total_num);Ke++){var wt;be.push({})}return be},Sn=et==null||((se=et.questionList)===null||se===void 0)?void 0:se.reduce(function(ot,be){return ot+be.questions_score},0),wr=Lt&&(et==null||((ue=et.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,et==null?void 0:et.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,et==null||((Se=et.exam)===null||Se===void 0)?void 0:Se.time))),et==null||((Pe=et.questionList)===null||Pe===void 0)?void 0:Pe.map(function(ot,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,ot.name)),l.a.createElement("aside",null,l.a.createElement("div",null,"\u5171",l.a.createElement("span",{className:f.a.b},ot.questions_count),"\u9898"," ",l.a.createElement("span",{className:f.a.l},"|"),"\u5171",l.a.createElement("span",{className:f.a.r},ot.questions_score),"\u5206"),l.a.createElement("div",{className:f.a.answerSheet},ot==null||((Ke=ot.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:et==null||((Ze=et.exam)===null||Ze===void 0)?void 0:Ze.name,getPopupContainer:function(be){return be.parentNode}},l.a.createElement("span",{className:f.a.t},et==null||((qe=et.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:et==null||((Et=et.exam)===null||Et===void 0)?void 0:Et.total_num,pageSize:1,current:Zt+1,showSizeChanger:!1,onChange:er,showQuickJumper:!0,hideOnSinglePage:!1}):l.a.createElement(P.a,{onClick:kt,type:"primary"},"\u968F\u673A\u66F4\u6362")),l.a.createElement("div",{className:f.a.topWarp},et==null||((Pt=et.questionList)===null||Pt===void 0)?void 0:Pt.map(function(ot,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,ot.name)),l.a.createElement("div",{className:f.a.so},"\u5171",l.a.createElement("span",{className:f.a.b},ot.questions_count," "),"\u9898"," ",ot.type==="COMBINATION"&&"\uFF08\u5305\u542B".concat(ot==null||((Ke=ot.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},ot.questions_score),"\u5206"),!Lt&&l.a.createElement("div",{className:f.a.btn},l.a.createElement(P.a,{onClick:function(){Ne(ot)},type:"primary",ghost:!0,className:"mr20"},"\u8BBE\u7F6E\u5F97\u5206"),l.a.createElement(P.a,{onClick:function(){return Be(ot)},type:"primary",ghost:!0},"\u968F\u673A\u66F4\u6362"))),ot==null||((wt=ot.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(P.a,{onClick:function(){return St(null)},className:"mr20",type:"primary",ghost:!0},"\u53D6\u6D88"),l.a.createElement(P.a,{onClick:function(){return Ir(ot==null?void 0:ot.type,mt)},type:"primary"},"\u4FDD\u5B58")),Mr(mt,ot.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(P.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(P.a,{disabled:wr,onClick:function(){return Tt(mt.id,ot.type,vt,ot)},type:"primary",ghost:!0},"\u6362\u4E00\u9898")),(ot.type==="SINGLE"||ot.type==="JUDGMENT"||ot.type==="MULTIPLE")&&u(mt),ot.type==="COMPLETION"&&g(mt),ot.type==="SUBJECTIVE"&&M(mt),ot.type==="PROGRAM"&&J(mt),ot.type==="COMBINATION"&&F(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 ot(){var be;return y.a.wrap(function(wt){for(;;)switch(wt.prev=wt.next){case 0:return be=Rt.current,wt.next=3,pt({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()}},ot)})),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=ft.a=pe},ulZh:function(At,ft,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(j){return X[j]}.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,D){this.fn=E,this.context=L,this.once=D||!1}function j(E,L,D,T,A){if(typeof D!="function")throw new TypeError("The listener must be a function");var w=new z(D,T||E,A),h=N?N+L:L;return E._events[h]?E._events[h].fn?E._events[h]=[E._events[h],w]:E._events[h].push(w):(E._events[h]=w,E._eventsCount++),E}function O(E,L){--E._eventsCount===0?E._events=new I:delete E._events[L]}function P(){this._events=new I,this._eventsCount=0}P.prototype.eventNames=function(){var L=[],D,T;if(this._eventsCount===0)return L;for(T in D=this._events)X.call(D,T)&&L.push(N?T.slice(1):T);return Object.getOwnPropertySymbols?L.concat(Object.getOwnPropertySymbols(D)):L},P.prototype.listeners=function(L){var D=N?N+L:L,T=this._events[D];if(!T)return[];if(T.fn)return[T.fn];for(var A=0,w=T.length,h=new Array(w);A<w;A++)h[A]=T[A].fn;return h},P.prototype.listenerCount=function(L){var D=N?N+L:L,T=this._events[D];return T?T.fn?1:T.length:0},P.prototype.emit=function(L,D,T,A,w,h){var o=N?N+L:L;if(!this._events[o])return!1;var d=this._events[o],c=arguments.length,C,y;if(d.fn){d.once&&this.removeListener(L,d.fn,void 0,!0);switch(c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,D),!0;case 3:return d.fn.call(d.context,D,T),!0;case 4:return d.fn.call(d.context,D,T,A),!0;case 5:return d.fn.call(d.context,D,T,A,w),!0;case 6:return d.fn.call(d.context,D,T,A,w,h),!0}for(y=1,C=new Array(c-1);y<c;y++)C[y-1]=arguments[y];d.fn.apply(d.context,C)}else{var m=d.length,l;for(y=0;y<m;y++){d[y].once&&this.removeListener(L,d[y].fn,void 0,!0);switch(c){case 1:d[y].fn.call(d[y].context);break;case 2:d[y].fn.call(d[y].context,D);break;case 3:d[y].fn.call(d[y].context,D,T);break;case 4:d[y].fn.call(d[y].context,D,T,A);break;default:if(!C)for(l=1,C=new Array(c-1);l<c;l++)C[l-1]=arguments[l];d[y].fn.apply(d[y].context,C)}}}return!0},P.prototype.on=function(L,D,T){return j(this,L,D,T,!1)},P.prototype.once=function(L,D,T){return j(this,L,D,T,!0)},P.prototype.removeListener=function(L,D,T,A){var w=N?N+L:L;if(!this._events[w])return this;if(!D)return O(this,w),this;var h=this._events[w];if(h.fn)h.fn===D&&(!A||h.once)&&(!T||h.context===T)&&O(this,w);else{for(var o=0,d=[],c=h.length;o<c;o++)(h[o].fn!==D||A&&!h[o].once||T&&h[o].context!==T)&&d.push(h[o]);d.length?this._events[w]=d.length===1?d[0]:d:O(this,w)}return this},P.prototype.removeAllListeners=function(L){var D;return L?(D=N?N+L:L,this._events[D]&&O(this,D)):(this._events=new I,this._eventsCount=0),this},P.prototype.off=P.prototype.removeListener,P.prototype.addListener=P.prototype.on,P.prefixed=N,P.EventEmitter=P,ae.exports=P},"./node_modules/url-toolkit/src/url-toolkit.js":function(ae,$,R){(function(X){var N=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,I=/^([^\/?#]*)([^]*)$/,z=/(?:\/|^)\.(?=\/)/g,j=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(P,E,L){if(L=L||{},P=P.trim(),E=E.trim(),!E){if(!L.alwaysNormalize)return P;var D=O.parseURL(P);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}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(P);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var w=I.exec(A.path);A.netLoc=w[1],A.path=w[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,d=o.substring(0,o.lastIndexOf("/")+1)+T.path;h.path=O.normalizePath(d)}return h.path===null&&(h.path=L.alwaysNormalize?O.normalizePath(T.path):T.path),O.buildURLFromParts(h)},parseURL:function(P){var E=N.exec(P);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(P){for(P=P.split("").reverse().join("").replace(z,"");P.length!==(P=P.replace(j,"")).length;);return P.split("").reverse().join("")},buildURLFromParts:function(P){return P.scheme+P.netLoc+P.path+P.params+P.query+P.fragment}};ae.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(ae,$,R){function X(L){var D={};function T(w){if(D[w])return D[w].exports;var h=D[w]={i:w,l:!1,exports:{}};return L[w].call(h.exports,h,h.exports,T),h.l=!0,h.exports}T.m=L,T.c=D,T.i=function(w){return w},T.d=function(w,h,o){T.o(w,h)||Object.defineProperty(w,h,{configurable:!1,enumerable:!0,get:o})},T.r=function(w){Object.defineProperty(w,"__esModule",{value:!0})},T.n=function(w){var h=w&&w.__esModule?function(){return w.default}:function(){return w};return T.d(h,"a",h),h},T.o=function(w,h){return Object.prototype.hasOwnProperty.call(w,h)},T.p="/",T.oe=function(w){throw console.error(w),w};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 j(L){return!isNaN(1*L)}function O(L,D,T){var A={};A[T]=[];var w=D.toString(),h=w.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return A;for(var o=h[1],d=new RegExp("(\\\\n|\\W)"+z(o)+I,"g"),c;c=d.exec(w);){if(c[3]==="dll-reference")continue;A[T].push(c[3])}for(d=new RegExp("\\("+z(o)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+I,"g");c=d.exec(w);)L[c[2]]||(A[T].push(c[1]),L[c[2]]=R(c[1]).m),A[c[2]]=A[c[2]]||[],A[c[2]].push(c[4]);for(var C=Object.keys(A),y=0;y<C.length;y++)for(var m=0;m<A[C[y]].length;m++)j(A[C[y]][m])&&(A[C[y]][m]=1*A[C[y]][m]);return A}function P(L){var D=Object.keys(L);return D.reduce(function(T,A){return T||L[A].length>0},!1)}function E(L,D){for(var T={main:[D]},A={main:[]},w={main:{}};P(T);)for(var h=Object.keys(T),o=0;o<h.length;o++){var d=h[o],c=T[d],C=c.pop();if(w[d]=w[d]||{},w[d][C]||!L[d][C])continue;w[d][C]=!0,A[d]=A[d]||[],A[d].push(C);for(var y=O(L,L[d][C],d),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,D){D=D||{};var T={main:R.m},A=D.all?{main:Object.keys(T.main)}:E(T,L),w="";Object.keys(A).filter(function(C){return C!=="main"}).forEach(function(C){for(var y=0;A[C][y];)y++;A[C].push(y),T[C][y]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",w=w+"var "+C+" = ("+X.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+A[C].map(function(m){return""+JSON.stringify(m)+": "+T[C][m].toString()}).join(",")+`});
|
|
`}),w=w+"new (("+X.toString().replace("ENTRY_MODULE",JSON.stringify(L))+")({"+A.main.map(function(C){return""+JSON.stringify(C)+": "+T.main[C].toString()}).join(",")+"}))(self);";var h=new window.Blob([w],{type:"text/javascript"});if(D.bare)return h;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,d=o.createObjectURL(h),c=new window.Worker(d);return c.objectURL=d,c}},"./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"),j=R("./src/controller/subtitle-track-controller.ts"),O=R("./src/controller/buffer-controller.ts"),P=R("./src/controller/timeline-controller.ts"),E=R("./src/controller/cap-level-controller.ts"),L=R("./src/controller/fps-controller.ts"),D=R("./src/controller/eme-controller.ts"),T=R("./src/controller/cmcd-controller.ts"),A=R("./src/utils/xhr-loader.ts"),w=R("./src/utils/fetch-loader.ts"),h=R("./src/utils/cues.ts"),o=R("./src/utils/mediakeys-helper.ts"),d=R("./src/utils/logger.ts");function c(){return c=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},c.apply(this,arguments)}function C(s,a){var b=Object.keys(s);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(s);a&&(v=v.filter(function(x){return Object.getOwnPropertyDescriptor(s,x).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?C(Object(b),!0).forEach(function(v){m(s,v,b[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(b)):C(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},S()),{},{subtitleStreamController:z.SubtitleStreamController,subtitleTrackController:j.default,timelineController:P.TimelineController,audioStreamController:N.default,audioTrackController:I.default,emeController:D.default,cmcdController:T.default});function S(){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 c({},s,a)}function p(s){var a=s.loader;if(a!==w.default&&a!==A.default)d.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var b=Object(w.fetchSupported)();b&&(s.loader=w.default,s.progressive=!0,s.enableSoftwareAES=!0,d.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"),j=R("./src/errors.ts"),O=R("./src/types/loader.ts"),P=R("./src/utils/logger.ts");function E(T,A){for(var w=0;w<A.length;w++){var h=A[w];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function L(T,A,w){return A&&E(T.prototype,A),w&&E(T,w),T}var D=function(){function T(w){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=w;var h=w.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 d=o.frag;if(d.type===O.PlaylistLevelType.MAIN&&!this.timer){var c;this.fragCurrent=d,this.partCurrent=(c=o.part)!=null?c:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(h,o){var d=this.hls.config;o.details.live?this.bwEstimator.update(d.abrEwmaSlowLive,d.abrEwmaFastLive):this.bwEstimator.update(d.abrEwmaSlowVoD,d.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var h=this.fragCurrent,o=this.partCurrent,d=this.hls,c=d.autoLevelEnabled,C=d.config,y=d.media;if(!h||!y)return;var m=o?o.stats:h.stats,l=o?o.duration:h.duration;if(m.aborted){P.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!c||y.paused||!y.playbackRate||!y.readyState)return;var S=performance.now()-m.loading.start,f=Math.abs(y.playbackRate);if(S<=500*l/f)return;var p=d.levels,s=d.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/S),x=(b-m.loaded)/v,k=y.currentTime,H=(z.BufferHelper.bufferInfo(y,k,C.maxBufferHole).end-k)/f;if(H>=2*l/f||x<=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>=x)return;var W=this.bwEstimator.getEstimate();P.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: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+V.toFixed(3)+` s
|
|
Time to underbuffer: `+H.toFixed(3)+" s"),d.nextLoadLevel=Q,this.bwEstimator.sample(S,m.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),d.trigger(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:m})},A.onFragLoaded=function(h,o){var d=o.frag,c=o.part;if(d.type===O.PlaylistLevelType.MAIN&&Object(X.isFiniteNumber)(d.sn)){var C=c?c.stats:d.stats,y=c?c.duration:d.duration;if(this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var m=this.hls.levels[d.level],l=(m.loaded?m.loaded.bytes:0)+C.loaded,S=(m.loaded?m.loaded.duration:0)+y;m.loaded={bytes:l,duration:S},m.realBitrate=Math.round(8*l/S)}if(d.bitrateTest){var f={stats:C,frag:d,part:c,id:d.type};this.onFragBuffered(I.Events.FRAG_BUFFERED,f),d.bitrateTest=!1}}},A.onFragBuffered=function(h,o){var d=o.frag,c=o.part,C=c?c.stats:d.stats;if(C.aborted)return;if(d.type!==O.PlaylistLevelType.MAIN||d.sn==="initSegment")return;var y=C.parsing.end-C.loading.start;this.bwEstimator.sample(y,C.loaded),C.bwEstimate=this.bwEstimator.getEstimate(),d.bitrateTest?this.bitrateTestDelay=y/1e3:this.bitrateTestDelay=0},A.onError=function(h,o){switch(o.details){case j.ErrorDetails.FRAG_LOAD_ERROR:case j.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,d=this.hls,c=d.maxAutoLevel,C=d.config,y=d.minAutoLevel,m=d.media,l=o?o.duration:h?h.duration:0,S=m?m.currentTime:0,f=m&&m.playbackRate!==0?Math.abs(m.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():C.abrEwmaDefaultEstimate,s=(z.BufferHelper.bufferInfo(m,S,C.maxBufferHole).end-S)/f,a=this.findBestLevel(p,y,c,s,C.abrBandWidthFactor,C.abrBandWidthUpFactor);if(a>=0)return a;P.logger.trace((s?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=l?Math.min(l,C.maxStarvationDelay):C.maxStarvationDelay,v=C.abrBandWidthFactor,x=C.abrBandWidthUpFactor;if(!s){var k=this.bitrateTestDelay;if(k){var H=l?Math.min(l,C.maxLoadingDelay):C.maxLoadingDelay;b=H-k,P.logger.trace("bitrate test took "+Math.round(1e3*k)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),v=x=1}}return a=this.findBestLevel(p,y,c,s+b,v,x),Math.max(a,0)},A.findBestLevel=function(h,o,d,c,C,y){for(var m,l=this.fragCurrent,S=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=S?S.duration:l?l.duration:0,x=d;x>=o;x--){var k=p[x];if(!k||b&&k.codecSet!==b)continue;var H=k.details,V=(S?H==null?void 0:H.partTarget:H==null?void 0:H.averagetargetduration)||v,Q=void 0;x<=f?Q=C*h:Q=y*h;var G=p[x].maxBitrate,W=G*V/Q;if(P.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(Q)+"/"+G+"/"+V+"/"+c+"/"+W),Q>G&&(!W||a&&!this.bitrateTestDelay||W<c))return x}return-1},L(T,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&(!o||!o.canEstimate()))return h;var d=this.getNextABRAutoLevel();return h!==-1&&(d=Math.min(h,d)),d},set:function(h){this._nextAutoLevel=h}}]),T}();$.default=D},"./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"),j=R("./src/controller/fragment-tracker.ts"),O=R("./src/types/level.ts"),P=R("./src/types/loader.ts"),E=R("./src/loader/fragment.ts"),L=R("./src/demux/chunk-cache.ts"),D=R("./src/demux/transmuxer-interface.ts"),T=R("./src/types/transmuxer.ts"),A=R("./src/controller/fragment-finders.ts"),w=R("./src/utils/discontinuities.ts"),h=R("./src/errors.ts"),o=R("./src/utils/logger.ts");function d(){return d=Object.assign||function(l){for(var S=1;S<arguments.length;S++){var f=arguments[S];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(l[p]=f[p])}return l},d.apply(this,arguments)}function c(l,S){l.prototype=Object.create(S.prototype),l.prototype.constructor=l,C(l,S)}function C(l,S){return C=Object.setPrototypeOf||function(p,s){return p.__proto__=s,p},C(l,S)}var y=100,m=function(l){c(S,l);function S(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=S.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,x=a.initPTS;if(v==="main"){var k=b.cc;this.initPTS[b.cc]=x,this.log("InitPTS for cc: "+k+" found from main: "+x),this.videoTrackCC=k,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 x,k=performance.now(),H=this.retryDate;(!H||k>=H||(x=this.media)!==null&&x!==void 0&&x.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(),ke=z.BufferHelper.bufferInfo(this.mediaBuffer,ve,this.config.maxBufferHole),Ee=Object(A.fragmentWithinToleranceTest)(ke.end,this.config.maxFragLookUpTolerance,Q);Ee<0&&(o.logger.log("Waiting fragment cc ("+Q.cc+") @ "+Q.start+" cancelled because another fragment at "+ke.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,x=this.media,k=this.trackId,H=b.config;if(!v||!v[k])return;if(!x&&(this.startFragRequested||!H.startFragPrefetch))return;var V=v[k],Q=V.details;if(!Q||Q.live&&this.levelLastLoaded!==k||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,P.PlaylistLevelType.AUDIO));var G=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,P.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,ke=G.end;if(oe){var Ee=this.getLoadPosition();ke=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"),x.currentTime=ve+.05))}var _e=this.getNextFragment(ke,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,ke)},f.getMaxBufferLength=function(){var s=l.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,P.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,x=a.details,k=a.id;if(!v){this.warn("Audio tracks were reset while loading level "+k);return}this.log("Track "+k+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var H=v[k],V=0;if(x.live||(b=H.details)!==null&&b!==void 0&&b.live){var Q=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!Q)return;!H.details&&x.hasProgramDateTime&&Q.hasProgramDateTime?(Object(w.alignMediaPlaylistByPDT)(x,Q),V=x.fragments[0].start):V=this.alignPlaylists(x,H.details)}H.details=x,this.levelLastLoaded=k,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(H.details,V),this.state===N.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=N.State.IDLE),this.tick()},f._handleFragmentLoadProgress=function(s){var a,b=s.frag,v=s.part,x=s.payload,k=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=k.defaultAudioCodec||Q.audioCodec||"mp4a.40.2",q=this.transmuxer;q||(q=this.transmuxer=new D.default(this.hls,P.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,ke=v?v.index:-1,Ee=ke!==-1,_e=new T.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,x.byteLength,ke,Ee);q.push(x,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(x)),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!==P.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(P.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,P.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,x=s.remuxResult,k=s.chunkMeta,H=this.getCurrentContext(k);if(!H){this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(k.level);return}var V=H.frag,Q=H.part,G=x.audio,W=x.text,q=x.id3,oe=x.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,k),v.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:V,id:b,tracks:oe.tracks})),G){var fe=G.startPTS,ve=G.endPTS,ke=G.startDTS,Ee=G.endDTS;Q&&(Q.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:fe,endPTS:ve,startDTS:ke,endDTS:Ee}),V.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,fe,ve,ke,Ee),this.bufferFragmentData(G,V,Q,k)}if(q!=null&&(a=q.samples)!==null&&a!==void 0&&a.length){var _e=d({frag:V,id:b},q);v.trigger(I.Events.FRAG_PARSING_METADATA,_e)}if(W){var Te=d({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 x=v.initSegment;if(x!=null&&x.byteLength){var k={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:x};this.hls.trigger(I.Events.BUFFER_APPENDING,k)}this.tick()},f.loadFragment=function(s,a,b){var v=this.fragmentTracker.getState(s);this.fragCurrent=s,(this.audioSwitch||v===j.FragmentState.NOT_LOADED||v===j.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})},S}(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 j(D,T){for(var A=0;A<T.length;A++){var w=T[A];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(D,w.key,w)}}function O(D,T,A){return T&&j(D.prototype,T),A&&j(D,A),D}function P(D,T){D.prototype=Object.create(T.prototype),D.prototype.constructor=D,E(D,T)}function E(D,T){return E=Object.setPrototypeOf||function(w,h){return w.__proto__=h,w},E(D,T)}var L=function(D){P(T,D);function T(w){var h;return h=D.call(this,w,"[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,D.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 d=o.id,c=o.details,C=this.tracksInGroup[d];if(!C){this.warn("Invalid audio track id "+d);return}var y=C.details;C.details=o.details,this.log("audioTrack "+d+" loaded ["+c.startSN+"-"+c.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,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 d=o.audioGroupIds[o.urlId];if(this.groupId!==d){this.groupId=d;var c=this.tracks.filter(function(y){return!d||y.groupId===d});this.selectDefaultTrack&&!c.some(function(y){return y.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=c;var C={audioTracks:c};this.log("Updating audio tracks, "+c.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(X.Events.AUDIO_TRACKS_UPDATED,C),this.selectInitialTrack()}},A.onError=function(h,o){if(D.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 d=o[this.trackId];this.log("Now switching to audio-track index "+h);var c=o[h],C=c.id,y=c.groupId,m=y===void 0?"":y,l=c.name,S=c.type,f=c.url;if(this.trackId=h,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(X.Events.AUDIO_TRACK_SWITCHING,{id:C,groupId:m,name:l,type:S,url:f}),c.details&&!c.details.live)return;var p=this.switchParams(c.url,d==null?void 0:d.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,d=this.findTrackId(o)||this.findTrackId();d!==-1?this.setAudioTrack(d):(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,d=0;d<o.length;d++){var c=o[d];if((!this.selectDefaultTrack||c.default)&&(!h||h===c.name))return c.id}return-1},A.loadPlaylist=function(h){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var d=o.id,c=o.groupId,C=o.url;if(h)try{C=h.addDirectives(C)}catch(y){this.warn("Could not construct new URL with HLS Delivery Directives: "+y)}this.log("loading audio-track playlist for id: "+d),this.clearTimer(),this.hls.trigger(X.Events.AUDIO_TRACK_LOADING,{url:C,id:d,groupId:c,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"),j=R("./src/errors.ts"),O=function(){function P(L,D){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,D+":"),this.warn=z.logger.warn.bind(z.logger,D+":"),this.hls=L}var E=P.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(D,T){T.fatal&&T.type===j.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(D,T){var A=T==null?void 0:T.renditionReports;if(A)for(var w=0;w<A.length;w++){var h=A[w],o=""+h.URI;if(o===D.substr(-o.length)){var d=parseInt(h["LAST-MSN"]),c=parseInt(h["LAST-PART"]);if(T&&this.hls.config.lowLatencyMode){var C=Math.min(T.age-T.partTarget,T.targetduration);c!==void 0&&C>T.partTarget&&(c+=1)}if(Object(X.isFiniteNumber)(d))return new N.HlsUrlParameters(d,Object(X.isFiniteNumber)(c)?c:void 0,N.HlsSkip.No)}}},E.loadPlaylist=function(D){},E.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},E.playlistLoaded=function(D,T,A){var w=this,h=T.details,o=T.stats,d=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(h.advancedDateTime=Date.now()-d,h.live||A!=null&&A.live){if(h.reloaded(A),A&&this.log("live playlist "+D+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),A&&h.fragments.length>0&&Object(I.mergeDetails)(A,h),!this.canLoad||!h.live)return;var c,C=void 0,y=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var m=this.hls.config.lowLatencyMode,l=h.lastPartSn,S=h.endSN,f=h.lastPartIndex,p=f!==-1,s=l===S,a=m?0:f;p?(C=s?S+1:l,y=s?a:f+1):C=S+1;var b=h.age,v=b+h.ageHeader,x=Math.min(v-h.partTarget,h.targetduration*1.5);if(x>0){if(A&&x>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+x+" with playlist age: "+h.age),x=0;else{var k=Math.floor(x/h.targetduration);if(C+=k,y!==void 0){var H=Math.round(x%h.targetduration/h.partTarget);y+=H}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+x+" skip sn "+k+" to part "+y)}h.tuneInGoal=x}if(c=this.getDeliveryDirectives(h,T.deliveryDirectives,C,y),m||!s){this.loadPlaylist(c);return}}else c=this.getDeliveryDirectives(h,T.deliveryDirectives,C,y);var V=Object(I.computeReloadInterval)(h,o);C!==void 0&&h.canBlockReload&&(V-=h.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(V)+" ms"),this.timer=self.setTimeout(function(){return w.loadPlaylist(c)},V)}else this.clearTimer()},E.getDeliveryDirectives=function(D,T,A,w){var h=Object(N.getSkipValue)(D,A);return T!=null&&T.skip&&D.deltaUpdateFailed&&(A=T.msn,w=T.part,h=N.HlsSkip.No),new N.HlsUrlParameters(A,w,h)},E.retryLoadingOrFail=function(D){var T=this,A=this.hls.config,w=this.retryCount<A.levelLoadingMaxRetry;if(w){var h;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(h=D.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.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 "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return w},P}()},"./src/controller/base-stream-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"State",function(){return S}),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"),j=R("./src/utils/logger.ts"),O=R("./src/events.ts"),P=R("./src/errors.ts"),E=R("./src/types/transmuxer.ts"),L=R("./src/utils/mp4-tools.ts"),D=R("./src/utils/discontinuities.ts"),T=R("./src/controller/fragment-finders.ts"),A=R("./src/controller/level-helper.ts"),w=R("./src/loader/fragment-loader.ts"),h=R("./src/crypt/decrypter.ts"),o=R("./src/utils/time-ranges.ts"),d=R("./src/types/loader.ts");function c(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 C(p,s,a){return s&&c(p.prototype,s),a&&c(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 S={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,x){var k;return k=p.call(this)||this,k.hls=void 0,k.fragPrevious=null,k.fragCurrent=null,k.fragmentTracker=void 0,k.transmuxer=null,k._state=S.STOPPED,k.media=void 0,k.mediaBuffer=void 0,k.config=void 0,k.bitrateTest=!1,k.lastCurrentTime=0,k.nextLoadPosition=0,k.startPosition=0,k.loadedmetadata=!1,k.fragLoadError=0,k.retryDate=0,k.levels=null,k.fragmentLoader=void 0,k.levelLastLoaded=null,k.startFragRequested=!1,k.decrypter=void 0,k.initPTS=[],k.onvseeking=null,k.onvended=null,k.logPrefix="",k.log=void 0,k.warn=void 0,k.logPrefix=x,k.log=j.logger.log.bind(j.logger,x+":"),k.warn=j.logger.warn.bind(j.logger,x+":"),k.hls=b,k.fragmentLoader=new w.default(b.config),k.fragmentTracker=v,k.config=b.config,k.decrypter=new h.default(b,b.config),b.on(O.Events.KEY_LOADED,k.onKeyLoaded,y(k)),k}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=S.STOPPED},a._streamEnded=function(v,x){var k=this.fragCurrent,H=this.fragmentTracker;if(!x.live&&k&&k.sn===x.endSN&&!v.nextStart){var V=H.getState(k);return V===I.FragmentState.PARTIAL||V===I.FragmentState.OK}return!1},a.onMediaAttached=function(v,x){var k=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),k.addEventListener("seeking",this.onvseeking),k.addEventListener("ended",this.onvended);var H=this.config;this.levels&&H.autoStartLoad&&this.state===S.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,x=this.fragCurrent,k=this.media,H=this.mediaBuffer,V=this.state,Q=k?k.currentTime:0,G=z.BufferHelper.bufferInfo(H||k,Q,v.maxBufferHole);if(this.log("media seeking to "+(Object(X.isFiniteNumber)(Q)?Q.toFixed(3):Q)+", state: "+V),V===S.ENDED)this.resetLoadingState();else if(x&&!G.len){var W=v.maxFragLookUpTolerance,q=x.start-W,oe=x.start+x.duration+W,fe=Q>oe;(Q<q||fe)&&(fe&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}k&&(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,x){if(this.state!==S.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=S.IDLE;var k=this.levels[x.frag.level].details;k&&this.loadFragment(x.frag,k,x.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=S.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,x){this.log("Loading key for "+v.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=S.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(O.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,x,k){this._loadFragForPlayback(v,x,k)},a._loadFragForPlayback=function(v,x,k){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,x,k,V).then(function(Q){if(!Q)return;H.fragLoadError=0;var G=H.state;if(H.fragContextChanged(v)){(G===S.FRAG_LOADING||G===S.BACKTRACKING||!H.fragCurrent&&G===S.PARSING)&&(H.fragmentTracker.removeFragment(v),H.state=S.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===S.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,x,k){if(k===void 0&&(k=null),!(v-x))return;var H={startOffset:v,endOffset:x,type:k};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,H)},a._loadInitSegment=function(v){var x=this;this._doFragLoad(v).then(function(k){if(!k||x.fragContextChanged(v)||!x.levels)throw new Error("init load aborted");return k}).then(function(k){var H=x.hls,V=k.payload,Q=v.decryptdata;if(V&&V.byteLength>0&&Q&&Q.key&&Q.iv&&Q.method==="AES-128"){var G=self.performance.now();return x.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}}),k.payload=W,k})}return k}).then(function(k){var H=x.fragCurrent,V=x.hls,Q=x.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;x.state=S.IDLE,x.fragLoadError=0,v.data=new Uint8Array(k.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),k.frag===H&&V.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:H,part:null,id:v.type}),x.tick()}).catch(function(k){x.warn(k),x.resetFragmentLoading(v)})},a.fragContextChanged=function(v){var x=this.fragCurrent;return!v||!x||v.level!==x.level||v.sn!==x.sn||v.urlId!==x.urlId},a.fragBufferedComplete=function(v,x){var k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+o.default.toString(z.BufferHelper.getBuffered(k))),this.state=S.IDLE,this.tick()},a._handleFragmentLoadComplete=function(v){var x=this.transmuxer;if(!x)return;var k=v.frag,H=v.part,V=v.partsLoaded,Q=!V||V.length===0||V.some(function(W){return!W}),G=new E.ChunkMetadata(k.level,k.sn,k.stats.chunkCount+1,0,H?H.index:-1,!Q);x.flush(G)},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,x,k,H){var V=this;if(k===void 0&&(k=null),!this.levels)throw new Error("frag load aborted, missing levels");if(k=Math.max(v.start,k||0),this.config.lowLatencyMode&&x){var Q=x.partList;if(Q&&H){k>v.end&&x.fragmentHint&&(v=x.fragmentHint);var G=this.getNextPart(Q,v,k);if(G>-1){var W=Q[G];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+G+"-"+(Q.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(k.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=S.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:Q[G],targetBufferTime:k}),this.doFragPartsLoad(v,Q,G,H).catch(function(q){return V.handleFragLoadError(q)})}else if(!v.url||this.loadedEndOfParts(Q,k))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(k.toFixed(3))),Object(X.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=S.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:k}),this.fragmentLoader.load(v,H).catch(function(q){return V.handleFragLoadError(q)})},a.doFragPartsLoad=function(v,x,k,H){var V=this;return new Promise(function(Q,G){var W=[],q=function oe(fe){var ve=x[fe];V.fragmentLoader.loadPart(v,ve,H).then(function(ke){W[ve.index]=ke;var Ee=ke.part;V.hls.trigger(O.Events.FRAG_LOADED,ke);var _e=x[fe+1];if(_e&&_e.fragment===v)oe(fe+1);else return Q({frag:v,part:Ee,partsLoaded:W})}).catch(G)};q(k)})},a.handleFragLoadError=function(v){var x=v.data;return x&&x.details===P.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(O.Events.ERROR,x),null},a._handleTransmuxerFlush=function(v){var x=this.getCurrentContext(v);if(!x||this.state!==S.PARSING){this.fragCurrent||(this.state=S.IDLE);return}var k=x.frag,H=x.part,V=x.level,Q=self.performance.now();k.stats.parsing.end=Q,H&&(H.stats.parsing.end=Q),this.updateLevelTiming(k,H,V,v.partial)},a.getCurrentContext=function(v){var x=this.levels,k=v.level,H=v.sn,V=v.part;if(!x||!x[k])return this.warn("Levels object was unset while buffering fragment "+H+" of level "+k+". The current chunk will not be buffered."),null;var Q=x[k],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,x,k,H){if(!v||this.state!==S.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:x,part:k,chunkMeta:H,parent:x.type,data:G};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!k&&this.flushBufferGap(x)},a.flushBufferGap=function(v){var x=this.media;if(!x)return;if(!z.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,v.start);return}var k=x.currentTime,H=z.BufferHelper.bufferInfo(x,k,0),V=v.duration,Q=Math.min(this.config.maxFragLookUpTolerance*2,V*.25),G=Math.max(Math.min(v.start-Q,H.end-Q),k+Q);v.start-G>Q&&this.flushMainBuffer(G,v.start)},a.getFwdBufferInfo=function(v,x){var k=this.config,H=this.getLoadPosition();if(!Object(X.isFiniteNumber)(H))return null;var V=z.BufferHelper.bufferInfo(v,H,k.maxBufferHole);if(V.len===0&&V.nextStart!==void 0){var Q=this.fragmentTracker.getBufferedFrag(H,x);if(Q&&V.nextStart<Q.end)return z.BufferHelper.bufferInfo(v,H,Math.max(V.nextStart,k.maxBufferHole))}return V},a.getMaxBufferLength=function(v){var x=this.config,k;return v?k=Math.max(8*x.maxBufferSize/v,x.maxBufferLength):k=x.maxBufferLength,Math.min(k,x.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var x=this.config,k=v||x.maxBufferLength;return x.maxMaxBufferLength>=k?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,x){var k,H,V=x.fragments,Q=V.length;if(!Q)return null;var G=this.config,W=V[0].start,q;if(x.live){var oe=G.initialLiveManifestSize;if(Q<oe)return this.warn("Not enough fragments to start playback (have: "+Q+", need: "+oe+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(q=this.getInitialLiveFragment(x,V),this.startPosition=q?this.hls.liveSyncPosition||q.start:v)}else v<=W&&(q=V[0]);if(!q){var fe=G.lowLatencyMode?x.partEnd:x.fragmentEnd;q=this.getFragmentAtPosition(v,fe,x)}return(k=q)!==null&&k!==void 0&&k.initSegment&&!((H=q)!==null&&H!==void 0&&H.initSegment.data)&&!this.bitrateTest&&(q=q.initSegment),q},a.getNextPart=function(v,x,k){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&&k<q.start)break;var oe=q.loaded;!oe&&(V||q.independent||Q)&&q.fragment===x&&(H=G),V=oe}return H},a.loadedEndOfParts=function(v,x){var k=v[v.length-1];return k&&x>k.start&&k.loaded},a.getInitialLiveFragment=function(v,x){var k=this.fragPrevious,H=null;if(k){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+k.programDateTime),H=Object(T.findFragmentByPDT)(x,k.endProgramDateTime,this.config.maxFragLookUpTolerance)),!H){var V=k.sn+1;if(V>=v.startSN&&V<=v.endSN){var Q=x[V-v.startSN];k.cc===Q.cc&&(H=Q,this.log("Live playlist, switching playlist, load frag with next SN: "+H.sn))}H||(H=Object(T.findFragWithCC)(x,k.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,x,k){var H=this.config,V=this.fragPrevious,Q=k.fragments,G=k.endSN,W=k.fragmentHint,q=H.maxFragLookUpTolerance,oe=!!(H.lowLatencyMode&&k.partList&&W);oe&&W&&!this.bitrateTest&&(Q=Q.concat(W),G=W.sn);var fe;if(v<x){var ve=v>x-q?0:q;fe=Object(T.findFragmentByPTS)(V,Q,v,ve)}else fe=Q[Q.length-1];if(fe){var ke=fe.sn-k.startSN,Ee=V&&fe.level===V.level,_e=Q[ke+1],Te=this.fragmentTracker.getState(fe);if(Te===I.FragmentState.BACKTRACKED){fe=null;for(var Ce=ke;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 x=this.config,k=this.media;if(!k)return;var H=this.hls.liveSyncPosition,V=k.currentTime,Q=v.fragments[0].start,G=v.edge,W=V>=Q-x.maxFragLookUpTolerance&&V<=G;if(H!==null&&k.duration>H&&(V<H||!W)){var q=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*v.targetduration;(!W&&k.readyState<4||V<G-q)&&(this.loadedmetadata||(this.nextLoadPosition=H),k.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)),k.currentTime=H))}},a.alignPlaylists=function(v,x){var k=this.levels,H=this.levelLastLoaded,V=this.fragPrevious,Q=H!==null?k[H]:null,G=v.fragments.length;if(!G)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,q=!x,oe=v.alignedSliding&&Object(X.isFiniteNumber)(W);if(q||!oe&&!W){Object(D.alignStream)(V,Q,v);var fe=v.fragments[0].start;return this.log("Live playlist sliding: "+fe.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+v.startSN+" prev-sn: "+(V?V.sn:"na")+" fragments: "+G),fe}return W},a.waitForCdnTuneIn=function(v){var x=3;return v.live&&v.canBlockReload&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*x)},a.setStartPosition=function(v,x){var k=this.startPosition;if(k<x&&(k=-1),k===-1||this.lastCurrentTime===-1){var H=v.startTimeOffset;Object(X.isFiniteNumber)(H)?(k=x+H,H<0&&(k+=v.totalduration),k=Math.min(Math.max(x,k),x+v.totalduration),this.log("Start time offset "+H+" found in playlist, adjust startPosition to "+k),this.startPosition=k):v.live?k=this.hls.liveSyncPosition||x:this.startPosition=k=0,this.lastCurrentTime=k}this.nextLoadPosition=k},a.getLoadPosition=function(){var v=this.media,x=0;return this.loadedmetadata&&v?x=v.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},a.handleFragLoadAborted=function(v,x){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(x?" part"+x.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v))&&(this.state=S.IDLE)},a.onFragmentOrKeyLoadError=function(v,x){if(x.fatal)return;var k=x.frag;if(!k||k.type!==v)return;var H=this.fragCurrent;console.assert(H&&k.sn===H.sn&&k.level===H.level&&k.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(k.level))return;var Q=Math.min(Math.pow(2,this.fragLoadError)*V.fragLoadingRetryDelay,V.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+v+" "+k.level+" failed to load, retrying in "+Q+"ms"),this.retryDate=self.performance.now()+Q,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(v===d.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(j.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)},a.afterBufferFlushed=function(v,x,k){if(!v)return;var H=z.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(x,H,k),this.state===S.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},a.resetLiveStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[v].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(v,x,k,H){var V=this,Q=k.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:k,drift:ve,type:q,frag:v,start:oe.startPTS,end:oe.endPTS}),!0}return W},!1);G?(this.state=S.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:v,part:x})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C(s,[{key:"state",get:function(){return this._state},set:function(v){var x=this._state;x!==v&&(this._state=v,this.log(x+"->"+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"),j=R("./src/utils/buffer-helper.ts"),O=R("./src/utils/mediasource-helper.ts"),P=R("./src/loader/fragment.ts"),E=R("./src/controller/buffer-operation-queue.ts"),L=Object(O.getMediaSource)(),D=/([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 d=o.hls,c=o.media,C=o.mediaSource;I.logger.log("[buffer-controller]: Media source opened"),c&&(o.updateMediaElementDuration(),d.trigger(N.Events.MEDIA_ATTACHED,{media:c})),C&&C.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 w=A.prototype;return w.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},w.destroy=function(){this.unregisterListeners(),this.details=null},w.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)},w.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)},w._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},w.onManifestParsed=function(o,d){var c=2;(d.audio&&!d.video||!d.altAudio)&&(c=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=c,this.details=null,I.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},w.onMediaAttaching=function(o,d){var c=this.media=d.media;if(c&&L){var C=this.mediaSource=new L;C.addEventListener("sourceopen",this._onMediaSourceOpen),C.addEventListener("sourceended",this._onMediaSourceEnded),C.addEventListener("sourceclose",this._onMediaSourceClose),c.src=self.URL.createObjectURL(C),this._objectUrl=c.src}},w.onMediaDetaching=function(){var o=this.media,d=this.mediaSource,c=this._objectUrl;if(d){if(I.logger.log("[buffer-controller]: media source detaching"),d.readyState==="open")try{d.endOfStream()}catch(C){I.logger.warn("[buffer-controller]: onMediaDetaching: "+C.message+" while calling endOfStream")}this.onBufferReset(),d.removeEventListener("sourceopen",this._onMediaSourceOpen),d.removeEventListener("sourceended",this._onMediaSourceEnded),d.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(c&&self.URL.revokeObjectURL(c),o.src===c?(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)},w.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(d){var c=o.sourceBuffer[d];try{c&&(o.removeBufferListeners(d),o.mediaSource&&o.mediaSource.removeSourceBuffer(c),o.sourceBuffer[d]=void 0)}catch(C){I.logger.warn("[buffer-controller]: Failed to reset the "+d+" buffer",C)}}),this._initSourceBuffer()},w.onBufferCodecs=function(o,d){var c=this,C=this.getSourceBufferTypes().length;if(Object.keys(d).forEach(function(y){if(C){var m=c.tracks[y];if(m&&typeof m.buffer.changeType=="function"){var l=d[y],S=l.codec,f=l.levelCodec,p=l.container,s=(m.levelCodec||m.codec).replace(D,"$1"),a=(f||S).replace(D,"$1");if(s!==a){var b=p+";codecs="+(f||S);c.appendChangeType(y,b)}}}else c.pendingTracks[y]=d[y]}),C)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},w.appendChangeType=function(o,d){var c=this,C=this.operationQueue,y={execute:function(){var l=c.sourceBuffer[o];l&&(I.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+d),l.changeType(d)),C.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(l){I.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",l)}};C.append(y,o)},w.onBufferAppending=function(o,d){var c=this,C=this.hls,y=this.operationQueue,m=this.tracks,l=d.data,S=d.type,f=d.frag,p=d.part,s=d.chunkMeta,a=s.buffering[S],b=self.performance.now();a.start=b;var v=f.stats.buffering,x=p?p.stats.buffering:null;v.start===0&&(v.start=b),x&&x.start===0&&(x.start=b);var k=m.audio,H=S==="audio"&&s.id===1&&(k==null?void 0:k.container)==="audio/mpeg",V={execute:function(){if(a.executeStart=self.performance.now(),H){var G=c.sourceBuffer[S];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)}}c.appendExecutor(l,S)},onStart:function(){},onComplete:function(){var G=self.performance.now();a.executeEnd=a.end=G,v.first===0&&(v.first=G),x&&x.first===0&&(x.first=G);var W=c.sourceBuffer,q={};for(var oe in W)q[oe]=j.BufferHelper.getBuffered(W[oe]);c.appendError=0,c.hls.trigger(N.Events.BUFFER_APPENDED,{type:S,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 "+S+" 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:(c.appendError++,W.details=z.ErrorDetails.BUFFER_APPEND_ERROR,c.appendError>C.config.appendErrorMaxRetry&&(I.logger.error("[buffer-controller]: Failed "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0)),C.trigger(N.Events.ERROR,W)}};y.append(V,S)},w.onBufferFlushing=function(o,d){var c=this,C=this.operationQueue,y=function(l){return{execute:c.removeExecutor.bind(c,l,d.startOffset,d.endOffset),onStart:function(){},onComplete:function(){c.hls.trigger(N.Events.BUFFER_FLUSHED,{type:l})},onError:function(f){I.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",f)}}};d.type?C.append(y(d.type),d.type):this.getSourceBufferTypes().forEach(function(m){C.append(y(m),m)})},w.onFragParsed=function(o,d){var c=this,C=d.frag,y=d.part,m=[],l=y?y.elementaryStreams:C.elementaryStreams;l[P.ElementaryStreamTypes.AUDIOVIDEO]?m.push("audiovideo"):(l[P.ElementaryStreamTypes.AUDIO]&&m.push("audio"),l[P.ElementaryStreamTypes.VIDEO]&&m.push("video"));var S=function(){var p=self.performance.now();C.stats.buffering.end=p,y&&(y.stats.buffering.end=p);var s=y?y.stats:C.stats;c.hls.trigger(N.Events.FRAG_BUFFERED,{frag:C,part:y,stats:s,id:C.type})};m.length===0&&I.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+C.type+" level: "+C.level+" sn: "+C.sn),this.blockBuffers(S,m)},w.onFragChanged=function(o,d){this.flushBackBuffer()},w.onBufferEos=function(o,d){var c=this,C=this.getSourceBufferTypes().reduce(function(y,m){var l=c.sourceBuffer[m];return(!d.type||d.type===m)&&(l&&!l.ended&&(l.ended=!0,I.logger.log("[buffer-controller]: "+m+" sourceBuffer now EOS"))),y&&!!(!l||l.ended)},!0);C&&this.blockBuffers(function(){var y=c.mediaSource;if(!y||y.readyState!=="open")return;y.endOfStream()})},w.onLevelUpdated=function(o,d){var c=d.details;if(!c.fragments.length)return;this.details=c,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},w.flushBackBuffer=function(){var o=this.hls,d=this.details,c=this.media,C=this.sourceBuffer;if(!c||d===null)return;var y=this.getSourceBufferTypes();if(!y.length)return;var m=d.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(X.isFiniteNumber)(m)||m<0)return;var l=c.currentTime,S=d.levelTargetDuration,f=Math.max(m,S),p=Math.floor(l/S)*S-f;y.forEach(function(s){var a=C[s];if(a){var b=j.BufferHelper.getBuffered(a);b.length>0&&p>b.start(0)&&(o.trigger(N.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),d.live&&o.trigger(N.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),o.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:s}))}})},w.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,d=this.hls,c=this.media,C=this.mediaSource,y=o.fragments[0].start+o.totalduration,m=c.duration,l=Object(X.isFiniteNumber)(C.duration)?C.duration:0;o.live&&d.config.liveDurationInfinity?(I.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),C.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)),C.duration=y)},w.updateSeekableRange=function(o){var d=this.mediaSource,c=o.fragments,C=c.length;if(C&&o.live&&d!==null&&d!==void 0&&d.setLiveSeekableRange){var y=Math.max(0,c[0].start),m=Math.max(y,y+o.totalduration);d.setLiveSeekableRange(y,m)}},w.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,d=this.operationQueue,c=this.pendingTracks,C=Object.keys(c).length;if(C&&!o||C===2){this.createSourceBuffers(c),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){d.executeNext(m)})}},w.createSourceBuffers=function(o){var d=this.sourceBuffer,c=this.mediaSource;if(!c)throw Error("createSourceBuffers called when mediaSource was null");var C=0;for(var y in o)if(!d[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,S=m.container+";codecs="+l;I.logger.log("[buffer-controller]: creating sourceBuffer("+S+")");try{var f=d[y]=c.addSourceBuffer(S),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},C++}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:S})}}C&&this.hls.trigger(N.Events.BUFFER_CREATED,{tracks:this.tracks})},w._onSBUpdateStart=function(o){var d=this.operationQueue,c=d.current(o);c.onStart()},w._onSBUpdateEnd=function(o){var d=this.operationQueue,c=d.current(o);c.onComplete(),d.shiftAndExecuteNext(o)},w._onSBUpdateError=function(o,d){I.logger.error("[buffer-controller]: "+o+" SourceBuffer error",d),this.hls.trigger(N.Events.ERROR,{type:z.ErrorTypes.MEDIA_ERROR,details:z.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var c=this.operationQueue.current(o);c&&c.onError(d)},w.removeExecutor=function(o,d,c){var C=this.media,y=this.mediaSource,m=this.operationQueue,l=this.sourceBuffer,S=l[o];if(!C||!y||!S){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)(C.duration)?C.duration:Infinity,p=Object(X.isFiniteNumber)(y.duration)?y.duration:Infinity,s=Math.max(0,d),a=Math.min(c,f,p);a>s?(I.logger.log("[buffer-controller]: Removing ["+s+","+a+"] from the "+o+" SourceBuffer"),console.assert(!S.updating,o+" sourceBuffer must not be updating"),S.remove(s,a)):m.shiftAndExecuteNext(o)},w.appendExecutor=function(o,d){var c=this.operationQueue,C=this.sourceBuffer,y=C[d];if(!y){I.logger.warn("[buffer-controller]: Attempting to append to the "+d+" SourceBuffer, but it does not exist"),c.shiftAndExecuteNext(d);return}y.ended=!1,console.assert(!y.updating,d+" sourceBuffer must not be updating"),y.appendBuffer(o)},w.blockBuffers=function(o,d){var c=this;if(d===void 0&&(d=this.getSourceBufferTypes()),!d.length){I.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var C=this.operationQueue,y=d.map(function(m){return C.appendBlocker(m)});Promise.all(y).then(function(){o(),d.forEach(function(m){var l=c.sourceBuffer[m];(!l||!l.updating)&&C.shiftAndExecuteNext(m)})})},w.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},w.addBufferListener=function(o,d,c){var C=this.sourceBuffer[o];if(!C)return;var y=c.bind(this,o);this.listeners[o].push({event:d,listener:y}),C.addEventListener(d,y)},w.removeBufferListeners=function(o){var d=this.sourceBuffer[o];if(!d)return;this.listeners[o].forEach(function(c){d.removeEventListener(c.event,c.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(j){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=j}var z=I.prototype;return z.append=function(O,P){var E=this.queues[P];E.push(O),E.length===1&&this.buffers[P]&&this.executeNext(P)},z.insertAbort=function(O,P){var E=this.queues[P];E.unshift(O),this.executeNext(P)},z.appendBlocker=function(O){var P,E=new Promise(function(D){P=D}),L={execute:P,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,O),E},z.executeNext=function(O){var P=this.buffers,E=this.queues,L=P[O],D=E[O];if(D.length){var T=D[0];try{T.execute()}catch(A){X.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(A),(!L||!L.updating)&&(D.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(j,O){for(var P=0;P<O.length;P++){var E=O[P];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(j,E.key,E)}}function I(j,O,P){return O&&N(j.prototype,O),P&&N(j,P),j}var z=function(){function j(P){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=P,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=j.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){j.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 D=this.hls;this.restrictedLevels=[],this.firstLevel=L.firstLevel,D.config.capLevelToPlayerSize&&L.video&&this.startCapping()},O.onBufferCodecs=function(E,L){var D=this.hls;D.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,D=this.hls.levels;if(!D.length)return-1;var T=D.filter(function(A,w){return j.isLevelAllowed(w,L.restrictedLevels)&&w<=E});return this.clientRect=null,j.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 D=E.getBoundingClientRect();L.width=D.width,L.height=D.height,!L.width&&!L.height&&(L.width=D.right-D.left||E.width||0,L.height=D.bottom-D.top||E.height||0)}return this.clientRect=L,L},j.isLevelAllowed=function(E,L){return L===void 0&&(L=[]),L.indexOf(E)===-1},j.getMaxLevelByMediaSize=function(E,L,D){if(!E||!E.length)return-1;for(var T=function(d,c){return c?d.width!==c.width||d.height!==c.height:!0},A=E.length-1,w=0;w<E.length;w+=1){var h=E[w];if((h.width>=L||h.height>=D)&&T(h,E[w+1])){A=w;break}}return A},I(j,[{key:"mediaWidth",get:function(){return this.getDimensions().width*j.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*j.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var E=1;try{E=self.devicePixelRatio}catch(L){}return E}}]),j}();$.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 j(A,w){for(var h=0;h<w.length;h++){var o=w[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(A,o.key,o)}}function O(A,w,h){return w&&j(A.prototype,w),h&&j(A,h),A}function P(A,w){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))||w&&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,w){if(!A)return;if(typeof A=="string")return L(A,w);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,w)}function L(A,w){(w==null||w>A.length)&&(w=A.length);for(var h=0,o=new Array(w);h<w;h++)o[h]=A[h];return o}function D(){return D=Object.assign||function(A){for(var w=1;w<arguments.length;w++){var h=arguments[w];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(A[o]=h[o])}return A},D.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(C){try{o.apply(C,{ot:N.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(y){z.logger.warn("Could not generate manifest CMCD data.",y)}},this.applyFragmentData=function(C){try{var y=C.frag,m=o.hls.levels[y.level],l=o.getObjectType(y),S={d:y.duration*1e3,ot:l};(l===N.CMCDObjectType.VIDEO||l===N.CMCDObjectType.AUDIO||l==N.CMCDObjectType.MUXED)&&(S.br=m.bitrate/1e3,S.tb=o.getTopBandwidth(l),S.bl=o.getBufferLength(l)),o.apply(C,S)}catch(f){z.logger.warn("Could not generate segment CMCD data.",f)}},this.hls=h;var d=this.config=h.config,c=d.cmcd;c!=null&&(d.pLoader=this.createPlaylistLoader(),d.fLoader=this.createFragmentLoader(),this.sid=c.sessionId||A.uuid(),this.cid=c.contentId,this.useHeaders=c.useHeaders===!0,this.registerListeners())}var w=A.prototype;return w.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)},w.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()},w.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},w.onMediaAttached=function(o,d){this.media=d.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},w.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},w.onBufferCreated=function(o,d){var c,C;this.audioBuffer=(c=d.tracks.audio)===null||c===void 0?void 0:c.buffer,this.videoBuffer=(C=d.tracks.video)===null||C===void 0?void 0:C.buffer},w.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}},w.apply=function(o,d){d===void 0&&(d={}),D(d,this.createData());var c=d.ot===N.CMCDObjectType.INIT||d.ot===N.CMCDObjectType.VIDEO||d.ot===N.CMCDObjectType.MUXED;if(this.starved&&c&&(d.bs=!0,d.su=!0,this.starved=!1),d.su==null&&(d.su=this.buffering),this.useHeaders){var C=A.toHeaders(d);if(!Object.keys(C).length)return;o.headers||(o.headers={}),D(o.headers,C)}else{var y=A.toQuery(d);if(!y)return;o.url=A.appendQueryToUri(o.url,y)}},w.getObjectType=function(o){var d=o.type;return d==="subtitle"?N.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?N.CMCDObjectType.INIT:d==="audio"?N.CMCDObjectType.AUDIO:d==="main"?this.hls.audioTracks.length?N.CMCDObjectType.VIDEO:N.CMCDObjectType.MUXED:void 0},w.getTopBandwidth=function(o){for(var d=0,c=o===N.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,C=P(c),y;!(y=C()).done;){var m=y.value;m.bitrate>d&&(d=m.bitrate)}return d>0?d:NaN},w.getBufferLength=function(o){var d=this.hls.media,c=o===N.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!c||!d)return NaN;var C=I.BufferHelper.bufferInfo(c,d.currentTime,this.config.maxBufferHole);return C.len*1e3},w.createPlaylistLoader=function(){var o=this.config.pLoader,d=this.applyPlaylistData,c=o||this.config.loader;return function(){function C(m){this.loader=void 0,this.loader=new c(m)}var y=C.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,S,f){d(l),this.loader.load(l,S,f)},O(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},w.createFragmentLoader=function(){var o=this.config.fLoader,d=this.applyFragmentData,c=o||this.config.loader;return function(){function C(m){this.loader=void 0,this.loader=new c(m)}var y=C.prototype;return y.destroy=function(){this.loader.destroy()},y.abort=function(){this.loader.abort()},y.load=function(l,S,f){d(l),this.loader.load(l,S,f)},O(C,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),C}()},A.uuid=function(){var o=URL.createObjectURL(new Blob),d=o.toString();return URL.revokeObjectURL(o),d.substr(d.lastIndexOf("/")+1)},A.serialize=function(o){for(var d=[],c=function(H){return!Number.isNaN(H)&&H!=null&&H!==""&&H!==!1},C=function(H){return Math.round(H)},y=function(H){return C(H/100)*100},m=function(H){return encodeURIComponent(H)},l={br:C,d:C,bl:y,dl:y,mtp:y,nor:m,rtp:y,tb:C},S=Object.keys(o||{}).sort(),f=P(S),p;!(p=f()).done;){var s=p.value,a=o[s];if(!c(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,x=void 0;s==="ot"||s==="sf"||s==="st"?x=s+"="+a:v==="boolean"?x=s:v==="number"?x=s+"="+a:x=s+"="+JSON.stringify(a),d.push(x)}return d.join(",")},A.toHeaders=function(o){for(var d=Object.keys(o),c={},C=["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,S=d;l<S.length;l++){var f=S[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&&(c["CMCD-"+C[s]]=a)}return c},A.toQuery=function(o){return"CMCD="+encodeURIComponent(A.serialize(o))},A.appendQueryToUri=function(o,d){if(!d)return o;var c=o.includes("?")?"&":"?";return""+o+c+d},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 j(T,A){for(var w=0;w<A.length;w++){var h=A[w];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function O(T,A,w){return A&&j(T.prototype,A),w&&j(T,w),T}var P=3,E=function(A,w,h){var o={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(d){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+d+'"',robustness:h.audioRobustness||""})}),w.forEach(function(d){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+d+'"',robustness:h.videoRobustness||""})}),[o]},L=function(A,w,h,o){switch(A){case z.KeySystems.WIDEVINE:return E(w,h,o);default:throw new Error("Unknown key-system: "+A)}},D=function(){function T(w){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=w,this._config=w.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,d){var c=this,C=L(h,o,d,this._drmSystemOptions);I.logger.log("Requesting encrypted media key-system access");var y=this.requestMediaKeySystemAccess(h,C);this.mediaKeysPromise=y.then(function(m){return c._onMediaKeySystemAccessObtained(h,m)}),y.catch(function(m){I.logger.error('Failed to obtain key-system "'+h+'" access:',m)})},A._onMediaKeySystemAccessObtained=function(h,o){var d=this;I.logger.log('Access for key-system "'+h+'" obtained');var c={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:h};this._mediaKeysList.push(c);var C=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(y){return c.mediaKeys=y,I.logger.log('Media-keys created for key-system "'+h+'"'),d._onMediaKeysCreated(),y});return C.catch(function(y){I.logger.error("Failed to create media-keys:",y)}),C},A._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),h._onNewMediaKeySession(o.mediaKeysSession))})},A._onNewMediaKeySession=function(h){var o=this;I.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(d){o._onKeySessionMessage(h,d.message)},!1)},A._onKeySessionMessage=function(h,o){I.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(d){I.logger.log("Received license data (length: "+(d&&d.byteLength)+"), updating key-session"),h.update(d)})},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 d=function(C){if(!o._media)return;o._attemptSetMediaKeys(C),o._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(d).catch(d)},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 d=this,c=this._mediaKeysList[0];if(!c){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(c.mediaKeysSessionInitialized){I.logger.warn("Key-Session already initialized but requested again");return}var C=c.mediaKeysSession;if(!C){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'),c.mediaKeysSessionInitialized=!0,C.generateRequest(h,o).then(function(){I.logger.debug("Key-session generation succeeded")}).catch(function(y){I.logger.error("Error generating key-session request:",y),d.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,d){var c=new XMLHttpRequest;c.responseType="arraybuffer",c.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,c,h,o,d);var C=this._licenseXhrSetup;if(C)try{C.call(this.hls,c,h),C=void 0}catch(y){I.logger.error(y)}try{c.readyState||c.open("POST",h,!0),C&&C.call(this.hls,c,h)}catch(y){throw new Error("issue setting up KeySystem license XHR "+y)}return c},A._onLicenseRequestReadyStageChange=function(h,o,d,c){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,I.logger.log("License request succeeded");var C=h.response,y=this._licenseResponseCallback;if(y)try{C=y.call(this.hls,h,o)}catch(l){I.logger.error(l)}c(C)}else{if(I.logger.error("License Request XHR failed ("+o+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>P){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=P-this._requestLicenseFailureCount+1;I.logger.warn("Retrying license request, "+m+" attempts left"),this._requestLicense(d,c)}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 d=this._mediaKeysList[0];if(!d){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 c=this.getLicenseServerUrl(d.mediaKeySystemDomain),C=this._createLicenseXhr(c,h,o);I.logger.log("Sending license request to URL: "+c);var y=this._generateLicenseRequestChallenge(d,h);C.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 d=o.media;this._media=d,d.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(d){if(d.mediaKeysSession)return d.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},A.onManifestParsed=function(h,o){if(!this._emeEnabled)return;var d=o.levels.map(function(C){return C.audioCodec}).filter(function(C){return!!C}),c=o.levels.map(function(C){return C.videoCodec}).filter(function(C){return!!C});this._attemptKeySystemAccess(z.KeySystems.WIDEVINE,d,c)},O(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();$.default=D},"./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 j=z.prototype;return j.setStreamController=function(P){this.streamController=P},j.registerListeners=function(){this.hls.on(X.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},j.unregisterListeners=function(){this.hls.off(X.Events.MEDIA_ATTACHING,this.onMediaAttaching)},j.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},j.onMediaAttaching=function(P,E){var L=this.hls.config;if(L.capLevelOnFPSDrop){var D=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},j.checkFPS=function(P,E,L){var D=performance.now();if(E){if(this.lastTime){var T=D-this.lastTime,A=L-this.lastDroppedFrames,w=E-this.lastDecodedFrames,h=1e3*A/T,o=this.hls;if(o.trigger(X.Events.FPS_DROP,{currentDropped:A,currentDecoded:w,totalDroppedFrames:L}),h>0&&A>o.config.fpsDroppedMonitoringThreshold*w){var d=o.currentLevel;N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=d)&&(d=d-1,o.trigger(X.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:o.currentLevel}),o.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=L,this.lastDecodedFrames=E}},j.checkFPSInterval=function(){var P=this.media;if(P)if(this.isVideoPlaybackQualityAvailable){var E=P.getVideoPlaybackQuality();this.checkFPS(P,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(P,P.webkitDecodedFrameCount,P.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 j}),R.d($,"pdtWithinToleranceTest",function(){return O}),R.d($,"findFragWithCC",function(){return P});var X=R("./src/polyfills/number.ts"),N=R("./src/utils/binary-search.ts");function I(E,L,D){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;D=D||0;for(var w=0;w<E.length;++w){var h=E[w];if(O(L,D,h))return h}return null}function z(E,L,D,T){D===void 0&&(D=0),T===void 0&&(T=0);var A=null;if(E?A=L[E.sn-L[0].sn+1]||null:D===0&&L[0].start===0&&(A=L[0]),A&&j(D,T,A)===0)return A;var w=N.default.search(L,j.bind(null,D,T));return w||A}function j(E,L,D){E===void 0&&(E=0),L===void 0&&(L=0);var T=Math.min(L,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-T<=E?1:D.start-T>E&&D.start?-1:0}function O(E,L,D){var T=Math.min(L,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,A=D.endProgramDateTime||0;return A-T>E}function P(E,L){return N.default.search(E,function(D){return D.cc<L?1:D.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(P){P.NOT_LOADED="NOT_LOADED",P.BACKTRACKED="BACKTRACKED",P.APPENDING="APPENDING",P.PARTIAL="PARTIAL",P.OK="OK"})(I||(I={}));var z=function(){function P(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=P.prototype;return E._registerListeners=function(){var D=this.hls;D.on(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E._unregisterListeners=function(){var D=this.hls;D.off(X.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(X.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(X.Events.FRAG_LOADED,this.onFragLoaded,this)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(D,T){if(T===N.PlaylistLevelType.MAIN){var A=this.activeFragment,w=this.activeParts;if(!A)return null;if(w)for(var h=w.length;h--;){var o=w[h],d=o?o.end:A.appendedPTS;if(o.start<=D&&d!==void 0&&D<=d)return h>9&&(this.activeParts=w.slice(h-9)),o}else if(A.start<=D&&A.appendedPTS!==void 0&&D<=A.appendedPTS)return A}return this.getBufferedFrag(D,T)},E.getBufferedFrag=function(D,T){for(var A=this.fragments,w=Object.keys(A),h=w.length;h--;){var o=A[w[h]];if((o==null?void 0:o.body.type)===T&&o.buffered){var d=o.body;if(d.start<=D&&D<=d.end)return d}}return null},E.detectEvictedFragments=function(D,T,A){var w=this;Object.keys(this.fragments).forEach(function(h){var o=w.fragments[h];if(!o)return;if(!o.buffered){o.body.type===A&&w.removeFragment(o.body);return}var d=o.range[D];if(!d)return;d.time.some(function(c){var C=!w.isTimeBuffered(c.startPTS,c.endPTS,T);return C&&w.removeFragment(o.body),C})})},E.detectPartialFragments=function(D){var T=this,A=this.timeRanges,w=D.frag,h=D.part;if(!A||w.sn==="initSegment")return;var o=O(w),d=this.fragments[o];if(!d)return;Object.keys(A).forEach(function(c){var C=w.elementaryStreams[c];if(!C)return;var y=A[c],m=h!==null||C.partial===!0;d.range[c]=T.getBufferedTimes(w,h,m,y)}),d.backtrack=d.loaded=null,Object.keys(d.range).length?d.buffered=!0:this.removeFragment(d.body)},E.fragBuffered=function(D){var T=O(D),A=this.fragments[T];A&&(A.backtrack=A.loaded=null,A.buffered=!0)},E.getBufferedTimes=function(D,T,A,w){for(var h={time:[],partial:A},o=T?T.start:D.start,d=T?T.end:D.end,c=D.minEndPTS||d,C=D.maxStartPTS||o,y=0;y<w.length;y++){var m=w.start(y)-this.bufferPadding,l=w.end(y)+this.bufferPadding;if(C>=m&&c<=l){h.time.push({startPTS:Math.max(o,w.start(y)),endPTS:Math.min(d,w.end(y))});break}else if(o<l&&d>m)h.partial=!0,h.time.push({startPTS:Math.max(o,w.start(y)),endPTS:Math.min(d,w.end(y))});else if(d<=m)break}return h},E.getPartialFragment=function(D){var T=null,A,w,h,o=0,d=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(C){var y=c[C];if(!y)return;j(y)&&(w=y.body.start-d,h=y.body.end+d,D>=w&&D<=h&&(A=Math.min(D-w,h-D),o<=A&&(T=y.body,o=A)))}),T},E.getState=function(D){var T=O(D),A=this.fragments[T];return A?A.buffered?j(A)?I.PARTIAL:I.OK:A.backtrack?I.BACKTRACKED:I.APPENDING:I.NOT_LOADED},E.backtrack=function(D,T){var A=O(D),w=this.fragments[A];if(!w||w.backtrack)return null;var h=w.backtrack=T||w.loaded;return w.loaded=null,h},E.getBacktrackData=function(D){var T=O(D),A=this.fragments[T];if(A){var w,h=A.backtrack;if(h!=null&&(w=h.payload)!==null&&w!==void 0&&w.byteLength)return h;this.removeFragment(D)}return null},E.isTimeBuffered=function(D,T,A){for(var w,h,o=0;o<A.length;o++){if(w=A.start(o)-this.bufferPadding,h=A.end(o)+this.bufferPadding,D>=w&&T<=h)return!0;if(T<=w)return!1}return!1},E.onFragLoaded=function(D,T){var A=T.frag,w=T.part;if(A.sn==="initSegment"||A.bitrateTest||w)return;var h=O(A);this.fragments[h]={body:A,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}},E.onBufferAppended=function(D,T){var A=this,w=T.frag,h=T.part,o=T.timeRanges;if(w.type===N.PlaylistLevelType.MAIN)if(this.activeFragment=w,h){var d=this.activeParts;d||(this.activeParts=d=[]),d.push(h)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(c){var C=o[c];if(A.detectEvictedFragments(c,C),!h)for(var y=0;y<C.length;y++)w.appendedPTS=Math.max(C.end(y),w.appendedPTS||0)})},E.onFragBuffered=function(D,T){this.detectPartialFragments(T)},E.hasFragment=function(D){var T=O(D);return!!this.fragments[T]},E.removeFragmentsInRange=function(D,T,A){var w=this;Object.keys(this.fragments).forEach(function(h){var o=w.fragments[h];if(!o)return;if(o.buffered){var d=o.body;d.type===A&&d.start<T&&d.end>D&&w.removeFragment(d)}})},E.removeFragment=function(D){var T=O(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[T]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},P}();function j(P){var E,L;return P.buffered&&(((E=P.range.video)===null||E===void 0?void 0:E.partial)||((L=P.range.audio)===null||L===void 0?void 0:L.partial))}function O(P){return P.type+"_"+P.level+"_"+P.urlId+"_"+P.sn}},"./src/controller/gap-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"STALL_MINIMUM_DURATION_MS",function(){return j}),R.d($,"MAX_START_GAP_JUMP",function(){return O}),R.d($,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return P}),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"),j=250,O=2,P=.1,E=.05,L=function(){function D(A,w,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=w,this.fragmentTracker=h,this.hls=o}var T=D.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(w){var h=this.config,o=this.media,d=this.stalled,c=o.currentTime,C=o.seeking,y=this.seeking&&!C,m=!this.seeking&&C;if(this.seeking=C,c!==w){if(this.moved=!0,d!==null){if(this.stallReported){var l=self.performance.now()-d;z.logger.warn("playback not stuck anymore @"+c+", 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 S=X.BufferHelper.bufferInfo(o,c,0),f=S.len>0,p=S.nextStart||0;if(!f&&!p)return;if(C){var s=S.len>O,a=!p||p-c>O&&!this.fragmentTracker.getPartialFragment(c);if(s||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,v=Math.max(p,S.start||0)-c,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,k=x==null||((b=x.details)===null||b===void 0)?void 0:b.live,H=k?x.details.targetduration*2:O;if(v>0&&v<=H){this._trySkipBufferHole(null);return}}var V=self.performance.now();if(d===null){this.stalled=V;return}var Q=V-d;!C&&Q>=j&&this._reportStall(S.len);var G=X.BufferHelper.bufferInfo(o,c,h.maxBufferHole);this._tryFixBufferStall(G,Q)},T._tryFixBufferStall=function(w,h){var o=this.config,d=this.fragmentTracker,c=this.media,C=c.currentTime,y=d.getPartialFragment(C);if(y){var m=this._trySkipBufferHole(y);if(m)return}w.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(w){var h=this.hls,o=this.media,d=this.stallReported;d||(this.stallReported=!0,z.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+w+")"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:w}))},T._trySkipBufferHole=function(w){for(var h=this.config,o=this.hls,d=this.media,c=d.currentTime,C=0,y=X.BufferHelper.getBuffered(d),m=0;m<y.length;m++){var l=y.start(m);if(c+h.maxBufferHole>=C&&c<l){var S=Math.max(l+E,d.currentTime+P);return z.logger.warn("skipping hole, adjusting currentTime from "+c+" to "+S),this.moved=!0,this.stalled=null,d.currentTime=S,w&&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 "+c+" to "+S,frag:w}),S}C=y.end(m)}return 0},T._tryNudgeBuffer=function(){var w=this.config,h=this.hls,o=this.media,d=o.currentTime,c=(this.nudgeRetry||0)+1;if(this.nudgeRetry=c,c<w.nudgeMaxRetry){var C=d+c*w.nudgeOffset;z.logger.warn("Nudging 'currentTime' from "+d+" to "+C),o.currentTime=C,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 @"+d+" after "+w.nudgeMaxRetry+" nudges"),h.trigger(I.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},D}()},"./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,j=function(){function O(E){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=E,this._registerListeners()}var P=O.prototype;return P.destroy=function(){this._unregisterListeners()},P._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)},P._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)},P.onMediaAttached=function(L,D){this.media=D.media},P.onMediaDetaching=function(){if(!this.id3Track)return;Object(N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},P.getID3Track=function(L){if(!this.media)return;for(var D=0;D<L.length;D++){var T=L[D];if(T.kind==="metadata"&&T.label==="id3")return Object(N.sendAddTrackEvent)(T,this.media),T}return this.media.addTextTrack("metadata","id3")},P.onFragParsingMetadata=function(L,D){if(!this.media)return;var T=D.frag,A=D.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var w=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<A.length;h++){var o=I.getID3Frames(A[h].data);if(o){var d=A[h].pts,c=h<A.length-1?A[h+1].pts:T.end,C=c-d;C<=0&&(c=d+z);for(var y=0;y<o.length;y++){var m=o[y];if(!I.isTimeStampFrame(m)){var l=new w(d,c,"");l.value=m,this.id3Track.addCue(l)}}}}},P.onBufferFlushing=function(L,D){var T=D.startOffset,A=D.endOffset,w=D.type;if(!w||w==="audio"){var h=this.id3Track;h&&Object(N.removeCuesInRange)(h,T,A)}},O}();$.default=j},"./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(P,E){for(var L=0;L<E.length;L++){var D=E[L];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(P,D.key,D)}}function j(P,E,L){return E&&z(P.prototype,E),L&&z(P,L),P}var O=function(){function P(L){var D=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 D.timeupdate()},this.hls=L,this.config=L.config,this.registerListeners()}var E=P.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(D,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(D,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(D,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 D=this.media,T=this.levelDetails;if(!D||!T)return;this.currentTime=D.currentTime;var A=this.computeLatency();if(A===null)return;this._latency=A;var w=this.config,h=w.lowLatencyMode,o=w.maxLiveSyncPlaybackRate;if(!h||o===1)return;var d=this.targetLatency;if(d===null)return;var c=A-d,C=Math.min(this.maxLatency,d+T.targetduration),y=c<C;if(T.live&&y&&c>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,o)),l=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;D.playbackRate=Math.min(m,Math.max(1,l))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)},E.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},E.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},j(P,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,T=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:T?D.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var T=D.holdBack,A=D.partHoldBack,w=D.targetduration,h=this.config,o=h.liveSyncDuration,d=h.liveSyncDurationCount,c=h.lowLatencyMode,C=this.hls.userConfig,y=c&&A||T;(C.liveSyncDuration||C.liveSyncDurationCount||y===0)&&(y=o!==void 0?o:d*w);var m=w,l=1;return y+Math.min(this.stallCount*l,m)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),T=this.targetLatency,A=this.levelDetails;if(D===null||T===null||A===null)return null;var w=A.edge,h=D-T-this.edgeStalled,o=w-A.totalduration,d=w-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(o,h),d)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var T=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-T,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,T=this.levelDetails;if(!D||!T)return 0;var A=D.buffered.length;return A?D.buffered.end(A-1):T.edge-this.currentTime}}]),P}()},"./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"),j=R("./src/controller/level-helper.ts"),O=R("./src/controller/base-playlist-controller.ts"),P=R("./src/types/loader.ts");function E(){return E=Object.assign||function(o){for(var d=1;d<arguments.length;d++){var c=arguments[d];for(var C in c)Object.prototype.hasOwnProperty.call(c,C)&&(o[C]=c[C])}return o},E.apply(this,arguments)}function L(o,d){for(var c=0;c<d.length;c++){var C=d[c];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function D(o,d,c){return d&&L(o.prototype,d),c&&L(o,c),o}function T(o,d){o.prototype=Object.create(d.prototype),o.prototype.constructor=o,A(o,d)}function A(o,d){return A=Object.setPrototypeOf||function(C,y){return C.__proto__=y,C},A(o,d)}var w=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){T(d,o);function d(C){var y;return y=o.call(this,C,"[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 c=d.prototype;return c._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)},c._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)},c.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},c.startLoad=function(){var y=this._levels;y.forEach(function(m){m.loadError=0}),o.prototype.startLoad.call(this)},c.onManifestLoaded=function(y,m){var l=[],S=[],f=[],p,s={},a,b=!1,v=!1,x=!1;if(m.levels.forEach(function(Q){var G=Q.attrs;b=b||!!(Q.width&&Q.height),v=v||!!Q.videoCodec,x=x||!!Q.audioCodec,w&&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(j.addGroupId)(a,"audio",G.AUDIO),G.SUBTITLES&&Object(j.addGroupId)(a,"text",G.SUBTITLES))}),(b||v)&&x&&(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&&(S=m.audioTracks.filter(function(Q){return!Q.audioCodec||Object(z.isCodecSupportedInMp4)(Q.audioCodec,"audio")}),Object(j.assignTrackIdsByGroup)(S)),m.subtitles&&(f=m.subtitles,Object(j.assignTrackIdsByGroup)(f)),l.length>0){p=l[0].bitrate,l.sort(function(Q,G){return Q.bitrate-G.bitrate}),this._levels=l;for(var k=0;k<l.length;k++)if(l[k].bitrate===p){this._firstLevel=k,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+p);break}var H=x&&!v,V={levels:l,audioTracks:S,subtitleTracks:f,firstLevel:this._firstLevel,stats:m.stats,audio:x,video:v,altAudio:!H&&S.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"})},c.onError=function(y,m){if(o.prototype.onError.call(this,y,m),m.fatal)return;var l=m.context,S=this._levels[this.currentLevelIndex];if(l&&(l.type===P.PlaylistContextType.AUDIO_TRACK&&S.audioGroupIds&&l.groupId===S.audioGroupIds[S.urlId]||l.type===P.PlaylistContextType.SUBTITLE_TRACK&&S.textGroupIds&&l.groupId===S.textGroupIds[S.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)},c.recoverLevel=function(y,m,l,S){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(S){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)}}},c.redundantFailover=function(y){var m=this._levels[y],l=m.url.length;if(l>1){var S=(m.urlId+1)%l;this.warn("Switching to redundant URL-id "+S),this._levels.forEach(function(f){f.urlId=S}),this.level=y}},c.onFragLoaded=function(y,m){var l=m.frag;if(l!==void 0&&l.type===P.PlaylistLevelType.MAIN){var S=this._levels[l.level];S!==void 0&&(S.fragmentError=0,S.loadError=0)}},c.onLevelLoaded=function(y,m){var l,S=m.level,f=m.details,p=this._levels[S];if(!p){var s;this.warn("Invalid level index "+S),(s=m.deliveryDirectives)!==null&&s!==void 0&&s.skip&&(f.deltaUpdateFailed=!0);return}S===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(S,m,p.details)):(l=m.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(f.deltaUpdateFailed=!0)},c.onAudioTrackSwitched=function(y,m){var l=this.hls.levels[this.currentLevelIndex];if(!l)return;if(l.audioGroupIds){for(var S=-1,f=this.hls.audioTracks[m.id].groupId,p=0;p<l.audioGroupIds.length;p++)if(l.audioGroupIds[p]===f){S=p;break}S!==l.urlId&&(l.urlId=S,this.startLoad())}},c.loadPlaylist=function(y){var m=this.currentLevelIndex,l=this._levels[m];if(this.canLoad&&l&&l.url.length>0){var S=l.urlId,f=l.url[S];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 "+S+" "+f),this.clearTimer(),this.hls.trigger(N.Events.LEVEL_LOADING,{url:f,level:m,id:S,deliveryDirectives:y||null})}},c.removeLevel=function(y,m){var l=function(p,s){return s!==m},S=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=S,this.hls.trigger(N.Events.LEVELS_UPDATED,{levels:S})},D(d,[{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 S=y<0;if(this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.LEVEL_SWITCH_ERROR,level:y,fatal:S,reason:"invalid level idx"}),S)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)}}]),d}(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 j}),R.d($,"updateFragPTSDTS",function(){return P}),R.d($,"mergeDetails",function(){return E}),R.d($,"mapPartIntersection",function(){return L}),R.d($,"mapFragmentIntersection",function(){return D}),R.d($,"adjustSliding",function(){return T}),R.d($,"addSliding",function(){return A}),R.d($,"computeReloadInterval",function(){return w}),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(d,c,C){switch(c){case"audio":d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds.push(C);break;case"text":d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds.push(C);break}}function z(d){var c={};d.forEach(function(C){var y=C.groupId||"";C.id=c[y]=c[y]||0,c[y]++})}function j(d,c,C){var y=d[c],m=d[C];O(y,m)}function O(d,c){var C=c.startPTS;if(Object(X.isFiniteNumber)(C)){var y=0,m;c.sn>d.sn?(y=C-d.start,m=d):(y=d.start-C,m=c),m.duration!==y&&(m.duration=y)}else if(c.sn>d.sn){var l=d.cc===c.cc;l&&d.minEndPTS?c.start=d.start+(d.minEndPTS-d.start):c.start=d.start+d.duration}else c.start=Math.max(d.start-c.duration,0)}function P(d,c,C,y,m,l){var S=y-C;S<=0&&(N.logger.warn("Fragment should have a positive duration",c),y=C+c.duration,l=m+c.duration);var f=C,p=y,s=c.startPTS,a=c.endPTS;if(Object(X.isFiniteNumber)(s)){var b=Math.abs(s-C);Object(X.isFiniteNumber)(c.deltaPTS)?c.deltaPTS=Math.max(b,c.deltaPTS):c.deltaPTS=b,f=Math.max(C,s),C=Math.min(C,s),m=Math.min(m,c.startDTS),p=Math.min(y,a),y=Math.max(y,a),l=Math.max(l,c.endDTS)}c.duration=y-C;var v=C-c.start;c.appendedPTS=y,c.start=c.startPTS=C,c.maxStartPTS=f,c.startDTS=m,c.endPTS=y,c.minEndPTS=p,c.endDTS=l;var x=c.sn;if(!d||x<d.startSN||x>d.endSN)return 0;var k,H=x-d.startSN,V=d.fragments;for(V[H]=c,k=H;k>0;k--)O(V[k],V[k-1]);for(k=H;k<V.length-1;k++)O(V[k],V[k+1]);return d.fragmentHint&&O(V[V.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,v}function E(d,c){for(var C=null,y=d.fragments,m=y.length-1;m>=0;m--){var l=y[m].initSegment;if(l){C=l;break}}d.fragmentHint&&delete d.fragmentHint.endPTS;var S=0,f;if(D(d,c,function(k,H){k.relurl&&(S=k.cc-H.cc),Object(X.isFiniteNumber)(k.startPTS)&&Object(X.isFiniteNumber)(k.endPTS)&&(H.start=H.startPTS=k.startPTS,H.startDTS=k.startDTS,H.appendedPTS=k.appendedPTS,H.maxStartPTS=k.maxStartPTS,H.endPTS=k.endPTS,H.endDTS=k.endDTS,H.minEndPTS=k.minEndPTS,H.duration=k.endPTS-k.startPTS,H.duration&&(f=H),c.PTSKnown=c.alignedSliding=!0),H.elementaryStreams=k.elementaryStreams,H.loader=k.loader,H.stats=k.stats,H.urlId=k.urlId,k.initSegment&&(H.initSegment=k.initSegment,C=k.initSegment)}),C){var p=c.fragmentHint?c.fragments.concat(c.fragmentHint):c.fragments;p.forEach(function(k){var H;(!k.initSegment||k.initSegment.relurl===((H=C)===null||H===void 0?void 0:H.relurl))&&(k.initSegment=C)})}if(c.skippedSegments&&(c.deltaUpdateFailed=c.fragments.some(function(k){return!k}),c.deltaUpdateFailed)){N.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var s=c.skippedSegments;s--;)c.fragments.shift();c.startSN=c.fragments[0].sn,c.startCC=c.fragments[0].cc}var a=c.fragments;if(S){N.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].cc+=S}c.skippedSegments&&(c.startCC=c.fragments[0].cc),L(d.partList,c.partList,function(k,H){H.elementaryStreams=k.elementaryStreams,H.stats=k.stats}),f?P(c,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):T(d,c),a.length&&(c.totalduration=c.edge-a[0].start),c.driftStartTime=d.driftStartTime,c.driftStart=d.driftStart;var v=c.advancedDateTime;if(c.advanced&&v){var x=c.edge;c.driftStart||(c.driftStartTime=v,c.driftStart=x),c.driftEndTime=v,c.driftEnd=x}else c.driftEndTime=d.driftEndTime,c.driftEnd=d.driftEnd,c.advancedDateTime=d.advancedDateTime}function L(d,c,C){if(d&&c)for(var y=0,m=0,l=d.length;m<=l;m++){var S=d[m],f=c[m+y];S&&f&&S.index===f.index&&S.fragment.sn===f.fragment.sn?C(S,f):y--}}function D(d,c,C){for(var y=c.skippedSegments,m=Math.max(d.startSN,c.startSN)-c.startSN,l=(d.fragmentHint?1:0)+(y?c.endSN:Math.min(d.endSN,c.endSN))-c.startSN,S=c.startSN-d.startSN,f=c.fragmentHint?c.fragments.concat(c.fragmentHint):c.fragments,p=d.fragmentHint?d.fragments.concat(d.fragmentHint):d.fragments,s=m;s<=l;s++){var a=p[S+s],b=f[s];y&&!b&&s<y&&(b=c.fragments[s]=a),a&&b&&C(a,b)}}function T(d,c){var C=c.startSN+c.skippedSegments-d.startSN,y=d.fragments;if(C<0||C>=y.length)return;A(c,y[C].start)}function A(d,c){if(c){for(var C=d.fragments,y=d.skippedSegments;y<C.length;y++)C[y].start+=c;d.fragmentHint&&(d.fragmentHint.start+=c)}}function w(d,c){var C=1e3*d.levelTargetDuration,y=C/2,m=d.age,l=m>0&&m<C*3,S=c.loading.end-c.loading.start,f,p=d.availabilityDelay;if(d.updated===!1)if(l){var s=333*d.misses;f=Math.max(Math.min(y,S*2),s),d.availabilityDelay=(d.availabilityDelay||0)+f}else f=y;else l?(p=Math.min(p||C/2,m),d.availabilityDelay=p,f=p+C-m):f=C-S;return Math.round(f)}function h(d,c,C){if(!d||!d.details)return null;var y=d.details,m=y.fragments[c-y.startSN];return m||(m=y.fragmentHint,m&&m.sn===c?m:c<y.startSN&&C&&C.sn===c?C:null)}function o(d,c,C){if(!d||!d.details)return null;var y=d.details.partList;if(y)for(var m=y.length;m--;){var l=y[m];if(l.index===C&&l.fragment.sn===c)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"),j=R("./src/utils/buffer-helper.ts"),O=R("./src/controller/fragment-tracker.ts"),P=R("./src/types/loader.ts"),E=R("./src/loader/fragment.ts"),L=R("./src/demux/transmuxer-interface.ts"),D=R("./src/types/transmuxer.ts"),T=R("./src/controller/gap-controller.ts"),A=R("./src/errors.ts"),w=R("./src/utils/logger.ts");function h(m,l){for(var S=0;S<l.length;S++){var f=l[S];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function o(m,l,S){return l&&h(m.prototype,l),S&&h(m,S),m}function d(m,l){m.prototype=Object.create(l.prototype),m.prototype.constructor=m,c(m,l)}function c(m,l){return c=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},c(m,l)}var C=100,y=function(m){d(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 S=l.prototype;return S._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)},S._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)},S.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},S.startLoad=function(p){if(this.levels){var s=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(C),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},S.stopLoad=function(){this._forceStartLoad=!1,m.prototype.stopLoad.call(this)},S.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,x=self.performance.now(),k=this.retryDate;(!k||x>=k||(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()},S.onTickEnd=function(){m.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},S.doTickIdle=function(){var p,s,a=this.hls,b=this.levelLastLoaded,v=this.levels,x=this.media,k=a.config,H=a.nextLoadLevel;if(b===null||!x&&(this.startFragRequested||!k.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:x,P.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 ke=ve.sn-Q.startSN;ke>1&&(ve=Q.fragments[ke-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(x,Ee,P.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)},S.loadFragment=function(p,s,a){var b,v=this.fragmentTracker.getState(p);if(this.fragCurrent=p,v===O.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(p);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);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()},S.getAppendedFrag=function(p){var s=this.fragmentTracker.getAppendedFrag(p,P.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},S.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,P.PlaylistLevelType.MAIN)},S.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},S.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},S.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,x=p[v],k=this.fragLastKbps;k&&this.fragCurrent?a=this.fragCurrent.duration*x.maxBitrate/(1e3*k)+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)}}}},S.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()},S.flushMainBuffer=function(p,s){m.prototype.flushMainBuffer.call(this,p,s,this.altAudio?"video":null)},S.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)},S.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)},S.onMediaPlaying=function(){this.tick()},S.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()},S.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},S.onManifestParsed=function(p,s){var a=!1,b=!1,v;s.levels.forEach(function(x){v=x.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},S.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)},S.onLevelLoaded=function(p,s){var a,b=this.levels,v=s.level,x=s.details,k=x.totalduration;if(!b){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+k);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(x.live||(a=V.details)!==null&&a!==void 0&&a.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;Q=this.alignPlaylists(x,V.details)}if(V.details=x,this.levelLastLoaded=v,this.hls.trigger(z.Events.LEVEL_UPDATED,{details:x,level:v}),this.state===N.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=N.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,Q),this.tick()},S._handleFragmentLoadProgress=function(p){var s,a=p.frag,b=p.part,v=p.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var k=x[a.level],H=k.details;if(!H){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var V=k.videoCodec,Q=H.PTSKnown||!H.live,G=(s=a.initSegment)===null||s===void 0?void 0:s.data,W=this._getAudioCodec(k),q=this.transmuxer=this.transmuxer||new L.default(this.hls,P.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=b?b.index:-1,fe=oe!==-1,ve=new D.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,oe,fe),ke=this.initPTS[a.cc];q.push(v,G,W,V,a,b,H.totalduration,Q,ve,ke)},S.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 x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var k=this.hls;a&&k.trigger(z.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),k.trigger(z.Events.AUDIO_TRACK_SWITCHED,{id:v})}},S.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()},S.onBufferCreated=function(p,s){var a=s.tracks,b,v,x=!1;for(var k in a){var H=a[k];if(H.id==="main"){if(v=k,b=H,k==="video"){var V=a[k];V&&(this.videoBuffer=V.buffer)}}else x=!0}x&&b?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},S.onFragBuffered=function(p,s){var a=s.frag,b=s.part;if(a&&a.type!==P.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)},S.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(P.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,P.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}},S.checkBuffer=function(){var p=this.media,s=this.gapController;if(!p||!s||!p.readyState)return;var a=j.BufferHelper.getBuffered(p);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):s.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime},S.onFragLoadEmergencyAborted=function(){this.state=N.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},S.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,P.PlaylistLevelType.MAIN)}},S.onLevelsUpdated=function(p,s){this.levels=s.levels},S.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},S.seekToStartPos=function(){var p=this.media,s=p.currentTime,a=this.startPosition;if(a>=0&&s<a){if(p.seeking){w.logger.log("could not seek to "+a+", already seeking at "+s);return}var b=j.BufferHelper.getBuffered(p),v=b.length?b.start(0):0,x=v-a;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(w.logger.log("adjusting start position by "+x+" to match buffer start"),a+=x,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+s),p.currentTime=a}},S._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},S._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)})},S._handleTransmuxComplete=function(p){var s,a="main",b=this.hls,v=p.remuxResult,x=p.chunkMeta,k=this.getCurrentContext(x);if(!k){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var H=k.frag,V=k.part,Q=k.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,x),b.trigger(z.Events.FRAG_PARSING_INIT_SEGMENT,{frag:H,id:a,tracks:oe.tracks}));var ve=oe.initPTS,ke=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:ke}))}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,x)}}else if(v.independent===!1){this.backtrack(H);return}if(fe){var ne=fe.startPTS,we=fe.endPTS,tt=fe.startDTS,Ye=fe.endDTS;V&&(V.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:ne,endPTS:we,startDTS:tt,endDTS:Ye}),H.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,ne,we,tt,Ye),this.bufferFragmentData(fe,H,V,x)}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)}},S._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 x=s.audio,k=s.video,H=s.audiovideo;if(x){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"),x.metadata.channelCount!==1&&Q.indexOf("firefox")===-1&&(V="mp4a.40.5")),Q.indexOf("android")!==-1&&x.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+'"'),x.levelCodec=V,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(V||"")+"/"+(p.audioCodec||"")+"/"+x.codec+"]")}k&&(k.levelCodec=p.videoCodec,k.id="main",this.log("Init video buffer, container:"+k.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+k.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()},S.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},S.checkFragmentChanged=function(){var p=this.media,s=null;if(p&&p.readyState>1&&p.seeking===!1){var a=p.currentTime;if(j.BufferHelper.isBuffered(p,a)?s=this.getAppendedFrag(a):j.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 d});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"),j=R("./src/utils/discontinuities.ts"),O=R("./src/controller/level-helper.ts"),P=R("./src/controller/fragment-tracker.ts"),E=R("./src/controller/base-stream-controller.ts"),L=R("./src/types/loader.ts"),D=R("./src/types/level.ts");function T(c,C){for(var y=0;y<C.length;y++){var m=C[y];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(c,m.key,m)}}function A(c,C,y){return C&&T(c.prototype,C),y&&T(c,y),c}function w(c,C){c.prototype=Object.create(C.prototype),c.prototype.constructor=c,h(c,C)}function h(c,C){return h=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},h(c,C)}var o=500,d=function(c){w(C,c);function C(m,l){var S;return S=c.call(this,m,l,"[subtitle-stream-controller]")||this,S.levels=[],S.currentTrackId=-1,S.tracksBuffered=[],S.mainDetails=null,S._registerListeners(),S}var y=C.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,S){this.mainDetails=S.details},y.onSubtitleFragProcessed=function(l,S){var f=S.frag,p=S.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 x=f.start+f.duration;a?a.end=x:(a={start:b,end:x},s.push(a)),this.fragmentTracker.fragBuffered(f)},y.onBufferFlushing=function(l,S){var f=S.startOffset,p=S.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,x=p-v;if(x<=0)return;S.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(k){for(var H=0;H<k.length;){if(k[H].end<=x){k.shift();continue}else if(k[H].start<x)k[H].start=x;else break;H++}}),this.fragmentTracker.removeFragmentsInRange(f,x,L.PlaylistLevelType.SUBTITLE)}},y.onError=function(l,S){var f,p=S.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,S){var f=this,p=S.subtitleTracks;this.tracksBuffered=[],this.levels=p.map(function(s){return new D.Level(s)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(s){f.tracksBuffered[s.id]=[]}),this.mediaBuffer=null},y.onSubtitleTrackSwitch=function(l,S){if(this.currentTrackId=S.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,S){var f,p=S.details,s=S.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 x=this.mainDetails;if(p.deltaUpdateFailed||!x)return;var k=x.fragments[0];if(!v.details)p.hasProgramDateTime&&x.hasProgramDateTime?Object(j.alignMediaPlaylistByPDT)(p,x):k&&Object(O.addSliding)(p,k.start);else{var H=this.alignPlaylists(p,v.details);H===0&&k&&Object(O.addSliding)(p,k.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 S=l.frag,f=l.payload,p=S.decryptdata,s=this.hls;if(this.fragContextChanged(S))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:S,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,S=this.currentTrackId,f=this.levels;if(!f.length||!f[S]||!f[S].details)return;var p=f[S].details,s=p.targetduration,a=this.config,b=this.media,v=I.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-s,a.maxBufferHole),x=v.end,k=v.len,H=this.getMaxBufferLength()+s;if(k>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(x<G){var oe=a.maxFragLookUpTolerance;q&&p.hasProgramDateTime&&(W=Object(z.findFragmentByPDT)(V,q.endProgramDateTime,oe)),W||(W=Object(z.findFragmentByPTS)(q,V,x,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)===P.FragmentState.NOT_LOADED&&this.loadFragment(W,p,x)}},y.loadFragment=function(l,S,f){this.fragCurrent=l,c.prototype.loadFragment.call(this,l,S,f)},A(C,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),C}(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 j(T,A){for(var w=0;w<A.length;w++){var h=A[w];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(T,h.key,h)}}function O(T,A,w){return A&&j(T.prototype,A),w&&j(T,w),T}function P(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){P(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 w=A.prototype;return w.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},w.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)},w.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)},w.onMediaAttached=function(o,d){if(this.media=d.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)},w.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},w.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=D(this.media.textTracks);o.forEach(function(d){Object(N.clearCurrentCues)(d)}),this.subtitleTrack=-1,this.media=null},w.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},w.onManifestParsed=function(o,d){this.tracks=d.subtitleTracks},w.onSubtitleTrackLoaded=function(o,d){var c=d.id,C=d.details,y=this.trackId,m=this.tracksInGroup[y];if(!m){this.warn("Invalid subtitle track id "+c);return}var l=m.details;m.details=d.details,this.log("subtitle track "+c+" loaded ["+C.startSN+"-"+C.endSN+"]"),c===this.trackId&&(this.retryCount=0,this.playlistLoaded(c,d,l))},w.onLevelLoading=function(o,d){this.switchLevel(d.level)},w.onLevelSwitching=function(o,d){this.switchLevel(d.level)},w.switchLevel=function(o){var d=this.hls.levels[o];if(!(d!=null&&d.textGroupIds))return;var c=d.textGroupIds[d.urlId];if(this.groupId!==c){var C=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,y=this.tracks.filter(function(S){return!c||S.groupId===c});this.tracksInGroup=y;var m=this.findTrackId(C==null?void 0:C.name)||this.findTrackId();this.groupId=c;var l={subtitleTracks:y};this.log("Updating subtitle tracks, "+y.length+' track(s) found in "'+c+'" group-id'),this.hls.trigger(X.Events.SUBTITLE_TRACKS_UPDATED,l),m!==-1&&this.setSubtitleTrack(m,C)}},w.findTrackId=function(o){for(var d=this.tracksInGroup,c=0;c<d.length;c++){var C=d[c];if((!this.selectDefaultTrack||C.default)&&(!o||o===C.name))return C.id}return-1},w.onError=function(o,d){if(T.prototype.onError.call(this,o,d),d.fatal||!d.context)return;d.context.type===z.PlaylistContextType.SUBTITLE_TRACK&&d.context.id===this.trackId&&d.context.groupId===this.groupId&&this.retryLoadingOrFail(d)},w.loadPlaylist=function(o){var d=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(d)){var c=d.id,C=d.groupId,y=d.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 "+c),this.hls.trigger(X.Events.SUBTITLE_TRACK_LOADING,{url:y,id:c,groupId:C,deliveryDirectives:o||null})}},w.toggleTrackModes=function(o){var d=this,c=this.media,C=this.subtitleDisplay,y=this.trackId;if(!c)return;var m=D(c.textTracks),l=m.filter(function(p){return p.groupId===d.groupId});if(o===-1)[].slice.call(m).forEach(function(p){p.mode="disabled"});else{var S=l[y];S&&(S.mode="disabled")}var f=l[o];f&&(f.mode=C?"showing":"hidden")},w.setSubtitleTrack=function(o,d){var c,C=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(c=C[o])!==null&&c!==void 0&&c.details)||o<-1||o>=C.length)return;this.clearTimer();var y=C[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,y){var m=y.id,l=y.groupId,S=l===void 0?"":l,f=y.name,p=y.type,s=y.url;this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:m,groupId:S,name:f,type:p,url:s});var a=this.switchParams(y.url,d==null?void 0:d.details);this.loadPlaylist(a)}else this.hls.trigger(X.Events.SUBTITLE_TRACK_SWITCH,{id:o})},w.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,d=D(this.media.textTracks),c=0;c<d.length;c++)if(d[c].mode==="hidden")o=c;else if(d[c].mode==="showing"){o=c;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 d=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,d)}}]),A}(I.default);function D(T){for(var A=[],w=0;w<T.length;w++){var h=T[w];h.kind==="subtitles"&&h.label&&A.push(T[w])}return A}$.default=L},"./src/controller/timeline-controller.ts":function(ae,$,R){"use strict";R.r($),R.d($,"TimelineController",function(){return D});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"),j=R("./src/utils/webvtt-parser.ts"),O=R("./src/utils/texttrack-utils.ts"),P=R("./src/utils/imsc1-ttml-parser.ts"),E=R("./src/types/loader.ts"),L=R("./src/utils/logger.ts"),D=function(){function h(d){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=w(),this.captionsProperties=void 0,this.hls=d,this.config=d.config,this.Cues=d.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 c=new z.default(this,"textTrack1"),C=new z.default(this,"textTrack2"),y=new z.default(this,"textTrack3"),m=new z.default(this,"textTrack4");this.cea608Parser1=new I.default(1,c,C),this.cea608Parser2=new I.default(3,y,m)}d.on(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.on(N.Events.FRAG_LOADING,this.onFragLoading,this),d.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.on(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.on(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=h.prototype;return o.destroy=function(){var c=this.hls;c.off(N.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),c.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(N.Events.MANIFEST_LOADED,this.onManifestLoaded,this),c.off(N.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.off(N.Events.FRAG_LOADING,this.onFragLoading,this),c.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),c.off(N.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),c.off(N.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),c.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(N.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),c.off(N.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(c,C,y,m,l){for(var S=!1,f=l.length;f--;){var p=l[f],s=A(p[0],p[1],C,y);if(s>=0&&(p[0]=Math.min(p[0],C),p[1]=Math.max(p[1],y),S=!0,s/(y-C)>.5))return}if(S||l.push([C,y]),this.config.renderTextTracksNatively){var a=this.captionsTracks[c];this.Cues.newCue(a,C,y,m)}else{var b=this.Cues.newCue(null,C,y,m);this.hls.trigger(N.Events.CUES_PARSED,{type:"captions",cues:b,track:c})}},o.onInitPtsFound=function(c,C){var y=this,m=C.frag,l=C.id,S=C.initPTS,f=C.timescale,p=this.unparsedVttFrags;l==="main"&&(this.initPTS[m.cc]=S,this.timescale[m.cc]=f),p.length&&(this.unparsedVttFrags=[],p.forEach(function(s){y.onFragLoaded(N.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(c){var C=this.media;if(C)for(var y=0;y<C.textTracks.length;y++){var m=C.textTracks[y];if(m[c])return m}return null},o.createCaptionsTrack=function(c){this.config.renderTextTracksNatively?this.createNativeTrack(c):this.createNonNativeTrack(c)},o.createNativeTrack=function(c){if(this.captionsTracks[c])return;var C=this.captionsProperties,y=this.captionsTracks,m=this.media,l=C[c],S=l.label,f=l.languageCode,p=this.getExistingTrack(c);if(p)y[c]=p,Object(O.clearCurrentCues)(y[c]),Object(O.sendAddTrackEvent)(y[c],m);else{var s=this.createTextTrack("captions",S,f);s&&(s[c]=!0,y[c]=s)}},o.createNonNativeTrack=function(c){if(this.nonNativeCaptionsTracks[c])return;var C=this.captionsProperties[c];if(!C)return;var y=C.label,m={_id:c,label:y,kind:"captions",default:C.media?!!C.media.default:!1,closedCaptions:C.media};this.nonNativeCaptionsTracks[c]=m,this.hls.trigger(N.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[m]})},o.createTextTrack=function(c,C,y){var m=this.media;return m?m.addTextTrack(c,C,y):void 0},o.onMediaAttaching=function(c,C){this.media=C.media,this._cleanTracks()},o.onMediaDetaching=function(){var c=this.captionsTracks;Object.keys(c).forEach(function(C){Object(O.clearCurrentCues)(c[C]),delete c[C]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=w(),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 c=this.media;if(!c)return;var C=c.textTracks;if(C)for(var y=0;y<C.length;y++)Object(O.clearCurrentCues)(C[y])},o.onSubtitleTracksUpdated=function(c,C){var y=this;this.textTracks=[];var m=C.subtitleTracks||[],l=m.some(function(s){return s.textCodec===P.IMSC1_CODEC});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){var S=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,x=0;x<f.length;x++)if(T(f[x],s)){v=f[x];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(!S&&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(c,C){var y=this;this.config.enableCEA708Captions&&C.captions&&C.captions.forEach(function(m){var l=/(?:CC|SERVICE)([1-4])/.exec(m.instreamId);if(!l)return;var S="textTrack"+l[1],f=y.captionsProperties[S];if(!f)return;f.label=m.name,m.lang&&(f.languageCode=m.lang),f.media=m})},o.onFragLoading=function(c,C){var y=this.cea608Parser1,m=this.cea608Parser2,l=this.lastSn,S=this.lastPartIndex;if(!this.enabled||!(y&&m))return;if(C.frag.type===E.PlaylistLevelType.MAIN){var f,p,s=C.frag.sn,a=(f=C==null||((p=C.part)===null||p===void 0)?void 0:p.index)!=null?f:-1;s===l+1||s===l&&a===S+1||(y.reset(),m.reset()),this.lastSn=s,this.lastPartIndex=a}},o.onFragLoaded=function(c,C){var y=C.frag,m=C.payload,l=this.initPTS,S=this.unparsedVttFrags;if(y.type===E.PlaylistLevelType.SUBTITLE)if(m.byteLength){if(!Object(X.isFiniteNumber)(l[y.cc])){S.push(C),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===P.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(c,C){var y=this,m=this.hls;Object(P.parseIMSC1)(C,this.initPTS[c.cc],this.timescale[c.cc],function(l){y._appendCues(l,c.level),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:c})},function(l){L.logger.log("Failed to parse IMSC1: "+l),m.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c,error:l})})},o._parseVTTs=function(c,C,y){var m=this,l=this.hls;Object(j.parseWebVTT)(C,this.initPTS[c.cc],this.timescale[c.cc],y,c.cc,c.start,function(S){m._appendCues(S,c.level),l.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:c})},function(S){m._fallbackToIMSC1(c,C),L.logger.log("Failed to parse VTT cue: "+S),l.trigger(N.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c,error:S})})},o._fallbackToIMSC1=function(c,C){var y=this,m=this.tracks[c.level];m.textCodec||Object(P.parseIMSC1)(C,this.initPTS[c.cc],this.timescale[c.cc],function(){m.textCodec=P.IMSC1_CODEC,y._parseIMSC1(c,C)},function(){m.textCodec="wvtt"})},o._appendCues=function(c,C){var y=this.hls;if(this.config.renderTextTracksNatively){var m=this.textTracks[C];if(m.mode==="disabled")return;c.forEach(function(f){return Object(O.addCueToTrack)(m,f)})}else{var l=this.tracks[C],S=l.default?"default":"subtitles"+C;y.trigger(N.Events.CUES_PARSED,{type:"subtitles",cues:c,track:S})}},o.onFragDecrypted=function(c,C){var y=C.frag;if(y.type===E.PlaylistLevelType.SUBTITLE){if(!Object(X.isFiniteNumber)(this.initPTS[y.cc])){this.unparsedVttFrags.push(C);return}this.onFragLoaded(N.Events.FRAG_LOADED,C)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(c,C){var y=this.cea608Parser1,m=this.cea608Parser2;if(!this.enabled||!(y&&m))return;for(var l=0;l<C.samples.length;l++){var S=C.samples[l].bytes;if(S){var f=this.extractCea608Data(S);y.addData(C.samples[l].pts,f[0]),m.addData(C.samples[l].pts,f[1])}}},o.onBufferFlushing=function(c,C){var y=C.startOffset,m=C.endOffset,l=C.endOffsetSubtitles,S=C.type,f=this.media;if(!f||f.currentTime<m)return;if(!S||S==="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(c){for(var C=c[0]&31,y=2,m=[[],[]],l=0;l<C;l++){var S=c[y++],f=127&c[y++],p=127&c[y++],s=(4&S)!==0,a=3&S;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,d,c){return Math.min(o,c)-Math.max(h,d)}function w(){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,j){this.subtle=void 0,this.aesIV=void 0,this.subtle=z,this.aesIV=j}var I=N.prototype;return I.decrypt=function(j,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,j)},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 j=z.byteLength,O=j&&new DataView(z.buffer).getUint8(j-1);return O?Object(X.sliceUint8)(z,0,j-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 j=z.prototype;return j.uint8ArrayToUint32Array_=function(P){for(var E=new DataView(P),L=new Uint32Array(4),D=0;D<4;D++)L[D]=E.getUint32(D*4);return L},j.initTable=function(){var P=this.sBox,E=this.invSBox,L=this.subMix,D=L[0],T=L[1],A=L[2],w=L[3],h=this.invSubMix,o=h[0],d=h[1],c=h[2],C=h[3],y=new Uint32Array(256),m=0,l=0,S=0;for(S=0;S<256;S++)S<128?y[S]=S<<1:y[S]=S<<1^283;for(S=0;S<256;S++){var f=l^l<<1^l<<2^l<<3^l<<4;f=f>>>8^f&255^99,P[m]=f,E[f]=m;var p=y[m],s=y[p],a=y[s],b=y[f]*257^f*16843008;D[m]=b<<24|b>>>8,T[m]=b<<16|b>>>16,A[m]=b<<8|b>>>24,w[m]=b,b=a*16843009^s*65537^p*257^m*16843008,o[f]=b<<24|b>>>8,d[f]=b<<16|b>>>16,c[f]=b<<8|b>>>24,C[f]=b,m?(m=p^y[y[y[a^p]]],l^=y[y[l]]):m=l=1}},j.expandKey=function(P){for(var E=this.uint8ArrayToUint32Array_(P),L=!0,D=0;D<E.length&&L;)L=E[D]===this.key[D],D++;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,w,h,o=this.keySchedule=new Uint32Array(A),d=this.invKeySchedule=new Uint32Array(A),c=this.sBox,C=this.rcon,y=this.invSubMix,m=y[0],l=y[1],S=y[2],f=y[3],p,s;for(w=0;w<A;w++){if(w<T){p=o[w]=E[w];continue}s=p,w%T===0?(s=s<<8|s>>>24,s=c[s>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[s&255],s^=C[w/T|0]<<24):T>6&&w%T===4&&(s=c[s>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[s&255]),o[w]=p=(o[w-T]^s)>>>0}for(h=0;h<A;h++)w=A-h,h&3?s=o[w]:s=o[w-4],h<4||w<=4?d[h]=s:d[h]=m[c[s>>>24]]^l[c[s>>>16&255]]^S[c[s>>>8&255]]^f[c[s&255]],d[h]=d[h]>>>0},j.networkToHostOrderSwap=function(P){return P<<24|(P&65280)<<8|(P&16711680)>>8|P>>>24},j.decrypt=function(P,E,L){for(var D=this.keySize+6,T=this.invKeySchedule,A=this.invSBox,w=this.invSubMix,h=w[0],o=w[1],d=w[2],c=w[3],C=this.uint8ArrayToUint32Array_(L),y=C[0],m=C[1],l=C[2],S=C[3],f=new Int32Array(P),p=new Int32Array(f.length),s,a,b,v,x,k,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]),x=Q^T[0],k=q^T[1],H=W^T[2],V=G^T[3],oe=4,fe=1;fe<D;fe++)s=h[x>>>24]^o[k>>16&255]^d[H>>8&255]^c[V&255]^T[oe],a=h[k>>>24]^o[H>>16&255]^d[V>>8&255]^c[x&255]^T[oe+1],b=h[H>>>24]^o[V>>16&255]^d[x>>8&255]^c[k&255]^T[oe+2],v=h[V>>>24]^o[x>>16&255]^d[k>>8&255]^c[H&255]^T[oe+3],x=s,k=a,H=b,V=v,oe=oe+4;s=A[x>>>24]<<24^A[k>>16&255]<<16^A[H>>8&255]<<8^A[V&255]^T[oe],a=A[k>>>24]<<24^A[H>>16&255]<<16^A[V>>8&255]<<8^A[x&255]^T[oe+1],b=A[H>>>24]<<24^A[V>>16&255]<<16^A[x>>8&255]<<8^A[k&255]^T[oe+2],v=A[V>>>24]<<24^A[x>>16&255]<<16^A[k>>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^S),y=Q,m=G,l=W,S=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"),j=R("./src/utils/mp4-tools.ts"),O=R("./src/utils/typed-array.ts"),P=16,E=function(){function L(T,A,w){var h=w===void 0?{}:w,o=h.removePKCS7Padding,d=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=d,d)try{var c=self.crypto;c&&(this.subtle=c.subtle||c.webkitSubtle)}catch(C){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=L.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var w=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(I.removePadding)(w):w},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(A,w,h,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),w,h);var d=this.flush();d&&o(d.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),w,h).then(o)},D.softwareDecrypt=function(A,w,h){var o=this.currentIV,d=this.currentResult,c=this.remainderData;this.logOnce("JS AES decrypt"),c&&(A=Object(j.appendUint8Array)(c,A),this.remainderData=null);var C=this.getValidChunk(A);if(!C.length)return null;o&&(h=o);var y=this.softwareDecrypter;y||(y=this.softwareDecrypter=new I.default),y.expandKey(w);var m=d;return this.currentResult=y.decrypt(C.buffer,0,h),this.currentIV=Object(O.sliceUint8)(C,-16).buffer,m||null},D.webCryptoDecrypt=function(A,w,h){var o=this,d=this.subtle;return(this.key!==w||!this.fastAesKey)&&(this.key=w,this.fastAesKey=new N.default(d,w)),this.fastAesKey.expandKey().then(function(c){if(!d)return Promise.reject(new Error("web crypto not initialized"));var C=new X.default(d,h);return C.decrypt(A.buffer,c)}).catch(function(c){return o.onWebCryptoError(c,A,w,h)})},D.onWebCryptoError=function(A,w,h,o){return z.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(w,h,o)},D.getValidChunk=function(A){var w=A,h=A.length-A.length%P;return h!==A.length&&(w=Object(O.sliceUint8)(A,0,h),this.remainderData=Object(O.sliceUint8)(A,h)),w},D.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,j){this.subtle=void 0,this.key=void 0,this.subtle=z,this.key=j}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 j(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 P=function(E){j(L,E);function L(T,A){var w;return w=E.call(this)||this,w.observer=void 0,w.config=void 0,w.observer=T,w.config=A,w}var D=L.prototype;return D.resetInitSegment=function(A,w,h){E.prototype.resetInitSegment.call(this,A,w,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 w=z.getID3Data(A,0)||[],h=w.length,o=A.length;h<o;h++)if(N.probe(A,h))return I.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(A,w){return N.canParse(A,w)},D.appendFrame=function(A,w,h){N.initTrackConfig(A,this.observer,w,h,A.manifestCodec);var o=N.appendFrame(A,w,h,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},L}(X.default);P.minProbeByteLength=9,$.default=P},"./src/demux/adts.ts":function(ae,$,R){"use strict";R.r($),R.d($,"getAudioConfig",function(){return z}),R.d($,"isHeaderPattern",function(){return j}),R.d($,"getHeaderLength",function(){return O}),R.d($,"getFullFrameLength",function(){return P}),R.d($,"canGetFrameLength",function(){return E}),R.d($,"isHeader",function(){return L}),R.d($,"canParse",function(){return D}),R.d($,"probe",function(){return T}),R.d($,"initTrackConfig",function(){return A}),R.d($,"getFrameDuration",function(){return w}),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(d,c,C,y){var m,l,S,f,p=navigator.userAgent.toLowerCase(),s=y,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];m=((c[C+2]&192)>>>6)+1;var b=(c[C+2]&60)>>>2;if(b>a.length-1){d.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 S=(c[C+2]&1)<<2,S|=(c[C+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&&S===1||/vivaldi/i.test(p))||!y&&S===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]|=S<<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:S,codec:"mp4a.40."+m,manifestCodec:s}}function j(d,c){return d[c]===255&&(d[c+1]&246)===240}function O(d,c){return d[c+1]&1?7:9}function P(d,c){return(d[c+3]&3)<<11|d[c+4]<<3|(d[c+5]&224)>>>5}function E(d,c){return c+5<d.length}function L(d,c){return c+1<d.length&&j(d,c)}function D(d,c){return E(d,c)&&j(d,c)&&P(d,c)<=d.length-c}function T(d,c){if(L(d,c)){var C=O(d,c);if(c+C>=d.length)return!1;var y=P(d,c);if(y<=C)return!1;var m=c+y;return m===d.length||L(d,m)}return!1}function A(d,c,C,y,m){if(!d.samplerate){var l=z(c,C,y,m);if(!l)return;d.config=l.config,d.samplerate=l.samplerate,d.channelCount=l.channelCount,d.codec=l.codec,d.manifestCodec=l.manifestCodec,X.logger.log("parsed codec:"+d.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function w(d){return 1024*9e4/d}function h(d,c,C,y,m){var l=O(d,c),S=P(d,c);if(S-=l,S>0){var f=C+y*m;return{headerLength:l,frameLength:S,stamp:f}}}function o(d,c,C,y,m){var l=w(d.samplerate),S=h(c,C,y,m,l);if(S){var f=S.frameLength,p=S.headerLength,s=S.stamp,a=p+f,b=Math.max(0,C+a-c.length),v;b?(v=new Uint8Array(a-p),v.set(c.subarray(C+p,c.length),0)):v=c.subarray(C+p,C+a);var x={unit:v,pts:s};return b||d.samples.push(x),{sample:x,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(ae,$,R){"use strict";R.r($),R.d($,"initPTSFn",function(){return P});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"),j=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,w){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,w){},L.demux=function(T,A){this.cachedData&&(T=Object(z.appendUint8Array)(this.cachedData,T),this.cachedData=null);var w=N.getID3Data(T,0),h=w?w.length:0,o,d,c=this._audioTrack,C=this._id3Track,y=w?N.getTimeStamp(w):void 0,m=T.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=P(y,A)),w&&w.length>0&&C.samples.push({pts:this.initPTS,dts:this.initPTS,data:w}),d=this.initPTS;h<m;){if(this.canParse(T,h)){var l=this.appendFrame(c,T,h);l?(this.frameIndex++,d=l.sample.pts,h+=l.length,o=h):h=m}else N.canParse(T,h)?(w=N.getID3Data(T,h),C.samples.push({pts:d,dts:d,data:w}),h+=w.length,o=h):h++;if(h===m&&o!==m){var S=Object(j.sliceUint8)(T,o);this.cachedData?this.cachedData=Object(z.appendUint8Array)(this.cachedData,S):this.cachedData=S}}return{audioTrack:c,avcTrack:Object(I.dummyTrack)(),id3Track:C,textTrack:Object(I.dummyTrack)()}},L.demuxSampleAes=function(T,A,w){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}(),P=function(L,D){return Object(X.isFiniteNumber)(L)?L*90:D*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,P=this.dataLength,E;if(O.length)O.length===1?E=O[0]:E=N(O,P);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 j=new Uint8Array(z),O=0,P=0;P<I.length;P++){var E=I[P];j.set(E,O),O+=E.length}return j}},"./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(j){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=j,this.bytesAvailable=j.byteLength,this.word=0,this.bitsAvailable=0}var z=I.prototype;return z.loadWord=function(){var O=this.data,P=this.bytesAvailable,E=O.byteLength-P,L=new Uint8Array(4),D=Math.min(4,P);if(D===0)throw new Error("no bytes available");L.set(O.subarray(E,E+D)),this.word=new DataView(L.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},z.skipBits=function(O){var P;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,P=O>>3,O-=P>>3,this.bytesAvailable-=P,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},z.readBits=function(O){var P=Math.min(this.bitsAvailable,O),E=this.word>>>32-P;return O>32&&X.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=P,this.bitsAvailable>0?this.word<<=P:this.bytesAvailable>0&&this.loadWord(),P=O-P,P>0&&this.bitsAvailable?E<<P|this.readBits(P):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 P=8,E=8,L,D=0;D<O;D++)E!==0&&(L=this.readEG(),E=(P+L+256)%256),P=E===0?P:E},z.readSPS=function(){var O=0,P=0,E=0,L=0,D,T,A,w=this.readUByte.bind(this),h=this.readBits.bind(this),o=this.readUEG.bind(this),d=this.readBoolean.bind(this),c=this.skipBits.bind(this),C=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);w();var l=w();if(h(5),c(3),w(),y(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var S=o();if(S===3&&c(1),y(),y(),c(1),d())for(T=S!==3?8:12,A=0;A<T;A++)d()&&(A<6?m(16):m(64))}y();var f=o();if(f===0)o();else if(f===1)for(c(1),C(),C(),D=o(),A=0;A<D;A++)C();y(),c(1);var p=o(),s=o(),a=h(1);a===0&&c(1),c(1),d()&&(O=o(),P=o(),E=o(),L=o());var b=[1,1];if(d()&&d()){var v=w();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=[w()<<8|w(),w()<<8|w()];break}}}return{width:Math.ceil((p+1)*16-O*2-P*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 j}),R.d($,"getTimeStamp",function(){return O}),R.d($,"isTimeStampFrame",function(){return P}),R.d($,"getID3Frames",function(){return L}),R.d($,"decodeFrame",function(){return D}),R.d($,"utf8ArrayToStr",function(){return o}),R.d($,"testables",function(){return d});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 S=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(S,S+f):void 0},z=function(m,l){var S=0;return S=(m[l]&127)<<21,S|=(m[l+1]&127)<<14,S|=(m[l+2]&127)<<7,S|=m[l+3]&127,S},j=function(m,l){return X(m,l)&&z(m,l+6)+10<=m.length-l},O=function(m){for(var l=L(m),S=0;S<l.length;S++){var f=l[S];if(P(f))return h(f)}return},P=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]),S=z(m,4),f=10;return{type:l,size:S,data:m.subarray(f,f+S)}},L=function(m){for(var l=0,S=[];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=D(s);a&&S.push(a),l+=s.size+10}N(m,l)&&(l+=10)}return S},D=function(m){return m.type==="PRIV"?T(m):m.type[0]==="W"?w(m):A(m)},T=function(m){if(m.size<2)return;var l=o(m.data,!0),S=new Uint8Array(m.data.subarray(l.length+1));return{key:m.type,info:l,data:S.buffer}},A=function(m){if(m.size<2)return;if(m.type==="TXXX"){var l=1,S=o(m.data.subarray(l),!0);l+=S.length+1;var f=o(m.data.subarray(l));return{key:m.type,info:S,data:f}}var p=o(m.data.subarray(1));return{key:m.type,data:p}},w=function(m){if(m.type==="WXXX"){if(m.size<2)return;var l=1,S=o(m.data.subarray(l),!0);l+=S.length+1;var f=o(m.data.subarray(l));return{key:m.type,info:S,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),S=l[3]&1,f=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return f/=45,S&&(f+=4772185884e-2),Math.round(f)}return},o=function(m,l){l===void 0&&(l=!1);var S=C();if(S){var f=S.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,x="",k=0;k<s;){if(a=m[k++],a===0&&l)return x;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:x+=String.fromCharCode(a);break;case 12:case 13:b=m[k++],x+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=m[k++],v=m[k++],x+=String.fromCharCode((a&15)<<12|(b&63)<<6|(v&63)<<0);break;default:}}return x},d={decodeTextFrame:A},c;function C(){return!c&&typeof self.TextDecoder!="undefined"&&(c=new self.TextDecoder("utf-8")),c}},"./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 j(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 P=function(E){j(L,E);function L(){return E.apply(this,arguments)||this}var D=L.prototype;return D.resetInitSegment=function(A,w,h){E.prototype.resetInitSegment.call(this,A,w,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 w=N.getID3Data(A,0)||[],h=w.length,o=A.length;h<o;h++)if(z.probe(A,h))return I.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(A,w){return z.canParse(A,w)},D.appendFrame=function(A,w,h){return this.initPTS===null?void 0:z.appendFrame(A,w,h,this.initPTS,this.frameIndex)},L}(X.default);P.minProbeByteLength=4,$.default=P},"./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,P){this.remainderData=null,this.config=void 0,this.config=P}var j=z.prototype;return j.resetTimeStamp=function(){},j.resetInitSegment=function(){},j.resetContiguity=function(){},z.probe=function(P){return Object(X.findBox)({data:P,start:0,end:Math.min(P.length,16384)},["moof"]).length>0},j.demux=function(P){var E=P,L=Object(N.dummyTrack)();if(this.config.progressive){this.remainderData&&(E=Object(X.appendUint8Array)(this.remainderData,P));var D=Object(X.segmentValidRange)(E);this.remainderData=D.remainder,L.samples=D.valid||new Uint8Array}else L.samples=E;return{audioTrack:Object(N.dummyTrack)(),avcTrack:L,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},j.flush=function(){var P=Object(N.dummyTrack)();return P.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(N.dummyTrack)(),avcTrack:P,id3Track:Object(N.dummyTrack)(),textTrack:Object(N.dummyTrack)()}},j.demuxSampleAes=function(P,E,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},j.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 P}),R.d($,"isHeaderPattern",function(){return E}),R.d($,"isHeader",function(){return L}),R.d($,"canParse",function(){return D}),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]],j=[0,1,1,4];function O(A,w,h,o,d){if(h+24>w.length)return;var c=P(w,h);if(c&&h+c.frameLength<=w.length){var C=c.samplesPerFrame*9e4/c.sampleRate,y=o+d*C,m={unit:w.subarray(h,h+c.frameLength),pts:y,dts:y};return A.config=[],A.channelCount=c.channelCount,A.samplerate=c.sampleRate,A.samples.push(m),{sample:m,length:c.frameLength,missing:0}}}function P(A,w){var h=A[w+1]>>3&3,o=A[w+1]>>1&3,d=A[w+2]>>4&15,c=A[w+2]>>2&3;if(h!==1&&d!==0&&d!==15&&c!==3){var C=A[w+2]>>1&1,y=A[w+3]>>6,m=h===3?3-o:o===3?3:4,l=N[m*14+d-1]*1e3,S=h===3?0:h===2?1:2,f=I[S*3+c],p=y===3?1:2,s=z[h][o],a=j[o],b=s*8*a,v=Math.floor(s*l/f+C)*a;if(X===null){var x=navigator.userAgent||"",k=x.match(/Chrome\/(\d+)/i);X=k?parseInt(k[1]):0}var H=!!X&&X<=87;return H&&o===2&&l>=224e3&&y===0&&(A[w+3]=A[w+3]|128),{sampleRate:f,channelCount:p,frameLength:v,samplesPerFrame:b}}}function E(A,w){return A[w]===255&&(A[w+1]&224)===224&&(A[w+1]&6)!==0}function L(A,w){return w+1<A.length&&E(A,w)}function D(A,w){var h=4;return E(A,w)&&h<=A.length-w}function T(A,w){if(w+1<A.length&&E(A,w)){var h=4,o=P(A,w),d=h;o!=null&&o.frameLength&&(d=o.frameLength);var c=w+d;return c===A.length||L(A,c)}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,P,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new X.default(O,P,{removePKCS7Padding:!1})}var j=z.prototype;return j.decryptBuffer=function(P,E){this.decrypter.decrypt(P,this.keyData.key.buffer,this.keyData.iv.buffer,E)},j.decryptAacSample=function(P,E,L,D){var T=P[E].unit,A=T.subarray(16,T.length-T.length%16),w=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),h=this;this.decryptBuffer(w,function(o){var d=new Uint8Array(o);T.set(d,16),D||h.decryptAacSamples(P,E+1,L)})},j.decryptAacSamples=function(P,E,L){for(;;E++){if(E>=P.length){L();return}if(P[E].unit.length<32)continue;var D=this.decrypter.isSync();if(this.decryptAacSample(P,E,L,D),!D)return}},j.getAvcEncryptedData=function(P){for(var E=Math.floor((P.length-48)/160)*16+16,L=new Int8Array(E),D=0,T=32;T<=P.length-16;T+=160,D+=16)L.set(P.subarray(T,T+16),D);return L},j.getAvcDecryptedUnit=function(P,E){for(var L=new Uint8Array(E),D=0,T=32;T<=P.length-16;T+=160,D+=16)P.set(L.subarray(D,D+16),T);return P},j.decryptAvcSample=function(P,E,L,D,T,A){var w=Object(N.discardEPB)(T.data),h=this.getAvcEncryptedData(w),o=this;this.decryptBuffer(h.buffer,function(d){T.data=o.getAvcDecryptedUnit(w,d),A||o.decryptAvcSamples(P,E,L+1,D)})},j.decryptAvcSamples=function(P,E,L,D){if(P instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,L=0){if(E>=P.length){D();return}for(var T=P[E].units;!(L>=T.length);L++){var A=T[L];if(A.data.length<=48||A.type!==1&&A.type!==5)continue;var w=this.decrypter.isSync();if(this.decryptAvcSample(P,E,L,D,A,w),!w)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"),j=R("./src/utils/logger.ts"),O=R("./src/errors.ts"),P=R("./src/utils/mediasource-helper.ts"),E=R("./node_modules/eventemitter3/index.js"),L=R.n(E),D=Object(P.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function A(h,o,d,c){var C=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=h,this.id=o,this.onTransmuxComplete=d,this.onFlush=c;var y=h.config,m=function(s,a){a=a||{},a.frag=C.frag,a.id=C.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:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},S=navigator.vendor;if(y.enableWorker&&typeof Worker!="undefined"){j.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:S,id:o,config:JSON.stringify(y)})}catch(p){j.logger.warn("Error in worker:",p),j.logger.error("Error while initializing DemuxerWorker, fallback to inline"),f&&self.URL.revokeObjectURL(f.objectURL),this.transmuxer=new z.default(this.observer,l,y,S,o),this.worker=null}}else this.transmuxer=new z.default(this.observer,l,y,S,o)}var w=A.prototype;return w.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var c=this.observer;c&&c.removeAllListeners(),this.observer=null},w.push=function(o,d,c,C,y,m,l,S,f,p){var s=this;f.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,v=m?m.start:y.start,x=y.decryptdata,k=this.frag,H=!(k&&y.cc===k.cc),V=!(k&&f.level===k.level),Q=k?f.sn-k.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,S,V,v);if(!W||H){j.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: `+S+`
|
|
timeOffset: `+v);var fe=new z.TransmuxConfig(c,C,d,l,p);this.configureTransmuxer(fe)}if(this.frag=y,this.part=m,b)b.postMessage({cmd:"demux",data:o,decryptdata:x,chunkMeta:f,state:oe},o instanceof ArrayBuffer?[o]:[]);else if(a){var ve=a.push(o,x,f,oe);Object(z.isPromise)(ve)?ve.then(function(ke){s.handleTransmuxComplete(ke)}):this.handleTransmuxComplete(ve)}},w.flush=function(o){var d=this;o.transmuxing.start=self.performance.now();var c=this.transmuxer,C=this.worker;if(C)C.postMessage({cmd:"flush",chunkMeta:o});else if(c){var y=c.flush(o);Object(z.isPromise)(y)?y.then(function(m){d.handleFlushResult(m,o)}):this.handleFlushResult(y,o)}},w.handleFlushResult=function(o,d){var c=this;o.forEach(function(C){c.handleTransmuxComplete(C)}),this.onFlush(d)},w.onWorkerMessage=function(o){var d=o.data,c=this.hls;switch(d.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,c.trigger(d.event,d.data);break}}},w.configureTransmuxer=function(o){var d=this.worker,c=this.transmuxer;d?d.postMessage({cmd:"configure",config:o}):c&&c.configure(o)},w.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"),j=R.n(z);function O(T){var A=new z.EventEmitter,w=function(o,d){T.postMessage({event:o,data:d})};A.on(N.Events.FRAG_DECRYPTED,w),A.on(N.Events.ERROR,w),T.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var d=JSON.parse(o.config);T.transmuxer=new X.default(A,o.typeSupported,d,o.vendor,o.id),Object(I.enableLogs)(d.debug),w("init",null);break}case"configure":{T.transmuxer.configure(o.config);break}case"demux":{var c=T.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(X.isPromise)(c)?c.then(function(m){P(T,m)}):P(T,c);break}case"flush":{var C=o.chunkMeta,y=T.transmuxer.flush(C);Object(X.isPromise)(y)?y.then(function(m){L(T,m,C)}):L(T,y,C);break}default:break}})}function P(T,A){if(D(A.remuxResult))return;var w=[],h=A.remuxResult,o=h.audio,d=h.video;o&&E(w,o),d&&E(w,d),T.postMessage({event:"transmuxComplete",data:A},w)}function E(T,A){A.data1&&T.push(A.data1.buffer),A.data2&&T.push(A.data2.buffer)}function L(T,A,w){A.forEach(function(h){P(T,h)}),T.postMessage({event:"flush",data:w})}function D(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 d}),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"),j=R("./src/demux/mp4demuxer.ts"),O=R("./src/demux/tsdemuxer.ts"),P=R("./src/demux/mp3demuxer.ts"),E=R("./src/remux/mp4-remuxer.ts"),L=R("./src/remux/passthrough-remuxer.ts"),D=R("./src/demux/chunk-cache.ts"),T=R("./src/utils/mp4-tools.ts"),A=R("./src/utils/logger.ts"),w;try{w=self.performance.now.bind(self.performance)}catch(S){A.logger.debug("Unable to use Performance API on this environment"),w=self.Date.now}var h=[{demux:O.default,remux:E.default},{demux:j.default,remux:L.default},{demux:z.default,remux:E.default},{demux:P.default,remux:E.default}],o=1024;h.forEach(function(S){var f=S.demux;o=Math.max(o,f.minProbeByteLength)});var d=function(){function S(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 D.default,this.observer=p,this.typeSupported=s,this.config=a,this.vendor=b,this.id=v}var f=S.prototype;return f.configure=function(s){this.transmuxConfig=s,this.decrypter&&this.decrypter.reset()},f.push=function(s,a,b,v){var x=this,k=b.transmuxing;k.executeStart=w();var H=new Uint8Array(s),V=this.cache,Q=this.config,G=this.currentTransmuxState,W=this.transmuxConfig;v&&(this.currentTransmuxState=v);var q=c(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 k.executeEnd=w(),C(b);H=new Uint8Array(fe)}else return this.decryptionPromise=oe.webCryptoDecrypt(H,q.key.buffer,q.iv.buffer).then(function(Me){var He=x.push(Me,null,b);return x.decryptionPromise=null,He}),this.decryptionPromise}var ve=v||G,ke=ve.contiguous,Ee=ve.discontinuity,_e=ve.trackSwitch,Te=ve.accurateTimeOffset,Ce=ve.timeOffset,me=W.audioCodec,ne=W.videoCodec,we=W.defaultInitPts,tt=W.duration,Ye=W.initSegmentData;if((Ee||_e)&&this.resetInitSegment(Ye,me,ne,tt),Ee&&this.resetInitialTimestamp(we),ke||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,k.executeEnd=w(),Ve},f.flush=function(s){var a=this,b=s.transmuxing;b.executeStart=w();var v=this.decrypter,x=this.cache,k=this.currentTransmuxState,H=this.decryptionPromise;if(H)return H.then(function(){return a.flush(s)});var V=[],Q=k.timeOffset;if(v){var G=v.flush();G&&V.push(this.push(G,null,s))}var W=x.dataLength;x.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=w(),[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,x=a.avcTrack,k=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,x,k,H,G,Q,!0,this.id);s.push({remuxResult:W,chunkMeta:b}),b.transmuxing.executeEnd=w()},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 x=this.demuxer,k=this.remuxer;if(!x||!k)return;x.resetInitSegment(a,b,v),k.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,x){var k;return a&&a.method==="SAMPLE-AES"?k=this.transmuxSampleAes(s,a,b,v,x):k=this.transmuxUnencrypted(s,b,v,x),k},f.transmuxUnencrypted=function(s,a,b,v){var x=this.demuxer.demux(s,a,!1,!this.config.progressive),k=x.audioTrack,H=x.avcTrack,V=x.id3Track,Q=x.textTrack,G=this.remuxer.remux(k,H,V,Q,a,b,!1,this.id);return{remuxResult:G,chunkMeta:v}},f.transmuxSampleAes=function(s,a,b,v,x){var k=this;return this.demuxer.demuxSampleAes(s,a,b).then(function(H){var V=k.remuxer.remux(H.audioTrack,H.avcTrack,H.id3Track,H.textTrack,b,v,!1,k.id);return{remuxResult:V,chunkMeta:x}})},f.configureTransmuxer=function(s,a){for(var b=this.config,v=this.observer,x=this.typeSupported,k=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:j.default,remux:L.default});var ve=this.demuxer,ke=this.remuxer,Ee=q.remux,_e=q.demux;(!ke||!(ke instanceof Ee))&&(this.remuxer=new Ee(v,b,x,k)),(!ve||!(ve instanceof _e))&&(this.demuxer=new _e(v,b,x),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},S}();function c(S,f){var p=null;return S.byteLength>0&&f!=null&&f.key!=null&&f.iv!==null&&f.method!=null&&(p=f),p}var C=function(f){return{remuxResult:{},chunkMeta:f}};function y(S){return"then"in S&&S.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 C});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"),j=R("./src/demux/sample-aes.ts"),O=R("./src/events.ts"),P=R("./src/utils/mp4-tools.ts"),E=R("./src/utils/logger.ts"),L=R("./src/errors.ts"),D={video:1,audio:2,id3:3,text:4},T=function(){function y(l,S,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=S,this.typeSupported=f}y.probe=function(S){var f=y.syncOffset(S);return f<0?!1:(f&&E.logger.warn("MPEG2-TS detected but first sync word found @ offset "+f+", junk ahead ?"),!0)},y.syncOffset=function(S){for(var f=Math.min(1e3,S.length-3*188),p=0;p<f;){if(S[p]===71&&S[p+188]===71&&S[p+2*188]===71)return p;p++}return-1},y.createTrack=function(S,f){return{container:S==="video"||S==="audio"?"video/mp2t":void 0,type:S,id:D[S],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:S==="audio"?f:void 0}};var m=y.prototype;return m.resetInitSegment=function(S,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=S,this.videoCodec=f,this._duration=p},m.resetTimeStamp=function(){},m.resetContiguity=function(){var S=this._audioTrack,f=this._avcTrack,p=this._id3Track;S&&(S.pesData=null),f&&(f.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},m.demux=function(S,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,x=this._id3Track,k=b.pid,H=b.pesData,V=v.pid,Q=x.pid,G=v.pesData,W=x.pesData,q=!1,oe=this.pmtParsed,fe=this._pmtId,ve=S.length;if(this.remainderData&&(S=Object(P.appendUint8Array)(this.remainderData,S),ve=S.length,this.remainderData=null),ve<188&&!s)return this.remainderData=S,{audioTrack:v,avcTrack:b,id3Track:x,textTrack:this._txtTrack};var ke=Math.max(0,y.syncOffset(S));ve-=(ve+ke)%188,ve<S.byteLength&&!s&&(this.remainderData=new Uint8Array(S.buffer,ve,S.buffer.byteLength-ve));for(var Ee=ke;Ee<ve;Ee+=188)if(S[Ee]===71){var _e=!!(S[Ee+1]&64),Te=((S[Ee+1]&31)<<8)+S[Ee+2],Ce=(S[Ee+3]&48)>>4,me=void 0;if(Ce>1){if(me=Ee+5+S[Ee+4],me===Ee+188)continue}else me=Ee+4;switch(Te){case k:_e&&(H&&(a=o(H))&&this.parseAVCPES(a,!1),H={data:[],size:0}),H&&(H.data.push(S.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(S.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(S.subarray(me,Ee+188)),W.size+=Ee+188-me);break;case 0:_e&&(me+=S[me]+1),fe=this._pmtId=w(S,me);break;case fe:{_e&&(me+=S[me]+1);var ne=h(S,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);k=ne.avc,k>0&&(b.pid=k),V=ne.audio,V>0&&(v.pid=V,v.isAAC=ne.isAAC),Q=ne.id3,Q>0&&(x.pid=Q),q&&!oe&&(E.logger.log("reparse from beginning"),q=!1,Ee=ke-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,x.pesData=W;var we={audioTrack:v,avcTrack:b,id3Track:x,textTrack:this._txtTrack};return s&&this.extractRemainingSamples(we),we},m.flush=function(){var S=this.remainderData;this.remainderData=null;var f;return S?f=this.demux(S,-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(S){var f=S.audioTrack,p=S.avcTrack,s=S.id3Track,a=p.pesData,b=f.pesData,v=s.pesData,x;a&&(x=o(a))?(this.parseAVCPES(x,!0),p.pesData=null):p.pesData=a,b&&(x=o(b))?(f.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),f.pesData=null):(b!=null&&b.size&&E.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=b),v&&(x=o(v))?(this.parseID3PES(x),s.pesData=null):s.pesData=v},m.demuxSampleAes=function(S,f,p){var s=this.demux(S,p,!0,!this.config.progressive),a=this.sampleAes=new j.default(this.observer,this.config,f);return this.decrypt(s,a)},m.decrypt=function(S,f){return new Promise(function(p){var s=S.audioTrack,a=S.avcTrack;s.samples&&s.isAAC?f.decryptAacSamples(s.samples,0,function(){a.samples?f.decryptAvcSamples(a.samples,0,0,function(){p(S)}):p(S)}):a.samples&&f.decryptAvcSamples(a.samples,0,0,function(){p(S)})})},m.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},m.parseAVCPES=function(S,f){var p=this,s=this._avcTrack,a=this.parseAVCNALu(S.data),b=!1,v=this.avcSample,x,k=!1;S.data=null,v&&a.length&&!s.audFound&&(d(v,s),v=this.avcSample=A(!1,S.pts,S.dts,"")),a.forEach(function(H){switch(H.type){case 1:{x=!0,v||(v=p.avcSample=A(!0,S.pts,S.dts,"")),b&&(v.debug+="NDR "),v.frame=!0;var V=H.data;if(k&&V.length>4){var Q=new I.default(V).readSliceType();(Q===2||Q===4||Q===7||Q===9)&&(v.key=!0)}break}case 5:x=!0,v||(v=p.avcSample=A(!0,S.pts,S.dts,"")),b&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{x=!0,b&&v&&(v.debug+="SEI ");var G=new I.default(C(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 ke=G.readUShort();if(ke===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],we=0;we<me;we++)ne.push(G.readUByte()),ne.push(G.readUByte()),ne.push(G.readUByte());c(p._txtTrack.samples,{type:3,pts:S.pts,bytes:ne})}}}}}else if(W===5&&G.bytesAvailable!==0){if(oe=!0,q>16){for(var tt=[],Ye=0;Ye<16;Ye++)tt.push(G.readUByte().toString(16)),(Ye===3||Ye===5||Ye===7||Ye===9)&&tt.push("-");for(var Xe=q-16,Ve=new Uint8Array(Xe),Le=0;Le<Xe;Le++)Ve[Le]=G.readUByte();c(p._txtTrack.samples,{pts:S.pts,payloadType:W,uuid:tt.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(x=!0,k=!0,b&&v&&(v.debug+="SPS "),!s.sps){var He=new I.default(H.data),Ge=He.readSPS();s.width=Ge.width,s.height=Ge.height,s.pixelRatio=Ge.pixelRatio,s.sps=[H.data],s.duration=p._duration;for(var je=H.data.subarray(1,4),Ue="avc1.",Re=0;Re<3;Re++){var st=je[Re].toString(16);st.length<2&&(st="0"+st),Ue+=st}s.codec=Ue}break;case 8:x=!0,b&&v&&(v.debug+="PPS "),s.pps||(s.pps=[H.data]);break;case 9:x=!1,s.audFound=!0,v&&d(v,s),v=p.avcSample=A(!1,S.pts,S.dts,b?"AUD ":"");break;case 12:x=!1;break;default:x=!1,v&&(v.debug+="unknown NAL "+H.type+" ");break}if(v&&x){var Je=v.units;Je.push(H)}}),f&&v&&(d(v,s),this.avcSample=null)},m.getLastNalUnit=function(){var S,f=this.avcSample,p;if(!f||f.units.length===0){var s=this._avcTrack.samples;f=s[s.length-1]}if((S=f)!==null&&S!==void 0&&S.units){var a=f.units;p=a[a.length-1]}return p},m.parseAVCNALu=function(S){var f=S.byteLength,p=this._avcTrack,s=p.naluState||0,a=s,b=[],v=0,x,k,H,V=-1,Q=0;for(s===-1&&(V=0,Q=S[0]&31,s=0,v=1);v<f;){if(x=S[v++],!s){s=x?0:1;continue}if(s===1){s=x?0:2;continue}if(!x)s=3;else if(x===1){if(V>=0){var G={data:S.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))),k=v-s-1,k>0)){var q=new Uint8Array(W.data.byteLength+k);q.set(W.data,0),q.set(S.subarray(0,k),W.data.byteLength),W.data=q,W.state=0}}v<f?(H=S[v]&31,V=v,Q=H,s=0):s=-1}else s=0}if(V>=0&&s>=0){var oe={data:S.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+S.byteLength);ve.set(fe.data,0),ve.set(S,fe.data.byteLength),fe.data=ve}}return p.naluState=s,b},m.parseAACPES=function(S){var f=0,p=this._audioTrack,s=this.aacOverFlow,a=S.data;if(s){this.aacOverFlow=null;var b=s.sample.unit.byteLength,v=Math.min(s.missing,b),x=b-v;s.sample.unit.set(a.subarray(0,v),x),p.samples.push(s.sample),f=s.missing}var k,H;for(k=f,H=a.length;k<H-1&&!X.isHeader(a,k);k++);if(k!==f){var V,Q;if(k<H-1?(V="AAC PES did not start with ADTS header,offset:"+k,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,k,this.audioCodec);var G;if(S.pts!==void 0)G=S.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;k<H;)if(X.isHeader(a,k)){if(k+5<H){var oe=X.appendFrame(p,a,k,G,q);if(oe)if(oe.missing)this.aacOverFlow=oe;else{k+=oe.length,q++;continue}}break}else k++},m.parseMPEGPES=function(S){var f=S.data,p=f.length,s=0,a=0,b=S.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(S){if(S.pts===void 0){E.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(S)},y}();T.minProbeByteLength=188;function A(y,m,l,S){return{key:y,frame:!1,pts:m,dts:l,units:[],debug:S,length:0}}function w(y,m){return(y[m+10]&31)<<8|y[m+11]}function h(y,m,l,S){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(!S){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(!S){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,S,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(S=(l[4]<<8)+l[5],S&&S>y.size-6)return null;var x=l[7];x&192&&(p=(l[9]&14)*536870912+(l[10]&255)*4194304+(l[11]&254)*16384+(l[12]&255)*128+(l[13]&254)/2,x&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 k=f+9;if(y.size<=k)return null;y.size-=k;for(var H=new Uint8Array(y.size),V=0,Q=a.length;V<Q;V++){l=a[V];var G=l.byteLength;if(k)if(k>G){k-=G;continue}else l=l.subarray(k),G-=k,k=0;H.set(l,m),m+=G}return S&&(S-=f+3),{data:H,pts:p,dts:s,len:S}}return null}function d(y,m){if(y.units.length&&y.frame){if(y.pts===void 0){var l=m.samples,S=l.length;if(S){var f=l[S-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 c(y,m){var l=y.length;if(l>0){if(m.pts>=y[l-1].pts)y.push(m);else for(var S=l-1;S>=0;S--)if(m.pts<y[S].pts){y.splice(S,0,m);break}}else y.push(m)}function C(y){for(var m=y.byteLength,l=[],S=1;S<m-2;)y[S]===0&&y[S+1]===0&&y[S+2]===3?(l.push(S+2),S+=2):S++;if(l.length===0)return y;var f=m-l.length,p=new Uint8Array(f),s=0;for(S=0;S<f;s++,S++)s===l[0]&&(s++,l.shift()),p[S]=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"),j=R("./src/controller/id3-track-controller.ts"),O=R("./src/controller/latency-controller.ts"),P=R("./src/controller/level-controller.ts"),E=R("./src/controller/fragment-tracker.ts"),L=R("./src/controller/stream-controller.ts"),D=R("./src/is-supported.ts"),T=R("./src/utils/logger.ts"),A=R("./src/config.ts"),w=R("./node_modules/eventemitter3/index.js"),h=R.n(w),o=R("./src/events.ts"),d=R("./src/errors.ts");function c(m,l){for(var S=0;S<l.length;S++){var f=l[S];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(m,f.key,f)}}function C(m,l,S){return l&&c(m.prototype,l),S&&c(m,S),m}var y=function(){m.isSupported=function(){return Object(D.isSupported)()};function m(S){S===void 0&&(S={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new w.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,S);this.userConfig=S,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),x=this.bufferController=new s(this),k=this.capLevelController=new a(this),H=new b(this),V=new I.default(this),Q=new z.default(this),G=new j.default(this),W=this.levelController=new P.default(this),q=new E.FragmentTracker(this),oe=this.streamController=new L.default(this,q);k.setStreamController(oe),H.setStreamController(oe);var fe=[W,oe];this.networkControllers=fe;var ve=[V,Q,v,x,k,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:d.ErrorTypes.OTHER_ERROR,details:d.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)},C(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 d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.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 j=Object(X.getMediaSource)();if(!j)return!1;var O=N(),P=j&&typeof j.isTypeSupported=="function"&&j.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!P&&!!E}function z(){var j,O=N();return typeof(O==null||((j=O.prototype)===null||j===void 0)?void 0:j.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 w});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(c){if(c===null||!P(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(c))return o.get(c);o.set(c,C)}function C(){return j(c,arguments,L(this).constructor)}return C.prototype=Object.create(c.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),E(C,c)},z(h)}function j(h,o,d){return O()?j=Reflect.construct:j=function(C,y,m){var l=[null];l.push.apply(l,y);var S=Function.bind.apply(C,l),f=new S;return m&&E(f,m.prototype),f},j.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 P(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function E(h,o){return E=Object.setPrototypeOf||function(c,C){return c.__proto__=C,c},E(h,o)}function L(h){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},L(h)}var D=Math.pow(2,17),T=function(){function h(d){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=d}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(c,C){var y=this,m=c.url;if(!m)return Promise.reject(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,networkDetails:null},"Fragment does not have a "+(m?"part list":"url")));this.abort();var l=this.config,S=l.fLoader,f=l.loader;return new Promise(function(p,s){y.loader&&y.loader.destroy();var a=y.loader=c.loader=S?new S(l):new f(l),b=A(c),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:D};c.stats=a.stats,a.load(b,v,{onSuccess:function(k,H,V,Q){y.resetLoader(c,a),p({frag:c,part:null,payload:k.data,networkDetails:Q})},onError:function(k,H,V){y.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,response:k,networkDetails:V}))},onAbort:function(k,H,V){y.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,networkDetails:V}))},onTimeout:function(k,H,V){y.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,networkDetails:V}))},onProgress:function(k,H,V,Q){C&&C({frag:c,part:null,payload:V,networkDetails:Q})}})})},o.loadPart=function(c,C,y){var m=this;this.abort();var l=this.config,S=l.fLoader,f=l.loader;return new Promise(function(p,s){m.loader&&m.loader.destroy();var a=m.loader=c.loader=S?new S(l):new f(l),b=A(c,C),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:D};C.stats=a.stats,a.load(b,v,{onSuccess:function(k,H,V,Q){m.resetLoader(c,a),m.updateStatsFromPart(c,C);var G={frag:c,part:C,payload:k.data,networkDetails:Q};y(G),p(G)},onError:function(k,H,V){m.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:c,part:C,response:k,networkDetails:V}))},onAbort:function(k,H,V){c.stats.aborted=C.stats.aborted,m.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:c,part:C,networkDetails:V}))},onTimeout:function(k,H,V){m.resetLoader(c,a),s(new w({type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:c,part:C,networkDetails:V}))}})})},o.updateStatsFromPart=function(c,C){var y=c.stats,m=C.stats,l=m.total;if(y.loaded+=m.loaded,l){var S=Math.round(c.duration/C.duration),f=Math.min(Math.round(y.loaded/l),S),p=S-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(c,C){c.loader=null,this.loader===C&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),C.destroy()},h}();function A(h,o){o===void 0&&(o=null);var d=o||h,c={frag:h,part:o,responseType:"arraybuffer",url:d.url,headers:{},rangeStart:0,rangeEnd:0},C=d.byteRangeStartOffset,y=d.byteRangeEndOffset;return Object(X.isFiniteNumber)(C)&&Object(X.isFiniteNumber)(y)&&(c.rangeStart=C,c.rangeEnd=y),c}var w=function(h){I(o,h);function o(d){for(var c,C=arguments.length,y=new Array(C>1?C-1:0),m=1;m<C;m++)y[m-1]=arguments[m];return c=h.call.apply(h,[this].concat(y))||this,c.data=void 0,c.data=d,c}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 w}),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"),j=R("./src/loader/level-key.ts"),O=R("./src/loader/load-stats.ts");function P(o,d){o.prototype=Object.create(d.prototype),o.prototype.constructor=o,E(o,d)}function E(o,d){return E=Object.setPrototypeOf||function(C,y){return C.__proto__=y,C},E(o,d)}function L(o,d){for(var c=0;c<d.length;c++){var C=d[c];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(o,C.key,C)}}function D(o,d,c){return d&&L(o.prototype,d),c&&L(o,c),o}var T;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(T||(T={}));var A=function(){function o(c){var C;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(C={},C[T.AUDIO]=null,C[T.VIDEO]=null,C[T.AUDIOVIDEO]=null,C),this.baseurl=c}var d=o.prototype;return d.setByteRange=function(C,y){var m=C.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},D(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(N.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(C){this._url=C}}]),o}(),w=function(o){P(d,o);function d(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=C,m}var c=d.prototype;return c.createInitializationVector=function(y){for(var m=new Uint8Array(16),l=12;l<16;l++)m[l]=y>>8*(15-l)&255;return m},c.setDecryptDataFromLevelKey=function(y,m){var l=y;return(y==null?void 0:y.method)==="AES-128"&&y.uri&&!y.iv&&(l=j.LevelKey.fromURI(y.uri),l.method=y.method,l.iv=this.createInitializationVector(m),l.keyFormat="identity"),l},c.setElementaryStreamInfo=function(y,m,l,S,f,p){p===void 0&&(p=!1);var s=this.elementaryStreams,a=s[y];if(!a){s[y]={startPTS:m,endPTS:l,startDTS:S,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,S),a.endDTS=Math.max(a.endDTS,f)},c.clearElementaryStreamInfo=function(){var y=this.elementaryStreams;y[T.AUDIO]=null,y[T.VIDEO]=null,y[T.AUDIOVIDEO]=null},D(d,[{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)}}]),d}(A),h=function(o){P(d,o);function d(c,C,y,m,l){var S;S=o.call(this,y)||this,S.fragOffset=0,S.duration=0,S.gap=!1,S.independent=!1,S.relurl=void 0,S.fragment=void 0,S.index=void 0,S.stats=new O.LoadStats,S.duration=c.decimalFloatingPoint("DURATION"),S.gap=c.bool("GAP"),S.independent=c.bool("INDEPENDENT"),S.relurl=c.enumeratedString("URI"),S.fragment=C,S.index=m;var f=c.enumeratedString("BYTERANGE");return f&&S.setByteRange(f,l),l&&(S.fragOffset=l.fragOffset+l.duration),S}return D(d,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var C=this.elementaryStreams;return!!(C.audio||C.video||C.audiovideo)}}]),d}(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 j(P){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=P,this._registerListeners()}var O=j.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 D=L.frag,T=D.type,A=this.loaders[T];if(!D.decryptdata){I.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var w=D.decryptdata.uri;if(w!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(A&&(I.logger.warn("abort previous key loader for type:"+T),A.abort()),!w){I.logger.warn("key uri is falsy");return}var o=h.loader,d=D.loader=this.loaders[T]=new o(h);this.decrypturl=w,this.decryptkey=null;var c={url:w,frag:D,responseType:"arraybuffer"},C={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)};d.load(c,C,y)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(X.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(E,L,D){var T=D.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 D=L.frag,T=D.loader;T&&T.abort(),delete this.loaders[D.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:E})},O.loadtimeout=function(E,L){var D=L.frag,T=D.loader;T&&T.abort(),delete this.loaders[D.type],this.hls.trigger(X.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},j}()},"./src/loader/level-details.ts":function(ae,$,R){"use strict";R.r($),R.d($,"LevelDetails",function(){return j});var X=R("./src/polyfills/number.ts");function N(O,P){for(var E=0;E<P.length;E++){var L=P[E];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(O,L.key,L)}}function I(O,P,E){return P&&N(O.prototype,P),E&&N(O,E),O}var z=10,j=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 P=O.prototype;return P.reloaded=function(L){if(!L){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-L.lastPartSn,T=this.lastPartIndex-L.lastPartIndex;this.updated=this.endSN!==L.endSN||!!T||!!D,this.advanced=this.endSN>L.endSN||D>0||D===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 D=this.driftEnd-this.driftStart;return D*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 j});var X=R("./node_modules/url-toolkit/src/url-toolkit.js"),N=R.n(X);function I(O,P){for(var E=0;E<P.length;E++){var L=P[E];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(O,L.key,L)}}function z(O,P,E){return P&&I(O.prototype,P),E&&I(O,E),O}var j=function(){O.fromURL=function(E,L){return new O(E,L)},O.fromURI=function(E){return new O(E)};function O(P,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)(P,E,{alwaysNormalize:!0}):this._uri=P}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 d});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"),j=R("./src/loader/level-details.ts"),O=R("./src/loader/level-key.ts"),P=R("./src/utils/attr-list.ts"),E=R("./src/utils/logger.ts"),L=R("./src/utils/codecs.ts"),D=/#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"),w=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 S,f;return h.test((S=(f=N.parseURL(l))===null||f===void 0?void 0:f.path)!=null?S:"")}var d=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;D.lastIndex=0;for(var v;(v=D.exec(f))!=null;)if(v[1]){var x=new P.AttrList(v[1]),k={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:l.resolve(v[2],p)},H=x.decimalResolution("RESOLUTION");H&&(k.width=H.width,k.height=H.height),c((x.CODECS||"").split(/[ ,]+/).filter(function(Q){return Q}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=l.convertAVC1ToAVCOTI(k.videoCodec)),s.push(k)}else if(v[3]){var V=new P.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=[],x=0;for(T.lastIndex=0;(b=T.exec(f))!==null;){var k=new P.AttrList(b[1]);if(k.TYPE===s){var H={attrs:k,bitrate:0,id:x++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:s,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?l.resolve(k.URI,p):""};if(a.length){var V=l.findGroup(a,H.groupId)||a[0];C(H,V,"audioCodec"),C(H,V,"textCodec")}v.push(H)}}return v},l.parseLevelPlaylist=function(f,p,s,a,b){var v=new j.LevelDetails(p),x=v.fragments,k=null,H=0,V=0,Q=0,G=0,W=null,q=new z.Fragment(a,p),oe,fe,ve,ke=-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,k&&(q.initSegment=k,q.rawProgramDateTime=k.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,x.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]),ke===-1&&(ke=x.length);else{if(oe=oe[0].match(w),!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),we=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 tt=new P.AttrList(ne),Ye=tt.decimalInteger("SKIPPED-SEGMENTS");if(Object(X.isFiniteNumber)(Ye)){v.skippedSegments=Ye;for(var Xe=Ye;Xe--;)x.unshift(null);H+=Ye}var Ve=tt.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||we)&&q.tagList.push(we?[ne,we]:[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 P.AttrList(ne),He=Me.enumeratedString("METHOD"),Ge=Me.URI,je=Me.hexadecimalInteger("IV"),Ue=Me.enumeratedString("KEYFORMATVERSIONS"),Re=Me.enumeratedString("KEYID"),st=(Le=Me.enumeratedString("KEYFORMAT"))!=null?Le:"identity",Je=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Je.indexOf(st)>-1){E.logger.warn("Keyformat "+st+" is not supported from the manifest");continue}else if(st!=="identity")continue;He&&(ve=O.LevelKey.fromURL(p,Ge),Ge&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(He)>=0&&(ve.method=He,ve.keyFormat=st,Re&&(ve.keyID=Re),Ue&&(ve.keyFormatVersions=Ue),ve.iv=je));break}case"START":{var Qe=new P.AttrList(ne),nt=Qe.decimalFloatingPoint("TIME-OFFSET");Object(X.isFiniteNumber)(nt)&&(v.startTimeOffset=nt);break}case"MAP":{var bt=new P.AttrList(ne);q.relurl=bt.URI,bt.BYTERANGE&&q.setByteRange(bt.BYTERANGE),q.level=s,q.sn="initSegment",ve&&(q.levelkey=ve),q.initSegment=null,k=q,Ee=!0;break}case"SERVER-CONTROL":{var at=new P.AttrList(ne);v.canBlockReload=at.bool("CAN-BLOCK-RELOAD"),v.canSkipUntil=at.optionalFloat("CAN-SKIP-UNTIL",0),v.canSkipDateRanges=v.canSkipUntil>0&&at.bool("CAN-SKIP-DATERANGES"),v.partHoldBack=at.optionalFloat("PART-HOLD-BACK",0),v.holdBack=at.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ht=new P.AttrList(ne);v.partTarget=ht.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ae=v.partList;Ae||(Ae=v.partList=[]);var gt=V>0?Ae[Ae.length-1]:void 0,dt=V++,De=new z.Part(new P.AttrList(ne),q,p,dt,gt);Ae.push(De),q.duration+=De.duration;break}case"PRELOAD-HINT":{var We=new P.AttrList(ne);v.preloadHint=We;break}case"RENDITION-REPORT":{var ge=new P.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?(x.pop(),Q-=W.duration,v.partList&&(v.fragmentHint=W)):v.partList&&(m(q,W),q.cc=G,v.fragmentHint=q);var de=x.length,pe=x[0],ee=x[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,ke>0&&y(x,ke),v},l}();function c(l,S){["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});S[f+"Codec"]=s.length>0?s[0]:p[0],l=l.filter(function(a){return p.indexOf(a)===-1})}}),S.unknownCodecs=l}function C(l,S,f){var p=S[f];p&&(l[f]=p)}function y(l,S){for(var f=l[S],p=S;p--;){var s=l[p];if(!s)return;s.programDateTime=f.programDateTime-s.duration*1e3,f=s}}function m(l,S){l.rawProgramDateTime?l.programDateTime=Date.parse(l.rawProgramDateTime):S!=null&&S.programDateTime&&(l.programDateTime=S.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"),j=R("./src/utils/mp4-tools.ts"),O=R("./src/loader/m3u8-parser.ts"),P=R("./src/types/loader.ts"),E=R("./src/utils/attr-list.ts");function L(A){var w=A.type;switch(w){case P.PlaylistContextType.AUDIO_TRACK:return P.PlaylistLevelType.AUDIO;case P.PlaylistContextType.SUBTITLE_TRACK:return P.PlaylistLevelType.SUBTITLE;default:return P.PlaylistLevelType.MAIN}}function D(A,w){var h=A.url;return(h===void 0||h.indexOf("data:")===0)&&(h=w.url),h}var T=function(){function A(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var w=A.prototype;return w.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)},w.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)},w.createInternalLoader=function(o){var d=this.hls.config,c=d.pLoader,C=d.loader,y=c||C,m=new y(d);return o.loader=m,this.loaders[o.type]=m,m},w.getInternalLoader=function(o){return this.loaders[o.type]},w.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},w.destroyInternalLoaders=function(){for(var o in this.loaders){var d=this.loaders[o];d&&d.destroy(),this.resetInternalLoader(o)}},w.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},w.onManifestLoading=function(o,d){var c=d.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:P.PlaylistContextType.MANIFEST,url:c,deliveryDirectives:null})},w.onLevelLoading=function(o,d){var c=d.id,C=d.level,y=d.url,m=d.deliveryDirectives;this.load({id:c,groupId:null,level:C,responseType:"text",type:P.PlaylistContextType.LEVEL,url:y,deliveryDirectives:m})},w.onAudioTrackLoading=function(o,d){var c=d.id,C=d.groupId,y=d.url,m=d.deliveryDirectives;this.load({id:c,groupId:C,level:null,responseType:"text",type:P.PlaylistContextType.AUDIO_TRACK,url:y,deliveryDirectives:m})},w.onSubtitleTrackLoading=function(o,d){var c=d.id,C=d.groupId,y=d.url,m=d.deliveryDirectives;this.load({id:c,groupId:C,level:null,responseType:"text",type:P.PlaylistContextType.SUBTITLE_TRACK,url:y,deliveryDirectives:m})},w.load=function(o){var d,c=this.hls.config,C=this.getInternalLoader(o);if(C){var y=C.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),C.abort()}var m,l,S,f;switch(o.type){case P.PlaylistContextType.MANIFEST:m=c.manifestLoadingMaxRetry,l=c.manifestLoadingTimeOut,S=c.manifestLoadingRetryDelay,f=c.manifestLoadingMaxRetryTimeout;break;case P.PlaylistContextType.LEVEL:case P.PlaylistContextType.AUDIO_TRACK:case P.PlaylistContextType.SUBTITLE_TRACK:m=0,l=c.levelLoadingTimeOut;break;default:m=c.levelLoadingMaxRetry,l=c.levelLoadingTimeOut,S=c.levelLoadingRetryDelay,f=c.levelLoadingMaxRetryTimeout;break}if(C=this.createInternalLoader(o),(d=o.deliveryDirectives)!==null&&d!==void 0&&d.part){var p;if(o.type===P.PlaylistContextType.LEVEL&&o.level!==null?p=this.hls.levels[o.level].details:o.type===P.PlaylistContextType.AUDIO_TRACK&&o.id!==null?p=this.hls.audioTracks[o.id].details:o.type===P.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:S,maxRetryDelay:f,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};C.load(o,b,v)},w.loadsuccess=function(o,d,c,C){if(C===void 0&&(C=null),c.isSidxRequest){this.handleSidxRequest(o,c),this.handlePlaylistLoaded(o,d,c,C);return}this.resetInternalLoader(c.type);var y=o.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,c,"no EXTM3U delimiter",C);return}d.parsing.start=performance.now(),y.indexOf("#EXTINF:")>0||y.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,d,c,C):this.handleMasterPlaylist(o,d,c,C)},w.loaderror=function(o,d,c){c===void 0&&(c=null),this.handleNetworkError(d,c,!1,o)},w.loadtimeout=function(o,d,c){c===void 0&&(c=null),this.handleNetworkError(d,c,!0)},w.handleMasterPlaylist=function(o,d,c,C){var y=this.hls,m=o.data,l=D(o,c),S=O.default.parseMasterPlaylist(m,l),f=S.levels,p=S.sessionData;if(!f.length){this.handleManifestParsingError(o,c,"no level found in manifest",C);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),x=O.default.parseMasterPlaylistMedia(m,l,"CLOSED-CAPTIONS");if(b.length){var k=b.some(function(H){return!H.url});!k&&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:x,url:l,stats:d,networkDetails:C,sessionData:p})},w.handleTrackOrLevelPlaylist=function(o,d,c,C){var y=this.hls,m=c.id,l=c.level,S=c.type,f=D(o,c),p=Object(X.isFiniteNumber)(m)?m:0,s=Object(X.isFiniteNumber)(l)?l:p,a=L(c),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 c.level=="number"?c.level:void 0});return}if(S===P.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:d,networkDetails:C,sessionData:null})}if(d.parsing.end=performance.now(),b.needSidxRanges){var x,k=(x=b.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:k,isSidxRequest:!0,type:S,level:l,levelDetails:b,id:m,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}c.levelDetails=b,this.handlePlaylistLoaded(o,d,c,C)},w.handleSidxRequest=function(o,d){var c=Object(j.parseSegmentIndex)(new Uint8Array(o.data));if(!c)return;var C=c.references,y=d.levelDetails;C.forEach(function(m,l){var S=m.info,f=y.fragments[l];f.byteRange.length===0&&f.setByteRange(String(1+S.end-S.start)+"@"+String(S.start)),f.initSegment&&f.initSegment.setByteRange(String(c.moovEndOffset)+"@0")})},w.handleManifestParsingError=function(o,d,c,C){this.hls.trigger(N.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:d.type===P.PlaylistContextType.MANIFEST,url:o.url,reason:c,response:o,context:d,networkDetails:C})},w.handleNetworkError=function(o,d,c,C){c===void 0&&(c=!1),z.logger.warn("[playlist-loader]: A network "+(c?"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 P.PlaylistContextType.MANIFEST:y=c?I.ErrorDetails.MANIFEST_LOAD_TIMEOUT:I.ErrorDetails.MANIFEST_LOAD_ERROR,m=!0;break;case P.PlaylistContextType.LEVEL:y=c?I.ErrorDetails.LEVEL_LOAD_TIMEOUT:I.ErrorDetails.LEVEL_LOAD_ERROR,m=!1;break;case P.PlaylistContextType.AUDIO_TRACK:y=c?I.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case P.PlaylistContextType.SUBTITLE_TRACK:y=c?I.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:I.ErrorDetails.SUBTITLE_LOAD_ERROR,m=!1;break}l&&this.resetInternalLoader(o.type);var S={type:I.ErrorTypes.NETWORK_ERROR,details:y,fatal:m,url:o.url,loader:l,context:o,networkDetails:d};C&&(S.response=C),this.hls.trigger(N.Events.ERROR,S)},w.handlePlaylistLoaded=function(o,d,c,C){var y=c.type,m=c.level,l=c.id,S=c.groupId,f=c.loader,p=c.levelDetails,s=c.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(o,c,"invalid target duration",C);return}if(!f)return;p.live&&(f.getCacheAge&&(p.ageHeader=f.getCacheAge()||0),(!f.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0));switch(y){case P.PlaylistContextType.MANIFEST:case P.PlaylistContextType.LEVEL:this.hls.trigger(N.Events.LEVEL_LOADED,{details:p,level:m||0,id:l||0,stats:d,networkDetails:C,deliveryDirectives:s});break;case P.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,{details:p,id:l||0,groupId:S||"",stats:d,networkDetails:C,deliveryDirectives:s});break;case P.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(N.Events.SUBTITLE_TRACK_LOADED,{details:p,id:l||0,groupId:S||"",stats:d,networkDetails:C,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,j){switch(z){case"mp4a.40.2":if(j===1)return new Uint8Array([0,200,0,128,35,128]);if(j===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(j===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(j===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(j===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(j===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(j===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(j===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(j===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},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 j;for(j in I.types)I.types.hasOwnProperty(j)&&(I.types[j]=[j.charCodeAt(0),j.charCodeAt(1),j.charCodeAt(2),j.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]),P=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:P};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 D=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,D,A,D,T),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,E))},I.box=function(j){for(var O=8,P=arguments.length,E=new Array(P>1?P-1:0),L=1;L<P;L++)E[L-1]=arguments[L];for(var D=E.length,T=D;D--;)O+=E[D].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(j,4),D=0,O=8;D<T;D++)A.set(E[D],O),O+=E[D].byteLength;return A},I.hdlr=function(j){return I.box(I.types.hdlr,I.HDLR_TYPES[j])},I.mdat=function(j){return I.box(I.types.mdat,j)},I.mdhd=function(j,O){O*=j;var P=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,j>>24&255,j>>16&255,j>>8&255,j&255,P>>24,P>>16&255,P>>8&255,P&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},I.mdia=function(j){return I.box(I.types.mdia,I.mdhd(j.timescale,j.duration),I.hdlr(j.type),I.minf(j))},I.mfhd=function(j){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,j>>24,j>>16&255,j>>8&255,j&255]))},I.minf=function(j){return j.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(j)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(j))},I.moof=function(j,O,P){return I.box(I.types.moof,I.mfhd(j),I.traf(P,O))},I.moov=function(j){for(var O=j.length,P=[];O--;)P[O]=I.trak(j[O]);return I.box.apply(null,[I.types.moov,I.mvhd(j[0].timescale,j[0].duration)].concat(P).concat(I.mvex(j)))},I.mvex=function(j){for(var O=j.length,P=[];O--;)P[O]=I.trex(j[O]);return I.box.apply(null,[I.types.mvex].concat(P))},I.mvhd=function(j,O){O*=j;var P=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,j>>24&255,j>>16&255,j>>8&255,j&255,P>>24,P>>16&255,P>>8&255,P&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(j){var O=j.samples||[],P=new Uint8Array(4+O.length),E,L;for(E=0;E<O.length;E++)L=O[E].flags,P[E+4]=L.dependsOn<<4|L.isDependedOn<<2|L.hasRedundancy;return I.box(I.types.sdtp,P)},I.stbl=function(j){return I.box(I.types.stbl,I.stsd(j),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(j){var O=[],P=[],E,L,D;for(E=0;E<j.sps.length;E++)L=j.sps[E],D=L.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(L));for(E=0;E<j.pps.length;E++)L=j.pps[E],D=L.byteLength,P.push(D>>>8&255),P.push(D&255),P=P.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|j.sps.length].concat(O).concat([j.pps.length]).concat(P))),A=j.width,w=j.height,h=j.pixelRatio[0],o=j.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,w>>8&255,w&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(j){var O=j.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(j.config).concat([6,1,2]))},I.mp4a=function(j){var O=j.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,j.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),I.box(I.types.esds,I.esds(j)))},I.mp3=function(j){var O=j.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,j.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},I.stsd=function(j){return j.type==="audio"?!j.isAAC&&j.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(j)):I.box(I.types.stsd,I.STSD,I.mp4a(j)):I.box(I.types.stsd,I.STSD,I.avc1(j))},I.tkhd=function(j){var O=j.id,P=j.duration*j.timescale,E=j.width,L=j.height,D=Math.floor(P/(X+1)),T=Math.floor(P%(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,D>>24,D>>16&255,D>>8&255,D&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(j,O){var P=I.sdtp(j),E=j.id,L=Math.floor(O/(X+1)),D=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,D>>24,D>>16&255,D>>8&255,D&255])),I.trun(j,P.length+16+20+8+16+8+8),P)},I.trak=function(j){return j.duration=j.duration||4294967295,I.box(I.types.trak,I.tkhd(j),I.mdia(j))},I.trex=function(j){var O=j.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(j,O){var P=j.samples||[],E=P.length,L=12+16*E,D=new Uint8Array(L),T,A,w,h,o,d;for(O+=8+L,D.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=P[T],w=A.duration,h=A.size,o=A.flags,d=A.cts,D.set([w>>>24&255,w>>>16&255,w>>>8&255,w&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,d>>>24&255,d>>>16&255,d>>>8&255,d&255],12+16*T);return I.box(I.types.trun,D)},I.initSegment=function(j){I.types||I.init();var O=I.moov(j),P=new Uint8Array(I.FTYP.byteLength+O.byteLength);return P.set(I.FTYP),P.set(O,I.FTYP.byteLength),P},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 d}),R.d($,"normalizePts",function(){return c});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"),j=R("./src/errors.ts"),O=R("./src/utils/logger.ts"),P=R("./src/types/loader.ts"),E=R("./src/utils/timescale-conversion.ts");function L(){return L=Object.assign||function(l){for(var S=1;S<arguments.length;S++){var f=arguments[S];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(l[p]=f[p])}return l},L.apply(this,arguments)}var D=10*1e3,T=1024,A=1152,w=null,h=null,o=!1,d=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,w===null){var b=navigator.userAgent||"",v=b.match(/Chrome\/(\d+)/i);w=v?parseInt(v[1]):0}if(h===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);h=x?parseInt(x[1]):0}o=!!w&&w<75||!!h&&h<600}var S=l.prototype;return S.destroy=function(){},S.resetTimeStamp=function(p){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},S.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},S.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},S.getVideoStartPts=function(p){var s=!1,a=p.reduce(function(b,v){var x=v.pts-b;return x<-4294967296?(s=!0,c(b,v.pts)):x>0?b:v.pts},p[0].pts);return s&&O.logger.debug("PTS rollover detected"),a},S.remux=function(p,s,a,b,v,x,k,H){var V,Q,G,W,q,oe,fe=v,ve=v,ke=p.pid>-1,Ee=s.pid>-1,_e=s.samples.length,Te=p.samples.length>0,Ce=_e>1,me=(!ke||Te)&&(!Ee||Ce)||this.ISGenerated||k;if(me){this.ISGenerated||(G=this.generateIS(p,s,v));var ne=this.isVideoContiguous,we=-1;if(Ce&&(we=C(s.samples),!ne&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,we>0){O.logger.warn("[mp4-remuxer]: Dropped "+we+" out of "+_e+" video samples due to a missing keyframe");var tt=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(we),s.dropped+=we,ve+=(s.samples[0].pts-tt)/(s.timescale||9e4)}else we===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+_e+" video samples"),oe=!1);if(this.ISGenerated){if(Te&&Ce){var Ye=this.getVideoStartPts(s.samples),Xe=c(p.samples[0].pts,Ye)-Ye,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,x,Ee||Ce||H===P.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=we,V.independent=we!==-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}},S.generateIS=function(p,s,a){var b=p.samples,v=s.samples,x=this.typeSupported,k={},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||(x.mpeg?(V="audio/mpeg",p.codec=""):x.mp3&&(p.codec="mp3")),k.audio={id:"audio",container:V,codec:p.codec,initSegment:!p.isAAC&&x.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,k.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,c(v[0].dts,q)-oe),Q=Math.min(Q,q-oe)}if(Object.keys(k).length)return this.ISGenerated=!0,H&&(this._initPTS=Q,this._initDTS=G),{tracks:k,initPTS:Q,timescale:W}},S.remuxVideo=function(p,s,a,b){var v=p.inputTimeScale,x=p.samples,k=[],H=x.length,V=this._initPTS,Q=this.nextAvcDts,G=8,W,q,oe,fe=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,ke=0,Ee=!1;if(!a||Q===null){var _e=s*v,Te=x[0].pts-c(x[0].dts,x[0].pts);Q=_e-Te}for(var Ce=0;Ce<H;Ce++){var me=x[Ce];if(me.pts=c(me.pts-V,Q),me.dts=c(me.dts-V,Q),me.dts>me.pts){var ne=9e4*.2;ke=Math.max(Math.min(ke,me.pts-me.dts),-1*ne)}me.dts<x[Ce>0?Ce-1:Ce].dts&&(Ee=!0)}Ee&&x.sort(function(Pt,et){var ct=Pt.dts-et.dts,Ft=Pt.pts-et.pts;return ct||Ft}),q=x[0].dts,oe=x[x.length-1].dts;var we=Math.round((oe-q)/(H-1));if(ke<0){if(ke<we*-2){O.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(E.toMsFromMpegTsClock)(-we,!0)+" ms");for(var tt=ke,Ye=0;Ye<H;Ye++)x[Ye].dts=tt=Math.max(tt,x[Ye].pts-we),x[Ye].pts=Math.max(tt,x[Ye].pts)}else{O.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(E.toMsFromMpegTsClock)(ke,!0)+" ms to overcome this issue");for(var Xe=0;Xe<H;Xe++)x[Xe].dts=x[Xe].dts+ke}q=x[0].dts}if(a){var Ve=q-Q,Le=Ve>we,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 He=x[0].pts-Ve;x[0].dts=q,x[0].pts=He,O.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(He,!0)+"/"+Object(E.toMsFromMpegTsClock)(q,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Ve,!0)+" ms")}}o&&(q=Math.max(0,q));for(var Ge=0,je=0,Ue=0;Ue<H;Ue++){for(var Re=x[Ue],st=Re.units,Je=st.length,Qe=0,nt=0;nt<Je;nt++)Qe+=st[nt].data.length;je+=Qe,Ge+=Je,Re.length=Qe,Re.dts=Math.max(Re.dts,q),Re.pts=Math.max(Re.pts,Re.dts,0),fe=Math.min(Re.pts,fe),ve=Math.max(Re.pts,ve)}oe=x[H-1].dts;var bt=je+4*Ge+8,at;try{at=new Uint8Array(bt)}catch(Pt){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:bt,reason:"fail allocating video mdat "+bt});return}var ht=new DataView(at.buffer);ht.setUint32(0,bt),at.set(I.default.types.mdat,4);for(var Ae=0;Ae<H;Ae++){for(var gt=x[Ae],dt=gt.units,De=0,We=0,ge=dt.length;We<ge;We++){var de=dt[We],pe=de.data,ee=de.data.byteLength;ht.setUint32(G,ee),G+=4,at.set(pe,G),G+=ee,De+=4+ee}if(Ae<H-1)W=x[Ae+1].dts-gt.dts;else{var te=this.config,ie=gt.dts-x[Ae>0?Ae-1:Ae].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);k.push(new y(gt.key,W,De,Se))}if(k.length&&w&&w<70){var Pe=k[0].flags;Pe.dependsOn=2,Pe.isNonSync=0}console.assert(W!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=Q=oe+W,this.isVideoContiguous=!0;var Ze=I.default.moof(p.sequenceNumber++,q,L({},p,{samples:k})),qe="video",Et={data1:Ze,data2:at,startPTS:fe/v,endPTS:(ve+W)/v,startDTS:q/v,endDTS:Q/v,type:qe,hasAudio:!1,hasVideo:!0,nb:k.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(at.length,"MDAT length must not be zero"),Et},S.remuxAudio=function(p,s,a,b,v){var x=p.inputTimeScale,k=p.samplerate?p.samplerate:x,H=x/k,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,ke=s*x;if(this.isAudioContiguous=a=a||oe.length&&ve>0&&(b&&Math.abs(ke-ve)<9e3||Math.abs(c(oe[0].pts-G,ke)-ve)<20*Q),oe.forEach(function(pe){pe.pts=c(pe.pts-G,ke)}),!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,ke):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,we=ne-Ce,tt=Math.abs(1e3*we/x);if(we<=-_e*Q&&Ee)Te===0&&(O.logger.warn("Audio frame @ "+(ne/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*we/x)+" ms."),this.nextAudioPts=ve=Ce=ne);else if(we>=_e*Q&&tt<D&&Ee){var Ye=Math.round(we/Q);Ce=ne-Ye*Q,Ce<0&&(Ye--,Ce+=Q),Te===0&&(this.nextAudioPts=ve=Ce),O.logger.warn("[mp4-remuxer]: Injecting "+Ye+" audio frame @ "+(Ce/x).toFixed(3)+"s due to "+Math.round(1e3*we/x)+" ms gap.");for(var Xe=0;Xe<Ye;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,He=null,Ge,je=0,Ue=oe.length;Ue--;)je+=oe[Ue].unit.byteLength;for(var Re=0,st=oe.length;Re<st;Re++){var Je=oe[Re],Qe=Je.unit,nt=Je.pts;if(He!==null){var bt=q[Re-1];bt.duration=Math.round((nt-He)/H)}else if(a&&p.isAAC&&(nt=ve),Me=nt,je>0){je+=fe;try{Ge=new Uint8Array(je)}catch(pe){this.observer.emit(z.Events.ERROR,z.Events.ERROR,{type:j.ErrorTypes.MUX_ERROR,details:j.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating audio mdat "+je});return}if(!W){var at=new DataView(Ge.buffer);at.setUint32(0,je),Ge.set(I.default.types.mdat,4)}}else return;Ge.set(Qe,fe);var ht=Qe.byteLength;fe+=ht,q.push(new y(!0,V,ht,0)),He=nt}var Ae=q.length;if(!Ae)return;var gt=q[q.length-1];this.nextAudioPts=ve=He+H*gt.duration;var dt=W?new Uint8Array(0):I.default.moof(p.sequenceNumber++,Me/H,L({},p,{samples:q}));p.samples=[];var De=Me/x,We=ve/x,ge="audio",de={data1:dt,data2:Ge,startPTS:De,endPTS:We,startDTS:De,endDTS:We,type:ge,hasAudio:!0,hasVideo:!1,nb:Ae};return this.isAudioContiguous=!0,console.assert(Ge.length,"MDAT length must not be zero"),de},S.remuxEmptyAudio=function(p,s,a,b){var v=p.inputTimeScale,x=p.samplerate?p.samplerate:v,k=v/x,H=this.nextAudioPts,V=(H!==null?H:b.startDTS*v)+this._initDTS,Q=b.endDTS*v+this._initDTS,G=k*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)},S.remuxID3=function(p,s){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,v=this._initPTS,x=this._initDTS,k=0;k<a;k++){var H=p.samples[k];H.pts=c(H.pts-v,s*b)/b,H.dts=c(H.dts-x,s*b)/b}var V=p.samples;return p.samples=[],{samples:V}},S.remuxText=function(p,s){var a=p.samples.length;if(!a)return;for(var b=p.inputTimeScale,v=this._initPTS,x=0;x<a;x++){var k=p.samples[x];k.pts=c(k.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 c(l,S){var f;if(S===null)return l;for(S<l?f=-8589934592:f=8589934592;Math.abs(l-S)>4294967296;)l+=f;return l}function C(l){for(var S=0;S<l.length;S++)if(l[S].key)return S;return-1}var y=function(S,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(S)},m=function(S){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=S?2:1,this.isNonSync=S?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"),j=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,w){this.audioCodec=A,this.videoCodec=w,this.generateInitSegment(T),this.emitInitSegment=!0},L.generateInitSegment=function(T){var A=this.audioCodec,w=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=P(h.audio,I.ElementaryStreamTypes.AUDIO)),w||(w=P(h.video,I.ElementaryStreamTypes.VIDEO));var o={};h.audio&&h.video?o.audiovideo={container:"video/mp4",codec:A+","+w,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:w,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,w,h,o){var d=this.initPTS,c=this.lastEndDTS,C={audio:void 0,video:void 0,text:h,id3:w,initSegment:void 0};Object(X.isFiniteNumber)(c)||(c=this.lastEndDTS=o||0);var y=A.samples;if(!y||!y.length)return C;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."),C;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1),Object(X.isFiniteNumber)(d)||(this.initPTS=m.initPTS=d=O(l,y,c));var S=Object(N.getDuration)(y,l),f=c,p=S+f;Object(N.offsetStartDTS)(l,y,d),S>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 C.audio=v.type==="audio"?v:void 0,C.video=v.type!=="audio"?v:void 0,C.text=h,C.id3=w,C.initSegment=m,C},E}(),O=function(L,D,T){return Object(N.getStartDTS)(L,D)-T};function P(E,L){var D=E==null?void 0:E.codec;return D&&D.length>4?D:D==="hvc1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||L===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}$.default=j},"./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(j){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,j),!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(j){j.MANIFEST="m",j.AUDIO="a",j.VIDEO="v",j.MUXED="av",j.INIT="i",j.CAPTION="c",j.TIMED_TEXT="tt",j.KEY="k",j.OTHER="o"})(N||(N={}));var I;(function(j){j.DASH="d",j.HLS="h",j.SMOOTH="s",j.OTHER="o"})(I||(I={}));var z;(function(j){j.VOD="v",j.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 j}),R.d($,"Level",function(){return O});function X(P,E){for(var L=0;L<E.length;L++){var D=E[L];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(P,D.key,D)}}function N(P,E,L){return E&&X(P.prototype,E),L&&X(P,L),P}var I;(function(P){P.No="",P.Yes="YES",P.v2="v2"})(I||(I={}));function z(P,E){var L=P.canSkipUntil,D=P.canSkipDateRanges,T=P.endSN,A=E!==void 0?E-T:0;return L&&A<L?D?I.v2:I.Yes:I.No}var j=function(){function P(L,D,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=L,this.part=D,this.skip=T}var E=P.prototype;return E.addDirectives=function(D){var T=new self.URL(D);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()},P}(),O=function(){function P(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(P,[{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 D=L%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),P}()},"./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,j,O,P,E,L){P===void 0&&(P=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=j,this.id=O,this.size=P,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 P in O)O.hasOwnProperty(P)&&(this[P]=O[P])}var j=z.prototype;return j.decimalInteger=function(P){var E=parseInt(this[P],10);return E>Number.MAX_SAFE_INTEGER?Infinity:E},j.hexadecimalInteger=function(P){if(this[P]){var E=(this[P]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var L=new Uint8Array(E.length/2),D=0;D<E.length/2;D++)L[D]=parseInt(E.slice(D*2,D*2+2),16);return L}else return null},j.hexadecimalIntegerAsNumber=function(P){var E=parseInt(this[P],16);return E>Number.MAX_SAFE_INTEGER?Infinity:E},j.decimalFloatingPoint=function(P){return parseFloat(this[P])},j.optionalFloat=function(P,E){var L=this[P];return L?parseFloat(L):E},j.enumeratedString=function(P){return this[P]},j.bool=function(P){return this[P]==="YES"},j.decimalResolution=function(P){var E=X.exec(this[P]);return E===null?void 0:{width:parseInt(E[1],10),height:parseInt(E[2],10)}},z.parseAttrList=function(P){var E,L={},D='"';for(N.lastIndex=0;(E=N.exec(P))!==null;){var T=E[2];T.indexOf(D)===0&&T.lastIndexOf(D)===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 j=0,O=I.length-1,P=null,E=null;j<=O;){P=(j+O)/2|0,E=I[P];var L=z(E);if(L>0)j=P+1;else if(L<0)O=P-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,P){try{if(O){for(var E=z.getBuffered(O),L=0;L<E.length;L++)if(P>=E.start(L)&&P<=E.end(L))return!0}}catch(D){}return!1},z.bufferInfo=function(O,P,E){try{if(O){var L=z.getBuffered(O),D=[],T;for(T=0;T<L.length;T++)D.push({start:L.start(T),end:L.end(T)});return this.bufferedInfo(D,P,E)}}catch(A){}return{len:0,start:P,end:P,nextStart:void 0}},z.bufferedInfo=function(O,P,E){P=Math.max(0,P),O.sort(function(m,l){var S=m.start-l.start;return S||l.end-m.end});var L=[];if(E)for(var D=0;D<O.length;D++){var T=L.length;if(T){var A=L[T-1].end;O[D].start-A<E?O[D].end>A&&(L[T-1].end=O[D].end):L.push(O[D])}else L.push(O[D])}else L=O;for(var w=0,h,o=P,d=P,c=0;c<L.length;c++){var C=L[c].start,y=L[c].end;if(P+E>=C&&P<y)o=C,d=y,w=d-P;else if(P+E<C){h=C;break}}return{len:w,start:o||0,end:d||0,nextStart:h}},z.getBuffered=function(O){try{return O.buffered}catch(P){return X.logger.log("failed to get media.buffered",P),N}},z}()},"./src/utils/cea-608-parser.ts":function(ae,$,R){"use strict";R.r($),R.d($,"Row",function(){return d}),R.d($,"CaptionScreen",function(){return c});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,j=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},P={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},D=["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}(),w=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,x){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=x||!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 x=b[v];a.hasOwnProperty(x)&&(this[x]=a[x])}},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,x,k){this.uchar=void 0,this.penState=void 0,this.uchar=s||" ",this.penState=new h(a,b,v,x,k)}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}(),d=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<j;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<j;v++)if(!this.chars[v].equals(a.chars[v])){b=!1;break}return b},p.copy=function(a){for(var b=0;b<j;b++)this.chars[b].copy(a.chars[b])},p.isEmpty=function(){for(var a=!0,b=0;b<j;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>j&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=j)},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>=j){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<j;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<j;v++){var x=this.chars[v].uchar;x!==" "&&(b=!1),a.push(x)}return b?"":a.join("")},p.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.setPenState(this.currPenState)},f}(),c=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 d(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 x=this.currRow+1-this.nrRollUpRows,k=this.lastOutputScreen;if(k){var H=k.rows[x].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(k.rows[x+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="",x=-1,k=0;k<z;k++){var H=this.rows[k].getTextString();H&&(x=k+1,a?b.push("Row "+x+": '"+H+"'"):b.push(H.trim()))}return b.length>0&&(a?v="["+b.join(" | ")+"]":v=b.join(`
|
|
`)),v},p.getTextAndFormat=function(){return this.rows},f}(),C=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 c(b),this.nonDisplayedMemory=new c(b),this.lastOutputScreen=new c(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,x=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=x[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 C(s,a,v),new C(s+1,b,v)],this.cmdHistory=S(),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,x,k,H=!1;this.logger.time=a;for(var V=0;V<b.length;V+=2){if(x=b[V]&127,k=b[V+1]&127,x===0&&k===0)continue;if(this.logger.log(T.DATA,"["+w([b[V],b[V+1]])+"] -> ("+w([x,k])+")"),v=this.parseCmd(x,k),v||(v=this.parseMidrow(x,k)),v||(v=this.parsePAC(x,k)),v||(v=this.parseBackgroundAttributes(x,k)),!v&&(H=this.parseChars(x,k),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 "+w([x,k])+" orig: "+w([b[V],b[V+1]]))}},p.parseCmd=function(a,b){var v=this.cmdHistory,x=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,k=(a===23||a===31)&&b>=33&&b<=35;if(!(x||k))return!1;if(l(a,b,v))return m(null,null,v),this.logger.log(T.DEBUG,"Repeated command ("+w([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 x=this.channels[v];return x?(x.ccMIDROW(b),this.logger.log(T.DEBUG,"MIDROW ("+w([a,b])+")"),!0):!1}return!1},p.parsePAC=function(a,b){var v,x=this.cmdHistory,k=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,H=(a===16||a===24)&&b>=64&&b<=95;if(!(k||H))return!1;if(l(a,b,x))return m(null,null,x),!0;var V=a<=23?1:2;b>=64&&b<=95?v=V===1?O[a]:E[a]:v=V===1?P[a]:L[a];var Q=this.channels[V];return Q?(Q.setPAC(this.interpretPAC(v,b)),m(a,b,x),this.currentChannel=V,!0):!1},p.interpretPAC=function(a,b){var v,x={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?v=b-96:v=b-64,x.underline=(v&1)===1,v<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((v-16)/2)*4,x},p.parseChars=function(a,b){var v,x=null,k=null;if(a>=25?(v=2,k=a-8):(v=1,k=a),k>=17&&k<=19){var H;k===17?H=b+80:k===18?H=b+112:H=b+144,this.logger.log(T.INFO,"Special char '"+I(H)+"' in channel "+v),x=[H]}else a>=32&&a<=127&&(x=b===0?[a]:[a,b]);if(x){var V=w(x);this.logger.log(T.DEBUG,"Char codes = "+V.join(",")),m(a,b,this.cmdHistory)}return x},p.parseBackgroundAttributes=function(a,b){var v=(a===16||a===24)&&b>=32&&b<=47,x=(a===23||a===31)&&b>=45&&b<=47;if(!(v||x))return!1;var k,H={};a===16||a===24?(k=Math.floor((b-32)/2),H.background=D[k],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=S()},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 S(){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,j){var O=X[j];return!!O&&O[z.slice(0,4)]===!0}function I(z,j){return MediaSource.isTypeSupported((j||"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/,j={newCue:function(P,E,L,D){for(var T=[],A,w,h,o,d,c=self.VTTCue||self.TextTrackCue,C=0;C<D.rows.length;C++)if(A=D.rows[C],h=!0,o=0,d="",!A.isEmpty()){for(var y=0;y<A.chars.length;y++)z.test(A.chars[y].uchar)&&h?o++:(d+=A.chars[y].uchar,h=!1);A.cueStartTime=E,E===L&&(L+=1e-4),o>=16?o--:o++;var m=Object(X.fixLineBreaks)(d.trim()),l=Object(N.generateCueId)(E,L,m);(!P||!P.cues||!P.cues.getCueById(l))&&(w=new c(E,L,m),w.id=l,w.line=C+1,w.align="left",w.position=10+Math.min(80,Math.floor(o*8/32)*10),T.push(w))}return P&&T.length&&(T.sort(function(S,f){return S.line==="auto"||f.line==="auto"?0:S.line>8&&f.line>8?f.line-S.line:S.line-f.line}),T.forEach(function(S){return Object(I.addCueToTrack)(P,S)})),T}};$.default=j},"./src/utils/discontinuities.ts":function(ae,$,R){"use strict";R.r($),R.d($,"findFirstFragWithCC",function(){return z}),R.d($,"shouldAlignOnDiscontinuities",function(){return j}),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 w});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 d=null,c=0,C=h.length;c<C;c++){var y=h[c];if(y&&y.cc===o){d=y;break}}return d}function j(h,o,d){return!!(o.details&&(d.endCC>d.startCC||h&&h.cc<d.startCC))}function O(h,o){var d=h.fragments,c=o.fragments;if(!c.length||!d.length){N.logger.log("No fragments to align");return}var C=z(d,c[0].cc);if(!C||C&&!C.startPTS){N.logger.log("No frag in previous level to align on");return}return C}function P(h,o){if(h){var d=h.start+o;h.start=h.startPTS=d,h.endPTS=d+h.duration}}function E(h,o){for(var d=o.fragments,c=0,C=d.length;c<C;c++)P(d[c],h);o.fragmentHint&&P(o.fragmentHint,h),o.alignedSliding=!0}function L(h,o,d){if(!o)return;D(h,d,o),!d.alignedSliding&&o.details&&T(d,o.details),!d.alignedSliding&&o.details&&!d.skippedSegments&&Object(I.adjustSliding)(o.details,d)}function D(h,o,d){if(j(h,d,o)){var c=O(d.details,o);c&&Object(X.isFiniteNumber)(c.start)&&(N.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),E(c.start,o))}}function T(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var d=o.fragments[0].programDateTime,c=h.fragments[0].programDateTime,C=(c-d)/1e3+o.fragments[0].start;C&&Object(X.isFiniteNumber)(C)&&(N.logger.log("Adjusting PTS using programDateTime delta "+(c-d)+"ms, sliding:"+C.toFixed(3)+" "+h.url+" "),E(C,h))}function A(h,o){var d=h.programDateTime;if(!d)return;var c=(d-o)/1e3;h.start=h.startPTS=c,h.endPTS=c+h.duration}function w(h,o){if(!o.fragments.length||!h.hasProgramDateTime||!o.hasProgramDateTime)return;var d=o.fragments[0].programDateTime,c=o.fragments[0].start,C=d-c*1e3;h.fragments.forEach(function(y){A(y,C)}),h.fragmentHint&&A(h.fragmentHint,C),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(j,O,P){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=P,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new X.default(j),this.fast_=new X.default(O)}var z=I.prototype;return z.update=function(O,P){var E=this.slow_,L=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new X.default(O,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==P&&(this.fast_=new X.default(P,L.getEstimate(),L.getTotalWeight()))},z.sample=function(O,P){O=Math.max(O,this.minDelayMs_);var E=8*P,L=O/1e3,D=E/L;this.fast_.sample(L,D),this.slow_.sample(L,D)},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,j,O){j===void 0&&(j=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_=j,this.totalWeight_=O}var I=N.prototype;return I.sample=function(j,O){var P=Math.pow(this.alpha_,j);this.estimate_=O*(1-P)+P*this.estimate_,this.totalWeight_+=j},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var j=1-Math.pow(this.alpha_,this.totalWeight_);if(j)return this.estimate_/j}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(c,C){c.prototype=Object.create(C.prototype),c.prototype.constructor=c,L(c,C)}function j(c){var C=typeof Map=="function"?new Map:void 0;return j=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 C!="undefined"){if(C.has(m))return C.get(m);C.set(m,l)}function l(){return O(m,arguments,D(this).constructor)}return l.prototype=Object.create(m.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),L(l,m)},j(c)}function O(c,C,y){return P()?O=Reflect.construct:O=function(l,S,f){var p=[null];p.push.apply(p,S);var s=Function.bind.apply(l,p),a=new s;return f&&L(a,f.prototype),a},O.apply(null,arguments)}function P(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(c){return!1}}function E(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function L(c,C){return L=Object.setPrototypeOf||function(m,l){return m.__proto__=l,m},L(c,C)}function D(c){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(y){return y.__proto__||Object.getPrototypeOf(y)},D(c)}function T(){return T=Object.assign||function(c){for(var C=1;C<arguments.length;C++){var y=arguments[C];for(var m in y)Object.prototype.hasOwnProperty.call(y,m)&&(c[m]=y[m])}return c},T.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(c){}return!1}var w=function(){function c(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 C=c.prototype;return C.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},C.abortInternal=function(){var m=this.response;(!m||!m.ok)&&(this.stats.aborted=!0,this.controller.abort())},C.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},C.load=function(m,l,S){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=S.onProgress,b=m.responseType==="arraybuffer",v=b?"byteLength":"length";this.context=m,this.config=l,this.callbacks=S,this.request=this.fetchSetup(m,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){f.abortInternal(),S.onTimeout(p,m,f.response)},l.timeout),self.fetch(this.request).then(function(x){if(f.response=f.loader=x,!x.ok){var k=x.status,H=x.statusText;throw new d(H||"fetch, bad network response",k,x)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(x.headers.get("Content-Length")||"0"),a&&Object(X.isFiniteNumber)(l.highWaterMark)?f.loadProgressively(x,p,m,l.highWaterMark,a):b?x.arrayBuffer():x.text()}).then(function(x){var k=f.response;self.clearTimeout(f.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=x[v];var H={url:k.url,data:x};a&&!Object(X.isFiniteNumber)(l.highWaterMark)&&a(p,m,x,k),S.onSuccess(H,p,m,k)}).catch(function(x){if(self.clearTimeout(f.requestTimeout),p.aborted)return;var k=x.code||0;S.onError({code:k,text:x.message},m,x.details)})},C.getCacheAge=function(){var m=null;if(this.response){var l=this.response.headers.get("age");m=l?parseFloat(l):null}return m},C.loadProgressively=function(m,l,S,f,p){f===void 0&&(f=0);var s=new I.default,a=m.body.getReader(),b=function v(){return a.read().then(function(x){if(x.done)return s.dataLength&&p(l,S,s.flush(),m),Promise.resolve(new ArrayBuffer(0));var k=x.value,H=k.length;return l.loaded+=H,H<f||s.dataLength?(s.push(k),s.dataLength>=f&&p(l,S,s.flush(),m)):p(l,S,k,m),v()}).catch(function(){return Promise.reject()})};return b()},c}();function h(c,C){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:C,headers:new self.Headers(T({},c.headers))};return c.rangeEnd&&y.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),y}function o(c,C){return new self.Request(c.url,C)}var d=function(c){z(C,c);function C(y,m,l){var S;return S=c.call(this,y)||this,S.code=void 0,S.details=void 0,S.code=m,S.details=l,S}return C}(j(Error));$.default=w},"./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"),j=R("./src/utils/timescale-conversion.ts"),O=R("./src/utils/webvtt-parser.ts");function P(){return P=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},P.apply(this,arguments)}var E="stpp.ttml.im1t",L=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\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 x=v[0],k=Object(z.utf8ArrayToStr)(new Uint8Array(f,x.start,x.end-x.start)),H=Object(j.toTimescaleFromScale)(p,1,s);try{a(w(k,H))}catch(V){b(V)}}function w(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},x=Object.keys(v).reduce(function(G,W){return G[W]=b.getAttribute("ttp:"+W)||v[W],G},{}),k=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=d(G,k);if(!W||!G.hasAttribute("begin"))return null;var q=m(G.getAttribute("begin"),x),oe=m(G.getAttribute("dur"),x),fe=m(G.getAttribute("end"),x);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 ke=V[G.getAttribute("region")],Ee=H[G.getAttribute("style")];ve.position=10,ve.size=80;var _e=c(ke,Ee),Te=_e.textAlign;if(Te){var Ce=T[Te];Ce&&(ve.lineAlign=Ce),ve.align=Te}return P(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 d(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?d(a,p):p?s+a.textContent.trim().replace(/\s+/g," "):s+a.textContent},"")}function c(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 x=C(p,s,v)||C(f,s,v);return x&&(b[v]=x),b},{})}function C(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):D.test(f)&&(s=S(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 S(f,p){var s=D.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 P});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 j(E){for(var L=arguments.length,D=new Array(L>1?L-1:0),T=1;T<L;T++)D[T-1]=arguments[T];D.forEach(function(A){I[A]=E[A]?E[A].bind(E):z(A)})}function O(E){if(self.console&&E===!0||typeof E=="object"){j(E,"debug","log","info","warn","error");try{I.log()}catch(L){I=N}}else I=N}var P=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 j}),R.d($,"readUint16",function(){return O}),R.d($,"readUint32",function(){return P}),R.d($,"writeUint32",function(){return E}),R.d($,"findBox",function(){return L}),R.d($,"parseSegmentIndex",function(){return D}),R.d($,"parseInitSegment",function(){return T}),R.d($,"getStartDTS",function(){return A}),R.d($,"getDuration",function(){return w}),R.d($,"computeRawDurationFromSamples",function(){return h}),R.d($,"offsetStartDTS",function(){return o}),R.d($,"segmentValidRange",function(){return d}),R.d($,"appendUint8Array",function(){return c});var X=R("./src/utils/typed-array.ts"),N=R("./src/loader/fragment.ts"),I=Math.pow(2,32)-1,z=[].push;function j(C){return String.fromCharCode.apply(null,C)}function O(C,y){"data"in C&&(y+=C.start,C=C.data);var m=C[y]<<8|C[y+1];return m<0?65536+m:m}function P(C,y){"data"in C&&(y+=C.start,C=C.data);var m=C[y]<<24|C[y+1]<<16|C[y+2]<<8|C[y+3];return m<0?4294967296+m:m}function E(C,y,m){"data"in C&&(y+=C.start,C=C.data),C[y]=m>>24,C[y+1]=m>>16&255,C[y+2]=m>>8&255,C[y+3]=m&255}function L(C,y){var m=[];if(!y.length)return m;var l,S,f;"data"in C?(l=C.data,S=C.start,f=C.end):(l=C,S=0,f=l.byteLength);for(var p=S;p<f;){var s=P(l,p),a=j(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 D(C){var y=L(C,["moov"]),m=y[0],l=m?m.end:null,S=L(C,["sidx"]);if(!S||!S[0])return null;var f=[],p=S[0],s=p.data[0],a=s===0?8:16,b=P(p,a);a+=4;var v=0,x=0;s===0?a+=8:a+=16,a+=2;var k=p.end+x,H=O(p,a);a+=2;for(var V=0;V<H;V++){var Q=a,G=P(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=P(p,Q);Q+=4,f.push({referenceSize:W,subsegmentDuration:oe,info:{duration:oe/b,start:k,end:k+W-1}}),k+=W,Q+=4,a=Q}return{earliestPresentationTime:v,timescale:b,version:s,referencesCount:H,references:f,moovEndOffset:l}}function T(C){for(var y=[],m=L(C,["moov","trak"]),l=0;l<m.length;l++){var S=m[l],f=L(S,["tkhd"])[0];if(f){var p=f.data[f.start],s=p===0?12:20,a=P(f,s),b=L(S,["mdia","mdhd"])[0];if(b){p=b.data[b.start],s=p===0?12:20;var v=P(b,s),x=L(S,["mdia","hdlr"])[0];if(x){var k=j(x.data.subarray(x.start+8,x.start+12)),H={soun:N.ElementaryStreamTypes.AUDIO,vide:N.ElementaryStreamTypes.VIDEO}[k];if(H){var V=L(S,["mdia","minf","stbl","stsd"])[0],Q=void 0;V&&(Q=j(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(C,["moov","mvex","trex"]);return G.forEach(function(W){var q=P(W,4),oe=y[q];oe&&(oe.default={duration:P(W,12),flags:P(W,20)})}),y}function A(C,y){return L(y,["moof","traf"]).reduce(function(m,l){var S=L(l,["tfdt"])[0],f=S.data[S.start],p=L(l,["tfhd"]).reduce(function(s,a){var b=P(a,4),v=C[b];if(v){var x=P(S,4);f===1&&(x*=Math.pow(2,32),x+=P(S,8));var k=v.timescale||9e4,H=x/k;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 w(C,y){for(var m=0,l=0,S=0,f=L(C,["moof","traf"]),p=0;p<f.length;p++){var s=f[p],a=L(s,["tfhd"])[0],b=P(a,4),v=y[b];if(!v)continue;var x=v.default,k=P(a,0)|(x==null?void 0:x.flags),H=x==null?void 0:x.duration;k&8&&(k&2?H=P(a,12):H=P(a,8));for(var V=v.timescale||9e4,Q=L(s,["trun"]),G=0;G<Q.length;G++){if(H){var W=P(Q[G],4);m=H*W}else m=h(Q[G]);v.type===N.ElementaryStreamTypes.VIDEO?l+=m/V:v.type===N.ElementaryStreamTypes.AUDIO&&(S+=m/V)}}if(l===0&&S===0){var q=D(C);if(q!=null&&q.references)return q.references.reduce(function(oe,fe){return oe+fe.info.duration||0},0)}return l||S}function h(C){var y=P(C,0),m=8;y&1&&(m+=4),y&4&&(m+=4);for(var l=0,S=P(C,4),f=0;f<S;f++){if(y&256){var p=P(C,m);l+=p,m+=4}y&512&&(m+=4),y&1024&&(m+=4),y&2048&&(m+=4)}return l}function o(C,y,m){L(y,["moof","traf"]).forEach(function(l){L(l,["tfhd"]).forEach(function(S){var f=P(S,4),p=C[f];if(!p)return;var s=p.timescale||9e4;L(l,["tfdt"]).forEach(function(a){var b=a.data[a.start],v=P(a,4);if(b===0)E(a,4,v-m*s);else{v*=Math.pow(2,32),v+=P(a,8),v-=m*s,v=Math.max(v,0);var x=Math.floor(v/(I+1)),k=Math.floor(v%(I+1));E(a,4,x),E(a,8,k)}})})})}function d(C){var y={valid:null,remainder:null},m=L(C,["moof"]);if(m){if(m.length<2)return y.remainder=C,y}else return y;var l=m[m.length-1];return y.valid=Object(X.sliceUint8)(C,0,l.start-8),y.remainder=Object(X.sliceUint8)(C,l.start-8),y}function c(C,y){var m=new Uint8Array(C.length+y.length);return m.set(C),m.set(y,C.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,j){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=z,this.trackName=j}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(j,O,P){(this.startTime===null||this.startTime>j)&&(this.startTime=j),this.endTime=O,this.screen=P,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 j}),R.d($,"getCuesInRange",function(){return P});var X=R("./src/utils/logger.ts");function N(E,L){var D;try{D=new Event("addtrack")}catch(T){D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=E,L.dispatchEvent(D)}function I(E,L){var D=E.mode;if(D==="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)}D==="disabled"&&(E.mode=D)}function z(E){var L=E.mode;if(L==="disabled"&&(E.mode="hidden"),E.cues)for(var D=E.cues.length;D--;)E.removeCue(E.cues[D]);L==="disabled"&&(E.mode=L)}function j(E,L,D){var T=E.mode;if(T==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var A=P(E.cues,L,D),w=0;w<A.length;w++)E.removeCue(A[w]);T==="disabled"&&(E.mode=T)}function O(E,L){if(L<E[0].startTime)return 0;var D=E.length-1;if(L>E[D].endTime)return-1;for(var T=0,A=D;T<=A;){var w=Math.floor((A+T)/2);if(L<E[w].startTime)A=w-1;else if(L>E[w].startTime&&T<D)T=w+1;else return w}return E[T].startTime-L<L-E[A].startTime?T:A}function P(E,L,D){var T=[],A=O(E,L);if(A>-1)for(var w=A,h=E.length;w<h;w++){var o=E[w];if(o.startTime>=L&&o.endTime<=D)T.push(o);else if(o.startTime>D)return T}return T}},"./src/utils/time-ranges.ts":function(ae,$,R){"use strict";R.r($);var X={toString:function(I){for(var z="",j=I.length,O=0;O<j;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 j});var X=9e4;function N(O,P,E,L){E===void 0&&(E=1),L===void 0&&(L=!1);var D=O*P*E;return L?Math.round(D):D}function I(O,P,E,L){return E===void 0&&(E=1),L===void 0&&(L=!1),N(O,P,1/E,L)}function z(O,P){return P===void 0&&(P=!1),N(O,1e3,1/X,P)}function j(O,P){return P===void 0&&(P=1),N(O,X,1/P)}},"./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 D=L.toLowerCase();return~E.indexOf(D)?D:!1}function z(E){return I(X,E)}function j(E){return I(N,E)}function O(E){for(var L=arguments.length,D=new Array(L>1?L-1:0),T=1;T<L;T++)D[T-1]=arguments[T];for(var A=1;A<arguments.length;A++){var w=arguments[A];for(var h in w)E[h]=w[h]}return E}function P(E,L,D){var T=this,A={enumerable:!0};T.hasBeenReset=!1;var w="",h=!1,o=E,d=L,c=D,C=null,y="",m=!0,l="auto",S="start",f=50,p="middle",s=50,a="middle";Object.defineProperty(T,"id",O({},A,{get:function(){return w},set:function(v){w=""+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 d},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");d=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",O({},A,{get:function(){return c},set:function(v){c=""+v,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",O({},A,{get:function(){return C},set:function(v){C=v,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",O({},A,{get:function(){return y},set:function(v){var x=z(v);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=x,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 S},set:function(v){var x=j(v);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");S=x,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 x=j(v);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");p=x,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 x=j(v);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");a=x,this.hasBeenReset=!0}})),T.displayState=void 0}return P.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},P}()},"./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 D});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,d,c){return(h|0)*3600+(o|0)*60+(d|0)+parseFloat(c||0)}var w=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return w?parseFloat(w[2])>59?A(w[2],w[3],0,w[4]):A(w[1],w[2],w[3],w[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,d){return d?this.has(h)?this.values[h]:o[d]:this.has(h)?this.values[h]:o},A.has=function(h){return h in this.values},A.alt=function(h,o,d){for(var c=0;c<d.length;++c)if(o===d[c]){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 d=parseFloat(o);if(d>=0&&d<=100)return this.set(h,d),!0}return!1},T}();function j(T,A,w,h){var o=h?T.split(h):[T];for(var d in o){if(typeof o[d]!="string")continue;var c=o[d].split(w);if(c.length!==2)continue;var C=c[0],y=c[1];A(C,y)}}var O=new X.default(0,0,""),P=O.align==="middle"?"middle":"center";function E(T,A,w){var h=T;function o(){var C=I(T);if(C===null)throw new Error("Malformed timestamp: "+h);return T=T.replace(/^[^\sa-zA-Z-]+/,""),C}function d(C,y){var m=new z;j(C,function(f,p){var s;switch(f){case"region":for(var a=w.length-1;a>=0;a--)if(w[a].id===p){m.set(f,w[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",P,"end"]);break;case"position":s=p.split(","),m.percent(f,s[0]),s.length===2&&m.alt("positionAlign",s[1],["start",P,"end","line-left","line-right","auto"]);break;case"size":m.percent(f,p);break;case"align":m.alt(f,p,["start",P,"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",P);var S=m.get("position","auto");S==="auto"&&O.position===50&&(S=y.align==="start"||y.align==="left"?0:y.align==="end"||y.align==="right"?100:50),y.position=S}function c(){T=T.replace(/^\s+/,"")}if(c(),A.startTime=o(),c(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);T=T.substr(3),c(),A.endTime=o(),c(),d(T,A)}function L(T){return T.replace(/<br(?: \/)?>/gi,`
|
|
`)}var D=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 d(){var S=o.buffer,f=0;for(S=L(S);f<S.length&&S[f]!=="\r"&&S[f]!==`
|
|
`;)++f;var p=S.substr(0,f);return S[f]==="\r"&&++f,S[f]===`
|
|
`&&++f,o.buffer=S.substr(f),p}function c(S){j(S,function(f,p){},/:/)}try{var C="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;C=d();var y=C.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=d();switch(o.state){case"HEADER":/:/.test(C)?c(C):C||(o.state="ID");continue;case"NOTE":C||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(C)){o.state="NOTE";break}if(!C)continue;if(o.cue=new X.default(0,0,""),o.state="CUE",C.indexOf("-->")===-1){o.cue.id=C;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{E(C,o.cue,o.regionList)}catch(S){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var l=C.indexOf("-->")!==-1;if(!C||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+=C}continue;case"BADCUE":C||(o.state="ID")}}}catch(S){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 D}),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"),j=R("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,P=function(h,o,d){return d===void 0&&(d=0),h.substr(d,o.length)===o},E=function(h){var o=parseInt(h.substr(-3)),d=parseInt(h.substr(-6,2)),c=parseInt(h.substr(-9,2)),C=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(X.isFiniteNumber)(o)||!Object(X.isFiniteNumber)(d)||!Object(X.isFiniteNumber)(c)||!Object(X.isFiniteNumber)(C))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return o+=1e3*d,o+=60*1e3*c,o+=60*60*1e3*C,o},L=function(h){for(var o=5381,d=h.length;d;)o=o*33^h.charCodeAt(--d);return(o>>>0).toString()};function D(w,h,o){return L(w.toString())+L(h.toString())+L(o)}var T=function(h,o,d){var c=h[o],C=h[c.prevCC];if(!C||!C.new&&c.new){h.ccOffset=h.presentationOffset=c.start,c.new=!1;return}for(;(y=C)!==null&&y!==void 0&&y.new;){var y;h.ccOffset+=c.start-C.start,c.new=!1,c=C,C=h[c.prevCC]}h.presentationOffset=d};function A(w,h,o,d,c,C,y,m){var l=new N.VTTParser,S=Object(I.utf8ArrayToStr)(new Uint8Array(w)).trim().replace(O,`
|
|
`).split(`
|
|
`),f=[],p=Object(z.toMpegTsClockFromTimescale)(h,o),s="00:00.000",a=0,b=0,v,x=!0,k=!1;l.oncue=function(H){var V=d[c],Q=d.ccOffset,G=(a-p)/9e4;if(V!=null&&V.new&&(b!==void 0?Q=d.ccOffset=V.start:T(d,c,G)),G&&(Q=G-d.presentationOffset),k){var W=H.endTime-H.startTime,q=Object(j.normalizePts)((H.startTime+Q-b)*9e4,C*9e4)/9e4;H.startTime=q,H.endTime=q+W}var oe=H.text.trim();H.text=decodeURIComponent(encodeURIComponent(oe)),H.id||(H.id=D(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)},S.forEach(function(H){if(x)if(P(H,"X-TIMESTAMP-MAP=")){x=!1,k=!0,H.substr(16).split(",").forEach(function(V){P(V,"LOCAL:")?s=V.substr(6):P(V,"MPEGTS:")&&(a=parseInt(V.substr(7)))});try{b=E(s)/1e3}catch(V){k=!1,v=V}return}else H===""&&(x=!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 j(P){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=P?P.xhrSetup:null,this.stats=new N.LoadStats,this.retryDelay=0}var O=j.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,D){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=D,this.retryDelay=L.retryDelay,this.loadInternal()},O.loadInternal=function(){var E=this.config,L=this.context;if(!E)return;var D=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var A=this.xhrSetup;try{if(A)try{A(D,L.url)}catch(o){D.open("GET",L.url,!0),A(D,L.url)}D.readyState||D.open("GET",L.url,!0);var w=this.context.headers;if(w)for(var h in w)D.setRequestHeader(h,w[h])}catch(o){this.callbacks.onError({code:D.status,text:o.message},L,D);return}L.rangeEnd&&D.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),D.send()},O.readystatechange=function(){var E=this.context,L=this.loader,D=this.stats;if(!E||!L)return;var T=L.readyState,A=this.config;if(D.aborted)return;if(T>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),T===4){L.onreadystatechange=null,L.onprogress=null;var w=L.status;if(w>=200&&w<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var h,o;if(E.responseType==="arraybuffer"?(h=L.response,o=h.byteLength):(h=L.responseText,o=h.length),D.loaded=D.total=o,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(D,E,h,L),!this.callbacks)return;var c={url:L.responseURL,data:h};this.callbacks.onSuccess(c,D,E,L)}else D.retry>=A.maxRetry||w>=400&&w<499?(X.logger.error(w+" while loading "+E.url),this.callbacks.onError({code:w,text:L.statusText},E,L)):(X.logger.warn(w+" 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),D.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},j}();$.default=z}}).default})},vHTk:function(At,ft,re){At.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|