|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[249,5,7,10],{"+NIl":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/stex/stex.js ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){"use strict";t.defineMode("stex",(function(t,e){function i(t,e){t.cmdState.push(e)}function n(t){return t.cmdState.length>0?t.cmdState[t.cmdState.length-1]:null}function r(t,e,i){return function(){this.name=t,this.bracketNo=0,this.style=e,this.styles=i,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var a={};function o(t,e){t.f=e}function s(t,e){var r;if(t.match(/^\\[a-zA-Z@]+/)){var s=t.current().slice(1);return i(e,r=new(r=a.hasOwnProperty(s)?a[s]:a.DEFAULT)),o(e,c),r.style}if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/\\]/))return"tag";if(t.match("\\["))return o(e,(function(t,e){return l(t,e,"\\]")})),"keyword";if(t.match("\\("))return o(e,(function(t,e){return l(t,e,"\\)")})),"keyword";if(t.match("$$"))return o(e,(function(t,e){return l(t,e,"$$")})),"keyword";if(t.match("$"))return o(e,(function(t,e){return l(t,e,"$")})),"keyword";var u=t.next();return"%"==u?(t.skipToEnd(),"comment"):"}"==u||"]"==u?(r=n(e))?(r.closeBracket(u),o(e,c),"bracket"):"error":"{"==u||"["==u?(i(e,r=new(r=a.DEFAULT)),"bracket"):/\d/.test(u)?(t.eatWhile(/[\w.%]/),"atom"):(t.eatWhile(/[\w\-_]/),"begin"==(r=function(t){for(var e=t.cmdState,i=e.length-1;i>=0;i--){var n=e[i];if("DEFAULT"!=n.name)return n}return{styleIdentifier:function(){return null}}}(e)).name&&(r.argument=t.current()),r.styleIdentifier())}function l(t,e,i){if(t.eatSpace())return null;if(i&&t.match(i))return o(e,s),"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 n=t.next();return"{"==n||"}"==n||"["==n||"]"==n||"("==n||")"==n?"bracket":"%"==n?(t.skipToEnd(),"comment"):"error"}function c(t,e){var i=t.peek();return"{"==i||"["==i?(n(e).openBracket(i),t.eat(i),o(e,s),"bracket"):/[ \t\r]/.test(i)?(t.eat(i),null):(o(e,s),function(t){var e=t.cmdState.pop();e&&e.closeBracket()}(e),s(t,e))}return a.importmodule=r("importmodule","tag",["string","builtin"]),a.documentclass=r("documentclass","tag",["","atom"]),a.usepackage=r("usepackage","tag",["atom"]),a.begin=r("begin","tag",["atom"]),a.end=r("end","tag",["atom"]),a.label=r("label","tag",["atom"]),a.ref=r("ref","tag",["atom"]),a.eqref=r("eqref","tag",["atom"]),a.cite=r("cite","tag",["atom"]),a.bibitem=r("bibitem","tag",["atom"]),a.Bibitem=r("Bibitem","tag",["atom"]),a.RBibitem=r("RBibitem","tag",["atom"]),a.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{startState:function(){return{cmdState:[],f:e.inMathMode?function(t,e){return l(t,e)}:s}},copyState:function(t){return{cmdState:t.cmdState.slice(),f:t.f}},token:function(t,e){return e.f(t,e)},blankLine:function(t){t.f=s,t.cmdState.length=0},lineComment:"%"}})),t.defineMIME("text/x-stex","stex"),t.defineMIME("text/x-latex","stex")}(i(/*! ../../lib/codemirror */"VrN/"))},"19Vz":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/display/placeholder.js ***!
|
|
|
\**************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){function e(t){t.state.placeholder&&(t.state.placeholder.parentNode.removeChild(t.state.placeholder),t.state.placeholder=null)}function i(t){e(t);var i=t.state.placeholder=document.createElement("pre");i.style.cssText="height: 0; overflow: visible",i.style.direction=t.getOption("direction"),i.className="CodeMirror-placeholder CodeMirror-line-like";var n=t.getOption("placeholder");"string"==typeof n&&(n=document.createTextNode(n)),i.appendChild(n),t.display.lineSpace.insertBefore(i,t.display.lineSpace.firstChild)}function n(t){a(t)&&i(t)}function r(t){var n=t.getWrapperElement(),r=a(t);n.className=n.className.replace(" CodeMirror-empty","")+(r?" CodeMirror-empty":""),r?i(t):e(t)}function a(t){return 1===t.lineCount()&&""===t.getLine(0)}t.defineOption("placeholder","",(function(a,o,s){var l=s&&s!=t.Init;if(o&&!l)a.on("blur",n),a.on("change",r),a.on("swapDoc",r),t.on(a.getInputField(),"compositionupdate",a.state.placeholderCompose=function(){!function(t){setTimeout((function(){var n=!1,r=t.getInputField();"TEXTAREA"==r.nodeName?n=!r.value:1==t.lineCount()&&(n=!/[^\u200b]/.test(r.querySelector(".CodeMirror-line").textContent)),n?i(t):e(t)}),20)}(a)}),r(a);else if(!o&&l){a.off("blur",n),a.off("change",r),a.off("swapDoc",r),t.off(a.getInputField(),"compositionupdate",a.state.placeholderCompose),e(a);var c=a.getWrapperElement();c.className=c.className.replace(" CodeMirror-empty","")}o&&!a.hasFocus()&&n(a)}))}(i(/*! ../../lib/codemirror */"VrN/"))},"1eCo":
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/xml/xml.js ***!
|
|
|
\*************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){"use strict";var e={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},i={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};t.defineMode("xml",(function(n,r){var a,o,s=n.indentUnit,l={},c=r.htmlMode?e:i;for(var u in c)l[u]=c[u];for(var u in r)l[u]=r[u];function h(t,e){function i(i){return e.tokenize=i,i(t,e)}var n=t.next();return"<"==n?t.eat("!")?t.eat("[")?t.match("CDATA[")?i(f("atom","]]>")):null:t.match("--")?i(f("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),i(function t(e){return function(i,n){for(var r;null!=(r=i.next());){if("<"==r)return n.tokenize=t(e+1),n.tokenize(i,n);if(">"==r){if(1==e){n.tokenize=h;break}return n.tokenize=t(e-1),n.tokenize(i,n)}}return"meta"}}(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=f("meta","?>"),"meta"):(a=t.eat("/")?"closeTag":"openTag",e.tokenize=d,"tag bracket"):"&"==n?(t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"))?"atom":"error":(t.eatWhile(/[^&<]/),null)}function d(t,e){var i,n,r=t.next();if(">"==r||"/"==r&&t.eat(">"))return e.tokenize=h,a=">"==r?"endTag":"selfcloseTag","tag bracket";if("="==r)return a="equals",null;if("<"==r){e.tokenize=h,e.state=v,e.tagName=e.tagStart=null;var o=e.tokenize(t,e);return o?o+" tag error":"tag error"}return/[\'\"]/.test(r)?(e.tokenize=(i=r,(n=function(t,e){for(;!t.eol();)if(t.next()==i){e.tokenize=d;break}return"string"}).isInAttribute=!0,n),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function f(t,e){return function(i,n){for(;!i.eol();){if(i.match(e)){n.tokenize=h;break}i.next()}return t}}function p(t,e,i){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=i,(l.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}function m(t){t.context&&(t.context=t.context.prev)}function g(t,e){for(var i;;){if(!t.context)return;if(i=t.context.tagName,!l.contextGrabbers.hasOwnProperty(i)||!l.contextGrabbers[i].hasOwnProperty(e))return;m(t)}}function v(t,e,i){return"openTag"==t?(i.tagStart=e.column(),y):"closeTag"==t?b:v}function y(t,e,i){return"word"==t?(i.tagName=e.current(),o="tag",C):l.allowMissingTagName&&"endTag"==t?(o="tag bracket",C(t,0,i)):(o="error",y)}function b(t,e,i){if("word"==t){var n=e.current();return i.context&&i.context.tagName!=n&&l.implicitlyClosed.hasOwnProperty(i.context.tagName)&&m(i),i.context&&i.context.tagName==n||!1===l.matchClosing?(o="tag",x):(o="tag error",S)}return l.allowMissingTagName&&"endTag"==t?(o="tag bracket",x(t,0,i)):(o="error",S)}function x(t,e,i){return"endTag"!=t?(o="error",x):(m(i),v)}function S(t,e,i){return o="error",x(t,0,i)}function C(t,e,i){if("word"==t)return o="attribute",k;if("endTag"==t||"selfcloseTag"==t){var n=i.tagName,r=i.tagStart;return i.tagName=i.tagStart=null,"selfcloseTag"==t||l.autoSelfClosers.hasOwnProperty(n)?g(i,n):(g(i,n),i.context=new p(i,n,r==i.indented)),v}return o="error",C}function k(t,e,i){return"equals"==t?E:(l.allowMissing||(o="error"),C(t,0,i))}function E(t,e,i){return"string"==t?w:"word"==t&&l.allowUnquoted?(o="string",C):(o="error",C(t,0,i))}function w(t,e,i){return"string"==t?w:C(t,0,i)}return h.isInText=!0,{startState:function(t){var e={tokenize:h,state:v,indented:t||0,tagName:null,tagStart:null,context:null};return null!=t&&(e.baseIndent=t),e},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;a=null;var i=e.tokenize(t,e);return(i||a)&&"comment"!=i&&(o=null,e.state=e.state(a||i,t,e),o&&(i="error"==o?i+" error":o)),i},indent:function(e,i,n){var r=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+s;if(r&&r.noIndent)return t.Pass;if(e.tokenize!=d&&e.tokenize!=h)return n?n.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==l.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+s*(l.multilineTagIndentFactor||1);if(l.alignCDATA&&/<!\[CDATA\[/.test(i))return 0;var a=i&&/^<(\/)?([\w_:\.-]*)/.exec(i);if(a&&a[1])for(;r;){if(r.tagName==a[2]){r=r.prev;break}if(!l.implicitlyClosed.hasOwnProperty(r.tagName))break;r=r.prev}else if(a)for(;r;){var o=l.contextGrabbers[r.tagName];if(!o||!o.hasOwnProperty(a[2]))break;r=r.prev}for(;r&&r.prev&&!r.startOfLine;)r=r.prev;return r?r.indent+s:e.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:l.htmlMode?"html":"xml",helperType:l.htmlMode?"html":"xml",skipAttribute:function(t){t.state==E&&(t.state=C)},xmlCurrentTag:function(t){return t.tagName?{name:t.tagName,close:"closeTag"==t.type}:null},xmlCurrentContext:function(t){for(var e=[],i=t.context;i;i=i.prev)i.tagName&&e.push(i.tagName);return e.reverse()}}})),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})}(i(/*! ../../lib/codemirror */"VrN/"))},"55Ip":
|
|
|
/*!***************************************************************!*\
|
|
|
!*** ./node_modules/react-router-dom/esm/react-router-dom.js ***!
|
|
|
\***************************************************************/
|
|
|
/*! exports provided: MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter, BrowserRouter, HashRouter, Link, NavLink */
|
|
|
/*! exports used: Link, NavLink */function(t,e,i){"use strict";i.d(e,"a",(function(){return g})),i.d(e,"b",(function(){return b}));var n=i(/*! react-router */"Ty5D"),r=i(/*! @babel/runtime/helpers/esm/inheritsLoose */"dI71"),a=i(/*! react */"q1tI"),o=i.n(a),s=i(/*! history */"YS25"),l=(i(/*! prop-types */"17x9"),i(/*! @babel/runtime/helpers/esm/extends */"wx14")),c=i(/*! @babel/runtime/helpers/esm/objectWithoutPropertiesLoose */"zLVn"),u=i(/*! tiny-invariant */"9R94");o.a.Component;o.a.Component;var h=function(t,e){return"function"==typeof t?t(e):t},d=function(t,e){return"string"==typeof t?Object(s.c)(t,null,null,e):t},f=function(t){return t},p=o.a.forwardRef;void 0===p&&(p=f);var m=p((function(t,e){var i=t.innerRef,n=t.navigate,r=t.onClick,a=Object(c.a)(t,["innerRef","navigate","onClick"]),s=a.target,u=Object(l.a)({},a,{onClick:function(t){try{r&&r(t)}catch(e){throw t.preventDefault(),e}t.defaultPrevented||0!==t.button||s&&"_self"!==s||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||(t.preventDefault(),n())}});return u.ref=f!==p&&e||i,o.a.createElement("a",u)}));var g=p((function(t,e){var i=t.component,r=void 0===i?m:i,a=t.replace,s=t.to,g=t.innerRef,v=Object(c.a)(t,["component","replace","to","innerRef"]);return o.a.createElement(n.e.Consumer,null,(function(t){t||Object(u.a)(!1);var i=t.history,n=d(h(s,t.location),t.location),c=n?i.createHref(n):"",m=Object(l.a)({},v,{href:c,navigate:function(){var e=h(s,t.location);(a?i.replace:i.push)(e)}});return f!==p?m.ref=e||g:m.innerRef=g,o.a.createElement(r,m)}))})),v=function(t){return t},y=o.a.forwardRef;void 0===y&&(y=v);var b=y((function(t,e){var i=t["aria-current"],r=void 0===i?"page":i,a=t.activeClassName,s=void 0===a?"active":a,f=t.activeStyle,p=t.className,m=t.exact,b=t.isActive,x=t.location,S=t.sensitive,C=t.strict,k=t.style,E=t.to,w=t.innerRef,T=Object(c.a)(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return o.a.createElement(n.e.Consumer,null,(function(t){t||Object(u.a)(!1);var i=x||t.location,a=d(h(E,i),i),c=a.pathname,O=c&&c.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),L=O?Object(n.f)(i.pathname,{path:O,exact:m,sensitive:S,strict:C}):null,A=!!(b?b(L,i):L),D=A?function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.filter((function(t){return t})).join(" ")}(p,s):p,_=A?Object(l.a)({},k,{},f):k,R=Object(l.a)({"aria-current":A&&r||null,className:D,style:_,to:a},T);return v!==y?R.ref=e||w:R.innerRef=w,o.a.createElement(g,R)}))}))},"7Cbv":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),r=new Uint8Array(16);function a(){if(!n)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(r)}var o=/^(?:[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;for(var s=function(t){return"string"==typeof t&&o.test(t)},l=[],c=0;c<256;++c)l.push((c+256).toString(16).substr(1));var u=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase();if(!s(i))throw TypeError("Stringified UUID is invalid");return i};e.a=function(t,e,i){var n=(t=t||{}).random||(t.rng||a)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){i=i||0;for(var r=0;r<16;++r)e[i+r]=n[r];return e}return u(n)}},"7ahc":
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/code-block/index.tsx ***!
|
|
|
\*************************************************************/
|
|
|
/*! exports provided: default, MyCodeMirror */
|
|
|
/*! exports used: MyCodeMirror, default */function(t,e,i){"use strict";i.d(e,"a",(function(){return g}));var n=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),r=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends */"0Owb"),a=(i(/*! antd/es/button/style */"+L6B"),i(/*! antd/es/button */"2/Rp")),o=(i(/*! antd/es/form/style */"y8nQ"),i(/*! antd/es/form */"Vl3Y")),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),l=(i(/*! antd/es/select/style */"OaEy"),i(/*! antd/es/select */"2fM7")),c=i(/*! react */"q1tI"),u=i.n(c),h=i(/*! codemirror */"VrN/"),d=i.n(h),f=(i(/*! codemirror/lib/codemirror.css */"p77/"),i(/*! codemirror/theme/blackboard.css */"c5Ni"),l.a.Option),p={labelCol:{span:4},wrapperCol:{span:20}},m={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"]};function g(t){var e=t.value,i=t.onChange,r=t.mode,a=t.options,o=void 0===a?{}:a,l=Object(c.useRef)(),h=Object(c.useState)(),f=Object(s.a)(h,2),p=f[0],m=f[1];return Object(c.useEffect)((function(){if(p){function t(t){var e=t.getValue();i&&i(e)}return p.on("change",t),function(){p.off("change",t)}}}),[p,i]),Object(c.useEffect)((function(){p&&p.setOption("mode",r)}),[p,r]),Object(c.useEffect)((function(){p&&(e===p.getValue()&&""!==e||setTimeout((function(){p.setValue(e||" ")}),300))}),[p,e]),Object(c.useEffect)((function(){if(l.current&&!p){var t=d.a.fromTextArea(l.current,Object(n.a)({mode:r,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},o));m(t)}}),[l.current,p]),u.a.createElement("div",{className:"my-codemirror-container"},u.a.createElement("textarea",{ref:l}))}e.b=function(t){var e=t.callback,i=t.onCancel,n=Object(c.useState)("python"),h=Object(s.a)(n,2),d=h[0],v=h[1];return u.a.createElement(o.a,Object(r.a)({},p,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:function(t){e(t)}}),u.a.createElement(o.a.Item,{label:"代码语言",name:"language"},u.a.createElement(l.a,{onChange:function(t){v(m[t][1])}},Object.keys(m).map((function(t){return u.a.createElement(f,{key:t,value:t},m[t][0])})))),u.a.createElement(o.a.Item,{label:"代码内容",name:"content",rules:[{required:!0,message:"请输入代码内容"}]},u.a.createElement(g,{mode:d})),u.a.createElement("div",{className:"flex-container flex-end"},u.a.createElement(a.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),u.a.createElement(a.a,{type:"ghost",onClick:i},"取消")))}},"7qnI":
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./src/components/Editor/NullChildEditor/index.js ***!
|
|
|
\********************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i(/*! antd/es/tooltip/style */"5Dmo");var n=i(/*! antd/es/tooltip */"3S7+"),r=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/classCallCheck */"fWQN"),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createClass */"mtLc"),o=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/inherits */"yKVA"),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createSuper */"879j"),l=(i(/*! antd/es/input/style */"5NDa"),i(/*! antd/es/input */"5rEg")),c=i(/*! react */"q1tI"),u=i.n(c),h=i(/*! ./index.less?modules */"O2Wb"),d=i.n(h),f=l.a.TextArea,p=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(){return Object(r.a)(this,i),e.apply(this,arguments)}return Object(a.a)(i,[{key:"render",value:function(){var t=this,e=this.props,i=e.index,r=e.onAnswerChange,a=e.addChildAnswer,o=e.exerciseIsPublish,s=e.answers,l=e.activeOptionErrorIndex,c=e.flex,h=void 0===c?"0 0 1000px":c;return u.a.createElement("div",{className:d.a.flex},u.a.createElement("div",{className:"".concat(d.a.color666," mb5 mt6"),style:{flex:"0 0 90px"}},"答案(填空",i+1,"):"),u.a.createElement("div",{className:"".concat(d.a.flex," ").concat(d.a.flex1),style:{flexDirection:"column"}},s.map((function(e,c){var p="".concat(i,"-").concat(c);return u.a.createElement("div",{className:"".concat(d.a.flex," ").concat(d.a.flex1),key:c},u.a.createElement("div",{className:d.a.flex1,style:{flex:h}},u.a.createElement("div",null,u.a.createElement(f,{className:p===l?d.a.error:"",spellCheck:!1,rows:4,value:e||"",defaultValue:"请输入参考答案".concat(0==c?"":"(可选)"),onChange:function(t){return r(i,c,t.target.value)},style:{minHeight:95}}))),!o&&u.a.createElement(u.a.Fragment,null,0!=c&&u.a.createElement(n.a,{title:"删除"},u.a.createElement("i",{className:"".concat(d.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return t.props.deleteChildAnswer(i,c)},style:{float:"right"}})),0===c&&u.a.createElement(n.a,{title:"删除"},u.a.createElement("i",{className:"".concat(d.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return t.props.deleteChildAnswermain(i,c)},style:{float:"right"}})),u.a.createElement(n.a,{title:"新增参考答案"},u.a.createElement("i",{className:"".concat(d.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return a(i)},style:{float:"right",visibility:c==s.length-1?"":"hidden"}}))))}))))}}]),i}(c.Component);e.a=p},"8EBN":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/meta.js ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){"use strict";t.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 e=0;e<t.modeInfo.length;e++){var i=t.modeInfo[e];i.mimes&&(i.mime=i.mimes[0])}t.findModeByMIME=function(e){e=e.toLowerCase();for(var i=0;i<t.modeInfo.length;i++){var n=t.modeInfo[i];if(n.mime==e)return n;if(n.mimes)for(var r=0;r<n.mimes.length;r++)if(n.mimes[r]==e)return n}return/\+xml$/.test(e)?t.findModeByMIME("application/xml"):/\+json$/.test(e)?t.findModeByMIME("application/json"):void 0},t.findModeByExtension=function(e){e=e.toLowerCase();for(var i=0;i<t.modeInfo.length;i++){var n=t.modeInfo[i];if(n.ext)for(var r=0;r<n.ext.length;r++)if(n.ext[r]==e)return n}},t.findModeByFileName=function(e){for(var i=0;i<t.modeInfo.length;i++){var n=t.modeInfo[i];if(n.file&&n.file.test(e))return n}var r=e.lastIndexOf("."),a=r>-1&&e.substring(r+1,e.length);if(a)return t.findModeByExtension(a)},t.findModeByName=function(e){e=e.toLowerCase();for(var i=0;i<t.modeInfo.length;i++){var n=t.modeInfo[i];if(n.name.toLowerCase()==e)return n;if(n.alias)for(var r=0;r<n.alias.length;r++)if(n.alias[r].toLowerCase()==e)return n}}}(i(/*! ../lib/codemirror */"VrN/"))},"8hTe":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={button:"button___1wy9m"}},"9Bee":
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.tsx + 3 modules ***!
|
|
|
\*********************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/PreviewAll/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/env.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/space/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/space/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/hls.js/dist/hls.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/katex/dist/katex.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/lib/marked.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/src/helpers.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i("DYRE");var n=i("zeV3"),r=(i("+L6B"),i("2/Rp")),a=i("k1fw"),o=i("9og8"),s=i("tJVT"),l=i("WmNS"),c=i.n(l),u=i("q1tI"),h=i.n(u),d=(i("vg9a"),i("DlQD")),f=i.n(d),p=i("rUJ1");var m=[],g=["<ul>"],v=new f.a.Renderer,y=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function b(){m.length=0,g=["<ul>"]}var x={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function S(){return function t(e,i,n,r){if(i>=e.length||e[i].level<=n)return i;var a=e[i];r.push("<li><a href='#"+a.anchor+"'>"+a.text+"</a>");var o=[];return i=t(e,++i,a.level,o),o.length>0&&(r.push("<ul>"),o.forEach((function(t){r.push(t)})),r.push("</ul>")),r.push("</li>"),i=t(e,i,n,r)}(m,0,0,g),g.push("</ul>"),g.join("")}var C={heading:function(t){var e=y.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[1].length,text:e[2]}},fences:function(t){var e=this.rules.block.fences.exec(t);if(e){var i=e[0],n=function(t,e){var i=t.match(/^(\s+)(?:```)/);if(null===i)return e;var n=i[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:Object(s.a)(e,1)[0].length>=n.length?t.slice(n.length):t})).join("\n")}(i,e[3]||""),r=e[2]?e[2].trim():e[2];if(["latex","katex","math"].indexOf(r)>=0){var a=w(),o=n;n=a,T[a]={type:"block",expression:o}}return{type:"code",raw:i,lang:r,text:n}}}},k=/(?:\${2})([^\n`]+?)(?:\${2})/gi,E=0,w=function(){return"__special_katext_id_".concat(E++,"__")},T={};function O(){E=0,T={}}function L(t){return t=t.replace(k,(function(t,e){var i=w();return T[i]={type:"inline",expression:e},i}))}var A=v.listitem;v.listitem=function(t){return A(L(t))};var D=v.paragraph;v.paragraph=function(t){return D(L(t))};var _=v.tablecell;v.tablecell=function(t,e){return _(L(t),e)},v.code=function(t,e,i){var n=(e||"").match(/\S*/)[0];return n?["latex","katex","math"].indexOf(n)>=0?"<p class='editormd-tex'>".concat(t,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(e,'">').concat(i?t:Object(p.escape)(t,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(i?t:Object(p.escape)(t,!0))+"</code></pre>"},v.heading=function(t,e,i){var n=this.options.headerPrefix+i.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return m.push({anchor:n,level:e,text:t}),"<h"+e+' id="'+n+'">'+t+"</h"+e+">"},f.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),f.a.use({tokenizer:C,renderer:v});var R=f.a,I=(i("SJMd"),i("ulZh")),M=i.n(I),N=i("m3rI"),P=i("Oy/b"),F=i("p5ED"),j=i("ErOA"),B=function(t,e){return(B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function U(t,e){function i(){this.constructor=t}B(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function H(t,e,i,n){return new(i||(i=Promise))((function(r,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,s)}l((n=n.apply(t,e||[])).next())}))}function G(t,e){var i,n,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function z(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var a=arguments[e],o=0,s=a.length;o<s;o++,r++)n[r]=a[o];return n}var V=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var i=0,n=e;i<n.length;i++){var r=n[i],a=r[0],o=r[1];t.setAttribute(a,o)}},t.createRect=function(e,i,n){var r=document.createElementNS("http://www.w3.org/2000/svg","rect");return r.setAttribute("width",e.toString()),r.setAttribute("height",i.toString()),n&&t.setAttributes(r,n),r},t.createLine=function(e,i,n,r,a){var o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1",e.toString()),o.setAttribute("y1",i.toString()),o.setAttribute("x2",n.toString()),o.setAttribute("y2",r.toString()),a&&t.setAttributes(o,a),o},t.createPolygon=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","polygon");return n.setAttribute("points",e),i&&t.setAttributes(n,i),n},t.createCircle=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(e/2).toString()),n.setAttribute("r",e.toString()),i&&t.setAttributes(n,i),n},t.createEllipse=function(e,i,n){var r=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return r.setAttribute("cx",(e/2).toString()),r.setAttribute("cy",(i/2).toString()),r.setAttribute("rx",(e/2).toString()),r.setAttribute("ry",(i/2).toString()),n&&t.setAttributes(r,n),r},t.createGroup=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(i,e),i},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,i,n,r,a,o,s){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",i],["markerWidth",n.toString()],["markerHeight",r.toString()],["refX",a.toString()],["refY",o.toString()]]),l.appendChild(s),l},t.createText=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),e&&t.setAttributes(i,e),i},t.createTSpan=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","tspan");return n.textContent=e,i&&t.setAttributes(n,i),n},t.createImage=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(i,e),i},t.createPoint=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return i.x=t,i.y=e,i},t.createPath=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),i&&t.setAttributes(n,i),n},t}(),W=function(){function t(){}return t.addKey=function(e){t.key=e},Object.defineProperty(t,"isLicensed",{get:function(){return!!t.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(t.key)},enumerable:!1,configurable:!0}),t}(),K=function(){function t(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return t.prototype.rasterize=function(t,e,i){var n=this;return new Promise((function(r){var a=void 0!==i?i:document.createElement("canvas");null===t&&(n.markersOnly=!0,n.naturalSize=!1);var o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o.setAttribute("width",e.width.baseVal.valueAsString),o.setAttribute("height",e.height.baseVal.valueAsString),o.setAttribute("viewBox","0 0 "+e.viewBox.baseVal.width.toString()+" "+e.viewBox.baseVal.height.toString()),o.innerHTML=e.innerHTML,!0===n.naturalSize?(o.width.baseVal.value=t.naturalWidth,o.height.baseVal.value=t.naturalHeight):void 0!==n.width&&void 0!==n.height&&(o.width.baseVal.value=n.width,o.height.baseVal.value=n.height),a.width=o.width.baseVal.value,a.height=o.height.baseVal.value;var s=o.outerHTML,l=a.getContext("2d");!0!==n.markersOnly&&l.drawImage(t,0,0,a.width,a.height);var c=window.URL,u=new Image(a.width,a.height);u.setAttribute("crossOrigin","anonymous");var h=new Blob([s],{type:"image/svg+xml"}),d=c.createObjectURL(h);u.onload=function(){l.drawImage(u,0,0),c.revokeObjectURL(d);var t=a.toDataURL(n.imageType,n.imageQuality);r(t)},u.src=d}))},t}(),q=function(){},Y=function(){function t(t){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(t.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(t.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(t.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),t.prototype.addClass=function(t){return void 0===this.styleSheet&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},t.prototype.addRule=function(t){void 0===this.styleSheet&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},t.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),(null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).appendChild(this.styleSheet),this.addRule(new X("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new X("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames","\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n ")),this.addRule(new X("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames","\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n ")),this.addClass(new $("fade_in","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_in_animation_frames;\n ")),this.addClass(new $("fade_out","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_out_animation_frames;\n "))},t.prototype.removeStyleSheet=function(){var t;this.styleSheet&&((null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},t}(),X=function(t,e){this.selector=t,this.style=e},$=function(t,e){this.localName=t,this.style=e},Z=function(){function t(t,e,i,n,r){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=t,this.displayMode=e,this.markerItems=i,this.uiStyleSettings=n,this.styles=r,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return t.prototype.show=function(t){var e=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var i=document.createElement("div");i.className=this.toolbarBlockStyleClass.name,i.style.whiteSpace="nowrap",this.uiContainer.appendChild(i),this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(i,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach((function(t){var i=document.createElement("div");i.className=""+e.toolbarButtonStyleClass.name,i.setAttribute("data-type-name",t.typeName),i.innerHTML=t.icon,i.addEventListener("click",(function(){e.markerToolbarButtonClicked(i,t)})),e.buttons.push(i),e.markerButtons.push(i)})),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 n=document.createElement("div");n.className=this.toolbarBlockStyleClass.name,n.style.whiteSpace="nowrap",n.style.display=!1!==this.uiStyleSettings.resultButtonBlockVisible?"":"none",this.uiContainer.appendChild(n),this.addActionButton(n,'<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(n,'<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()},t.prototype.addButtonClickListener=function(t){this.buttonClickListeners.push(t)},t.prototype.removeButtonClickListener=function(t){this.buttonClickListeners.indexOf(t)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(t),1)},t.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},t.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var t=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var e=0;e<this.markerButtons.length;e++)e<t||e===t&&this.markerButtons.length-1===t?this.markerButtonBlock.appendChild(this.markerButtons[e]):(e===t&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[e]))}},t.prototype.overflowButtonClicked=function(){"none"!==this.markerButtonOverflowBlock.style.display?(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")},t.prototype.resetButtonStyles=function(){var t=this;this.buttons.forEach((function(e){e.className=e.className.replace(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name,"").trim(),e.className=e.className.replace(t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:t.toolbarActiveButtonStyleColorsClass.name,"").trim(),e.className+=" "+(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name)}))},t.prototype.addActionButton=function(t,e,i){var n=this,r=document.createElement("div");switch(r.className=""+this.toolbarButtonStyleClass.name,r.innerHTML=e,r.setAttribute("data-action",i),r.addEventListener("click",(function(){n.actionToolbarButtonClicked(r,i)})),i){case"select":r.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":r.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":r.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":r.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":r.style.fill=this.uiStyleSettings.closeButtonColor}t.appendChild(r),this.buttons.push(r)},t.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new $("toolbar","\n width: 100%;\n flex-shrink: 0;\n display: flex;\n flex-direction: row;\n justify-content: space-between; \n height: "+this.uiStyleSettings.toolbarHeight+"px;\n box-sizing: content-box;\n "+("inline"===this.displayMode?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n "+("inline"===this.displayMode?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n overflow: hidden;\n ")),this.toolbarStyleColorsClass=this.styles.addClass(new $("toolbar_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n box-shadow: 0px 3px rgba(33, 33, 33, 0.1);\n ")),this.toolbarBlockStyleClass=this.styles.addClass(new $("toolbar-block","\n display: inline-block;\n box-sizing: content-box;\n ")),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new $("toolbar-overflow-block","\n position: absolute;\n top: "+this.uiStyleSettings.toolbarHeight+"px;\n max-width: "+2*this.uiStyleSettings.toolbarHeight+"px;\n z-index: 10;\n box-sizing: content-box;\n ")),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new $("toolbar-overflow-block_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n "));var t=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new $("toolbar_button","\n display: inline-block;\n width: "+(this.uiStyleSettings.toolbarHeight-2*t)+"px;\n height: "+(this.uiStyleSettings.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n box-sizing: content-box;\n ")),this.toolbarButtonStyleColorsClass=this.styles.addClass(new $("toolbar_button_colors","\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new $("toolbar_active_button","\n fill: "+this.uiStyleSettings.toolbarColor+";\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n ")),this.styles.addRule(new X("."+this.toolbarButtonStyleClass.name+" svg","\n height: "+this.uiStyleSettings.toolbarHeight/2+"px;\n ")),this.styles.addRule(new X("."+this.toolbarButtonStyleColorsClass.name+":hover","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n "))},t.prototype.markerToolbarButtonClicked=function(t,e){this.setActiveButton(t),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach((function(t){return t("marker",e)})),this.markerButtonOverflowBlock.style.display="none"},t.prototype.actionToolbarButtonClicked=function(t,e){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach((function(t){return t("action",e)})),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},t.prototype.setActiveButton=function(t){this.resetButtonStyles(),t.className=t.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),t.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},t.prototype.setActiveMarkerButton=function(t){var e=this.markerButtons.find((function(e){return e.getAttribute("data-type-name")===t}));e&&this.setActiveButton(e)},t.prototype.setCurrentMarker=function(t){var e=this;this.currentMarker=t,this.buttons.filter((function(t){return/delete|notes/.test(t.getAttribute("data-action"))})).forEach((function(t){void 0===e.currentMarker?(t.style.fillOpacity="0.4",t.style.pointerEvents="none"):(t.style.fillOpacity="1",t.style.pointerEvents="all")}))},t}(),J=function(){function t(t,e,i,n){this.panels=[],this.panelButtons=[],this.markerjsContainer=t,this.displayMode=e,this.uiStyleSettings=i,this.styles=n,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return t.prototype.addStyles=function(){var t;this.toolboxStyleClass=this.styles.addClass(new $("toolbox","\n width: 100%;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n font-family: sans-serif;\n "+("popup"===this.displayMode?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+"\n box-sizing: content-box;\n "+("popup"===this.displayMode?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+"\n "+("inline"===this.displayMode?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n "+("inline"===this.displayMode?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+"\n overflow: hidden;\n ")),this.toolboxStyleColorsClass=this.styles.addClass(new $("toolbox_colors","\n color: "+this.uiStyleSettings.toolboxColor+";\n "));var e=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new $("toolbox-button-row","\n display: flex;\n cursor: default;\n box-sizing: content-box;\n ")),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new $("toolbox-button-row_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundColor+";\n ")),this.toolboxPanelRowStyleClass=this.styles.addClass(new $("toolbox-panel-row","\n display: flex;\n "+("inline"===this.displayMode?"position: absolute;":"")+"\n "+("inline"===this.displayMode?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+"\n cursor: default;\n height: "+1.5*this.uiStyleSettings.toolbarHeight+"px;\n "+("inline"===this.displayMode?"width: 100%;":"")+"\n box-sizing: content-box;\n ")),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new $("toolbox-panel-row_colors","\n background-color: "+(null!==(t=this.uiStyleSettings.toolboxBackgroundColor)&&void 0!==t?t:this.uiStyleSettings.toolbarBackgroundHoverColor)+";\n ")),this.toolboxButtonStyleClass=this.styles.addClass(new $("toolbox_button","\n display: inline-block;\n width: "+(this.uiStyleSettings.toolbarHeight-2*e)+"px;\n height: "+(this.uiStyleSettings.toolbarHeight-2*e)+"px;\n padding: "+e+"px;\n box-sizing: content-box;\n ")),this.toolboxButtonStyleColorsClass=this.styles.addClass(new $("toolbox-button_colors","\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new $("toolbox-active-button_colors","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+";\n fill: "+this.uiStyleSettings.toolbarColor+";\n ")),this.styles.addRule(new X("."+this.toolboxButtonStyleColorsClass.name+":hover","\n background-color: "+this.uiStyleSettings.toolbarBackgroundHoverColor+"\n ")),this.styles.addRule(new X("."+this.toolboxButtonStyleClass.name+" svg","\n height: "+this.uiStyleSettings.toolbarHeight/2+"px;\n "))},t.prototype.show=function(t){var e;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolboxStyleClass.name+" "+(null!==(e=this.uiStyleSettings.toolboxStyleColorsClassName)&&void 0!==e?e:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},t.prototype.setPanelButtons=function(t){var e,i,n=this;this.panels=t,void 0!==this.uiContainer&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+(null!==(e=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)&&void 0!==e?e:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+(null!==(i=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)&&void 0!==i?i:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach((function(t){var e;t.uiStyleSettings=n.uiStyleSettings;var i=document.createElement("div");i.className=n.toolboxButtonStyleClass.name+" "+(null!==(e=n.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==e?e:n.toolboxButtonStyleColorsClass.name),i.innerHTML=t.icon,i.title=t.title,i.addEventListener("click",(function(){n.panelButtonClick(t)})),n.panelButtons.push(i),n.buttonRow.appendChild(i)})),"inline"===this.displayMode?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},t.prototype.panelButtonClick=function(t){var e=this,i=-1;if(t!==this.activePanel){i=this.panels.indexOf(t),this.panelRow.innerHTML="";var n=t.getUi();n.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(n),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=t}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout((function(){"inline"===e.displayMode?e.panelRow.style.display="none":e.panelRow.style.visibility="hidden"}),200);this.panelButtons.forEach((function(t,n){var r,a;t.className=e.toolboxButtonStyleClass.name+" "+(n===i?""+(null!==(r=e.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)&&void 0!==r?r:e.toolboxActiveButtonStyleColorsClass.name):""+(null!==(a=e.uiStyleSettings.toolboxButtonStyleColorsClassName)&&void 0!==a?a:e.toolboxButtonStyleColorsClass.name))}))},t}(),Q=function(t,e){this.title=t,this.icon=e},tt=function(t){function e(e,i,n,r){var a=t.call(this,e,r||'<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 a.colors=[],a.addTransparent=!1,a.colorBoxes=[],a.colors=i,a.currentColor=n,a.setCurrentColor=a.setCurrentColor.bind(a),a.getColorBox=a.getColorBox.bind(a),a}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.overflow="hidden",e.style.whiteSpace="nowrap",this.colors.forEach((function(i){var n=t.getColorBox(i);e.appendChild(n),t.colorBoxes.push(n)})),e},e.prototype.getColorBox=function(t){var e=this,i=this.uiStyleSettings.toolbarHeight/4,n=this.uiStyleSettings.toolbarHeight-i,r=document.createElement("div");r.style.display="inline-block",r.style.boxSizing="content-box",r.style.width=n-2+"px",r.style.height=n-2+"px",r.style.padding="1px",r.style.marginRight="2px",r.style.marginBottom="2px",r.style.borderWidth="2px",r.style.borderStyle="solid",r.style.borderRadius=(n+2)/2+"px",r.style.borderColor=t===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",r.addEventListener("click",(function(){e.setCurrentColor(t,r)}));var a=document.createElement("div");return a.style.display="inline-block",a.style.width=n-2+"px",a.style.height=n-2+"px",a.style.backgroundColor=t,a.style.borderRadius=n/2+"px","transparent"===t&&(a.style.fill=this.uiStyleSettings.toolboxAccentColor,a.innerHTML='<svg viewBox="0 0 24 24">\n <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" />\n </svg>'),r.appendChild(a),r},e.prototype.setCurrentColor=function(t,e){var i=this;this.currentColor=t,this.colorBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onColorChanged&&this.onColorChanged(t)},e}(Q),et=function(){function t(t,e,i){this._state="new",this._isSelected=!1,this._container=t,this._overlayContainer=e,this.globalSettings=i,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(t.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(t){return!1},Object.defineProperty(t.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),t.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},t.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},t.prototype.pointerDown=function(t,e){},t.prototype.dblClick=function(t,e){},t.prototype.manipulate=function(t){},t.prototype.pointerUp=function(t){this.stateChanged()},t.prototype.dispose=function(){},t.prototype.addMarkerVisualToContainer=function(t){this.container.childNodes.length>0?this.container.insertBefore(t,this.container.childNodes[0]):this.container.appendChild(t)},t.prototype.getState=function(){return{typeName:t.typeName,state:this.state,notes:this.notes}},t.prototype.restoreState=function(t){this._state=t.state,this.notes=t.notes},t.prototype.scale=function(t,e){},t.prototype.colorChanged=function(t){this.onColorChanged&&this.onColorChanged(t),this.stateChanged()},t.prototype.fillColorChanged=function(t){this.onFillColorChanged&&this.onFillColorChanged(t),this.stateChanged()},t.prototype.stateChanged=function(){if(this.onStateChanged&&"creating"!==this.state&&"new"!==this.state){var t=this.getState();void 0!==this.manipulationStartState&&(this.manipulationStartState.state="select"),t.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(t)&&this.onStateChanged(this)}},t.typeName="MarkerBase",t}(),it=function(){function t(){this.findGripByVisual=this.findGripByVisual.bind(this)}return t.prototype.findGripByVisual=function(t){return this.topLeft.ownsTarget(t)?this.topLeft:this.topCenter.ownsTarget(t)?this.topCenter:this.topRight.ownsTarget(t)?this.topRight:this.centerLeft.ownsTarget(t)?this.centerLeft:this.centerRight.ownsTarget(t)?this.centerRight:this.bottomLeft.ownsTarget(t)?this.bottomLeft:this.bottomCenter.ownsTarget(t)?this.bottomCenter:this.bottomRight.ownsTarget(t)?this.bottomRight:void 0},t}(),nt=function(){function t(){this.GRIP_SIZE=10,this.visual=V.createGroup(),this.visual.appendChild(V.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(V.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return t.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},t}(),rt=function(){function t(){}return t.toITransformMatrix=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}},t.toSVGMatrix=function(t,e){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},t}(),at=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.left=0,r.top=0,r.width=0,r.height=0,r.defaultSize={x:50,y:20},r.offsetX=0,r.offsetY=0,r.rotationAngle=0,r.CB_DISTANCE=10,r._suppressMarkerCreateEvent=!1,r.container.transform.baseVal.appendItem(V.createTransform()),r.setupControlBox(),r}return U(e,t),Object.defineProperty(e.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visual",{get:function(){return this._visual},set:function(t){this._visual=t;var e=V.createTransform();this._visual.transform.baseVal.appendItem(e)},enumerable:!1,configurable:!0}),e.prototype.ownsTarget=function(e){return!!t.prototype.ownsTarget.call(this,e)||!!(void 0!==this.controlGrips.findGripByVisual(e)||void 0!==this.rotatorGrip&&this.rotatorGrip.ownsTarget(e))},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"new"===this.state&&(this.left=e.x,this.top=e.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var n=this.unrotatePoint(e);if(this.manipulationStartX=n.x,this.manipulationStartY=n.y,this.offsetX=n.x-this.left,this.offsetY=n.y-this.top,"new"!==this.state)if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(i),void 0!==this.activeGrip)this._state="resize";else if(void 0!==this.rotatorGrip&&this.rotatorGrip.ownsTarget(i)){this.activeGrip=this.rotatorGrip;var r=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=r.x-this.width/2,this.top=r.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var a=this.container.transform.baseVal.getItem(0);a.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(a,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},e.prototype.pointerUp=function(e){var i=this.state;t.prototype.pointerUp.call(this,e),"creating"===this.state&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(e),this._state="select","creating"===i&&this.onMarkerCreated&&!1===this._suppressMarkerCreateEvent&&this.onMarkerCreated(this)},e.prototype.moveVisual=function(t){this.visual.style.transform="translate("+t.x+"px, "+t.y+"px)"},e.prototype.manipulate=function(t){var e=this.unrotatePoint(t);"creating"===this.state?this.resize(t):"move"===this.state?(this.left=this.manipulationStartLeft+(e.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(e.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):"resize"===this.state?this.resize(e):"rotate"===this.state&&this.rotate(t)},e.prototype.resize=function(t){var e=this.manipulationStartLeft,i=this.manipulationStartWidth,n=this.manipulationStartTop,r=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:e=this.manipulationStartLeft+t.x-this.manipulationStartX,i=this.manipulationStartWidth+this.manipulationStartLeft-e;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:i=this.manipulationStartWidth+t.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:n=this.manipulationStartTop+t.y-this.manipulationStartY,r=this.manipulationStartHeight+this.manipulationStartTop-n;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:r=this.manipulationStartHeight+t.y-this.manipulationStartY}i>=0?(this.left=e,this.width=i):(this.left=e+i,this.width=-i),r>=0?(this.top=n,this.height=r):(this.top=n+r,this.height=-r),this.setSize()},e.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},e.prototype.rotate=function(t){if(Math.abs(t.x-this.centerX)>.1){var e=Math.sign(t.x-this.centerX);this.rotationAngle=180*Math.atan((t.y-this.centerY)/(t.x-this.centerX))/Math.PI+90*e,this.applyRotation()}},e.prototype.applyRotation=function(){var t=this.container.transform.baseVal.getItem(0);t.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(t,0)},e.prototype.rotatePoint=function(t){if(0===this.rotationAngle)return t;var e=this.container.getCTM(),i=V.createPoint(t.x,t.y);return{x:(i=i.matrixTransform(e)).x,y:i.y}},e.prototype.unrotatePoint=function(t){if(0===this.rotationAngle)return t;var e=this.container.getCTM();e=e.inverse();var i=V.createPoint(t.x,t.y);return{x:(i=i.matrixTransform(e)).x,y:i.y}},e.prototype.select=function(){t.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},e.prototype.deselect=function(){t.prototype.deselect.call(this),this.controlBox.style.display="none"},e.prototype.setupControlBox=function(){this.controlBox=V.createGroup();var t=V.createTransform();t.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(t),this.container.appendChild(this.controlBox),this.controlRect=V.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),!0!==this.globalSettings.disableRotation&&(this.rotatorGripLine=V.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 it,this.addControlGrips(),this.controlBox.style.display="none"},e.prototype.adjustControlBox=function(){var t=this.controlBox.transform.baseVal.getItem(0);t.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(t,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),void 0!==this.rotatorGripLine&&(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()},e.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(),!0!==this.globalSettings.disableRotation&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},e.prototype.createGrip=function(){var t=new nt;return t.visual.transform.baseVal.appendItem(V.createTransform()),this.controlBox.appendChild(t.visual),t},e.prototype.positionGrips=function(){var t=this.controlGrips.topLeft.GRIP_SIZE,e=-t/2,i=e,n=(this.width+this.CB_DISTANCE)/2-t/2,r=(this.height+this.CB_DISTANCE)/2-t/2,a=this.height+this.CB_DISTANCE-t/2,o=this.width+this.CB_DISTANCE-t/2;this.positionGrip(this.controlGrips.topLeft.visual,e,i),this.positionGrip(this.controlGrips.topCenter.visual,n,i),this.positionGrip(this.controlGrips.topRight.visual,o,i),this.positionGrip(this.controlGrips.centerLeft.visual,e,r),this.positionGrip(this.controlGrips.centerRight.visual,o,r),this.positionGrip(this.controlGrips.bottomLeft.visual,e,a),this.positionGrip(this.controlGrips.bottomCenter.visual,n,a),this.positionGrip(this.controlGrips.bottomRight.visual,o,a),void 0!==this.rotatorGrip&&this.positionGrip(this.rotatorGrip.visual,n,i-3*this.CB_DISTANCE)},e.prototype.positionGrip=function(t,e,i){var n=t.transform.baseVal.getItem(0);n.setTranslate(e,i),t.transform.baseVal.replaceItem(n,0)},e.prototype.hideControlBox=function(){this.controlBox.style.display="none"},e.prototype.showControlBox=function(){this.controlBox.style.display=""},e.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:rt.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:rt.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.left=i.left,this.top=i.top,this.width=i.width,this.height=i.height,this.rotationAngle=i.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(rt.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,i.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(rt.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,i.containerTransformMatrix))},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i);var n=this.rotatePoint({x:this.left,y:this.top}),r=this.unrotatePoint({x:n.x*e,y:n.y*i});this.left=r.x,this.top=r.y,this.width=this.width*e,this.height=this.height*i,this.adjustControlBox()},e}(et),ot=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.fillColor="transparent",r.strokeColor="transparent",r.strokeWidth=0,r.strokeDasharray="",r.opacity=1,r.setStrokeColor=r.setStrokeColor.bind(r),r.setFillColor=r.setFillColor.bind(r),r.setStrokeWidth=r.setStrokeWidth.bind(r),r.setStrokeDasharray=r.setStrokeDasharray.bind(r),r.createVisual=r.createVisual.bind(r),r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual)},e.prototype.createVisual=function(){this.visual=V.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)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.setSize()},e.prototype.setSize=function(){t.prototype.setSize.call(this),V.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},e.prototype.pointerUp=function(e){t.prototype.pointerUp.call(this,e),this.setSize()},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.visual&&V.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&V.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&V.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&V.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},e.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){var i=e;this.fillColor=i.fillColor,this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.opacity=i.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.setSize()},e.title="Rectangle marker",e}(at),st=function(t){function e(e,i,n,r){var a=t.call(this,e,r||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return a.widths=[],a.widthBoxes=[],a.widths=i,a.currentWidth=n,a.setCurrentWidth=a.setCurrentWidth.bind(a),a}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",this.widths.forEach((function(i){var n=document.createElement("div");n.style.display="flex",n.style.flexGrow="2",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="5px",n.style.borderWidth="2px",n.style.borderStyle="solid",n.style.borderColor=i===t.currentWidth?t.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){t.setCurrentWidth(i,n)})),e.appendChild(n);var r=document.createElement("div");r.innerText=i.toString(),r.style.marginRight="5px",n.appendChild(r);var a=document.createElement("div");a.style.minHeight="20px",a.style.flexGrow="2",a.style.display="flex",a.style.alignItems="center";var o=document.createElement("hr");o.style.minWidth="20px",o.style.border="0px",o.style.borderTop=i+"px solid "+t.uiStyleSettings.toolboxColor,o.style.flexGrow="2",a.appendChild(o),n.appendChild(a),t.widthBoxes.push(n)})),e},e.prototype.setCurrentWidth=function(t,e){var i=this;this.currentWidth=t,this.widthBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},e}(Q),lt=function(t){function e(e,i,n,r){var a=t.call(this,e,r||'<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 a.styles=[],a.styleBoxes=[],a.styles=i,a.currentStyle=n,a.setCurrentStyle=a.setCurrentStyle.bind(a),a}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",this.styles.forEach((function(i){var n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="5px",n.style.borderWidth="2px",n.style.borderStyle="solid",n.style.overflow="hidden",n.style.maxWidth=100/t.styles.length-5+"%",n.style.borderColor=i===t.currentStyle?t.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){t.setCurrentStyle(i,n)})),e.appendChild(n);var r=document.createElement("div");r.style.minHeight="20px",r.style.flexGrow="2",r.style.overflow="hidden";var a='<svg width="100" height="20">\n <line x1="0" y1="10" x2="100" y2="10" stroke="'+t.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(""!==i?'stroke-dasharray="'+i+'"':"")+" />\n </svg>";r.innerHTML=a,n.appendChild(r),t.styleBoxes.push(n)})),e},e.prototype.setCurrentStyle=function(t,e){var i=this;this.currentStyle=t,this.styleBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},e}(Q),ct=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.strokeColor=n.defaultColor,r.strokeWidth=n.defaultStrokeWidth,r.strokeDasharray=n.defaultStrokeDasharray,r.strokePanel=new tt("Line color",n.defaultColorSet,n.defaultColor),r.strokePanel.onColorChanged=r.setStrokeColor,r.strokeWidthPanel=new st("Line width",n.defaultStrokeWidths,n.defaultStrokeWidth),r.strokeWidthPanel.onWidthChanged=r.setStrokeWidth,r.strokeStylePanel=new lt("Line style",n.defaultStrokeDasharrays,n.defaultStrokeDasharray),r.strokeStylePanel.onStyleChanged=r.setStrokeDasharray,r}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="FrameMarker",e.title="Frame marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',e}(ot),ut=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},ht=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.x1=0,r.y1=0,r.x2=0,r.y2=0,r.defaultLength=50,r.manipulationStartX=0,r.manipulationStartY=0,r.manipulationStartX1=0,r.manipulationStartY1=0,r.manipulationStartX2=0,r.manipulationStartY2=0,r.setupControlBox(),r}return U(e,t),e.prototype.ownsTarget=function(e){return!!t.prototype.ownsTarget.call(this,e)||!(!this.grip1.ownsTarget(e)&&!this.grip2.ownsTarget(e))},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),this.manipulationStartX=e.x,this.manipulationStartY=e.y,"new"===this.state&&(this.x1=e.x,this.y1=e.y,this.x2=e.x,this.y2=e.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,"new"!==this.state&&(this.select(),this.grip1.ownsTarget(i)?this.activeGrip=this.grip1:this.grip2.ownsTarget(i)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},e.prototype.pointerUp=function(e){var i=this.state;t.prototype.pointerUp.call(this,e),"creating"===this.state&&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(e),this._state="select","creating"===i&&this.onMarkerCreated&&this.onMarkerCreated(this)},e.prototype.adjustVisual=function(){},e.prototype.manipulate=function(t){"creating"===this.state?this.resize(t):"move"===this.state?(this.x1=this.manipulationStartX1+t.x-this.manipulationStartX,this.y1=this.manipulationStartY1+t.y-this.manipulationStartY,this.x2=this.manipulationStartX2+t.x-this.manipulationStartX,this.y2=this.manipulationStartY2+t.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):"resize"===this.state&&this.resize(t)},e.prototype.resize=function(t){switch(this.activeGrip){case this.grip1:this.x1=t.x,this.y1=t.y;break;case this.grip2:case void 0:this.x2=t.x,this.y2=t.y}this.adjustVisual(),this.adjustControlBox()},e.prototype.select=function(){t.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},e.prototype.deselect=function(){t.prototype.deselect.call(this),this.controlBox.style.display="none"},e.prototype.setupControlBox=function(){this.controlBox=V.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},e.prototype.adjustControlBox=function(){this.positionGrips()},e.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},e.prototype.createGrip=function(){var t=new nt;return t.visual.transform.baseVal.appendItem(V.createTransform()),this.controlBox.appendChild(t.visual),t},e.prototype.positionGrips=function(){var t=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-t/2,this.y1-t/2),this.positionGrip(this.grip2.visual,this.x2-t/2,this.y2-t/2)},e.prototype.positionGrip=function(t,e,i){var n=t.transform.baseVal.getItem(0);n.setTranslate(e,i),t.transform.baseVal.replaceItem(n,0)},e.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},t.prototype.getState.call(this))},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.x1=i.x1,this.y1=i.y1,this.x2=i.x2,this.y2=i.y2},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.x1=this.x1*e,this.y1=this.y1*i,this.x2=this.x2*e,this.y2=this.y2*i,this.adjustVisual(),this.adjustControlBox()},e}(et),dt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.strokeColor="transparent",r.strokeWidth=0,r.strokeDasharray="",r.setStrokeColor=r.setStrokeColor.bind(r),r.setStrokeWidth=r.setStrokeWidth.bind(r),r.setStrokeDasharray=r.setStrokeDasharray.bind(r),r.strokeColor=n.defaultColor,r.strokeWidth=n.defaultStrokeWidth,r.strokeDasharray=n.defaultStrokeDasharray,r.strokePanel=new tt("Line color",n.defaultColorSet,n.defaultColor),r.strokePanel.onColorChanged=r.setStrokeColor,r.strokeWidthPanel=new st("Line width",n.defaultStrokeWidths,n.defaultStrokeWidth),r.strokeWidthPanel.onWidthChanged=r.setStrokeWidth,r.strokeStylePanel=new lt("Line style",n.defaultStrokeDasharrays,n.defaultStrokeDasharray),r.strokeStylePanel.onStyleChanged=r.setStrokeDasharray,r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.selectorLine&&e!==this.visibleLine)},e.prototype.createVisual=function(){this.visual=V.createGroup(),this.selectorLine=V.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=V.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)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"new"===this.state&&(this.createVisual(),this.adjustVisual(),this._state="creating")},e.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()),V.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),V.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),V.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.adjustVisual(),this.colorChanged(t)},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.adjustVisual()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.adjustVisual(),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.createVisual(),this.adjustVisual()},e.typeName="LineMarker",e.title="Line marker",e.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',e}(ht),ft=function(t){function e(e,i,n,r){var a=t.call(this,e,r||'<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 a.fonts=[],a.fontBoxes=[],a.fonts=i,a.currentFont=n,a.setCurrentFont=a.setCurrentFont.bind(a),a}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.overflow="hidden",e.style.flexGrow="2",this.fonts.forEach((function(i){var n=document.createElement("div");n.style.display="inline-block",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="5px",n.style.borderWidth="2px",n.style.borderStyle="solid",n.style.overflow="hidden",n.style.maxWidth=100/t.fonts.length-5+"%",n.style.borderColor=i===t.currentFont?t.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){t.setCurrentFont(i,n)})),e.appendChild(n);var r=document.createElement("div");r.style.display="flex",r.style.minHeight="20px",r.style.flexGrow="2",r.style.fontFamily=i,r.style.overflow="hidden";var a=document.createElement("div");a.style.whiteSpace="nowrap",a.style.overflow="hidden",a.style.textOverflow="ellipsis",a.innerHTML="The quick brown fox jumps over the lazy dog",r.appendChild(a),n.appendChild(r),t.fontBoxes.push(n)})),e},e.prototype.setCurrentFont=function(t,e){var i=this;this.currentFont=t,this.fontBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onFontChanged&&this.onFontChanged(this.currentFont)},e}(Q),pt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.color="transparent",r.padding=5,r.DEFAULT_TEXT="your text here",r.text=r.DEFAULT_TEXT,r.isMoved=!1,r.color=n.defaultColor,r.fontFamily=n.defaultFontFamily,r.defaultSize={x:100,y:30},r.setColor=r.setColor.bind(r),r.setFont=r.setFont.bind(r),r.renderText=r.renderText.bind(r),r.sizeText=r.sizeText.bind(r),r.textEditDivClicked=r.textEditDivClicked.bind(r),r.showTextEditor=r.showTextEditor.bind(r),r.setSize=r.setSize.bind(r),r.positionTextEditor=r.positionTextEditor.bind(r),r.colorPanel=new tt("Color",n.defaultColorSet,n.defaultColor),r.colorPanel.onColorChanged=r.setColor,r.fontFamilyPanel=new ft("Font",n.defaultFontFamilies,n.defaultFontFamily),r.fontFamilyPanel.onFontChanged=r.setFont,r}return U(e,t),e.prototype.ownsTarget=function(e){if(t.prototype.ownsTarget.call(this,e)||e===this.visual||e===this.textElement||e===this.bgRectangle)return!0;var i=!1;return this.textElement.childNodes.forEach((function(t){t===e&&(i=!0)})),i},e.prototype.createVisual=function(){this.visual=V.createGroup(),this.bgRectangle=V.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=V.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(V.createTransform()),this.textElement.transform.baseVal.appendItem(V.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),this.isMoved=!1,this.pointerDownPoint=e,this.pointerDownTimestamp=Date.now(),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.renderText=function(){var t=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(e){t.textElement.appendChild(V.createTSpan(""===e.trim()?" ":e.trim(),[["x","0"],["dy","1.2em"]]))})),setTimeout(this.sizeText,10)}},e.prototype.getTextScale=function(){var t=this.textElement.getBBox(),e=1;if(t.width>0&&t.height>0){var i=(1*this.width-this.width*this.padding*2/100)/t.width,n=(1*this.height-this.height*this.padding*2/100)/t.height;e=Math.min(i,n)}return e},e.prototype.getTextPosition=function(t){var e=this.textElement.getBBox(),i=0,n=0;return e.width>0&&e.height>0&&(i=(this.width-e.width*t)/2,n=this.height/2-e.height*t/2),{x:i,y:n}},e.prototype.sizeText=function(){var t=this.textElement.getBBox(),e=this.getTextScale(),i=this.getTextPosition(e);i.y-=t.y*e,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+i.x+"px, "+i.y+"px) scale("+e+", "+e+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(i.x,i.y),this.textElement.transform.baseVal.getItem(1).setScale(e,e))},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e),void 0!==this.pointerDownPoint&&(this.isMoved=Math.abs(e.x-this.pointerDownPoint.x)>5||Math.abs(e.y-this.pointerDownPoint.y)>5)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.isMoved=!0,this.setSize(),this.sizeText()},e.prototype.setSize=function(){t.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(V.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),V.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},e.prototype.pointerUp=function(e){var i=this.state;"creating"===i&&(this._suppressMarkerCreateEvent=!0),t.prototype.pointerUp.call(this,e),this.setSize(),("creating"===i||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},e.prototype.showTextEditor=function(){var t=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(t){t.stopPropagation()})),this.textEditor.addEventListener("input",(function(){for(var e=Number.parseFloat(t.textEditor.style.fontSize);t.textEditor.clientWidth>=Number.parseInt(t.textEditor.style.maxWidth)&&e>.9;)e-=.1,t.textEditor.style.fontSize=Math.max(e,.9)+"em"})),this.textEditor.addEventListener("keyup",(function(t){t.cancelBubble=!0})),this.textEditor.addEventListener("paste",(function(t){if(t.clipboardData){var e=t.clipboardData.getData("text"),i=window.getSelection();if(!i.rangeCount)return!1;i.deleteFromDocument(),i.getRangeAt(0).insertNode(document.createTextNode(e)),t.preventDefault()}})),this.textEditDiv.addEventListener("pointerup",(function(){t.textEditDivClicked(t.textEditor.innerText)})),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},e.prototype.positionTextEditor=function(){if("edit"===this.state)if(void 0===this.textEditor)this.showTextEditor();else{this.textElement.style.display="";var t=this.getTextScale(),e=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),i=this.textElement.getBBox(),n={x:i.width*t,y:i.height*t};e.x-=n.x/2,e.y-=n.y/2,this.textEditor.style.top=e.y+"px",this.textEditor.style.left=e.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-e.x+"px",this.textEditor.style.fontSize=Math.max(16*t,12)+"px",this.textElement.style.display="none"}},e.prototype.textEditDivClicked=function(t){this.text=t.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},e.prototype.select=function(){t.prototype.select.call(this),"edit"===this.state&&this.textEditDivClicked(this.textEditor.innerText)},e.prototype.deselect=function(){"edit"===this.state&&this.textEditDivClicked(this.textEditor.innerText),t.prototype.deselect.call(this)},e.prototype.dblClick=function(e,i){t.prototype.dblClick.call(this,e,i),this.showTextEditor()},e.prototype.setColor=function(t){this.textElement&&V.setAttributes(this.textElement,[["fill",t]]),this.color=t,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(t)},e.prototype.setFont=function(t){this.textElement&&V.setAttributes(this.textElement,[["font-family",t]]),this.fontFamily=t,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},e.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},e.prototype.showVisual=function(){"edit"===this.state&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.color=i.color,this.fontFamily=i.fontFamily,this.padding=i.padding,this.text=i.text,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.setSize(),this.sizeText(),this.positionTextEditor()},e.typeName="TextMarker",e.title="Text marker",e.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>',e}(at),mt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.color="transparent",r.lineWidth=3,r.drawing=!1,r.pixelRatio=1,r.color=n.defaultColor,r.lineWidth=n.defaultStrokeWidth,r.pixelRatio=n.freehandPixelRatio,r.setColor=r.setColor.bind(r),r.addCanvas=r.addCanvas.bind(r),r.finishCreation=r.finishCreation.bind(r),r.setLineWidth=r.setLineWidth.bind(r),r.colorPanel=new tt("Color",n.defaultColorSet,n.defaultColor),r.colorPanel.onColorChanged=r.setColor,r.lineWidthPanel=new st("Line width",n.defaultStrokeWidths,n.defaultStrokeWidth),r.lineWidthPanel.onWidthChanged=r.setLineWidth,r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.drawingImage)},e.prototype.createVisual=function(){this.visual=V.createGroup(),this.drawingImage=V.createImage(),this.visual.appendChild(this.drawingImage);var t=V.createTransform();this.visual.transform.baseVal.appendItem(t),this.addMarkerVisualToContainer(this.visual)},e.prototype.pointerDown=function(e,i){"new"===this.state&&(this.addCanvas(),this.createVisual(),this._state="creating"),"creating"===this.state?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(e.x,e.y),this.drawing=!0):t.prototype.pointerDown.call(this,e,i)},e.prototype.manipulate=function(e){"creating"===this.state?this.drawing&&(this.canvasContext.lineTo(e.x,e.y),this.canvasContext.stroke()):t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),V.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),V.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},e.prototype.pointerUp=function(e){"creating"===this._state?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):t.prototype.pointerUp.call(this,e)},e.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)},e.prototype.select=function(){"creating"===this.state&&this.finishCreation(),t.prototype.select.call(this)},e.prototype.deselect=function(){"creating"===this.state&&this.finishCreation(),t.prototype.deselect.call(this)},e.prototype.finishCreation=function(){for(var t=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),e=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],i=e[0],n=e[1],r=e[2],a=e[3],o=!1,s=0;s<this.canvasElement.height;s++)for(var l=0;l<this.canvasElement.width;l++)t.data[s*this.canvasElement.width*4+4*l+3]>0&&(o=!0,s<n&&(n=s),l<i&&(i=l),s>a&&(a=s),l>r&&(r=l));if(o){this.left=i/this.pixelRatio,this.top=n/this.pixelRatio,this.width=(r-i)/this.pixelRatio,this.height=(a-n)/this.pixelRatio;var c=document.createElement("canvas");c.width=r-i,c.height=a-n,c.getContext("2d").putImageData(this.canvasContext.getImageData(i,n,r-i,a-n),0,0),this.drawingImgUrl=c.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},e.prototype.setDrawingImage=function(){V.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),V.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},e.prototype.setColor=function(t){this.color=t,this.colorChanged(t)},e.prototype.setLineWidth=function(t){this.lineWidth=t},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return"new"===this.state||"creating"===this.state?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({drawingImgUrl:this.drawingImgUrl},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){this.createVisual(),t.prototype.restoreState.call(this,e),this.drawingImgUrl=e.drawingImgUrl,this.setDrawingImage()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.setDrawingImage()},e.typeName="FreehandMarker",e.title="Freehand marker",e.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>',e}(at),gt=function(t){function e(e,i,n){var r=t.call(this,e,n||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return r.typeBoxes=[],r.currentType=i,r.setCurrentType=r.setCurrentType.bind(r),r}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2";for(var i=function(i){var r="both";switch(i){case 0:r="both";break;case 1:r="start";break;case 2:r="end";break;case 3:r="none"}var a=document.createElement("div");if(a.style.display="flex",a.style.flexGrow="2",a.style.alignItems="center",a.style.justifyContent="space-between",a.style.padding="5px",a.style.borderWidth="2px",a.style.borderStyle="solid",a.style.borderColor=r===n.currentType?n.uiStyleSettings.toolboxAccentColor:"transparent",a.addEventListener("click",(function(){t.setCurrentType(r,a)})),e.appendChild(a),"both"===r||"start"===r){var o=document.createElement("div");o.style.display="flex",o.style.alignItems="center",o.style.minHeight="20px",o.innerHTML='<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">\n <polygon points="0,5 10,0 10,10" fill="'+(void 0!==n.uiStyleSettings?n.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',o.style.marginLeft="5px",a.appendChild(o)}var s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.minHeight="20px",s.style.flexGrow="2";var l=document.createElement("hr");if(l.style.minWidth="20px",l.style.border="0px",l.style.borderTop="3px solid "+(void 0!==n.uiStyleSettings?n.uiStyleSettings.toolboxColor:"#eeeeee"),l.style.flexGrow="2",s.appendChild(l),a.appendChild(s),"both"===r||"end"===r){var c=document.createElement("div");c.style.display="flex",c.style.alignItems="center",c.style.minHeight="20px",c.innerHTML='<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">\n <polygon points="0,0 10,5 0,10" fill="'+(void 0!==n.uiStyleSettings?n.uiStyleSettings.toolboxColor:"#eeeeee")+'" />\n </svg>',c.style.marginRight="5px",a.appendChild(c)}n.typeBoxes.push(a)},n=this,r=0;r<4;r++)i(r);return e},e.prototype.setCurrentType=function(t,e){var i=this;this.currentType=t,this.typeBoxes.forEach((function(t){t.style.borderColor=t===e?void 0!==i.uiStyleSettings?i.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"})),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},e}(Q),vt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.arrowType="end",r.arrowBaseHeight=10,r.arrowBaseWidth=10,r.getArrowPoints=r.getArrowPoints.bind(r),r.setArrowType=r.setArrowType.bind(r),r.arrowTypePanel=new gt("Arrow type","end"),r.arrowTypePanel.onArrowTypeChanged=r.setArrowType,r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.arrow1&&e!==this.arrow2)},e.prototype.getArrowPoints=function(t,e){var i=this.arrowBaseWidth+2*this.strokeWidth,n=this.arrowBaseHeight+2*this.strokeWidth;return t-i/2+","+(e+n/2)+" "+t+","+(e-n/2)+" "+(t+i/2)+","+(e+n/2)},e.prototype.createTips=function(){this.arrow1=V.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(V.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=V.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(V.createTransform()),this.visual.appendChild(this.arrow2)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"creating"===this.state&&this.createTips()},e.prototype.adjustVisual=function(){if(t.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display="both"===this.arrowType||"start"===this.arrowType?"":"none",this.arrow2.style.display="both"===this.arrowType||"end"===this.arrowType?"":"none",V.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),V.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var e=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),i=this.arrow1.transform.baseVal.getItem(0);i.setRotate(e,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(i,0);var n=this.arrow2.transform.baseVal.getItem(0);n.setRotate(e+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(n,0)}},e.prototype.setArrowType=function(t){this.arrowType=t,this.adjustVisual(),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({arrowType:this.arrowType},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.arrowType=i.arrowType,this.createTips(),this.adjustVisual()},e.typeName="ArrowMarker",e.title="Arrow marker",e.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',e}(dt),yt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.fillColor=n.defaultFillColor,r.strokeWidth=0,r.fillPanel=new tt("Color",n.defaultColorSet,n.defaultFillColor),r.fillPanel.onColorChanged=r.setFillColor,r}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="CoverMarker",e.title="Cover marker",e.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',e}(ot),bt=function(t){function e(e,i,n,r){var a=t.call(this,e,r||'<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 a.opacities=[],a.opacityBoxes=[],a.opacities=i,a.currentOpacity=n,a.setCurrentOpacity=a.setCurrentOpacity.bind(a),a}return U(e,t),e.prototype.getUi=function(){var t=this,e=document.createElement("div");return e.style.display="flex",e.style.overflow="hidden",e.style.flexGrow="2",e.style.justifyContent="space-between",this.opacities.forEach((function(i){var n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.padding="5px",n.style.borderWidth="2px",n.style.borderStyle="solid",n.style.borderColor=i===t.currentOpacity?t.uiStyleSettings.toolboxAccentColor:"transparent",n.addEventListener("click",(function(){t.setCurrentOpacity(i,n)})),e.appendChild(n);var r=document.createElement("div");r.innerText=100*i+"%",n.appendChild(r),t.opacityBoxes.push(n)})),e},e.prototype.setCurrentOpacity=function(t,e){var i=this;this.currentOpacity=t,this.opacityBoxes.forEach((function(t){t.style.borderColor=t===e?i.uiStyleSettings.toolboxAccentColor:"transparent"})),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},e}(Q),xt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.setOpacity=r.setOpacity.bind(r),r.fillColor=n.defaultHighlightColor,r.strokeWidth=0,r.opacity=n.defaultHighlightOpacity,r.fillPanel=new tt("Color",n.defaultColorSet,r.fillColor),r.fillPanel.onColorChanged=r.setFillColor,r.opacityPanel=new bt("Opacity",n.defaultOpacitySteps,r.opacity),r.opacityPanel.onOpacityChanged=r.setOpacity,r}return U(e,t),e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&V.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="HighlightMarker",e.title="Highlight marker",e.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>',e}(yt),St='<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>',Ct=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.bgColor="transparent",r.tipPosition={x:0,y:0},r.tipBase1Position={x:0,y:0},r.tipBase2Position={x:0,y:0},r.tipMoving=!1,r.color=n.defaultStrokeColor,r.bgColor=n.defaultFillColor,r.fontFamily=n.defaultFontFamily,r.defaultSize={x:100,y:30},r.setBgColor=r.setBgColor.bind(r),r.getTipPoints=r.getTipPoints.bind(r),r.positionTip=r.positionTip.bind(r),r.setTipPoints=r.setTipPoints.bind(r),r.colorPanel=new tt("Text color",n.defaultColorSet,r.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>'),r.colorPanel.onColorChanged=r.setColor,r.bgColorPanel=new tt("Fill color",n.defaultColorSet,r.bgColor,St),r.bgColorPanel.onColorChanged=r.setBgColor,r.fontFamilyPanel=new ft("Font",n.defaultFontFamilies,n.defaultFontFamily),r.fontFamilyPanel.onFontChanged=r.setFont,r.tipGrip=new nt,r.tipGrip.visual.transform.baseVal.appendItem(V.createTransform()),r.controlBox.appendChild(r.tipGrip.visual),r}return U(e,t),e.prototype.ownsTarget=function(e){return t.prototype.ownsTarget.call(this,e)||this.tipGrip.ownsTarget(e)||this.tip===e},e.prototype.createTip=function(){V.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=V.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},e.prototype.pointerDown=function(e,i){"new"===this.state&&t.prototype.pointerDown.call(this,e,i),"creating"===this.state?this.createTip():this.tipGrip.ownsTarget(i)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):t.prototype.pointerDown.call(this,e,i)},e.prototype.pointerUp=function(e){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,t.prototype.pointerUp.call(this,e);else{var i="creating"===this.state;t.prototype.pointerUp.call(this,e),this.setTipPoints(i),this.positionTip()}},e.prototype.manipulate=function(e){if(this.tipMoving){var i=this.unrotatePoint(e);this.tipPosition={x:i.x-this.manipulationStartLeft,y:i.y-this.manipulationStartTop},this.positionTip()}else t.prototype.manipulate.call(this,e)},e.prototype.setBgColor=function(t){this.bgRectangle&&this.tip&&(V.setAttributes(this.bgRectangle,[["fill",t]]),V.setAttributes(this.tip,[["fill",t]])),this.bgColor=t,this.fillColorChanged(t)},e.prototype.getTipPoints=function(){return this.setTipPoints("creating"===this.state),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},e.prototype.setTipPoints=function(t){void 0===t&&(t=!1);var e=Math.min(this.height/2,15),i=this.height/5;t&&(this.tipPosition={x:e+i/2,y:this.height+20});var n=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?n<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:0},this.tipBase2Position={x:e+i,y:0}):(this.tipBase1Position={x:0,y:e},this.tipBase2Position={x:0,y:e+i}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?n<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-i,y:0},this.tipBase2Position={x:this.width-e,y:0}):(this.tipBase1Position={x:this.width,y:e},this.tipBase2Position={x:this.width,y:e+i}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?n<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-e-i,y:this.height},this.tipBase2Position={x:this.width-e,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-e-i},this.tipBase2Position={x:this.width,y:this.height-e}):n<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(i=this.width/5,e=Math.min(this.width/2,15),this.tipBase1Position={x:e,y:this.height},this.tipBase2Position={x:e+i,y:this.height}):(this.tipBase1Position={x:0,y:this.height-e},this.tipBase2Position={x:0,y:this.height-e-i})},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.positionTip()},e.prototype.positionTip=function(){V.setAttributes(this.tip,[["points",this.getTipPoints()]]);var t=this.tipGrip.visual.transform.baseVal.getItem(0);t.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(t,0)},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),e.prototype.select=function(){this.positionTip(),t.prototype.select.call(this)},e.prototype.getState=function(){var i=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.bgColor=i.bgColor,this.tipPosition=i.tipPosition,t.prototype.restoreState.call(this,e),this.createTip(),this.setTipPoints()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.tipPosition={x:this.tipPosition.x*e,y:this.tipPosition.y*i},this.positionTip()},e.typeName="CalloutMarker",e.title="Callout marker",e.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>',e}(pt),kt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.fillColor="transparent",r.strokeColor="transparent",r.strokeWidth=0,r.strokeDasharray="",r.opacity=1,r.strokeColor=n.defaultColor,r.strokeWidth=n.defaultStrokeWidth,r.strokeDasharray=n.defaultStrokeDasharray,r.fillColor=n.defaultFillColor,r.setStrokeColor=r.setStrokeColor.bind(r),r.setFillColor=r.setFillColor.bind(r),r.setStrokeWidth=r.setStrokeWidth.bind(r),r.setStrokeDasharray=r.setStrokeDasharray.bind(r),r.setOpacity=r.setOpacity.bind(r),r.createVisual=r.createVisual.bind(r),r.strokePanel=new tt("Line color",z(n.defaultColorSet,["transparent"]),n.defaultColor),r.strokePanel.onColorChanged=r.setStrokeColor,r.fillPanel=new tt("Fill color",z(n.defaultColorSet,["transparent"]),r.fillColor,St),r.fillPanel.onColorChanged=r.setFillColor,r.strokeWidthPanel=new st("Line width",n.defaultStrokeWidths,n.defaultStrokeWidth),r.strokeWidthPanel.onWidthChanged=r.setStrokeWidth,r.strokeStylePanel=new lt("Line style",n.defaultStrokeDasharrays,n.defaultStrokeDasharray),r.strokeStylePanel.onStyleChanged=r.setStrokeDasharray,r.opacityPanel=new bt("Opacity",n.defaultOpacitySteps,r.opacity),r.opacityPanel.onOpacityChanged=r.setOpacity,r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual)},e.prototype.createVisual=function(){this.visual=V.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)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"new"===this.state&&(this.createVisual(),this.moveVisual(e),this._state="creating")},e.prototype.manipulate=function(e){t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){t.prototype.resize.call(this,e),this.setSize()},e.prototype.setSize=function(){t.prototype.setSize.call(this),V.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},e.prototype.pointerUp=function(e){t.prototype.pointerUp.call(this,e),this.setSize()},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.visual&&V.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(t),this.stateChanged()},e.prototype.setFillColor=function(t){this.fillColor=t,this.visual&&V.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(t),this.stateChanged()},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.visual&&V.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.visual&&V.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},e.prototype.setOpacity=function(t){this.opacity=t,this.visual&&V.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){var i=e;this.fillColor=i.fillColor,this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.opacity=i.opacity,this.createVisual(),t.prototype.restoreState.call(this,e),this.setSize()},e.prototype.scale=function(e,i){t.prototype.scale.call(this,e,i),this.setSize()},e.typeName="EllipseMarker",e.title="Ellipse marker",e.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>',e}(at),Et=function(t){function e(e,i,n){return t.call(this,e,i,n)||this}return U(e,t),Object.defineProperty(e.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.tip1&&e!==this.tip2)},e.prototype.createTips=function(){this.tip1=V.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(V.createTransform()),this.visual.appendChild(this.tip1),this.tip2=V.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(V.createTransform()),this.visual.appendChild(this.tip2)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),"creating"===this.state&&this.createTips()},e.prototype.adjustVisual=function(){if(t.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(V.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()]]),V.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 e=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),i=this.tip1.transform.baseVal.getItem(0);i.setRotate(e,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(i,0);var n=this.tip2.transform.baseVal.getItem(0);n.setRotate(e+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(n,0)}},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e),this.createTips(),this.adjustVisual()},e.typeName="MeasurementMarker",e.title="Measurement marker",e.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>',e}(dt),wt=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.strokePanel.colors=n.defaultColorSet,r.fillColor="transparent",r}return U(e,t),Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=t.prototype.getState.call(this);return i.typeName=e.typeName,i},e.typeName="EllipseFrameMarker",e.title="Ellipse frame marker",e.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>',e}(kt),Tt=function(){function t(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(t.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),t.prototype.addUndoStep=function(t){0!==this.undoStack.length&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(t)||(this.undoStack.push(t),JSON.stringify(this.lastRedoStep)!==JSON.stringify(t)&&this.redoStack.splice(0,this.redoStack.length))},t.prototype.replaceLastUndoStep=function(t){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=t)},t.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},t.prototype.undo=function(){if(this.undoStack.length>1){var t=this.undoStack.pop();return void 0!==t&&this.redoStack.push(t),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},t.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},t}(),Ot=function(t){function e(e,i,n){var r=t.call(this,e,i,n)||this;return r.strokeColor="transparent",r.strokeWidth=0,r.strokeDasharray="",r.curveX=0,r.curveY=0,r.manipulationStartCurveX=0,r.manipulationStartCurveY=0,r.setStrokeColor=r.setStrokeColor.bind(r),r.setStrokeWidth=r.setStrokeWidth.bind(r),r.setStrokeDasharray=r.setStrokeDasharray.bind(r),r.positionGrips=r.positionGrips.bind(r),r.addControlGrips=r.addControlGrips.bind(r),r.adjustVisual=r.adjustVisual.bind(r),r.setupControlBox=r.setupControlBox.bind(r),r.resize=r.resize.bind(r),r.strokeColor=n.defaultColor,r.strokeWidth=n.defaultStrokeWidth,r.strokeDasharray=n.defaultStrokeDasharray,r.strokePanel=new tt("Line color",n.defaultColorSet,n.defaultColor),r.strokePanel.onColorChanged=r.setStrokeColor,r.strokeWidthPanel=new st("Line width",n.defaultStrokeWidths,n.defaultStrokeWidth),r.strokeWidthPanel.onWidthChanged=r.setStrokeWidth,r.strokeStylePanel=new lt("Line style",n.defaultStrokeDasharrays,n.defaultStrokeDasharray),r.strokeStylePanel.onStyleChanged=r.setStrokeDasharray,r}return U(e,t),e.prototype.ownsTarget=function(e){return!(!t.prototype.ownsTarget.call(this,e)&&e!==this.visual&&e!==this.selectorCurve&&e!==this.visibleCurve&&!this.curveGrip.ownsTarget(e))},e.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},e.prototype.createVisual=function(){this.visual=V.createGroup(),this.selectorCurve=V.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=V.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)},e.prototype.pointerDown=function(e,i){t.prototype.pointerDown.call(this,e,i),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,"new"===this.state&&(this.curveX=e.x,this.curveY=e.y),"new"===this.state?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(i)&&(this.activeGrip=this.curveGrip,this._state="resize")},e.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),V.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),V.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),V.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},e.prototype.setupControlBox=function(){t.prototype.setupControlBox.call(this),this.curveControlLine1=V.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=V.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)},e.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,t.prototype.addControlGrips.call(this)},e.prototype.positionGrips=function(){t.prototype.positionGrips.call(this);var e=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-e/2,this.curveY-e/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()))},e.prototype.manipulate=function(e){"move"===this.state&&(this.curveX=this.manipulationStartCurveX+e.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+e.y-this.manipulationStartY),t.prototype.manipulate.call(this,e)},e.prototype.resize=function(e){this.activeGrip===this.curveGrip&&(this.curveX=e.x,this.curveY=e.y),t.prototype.resize.call(this,e),"creating"===this.state&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},e.prototype.setStrokeColor=function(t){this.strokeColor=t,this.adjustVisual(),this.colorChanged(t)},e.prototype.setStrokeWidth=function(t){this.strokeWidth=t,this.adjustVisual()},e.prototype.setStrokeDasharray=function(t){this.strokeDasharray=t,this.adjustVisual()},e.prototype.scale=function(e,i){this.curveX=this.curveX*e,this.curveY=this.curveY*i,t.prototype.scale.call(this,e,i)},Object.defineProperty(e.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),e.prototype.getState=function(){var i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},t.prototype.getState.call(this));return i.typeName=e.typeName,i},e.prototype.restoreState=function(e){t.prototype.restoreState.call(this,e);var i=e;this.strokeColor=i.strokeColor,this.strokeWidth=i.strokeWidth,this.strokeDasharray=i.strokeDasharray,this.curveX=i.curveX,this.curveY=i.curveY,this.createVisual(),this.adjustVisual()},e.typeName="CurveMarker",e.title="Curve marker",e.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>',e}(ht),Lt=function(){function t(t,e){void 0===e&&(e=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=t,this.cancelable=e}return Object.defineProperty(t.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this._defaultPrevented=!0},t}(),At=function(t){function e(e,i,n){var r=t.call(this,e,!1)||this;return r.dataUrl=i,r.state=n,r}return U(e,t),e}(Lt),Dt=function(t){function e(e,i,n){void 0===n&&(n=!1);var r=t.call(this,e,n)||this;return r.marker=i,r}return U(e,t),e}(Lt),_t=function(){function t(){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 t.prototype.addEventListener=function(t,e){this[t].push(e)},t.prototype.removeEventListener=function(t,e){var i=this[t].indexOf(e);i>-1&&this[t].splice(i,1)},t}(),Rt=function(){function t(e){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new ut,this._isOpen=!1,this.undoRedoManager=new Tt,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 _t,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=t.instanceCounter++,this.styles=new Y(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=e,this.targetRoot=document.body,this.width=e.clientWidth,this.height=e.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(t.prototype,"ALL_MARKER_TYPES",{get:function(){return[ct,mt,vt,pt,wt,kt,xt,Ct,Et,yt,dt,Ot]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[ct,mt,vt,pt,kt,xt,Ct]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BASIC_MARKER_TYPES",{get:function(){return[ct,mt,vt,pt,xt]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(t){var e=this;this._availableMarkerTypes.splice(0),t.forEach((function(t){if("string"==typeof t){var i=e.ALL_MARKER_TYPES.find((function(e){return e.typeName===t}));void 0!==i&&e._availableMarkerTypes.push(i)}else e._availableMarkerTypes.push(t)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(t){this._zoomLevel=t,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(t.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),t.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),"popup"===this.settings.displayMode&&this.onPopupTargetResize(),W.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},t.prototype.show=function(){var t=this;void 0===this.styles.styleSheetRoot&&void 0!==q.styleSheetRoot&&(this.styles.styleSheetRoot=q.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach((function(e){return e(new Lt(t))}))},t.prototype.render=function(){return H(this,void 0,void 0,(function(){var t;return G(this,(function(e){switch(e.label){case 0:return this.setCurrentMarker(),(t=new K).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.markersOnly=this.renderMarkersOnly,t.width=this.renderWidth,t.height=this.renderHeight,[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return e.sent(),[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,e.sent()]}}))}))},t.prototype.close=function(t){var e=this;if(void 0===t&&(t=!1),this.isOpen){var i=!1;t||this.eventListeners.beforeclose.forEach((function(t){var n=new Lt(e,!0);t(n),n.defaultPrevented&&(i=!0)})),i||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),"popup"===this.settings.displayMode&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach((function(t){return t(new Lt(e))})),this.detachEvents(),this._isOpen=!1)}},t.prototype.addMarkersToToolbar=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];(t=this._availableMarkerTypes).push.apply(t,e)},t.prototype.addRenderEventListener=function(t){this.addEventListener("render",(function(e){t(e.dataUrl,e.state)}))},t.prototype.removeRenderEventListener=function(t){},t.prototype.addCloseEventListener=function(t){this.addEventListener("close",(function(){t()}))},t.prototype.removeCloseEventListener=function(t){},t.prototype.setupResizeObserver=function(){var t=this;"inline"===this.settings.displayMode?window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){t.resize(t.target.clientWidth,t.target.clientHeight)})),this.targetObserver.observe(this.target)):"popup"===this.settings.displayMode&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){return t.onPopupTargetResize()})),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},t.prototype.onPopupTargetResize=function(){var t=1*this.target.clientWidth/this.target.clientHeight,e=this.editorCanvas.clientWidth/t>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*t:this.editorCanvas.clientWidth,i=e<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/t;this.resize(e,i)},t.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},t.prototype.resize=function(t,e){this._isResizing=!0;var i=t/this.imageWidth,n=e/this.imageHeight;this.imageWidth=Math.round(t),this.imageHeight=Math.round(e),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","popup"!==this.settings.displayMode?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),void 0!==this.toolbar&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(i,n),this._isResizing=!1},t.prototype.scaleMarkers=function(t,e){var i,n=this;this._currentMarker&&this._currentMarker instanceof pt?this._currentMarker.scale(t,e):(i=this._currentMarker,this.setCurrentMarker()),this.markers.forEach((function(i){i!==n._currentMarker&&i.scale(t,e)})),void 0!==i&&this.setCurrentMarker(i)},t.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"},t.prototype.setTopLeft=function(){var t=this.editingTarget.getBoundingClientRect(),e=this.editorCanvas.getBoundingClientRect();this.left=t.left-e.left,this.top=t.top-e.top},t.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)},t.prototype.addDefs=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];this.defs=V.createDefs(),this.addDefsToImage(),(t=this.defs).append.apply(t,e)},t.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},t.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)},t.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},t.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},t.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)},t.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},t.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)},t.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 t=document.createElement("a");t.href="https://markerjs.com/",t.target="_blank",t.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>',t.title="Powered by marker.js",t.style.display="grid",t.style.alignItems="center",t.style.justifyItems="center",t.style.padding="3px",t.style.width="20px",t.style.height="20px",this.logoUI.appendChild(t),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},t.prototype.positionLogo=function(){this.logoUI&&("right"!==this.uiStyleSettings.logoPosition?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")},t.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"},t.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},t.prototype.showUI=function(){switch("popup"===this.settings.displayMode&&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 t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=void 0!==this.uiStyleSettings.zIndex?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=void 0!==this.uiStyleSettings.zIndex?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="popup"===this.settings.displayMode?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new Z(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","popup"===this.settings.displayMode&&(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","popup"===this.settings.displayMode&&(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 J(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},t.prototype.closeUI=function(){"popup"===this.settings.displayMode&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},t.prototype.removeMarker=function(t){this.markerImage.removeChild(t.container),this.markers.indexOf(t)>-1&&this.markers.splice(this.markers.indexOf(t),1),t.dispose()},t.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),void 0!==this._currentMarker&&("new"!==this._currentMarker.state?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},t.prototype.toolbarButtonClicked=function(t,e){if("marker"===t&&void 0!==e)this.createNewMarker(e);else if("action"===t)switch(e){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":void 0===this.notesArea?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},t.prototype.deleteSelectedMarker=function(){var t=this;if(void 0!==this._currentMarker){var e=!1;if(this.eventListeners.markerbeforedelete.forEach((function(i){var n=new Dt(t,t._currentMarker,!0);i(n),n.defaultPrevented&&(e=!0)})),!e){var i=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach((function(e){return e(new Dt(t,i))}))}}},t.prototype.clear=function(){var t=this,e=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach((function(i){var n=new Dt(t,void 0,!0);i(n),n.defaultPrevented&&(e=!0)})),!e)){this.setCurrentMarker();for(var i=function(e){var i=n.markers[e];n.setCurrentMarker(n.markers[e]),n._currentMarker.dispose(),n.markerImage.removeChild(n._currentMarker.container),n.markers.splice(n.markers.indexOf(n._currentMarker),1),n.eventListeners.markerdelete.forEach((function(e){return e(new Dt(t,i))}))},n=this,r=this.markers.length-1;r>=0;r--)i(r);this.addUndoStep()}},Object.defineProperty(t.prototype,"isNotesAreaOpen",{get:function(){return void 0!==this.notesArea},enumerable:!1,configurable:!0}),t.prototype.showNotesEditor=function(){var t;void 0!==this._currentMarker&&(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=null!==(t=this._currentMarker.notes)&&void 0!==t?t:"",this.overlayContainer.appendChild(this.notesArea))},t.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(void 0!==this._currentMarker&&(this._currentMarker.notes=""!==this.notesArea.value.trim()?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},t.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},t.prototype.addUndoStep=function(){var t=this;if(void 0===this._currentMarker||"edit"!==this._currentMarker.state){var e=this.getState(),i=this.undoRedoManager.getLastUndoStep();if(!i||i.width===e.width&&i.height===e.height){var n=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(e),n<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach((function(e){return e(new Lt(t))}))}else this.undoRedoManager.replaceLastUndoStep(e),this.eventListeners.statechange.forEach((function(e){return e(new Lt(t))}))}},t.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},t.prototype.undoStep=function(){var t=this,e=this.undoRedoManager.undo();void 0!==e&&(this.restoreState(e),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach((function(e){return e(new Lt(t))})))},t.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},t.prototype.redoStep=function(){var t=this,e=this.undoRedoManager.redo();void 0!==e&&(this.restoreState(e),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach((function(e){return e(new Lt(t))})))},t.prototype.stepZoom=function(){var t=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=t<this.zoomSteps.length-1?this.zoomSteps[t+1]:this.zoomSteps[0]},t.prototype.panTo=function(t){this.contentDiv.scrollBy({left:this.prevPanPoint.x-t.x,top:this.prevPanPoint.y-t.y}),this.prevPanPoint=t},t.prototype.startRenderAndClose=function(){return H(this,void 0,void 0,(function(){var t,e,i=this;return G(this,(function(n){switch(n.label){case 0:return[4,this.render()];case 1:return t=n.sent(),e=this.getState(),this.eventListeners.render.forEach((function(n){return n(new At(i,t,e))})),this.close(!0),[2]}}))}))},t.prototype.getState=function(t){!0===t&&this.setCurrentMarker();var e={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach((function(t){return e.markers.push(t.getState())})),e},t.prototype.restoreState=function(t){var e=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);t.markers.forEach((function(t){var i=e._availableMarkerTypes.find((function(e){return e.typeName===t.typeName}));if(void 0!==i){var n=e.addNewMarker(i);n.restoreState(t),e.markers.push(n)}})),t.width&&t.height&&(t.width!==this.imageWidth||t.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/t.width,this.imageHeight/t.height),this.eventListeners.restorestate.forEach((function(t){return t(new Lt(e))}))},t.prototype.addNewMarker=function(t){var e=V.createGroup();return this.markerImage.appendChild(e),new t(e,this.overlayContainer,this.settings)},t.prototype.createNewMarker=function(t){var e,i=this;(e="string"==typeof t?this._availableMarkerTypes.find((function(e){return e.typeName===t})):t)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(e),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(e.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach((function(t){return t(new Dt(i,i._currentMarker))})))},t.prototype.markerCreated=function(t){var e=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(t),this.setCurrentMarker(t),t instanceof mt&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(mt):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach((function(t){return t(new Dt(e,e._currentMarker))}))},t.prototype.colorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=t,this.settings.defaultStrokeColor=t)},t.prototype.fillColorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=t)},t.prototype.markerStateChanged=function(t){var e=this;this.eventListeners.markerchange.forEach((function(i){return i(new Dt(e,t))}))},t.prototype.setCurrentMarker=function(t){var e=this;this._currentMarker!==t&&void 0!==this._currentMarker&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach((function(t){return t(new Dt(e,e._currentMarker))}))),this._currentMarker=t,void 0===this._currentMarker||this._currentMarker.isSelected||("new"!==this._currentMarker.state&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach((function(t){return t(new Dt(e,e._currentMarker))})))},t.prototype.onPointerDown=function(t){if(this._isFocused||this.focus(),this.touchPoints++,1===this.touchPoints||"touch"!==t.pointerType)if(void 0===this._currentMarker||"new"!==this._currentMarker.state&&"creating"!==this._currentMarker.state){if("select"===this.mode){var e=this.markers.find((function(e){return e.ownsTarget(t.target)}));void 0!==e?(this.setCurrentMarker(e),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:t.clientX,y:t.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY))},t.prototype.onDblClick=function(t){if(this._isFocused||this.focus(),"select"===this.mode){var e=this.markers.find((function(e){return e.ownsTarget(t.target)}));void 0!==e&&e!==this._currentMarker&&this.setCurrentMarker(e),void 0!==this._currentMarker?this._currentMarker.dblClick(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target):this.setCurrentMarker()}},t.prototype.onPointerMove=function(t){1!==this.touchPoints&&"touch"===t.pointerType||(void 0!==this._currentMarker||this.isDragging)&&(void 0!==this._currentMarker&&"edit"===this._currentMarker.state||t.preventDefault(),void 0!==this._currentMarker?this._currentMarker.manipulate(this.clientToLocalCoordinates(t.clientX,t.clientY)):this.zoomLevel>1&&this.panTo({x:t.clientX,y:t.clientY}))},t.prototype.onPointerUp=function(t){this.touchPoints>0&&this.touchPoints--,0===this.touchPoints&&this.isDragging&&void 0!==this._currentMarker&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(t.clientX,t.clientY)),this.isDragging=!1,this.addUndoStep()},t.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},t.prototype.onKeyUp=function(t){void 0===this._currentMarker||void 0!==this.notesArea||"Delete"!==t.key&&"Backspace"!==t.key||this.deleteSelectedMarker()},t.prototype.clientToLocalCoordinates=function(t,e){var i=this.markerImage.getBoundingClientRect();return{x:(t-i.left)/this.zoomLevel,y:(e-i.top)/this.zoomLevel}},t.prototype.onWindowResize=function(){this.positionUI()},t.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var t=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=t+"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()},t.prototype.addLicenseKey=function(t){W.addKey(t)},t.prototype.addEventListener=function(t,e){this.eventListeners.addEventListener(t,e)},t.prototype.removeEventListener=function(t,e){this.eventListeners.removeEventListener(t,e)},t.prototype.renderState=function(t){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(t),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(t.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),t.prototype.focus=function(){var t=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,void 0!==this._previousCurrentMarker&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach((function(e){return e(new Lt(t))})))},t.prototype.blur=function(){var t=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach((function(e){return e(new Lt(t))})))},t.instanceCounter=0,t}(),It=function(t,e){return(It=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};
|
|
|
/* **********************************
|
|
|
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.
|
|
|
***************************************************************************** */function Mt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}It(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function Nt(t,e,i,n){return new(i||(i=Promise))((function(r,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,s)}l((n=n.apply(t,e||[])).next())}))}function Pt(t,e){var i,n,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var Ft=function(){function t(){}return t.addKey=function(e){t.key=e},Object.defineProperty(t,"isLicensed",{get:function(){return!!t.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(t.key)},enumerable:!1,configurable:!0}),t}(),jt=function(){function t(){}return t.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},t.setAttributes=function(t,e){for(var i=0,n=e;i<n.length;i++){var r=n[i],a=r[0],o=r[1];t.setAttribute(a,o)}},t.createRect=function(e,i,n){var r=document.createElementNS("http://www.w3.org/2000/svg","rect");return r.setAttribute("width",e.toString()),r.setAttribute("height",i.toString()),n&&t.setAttributes(r,n),r},t.createLine=function(e,i,n,r,a){var o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1",e.toString()),o.setAttribute("y1",i.toString()),o.setAttribute("x2",n.toString()),o.setAttribute("y2",r.toString()),a&&t.setAttributes(o,a),o},t.createPolygon=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","polygon");return n.setAttribute("points",e),i&&t.setAttributes(n,i),n},t.createCircle=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttribute("cx",(e/2).toString()),n.setAttribute("cy",(e/2).toString()),n.setAttribute("r",e.toString()),i&&t.setAttributes(n,i),n},t.createEllipse=function(e,i,n){var r=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return r.setAttribute("cx",(e/2).toString()),r.setAttribute("cy",(i/2).toString()),r.setAttribute("rx",(e/2).toString()),r.setAttribute("ry",(i/2).toString()),n&&t.setAttributes(r,n),r},t.createGroup=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return e&&t.setAttributes(i,e),i},t.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},t.createMarker=function(e,i,n,r,a,o,s){var l=document.createElementNS("http://www.w3.org/2000/svg","marker");return t.setAttributes(l,[["id",e],["orient",i],["markerWidth",n.toString()],["markerHeight",r.toString()],["refX",a.toString()],["refY",o.toString()]]),l.appendChild(s),l},t.createText=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),e&&t.setAttributes(i,e),i},t.createTSpan=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","tspan");return n.textContent=e,i&&t.setAttributes(n,i),n},t.createImage=function(e){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return e&&t.setAttributes(i,e),i},t.createPoint=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return i.x=t,i.y=e,i},t.createPath=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),i&&t.setAttributes(n,i),n},t.createElement=function(e,i){var n=document.createElementNS("http://www.w3.org/2000/svg",e);return i&&t.setAttributes(n,i),n},t.getHollowRectanglePath=function(t,e,i,n,r,a,o,s){return"M"+t+","+e+"V"+(e+n)+"H"+(t+i)+"V"+e+"H"+r+"V"+a+"H"+(r+o)+"V"+(a+s)+"H"+r+"V"+e+"Z"},t}(),Bt=function(){function t(t){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(t.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(t.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(t.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),t.prototype.addClass=function(t){return void 0===this.styleSheet&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},t.prototype.addRule=function(t){void 0===this.styleSheet&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},t.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),(null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).appendChild(this.styleSheet),this.addRule(new Ut("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ut("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames","\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n ")),this.addRule(new Ut("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames","\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n ")),this.addClass(new Ht("_fade_in","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_in_animation_frames;\n ")),this.addClass(new Ht("_fade_out","\n animation-duration: 0.3s;\n animation-name: "+this.classNamePrefix+"_fade_out_animation_frames;\n "))},t.prototype.removeStyleSheet=function(){var t;this.styleSheet&&((null!==(t=this.styleSheetRoot)&&void 0!==t?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},t}(),Ut=function(t,e){this.selector=t,this.style=e},Ht=function(t,e){this.localName=t,this.style=e},Gt=function(){function t(){this.blocks=[],this.display=""}return t.prototype.addButtonBlock=function(t){t.className=this.blockClassName,t.buttonClassName=this.buttonClassName,t.buttonColorsClassName=this.buttonColorsClassName,t.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(t)},t.prototype.addElementBlock=function(t){void 0===t.className&&(t.className=this.blockClassName),this.blocks.push(t)},t.prototype.getUI=function(){var t=document.createElement("div");return t.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,t.style.display=this.display,this.blocks.forEach((function(e){return t.appendChild(e.getUI())})),t},t}(),zt=function(){function t(){}return t.prototype.getUI=function(){var t=document.createElement("div");if(t.className=this.className,void 0!==this.minWidth&&(t.style.minWidth=this.minWidth),void 0!==this.contentAlign)switch(this.contentAlign){case"start":t.style.justifyContent="flex-start";break;case"center":t.style.justifyContent="center";break;case"end":t.style.justifyContent="flex-end"}return t.style.whiteSpace="nowrap",t},t}(),Vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.buttons=[],e}return Mt(e,t),e.prototype.addButton=function(t){t.className=this.buttonClassName,t.colorsClassName=this.buttonColorsClassName,t.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(t)},e.prototype.getUI=function(){var e=t.prototype.getUI.call(this);return this.buttons.forEach((function(t){return e.appendChild(t.getUI())})),e},e}(zt),Wt=function(){function t(t,e){this._isActive=!1,this._isHidden=!1,this._icon=t,this.title=e,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(t.prototype,"icon",{get:function(){return this._icon},set:function(t){this._icon=t,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return this._isActive},set:function(t){this._isActive=t,this.adjustClassName()},enumerable:!1,configurable:!0}),t.prototype.getUI=function(){var t=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 t.onClick()})),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},t.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,"")))},t.prototype.hide=function(){this._isHidden=!0},t}(),Kt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.elements=[],e}return Mt(e,t),e.prototype.addElement=function(t){this.elements.push(t)},e.prototype.getUI=function(){var e=t.prototype.getUI.call(this);return this.elements.forEach((function(t){return e.appendChild(t)})),e},e}(zt),qt=function(){function t(t,e){this.horizontal=t,this.vertical=e}return Object.defineProperty(t.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),t.prototype.getVerticalLength=function(t){return t/this.ratio},t.prototype.getHorizontalLength=function(t){return t*this.ratio},t}(),Yt=function(){function t(){}return t.getIcon=function(t,e){if(t>0&&e>0){var i=new qt(t,e),n=i.ratio>=1?20:i.getHorizontalLength(20),r=i.ratio<1?20:i.getVerticalLength(20),a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(a);var o=jt.createDefs();a.appendChild(o);var s=jt.createElement("clipPath",[["id","text-bg-clip"]]);o.appendChild(s);var l=jt.createPath(jt.getHollowRectanglePath((24-n)/2,(24-r)/2,n,r,(24-n)/2+2,(24-r)/2+2,n-4,r-4));a.appendChild(l);var c=jt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);c.appendChild(jt.createTSpan(t+":"+e)),a.appendChild(c);var u=c.getBBox();jt.setAttributes(c,[["x",((24-u.width)/2).toString()],["y",((24-u.height)/2-u.y).toString()]]);var h=jt.createPath(jt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(u.width))/2,(24-Math.ceil(u.height))/2,Math.ceil(u.width),Math.ceil(u.height)));return s.appendChild(h),jt.setAttributes(l,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(a),a.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>'},t}(),Xt=function(t){function e(e,i,n){var r=t.call(this,e,i)||this;return r.isDropdownOpen=!1,r.onClick=r.dropdownButtonClicked,r.dropdownButtons=n,r}return Mt(e,t),e.prototype.setupDropdown=function(){var t=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach((function(e){e.className=t.className,e.colorsClassName=t.colorsClassName,t.dropdownBlock.appendChild(e.getUI())})),this.uiContainer.appendChild(this.dropdownBlock)},e.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},e.prototype.dropdownButtonClicked=function(){void 0===this.dropdownBlock&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},e.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},e.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},e.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},e}(Wt),$t=function(){function t(t,e){this.GRIP_SIZE=10,this.color=t,this.fillColor=e,this.visual=jt.createGroup(),this.visual.appendChild(jt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(jt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return t.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},t.prototype.setCenter=function(t,e){this.visual.childNodes.forEach((function(i){return jt.setAttributes(i,[["cx",t.toString()],["cy",e.toString()]])}))},t}(),Zt=function(){function t(t,e,i,n){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=t,this.canvasHeight=e,this.margin=i,this.container=n,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(t.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(t){this._aspectRatio=t,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.gridContainer&&jt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(t){this._zoomFactor=t,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),t.prototype.open=function(){var t=this;this.cropShadeElement=jt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=jt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var e=0;e<this.numberOfGridLines;e++)this.horizontalGridLines.push(jt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(jt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach((function(e){return t.gridContainer.appendChild(e)})),this.verticalGridLines.forEach((function(e){return t.gridContainer.appendChild(e)})),this.cropRectElement=jt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new $t(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},t.prototype.setCropRectangle=function(t){this.cropRect=t;var e=Object.assign({},this.cropRect);1!==this.zoomFactor&&(e.width=this.cropRect.width*this.zoomFactor,e.height=this.cropRect.height*this.zoomFactor,e.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-e.width/2,e.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-e.height/2),jt.setAttributes(this.cropRectElement,[["x",e.x.toString()],["y",e.y.toString()],["width",e.width.toString()],["height",e.height.toString()]]);var i=e.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach((function(t,n){var r=e.y+i*(n+1);jt.setAttributes(t,[["x1",""+e.x],["y1",""+r],["x2",""+(e.x+e.width)],["y2",""+r]])}));var n=e.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach((function(t,i){var r=e.x+n*(i+1);jt.setAttributes(t,[["x1",""+r],["y1",""+e.y],["x2",""+r],["y2",""+(e.y+e.height)]])})),jt.setAttributes(this.cropShadeElement,[["d",jt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,e.x,e.y,e.width,e.height)]]),this.topLeftGrip.setCenter(e.x,e.y),this.topRightGrip.setCenter(e.x+e.width,e.y),this.bottomLeftGrip.setCenter(e.x,e.y+e.height),this.bottomRightGrip.setCenter(e.x+e.width,e.y+e.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},t.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)},t.prototype.clientToLocalCoordinates=function(t,e){var i=this.container.getBoundingClientRect();return{x:t-i.left+this.margin,y:e-i.top+this.margin}},t.prototype.onPointerDown=function(t){this.container.setPointerCapture(t.pointerId),this.previousPoint=this.clientToLocalCoordinates(t.clientX,t.clientY),this.cropRectElement===t.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(t.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(t.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(t.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(t.target)&&(this.activeGrip=this.bottomRightGrip)},t.prototype.onPointerMove=function(t){if(this.isMoving)this.move(this.clientToLocalCoordinates(t.clientX,t.clientY));else if(this.activeGrip){var e=this.clientToLocalCoordinates(t.clientX,t.clientY);this.resize(e)}t.preventDefault()},t.prototype.onPointerUp=function(t){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(t.pointerId)},t.prototype.move=function(t){var e=t.x-this.previousPoint.x,i=t.y-this.previousPoint.y;1!==this.zoomFactor&&(e=-e/this.zoomFactor,i=-i/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+e),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+i),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=t},t.prototype.resize=function(t){var e=Object.assign({},this.cropRect),i=t.x-this.previousPoint.x,n=t.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:e.x+i<this.margin&&(i=this.margin-e.x),e.x+=i,e.width=this.cropRect.x+this.cropRect.width-e.x;break;case this.bottomRightGrip:case this.topRightGrip:e.width+i>this.canvasWidth*this.zoomFactor&&(i=this.canvasWidth*this.zoomFactor-e.width),e.width+=i}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(e.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(i),e.height=this.aspectRatio.getVerticalLength(e.width)):(e.y+=n,e.height=this.cropRect.y+this.cropRect.height-e.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?e.height=this.aspectRatio.getVerticalLength(e.width):e.height+=n}e.width<10&&(e.x=this.cropRect.x,e.width=10),e.height<10&&(e.y=this.cropRect.y,e.height=10),this.previousPoint=t,e.x>=this.margin&&e.y>=this.margin&&e.x-this.margin+e.width<=this.canvasWidth&&e.y-this.margin+e.height<=this.canvasHeight&&(this.cropRect=e,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},t.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var t=this.cropRect.x+this.cropRect.width/2,e=this.cropRect.y+this.cropRect.height/2,i=this.aspectRatio.getHorizontalLength(this.cropRect.height),n=this.aspectRatio.getVerticalLength(this.cropRect.width);i/this.canvasWidth<n/this.canvasHeight?this.cropRect.width=i:this.cropRect.height=n,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=t-this.cropRect.width/2,this.cropRect.y=e-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)}},t.prototype.getRescaledRect=function(t,e,i,n,r,a){var o=i/t,s=n/e;return{x:(r.x-a)*o+a,y:(r.y-a)*s+a,width:r.width*o,height:r.height*s}},t.prototype.scaleCanvas=function(t,e){var i=this.getRescaledRect(this.canvasWidth,this.canvasHeight,t,e,this.cropRect,this.margin);this.canvasWidth=t,this.canvasHeight=e,this.onCropChange&&this.onCropChange(i),this.setCropRectangle(i)},t}(),Jt=function(){function t(t){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=t,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(t.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),t.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},t.prototype.onPointerDown=function(t){this.controlContainer.setPointerCapture(t.pointerId),this.isDragging=!0,this.previousPoint={x:t.clientX,y:t.clientY}},t.prototype.onPointerMove=function(t){this.isDragging&&(this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.previousPoint.x=t.clientX)},t.prototype.onPointerUp=function(t){this.isDragging&&this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(t.pointerId)},t.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var t=this.angleLabelText.getBBox();jt.setAttributes(this.angleLabelElement,[["x",((this.width-t.width)/2).toString()],["y",(this.height/2).toString()]])}},t.prototype.positionScaleShape=function(){if(this.scaleShape){var t=this.scaleShape.transform.baseVal.getItem(0);t.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(t,0)}},t.prototype.getVisual=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("width",this.width+"px"),t.setAttribute("height",this.height+"px"),t.setAttribute("viewBox","0 0 "+this.width+" "+this.height),t.style.flexShrink="0",document.body.appendChild(t);for(var e="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,i=1;i<=this.width/5+10;i++){var n=i%5==0?this.height/3:this.height/6;e+="h4v"+-n+"h1v"+n}e+="v1H0Z",this.scaleShape=jt.createPath(e);var r=jt.createTransform();this.scaleShape.transform.baseVal.appendItem(r),t.appendChild(this.scaleShape),this.angleLabelElement=jt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=jt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var a=jt.createTSpan("");return a.innerHTML="°",this.angleLabelElement.appendChild(a),t.appendChild(this.angleLabelElement),document.body.removeChild(t),t},t}(),Qt=function(){function t(){this.naturalSize=!1,this.imageType="image/png"}return t.prototype.rasterize=function(t,e,i,n,r,a,o){var s=this;return new Promise((function(l){var c=document.createElement("canvas");c.width=t.width.baseVal.value-2*n,c.height=t.height.baseVal.value-2*n;var u=1,h=1;!0===s.naturalSize?(u=e.naturalWidth/(t.width.baseVal.value-2*n)/a,h=e.naturalHeight/(t.height.baseVal.value-2*n)/o,c.width=e.naturalWidth/a,c.height=e.naturalHeight/o):void 0!==s.width&&void 0!==s.height&&(u=s.width/i.width,h=s.height/i.height,c.width*=u,c.height*=h);var d=c.getContext("2d");d.translate(c.width/2,c.height/2),d.rotate(r*Math.PI/180),d.scale(a,o),d.translate(-c.width/2,-c.height/2),d.drawImage(e,0,0,c.width,c.height);var f=document.createElement("canvas");f.width=i.width*u,f.height=i.height*h,f.getContext("2d").putImageData(d.getImageData((i.x-n)*u,(i.y-n)*h,i.width*u,i.height*h),0,0),l(f.toDataURL(s.imageType,s.imageQuality))}))},t}(),te=function(){function t(e){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=t.instanceCounter++,this.styles=new Bt(this.instanceNo),this.target=e,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(t.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(t){this._zoomToCropEnabled=t,t?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gridLines",{get:function(){return this._gridLines},set:function(t){this._gridLines=t,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(t){this._rotationAngle=t,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatio",{get:function(){var t;return null!==(t=this._aspectRatio)&&void 0!==t?t:this.aspectRatios[0]},set:function(t){this._aspectRatio=t},enumerable:!1,configurable:!0}),t.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(),"popup"===this.displayMode&&this.onPopupResize(),this._isOpen=!0},t.prototype.show=function(){this.showUI(),this.open()},t.prototype.close=function(t){void 0===t&&(t=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),"popup"===this.displayMode&&window.removeEventListener("resize",this.setWindowHeight),t||this.closeEventListeners.forEach((function(t){return t()})),this._isOpen=!1)},t.prototype.addRenderEventListener=function(t){this.renderEventListeners.push(t)},t.prototype.removeRenderEventListener=function(t){this.renderEventListeners.indexOf(t)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(t),1)},t.prototype.addCloseEventListener=function(t){this.closeEventListeners.push(t)},t.prototype.removeCloseEventListener=function(t){this.closeEventListeners.indexOf(t)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(t),1)},t.prototype.setupResizeObserver=function(){var t=this;"inline"===this.displayMode?window.ResizeObserver&&(this.targetObserver=new ResizeObserver((function(){t.resize(t.target.clientWidth,t.target.clientHeight)})),this.targetObserver.observe(this.target)):"popup"===this.displayMode&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},t.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var t=1*this.target.clientWidth/this.target.clientHeight,e=this.contentDiv.clientWidth/t>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*t:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,i=e+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/t;this.resize(e,i)}},t.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},t.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",jt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},t.prototype.resize=function(t,e){this.imageWidth=Math.round(t),this.imageHeight=Math.round(e),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","popup"!==this.displayMode?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},t.prototype.setEditingTarget=function(){var t=document.createElement("canvas");t.width=this.target.naturalWidth,t.height=this.target.naturalHeight,t.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var e=t.toDataURL();jt.setAttributes(this.editingTarget,[["href",e]]),this.setEditingTargetSize()},t.prototype.setTopLeft=function(){var t=this.target.getBoundingClientRect(),e=this.editorCanvas.getBoundingClientRect();this.left=t.left-e.left-this.CANVAS_MARGIN,this.top=t.top-e.top-this.CANVAS_MARGIN},t.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=jt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=jt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=jt.createGroup(),this.editingTargetRotationScaleContainer=jt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var t=jt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(t);var e=jt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(e),this.editingTargetContainer=jt.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)},t.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},t.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=jt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Zt(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()},t.prototype.zoomToCrop=function(){if(this.cropRect){var t=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,e=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=t+"px "+e+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-t+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-e+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},t.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)},t.prototype.cropRectChanged=function(t){this.cropRect=t,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},t.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},t.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"},t.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},t.prototype.showUI=function(){switch(this.addStyles(),"popup"===this.displayMode&&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 t=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,e=this.target.offsetTop>t+this.CANVAS_MARGIN?this.target.offsetTop-(t+this.CANVAS_MARGIN):0;this.coverDiv.style.top=e+"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=void 0!==this.styles.settings.zIndex?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=void 0!==this.styles.settings.zIndex?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="popup"===this.displayMode?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,"popup"===this.displayMode&&(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","popup"===this.displayMode&&(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},t.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},t.prototype.addTopToolbar=function(){var t=this;this.topToolbar=new Gt,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 e=new Vt;e.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(e);var i=[];this.aspectRatios.forEach((function(e){var n=new Wt(Yt.getIcon(e.horizontal,e.vertical),0===e.horizontal&&0===e.vertical?"FREE":e.horizontal+":"+e.vertical);n.onClick=function(){return t.ratioButtonClicked(e)},i.push(n)})),this.aspectRatioButton=new Xt(Yt.getIcon(0,0),"Aspect ratio",i),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,e.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var n=new Wt('<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");n.isActive=this.isGridVisible,n.onClick=function(){t.isGridVisible=!t.isGridVisible,n.isActive=t.isGridVisible},e.addButton(n);var r=new Wt('<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(r.isActive=this.zoomToCropEnabled,r.onClick=function(){t.zoomToCropEnabled=!t.zoomToCropEnabled,r.isActive=t.zoomToCropEnabled},e.addButton(r),!Ft.isLicensed){var a=new Kt;this.topToolbar.addElementBlock(a);var o=document.createElement("div");o.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var s=document.createElement("a");s.style.color="currentColor",s.href="https://markerjs.com/products/cropro",s.target="_blank",s.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>',o.appendChild(s),a.addElement(o)}var l=new Vt;l.minWidth=3*this.toolbarHeight+"px",l.contentAlign="end",this.topToolbar.addButtonBlock(l);var c=new Wt('<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");c.onClick=this.startRenderAndClose,l.addButton(c),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(c.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var u=new Wt('<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");u.onClick=this.close,l.addButton(u),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(u.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},t.prototype.addBottomToolbar=function(){var t=this;this.bottomToolbar=new Gt,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 e=new Vt;e.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(e);var i=new Wt('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");i.onClick=this.rotateLeftButtonClicked,e.addButton(i);var n=new Wt('<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");n.onClick=this.rotateRightButtonClicked,e.addButton(n);var r=new Kt;r.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(r),this.straightener=new Jt("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(e){t.rotateBy(e),t.straightener.angle=t.rotationAngle},r.addElement(this.straightener.getUI());var a=new Vt;a.minWidth=2*this.toolbarHeight+"px",a.contentAlign="end",this.bottomToolbar.addButtonBlock(a);var o=new Wt('<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");o.onClick=this.flipHorizontallyButtonClicked,a.addButton(o);var s=new Wt('<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");s.onClick=this.flipVerticallyButtonClicked,a.addButton(s)},t.prototype.ratioButtonClicked=function(t){this.aspectRatio=t,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},t.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Yt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},t.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&0!==this.aspectRatio.horizontal&&0!==this.aspectRatio.vertical?this.cropLayer.aspectRatio=new qt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},t.prototype.closeUI=function(){"popup"===this.displayMode&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},t.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},t.prototype.restoreState=function(t){if(t){var e=this.cropLayer.getRescaledRect(t.width,t.height,this.imageWidth,this.imageHeight,t.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(e),this.cropRectChanged(e),this.flippedHorizontally=t.flippedHorizontally,this.flippedVertically=t.flippedVertically,this.applyFlip(),this.rotationAngle=t.rotationAngle,this.applyRotation()}},t.prototype.clientToLocalCoordinates=function(t,e){var i=this.cropImage.getBoundingClientRect();return{x:t-i.left,y:e-i.top}},t.prototype.onWindowResize=function(){this.positionUI()},t.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var t=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=t+"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()},t.prototype.rotateLeftButtonClicked=function(){var t=this.rotationAngle-90;this.rotationAngle%90!=0&&(t+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(t)},t.prototype.rotateRightButtonClicked=function(){var t=this.rotationAngle+90;this.rotationAngle%90!=0&&(t-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(t)},t.prototype.rotateTo=function(t){t=(t=t>180?t-360:t)<=-180?t+360:t,this.rotationAngle=t,this.applyRotation()},t.prototype.rotateBy=function(t){this.rotateTo((this.rotationAngle+t)%360)},t.prototype.applyRotation=function(){var t=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var e=this.editingTargetRotationContainer.transform.baseVal.getItem(0);e.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(e,0);var i=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/i.width,this.imageHeight/i.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=t},t.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},t.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},t.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},t.prototype.startRenderAndClose=function(){return Nt(this,void 0,void 0,(function(){var t,e;return Pt(this,(function(i){switch(i.label){case 0:return[4,this.render()];case 1:return t=i.sent(),e=this.getState(),this.renderEventListeners.forEach((function(i){return i(t,e)})),this.close(!0),[2]}}))}))},t.prototype.render=function(){return Nt(this,void 0,void 0,(function(){var t;return Pt(this,(function(e){switch(e.label){case 0:return(t=new Qt).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.width=this.renderWidth,t.height=this.renderHeight,this.unzoomFromCrop(),jt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,t.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 e.sent(),[4,t.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,e.sent()]}}))}))},t.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new Ht("toolbar","\n width: "+("inline"===this.displayMode?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+";\n flex-shrink: 0;\n display: flex;\n flex-direction: row;\n justify-content: space-between; \n height: "+this.toolbarHeight+"px;\n box-sizing: content-box;\n overflow: hidden;\n line-height: 0px;\n ")),this.toolbarStyleColorsClass=this.styles.addClass(new Ht("toolbar_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarBlockStyleClass=this.styles.addClass(new Ht("toolbar-block","\n display: flex;\n align-items: center;\n box-sizing: content-box;\n "));var t=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new Ht("toolbar_button","\n display: inline-block;\n width: "+(this.toolbarHeight-2*t)+"px;\n height: "+(this.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n cursor: default;\n user-select: none;\n box-sizing: content-box;\n ")),this.toolbarButtonStyleColorsClass=this.styles.addClass(new Ht("toolbar_button_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n ")),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new Ht("toolbar_active_button","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n background-color: "+this.styles.settings.toolbarBackgroundActiveColor+"\n ")),this.styles.addRule(new Ut("."+this.toolbarButtonStyleClass.name+" svg","\n height: "+this.toolbarHeight/2+"px;\n ")),this.styles.addRule(new Ut("."+this.toolbarButtonStyleColorsClass.name+":hover","\n background-color: "+this.styles.settings.toolbarBackgroundHoverColor+"\n ")),this.toolbarDropdownStyleClass=this.styles.addClass(new Ht("toolbar_dropdown","\n position: absolute;\n max-width: "+4*this.toolbarHeight+"px;\n z-index: 20;\n white-space: normal;\n box-sizing: content-box;\n box-shadow: 3px 3px rgba(33, 33, 33, 0.1);\n margin: "+("inline"===this.displayMode?"0":this.popupMargin)+"px;\n line-height: 0px;\n ")),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new Ht("toolbar_dropdown_colors","\n background-color: "+this.styles.settings.toolbarBackgroundColor+";\n ")),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new Ht("toolbar_straightener_block","\n display: flex;\n overflow: hidden;\n justify-content: center;\n -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%);\n ")),this.toolbarStraightenerStyleClass=this.styles.addClass(new Ht("toolbar_straightener","\n display: flex;\n overflow: hidden;\n justify-content: center;\n height: "+(this.toolbarHeight-2*t)+"px;\n padding: "+t+"px;\n cursor: default;\n user-select: none;\n box-sizing: content-box;\n ")),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new Ht("toolbar_straightener_colors","\n color: "+this.styles.settings.toolbarColor+";\n fill: currentColor;\n "))},t.instanceCounter=0,t}(),ee=i("8hTe"),ie=i.n(ee),ne=/<pre[^>]*>/g;e.a=function(t){var e=t.value,i=void 0===e?"":e,l=t.edit,d=void 0!==l&&l,f=t.className,p=t.showTextOnly,m=t.showLines,g=t.replaces,v=t.zoomImg,y=t.hasMask,C=t.style,k=void 0===C?{}:C,E=t.stylesPrev,w=void 0===E?{}:E,L=String(i),A=Object(u.useRef)(),D=Object(u.useRef)(),_=Object(u.useState)(""),I=Object(s.a)(_,2),B=I[0],U=I[1],H=Object(u.useState)("office"),G=Object(s.a)(H,2),z=G[0],V=G[1],W=Object(u.useMemo)((function(){try{L=(L=L.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+N.a.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+N.a.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+N.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,"\n")).replace(new RegExp("(?<!\\n)\\n(?!\\n)","g")," \n")}catch(t){}var t=R(L),e=T;if(L.match(/\[TOC\]/)&&(t=t.replace("<p>[TOC]</p>",S()),b()),t=(t=t.replace(/(__special_katext_id_\d+__)/g,(function(t,i){var n=e[i],r=n.type,a=n.expression;return Object(P.renderToString)(function(t){var e=document.createElement("div");return e.innerHTML=t,0===e.childNodes.length?"":e.childNodes[0].nodeValue}(a)||"",{displayMode:"block"===r,throwOnError:!1,output:"html"})}))).replace(/▁/g,"▁▁▁"),O(),p){var i=document.createElement("div");return i.innerHTML=t,i.innerText}return setTimeout((function(){return Y()}),500),t}),[L]),K=Object(u.useRef)();function q(t){var e=t.target;if("IMG"===e.tagName.toUpperCase()){if(v){var i=e.getAttribute("src");U(i),V("image")}}else if("A"===e.tagName.toUpperCase()){var n=e.getAttribute("href");if(n.indexOf("office")>-1)t.preventDefault(),U(n),V("office");else if(n.indexOf("application/pdf")>-1)t.preventDefault(),U(n),V("pdf");else if(n.indexOf("type=text")>-1)t.preventDefault(),U(n),V("html");else if(n.startsWith("#")){t.preventDefault();var r=document.getElementById(n.replace("#",""));r&&r.scrollIntoView(!0)}}}x.WebkitLineClamp=m,m&&(k=Object(a.a)(Object(a.a)({},k),x));var Y=function(){var t,e=null===(t=K.current)||void 0===t?void 0:t.querySelectorAll("video");null==e||e.forEach((function(t){if(t.oncontextmenu=function(){return!1},t.src.indexOf(".m3u8")>-1)if(t.canPlayType("application/vnd.apple.mpegurl"));else if(M.a.isSupported()){var e=new M.a;e.loadSource(t.src),e.attachMedia(t)}}))};Object(u.useEffect)((function(){if(K.current&&W&&W.match(ne)&&window.PR.prettyPrint(),K.current)return K.current.addEventListener("click",q),function(){K.current.removeEventListener("click",q),O(),b()}}),[W,K.current,q]);return h.a.createElement("div",{style:{position:"relative"}},h.a.createElement("div",{ref:K,style:Object(a.a)({},k),className:"".concat(f||""," markdown-body ").concat(ie.a.mdBody),onMouseOver:function(t){d&&("IMG"===t.target.nodeName?(A.current.style.display="flex",A.current.style.width=t.target.clientWidth+"px",A.current.style.height=t.target.clientHeight+"px",A.current.style.top=t.target.offsetTop+"px",A.current.style.left=t.target.offsetLeft+"px",D.current.src=t.target.getAttribute("src")):A.current.style.display="none")},dangerouslySetInnerHTML:{__html:W}}),h.a.createElement("div",{ref:A,className:ie.a.button},h.a.createElement(n.a,null,h.a.createElement(r.a,{onClick:function(){return(t=new te(D.current)).displayMode="popup",t.addRenderEventListener(function(){var t=Object(o.a)(c.a.mark((function t(e){var i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A.current.style.display="none",t.next=3,Object(j.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e}});case 3:null!=(i=t.sent)&&i.id&&g(D.current.getAttribute("src").replace(N.a.API_SERVER,""),"/api/attachments/".concat(null==i?void 0:i.id,"?type=").concat(i.content_type));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),void t.show();var t}},"裁剪"),h.a.createElement(r.a,{onClick:function(){return(t=new Rt(D.current)).settings.displayMode="popup",t.addEventListener("render",function(){var t=Object(o.a)(c.a.mark((function t(e){var i;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(A.current.style.display="none",!D.current){t.next=6;break}return t.next=4,Object(j.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:e.dataUrl}});case 4:null!=(i=t.sent)&&i.id&&g(D.current.getAttribute("src").replace(N.a.API_SERVER,""),"/api/attachments/".concat(null==i?void 0:i.id,"?type=").concat(i.content_type));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.show(),void(window.markerArea=t);var t}},"编辑"))),h.a.createElement("img",{ref:D,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),h.a.createElement(F.a,{close:!0,data:B,hasMask:y,type:null!=B&&B.length?z:"",style:Object(a.a)({},w),onClose:function(){return U("")}}))}},"9VGf":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/components/useInterval.tsx ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var n=i(/*! react */"q1tI");function r(t,e){var i=Object(n.useRef)();Object(n.useEffect)((function(){i.current=t})),Object(n.useEffect)((function(){if(null!==e){var t=setInterval((function(){i.current()}),e);return function(){return clearInterval(t)}}}),[e])}},BU3w:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/Dom/dynamicCSS.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: injectCSS, updateCSS */
|
|
|
/*! exports used: updateCSS */function(t,e,i){"use strict";i.d(e,"a",(function(){return s}));var n=i(/*! ./canUseDom */"MNnm");function r(t){return t.attachTo?t.attachTo:document.querySelector("head")||document.body}function a(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.a)())return null;var a,o=document.createElement("style");(null===(e=i.csp)||void 0===e?void 0:e.nonce)&&(o.nonce=null===(a=i.csp)||void 0===a?void 0:a.nonce);o.innerHTML=t;var s=r(i),l=s.firstChild;return i.prepend&&s.prepend?s.prepend(o):i.prepend&&l?s.insertBefore(o,l):s.appendChild(o),o}var o=new Map;function s(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r(i);if(!o.has(n)){var s=a("",i),l=s.parentNode;o.set(n,l),l.removeChild(s)}var c=Array.from(o.get(n).children).find((function(t){return"STYLE"===t.tagName&&t["rc-util-key"]===e}));if(c){var u,h,d;if((null===(u=i.csp)||void 0===u?void 0:u.nonce)&&c.nonce!==(null===(h=i.csp)||void 0===h?void 0:h.nonce))c.nonce=null===(d=i.csp)||void 0===d?void 0:d.nonce;return c.innerHTML!==t&&(c.innerHTML=t),c}var f=a(t,i);return f["rc-util-key"]=e,f}},Bd2K:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/edit/closetag.js ***!
|
|
|
\********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){t.defineOption("autoCloseTags",!1,(function(o,s,l){if(l!=t.Init&&l&&o.removeKeyMap("autoCloseTags"),s){var c={name:"autoCloseTags"};"object"==typeof s&&!1===s.whenClosing||(c["'/'"]=function(e){return function(e){return e.getOption("disableInput")?t.Pass:n(e,!0)}(e)}),"object"==typeof s&&!1===s.whenOpening||(c["'>'"]=function(n){return function(n){if(n.getOption("disableInput"))return t.Pass;for(var o=n.listSelections(),s=[],l=n.getOption("autoCloseTags"),c=0;c<o.length;c++){if(!o[c].empty())return t.Pass;var u=o[c].head,h=n.getTokenAt(u),d=t.innerMode(n.getMode(),h.state),f=d.state,p=d.mode.xmlCurrentTag&&d.mode.xmlCurrentTag(f),m=p&&p.name;if(!m)return t.Pass;var g="html"==d.mode.configuration,v="object"==typeof l&&l.dontCloseTags||g&&e,y="object"==typeof l&&l.indentTags||g&&i;h.end>u.ch&&(m=m.slice(0,m.length-h.end+u.ch));var b=m.toLowerCase();if(!m||"string"==h.type&&(h.end!=u.ch||!/[\"\']/.test(h.string.charAt(h.string.length-1))||1==h.string.length)||"tag"==h.type&&p.close||h.string.indexOf("/")==u.ch-h.start-1||v&&r(v,b)>-1||a(n,d.mode.xmlCurrentContext&&d.mode.xmlCurrentContext(f)||[],m,u,!0))return t.Pass;var x="object"==typeof l&&l.emptyTags;if(x&&r(x,m)>-1)s[c]={text:"/>",newPos:t.Pos(u.line,u.ch+2)};else{var S=y&&r(y,b)>-1;s[c]={indent:S,text:">"+(S?"\n\n":"")+"</"+m+">",newPos:S?t.Pos(u.line+1,0):t.Pos(u.line,u.ch+1)}}}var C="object"==typeof l&&l.dontIndentOnAutoClose;for(c=o.length-1;c>=0;c--){var k=s[c];n.replaceRange(k.text,o[c].head,o[c].anchor,"+insert");var E=n.listSelections().slice(0);E[c]={head:k.newPos,anchor:k.newPos},n.setSelections(E),!C&&k.indent&&(n.indentLine(k.newPos.line,null,!0),n.indentLine(k.newPos.line+1,null,!0))}}(n)}),o.addKeyMap(c)}}));var e=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],i=["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 n(e,i){for(var n=e.listSelections(),r=[],o=i?"/":"</",s=e.getOption("autoCloseTags"),l="object"==typeof s&&s.dontIndentOnSlash,c=0;c<n.length;c++){if(!n[c].empty())return t.Pass;var u=n[c].head,h=e.getTokenAt(u),d=t.innerMode(e.getMode(),h.state),f=d.state;if(i&&("string"==h.type||"<"!=h.string.charAt(0)||h.start!=u.ch-1))return t.Pass;var p,m="xml"!=d.mode.name&&"htmlmixed"==e.getMode().name;if(m&&"javascript"==d.mode.name)p=o+"script";else if(m&&"css"==d.mode.name)p=o+"style";else{var g=d.mode.xmlCurrentContext&&d.mode.xmlCurrentContext(f);if(!g||g.length&&a(e,g,g[g.length-1],u))return t.Pass;p=o+g[g.length-1]}">"!=e.getLine(u.line).charAt(h.end)&&(p+=">"),r[c]=p}if(e.replaceSelections(r),n=e.listSelections(),!l)for(c=0;c<n.length;c++)(c==n.length-1||n[c].head.line<n[c+1].head.line)&&e.indentLine(n[c].head.line)}function r(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0,n=t.length;i<n;++i)if(t[i]==e)return i;return-1}function a(e,i,n,r,a){if(!t.scanForClosingTag)return!1;var o=Math.min(e.lastLine()+1,r.line+500),s=t.scanForClosingTag(e,r,null,o);if(!s||s.tag!=n)return!1;for(var l=a?1:0,c=i.length-1;c>=0&&i[c]==n;c--)++l;for(r=s.to,c=1;c<l;c++){var u=t.scanForClosingTag(e,r,null,o);if(!u||u.tag!=n)return!1;r=u.to}return!0}t.commands.closeTag=function(t){return n(t)}}(i(/*! ../../lib/codemirror */"VrN/"),i(/*! ../fold/xml-fold */"osHv"))},BdwD:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/components/NoData/index.tsx ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i(/*! antd/es/button/style */"+L6B");var n=i(/*! antd/es/button */"2/Rp"),r=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends */"0Owb"),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),o=i(/*! react */"q1tI"),s=i.n(o),l=i(/*! @/assets/images/icons/nodata.png */"FOrL"),c=i.n(l);e.a=function(t){var e=t.buttonProps,i=void 0===e?{}:e,o=t.styles,l=void 0===o?{}:o,u=t.customText,h=t.ButtonText,d=t.ButtonClick,f=t.Buttonclass,p=t.ButtonTwo;return s.a.createElement("section",{className:"tc animated fadeIn",style:Object(a.a)(Object(a.a)({},{color:"#999",margin:"200px auto"}),l)},s.a.createElement("img",{src:c.a}),s.a.createElement("p",{className:"mt20 font14"},u||"暂时还没有相关数据哦!"),h&&s.a.createElement(n.a,Object(r.a)({className:f,onClick:d},i),h),p&&p)}},BjJ7:
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/pages/tasks/util.js ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isCompileOk, getTreeData, processTreeData, debounce, isProd, apiPref */
|
|
|
/*! exports used: apiPref, debounce, getTreeData, isCompileOk, processTreeData */function(t,e,i){"use strict";function n(t){var e=!0;if(t.length>0){for(var i=0;i<t.length;i++)if(0==t[i].compile_success||!t[i].compile_success){e=!1;break}}else e=!1;return e}function r(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=[],n=0;n<t.length;n++){var r=t[n],a=e?"".concat(e,"/").concat(r.name):"".concat(r.name);i.push({title:r.name,isLeaf:"tree"!==r.type,key:a})}return i}function a(t,e,i){for(var n=0;n<t.length;n++){var r=t[n];if(r.key===e){r.children=i;break}r.children&&a(r.children,e,i)}return t}function o(t,e,i){var n;return function(){var r=this,a=arguments,o=function(){n=null,i||t.apply(r,a)},s=i&&!n;clearTimeout(n),n=setTimeout(o,e),s&&t.apply(r,a)}}i.d(e,"d",(function(){return n})),i.d(e,"c",(function(){return r})),i.d(e,"e",(function(){return a})),i.d(e,"b",(function(){return o})),i.d(e,"a",(function(){return s}));var s=i(/*! @/utils/env */"m3rI").a.API_SERVER},"C+DQ":
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/css/iconfont.css ***!
|
|
|
\*********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},DlQD:
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./node_modules/marked/lib/marked.js ***!
|
|
|
\*******************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports=function(){"use strict";function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function i(t,i){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,i){if(t){if("string"==typeof t)return e(t,i);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var n=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){function e(){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}}t.exports={defaults:{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},getDefaults:e,changeDefaults:function(e){t.exports.defaults=e}}})),r=(n.defaults,n.getDefaults,n.changeDefaults,/[&<>"']/),a=/[&<>"']/g,o=/[<>"']|&(?!#?\w+;)/,s=/[<>"']|&(?!#?\w+;)/g,l={"&":"&","<":"<",">":">",'"':""","'":"'"},c=function(t){return l[t]},u=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function h(t){return t.replace(u,(function(t,e){return"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""}))}var d=/(^|[^\[])\^/g,f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i,m={},g=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function b(t,e){m[" "+t]||(g.test(t)?m[" "+t]=t+"/":m[" "+t]=x(t,"/",!0));var i=-1===(t=m[" "+t]).indexOf(":");return"//"===e.substring(0,2)?i?e:t.replace(v,"$1")+e:"/"===e.charAt(0)?i?e:t.replace(y,"$1")+e:t+e}function x(t,e,i){var n=t.length;if(0===n)return"";for(var r=0;r<n;){var a=t.charAt(n-r-1);if(a!==e||i){if(a===e||!i)break;r++}else r++}return t.substr(0,n-r)}var S=function(t,e){if(e){if(r.test(t))return t.replace(a,c)}else if(o.test(t))return t.replace(s,c);return t},C=h,k=function(t,e){t=t.source||t,e=e||"";var i={replace:function(e,n){return n=(n=n.source||n).replace(d,"$1"),t=t.replace(e,n),i},getRegex:function(){return new RegExp(t,e)}};return i},E=function(t,e,i){if(t){var n;try{n=decodeURIComponent(h(i)).replace(f,"").toLowerCase()}catch(t){return null}if(0===n.indexOf("javascript:")||0===n.indexOf("vbscript:")||0===n.indexOf("data:"))return null}e&&!p.test(i)&&(i=b(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(t){return null}return i},w={exec:function(){}},T=function(t){for(var e,i,n=1;n<arguments.length;n++)for(i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},O=function(t,e){var i=t.replace(/\|/g,(function(t,e,i){for(var n=!1,r=e;--r>=0&&"\\"===i[r];)n=!n;return n?"|":" |"})).split(/ \|/),n=0;if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(/\\\|/g,"|");return i},L=x,A=function(t,e){if(-1===t.indexOf(e[1]))return-1;for(var i=t.length,n=0,r=0;r<i;r++)if("\\"===t[r])r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&--n<0)return r;return-1},D=function(t){t&&t.sanitize&&!t.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")},_=n.defaults,R=L,I=O,M=S,N=A;function P(t,e,i){var n=e.href,r=e.title?M(e.title):null,a=t[1].replace(/\\([\[\]])/g,"$1");return"!"!==t[0].charAt(0)?{type:"link",raw:i,href:n,title:r,text:a}:{type:"image",raw:i,href:n,title:r,text:M(a)}}var F=function(){function t(t){this.options=t||_}var e=t.prototype;return e.space=function(t){var e=this.rules.block.newline.exec(t);if(e)return e[0].length>1?{type:"space",raw:e[0]}:{raw:"\n"}},e.code=function(t,e){var i=this.rules.block.code.exec(t);if(i){var n=e[e.length-1];if(n&&"paragraph"===n.type)return{raw:i[0],text:i[0].trimRight()};var r=i[0].replace(/^ {4}/gm,"");return{type:"code",raw:i[0],codeBlockStyle:"indented",text:this.options.pedantic?r:R(r,"\n")}}},e.fences=function(t){var e=this.rules.block.fences.exec(t);if(e){var i=e[0],n=function(t,e){var i=t.match(/^(\s+)(?:```)/);if(null===i)return e;var n=i[1];return e.split("\n").map((function(t){var e=t.match(/^\s+/);return null===e?t:e[0].length>=n.length?t.slice(n.length):t})).join("\n")}(i,e[3]||"");return{type:"code",raw:i,lang:e[2]?e[2].trim():e[2],text:n}}},e.heading=function(t){var e=this.rules.block.heading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[1].length,text:e[2]}},e.nptable=function(t){var e=this.rules.block.nptable.exec(t);if(e){var i={type:"table",header:I(e[1].replace(/^ *| *\| *$/g,"")),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:e[3]?e[3].replace(/\n$/,"").split("\n"):[],raw:e[0]};if(i.header.length===i.align.length){var n,r=i.align.length;for(n=0;n<r;n++)/^ *-+: *$/.test(i.align[n])?i.align[n]="right":/^ *:-+: *$/.test(i.align[n])?i.align[n]="center":/^ *:-+ *$/.test(i.align[n])?i.align[n]="left":i.align[n]=null;for(r=i.cells.length,n=0;n<r;n++)i.cells[n]=I(i.cells[n],i.header.length);return i}}},e.hr=function(t){var e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:e[0]}},e.blockquote=function(t){var e=this.rules.block.blockquote.exec(t);if(e){var i=e[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:e[0],text:i}}},e.list=function(t){var e=this.rules.block.list.exec(t);if(e){for(var i,n,r,a,o,s,l,c=e[0],u=e[2],h=u.length>1,d=")"===u[u.length-1],f={type:"list",raw:c,ordered:h,start:h?+u.slice(0,-1):"",loose:!1,items:[]},p=e[0].match(this.rules.block.item),m=!1,g=p.length,v=0;v<g;v++)c=i=p[v],n=i.length,~(i=i.replace(/^ *([*+-]|\d+[.)]) */,"")).indexOf("\n ")&&(n-=i.length,i=this.options.pedantic?i.replace(/^ {1,4}/gm,""):i.replace(new RegExp("^ {1,"+n+"}","gm"),"")),v!==g-1&&(r=this.rules.block.bullet.exec(p[v+1])[0],(h?1===r.length||!d&&")"===r[r.length-1]:r.length>1||this.options.smartLists&&r!==u)&&(a=p.slice(v+1).join("\n"),f.raw=f.raw.substring(0,f.raw.length-a.length),v=g-1)),o=m||/\n\n(?!\s*$)/.test(i),v!==g-1&&(m="\n"===i.charAt(i.length-1),o||(o=m)),o&&(f.loose=!0),l=void 0,(s=/^\[[ xX]\] /.test(i))&&(l=" "!==i[1],i=i.replace(/^\[[ xX]\] +/,"")),f.items.push({type:"list_item",raw:c,task:s,checked:l,loose:o,text:i});return f}},e.html=function(t){var e=this.rules.block.html.exec(t);if(e)return{type:this.options.sanitize?"paragraph":"html",raw:e[0],pre:!this.options.sanitizer&&("pre"===e[1]||"script"===e[1]||"style"===e[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(e[0]):M(e[0]):e[0]}},e.def=function(t){var e=this.rules.block.def.exec(t);if(e)return e[3]&&(e[3]=e[3].substring(1,e[3].length-1)),{tag:e[1].toLowerCase().replace(/\s+/g," "),raw:e[0],href:e[2],title:e[3]}},e.table=function(t){var e=this.rules.block.table.exec(t);if(e){var i={type:"table",header:I(e[1].replace(/^ *| *\| *$/g,"")),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:e[3]?e[3].replace(/\n$/,"").split("\n"):[]};if(i.header.length===i.align.length){i.raw=e[0];var n,r=i.align.length;for(n=0;n<r;n++)/^ *-+: *$/.test(i.align[n])?i.align[n]="right":/^ *:-+: *$/.test(i.align[n])?i.align[n]="center":/^ *:-+ *$/.test(i.align[n])?i.align[n]="left":i.align[n]=null;for(r=i.cells.length,n=0;n<r;n++)i.cells[n]=I(i.cells[n].replace(/^ *\| *| *\| *$/g,""),i.header.length);return i}}},e.lheading=function(t){var e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:"="===e[2].charAt(0)?1:2,text:e[1]}},e.paragraph=function(t){var e=this.rules.block.paragraph.exec(t);if(e)return{type:"paragraph",raw:e[0],text:"\n"===e[1].charAt(e[1].length-1)?e[1].slice(0,-1):e[1]}},e.text=function(t,e){var i=this.rules.block.text.exec(t);if(i){var n=e[e.length-1];return n&&"text"===n.type?{raw:i[0],text:i[0]}:{type:"text",raw:i[0],text:i[0]}}},e.escape=function(t){var e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:M(e[1])}},e.tag=function(t,e,i){var n=this.rules.inline.tag.exec(t);if(n)return!e&&/^<a /i.test(n[0])?e=!0:e&&/^<\/a>/i.test(n[0])&&(e=!1),!i&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?i=!0:i&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(i=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:e,inRawBlock:i,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):M(n[0]):n[0]}},e.link=function(t){var e=this.rules.inline.link.exec(t);if(e){var i=N(e[2],"()");if(i>-1){var n=(0===e[0].indexOf("!")?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,n).trim(),e[3]=""}var r=e[2],a="";if(this.options.pedantic){var o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r);o?(r=o[1],a=o[3]):a=""}else a=e[3]?e[3].slice(1,-1):"";return P(e,{href:(r=r.trim().replace(/^<([\s\S]*)>$/,"$1"))?r.replace(this.rules.inline._escapes,"$1"):r,title:a?a.replace(this.rules.inline._escapes,"$1"):a},e[0])}},e.reflink=function(t,e){var i;if((i=this.rules.inline.reflink.exec(t))||(i=this.rules.inline.nolink.exec(t))){var n=(i[2]||i[1]).replace(/\s+/g," ");if(!(n=e[n.toLowerCase()])||!n.href){var r=i[0].charAt(0);return{type:"text",raw:r,text:r}}return P(i,n,i[0])}},e.strong=function(t,e,i){void 0===i&&(i="");var n=this.rules.inline.strong.start.exec(t);if(n&&(!n[1]||n[1]&&(""===i||this.rules.inline.punctuation.exec(i)))){e=e.slice(-1*t.length);var r,a="**"===n[0]?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;for(a.lastIndex=0;null!=(n=a.exec(e));)if(r=this.rules.inline.strong.middle.exec(e.slice(0,n.index+3)))return{type:"strong",raw:t.slice(0,r[0].length),text:t.slice(2,r[0].length-2)}}},e.em=function(t,e,i){void 0===i&&(i="");var n=this.rules.inline.em.start.exec(t);if(n&&(!n[1]||n[1]&&(""===i||this.rules.inline.punctuation.exec(i)))){e=e.slice(-1*t.length);var r,a="*"===n[0]?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;for(a.lastIndex=0;null!=(n=a.exec(e));)if(r=this.rules.inline.em.middle.exec(e.slice(0,n.index+2)))return{type:"em",raw:t.slice(0,r[0].length),text:t.slice(1,r[0].length-1)}}},e.codespan=function(t){var e=this.rules.inline.code.exec(t);if(e){var i=e[2].replace(/\n/g," "),n=/[^ ]/.test(i),r=i.startsWith(" ")&&i.endsWith(" ");return n&&r&&(i=i.substring(1,i.length-1)),i=M(i,!0),{type:"codespan",raw:e[0],text:i}}},e.br=function(t){var e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}},e.del=function(t){var e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[1]}},e.autolink=function(t,e){var i,n,r=this.rules.inline.autolink.exec(t);if(r)return n="@"===r[2]?"mailto:"+(i=M(this.options.mangle?e(r[1]):r[1])):i=M(r[1]),{type:"link",raw:r[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}},e.url=function(t,e){var i;if(i=this.rules.inline.url.exec(t)){var n,r;if("@"===i[2])r="mailto:"+(n=M(this.options.mangle?e(i[0]):i[0]));else{var a;do{a=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0]}while(a!==i[0]);n=M(i[0]),r="www."===i[1]?"http://"+n:n}return{type:"link",raw:i[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}},e.inlineText=function(t,e,i){var n,r=this.rules.inline.text.exec(t);if(r)return n=e?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):M(r[0]):r[0]:M(this.options.smartypants?i(r[0]):r[0]),{type:"text",raw:r[0],text:n}},t}(),j=w,B=k,U=T,H={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:j,table:j,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};H.def=B(H.def).replace("label",H._label).replace("title",H._title).getRegex(),H.bullet=/(?:[*+-]|\d{1,9}[.)])/,H.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,H.item=B(H.item,"gm").replace(/bull/g,H.bullet).getRegex(),H.list=B(H.list).replace(/bull/g,H.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+H.def.source+")").getRegex(),H._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",H._comment=/<!--(?!-?>)[\s\S]*?-->/,H.html=B(H.html,"i").replace("comment",H._comment).replace("tag",H._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),H.paragraph=B(H._paragraph).replace("hr",H.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",H._tag).getRegex(),H.blockquote=B(H.blockquote).replace("paragraph",H.paragraph).getRegex(),H.normal=U({},H),H.gfm=U({},H.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*|$)"}),H.gfm.nptable=B(H.gfm.nptable).replace("hr",H.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",H._tag).getRegex(),H.gfm.table=B(H.gfm.table).replace("hr",H.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",H._tag).getRegex(),H.pedantic=U({},H.normal,{html:B("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",H._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:j,paragraph:B(H.normal._paragraph).replace("hr",H.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",H.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var G={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:j,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:j,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};G.punctuation=B(G.punctuation).replace(/punctuation/g,G._punctuation).getRegex(),G._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",G._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",G.em.start=B(G.em.start).replace(/punctuation/g,G._punctuation).getRegex(),G.em.middle=B(G.em.middle).replace(/punctuation/g,G._punctuation).replace(/overlapSkip/g,G._overlapSkip).getRegex(),G.em.endAst=B(G.em.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.em.endUnd=B(G.em.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.start=B(G.strong.start).replace(/punctuation/g,G._punctuation).getRegex(),G.strong.middle=B(G.strong.middle).replace(/punctuation/g,G._punctuation).replace(/blockSkip/g,G._blockSkip).getRegex(),G.strong.endAst=B(G.strong.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.endUnd=B(G.strong.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.blockSkip=B(G._blockSkip,"g").getRegex(),G.overlapSkip=B(G._overlapSkip,"g").getRegex(),G._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,G._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,G._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])?)+(?![-_])/,G.autolink=B(G.autolink).replace("scheme",G._scheme).replace("email",G._email).getRegex(),G._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,G.tag=B(G.tag).replace("comment",H._comment).replace("attribute",G._attribute).getRegex(),G._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,G._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,G._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,G.link=B(G.link).replace("label",G._label).replace("href",G._href).replace("title",G._title).getRegex(),G.reflink=B(G.reflink).replace("label",G._label).getRegex(),G.reflinkSearch=B(G.reflinkSearch,"g").replace("reflink",G.reflink).replace("nolink",G.nolink).getRegex(),G.normal=U({},G),G.pedantic=U({},G.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:B(/^!?\[(label)\]\((.*?)\)/).replace("label",G._label).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G._label).getRegex()}),G.gfm=U({},G.normal,{escape:B(G.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),G.gfm.url=B(G.gfm.url,"i").replace("email",G.gfm._extended_email).getRegex(),G.breaks=U({},G.gfm,{br:B(G.br).replace("{2,}","*").getRegex(),text:B(G.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var z={block:H,inline:G},V=n.defaults,W=z.block,K=z.inline;function q(t){return t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Y(t){var e,i,n="",r=t.length;for(e=0;e<r;e++)i=t.charCodeAt(e),Math.random()>.5&&(i="x"+i.toString(16)),n+="&#"+i+";";return n}var X=function(){function e(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||V,this.options.tokenizer=this.options.tokenizer||new F,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var e={block:W.normal,inline:K.normal};this.options.pedantic?(e.block=W.pedantic,e.inline=K.pedantic):this.options.gfm&&(e.block=W.gfm,this.options.breaks?e.inline=K.breaks:e.inline=K.gfm),this.tokenizer.rules=e}e.lex=function(t,i){return new e(i).lex(t)};var i,n,r,a=e.prototype;return a.lex=function(t){return t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(t,this.tokens,!0),this.inline(this.tokens),this.tokens},a.blockTokens=function(t,e,i){var n,r,a,o;for(void 0===e&&(e=[]),void 0===i&&(i=!0),t=t.replace(/^ +$/gm,"");t;)if(n=this.tokenizer.space(t))t=t.substring(n.raw.length),n.type&&e.push(n);else if(n=this.tokenizer.code(t,e))t=t.substring(n.raw.length),n.type?e.push(n):((o=e[e.length-1]).raw+="\n"+n.raw,o.text+="\n"+n.text);else if(n=this.tokenizer.fences(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.heading(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.nptable(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.hr(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.blockquote(t))t=t.substring(n.raw.length),n.tokens=this.blockTokens(n.text,[],i),e.push(n);else if(n=this.tokenizer.list(t)){for(t=t.substring(n.raw.length),a=n.items.length,r=0;r<a;r++)n.items[r].tokens=this.blockTokens(n.items[r].text,[],!1);e.push(n)}else if(n=this.tokenizer.html(t))t=t.substring(n.raw.length),e.push(n);else if(i&&(n=this.tokenizer.def(t)))t=t.substring(n.raw.length),this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});else if(n=this.tokenizer.table(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.lheading(t))t=t.substring(n.raw.length),e.push(n);else if(i&&(n=this.tokenizer.paragraph(t)))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.text(t,e))t=t.substring(n.raw.length),n.type?e.push(n):((o=e[e.length-1]).raw+="\n"+n.raw,o.text+="\n"+n.text);else if(t){var s="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(s);break}throw new Error(s)}return e},a.inline=function(t){var e,i,n,r,a,o,s=t.length;for(e=0;e<s;e++)switch((o=t[e]).type){case"paragraph":case"text":case"heading":o.tokens=[],this.inlineTokens(o.text,o.tokens);break;case"table":for(o.tokens={header:[],cells:[]},r=o.header.length,i=0;i<r;i++)o.tokens.header[i]=[],this.inlineTokens(o.header[i],o.tokens.header[i]);for(r=o.cells.length,i=0;i<r;i++)for(a=o.cells[i],o.tokens.cells[i]=[],n=0;n<a.length;n++)o.tokens.cells[i][n]=[],this.inlineTokens(a[n],o.tokens.cells[i][n]);break;case"blockquote":this.inline(o.tokens);break;case"list":for(r=o.items.length,i=0;i<r;i++)this.inline(o.items[i].tokens)}return t},a.inlineTokens=function(t,e,i,n,r){var a;void 0===e&&(e=[]),void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r="");var o,s=t;if(this.tokens.links){var l=Object.keys(this.tokens.links);if(l.length>0)for(;null!=(o=this.tokenizer.rules.inline.reflinkSearch.exec(s));)l.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(o=this.tokenizer.rules.inline.blockSkip.exec(s));)s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;t;)if(a=this.tokenizer.escape(t))t=t.substring(a.raw.length),e.push(a);else if(a=this.tokenizer.tag(t,i,n))t=t.substring(a.raw.length),i=a.inLink,n=a.inRawBlock,e.push(a);else if(a=this.tokenizer.link(t))t=t.substring(a.raw.length),"link"===a.type&&(a.tokens=this.inlineTokens(a.text,[],!0,n)),e.push(a);else if(a=this.tokenizer.reflink(t,this.tokens.links))t=t.substring(a.raw.length),"link"===a.type&&(a.tokens=this.inlineTokens(a.text,[],!0,n)),e.push(a);else if(a=this.tokenizer.strong(t,s,r))t=t.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],i,n),e.push(a);else if(a=this.tokenizer.em(t,s,r))t=t.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],i,n),e.push(a);else if(a=this.tokenizer.codespan(t))t=t.substring(a.raw.length),e.push(a);else if(a=this.tokenizer.br(t))t=t.substring(a.raw.length),e.push(a);else if(a=this.tokenizer.del(t))t=t.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],i,n),e.push(a);else if(a=this.tokenizer.autolink(t,Y))t=t.substring(a.raw.length),e.push(a);else if(i||!(a=this.tokenizer.url(t,Y))){if(a=this.tokenizer.inlineText(t,n,q))t=t.substring(a.raw.length),r=a.raw.slice(-1),e.push(a);else if(t){var c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}throw new Error(c)}}else t=t.substring(a.raw.length),e.push(a);return e},i=e,r=[{key:"rules",get:function(){return{block:W,inline:K}}}],(n=null)&&t(i.prototype,n),r&&t(i,r),e}(),$=n.defaults,Z=E,J=S,Q=function(){function t(t){this.options=t||$}var e=t.prototype;return e.code=function(t,e,i){var n=(e||"").match(/\S*/)[0];if(this.options.highlight){var r=this.options.highlight(t,n);null!=r&&r!==t&&(i=!0,t=r)}return n?'<pre><code class="'+this.options.langPrefix+J(n,!0)+'">'+(i?t:J(t,!0))+"</code></pre>\n":"<pre><code>"+(i?t:J(t,!0))+"</code></pre>\n"},e.blockquote=function(t){return"<blockquote>\n"+t+"</blockquote>\n"},e.html=function(t){return t},e.heading=function(t,e,i,n){return this.options.headerIds?"<h"+e+' id="'+this.options.headerPrefix+n.slug(i)+'">'+t+"</h"+e+">\n":"<h"+e+">"+t+"</h"+e+">\n"},e.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},e.list=function(t,e,i){var n=e?"ol":"ul";return"<"+n+(e&&1!==i?' start="'+i+'"':"")+">\n"+t+"</"+n+">\n"},e.listitem=function(t){return"<li>"+t+"</li>\n"},e.checkbox=function(t){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},e.paragraph=function(t){return"<p>"+t+"</p>\n"},e.table=function(t,e){return e&&(e="<tbody>"+e+"</tbody>"),"<table>\n<thead>\n"+t+"</thead>\n"+e+"</table>\n"},e.tablerow=function(t){return"<tr>\n"+t+"</tr>\n"},e.tablecell=function(t,e){var i=e.header?"th":"td";return(e.align?"<"+i+' align="'+e.align+'">':"<"+i+">")+t+"</"+i+">\n"},e.strong=function(t){return"<strong>"+t+"</strong>"},e.em=function(t){return"<em>"+t+"</em>"},e.codespan=function(t){return"<code>"+t+"</code>"},e.br=function(){return this.options.xhtml?"<br/>":"<br>"},e.del=function(t){return"<del>"+t+"</del>"},e.link=function(t,e,i){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return i;var n='<a href="'+J(t)+'"';return e&&(n+=' title="'+e+'"'),n+=">"+i+"</a>"},e.image=function(t,e,i){if(null===(t=Z(this.options.sanitize,this.options.baseUrl,t)))return i;var n='<img src="'+t+'" alt="'+i+'"';return e&&(n+=' title="'+e+'"'),n+=this.options.xhtml?"/>":">"},e.text=function(t){return t},t}(),tt=function(){function t(){}var e=t.prototype;return e.strong=function(t){return t},e.em=function(t){return t},e.codespan=function(t){return t},e.del=function(t){return t},e.html=function(t){return t},e.text=function(t){return t},e.link=function(t,e,i){return""+i},e.image=function(t,e,i){return""+i},e.br=function(){return""},t}(),et=function(){function t(){this.seen={}}return t.prototype.slug=function(t){var e=t.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(e)){var i=e;do{this.seen[i]++,e=i+"-"+this.seen[i]}while(this.seen.hasOwnProperty(e))}return this.seen[e]=0,e},t}(),it=n.defaults,nt=C,rt=function(){function t(t){this.options=t||it,this.options.renderer=this.options.renderer||new Q,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new tt,this.slugger=new et}t.parse=function(e,i){return new t(i).parse(e)};var e=t.prototype;return e.parse=function(t,e){void 0===e&&(e=!0);var i,n,r,a,o,s,l,c,u,h,d,f,p,m,g,v,y,b,x="",S=t.length;for(i=0;i<S;i++)switch((h=t[i]).type){case"space":continue;case"hr":x+=this.renderer.hr();continue;case"heading":x+=this.renderer.heading(this.parseInline(h.tokens),h.depth,nt(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue;case"code":x+=this.renderer.code(h.text,h.lang,h.escaped);continue;case"table":for(c="",l="",a=h.header.length,n=0;n<a;n++)l+=this.renderer.tablecell(this.parseInline(h.tokens.header[n]),{header:!0,align:h.align[n]});for(c+=this.renderer.tablerow(l),u="",a=h.cells.length,n=0;n<a;n++){for(l="",o=(s=h.tokens.cells[n]).length,r=0;r<o;r++)l+=this.renderer.tablecell(this.parseInline(s[r]),{header:!1,align:h.align[r]});u+=this.renderer.tablerow(l)}x+=this.renderer.table(c,u);continue;case"blockquote":u=this.parse(h.tokens),x+=this.renderer.blockquote(u);continue;case"list":for(d=h.ordered,f=h.start,p=h.loose,a=h.items.length,u="",n=0;n<a;n++)v=(g=h.items[n]).checked,y=g.task,m="",g.task&&(b=this.renderer.checkbox(v),p?g.tokens.length>0&&"text"===g.tokens[0].type?(g.tokens[0].text=b+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&"text"===g.tokens[0].tokens[0].type&&(g.tokens[0].tokens[0].text=b+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:b}):m+=b),m+=this.parse(g.tokens,p),u+=this.renderer.listitem(m,y,v);x+=this.renderer.list(u,d,f);continue;case"html":x+=this.renderer.html(h.text);continue;case"paragraph":x+=this.renderer.paragraph(this.parseInline(h.tokens));continue;case"text":for(u=h.tokens?this.parseInline(h.tokens):h.text;i+1<S&&"text"===t[i+1].type;)u+="\n"+((h=t[++i]).tokens?this.parseInline(h.tokens):h.text);x+=e?this.renderer.paragraph(u):u;continue;default:var C='Token with "'+h.type+'" type was not found.';if(this.options.silent)return void console.error(C);throw new Error(C)}return x},e.parseInline=function(t,e){e=e||this.renderer;var i,n,r="",a=t.length;for(i=0;i<a;i++)switch((n=t[i]).type){case"escape":r+=e.text(n.text);break;case"html":r+=e.html(n.text);break;case"link":r+=e.link(n.href,n.title,this.parseInline(n.tokens,e));break;case"image":r+=e.image(n.href,n.title,n.text);break;case"strong":r+=e.strong(this.parseInline(n.tokens,e));break;case"em":r+=e.em(this.parseInline(n.tokens,e));break;case"codespan":r+=e.codespan(n.text);break;case"br":r+=e.br();break;case"del":r+=e.del(this.parseInline(n.tokens,e));break;case"text":r+=e.text(n.text);break;default:var o='Token with "'+n.type+'" type was not found.';if(this.options.silent)return void console.error(o);throw new Error(o)}return r},t}(),at=T,ot=D,st=S,lt=n.getDefaults,ct=n.changeDefaults,ut=n.defaults;function ht(t,e,i){if(null==t)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");if("function"==typeof e&&(i=e,e=null),e=at({},ht.defaults,e||{}),ot(e),i){var n,r=e.highlight;try{n=X.lex(t,e)}catch(t){return i(t)}var a=function(t){var a;if(!t)try{a=rt.parse(n,e)}catch(e){t=e}return e.highlight=r,t?i(t):i(null,a)};if(!r||r.length<3)return a();if(delete e.highlight,!n.length)return a();var o=0;return ht.walkTokens(n,(function(t){"code"===t.type&&(o++,setTimeout((function(){r(t.text,t.lang,(function(e,i){if(e)return a(e);null!=i&&i!==t.text&&(t.text=i,t.escaped=!0),0==--o&&a()}))}),0))})),void(0===o&&a())}try{var s=X.lex(t,e);return e.walkTokens&&ht.walkTokens(s,e.walkTokens),rt.parse(s,e)}catch(t){if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"<p>An error occurred:</p><pre>"+st(t.message+"",!0)+"</pre>";throw t}}return ht.options=ht.setOptions=function(t){return at(ht.defaults,t),ct(ht.defaults),ht},ht.getDefaults=lt,ht.defaults=ut,ht.use=function(t){var e=at({},t);if(t.renderer&&function(){var i=ht.defaults.renderer||new Q,n=function(e){var n=i[e];i[e]=function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];var s=t.renderer[e].apply(i,a);return!1===s&&(s=n.apply(i,a)),s}};for(var r in t.renderer)n(r);e.renderer=i}(),t.tokenizer&&function(){var i=ht.defaults.tokenizer||new F,n=function(e){var n=i[e];i[e]=function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];var s=t.tokenizer[e].apply(i,a);return!1===s&&(s=n.apply(i,a)),s}};for(var r in t.tokenizer)n(r);e.tokenizer=i}(),t.walkTokens){var i=ht.defaults.walkTokens;e.walkTokens=function(e){t.walkTokens(e),i&&i(e)}}ht.setOptions(e)},ht.walkTokens=function(t,e){for(var n,r=i(t);!(n=r()).done;){var a=n.value;switch(e(a),a.type){case"table":for(var o,s=i(a.tokens.header);!(o=s()).done;){var l=o.value;ht.walkTokens(l,e)}for(var c,u=i(a.tokens.cells);!(c=u()).done;)for(var h,d=i(c.value);!(h=d()).done;){var f=h.value;ht.walkTokens(f,e)}break;case"list":ht.walkTokens(a.items,e);break;default:a.tokens&&ht.walkTokens(a.tokens,e)}}},ht.Parser=rt,ht.parser=rt.parse,ht.Renderer=Q,ht.TextRenderer=tt,ht.Lexer=X,ht.lexer=X.lex,ht.Tokenizer=F,ht.Slugger=et,ht.parse=ht,ht}()},ELLl:
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/edit/closebrackets.js ***!
|
|
|
\*************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){var e={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},i=t.Pos;function n(t,i){return"pairs"==i&&"string"==typeof t?t:"object"==typeof t&&null!=t[i]?t[i]:e[i]}t.defineOption("autoCloseBrackets",!1,(function(e,i,o){o&&o!=t.Init&&(e.removeKeyMap(r),e.state.closeBrackets=null),i&&(a(n(i,"pairs")),e.state.closeBrackets=i,e.addKeyMap(r))}));var r={Backspace:function(e){var r=s(e);if(!r||e.getOption("disableInput"))return t.Pass;for(var a=n(r,"pairs"),o=e.listSelections(),c=0;c<o.length;c++){if(!o[c].empty())return t.Pass;var u=l(e,o[c].head);if(!u||a.indexOf(u)%2!=0)return t.Pass}for(c=o.length-1;c>=0;c--){var h=o[c].head;e.replaceRange("",i(h.line,h.ch-1),i(h.line,h.ch+1),"+delete")}},Enter:function(e){var i=s(e),r=i&&n(i,"explode");if(!r||e.getOption("disableInput"))return t.Pass;for(var a=e.listSelections(),o=0;o<a.length;o++){if(!a[o].empty())return t.Pass;var c=l(e,a[o].head);if(!c||r.indexOf(c)%2!=0)return t.Pass}e.operation((function(){var t=e.lineSeparator()||"\n";e.replaceSelection(t+t,null),e.execCommand("goCharLeft"),a=e.listSelections();for(var i=0;i<a.length;i++){var n=a[i].head.line;e.indentLine(n,null,!0),e.indentLine(n+1,null,!0)}}))}};function a(t){for(var e=0;e<t.length;e++){var i=t.charAt(e),n="'"+i+"'";r[n]||(r[n]=o(i))}}function o(e){return function(r){return function(e,r){var a=s(e);if(!a||e.getOption("disableInput"))return t.Pass;var o=n(a,"pairs"),l=o.indexOf(r);if(-1==l)return t.Pass;for(var u,h=n(a,"closeBefore"),d=n(a,"triples"),f=o.charAt(l+1)==r,p=e.listSelections(),m=l%2==0,g=0;g<p.length;g++){var v,y=p[g],b=y.head,x=e.getRange(b,i(b.line,b.ch+1));if(m&&!y.empty())v="surround";else if(!f&&m||x!=r)if(f&&b.ch>1&&d.indexOf(r)>=0&&e.getRange(i(b.line,b.ch-2),b)==r+r){if(b.ch>2&&/\bstring/.test(e.getTokenTypeAt(i(b.line,b.ch-2))))return t.Pass;v="addFour"}else if(f){var S=0==b.ch?" ":e.getRange(i(b.line,b.ch-1),b);if(t.isWordChar(x)||S==r||t.isWordChar(S))return t.Pass;v="both"}else{if(!m||!(0===x.length||/\s/.test(x)||h.indexOf(x)>-1))return t.Pass;v="both"}else v=f&&c(e,b)?"both":d.indexOf(r)>=0&&e.getRange(b,i(b.line,b.ch+3))==r+r+r?"skipThree":"skip";if(u){if(u!=v)return t.Pass}else u=v}var C=l%2?o.charAt(l-1):r,k=l%2?r:o.charAt(l+1);e.operation((function(){if("skip"==u)e.execCommand("goCharRight");else if("skipThree"==u)for(var n=0;n<3;n++)e.execCommand("goCharRight");else if("surround"==u){var r=e.getSelections();for(n=0;n<r.length;n++)r[n]=C+r[n]+k;for(e.replaceSelections(r,"around"),r=e.listSelections().slice(),n=0;n<r.length;n++)r[n]=(a=r[n],o=void 0,o=t.cmpPos(a.anchor,a.head)>0,{anchor:new i(a.anchor.line,a.anchor.ch+(o?-1:1)),head:new i(a.head.line,a.head.ch+(o?1:-1))});e.setSelections(r)}else"both"==u?(e.replaceSelection(C+k,null),e.triggerElectric(C+k),e.execCommand("goCharLeft")):"addFour"==u&&(e.replaceSelection(C+C+C+C,"before"),e.execCommand("goCharRight"));var a,o}))}(r,e)}}function s(t){var e=t.state.closeBrackets;return!e||e.override?e:t.getModeAt(t.getCursor()).closeBrackets||e}function l(t,e){var n=t.getRange(i(e.line,e.ch-1),i(e.line,e.ch+1));return 2==n.length?n:null}function c(t,e){var n=t.getTokenAt(i(e.line,e.ch+1));return/\bstring/.test(n.type)&&n.start==e.ch&&(0==e.ch||!/\bstring/.test(t.getTokenTypeAt(e)))}a(e.pairs+"`")}(i(/*! ../../lib/codemirror */"VrN/"))},FOrL:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/assets/images/icons/nodata.png ***!
|
|
|
\********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports=i.p+"static/nodata.a6b3f948.png"},HmJG:
|
|
|
/*!****************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/upload-image/index.less ***!
|
|
|
\****************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},LdHM:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/rc-select/es/index.js + 6 modules ***!
|
|
|
\********************************************************/
|
|
|
/*! exports provided: Option, OptGroup, default */
|
|
|
/*! exports used: OptGroup, Option, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/typeof.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/TransBtn.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/generate.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/commonUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/valueUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/hooks/useMemo.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/pickAttrs.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-virtual-list/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i.d(e,"b",(function(){return S})),i.d(e,"a",(function(){return k}));var n=i("1OyB"),r=i("vuIU"),a=i("Ji7U"),o=i("LK+K"),s=i("q1tI"),l=i("rePB"),c=i("Ff2n"),u=i("ODXe"),h=i("4IlW"),d=i("bX4T"),f=i("YrtM"),p=i("TSYQ"),m=i.n(p),g=i("+nKL"),v=i("8OUc"),y=s.forwardRef((function(t,e){var i=t.prefixCls,n=t.id,r=t.flattenOptions,a=t.childrenAsData,o=t.values,p=t.searchValue,y=t.multiple,b=t.defaultActiveFirstOption,x=t.height,S=t.itemHeight,C=t.notFoundContent,k=t.open,E=t.menuItemSelectedIcon,w=t.virtual,T=t.onSelect,O=t.onToggleOpen,L=t.onActiveValue,A=t.onScroll,D=t.onMouseEnter,_="".concat(i,"-item"),R=Object(f.a)((function(){return r}),[k,r],(function(t,e){return e[0]&&t[1]!==e[1]})),I=s.useRef(null),M=function(t){t.preventDefault()},N=function(t){I.current&&I.current.scrollTo({index:t})},P=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=R.length,n=0;n<i;n+=1){var r=(t+n*e+i)%i,a=R[r],o=a.group,s=a.data;if(!o&&!s.disabled)return r}return-1},F=s.useState((function(){return P(0)})),j=Object(u.a)(F,2),B=j[0],U=j[1],H=function(t){U(t);var e=R[t];e?L(e.data.value,t):L(null,-1)};s.useEffect((function(){H(!1!==b?P(0):-1)}),[R.length,p]),s.useEffect((function(){var t=setTimeout((function(){if(!y&&k&&1===o.size){var t=Array.from(o)[0],e=R.findIndex((function(e){return e.data.value===t}));H(e),N(e)}}));return function(){return clearTimeout(t)}}),[k]);var G=function(t){void 0!==t&&T(t,{selected:!o.has(t)}),y||O(!1)};if(s.useImperativeHandle(e,(function(){return{onKeyDown:function(t){var e=t.which;switch(e){case h.a.UP:case h.a.DOWN:var i=0;if(e===h.a.UP?i=-1:e===h.a.DOWN&&(i=1),0!==i){var n=P(B+i,i);N(n),H(n)}break;case h.a.ENTER:var r=R[B];r&&!r.data.disabled?G(r.data.value):G(void 0),k&&t.preventDefault();break;case h.a.ESC:O(!1)}},onKeyUp:function(){},scrollTo:function(t){N(t)}}})),0===R.length)return s.createElement("div",{role:"listbox",id:"".concat(n,"_list"),className:"".concat(_,"-empty"),onMouseDown:M},C);function z(t){var e=R[t];if(!e)return null;var i=e.data||{},r=i.value,l=i.label,c=i.children,u=Object(d.a)(i,!0),h=a?c:l;return e?s.createElement("div",Object.assign({"aria-label":"string"==typeof h?h:null},u,{key:t,role:"option",id:"".concat(n,"_list_").concat(t),"aria-selected":o.has(r)}),r):null}return s.createElement(s.Fragment,null,s.createElement("div",{role:"listbox",id:"".concat(n,"_list"),style:{height:0,width:0,overflow:"hidden"}},z(B-1),z(B),z(B+1)),s.createElement(g.a,{itemKey:"key",ref:I,data:R,height:x,itemHeight:S,fullHeight:!1,onMouseDown:M,onScroll:A,virtual:w,onMouseEnter:D},(function(t,e){var i,n=t.group,r=t.groupOption,u=t.data,h=u.label,d=u.key;if(n)return s.createElement("div",{className:m()(_,"".concat(_,"-group"))},void 0!==h?h:d);var f=u.disabled,p=u.value,g=u.title,y=u.children,b=u.style,x=u.className,S=Object(c.a)(u,["disabled","value","title","children","style","className"]),C=o.has(p),k="".concat(_,"-option"),w=m()(_,k,x,(i={},Object(l.a)(i,"".concat(k,"-grouped"),r),Object(l.a)(i,"".concat(k,"-active"),B===e&&!f),Object(l.a)(i,"".concat(k,"-disabled"),f),Object(l.a)(i,"".concat(k,"-selected"),C),i)),T=a?y:h,O=!E||"function"==typeof E||C;return s.createElement("div",Object.assign({},S,{"aria-selected":C,className:w,title:g,onMouseMove:function(){B===e||f||H(e)},onClick:function(){f||G(p)},style:b}),s.createElement("div",{className:"".concat(k,"-content")},T||p),s.isValidElement(E)||C,O&&s.createElement(v.a,{className:"".concat(_,"-option-state"),customizeIcon:E,customizeIconProps:{isSelected:C}},C?"✓":null))})))}));y.displayName="OptionList";var b=y,x=function(){return null};x.isSelectOption=!0;var S=x,C=function(){return null};C.isSelectOptGroup=!0;var k=C,E=i("VTBJ"),w=i("Zm9Q");function T(t){var e=t.key,i=t.props,n=i.children,r=i.value,a=Object(c.a)(i,["children","value"]);return Object(E.a)({key:e,value:void 0!==r?r:e,children:n},a)}function O(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object(w.a)(t).map((function(t,i){if(!s.isValidElement(t)||!t.type)return null;var n=t.type.isSelectOptGroup,r=t.key,a=t.props,o=a.children,l=Object(c.a)(a,["children"]);return e||!n?T(t):Object(E.a)(Object(E.a)({key:"__RC_SELECT_GRP__".concat(null===r?i:r,"__"),label:r},l),{},{options:O(o)})})).filter((function(t){return t}))}var L=i("2Qr1"),A=i("qNPg"),D=i("U8pU"),_=i("Kwbf"),R=i("WKfj");var I=function(t){var e=t.mode,i=t.options,n=t.children,r=t.backfill,a=t.allowClear,o=t.placeholder,l=t.getInputElement,c=t.showSearch,u=t.onSearch,h=t.defaultOpen,d=t.autoFocus,f=t.labelInValue,p=t.value,m=t.inputValue,g=t.optionLabelProp,v="multiple"===e||"tags"===e,y=void 0!==c?c:v||"combobox"===e,b=i||O(n);if(Object(_.a)("tags"!==e||b.every((function(t){return!t.disabled})),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),"tags"===e||"combobox"===e){var x=b.some((function(t){return t.options?t.options.some((function(t){return"number"==typeof("value"in t?t.value:t.key)})):"number"==typeof("value"in t?t.value:t.key)}));Object(_.a)(!x,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(_.a)("combobox"!==e||!g,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(_.a)("combobox"===e||!r,"`backfill` only works with `combobox` mode."),Object(_.a)("combobox"===e||!l,"`getInputElement` only work with `combobox` mode."),Object(_.b)("combobox"!==e||!l||!a||!o,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),u&&!y&&"combobox"!==e&&"tags"!==e&&Object(_.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(_.b)(!h||d,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),null!=p){var S=Object(R.d)(p);Object(_.a)(!f||S.every((function(t){return"object"===Object(D.a)(t)&&("key"in t||"value"in t)})),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(_.a)(!v||Array.isArray(p),"`value` should be array when `mode` is `multiple` or `tags`")}if(n){var C=null;Object(w.a)(n).some((function(t){if(!s.isValidElement(t)||!t.type)return!1;var e=t.type;return!e.isSelectOption&&(e.isSelectOptGroup?!Object(w.a)(t.props.children).every((function(e){return!(s.isValidElement(e)&&t.type&&!e.type.isSelectOption)||(C=e.type,!1)})):(C=e,!0))})),C&&Object(_.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(C.displayName||C.name||C,"`.")),Object(_.a)(void 0===m,"`inputValue` is deprecated, please use `searchValue` instead.")}},M=Object(A.a)({prefixCls:"rc-select",components:{optionList:b},convertChildrenToData:O,flattenOptions:L.d,getLabeledValue:L.e,filterOptions:L.b,isValueDisabled:L.g,findValueOption:L.c,warningProps:I,fillOptionsWithMissingValue:L.a}),N=function(t){Object(a.a)(i,t);var e=Object(o.a)(i);function i(){var t;return Object(n.a)(this,i),(t=e.apply(this,arguments)).selectRef=s.createRef(),t.focus=function(){t.selectRef.current.focus()},t.blur=function(){t.selectRef.current.blur()},t}return Object(r.a)(i,[{key:"render",value:function(){return s.createElement(M,Object.assign({ref:this.selectRef},this.props))}}]),i}(s.Component);N.Option=S,N.OptGroup=k;var P=N;e.c=P},M8RZ:
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/components/modal.tsx ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return u}));var n=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/classCallCheck */"fWQN"),r=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createClass */"mtLc"),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/inherits */"yKVA"),o=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createSuper */"879j"),s=i(/*! react */"q1tI"),l=i.n(s),c=i(/*! react-dom */"i8i4"),u=function(t){Object(a.a)(i,t);var e=Object(o.a)(i);function i(t){var r;Object(n.a)(this,i),r=e.call(this,t);var a=window.document;return r.node=a.createElement("div"),a.body.appendChild(r.node),r}return Object(r.a)(i,[{key:"render",value:function(){var t=this.props.children;return Object(c.createPortal)(t,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),i}(l.a.Component)},NcEG:
|
|
|
/*!****************************************************************************!*\
|
|
|
!*** ./src/pages/User/Detail/Topics/Exercise/Detail/index.tsx + 6 modules ***!
|
|
|
\****************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/User/Detail/Topics/Exercise/Detail/components/editor.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/User/Detail/Topics/Exercise/Detail/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/.umi-production/core/umiExports.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/Editor/NullChildEditor/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/Editor/NullMDEditor.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/NoData/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/markdown-editor/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/service/exercise.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/service/polls.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/service/user.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/util.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/checkbox/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/checkbox/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/divider/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/divider/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/layout/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/layout/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/menu/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/menu/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/row/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/row/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tabs/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tabs/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router-dom/esm/react-router-dom.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router/esm/react-router.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i.r(e);i("+L6B");var n=i("2/Rp"),r=(i("5NDa"),i("5rEg")),a=(i("Znn+"),i("ZTPi")),o=(i("2qtc"),i("kLXV")),s=(i("14J3"),i("BMrR")),l=(i("jCWc"),i("kPKH")),c=(i("sPJy"),i("bE4q")),u=(i("/zsF"),i("PArb")),h=(i("miYZ"),i("tsqr")),d=i("9og8"),f=i("k1fw"),p=i("oBTY"),m=(i("y8nQ"),i("Vl3Y")),g=i("tJVT"),v=i("PpiC"),y=(i("B9cy"),i("Ol7k")),b=(i("lUTK"),i("BvKs")),x=i("WmNS"),S=i.n(x),C=i("q1tI"),k=i.n(C),E=i("Ty5D"),w=i("55Ip"),T=i("9kvl"),O=i("tgas"),L=i("jb+D"),A=i("BdwD"),D=(i("giR+"),i("fyUT")),_=(i("sRBo"),i("kaz8")),R=(i("5Dmo"),i("3S7+")),I=i("V0Rq"),M=i("Ot1p"),N=i("9Bee"),P=i("xvzu"),F=i.n(P),j=["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"],B=function(t,e){t.problemset,t.globalSetting,t.loading;var i=t.dispatch,r=(t.onRef,t.editData),a=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","onRef","editData"]),Object(C.useState)([])),c=Object(g.a)(a,2),u=c[0],m=c[1],y=Object(C.useState)(),b=Object(g.a)(y,2),x=b[0],w=b[1],T=Object(C.useState)([]),O=Object(g.a)(T,2),L=O[0],A=O[1],P=Object(C.useState)(""),B=Object(g.a)(P,2),U=B[0],H=B[1],G=Object(C.useState)(5),z=Object(g.a)(G,2),V=z[0],W=z[1],K=Object(C.useState)(!1),q=Object(g.a)(K,2),Y=q[0],X=q[1],$=Object(E.i)();Object(C.useEffect)((function(){m(["","","",""])}),[]),Object(C.useEffect)((function(){if(null!=r&&r.question_choices){H(null==r?void 0:r.question_title),W(parseInt(null==r?void 0:r.question_score)),m(null==r?void 0:r.question_choices.map((function(t){return t.choice_text})));var t=[];null==r||r.standard_answer.map((function(e,i){t.push(e-1)})),A(t)}else X(!0)}),[r]),Object(C.useImperativeHandle)(e,(function(){return{onSave:J,isEdit:Y}}));var Z,J=function(){var t=Object(d.a)(S.a.mark((function t(){var e,n,a;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(U){t.next=3;break}return h.b.info("请您输入题目"),t.abrupt("return",!1);case 3:if(!((e=u.findIndex((function(t){return!t})))>-1)){t.next=7;break}return h.b.info("请先输入 ".concat(j[e]," 选项的内容")),t.abrupt("return",!1);case 7:if(L.length){t.next=10;break}return h.b.info("请设置本题的正确答案,点击选项A/B...即可完成设置"),t.abrupt("return",!1);case 10:if(!(L.length<1)){t.next=13;break}return h.b.info("请选择答案"),t.abrupt("return",!1);case 13:if(n=u.map((function(t,e){return{choice_text:t,is_answer:L.includes(e)?e+1:0}})),!r.question_id){t.next=20;break}return t.next=17,i({type:"exercise/editExerciseQuestion",payload:{id:r.question_id,question_title:U,question_type:1,question_score:"5.0",question_choices:n.map((function(t){return t.choice_text})),standard_answers:n.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))}});case 17:a=t.sent,t.next=23;break;case 20:return t.next=22,i({type:"exercise/addExerciseQuestion",payload:{categoryId:$.categoryId,question_title:U,question_type:1,question_score:"5.0",question_choices:n.map((function(t){return t.choice_text})),standard_answers:n.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))}});case 22:a=t.sent;case 23:0===a.status&&(h.b.success("保存成功"),X(!1),i({type:"exercise/editExercise",payload:Object(f.a)({},$)}));case 24:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),Q=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],tt=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(I.m)({id:r.question_id});case 2:i({type:"exercise/editExercise",payload:Object(f.a)({},$)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,i({type:"exercise/exeriseMoveUpDown",payload:{id:r.question_id,opr:e.id}});case 7:return i({type:"exercise/editExercise",payload:Object(f.a)({},$)}),t.abrupt("break",11);case 9:return X(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!Y&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},r.key,"、多选题"),"(",r.question_score,"分)"),!r.hideAction&&Q.map((function(t,e){return"up"===t.id&&1===r.key||"down"===t.id&&r.key===r.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return tt(t)},className:t.icon}))}))),k.a.createElement("div",{className:"mt5"},k.a.createElement(N.a,{value:r.question_title})),k.a.createElement("div",{className:F.a.questionChoices},null==r||null===(Z=r.question_choices)||void 0===Z?void 0:Z.map((function(t,e){return k.a.createElement(s.a,null,k.a.createElement(l.a,null,k.a.createElement(_.a,{key:e,checked:r.standard_answer.includes(e+1),disabled:!0},j[e],".")),k.a.createElement(l.a,{flex:"1"},k.a.createElement("span",{className:"c-black font14"},k.a.createElement(N.a,{value:t.choice_text}))))})))),Y&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"选择题"),"(客观题,由系统自动评分,请设置标准答案)")),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"题干:")),k.a.createElement(M.a,{id:"single-question-title",watch:!0,height:155,placeholder:"请您输入题干",defaultValue:U,onChange:function(t){return H(t)}}),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"答案选项:",k.a.createElement("span",{className:F.a.colorGray},"点击选项可设置正确答案"))),u.map((function(t,e){return k.a.createElement("div",{className:F.a.choiceWrap,key:e},k.a.createElement(R.a,{title:"点击设置为标准答案",placement:"left"},k.a.createElement("div",{className:"".concat(F.a.answer," ").concat(L.includes(e)?F.a.activeAnswer:""),onClick:function(){L.includes(e)?A(L.filter((function(t){return t!==e}))):A([].concat(Object(p.a)(L),[e]))}},j[e])),k.a.createElement("div",{className:F.a.editorWrap},x===e?k.a.createElement(M.a,{id:"single-question-option-".concat(e),watch:!0,height:155,placeholder:"请您输入选项",defaultValue:t,onChange:function(t){u[e]=t,m(u)}}):k.a.createElement("div",{className:F.a.htmlWrap,onClick:function(){return w(e)}},k.a.createElement(N.a,{value:t}))),e>1&&k.a.createElement(R.a,{title:"删除"},k.a.createElement("i",{className:"".concat(F.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return m(u.filter((function(t,i){return i!==e})))}})),e<7&&e===u.length-1&&k.a.createElement(R.a,{title:"新增参考答案"},k.a.createElement("i",{className:"".concat(F.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return m([].concat(Object(p.a)(u),[""]))}})))})),k.a.createElement("p",{className:"c-orange"},"温馨提示:点击选项输入框可设置答案;选中的选项即为正确答案,选择多个答案即为多选题"),k.a.createElement("p",{className:""},"分值:",k.a.createElement(D.a,{value:V,max:1e4,min:-1,onChange:function(t){W(t)}})," 分"),k.a.createElement("aside",{className:"tr"},r.question_id&&k.a.createElement(n.a,{type:"default",onClick:function(){return X(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return J()}},"保存"))))},U=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(B)),H=(i("7Kak"),i("9yH6")),G=["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"],z=function(t,e){t.problemset,t.globalSetting,t.loading;var i=t.dispatch,r=(t.onRef,t.editData),a=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","onRef","editData"]),Object(C.useState)([])),c=Object(g.a)(a,2),u=c[0],m=c[1],y=Object(C.useState)(),b=Object(g.a)(y,2),x=b[0],w=b[1],T=Object(C.useState)([]),L=Object(g.a)(T,2),A=L[0],_=L[1],I=Object(C.useState)(""),P=Object(g.a)(I,2),j=P[0],B=P[1],U=Object(C.useState)(0),z=Object(g.a)(U,2),V=z[0],W=z[1],K=Object(C.useState)(!1),q=Object(g.a)(K,2),Y=q[0],X=q[1],$=Object(E.i)();Object(C.useEffect)((function(){m(["","","",""])}),[]),Object(C.useEffect)((function(){if(null!=r&&r.question_choices){B(null==r?void 0:r.question_title),W(parseInt(null==r?void 0:r.question_score)),m(null==r?void 0:r.question_choices.map((function(t){return t.choice_text})));var t=[];null==r||r.standard_answer.map((function(e,i){t.push(e-1)})),_(t)}else X(!0)}),[r]),Object(C.useImperativeHandle)(e,(function(){return{onSave:J,isEdit:Y}}));var Z,J=function(){var t=Object(d.a)(S.a.mark((function t(){var e,n,a;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(j){t.next=3;break}return h.b.info("请您输入题目"),t.abrupt("return",!1);case 3:if(!((e=u.findIndex((function(t){return!t})))>-1)){t.next=7;break}return h.b.info("请先输入 ".concat(G[e]," 选项的内容")),t.abrupt("return",!1);case 7:if(A.length){t.next=10;break}return h.b.info("请设置本题的正确答案,点击选项A/B...即可完成设置"),t.abrupt("return",!1);case 10:if(!(A.length<1)){t.next=13;break}return h.b.info("请选择答案"),t.abrupt("return",!1);case 13:if(n=u.map((function(t,e){return{choice_text:t,is_answer:A.includes(e)?e+1:0}})),!r.question_id){t.next=20;break}return t.next=17,Object(O.u)({id:r.question_id,question_title:j,question_type:1,question_score:V,question_choices:n.map((function(t){return t.choice_text})),standard_answers:n.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))});case 17:a=t.sent,t.next=23;break;case 20:return t.next=22,Object(O.a)({exercise_bank_id:$.topicId,question_title:j,question_type:1,question_score:"5.0",question_choices:n.map((function(t){return t.choice_text})),standard_answers:n.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))});case 22:a=t.sent;case 23:return 0===a.status&&(h.b.success("保存成功"),X(!1)),t.next=26,i({type:"polls/getExerciseBanks",payload:Object(f.a)({},$)});case 26:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),Q=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],tt=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(O.e)({pollsId:r.question_id});case 2:i({type:"polls/getExerciseBanks",payload:Object(f.a)({},$)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,Object(O.j)({exerciseId:null==r?void 0:r.question_id,opr:e.id});case 7:return i({type:"polls/getExerciseBanks",payload:Object(f.a)({},$)}),t.abrupt("break",11);case 9:return X(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!Y&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},r.key,"、单选题"),"(",r.question_score,"分)"),!r.hideAction&&Q.map((function(t,e){return"up"===t.id&&1===r.key||"down"===t.id&&r.key===r.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return tt(t)},className:t.icon}))}))),k.a.createElement("div",{className:"mt5"},k.a.createElement(N.a,{value:r.question_title})),k.a.createElement("div",{className:F.a.questionChoices},null==r||null===(Z=r.question_choices)||void 0===Z?void 0:Z.map((function(t,e){return k.a.createElement(s.a,null,k.a.createElement(l.a,null,k.a.createElement(H.a,{key:e,checked:r.standard_answer.includes(e+1),disabled:!0},G[e],".")),k.a.createElement(l.a,{flex:"1"},k.a.createElement("span",{className:"c-black font14"},k.a.createElement(N.a,{value:t.choice_text}))))})))),Y&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"选择题"),"(客观题,由系统自动评分,请设置标准答案)")),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"题干:")),k.a.createElement(M.a,{id:"single-question-title",watch:!0,height:155,placeholder:"请您输入题干",defaultValue:j,onChange:function(t){return B(t)}}),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"答案选项:",k.a.createElement("span",{className:F.a.colorGray},"点击选项可设置正确答案"))),u.map((function(t,e){return k.a.createElement("div",{className:F.a.choiceWrap,key:e},k.a.createElement(R.a,{title:"点击设置为标准答案",placement:"left"},k.a.createElement("div",{className:"".concat(F.a.answer," ").concat(A.includes(e)?F.a.activeAnswer:""),onClick:function(){A.includes(e)?_(A.filter((function(t){return t!==e}))):_([].concat(Object(p.a)(A),[e]))}},G[e])),k.a.createElement("div",{className:F.a.editorWrap},x===e?k.a.createElement(M.a,{id:"single-question-option-".concat(e),watch:!0,height:155,placeholder:"请您输入选项",defaultValue:t,onChange:function(t){u[e]=t,m(u)}}):k.a.createElement("div",{className:F.a.htmlWrap,onClick:function(){return w(e)}},k.a.createElement(N.a,{value:t}))),e>1&&k.a.createElement(R.a,{title:"删除"},k.a.createElement("i",{className:"".concat(F.a.deleteIcon," iconfont icon-htmal5icon19"),onClick:function(){return m(u.filter((function(t,i){return i!==e})))}})),e<7&&e===u.length-1&&k.a.createElement(R.a,{title:"新增参考答案"},k.a.createElement("i",{className:"".concat(F.a.addIcon," iconfont icon-roundaddfill ml6"),onClick:function(){return m([].concat(Object(p.a)(u),[""]))}})))})),k.a.createElement("p",{className:"c-orange"},"温馨提示:点击选项输入框可设置答案;选中的选项即为正确答案,选择多个答案即为多选题"),k.a.createElement("p",{className:""},"分值:",k.a.createElement(D.a,{value:V,max:1e4,min:-1,onChange:function(t){W(t)}})," 分"),k.a.createElement("aside",{className:"tr"},r.question_id&&k.a.createElement(n.a,{type:"default",onClick:function(){return X(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return J()}},"保存"))))},V=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(z)),W=["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"],K=function(t,e){t.problemset,t.globalSetting,t.loading;var i=t.dispatch,r=(t.onRef,t.editData),a=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","onRef","editData"]),Object(C.useState)()),s=Object(g.a)(a,2),l=s[0],c=s[1],u=Object(C.useState)(""),p=Object(g.a)(u,2),m=p[0],y=p[1],b=Object(C.useState)(!1),x=Object(g.a)(b,2),w=x[0],T=x[1],L=Object(C.useState)(5),A=Object(g.a)(L,2),_=A[0],I=A[1],N=Object(E.i)();Object(C.useEffect)((function(){null!=r&&r.question_choices?(y(null==r?void 0:r.question_title),I(null==r?void 0:r.question_score),c(r.standard_answer[0]+"")):T(!0)}),[r]),Object(C.useImperativeHandle)(e,(function(){return{onSave:j,isEdit:w}}));var P,j=function(){var t=Object(d.a)(S.a.mark((function t(){var e,n;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(m){t.next=3;break}return h.b.info("请您输入题干"),t.abrupt("return",!1);case 3:if(l){t.next=6;break}return h.b.info("请先点击选择本选择题的正确选项"),t.abrupt("return",!1);case 6:if(e=[{choice_text:"正确",is_answer:"1"===l?1:0},{choice_text:"错误",is_answer:"2"===l?2:0}],!r.question_id){t.next=13;break}return t.next=10,Object(O.u)({id:r.question_id,question_title:m,question_type:2,question_score:_,question_choices:e.map((function(t){return t.choice_text})),standard_answers:e.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))});case 10:n=t.sent,t.next=16;break;case 13:return t.next=15,Object(O.a)({exercise_bank_id:N.topicId,question_title:m,question_type:2,question_score:_,question_choices:e.map((function(t){return t.choice_text})),standard_answers:e.filter((function(t){return t.is_answer})).map((function(t){return t.is_answer}))});case 15:n=t.sent;case 16:return 0===n.status&&(h.b.success("保存成功"),T(!1)),i({type:"polls/getExerciseBanks",payload:Object(f.a)({},N)}),t.abrupt("return",{name:m,choices:e});case 19:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),B=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],U=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(O.e)({pollsId:r.question_id});case 2:i({type:"polls/getExerciseBanks",payload:Object(f.a)({},N)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,Object(O.j)({exerciseId:null==r?void 0:r.question_id,opr:e.id});case 7:return i({type:"polls/getExerciseBanks",payload:Object(f.a)({},N)}),t.abrupt("break",11);case 9:return T(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!w&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},r.key,"、判断题"),"(",r.question_score,"分)"),!r.hideAction&&B.map((function(t,e){return"up"===t.id&&1===r.key||"down"===t.id&&r.key===r.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return U(t)},className:t.icon}))}))),k.a.createElement("div",{className:"mt5"},r.question_title),k.a.createElement("div",{className:F.a.questionChoices},null==r||null===(P=r.question_choices)||void 0===P?void 0:P.map((function(t,e){return k.a.createElement(H.a,{key:e,checked:r.standard_answer.includes(e+1),disabled:!0},W[e],". ",k.a.createElement("span",{className:"c-black font14"},t.choice_text))})))),w&&k.a.createElement("aside",null,k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"判断题"),"(客观题,由系统自动评分,请设置标准答案)"),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"题干:")),k.a.createElement(M.a,{id:"single-question-title",watch:!0,height:155,placeholder:"请您输入题干",defaultValue:m,onChange:function(t){return y(t)}}),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.required},"*"),k.a.createElement("span",{className:F.a.title},"答案选项:",k.a.createElement("span",{className:F.a.colorGray},"点击选项可设置正确答案"))),k.a.createElement(H.a.Group,{buttonStyle:"solid",value:l,onChange:function(t){return c(t.target.value)}},k.a.createElement(H.a.Button,{value:"1",className:"".concat(F.a.radio," mr40")},"正确"),k.a.createElement(H.a.Button,{value:"2",className:F.a.radio},"错误")),k.a.createElement("p",{className:"c-orange"},"温馨提示:点击选项,可以直接设置标准答案"),k.a.createElement("p",{className:""},"分值:",k.a.createElement(D.a,{value:_,max:1e4,min:-1,onChange:function(t){I(t)}})," 分"),k.a.createElement("aside",{className:"tr"},r.question_id&&k.a.createElement(n.a,{type:"default",onClick:function(){return T(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return j()}},"保存"))))},q=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(K)),Y=i("kqOp"),X=i("7qnI"),$=i("1vsH"),Z=function(t,e){var i=t.problemset,a=(t.globalSetting,t.loading,t.dispatch),c=t.editData,u=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","editData"]),Object(C.useState)("")),m=Object(g.a)(u,2),y=m[0],b=m[1],x=Object(C.useState)(""),w=Object(g.a)(x,2),T=w[0],L=(w[1],Object(C.useState)([])),A=Object(g.a)(L,2),I=A[0],M=A[1],N=Object(C.useState)(""),P=Object(g.a)(N,2),j=P[0],B=P[1],U=Object(C.useState)(),H=Object(g.a)(U,2),G=H[0],z=H[1],V=Object(C.useState)(!1),W=Object(g.a)(V,2),K=W[0],q=W[1],Z=Object(C.useState)(5),J=Object(g.a)(Z,2),Q=J[0],tt=J[1],et=Object(C.useState)(!1),it=Object(g.a)(et,2),nt=it[0],rt=it[1],at=Object(E.i)();Object(C.useEffect)((function(){if(null!=c&&c.question_title){b(null==c?void 0:c.question_title),z(null==c?void 0:c.is_ordered),tt(null==c?void 0:c.question_score);var t=null==c?void 0:c.standard_answer.map((function(t){return t.answer_text}));M(t)}else rt(!0)}),[i.editData]),Object(C.useEffect)((function(){q(!1)}),[nt]),Object(C.useImperativeHandle)(e,(function(){return{onSave:st,isEdit:nt}}));var ot,st=function(){var t=Object(d.a)(S.a.mark((function t(){var e,i,n;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=[],i=!1,I.forEach((function(t,n){e.push({choice_id:n+1,answer_text:[]}),t.forEach((function(t,r){e[n].answer_text.push(t),t&&Object($.Z)(t,1e4)||(B("".concat(n,"-").concat(r)),h.b.info(t?"答案不能超过10000字符":"答案:不能为空"),i=!0)}))})),!i){t.next=5;break}return t.abrupt("return",!1);case 5:if(!c.question_id){t.next=11;break}return t.next=8,Object(O.u)({id:c.question_id,question_title:y,question_type:3,question_score:Q,is_ordered:G,standard_answers:e});case 8:n=t.sent,t.next=14;break;case 11:return t.next=13,Object(O.a)({exercise_bank_id:at.topicId,question_title:y,question_type:3,question_score:Q,is_ordered:G,standard_answers:e});case 13:n=t.sent;case 14:return 0===n.status&&(h.b.success("保存成功"),rt(!1)),a({type:"polls/getExerciseBanks",payload:Object(f.a)({},at)}),t.abrupt("return",{name:y,analysis:T,standard_answers:e,is_ordered:G});case 17:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),lt=function(t,e,i){var n=I.slice();if(e&&n.splice(t,e),i&&K)for(var r=0;r<i;r++)n.splice(t+r,0,[""]);q(!0),M(n)},ct=function(t,e,i){B("");var n=I.slice();n[t][e]=i,M(n)},ut=function(t){var e=I.slice();e[t]=[].concat(Object(p.a)(e[t]),[""]),M(e)},ht=function(t,e){var i=I.slice();if(!i[t][e])return i[t]=i[t].filter((function(t,i){return i!==e})),void M(i);o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"提示",content:"确认要删除这个参考答案吗?",className:F.a.modal,onOk:function(){i[t]=i[t].filter((function(t,i){return i!==e})),M(i)}})},dt=function(t){o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"提示",content:"确认要删除这个参考答案吗?",className:F.a.modal,onOk:function(){var e=I.slice();e=I.filter((function(e,i){return t!==i})),M(e)}})},ft=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],pt=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(O.e)({pollsId:c.question_id});case 2:a({type:"polls/getExerciseBanks",payload:Object(f.a)({},at)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,Object(O.j)({exerciseId:null==c?void 0:c.question_id,opr:e.id});case 7:return a({type:"polls/getExerciseBanks",payload:Object(f.a)({},at)}),t.abrupt("break",11);case 9:return rt(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!nt&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},c.key,"、填空题"),"(",c.question_score,"分)"),!c.hideAction&&ft.map((function(t,e){return"up"===t.id&&1===c.key||"down"===t.id&&c.key===c.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return pt(t)},className:t.icon}))}))),k.a.createElement("div",{className:"mt5"},c.question_title),k.a.createElement("div",{className:F.a.questionChoices},null==c||null===(ot=c.standard_answer)||void 0===ot?void 0:ot.map((function(t,e){return k.a.createElement(s.a,null,k.a.createElement(l.a,null,"答案(填空",t.choice_id,"):"),k.a.createElement(l.a,{flex:"1"},k.a.createElement(r.a,{key:e,checked:c.standard_answer.includes(e),disabled:!0,value:t.answer_text})))})))),nt&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"填空题"),"(客观题,由系统自动评分,允许手动调分,请设置标准答案 ;支持最多5个空,每空得分按照本题的总分平均计算)")),k.a.createElement("div",null,k.a.createElement(Y.a,{id:"completion-question-tittle",placeholder:"请您输入题目",height:155,defaultValue:y,onChange:function(t){return b(t)},showNullButton:!0,onPlaceholderChange:lt})),k.a.createElement("div",{className:"mt20"},I.map((function(t,e){return k.a.createElement(X.a,{key:e,answers:t,index:e,is_md:!0,activeOptionErrorIndex:j,onAnswerChange:ct,addChildAnswer:ut,deleteChildAnswer:ht,deleteChildAnswermain:dt})}))),k.a.createElement("div",{className:"mt20"},I.length>1&&k.a.createElement("span",null,k.a.createElement(_.a,{checked:G,onChange:function(t){return z(t.target.checked)},className:"".concat(F.a.color333," font14")},"多个填空的答案有顺序要求"),k.a.createElement("span",{className:"".concat(F.a.color999," font12")},"(选中,每个填空的答案顺序必须与参考答案一致)"))),k.a.createElement("p",{className:""},"分值:",k.a.createElement(D.a,{value:Q,max:1e4,min:-1,onChange:function(t){tt(t)}})," 分"),k.a.createElement("aside",{className:"tr"},c.question_id&&k.a.createElement(n.a,{type:"default",onClick:function(){return rt(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return st()}},"保存"))))},J=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(Z)),Q=function(t,e){var i=t.problemset,r=(t.globalSetting,t.loading,t.dispatch),a=(t.onRef,t.editData),s=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","onRef","editData"]),Object(C.useState)("")),l=Object(g.a)(s,2),c=l[0],u=l[1],p=Object(C.useState)(""),m=Object(g.a)(p,2),y=m[0],b=(m[1],Object(C.useState)("")),x=Object(g.a)(b,2),w=x[0],T=x[1],L=Object(C.useState)(5),A=Object(g.a)(L,2),_=A[0],I=A[1],P=Object(C.useState)(!1),j=Object(g.a)(P,2),B=j[0],U=j[1],H=Object(E.i)();Object(C.useEffect)((function(){var t;null!=a&&a.question_title?(u(null==a?void 0:a.question_title),T(null==a||null===(t=a.standard_answer)||void 0===t?void 0:t[0]),I(null==a?void 0:a.question_score)):U(!0)}),[i.editData]),Object(C.useImperativeHandle)(e,(function(){return{onSave:G,isEdit:B}}));var G=function(){var t=Object(d.a)(S.a.mark((function t(){var e;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c){t.next=3;break}return h.b.info("请您输入题干"),t.abrupt("return",!1);case 3:if(!a.question_id){t.next=9;break}return t.next=6,Object(O.u)({id:a.question_id,question_title:c,question_type:4,question_score:_,standard_answers:[w]});case 6:e=t.sent,t.next=12;break;case 9:return t.next=11,Object(O.a)({exercise_bank_id:H.topicId,question_title:c,question_type:4,question_score:_,standard_answers:[w]});case 11:e=t.sent;case 12:return 0===e.status&&(h.b.success("保存成功"),U(!1),r({type:"polls/getExerciseBanks",payload:Object(f.a)({},H)})),t.abrupt("return",{name:c,answer_texts:[w],analysis:y});case 14:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),z=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],V=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(O.e)({pollsId:a.question_id});case 2:r({type:"polls/getExerciseBanks",payload:Object(f.a)({},H)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,Object(O.j)({exerciseId:null==a?void 0:a.question_id,opr:e.id});case 7:return r({type:"polls/getExerciseBanks",payload:Object(f.a)({},H)}),t.abrupt("break",11);case 9:return U(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!B&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},a.key,"、简答题"),"(",a.question_score,"分)"),!a.hideAction&&z.map((function(t,e){return"up"===t.id&&1===a.key||"down"===t.id&&a.key===a.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return V(t)},className:t.icon}))}))),k.a.createElement("div",{className:"mt5"},a.question_title),k.a.createElement("div",{className:F.a.questionChoices},k.a.createElement("p",null,k.a.createElement("strong",null,"参考答案:")),k.a.createElement(N.a,{value:w}))),B&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"简答题"),"(主观题,未作答的情况下自动评为零分)")),k.a.createElement(M.a,{id:"single-question-title",watch:!0,height:155,placeholder:"请您输入题干",defaultValue:c,onChange:function(t){return u(t)}}),k.a.createElement("p",{className:F.a.titleWrap},k.a.createElement("span",{className:F.a.title},"参考答案:")),k.a.createElement(M.a,{id:"single-question-reference-answer",watch:!0,height:155,placeholder:"请您输入参考答案",defaultValue:w,onChange:function(t){return T(t)}}),k.a.createElement("p",{className:""},"分值:",k.a.createElement(D.a,{value:_,max:1e4,min:-1,onChange:function(t){I(t)}})," 分"),k.a.createElement("aside",{className:"tr"},a.question_id&&k.a.createElement(n.a,{type:"default",onClick:function(){return U(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return G()}},"保存"))))},tt=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(Q)),et=function(t,e){t.problemset,t.globalSetting,t.loading;var i=t.dispatch,a=t.editData,c=(Object(v.a)(t,["problemset","globalSetting","loading","dispatch","editData"]),Object(C.useState)("")),u=Object(g.a)(c,2),p=u[0],m=u[1],y=Object(C.useState)(""),b=Object(g.a)(y,2),x=b[0],T=b[1],L=Object(C.useState)(""),A=Object(g.a)(L,2),I=A[0],N=(A[1],Object(C.useState)([])),P=Object(g.a)(N,2),j=P[0],B=(P[1],Object(C.useState)("")),U=Object(g.a)(B,2),H=(U[0],U[1],Object(C.useState)()),G=Object(g.a)(H,2),z=G[0],V=G[1],W=Object(C.useState)(!1),K=Object(g.a)(W,2),q=(K[0],K[1]),Y=Object(C.useState)([]),X=Object(g.a)(Y,2),$=X[0],Z=X[1],J=Object(C.useState)(!1),Q=Object(g.a)(J,2),tt=Q[0],et=Q[1],it=Object(E.i)();Object(C.useEffect)((function(){var t;a.edit&&et(!0),m(a.shixun_name),T(a.question_title);var e=[];null===(t=a.shixun)||void 0===t||t.map((function(t){e.push(t.challenge_score)})),Z(e)}),[a]),Object(C.useEffect)((function(){q(!1)}),[tt]),Object(C.useImperativeHandle)(e,(function(){return{onSave:at,isEdit:tt}}));var nt,rt,at=function(){var t=Object(d.a)(S.a.mark((function t(){var e,n;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],!1,t.next=4;break;case 4:if(!a.question_id){t.next=10;break}return t.next=7,Object(O.u)({id:a.question_id,question_title:x,shixun_name:p,shixun_id:a.shixun_id,question_type:5,question_scores:$});case 7:n=t.sent,t.next=13;break;case 10:return t.next=12,Object(O.a)({exercise_bank_id:it.topicId,question_title:x,shixun_name:p,shixun_id:a.shixun_id,question_type:5,question_scores:$});case 12:n=t.sent;case 13:return 0===n.status&&(h.b.success("保存成功"),et(!1)),t.next=16,i({type:"polls/getExerciseBanks",payload:Object(f.a)({},it)});case 16:return t.abrupt("return",{name:x,analysis:I,standard_answers:e,is_ordered:z});case 17:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),ot=[{name:"删除",icon:"iconfont c-light-black ml30 icon-shanchu",id:"del"},{name:"上移",icon:"iconfont c-green ml30 icon-shangyi_Hover",id:"up"},{name:"下移",icon:"iconfont c-green ml30 icon-xiayi_moren",id:"down"},{name:"编辑",icon:"iconfont c-green ml30 icon-bianjishijuan3x",id:"edit"}],st=function(){var t=Object(d.a)(S.a.mark((function t(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.id,t.next="del"===t.t0?3:"up"===t.t0||"down"===t.t0?5:"edit"===t.t0?9:11;break;case 3:return o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"确认要删除这个问题吗?",onOk:function(){return Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(O.e)({pollsId:a.question_id});case 2:i({type:"polls/getExerciseBanks",payload:Object(f.a)({},it)});case 3:case"end":return t.stop()}}),t)})))()}}),t.abrupt("break",11);case 5:return t.next=7,Object(O.j)({exerciseId:null==a?void 0:a.question_id,opr:e.id});case 7:return i({type:"polls/getExerciseBanks",payload:Object(f.a)({},it)}),t.abrupt("break",11);case 9:return et(!0),t.abrupt("break",11);case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:F.a.wrap},!tt&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},a.key,"、实训题"),"(",a.question_score,"分)"),k.a.createElement("div",{className:"tr"},k.a.createElement(w.a,{target:"_blank",to:"/shixuns/".concat(a.shixun_identifier,"/challenges")},"实训详情"),!a.hideAction&&ot.map((function(t,e){return"up"===t.id&&1===a.key||"down"===t.id&&a.key===a.len?null:k.a.createElement(R.a,{key:e,placement:"bottom",title:t.name},k.a.createElement("span",{onClick:function(){return st(t)},className:t.icon}))})))),k.a.createElement("div",{className:"font16"},a.shixun_name),k.a.createElement("div",{className:"mt30"}),null===(rt=a.shixun)||void 0===rt?void 0:rt.map((function(t,e){return k.a.createElement("div",{key:e},"第",e+1,"关 ",k.a.createElement("span",{className:"ml10"},t.challenge_name)," ",k.a.createElement("span",{className:"ml10"},t.challenge_score))}))),tt&&k.a.createElement("aside",null,k.a.createElement("div",{className:F.a.questionType},k.a.createElement("div",null,k.a.createElement("span",{className:"font16 c-blue"},"实训题"),"(客观题,由系统自动评分,允许手动调分)")),k.a.createElement("div",{className:"mt10"},k.a.createElement(r.a,{defaultValue:p,onChange:function(t){m(t.target.value)}})),k.a.createElement("div",{className:"mt10"},k.a.createElement(M.a,{id:"single-question-option-0",height:155,placeholder:"请输入实训题完成要求",defaultValue:x,onChange:function(t){T(t)}})),k.a.createElement("div",{className:"mt20"},null===(nt=a.shixun)||void 0===nt?void 0:nt.map((function(t,e){return k.a.createElement(s.a,{gutter:[20,20]},k.a.createElement(l.a,{flex:"1"},e+1,".",t.challenge_name),k.a.createElement(l.a,null,k.a.createElement(D.a,{defaultValue:$[e],onChange:function(t){$[e]=t,Z($),console.log("srore:L",$[e])}})))}))),k.a.createElement("div",{className:"mt20"},j.length>1&&k.a.createElement("span",null,k.a.createElement(_.a,{checked:z,onChange:function(t){return V(t.target.checked)},className:"".concat(F.a.color333," font14")},"多个填空的答案有顺序要求"),k.a.createElement("span",{className:"".concat(F.a.color999," font12")},"(选中,每个填空的答案顺序必须与参考答案一致)"))),k.a.createElement("aside",{className:"tr"},!(null!=a&&a.edit)&&k.a.createElement(n.a,{type:"default",onClick:function(){return et(!1)}},"取消"),k.a.createElement(n.a,{className:"ml20",type:"primary",onClick:function(){return at()}},"保存"))))},it=Object(T.a)((function(t){var e=t.problemset,i=t.loading;return{problemset:e,globalSetting:t.globalSetting,loading:i.effects}}),null,null,{forwardRef:!0})(Object(C.forwardRef)(et)),nt=i("UU91"),rt=i.n(nt),at=i("fJjg");b.a.SubMenu,y.a.Content,y.a.Sider,e.default=Object(T.a)((function(t){var e=t.polls,i=t.loading,n=t.user;return{polls:e,globalSetting:t.globalSetting,user:n,loading:i.effects}}))((function(t){var e,i,h,y,b,x,D,_,R,I,M,N,P,F,j,B,H,G,z,W,K,Y,X,Z,Q,et,nt,ot,st,lt,ct,ut,ht,dt,ft,pt,mt,gt,vt,yt,bt,xt,St,Ct,kt,Et,wt,Tt,Ot,Lt,At,Dt,_t,Rt,It,Mt,Nt,Pt=t.polls,Ft=(t.globalSetting,t.loading,t.user),jt=t.dispatch,Bt=(Object(v.a)(t,["polls","globalSetting","loading","user","dispatch"]),Object(E.i)()),Ut=(Object(E.h)(),Ft.userInfo),Ht=m.a.useForm(),Gt=Object(g.a)(Ht,1)[0],zt=Object(C.useState)([]),Vt=Object(g.a)(zt,2),Wt=Vt[0],Kt=Vt[1],qt=Object(C.useState)(!1),Yt=Object(g.a)(qt,2),Xt=Yt[0],$t=Yt[1],Zt=Object(C.useRef)();Object(C.useEffect)((function(){var t,e,i,n,r,a;null!==(t=Pt.exerciseBanks)&&void 0!==t&&t.exercise_questions&&(Kt(Object(p.a)(null===(e=Pt.exerciseBanks)||void 0===e?void 0:e.exercise_questions)),Gt.setFieldsValue({exercise_name:null===(i=Pt.exerciseBanks)||void 0===i||null===(n=i.exercise)||void 0===n?void 0:n.exercise_name,exercise_description:null===(r=Pt.exerciseBanks)||void 0===r||null===(a=r.exercise)||void 0===a?void 0:a.exercise_description}))}),[Pt.exerciseBanks]),Object(C.useEffect)((function(){jt({type:"polls/getExerciseBanks",payload:Object(f.a)({},Bt)})}),[Bt.categoryId]);var Jt=function(){var t=Object(d.a)(S.a.mark((function t(){var e,i,n;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Gt.validateFields();case 2:return(n=Gt.getFieldValue()).is_md=!0,n.topicId=null===(e=Pt.exerciseBanks)||void 0===e||null===(i=e.exercise)||void 0===i?void 0:i.id,$t(!1),t.next=8,Object(O.v)(Object(f.a)({},n));case 8:jt({type:"polls/getExerciseBanks",payload:Object(f.a)({},Bt)});case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return k.a.createElement("section",{className:"edu-container"},k.a.createElement("section",{className:"animated fadeIn"},k.a.createElement("aside",{className:"mt10"},Ut&&k.a.createElement(c.a,{separator:">"},k.a.createElement(c.a.Item,null,k.a.createElement(w.a,{to:"/users/".concat(Bt.username,"/").concat("personal"===Bt.topictype?"topics":"topicbank","/").concat(Bt.topictype)},"personal"===Bt.topictype?"我的题库":"公共题库")),k.a.createElement(c.a.Item,null,"详情"))),k.a.createElement("aside",{className:[rt.a.title,"mt20"].join(" ")},k.a.createElement(s.a,{style:{width:"100%"},align:"middle"},k.a.createElement(l.a,{flex:"1"},k.a.createElement("strong",{className:"font20 ml5"},null===(e=Pt.exerciseBanks)||void 0===e||null===(i=e.exercise)||void 0===i?void 0:i.exercise_name),k.a.createElement($.k,{status:[null!==(h=Pt.exerciseBanks)&&void 0!==h&&null!==(y=h.exercise)&&void 0!==y&&y.is_public?"公开":"私有"]})),k.a.createElement(l.a,null,k.a.createElement(w.a,{className:"font16 c-light-black",to:"/users/".concat(Ut.login,"/topics/").concat(Bt.topictype)},"返回"))))),k.a.createElement("section",{className:[rt.a.bg,"pl30","pr30","pb30","mt20 relative"].join(" ")},k.a.createElement("div",{className:rt.a.export},(null===(b=Pt.exerciseBanks)||void 0===b?void 0:b.authorize)&&k.a.createElement(k.a.Fragment,null,k.a.createElement("a",{onClick:function(t){var e;t.preventDefault(),o.a.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"提示",content:"是否确认删除?",onOk:(e=Object(d.a)(S.a.mark((function t(){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(L.j)({object_type:"normal",object_id:[Bt.topicId]});case 2:0===t.sent.status&&T.d.push("/users/".concat(Bt.username,"/topics/personal"));case 4:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)})})}},"删除"),k.a.createElement(w.a,{to:"/users/".concat(Ut.login,"/topics/").concat(Bt.topicId,"/").concat(Bt.topictype,"/exercise/edit")},"编辑")),k.a.createElement("a",{onClick:function(t){t.preventDefault(),jt({type:"userDetail/setActionTabs",payload:{key:"UserDetail-SendToClass",params:{object_id:[Bt.topicId],object_type:"exercise"}}})}},"发送")),k.a.createElement(a.a,{className:rt.a.tabs},k.a.createElement(a.a.TabPane,{tab:k.a.createElement("span",{className:"font16 pt10 pb12"},"内容详情"),key:"1"},k.a.createElement("div",{className:"c-light-black"},null===(x=Pt.exerciseBanks)||void 0===x||null===(D=x.exercise)||void 0===D?void 0:D.exercise_description))),Xt&&k.a.createElement(m.a,{layout:"vertical",form:Gt},k.a.createElement(m.a.Item,{name:"exercise_name",label:"试卷标题:",rules:[{required:!0,message:"请填写试卷标题"}]},k.a.createElement(r.a,{maxLength:60,placeholder:"试卷标题,最大限制60个字符"})),k.a.createElement(m.a.Item,{label:"试卷须知:",name:"exercise_description"},k.a.createElement(r.a.TextArea,{rows:6,placeholder:"请在此输入本次试卷答题的相关说明,最大限制100个字符"})),k.a.createElement(m.a.Item,{className:"tr"},k.a.createElement(n.a,{type:"primary",onClick:function(){Jt()}},"保存")))),k.a.createElement("p",{className:"mt10",style:{display:"flex"}},k.a.createElement("span",{className:"fl",style:{flex:"1"}},!(null===(_=Pt.exerciseBanks)||void 0===_||null===(R=_.exercise_types)||void 0===R||!R.q_singles)&&k.a.createElement("span",{className:"ml20"},"单选题",null===(I=Pt.exerciseBanks)||void 0===I||null===(M=I.exercise_types)||void 0===M?void 0:M.q_singles,"题,共",null===(N=Pt.exerciseBanks)||void 0===N||null===(P=N.exercise_types)||void 0===P?void 0:P.q_singles_scores,"分"),!(null===(F=Pt.exerciseBanks)||void 0===F||null===(j=F.exercise_types)||void 0===j||!j.q_doubles)&&k.a.createElement("span",{className:"ml20"},"多选题",null===(B=Pt.exerciseBanks)||void 0===B||null===(H=B.exercise_types)||void 0===H?void 0:H.q_doubles,"题,共",null===(G=Pt.exerciseBanks)||void 0===G||null===(z=G.exercise_types)||void 0===z?void 0:z.q_doubles_scores,"分"),!(null===(W=Pt.exerciseBanks)||void 0===W||null===(K=W.exercise_types)||void 0===K||!K.q_judges)&&k.a.createElement("span",{className:"ml20"},"判断题",null===(Y=Pt.exerciseBanks)||void 0===Y||null===(X=Y.exercise_types)||void 0===X?void 0:X.q_judges,"题,共",null===(Z=Pt.exerciseBanks)||void 0===Z||null===(Q=Z.exercise_types)||void 0===Q?void 0:Q.q_judges_scores,"分"),!(null===(et=Pt.exerciseBanks)||void 0===et||null===(nt=et.exercise_types)||void 0===nt||!nt.q_nulls)&&k.a.createElement("span",{className:"ml20"},"填空题",null===(ot=Pt.exerciseBanks)||void 0===ot||null===(st=ot.exercise_types)||void 0===st?void 0:st.q_nulls,"题,共",null===(lt=Pt.exerciseBanks)||void 0===lt||null===(ct=lt.exercise_types)||void 0===ct?void 0:ct.q_nulls_scores,"分"),!(null===(ut=Pt.exerciseBanks)||void 0===ut||null===(ht=ut.exercise_types)||void 0===ht||!ht.q_mains)&&k.a.createElement("span",{className:"ml20"},"简答题",null===(dt=Pt.exerciseBanks)||void 0===dt||null===(ft=dt.exercise_types)||void 0===ft?void 0:ft.q_mains,"题,共",null===(pt=Pt.exerciseBanks)||void 0===pt||null===(mt=pt.exercise_types)||void 0===mt?void 0:mt.q_mains_scores,"分"),!(null===(gt=Pt.exerciseBanks)||void 0===gt||null===(vt=gt.exercise_types)||void 0===vt||!vt.q_shixuns)&&k.a.createElement("span",{className:"ml20"},"实训题",null===(yt=Pt.exerciseBanks)||void 0===yt||null===(bt=yt.exercise_types)||void 0===bt?void 0:bt.q_shixuns,"题,共",null===(xt=Pt.exerciseBanks)||void 0===xt||null===(St=xt.exercise_types)||void 0===St?void 0:St.q_shixuns_scores,"分"),!(null===(Ct=Pt.exerciseBanks)||void 0===Ct||null===(kt=Ct.exercise_types)||void 0===kt||!kt.q_pros)&&k.a.createElement("span",{className:"ml20"},"编程题",null===(Et=Pt.exerciseBanks)||void 0===Et||null===(wt=Et.exercise_types)||void 0===wt?void 0:wt.q_pros,"题,共",null===(Tt=Pt.exerciseBanks)||void 0===Tt||null===(Ot=Tt.exercise_types)||void 0===Ot?void 0:Ot.q_pros_scores,"分")),k.a.createElement("span",{className:"fr"},!(null===(Lt=Pt.exerciseBanks)||void 0===Lt||null===(At=Lt.exercise_types)||void 0===At||!At.q_counts)&&k.a.createElement("span",null,"合计 ",k.a.createElement("span",{className:"color-blue"},null===(Dt=Pt.exerciseBanks)||void 0===Dt||null===(_t=Dt.exercise_types)||void 0===_t?void 0:_t.q_counts)," 题, 共 ",k.a.createElement("span",{className:"".concat((null===(Rt=Pt.exerciseBanks)||void 0===Rt||null===(It=Rt.exercise_types)||void 0===It?void 0:It.q_scores)>100?"color-red font-bd":"color-orange")},null===(Mt=Pt.exerciseBanks)||void 0===Mt||null===(Nt=Mt.exercise_types)||void 0===Nt?void 0:Nt.q_scores)," 分"))),k.a.createElement("section",{className:[rt.a.bg,"pt30","pl20","pr20","pb20","mt20"].join(" ")},""!=Wt&&(null==Wt?void 0:Wt.map((function(t,e){return t.key=e+1,t.len=Wt.length,0===t.question_type?k.a.createElement("aside",null,k.a.createElement(V,{ref:Zt,editData:t}),k.a.createElement(u.a,null)):1===t.question_type?k.a.createElement("aside",null,k.a.createElement(U,{ref:Zt,editData:t}),k.a.createElement(u.a,null)):2===t.question_type?k.a.createElement("aside",null,k.a.createElement(q,{ref:Zt,editData:t}),k.a.createElement(u.a,null)):3===t.question_type?k.a.createElement("aside",null,k.a.createElement(J,{editData:t}),k.a.createElement(u.a,null)):4===t.question_type?k.a.createElement("aside",null,k.a.createElement(tt,{editData:t}),k.a.createElement(u.a,null)):5===t.question_type?k.a.createElement("aside",null,k.a.createElement(it,{editData:t}),k.a.createElement(u.a,null)):void 0}))),""==Wt&&k.a.createElement(A.a,null)),k.a.createElement(at.a,null))}))},Nska:
|
|
|
/*!*******************************************************************************!*\
|
|
|
!*** ./src/pages/User/Detail/Topics/components/SendToClassModal.less?modules ***!
|
|
|
\*******************************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={wrap:"wrap___1qNoS",title:"title___18s87",radioWrap:"radioWrap___3ZobS",radio:"radio___19YEl",colorFF0000:"colorFF0000___2BuLq",pagination:"pagination___18hXH"}},O2Wb:
|
|
|
/*!******************************************************************!*\
|
|
|
!*** ./src/components/Editor/NullChildEditor/index.less?modules ***!
|
|
|
\******************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={flex:"flex___2gmSR",flex1:"flex1___3Tu1g",color666:"color666___2uyGL",error:"error___yJ86W",deleteIcon:"deleteIcon___1D2tg",addIcon:"addIcon___2VIYB"}},Ot1p:
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/index.tsx + 6 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/markdown-editor/code-block/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/modal.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/useInterval.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/tasks/util.js because of ./src/pages/tasks/index.jsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/env.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/util.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/button/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input-number/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/radio/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/codemirror/lib/codemirror.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/uuid/dist/esm-browser/v4.js */function(t,e,i){"use strict";i("2qtc");var n=i("kLXV"),r=i("rAM+"),a=(i("miYZ"),i("tsqr")),o=i("9og8"),s=i("tJVT"),l=i("jrin"),c=i("WmNS"),u=i.n(c),h=i("q1tI"),d=i.n(h),f=i("VrN/"),p=i.n(f),m=i("bdgK"),g=(i("p77/"),i("Bd2K"),i("ELLl"),i("19Vz"),i("lZu9"),i("+NIl"),i("kSUc"),i("9Bee")),v=function(t){var e=t.value,i=void 0===e?"":e,n=(t.className,t.showTextOnly,t.showLines,t.style,Object(h.useMemo)((function(){return""}),[i]));return d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{dangerouslySetInnerHTML:{__html:n}}))},y=i("0Owb"),b=(i("dejd"),i("C+DQ"),i("1vsH")),x=i("m3rI"),S=[{title:"粗体",icon:"icon-bold",actionName:"bold"},{title:"斜体",icon:"icon-italic",actionName:"italic"},"|",{title:"无序列表",icon:"icon-unorder-list",actionName:"list-ul"},{title:"有序列表",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"行内代码",icon:"icon-code",actionName:"code"},{title:"代码块(多语言风格)",icon:"icon-file-code",actionName:"code-block"},{title:"链接",icon:"icon-link",actionName:"link"},"|",{title:"行内公式",icon:"icon-sum",actionName:"inline-latex"},{title:"多行公式",icon:"icon-formula",actionName:"latex"},"|",{title:"添加图片",icon:"icon-picture",actionName:"upload-image"},{title:"表格",icon:"icon-table",actionName:"add-table"},"|",{title:"换行",icon:"icon-minus",actionName:"line-break"},{title:"清空",icon:"icon-eraser",actionName:"eraser"}];function C(t){var e=t.onActionCallback,i=t.title,n=t.icon,r=t.actionName,a=t.className,o=void 0===a?"":a,s=t.children;return d.a.createElement("a",{title:i,className:o,onClick:function(){e(r)}},d.a.createElement("i",{className:"md-iconfont ".concat(n)}),s)}var k=function(t){var e=t.watch,i=t.showNullButton,n=t.onActionCallback,r=t.fullScreen,a=t.insertTemp,o=t.hidetoolBar,s=t.uuid;t.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(b.D)("_educoder_session_login"),"&_educoder_session=").concat(Object(b.D)("_educoder_session"),"&key=").concat(s,"&api=").concat(encodeURIComponent(x.a.PROXY_SERVER)));var l=[].concat(S,[{title:"".concat(e?"关闭实时预览":"开启实时预览"),icon:"".concat(e?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return d.a.createElement("ul",{className:"markdown-toolbar-container"},!o&&l.map((function(t,e){return d.a.createElement("li",{key:e},t.actionName?d.a.createElement(C,Object(y.a)({},t,{onActionCallback:n})):d.a.createElement("span",{className:"v-line"}))})),i?d.a.createElement("li",null,d.a.createElement(C,{icon:"icon-edit",className:"btn-null",title:"增加填空",actionName:"add-null-ch",onActionCallback:n},d.a.createElement("span",{className:"fill-tip"},"点击插入\b填空项"))):null,a&&d.a.createElement("li",null,d.a.createElement(C,{icon:"icon-edit",className:"btn-null",title:"插入模板",actionName:"inster-template-".concat(a),onActionCallback:n},d.a.createElement("span",{className:"fill-tip"},"插入模板"))),d.a.createElement("li",{className:"btn-full-screen"},d.a.createElement(C,{icon:"".concat(r?"icon-shrink":"icon-enlarge"),title:r?"关闭全屏":"开启全屏",actionName:"trigger-full-screen",onActionCallback:n})))},E=i("M8RZ"),w=(i("+L6B"),i("2/Rp")),T=(i("y8nQ"),i("Vl3Y")),O=(i("5NDa"),i("5rEg")),L={labelCol:{span:4},wrapperCol:{span:20}},A=function(t){var e=t.callback,i=t.onCancel;return d.a.createElement(T.a,Object(y.a)({},L,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:function(t){e(t)}}),d.a.createElement(T.a.Item,{label:"链接地址",name:"link",rules:[{required:!0,message:"请输入链接地址"}]},d.a.createElement(O.a,null)),d.a.createElement(T.a.Item,{label:"链接标题",name:"title",rules:[{required:!0,message:"请输入链接标题"}]},d.a.createElement(O.a,null)),d.a.createElement("div",{className:"flex-container flex-end"},d.a.createElement(w.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(w.a,{type:"ghost",onClick:i},"取消")))},D=i("7ahc"),_=i("k1fw"),R=(i("HmJG"),i("BjJ7")),I=T.a.useForm,M={width:280,marginRight:10},N={labelCol:{span:5},wrapperCol:{span:19}},P=function(t){var e=t.callback,i=t.onCancel,n=I(),r=Object(s.a)(n,1)[0],a=Object(h.useRef)();function o(t,e){r.setFieldsValue({src:"/api/attachments/".concat(t.id,"?type=").concat(t.content_type),type:e.type})}return d.a.createElement(T.a,Object(y.a)({form:r},N,{className:"upload-image-panel",onFinish:function(t){e(Object(_.a)(Object(_.a)({},t),{},{name:a.current}))}}),d.a.createElement(T.a.Item,{label:"文件地址",required:!0},d.a.createElement("div",{className:"flex-container"},d.a.createElement(T.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"请输入文件地址"}]},d.a.createElement(O.a,{style:M})),d.a.createElement(F,{onFileChange:function(t){var e=t.target.files[0];a.current=e.name,j(e,o)}}))),d.a.createElement(T.a.Item,{label:"文件描述",name:"alt"},d.a.createElement(O.a,{style:{width:264}})),d.a.createElement(T.a.Item,{style:{textAlign:"right"}},d.a.createElement(w.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(w.a,{type:"ghost",onClick:i},"取消")))};function F(t){var e=t.onFileChange;return d.a.createElement("a",{className:"upload-button"},"本地上传",d.a.createElement("input",{type:"file",onChange:e}))}function j(t,e){if(!t)throw new String("没有文件");var i=new FormData;i.append("editormd-image-file",t),i.append("file_param_name","editormd-image-file"),i.append("byxhr","true");var n=new window.XMLHttpRequest;n.withCredentials=!0,n.addEventListener("load",(function(i){e(JSON.parse(i.target.responseText),t)}),!1),n.addEventListener("error",(function(t){console.error(t)}),!1),n.open("POST","".concat(R.a,"/api/attachments.json")),n.send(i)}i("giR+");var B,U,H=i("fyUT"),G=(i("7Kak"),i("9yH6")),z=G.a.Group,V={margin:"0 8px"},W=function(t){var e=t.callback,i=t.onCancel;return d.a.createElement(T.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:function(t){e(t)}},d.a.createElement("div",{className:"flex-container"},d.a.createElement("span",{style:V},"单元格数:"),d.a.createElement("span",{style:V},"行数"),d.a.createElement(T.a.Item,{name:"row",rules:[{required:!0,message:"请输入行数"}]},d.a.createElement(H.a,null)),d.a.createElement("span",{style:V},"列数"),d.a.createElement(T.a.Item,{name:"col",rules:[{required:!0,message:"请输入列数"}]},d.a.createElement(H.a,null))),d.a.createElement("div",{className:"flex-container",style:{marginTop:12}},d.a.createElement("span",{style:V},"对齐方式:"),d.a.createElement(T.a.Item,{name:"align"},d.a.createElement(z,null,d.a.createElement(G.a,{value:"default"},d.a.createElement("i",{className:"fa fa-align-justify"})),d.a.createElement(G.a,{value:"left"},d.a.createElement("i",{className:"fa fa-align-left"})),d.a.createElement(G.a,{value:"center"},d.a.createElement("i",{className:"fa fa-align-center"})),d.a.createElement(G.a,{value:"right"},d.a.createElement("i",{className:"fa fa-align-right"}))))),d.a.createElement("div",{className:"flex-container flex-end"},d.a.createElement(w.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"确定"),d.a.createElement(w.a,{type:"ghost",onClick:i},"取消")))},K=i("ErOA"),q=i("7Cbv"),Y="------------",X={default:Y,left:":".concat(Y),center:":".concat(Y,":"),right:"".concat(Y,":")},$=i("9VGf");function Z(t){return/^\d+$/.test(t)?"".concat(t,"px"):t}var J=navigator.platform.toUpperCase().indexOf("MAC")>=0?"Cmd":"Ctrl",Q=["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"],tt=(B={},Object(l.a)(B,J+"-B","bold"),Object(l.a)(B,J+"-I","italic"),B),et=(U={},Object(l.a)(U,"link","添加链接"),Object(l.a)(U,"code-block","添加代码块"),Object(l.a)(U,"upload-image","添加文件"),Object(l.a)(U,"add-table","添加表格"),U);e.a=function(t){var e=t.defaultValue,i=void 0===e?"":e,c=t.onChange,f=t.width,y=void 0===f?"100%":f,b=t.height,S=void 0===b?400:b,C=t.miniToolbar,w=void 0!==C&&C,T=t.isFocus,O=void 0!==T&&T,L=t.watch,_=t.insertTemp,R=t.mode,I=void 0===R?"markdown":R,M=t.id,N=void 0===M?"markdown-editor-id":M,F=t.showResizeBar,B=void 0!==F&&F,U=t.noStorage,H=void 0!==U&&U,G=t.showNullButton,z=void 0!==G&&G,V=t.hidetoolBar,Y=void 0!==V&&V,J=t.fullScreen,it=void 0!==J&&J,nt=t.onBlur,rt=t.onCMBeforeChange,at=t.onFullScreen,ot=t.className,st=void 0===ot?"":ot,lt=t.disablePaste,ct=void 0!==lt&<,ut=t.placeholder,ht=void 0===ut?"":ut,dt=t.values,ft=void 0===dt?"":dt,pt=Object(h.useState)(null),mt=Object(s.a)(pt,2),gt=mt[0],vt=mt[1],yt=Object(h.useState)(i),bt=Object(s.a)(yt,2),xt=bt[0],St=bt[1],Ct=Object(h.useState)(L),kt=Object(s.a)(Ct,2),Et=kt[0],wt=kt[1],Tt=Object(h.useState)(it),Ot=Object(s.a)(Tt,2),Lt=Ot[0],At=Ot[1],Dt=Object(h.useState)(""),_t=Object(s.a)(Dt,2),Rt=_t[0],It=_t[1],Mt=Object(h.useState)(0),Nt=Object(s.a)(Mt,2),Pt=Nt[0],Ft=Nt[1],jt=Object(h.useState)(S),Bt=Object(s.a)(jt,2),Ut=Bt[0],Ht=Bt[1],Gt=Object(h.useState)(!1),zt=Object(s.a)(Gt,2),Vt=(zt[0],zt[1]),Wt=Object(h.useRef)(Object(q.a)()),Kt=Object(h.useRef)(!1),qt=Object(h.useRef)(),Yt=Object(h.useRef)(),Xt=Object(h.useRef)(),$t=Object(h.useRef)(),Zt=Object(h.useRef)(),Jt=function(){var t=Object(o.a)(u.a.mark((function t(){var e,i;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(K.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Wt.current}});case 2:null!=(i=t.sent)&&null!==(e=i.attachments)&&void 0!==e&&e.length&&(console.log("cm:",gt,Yt),i.attachments.map((function(t){t.content_type.indexOf("image")>-1?gt.replaceSelection(".concat(t.content_type,")")):t.content_type.indexOf("video")>-1?gt.replaceSelection('<video width="100%" controls src="'.concat(x.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):t.content_type.indexOf("pdf")>-1?gt.replaceSelection('<a href="'.concat(x.a.API_SERVER,"/api/attachments/").concat(t.id,"?type=").concat(t.content_type,'&disposition=inline" target="_blank">').concat(t.name,"</a>")):gt.replaceSelection("[".concat(t.name,"](").concat(x.a.API_SERVER,"/api/attachments/").concat(t.id,"?type=").concat(t.content_type,")"))})));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();Object(h.useEffect)((function(){St(ft),null==gt||gt.setValue(ft)}),[ft]),Object(h.useEffect)((function(){null==at||at(Lt)}),[Lt]),Object(h.useEffect)((function(){if(Yt.current){var t=p.a.fromTextArea(Yt.current,{mode:I,lineNumbers:!w,lineWrapping:!0,value:i,autoCloseTags:!0,autoCloseBrackets:!0});function e(e,i){if(!ct){var n=i.clipboardData;if(n){var r=n.types.toString(),o=n.items;if("Files"===r||n.types.indexOf("Files")>-1){if(i.preventDefault(),"stex"==I)return;try{var s,l=o[1];"file"===(null===(s=o[0])||void 0===s?void 0:s.kind)&&(l=o[0]);var c=l.getAsFile(),u=c.name.split(".").pop();j(c,(function(e){var i,n,r;e.id?(null==c||null===(i=c.type)||void 0===i?void 0:i.indexOf("image"))>-1?t.replaceSelection(".concat(e.content_type,")")):(null==c||null===(n=c.type)||void 0===n?void 0:n.indexOf("video"))>-1?t.replaceSelection('<video width="100%" controls src="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,'"></video>')):(null==c||null===(r=c.type)||void 0===r?void 0:r.indexOf("pdf"))>-1?t.replaceSelection('<a href="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(c.type,'&disposition=inline" target="_blank">').concat(c.name,"</a>")):Q.includes(u)?t.replaceSelection('<a href="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,'?type=office&disposition=inline" target="_blank">').concat(c.name,"</a>")):t.replaceSelection("[".concat(c.name,"](").concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")")):401===(null==e?void 0:e.status)&&(document.location.href="/user/login")}))}catch(i){a.b.warn("请使用chrome浏览器粘贴")}return!0}return!0}return!0}i.preventDefault()}return O&&t.focus(),t.on("paste",e),t.on("dragleave",(function(t,e){Xt.current.classList.remove("mouse-hover-md")})),t.on("dragover",(function(t,e){Xt.current.classList.add("mouse-hover-md")})),t.on("drop",(function(e,i){var n;if(Xt.current.classList.add("mouse-hover-md"),(n=i.dataTransfer.files).length>0){i.preventDefault(),i.stopPropagation();for(var r=function(e){var i=n[e],r=i.name.split(".").pop();j(i,(function(e){var n,a,o;e.id?(null==i||null===(n=i.type)||void 0===n?void 0:n.indexOf("image"))>-1?t.replaceSelection(".concat(e.content_type,")")):(null==i||null===(a=i.type)||void 0===a?void 0:a.indexOf("video"))>-1?t.replaceSelection('<video width="100%" controls src="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,'"></video>')):(null==i||null===(o=i.type)||void 0===o?void 0:o.indexOf("pdf"))>-1?t.replaceSelection('<a href="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(i.type,'&disposition=inline" target="_blank">').concat(i.name,"</a>")):Q.includes(r)?t.replaceSelection('<a href="'.concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,'?type=office&disposition=inline" target="_blank">').concat(i.name,"</a>")):t.replaceSelection("[".concat(i.name,"](").concat(x.a.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")")):401===(null==e?void 0:e.status)&&(document.location.href="/user/login")}))},a=0;a<n.length;a++)r(a)}})),vt(t),function(){t.off("paste",e)}}}),[]);var Qt=Object(h.useCallback)((function(){Xt.current}),[Ut,Xt,Lt]);Object(h.useEffect)((function(){if(gt){var t=function(){var t=new m.default((function(t){var e,i=Object(r.a)(t);try{for(i.s();!(e=i.n()).done;){var n=e.value;(n.target.offsetHeight>0||n.target.offsetWidth>0)&&(Qt(),gt.setSize("100%","100%"),gt.refresh())}}catch(t){i.e(t)}finally{i.f()}}));return t.observe(Yt.current.parentElement),t}();return function(){t.unobserve(Yt.current.parentElement)}}}),[gt,Qt]),Object(h.useEffect)((function(){if(gt){for(var t=[],e=function(){var e=n[i],r=(a=Object(s.a)(e,2))[0],o=a[1],c=Object(l.a)({},r,(function(){te(o)}));t.push(c),gt.addKeyMap(c)},i=0,n=Object.entries(tt);i<n.length;i++){var a;e()}return qt.current=setInterval((function(){Kt.current&&Jt()}),4e3),function(){clearInterval(qt.current);var e,i=Object(r.a)(t);try{for(i.s();!(e=i.n()).done;){var n=e.value;gt.removeKeyMap(n)}}catch(t){i.e(t)}finally{i.f()}}}}),[gt]),Object(h.useEffect)((function(){it!==Lt&&At(it)}),[it]),Object($.a)((function(){if(!H&&Pt>0){var t=(new Date).getTime(),e=window.sessionStorage.getItem(N);t>=Pt+1e4&&(!e||e!==xt)&&(window.sessionStorage.setItem(N,xt),Vt(!0))}}),1e4),Object(h.useEffect)((function(){wt(L)}),[gt,L]),Object(h.useEffect)((function(){gt&&O&>.focus()}),[gt,O]),Object(h.useEffect)((function(){if(Et&>){var t=gt.getScrollerElement();function e(t){var e=t.target;if(Zt.current){var i=e.scrollTop/e.scrollHeight;Zt.current.scrollTop=Zt.current.scrollHeight*i}}return t.addEventListener("scroll",e),function(){t.removeEventListener("scroll",e)}}}),[gt,Et]),Object(h.useEffect)((function(){if(gt&&rt){function t(t,e){rt(t,e)}return gt.on("beforeChange",t),function(){gt.off("beforeChange",t)}}}),[gt,rt]),Object(h.useEffect)((function(){if(gt&&nt){function t(){nt(gt.getValue())}return gt.on("blur",t),function(){gt.off("blur",t)}}}),[gt,nt]),Object(h.useEffect)((function(){if(gt){function t(t){var e=t.getValue();St(e),Ft((new Date).getTime()),t.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),c&&c(e)}return gt.on("change",t),function(){gt.off("change",t)}}}),[gt,c]),Object(h.useEffect)((function(){gt&&(null==i?(gt.setValue(""),St("")):i!==gt.getValue()&&(gt.setValue(i),St(i),gt.setCursor(gt.lineCount(),0)))}),[gt,i]);var te=Object(h.useCallback)((function(t){var e=gt.getCursor(),i=gt.getSelection(),n=i.split("\n");switch(t){case"bold":return gt.replaceSelection("**"+i+"**"),""===i&>.setCursor(e.line,e.ch+2),gt.focus();case"italic":return gt.replaceSelection("*"+i+"*"),""===i&>.setCursor(e.line,e.ch+1),gt.focus();case"code":return gt.replaceSelection("`"+i+"`"),""===i&>.setCursor(e.line,e.ch+1),gt.focus();case"inline-latex":return gt.replaceSelection("`$$"+i+"$$`"),""===i&>.setCursor(e.line,e.ch+3),gt.focus();case"latex":return gt.replaceSelection("```latex\n"+i+"\n```"),gt.setCursor(e.line+1,i.length+1),gt.focus();case"line-break":return gt.replaceSelection("<br/>\n"),gt.focus();case"list-ul":return""===i?gt.replaceSelection("- "+i):gt.replaceSelection(n.map((function(t){return""===t?"":"- ".concat(t)})).join("\n")),gt.focus();case"list-ol":return""===i?gt.replaceSelection("1. "+i):gt.replaceSelection(n.map((function(t,e){return""===t?"":"".concat(e+1,". ").concat(t)})).join("\n")),gt.focus();case"add-null-ch":return""===i&>.setCursor(e.line,e.ch+1),gt.replaceSelection("▁"),gt.focus();case"inster-template-1":return""===i&>.setCursor(e.line,e.ch),gt.replaceSelection("\n**模板标题**\n模板正文内容,可输入文本内容和粘贴图片等操作"),gt.focus();case"eraser":return gt.setValue(""),gt.focus();case"trigger-watch":return wt(!Et),gt.focus();case"trigger-full-screen":return At(!Lt),gt.focus();case"link":return void It("link");case"code-block":return void It("code-block");case"upload-image":return void It("upload-image");case"add-table":return void It("add-table");default:throw new Error}}),[gt,Et,Lt]),ee=Object(h.useCallback)((function(t){switch(It(""),Rt){case"link":var e=t.title,i=t.link;return gt.replaceSelection("[".concat(e,"](").concat(i,")")),gt.focus();case"code-block":var n=t.language,r=t.content;return gt.replaceSelection(["```"+n,r,"```"].join("\n")),gt.focus();case"upload-image":var a=t.src,o=t.alt,s=t.name;return a.indexOf("type=image")>-1?gt.replaceSelection(".concat(a,' "').concat(o||"",'" )')):a.indexOf("type=application/pdf")>-1?gt.replaceSelection('<a href="'.concat(a,'&disposition=inline" target="_blank">').concat(s,"</a>")):gt.replaceSelection('<a href="'.concat(a,'" target="_blank">').concat(s,"</a>")),gt.focus();case"add-table":for(var l=t.row,c=t.col,u=t.align,h="\n",d=0;d<l;d++){for(var f=[],p=[],m=0;m<c;m++)1===d&&p.push(X[u]),f.push(" ");1===d&&(h+="| ".concat(p.join(" | ")," |\n")),h+="| ".concat(f.join(1===c?"":" | ")," |\n")}return gt.replaceSelection(h+"\n"),gt.focus();default:throw new Error}}),[gt,Rt]),ie=Object(h.useMemo)((function(){switch(Rt){case"link":return d.a.createElement(A,{callback:ee,onCancel:ne});case"code-block":return d.a.createElement(D.b,{callback:ee,onCancel:ne});case"upload-image":return d.a.createElement(P,{callback:ee,onCancel:ne});case"add-table":return d.a.createElement(W,{callback:ee,onCancel:ne});default:return null}}),[Rt]);function ne(){It("")}Object(h.useEffect)((function(){if($t.current){var t=$t.current,e=!1,i=0;function n(t){e=!0,i=t.pageY}function r(){e=!1}function a(t){if(e){var n=t.pageY-i;n<0&&(n=0),n>300&&(n=300),Ht(S+n+"px")}}return t.addEventListener("mousedown",n),document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),function(){t.removeEventListener("mousedown",n),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}}}),[gt,$t]),Object(h.useEffect)((function(){Ht(S)}),[S]);var re={width:Z(y),height:Z(Ut)};Object(h.useMemo)((function(){if(Pt){var t=new Date(Pt),e=t.getHours(),i=t.getMinutes(),n=t.getSeconds();return i=i<10?"0"+i:i,n=n<10?"0"+n:n,"".concat(e=e<10?"0"+e:e,":").concat(i,":").concat(n)}return 0}),[Pt]);return d.a.createElement(h.Fragment,null,d.a.createElement("div",{className:"markdown-editor-wrapper",ref:Xt},d.a.createElement("div",{className:"markdown-editor-container ".concat(st," ").concat(Et?"on-preview":""," ").concat(w?"mini":""," ").concat(Lt?"full-screen":""),style:re},d.a.createElement(k,{insertTemp:_,watch:Et,fullScreen:Lt,showNullButton:z,onActionCallback:te,hidetoolBar:Y,uuid:Wt.current,setOpenPhones:function(){Kt.current=!0}}),d.a.createElement("div",{className:"markdown-editor-body"},d.a.createElement("div",{className:"codemirror-container"},d.a.createElement("textarea",{ref:Yt,placeholder:ht})),Et?d.a.createElement("div",{ref:Zt,className:"preview-container"},"stex"===I&&d.a.createElement(v,{value:xt}),"stex"!==I&&d.a.createElement(g.a,{edit:!0,value:xt,replaces:function(t,e){var i=gt.getValue();i=i.replace(t,e),St(i),null==gt||gt.setValue(i)}})):null))),B?d.a.createElement("a",{ref:$t,className:"editor-resize"}):null,d.a.createElement(E.a,null,et[Rt]?d.a.createElement(n.a,{centered:!0,title:et[Rt],visible:!0,onCancel:ne,footer:null},ie):null))}},SJMd:
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/code-prettify/src/prettify.js ***!
|
|
|
\****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){window.PR_SHOULD_USE_CONTINUATION=!0,function(){var t=window,e=["break,continue,do,else,for,if,return,while"],i=[[e,"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"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],n=[i,"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"],r=[i,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],a=[i,"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"],o=[i,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],s="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",l=[e,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],c=[e,"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"],u=[e,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],h=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;function d(t,e,i,n,r){if(i){var a={sourceNode:t,pre:1,langExtension:null,numberLines:null,sourceCode:i,spans:null,basePos:e,decorations:null};n(a),r.push.apply(r,a.decorations)}}var f=/\S/;function p(t){for(var e=void 0,i=t.firstChild;i;i=i.nextSibling){var n=i.nodeType;e=1===n?e?t:i:3===n&&f.test(i.nodeValue)?t:e}return e===t?void 0:e}function m(t,e){var i,n={};!function(){for(var r=t.concat(e),a=[],o={},s=0,l=r.length;s<l;++s){var c=r[s],u=c[3];if(u)for(var h=u.length;--h>=0;)n[u.charAt(h)]=c;var d=c[1],f=""+d;o.hasOwnProperty(f)||(a.push(d),o[f]=null)}a.push(/[\0-\uffff]/),i=function(t){for(var e=0,i=!1,n=!1,r=0,a=t.length;r<a;++r){if((d=t[r]).ignoreCase)n=!0;else if(/[a-z]/i.test(d.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){i=!0,n=!1;break}}var o={b:8,t:9,n:10,v:11,f:12,r:13};function s(t){var e=t.charCodeAt(0);if(92!==e)return e;var i=t.charAt(1);return(e=o[i])||("0"<=i&&i<="7"?parseInt(t.substring(1),8):"u"===i||"x"===i?parseInt(t.substring(2),16):t.charCodeAt(1))}function l(t){if(t<32)return(t<16?"\\x0":"\\x")+t.toString(16);var e=String.fromCharCode(t);return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(t){var e=t.substring(1,t.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")),i=[],n="^"===e[0],r=["["];n&&r.push("^");for(var a=n?1:0,o=e.length;a<o;++a){var c=e[a];if(/\\[bdsw]/i.test(c))r.push(c);else{var u,h=s(c);a+2<o&&"-"===e[a+1]?(u=s(e[a+2]),a+=2):u=h,i.push([h,u]),u<65||h>122||(u<65||h>90||i.push([32|Math.max(65,h),32|Math.min(u,90)]),u<97||h>122||i.push([-33&Math.max(97,h),-33&Math.min(u,122)]))}}i.sort((function(t,e){return t[0]-e[0]||e[1]-t[1]}));var d=[],f=[];for(a=0;a<i.length;++a){(p=i[a])[0]<=f[1]+1?f[1]=Math.max(f[1],p[1]):d.push(f=p)}for(a=0;a<d.length;++a){var p=d[a];r.push(l(p[0])),p[1]>p[0]&&(p[1]+1>p[0]&&r.push("-"),r.push(l(p[1])))}return r.push("]"),r.join("")}function u(t){for(var n=t.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")),r=n.length,a=[],o=0,s=0;o<r;++o){if("("===(h=n[o]))++s;else if("\\"===h.charAt(0)){(u=+h.substring(1))&&(u<=s?a[u]=-1:n[o]=l(u))}}for(o=1;o<a.length;++o)-1===a[o]&&(a[o]=++e);for(o=0,s=0;o<r;++o){if("("===(h=n[o]))a[++s]||(n[o]="(?:");else if("\\"===h.charAt(0)){var u;(u=+h.substring(1))&&u<=s&&(n[o]="\\"+a[u])}}for(o=0;o<r;++o)"^"===n[o]&&"^"!==n[o+1]&&(n[o]="");if(t.ignoreCase&&i)for(o=0;o<r;++o){var h,d=(h=n[o]).charAt(0);h.length>=2&&"["===d?n[o]=c(h):"\\"!==d&&(n[o]=h.replace(/[a-zA-Z]/g,(function(t){var e=t.charCodeAt(0);return"["+String.fromCharCode(-33&e,32|e)+"]"})))}return n.join("")}var h=[];for(r=0,a=t.length;r<a;++r){var d;if((d=t[r]).global||d.multiline)throw new Error(""+d);h.push("(?:"+u(d)+")")}return new RegExp(h.join("|"),n?"gi":"g")}(a)}();var r=e.length,a=function(t){for(var o=t.sourceCode,s=t.basePos,l=t.sourceNode,c=[s,"pln"],u=0,h=o.match(i)||[],f={},p=0,m=h.length;p<m;++p){var g,v=h[p],y=f[v],b=void 0;if("string"==typeof y)g=!1;else{var x=n[v.charAt(0)];if(x)b=v.match(x[1]),y=x[0];else{for(var C=0;C<r;++C)if(x=e[C],b=v.match(x[1])){y=x[0];break}b||(y="pln")}!(g=y.length>=5&&"lang-"===y.substring(0,5))||b&&"string"==typeof b[1]||(g=!1,y="src"),g||(f[v]=y)}var k=u;if(u+=v.length,g){var E=b[1],w=v.indexOf(E),T=w+E.length;b[2]&&(w=(T=v.length-b[2].length)-E.length);var O=y.substring(5);d(l,s+k,v.substring(0,w),a,c),d(l,s+k+w,E,S(O,E),c),d(l,s+k+T,v.substring(T),a,c)}else c.push(s+k,y)}t.decorations=c};return a}function g(t){var e=[],i=[];t.tripleQuotedStrings?e.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):t.multiLineStrings?e.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):e.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),t.verbatimStrings&&i.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var n=t.hashComments;n&&(t.cStyleComments?(n>1?e.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):e.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),i.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):e.push(["com",/^#[^\r\n]*/,null,"#"])),t.cStyleComments&&(i.push(["com",/^\/\/[^\r\n]*/,null]),i.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var r=t.regexLiterals;if(r){var a=r>1?"":"\n\r",o=a?".":"[\\S\\s]",s="/(?=[^/*"+a+"])(?:[^/\\x5B\\x5C"+a+"]|\\x5C"+o+"|\\x5B(?:[^\\x5C\\x5D"+a+"]|\\x5C"+o+")*(?:\\x5D|$))+/";i.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+s+")")])}var l=t.types;l&&i.push(["typ",l]);var c=(""+t.keywords).replace(/^ | $/g,"");c.length&&i.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]),e.push(["pln",/^\s+/,null," \r\n\t "]);var u="^.[^\\s\\w.$@'\"`/\\\\]*";return t.regexLiterals&&(u+="(?!s*/)"),i.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,null],["lit",new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(u),null]),m(e,i)}var v=g({keywords:[n,a,r,o,s,l,c,u],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function y(t,e,i){for(var n=/(?:^|\s)nocode(?:\s|$)/,r=/\r\n?|\n/,a=t.ownerDocument,o=a.createElement("li");t.firstChild;)o.appendChild(t.firstChild);var s=[o];function l(t){var e=t.nodeType;if(1!=e||n.test(t.className)){if((3==e||4==e)&&i){var o=t.nodeValue,s=o.match(r);if(s){var u=o.substring(0,s.index);t.nodeValue=u;var h=o.substring(s.index+s[0].length);if(h)t.parentNode.insertBefore(a.createTextNode(h),t.nextSibling);c(t),u||t.parentNode.removeChild(t)}}}else if("br"===t.nodeName)c(t),t.parentNode&&t.parentNode.removeChild(t);else for(var d=t.firstChild;d;d=d.nextSibling)l(d)}function c(t){for(;!t.nextSibling;)if(!(t=t.parentNode))return;for(var e,i=function t(e,i){var n=i?e.cloneNode(!1):e,r=e.parentNode;if(r){var a=t(r,1),o=e.nextSibling;a.appendChild(n);for(var s=o;s;s=o)o=s.nextSibling,a.appendChild(s)}return n}(t.nextSibling,0);(e=i.parentNode)&&1===e.nodeType;)i=e;s.push(i)}for(var u=0;u<s.length;++u)l(s[u]);e===(0|e)&&s[0].setAttribute("value",e);var h=a.createElement("ol");h.className="linenums";for(var d=Math.max(0,e-1|0)||0,f=(u=0,s.length);u<f;++u)(o=s[u]).className="L"+(u+d)%10,o.firstChild||o.appendChild(a.createTextNode(" ")),h.appendChild(o);t.appendChild(h)}var b={};function x(e,i){for(var n=i.length;--n>=0;){var r=i[n];b.hasOwnProperty(r)?t.console&&console.warn("cannot override language handler %s",r):b[r]=e}}function S(t,e){return t&&b.hasOwnProperty(t)||(t=/^\s*</.test(e)?"default-markup":"default-code"),b[t]}function C(e){var i,n,r,a,o,s,l,c=e.langExtension;try{var u=(i=e.sourceNode,n=e.pre,r=/(?:^|\s)nocode(?:\s|$)/,a=[],o=0,s=[],l=0,function t(e){var i=e.nodeType;if(1==i){if(r.test(e.className))return;for(var c=e.firstChild;c;c=c.nextSibling)t(c);var u=e.nodeName.toLowerCase();"br"!==u&&"li"!==u||(a[l]="\n",s[l<<1]=o++,s[l++<<1|1]=e)}else if(3==i||4==i){var h=e.nodeValue;h.length&&(h=n?h.replace(/\r\n?/g,"\n"):h.replace(/[ \t\r\n]+/g," "),a[l]=h,s[l<<1]=o,o+=h.length,s[l++<<1|1]=e)}}(i),{sourceCode:a.join("").replace(/\n$/,""),spans:s}),h=u.sourceCode;e.sourceCode=h,e.spans=u.spans,e.basePos=0,S(c,h)(e),function(t){var e=/\bMSIE\s(\d+)/.exec(navigator.userAgent);e=e&&+e[1]<=8;var i,n,r=/\n/g,a=t.sourceCode,o=a.length,s=0,l=t.spans,c=l.length,u=0,h=t.decorations,d=h.length,f=0;for(h[d]=o,n=i=0;n<d;)h[n]!==h[n+2]?(h[i++]=h[n++],h[i++]=h[n++]):n+=2;for(d=i,n=i=0;n<d;){for(var p=h[n],m=h[n+1],g=n+2;g+2<=d&&h[g+1]===m;)g+=2;h[i++]=p,h[i++]=m,n=g}d=h.length=i;var v=t.sourceNode,y="";v&&(y=v.style.display,v.style.display="none");try{for(;u<c;){l[u];var b,x=l[u+2]||o,S=h[f+2]||o,C=(g=Math.min(x,S),l[u+1]);if(1!==C.nodeType&&(b=a.substring(s,g))){e&&(b=b.replace(r,"\r")),C.nodeValue=b;var k=C.ownerDocument,E=k.createElement("span");E.className=h[f+1];var w=C.parentNode;w.replaceChild(E,C),E.appendChild(C),s<x&&(l[u+1]=C=k.createTextNode(a.substring(g,x)),w.insertBefore(C,E.nextSibling))}(s=g)>=x&&(u+=2),s>=S&&(f+=2)}}finally{v&&(v.style.display=y)}}(e)}catch(e){t.console&&console.log(e&&e.stack||e)}}function k(t,e,i){var n=i||!1,r=e||null,a=document.createElement("div");return a.innerHTML="<pre>"+t+"</pre>",a=a.firstChild,n&&y(a,n,!0),C({langExtension:r,numberLines:n,sourceNode:a,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null}),a.innerHTML}function E(e,i){var n=i||document.body,r=n.ownerDocument||document;function a(t){return n.getElementsByTagName(t)}for(var o=[a("pre"),a("code"),a("xmp")],s=[],l=0;l<o.length;++l)for(var c=0,u=o[l].length;c<u;++c)s.push(o[l][c]);o=null;var h=Date;h.now||(h={now:function(){return+new Date}});var d=0,f=/\blang(?:uage)?-([\w.]+)(?!\S)/,m=/\bprettyprint\b/,g=/\bprettyprinted\b/,v=/pre|xmp/i,b=/^code$/i,x=/^(?:pre|code|xmp)$/i,S={};!function i(){for(var n=t.PR_SHOULD_USE_CONTINUATION?h.now()+250:1/0;d<s.length&&h.now()<n;d++){for(var a=s[d],o=S,l=a;l=l.previousSibling;){var c=l.nodeType,u=(7===c||8===c)&&l.nodeValue;if(u?!/^\??prettify\b/.test(u):3!==c||/\S/.test(l.nodeValue))break;if(u){o={},u.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(t,e,i){o[e]=i}));break}}var k=a.className;if((o!==S||m.test(k))&&!g.test(k)){for(var E=!1,w=a.parentNode;w;w=w.parentNode){var T=w.tagName;if(x.test(T)&&w.className&&m.test(w.className)){E=!0;break}}if(!E){a.className+=" prettyprinted";var O,L,A=o.lang;if(!A)!(A=k.match(f))&&(O=p(a))&&b.test(O.tagName)&&(A=O.className.match(f)),A&&(A=A[1]);if(v.test(a.tagName))L=1;else{var D=a.currentStyle,_=r.defaultView,R=D?D.whiteSpace:_&&_.getComputedStyle?_.getComputedStyle(a,null).getPropertyValue("white-space"):0;L=R&&"pre"===R.substring(0,3)}var I=o.linenums;(I="true"===I||+I)||(I=!!(I=k.match(/\blinenums\b(?::(\d+))?/))&&(!I[1]||!I[1].length||+I[1])),I&&y(a,I,L),C({langExtension:A,sourceNode:a,numberLines:I,pre:L,sourceCode:null,basePos:null,spans:null,decorations:null})}}}d<s.length?t.setTimeout(i,250):"function"==typeof e&&e()}()}x(v,["default-code"]),x(m([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["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"]),x(m([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["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"]),x(m([],[["atv",/^[\s\S]+/]]),["uq.val"]),x(g({keywords:n,hashComments:!0,cStyleComments:!0,types:h}),["c","cc","cpp","cxx","cyc","m"]),x(g({keywords:"null,true,false"}),["json"]),x(g({keywords:a,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:h}),["cs"]),x(g({keywords:r,cStyleComments:!0}),["java"]),x(g({keywords:u,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),x(g({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),x(g({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),x(g({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),x(g({keywords:o,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),x(g({keywords:"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",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),x(m([],[["str",/^[\s\S]+/]]),["regex"]);var w=t.PR={createSimpleLexer:m,registerLangHandler:x,sourceDecorator:g,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:k,prettyPrint:E},T=t.define;"function"==typeof T&&T.amd&&T("google-code-prettify",[],(function(){return w}))}()},UU91:
|
|
|
/*!*************************************************************************!*\
|
|
|
!*** ./src/pages/User/Detail/Topics/Exercise/Detail/index.less?modules ***!
|
|
|
\*************************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={flex_box_center:"flex_box_center___W-luD",flex_space_between:"flex_space_between___MDZOl",flex_box_vertical_center:"flex_box_vertical_center___GF3w8",flex_box_center_end:"flex_box_center_end___UZLKo",flex_box_column:"flex_box_column___26ZEG",bg:"bg___Lrg3h",containerTitle:"containerTitle___36aFc",containerDesc:"containerDesc___1ITIo",listItem:"listItem___3yIgk",info:"info___1J349",title:"title___1poFp",titleLeft:"titleLeft___1G4yJ",titleRight:"titleRight___3ZAtk",acitons:"acitons___rsUze",export:"export___23Ina"}},"VrN/":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/codemirror/lib/codemirror.js ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports=function(){"use strict";var t=navigator.userAgent,e=navigator.platform,i=/gecko\/\d/i.test(t),n=/MSIE \d/.test(t),r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(t),a=/Edge\/(\d+)/.exec(t),o=n||r||a,s=o&&(n?document.documentMode||6:+(a||r)[1]),l=!a&&/WebKit\//.test(t),c=l&&/Qt\/\d+\.\d+/.test(t),u=!a&&/Chrome\//.test(t),h=/Opera\//.test(t),d=/Apple Computer/.test(navigator.vendor),f=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(t),p=/PhantomJS/.test(t),m=!a&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t),g=/Android/.test(t),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),y=m||/Mac/.test(e),b=/\bCrOS\b/.test(t),x=/win/i.test(e),S=h&&t.match(/Version\/(\d*\.\d*)/);S&&(S=Number(S[1])),S&&S>=15&&(h=!1,l=!0);var C=y&&(c||h&&(null==S||S<12.11)),k=i||o&&s>=9;function E(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var w,T=function(t,e){var i=t.className,n=E(e).exec(i);if(n){var r=i.slice(n.index+n[0].length);t.className=i.slice(0,n.index)+(r?n[1]+r:"")}};function O(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function L(t,e){return O(t).appendChild(e)}function A(t,e,i,n){var r=document.createElement(t);if(i&&(r.className=i),n&&(r.style.cssText=n),"string"==typeof e)r.appendChild(document.createTextNode(e));else if(e)for(var a=0;a<e.length;++a)r.appendChild(e[a]);return r}function D(t,e,i,n){var r=A(t,e,i,n);return r.setAttribute("role","presentation"),r}function _(t,e){if(3==e.nodeType&&(e=e.parentNode),t.contains)return t.contains(e);do{if(11==e.nodeType&&(e=e.host),e==t)return!0}while(e=e.parentNode)}function R(){var t;try{t=document.activeElement}catch(e){t=document.body||null}for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function I(t,e){var i=t.className;E(e).test(i)||(t.className+=(i?" ":"")+e)}function M(t,e){for(var i=t.split(" "),n=0;n<i.length;n++)i[n]&&!E(i[n]).test(e)&&(e+=" "+i[n]);return e}w=document.createRange?function(t,e,i,n){var r=document.createRange();return r.setEnd(n||t,i),r.setStart(t,e),r}:function(t,e,i){var n=document.body.createTextRange();try{n.moveToElementText(t.parentNode)}catch(t){return n}return n.collapse(!0),n.moveEnd("character",i),n.moveStart("character",e),n};var N=function(t){t.select()};function P(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e)}}function F(t,e,i){for(var n in e||(e={}),t)!t.hasOwnProperty(n)||!1===i&&e.hasOwnProperty(n)||(e[n]=t[n]);return e}function j(t,e,i,n,r){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);for(var a=n||0,o=r||0;;){var s=t.indexOf("\t",a);if(s<0||s>=e)return o+(e-a);o+=s-a,o+=i-o%i,a=s+1}}m?N=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:o&&(N=function(t){try{t.select()}catch(t){}});var B=function(){this.id=null,this.f=null,this.time=0,this.handler=P(this.onTimeout,this)};function U(t,e){for(var i=0;i<t.length;++i)if(t[i]==e)return i;return-1}B.prototype.onTimeout=function(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)},B.prototype.set=function(t,e){this.f=e;var i=+new Date+t;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,t),this.time=i)};var H={toString:function(){return"CodeMirror.Pass"}},G={scroll:!1},z={origin:"*mouse"},V={origin:"+move"};function W(t,e,i){for(var n=0,r=0;;){var a=t.indexOf("\t",n);-1==a&&(a=t.length);var o=a-n;if(a==t.length||r+o>=e)return n+Math.min(o,e-r);if(r+=a-n,n=a+1,(r+=i-r%i)>=e)return n}}var K=[""];function q(t){for(;K.length<=t;)K.push(Y(K)+" ");return K[t]}function Y(t){return t[t.length-1]}function X(t,e){for(var i=[],n=0;n<t.length;n++)i[n]=e(t[n],n);return i}function $(){}function Z(t,e){var i;return Object.create?i=Object.create(t):($.prototype=t,i=new $),e&&F(e,i),i}var J=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Q(t){return/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||J.test(t))}function tt(t,e){return e?!!(e.source.indexOf("\\w")>-1&&Q(t))||e.test(t):Q(t)}function et(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var it=/[\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 nt(t){return t.charCodeAt(0)>=768&&it.test(t)}function rt(t,e,i){for(;(i<0?e>0:e<t.length)&&nt(t.charAt(e));)e+=i;return e}function at(t,e,i){for(var n=e>i?-1:1;;){if(e==i)return e;var r=(e+i)/2,a=n<0?Math.ceil(r):Math.floor(r);if(a==e)return t(a)?e:i;t(a)?i=a:e=a+n}}var ot=null;function st(t,e,i){var n;ot=null;for(var r=0;r<t.length;++r){var a=t[r];if(a.from<e&&a.to>e)return r;a.to==e&&(a.from!=a.to&&"before"==i?n=r:ot=r),a.from==e&&(a.from!=a.to&&"before"!=i?n=r:ot=r)}return null!=n?n:ot}var lt=function(){var t=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,i=/[LRr]/,n=/[Lb1n]/,r=/[1n]/;function a(t,e,i){this.level=t,this.from=e,this.to=i}return function(o,s){var l="ltr"==s?"L":"R";if(0==o.length||"ltr"==s&&!t.test(o))return!1;for(var c,u=o.length,h=[],d=0;d<u;++d)h.push((c=o.charCodeAt(d))<=247?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(c):1424<=c&&c<=1524?"R":1536<=c&&c<=1785?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(c-1536):1774<=c&&c<=2220?"r":8192<=c&&c<=8203?"w":8204==c?"b":"L");for(var f=0,p=l;f<u;++f){var m=h[f];"m"==m?h[f]=p:p=m}for(var g=0,v=l;g<u;++g){var y=h[g];"1"==y&&"r"==v?h[g]="n":i.test(y)&&(v=y,"r"==y&&(h[g]="R"))}for(var b=1,x=h[0];b<u-1;++b){var S=h[b];"+"==S&&"1"==x&&"1"==h[b+1]?h[b]="1":","!=S||x!=h[b+1]||"1"!=x&&"n"!=x||(h[b]=x),x=S}for(var C=0;C<u;++C){var k=h[C];if(","==k)h[C]="N";else if("%"==k){var E=void 0;for(E=C+1;E<u&&"%"==h[E];++E);for(var w=C&&"!"==h[C-1]||E<u&&"1"==h[E]?"1":"N",T=C;T<E;++T)h[T]=w;C=E-1}}for(var O=0,L=l;O<u;++O){var A=h[O];"L"==L&&"1"==A?h[O]="L":i.test(A)&&(L=A)}for(var D=0;D<u;++D)if(e.test(h[D])){var _=void 0;for(_=D+1;_<u&&e.test(h[_]);++_);for(var R="L"==(D?h[D-1]:l),I=R==("L"==(_<u?h[_]:l))?R?"L":"R":l,M=D;M<_;++M)h[M]=I;D=_-1}for(var N,P=[],F=0;F<u;)if(n.test(h[F])){var j=F;for(++F;F<u&&n.test(h[F]);++F);P.push(new a(0,j,F))}else{var B=F,U=P.length,H="rtl"==s?1:0;for(++F;F<u&&"L"!=h[F];++F);for(var G=B;G<F;)if(r.test(h[G])){B<G&&(P.splice(U,0,new a(1,B,G)),U+=H);var z=G;for(++G;G<F&&r.test(h[G]);++G);P.splice(U,0,new a(2,z,G)),U+=H,B=G}else++G;B<F&&P.splice(U,0,new a(1,B,F))}return"ltr"==s&&(1==P[0].level&&(N=o.match(/^\s+/))&&(P[0].from=N[0].length,P.unshift(new a(0,0,N[0].length))),1==Y(P).level&&(N=o.match(/\s+$/))&&(Y(P).to-=N[0].length,P.push(new a(0,u-N[0].length,u)))),"rtl"==s?P.reverse():P}}();function ct(t,e){var i=t.order;return null==i&&(i=t.order=lt(t.text,e)),i}var ut=[],ht=function(t,e,i){if(t.addEventListener)t.addEventListener(e,i,!1);else if(t.attachEvent)t.attachEvent("on"+e,i);else{var n=t._handlers||(t._handlers={});n[e]=(n[e]||ut).concat(i)}};function dt(t,e){return t._handlers&&t._handlers[e]||ut}function ft(t,e,i){if(t.removeEventListener)t.removeEventListener(e,i,!1);else if(t.detachEvent)t.detachEvent("on"+e,i);else{var n=t._handlers,r=n&&n[e];if(r){var a=U(r,i);a>-1&&(n[e]=r.slice(0,a).concat(r.slice(a+1)))}}}function pt(t,e){var i=dt(t,e);if(i.length)for(var n=Array.prototype.slice.call(arguments,2),r=0;r<i.length;++r)i[r].apply(null,n)}function mt(t,e,i){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),pt(t,i||e.type,t,e),St(e)||e.codemirrorIgnore}function gt(t){var e=t._handlers&&t._handlers.cursorActivity;if(e)for(var i=t.curOp.cursorActivityHandlers||(t.curOp.cursorActivityHandlers=[]),n=0;n<e.length;++n)-1==U(i,e[n])&&i.push(e[n])}function vt(t,e){return dt(t,e).length>0}function yt(t){t.prototype.on=function(t,e){ht(this,t,e)},t.prototype.off=function(t,e){ft(this,t,e)}}function bt(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function xt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function St(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function Ct(t){bt(t),xt(t)}function kt(t){return t.target||t.srcElement}function Et(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),y&&t.ctrlKey&&1==e&&(e=3),e}var wt,Tt,Ot=function(){if(o&&s<9)return!1;var t=A("div");return"draggable"in t||"dragDrop"in t}();function Lt(t){if(null==wt){var e=A("span","");L(t,A("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(wt=e.offsetWidth<=1&&e.offsetHeight>2&&!(o&&s<8))}var i=wt?A("span",""):A("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function At(t){if(null!=Tt)return Tt;var e=L(t,document.createTextNode("AخA")),i=w(e,0,1).getBoundingClientRect(),n=w(e,1,2).getBoundingClientRect();return O(t),!(!i||i.left==i.right)&&(Tt=n.right-i.right<3)}var Dt,_t=3!="\n\nb".split(/\n/).length?function(t){for(var e=0,i=[],n=t.length;e<=n;){var r=t.indexOf("\n",e);-1==r&&(r=t.length);var a=t.slice(e,"\r"==t.charAt(r-1)?r-1:r),o=a.indexOf("\r");-1!=o?(i.push(a.slice(0,o)),e+=o+1):(i.push(a),e=r+1)}return i}:function(t){return t.split(/\r\n?|\n/)},Rt=window.getSelection?function(t){try{return t.selectionStart!=t.selectionEnd}catch(t){return!1}}:function(t){var e;try{e=t.ownerDocument.selection.createRange()}catch(t){}return!(!e||e.parentElement()!=t)&&0!=e.compareEndPoints("StartToEnd",e)},It="oncopy"in(Dt=A("div"))||(Dt.setAttribute("oncopy","return;"),"function"==typeof Dt.oncopy),Mt=null,Nt={},Pt={};function Ft(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Nt[t]=e}function jt(t){if("string"==typeof t&&Pt.hasOwnProperty(t))t=Pt[t];else if(t&&"string"==typeof t.name&&Pt.hasOwnProperty(t.name)){var e=Pt[t.name];"string"==typeof e&&(e={name:e}),(t=Z(e,t)).name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return jt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return jt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function Bt(t,e){e=jt(e);var i=Nt[e.name];if(!i)return Bt(t,"text/plain");var n=i(t,e);if(Ut.hasOwnProperty(e.name)){var r=Ut[e.name];for(var a in r)r.hasOwnProperty(a)&&(n.hasOwnProperty(a)&&(n["_"+a]=n[a]),n[a]=r[a])}if(n.name=e.name,e.helperType&&(n.helperType=e.helperType),e.modeProps)for(var o in e.modeProps)n[o]=e.modeProps[o];return n}var Ut={};function Ht(t,e){F(e,Ut.hasOwnProperty(t)?Ut[t]:Ut[t]={})}function Gt(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var i={};for(var n in e){var r=e[n];r instanceof Array&&(r=r.concat([])),i[n]=r}return i}function zt(t,e){for(var i;t.innerMode&&(i=t.innerMode(e))&&i.mode!=t;)e=i.state,t=i.mode;return i||{mode:t,state:e}}function Vt(t,e,i){return!t.startState||t.startState(e,i)}var Wt=function(t,e,i){this.pos=this.start=0,this.string=t,this.tabSize=e||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};function Kt(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var i=t;!i.lines;)for(var n=0;;++n){var r=i.children[n],a=r.chunkSize();if(e<a){i=r;break}e-=a}return i.lines[e]}function qt(t,e,i){var n=[],r=e.line;return t.iter(e.line,i.line+1,(function(t){var a=t.text;r==i.line&&(a=a.slice(0,i.ch)),r==e.line&&(a=a.slice(e.ch)),n.push(a),++r})),n}function Yt(t,e,i){var n=[];return t.iter(e,i,(function(t){n.push(t.text)})),n}function Xt(t,e){var i=e-t.height;if(i)for(var n=t;n;n=n.parent)n.height+=i}function $t(t){if(null==t.parent)return null;for(var e=t.parent,i=U(e.lines,t),n=e.parent;n;e=n,n=n.parent)for(var r=0;n.children[r]!=e;++r)i+=n.children[r].chunkSize();return i+e.first}function Zt(t,e){var i=t.first;t:do{for(var n=0;n<t.children.length;++n){var r=t.children[n],a=r.height;if(e<a){t=r;continue t}e-=a,i+=r.chunkSize()}return i}while(!t.lines);for(var o=0;o<t.lines.length;++o){var s=t.lines[o].height;if(e<s)break;e-=s}return i+o}function Jt(t,e){return e>=t.first&&e<t.first+t.size}function Qt(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function te(t,e,i){if(void 0===i&&(i=null),!(this instanceof te))return new te(t,e,i);this.line=t,this.ch=e,this.sticky=i}function ee(t,e){return t.line-e.line||t.ch-e.ch}function ie(t,e){return t.sticky==e.sticky&&0==ee(t,e)}function ne(t){return te(t.line,t.ch)}function re(t,e){return ee(t,e)<0?e:t}function ae(t,e){return ee(t,e)<0?t:e}function oe(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function se(t,e){if(e.line<t.first)return te(t.first,0);var i=t.first+t.size-1;return e.line>i?te(i,Kt(t,i).text.length):function(t,e){var i=t.ch;return null==i||i>e?te(t.line,e):i<0?te(t.line,0):t}(e,Kt(t,e.line).text.length)}function le(t,e){for(var i=[],n=0;n<e.length;n++)i[n]=se(t,e[n]);return i}Wt.prototype.eol=function(){return this.pos>=this.string.length},Wt.prototype.sol=function(){return this.pos==this.lineStart},Wt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Wt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Wt.prototype.eat=function(t){var e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t.test?t.test(e):t(e)))return++this.pos,e},Wt.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},Wt.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},Wt.prototype.skipToEnd=function(){this.pos=this.string.length},Wt.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},Wt.prototype.backUp=function(t){this.pos-=t},Wt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=j(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?j(this.string,this.lineStart,this.tabSize):0)},Wt.prototype.indentation=function(){return j(this.string,null,this.tabSize)-(this.lineStart?j(this.string,this.lineStart,this.tabSize):0)},Wt.prototype.match=function(t,e,i){if("string"!=typeof t){var n=this.string.slice(this.pos).match(t);return n&&n.index>0?null:(n&&!1!==e&&(this.pos+=n[0].length),n)}var r=function(t){return i?t.toLowerCase():t};if(r(this.string.substr(this.pos,t.length))==r(t))return!1!==e&&(this.pos+=t.length),!0},Wt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Wt.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},Wt.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},Wt.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var ce=function(t,e){this.state=t,this.lookAhead=e},ue=function(t,e,i,n){this.state=e,this.doc=t,this.line=i,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};function he(t,e,i,n){var r=[t.state.modeGen],a={};xe(t,e.text,t.doc.mode,i,(function(t,e){return r.push(t,e)}),a,n);for(var o=i.state,s=function(n){i.baseTokens=r;var s=t.state.overlays[n],l=1,c=0;i.state=!0,xe(t,e.text,s.mode,i,(function(t,e){for(var i=l;c<t;){var n=r[l];n>t&&r.splice(l,1,t,r[l+1],n),l+=2,c=Math.min(t,n)}if(e)if(s.opaque)r.splice(i,l-i,t,"overlay "+e),l=i+2;else for(;i<l;i+=2){var a=r[i+1];r[i+1]=(a?a+" ":"")+"overlay "+e}}),a),i.state=o,i.baseTokens=null,i.baseTokenPos=1},l=0;l<t.state.overlays.length;++l)s(l);return{styles:r,classes:a.bgClass||a.textClass?a:null}}function de(t,e,i){if(!e.styles||e.styles[0]!=t.state.modeGen){var n=fe(t,$t(e)),r=e.text.length>t.options.maxHighlightLength&&Gt(t.doc.mode,n.state),a=he(t,e,n);r&&(n.state=r),e.stateAfter=n.save(!r),e.styles=a.styles,a.classes?e.styleClasses=a.classes:e.styleClasses&&(e.styleClasses=null),i===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function fe(t,e,i){var n=t.doc,r=t.display;if(!n.mode.startState)return new ue(n,!0,e);var a=function(t,e,i){for(var n,r,a=t.doc,o=i?-1:e-(t.doc.mode.innerMode?1e3:100),s=e;s>o;--s){if(s<=a.first)return a.first;var l=Kt(a,s-1),c=l.stateAfter;if(c&&(!i||s+(c instanceof ce?c.lookAhead:0)<=a.modeFrontier))return s;var u=j(l.text,null,t.options.tabSize);(null==r||n>u)&&(r=s-1,n=u)}return r}(t,e,i),o=a>n.first&&Kt(n,a-1).stateAfter,s=o?ue.fromSaved(n,o,a):new ue(n,Vt(n.mode),a);return n.iter(a,e,(function(i){pe(t,i.text,s);var n=s.line;i.stateAfter=n==e-1||n%5==0||n>=r.viewFrom&&n<r.viewTo?s.save():null,s.nextLine()})),i&&(n.modeFrontier=s.line),s}function pe(t,e,i,n){var r=t.doc.mode,a=new Wt(e,t.options.tabSize,i);for(a.start=a.pos=n||0,""==e&&me(r,i.state);!a.eol();)ge(r,a,i.state),a.start=a.pos}function me(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var i=zt(t,e);return i.mode.blankLine?i.mode.blankLine(i.state):void 0}}function ge(t,e,i,n){for(var r=0;r<10;r++){n&&(n[0]=zt(t,i).mode);var a=t.token(e,i);if(e.pos>e.start)return a}throw new Error("Mode "+t.name+" failed to advance stream.")}ue.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ue.prototype.baseToken=function(t){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)this.baseTokenPos+=2;var e=this.baseTokens[this.baseTokenPos+1];return{type:e&&e.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},ue.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ue.fromSaved=function(t,e,i){return e instanceof ce?new ue(t,Gt(t.mode,e.state),i,e.lookAhead):new ue(t,Gt(t.mode,e),i)},ue.prototype.save=function(t){var e=!1!==t?Gt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ce(e,this.maxLookAhead):e};var ve=function(t,e,i){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=i};function ye(t,e,i,n){var r,a,o=t.doc,s=o.mode,l=Kt(o,(e=se(o,e)).line),c=fe(t,e.line,i),u=new Wt(l.text,t.options.tabSize,c);for(n&&(a=[]);(n||u.pos<e.ch)&&!u.eol();)u.start=u.pos,r=ge(s,u,c.state),n&&a.push(new ve(u,r,Gt(o.mode,c.state)));return n?a:new ve(u,r,c.state)}function be(t,e){if(t)for(;;){var i=t.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;t=t.slice(0,i.index)+t.slice(i.index+i[0].length);var n=i[1]?"bgClass":"textClass";null==e[n]?e[n]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(e[n])||(e[n]+=" "+i[2])}return t}function xe(t,e,i,n,r,a,o){var s=i.flattenSpans;null==s&&(s=t.options.flattenSpans);var l,c=0,u=null,h=new Wt(e,t.options.tabSize,n),d=t.options.addModeClass&&[null];for(""==e&&be(me(i,n.state),a);!h.eol();){if(h.pos>t.options.maxHighlightLength?(s=!1,o&&pe(t,e,n,h.pos),h.pos=e.length,l=null):l=be(ge(i,h,n.state,d),a),d){var f=d[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!s||u!=l){for(;c<h.start;)r(c=Math.min(h.start,c+5e3),u);u=l}h.start=h.pos}for(;c<h.pos;){var p=Math.min(h.pos,c+5e3);r(p,u),c=p}}var Se=!1,Ce=!1;function ke(t,e,i){this.marker=t,this.from=e,this.to=i}function Ee(t,e){if(t)for(var i=0;i<t.length;++i){var n=t[i];if(n.marker==e)return n}}function we(t,e){for(var i,n=0;n<t.length;++n)t[n]!=e&&(i||(i=[])).push(t[n]);return i}function Te(t,e){if(e.full)return null;var i=Jt(t,e.from.line)&&Kt(t,e.from.line).markedSpans,n=Jt(t,e.to.line)&&Kt(t,e.to.line).markedSpans;if(!i&&!n)return null;var r=e.from.ch,a=e.to.ch,o=0==ee(e.from,e.to),s=function(t,e,i){var n;if(t)for(var r=0;r<t.length;++r){var a=t[r],o=a.marker;if(null==a.from||(o.inclusiveLeft?a.from<=e:a.from<e)||a.from==e&&"bookmark"==o.type&&(!i||!a.marker.insertLeft)){var s=null==a.to||(o.inclusiveRight?a.to>=e:a.to>e);(n||(n=[])).push(new ke(o,a.from,s?null:a.to))}}return n}(i,r,o),l=function(t,e,i){var n;if(t)for(var r=0;r<t.length;++r){var a=t[r],o=a.marker;if(null==a.to||(o.inclusiveRight?a.to>=e:a.to>e)||a.from==e&&"bookmark"==o.type&&(!i||a.marker.insertLeft)){var s=null==a.from||(o.inclusiveLeft?a.from<=e:a.from<e);(n||(n=[])).push(new ke(o,s?null:a.from-e,null==a.to?null:a.to-e))}}return n}(n,a,o),c=1==e.text.length,u=Y(e.text).length+(c?r:0);if(s)for(var h=0;h<s.length;++h){var d=s[h];if(null==d.to){var f=Ee(l,d.marker);f?c&&(d.to=null==f.to?null:f.to+u):d.to=r}}if(l)for(var p=0;p<l.length;++p){var m=l[p];null!=m.to&&(m.to+=u),null==m.from?Ee(s,m.marker)||(m.from=u,c&&(s||(s=[])).push(m)):(m.from+=u,c&&(s||(s=[])).push(m))}s&&(s=Oe(s)),l&&l!=s&&(l=Oe(l));var g=[s];if(!c){var v,y=e.text.length-2;if(y>0&&s)for(var b=0;b<s.length;++b)null==s[b].to&&(v||(v=[])).push(new ke(s[b].marker,null,null));for(var x=0;x<y;++x)g.push(v);g.push(l)}return g}function Oe(t){for(var e=0;e<t.length;++e){var i=t[e];null!=i.from&&i.from==i.to&&!1!==i.marker.clearWhenEmpty&&t.splice(e--,1)}return t.length?t:null}function Le(t){var e=t.markedSpans;if(e){for(var i=0;i<e.length;++i)e[i].marker.detachLine(t);t.markedSpans=null}}function Ae(t,e){if(e){for(var i=0;i<e.length;++i)e[i].marker.attachLine(t);t.markedSpans=e}}function De(t){return t.inclusiveLeft?-1:0}function _e(t){return t.inclusiveRight?1:0}function Re(t,e){var i=t.lines.length-e.lines.length;if(0!=i)return i;var n=t.find(),r=e.find(),a=ee(n.from,r.from)||De(t)-De(e);if(a)return-a;var o=ee(n.to,r.to)||_e(t)-_e(e);return o||e.id-t.id}function Ie(t,e){var i,n=Ce&&t.markedSpans;if(n)for(var r=void 0,a=0;a<n.length;++a)(r=n[a]).marker.collapsed&&null==(e?r.from:r.to)&&(!i||Re(i,r.marker)<0)&&(i=r.marker);return i}function Me(t){return Ie(t,!0)}function Ne(t){return Ie(t,!1)}function Pe(t,e){var i,n=Ce&&t.markedSpans;if(n)for(var r=0;r<n.length;++r){var a=n[r];a.marker.collapsed&&(null==a.from||a.from<e)&&(null==a.to||a.to>e)&&(!i||Re(i,a.marker)<0)&&(i=a.marker)}return i}function Fe(t,e,i,n,r){var a=Kt(t,e),o=Ce&&a.markedSpans;if(o)for(var s=0;s<o.length;++s){var l=o[s];if(l.marker.collapsed){var c=l.marker.find(0),u=ee(c.from,i)||De(l.marker)-De(r),h=ee(c.to,n)||_e(l.marker)-_e(r);if(!(u>=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?ee(c.to,i)>=0:ee(c.to,i)>0)||u>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?ee(c.from,n)<=0:ee(c.from,n)<0)))return!0}}}function je(t){for(var e;e=Me(t);)t=e.find(-1,!0).line;return t}function Be(t,e){var i=Kt(t,e),n=je(i);return i==n?e:$t(n)}function Ue(t,e){if(e>t.lastLine())return e;var i,n=Kt(t,e);if(!He(t,n))return e;for(;i=Ne(n);)n=i.find(1,!0).line;return $t(n)+1}function He(t,e){var i=Ce&&e.markedSpans;if(i)for(var n=void 0,r=0;r<i.length;++r)if((n=i[r]).marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&Ge(t,e,n))return!0}}function Ge(t,e,i){if(null==i.to){var n=i.marker.find(1,!0);return Ge(t,n.line,Ee(n.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==e.text.length)return!0;for(var r=void 0,a=0;a<e.markedSpans.length;++a)if((r=e.markedSpans[a]).marker.collapsed&&!r.marker.widgetNode&&r.from==i.to&&(null==r.to||r.to!=i.from)&&(r.marker.inclusiveLeft||i.marker.inclusiveRight)&&Ge(t,e,r))return!0}function ze(t){for(var e=0,i=(t=je(t)).parent,n=0;n<i.lines.length;++n){var r=i.lines[n];if(r==t)break;e+=r.height}for(var a=i.parent;a;a=(i=a).parent)for(var o=0;o<a.children.length;++o){var s=a.children[o];if(s==i)break;e+=s.height}return e}function Ve(t){if(0==t.height)return 0;for(var e,i=t.text.length,n=t;e=Me(n);){var r=e.find(0,!0);n=r.from.line,i+=r.from.ch-r.to.ch}for(n=t;e=Ne(n);){var a=e.find(0,!0);i-=n.text.length-a.from.ch,i+=(n=a.to.line).text.length-a.to.ch}return i}function We(t){var e=t.display,i=t.doc;e.maxLine=Kt(i,i.first),e.maxLineLength=Ve(e.maxLine),e.maxLineChanged=!0,i.iter((function(t){var i=Ve(t);i>e.maxLineLength&&(e.maxLineLength=i,e.maxLine=t)}))}var Ke=function(t,e,i){this.text=t,Ae(this,e),this.height=i?i(this):1};function qe(t){t.parent=null,Le(t)}Ke.prototype.lineNo=function(){return $t(this)},yt(Ke);var Ye={},Xe={};function $e(t,e){if(!t||/^\s*$/.test(t))return null;var i=e.addModeClass?Xe:Ye;return i[t]||(i[t]=t.replace(/\S+/g,"cm-$&"))}function Ze(t,e){var i=D("span",null,null,l?"padding-right: .1px":null),n={pre:D("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:t,trailingSpace:!1,splitSpaces:t.getOption("lineWrapping")};e.measure={};for(var r=0;r<=(e.rest?e.rest.length:0);r++){var a=r?e.rest[r-1]:e.line,o=void 0;n.pos=0,n.addToken=Qe,At(t.display.measure)&&(o=ct(a,t.doc.direction))&&(n.addToken=ti(n.addToken,o)),n.map=[],ii(a,n,de(t,a,e!=t.display.externalMeasured&&$t(a))),a.styleClasses&&(a.styleClasses.bgClass&&(n.bgClass=M(a.styleClasses.bgClass,n.bgClass||"")),a.styleClasses.textClass&&(n.textClass=M(a.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Lt(t.display.measure))),0==r?(e.measure.map=n.map,e.measure.cache={}):((e.measure.maps||(e.measure.maps=[])).push(n.map),(e.measure.caches||(e.measure.caches=[])).push({}))}if(l){var s=n.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return pt(t,"renderLine",t,e.line,n.pre),n.pre.className&&(n.textClass=M(n.pre.className,n.textClass||"")),n}function Je(t){var e=A("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function Qe(t,e,i,n,r,a,l){if(e){var c,u=t.splitSpaces?function(t,e){if(t.length>1&&!/ /.test(t))return t;for(var i=e,n="",r=0;r<t.length;r++){var a=t.charAt(r);" "!=a||!i||r!=t.length-1&&32!=t.charCodeAt(r+1)||(a=" "),n+=a,i=" "==a}return n}(e,t.trailingSpace):e,h=t.cm.state.specialChars,d=!1;if(h.test(e)){c=document.createDocumentFragment();for(var f=0;;){h.lastIndex=f;var p=h.exec(e),m=p?p.index-f:e.length-f;if(m){var g=document.createTextNode(u.slice(f,f+m));o&&s<9?c.appendChild(A("span",[g])):c.appendChild(g),t.map.push(t.pos,t.pos+m,g),t.col+=m,t.pos+=m}if(!p)break;f+=m+1;var v=void 0;if("\t"==p[0]){var y=t.cm.options.tabSize,b=y-t.col%y;(v=c.appendChild(A("span",q(b),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),t.col+=b}else"\r"==p[0]||"\n"==p[0]?((v=c.appendChild(A("span","\r"==p[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",p[0]),t.col+=1):((v=t.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),o&&s<9?c.appendChild(A("span",[v])):c.appendChild(v),t.col+=1);t.map.push(t.pos,t.pos+1,v),t.pos++}}else t.col+=e.length,c=document.createTextNode(u),t.map.push(t.pos,t.pos+e.length,c),o&&s<9&&(d=!0),t.pos+=e.length;if(t.trailingSpace=32==u.charCodeAt(e.length-1),i||n||r||d||a||l){var x=i||"";n&&(x+=n),r&&(x+=r);var S=A("span",[c],x,a);if(l)for(var C in l)l.hasOwnProperty(C)&&"style"!=C&&"class"!=C&&S.setAttribute(C,l[C]);return t.content.appendChild(S)}t.content.appendChild(c)}}function ti(t,e){return function(i,n,r,a,o,s,l){r=r?r+" cm-force-border":"cm-force-border";for(var c=i.pos,u=c+n.length;;){for(var h=void 0,d=0;d<e.length&&!((h=e[d]).to>c&&h.from<=c);d++);if(h.to>=u)return t(i,n,r,a,o,s,l);t(i,n.slice(0,h.to-c),r,a,null,s,l),a=null,n=n.slice(h.to-c),c=h.to}}}function ei(t,e,i,n){var r=!n&&i.widgetNode;r&&t.map.push(t.pos,t.pos+e,r),!n&&t.cm.display.input.needsContentAttribute&&(r||(r=t.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",i.id)),r&&(t.cm.display.input.setUneditable(r),t.content.appendChild(r)),t.pos+=e,t.trailingSpace=!1}function ii(t,e,i){var n=t.markedSpans,r=t.text,a=0;if(n)for(var o,s,l,c,u,h,d,f=r.length,p=0,m=1,g="",v=0;;){if(v==p){l=c=u=s="",d=null,h=null,v=1/0;for(var y=[],b=void 0,x=0;x<n.length;++x){var S=n[x],C=S.marker;if("bookmark"==C.type&&S.from==p&&C.widgetNode)y.push(C);else if(S.from<=p&&(null==S.to||S.to>p||C.collapsed&&S.to==p&&S.from==p)){if(null!=S.to&&S.to!=p&&v>S.to&&(v=S.to,c=""),C.className&&(l+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&S.from==p&&(u+=" "+C.startStyle),C.endStyle&&S.to==v&&(b||(b=[])).push(C.endStyle,S.to),C.title&&((d||(d={})).title=C.title),C.attributes)for(var k in C.attributes)(d||(d={}))[k]=C.attributes[k];C.collapsed&&(!h||Re(h.marker,C)<0)&&(h=S)}else S.from>p&&v>S.from&&(v=S.from)}if(b)for(var E=0;E<b.length;E+=2)b[E+1]==v&&(c+=" "+b[E]);if(!h||h.from==p)for(var w=0;w<y.length;++w)ei(e,0,y[w]);if(h&&(h.from||0)==p){if(ei(e,(null==h.to?f+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}}if(p>=f)break;for(var T=Math.min(f,v);;){if(g){var O=p+g.length;if(!h){var L=O>T?g.slice(0,T-p):g;e.addToken(e,L,o?o+l:l,u,p+L.length==v?c:"",s,d)}if(O>=T){g=g.slice(T-p),p=T;break}p=O,u=""}g=r.slice(a,a=i[m++]),o=$e(i[m++],e.cm.options)}}else for(var A=1;A<i.length;A+=2)e.addToken(e,r.slice(a,a=i[A]),$e(i[A+1],e.cm.options))}function ni(t,e,i){this.line=e,this.rest=function(t){for(var e,i;e=Ne(t);)t=e.find(1,!0).line,(i||(i=[])).push(t);return i}(e),this.size=this.rest?$t(Y(this.rest))-i+1:1,this.node=this.text=null,this.hidden=He(t,e)}function ri(t,e,i){for(var n,r=[],a=e;a<i;a=n){var o=new ni(t.doc,Kt(t.doc,a),a);n=a+o.size,r.push(o)}return r}var ai=null,oi=null;function si(t,e){var i=dt(t,e);if(i.length){var n,r=Array.prototype.slice.call(arguments,2);ai?n=ai.delayedCallbacks:oi?n=oi:(n=oi=[],setTimeout(li,0));for(var a=function(t){n.push((function(){return i[t].apply(null,r)}))},o=0;o<i.length;++o)a(o)}}function li(){var t=oi;oi=null;for(var e=0;e<t.length;++e)t[e]()}function ci(t,e,i,n){for(var r=0;r<e.changes.length;r++){var a=e.changes[r];"text"==a?di(t,e):"gutter"==a?pi(t,e,i,n):"class"==a?fi(t,e):"widget"==a&&mi(t,e,n)}e.changes=null}function ui(t){return t.node==t.text&&(t.node=A("div",null,null,"position: relative"),t.text.parentNode&&t.text.parentNode.replaceChild(t.node,t.text),t.node.appendChild(t.text),o&&s<8&&(t.node.style.zIndex=2)),t.node}function hi(t,e){var i=t.display.externalMeasured;return i&&i.line==e.line?(t.display.externalMeasured=null,e.measure=i.measure,i.built):Ze(t,e)}function di(t,e){var i=e.text.className,n=hi(t,e);e.text==e.node&&(e.node=n.pre),e.text.parentNode.replaceChild(n.pre,e.text),e.text=n.pre,n.bgClass!=e.bgClass||n.textClass!=e.textClass?(e.bgClass=n.bgClass,e.textClass=n.textClass,fi(t,e)):i&&(e.text.className=i)}function fi(t,e){!function(t,e){var i=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),e.background)i?e.background.className=i:(e.background.parentNode.removeChild(e.background),e.background=null);else if(i){var n=ui(e);e.background=n.insertBefore(A("div",null,i),n.firstChild),t.display.input.setUneditable(e.background)}}(t,e),e.line.wrapClass?ui(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var i=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=i||""}function pi(t,e,i,n){if(e.gutter&&(e.node.removeChild(e.gutter),e.gutter=null),e.gutterBackground&&(e.node.removeChild(e.gutterBackground),e.gutterBackground=null),e.line.gutterClass){var r=ui(e);e.gutterBackground=A("div",null,"CodeMirror-gutter-background "+e.line.gutterClass,"left: "+(t.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),t.display.input.setUneditable(e.gutterBackground),r.insertBefore(e.gutterBackground,e.text)}var a=e.line.gutterMarkers;if(t.options.lineNumbers||a){var o=ui(e),s=e.gutter=A("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(t.display.input.setUneditable(s),o.insertBefore(s,e.text),e.line.gutterClass&&(s.className+=" "+e.line.gutterClass),!t.options.lineNumbers||a&&a["CodeMirror-linenumbers"]||(e.lineNumber=s.appendChild(A("div",Qt(t.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),a)for(var l=0;l<t.display.gutterSpecs.length;++l){var c=t.display.gutterSpecs[l].className,u=a.hasOwnProperty(c)&&a[c];u&&s.appendChild(A("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[c]+"px; width: "+n.gutterWidth[c]+"px"))}}}function mi(t,e,i){e.alignable&&(e.alignable=null);for(var n=E("CodeMirror-linewidget"),r=e.node.firstChild,a=void 0;r;r=a)a=r.nextSibling,n.test(r.className)&&e.node.removeChild(r);vi(t,e,i)}function gi(t,e,i,n){var r=hi(t,e);return e.text=e.node=r.pre,r.bgClass&&(e.bgClass=r.bgClass),r.textClass&&(e.textClass=r.textClass),fi(t,e),pi(t,e,i,n),vi(t,e,n),e.node}function vi(t,e,i){if(yi(t,e.line,e,i,!0),e.rest)for(var n=0;n<e.rest.length;n++)yi(t,e.rest[n],e,i,!1)}function yi(t,e,i,n,r){if(e.widgets)for(var a=ui(i),o=0,s=e.widgets;o<s.length;++o){var l=s[o],c=A("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),bi(l,c,i,n),t.display.input.setUneditable(c),r&&l.above?a.insertBefore(c,i.gutter||i.text):a.appendChild(c),si(l,"redraw")}}function bi(t,e,i,n){if(t.noHScroll){(i.alignable||(i.alignable=[])).push(e);var r=n.wrapperWidth;e.style.left=n.fixedPos+"px",t.coverGutter||(r-=n.gutterTotalWidth,e.style.paddingLeft=n.gutterTotalWidth+"px"),e.style.width=r+"px"}t.coverGutter&&(e.style.zIndex=5,e.style.position="relative",t.noHScroll||(e.style.marginLeft=-n.gutterTotalWidth+"px"))}function xi(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!_(document.body,t.node)){var i="position: relative;";t.coverGutter&&(i+="margin-left: -"+e.display.gutters.offsetWidth+"px;"),t.noHScroll&&(i+="width: "+e.display.wrapper.clientWidth+"px;"),L(e.display.measure,A("div",[t.node],null,i))}return t.height=t.node.parentNode.offsetHeight}function Si(t,e){for(var i=kt(e);i!=t.wrapper;i=i.parentNode)if(!i||1==i.nodeType&&"true"==i.getAttribute("cm-ignore-events")||i.parentNode==t.sizer&&i!=t.mover)return!0}function Ci(t){return t.lineSpace.offsetTop}function ki(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function Ei(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=L(t.measure,A("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,n={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(t.cachedPaddingH=n),n}function wi(t){return 50-t.display.nativeBarWidth}function Ti(t){return t.display.scroller.clientWidth-wi(t)-t.display.barWidth}function Oi(t){return t.display.scroller.clientHeight-wi(t)-t.display.barHeight}function Li(t,e,i){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};for(var n=0;n<t.rest.length;n++)if(t.rest[n]==e)return{map:t.measure.maps[n],cache:t.measure.caches[n]};for(var r=0;r<t.rest.length;r++)if($t(t.rest[r])>i)return{map:t.measure.maps[r],cache:t.measure.caches[r],before:!0}}function Ai(t,e,i,n){return Ri(t,_i(t,e),i,n)}function Di(t,e){if(e>=t.display.viewFrom&&e<t.display.viewTo)return t.display.view[un(t,e)];var i=t.display.externalMeasured;return i&&e>=i.lineN&&e<i.lineN+i.size?i:void 0}function _i(t,e){var i=$t(e),n=Di(t,i);n&&!n.text?n=null:n&&n.changes&&(ci(t,n,i,an(t)),t.curOp.forceUpdate=!0),n||(n=function(t,e){var i=$t(e=je(e)),n=t.display.externalMeasured=new ni(t.doc,e,i);n.lineN=i;var r=n.built=Ze(t,n);return n.text=r.pre,L(t.display.lineMeasure,r.pre),n}(t,e));var r=Li(n,e,i);return{line:e,view:n,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function Ri(t,e,i,n,r){e.before&&(i=-1);var a,l=i+(n||"");return e.cache.hasOwnProperty(l)?a=e.cache[l]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(function(t,e,i){var n=t.options.lineWrapping,r=n&&Ti(t);if(!e.measure.heights||n&&e.measure.width!=r){var a=e.measure.heights=[];if(n){e.measure.width=r;for(var o=e.text.firstChild.getClientRects(),s=0;s<o.length-1;s++){var l=o[s],c=o[s+1];Math.abs(l.bottom-c.bottom)>2&&a.push((l.bottom+c.top)/2-i.top)}}a.push(i.bottom-i.top)}}(t,e.view,e.rect),e.hasHeights=!0),(a=function(t,e,i,n){var r,a=Ni(e.map,i,n),l=a.node,c=a.start,u=a.end,h=a.collapse;if(3==l.nodeType){for(var d=0;d<4;d++){for(;c&&nt(e.line.text.charAt(a.coverStart+c));)--c;for(;a.coverStart+u<a.coverEnd&&nt(e.line.text.charAt(a.coverStart+u));)++u;if((r=o&&s<9&&0==c&&u==a.coverEnd-a.coverStart?l.parentNode.getBoundingClientRect():Pi(w(l,c,u).getClientRects(),n)).left||r.right||0==c)break;u=c,c-=1,h="right"}o&&s<11&&(r=function(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(t){if(null!=Mt)return Mt;var e=L(t,A("span","x")),i=e.getBoundingClientRect(),n=w(e,0,1).getBoundingClientRect();return Mt=Math.abs(i.left-n.left)>1}(t))return e;var i=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:e.left*i,right:e.right*i,top:e.top*n,bottom:e.bottom*n}}(t.display.measure,r))}else{var f;c>0&&(h=n="right"),r=t.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(o&&s<9&&!c&&(!r||!r.left&&!r.right)){var p=l.parentNode.getClientRects()[0];r=p?{left:p.left,right:p.left+rn(t.display),top:p.top,bottom:p.bottom}:Mi}for(var m=r.top-e.rect.top,g=r.bottom-e.rect.top,v=(m+g)/2,y=e.view.measure.heights,b=0;b<y.length-1&&!(v<y[b]);b++);var x=b?y[b-1]:0,S=y[b],C={left:("right"==h?r.right:r.left)-e.rect.left,right:("left"==h?r.left:r.right)-e.rect.left,top:x,bottom:S};return r.left||r.right||(C.bogus=!0),t.options.singleCursorHeightPerLine||(C.rtop=m,C.rbottom=g),C}(t,e,i,n)).bogus||(e.cache[l]=a)),{left:a.left,right:a.right,top:r?a.rtop:a.top,bottom:r?a.rbottom:a.bottom}}var Ii,Mi={left:0,right:0,top:0,bottom:0};function Ni(t,e,i){for(var n,r,a,o,s,l,c=0;c<t.length;c+=3)if(s=t[c],l=t[c+1],e<s?(r=0,a=1,o="left"):e<l?a=1+(r=e-s):(c==t.length-3||e==l&&t[c+3]>e)&&(r=(a=l-s)-1,e>=l&&(o="right")),null!=r){if(n=t[c+2],s==l&&i==(n.insertLeft?"left":"right")&&(o=i),"left"==i&&0==r)for(;c&&t[c-2]==t[c-3]&&t[c-1].insertLeft;)n=t[2+(c-=3)],o="left";if("right"==i&&r==l-s)for(;c<t.length-3&&t[c+3]==t[c+4]&&!t[c+5].insertLeft;)n=t[(c+=3)+2],o="right";break}return{node:n,start:r,end:a,collapse:o,coverStart:s,coverEnd:l}}function Pi(t,e){var i=Mi;if("left"==e)for(var n=0;n<t.length&&(i=t[n]).left==i.right;n++);else for(var r=t.length-1;r>=0&&(i=t[r]).left==i.right;r--);return i}function Fi(t){if(t.measure&&(t.measure.cache={},t.measure.heights=null,t.rest))for(var e=0;e<t.rest.length;e++)t.measure.caches[e]={}}function ji(t){t.display.externalMeasure=null,O(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)Fi(t.display.view[e])}function Bi(t){ji(t),t.display.cachedCharWidth=t.display.cachedTextHeight=t.display.cachedPaddingH=null,t.options.lineWrapping||(t.display.maxLineChanged=!0),t.display.lineNumChars=null}function Ui(){return u&&g?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Hi(){return u&&g?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Gi(t){var e=0;if(t.widgets)for(var i=0;i<t.widgets.length;++i)t.widgets[i].above&&(e+=xi(t.widgets[i]));return e}function zi(t,e,i,n,r){if(!r){var a=Gi(e);i.top+=a,i.bottom+=a}if("line"==n)return i;n||(n="local");var o=ze(e);if("local"==n?o+=Ci(t.display):o-=t.display.viewOffset,"page"==n||"window"==n){var s=t.display.lineSpace.getBoundingClientRect();o+=s.top+("window"==n?0:Hi());var l=s.left+("window"==n?0:Ui());i.left+=l,i.right+=l}return i.top+=o,i.bottom+=o,i}function Vi(t,e,i){if("div"==i)return e;var n=e.left,r=e.top;if("page"==i)n-=Ui(),r-=Hi();else if("local"==i||!i){var a=t.display.sizer.getBoundingClientRect();n+=a.left,r+=a.top}var o=t.display.lineSpace.getBoundingClientRect();return{left:n-o.left,top:r-o.top}}function Wi(t,e,i,n,r){return n||(n=Kt(t.doc,e.line)),zi(t,n,Ai(t,n,e.ch,r),i)}function Ki(t,e,i,n,r,a){function o(e,o){var s=Ri(t,r,e,o?"right":"left",a);return o?s.left=s.right:s.right=s.left,zi(t,n,s,i)}n=n||Kt(t.doc,e.line),r||(r=_i(t,n));var s=ct(n,t.doc.direction),l=e.ch,c=e.sticky;if(l>=n.text.length?(l=n.text.length,c="before"):l<=0&&(l=0,c="after"),!s)return o("before"==c?l-1:l,"before"==c);function u(t,e,i){return o(i?t-1:t,1==s[e].level!=i)}var h=st(s,l,c),d=ot,f=u(l,h,"before"==c);return null!=d&&(f.other=u(l,d,"before"!=c)),f}function qi(t,e){var i=0;e=se(t.doc,e),t.options.lineWrapping||(i=rn(t.display)*e.ch);var n=Kt(t.doc,e.line),r=ze(n)+Ci(t.display);return{left:i,right:i,top:r,bottom:r+n.height}}function Yi(t,e,i,n,r){var a=te(t,e,i);return a.xRel=r,n&&(a.outside=n),a}function Xi(t,e,i){var n=t.doc;if((i+=t.display.viewOffset)<0)return Yi(n.first,0,null,-1,-1);var r=Zt(n,i),a=n.first+n.size-1;if(r>a)return Yi(n.first+n.size-1,Kt(n,a).text.length,null,1,1);e<0&&(e=0);for(var o=Kt(n,r);;){var s=Qi(t,o,r,e,i),l=Pe(o,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==r)return c;o=Kt(n,r=c.line)}}function $i(t,e,i,n){n-=Gi(e);var r=e.text.length,a=at((function(e){return Ri(t,i,e-1).bottom<=n}),r,0);return{begin:a,end:r=at((function(e){return Ri(t,i,e).top>n}),a,r)}}function Zi(t,e,i,n){return i||(i=_i(t,e)),$i(t,e,i,zi(t,e,Ri(t,i,n),"line").top)}function Ji(t,e,i,n){return!(t.bottom<=i)&&(t.top>i||(n?t.left:t.right)>e)}function Qi(t,e,i,n,r){r-=ze(e);var a=_i(t,e),o=Gi(e),s=0,l=e.text.length,c=!0,u=ct(e,t.doc.direction);if(u){var h=(t.options.lineWrapping?en:tn)(t,e,i,a,u,n,r);s=(c=1!=h.level)?h.from:h.to-1,l=c?h.to:h.from-1}var d,f,p=null,m=null,g=at((function(e){var i=Ri(t,a,e);return i.top+=o,i.bottom+=o,!!Ji(i,n,r,!1)&&(i.top<=r&&i.left<=n&&(p=e,m=i),!0)}),s,l),v=!1;if(m){var y=n-m.left<m.right-n,b=y==c;g=p+(b?0:1),f=b?"after":"before",d=y?m.left:m.right}else{c||g!=l&&g!=s||g++,f=0==g?"after":g==e.text.length?"before":Ri(t,a,g-(c?1:0)).bottom+o<=r==c?"after":"before";var x=Ki(t,te(i,g,f),"line",e,a);d=x.left,v=r<x.top?-1:r>=x.bottom?1:0}return Yi(i,g=rt(e.text,g,1),f,v,n-d)}function tn(t,e,i,n,r,a,o){var s=at((function(s){var l=r[s],c=1!=l.level;return Ji(Ki(t,te(i,c?l.to:l.from,c?"before":"after"),"line",e,n),a,o,!0)}),0,r.length-1),l=r[s];if(s>0){var c=1!=l.level,u=Ki(t,te(i,c?l.from:l.to,c?"after":"before"),"line",e,n);Ji(u,a,o,!0)&&u.top>o&&(l=r[s-1])}return l}function en(t,e,i,n,r,a,o){var s=$i(t,e,n,o),l=s.begin,c=s.end;/\s/.test(e.text.charAt(c-1))&&c--;for(var u=null,h=null,d=0;d<r.length;d++){var f=r[d];if(!(f.from>=c||f.to<=l)){var p=Ri(t,n,1!=f.level?Math.min(c,f.to)-1:Math.max(l,f.from)).right,m=p<a?a-p+1e9:p-a;(!u||h>m)&&(u=f,h=m)}}return u||(u=r[r.length-1]),u.from<l&&(u={from:l,to:u.to,level:u.level}),u.to>c&&(u={from:u.from,to:c,level:u.level}),u}function nn(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==Ii){Ii=A("pre",null,"CodeMirror-line-like");for(var e=0;e<49;++e)Ii.appendChild(document.createTextNode("x")),Ii.appendChild(A("br"));Ii.appendChild(document.createTextNode("x"))}L(t.measure,Ii);var i=Ii.offsetHeight/50;return i>3&&(t.cachedTextHeight=i),O(t.measure),i||1}function rn(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=A("span","xxxxxxxxxx"),i=A("pre",[e],"CodeMirror-line-like");L(t.measure,i);var n=e.getBoundingClientRect(),r=(n.right-n.left)/10;return r>2&&(t.cachedCharWidth=r),r||10}function an(t){for(var e=t.display,i={},n={},r=e.gutters.clientLeft,a=e.gutters.firstChild,o=0;a;a=a.nextSibling,++o){var s=t.display.gutterSpecs[o].className;i[s]=a.offsetLeft+a.clientLeft+r,n[s]=a.clientWidth}return{fixedPos:on(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:i,gutterWidth:n,wrapperWidth:e.wrapper.clientWidth}}function on(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function sn(t){var e=nn(t.display),i=t.options.lineWrapping,n=i&&Math.max(5,t.display.scroller.clientWidth/rn(t.display)-3);return function(r){if(He(t.doc,r))return 0;var a=0;if(r.widgets)for(var o=0;o<r.widgets.length;o++)r.widgets[o].height&&(a+=r.widgets[o].height);return i?a+(Math.ceil(r.text.length/n)||1)*e:a+e}}function ln(t){var e=t.doc,i=sn(t);e.iter((function(t){var e=i(t);e!=t.height&&Xt(t,e)}))}function cn(t,e,i,n){var r=t.display;if(!i&&"true"==kt(e).getAttribute("cm-not-content"))return null;var a,o,s=r.lineSpace.getBoundingClientRect();try{a=e.clientX-s.left,o=e.clientY-s.top}catch(t){return null}var l,c=Xi(t,a,o);if(n&&c.xRel>0&&(l=Kt(t.doc,c.line).text).length==c.ch){var u=j(l,l.length,t.options.tabSize)-l.length;c=te(c.line,Math.max(0,Math.round((a-Ei(t.display).left)/rn(t.display))-u))}return c}function un(t,e){if(e>=t.display.viewTo)return null;if((e-=t.display.viewFrom)<0)return null;for(var i=t.display.view,n=0;n<i.length;n++)if((e-=i[n].size)<0)return n}function hn(t,e,i,n){null==e&&(e=t.doc.first),null==i&&(i=t.doc.first+t.doc.size),n||(n=0);var r=t.display;if(n&&i<r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>e)&&(r.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=r.viewTo)Ce&&Be(t.doc,e)<r.viewTo&&fn(t);else if(i<=r.viewFrom)Ce&&Ue(t.doc,i+n)>r.viewFrom?fn(t):(r.viewFrom+=n,r.viewTo+=n);else if(e<=r.viewFrom&&i>=r.viewTo)fn(t);else if(e<=r.viewFrom){var a=pn(t,i,i+n,1);a?(r.view=r.view.slice(a.index),r.viewFrom=a.lineN,r.viewTo+=n):fn(t)}else if(i>=r.viewTo){var o=pn(t,e,e,-1);o?(r.view=r.view.slice(0,o.index),r.viewTo=o.lineN):fn(t)}else{var s=pn(t,e,e,-1),l=pn(t,i,i+n,1);s&&l?(r.view=r.view.slice(0,s.index).concat(ri(t,s.lineN,l.lineN)).concat(r.view.slice(l.index)),r.viewTo+=n):fn(t)}var c=r.externalMeasured;c&&(i<c.lineN?c.lineN+=n:e<c.lineN+c.size&&(r.externalMeasured=null))}function dn(t,e,i){t.curOp.viewChanged=!0;var n=t.display,r=t.display.externalMeasured;if(r&&e>=r.lineN&&e<r.lineN+r.size&&(n.externalMeasured=null),!(e<n.viewFrom||e>=n.viewTo)){var a=n.view[un(t,e)];if(null!=a.node){var o=a.changes||(a.changes=[]);-1==U(o,i)&&o.push(i)}}}function fn(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function pn(t,e,i,n){var r,a=un(t,e),o=t.display.view;if(!Ce||i==t.doc.first+t.doc.size)return{index:a,lineN:i};for(var s=t.display.viewFrom,l=0;l<a;l++)s+=o[l].size;if(s!=e){if(n>0){if(a==o.length-1)return null;r=s+o[a].size-e,a++}else r=s-e;e+=r,i+=r}for(;Be(t.doc,i)!=i;){if(a==(n<0?0:o.length-1))return null;i+=n*o[a-(n<0?1:0)].size,a+=n}return{index:a,lineN:i}}function mn(t){for(var e=t.display.view,i=0,n=0;n<e.length;n++){var r=e[n];r.hidden||r.node&&!r.changes||++i}return i}function gn(t){t.display.input.showSelection(t.display.input.prepareSelection())}function vn(t,e){void 0===e&&(e=!0);for(var i=t.doc,n={},r=n.cursors=document.createDocumentFragment(),a=n.selection=document.createDocumentFragment(),o=0;o<i.sel.ranges.length;o++)if(e||o!=i.sel.primIndex){var s=i.sel.ranges[o];if(!(s.from().line>=t.display.viewTo||s.to().line<t.display.viewFrom)){var l=s.empty();(l||t.options.showCursorWhenSelecting)&&yn(t,s.head,r),l||xn(t,s,a)}}return n}function yn(t,e,i){var n=Ki(t,e,"div",null,null,!t.options.singleCursorHeightPerLine),r=i.appendChild(A("div"," ","CodeMirror-cursor"));if(r.style.left=n.left+"px",r.style.top=n.top+"px",r.style.height=Math.max(0,n.bottom-n.top)*t.options.cursorHeight+"px",n.other){var a=i.appendChild(A("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=n.other.left+"px",a.style.top=n.other.top+"px",a.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function bn(t,e){return t.top-e.top||t.left-e.left}function xn(t,e,i){var n=t.display,r=t.doc,a=document.createDocumentFragment(),o=Ei(t.display),s=o.left,l=Math.max(n.sizerWidth,Ti(t)-n.sizer.offsetLeft)-o.right,c="ltr"==r.direction;function u(t,e,i,n){e<0&&(e=0),e=Math.round(e),n=Math.round(n),a.appendChild(A("div",null,"CodeMirror-selected","position: absolute; left: "+t+"px;\n top: "+e+"px; width: "+(null==i?l-t:i)+"px;\n height: "+(n-e)+"px"))}function h(e,i,n){var a,o,h=Kt(r,e),d=h.text.length;function f(i,n){return Wi(t,te(e,i),"div",h,n)}function p(e,i,n){var r=Zi(t,h,null,e),a="ltr"==i==("after"==n)?"left":"right";return f("after"==n?r.begin:r.end-(/\s/.test(h.text.charAt(r.end-1))?2:1),a)[a]}var m=ct(h,r.direction);return function(t,e,i,n){if(!t)return n(e,i,"ltr",0);for(var r=!1,a=0;a<t.length;++a){var o=t[a];(o.from<i&&o.to>e||e==i&&o.to==e)&&(n(Math.max(o.from,e),Math.min(o.to,i),1==o.level?"rtl":"ltr",a),r=!0)}r||n(e,i,"ltr")}(m,i||0,null==n?d:n,(function(t,e,r,h){var g="ltr"==r,v=f(t,g?"left":"right"),y=f(e-1,g?"right":"left"),b=null==i&&0==t,x=null==n&&e==d,S=0==h,C=!m||h==m.length-1;if(y.top-v.top<=3){var k=(c?x:b)&&C,E=(c?b:x)&&S?s:(g?v:y).left,w=k?l:(g?y:v).right;u(E,v.top,w-E,v.bottom)}else{var T,O,L,A;g?(T=c&&b&&S?s:v.left,O=c?l:p(t,r,"before"),L=c?s:p(e,r,"after"),A=c&&x&&C?l:y.right):(T=c?p(t,r,"before"):s,O=!c&&b&&S?l:v.right,L=!c&&x&&C?s:y.left,A=c?p(e,r,"after"):l),u(T,v.top,O-T,v.bottom),v.bottom<y.top&&u(s,v.bottom,null,y.top),u(L,y.top,A-L,y.bottom)}(!a||bn(v,a)<0)&&(a=v),bn(y,a)<0&&(a=y),(!o||bn(v,o)<0)&&(o=v),bn(y,o)<0&&(o=y)})),{start:a,end:o}}var d=e.from(),f=e.to();if(d.line==f.line)h(d.line,d.ch,f.ch);else{var p=Kt(r,d.line),m=Kt(r,f.line),g=je(p)==je(m),v=h(d.line,d.ch,g?p.text.length+1:null).end,y=h(f.line,g?0:null,f.ch).start;g&&(v.top<y.top-2?(u(v.right,v.top,null,v.bottom),u(s,y.top,y.left,y.bottom)):u(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&u(s,v.bottom,null,y.top)}i.appendChild(a)}function Sn(t){if(t.state.focused){var e=t.display;clearInterval(e.blinker);var i=!0;e.cursorDiv.style.visibility="",t.options.cursorBlinkRate>0?e.blinker=setInterval((function(){t.hasFocus()||wn(t),e.cursorDiv.style.visibility=(i=!i)?"":"hidden"}),t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function Cn(t){t.state.focused||(t.display.input.focus(),En(t))}function kn(t){t.state.delayingBlurEvent=!0,setTimeout((function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,wn(t))}),100)}function En(t,e){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(pt(t,"focus",t,e),t.state.focused=!0,I(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(t.display.input.reset(),l&&setTimeout((function(){return t.display.input.reset(!0)}),20)),t.display.input.receivedFocus()),Sn(t))}function wn(t,e){t.state.delayingBlurEvent||(t.state.focused&&(pt(t,"blur",t,e),t.state.focused=!1,T(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout((function(){t.state.focused||(t.display.shift=!1)}),150))}function Tn(t){for(var e=t.display,i=e.lineDiv.offsetTop,n=0;n<e.view.length;n++){var r=e.view[n],a=t.options.lineWrapping,l=void 0,c=0;if(!r.hidden){if(o&&s<8){var u=r.node.offsetTop+r.node.offsetHeight;l=u-i,i=u}else{var h=r.node.getBoundingClientRect();l=h.bottom-h.top,!a&&r.text.firstChild&&(c=r.text.firstChild.getBoundingClientRect().right-h.left-1)}var d=r.line.height-l;if((d>.005||d<-.005)&&(Xt(r.line,l),On(r.line),r.rest))for(var f=0;f<r.rest.length;f++)On(r.rest[f]);if(c>t.display.sizerWidth){var p=Math.ceil(c/rn(t.display));p>t.display.maxLineLength&&(t.display.maxLineLength=p,t.display.maxLine=r.line,t.display.maxLineChanged=!0)}}}}function On(t){if(t.widgets)for(var e=0;e<t.widgets.length;++e){var i=t.widgets[e],n=i.node.parentNode;n&&(i.height=n.offsetHeight)}}function Ln(t,e,i){var n=i&&null!=i.top?Math.max(0,i.top):t.scroller.scrollTop;n=Math.floor(n-Ci(t));var r=i&&null!=i.bottom?i.bottom:n+t.wrapper.clientHeight,a=Zt(e,n),o=Zt(e,r);if(i&&i.ensure){var s=i.ensure.from.line,l=i.ensure.to.line;s<a?(a=s,o=Zt(e,ze(Kt(e,s))+t.wrapper.clientHeight)):Math.min(l,e.lastLine())>=o&&(a=Zt(e,ze(Kt(e,l))-t.wrapper.clientHeight),o=l)}return{from:a,to:Math.max(o,a+1)}}function An(t,e){var i=t.display,n=nn(t.display);e.top<0&&(e.top=0);var r=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:i.scroller.scrollTop,a=Oi(t),o={};e.bottom-e.top>a&&(e.bottom=e.top+a);var s=t.doc.height+ki(i),l=e.top<n,c=e.bottom>s-n;if(e.top<r)o.scrollTop=l?0:e.top;else if(e.bottom>r+a){var u=Math.min(e.top,(c?s:e.bottom)-a);u!=r&&(o.scrollTop=u)}var h=t.options.fixedGutter?0:i.gutters.offsetWidth,d=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:i.scroller.scrollLeft-h,f=Ti(t)-i.gutters.offsetWidth,p=e.right-e.left>f;return p&&(e.right=e.left+f),e.left<10?o.scrollLeft=0:e.left<d?o.scrollLeft=Math.max(0,e.left+h-(p?0:10)):e.right>f+d-3&&(o.scrollLeft=e.right+(p?0:10)-f),o}function Dn(t,e){null!=e&&(In(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function _n(t){In(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function Rn(t,e,i){null==e&&null==i||In(t),null!=e&&(t.curOp.scrollLeft=e),null!=i&&(t.curOp.scrollTop=i)}function In(t){var e=t.curOp.scrollToPos;e&&(t.curOp.scrollToPos=null,Mn(t,qi(t,e.from),qi(t,e.to),e.margin))}function Mn(t,e,i,n){var r=An(t,{left:Math.min(e.left,i.left),top:Math.min(e.top,i.top)-n,right:Math.max(e.right,i.right),bottom:Math.max(e.bottom,i.bottom)+n});Rn(t,r.scrollLeft,r.scrollTop)}function Nn(t,e){Math.abs(t.doc.scrollTop-e)<2||(i||lr(t,{top:e}),Pn(t,e,!0),i&&lr(t),nr(t,100))}function Pn(t,e,i){e=Math.max(0,Math.min(t.display.scroller.scrollHeight-t.display.scroller.clientHeight,e)),(t.display.scroller.scrollTop!=e||i)&&(t.doc.scrollTop=e,t.display.scrollbars.setScrollTop(e),t.display.scroller.scrollTop!=e&&(t.display.scroller.scrollTop=e))}function Fn(t,e,i,n){e=Math.max(0,Math.min(e,t.display.scroller.scrollWidth-t.display.scroller.clientWidth)),(i?e==t.doc.scrollLeft:Math.abs(t.doc.scrollLeft-e)<2)&&!n||(t.doc.scrollLeft=e,hr(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function jn(t){var e=t.display,i=e.gutters.offsetWidth,n=Math.round(t.doc.height+ki(t.display));return{clientHeight:e.scroller.clientHeight,viewHeight:e.wrapper.clientHeight,scrollWidth:e.scroller.scrollWidth,clientWidth:e.scroller.clientWidth,viewWidth:e.wrapper.clientWidth,barLeft:t.options.fixedGutter?i:0,docHeight:n,scrollHeight:n+wi(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:i}}var Bn=function(t,e,i){this.cm=i;var n=this.vert=A("div",[A("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r=this.horiz=A("div",[A("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=r.tabIndex=-1,t(n),t(r),ht(n,"scroll",(function(){n.clientHeight&&e(n.scrollTop,"vertical")})),ht(r,"scroll",(function(){r.clientWidth&&e(r.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,o&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Bn.prototype.update=function(t){var e=t.scrollWidth>t.clientWidth+1,i=t.scrollHeight>t.clientHeight+1,n=t.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=e?n+"px":"0";var r=t.viewHeight-(e?n:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+r)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(e){this.horiz.style.display="block",this.horiz.style.right=i?n+"px":"0",this.horiz.style.left=t.barLeft+"px";var a=t.viewWidth-t.barLeft-(i?n:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+a)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?n:0,bottom:e?n:0}},Bn.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Bn.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Bn.prototype.zeroWidthHack=function(){var t=y&&!f?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new B,this.disableVert=new B},Bn.prototype.enableZeroWidthBar=function(t,e,i){t.style.pointerEvents="auto",e.set(1e3,(function n(){var r=t.getBoundingClientRect();("vert"==i?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1))!=t?t.style.pointerEvents="none":e.set(1e3,n)}))},Bn.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var Un=function(){};function Hn(t,e){e||(e=jn(t));var i=t.display.barWidth,n=t.display.barHeight;Gn(t,e);for(var r=0;r<4&&i!=t.display.barWidth||n!=t.display.barHeight;r++)i!=t.display.barWidth&&t.options.lineWrapping&&Tn(t),Gn(t,jn(t)),i=t.display.barWidth,n=t.display.barHeight}function Gn(t,e){var i=t.display,n=i.scrollbars.update(e);i.sizer.style.paddingRight=(i.barWidth=n.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=n.bottom)+"px",i.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=n.bottom+"px",i.scrollbarFiller.style.width=n.right+"px"):i.scrollbarFiller.style.display="",n.bottom&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=n.bottom+"px",i.gutterFiller.style.width=e.gutterWidth+"px"):i.gutterFiller.style.display=""}Un.prototype.update=function(){return{bottom:0,right:0}},Un.prototype.setScrollLeft=function(){},Un.prototype.setScrollTop=function(){},Un.prototype.clear=function(){};var zn={native:Bn,null:Un};function Vn(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&T(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new zn[t.options.scrollbarStyle]((function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ht(e,"mousedown",(function(){t.state.focused&&setTimeout((function(){return t.display.input.focus()}),0)})),e.setAttribute("cm-not-content","true")}),(function(e,i){"horizontal"==i?Fn(t,e):Nn(t,e)}),t),t.display.scrollbars.addClass&&I(t.display.wrapper,t.display.scrollbars.addClass)}var Wn=0;function Kn(t){var e;t.curOp={cm:t,viewChanged:!1,startHeight:t.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:++Wn},e=t.curOp,ai?ai.ops.push(e):e.ownsGroup=ai={ops:[e],delayedCallbacks:[]}}function qn(t){var e=t.curOp;e&&function(t,e){var i=t.ownsGroup;if(i)try{!function(t){var e=t.delayedCallbacks,i=0;do{for(;i<e.length;i++)e[i].call(null);for(var n=0;n<t.ops.length;n++){var r=t.ops[n];if(r.cursorActivityHandlers)for(;r.cursorActivityCalled<r.cursorActivityHandlers.length;)r.cursorActivityHandlers[r.cursorActivityCalled++].call(null,r.cm)}}while(i<e.length)}(i)}finally{ai=null,e(i)}}(e,(function(t){for(var e=0;e<t.ops.length;e++)t.ops[e].cm.curOp=null;!function(t){for(var e=t.ops,i=0;i<e.length;i++)Yn(e[i]);for(var n=0;n<e.length;n++)Xn(e[n]);for(var r=0;r<e.length;r++)$n(e[r]);for(var a=0;a<e.length;a++)Zn(e[a]);for(var o=0;o<e.length;o++)Jn(e[o])}(t)}))}function Yn(t){var e=t.cm,i=e.display;!function(t){var e=t.display;!e.scrollbarsClipped&&e.scroller.offsetWidth&&(e.nativeBarWidth=e.scroller.offsetWidth-e.scroller.clientWidth,e.heightForcer.style.height=wi(t)+"px",e.sizer.style.marginBottom=-e.nativeBarWidth+"px",e.sizer.style.borderRightWidth=wi(t)+"px",e.scrollbarsClipped=!0)}(e),t.updateMaxLine&&We(e),t.mustUpdate=t.viewChanged||t.forceUpdate||null!=t.scrollTop||t.scrollToPos&&(t.scrollToPos.from.line<i.viewFrom||t.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new ar(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function Xn(t){t.updatedDisplay=t.mustUpdate&&or(t.cm,t.update)}function $n(t){var e=t.cm,i=e.display;t.updatedDisplay&&Tn(e),t.barMeasure=jn(e),i.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=Ai(e,i.maxLine,i.maxLine.text.length).left+3,e.display.sizerWidth=t.adjustWidthTo,t.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+t.adjustWidthTo+wi(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+t.adjustWidthTo-Ti(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=i.input.prepareSelection())}function Zn(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLeft<e.doc.scrollLeft&&Fn(e,Math.min(e.display.scroller.scrollLeft,t.maxScrollLeft),!0),e.display.maxLineChanged=!1);var i=t.focus&&t.focus==R();t.preparedSelection&&e.display.input.showSelection(t.preparedSelection,i),(t.updatedDisplay||t.startHeight!=e.doc.height)&&Hn(e,t.barMeasure),t.updatedDisplay&&ur(e,t.barMeasure),t.selectionChanged&&Sn(e),e.state.focused&&t.updateInput&&e.display.input.reset(t.typing),i&&Cn(t.cm)}function Jn(t){var e=t.cm,i=e.display,n=e.doc;t.updatedDisplay&&sr(e,t.update),null==i.wheelStartX||null==t.scrollTop&&null==t.scrollLeft&&!t.scrollToPos||(i.wheelStartX=i.wheelStartY=null),null!=t.scrollTop&&Pn(e,t.scrollTop,t.forceScroll),null!=t.scrollLeft&&Fn(e,t.scrollLeft,!0,!0),t.scrollToPos&&function(t,e){if(!mt(t,"scrollCursorIntoView")){var i=t.display,n=i.sizer.getBoundingClientRect(),r=null;if(e.top+n.top<0?r=!0:e.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1),null!=r&&!p){var a=A("div","",null,"position: absolute;\n top: "+(e.top-i.viewOffset-Ci(t.display))+"px;\n height: "+(e.bottom-e.top+wi(t)+i.barHeight)+"px;\n left: "+e.left+"px; width: "+Math.max(2,e.right-e.left)+"px;");t.display.lineSpace.appendChild(a),a.scrollIntoView(r),t.display.lineSpace.removeChild(a)}}}(e,function(t,e,i,n){var r;null==n&&(n=0),t.options.lineWrapping||e!=i||(i="before"==(e=e.ch?te(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e).sticky?te(e.line,e.ch+1,"before"):e);for(var a=0;a<5;a++){var o=!1,s=Ki(t,e),l=i&&i!=e?Ki(t,i):s,c=An(t,r={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-n,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+n}),u=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=c.scrollTop&&(Nn(t,c.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(o=!0)),null!=c.scrollLeft&&(Fn(t,c.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(o=!0)),!o)break}return r}(e,se(n,t.scrollToPos.from),se(n,t.scrollToPos.to),t.scrollToPos.margin));var r=t.maybeHiddenMarkers,a=t.maybeUnhiddenMarkers;if(r)for(var o=0;o<r.length;++o)r[o].lines.length||pt(r[o],"hide");if(a)for(var s=0;s<a.length;++s)a[s].lines.length&&pt(a[s],"unhide");i.wrapper.offsetHeight&&(n.scrollTop=e.display.scroller.scrollTop),t.changeObjs&&pt(e,"changes",e,t.changeObjs),t.update&&t.update.finish()}function Qn(t,e){if(t.curOp)return e();Kn(t);try{return e()}finally{qn(t)}}function tr(t,e){return function(){if(t.curOp)return e.apply(t,arguments);Kn(t);try{return e.apply(t,arguments)}finally{qn(t)}}}function er(t){return function(){if(this.curOp)return t.apply(this,arguments);Kn(this);try{return t.apply(this,arguments)}finally{qn(this)}}}function ir(t){return function(){var e=this.cm;if(!e||e.curOp)return t.apply(this,arguments);Kn(e);try{return t.apply(this,arguments)}finally{qn(e)}}}function nr(t,e){t.doc.highlightFrontier<t.display.viewTo&&t.state.highlight.set(e,P(rr,t))}function rr(t){var e=t.doc;if(!(e.highlightFrontier>=t.display.viewTo)){var i=+new Date+t.options.workTime,n=fe(t,e.highlightFrontier),r=[];e.iter(n.line,Math.min(e.first+e.size,t.display.viewTo+500),(function(a){if(n.line>=t.display.viewFrom){var o=a.styles,s=a.text.length>t.options.maxHighlightLength?Gt(e.mode,n.state):null,l=he(t,a,n,!0);s&&(n.state=s),a.styles=l.styles;var c=a.styleClasses,u=l.classes;u?a.styleClasses=u:c&&(a.styleClasses=null);for(var h=!o||o.length!=a.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),d=0;!h&&d<o.length;++d)h=o[d]!=a.styles[d];h&&r.push(n.line),a.stateAfter=n.save(),n.nextLine()}else a.text.length<=t.options.maxHighlightLength&&pe(t,a.text,n),a.stateAfter=n.line%5==0?n.save():null,n.nextLine();if(+new Date>i)return nr(t,t.options.workDelay),!0})),e.highlightFrontier=n.line,e.modeFrontier=Math.max(e.modeFrontier,n.line),r.length&&Qn(t,(function(){for(var e=0;e<r.length;e++)dn(t,r[e],"text")}))}}var ar=function(t,e,i){var n=t.display;this.viewport=e,this.visible=Ln(n,t.doc,e),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ti(t),this.force=i,this.dims=an(t),this.events=[]};function or(t,e){var i=t.display,n=t.doc;if(e.editorIsHidden)return fn(t),!1;if(!e.force&&e.visible.from>=i.viewFrom&&e.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==mn(t))return!1;dr(t)&&(fn(t),e.dims=an(t));var r=n.first+n.size,a=Math.max(e.visible.from-t.options.viewportMargin,n.first),o=Math.min(r,e.visible.to+t.options.viewportMargin);i.viewFrom<a&&a-i.viewFrom<20&&(a=Math.max(n.first,i.viewFrom)),i.viewTo>o&&i.viewTo-o<20&&(o=Math.min(r,i.viewTo)),Ce&&(a=Be(t.doc,a),o=Ue(t.doc,o));var s=a!=i.viewFrom||o!=i.viewTo||i.lastWrapHeight!=e.wrapperHeight||i.lastWrapWidth!=e.wrapperWidth;!function(t,e,i){var n=t.display;0==n.view.length||e>=n.viewTo||i<=n.viewFrom?(n.view=ri(t,e,i),n.viewFrom=e):(n.viewFrom>e?n.view=ri(t,e,n.viewFrom).concat(n.view):n.viewFrom<e&&(n.view=n.view.slice(un(t,e))),n.viewFrom=e,n.viewTo<i?n.view=n.view.concat(ri(t,n.viewTo,i)):n.viewTo>i&&(n.view=n.view.slice(0,un(t,i)))),n.viewTo=i}(t,a,o),i.viewOffset=ze(Kt(t.doc,i.viewFrom)),t.display.mover.style.top=i.viewOffset+"px";var c=mn(t);if(!s&&0==c&&!e.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;var u=function(t){if(t.hasFocus())return null;var e=R();if(!e||!_(t.display.lineDiv,e))return null;var i={activeElt:e};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&_(t.display.lineDiv,n.anchorNode)&&(i.anchorNode=n.anchorNode,i.anchorOffset=n.anchorOffset,i.focusNode=n.focusNode,i.focusOffset=n.focusOffset)}return i}(t);return c>4&&(i.lineDiv.style.display="none"),function(t,e,i){var n=t.display,r=t.options.lineNumbers,a=n.lineDiv,o=a.firstChild;function s(e){var i=e.nextSibling;return l&&y&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),i}for(var c=n.view,u=n.viewFrom,h=0;h<c.length;h++){var d=c[h];if(d.hidden);else if(d.node&&d.node.parentNode==a){for(;o!=d.node;)o=s(o);var f=r&&null!=e&&e<=u&&d.lineNumber;d.changes&&(U(d.changes,"gutter")>-1&&(f=!1),ci(t,d,u,i)),f&&(O(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(Qt(t.options,u)))),o=d.node.nextSibling}else{var p=gi(t,d,u,i);a.insertBefore(p,o)}u+=d.size}for(;o;)o=s(o)}(t,i.updateLineNumbers,e.dims),c>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,function(t){if(t&&t.activeElt&&t.activeElt!=R()&&(t.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(t.activeElt.nodeName)&&t.anchorNode&&_(document.body,t.anchorNode)&&_(document.body,t.focusNode))){var e=window.getSelection(),i=document.createRange();i.setEnd(t.anchorNode,t.anchorOffset),i.collapse(!1),e.removeAllRanges(),e.addRange(i),e.extend(t.focusNode,t.focusOffset)}}(u),O(i.cursorDiv),O(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,s&&(i.lastWrapHeight=e.wrapperHeight,i.lastWrapWidth=e.wrapperWidth,nr(t,400)),i.updateLineNumbers=null,!0}function sr(t,e){for(var i=e.viewport,n=!0;;n=!1){if(n&&t.options.lineWrapping&&e.oldDisplayWidth!=Ti(t))n&&(e.visible=Ln(t.display,t.doc,i));else if(i&&null!=i.top&&(i={top:Math.min(t.doc.height+ki(t.display)-Oi(t),i.top)}),e.visible=Ln(t.display,t.doc,i),e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)break;if(!or(t,e))break;Tn(t);var r=jn(t);gn(t),Hn(t,r),ur(t,r),e.force=!1}e.signal(t,"update",t),t.display.viewFrom==t.display.reportedViewFrom&&t.display.viewTo==t.display.reportedViewTo||(e.signal(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo),t.display.reportedViewFrom=t.display.viewFrom,t.display.reportedViewTo=t.display.viewTo)}function lr(t,e){var i=new ar(t,e);if(or(t,i)){Tn(t),sr(t,i);var n=jn(t);gn(t),Hn(t,n),ur(t,n),i.finish()}}function cr(t){var e=t.gutters.offsetWidth;t.sizer.style.marginLeft=e+"px"}function ur(t,e){t.display.sizer.style.minHeight=e.docHeight+"px",t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=e.docHeight+t.display.barHeight+wi(t)+"px"}function hr(t){var e=t.display,i=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var n=on(e)-e.scroller.scrollLeft+t.doc.scrollLeft,r=e.gutters.offsetWidth,a=n+"px",o=0;o<i.length;o++)if(!i[o].hidden){t.options.fixedGutter&&(i[o].gutter&&(i[o].gutter.style.left=a),i[o].gutterBackground&&(i[o].gutterBackground.style.left=a));var s=i[o].alignable;if(s)for(var l=0;l<s.length;l++)s[l].style.left=a}t.options.fixedGutter&&(e.gutters.style.left=n+r+"px")}}function dr(t){if(!t.options.lineNumbers)return!1;var e=t.doc,i=Qt(t.options,e.first+e.size-1),n=t.display;if(i.length!=n.lineNumChars){var r=n.measure.appendChild(A("div",[A("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),a=r.firstChild.offsetWidth,o=r.offsetWidth-a;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(a,n.lineGutter.offsetWidth-o)+1,n.lineNumWidth=n.lineNumInnerWidth+o,n.lineNumChars=n.lineNumInnerWidth?i.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",cr(t.display),!0}return!1}function fr(t,e){for(var i=[],n=!1,r=0;r<t.length;r++){var a=t[r],o=null;if("string"!=typeof a&&(o=a.style,a=a.className),"CodeMirror-linenumbers"==a){if(!e)continue;n=!0}i.push({className:a,style:o})}return e&&!n&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function pr(t){var e=t.gutters,i=t.gutterSpecs;O(e),t.lineGutter=null;for(var n=0;n<i.length;++n){var r=i[n],a=r.className,o=r.style,s=e.appendChild(A("div",null,"CodeMirror-gutter "+a));o&&(s.style.cssText=o),"CodeMirror-linenumbers"==a&&(t.lineGutter=s,s.style.width=(t.lineNumWidth||1)+"px")}e.style.display=i.length?"":"none",cr(t)}function mr(t){pr(t.display),hn(t),hr(t)}function gr(t,e,n,r){var a=this;this.input=n,a.scrollbarFiller=A("div",null,"CodeMirror-scrollbar-filler"),a.scrollbarFiller.setAttribute("cm-not-content","true"),a.gutterFiller=A("div",null,"CodeMirror-gutter-filler"),a.gutterFiller.setAttribute("cm-not-content","true"),a.lineDiv=D("div",null,"CodeMirror-code"),a.selectionDiv=A("div",null,null,"position: relative; z-index: 1"),a.cursorDiv=A("div",null,"CodeMirror-cursors"),a.measure=A("div",null,"CodeMirror-measure"),a.lineMeasure=A("div",null,"CodeMirror-measure"),a.lineSpace=D("div",[a.measure,a.lineMeasure,a.selectionDiv,a.cursorDiv,a.lineDiv],null,"position: relative; outline: none");var c=D("div",[a.lineSpace],"CodeMirror-lines");a.mover=A("div",[c],null,"position: relative"),a.sizer=A("div",[a.mover],"CodeMirror-sizer"),a.sizerWidth=null,a.heightForcer=A("div",null,null,"position: absolute; height: 50px; width: 1px;"),a.gutters=A("div",null,"CodeMirror-gutters"),a.lineGutter=null,a.scroller=A("div",[a.sizer,a.heightForcer,a.gutters],"CodeMirror-scroll"),a.scroller.setAttribute("tabIndex","-1"),a.wrapper=A("div",[a.scrollbarFiller,a.gutterFiller,a.scroller],"CodeMirror"),o&&s<8&&(a.gutters.style.zIndex=-1,a.scroller.style.paddingRight=0),l||i&&v||(a.scroller.draggable=!0),t&&(t.appendChild?t.appendChild(a.wrapper):t(a.wrapper)),a.viewFrom=a.viewTo=e.first,a.reportedViewFrom=a.reportedViewTo=e.first,a.view=[],a.renderedView=null,a.externalMeasured=null,a.viewOffset=0,a.lastWrapHeight=a.lastWrapWidth=0,a.updateLineNumbers=null,a.nativeBarWidth=a.barHeight=a.barWidth=0,a.scrollbarsClipped=!1,a.lineNumWidth=a.lineNumInnerWidth=a.lineNumChars=null,a.alignWidgets=!1,a.cachedCharWidth=a.cachedTextHeight=a.cachedPaddingH=null,a.maxLine=null,a.maxLineLength=0,a.maxLineChanged=!1,a.wheelDX=a.wheelDY=a.wheelStartX=a.wheelStartY=null,a.shift=!1,a.selForContextMenu=null,a.activeTouch=null,a.gutterSpecs=fr(r.gutters,r.lineNumbers),pr(a),n.init(a)}ar.prototype.signal=function(t,e){vt(t,e)&&this.events.push(arguments)},ar.prototype.finish=function(){for(var t=0;t<this.events.length;t++)pt.apply(null,this.events[t])};var vr=0,yr=null;function br(t){var e=t.wheelDeltaX,i=t.wheelDeltaY;return null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(e=t.detail),null==i&&t.detail&&t.axis==t.VERTICAL_AXIS?i=t.detail:null==i&&(i=t.wheelDelta),{x:e,y:i}}function xr(t){var e=br(t);return e.x*=yr,e.y*=yr,e}function Sr(t,e){var n=br(e),r=n.x,a=n.y,o=t.display,s=o.scroller,c=s.scrollWidth>s.clientWidth,u=s.scrollHeight>s.clientHeight;if(r&&c||a&&u){if(a&&y&&l)t:for(var d=e.target,f=o.view;d!=s;d=d.parentNode)for(var p=0;p<f.length;p++)if(f[p].node==d){t.display.currentWheelTarget=d;break t}if(r&&!i&&!h&&null!=yr)return a&&u&&Nn(t,Math.max(0,s.scrollTop+a*yr)),Fn(t,Math.max(0,s.scrollLeft+r*yr)),(!a||a&&u)&&bt(e),void(o.wheelStartX=null);if(a&&null!=yr){var m=a*yr,g=t.doc.scrollTop,v=g+o.wrapper.clientHeight;m<0?g=Math.max(0,g+m-50):v=Math.min(t.doc.height,v+m+50),lr(t,{top:g,bottom:v})}vr<20&&(null==o.wheelStartX?(o.wheelStartX=s.scrollLeft,o.wheelStartY=s.scrollTop,o.wheelDX=r,o.wheelDY=a,setTimeout((function(){if(null!=o.wheelStartX){var t=s.scrollLeft-o.wheelStartX,e=s.scrollTop-o.wheelStartY,i=e&&o.wheelDY&&e/o.wheelDY||t&&o.wheelDX&&t/o.wheelDX;o.wheelStartX=o.wheelStartY=null,i&&(yr=(yr*vr+i)/(vr+1),++vr)}}),200)):(o.wheelDX+=r,o.wheelDY+=a))}}o?yr=-.53:i?yr=15:u?yr=-.7:d&&(yr=-1/3);var Cr=function(t,e){this.ranges=t,this.primIndex=e};Cr.prototype.primary=function(){return this.ranges[this.primIndex]},Cr.prototype.equals=function(t){if(t==this)return!0;if(t.primIndex!=this.primIndex||t.ranges.length!=this.ranges.length)return!1;for(var e=0;e<this.ranges.length;e++){var i=this.ranges[e],n=t.ranges[e];if(!ie(i.anchor,n.anchor)||!ie(i.head,n.head))return!1}return!0},Cr.prototype.deepCopy=function(){for(var t=[],e=0;e<this.ranges.length;e++)t[e]=new kr(ne(this.ranges[e].anchor),ne(this.ranges[e].head));return new Cr(t,this.primIndex)},Cr.prototype.somethingSelected=function(){for(var t=0;t<this.ranges.length;t++)if(!this.ranges[t].empty())return!0;return!1},Cr.prototype.contains=function(t,e){e||(e=t);for(var i=0;i<this.ranges.length;i++){var n=this.ranges[i];if(ee(e,n.from())>=0&&ee(t,n.to())<=0)return i}return-1};var kr=function(t,e){this.anchor=t,this.head=e};function Er(t,e,i){var n=t&&t.options.selectionsMayTouch,r=e[i];e.sort((function(t,e){return ee(t.from(),e.from())})),i=U(e,r);for(var a=1;a<e.length;a++){var o=e[a],s=e[a-1],l=ee(s.to(),o.from());if(n&&!o.empty()?l>0:l>=0){var c=ae(s.from(),o.from()),u=re(s.to(),o.to()),h=s.empty()?o.from()==o.head:s.from()==s.head;a<=i&&--i,e.splice(--a,2,new kr(h?u:c,h?c:u))}}return new Cr(e,i)}function wr(t,e){return new Cr([new kr(t,e||t)],0)}function Tr(t){return t.text?te(t.from.line+t.text.length-1,Y(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function Or(t,e){if(ee(t,e.from)<0)return t;if(ee(t,e.to)<=0)return Tr(e);var i=t.line+e.text.length-(e.to.line-e.from.line)-1,n=t.ch;return t.line==e.to.line&&(n+=Tr(e).ch-e.to.ch),te(i,n)}function Lr(t,e){for(var i=[],n=0;n<t.sel.ranges.length;n++){var r=t.sel.ranges[n];i.push(new kr(Or(r.anchor,e),Or(r.head,e)))}return Er(t.cm,i,t.sel.primIndex)}function Ar(t,e,i){return t.line==e.line?te(i.line,t.ch-e.ch+i.ch):te(i.line+(t.line-e.line),t.ch)}function Dr(t){t.doc.mode=Bt(t.options,t.doc.modeOption),_r(t)}function _r(t){t.doc.iter((function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)})),t.doc.modeFrontier=t.doc.highlightFrontier=t.doc.first,nr(t,100),t.state.modeGen++,t.curOp&&hn(t)}function Rr(t,e){return 0==e.from.ch&&0==e.to.ch&&""==Y(e.text)&&(!t.cm||t.cm.options.wholeLineUpdateBefore)}function Ir(t,e,i,n){function r(t){return i?i[t]:null}function a(t,i,r){!function(t,e,i,n){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Le(t),Ae(t,i);var r=n?n(t):1;r!=t.height&&Xt(t,r)}(t,i,r,n),si(t,"change",t,e)}function o(t,e){for(var i=[],a=t;a<e;++a)i.push(new Ke(c[a],r(a),n));return i}var s=e.from,l=e.to,c=e.text,u=Kt(t,s.line),h=Kt(t,l.line),d=Y(c),f=r(c.length-1),p=l.line-s.line;if(e.full)t.insert(0,o(0,c.length)),t.remove(c.length,t.size-c.length);else if(Rr(t,e)){var m=o(0,c.length-1);a(h,h.text,f),p&&t.remove(s.line,p),m.length&&t.insert(s.line,m)}else if(u==h)if(1==c.length)a(u,u.text.slice(0,s.ch)+d+u.text.slice(l.ch),f);else{var g=o(1,c.length-1);g.push(new Ke(d+u.text.slice(l.ch),f,n)),a(u,u.text.slice(0,s.ch)+c[0],r(0)),t.insert(s.line+1,g)}else if(1==c.length)a(u,u.text.slice(0,s.ch)+c[0]+h.text.slice(l.ch),r(0)),t.remove(s.line+1,p);else{a(u,u.text.slice(0,s.ch)+c[0],r(0)),a(h,d+h.text.slice(l.ch),f);var v=o(1,c.length-1);p>1&&t.remove(s.line+1,p-1),t.insert(s.line+1,v)}si(t,"change",t,e)}function Mr(t,e,i){!function t(n,r,a){if(n.linked)for(var o=0;o<n.linked.length;++o){var s=n.linked[o];if(s.doc!=r){var l=a&&s.sharedHist;i&&!l||(e(s.doc,l),t(s.doc,n,l))}}}(t,null,!0)}function Nr(t,e){if(e.cm)throw new Error("This document is already in use.");t.doc=e,e.cm=t,ln(t),Dr(t),Pr(t),t.options.lineWrapping||We(t),t.options.mode=e.modeOption,hn(t)}function Pr(t){("rtl"==t.doc.direction?I:T)(t.display.lineDiv,"CodeMirror-rtl")}function Fr(t){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=t||1}function jr(t,e){var i={from:ne(e.from),to:Tr(e),text:qt(t,e.from,e.to)};return zr(t,i,e.from.line,e.to.line+1),Mr(t,(function(t){return zr(t,i,e.from.line,e.to.line+1)}),!0),i}function Br(t){for(;t.length&&Y(t).ranges;)t.pop()}function Ur(t,e,i,n){var r=t.history;r.undone.length=0;var a,o,s=+new Date;if((r.lastOp==n||r.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&r.lastModTime>s-(t.cm?t.cm.options.historyEventDelay:500)||"*"==e.origin.charAt(0)))&&(a=function(t,e){return e?(Br(t.done),Y(t.done)):t.done.length&&!Y(t.done).ranges?Y(t.done):t.done.length>1&&!t.done[t.done.length-2].ranges?(t.done.pop(),Y(t.done)):void 0}(r,r.lastOp==n)))o=Y(a.changes),0==ee(e.from,e.to)&&0==ee(e.from,o.to)?o.to=Tr(e):a.changes.push(jr(t,e));else{var l=Y(r.done);for(l&&l.ranges||Gr(t.sel,r.done),a={changes:[jr(t,e)],generation:r.generation},r.done.push(a);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(i),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=s,r.lastOp=r.lastSelOp=n,r.lastOrigin=r.lastSelOrigin=e.origin,o||pt(t,"historyAdded")}function Hr(t,e,i,n){var r=t.history,a=n&&n.origin;i==r.lastSelOp||a&&r.lastSelOrigin==a&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==a||function(t,e,i,n){var r=e.charAt(0);return"*"==r||"+"==r&&i.ranges.length==n.ranges.length&&i.somethingSelected()==n.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}(t,a,Y(r.done),e))?r.done[r.done.length-1]=e:Gr(e,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=a,r.lastSelOp=i,n&&!1!==n.clearRedo&&Br(r.undone)}function Gr(t,e){var i=Y(e);i&&i.ranges&&i.equals(t)||e.push(t)}function zr(t,e,i,n){var r=e["spans_"+t.id],a=0;t.iter(Math.max(t.first,i),Math.min(t.first+t.size,n),(function(i){i.markedSpans&&((r||(r=e["spans_"+t.id]={}))[a]=i.markedSpans),++a}))}function Vr(t){if(!t)return null;for(var e,i=0;i<t.length;++i)t[i].marker.explicitlyCleared?e||(e=t.slice(0,i)):e&&e.push(t[i]);return e?e.length?e:null:t}function Wr(t,e){var i=function(t,e){var i=e["spans_"+t.id];if(!i)return null;for(var n=[],r=0;r<e.text.length;++r)n.push(Vr(i[r]));return n}(t,e),n=Te(t,e);if(!i)return n;if(!n)return i;for(var r=0;r<i.length;++r){var a=i[r],o=n[r];if(a&&o)t:for(var s=0;s<o.length;++s){for(var l=o[s],c=0;c<a.length;++c)if(a[c].marker==l.marker)continue t;a.push(l)}else o&&(i[r]=o)}return i}function Kr(t,e,i){for(var n=[],r=0;r<t.length;++r){var a=t[r];if(a.ranges)n.push(i?Cr.prototype.deepCopy.call(a):a);else{var o=a.changes,s=[];n.push({changes:s});for(var l=0;l<o.length;++l){var c=o[l],u=void 0;if(s.push({from:c.from,to:c.to,text:c.text}),e)for(var h in c)(u=h.match(/^spans_(\d+)$/))&&U(e,Number(u[1]))>-1&&(Y(s)[h]=c[h],delete c[h])}}}return n}function qr(t,e,i,n){if(n){var r=t.anchor;if(i){var a=ee(e,r)<0;a!=ee(i,r)<0?(r=e,e=i):a!=ee(e,i)<0&&(e=i)}return new kr(r,e)}return new kr(i||e,e)}function Yr(t,e,i,n,r){null==r&&(r=t.cm&&(t.cm.display.shift||t.extend)),Qr(t,new Cr([qr(t.sel.primary(),e,i,r)],0),n)}function Xr(t,e,i){for(var n=[],r=t.cm&&(t.cm.display.shift||t.extend),a=0;a<t.sel.ranges.length;a++)n[a]=qr(t.sel.ranges[a],e[a],null,r);Qr(t,Er(t.cm,n,t.sel.primIndex),i)}function $r(t,e,i,n){var r=t.sel.ranges.slice(0);r[e]=i,Qr(t,Er(t.cm,r,t.sel.primIndex),n)}function Zr(t,e,i,n){Qr(t,wr(e,i),n)}function Jr(t,e,i){var n=t.history.done,r=Y(n);r&&r.ranges?(n[n.length-1]=e,ta(t,e,i)):Qr(t,e,i)}function Qr(t,e,i){ta(t,e,i),Hr(t,t.sel,t.cm?t.cm.curOp.id:NaN,i)}function ta(t,e,i){(vt(t,"beforeSelectionChange")||t.cm&&vt(t.cm,"beforeSelectionChange"))&&(e=function(t,e,i){var n={ranges:e.ranges,update:function(e){this.ranges=[];for(var i=0;i<e.length;i++)this.ranges[i]=new kr(se(t,e[i].anchor),se(t,e[i].head))},origin:i&&i.origin};return pt(t,"beforeSelectionChange",t,n),t.cm&&pt(t.cm,"beforeSelectionChange",t.cm,n),n.ranges!=e.ranges?Er(t.cm,n.ranges,n.ranges.length-1):e}(t,e,i));var n=i&&i.bias||(ee(e.primary().head,t.sel.primary().head)<0?-1:1);ea(t,na(t,e,n,!0)),i&&!1===i.scroll||!t.cm||_n(t.cm)}function ea(t,e){e.equals(t.sel)||(t.sel=e,t.cm&&(t.cm.curOp.updateInput=1,t.cm.curOp.selectionChanged=!0,gt(t.cm)),si(t,"cursorActivity",t))}function ia(t){ea(t,na(t,t.sel,null,!1))}function na(t,e,i,n){for(var r,a=0;a<e.ranges.length;a++){var o=e.ranges[a],s=e.ranges.length==t.sel.ranges.length&&t.sel.ranges[a],l=aa(t,o.anchor,s&&s.anchor,i,n),c=aa(t,o.head,s&&s.head,i,n);(r||l!=o.anchor||c!=o.head)&&(r||(r=e.ranges.slice(0,a)),r[a]=new kr(l,c))}return r?Er(t.cm,r,e.primIndex):e}function ra(t,e,i,n,r){var a=Kt(t,e.line);if(a.markedSpans)for(var o=0;o<a.markedSpans.length;++o){var s=a.markedSpans[o],l=s.marker,c="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,u="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==s.from||(c?s.from<=e.ch:s.from<e.ch))&&(null==s.to||(u?s.to>=e.ch:s.to>e.ch))){if(r&&(pt(l,"beforeCursorEnter"),l.explicitlyCleared)){if(a.markedSpans){--o;continue}break}if(!l.atomic)continue;if(i){var h=l.find(n<0?1:-1),d=void 0;if((n<0?u:c)&&(h=oa(t,h,-n,h&&h.line==e.line?a:null)),h&&h.line==e.line&&(d=ee(h,i))&&(n<0?d<0:d>0))return ra(t,h,e,n,r)}var f=l.find(n<0?-1:1);return(n<0?c:u)&&(f=oa(t,f,n,f.line==e.line?a:null)),f?ra(t,f,e,n,r):null}}return e}function aa(t,e,i,n,r){var a=n||1,o=ra(t,e,i,a,r)||!r&&ra(t,e,i,a,!0)||ra(t,e,i,-a,r)||!r&&ra(t,e,i,-a,!0);return o||(t.cantEdit=!0,te(t.first,0))}function oa(t,e,i,n){return i<0&&0==e.ch?e.line>t.first?se(t,te(e.line-1)):null:i>0&&e.ch==(n||Kt(t,e.line)).text.length?e.line<t.first+t.size-1?te(e.line+1,0):null:new te(e.line,e.ch+i)}function sa(t){t.setSelection(te(t.firstLine(),0),te(t.lastLine()),G)}function la(t,e,i){var n={canceled:!1,from:e.from,to:e.to,text:e.text,origin:e.origin,cancel:function(){return n.canceled=!0}};return i&&(n.update=function(e,i,r,a){e&&(n.from=se(t,e)),i&&(n.to=se(t,i)),r&&(n.text=r),void 0!==a&&(n.origin=a)}),pt(t,"beforeChange",t,n),t.cm&&pt(t.cm,"beforeChange",t.cm,n),n.canceled?(t.cm&&(t.cm.curOp.updateInput=2),null):{from:n.from,to:n.to,text:n.text,origin:n.origin}}function ca(t,e,i){if(t.cm){if(!t.cm.curOp)return tr(t.cm,ca)(t,e,i);if(t.cm.state.suppressEdits)return}if(!(vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"))||(e=la(t,e,!0))){var n=Se&&!i&&function(t,e,i){var n=null;if(t.iter(e.line,i.line+1,(function(t){if(t.markedSpans)for(var e=0;e<t.markedSpans.length;++e){var i=t.markedSpans[e].marker;!i.readOnly||n&&-1!=U(n,i)||(n||(n=[])).push(i)}})),!n)return null;for(var r=[{from:e,to:i}],a=0;a<n.length;++a)for(var o=n[a],s=o.find(0),l=0;l<r.length;++l){var c=r[l];if(!(ee(c.to,s.from)<0||ee(c.from,s.to)>0)){var u=[l,1],h=ee(c.from,s.from),d=ee(c.to,s.to);(h<0||!o.inclusiveLeft&&!h)&&u.push({from:c.from,to:s.from}),(d>0||!o.inclusiveRight&&!d)&&u.push({from:s.to,to:c.to}),r.splice.apply(r,u),l+=u.length-3}}return r}(t,e.from,e.to);if(n)for(var r=n.length-1;r>=0;--r)ua(t,{from:n[r].from,to:n[r].to,text:r?[""]:e.text,origin:e.origin});else ua(t,e)}}function ua(t,e){if(1!=e.text.length||""!=e.text[0]||0!=ee(e.from,e.to)){var i=Lr(t,e);Ur(t,e,i,t.cm?t.cm.curOp.id:NaN),fa(t,e,i,Te(t,e));var n=[];Mr(t,(function(t,i){i||-1!=U(n,t.history)||(va(t.history,e),n.push(t.history)),fa(t,e,null,Te(t,e))}))}}function ha(t,e,i){var n=t.cm&&t.cm.state.suppressEdits;if(!n||i){for(var r,a=t.history,o=t.sel,s="undo"==e?a.done:a.undone,l="undo"==e?a.undone:a.done,c=0;c<s.length&&(r=s[c],i?!r.ranges||r.equals(t.sel):r.ranges);c++);if(c!=s.length){for(a.lastOrigin=a.lastSelOrigin=null;;){if(!(r=s.pop()).ranges){if(n)return void s.push(r);break}if(Gr(r,l),i&&!r.equals(t.sel))return void Qr(t,r,{clearRedo:!1});o=r}var u=[];Gr(o,l),l.push({changes:u,generation:a.generation}),a.generation=r.generation||++a.maxGeneration;for(var h=vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"),d=function(i){var n=r.changes[i];if(n.origin=e,h&&!la(t,n,!1))return s.length=0,{};u.push(jr(t,n));var a=i?Lr(t,n):Y(s);fa(t,n,a,Wr(t,n)),!i&&t.cm&&t.cm.scrollIntoView({from:n.from,to:Tr(n)});var o=[];Mr(t,(function(t,e){e||-1!=U(o,t.history)||(va(t.history,n),o.push(t.history)),fa(t,n,null,Wr(t,n))}))},f=r.changes.length-1;f>=0;--f){var p=d(f);if(p)return p.v}}}}function da(t,e){if(0!=e&&(t.first+=e,t.sel=new Cr(X(t.sel.ranges,(function(t){return new kr(te(t.anchor.line+e,t.anchor.ch),te(t.head.line+e,t.head.ch))})),t.sel.primIndex),t.cm)){hn(t.cm,t.first,t.first-e,e);for(var i=t.cm.display,n=i.viewFrom;n<i.viewTo;n++)dn(t.cm,n,"gutter")}}function fa(t,e,i,n){if(t.cm&&!t.cm.curOp)return tr(t.cm,fa)(t,e,i,n);if(e.to.line<t.first)da(t,e.text.length-1-(e.to.line-e.from.line));else if(!(e.from.line>t.lastLine())){if(e.from.line<t.first){var r=e.text.length-1-(t.first-e.from.line);da(t,r),e={from:te(t.first,0),to:te(e.to.line+r,e.to.ch),text:[Y(e.text)],origin:e.origin}}var a=t.lastLine();e.to.line>a&&(e={from:e.from,to:te(a,Kt(t,a).text.length),text:[e.text[0]],origin:e.origin}),e.removed=qt(t,e.from,e.to),i||(i=Lr(t,e)),t.cm?function(t,e,i){var n=t.doc,r=t.display,a=e.from,o=e.to,s=!1,l=a.line;t.options.lineWrapping||(l=$t(je(Kt(n,a.line))),n.iter(l,o.line+1,(function(t){if(t==r.maxLine)return s=!0,!0}))),n.sel.contains(e.from,e.to)>-1&>(t),Ir(n,e,i,sn(t)),t.options.lineWrapping||(n.iter(l,a.line+e.text.length,(function(t){var e=Ve(t);e>r.maxLineLength&&(r.maxLine=t,r.maxLineLength=e,r.maxLineChanged=!0,s=!1)})),s&&(t.curOp.updateMaxLine=!0)),function(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontier<e-10)){for(var i=t.first,n=e-1;n>i;n--){var r=Kt(t,n).stateAfter;if(r&&(!(r instanceof ce)||n+r.lookAhead<e)){i=n+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,i)}}(n,a.line),nr(t,400);var c=e.text.length-(o.line-a.line)-1;e.full?hn(t):a.line!=o.line||1!=e.text.length||Rr(t.doc,e)?hn(t,a.line,o.line+1,c):dn(t,a.line,"text");var u=vt(t,"changes"),h=vt(t,"change");if(h||u){var d={from:a,to:o,text:e.text,removed:e.removed,origin:e.origin};h&&si(t,"change",t,d),u&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(d)}t.display.selForContextMenu=null}(t.cm,e,n):Ir(t,e,n),ta(t,i,G),t.cantEdit&&aa(t,te(t.firstLine(),0))&&(t.cantEdit=!1)}}function pa(t,e,i,n,r){var a;n||(n=i),ee(n,i)<0&&(i=(a=[n,i])[0],n=a[1]),"string"==typeof e&&(e=t.splitLines(e)),ca(t,{from:i,to:n,text:e,origin:r})}function ma(t,e,i,n){i<t.line?t.line+=n:e<t.line&&(t.line=e,t.ch=0)}function ga(t,e,i,n){for(var r=0;r<t.length;++r){var a=t[r],o=!0;if(a.ranges){a.copied||((a=t[r]=a.deepCopy()).copied=!0);for(var s=0;s<a.ranges.length;s++)ma(a.ranges[s].anchor,e,i,n),ma(a.ranges[s].head,e,i,n)}else{for(var l=0;l<a.changes.length;++l){var c=a.changes[l];if(i<c.from.line)c.from=te(c.from.line+n,c.from.ch),c.to=te(c.to.line+n,c.to.ch);else if(e<=c.to.line){o=!1;break}}o||(t.splice(0,r+1),r=0)}}}function va(t,e){var i=e.from.line,n=e.to.line,r=e.text.length-(n-i)-1;ga(t.done,i,n,r),ga(t.undone,i,n,r)}function ya(t,e,i,n){var r=e,a=e;return"number"==typeof e?a=Kt(t,oe(t,e)):r=$t(e),null==r?null:(n(a,r)&&t.cm&&dn(t.cm,r,i),a)}function ba(t){this.lines=t,this.parent=null;for(var e=0,i=0;i<t.length;++i)t[i].parent=this,e+=t[i].height;this.height=e}function xa(t){this.children=t;for(var e=0,i=0,n=0;n<t.length;++n){var r=t[n];e+=r.chunkSize(),i+=r.height,r.parent=this}this.size=e,this.height=i,this.parent=null}kr.prototype.from=function(){return ae(this.anchor,this.head)},kr.prototype.to=function(){return re(this.anchor,this.head)},kr.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},ba.prototype={chunkSize:function(){return this.lines.length},removeInner:function(t,e){for(var i=t,n=t+e;i<n;++i){var r=this.lines[i];this.height-=r.height,qe(r),si(r,"delete")}this.lines.splice(t,e)},collapse:function(t){t.push.apply(t,this.lines)},insertInner:function(t,e,i){this.height+=i,this.lines=this.lines.slice(0,t).concat(e).concat(this.lines.slice(t));for(var n=0;n<e.length;++n)e[n].parent=this},iterN:function(t,e,i){for(var n=t+e;t<n;++t)if(i(this.lines[t]))return!0}},xa.prototype={chunkSize:function(){return this.size},removeInner:function(t,e){this.size-=e;for(var i=0;i<this.children.length;++i){var n=this.children[i],r=n.chunkSize();if(t<r){var a=Math.min(e,r-t),o=n.height;if(n.removeInner(t,a),this.height-=o-n.height,r==a&&(this.children.splice(i--,1),n.parent=null),0==(e-=a))break;t=0}else t-=r}if(this.size-e<25&&(this.children.length>1||!(this.children[0]instanceof ba))){var s=[];this.collapse(s),this.children=[new ba(s)],this.children[0].parent=this}},collapse:function(t){for(var e=0;e<this.children.length;++e)this.children[e].collapse(t)},insertInner:function(t,e,i){this.size+=e.length,this.height+=i;for(var n=0;n<this.children.length;++n){var r=this.children[n],a=r.chunkSize();if(t<=a){if(r.insertInner(t,e,i),r.lines&&r.lines.length>50){for(var o=r.lines.length%25+25,s=o;s<r.lines.length;){var l=new ba(r.lines.slice(s,s+=25));r.height-=l.height,this.children.splice(++n,0,l),l.parent=this}r.lines=r.lines.slice(0,o),this.maybeSpill()}break}t-=a}},maybeSpill:function(){if(!(this.children.length<=10)){var t=this;do{var e=new xa(t.children.splice(t.children.length-5,5));if(t.parent){t.size-=e.size,t.height-=e.height;var i=U(t.parent.children,t);t.parent.children.splice(i+1,0,e)}else{var n=new xa(t.children);n.parent=t,t.children=[n,e],t=n}e.parent=t.parent}while(t.children.length>10);t.parent.maybeSpill()}},iterN:function(t,e,i){for(var n=0;n<this.children.length;++n){var r=this.children[n],a=r.chunkSize();if(t<a){var o=Math.min(e,a-t);if(r.iterN(t,o,i))return!0;if(0==(e-=o))break;t=0}else t-=a}}};var Sa=function(t,e,i){if(i)for(var n in i)i.hasOwnProperty(n)&&(this[n]=i[n]);this.doc=t,this.node=e};function Ca(t,e,i){ze(e)<(t.curOp&&t.curOp.scrollTop||t.doc.scrollTop)&&Dn(t,i)}Sa.prototype.clear=function(){var t=this.doc.cm,e=this.line.widgets,i=this.line,n=$t(i);if(null!=n&&e){for(var r=0;r<e.length;++r)e[r]==this&&e.splice(r--,1);e.length||(i.widgets=null);var a=xi(this);Xt(i,Math.max(0,i.height-a)),t&&(Qn(t,(function(){Ca(t,i,-a),dn(t,n,"widget")})),si(t,"lineWidgetCleared",t,this,n))}},Sa.prototype.changed=function(){var t=this,e=this.height,i=this.doc.cm,n=this.line;this.height=null;var r=xi(this)-e;r&&(He(this.doc,n)||Xt(n,n.height+r),i&&Qn(i,(function(){i.curOp.forceUpdate=!0,Ca(i,n,r),si(i,"lineWidgetChanged",i,t,$t(n))})))},yt(Sa);var ka=0,Ea=function(t,e){this.lines=[],this.type=e,this.doc=t,this.id=++ka};function wa(t,e,i,n,r){if(n&&n.shared)return function(t,e,i,n,r){(n=F(n)).shared=!1;var a=[wa(t,e,i,n,r)],o=a[0],s=n.widgetNode;return Mr(t,(function(t){s&&(n.widgetNode=s.cloneNode(!0)),a.push(wa(t,se(t,e),se(t,i),n,r));for(var l=0;l<t.linked.length;++l)if(t.linked[l].isParent)return;o=Y(a)})),new Ta(a,o)}(t,e,i,n,r);if(t.cm&&!t.cm.curOp)return tr(t.cm,wa)(t,e,i,n,r);var a=new Ea(t,r),o=ee(e,i);if(n&&F(n,a,!1),o>0||0==o&&!1!==a.clearWhenEmpty)return a;if(a.replacedWith&&(a.collapsed=!0,a.widgetNode=D("span",[a.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||a.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(a.widgetNode.insertLeft=!0)),a.collapsed){if(Fe(t,e.line,e,i,a)||e.line!=i.line&&Fe(t,i.line,e,i,a))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ce=!0}a.addToHistory&&Ur(t,{from:e,to:i,origin:"markText"},t.sel,NaN);var s,l=e.line,c=t.cm;if(t.iter(l,i.line+1,(function(t){c&&a.collapsed&&!c.options.lineWrapping&&je(t)==c.display.maxLine&&(s=!0),a.collapsed&&l!=e.line&&Xt(t,0),function(t,e){t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],e.marker.attachLine(t)}(t,new ke(a,l==e.line?e.ch:null,l==i.line?i.ch:null)),++l})),a.collapsed&&t.iter(e.line,i.line+1,(function(e){He(t,e)&&Xt(e,0)})),a.clearOnEnter&&ht(a,"beforeCursorEnter",(function(){return a.clear()})),a.readOnly&&(Se=!0,(t.history.done.length||t.history.undone.length)&&t.clearHistory()),a.collapsed&&(a.id=++ka,a.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),a.collapsed)hn(c,e.line,i.line+1);else if(a.className||a.startStyle||a.endStyle||a.css||a.attributes||a.title)for(var u=e.line;u<=i.line;u++)dn(c,u,"text");a.atomic&&ia(c.doc),si(c,"markerAdded",c,a)}return a}Ea.prototype.clear=function(){if(!this.explicitlyCleared){var t=this.doc.cm,e=t&&!t.curOp;if(e&&Kn(t),vt(this,"clear")){var i=this.find();i&&si(this,"clear",i.from,i.to)}for(var n=null,r=null,a=0;a<this.lines.length;++a){var o=this.lines[a],s=Ee(o.markedSpans,this);t&&!this.collapsed?dn(t,$t(o),"text"):t&&(null!=s.to&&(r=$t(o)),null!=s.from&&(n=$t(o))),o.markedSpans=we(o.markedSpans,s),null==s.from&&this.collapsed&&!He(this.doc,o)&&t&&Xt(o,nn(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var l=0;l<this.lines.length;++l){var c=je(this.lines[l]),u=Ve(c);u>t.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=u,t.display.maxLineChanged=!0)}null!=n&&t&&this.collapsed&&hn(t,n,r+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&ia(t.doc)),t&&si(t,"markerCleared",t,this,n,r),e&&qn(t),this.parent&&this.parent.clear()}},Ea.prototype.find=function(t,e){var i,n;null==t&&"bookmark"==this.type&&(t=1);for(var r=0;r<this.lines.length;++r){var a=this.lines[r],o=Ee(a.markedSpans,this);if(null!=o.from&&(i=te(e?a:$t(a),o.from),-1==t))return i;if(null!=o.to&&(n=te(e?a:$t(a),o.to),1==t))return n}return i&&{from:i,to:n}},Ea.prototype.changed=function(){var t=this,e=this.find(-1,!0),i=this,n=this.doc.cm;e&&n&&Qn(n,(function(){var r=e.line,a=$t(e.line),o=Di(n,a);if(o&&(Fi(o),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0,!He(i.doc,r)&&null!=i.height){var s=i.height;i.height=null;var l=xi(i)-s;l&&Xt(r,r.height+l)}si(n,"markerChanged",n,t)}))},Ea.prototype.attachLine=function(t){if(!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;e.maybeHiddenMarkers&&-1!=U(e.maybeHiddenMarkers,this)||(e.maybeUnhiddenMarkers||(e.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(t)},Ea.prototype.detachLine=function(t){if(this.lines.splice(U(this.lines,t),1),!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;(e.maybeHiddenMarkers||(e.maybeHiddenMarkers=[])).push(this)}},yt(Ea);var Ta=function(t,e){this.markers=t,this.primary=e;for(var i=0;i<t.length;++i)t[i].parent=this};function Oa(t){return t.findMarks(te(t.first,0),t.clipPos(te(t.lastLine())),(function(t){return t.parent}))}function La(t){for(var e=function(e){var i=t[e],n=[i.primary.doc];Mr(i.primary.doc,(function(t){return n.push(t)}));for(var r=0;r<i.markers.length;r++){var a=i.markers[r];-1==U(n,a.doc)&&(a.parent=null,i.markers.splice(r--,1))}},i=0;i<t.length;i++)e(i)}Ta.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)this.markers[t].clear();si(this,"clear")}},Ta.prototype.find=function(t,e){return this.primary.find(t,e)},yt(Ta);var Aa=0,Da=function(t,e,i,n,r){if(!(this instanceof Da))return new Da(t,e,i,n,r);null==i&&(i=0),xa.call(this,[new ba([new Ke("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var a=te(i,0);this.sel=wr(a),this.history=new Fr(null),this.id=++Aa,this.modeOption=e,this.lineSep=n,this.direction="rtl"==r?"rtl":"ltr",this.extend=!1,"string"==typeof t&&(t=this.splitLines(t)),Ir(this,{from:a,to:a,text:t}),Qr(this,wr(a),G)};Da.prototype=Z(xa.prototype,{constructor:Da,iter:function(t,e,i){i?this.iterN(t-this.first,e-t,i):this.iterN(this.first,this.first+this.size,t)},insert:function(t,e){for(var i=0,n=0;n<e.length;++n)i+=e[n].height;this.insertInner(t-this.first,e,i)},remove:function(t,e){this.removeInner(t-this.first,e)},getValue:function(t){var e=Yt(this,this.first,this.first+this.size);return!1===t?e:e.join(t||this.lineSeparator())},setValue:ir((function(t){var e=te(this.first,0),i=this.first+this.size-1;ca(this,{from:e,to:te(i,Kt(this,i).text.length),text:this.splitLines(t),origin:"setValue",full:!0},!0),this.cm&&Rn(this.cm,0,0),Qr(this,wr(e),G)})),replaceRange:function(t,e,i,n){pa(this,t,e=se(this,e),i=i?se(this,i):e,n)},getRange:function(t,e,i){var n=qt(this,se(this,t),se(this,e));return!1===i?n:n.join(i||this.lineSeparator())},getLine:function(t){var e=this.getLineHandle(t);return e&&e.text},getLineHandle:function(t){if(Jt(this,t))return Kt(this,t)},getLineNumber:function(t){return $t(t)},getLineHandleVisualStart:function(t){return"number"==typeof t&&(t=Kt(this,t)),je(t)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(t){return se(this,t)},getCursor:function(t){var e=this.sel.primary();return null==t||"head"==t?e.head:"anchor"==t?e.anchor:"end"==t||"to"==t||!1===t?e.to():e.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:ir((function(t,e,i){Zr(this,se(this,"number"==typeof t?te(t,e||0):t),null,i)})),setSelection:ir((function(t,e,i){Zr(this,se(this,t),se(this,e||t),i)})),extendSelection:ir((function(t,e,i){Yr(this,se(this,t),e&&se(this,e),i)})),extendSelections:ir((function(t,e){Xr(this,le(this,t),e)})),extendSelectionsBy:ir((function(t,e){Xr(this,le(this,X(this.sel.ranges,t)),e)})),setSelections:ir((function(t,e,i){if(t.length){for(var n=[],r=0;r<t.length;r++)n[r]=new kr(se(this,t[r].anchor),se(this,t[r].head));null==e&&(e=Math.min(t.length-1,this.sel.primIndex)),Qr(this,Er(this.cm,n,e),i)}})),addSelection:ir((function(t,e,i){var n=this.sel.ranges.slice(0);n.push(new kr(se(this,t),se(this,e||t))),Qr(this,Er(this.cm,n,n.length-1),i)})),getSelection:function(t){for(var e,i=this.sel.ranges,n=0;n<i.length;n++){var r=qt(this,i[n].from(),i[n].to());e=e?e.concat(r):r}return!1===t?e:e.join(t||this.lineSeparator())},getSelections:function(t){for(var e=[],i=this.sel.ranges,n=0;n<i.length;n++){var r=qt(this,i[n].from(),i[n].to());!1!==t&&(r=r.join(t||this.lineSeparator())),e[n]=r}return e},replaceSelection:function(t,e,i){for(var n=[],r=0;r<this.sel.ranges.length;r++)n[r]=t;this.replaceSelections(n,e,i||"+input")},replaceSelections:ir((function(t,e,i){for(var n=[],r=this.sel,a=0;a<r.ranges.length;a++){var o=r.ranges[a];n[a]={from:o.from(),to:o.to(),text:this.splitLines(t[a]),origin:i}}for(var s=e&&"end"!=e&&function(t,e,i){for(var n=[],r=te(t.first,0),a=r,o=0;o<e.length;o++){var s=e[o],l=Ar(s.from,r,a),c=Ar(Tr(s),r,a);if(r=s.to,a=c,"around"==i){var u=t.sel.ranges[o],h=ee(u.head,u.anchor)<0;n[o]=new kr(h?c:l,h?l:c)}else n[o]=new kr(l,l)}return new Cr(n,t.sel.primIndex)}(this,n,e),l=n.length-1;l>=0;l--)ca(this,n[l]);s?Jr(this,s):this.cm&&_n(this.cm)})),undo:ir((function(){ha(this,"undo")})),redo:ir((function(){ha(this,"redo")})),undoSelection:ir((function(){ha(this,"undo",!0)})),redoSelection:ir((function(){ha(this,"redo",!0)})),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,i=0,n=0;n<t.done.length;n++)t.done[n].ranges||++e;for(var r=0;r<t.undone.length;r++)t.undone[r].ranges||++i;return{undo:e,redo:i}},clearHistory:function(){var t=this;this.history=new Fr(this.history.maxGeneration),Mr(this,(function(e){return e.history=t.history}),!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(t){return t&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(t){return this.history.generation==(t||this.cleanGeneration)},getHistory:function(){return{done:Kr(this.history.done),undone:Kr(this.history.undone)}},setHistory:function(t){var e=this.history=new Fr(this.history.maxGeneration);e.done=Kr(t.done.slice(0),null,!0),e.undone=Kr(t.undone.slice(0),null,!0)},setGutterMarker:ir((function(t,e,i){return ya(this,t,"gutter",(function(t){var n=t.gutterMarkers||(t.gutterMarkers={});return n[e]=i,!i&&et(n)&&(t.gutterMarkers=null),!0}))})),clearGutter:ir((function(t){var e=this;this.iter((function(i){i.gutterMarkers&&i.gutterMarkers[t]&&ya(e,i,"gutter",(function(){return i.gutterMarkers[t]=null,et(i.gutterMarkers)&&(i.gutterMarkers=null),!0}))}))})),lineInfo:function(t){var e;if("number"==typeof t){if(!Jt(this,t))return null;if(e=t,!(t=Kt(this,t)))return null}else if(null==(e=$t(t)))return null;return{line:e,handle:t,text:t.text,gutterMarkers:t.gutterMarkers,textClass:t.textClass,bgClass:t.bgClass,wrapClass:t.wrapClass,widgets:t.widgets}},addLineClass:ir((function(t,e,i){return ya(this,t,"gutter"==e?"gutter":"class",(function(t){var n="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass";if(t[n]){if(E(i).test(t[n]))return!1;t[n]+=" "+i}else t[n]=i;return!0}))})),removeLineClass:ir((function(t,e,i){return ya(this,t,"gutter"==e?"gutter":"class",(function(t){var n="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass",r=t[n];if(!r)return!1;if(null==i)t[n]=null;else{var a=r.match(E(i));if(!a)return!1;var o=a.index+a[0].length;t[n]=r.slice(0,a.index)+(a.index&&o!=r.length?" ":"")+r.slice(o)||null}return!0}))})),addLineWidget:ir((function(t,e,i){return function(t,e,i,n){var r=new Sa(t,i,n),a=t.cm;return a&&r.noHScroll&&(a.display.alignWidgets=!0),ya(t,e,"widget",(function(e){var i=e.widgets||(e.widgets=[]);if(null==r.insertAt?i.push(r):i.splice(Math.min(i.length-1,Math.max(0,r.insertAt)),0,r),r.line=e,a&&!He(t,e)){var n=ze(e)<t.scrollTop;Xt(e,e.height+xi(r)),n&&Dn(a,r.height),a.curOp.forceUpdate=!0}return!0})),a&&si(a,"lineWidgetAdded",a,r,"number"==typeof e?e:$t(e)),r}(this,t,e,i)})),removeLineWidget:function(t){t.clear()},markText:function(t,e,i){return wa(this,se(this,t),se(this,e),i,i&&i.type||"range")},setBookmark:function(t,e){var i={replacedWith:e&&(null==e.nodeType?e.widget:e),insertLeft:e&&e.insertLeft,clearWhenEmpty:!1,shared:e&&e.shared,handleMouseEvents:e&&e.handleMouseEvents};return wa(this,t=se(this,t),t,i,"bookmark")},findMarksAt:function(t){var e=[],i=Kt(this,(t=se(this,t)).line).markedSpans;if(i)for(var n=0;n<i.length;++n){var r=i[n];(null==r.from||r.from<=t.ch)&&(null==r.to||r.to>=t.ch)&&e.push(r.marker.parent||r.marker)}return e},findMarks:function(t,e,i){t=se(this,t),e=se(this,e);var n=[],r=t.line;return this.iter(t.line,e.line+1,(function(a){var o=a.markedSpans;if(o)for(var s=0;s<o.length;s++){var l=o[s];null!=l.to&&r==t.line&&t.ch>=l.to||null==l.from&&r!=t.line||null!=l.from&&r==e.line&&l.from>=e.ch||i&&!i(l.marker)||n.push(l.marker.parent||l.marker)}++r})),n},getAllMarks:function(){var t=[];return this.iter((function(e){var i=e.markedSpans;if(i)for(var n=0;n<i.length;++n)null!=i[n].from&&t.push(i[n].marker)})),t},posFromIndex:function(t){var e,i=this.first,n=this.lineSeparator().length;return this.iter((function(r){var a=r.text.length+n;if(a>t)return e=t,!0;t-=a,++i})),se(this,te(i,e))},indexFromPos:function(t){var e=(t=se(this,t)).ch;if(t.line<this.first||t.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,t.line,(function(t){e+=t.text.length+i})),e},copy:function(t){var e=new Da(Yt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return e.scrollTop=this.scrollTop,e.scrollLeft=this.scrollLeft,e.sel=this.sel,e.extend=!1,t&&(e.history.undoDepth=this.history.undoDepth,e.setHistory(this.getHistory())),e},linkedDoc:function(t){t||(t={});var e=this.first,i=this.first+this.size;null!=t.from&&t.from>e&&(e=t.from),null!=t.to&&t.to<i&&(i=t.to);var n=new Da(Yt(this,e,i),t.mode||this.modeOption,e,this.lineSep,this.direction);return t.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:t.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:t.sharedHist}],function(t,e){for(var i=0;i<e.length;i++){var n=e[i],r=n.find(),a=t.clipPos(r.from),o=t.clipPos(r.to);if(ee(a,o)){var s=wa(t,a,o,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}(n,Oa(this)),n},unlinkDoc:function(t){if(t instanceof Oo&&(t=t.doc),this.linked)for(var e=0;e<this.linked.length;++e)if(this.linked[e].doc==t){this.linked.splice(e,1),t.unlinkDoc(this),La(Oa(this));break}if(t.history==this.history){var i=[t.id];Mr(t,(function(t){return i.push(t.id)}),!0),t.history=new Fr(null),t.history.done=Kr(this.history.done,i),t.history.undone=Kr(this.history.undone,i)}},iterLinkedDocs:function(t){Mr(this,t)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(t){return this.lineSep?t.split(this.lineSep):_t(t)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:ir((function(t){var e;"rtl"!=t&&(t="ltr"),t!=this.direction&&(this.direction=t,this.iter((function(t){return t.order=null})),this.cm&&Qn(e=this.cm,(function(){Pr(e),hn(e)})))}))}),Da.prototype.eachLine=Da.prototype.iter;var _a=0;function Ra(t){var e=this;if(Ia(e),!mt(e,t)&&!Si(e.display,t)){bt(t),o&&(_a=+new Date);var i=cn(e,t,!0),n=t.dataTransfer.files;if(i&&!e.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var r=n.length,a=Array(r),s=0,l=function(){++s==r&&tr(e,(function(){var t={from:i=se(e.doc,i),to:i,text:e.doc.splitLines(a.filter((function(t){return null!=t})).join(e.doc.lineSeparator())),origin:"paste"};ca(e.doc,t),Jr(e.doc,wr(se(e.doc,i),se(e.doc,Tr(t))))}))()},c=function(t,i){if(e.options.allowDropFileTypes&&-1==U(e.options.allowDropFileTypes,t.type))l();else{var n=new FileReader;n.onerror=function(){return l()},n.onload=function(){var t=n.result;/[\x00-\x08\x0e-\x1f]{2}/.test(t)||(a[i]=t),l()},n.readAsText(t)}},u=0;u<n.length;u++)c(n[u],u);else{if(e.state.draggingText&&e.doc.sel.contains(i)>-1)return e.state.draggingText(t),void setTimeout((function(){return e.display.input.focus()}),20);try{var h=t.dataTransfer.getData("Text");if(h){var d;if(e.state.draggingText&&!e.state.draggingText.copy&&(d=e.listSelections()),ta(e.doc,wr(i,i)),d)for(var f=0;f<d.length;++f)pa(e.doc,"",d[f].anchor,d[f].head,"drag");e.replaceSelection(h,"around","paste"),e.display.input.focus()}}catch(t){}}}}function Ia(t){t.display.dragCursor&&(t.display.lineSpace.removeChild(t.display.dragCursor),t.display.dragCursor=null)}function Ma(t){if(document.getElementsByClassName){for(var e=document.getElementsByClassName("CodeMirror"),i=[],n=0;n<e.length;n++){var r=e[n].CodeMirror;r&&i.push(r)}i.length&&i[0].operation((function(){for(var e=0;e<i.length;e++)t(i[e])}))}}var Na=!1;function Pa(){var t;Na||(ht(window,"resize",(function(){null==t&&(t=setTimeout((function(){t=null,Ma(Fa)}),100))})),ht(window,"blur",(function(){return Ma(wn)})),Na=!0)}function Fa(t){var e=t.display;e.cachedCharWidth=e.cachedTextHeight=e.cachedPaddingH=null,e.scrollbarsClipped=!1,t.setSize()}for(var ja={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"},Ba=0;Ba<10;Ba++)ja[Ba+48]=ja[Ba+96]=String(Ba);for(var Ua=65;Ua<=90;Ua++)ja[Ua]=String.fromCharCode(Ua);for(var Ha=1;Ha<=12;Ha++)ja[Ha+111]=ja[Ha+63235]="F"+Ha;var Ga={};function za(t){var e,i,n,r,a=t.split(/-(?!$)/);t=a[a.length-1];for(var o=0;o<a.length-1;o++){var s=a[o];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))i=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return e&&(t="Alt-"+t),i&&(t="Ctrl-"+t),r&&(t="Cmd-"+t),n&&(t="Shift-"+t),t}function Va(t){var e={};for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if("..."==n){delete t[i];continue}for(var r=X(i.split(" "),za),a=0;a<r.length;a++){var o=void 0,s=void 0;a==r.length-1?(s=r.join(" "),o=n):(s=r.slice(0,a+1).join(" "),o="...");var l=e[s];if(l){if(l!=o)throw new Error("Inconsistent bindings for "+s)}else e[s]=o}delete t[i]}for(var c in e)t[c]=e[c];return t}function Wa(t,e,i,n){var r=(e=Xa(e)).call?e.call(t,n):e[t];if(!1===r)return"nothing";if("..."===r)return"multi";if(null!=r&&i(r))return"handled";if(e.fallthrough){if("[object Array]"!=Object.prototype.toString.call(e.fallthrough))return Wa(t,e.fallthrough,i,n);for(var a=0;a<e.fallthrough.length;a++){var o=Wa(t,e.fallthrough[a],i,n);if(o)return o}}}function Ka(t){var e="string"==typeof t?t:ja[t.keyCode];return"Ctrl"==e||"Alt"==e||"Shift"==e||"Mod"==e}function qa(t,e,i){var n=t;return e.altKey&&"Alt"!=n&&(t="Alt-"+t),(C?e.metaKey:e.ctrlKey)&&"Ctrl"!=n&&(t="Ctrl-"+t),(C?e.ctrlKey:e.metaKey)&&"Mod"!=n&&(t="Cmd-"+t),!i&&e.shiftKey&&"Shift"!=n&&(t="Shift-"+t),t}function Ya(t,e){if(h&&34==t.keyCode&&t.char)return!1;var i=ja[t.keyCode];return null!=i&&!t.altGraphKey&&(3==t.keyCode&&t.code&&(i=t.code),qa(i,t,e))}function Xa(t){return"string"==typeof t?Ga[t]:t}function $a(t,e){for(var i=t.doc.sel.ranges,n=[],r=0;r<i.length;r++){for(var a=e(i[r]);n.length&&ee(a.from,Y(n).to)<=0;){var o=n.pop();if(ee(o.from,a.from)<0){a.from=o.from;break}}n.push(a)}Qn(t,(function(){for(var e=n.length-1;e>=0;e--)pa(t.doc,"",n[e].from,n[e].to,"+delete");_n(t)}))}function Za(t,e,i){var n=rt(t.text,e+i,i);return n<0||n>t.text.length?null:n}function Ja(t,e,i){var n=Za(t,e.ch,i);return null==n?null:new te(e.line,n,i<0?"after":"before")}function Qa(t,e,i,n,r){if(t){"rtl"==e.doc.direction&&(r=-r);var a=ct(i,e.doc.direction);if(a){var o,s=r<0?Y(a):a[0],l=r<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==e.doc.direction){var c=_i(e,i);o=r<0?i.text.length-1:0;var u=Ri(e,c,o).top;o=at((function(t){return Ri(e,c,t).top==u}),r<0==(1==s.level)?s.from:s.to-1,o),"before"==l&&(o=Za(i,o,1))}else o=r<0?s.to:s.from;return new te(n,o,l)}}return new te(n,r<0?i.text.length:0,r<0?"before":"after")}Ga.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"},Ga.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"},Ga.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"},Ga.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"]},Ga.default=y?Ga.macDefault:Ga.pcDefault;var to={selectAll:sa,singleSelection:function(t){return t.setSelection(t.getCursor("anchor"),t.getCursor("head"),G)},killLine:function(t){return $a(t,(function(e){if(e.empty()){var i=Kt(t.doc,e.head.line).text.length;return e.head.ch==i&&e.head.line<t.lastLine()?{from:e.head,to:te(e.head.line+1,0)}:{from:e.head,to:te(e.head.line,i)}}return{from:e.from(),to:e.to()}}))},deleteLine:function(t){return $a(t,(function(e){return{from:te(e.from().line,0),to:se(t.doc,te(e.to().line+1,0))}}))},delLineLeft:function(t){return $a(t,(function(t){return{from:te(t.from().line,0),to:t.from()}}))},delWrappedLineLeft:function(t){return $a(t,(function(e){var i=t.charCoords(e.head,"div").top+5;return{from:t.coordsChar({left:0,top:i},"div"),to:e.from()}}))},delWrappedLineRight:function(t){return $a(t,(function(e){var i=t.charCoords(e.head,"div").top+5,n=t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:i},"div");return{from:e.from(),to:n}}))},undo:function(t){return t.undo()},redo:function(t){return t.redo()},undoSelection:function(t){return t.undoSelection()},redoSelection:function(t){return t.redoSelection()},goDocStart:function(t){return t.extendSelection(te(t.firstLine(),0))},goDocEnd:function(t){return t.extendSelection(te(t.lastLine()))},goLineStart:function(t){return t.extendSelectionsBy((function(e){return eo(t,e.head.line)}),{origin:"+move",bias:1})},goLineStartSmart:function(t){return t.extendSelectionsBy((function(e){return io(t,e.head)}),{origin:"+move",bias:1})},goLineEnd:function(t){return t.extendSelectionsBy((function(e){return function(t,e){var i=Kt(t.doc,e),n=function(t){for(var e;e=Ne(t);)t=e.find(1,!0).line;return t}(i);return n!=i&&(e=$t(n)),Qa(!0,t,i,e,-1)}(t,e.head.line)}),{origin:"+move",bias:-1})},goLineRight:function(t){return t.extendSelectionsBy((function(e){var i=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:i},"div")}),V)},goLineLeft:function(t){return t.extendSelectionsBy((function(e){var i=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:0,top:i},"div")}),V)},goLineLeftSmart:function(t){return t.extendSelectionsBy((function(e){var i=t.cursorCoords(e.head,"div").top+5,n=t.coordsChar({left:0,top:i},"div");return n.ch<t.getLine(n.line).search(/\S/)?io(t,e.head):n}),V)},goLineUp:function(t){return t.moveV(-1,"line")},goLineDown:function(t){return t.moveV(1,"line")},goPageUp:function(t){return t.moveV(-1,"page")},goPageDown:function(t){return t.moveV(1,"page")},goCharLeft:function(t){return t.moveH(-1,"char")},goCharRight:function(t){return t.moveH(1,"char")},goColumnLeft:function(t){return t.moveH(-1,"column")},goColumnRight:function(t){return t.moveH(1,"column")},goWordLeft:function(t){return t.moveH(-1,"word")},goGroupRight:function(t){return t.moveH(1,"group")},goGroupLeft:function(t){return t.moveH(-1,"group")},goWordRight:function(t){return t.moveH(1,"word")},delCharBefore:function(t){return t.deleteH(-1,"codepoint")},delCharAfter:function(t){return t.deleteH(1,"char")},delWordBefore:function(t){return t.deleteH(-1,"word")},delWordAfter:function(t){return t.deleteH(1,"word")},delGroupBefore:function(t){return t.deleteH(-1,"group")},delGroupAfter:function(t){return t.deleteH(1,"group")},indentAuto:function(t){return t.indentSelection("smart")},indentMore:function(t){return t.indentSelection("add")},indentLess:function(t){return t.indentSelection("subtract")},insertTab:function(t){return t.replaceSelection("\t")},insertSoftTab:function(t){for(var e=[],i=t.listSelections(),n=t.options.tabSize,r=0;r<i.length;r++){var a=i[r].from(),o=j(t.getLine(a.line),a.ch,n);e.push(q(n-o%n))}t.replaceSelections(e)},defaultTab:function(t){t.somethingSelected()?t.indentSelection("add"):t.execCommand("insertTab")},transposeChars:function(t){return Qn(t,(function(){for(var e=t.listSelections(),i=[],n=0;n<e.length;n++)if(e[n].empty()){var r=e[n].head,a=Kt(t.doc,r.line).text;if(a)if(r.ch==a.length&&(r=new te(r.line,r.ch-1)),r.ch>0)r=new te(r.line,r.ch+1),t.replaceRange(a.charAt(r.ch-1)+a.charAt(r.ch-2),te(r.line,r.ch-2),r,"+transpose");else if(r.line>t.doc.first){var o=Kt(t.doc,r.line-1).text;o&&(r=new te(r.line,1),t.replaceRange(a.charAt(0)+t.doc.lineSeparator()+o.charAt(o.length-1),te(r.line-1,o.length-1),r,"+transpose"))}i.push(new kr(r,r))}t.setSelections(i)}))},newlineAndIndent:function(t){return Qn(t,(function(){for(var e=t.listSelections(),i=e.length-1;i>=0;i--)t.replaceRange(t.doc.lineSeparator(),e[i].anchor,e[i].head,"+input");e=t.listSelections();for(var n=0;n<e.length;n++)t.indentLine(e[n].from().line,null,!0);_n(t)}))},openLine:function(t){return t.replaceSelection("\n","start")},toggleOverwrite:function(t){return t.toggleOverwrite()}};function eo(t,e){var i=Kt(t.doc,e),n=je(i);return n!=i&&(e=$t(n)),Qa(!0,t,n,e,1)}function io(t,e){var i=eo(t,e.line),n=Kt(t.doc,i.line),r=ct(n,t.doc.direction);if(!r||0==r[0].level){var a=Math.max(i.ch,n.text.search(/\S/)),o=e.line==i.line&&e.ch<=a&&e.ch;return te(i.line,o?0:a,i.sticky)}return i}function no(t,e,i){if("string"==typeof e&&!(e=to[e]))return!1;t.display.input.ensurePolled();var n=t.display.shift,r=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),i&&(t.display.shift=!1),r=e(t)!=H}finally{t.display.shift=n,t.state.suppressEdits=!1}return r}var ro=new B;function ao(t,e,i,n){var r=t.state.keySeq;if(r){if(Ka(e))return"handled";if(/\'$/.test(e)?t.state.keySeq=null:ro.set(50,(function(){t.state.keySeq==r&&(t.state.keySeq=null,t.display.input.reset())})),oo(t,r+" "+e,i,n))return!0}return oo(t,e,i,n)}function oo(t,e,i,n){var r=function(t,e,i){for(var n=0;n<t.state.keyMaps.length;n++){var r=Wa(e,t.state.keyMaps[n],i,t);if(r)return r}return t.options.extraKeys&&Wa(e,t.options.extraKeys,i,t)||Wa(e,t.options.keyMap,i,t)}(t,e,n);return"multi"==r&&(t.state.keySeq=e),"handled"==r&&si(t,"keyHandled",t,e,i),"handled"!=r&&"multi"!=r||(bt(i),Sn(t)),!!r}function so(t,e){var i=Ya(e,!0);return!!i&&(e.shiftKey&&!t.state.keySeq?ao(t,"Shift-"+i,e,(function(e){return no(t,e,!0)}))||ao(t,i,e,(function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion)return no(t,e)})):ao(t,i,e,(function(e){return no(t,e)})))}var lo=null;function co(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||(e.curOp.focus=R(),mt(e,t)))){o&&s<11&&27==t.keyCode&&(t.returnValue=!1);var n=t.keyCode;e.display.shift=16==n||t.shiftKey;var r=so(e,t);h&&(lo=r?n:null,r||88!=n||It||!(y?t.metaKey:t.ctrlKey)||e.replaceSelection("",null,"cut")),i&&!y&&!r&&46==n&&t.shiftKey&&!t.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=n||/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)||function(t){var e=t.display.lineDiv;function i(t){18!=t.keyCode&&t.altKey||(T(e,"CodeMirror-crosshair"),ft(document,"keyup",i),ft(document,"mouseover",i))}I(e,"CodeMirror-crosshair"),ht(document,"keyup",i),ht(document,"mouseover",i)}(e)}}function uo(t){16==t.keyCode&&(this.doc.sel.shift=!1),mt(this,t)}function ho(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||Si(e.display,t)||mt(e,t)||t.ctrlKey&&!t.altKey||y&&t.metaKey)){var i=t.keyCode,n=t.charCode;if(h&&i==lo)return lo=null,void bt(t);if(!h||t.which&&!(t.which<10)||!so(e,t)){var r=String.fromCharCode(null==n?i:n);"\b"!=r&&(function(t,e,i){return ao(t,"'"+i+"'",e,(function(e){return no(t,e,!0)}))}(e,t,r)||e.display.input.onKeyPress(t))}}}var fo,po,mo=function(t,e,i){this.time=t,this.pos=e,this.button=i};function go(t){var e=this,i=e.display;if(!(mt(e,t)||i.activeTouch&&i.input.supportsTouch()))if(i.input.ensurePolled(),i.shift=t.shiftKey,Si(i,t))l||(i.scroller.draggable=!1,setTimeout((function(){return i.scroller.draggable=!0}),100));else if(!bo(e,t)){var n=cn(e,t),r=Et(t),a=n?function(t,e){var i=+new Date;return po&&po.compare(i,t,e)?(fo=po=null,"triple"):fo&&fo.compare(i,t,e)?(po=new mo(i,t,e),fo=null,"double"):(fo=new mo(i,t,e),po=null,"single")}(n,r):"single";window.focus(),1==r&&e.state.selectingText&&e.state.selectingText(t),n&&function(t,e,i,n,r){var a="Click";return"double"==n?a="Double"+a:"triple"==n&&(a="Triple"+a),ao(t,qa(a=(1==e?"Left":2==e?"Middle":"Right")+a,r),r,(function(e){if("string"==typeof e&&(e=to[e]),!e)return!1;var n=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),n=e(t,i)!=H}finally{t.state.suppressEdits=!1}return n}))}(e,r,n,a,t)||(1==r?n?function(t,e,i,n){o?setTimeout(P(Cn,t),0):t.curOp.focus=R();var r,a=function(t,e,i){var n=t.getOption("configureMouse"),r=n?n(t,e,i):{};if(null==r.unit){var a=b?i.shiftKey&&i.metaKey:i.altKey;r.unit=a?"rectangle":"single"==e?"char":"double"==e?"word":"line"}return(null==r.extend||t.doc.extend)&&(r.extend=t.doc.extend||i.shiftKey),null==r.addNew&&(r.addNew=y?i.metaKey:i.ctrlKey),null==r.moveOnDrag&&(r.moveOnDrag=!(y?i.altKey:i.ctrlKey)),r}(t,i,n),c=t.doc.sel;t.options.dragDrop&&Ot&&!t.isReadOnly()&&"single"==i&&(r=c.contains(e))>-1&&(ee((r=c.ranges[r]).from(),e)<0||e.xRel>0)&&(ee(r.to(),e)>0||e.xRel<0)?function(t,e,i,n){var r=t.display,a=!1,c=tr(t,(function(e){l&&(r.scroller.draggable=!1),t.state.draggingText=!1,ft(r.wrapper.ownerDocument,"mouseup",c),ft(r.wrapper.ownerDocument,"mousemove",u),ft(r.scroller,"dragstart",h),ft(r.scroller,"drop",c),a||(bt(e),n.addNew||Yr(t.doc,i,null,null,n.extend),l&&!d||o&&9==s?setTimeout((function(){r.wrapper.ownerDocument.body.focus({preventScroll:!0}),r.input.focus()}),20):r.input.focus())})),u=function(t){a=a||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},h=function(){return a=!0};l&&(r.scroller.draggable=!0),t.state.draggingText=c,c.copy=!n.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),ht(r.wrapper.ownerDocument,"mouseup",c),ht(r.wrapper.ownerDocument,"mousemove",u),ht(r.scroller,"dragstart",h),ht(r.scroller,"drop",c),kn(t),setTimeout((function(){return r.input.focus()}),20)}(t,n,e,a):function(t,e,i,n){var r=t.display,a=t.doc;bt(e);var o,s,l=a.sel,c=l.ranges;if(n.addNew&&!n.extend?(s=a.sel.contains(i),o=s>-1?c[s]:new kr(i,i)):(o=a.sel.primary(),s=a.sel.primIndex),"rectangle"==n.unit)n.addNew||(o=new kr(i,i)),i=cn(t,e,!0,!0),s=-1;else{var u=vo(t,i,n.unit);o=n.extend?qr(o,u.anchor,u.head,n.extend):u}n.addNew?-1==s?(s=c.length,Qr(a,Er(t,c.concat([o]),s),{scroll:!1,origin:"*mouse"})):c.length>1&&c[s].empty()&&"char"==n.unit&&!n.extend?(Qr(a,Er(t,c.slice(0,s).concat(c.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),l=a.sel):$r(a,s,o,z):(s=0,Qr(a,new Cr([o],0),z),l=a.sel);var h=i;function d(e){if(0!=ee(h,e))if(h=e,"rectangle"==n.unit){for(var r=[],c=t.options.tabSize,u=j(Kt(a,i.line).text,i.ch,c),d=j(Kt(a,e.line).text,e.ch,c),f=Math.min(u,d),p=Math.max(u,d),m=Math.min(i.line,e.line),g=Math.min(t.lastLine(),Math.max(i.line,e.line));m<=g;m++){var v=Kt(a,m).text,y=W(v,f,c);f==p?r.push(new kr(te(m,y),te(m,y))):v.length>y&&r.push(new kr(te(m,y),te(m,W(v,p,c))))}r.length||r.push(new kr(i,i)),Qr(a,Er(t,l.ranges.slice(0,s).concat(r),s),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var b,x=o,S=vo(t,e,n.unit),C=x.anchor;ee(S.anchor,C)>0?(b=S.head,C=ae(x.from(),S.anchor)):(b=S.anchor,C=re(x.to(),S.head));var k=l.ranges.slice(0);k[s]=function(t,e){var i=e.anchor,n=e.head,r=Kt(t.doc,i.line);if(0==ee(i,n)&&i.sticky==n.sticky)return e;var a=ct(r);if(!a)return e;var o=st(a,i.ch,i.sticky),s=a[o];if(s.from!=i.ch&&s.to!=i.ch)return e;var l,c=o+(s.from==i.ch==(1!=s.level)?0:1);if(0==c||c==a.length)return e;if(n.line!=i.line)l=(n.line-i.line)*("ltr"==t.doc.direction?1:-1)>0;else{var u=st(a,n.ch,n.sticky),h=u-o||(n.ch-i.ch)*(1==s.level?-1:1);l=u==c-1||u==c?h<0:h>0}var d=a[c+(l?-1:0)],f=l==(1==d.level),p=f?d.from:d.to,m=f?"after":"before";return i.ch==p&&i.sticky==m?e:new kr(new te(i.line,p,m),n)}(t,new kr(se(a,C),b)),Qr(a,Er(t,k,s),z)}}var f=r.wrapper.getBoundingClientRect(),p=0;function m(e){t.state.selectingText=!1,p=1/0,e&&(bt(e),r.input.focus()),ft(r.wrapper.ownerDocument,"mousemove",g),ft(r.wrapper.ownerDocument,"mouseup",v),a.history.lastSelOrigin=null}var g=tr(t,(function(e){0!==e.buttons&&Et(e)?function e(i){var o=++p,s=cn(t,i,!0,"rectangle"==n.unit);if(s)if(0!=ee(s,h)){t.curOp.focus=R(),d(s);var l=Ln(r,a);(s.line>=l.to||s.line<l.from)&&setTimeout(tr(t,(function(){p==o&&e(i)})),150)}else{var c=i.clientY<f.top?-20:i.clientY>f.bottom?20:0;c&&setTimeout(tr(t,(function(){p==o&&(r.scroller.scrollTop+=c,e(i))})),50)}}(e):m(e)})),v=tr(t,m);t.state.selectingText=v,ht(r.wrapper.ownerDocument,"mousemove",g),ht(r.wrapper.ownerDocument,"mouseup",v)}(t,n,e,a)}(e,n,a,t):kt(t)==i.scroller&&bt(t):2==r?(n&&Yr(e.doc,n),setTimeout((function(){return i.input.focus()}),20)):3==r&&(k?e.display.input.onContextMenu(t):kn(e)))}}function vo(t,e,i){if("char"==i)return new kr(e,e);if("word"==i)return t.findWordAt(e);if("line"==i)return new kr(te(e.line,0),se(t.doc,te(e.line+1,0)));var n=i(t,e);return new kr(n.from,n.to)}function yo(t,e,i,n){var r,a;if(e.touches)r=e.touches[0].clientX,a=e.touches[0].clientY;else try{r=e.clientX,a=e.clientY}catch(t){return!1}if(r>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;n&&bt(e);var o=t.display,s=o.lineDiv.getBoundingClientRect();if(a>s.bottom||!vt(t,i))return St(e);a-=s.top-o.viewOffset;for(var l=0;l<t.display.gutterSpecs.length;++l){var c=o.gutters.childNodes[l];if(c&&c.getBoundingClientRect().right>=r)return pt(t,i,t,Zt(t.doc,a),t.display.gutterSpecs[l].className,e),St(e)}}function bo(t,e){return yo(t,e,"gutterClick",!0)}function xo(t,e){Si(t.display,e)||function(t,e){return!!vt(t,"gutterContextMenu")&&yo(t,e,"gutterContextMenu",!1)}(t,e)||mt(t,e,"contextmenu")||k||t.display.input.onContextMenu(e)}function So(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Bi(t)}mo.prototype.compare=function(t,e,i){return this.time+400>t&&0==ee(e,this.pos)&&i==this.button};var Co={toString:function(){return"CodeMirror.Init"}},ko={},Eo={};function wo(t,e,i){if(!e!=!(i&&i!=Co)){var n=t.display.dragFunctions,r=e?ht:ft;r(t.display.scroller,"dragstart",n.start),r(t.display.scroller,"dragenter",n.enter),r(t.display.scroller,"dragover",n.over),r(t.display.scroller,"dragleave",n.leave),r(t.display.scroller,"drop",n.drop)}}function To(t){t.options.lineWrapping?(I(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(T(t.display.wrapper,"CodeMirror-wrap"),We(t)),ln(t),hn(t),Bi(t),setTimeout((function(){return Hn(t)}),100)}function Oo(t,e){var i=this;if(!(this instanceof Oo))return new Oo(t,e);this.options=e=e?F(e):{},F(ko,e,!1);var n=e.value;"string"==typeof n?n=new Da(n,e.mode,null,e.lineSeparator,e.direction):e.mode&&(n.modeOption=e.mode),this.doc=n;var r=new Oo.inputStyles[e.inputStyle](this),a=this.display=new gr(t,n,r,e);for(var c in a.wrapper.CodeMirror=this,So(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Vn(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 B,keySeq:null,specialChars:null},e.autofocus&&!v&&a.input.focus(),o&&s<11&&setTimeout((function(){return i.display.input.reset(!0)}),20),function(t){var e=t.display;ht(e.scroller,"mousedown",tr(t,go)),ht(e.scroller,"dblclick",o&&s<11?tr(t,(function(e){if(!mt(t,e)){var i=cn(t,e);if(i&&!bo(t,e)&&!Si(t.display,e)){bt(e);var n=t.findWordAt(i);Yr(t.doc,n.anchor,n.head)}}})):function(e){return mt(t,e)||bt(e)}),ht(e.scroller,"contextmenu",(function(e){return xo(t,e)})),ht(e.input.getField(),"contextmenu",(function(i){e.scroller.contains(i.target)||xo(t,i)}));var i,n={end:0};function r(){e.activeTouch&&(i=setTimeout((function(){return e.activeTouch=null}),1e3),(n=e.activeTouch).end=+new Date)}function a(t,e){if(null==e.left)return!0;var i=e.left-t.left,n=e.top-t.top;return i*i+n*n>400}ht(e.scroller,"touchstart",(function(r){if(!mt(t,r)&&!function(t){if(1!=t.touches.length)return!1;var e=t.touches[0];return e.radiusX<=1&&e.radiusY<=1}(r)&&!bo(t,r)){e.input.ensurePolled(),clearTimeout(i);var a=+new Date;e.activeTouch={start:a,moved:!1,prev:a-n.end<=300?n:null},1==r.touches.length&&(e.activeTouch.left=r.touches[0].pageX,e.activeTouch.top=r.touches[0].pageY)}})),ht(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),ht(e.scroller,"touchend",(function(i){var n=e.activeTouch;if(n&&!Si(e,i)&&null!=n.left&&!n.moved&&new Date-n.start<300){var o,s=t.coordsChar(e.activeTouch,"page");o=!n.prev||a(n,n.prev)?new kr(s,s):!n.prev.prev||a(n,n.prev.prev)?t.findWordAt(s):new kr(te(s.line,0),se(t.doc,te(s.line+1,0))),t.setSelection(o.anchor,o.head),t.focus(),bt(i)}r()})),ht(e.scroller,"touchcancel",r),ht(e.scroller,"scroll",(function(){e.scroller.clientHeight&&(Nn(t,e.scroller.scrollTop),Fn(t,e.scroller.scrollLeft,!0),pt(t,"scroll",t))})),ht(e.scroller,"mousewheel",(function(e){return Sr(t,e)})),ht(e.scroller,"DOMMouseScroll",(function(e){return Sr(t,e)})),ht(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(e){mt(t,e)||Ct(e)},over:function(e){mt(t,e)||(function(t,e){var i=cn(t,e);if(i){var n=document.createDocumentFragment();yn(t,i,n),t.display.dragCursor||(t.display.dragCursor=A("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)),L(t.display.dragCursor,n)}}(t,e),Ct(e))},start:function(e){return function(t,e){if(o&&(!t.state.draggingText||+new Date-_a<100))Ct(e);else if(!mt(t,e)&&!Si(t.display,e)&&(e.dataTransfer.setData("Text",t.getSelection()),e.dataTransfer.effectAllowed="copyMove",e.dataTransfer.setDragImage&&!d)){var i=A("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(i.width=i.height=1,t.display.wrapper.appendChild(i),i._top=i.offsetTop),e.dataTransfer.setDragImage(i,0,0),h&&i.parentNode.removeChild(i)}}(t,e)},drop:tr(t,Ra),leave:function(e){mt(t,e)||Ia(t)}};var l=e.input.getField();ht(l,"keyup",(function(e){return uo.call(t,e)})),ht(l,"keydown",tr(t,co)),ht(l,"keypress",tr(t,ho)),ht(l,"focus",(function(e){return En(t,e)})),ht(l,"blur",(function(e){return wn(t,e)}))}(this),Pa(),Kn(this),this.curOp.forceUpdate=!0,Nr(this,n),e.autofocus&&!v||this.hasFocus()?setTimeout((function(){i.hasFocus()&&!i.state.focused&&En(i)}),20):wn(this),Eo)Eo.hasOwnProperty(c)&&Eo[c](this,e[c],Co);dr(this),e.finishInit&&e.finishInit(this);for(var u=0;u<Lo.length;++u)Lo[u](this);qn(this),l&&e.lineWrapping&&"optimizelegibility"==getComputedStyle(a.lineDiv).textRendering&&(a.lineDiv.style.textRendering="auto")}Oo.defaults=ko,Oo.optionHandlers=Eo;var Lo=[];function Ao(t,e,i,n){var r,a=t.doc;null==i&&(i="add"),"smart"==i&&(a.mode.indent?r=fe(t,e).state:i="prev");var o=t.options.tabSize,s=Kt(a,e),l=j(s.text,null,o);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==i&&((c=a.mode.indent(r,s.text.slice(u.length),s.text))==H||c>150)){if(!n)return;i="prev"}}else c=0,i="not";"prev"==i?c=e>a.first?j(Kt(a,e-1).text,null,o):0:"add"==i?c=l+t.options.indentUnit:"subtract"==i?c=l-t.options.indentUnit:"number"==typeof i&&(c=l+i),c=Math.max(0,c);var h="",d=0;if(t.options.indentWithTabs)for(var f=Math.floor(c/o);f;--f)d+=o,h+="\t";if(d<c&&(h+=q(c-d)),h!=u)return pa(a,h,te(e,0),te(e,u.length),"+input"),s.stateAfter=null,!0;for(var p=0;p<a.sel.ranges.length;p++){var m=a.sel.ranges[p];if(m.head.line==e&&m.head.ch<u.length){var g=te(e,u.length);$r(a,p,new kr(g,g));break}}}Oo.defineInitHook=function(t){return Lo.push(t)};var Do=null;function _o(t){Do=t}function Ro(t,e,i,n,r){var a=t.doc;t.display.shift=!1,n||(n=a.sel);var o=+new Date-200,s="paste"==r||t.state.pasteIncoming>o,l=_t(e),c=null;if(s&&n.ranges.length>1)if(Do&&Do.text.join("\n")==e){if(n.ranges.length%Do.text.length==0){c=[];for(var u=0;u<Do.text.length;u++)c.push(a.splitLines(Do.text[u]))}}else l.length==n.ranges.length&&t.options.pasteLinesPerSelection&&(c=X(l,(function(t){return[t]})));for(var h=t.curOp.updateInput,d=n.ranges.length-1;d>=0;d--){var f=n.ranges[d],p=f.from(),m=f.to();f.empty()&&(i&&i>0?p=te(p.line,p.ch-i):t.state.overwrite&&!s?m=te(m.line,Math.min(Kt(a,m.line).text.length,m.ch+Y(l).length)):s&&Do&&Do.lineWise&&Do.text.join("\n")==l.join("\n")&&(p=m=te(p.line,0)));var g={from:p,to:m,text:c?c[d%c.length]:l,origin:r||(s?"paste":t.state.cutIncoming>o?"cut":"+input")};ca(t.doc,g),si(t,"inputRead",t,g)}e&&!s&&Mo(t,e),_n(t),t.curOp.updateInput<2&&(t.curOp.updateInput=h),t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=-1}function Io(t,e){var i=t.clipboardData&&t.clipboardData.getData("Text");if(i)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||Qn(e,(function(){return Ro(e,i,0,null,"paste")})),!0}function Mo(t,e){if(t.options.electricChars&&t.options.smartIndent)for(var i=t.doc.sel,n=i.ranges.length-1;n>=0;n--){var r=i.ranges[n];if(!(r.head.ch>100||n&&i.ranges[n-1].head.line==r.head.line)){var a=t.getModeAt(r.head),o=!1;if(a.electricChars){for(var s=0;s<a.electricChars.length;s++)if(e.indexOf(a.electricChars.charAt(s))>-1){o=Ao(t,r.head.line,"smart");break}}else a.electricInput&&a.electricInput.test(Kt(t.doc,r.head.line).text.slice(0,r.head.ch))&&(o=Ao(t,r.head.line,"smart"));o&&si(t,"electricInput",t,r.head.line)}}}function No(t){for(var e=[],i=[],n=0;n<t.doc.sel.ranges.length;n++){var r=t.doc.sel.ranges[n].head.line,a={anchor:te(r,0),head:te(r+1,0)};i.push(a),e.push(t.getRange(a.anchor,a.head))}return{text:e,ranges:i}}function Po(t,e,i,n){t.setAttribute("autocorrect",i?"":"off"),t.setAttribute("autocapitalize",n?"":"off"),t.setAttribute("spellcheck",!!e)}function Fo(){var t=A("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),e=A("div",[t],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return l?t.style.width="1000px":t.setAttribute("wrap","off"),m&&(t.style.border="1px solid black"),Po(t),e}function jo(t,e,i,n,r){var a=e,o=i,s=Kt(t,e.line),l=r&&"rtl"==t.direction?-i:i;function c(a){var o,c;if("codepoint"==n){var u=s.text.charCodeAt(e.ch+(n>0?0:-1));o=isNaN(u)?null:new te(e.line,Math.max(0,Math.min(s.text.length,e.ch+i*(u>=55296&&u<56320?2:1))),-i)}else o=r?function(t,e,i,n){var r=ct(e,t.doc.direction);if(!r)return Ja(e,i,n);i.ch>=e.text.length?(i.ch=e.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var a=st(r,i.ch,i.sticky),o=r[a];if("ltr"==t.doc.direction&&o.level%2==0&&(n>0?o.to>i.ch:o.from<i.ch))return Ja(e,i,n);var s,l=function(t,i){return Za(e,t instanceof te?t.ch:t,i)},c=function(i){return t.options.lineWrapping?(s=s||_i(t,e),Zi(t,e,s,i)):{begin:0,end:e.text.length}},u=c("before"==i.sticky?l(i,-1):i.ch);if("rtl"==t.doc.direction||1==o.level){var h=1==o.level==n<0,d=l(i,h?1:-1);if(null!=d&&(h?d<=o.to&&d<=u.end:d>=o.from&&d>=u.begin)){var f=h?"before":"after";return new te(i.line,d,f)}}var p=function(t,e,n){for(var a=function(t,e){return e?new te(i.line,l(t,1),"before"):new te(i.line,t,"after")};t>=0&&t<r.length;t+=e){var o=r[t],s=e>0==(1!=o.level),c=s?n.begin:l(n.end,-1);if(o.from<=c&&c<o.to)return a(c,s);if(c=s?o.from:l(o.to,-1),n.begin<=c&&c<n.end)return a(c,s)}},m=p(a+n,n,u);if(m)return m;var g=n>0?u.end:l(u.begin,-1);return null==g||n>0&&g==e.text.length||!(m=p(n>0?0:r.length-1,n,c(g)))?null:m}(t.cm,s,e,i):Ja(s,e,i);if(null==o){if(a||(c=e.line+l)<t.first||c>=t.first+t.size||(e=new te(c,e.ch,e.sticky),!(s=Kt(t,c))))return!1;e=Qa(r,t.cm,s,e.line,l)}else e=o;return!0}if("char"==n||"codepoint"==n)c();else if("column"==n)c(!0);else if("word"==n||"group"==n)for(var u=null,h="group"==n,d=t.cm&&t.cm.getHelper(e,"wordChars"),f=!0;!(i<0)||c(!f);f=!1){var p=s.text.charAt(e.ch)||"\n",m=tt(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||m||(m="s"),u&&u!=m){i<0&&(i=1,c(),e.sticky="after");break}if(m&&(u=m),i>0&&!c(!f))break}var g=aa(t,e,a,o,!0);return ie(a,g)&&(g.hitSide=!0),g}function Bo(t,e,i,n){var r,a,o=t.doc,s=e.left;if("page"==n){var l=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),c=Math.max(l-.5*nn(t.display),3);r=(i>0?e.bottom:e.top)+i*c}else"line"==n&&(r=i>0?e.bottom+3:e.top-3);for(;(a=Xi(t,s,r)).outside;){if(i<0?r<=0:r>=o.height){a.hitSide=!0;break}r+=5*i}return a}var Uo=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new B,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Ho(t,e){var i=Di(t,e.line);if(!i||i.hidden)return null;var n=Kt(t.doc,e.line),r=Li(i,n,e.line),a=ct(n,t.doc.direction),o="left";a&&(o=st(a,e.ch)%2?"right":"left");var s=Ni(r.map,e.ch,o);return s.offset="right"==s.collapse?s.end:s.start,s}function Go(t,e){return e&&(t.bad=!0),t}function zo(t,e,i){var n;if(e==t.display.lineDiv){if(!(n=t.display.lineDiv.childNodes[i]))return Go(t.clipPos(te(t.display.viewTo-1)),!0);e=null,i=0}else for(n=e;;n=n.parentNode){if(!n||n==t.display.lineDiv)return null;if(n.parentNode&&n.parentNode==t.display.lineDiv)break}for(var r=0;r<t.display.view.length;r++){var a=t.display.view[r];if(a.node==n)return Vo(a,e,i)}}function Vo(t,e,i){var n=t.text.firstChild,r=!1;if(!e||!_(n,e))return Go(te($t(t.line),0),!0);if(e==n&&(r=!0,e=n.childNodes[i],i=0,!e)){var a=t.rest?Y(t.rest):t.line;return Go(te($t(a),a.text.length),r)}var o=3==e.nodeType?e:null,s=e;for(o||1!=e.childNodes.length||3!=e.firstChild.nodeType||(o=e.firstChild,i&&(i=o.nodeValue.length));s.parentNode!=n;)s=s.parentNode;var l=t.measure,c=l.maps;function u(e,i,n){for(var r=-1;r<(c?c.length:0);r++)for(var a=r<0?l.map:c[r],o=0;o<a.length;o+=3){var s=a[o+2];if(s==e||s==i){var u=$t(r<0?t.line:t.rest[r]),h=a[o]+n;return(n<0||s!=e)&&(h=a[o+(n?1:0)]),te(u,h)}}}var h=u(o,s,i);if(h)return Go(h,r);for(var d=s.nextSibling,f=o?o.nodeValue.length-i:0;d;d=d.nextSibling){if(h=u(d,d.firstChild,0))return Go(te(h.line,h.ch-f),r);f+=d.textContent.length}for(var p=s.previousSibling,m=i;p;p=p.previousSibling){if(h=u(p,p.firstChild,-1))return Go(te(h.line,h.ch+m),r);m+=p.textContent.length}}Uo.prototype.init=function(t){var e=this,i=this,n=i.cm,r=i.div=t.lineDiv;function a(t){for(var e=t.target;e;e=e.parentNode){if(e==r)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(e.className))break}return!1}function o(t){if(a(t)&&!mt(n,t)){if(n.somethingSelected())_o({lineWise:!1,text:n.getSelections()}),"cut"==t.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var e=No(n);_o({lineWise:!0,text:e.text}),"cut"==t.type&&n.operation((function(){n.setSelections(e.ranges,0,G),n.replaceSelection("",null,"cut")}))}if(t.clipboardData){t.clipboardData.clearData();var o=Do.text.join("\n");if(t.clipboardData.setData("Text",o),t.clipboardData.getData("Text")==o)return void t.preventDefault()}var s=Fo(),l=s.firstChild;n.display.lineSpace.insertBefore(s,n.display.lineSpace.firstChild),l.value=Do.text.join("\n");var c=document.activeElement;N(l),setTimeout((function(){n.display.lineSpace.removeChild(s),c.focus(),c==r&&i.showPrimarySelection()}),50)}}Po(r,n.options.spellcheck,n.options.autocorrect,n.options.autocapitalize),ht(r,"paste",(function(t){!a(t)||mt(n,t)||Io(t,n)||s<=11&&setTimeout(tr(n,(function(){return e.updateFromDOM()})),20)})),ht(r,"compositionstart",(function(t){e.composing={data:t.data,done:!1}})),ht(r,"compositionupdate",(function(t){e.composing||(e.composing={data:t.data,done:!1})})),ht(r,"compositionend",(function(t){e.composing&&(t.data!=e.composing.data&&e.readFromDOMSoon(),e.composing.done=!0)})),ht(r,"touchstart",(function(){return i.forceCompositionEnd()})),ht(r,"input",(function(){e.composing||e.readFromDOMSoon()})),ht(r,"copy",o),ht(r,"cut",o)},Uo.prototype.screenReaderLabelChanged=function(t){t?this.div.setAttribute("aria-label",t):this.div.removeAttribute("aria-label")},Uo.prototype.prepareSelection=function(){var t=vn(this.cm,!1);return t.focus=document.activeElement==this.div,t},Uo.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Uo.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Uo.prototype.showPrimarySelection=function(){var t=this.getSelection(),e=this.cm,n=e.doc.sel.primary(),r=n.from(),a=n.to();if(e.display.viewTo==e.display.viewFrom||r.line>=e.display.viewTo||a.line<e.display.viewFrom)t.removeAllRanges();else{var o=zo(e,t.anchorNode,t.anchorOffset),s=zo(e,t.focusNode,t.focusOffset);if(!o||o.bad||!s||s.bad||0!=ee(ae(o,s),r)||0!=ee(re(o,s),a)){var l=e.display.view,c=r.line>=e.display.viewFrom&&Ho(e,r)||{node:l[0].measure.map[2],offset:0},u=a.line<e.display.viewTo&&Ho(e,a);if(!u){var h=l[l.length-1].measure,d=h.maps?h.maps[h.maps.length-1]:h.map;u={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}}if(c&&u){var f,p=t.rangeCount&&t.getRangeAt(0);try{f=w(c.node,c.offset,u.offset,u.node)}catch(t){}f&&(!i&&e.state.focused?(t.collapse(c.node,c.offset),f.collapsed||(t.removeAllRanges(),t.addRange(f))):(t.removeAllRanges(),t.addRange(f)),p&&null==t.anchorNode?t.addRange(p):i&&this.startGracePeriod()),this.rememberSelection()}else t.removeAllRanges()}}},Uo.prototype.startGracePeriod=function(){var t=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout((function(){t.gracePeriod=!1,t.selectionChanged()&&t.cm.operation((function(){return t.cm.curOp.selectionChanged=!0}))}),20)},Uo.prototype.showMultipleSelections=function(t){L(this.cm.display.cursorDiv,t.cursors),L(this.cm.display.selectionDiv,t.selection)},Uo.prototype.rememberSelection=function(){var t=this.getSelection();this.lastAnchorNode=t.anchorNode,this.lastAnchorOffset=t.anchorOffset,this.lastFocusNode=t.focusNode,this.lastFocusOffset=t.focusOffset},Uo.prototype.selectionInEditor=function(){var t=this.getSelection();if(!t.rangeCount)return!1;var e=t.getRangeAt(0).commonAncestorContainer;return _(this.div,e)},Uo.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Uo.prototype.blur=function(){this.div.blur()},Uo.prototype.getField=function(){return this.div},Uo.prototype.supportsTouch=function(){return!0},Uo.prototype.receivedFocus=function(){var t=this;this.selectionInEditor()?this.pollSelection():Qn(this.cm,(function(){return t.cm.curOp.selectionChanged=!0})),this.polling.set(this.cm.options.pollInterval,(function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}))},Uo.prototype.selectionChanged=function(){var t=this.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastFocusNode||t.focusOffset!=this.lastFocusOffset},Uo.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var t=this.getSelection(),e=this.cm;if(g&&u&&this.cm.display.gutterSpecs.length&&function(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}(t.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var i=zo(e,t.anchorNode,t.anchorOffset),n=zo(e,t.focusNode,t.focusOffset);i&&n&&Qn(e,(function(){Qr(e.doc,wr(i,n),G),(i.bad||n.bad)&&(e.curOp.selectionChanged=!0)}))}}},Uo.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var t,e,i,n=this.cm,r=n.display,a=n.doc.sel.primary(),o=a.from(),s=a.to();if(0==o.ch&&o.line>n.firstLine()&&(o=te(o.line-1,Kt(n.doc,o.line-1).length)),s.ch==Kt(n.doc,s.line).text.length&&s.line<n.lastLine()&&(s=te(s.line+1,0)),o.line<r.viewFrom||s.line>r.viewTo-1)return!1;o.line==r.viewFrom||0==(t=un(n,o.line))?(e=$t(r.view[0].line),i=r.view[0].node):(e=$t(r.view[t].line),i=r.view[t-1].node.nextSibling);var l,c,u=un(n,s.line);if(u==r.view.length-1?(l=r.viewTo-1,c=r.lineDiv.lastChild):(l=$t(r.view[u+1].line)-1,c=r.view[u+1].node.previousSibling),!i)return!1;for(var h=n.doc.splitLines(function(t,e,i,n,r){var a="",o=!1,s=t.doc.lineSeparator(),l=!1;function c(){o&&(a+=s,l&&(a+=s),o=l=!1)}function u(t){t&&(c(),a+=t)}function h(e){if(1==e.nodeType){var i=e.getAttribute("cm-text");if(i)return void u(i);var a,d=e.getAttribute("cm-marker");if(d){var f=t.findMarks(te(n,0),te(r+1,0),(g=+d,function(t){return t.id==g}));return void(f.length&&(a=f[0].find(0))&&u(qt(t.doc,a.from,a.to).join(s)))}if("false"==e.getAttribute("contenteditable"))return;var p=/^(pre|div|p|li|table|br)$/i.test(e.nodeName);if(!/^br$/i.test(e.nodeName)&&0==e.textContent.length)return;p&&c();for(var m=0;m<e.childNodes.length;m++)h(e.childNodes[m]);/^(pre|p)$/i.test(e.nodeName)&&(l=!0),p&&(o=!0)}else 3==e.nodeType&&u(e.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "));var g}for(;h(e),e!=i;)e=e.nextSibling,l=!1;return a}(n,i,c,e,l)),d=qt(n.doc,te(e,0),te(l,Kt(n.doc,l).text.length));h.length>1&&d.length>1;)if(Y(h)==Y(d))h.pop(),d.pop(),l--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),e++}for(var f=0,p=0,m=h[0],g=d[0],v=Math.min(m.length,g.length);f<v&&m.charCodeAt(f)==g.charCodeAt(f);)++f;for(var y=Y(h),b=Y(d),x=Math.min(y.length-(1==h.length?f:0),b.length-(1==d.length?f:0));p<x&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;if(1==h.length&&1==d.length&&e==o.line)for(;f&&f>o.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)f--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var S=te(e,f),C=te(l,d.length?Y(d).length-p:0);return h.length>1||h[0]||ee(S,C)?(pa(n.doc,h,S,C,"+input"),!0):void 0},Uo.prototype.ensurePolled=function(){this.forceCompositionEnd()},Uo.prototype.reset=function(){this.forceCompositionEnd()},Uo.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Uo.prototype.readFromDOMSoon=function(){var t=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(t.readDOMTimeout=null,t.composing){if(!t.composing.done)return;t.composing=null}t.updateFromDOM()}),80))},Uo.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||Qn(this.cm,(function(){return hn(t.cm)}))},Uo.prototype.setUneditable=function(t){t.contentEditable="false"},Uo.prototype.onKeyPress=function(t){0==t.charCode||this.composing||(t.preventDefault(),this.cm.isReadOnly()||tr(this.cm,Ro)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Uo.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Uo.prototype.onContextMenu=function(){},Uo.prototype.resetPosition=function(){},Uo.prototype.needsContentAttribute=!0;var Wo=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new B,this.hasSelection=!1,this.composing=null};Wo.prototype.init=function(t){var e=this,i=this,n=this.cm;this.createField(t);var r=this.textarea;function a(t){if(!mt(n,t)){if(n.somethingSelected())_o({lineWise:!1,text:n.getSelections()});else{if(!n.options.lineWiseCopyCut)return;var e=No(n);_o({lineWise:!0,text:e.text}),"cut"==t.type?n.setSelections(e.ranges,null,G):(i.prevInput="",r.value=e.text.join("\n"),N(r))}"cut"==t.type&&(n.state.cutIncoming=+new Date)}}t.wrapper.insertBefore(this.wrapper,t.wrapper.firstChild),m&&(r.style.width="0px"),ht(r,"input",(function(){o&&s>=9&&e.hasSelection&&(e.hasSelection=null),i.poll()})),ht(r,"paste",(function(t){mt(n,t)||Io(t,n)||(n.state.pasteIncoming=+new Date,i.fastPoll())})),ht(r,"cut",a),ht(r,"copy",a),ht(t.scroller,"paste",(function(e){if(!Si(t,e)&&!mt(n,e)){if(!r.dispatchEvent)return n.state.pasteIncoming=+new Date,void i.focus();var a=new Event("paste");a.clipboardData=e.clipboardData,r.dispatchEvent(a)}})),ht(t.lineSpace,"selectstart",(function(e){Si(t,e)||bt(e)})),ht(r,"compositionstart",(function(){var t=n.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:t,range:n.markText(t,n.getCursor("to"),{className:"CodeMirror-composing"})}})),ht(r,"compositionend",(function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)}))},Wo.prototype.createField=function(t){this.wrapper=Fo(),this.textarea=this.wrapper.firstChild},Wo.prototype.screenReaderLabelChanged=function(t){t?this.textarea.setAttribute("aria-label",t):this.textarea.removeAttribute("aria-label")},Wo.prototype.prepareSelection=function(){var t=this.cm,e=t.display,i=t.doc,n=vn(t);if(t.options.moveInputWithCursor){var r=Ki(t,i.sel.primary().head,"div"),a=e.wrapper.getBoundingClientRect(),o=e.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(e.wrapper.clientHeight-10,r.top+o.top-a.top)),n.teLeft=Math.max(0,Math.min(e.wrapper.clientWidth-10,r.left+o.left-a.left))}return n},Wo.prototype.showSelection=function(t){var e=this.cm.display;L(e.cursorDiv,t.cursors),L(e.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},Wo.prototype.reset=function(t){if(!this.contextMenuPending&&!this.composing){var e=this.cm;if(e.somethingSelected()){this.prevInput="";var i=e.getSelection();this.textarea.value=i,e.state.focused&&N(this.textarea),o&&s>=9&&(this.hasSelection=i)}else t||(this.prevInput=this.textarea.value="",o&&s>=9&&(this.hasSelection=null))}},Wo.prototype.getField=function(){return this.textarea},Wo.prototype.supportsTouch=function(){return!1},Wo.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||R()!=this.textarea))try{this.textarea.focus()}catch(t){}},Wo.prototype.blur=function(){this.textarea.blur()},Wo.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Wo.prototype.receivedFocus=function(){this.slowPoll()},Wo.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){t.poll(),t.cm.state.focused&&t.slowPoll()}))},Wo.prototype.fastPoll=function(){var t=!1,e=this;e.pollingFast=!0,e.polling.set(20,(function i(){e.poll()||t?(e.pollingFast=!1,e.slowPoll()):(t=!0,e.polling.set(60,i))}))},Wo.prototype.poll=function(){var t=this,e=this.cm,i=this.textarea,n=this.prevInput;if(this.contextMenuPending||!e.state.focused||Rt(i)&&!n&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=i.value;if(r==n&&!e.somethingSelected())return!1;if(o&&s>=9&&this.hasSelection===r||y&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var a=r.charCodeAt(0);if(8203!=a||n||(n=""),8666==a)return this.reset(),this.cm.execCommand("undo")}for(var l=0,c=Math.min(n.length,r.length);l<c&&n.charCodeAt(l)==r.charCodeAt(l);)++l;return Qn(e,(function(){Ro(e,r.slice(l),n.length-l,null,t.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?i.value=t.prevInput="":t.prevInput=r,t.composing&&(t.composing.range.clear(),t.composing.range=e.markText(t.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},Wo.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Wo.prototype.onKeyPress=function(){o&&s>=9&&(this.hasSelection=null),this.fastPoll()},Wo.prototype.onContextMenu=function(t){var e=this,i=e.cm,n=i.display,r=e.textarea;e.contextMenuPending&&e.contextMenuPending();var a=cn(i,t),c=n.scroller.scrollTop;if(a&&!h){i.options.resetSelectionOnContextMenu&&-1==i.doc.sel.contains(a)&&tr(i,Qr)(i.doc,wr(a),G);var u,d=r.style.cssText,f=e.wrapper.style.cssText,p=e.wrapper.offsetParent.getBoundingClientRect();if(e.wrapper.style.cssText="position: static",r.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-p.top-5)+"px; left: "+(t.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(o?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",l&&(u=window.scrollY),n.input.focus(),l&&window.scrollTo(null,u),n.input.reset(),i.somethingSelected()||(r.value=e.prevInput=" "),e.contextMenuPending=v,n.selForContextMenu=i.doc.sel,clearTimeout(n.detectingSelectAll),o&&s>=9&&g(),k){Ct(t);var m=function(){ft(window,"mouseup",m),setTimeout(v,20)};ht(window,"mouseup",m)}else setTimeout(v,50)}function g(){if(null!=r.selectionStart){var t=i.somethingSelected(),a=""+(t?r.value:"");r.value="⇚",r.value=a,e.prevInput=t?"":"",r.selectionStart=1,r.selectionEnd=a.length,n.selForContextMenu=i.doc.sel}}function v(){if(e.contextMenuPending==v&&(e.contextMenuPending=!1,e.wrapper.style.cssText=f,r.style.cssText=d,o&&s<9&&n.scrollbars.setScrollTop(n.scroller.scrollTop=c),null!=r.selectionStart)){(!o||o&&s<9)&&g();var t=0,a=function(){n.selForContextMenu==i.doc.sel&&0==r.selectionStart&&r.selectionEnd>0&&""==e.prevInput?tr(i,sa)(i):t++<10?n.detectingSelectAll=setTimeout(a,500):(n.selForContextMenu=null,n.input.reset())};n.detectingSelectAll=setTimeout(a,200)}}},Wo.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t,this.textarea.readOnly=!!t},Wo.prototype.setUneditable=function(){},Wo.prototype.needsContentAttribute=!1,function(t){var e=t.optionHandlers;function i(i,n,r,a){t.defaults[i]=n,r&&(e[i]=a?function(t,e,i){i!=Co&&r(t,e,i)}:r)}t.defineOption=i,t.Init=Co,i("value","",(function(t,e){return t.setValue(e)}),!0),i("mode",null,(function(t,e){t.doc.modeOption=e,Dr(t)}),!0),i("indentUnit",2,Dr,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,(function(t){_r(t),Bi(t),hn(t)}),!0),i("lineSeparator",null,(function(t,e){if(t.doc.lineSep=e,e){var i=[],n=t.doc.first;t.doc.iter((function(t){for(var r=0;;){var a=t.text.indexOf(e,r);if(-1==a)break;r=a+e.length,i.push(te(n,a))}n++}));for(var r=i.length-1;r>=0;r--)pa(t.doc,e,i[r],te(i[r].line,i[r].ch+e.length))}})),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(function(t,e,i){t.state.specialChars=new RegExp(e.source+(e.test("\t")?"":"|\t"),"g"),i!=Co&&t.refresh()})),i("specialCharPlaceholder",Je,(function(t){return t.refresh()}),!0),i("electricChars",!0),i("inputStyle",v?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),i("spellcheck",!1,(function(t,e){return t.getInputField().spellcheck=e}),!0),i("autocorrect",!1,(function(t,e){return t.getInputField().autocorrect=e}),!0),i("autocapitalize",!1,(function(t,e){return t.getInputField().autocapitalize=e}),!0),i("rtlMoveVisually",!x),i("wholeLineUpdateBefore",!0),i("theme","default",(function(t){So(t),mr(t)}),!0),i("keyMap","default",(function(t,e,i){var n=Xa(e),r=i!=Co&&Xa(i);r&&r.detach&&r.detach(t,n),n.attach&&n.attach(t,r||null)})),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,To,!0),i("gutters",[],(function(t,e){t.display.gutterSpecs=fr(e,t.options.lineNumbers),mr(t)}),!0),i("fixedGutter",!0,(function(t,e){t.display.gutters.style.left=e?on(t.display)+"px":"0",t.refresh()}),!0),i("coverGutterNextToScrollbar",!1,(function(t){return Hn(t)}),!0),i("scrollbarStyle","native",(function(t){Vn(t),Hn(t),t.display.scrollbars.setScrollTop(t.doc.scrollTop),t.display.scrollbars.setScrollLeft(t.doc.scrollLeft)}),!0),i("lineNumbers",!1,(function(t,e){t.display.gutterSpecs=fr(t.options.gutters,e),mr(t)}),!0),i("firstLineNumber",1,mr,!0),i("lineNumberFormatter",(function(t){return t}),mr,!0),i("showCursorWhenSelecting",!1,gn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,(function(t,e){"nocursor"==e&&(wn(t),t.display.input.blur()),t.display.input.readOnlyChanged(e)})),i("screenReaderLabel",null,(function(t,e){e=""===e?null:e,t.display.input.screenReaderLabelChanged(e)})),i("disableInput",!1,(function(t,e){e||t.display.input.reset()}),!0),i("dragDrop",!0,wo),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,gn,!0),i("singleCursorHeightPerLine",!0,gn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,_r,!0),i("addModeClass",!1,_r,!0),i("pollInterval",100),i("undoDepth",200,(function(t,e){return t.doc.history.undoDepth=e})),i("historyEventDelay",1250),i("viewportMargin",10,(function(t){return t.refresh()}),!0),i("maxHighlightLength",1e4,_r,!0),i("moveInputWithCursor",!0,(function(t,e){e||t.display.input.resetPosition()})),i("tabindex",null,(function(t,e){return t.display.input.getField().tabIndex=e||""})),i("autofocus",null),i("direction","ltr",(function(t,e){return t.doc.setDirection(e)}),!0),i("phrases",null)}(Oo),function(t){var e=t.optionHandlers,i=t.helpers={};t.prototype={constructor:t,focus:function(){window.focus(),this.display.input.focus()},setOption:function(t,i){var n=this.options,r=n[t];n[t]==i&&"mode"!=t||(n[t]=i,e.hasOwnProperty(t)&&tr(this,e[t])(this,i,r),pt(this,"optionChange",this,t))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"](Xa(t))},removeKeyMap:function(t){for(var e=this.state.keyMaps,i=0;i<e.length;++i)if(e[i]==t||e[i].name==t)return e.splice(i,1),!0},addOverlay:er((function(e,i){var n=e.token?e:t.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");!function(t,e,i){for(var n=0,r=i(e);n<t.length&&i(t[n])<=r;)n++;t.splice(n,0,e)}(this.state.overlays,{mode:n,modeSpec:e,opaque:i&&i.opaque,priority:i&&i.priority||0},(function(t){return t.priority})),this.state.modeGen++,hn(this)})),removeOverlay:er((function(t){for(var e=this.state.overlays,i=0;i<e.length;++i){var n=e[i].modeSpec;if(n==t||"string"==typeof t&&n.name==t)return e.splice(i,1),this.state.modeGen++,void hn(this)}})),indentLine:er((function(t,e,i){"string"!=typeof e&&"number"!=typeof e&&(e=null==e?this.options.smartIndent?"smart":"prev":e?"add":"subtract"),Jt(this.doc,t)&&Ao(this,t,e,i)})),indentSelection:er((function(t){for(var e=this.doc.sel.ranges,i=-1,n=0;n<e.length;n++){var r=e[n];if(r.empty())r.head.line>i&&(Ao(this,r.head.line,t,!0),i=r.head.line,n==this.doc.sel.primIndex&&_n(this));else{var a=r.from(),o=r.to(),s=Math.max(i,a.line);i=Math.min(this.lastLine(),o.line-(o.ch?0:1))+1;for(var l=s;l<i;++l)Ao(this,l,t);var c=this.doc.sel.ranges;0==a.ch&&e.length==c.length&&c[n].from().ch>0&&$r(this.doc,n,new kr(a,c[n].to()),G)}}})),getTokenAt:function(t,e){return ye(this,t,e)},getLineTokens:function(t,e){return ye(this,te(t),e,!0)},getTokenTypeAt:function(t){t=se(this.doc,t);var e,i=de(this,Kt(this.doc,t.line)),n=0,r=(i.length-1)/2,a=t.ch;if(0==a)e=i[2];else for(;;){var o=n+r>>1;if((o?i[2*o-1]:0)>=a)r=o;else{if(!(i[2*o+1]<a)){e=i[2*o+2];break}n=o+1}}var s=e?e.indexOf("overlay "):-1;return s<0?e:0==s?null:e.slice(0,s-1)},getModeAt:function(e){var i=this.doc.mode;return i.innerMode?t.innerMode(i,this.getTokenAt(e).state).mode:i},getHelper:function(t,e){return this.getHelpers(t,e)[0]},getHelpers:function(t,e){var n=[];if(!i.hasOwnProperty(e))return n;var r=i[e],a=this.getModeAt(t);if("string"==typeof a[e])r[a[e]]&&n.push(r[a[e]]);else if(a[e])for(var o=0;o<a[e].length;o++){var s=r[a[e][o]];s&&n.push(s)}else a.helperType&&r[a.helperType]?n.push(r[a.helperType]):r[a.name]&&n.push(r[a.name]);for(var l=0;l<r._global.length;l++){var c=r._global[l];c.pred(a,this)&&-1==U(n,c.val)&&n.push(c.val)}return n},getStateAfter:function(t,e){var i=this.doc;return fe(this,(t=oe(i,null==t?i.first+i.size-1:t))+1,e).state},cursorCoords:function(t,e){var i=this.doc.sel.primary();return Ki(this,null==t?i.head:"object"==typeof t?se(this.doc,t):t?i.from():i.to(),e||"page")},charCoords:function(t,e){return Wi(this,se(this.doc,t),e||"page")},coordsChar:function(t,e){return Xi(this,(t=Vi(this,t,e||"page")).left,t.top)},lineAtHeight:function(t,e){return t=Vi(this,{top:t,left:0},e||"page").top,Zt(this.doc,t+this.display.viewOffset)},heightAtLine:function(t,e,i){var n,r=!1;if("number"==typeof t){var a=this.doc.first+this.doc.size-1;t<this.doc.first?t=this.doc.first:t>a&&(t=a,r=!0),n=Kt(this.doc,t)}else n=t;return zi(this,n,{top:0,left:0},e||"page",i||r).top+(r?this.doc.height-ze(n):0)},defaultTextHeight:function(){return nn(this.display)},defaultCharWidth:function(){return rn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,i,n,r){var a,o,s,l=this.display,c=(t=Ki(this,se(this.doc,t))).bottom,u=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),l.sizer.appendChild(e),"over"==n)c=t.top;else if("above"==n||"near"==n){var h=Math.max(l.wrapper.clientHeight,this.doc.height),d=Math.max(l.sizer.clientWidth,l.lineSpace.clientWidth);("above"==n||t.bottom+e.offsetHeight>h)&&t.top>e.offsetHeight?c=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=h&&(c=t.bottom),u+e.offsetWidth>d&&(u=d-e.offsetWidth)}e.style.top=c+"px",e.style.left=e.style.right="","right"==r?(u=l.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==r?u=0:"middle"==r&&(u=(l.sizer.clientWidth-e.offsetWidth)/2),e.style.left=u+"px"),i&&(a=this,o={left:u,top:c,right:u+e.offsetWidth,bottom:c+e.offsetHeight},null!=(s=An(a,o)).scrollTop&&Nn(a,s.scrollTop),null!=s.scrollLeft&&Fn(a,s.scrollLeft))},triggerOnKeyDown:er(co),triggerOnKeyPress:er(ho),triggerOnKeyUp:uo,triggerOnMouseDown:er(go),execCommand:function(t){if(to.hasOwnProperty(t))return to[t].call(null,this)},triggerElectric:er((function(t){Mo(this,t)})),findPosH:function(t,e,i,n){var r=1;e<0&&(r=-1,e=-e);for(var a=se(this.doc,t),o=0;o<e&&!(a=jo(this.doc,a,r,i,n)).hitSide;++o);return a},moveH:er((function(t,e){var i=this;this.extendSelectionsBy((function(n){return i.display.shift||i.doc.extend||n.empty()?jo(i.doc,n.head,t,e,i.options.rtlMoveVisually):t<0?n.from():n.to()}),V)})),deleteH:er((function(t,e){var i=this.doc.sel,n=this.doc;i.somethingSelected()?n.replaceSelection("",null,"+delete"):$a(this,(function(i){var r=jo(n,i.head,t,e,!1);return t<0?{from:r,to:i.head}:{from:i.head,to:r}}))})),findPosV:function(t,e,i,n){var r=1,a=n;e<0&&(r=-1,e=-e);for(var o=se(this.doc,t),s=0;s<e;++s){var l=Ki(this,o,"div");if(null==a?a=l.left:l.left=a,(o=Bo(this,l,r,i)).hitSide)break}return o},moveV:er((function(t,e){var i=this,n=this.doc,r=[],a=!this.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy((function(o){if(a)return t<0?o.from():o.to();var s=Ki(i,o.head,"div");null!=o.goalColumn&&(s.left=o.goalColumn),r.push(s.left);var l=Bo(i,s,t,e);return"page"==e&&o==n.sel.primary()&&Dn(i,Wi(i,l,"div").top-s.top),l}),V),r.length)for(var o=0;o<n.sel.ranges.length;o++)n.sel.ranges[o].goalColumn=r[o]})),findWordAt:function(t){var e=Kt(this.doc,t.line).text,i=t.ch,n=t.ch;if(e){var r=this.getHelper(t,"wordChars");"before"!=t.sticky&&n!=e.length||!i?++n:--i;for(var a=e.charAt(i),o=tt(a,r)?function(t){return tt(t,r)}:/\s/.test(a)?function(t){return/\s/.test(t)}:function(t){return!/\s/.test(t)&&!tt(t)};i>0&&o(e.charAt(i-1));)--i;for(;n<e.length&&o(e.charAt(n));)++n}return new kr(te(t.line,i),te(t.line,n))},toggleOverwrite:function(t){null!=t&&t==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?I(this.display.cursorDiv,"CodeMirror-overwrite"):T(this.display.cursorDiv,"CodeMirror-overwrite"),pt(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==R()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:er((function(t,e){Rn(this,t,e)})),getScrollInfo:function(){var t=this.display.scroller;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight-wi(this)-this.display.barHeight,width:t.scrollWidth-wi(this)-this.display.barWidth,clientHeight:Oi(this),clientWidth:Ti(this)}},scrollIntoView:er((function(t,e){null==t?(t={from:this.doc.sel.primary().head,to:null},null==e&&(e=this.options.cursorScrollMargin)):"number"==typeof t?t={from:te(t,0),to:null}:null==t.from&&(t={from:t,to:null}),t.to||(t.to=t.from),t.margin=e||0,null!=t.from.line?function(t,e){In(t),t.curOp.scrollToPos=e}(this,t):Mn(this,t.from,t.to,t.margin)})),setSize:er((function(t,e){var i=this,n=function(t){return"number"==typeof t||/^\d+$/.test(String(t))?t+"px":t};null!=t&&(this.display.wrapper.style.width=n(t)),null!=e&&(this.display.wrapper.style.height=n(e)),this.options.lineWrapping&&ji(this);var r=this.display.viewFrom;this.doc.iter(r,this.display.viewTo,(function(t){if(t.widgets)for(var e=0;e<t.widgets.length;e++)if(t.widgets[e].noHScroll){dn(i,r,"widget");break}++r})),this.curOp.forceUpdate=!0,pt(this,"refresh",this)})),operation:function(t){return Qn(this,t)},startOperation:function(){return Kn(this)},endOperation:function(){return qn(this)},refresh:er((function(){var t=this.display.cachedTextHeight;hn(this),this.curOp.forceUpdate=!0,Bi(this),Rn(this,this.doc.scrollLeft,this.doc.scrollTop),cr(this.display),(null==t||Math.abs(t-nn(this.display))>.5||this.options.lineWrapping)&&ln(this),pt(this,"refresh",this)})),swapDoc:er((function(t){var e=this.doc;return e.cm=null,this.state.selectingText&&this.state.selectingText(),Nr(this,t),Bi(this),this.display.input.reset(),Rn(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,si(this,"swapDoc",this,e),e})),phrase:function(t){var e=this.options.phrases;return e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:t},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}},yt(t),t.registerHelper=function(e,n,r){i.hasOwnProperty(e)||(i[e]=t[e]={_global:[]}),i[e][n]=r},t.registerGlobalHelper=function(e,n,r,a){t.registerHelper(e,n,a),i[e]._global.push({pred:r,val:a})}}(Oo);var Ko="iter insert remove copy getEditor constructor".split(" ");for(var qo in Da.prototype)Da.prototype.hasOwnProperty(qo)&&U(Ko,qo)<0&&(Oo.prototype[qo]=function(t){return function(){return t.apply(this.doc,arguments)}}(Da.prototype[qo]));return yt(Da),Oo.inputStyles={textarea:Wo,contenteditable:Uo},Oo.defineMode=function(t){Oo.defaults.mode||"null"==t||(Oo.defaults.mode=t),Ft.apply(this,arguments)},Oo.defineMIME=function(t,e){Pt[t]=e},Oo.defineMode("null",(function(){return{token:function(t){return t.skipToEnd()}}})),Oo.defineMIME("text/plain","null"),Oo.defineExtension=function(t,e){Oo.prototype[t]=e},Oo.defineDocExtension=function(t,e){Da.prototype[t]=e},Oo.fromTextArea=function(t,e){if((e=e?F(e):{}).value=t.value,!e.tabindex&&t.tabIndex&&(e.tabindex=t.tabIndex),!e.placeholder&&t.placeholder&&(e.placeholder=t.placeholder),null==e.autofocus){var i=R();e.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}function n(){t.value=s.getValue()}var r;if(t.form&&(ht(t.form,"submit",n),!e.leaveSubmitMethodAlone)){var a=t.form;r=a.submit;try{var o=a.submit=function(){n(),a.submit=r,a.submit(),a.submit=o}}catch(t){}}e.finishInit=function(i){i.save=n,i.getTextArea=function(){return t},i.toTextArea=function(){i.toTextArea=isNaN,n(),t.parentNode.removeChild(i.getWrapperElement()),t.style.display="",t.form&&(ft(t.form,"submit",n),e.leaveSubmitMethodAlone||"function"!=typeof t.form.submit||(t.form.submit=r))}},t.style.display="none";var s=Oo((function(e){return t.parentNode.insertBefore(e,t.nextSibling)}),e);return s},function(t){t.off=ft,t.on=ht,t.wheelEventPixels=xr,t.Doc=Da,t.splitLines=_t,t.countColumn=j,t.findColumn=W,t.isWordChar=Q,t.Pass=H,t.signal=pt,t.Line=Ke,t.changeEnd=Tr,t.scrollbarModel=zn,t.Pos=te,t.cmpPos=ee,t.modes=Nt,t.mimeModes=Pt,t.resolveMode=jt,t.getMode=Bt,t.modeExtensions=Ut,t.extendMode=Ht,t.copyState=Gt,t.startState=Vt,t.innerMode=zt,t.commands=to,t.keyMap=Ga,t.keyName=Ya,t.isModifierKey=Ka,t.lookupKey=Wa,t.normalizeKeyMap=Va,t.StringStream=Wt,t.SharedTextMarker=Ta,t.TextMarker=Ea,t.LineWidget=Sa,t.e_preventDefault=bt,t.e_stopPropagation=xt,t.e_stop=Ct,t.addClass=I,t.contains=_,t.rmClass=T,t.keyNames=ja}(Oo),Oo.version="5.58.2",Oo}()},Y1PL:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./node_modules/rc-textarea/es/index.js + 7 modules ***!
|
|
|
\**********************************************************/
|
|
|
/*! exports provided: ResizableTextArea, default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/findDOMNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/omit.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/ref.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/shallowequal/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i.r(e),i.d(e,"ResizableTextArea",(function(){return I}));var n=i("wx14"),r=i("1OyB"),a=i("vuIU"),o=i("Ji7U"),s=i("LK+K"),l=i("q1tI"),c=i("VTBJ"),u=i("rePB"),h=i("Zm9Q"),d=(i("Kwbf"),i("c+Xe")),f=i("m+aA"),p=i("bdgK"),m=new Map;var g=new p.default((function(t){t.forEach((function(t){var e,i=t.target;null===(e=m.get(i))||void 0===e||e.forEach((function(t){return t(i)}))}))}));var v=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(){return Object(r.a)(this,i),e.apply(this,arguments)}return Object(a.a)(i,[{key:"render",value:function(){return this.props.children}}]),i}(l.Component),y=l.createContext(null);function b(t){var e=t.children,i=t.disabled,n=l.useRef(null),r=l.useRef(null),a=l.useContext(y),o=l.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),s=l.isValidElement(e)&&Object(d.c)(e),u=s?e.ref:null,h=l.useMemo((function(){return Object(d.a)(u,n)}),[u,n]),p=l.useRef(t);p.current=t;var b=l.useCallback((function(t){var e=p.current,i=e.onResize,n=e.data,r=t.getBoundingClientRect(),s=r.width,l=r.height,u=t.offsetWidth,h=t.offsetHeight,d=Math.floor(s),f=Math.floor(l);if(o.current.width!==d||o.current.height!==f||o.current.offsetWidth!==u||o.current.offsetHeight!==h){var m={width:d,height:f,offsetWidth:u,offsetHeight:h};o.current=m;var g=u===Math.round(s)?s:u,v=h===Math.round(l)?l:h,y=Object(c.a)(Object(c.a)({},m),{},{offsetWidth:g,offsetHeight:v});null==a||a(y,t,n),i&&Promise.resolve().then((function(){i(y,t)}))}}),[]);return l.useEffect((function(){var t,e,a=Object(f.a)(n.current)||Object(f.a)(r.current);return a&&!i&&(t=a,e=b,m.has(t)||(m.set(t,new Set),g.observe(t)),m.get(t).add(e)),function(){return function(t,e){m.has(t)&&(m.get(t).delete(e),m.get(t).size||(g.unobserve(t),m.delete(t)))}(a,b)}}),[n.current,i]),l.createElement(v,{ref:r},s?l.cloneElement(e,{ref:h}):e)}function x(t){var e=t.children;return Object(h.a)(e).map((function(e,i){var r=(null==e?void 0:e.key)||"".concat("rc-observer-key","-").concat(i);return l.createElement(b,Object(n.a)({},t,{key:r}),e)}))}x.Collection=function(t){var e=t.children,i=t.onBatchResize,n=l.useRef(0),r=l.useRef([]),a=l.useContext(y),o=l.useCallback((function(t,e,o){n.current+=1;var s=n.current;r.current.push({size:t,element:e,data:o}),Promise.resolve().then((function(){s===n.current&&(null==i||i(r.current),r.current=[])})),null==a||a(t,e,o)}),[i,a]);return l.createElement(y.Provider,{value:o},e)};var S,C=x,k=i("bT9E"),E=i("TSYQ"),w=i.n(E),T="\n min-height:0 !important;\n max-height:none !important;\n height:0 !important;\n visibility:hidden !important;\n overflow:hidden !important;\n position:absolute !important;\n z-index:-1000 !important;\n top:0 !important;\n right:0 !important\n",O=["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"],L={};function A(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t.getAttribute("id")||t.getAttribute("data-reactid")||t.getAttribute("name");if(e&&L[i])return L[i];var n=window.getComputedStyle(t),r=n.getPropertyValue("box-sizing")||n.getPropertyValue("-moz-box-sizing")||n.getPropertyValue("-webkit-box-sizing"),a=parseFloat(n.getPropertyValue("padding-bottom"))+parseFloat(n.getPropertyValue("padding-top")),o=parseFloat(n.getPropertyValue("border-bottom-width"))+parseFloat(n.getPropertyValue("border-top-width")),s=O.map((function(t){return"".concat(t,":").concat(n.getPropertyValue(t))})).join(";"),l={sizingStyle:s,paddingSize:a,borderSize:o,boxSizing:r};return e&&i&&(L[i]=l),l}var D,_=i("Gytx"),R=i.n(_);!function(t){t[t.NONE=0]="NONE",t[t.RESIZING=1]="RESIZING",t[t.RESIZED=2]="RESIZED"}(D||(D={}));var I=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(t){var a;return Object(r.a)(this,i),(a=e.call(this,t)).nextFrameActionId=void 0,a.resizeFrameId=void 0,a.textArea=void 0,a.saveTextArea=function(t){a.textArea=t},a.handleResize=function(t){var e=a.state.resizeStatus,i=a.props,n=i.autoSize,r=i.onResize;e===D.NONE&&("function"==typeof r&&r(t),n&&a.resizeOnNextFrame())},a.resizeOnNextFrame=function(){cancelAnimationFrame(a.nextFrameActionId),a.nextFrameActionId=requestAnimationFrame(a.resizeTextarea)},a.resizeTextarea=function(){var t=a.props.autoSize;if(t&&a.textArea){var e=t.minRows,i=t.maxRows,n=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;S||((S=document.createElement("textarea")).setAttribute("tab-index","-1"),S.setAttribute("aria-hidden","true"),document.body.appendChild(S)),t.getAttribute("wrap")?S.setAttribute("wrap",t.getAttribute("wrap")):S.removeAttribute("wrap");var r=A(t,e),a=r.paddingSize,o=r.borderSize,s=r.boxSizing,l=r.sizingStyle;S.setAttribute("style","".concat(l,";").concat(T)),S.value=t.value||t.placeholder||"";var c,u=Number.MIN_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=S.scrollHeight;if("border-box"===s?d+=o:"content-box"===s&&(d-=a),null!==i||null!==n){S.value=" ";var f=S.scrollHeight-a;null!==i&&(u=f*i,"border-box"===s&&(u=u+a+o),d=Math.max(u,d)),null!==n&&(h=f*n,"border-box"===s&&(h=h+a+o),c=d>h?"":"hidden",d=Math.min(h,d))}return{height:d,minHeight:u,maxHeight:h,overflowY:c,resize:"none"}}(a.textArea,!1,e,i);a.setState({textareaStyles:n,resizeStatus:D.RESIZING},(function(){cancelAnimationFrame(a.resizeFrameId),a.resizeFrameId=requestAnimationFrame((function(){a.setState({resizeStatus:D.RESIZED},(function(){a.resizeFrameId=requestAnimationFrame((function(){a.setState({resizeStatus:D.NONE}),a.fixFirefoxAutoScroll()}))}))}))}))}},a.renderTextArea=function(){var t=a.props,e=t.prefixCls,i=void 0===e?"rc-textarea":e,r=t.autoSize,o=t.onResize,s=t.className,h=t.disabled,d=a.state,f=d.textareaStyles,p=d.resizeStatus,m=Object(k.a)(a.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),g=w()(i,s,Object(u.a)({},"".concat(i,"-disabled"),h));"value"in m&&(m.value=m.value||"");var v=Object(c.a)(Object(c.a)(Object(c.a)({},a.props.style),f),p===D.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return l.createElement(C,{onResize:a.handleResize,disabled:!(r||o)},l.createElement("textarea",Object(n.a)({},m,{className:g,style:v,ref:a.saveTextArea})))},a.state={textareaStyles:{},resizeStatus:D.NONE},a}return Object(a.a)(i,[{key:"componentDidUpdate",value:function(t){t.value===this.props.value&&R()(t.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 t=this.textArea.selectionStart,e=this.textArea.selectionEnd;this.textArea.setSelectionRange(t,e)}}catch(t){}}},{key:"render",value:function(){return this.renderTextArea()}}]),i}(l.Component),M=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(t){var n;Object(r.a)(this,i),(n=e.call(this,t)).resizableTextArea=void 0,n.focus=function(){n.resizableTextArea.textArea.focus()},n.saveTextArea=function(t){n.resizableTextArea=t},n.handleChange=function(t){var e=n.props.onChange;n.setValue(t.target.value,(function(){n.resizableTextArea.resizeTextarea()})),e&&e(t)},n.handleKeyDown=function(t){var e=n.props,i=e.onPressEnter,r=e.onKeyDown;13===t.keyCode&&i&&i(t),r&&r(t)};var a=void 0===t.value||null===t.value?t.defaultValue:t.value;return n.state={value:a},n}return Object(a.a)(i,[{key:"setValue",value:function(t,e){"value"in this.props||this.setState({value:t},e)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return l.createElement(I,Object(n.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(t){return"value"in t?{value:t.value}:null}}]),i}(l.Component);e.default=M},ZW9T:
|
|
|
/*!************************************************************!*\
|
|
|
!*** ./src/components/monaco-editor/index.jsx + 1 modules ***!
|
|
|
\************************************************************/
|
|
|
/*! exports provided: getLanguageByMirrorName, default, DiffEditor */
|
|
|
/*! exports used: DiffEditor, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */function(t,e,i){"use strict";i.d(e,"a",(function(){return v}));var n=i("k1fw"),r=(i("miYZ"),i("tsqr")),a=i("rAM+"),o=i("tJVT"),s=i("PpiC"),l=i("q1tI"),c=i.n(l),u=i("bdgK");function h(t,e,i,r,a){var o=e.getWordUntilPosition(i),s={startLineNumber:i.lineNumber,endLineNumber:i.lineNumber,startColumn:o.startColumn,endColumn:o.endColumn},l=r.map((function(e){return{label:e,kind:t.languages.CompletionItemKind.Keyword,insertText:e,insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:s}}));return a.map((function(t){l.push(Object(n.a)(Object(n.a)({},t),{},{range:s}))})),l}i("LvDl");function d(t){return/^\d+$/.test(t)?"".concat(t,"px"):t}function f(){}var p={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=t;if(Array.isArray(t)){for(var i=0;i<t.length;i++){var n=p[t[i]];if(n)return n}return e[0]}return p[e]||e}var g=null;e.b=function(t){var e=t.width,p=void 0===e?"100%":e,v=t.height,y=void 0===v?"100%":v,b=t.value,x=t.language,S=void 0===x?"javascript":x,C=t.style,k=void 0===C?{}:C,E=t.options,w=void 0===E?{}:E,T=t.overrideServices,O=void 0===T?{}:T,L=t.theme,A=void 0===L?"vs-dark":L,D=t.onEditBlur,_=t.onSave,R=t.autoHeight,I=void 0!==R&&R,M=t.forbidCopy,N=void 0!==M&&M,P=t.onChange,F=void 0===P?f:P,j=t.editorDidMount,B=void 0===j?f:j,U=t.onFocus,H=void 0===U?f:U,G=t.filename,z=void 0===G?"educoder.txt":G,V=(Object(s.a)(t,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Object(l.useRef)()),W=Object(l.useRef)({}),K=Object(l.useRef)(),q=Object(l.useRef)(!1),Y=Object(l.useRef)(),X=Object(l.useState)(!1),$=Object(o.a)(X,2),Z=$[0],J=$[1];function Q(){r.b.warn(decodeURIComponent("该任务关卡设置了禁止复制粘贴,请手动输入代码。"))}function tt(){var t=W.current.instance;if(t){var e=t.getSelection(),i=W.current.pastePos||{},n=new g.Range(i.startLineNumber||e.endLineNumber,i.startColumn||e.endColumn,i.endLineNumber||e.endLineNumber,i.endColumn||e.endColumn);setTimeout((function(){t.executeEdits("",[{range:n,text:""}])}),300)}}function et(t){(window.navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)&&83==t.keyCode&&(t.preventDefault(),_())}Object(l.useEffect)((function(){K.current&&clearTimeout(K.current),K.current=setTimeout((function(){!function(){var t=W.current.instance;if(null!=b&&t&&Z){var e=t.getModel();e&&b!==e.getValue()&&(!0,e.setValue(b),t.layout(),!1)}}()}),500)}),[b,Z,W.current]);var it=function(){if(I&&W.current.instance){var t=W.current.instance.getContentHeight();ut(t<y?y:t)}else ut(y)};function nt(t,e){var i,n,r=window.URL||window.webkitURL||window,a=new Blob([e]),o=document.createElementNS("http://www.w3.org/1999/xhtml","a");o.href=r.createObjectURL(a),o.download=t,i=o,(n=document.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(n)}Object(l.useEffect)((function(){it()}),[it]),Object(l.useEffect)((function(){V.current&&!Z&&i.e(/*! import() | monaco-editor */27).then(i.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){try{g=t,W.current.instance=g.editor.create(V.current,{value:b,language:m(S),theme:A,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},O);var e=W.current.instance;if(B(e,g),setTimeout((function(){it(),W.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){nt(z||"educoder.txt",e.getValue())}})}),500),W.current.subscription=e.onDidChangeModelContent((function(t){q.current?clearTimeout(Y.current):(it(),F(e.getValue(),t)),Y.current=setTimeout((function(){q.current=!1}),500)})),window.Monaco||function(t){var e={label:"ifelse",kind:t.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {","\t$0","} else {","\t","}"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet},i=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];t.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(n,r){return{suggestions:h(t,n,r,i,[e])}}});var n=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];t.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(e,i){var r=[{label:"print",kind:t.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:h(t,e,i,n,r)}}});var r=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];t.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(i,n){var a=[e,{label:"main",kind:t.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {","\t$0","}"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:t.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join("\n"),insertTextRules:t.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:h(t,i,n,r,a)}}})}(g),N&&(e.addCommand(g.KeyMod.CtrlCmd|g.KeyMod.Shift|g.KeyCode.KEY_V,(function(){return Q(),null})),e.addCommand(g.KeyMod.CtrlCmd|g.KeyCode.KEY_C,(function(){return Q(),null}))),window.Monaco=g,D&&e.onDidBlurEditorWidget((function(){D(e.getValue())})),H&&e.onDidFocusEditorText((function(){H(e.getValue())})),N){e.addCommand(g.KeyMod.CtrlCmd|g.KeyCode.KEY_V,(function(){return Q(),null})),e.onDidPaste((function(t){W.current.pastePos=t}));try{window.addEventListener("paste",tt)}catch(t){}}var i=function(){var t;return V.current&&(t=new u.default((function(t){var e,i=Object(a.a)(t);try{for(i.s();!(e=i.n()).done;){var n=e.value;(n.target.offsetHeight>0||n.target.offsetWidth>0)&&W.current.instance.layout()}}catch(t){i.e(t)}finally{i.f()}}))).observe(V.current),t}();return J(!0),function(){var t=W.current.instance;t.dispose();var e=t.getModel();e&&e.dispose(),W.current.subscription&&W.current.subscription.dispose(),N&&window.removeEventListener("paste",tt),i.unobserve(V.current)}}catch(t){}}))}),[]),Object(l.useEffect)((function(){if(W.current.instance&&Z)return document.addEventListener("keydown",et,!1),function(){document.removeEventListener("keydown",et)}}),[_,Z]),Object(l.useEffect)((function(){var t=W.current.instance;if(t&&Z){var e=m(S);g.editor.setModelLanguage(t.getModel(),e),console.log("language:",S,t.getModel(),e)}}),[S,Z]),Object(l.useEffect)((function(){W.current.instance&&Z&&g.editor.setTheme(A)}),[A,Z]),Object(l.useEffect)((function(){var t=W.current.instance;t&&Z&&(t.updateOptions(Object(n.a)({},w)),setTimeout((function(){t.getModel().updateOptions(Object(n.a)({},w))}),200))}),[JSON.stringify(w),Z]),Object(l.useEffect)((function(){var t=W.current.instance;t&&Z&&t.layout()}),[p,y,Z]);var rt=Object(l.useState)(d(p)),at=Object(o.a)(rt,2),ot=at[0],st=(at[1],Object(l.useState)(d(y))),lt=Object(o.a)(st,2),ct=lt[0],ut=lt[1],ht=Object(n.a)(Object(n.a)({},k),{},{width:ot,height:ct});return c.a.createElement("div",{className:"my-monaco-editor",ref:V,style:ht})};function v(t){var e=t.width,r=void 0===e?"100%":e,s=t.height,h=void 0===s?"100%":s,f=t.original,p=t.modified,m=t.language,v=t.options,y=void 0===v?{}:v,b=Object(l.useRef)(),x=Object(l.useState)(null),S=Object(o.a)(x,2),C=S[0],k=S[1];Object(l.useEffect)((function(){b.current&&i.e(/*! import() | monaco-editor */27).then(i.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(t){var e=(g=t).editor.createDiffEditor(b.current,Object(n.a)(Object(n.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},y),{},{wordWrap:!0}));k(e);var i=function(t){var e;return b.current&&(e=new u.default((function(e){var i,n=Object(a.a)(e);try{for(n.s();!(i=n.n()).done;){var r=i.value;(r.target.offsetHeight>0||r.target.offsetWidth>0)&&t.layout()}}catch(t){n.e(t)}finally{n.f()}}))).observe(b.current),e}(e);return function(){e.dispose();var t=e.getModel();t&&t.dispose(),i.unobserve(b.current)}}))}),[]),Object(l.useEffect)((function(){C&&C.setModel({original:g.editor.createModel(f,m),modified:g.editor.createModel(p,m)})}),[f,p,m,C]);var E={width:d(r),height:d(h)};return c.a.createElement("div",{className:"my-diff-editor",ref:b,style:E})}},ZpRC:
|
|
|
/*!*************************************************************************!*\
|
|
|
!*** ./node_modules/scroll-into-view-if-needed/es/index.js + 1 modules ***!
|
|
|
\*************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";function n(t){return"object"==typeof t&&null!=t&&1===t.nodeType}function r(t,e){return(!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function a(t,e){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var i=getComputedStyle(t,null);return r(i.overflowY,e)||r(i.overflowX,e)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return!!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return!1}function o(t,e,i,n,r,a,o,s){return a<t&&o>e||a>t&&o<e?0:a<=t&&s<=i||o>=e&&s>=i?a-t-n:o>e&&s<i||a<t&&s>i?o-e+r:0}var s=function(t,e){var i=window,r=e.scrollMode,s=e.block,l=e.inline,c=e.boundary,u=e.skipOverflowHiddenElements,h="function"==typeof c?c:function(t){return t!==c};if(!n(t))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,f=[],p=t;n(p)&&h(p);){if((p=p.parentElement)===d){f.push(p);break}null!=p&&p===document.body&&a(p)&&!a(document.documentElement)||null!=p&&a(p,u)&&f.push(p)}for(var m=i.visualViewport?i.visualViewport.width:innerWidth,g=i.visualViewport?i.visualViewport.height:innerHeight,v=window.scrollX||pageXOffset,y=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),x=b.height,S=b.width,C=b.top,k=b.right,E=b.bottom,w=b.left,T="start"===s||"nearest"===s?C:"end"===s?E:C+x/2,O="center"===l?w+S/2:"end"===l?k:w,L=[],A=0;A<f.length;A++){var D=f[A],_=D.getBoundingClientRect(),R=_.height,I=_.width,M=_.top,N=_.right,P=_.bottom,F=_.left;if("if-needed"===r&&C>=0&&w>=0&&E<=g&&k<=m&&C>=M&&E<=P&&w>=F&&k<=N)return L;var j=getComputedStyle(D),B=parseInt(j.borderLeftWidth,10),U=parseInt(j.borderTopWidth,10),H=parseInt(j.borderRightWidth,10),G=parseInt(j.borderBottomWidth,10),z=0,V=0,W="offsetWidth"in D?D.offsetWidth-D.clientWidth-B-H:0,K="offsetHeight"in D?D.offsetHeight-D.clientHeight-U-G:0;if(d===D)z="start"===s?T:"end"===s?T-g:"nearest"===s?o(y,y+g,g,U,G,y+T,y+T+x,x):T-g/2,V="start"===l?O:"center"===l?O-m/2:"end"===l?O-m:o(v,v+m,m,B,H,v+O,v+O+S,S),z=Math.max(0,z+y),V=Math.max(0,V+v);else{z="start"===s?T-M-U:"end"===s?T-P+G+K:"nearest"===s?o(M,P,R,U,G+K,T,T+x,x):T-(M+R/2)+K/2,V="start"===l?O-F-B:"center"===l?O-(F+I/2)+W/2:"end"===l?O-N+H+W:o(F,N,I,B,H+W,O,O+S,S);var q=D.scrollLeft,Y=D.scrollTop;T+=Y-(z=Math.max(0,Math.min(Y+z,D.scrollHeight-R+K))),O+=q-(V=Math.max(0,Math.min(q+V,D.scrollWidth-I+W)))}L.push({el:D,top:z,left:V})}return L};function l(t){return t===Object(t)&&0!==Object.keys(t).length}e.a=function(t,e){var i=!t.ownerDocument.documentElement.contains(t);if(l(e)&&"function"==typeof e.behavior)return e.behavior(i?[]:s(t,e));if(!i){var n=function(t){return!1===t?{block:"end",inline:"nearest"}:l(t)?t:{block:"start",inline:"nearest"}}(e);return function(t,e){void 0===e&&(e="auto");var i="scrollBehavior"in document.body.style;t.forEach((function(t){var n=t.el,r=t.top,a=t.left;n.scroll&&i?n.scroll({top:r,left:a,behavior:e}):(n.scrollTop=r,n.scrollLeft=a)}))}(s(t,n),n.behavior)}}},bT9E:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/omit.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var n=i(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ");function r(t,e){var i=Object(n.a)({},t);return Array.isArray(e)&&e.forEach((function(t){delete i[t]})),i}},c5Ni:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/codemirror/theme/blackboard.css ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},dejd:
|
|
|
/*!***********************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/toolbar/index.less ***!
|
|
|
\***********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},dmUQ:
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/rc-input-number/es/index.js + 1 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";var n=i("Ff2n"),r=i("rePB"),a=i("1OyB"),o=i("vuIU"),s=i("Ji7U"),l=i("md7G"),c=i("foSv"),u=i("q1tI"),h=i.n(u),d=i("TSYQ"),f=i.n(d),p=i("4IlW");function m(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function g(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?m(Object(i),!0).forEach((function(e){Object(r.a)(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):m(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function v(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=Object(c.a)(t);if(e){var r=Object(c.a)(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return Object(l.a)(this,i)}}function y(){}function b(t){t.preventDefault()}var x=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,S=function(t){return null!=t},C=function(t,e){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},k=function(t){Object(s.a)(i,t);var e=v(i);function i(t){var n;Object(a.a)(this,i),(n=e.call(this,t)).onKeyDown=function(t){var e=n.props,i=e.onKeyDown,r=e.onPressEnter;if(t.keyCode===p.a.UP){var a=n.getRatio(t);n.up(t,a,null),n.stop()}else if(t.keyCode===p.a.DOWN){var o=n.getRatio(t);n.down(t,o,null),n.stop()}else t.keyCode===p.a.ENTER&&r&&r(t);if(n.recordCursorPosition(),n.lastKeyCode=t.keyCode,i){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];i.apply(void 0,[t].concat(l))}},n.onKeyUp=function(t){var e=n.props.onKeyUp;if(n.stop(),n.recordCursorPosition(),e){for(var i=arguments.length,r=new Array(i>1?i-1:0),a=1;a<i;a++)r[a-1]=arguments[a];e.apply(void 0,[t].concat(r))}},n.onChange=function(t){var e=n.props.onChange;n.state.focused&&(n.inputting=!0),n.rawInput=n.props.parser(n.getValueFromEvent(t)),n.setState({inputValue:n.rawInput}),e(n.toNumber(n.rawInput))},n.onMouseUp=function(){var t=n.props.onMouseUp;n.recordCursorPosition(),t&&t.apply(void 0,arguments)},n.onFocus=function(){var t;n.setState({focused:!0}),(t=n.props).onFocus.apply(t,arguments)},n.onBlur=function(){var t=n.props.onBlur;n.inputting=!1,n.setState({focused:!1});var e=n.getCurrentValidValue(n.state.inputValue),i=n.setValue(e,y);if(t){var r=n.input.value,a=n.getInputDisplayValue({focus:!1,value:i});n.input.value=a?Number(a):a,t.apply(void 0,arguments),n.input.value=r}},n.getRatio=function(t){var e=1;return t.metaKey||t.ctrlKey?e=.1:t.shiftKey&&(e=10),e},n.getFullNum=function(t){return isNaN(t)?t:/e/i.test(String(t))?Number(t).toFixed(18).replace(/\.?0+$/,""):t},n.getPrecision=function(t){if(S(n.props.precision))return n.props.precision;var e=String(t);if(e.indexOf("e-")>=0)return parseInt(e.slice(e.indexOf("e-")+2),10);var i=0;return e.indexOf(".")>=0&&(i=e.length-e.indexOf(".")-1),i},n.getInputDisplayValue=function(t){var e,i=t||n.state,r=i.focused,a=i.inputValue,o=i.value;null==(e=r?a:n.toPrecisionAsStep(o))&&(e="");var s=n.formatWrapper(e);return S(n.props.decimalSeparator)&&(s=s.toString().replace(".",n.props.decimalSeparator)),s},n.recordCursorPosition=function(){try{n.cursorStart=n.input.selectionStart,n.cursorEnd=n.input.selectionEnd,n.currentValue=n.input.value,n.cursorBefore=n.input.value.substring(0,n.cursorStart),n.cursorAfter=n.input.value.substring(n.cursorEnd)}catch(t){}},n.restoreByAfter=function(t){if(void 0===t)return!1;var e=n.input.value,i=e.lastIndexOf(t);if(-1===i)return!1;var r=n.cursorBefore.length;return n.lastKeyCode===p.a.DELETE&&n.cursorBefore.charAt(r-1)===t[0]?(n.fixCaret(r,r),!0):i+t.length===e.length&&(n.fixCaret(i,i),!0)},n.partRestoreByAfter=function(t){return void 0!==t&&Array.prototype.some.call(t,(function(e,i){var r=t.substring(i);return n.restoreByAfter(r)}))},n.isNotCompleteNumber=function(t){return isNaN(t)||""===t||null===t||t&&t.toString().indexOf(".")===t.toString().length-1},n.stop=function(){n.autoStepTimer&&clearTimeout(n.autoStepTimer)},n.down=function(t,e,i){n.pressingUpOrDown=!0,n.step("down",t,e,i)},n.up=function(t,e,i){n.pressingUpOrDown=!0,n.step("up",t,e,i)},n.saveInput=function(t){n.input=t};var r=t.value;void 0===r&&(r=t.defaultValue),n.state={focused:t.autoFocus};var o=n.getValidValue(n.toNumber(r));return n.state=g(g({},n.state),{},{inputValue:n.toPrecisionAsStep(o),value:o}),n}return Object(o.a)(i,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(t){var e=this.props,i=e.value,n=e.onChange,r=e.max,a=e.min,o=this.state.focused;if(t){if(!C(t.value,i)||!C(t.max,r)||!C(t.min,a)){var s,l=o?i:this.getValidValue(i);s=this.pressingUpOrDown?l:this.inputting?this.rawInput:this.toPrecisionAsStep(l),this.setState({value:l,inputValue:s})}var c="value"in this.props?i:this.state.value;"max"in this.props&&t.max!==r&&"number"==typeof c&&c>r&&n&&n(r),"min"in this.props&&t.min!==a&&"number"==typeof c&&c<a&&n&&n(a)}try{if(void 0!==this.cursorStart&&this.state.focused)if(this.partRestoreByAfter(this.cursorAfter)||this.state.value===this.props.value){if(this.currentValue===this.input.value)switch(this.lastKeyCode){case p.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case p.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1)}}else{var u=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===p.a.BACKSPACE?u=this.cursorStart-1:this.lastKeyCode===p.a.DELETE&&(u=this.cursorStart):u=this.input.value.length,this.fixCaret(u,u)}}catch(t){}this.lastKeyCode=null,this.pressingUpOrDown&&this.props.focusOnUpDown&&this.state.focused&&document.activeElement!==this.input&&this.focus()}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(t){var e=t;return e=""===e?"":this.isNotCompleteNumber(parseFloat(e))?this.state.value:this.getValidValue(e),this.toNumber(e)}},{key:"getValueFromEvent",value:function(t){var e=t.target.value.trim().replace(/。/g,".");return S(this.props.decimalSeparator)&&(e=e.replace(this.props.decimalSeparator,".")),e}},{key:"getValidValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.min,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props.max,n=parseFloat(t);return isNaN(n)?t:(n<e&&(n=e),n>i&&(n=i),n)}},{key:"setValue",value:function(t,e){var i=this.props.precision,n=this.isNotCompleteNumber(parseFloat(t))?null:parseFloat(t),r=this.state.value,a=void 0===r?null:r,o=this.state.inputValue,s=void 0===o?null:o,l="number"==typeof n?n.toFixed(i):"".concat(n),c=n!==a||l!=="".concat(s);return"value"in this.props?(s=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:s},e)):this.setState({value:n,inputValue:this.toPrecisionAsStep(t)},e),c&&this.props.onChange(n),n}},{key:"getMaxPrecision",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=this.props,n=i.precision,r=i.step;if(S(n))return n;var a=this.getPrecision(e),o=this.getPrecision(r),s=this.getPrecision(t);return t?Math.max(s,a+o):a+o}},{key:"getPrecisionFactor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=this.getMaxPrecision(t,e);return Math.pow(10,i)}},{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(t){return this.props.formatter?this.props.formatter(t):t}},{key:"toPrecisionAsStep",value:function(t){if(this.isNotCompleteNumber(t)||""===t)return t;var e=Math.abs(this.getMaxPrecision(t));return isNaN(e)?t.toString():Number(t).toFixed(e)}},{key:"toNumber",value:function(t){var e=this.props.precision,i=this.state.focused,n=t&&t.length>16&&i;return this.isNotCompleteNumber(t)||n?t:S(e)?Math.round(t*Math.pow(10,e))/Math.pow(10,e):Number(t)}},{key:"upStep",value:function(t,e){var i=this.props.step,n=this.getPrecisionFactor(t,e),r=Math.abs(this.getMaxPrecision(t,e)),a=((n*t+n*i*e)/n).toFixed(r);return this.toNumber(a)}},{key:"downStep",value:function(t,e){var i=this.props.step,n=this.getPrecisionFactor(t,e),r=Math.abs(this.getMaxPrecision(t,e)),a=((n*t-n*i*e)/n).toFixed(r);return this.toNumber(a)}},{key:"step",value:function(t,e){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;this.stop(),e&&(e.persist(),e.preventDefault());var a=this.props;if(!a.disabled){var o=this.getCurrentValidValue(this.state.inputValue)||0;if(!this.isNotCompleteNumber(o)){var s=this["".concat(t,"Step")](o,n),l=s>a.max||s<a.min;s>a.max?s=a.max:s<a.min&&(s=a.min),this.setValue(s,null),this.setState({focused:!0},(function(){i.pressingUpOrDown=!1})),l||(this.autoStepTimer=setTimeout((function(){i[t](e,n,!0)}),r?200:600))}}}},{key:"fixCaret",value:function(t,e){if(void 0!==t&&void 0!==e&&this.input&&this.input.value)try{var i=this.input.selectionStart,n=this.input.selectionEnd;t===i&&e===n||this.input.setSelectionRange(t,e)}catch(t){}}},{key:"render",value:function(){var t,e=this.props,i=e.prefixCls,a=e.disabled,o=e.readOnly,s=e.useTouch,l=e.autoComplete,c=e.upHandler,u=e.downHandler,d=e.className,p=e.max,m=e.min,g=e.style,v=e.title,x=e.onMouseEnter,S=e.onMouseLeave,C=e.onMouseOver,k=e.onMouseOut,E=e.required,w=e.onClick,T=e.tabIndex,O=e.type,L=e.placeholder,A=e.id,D=e.inputMode,_=e.pattern,R=e.step,I=e.maxLength,M=e.autoFocus,N=e.name,P=e.onPaste,F=e.onInput,j=Object(n.a)(e,["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"]),B=this.state,U=B.value,H=B.focused,G=f()(i,(t={},Object(r.a)(t,d,!!d),Object(r.a)(t,"".concat(i,"-disabled"),a),Object(r.a)(t,"".concat(i,"-focused"),H),t)),z={};Object.keys(j).forEach((function(t){"data-"!==t.substr(0,5)&&"aria-"!==t.substr(0,5)&&"role"!==t||(z[t]=j[t])}));var V=!o&&!a,W=this.getInputDisplayValue(null),K=(U||0===U)&&(isNaN(U)||Number(U)>=p)||a||o,q=(U||0===U)&&(isNaN(U)||Number(U)<=m)||a||o,Y=f()("".concat(i,"-handler"),"".concat(i,"-handler-up"),Object(r.a)({},"".concat(i,"-handler-up-disabled"),K)),X=f()("".concat(i,"-handler"),"".concat(i,"-handler-down"),Object(r.a)({},"".concat(i,"-handler-down-disabled"),q)),$=s?{onTouchStart:K?y:this.up,onTouchEnd:this.stop}:{onMouseDown:K?y:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},Z=s?{onTouchStart:q?y:this.down,onTouchEnd:this.stop}:{onMouseDown:q?y:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return h.a.createElement("div",{className:G,style:g,title:v,onMouseEnter:x,onMouseLeave:S,onMouseOver:C,onMouseOut:k,onFocus:function(){return null},onBlur:function(){return null}},h.a.createElement("div",{className:"".concat(i,"-handler-wrap")},h.a.createElement("span",Object.assign({unselectable:"on"},$,{role:"button","aria-label":"Increase Value","aria-disabled":K,className:Y}),c||h.a.createElement("span",{unselectable:"on",className:"".concat(i,"-handler-up-inner"),onClick:b})),h.a.createElement("span",Object.assign({unselectable:"on"},Z,{role:"button","aria-label":"Decrease Value","aria-disabled":q,className:X}),u||h.a.createElement("span",{unselectable:"on",className:"".concat(i,"-handler-down-inner"),onClick:b}))),h.a.createElement("div",{className:"".concat(i,"-input-wrap")},h.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":m,"aria-valuemax":p,"aria-valuenow":U,required:E,type:O,placeholder:L,onPaste:P,onClick:w,onMouseUp:this.onMouseUp,className:"".concat(i,"-input"),tabIndex:T,autoComplete:l,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:V?this.onKeyDown:y,onKeyUp:V?this.onKeyUp:y,autoFocus:M,maxLength:I,readOnly:o,disabled:a,max:p,min:m,step:R,name:N,title:v,id:A,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(W),pattern:_,inputMode:D,onInput:F},z))))}}]),i}(h.a.Component);k.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:x,min:-x,step:1,style:{},onChange:y,onKeyDown:y,onPressEnter:y,onFocus:y,onBlur:y,parser:function(t){return t.replace(/[^\w.-]+/g,"")},required:!1,autoComplete:"off"};var E=k;e.a=E},fJjg:
|
|
|
/*!**********************************************************************!*\
|
|
|
!*** ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx ***!
|
|
|
\**********************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i(/*! antd/es/modal/style */"2qtc");var n=i(/*! antd/es/modal */"kLXV"),r=(i(/*! antd/es/radio/style */"7Kak"),i(/*! antd/es/radio */"9yH6")),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),o=(i(/*! antd/es/message/style */"miYZ"),i(/*! antd/es/message */"tsqr")),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),l=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),c=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties */"PpiC"),u=(i(/*! antd/es/input/style */"5NDa"),i(/*! antd/es/input */"5rEg")),h=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),d=i.n(h),f=i(/*! react */"q1tI"),p=i.n(f),m=i(/*! umi */"9kvl"),g=i(/*! ./SendToClassModal.less?modules */"Nska"),v=i.n(g),y=i(/*! @/utils/util */"1vsH"),b=u.a.Search;e.a=Object(m.a)((function(t){var e=t.userDetail,i=t.loading;return{userDetail:e,globalSetting:t.globalSetting,loading:i.effects}}))((function(t){var e=t.userDetail,i=(t.globalSetting,t.loading),u=t.dispatch,h=(Object(c.a)(t,["userDetail","globalSetting","loading","dispatch"]),Object(f.useState)("")),m=Object(l.a)(h,2),g=m[0],x=m[1],S=Object(f.useState)([]),C=Object(l.a)(S,2),k=C[0],E=C[1],w=Object(f.useState)(),T=Object(l.a)(w,2),O=T[0],L=T[1],A=Object(f.useState)(!1),D=Object(l.a)(A,2),_=D[0],R=D[1];Object(f.useEffect)((function(){I()}),[]);var I=function(){var t=Object(s.a)(d.a.mark((function t(){var e;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u({type:"userDetail/topicGetCourseList",payload:{search:g}});case 2:(e=t.sent)&&E((null==e?void 0:e.courses)||[]);case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),M=function(){var t=Object(s.a)(d.a.mark((function t(){var i,n,r,s,l;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(O){t.next=4;break}return o.b.info("您需要创建课堂,才能发送"),R(!0),t.abrupt("return");case 4:return t.next=6,u({type:"userDetail/topicSendToClass",payload:Object(a.a)({course_id:O},null===(i=e.actionTabs)||void 0===i?void 0:i.params)});case 6:n=t.sent,u({type:"userDetail/setActionTabs",payload:{}}),n&&0===n.status&&(l={normal:"common_homework",group:"group_homework",exercise:"exercise",poll:"poll"},Object(y.O)("/classrooms/".concat(O,"/").concat(l[null===(r=e.actionTabs)||void 0===r||null===(s=r.params)||void 0===s?void 0:s.object_type])));case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return p.a.createElement(n.a,{centered:!0,keyboard:!1,closable:!1,destroyOnClose:!0,visible:"UserDetail-SendToClass"===e.actionTabs.key,title:"发送至课堂",okText:"确定",cancelText:"取消",confirmLoading:i["userDetail/sendToClass"],width:600,onOk:M,onCancel:function(){u({type:"userDetail/setActionTabs",payload:{}})}},p.a.createElement("div",{className:v.a.wrap},p.a.createElement("div",{className:v.a.title},"温馨提示:选择的题将会发送到指定课堂"),p.a.createElement("div",{className:"mb10"},p.a.createElement(b,{placeholder:"输入课堂名称的关键字进行搜索",value:g,onChange:function(t){return x(t.target.value)},onSearch:function(t){x(t),I()}})),p.a.createElement("div",{className:v.a.radioWrap},p.a.createElement(r.a.Group,{value:O,onChange:function(t){L(t.target.value),R(!1)}},k.map((function(t,e){return p.a.createElement(r.a,{className:v.a.radio,value:t.course_id,key:t.course_id},t.course_name)})))),_&&p.a.createElement("div",{className:v.a.colorFF0000},"请先选择课堂")))}))},k3GJ:
|
|
|
/*!*******************************************************!*\
|
|
|
!*** ./node_modules/rc-tabs/es/index.js + 50 modules ***!
|
|
|
\*******************************************************/
|
|
|
/*! exports provided: TabPane, default */
|
|
|
/*! exports used: TabPane, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/typeof.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/mini-store/esm/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/raf/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-align/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-dropdown/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-resize-observer/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/addEventListener.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/canUseDom.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/contains.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/findDOMNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Portal.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/createChainedFunction.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/hooks/useMergedState.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/omit.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/raf.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/ref.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-dom/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/shallowequal/index.js (<- Module is not an ECMAScript module) */function(t,e,i){"use strict";i.d(e,"a",(function(){return We}));var n=i("rePB"),r=i("ODXe"),a=i("Ff2n"),o=i("VTBJ"),s=i("q1tI"),l=i("TSYQ"),c=i.n(l),u=i("Zm9Q"),h=i("6cGi"),d=i("KQm4"),f=i("xEkU"),p=i.n(f),m=i("t23M");function g(t){var e=Object(s.useRef)(),i=Object(s.useRef)(!1);return Object(s.useEffect)((function(){return function(){i.current=!0,p.a.cancel(e.current)}}),[]),function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];i.current||(p.a.cancel(e.current),e.current=p()((function(){t.apply(void 0,r)})))}}var v=i("4IlW");var y=s.forwardRef((function(t,e){var i,r=t.prefixCls,a=t.id,o=t.active,l=t.rtl,u=t.tab,h=u.key,d=u.tab,f=u.disabled,p=u.closeIcon,m=t.tabBarGutter,g=t.tabPosition,y=t.closable,b=t.renderWrapper,x=t.removeAriaLabel,S=t.editable,C=t.onClick,k=t.onRemove,E=t.onFocus,w="".concat(r,"-tab");s.useEffect((function(){return k}),[]);var T={};"top"===g||"bottom"===g?T[l?"marginLeft":"marginRight"]=m:T.marginBottom=m;var O=S&&!1!==y&&!f;function L(t){f||C(t)}var A=s.createElement("div",{key:h,ref:e,className:c()(w,(i={},Object(n.a)(i,"".concat(w,"-with-remove"),O),Object(n.a)(i,"".concat(w,"-active"),o),Object(n.a)(i,"".concat(w,"-disabled"),f),i)),style:T,onClick:L},s.createElement("div",{role:"tab","aria-selected":o,id:a&&"".concat(a,"-tab-").concat(h),className:"".concat(w,"-btn"),"aria-controls":a&&"".concat(a,"-panel-").concat(h),"aria-disabled":f,tabIndex:f?null:0,onClick:function(t){t.stopPropagation(),L(t)},onKeyDown:function(t){[v.a.SPACE,v.a.ENTER].includes(t.which)&&(t.preventDefault(),L(t))},onFocus:E},d),O&&s.createElement("button",{type:"button","aria-label":x||"remove",tabIndex:0,className:"".concat(w,"-remove"),onClick:function(t){var e;t.stopPropagation(),(e=t).preventDefault(),e.stopPropagation(),S.onEdit("remove",{key:h,event:e})}},p||S.removeIcon||"×"));return b&&(A=b(A)),A})),b={width:0,height:0,left:0,top:0};var x={width:0,height:0,left:0,top:0,right:0};var S=i("wx14"),C=i("1OyB"),k=i("vuIU"),E=i("JX7q"),w=i("Ji7U"),T=i("LK+K"),O=i("I8Z2"),L=i("bT9E"),A=i("2GS6"),D=i("Gytx"),_=i.n(D),R=i("U8pU"),I=/iPhone/i,M=/iPod/i,N=/iPad/i,P=/\bAndroid(?:.+)Mobile\b/i,F=/Android/i,j=/\bAndroid(?:.+)SD4930UR\b/i,B=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,U=/Windows Phone/i,H=/\bWindows(?:.+)ARM\b/i,G=/BlackBerry/i,z=/BB10/i,V=/Opera Mini/i,W=/\b(CriOS|Chrome)(?:.+)Mobile/i,K=/Mobile(?:.+)Firefox\b/i;function q(t,e){return t.test(e)}function Y(t){var e=t||("undefined"!=typeof navigator?navigator.userAgent:""),i=(e||"").split("[FBAN");if(void 0!==i[1]){var n=i;e=Object(r.a)(n,1)[0]}if(void 0!==(i=e.split("Twitter"))[1]){var a=i;e=Object(r.a)(a,1)[0]}var o={apple:{phone:q(I,e)&&!q(U,e),ipod:q(M,e),tablet:!q(I,e)&&q(N,e)&&!q(U,e),device:(q(I,e)||q(M,e)||q(N,e))&&!q(U,e)},amazon:{phone:q(j,e),tablet:!q(j,e)&&q(B,e),device:q(j,e)||q(B,e)},android:{phone:!q(U,e)&&q(j,e)||!q(U,e)&&q(P,e),tablet:!q(U,e)&&!q(j,e)&&!q(P,e)&&(q(B,e)||q(F,e)),device:!q(U,e)&&(q(j,e)||q(B,e)||q(P,e)||q(F,e))||q(/\bokhttp\b/i,e)},windows:{phone:q(U,e),tablet:q(H,e),device:q(U,e)||q(H,e)},other:{blackberry:q(G,e),blackberry10:q(z,e),opera:q(V,e),firefox:q(K,e),chrome:q(W,e),device:q(G,e)||q(z,e)||q(V,e)||q(K,e)||q(W,e)},any:null,phone:null,tablet:null};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}var X=Object(o.a)(Object(o.a)({},Y()),{},{isMobile:Y});function $(){}function Z(t,e,i){var n=e||"";return t.key||"".concat(n,"item_").concat(i)}function J(t){return"".concat(t,"-menu-")}function Q(t,e){var i=-1;s.Children.forEach(t,(function(t){i+=1,t&&t.type&&t.type.isMenuItemGroup?s.Children.forEach(t.props.children,(function(t){e(t,i+=1)})):e(t,i)}))}var tt=["defaultSelectedKeys","selectedKeys","defaultOpenKeys","openKeys","mode","getPopupContainer","onSelect","onDeselect","onDestroy","openTransitionName","openAnimation","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","triggerSubMenuAction","level","selectable","multiple","onOpenChange","visible","focusable","defaultActiveFirst","prefixCls","inlineIndent","parentMenu","title","rootPrefixCls","eventKey","active","onItemHover","onTitleMouseEnter","onTitleMouseLeave","onTitleClick","popupAlign","popupOffset","isOpen","renderMenuItem","manualRef","subMenuKey","disabled","index","isSelected","store","activeKey","builtinPlacements","overflowedIndicator","motion","attribute","value","popupClassName","inlineCollapsed","menu","theme","itemIcon","expandIcon"],et=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t&&"function"==typeof t.getBoundingClientRect&&t.getBoundingClientRect().width;if(i){if(e){var n=getComputedStyle(t),r=n.marginLeft,a=n.marginRight;i+=+r.replace("px","")+ +a.replace("px","")}i=+i.toFixed(6)}return i||0},it=function(t,e,i){t&&"object"===Object(R.a)(t.style)&&(t.style[e]=i)},nt=i("bdgK"),rt=i("i8i4"),at=i.n(rt),ot=i("wgJM"),st=i("l4aY"),lt=i("m+aA"),ct=i("c+Xe"),ut=i("zT1h"),ht=i("QC+M");function dt(t,e,i){return i?t[0]===e[0]:t[0]===e[0]&&t[1]===e[1]}var ft=i("MNnm");function pt(t,e){var i={};return i[t.toLowerCase()]=e.toLowerCase(),i["Webkit".concat(t)]="webkit".concat(e),i["Moz".concat(t)]="moz".concat(e),i["ms".concat(t)]="MS".concat(e),i["O".concat(t)]="o".concat(e.toLowerCase()),i}var mt,gt,vt,yt=(mt=Object(ft.a)(),gt="undefined"!=typeof window?window:{},vt={animationend:pt("Animation","AnimationEnd"),transitionend:pt("Transition","TransitionEnd")},mt&&("AnimationEvent"in gt||delete vt.animationend.animation,"TransitionEvent"in gt||delete vt.transitionend.transition),vt),bt={};if(Object(ft.a)()){var xt=document.createElement("div");bt=xt.style}var St={};function Ct(t){if(St[t])return St[t];var e=yt[t];if(e)for(var i=Object.keys(e),n=i.length,r=0;r<n;r+=1){var a=i[r];if(Object.prototype.hasOwnProperty.call(e,a)&&a in bt)return St[t]=e[a],St[t]}return""}var kt=Ct("animationend"),Et=Ct("transitionend"),wt=!(!kt||!Et),Tt=kt||"animationend",Ot=Et||"transitionend";function Lt(t,e){return t?"object"===Object(R.a)(t)?t[e.replace(/-\w/g,(function(t){return t[1].toUpperCase()}))]:"".concat(t,"-").concat(e):null}function At(t){var e=Object(s.useRef)(!1),i=Object(s.useState)(t),n=Object(r.a)(i,2),a=n[0],o=n[1];return Object(s.useEffect)((function(){return function(){e.current=!0}}),[]),[a,function(t){e.current||o(t)}]}var Dt=Object(ft.a)()?s.useLayoutEffect:s.useEffect,_t=["prepare","start","active","end"];function Rt(t){return"active"===t||"end"===t}var It=function(t,e){var i=s.useState("none"),n=Object(r.a)(i,2),a=n[0],o=n[1],l=function(){var t=s.useRef(null);function e(){ot.a.cancel(t.current)}return s.useEffect((function(){return function(){e()}}),[]),[function i(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;e();var a=Object(ot.a)((function(){r<=1?n({isCanceled:function(){return a!==t.current}}):i(n,r-1)}));t.current=a},e]}(),c=Object(r.a)(l,2),u=c[0],h=c[1];return Dt((function(){if("none"!==a&&"end"!==a){var t=_t.indexOf(a),i=_t[t+1],n=e(a);!1===n?o(i):u((function(t){function e(){t.isCanceled()||o(i)}!0===n?e():Promise.resolve(n).then(e)}))}}),[t,a]),s.useEffect((function(){return function(){h()}}),[]),[function(){o("prepare")},a]};function Mt(t,e,i,a){var l=a.motionEnter,c=void 0===l||l,u=a.motionAppear,h=void 0===u||u,d=a.motionLeave,f=void 0===d||d,p=a.motionDeadline,m=a.motionLeaveImmediately,g=a.onAppearPrepare,v=a.onEnterPrepare,y=a.onLeavePrepare,b=a.onAppearStart,x=a.onEnterStart,S=a.onLeaveStart,C=a.onAppearActive,k=a.onEnterActive,E=a.onLeaveActive,w=a.onAppearEnd,T=a.onEnterEnd,O=a.onLeaveEnd,L=a.onVisibleChanged,A=At(),D=Object(r.a)(A,2),_=D[0],R=D[1],I=At("none"),M=Object(r.a)(I,2),N=M[0],P=M[1],F=At(null),j=Object(r.a)(F,2),B=j[0],U=j[1],H=Object(s.useRef)(!1),G=Object(s.useRef)(null),z=Object(s.useRef)(!1),V=Object(s.useRef)(null);function W(){return i()||V.current}var K=Object(s.useRef)(!1);function q(t){var e,i=W();t&&!t.deadline&&t.target!==i||("appear"===N&&K.current?e=null==w?void 0:w(i,t):"enter"===N&&K.current?e=null==T?void 0:T(i,t):"leave"===N&&K.current&&(e=null==O?void 0:O(i,t)),!1===e||z.current||(P("none"),U(null)))}var Y=function(t){var e=Object(s.useRef)(),i=Object(s.useRef)(t);i.current=t;var n=s.useCallback((function(t){i.current(t)}),[]);function r(t){t&&(t.removeEventListener(Ot,n),t.removeEventListener(Tt,n))}return s.useEffect((function(){return function(){r(e.current)}}),[]),[function(t){e.current&&e.current!==t&&r(e.current),t&&t!==e.current&&(t.addEventListener(Ot,n),t.addEventListener(Tt,n),e.current=t)},r]}(q),X=Object(r.a)(Y,1)[0],$=s.useMemo((function(){var t,e,i;switch(N){case"appear":return t={},Object(n.a)(t,"prepare",g),Object(n.a)(t,"start",b),Object(n.a)(t,"active",C),t;case"enter":return e={},Object(n.a)(e,"prepare",v),Object(n.a)(e,"start",x),Object(n.a)(e,"active",k),e;case"leave":return i={},Object(n.a)(i,"prepare",y),Object(n.a)(i,"start",S),Object(n.a)(i,"active",E),i;default:return{}}}),[N]),Z=It(N,(function(t){if("prepare"===t){var e=$.prepare;return!!e&&e(W())}var i;tt in $&&U((null===(i=$[tt])||void 0===i?void 0:i.call($,W(),null))||null);return"active"===tt&&(X(W()),p>0&&(clearTimeout(G.current),G.current=setTimeout((function(){q({deadline:!0})}),p))),!0})),J=Object(r.a)(Z,2),Q=J[0],tt=J[1],et=Rt(tt);K.current=et,Dt((function(){R(e);var i,n=H.current;(H.current=!0,t)&&(!n&&e&&h&&(i="appear"),n&&e&&c&&(i="enter"),(n&&!e&&f||!n&&m&&!e&&f)&&(i="leave"),i&&(P(i),Q()))}),[e]),Object(s.useEffect)((function(){("appear"===N&&!h||"enter"===N&&!c||"leave"===N&&!f)&&P("none")}),[h,c,f]),Object(s.useEffect)((function(){return function(){clearTimeout(G.current),z.current=!0}}),[]),Object(s.useEffect)((function(){void 0!==_&&"none"===N&&(null==L||L(_))}),[_,N]);var it=B;return $.prepare&&"start"===tt&&(it=Object(o.a)({transition:"none"},it)),[N,tt,it,null!=_?_:e]}var Nt=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(){return Object(C.a)(this,i),e.apply(this,arguments)}return Object(k.a)(i,[{key:"render",value:function(){return this.props.children}}]),i}(s.Component);var Pt=function(t){var e=t;function i(t){return!(!t.motionName||!e)}"object"===Object(R.a)(t)&&(e=t.transitionSupport);var a=s.forwardRef((function(t,e){var a=t.visible,l=void 0===a||a,u=t.removeOnLeave,h=void 0===u||u,d=t.forceRender,f=t.children,p=t.motionName,m=t.leavedClassName,g=t.eventProps,v=i(t),y=Object(s.useRef)(),b=Object(s.useRef)();var x=Mt(v,l,(function(){try{return Object(lt.a)(y.current||b.current)}catch(t){return null}}),t),S=Object(r.a)(x,4),C=S[0],k=S[1],E=S[2],w=S[3],T=s.useRef(w);w&&(T.current=!0);var O=Object(s.useRef)(e);O.current=e;var L,A=s.useCallback((function(t){y.current=t,Object(ct.b)(O.current,t)}),[]),D=Object(o.a)(Object(o.a)({},g),{},{visible:l});if(f)if("none"!==C&&i(t)){var _,R;"prepare"===k?R="prepare":Rt(k)?R="active":"start"===k&&(R="start"),L=f(Object(o.a)(Object(o.a)({},D),{},{className:c()(Lt(p,C),(_={},Object(n.a)(_,Lt(p,"".concat(C,"-").concat(R)),R),Object(n.a)(_,p,"string"==typeof p),_)),style:E}),A)}else L=w?f(Object(o.a)({},D),A):!h&&T.current?f(Object(o.a)(Object(o.a)({},D),{},{className:m}),A):d?f(Object(o.a)(Object(o.a)({},D),{},{style:{display:"none"}}),A):null;else L=null;return s.createElement(Nt,{ref:b},L)}));return a.displayName="CSSMotion",a}(wt);function Ft(t){var e;return e=t&&"object"===Object(R.a)(t)&&"key"in t?t:{key:t},Object(o.a)(Object(o.a)({},e),{},{key:String(e.key)})}function jt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.map(Ft)}function Bt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=[],n=0,r=e.length,a=jt(t),s=jt(e);a.forEach((function(t){for(var e=!1,a=n;a<r;a+=1){var l=s[a];if(l.key===t.key){n<a&&(i=i.concat(s.slice(n,a).map((function(t){return Object(o.a)(Object(o.a)({},t),{},{status:"add"})}))),n=a),i.push(Object(o.a)(Object(o.a)({},l),{},{status:"keep"})),n+=1,e=!0;break}}e||i.push(Object(o.a)(Object(o.a)({},t),{},{status:"remove"}))})),n<r&&(i=i.concat(s.slice(n).map((function(t){return Object(o.a)(Object(o.a)({},t),{},{status:"add"})}))));var l={};i.forEach((function(t){var e=t.key;l[e]=(l[e]||0)+1}));var c=Object.keys(l).filter((function(t){return l[t]>1}));return c.forEach((function(t){(i=i.filter((function(e){var i=e.key,n=e.status;return i!==t||"remove"!==n}))).forEach((function(e){e.key===t&&(e.status="keep")}))})),i}var Ut=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];!function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pt,i=function(t){Object(w.a)(n,t);var i=Object(T.a)(n);function n(){var t;return Object(C.a)(this,n),(t=i.apply(this,arguments)).state={keyEntities:[]},t.removeKey=function(e){t.setState((function(t){return{keyEntities:t.keyEntities.map((function(t){return t.key!==e?t:Object(o.a)(Object(o.a)({},t),{},{status:"removed"})}))}}))},t}return Object(k.a)(n,[{key:"render",value:function(){var t=this,i=this.state.keyEntities,n=this.props,r=n.component,o=n.children,l=n.onVisibleChanged,c=Object(a.a)(n,["component","children","onVisibleChanged"]),u=r||s.Fragment,h={};return Ut.forEach((function(t){h[t]=c[t],delete c[t]})),delete c.keys,s.createElement(u,c,i.map((function(i){var n=i.status,r=Object(a.a)(i,["status"]),c="add"===n||"keep"===n;return s.createElement(e,Object(S.a)({},h,{key:r.key,visible:c,eventProps:r,onVisibleChanged:function(e){null==l||l(e,{key:r.key}),e||t.removeKey(r.key)}}),o)})))}}],[{key:"getDerivedStateFromProps",value:function(t,e){var i=t.keys,n=e.keyEntities,r=jt(i);return{keyEntities:Bt(n,r).filter((function(t){var e=n.find((function(e){var i=e.key;return t.key===i}));return!e||"removed"!==e.status||"remove"!==t.status}))}}}]),n}(s.Component);i.defaultProps={component:"div"}}(wt);var Ht=Pt;function Gt(t){var e=t.prefixCls,i=t.motion,n=t.animation,r=t.transitionName;return i||(n?{motionName:"".concat(e,"-").concat(n)}:r?{motionName:r}:null)}function zt(t){var e=t.prefixCls,i=t.visible,n=t.zIndex,r=t.mask,a=t.maskMotion,l=t.maskAnimation,u=t.maskTransitionName;if(!r)return null;var h={};return(a||u||l)&&(h=Object(o.a)({motionAppear:!0},Gt({motion:a,prefixCls:e,transitionName:u,animation:l}))),s.createElement(Ht,Object(S.a)({},h,{visible:i,removeOnLeave:!0}),(function(t){var i=t.className;return s.createElement("div",{style:{zIndex:n},className:c()("".concat(e,"-mask"),i)})}))}var Vt=i("9mu1"),Wt=i("o0o1"),Kt=i.n(Wt),qt=i("HaE+"),Yt=["measure","align",null,"motion"],Xt=s.forwardRef((function(t,e){var i=t.visible,n=t.prefixCls,a=t.className,l=t.style,u=t.children,h=t.zIndex,d=t.stretch,f=t.destroyPopupOnHide,p=t.forceRender,m=t.align,g=t.point,v=t.getRootDomNode,y=t.getClassNameFromAlign,b=t.onAlign,x=t.onMouseEnter,C=t.onMouseLeave,k=t.onMouseDown,E=t.onTouchStart,w=Object(s.useRef)(),T=Object(s.useRef)(),O=Object(s.useState)(),L=Object(r.a)(O,2),A=L[0],D=L[1],_=function(t){var e=s.useState({width:0,height:0}),i=Object(r.a)(e,2),n=i[0],a=i[1];return[s.useMemo((function(){var e={};if(t){var i=n.width,r=n.height;-1!==t.indexOf("height")&&r?e.height=r:-1!==t.indexOf("minHeight")&&r&&(e.minHeight=r),-1!==t.indexOf("width")&&i?e.width=i:-1!==t.indexOf("minWidth")&&i&&(e.minWidth=i)}return e}),[t,n]),function(t){a({width:t.offsetWidth,height:t.offsetHeight})}]}(d),R=Object(r.a)(_,2),I=R[0],M=R[1];var N=function(t,e){var i=Object(s.useState)(null),n=Object(r.a)(i,2),a=n[0],o=n[1],l=Object(s.useRef)(),c=Object(s.useRef)(!1);function u(t){c.current||o(t)}function h(){ot.a.cancel(l.current)}return Object(s.useEffect)((function(){u("measure")}),[t]),Object(s.useEffect)((function(){switch(a){case"measure":e()}a&&(l.current=Object(ot.a)(Object(qt.a)(Kt.a.mark((function t(){var e,i;return Kt.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Yt.indexOf(a),(i=Yt[e+1])&&-1!==e&&u(i);case 3:case"end":return t.stop()}}),t)})))))}),[a]),Object(s.useEffect)((function(){return function(){c.current=!0,h()}}),[]),[a,function(t){h(),l.current=Object(ot.a)((function(){u((function(t){switch(a){case"align":return"motion";case"motion":return"stable"}return t})),null==t||t()}))}]}(i,(function(){d&&M(v())})),P=Object(r.a)(N,2),F=P[0],j=P[1],B=Object(s.useRef)();function U(){var t;null===(t=w.current)||void 0===t||t.forceAlign()}function H(t,e){var i=y(e);A!==i&&D(i),"align"===F&&(A!==i?Promise.resolve().then((function(){U()})):j((function(){var t;null===(t=B.current)||void 0===t||t.call(B)})),null==b||b(t,e))}var G=Object(o.a)({},Gt(t));function z(){return new Promise((function(t){B.current=t}))}["onAppearEnd","onEnterEnd","onLeaveEnd"].forEach((function(t){var e=G[t];G[t]=function(t,i){return j(),null==e?void 0:e(t,i)}})),s.useEffect((function(){G.motionName||"motion"!==F||j()}),[G.motionName,F]),s.useImperativeHandle(e,(function(){return{forceAlign:U,getElement:function(){return T.current}}}));var V=Object(o.a)(Object(o.a)({},I),{},{zIndex:h,opacity:"motion"!==F&&"stable"!==F&&i?0:void 0,pointerEvents:"stable"===F?void 0:"none"},l),W=!0;!(null==m?void 0:m.points)||"align"!==F&&"stable"!==F||(W=!1);var K=u;return s.Children.count(u)>1&&(K=s.createElement("div",{className:"".concat(n,"-content")},u)),s.createElement(Ht,Object(S.a)({visible:i,ref:T,leavedClassName:"".concat(n,"-hidden")},G,{onAppearPrepare:z,onEnterPrepare:z,removeOnLeave:f,forceRender:p}),(function(t,e){var i=t.className,r=t.style,l=c()(n,a,A,i);return s.createElement(Vt.a,{target:g||v,key:"popup",ref:w,monitorWindowResize:!0,disabled:W,align:m,onAlign:H},s.createElement("div",{ref:e,className:l,onMouseEnter:x,onMouseLeave:C,onMouseDownCapture:k,onTouchStartCapture:E,style:Object(o.a)(Object(o.a)({},r),V)},K))}))}));Xt.displayName="PopupInner";var $t=Xt,Zt=s.forwardRef((function(t,e){var i=t.prefixCls,n=t.visible,r=t.zIndex,a=t.children,l=t.mobile,u=(l=void 0===l?{}:l).popupClassName,h=l.popupStyle,d=l.popupMotion,f=void 0===d?{}:d,p=l.popupRender,m=s.useRef();s.useImperativeHandle(e,(function(){return{forceAlign:function(){},getElement:function(){return m.current}}}));var g=Object(o.a)({zIndex:r},h),v=a;return s.Children.count(a)>1&&(v=s.createElement("div",{className:"".concat(i,"-content")},a)),p&&(v=p(v)),s.createElement(Ht,Object(S.a)({visible:n,ref:m,removeOnLeave:!0},f),(function(t,e){var n=t.className,r=t.style,a=c()(i,u,n);return s.createElement("div",{ref:e,className:a,style:Object(o.a)(Object(o.a)({},r),g)},v)}))}));Zt.displayName="MobilePopupInner";var Jt=Zt,Qt=["visible","mobile"],te=s.forwardRef((function(t,e){var i=t.visible,n=t.mobile,l=Object(a.a)(t,Qt),c=Object(s.useState)(i),u=Object(r.a)(c,2),h=u[0],d=u[1],f=Object(s.useState)(!1),p=Object(r.a)(f,2),m=p[0],g=p[1],v=Object(o.a)(Object(o.a)({},l),{},{visible:h});Object(s.useEffect)((function(){d(i),i&&n&&g(function(){if("undefined"==typeof navigator||"undefined"==typeof window)return!1;var t=navigator.userAgent||navigator.vendor||window.opera;return!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(null==t?void 0:t.substr(0,4)))}())}),[i,n]);var y=m?s.createElement(Jt,Object(S.a)({},v,{mobile:n,ref:e})):s.createElement($t,Object(S.a)({},v,{ref:e}));return s.createElement("div",null,s.createElement(zt,v),y)}));te.displayName="Popup";var ee=te,ie=s.createContext(null);function ne(){}function re(){return""}function ae(t){return t?t.ownerDocument:window.document}var oe=["onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur","onContextMenu"];var se,le,ce=(se=ht.a,(le=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(t){var n,r;return Object(C.a)(this,i),(n=e.call(this,t)).popupRef=s.createRef(),n.triggerRef=s.createRef(),n.attachId=void 0,n.clickOutsideHandler=void 0,n.touchOutsideHandler=void 0,n.contextMenuOutsideHandler1=void 0,n.contextMenuOutsideHandler2=void 0,n.mouseDownTimeout=void 0,n.focusTime=void 0,n.preClickTime=void 0,n.preTouchTime=void 0,n.delayTimer=void 0,n.hasPopupMouseDown=void 0,n.onMouseEnter=function(t){var e=n.props.mouseEnterDelay;n.fireEvents("onMouseEnter",t),n.delaySetPopupVisible(!0,e,e?null:t)},n.onMouseMove=function(t){n.fireEvents("onMouseMove",t),n.setPoint(t)},n.onMouseLeave=function(t){n.fireEvents("onMouseLeave",t),n.delaySetPopupVisible(!1,n.props.mouseLeaveDelay)},n.onPopupMouseEnter=function(){n.clearDelayTimer()},n.onPopupMouseLeave=function(t){var e;t.relatedTarget&&!t.relatedTarget.setTimeout&&Object(st.a)(null===(e=n.popupRef.current)||void 0===e?void 0:e.getElement(),t.relatedTarget)||n.delaySetPopupVisible(!1,n.props.mouseLeaveDelay)},n.onFocus=function(t){n.fireEvents("onFocus",t),n.clearDelayTimer(),n.isFocusToShow()&&(n.focusTime=Date.now(),n.delaySetPopupVisible(!0,n.props.focusDelay))},n.onMouseDown=function(t){n.fireEvents("onMouseDown",t),n.preClickTime=Date.now()},n.onTouchStart=function(t){n.fireEvents("onTouchStart",t),n.preTouchTime=Date.now()},n.onBlur=function(t){n.fireEvents("onBlur",t),n.clearDelayTimer(),n.isBlurToHide()&&n.delaySetPopupVisible(!1,n.props.blurDelay)},n.onContextMenu=function(t){t.preventDefault(),n.fireEvents("onContextMenu",t),n.setPopupVisible(!0,t)},n.onContextMenuClose=function(){n.isContextMenuToShow()&&n.close()},n.onClick=function(t){if(n.fireEvents("onClick",t),n.focusTime){var e;if(n.preClickTime&&n.preTouchTime?e=Math.min(n.preClickTime,n.preTouchTime):n.preClickTime?e=n.preClickTime:n.preTouchTime&&(e=n.preTouchTime),Math.abs(e-n.focusTime)<20)return;n.focusTime=0}n.preClickTime=0,n.preTouchTime=0,n.isClickToShow()&&(n.isClickToHide()||n.isBlurToHide())&&t&&t.preventDefault&&t.preventDefault();var i=!n.state.popupVisible;(n.isClickToHide()&&!i||i&&n.isClickToShow())&&n.setPopupVisible(!n.state.popupVisible,t)},n.onPopupMouseDown=function(){var t;n.hasPopupMouseDown=!0,clearTimeout(n.mouseDownTimeout),n.mouseDownTimeout=window.setTimeout((function(){n.hasPopupMouseDown=!1}),0),n.context&&(t=n.context).onPopupMouseDown.apply(t,arguments)},n.onDocumentClick=function(t){if(!n.props.mask||n.props.maskClosable){var e=t.target,i=n.getRootDomNode(),r=n.getPopupDomNode();Object(st.a)(i,e)&&!n.isContextMenuOnly()||Object(st.a)(r,e)||n.hasPopupMouseDown||n.close()}},n.getRootDomNode=function(){var t=n.props.getTriggerDOMNode;if(t)return t(n.triggerRef.current);try{var e=Object(lt.a)(n.triggerRef.current);if(e)return e}catch(t){}return at.a.findDOMNode(Object(E.a)(n))},n.getPopupClassNameFromAlign=function(t){var e=[],i=n.props,r=i.popupPlacement,a=i.builtinPlacements,o=i.prefixCls,s=i.alignPoint,l=i.getPopupClassNameFromAlign;return r&&a&&e.push(function(t,e,i,n){for(var r=i.points,a=Object.keys(t),o=0;o<a.length;o+=1){var s=a[o];if(dt(t[s].points,r,n))return"".concat(e,"-placement-").concat(s)}return""}(a,o,t,s)),l&&e.push(l(t)),e.join(" ")},n.getComponent=function(){var t=n.props,e=t.prefixCls,i=t.destroyPopupOnHide,r=t.popupClassName,a=t.onPopupAlign,o=t.popupMotion,l=t.popupAnimation,c=t.popupTransitionName,u=t.popupStyle,h=t.mask,d=t.maskAnimation,f=t.maskTransitionName,p=t.maskMotion,m=t.zIndex,g=t.popup,v=t.stretch,y=t.alignPoint,b=t.mobile,x=t.forceRender,C=n.state,k=C.popupVisible,E=C.point,w=n.getPopupAlign(),T={};return n.isMouseEnterToShow()&&(T.onMouseEnter=n.onPopupMouseEnter),n.isMouseLeaveToHide()&&(T.onMouseLeave=n.onPopupMouseLeave),T.onMouseDown=n.onPopupMouseDown,T.onTouchStart=n.onPopupMouseDown,s.createElement(ee,Object(S.a)({prefixCls:e,destroyPopupOnHide:i,visible:k,point:y&&E,className:r,align:w,onAlign:a,animation:l,getClassNameFromAlign:n.getPopupClassNameFromAlign},T,{stretch:v,getRootDomNode:n.getRootDomNode,style:u,mask:h,zIndex:m,transitionName:c,maskAnimation:d,maskTransitionName:f,maskMotion:p,ref:n.popupRef,motion:o,mobile:b,forceRender:x}),"function"==typeof g?g():g)},n.attachParent=function(t){ot.a.cancel(n.attachId);var e,i=n.props,r=i.getPopupContainer,a=i.getDocument,o=n.getRootDomNode();r?(o||0===r.length)&&(e=r(o)):e=a(n.getRootDomNode()).body,e?e.appendChild(t):n.attachId=Object(ot.a)((function(){n.attachParent(t)}))},n.getContainer=function(){var t=(0,n.props.getDocument)(n.getRootDomNode()).createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",n.attachParent(t),t},n.setPoint=function(t){n.props.alignPoint&&t&&n.setState({point:{pageX:t.pageX,pageY:t.pageY}})},n.handlePortalUpdate=function(){n.state.prevPopupVisible!==n.state.popupVisible&&n.props.afterPopupVisibleChange(n.state.popupVisible)},n.triggerContextValue={onPopupMouseDown:n.onPopupMouseDown},r="popupVisible"in t?!!t.popupVisible:!!t.defaultPopupVisible,n.state={prevPopupVisible:r,popupVisible:r},oe.forEach((function(t){n["fire".concat(t)]=function(e){n.fireEvents(t,e)}})),n}return Object(k.a)(i,[{key:"componentDidMount",value:function(){this.componentDidUpdate()}},{key:"componentDidUpdate",value:function(){var t,e=this.props;if(this.state.popupVisible)return this.clickOutsideHandler||!this.isClickToHide()&&!this.isContextMenuToShow()||(t=e.getDocument(this.getRootDomNode()),this.clickOutsideHandler=Object(ut.a)(t,"mousedown",this.onDocumentClick)),this.touchOutsideHandler||(t=t||e.getDocument(this.getRootDomNode()),this.touchOutsideHandler=Object(ut.a)(t,"touchstart",this.onDocumentClick)),!this.contextMenuOutsideHandler1&&this.isContextMenuToShow()&&(t=t||e.getDocument(this.getRootDomNode()),this.contextMenuOutsideHandler1=Object(ut.a)(t,"scroll",this.onContextMenuClose)),void(!this.contextMenuOutsideHandler2&&this.isContextMenuToShow()&&(this.contextMenuOutsideHandler2=Object(ut.a)(window,"blur",this.onContextMenuClose)));this.clearOutsideHandler()}},{key:"componentWillUnmount",value:function(){this.clearDelayTimer(),this.clearOutsideHandler(),clearTimeout(this.mouseDownTimeout),ot.a.cancel(this.attachId)}},{key:"getPopupDomNode",value:function(){var t;return(null===(t=this.popupRef.current)||void 0===t?void 0:t.getElement())||null}},{key:"getPopupAlign",value:function(){var t=this.props,e=t.popupPlacement,i=t.popupAlign,n=t.builtinPlacements;return e&&n?function(t,e,i){var n=t[e]||{};return Object(o.a)(Object(o.a)({},n),i)}(n,e,i):i}},{key:"setPopupVisible",value:function(t,e){var i=this.props.alignPoint,n=this.state.popupVisible;this.clearDelayTimer(),n!==t&&("popupVisible"in this.props||this.setState({popupVisible:t,prevPopupVisible:n}),this.props.onPopupVisibleChange(t)),i&&e&&t&&this.setPoint(e)}},{key:"delaySetPopupVisible",value:function(t,e,i){var n=this,r=1e3*e;if(this.clearDelayTimer(),r){var a=i?{pageX:i.pageX,pageY:i.pageY}:null;this.delayTimer=window.setTimeout((function(){n.setPopupVisible(t,a),n.clearDelayTimer()}),r)}else this.setPopupVisible(t,i)}},{key:"clearDelayTimer",value:function(){this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=null)}},{key:"clearOutsideHandler",value:function(){this.clickOutsideHandler&&(this.clickOutsideHandler.remove(),this.clickOutsideHandler=null),this.contextMenuOutsideHandler1&&(this.contextMenuOutsideHandler1.remove(),this.contextMenuOutsideHandler1=null),this.contextMenuOutsideHandler2&&(this.contextMenuOutsideHandler2.remove(),this.contextMenuOutsideHandler2=null),this.touchOutsideHandler&&(this.touchOutsideHandler.remove(),this.touchOutsideHandler=null)}},{key:"createTwoChains",value:function(t){var e=this.props.children.props,i=this.props;return e[t]&&i[t]?this["fire".concat(t)]:e[t]||i[t]}},{key:"isClickToShow",value:function(){var t=this.props,e=t.action,i=t.showAction;return-1!==e.indexOf("click")||-1!==i.indexOf("click")}},{key:"isContextMenuOnly",value:function(){var t=this.props.action;return"contextMenu"===t||1===t.length&&"contextMenu"===t[0]}},{key:"isContextMenuToShow",value:function(){var t=this.props,e=t.action,i=t.showAction;return-1!==e.indexOf("contextMenu")||-1!==i.indexOf("contextMenu")}},{key:"isClickToHide",value:function(){var t=this.props,e=t.action,i=t.hideAction;return-1!==e.indexOf("click")||-1!==i.indexOf("click")}},{key:"isMouseEnterToShow",value:function(){var t=this.props,e=t.action,i=t.showAction;return-1!==e.indexOf("hover")||-1!==i.indexOf("mouseEnter")}},{key:"isMouseLeaveToHide",value:function(){var t=this.props,e=t.action,i=t.hideAction;return-1!==e.indexOf("hover")||-1!==i.indexOf("mouseLeave")}},{key:"isFocusToShow",value:function(){var t=this.props,e=t.action,i=t.showAction;return-1!==e.indexOf("focus")||-1!==i.indexOf("focus")}},{key:"isBlurToHide",value:function(){var t=this.props,e=t.action,i=t.hideAction;return-1!==e.indexOf("focus")||-1!==i.indexOf("blur")}},{key:"forcePopupAlign",value:function(){var t;this.state.popupVisible&&(null===(t=this.popupRef.current)||void 0===t||t.forceAlign())}},{key:"fireEvents",value:function(t,e){var i=this.props.children.props[t];i&&i(e);var n=this.props[t];n&&n(e)}},{key:"close",value:function(){this.setPopupVisible(!1)}},{key:"render",value:function(){var t=this.state.popupVisible,e=this.props,i=e.children,n=e.forceRender,r=e.alignPoint,a=e.className,l=e.autoDestroy,u=s.Children.only(i),h={key:"trigger"};this.isContextMenuToShow()?h.onContextMenu=this.onContextMenu:h.onContextMenu=this.createTwoChains("onContextMenu"),this.isClickToHide()||this.isClickToShow()?(h.onClick=this.onClick,h.onMouseDown=this.onMouseDown,h.onTouchStart=this.onTouchStart):(h.onClick=this.createTwoChains("onClick"),h.onMouseDown=this.createTwoChains("onMouseDown"),h.onTouchStart=this.createTwoChains("onTouchStart")),this.isMouseEnterToShow()?(h.onMouseEnter=this.onMouseEnter,r&&(h.onMouseMove=this.onMouseMove)):h.onMouseEnter=this.createTwoChains("onMouseEnter"),this.isMouseLeaveToHide()?h.onMouseLeave=this.onMouseLeave:h.onMouseLeave=this.createTwoChains("onMouseLeave"),this.isFocusToShow()||this.isBlurToHide()?(h.onFocus=this.onFocus,h.onBlur=this.onBlur):(h.onFocus=this.createTwoChains("onFocus"),h.onBlur=this.createTwoChains("onBlur"));var d=c()(u&&u.props&&u.props.className,a);d&&(h.className=d);var f=Object(o.a)({},h);Object(ct.c)(u)&&(f.ref=Object(ct.a)(this.triggerRef,u.ref));var p,m=s.cloneElement(u,f);return(t||this.popupRef.current||n)&&(p=s.createElement(se,{key:"portal",getContainer:this.getContainer,didUpdate:this.handlePortalUpdate},this.getComponent())),!t&&l&&(p=null),s.createElement(ie.Provider,{value:this.triggerContextValue},m,p)}}],[{key:"getDerivedStateFromProps",value:function(t,e){var i=t.popupVisible,n={};return void 0!==i&&e.popupVisible!==i&&(n.popupVisible=i,n.prevPopupVisible=e.popupVisible),n}}]),i}(s.Component)).contextType=ie,le.defaultProps={prefixCls:"rc-trigger-popup",getPopupClassNameFromAlign:re,getDocument:ae,onPopupVisibleChange:ne,afterPopupVisibleChange:ne,onPopupAlign:ne,popupClassName:"",mouseEnterDelay:0,mouseLeaveDelay:.1,focusDelay:0,blurDelay:.15,popupStyle:{},destroyPopupOnHide:!1,popupAlign:{},defaultPopupVisible:!1,mask:!1,maskClosable:!0,action:[],showAction:[],hideAction:[],autoDestroy:!1},le),ue={adjustX:1,adjustY:1},he={topLeft:{points:["bl","tl"],overflow:ue,offset:[0,-7]},bottomLeft:{points:["tl","bl"],overflow:ue,offset:[0,7]},leftTop:{points:["tr","tl"],overflow:ue,offset:[-4,0]},rightTop:{points:["tl","tr"],overflow:ue,offset:[4,0]}},de={topLeft:{points:["bl","tl"],overflow:ue,offset:[0,-7]},bottomLeft:{points:["tl","bl"],overflow:ue,offset:[0,7]},rightTop:{points:["tr","tl"],overflow:ue,offset:[-4,0]},leftTop:{points:["tl","tr"],overflow:ue,offset:[4,0]}},fe=0,pe={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"},me=function(t,e,i){var r=J(e),a=t.getState();t.setState({defaultActiveFirst:Object(o.a)(Object(o.a)({},a.defaultActiveFirst),{},Object(n.a)({},r,i))})},ge=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(t){var n;Object(C.a)(this,i),(n=e.call(this,t)).onDestroy=function(t){n.props.onDestroy(t)},n.onKeyDown=function(t){var e=t.keyCode,i=n.menuInstance,r=n.props.store,a=n.getVisible();if(e===v.a.ENTER)return n.onTitleClick(t),me(r,n.props.eventKey,!0),!0;if(e===v.a.RIGHT)return a?i.onKeyDown(t):(n.triggerOpenChange(!0),me(r,n.props.eventKey,!0)),!0;if(e===v.a.LEFT){var o;if(!a)return;return(o=i.onKeyDown(t))||(n.triggerOpenChange(!1),o=!0),o}return!a||e!==v.a.UP&&e!==v.a.DOWN?void 0:i.onKeyDown(t)},n.onOpenChange=function(t){n.props.onOpenChange(t)},n.onPopupVisibleChange=function(t){n.triggerOpenChange(t,t?"mouseenter":"mouseleave")},n.onMouseEnter=function(t){var e=n.props,i=e.eventKey,r=e.onMouseEnter,a=e.store;me(a,n.props.eventKey,!1),r({key:i,domEvent:t})},n.onMouseLeave=function(t){var e=n.props,i=e.parentMenu,r=e.eventKey,a=e.onMouseLeave;i.subMenuInstance=Object(E.a)(n),a({key:r,domEvent:t})},n.onTitleMouseEnter=function(t){var e=n.props,i=e.eventKey,r=e.onItemHover,a=e.onTitleMouseEnter;r({key:i,hover:!0}),a({key:i,domEvent:t})},n.onTitleMouseLeave=function(t){var e=n.props,i=e.parentMenu,r=e.eventKey,a=e.onItemHover,o=e.onTitleMouseLeave;i.subMenuInstance=Object(E.a)(n),a({key:r,hover:!1}),o({key:r,domEvent:t})},n.onTitleClick=function(t){var e=Object(E.a)(n).props;e.onTitleClick({key:e.eventKey,domEvent:t}),"hover"!==e.triggerSubMenuAction&&(n.triggerOpenChange(!n.getVisible(),"click"),me(e.store,n.props.eventKey,!1))},n.onSubMenuClick=function(t){"function"==typeof n.props.onClick&&n.props.onClick(n.addKeyPath(t))},n.onSelect=function(t){n.props.onSelect(t)},n.onDeselect=function(t){n.props.onDeselect(t)},n.getPrefixCls=function(){return"".concat(n.props.rootPrefixCls,"-submenu")},n.getActiveClassName=function(){return"".concat(n.getPrefixCls(),"-active")},n.getDisabledClassName=function(){return"".concat(n.getPrefixCls(),"-disabled")},n.getSelectedClassName=function(){return"".concat(n.getPrefixCls(),"-selected")},n.getOpenClassName=function(){return"".concat(n.props.rootPrefixCls,"-submenu-open")},n.getVisible=function(){return n.state.isOpen},n.getMode=function(){return n.state.mode},n.saveMenuInstance=function(t){n.menuInstance=t},n.addKeyPath=function(t){return Object(o.a)(Object(o.a)({},t),{},{keyPath:(t.keyPath||[]).concat(n.props.eventKey)})},n.triggerOpenChange=function(t,e){var i=n.props.eventKey,r=function(){n.onOpenChange({key:i,item:Object(E.a)(n),trigger:e,open:t})};"mouseenter"===e?n.mouseenterTimeout=setTimeout((function(){r()}),0):r()},n.isChildrenSelected=function(){var t={find:!1};return function t(e,i,n){e&&!n.find&&s.Children.forEach(e,(function(e){if(e){var r=e.type;if(!r||!(r.isSubMenu||r.isMenuItem||r.isMenuItemGroup))return;-1!==i.indexOf(e.key)?n.find=!0:e.props.children&&t(e.props.children,i,n)}}))}(n.props.children,n.props.selectedKeys,t),t.find},n.isInlineMode=function(){return"inline"===n.getMode()},n.adjustWidth=function(){if(n.subMenuTitle&&n.menuInstance){var t=rt.findDOMNode(n.menuInstance);t.offsetWidth>=n.subMenuTitle.offsetWidth||(t.style.minWidth="".concat(n.subMenuTitle.offsetWidth,"px"))}},n.saveSubMenuTitle=function(t){n.subMenuTitle=t},n.getBaseProps=function(){var t=Object(E.a)(n).props,e=n.getMode();return{mode:"horizontal"===e?"vertical":e,visible:n.getVisible(),level:t.level+1,inlineIndent:t.inlineIndent,focusable:!1,onClick:n.onSubMenuClick,onSelect:n.onSelect,onDeselect:n.onDeselect,onDestroy:n.onDestroy,selectedKeys:t.selectedKeys,eventKey:"".concat(t.eventKey,"-menu-"),openKeys:t.openKeys,motion:t.motion,onOpenChange:n.onOpenChange,subMenuOpenDelay:t.subMenuOpenDelay,parentMenu:Object(E.a)(n),subMenuCloseDelay:t.subMenuCloseDelay,forceSubMenuRender:t.forceSubMenuRender,triggerSubMenuAction:t.triggerSubMenuAction,builtinPlacements:t.builtinPlacements,defaultActiveFirst:t.store.getState().defaultActiveFirst[J(t.eventKey)],multiple:t.multiple,prefixCls:t.rootPrefixCls,id:n.internalMenuId,manualRef:n.saveMenuInstance,itemIcon:t.itemIcon,expandIcon:t.expandIcon,direction:t.direction}},n.getMotion=function(t,e){var i=Object(E.a)(n).haveRendered,r=n.props,a=r.motion,s=r.rootPrefixCls;return Object(o.a)(Object(o.a)({},a),{},{leavedClassName:"".concat(s,"-hidden"),removeOnLeave:!1,motionAppear:i||!e||"inline"!==t})};var r=t.store,a=t.eventKey,l=r.getState().defaultActiveFirst;n.isRootMenu=!1;var c=!1;return l&&(c=l[a]),me(r,a,c),n.state={mode:t.mode,isOpen:t.isOpen},n}return Object(k.a)(i,[{key:"componentDidMount",value:function(){this.componentDidUpdate()}},{key:"componentDidUpdate",value:function(){var t=this,e=this.props,i=e.mode,n=e.parentMenu,r=e.manualRef,a=e.isOpen,o=function(){t.setState({mode:i,isOpen:a})},s=a!==this.state.isOpen,l=i!==this.state.mode;(l||s)&&(ot.a.cancel(this.updateStateRaf),l?this.updateStateRaf=Object(ot.a)(o):o()),r&&r(this),"horizontal"===i&&(null==n?void 0:n.isRootMenu)&&a&&(this.minWidthTimeout=setTimeout((function(){return t.adjustWidth()}),0))}},{key:"componentWillUnmount",value:function(){var t=this.props,e=t.onDestroy,i=t.eventKey;e&&e(i),this.minWidthTimeout&&clearTimeout(this.minWidthTimeout),this.mouseenterTimeout&&clearTimeout(this.mouseenterTimeout),ot.a.cancel(this.updateStateRaf)}},{key:"renderPopupMenu",value:function(t,e){var i=this.getBaseProps();return s.createElement(Te,Object(S.a)({},i,{id:this.internalMenuId,className:t,style:e}),this.props.children)}},{key:"renderChildren",value:function(){var t=this,e=this.getBaseProps(),i=e.mode,r=e.visible,a=e.forceSubMenuRender,o=e.direction,l=this.getMotion(i,r);if(this.haveRendered=!0,this.haveOpened=this.haveOpened||r||a,!this.haveOpened)return s.createElement("div",null);var u=c()("".concat(e.prefixCls,"-sub"),Object(n.a)({},"".concat(e.prefixCls,"-rtl"),"rtl"===o));return this.isInlineMode()?s.createElement(Ht,Object(S.a)({visible:e.visible,forceRender:a},l),(function(e){var i=e.className,n=e.style,r=c()(u,i);return t.renderPopupMenu(r,n)})):this.renderPopupMenu(u)}},{key:"render",value:function(){var t,e,i,r=Object(o.a)({},this.props),a=this.getVisible(),l=this.getPrefixCls(),u=this.isInlineMode(),h=this.getMode(),d=c()(l,"".concat(l,"-").concat(h),(t={},Object(n.a)(t,r.className,!!r.className),Object(n.a)(t,this.getOpenClassName(),a),Object(n.a)(t,this.getActiveClassName(),r.active||a&&!u),Object(n.a)(t,this.getDisabledClassName(),r.disabled),Object(n.a)(t,this.getSelectedClassName(),this.isChildrenSelected()),t));this.internalMenuId||(r.eventKey?this.internalMenuId="".concat(r.eventKey,"$Menu"):(fe+=1,this.internalMenuId="$__$".concat(fe,"$Menu")));var f={},p={},m={};r.disabled||(f={onMouseLeave:this.onMouseLeave,onMouseEnter:this.onMouseEnter},p={onClick:this.onTitleClick},m={onMouseEnter:this.onTitleMouseEnter,onMouseLeave:this.onTitleMouseLeave});var g={},v="rtl"===r.direction;u&&(v?g.paddingRight=r.inlineIndent*r.level:g.paddingLeft=r.inlineIndent*r.level);var y={};this.getVisible()&&(y={"aria-owns":this.internalMenuId});var b=null;"horizontal"!==h&&(b=this.props.expandIcon,"function"==typeof this.props.expandIcon&&(b=s.createElement(this.props.expandIcon,Object(o.a)({},this.props))));var x=s.createElement("div",Object(S.a)({ref:this.saveSubMenuTitle,style:g,className:"".concat(l,"-title"),role:"button"},m,p,{"aria-expanded":a},y,{"aria-haspopup":"true",title:"string"==typeof r.title?r.title:void 0}),r.title,b||s.createElement("i",{className:"".concat(l,"-arrow")})),C=this.renderChildren(),k=(null===(e=r.parentMenu)||void 0===e?void 0:e.isRootMenu)?r.parentMenu.props.getPopupContainer:function(t){return t.parentNode},E=pe[h],w=r.popupOffset?{offset:r.popupOffset}:{},T=c()((i={},Object(n.a)(i,r.popupClassName,r.popupClassName&&!u),Object(n.a)(i,"".concat(l,"-rtl"),v),i)),O=r.disabled,L=r.triggerSubMenuAction,A=r.subMenuOpenDelay,D=r.forceSubMenuRender,_=r.subMenuCloseDelay,R=r.builtinPlacements;tt.forEach((function(t){return delete r[t]})),delete r.onClick;var I=v?Object(o.a)(Object(o.a)({},de),R):Object(o.a)(Object(o.a)({},he),R);delete r.direction;var M=this.getBaseProps(),N=u?null:this.getMotion(M.mode,M.visible);return s.createElement("li",Object(S.a)({},r,f,{className:d,role:"menuitem"}),s.createElement(ce,{prefixCls:l,popupClassName:c()("".concat(l,"-popup"),T),getPopupContainer:k,builtinPlacements:I,popupPlacement:E,popupVisible:!u&&a,popupAlign:w,popup:u?null:C,action:O||u?[]:[L],mouseEnterDelay:A,mouseLeaveDelay:_,onPopupVisibleChange:this.onPopupVisibleChange,forceRender:D,popupMotion:N},x),u?C:null)}}]),i}(s.Component);ge.defaultProps={onMouseEnter:$,onMouseLeave:$,onTitleMouseEnter:$,onTitleMouseLeave:$,onTitleClick:$,manualRef:$,mode:"vertical",title:""};var ve=Object(O.b)((function(t,e){var i=t.openKeys,n=t.activeKey,r=t.selectedKeys,a=e.eventKey,o=e.subMenuKey;return{isOpen:i.indexOf(a)>-1,active:n[o]===a,selectedKeys:r}}))(ge);ve.isSubMenu=!0;var ye=ve,be=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(){var t;return Object(C.a)(this,i),(t=e.apply(this,arguments)).resizeObserver=null,t.mutationObserver=null,t.originalTotalWidth=0,t.overflowedItems=[],t.menuItemSizes=[],t.cancelFrameId=null,t.state={lastVisibleIndex:void 0},t.childRef=s.createRef(),t.getMenuItemNodes=function(){var e=t.props.prefixCls,i=t.childRef.current;return i?[].slice.call(i.children).filter((function(t){return t.className.split(" ").indexOf("".concat(e,"-overflowed-submenu"))<0})):[]},t.getOverflowedSubMenuItem=function(e,i,n){var r=t.props,l=r.overflowedIndicator,c=r.level,u=r.mode,h=r.prefixCls,d=r.theme;if(1!==c||"horizontal"!==u)return null;var f=t.props.children[0].props,p=(f.children,f.title,f.style),m=Object(a.a)(f,["children","title","style"]),g=Object(o.a)({},p),v="".concat(e,"-overflowed-indicator"),y="".concat(e,"-overflowed-indicator");0===i.length&&!0!==n?g=Object(o.a)(Object(o.a)({},g),{},{display:"none"}):n&&(g=Object(o.a)(Object(o.a)({},g),{},{visibility:"hidden",position:"absolute"}),v="".concat(v,"-placeholder"),y="".concat(y,"-placeholder"));var b=d?"".concat(h,"-").concat(d):"",x={};return tt.forEach((function(t){void 0!==m[t]&&(x[t]=m[t])})),s.createElement(ye,Object(S.a)({title:l,className:"".concat(h,"-overflowed-submenu"),popupClassName:b},x,{key:v,eventKey:y,disabled:!1,style:g}),i)},t.setChildrenWidthAndResize=function(){if("horizontal"===t.props.mode){var e=t.childRef.current;if(e){var i=e.children;if(i&&0!==i.length){var n=e.children[i.length-1];it(n,"display","inline-block");var r=t.getMenuItemNodes(),a=r.filter((function(t){return t.className.split(" ").indexOf("menuitem-overflowed")>=0}));a.forEach((function(t){it(t,"display","inline-block")})),t.menuItemSizes=r.map((function(t){return et(t,!0)})),a.forEach((function(t){it(t,"display","none")})),t.overflowedIndicatorWidth=et(e.children[e.children.length-1],!0),t.originalTotalWidth=t.menuItemSizes.reduce((function(t,e){return t+e}),0),t.handleResize(),it(n,"display","none")}}}},t.handleResize=function(){if("horizontal"===t.props.mode){var e=t.childRef.current;if(e){var i=et(e);t.overflowedItems=[];var n,r=0;t.originalTotalWidth>i+.5&&(n=-1,t.menuItemSizes.forEach((function(e){(r+=e)+t.overflowedIndicatorWidth<=i&&(n+=1)}))),t.setState({lastVisibleIndex:n})}}},t}return Object(k.a)(i,[{key:"componentDidMount",value:function(){var t=this;if(this.setChildrenWidthAndResize(),1===this.props.level&&"horizontal"===this.props.mode){var e=this.childRef.current;if(!e)return;this.resizeObserver=new nt.default((function(e){e.forEach((function(){var e=t.cancelFrameId;cancelAnimationFrame(e),t.cancelFrameId=requestAnimationFrame(t.setChildrenWidthAndResize)}))})),[].slice.call(e.children).concat(e).forEach((function(e){t.resizeObserver.observe(e)})),"undefined"!=typeof MutationObserver&&(this.mutationObserver=new MutationObserver((function(){t.resizeObserver.disconnect(),[].slice.call(e.children).concat(e).forEach((function(e){t.resizeObserver.observe(e)})),t.setChildrenWidthAndResize()})),this.mutationObserver.observe(e,{attributes:!1,childList:!0,subTree:!1}))}}},{key:"componentWillUnmount",value:function(){this.resizeObserver&&this.resizeObserver.disconnect(),this.mutationObserver&&this.mutationObserver.disconnect(),cancelAnimationFrame(this.cancelFrameId)}},{key:"renderChildren",value:function(t){var e=this,i=this.state.lastVisibleIndex;return(t||[]).reduce((function(n,r,a){var o=r;if("horizontal"===e.props.mode){var l=e.getOverflowedSubMenuItem(r.props.eventKey,[]);void 0!==i&&-1!==e.props.className.indexOf("".concat(e.props.prefixCls,"-root"))&&(a>i&&(o=s.cloneElement(r,{style:{display:"none"},eventKey:"".concat(r.props.eventKey,"-hidden"),className:"".concat("menuitem-overflowed")})),a===i+1&&(e.overflowedItems=t.slice(i+1).map((function(t){return s.cloneElement(t,{key:t.props.eventKey,mode:"vertical-left"})})),l=e.getOverflowedSubMenuItem(r.props.eventKey,e.overflowedItems)));var c=[].concat(Object(d.a)(n),[l,o]);return a===t.length-1&&c.push(e.getOverflowedSubMenuItem(r.props.eventKey,[],!0)),c}return[].concat(Object(d.a)(n),[o])}),[])}},{key:"render",value:function(){var t=this.props,e=(t.visible,t.prefixCls,t.overflowedIndicator,t.mode,t.level,t.tag),i=t.children,n=(t.theme,Object(a.a)(t,["visible","prefixCls","overflowedIndicator","mode","level","tag","children","theme"])),r=e;return s.createElement(r,Object(S.a)({ref:this.childRef},n),this.renderChildren(i))}}]),i}(s.Component);be.defaultProps={tag:"div",className:""};var xe=be;function Se(t,e,i){var r=t.getState();t.setState({activeKey:Object(o.a)(Object(o.a)({},r.activeKey),{},Object(n.a)({},e,i))})}function Ce(t){return t.eventKey||"0-menu-"}function ke(t,e){var i,n=e,r=t.children,a=t.eventKey;if(n&&(Q(r,(function(t,e){t&&t.props&&!t.props.disabled&&n===Z(t,a,e)&&(i=!0)})),i))return n;return n=null,t.defaultActiveFirst?(Q(r,(function(t,e){n||!t||t.props.disabled||(n=Z(t,a,e))})),n):n}function Ee(t){if(t){var e=this.instanceArray.indexOf(t);-1!==e?this.instanceArray[e]=t:this.instanceArray.push(t)}}var we=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(t){var r;return Object(C.a)(this,i),(r=e.call(this,t)).onKeyDown=function(t,e){var i,n=t.keyCode;if(r.getFlatInstanceArray().forEach((function(e){e&&e.props.active&&e.onKeyDown&&(i=e.onKeyDown(t))})),i)return 1;var a=null;return n!==v.a.UP&&n!==v.a.DOWN||(a=r.step(n===v.a.UP?-1:1)),a?(t.preventDefault(),Se(r.props.store,Ce(r.props),a.props.eventKey),"function"==typeof e&&e(a),1):void 0},r.onItemHover=function(t){var e=t.key,i=t.hover;Se(r.props.store,Ce(r.props),i?e:null)},r.onDeselect=function(t){r.props.onDeselect(t)},r.onSelect=function(t){r.props.onSelect(t)},r.onClick=function(t){r.props.onClick(t)},r.onOpenChange=function(t){r.props.onOpenChange(t)},r.onDestroy=function(t){r.props.onDestroy(t)},r.getFlatInstanceArray=function(){return r.instanceArray},r.step=function(t){var e=r.getFlatInstanceArray(),i=r.props.store.getState().activeKey[Ce(r.props)],n=e.length;if(!n)return null;t<0&&(e=e.concat().reverse());var a=-1;if(e.every((function(t,e){return!t||t.props.eventKey!==i||(a=e,!1)})),r.props.defaultActiveFirst||-1===a||(o=e.slice(a,n-1)).length&&!o.every((function(t){return!!t.props.disabled}))){var o,s=(a+1)%n,l=s;do{var c=e[l];if(c&&!c.props.disabled)return c;l=(l+1)%n}while(l!==s);return null}},r.renderCommonMenuItem=function(t,e,i){var n=r.props.store.getState(),a=Object(E.a)(r).props,l=Z(t,a.eventKey,e),c=t.props;if(!c||"string"==typeof t.type)return t;var u=l===n.activeKey,h=Object(o.a)(Object(o.a)({mode:c.mode||a.mode,level:a.level,inlineIndent:a.inlineIndent,renderMenuItem:r.renderMenuItem,rootPrefixCls:a.prefixCls,index:e,parentMenu:a.parentMenu,manualRef:c.disabled?void 0:Object(A.a)(t.ref,Ee.bind(Object(E.a)(r))),eventKey:l,active:!c.disabled&&u,multiple:a.multiple,onClick:function(t){(c.onClick||$)(t),r.onClick(t)},onItemHover:r.onItemHover,motion:a.motion,subMenuOpenDelay:a.subMenuOpenDelay,subMenuCloseDelay:a.subMenuCloseDelay,forceSubMenuRender:a.forceSubMenuRender,onOpenChange:r.onOpenChange,onDeselect:r.onDeselect,onSelect:r.onSelect,builtinPlacements:a.builtinPlacements,itemIcon:c.itemIcon||r.props.itemIcon,expandIcon:c.expandIcon||r.props.expandIcon},i),{},{direction:a.direction});return("inline"===a.mode||X.any)&&(h.triggerSubMenuAction="click"),s.cloneElement(t,Object(o.a)(Object(o.a)({},h),{},{key:l||e}))},r.renderMenuItem=function(t,e,i){if(!t)return null;var n=r.props.store.getState(),a={openKeys:n.openKeys,selectedKeys:n.selectedKeys,triggerSubMenuAction:r.props.triggerSubMenuAction,subMenuKey:i};return r.renderCommonMenuItem(t,e,a)},t.store.setState({activeKey:Object(o.a)(Object(o.a)({},t.store.getState().activeKey),{},Object(n.a)({},t.eventKey,ke(t,t.activeKey)))}),r.instanceArray=[],r}return Object(k.a)(i,[{key:"componentDidMount",value:function(){this.props.manualRef&&this.props.manualRef(this)}},{key:"shouldComponentUpdate",value:function(t){return this.props.visible||t.visible||this.props.className!==t.className||!_()(this.props.style,t.style)}},{key:"componentDidUpdate",value:function(t){var e=this.props,i="activeKey"in e?e.activeKey:e.store.getState().activeKey[Ce(e)],n=ke(e,i);if(n!==i)Se(e.store,Ce(e),n);else if("activeKey"in t){n!==ke(t,t.activeKey)&&Se(e.store,Ce(e),n)}}},{key:"render",value:function(){var t=this,e=Object(S.a)({},this.props);this.instanceArray=[];var i={className:c()(e.prefixCls,e.className,"".concat(e.prefixCls,"-").concat(e.mode)),role:e.role||"menu"};e.id&&(i.id=e.id),e.focusable&&(i.tabIndex=0,i.onKeyDown=this.onKeyDown);var n=e.prefixCls,r=e.eventKey,a=e.visible,o=e.level,l=e.mode,h=e.overflowedIndicator,d=e.theme;return tt.forEach((function(t){return delete e[t]})),delete e.onClick,s.createElement(xe,Object(S.a)({},e,{prefixCls:n,mode:l,tag:"ul",level:o,theme:d,visible:a,overflowedIndicator:h},i),Object(u.a)(e.children).map((function(e,i){return t.renderMenuItem(e,i,r||"0-menu-")})))}}]),i}(s.Component);we.defaultProps={prefixCls:"rc-menu",className:"",mode:"vertical",level:1,inlineIndent:24,visible:!0,focusable:!0,style:{},manualRef:$};var Te=Object(O.b)()(we),Oe=i("Kwbf");function Le(t,e,i){var n=t.prefixCls,r=t.motion,a=t.defaultMotions,o=void 0===a?{}:a,s=t.openAnimation,l=t.openTransitionName,c=e.switchingModeFromInline;if(r)return r;if("object"===Object(R.a)(s)&&s)Object(Oe.a)(!1,"Object type of `openAnimation` is removed. Please use `motion` instead.");else if("string"==typeof s)return{motionName:"".concat(n,"-open-").concat(s)};if(l)return{motionName:l};var u=o[i];return u||(c?null:o.other)}var Ae=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(t){var n;Object(C.a)(this,i),(n=e.call(this,t)).onSelect=function(t){var e=Object(E.a)(n).props;if(e.selectable){var i=n.store.getState().selectedKeys,r=t.key;i=e.multiple?i.concat([r]):[r],"selectedKeys"in e||n.store.setState({selectedKeys:i}),e.onSelect(Object(o.a)(Object(o.a)({},t),{},{selectedKeys:i}))}},n.onClick=function(t){var e=n.getRealMenuMode(),i=Object(E.a)(n),r=i.store,a=i.props.onOpenChange;"inline"===e||"openKeys"in n.props||(r.setState({openKeys:[]}),a([])),n.props.onClick(t)},n.onKeyDown=function(t,e){n.innerMenu.getWrappedInstance().onKeyDown(t,e)},n.onOpenChange=function(t){var e=Object(E.a)(n).props,i=n.store.getState().openKeys.concat(),r=!1,a=function(t){var e=!1;if(t.open)(e=-1===i.indexOf(t.key))&&i.push(t.key);else{var n=i.indexOf(t.key);(e=-1!==n)&&i.splice(n,1)}r=r||e};Array.isArray(t)?t.forEach(a):a(t),r&&("openKeys"in n.props||n.store.setState({openKeys:i}),e.onOpenChange(i))},n.onDeselect=function(t){var e=Object(E.a)(n).props;if(e.selectable){var i=n.store.getState().selectedKeys.concat(),r=t.key,a=i.indexOf(r);-1!==a&&i.splice(a,1),"selectedKeys"in e||n.store.setState({selectedKeys:i}),e.onDeselect(Object(o.a)(Object(o.a)({},t),{},{selectedKeys:i}))}},n.onMouseEnter=function(t){n.restoreModeVerticalFromInline();var e=n.props.onMouseEnter;e&&e(t)},n.onTransitionEnd=function(t){var e="width"===t.propertyName&&t.target===t.currentTarget,i=t.target.className,r="[object SVGAnimatedString]"===Object.prototype.toString.call(i)?i.animVal:i,a="font-size"===t.propertyName&&r.indexOf("anticon")>=0;(e||a)&&n.restoreModeVerticalFromInline()},n.setInnerMenu=function(t){n.innerMenu=t},n.isRootMenu=!0;var r=t.defaultSelectedKeys,a=t.defaultOpenKeys;return"selectedKeys"in t&&(r=t.selectedKeys||[]),"openKeys"in t&&(a=t.openKeys||[]),n.store=Object(O.c)({selectedKeys:r,openKeys:a,activeKey:{"0-menu-":ke(t,t.activeKey)}}),n.state={switchingModeFromInline:!1,prevProps:t,inlineOpenKeys:[],store:n.store},n}return Object(k.a)(i,[{key:"componentDidMount",value:function(){this.updateMiniStore(),this.updateMenuDisplay()}},{key:"componentDidUpdate",value:function(t){var e=this.props,i=e.siderCollapsed,n=e.inlineCollapsed,r=e.onOpenChange;(!t.inlineCollapsed&&n||!t.siderCollapsed&&i)&&r([]),this.updateMiniStore(),this.updateMenuDisplay()}},{key:"updateMenuDisplay",value:function(){var t=this.props.collapsedWidth,e=this.store,i=this.prevOpenKeys;this.getInlineCollapsed()&&(0===t||"0"===t||"0px"===t)?(this.prevOpenKeys=e.getState().openKeys.concat(),this.store.setState({openKeys:[]})):i&&(this.store.setState({openKeys:i}),this.prevOpenKeys=null)}},{key:"getRealMenuMode",value:function(){var t=this.props.mode,e=this.state.switchingModeFromInline,i=this.getInlineCollapsed();return e&&i?"inline":i?"vertical":t}},{key:"getInlineCollapsed",value:function(){var t=this.props,e=t.inlineCollapsed,i=t.siderCollapsed;return void 0!==i?i:e}},{key:"restoreModeVerticalFromInline",value:function(){this.state.switchingModeFromInline&&this.setState({switchingModeFromInline:!1})}},{key:"updateMiniStore",value:function(){"selectedKeys"in this.props&&this.store.setState({selectedKeys:this.props.selectedKeys||[]}),"openKeys"in this.props&&this.store.setState({openKeys:this.props.openKeys||[]})}},{key:"render",value:function(){var t=Object(o.a)({},Object(L.a)(this.props,["collapsedWidth","siderCollapsed","defaultMotions"])),e=this.getRealMenuMode();return t.className+=" ".concat(t.prefixCls,"-root"),"rtl"===t.direction&&(t.className+=" ".concat(t.prefixCls,"-rtl")),delete(t=Object(o.a)(Object(o.a)({},t),{},{mode:e,onClick:this.onClick,onOpenChange:this.onOpenChange,onDeselect:this.onDeselect,onSelect:this.onSelect,onMouseEnter:this.onMouseEnter,onTransitionEnd:this.onTransitionEnd,parentMenu:this,motion:Le(this.props,this.state,e)})).openAnimation,delete t.openTransitionName,s.createElement(O.a,{store:this.store},s.createElement(Te,Object(S.a)({},t,{ref:this.setInnerMenu}),this.props.children))}}],[{key:"getDerivedStateFromProps",value:function(t,e){var i=e.prevProps,n=e.store,r=n.getState(),a={},o={prevProps:t};return"inline"===i.mode&&"inline"!==t.mode&&(o.switchingModeFromInline=!0),"openKeys"in t?a.openKeys=t.openKeys||[]:((t.inlineCollapsed&&!i.inlineCollapsed||t.siderCollapsed&&!i.siderCollapsed)&&(o.switchingModeFromInline=!0,o.inlineOpenKeys=r.openKeys,a.openKeys=[]),(!t.inlineCollapsed&&i.inlineCollapsed||!t.siderCollapsed&&i.siderCollapsed)&&(a.openKeys=e.inlineOpenKeys,o.inlineOpenKeys=[])),Object.keys(a).length&&n.setState(a),o}}]),i}(s.Component);Ae.defaultProps={selectable:!0,onClick:$,onSelect:$,onOpenChange:$,onDeselect:$,defaultSelectedKeys:[],defaultOpenKeys:[],subMenuOpenDelay:.1,subMenuCloseDelay:.1,triggerSubMenuAction:"hover",prefixCls:"rc-menu",className:"",mode:"vertical",style:{},builtinPlacements:{},overflowedIndicator:s.createElement("span",null,"···")};var De=Ae,_e=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(){var t;return Object(C.a)(this,i),(t=e.apply(this,arguments)).onKeyDown=function(e){if(e.keyCode===v.a.ENTER)return t.onClick(e),!0},t.onMouseLeave=function(e){var i=t.props,n=i.eventKey,r=i.onItemHover,a=i.onMouseLeave;r({key:n,hover:!1}),a({key:n,domEvent:e})},t.onMouseEnter=function(e){var i=t.props,n=i.eventKey,r=i.onItemHover,a=i.onMouseEnter;r({key:n,hover:!0}),a({key:n,domEvent:e})},t.onClick=function(e){var i=t.props,n=i.eventKey,r=i.multiple,a=i.onClick,o=i.onSelect,s=i.onDeselect,l=i.isSelected,c={key:n,keyPath:[n],item:Object(E.a)(t),domEvent:e};a(c),r?l?s(c):o(c):l||o(c)},t.saveNode=function(e){t.node=e},t}return Object(k.a)(i,[{key:"componentDidMount",value:function(){this.callRef()}},{key:"componentDidUpdate",value:function(){this.callRef()}},{key:"componentWillUnmount",value:function(){var t=this.props;t.onDestroy&&t.onDestroy(t.eventKey)}},{key:"getPrefixCls",value:function(){return"".concat(this.props.rootPrefixCls,"-item")}},{key:"getActiveClassName",value:function(){return"".concat(this.getPrefixCls(),"-active")}},{key:"getSelectedClassName",value:function(){return"".concat(this.getPrefixCls(),"-selected")}},{key:"getDisabledClassName",value:function(){return"".concat(this.getPrefixCls(),"-disabled")}},{key:"callRef",value:function(){this.props.manualRef&&this.props.manualRef(this)}},{key:"render",value:function(){var t,e=Object(o.a)({},this.props),i=c()(this.getPrefixCls(),e.className,(t={},Object(n.a)(t,this.getActiveClassName(),!e.disabled&&e.active),Object(n.a)(t,this.getSelectedClassName(),e.isSelected),Object(n.a)(t,this.getDisabledClassName(),e.disabled),t)),r=Object(o.a)(Object(o.a)({},e.attribute),{},{title:"string"==typeof e.title?e.title:void 0,className:i,role:e.role||"menuitem","aria-disabled":e.disabled});"option"===e.role?r=Object(o.a)(Object(o.a)({},r),{},{role:"option","aria-selected":e.isSelected}):null!==e.role&&"none"!==e.role||(r.role="none");var a={onClick:e.disabled?null:this.onClick,onMouseLeave:e.disabled?null:this.onMouseLeave,onMouseEnter:e.disabled?null:this.onMouseEnter},l=Object(o.a)({},e.style);"inline"===e.mode&&("rtl"===e.direction?l.paddingRight=e.inlineIndent*e.level:l.paddingLeft=e.inlineIndent*e.level),tt.forEach((function(t){return delete e[t]})),delete e.direction;var u=this.props.itemIcon;return"function"==typeof this.props.itemIcon&&(u=s.createElement(this.props.itemIcon,this.props)),s.createElement("li",Object(S.a)({},Object(L.a)(e,["onClick","onMouseEnter","onMouseLeave","onSelect"]),r,a,{style:l,ref:this.saveNode}),e.children,u)}}]),i}(s.Component);_e.isMenuItem=!0,_e.defaultProps={onSelect:$,onMouseEnter:$,onMouseLeave:$,manualRef:$};var Re=Object(O.b)((function(t,e){var i=t.activeKey,n=t.selectedKeys,r=e.eventKey;return{active:i[e.subMenuKey]===r,isSelected:Array.isArray(n)?-1!==n.indexOf(r):n===r}}))(_e),Ie=function(t){Object(w.a)(i,t);var e=Object(T.a)(i);function i(){var t;return Object(C.a)(this,i),(t=e.apply(this,arguments)).renderInnerMenuItem=function(e){var i=t.props;return(0,i.renderMenuItem)(e,i.index,t.props.subMenuKey)},t}return Object(k.a)(i,[{key:"render",value:function(){var t=Object(S.a)({},this.props),e=t.className,i=void 0===e?"":e,n=t.rootPrefixCls,r="".concat(n,"-item-group-title"),a="".concat(n,"-item-group-list"),o=t.title,l=t.children;return tt.forEach((function(e){return delete t[e]})),delete t.direction,s.createElement("li",Object(S.a)({},t,{onClick:function(t){return t.stopPropagation()},className:"".concat(i," ").concat(n,"-item-group")}),s.createElement("div",{className:r,title:"string"==typeof o?o:void 0},o),s.createElement("ul",{className:a},s.Children.map(l,this.renderInnerMenuItem)))}}]),i}(s.Component);Ie.isMenuItemGroup=!0,Ie.defaultProps={disabled:!0};var Me=function(t){var e=t.className,i=t.rootPrefixCls,n=t.style;return s.createElement("li",{className:"".concat(e," ").concat(i,"-item-divider"),style:n})};Me.defaultProps={disabled:!0,className:"",style:{}};var Ne=De,Pe=i("eDIo");var Fe=s.forwardRef((function(t,e){var i=t.prefixCls,n=t.editable,r=t.locale,a=t.style;return n&&!1!==n.showAdd?s.createElement("button",{ref:e,type:"button",className:"".concat(i,"-nav-add"),style:a,"aria-label":(null==r?void 0:r.addAriaLabel)||"Add tab",onClick:function(t){n.onEdit("add",{event:t})}},n.addIcon||"+"):null}));var je=s.forwardRef((function(t,e){var i=t.prefixCls,a=t.id,o=t.tabs,l=t.locale,u=t.mobile,h=t.moreIcon,d=void 0===h?"More":h,f=t.moreTransitionName,p=t.style,m=t.className,g=t.editable,y=t.tabBarGutter,b=t.rtl,x=t.onTabClick,S=Object(s.useState)(!1),C=Object(r.a)(S,2),k=C[0],E=C[1],w=Object(s.useState)(null),T=Object(r.a)(w,2),O=T[0],L=T[1],A="".concat(a,"-more-popup"),D="".concat(i,"-dropdown"),_=null!==O?"".concat(A,"-").concat(O):null,R=null==l?void 0:l.dropdownAriaLabel,I=s.createElement(Ne,{onClick:function(t){var e=t.key,i=t.domEvent;x(e,i),E(!1)},id:A,tabIndex:-1,role:"listbox","aria-activedescendant":_,selectedKeys:[O],"aria-label":void 0!==R?R:"expanded dropdown"},o.map((function(t){return s.createElement(Re,{key:t.key,id:"".concat(A,"-").concat(t.key),role:"option","aria-controls":a&&"".concat(a,"-panel-").concat(t.key),disabled:t.disabled},t.tab)})));function M(t){for(var e=o.filter((function(t){return!t.disabled})),i=e.findIndex((function(t){return t.key===O}))||0,n=e.length,r=0;r<n;r+=1){var a=e[i=(i+t+n)%n];if(!a.disabled)return void L(a.key)}}Object(s.useEffect)((function(){var t=document.getElementById(_);t&&t.scrollIntoView&&t.scrollIntoView(!1)}),[O]),Object(s.useEffect)((function(){k||L(null)}),[k]);var N=Object(n.a)({},b?"marginLeft":"marginRight",y);o.length||(N.visibility="hidden",N.order=1);var P=c()(Object(n.a)({},"".concat(D,"-rtl"),b)),F=u?null:s.createElement(Pe.a,{prefixCls:D,overlay:I,trigger:["hover"],visible:k,transitionName:f,onVisibleChange:E,overlayClassName:P,mouseEnterDelay:.1,mouseLeaveDelay:.1},s.createElement("button",{type:"button",className:"".concat(i,"-nav-more"),style:N,tabIndex:-1,"aria-hidden":"true","aria-haspopup":"listbox","aria-controls":A,id:"".concat(a,"-more"),"aria-expanded":k,onKeyDown:function(t){var e=t.which;if(k)switch(e){case v.a.UP:M(-1),t.preventDefault();break;case v.a.DOWN:M(1),t.preventDefault();break;case v.a.ESC:E(!1);break;case v.a.SPACE:case v.a.ENTER:null!==O&&x(O,t)}else[v.a.DOWN,v.a.SPACE,v.a.ENTER].includes(e)&&(E(!0),t.preventDefault())}},d));return s.createElement("div",{className:c()("".concat(i,"-nav-operations"),m),style:p,ref:e},F,s.createElement(Fe,{prefixCls:i,locale:l,editable:g}))})),Be=Object(s.createContext)(null),Ue=Math.pow(.995,20);function He(t,e){var i=s.useRef(t),n=s.useState({}),a=Object(r.a)(n,2)[1];return[i.current,function(t){var n="function"==typeof t?t(i.current):t;n!==i.current&&e(n,i.current),i.current=n,a({})}]}var Ge=function(t){var e,i=t.position,n=t.prefixCls,r=t.extra;if(!r)return null;var a=r;return"right"===i&&(e=a.right||!a.left&&a||null),"left"===i&&(e=a.left||null),e?s.createElement("div",{className:"".concat(n,"-extra-content")},e):null};var ze=s.forwardRef((function(t,e){var i,a,l=s.useContext(Be),u=l.prefixCls,h=l.tabs,f=t.className,v=t.style,S=t.id,C=t.animated,k=t.activeKey,E=t.rtl,w=t.extra,T=t.editable,O=t.locale,L=t.tabPosition,A=t.tabBarGutter,D=t.children,_=t.onTabClick,R=t.onTabScroll,I=Object(s.useRef)(),M=Object(s.useRef)(),N=Object(s.useRef)(),P=Object(s.useRef)(),F=(a=Object(s.useRef)(new Map),[function(t){return a.current.has(t)||a.current.set(t,s.createRef()),a.current.get(t)},function(t){a.current.delete(t)}]),j=Object(r.a)(F,2),B=j[0],U=j[1],H="top"===L||"bottom"===L,G=He(0,(function(t,e){H&&R&&R({direction:t>e?"left":"right"})})),z=Object(r.a)(G,2),V=z[0],W=z[1],K=He(0,(function(t,e){!H&&R&&R({direction:t>e?"top":"bottom"})})),q=Object(r.a)(K,2),Y=q[0],X=q[1],$=Object(s.useState)(0),Z=Object(r.a)($,2),J=Z[0],Q=Z[1],tt=Object(s.useState)(0),et=Object(r.a)(tt,2),it=et[0],nt=et[1],rt=Object(s.useState)(0),at=Object(r.a)(rt,2),ot=at[0],st=at[1],lt=Object(s.useState)(0),ct=Object(r.a)(lt,2),ut=ct[0],ht=ct[1],dt=Object(s.useState)(null),ft=Object(r.a)(dt,2),pt=ft[0],mt=ft[1],gt=Object(s.useState)(null),vt=Object(r.a)(gt,2),yt=vt[0],bt=vt[1],xt=Object(s.useState)(0),St=Object(r.a)(xt,2),Ct=St[0],kt=St[1],Et=Object(s.useState)(0),wt=Object(r.a)(Et,2),Tt=wt[0],Ot=wt[1],Lt=function(t){var e=Object(s.useRef)([]),i=Object(s.useState)({}),n=Object(r.a)(i,2)[1],a=Object(s.useRef)("function"==typeof t?t():t),o=g((function(){var t=a.current;e.current.forEach((function(e){t=e(t)})),e.current=[],a.current=t,n({})}));return[a.current,function(t){e.current.push(t),o()}]}(new Map),At=Object(r.a)(Lt,2),Dt=At[0],_t=At[1],Rt=function(t,e,i){return Object(s.useMemo)((function(){for(var i,n=new Map,r=e.get(null===(i=t[0])||void 0===i?void 0:i.key)||b,a=r.left+r.width,s=0;s<t.length;s+=1){var l,c=t[s].key,u=e.get(c);if(!u)u=e.get(null===(l=t[s-1])||void 0===l?void 0:l.key)||b;var h=n.get(c)||Object(o.a)({},u);h.right=a-h.left-h.width,n.set(c,h)}return n}),[t.map((function(t){return t.key})).join("_"),e,i])}(h,Dt,J),It="".concat(u,"-nav-operations-hidden"),Mt=0,Nt=0;function Pt(t){return t<Mt?[Mt,!1]:t>Nt?[Nt,!1]:[t,!0]}H?E?(Mt=0,Nt=Math.max(0,J-pt)):(Mt=Math.min(0,pt-J),Nt=0):(Mt=Math.min(0,yt-it),Nt=0);var Ft=Object(s.useRef)(),jt=Object(s.useState)(),Bt=Object(r.a)(jt,2),Ut=Bt[0],Ht=Bt[1];function Gt(){Ht(Date.now())}function zt(){window.clearTimeout(Ft.current)}function Vt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k,e=Rt.get(t);if(e)if(H){var i=V;E?e.right<V?i=e.right:e.right+e.width>V+pt&&(i=e.right+e.width-pt):e.left<-V?i=-e.left:e.left+e.width>-V+pt&&(i=-(e.left+e.width-pt)),X(0),W(Pt(i)[0])}else{var n=Y;e.top<-Y?n=-e.top:e.top+e.height>-Y+yt&&(n=-(e.top+e.height-yt)),W(0),X(Pt(n)[0])}}!function(t,e){var i=Object(s.useState)(),n=Object(r.a)(i,2),a=n[0],o=n[1],l=Object(s.useState)(0),c=Object(r.a)(l,2),u=c[0],h=c[1],d=Object(s.useState)(0),f=Object(r.a)(d,2),p=f[0],m=f[1],g=Object(s.useState)(),v=Object(r.a)(g,2),y=v[0],b=v[1],x=Object(s.useRef)(),S=Object(s.useRef)(0),C=Object(s.useRef)(!1),k=Object(s.useRef)(),E=Object(s.useRef)(null);E.current={onTouchStart:function(t){var e=t.touches[0],i=e.screenX,n=e.screenY;o({x:i,y:n}),window.clearInterval(x.current)},onTouchMove:function(t){if(a){t.preventDefault();var i=t.touches[0],n=i.screenX,r=i.screenY;o({x:n,y:r});var s=n-a.x,l=r-a.y;e(s,l);var c=Date.now();h(c),m(c-u),b({x:s,y:l})}},onTouchEnd:function(){if(a&&(o(null),b(null),y)){var t=y.x/p,i=y.y/p,n=Math.abs(t),r=Math.abs(i);if(Math.max(n,r)<.1)return;var s=t,l=i;x.current=window.setInterval((function(){Math.abs(s)<.01&&Math.abs(l)<.01?window.clearInterval(x.current):e(20*(s*=Ue),20*(l*=Ue))}),20)}},onWheel:function(t){var i=t.deltaX,n=t.deltaY,r=0,a=Math.abs(i),o=Math.abs(n);a===o?r="x"===k.current?i:n:a>o?(r=i,k.current="x"):(r=n,k.current="y");var s=Date.now();s-S.current>100&&(C.current=!1),(e(-r,-r)||C.current)&&(t.preventDefault(),C.current=!0),S.current=s}},s.useEffect((function(){function e(t){E.current.onTouchMove(t)}function i(t){E.current.onTouchEnd(t)}return document.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("touchend",i,{passive:!1}),t.current.addEventListener("touchstart",(function(t){E.current.onTouchStart(t)}),{passive:!1}),t.current.addEventListener("wheel",(function(t){E.current.onWheel(t)})),function(){document.removeEventListener("touchmove",e),document.removeEventListener("touchend",i)}}),[])}(I,(function(t,e){var i=!1;function n(t,e){t((function(t){var n=Pt(t+e),a=Object(r.a)(n,2),o=a[0],s=a[1];return i=s,o}))}if(H){if(pt>=J)return i;n(W,t)}else{if(yt>=it)return i;n(X,e)}return zt(),Gt(),i})),Object(s.useEffect)((function(){return zt(),Ut&&(Ft.current=window.setTimeout((function(){Ht(0)}),100)),zt}),[Ut]);var Wt=function(t,e,i,n,r){var a,o,l,c=r.tabs,u=r.tabPosition,h=r.rtl;["top","bottom"].includes(u)?(a="width",o=h?"right":"left",l=Math.abs(e.left)):(a="height",o="top",l=-e.top);var d=e[a],f=i[a],p=n[a],m=d;return f+p>d&&(m=d-p),Object(s.useMemo)((function(){if(!c.length)return[0,0];for(var e=c.length,i=e,n=0;n<e;n+=1){var r=t.get(c[n].key)||x;if(r[o]+r[a]>l+m){i=n-1;break}}for(var s=0,u=e-1;u>=0;u-=1){if((t.get(c[u].key)||x)[o]<l){s=u+1;break}}return[s,i]}),[t,l,m,u,c.map((function(t){return t.key})).join("_"),h])}(Rt,{width:pt,height:yt,left:V,top:Y},{width:ot,height:ut},{width:Ct,height:Tt},Object(o.a)(Object(o.a)({},t),{},{tabs:h})),Kt=Object(r.a)(Wt,2),qt=Kt[0],Yt=Kt[1],Xt=h.map((function(t){var e=t.key;return s.createElement(y,{id:S,prefixCls:u,key:e,rtl:E,tab:t,closable:t.closable,editable:T,active:e===k,tabPosition:L,tabBarGutter:A,renderWrapper:D,removeAriaLabel:null==O?void 0:O.removeAriaLabel,ref:B(e),onClick:function(t){_(e,t)},onRemove:function(){U(e)},onFocus:function(){Vt(e),Gt(),E||(I.current.scrollLeft=0),I.current.scrollTop=0}})})),$t=g((function(){var t,e,i,n,r,a,o,s,l,c=(null===(t=I.current)||void 0===t?void 0:t.offsetWidth)||0,u=(null===(e=I.current)||void 0===e?void 0:e.offsetHeight)||0,d=(null===(i=P.current)||void 0===i?void 0:i.offsetWidth)||0,f=(null===(n=P.current)||void 0===n?void 0:n.offsetHeight)||0,p=(null===(r=N.current)||void 0===r?void 0:r.offsetWidth)||0,m=(null===(a=N.current)||void 0===a?void 0:a.offsetHeight)||0;mt(c),bt(u),kt(d),Ot(f);var g=((null===(o=M.current)||void 0===o?void 0:o.offsetWidth)||0)-d,v=((null===(s=M.current)||void 0===s?void 0:s.offsetHeight)||0)-f;Q(g),nt(v);var y=null===(l=N.current)||void 0===l?void 0:l.className.includes(It);st(g-(y?0:p)),ht(v-(y?0:m)),_t((function(){var t=new Map;return h.forEach((function(e){var i=e.key,n=B(i).current;n&&t.set(i,{width:n.offsetWidth,height:n.offsetHeight,left:n.offsetLeft,top:n.offsetTop})})),t}))})),Zt=h.slice(0,qt),Jt=h.slice(Yt+1),Qt=[].concat(Object(d.a)(Zt),Object(d.a)(Jt)),te=Object(s.useState)(),ee=Object(r.a)(te,2),ie=ee[0],ne=ee[1],re=Rt.get(k),ae=Object(s.useRef)();function oe(){p.a.cancel(ae.current)}Object(s.useEffect)((function(){var t={};return re&&(H?(E?t.right=re.right:t.left=re.left,t.width=re.width):(t.top=re.top,t.height=re.height)),oe(),ae.current=p()((function(){ne(t)})),oe}),[re,H,E]),Object(s.useEffect)((function(){Vt()}),[k,re,Rt,H]),Object(s.useEffect)((function(){$t()}),[E,A,k,h.map((function(t){return t.key})).join("_")]);var se,le,ce,ue,he=!!Qt.length,de="".concat(u,"-nav-wrap");return H?E?(le=V>0,se=V+pt<J):(se=V<0,le=-V+pt<J):(ce=Y<0,ue=-Y+yt<it),s.createElement("div",{ref:e,role:"tablist",className:c()("".concat(u,"-nav"),f),style:v,onKeyDown:function(){Gt()}},s.createElement(Ge,{position:"left",extra:w,prefixCls:u}),s.createElement(m.a,{onResize:$t},s.createElement("div",{className:c()(de,(i={},Object(n.a)(i,"".concat(de,"-ping-left"),se),Object(n.a)(i,"".concat(de,"-ping-right"),le),Object(n.a)(i,"".concat(de,"-ping-top"),ce),Object(n.a)(i,"".concat(de,"-ping-bottom"),ue),i)),ref:I},s.createElement(m.a,{onResize:$t},s.createElement("div",{ref:M,className:"".concat(u,"-nav-list"),style:{transform:"translate(".concat(V,"px, ").concat(Y,"px)"),transition:Ut?"none":void 0}},Xt,s.createElement(Fe,{ref:P,prefixCls:u,locale:O,editable:T,style:{visibility:he?"hidden":null}}),s.createElement("div",{className:c()("".concat(u,"-ink-bar"),Object(n.a)({},"".concat(u,"-ink-bar-animated"),C.inkBar)),style:ie}))))),s.createElement(je,Object.assign({},t,{ref:N,prefixCls:u,tabs:Qt,className:!he&&It})),s.createElement(Ge,{position:"right",extra:w,prefixCls:u}))}));function Ve(t){var e=t.id,i=t.activeKey,r=t.animated,a=t.tabPosition,o=t.rtl,l=t.destroyInactiveTabPane,u=s.useContext(Be),h=u.prefixCls,d=u.tabs,f=r.tabPane,p=d.findIndex((function(t){return t.key===i}));return s.createElement("div",{className:c()("".concat(h,"-content-holder"))},s.createElement("div",{className:c()("".concat(h,"-content"),"".concat(h,"-content-").concat(a),Object(n.a)({},"".concat(h,"-content-animated"),f)),style:p&&f?Object(n.a)({},o?"marginRight":"marginLeft","-".concat(p,"00%")):null},d.map((function(t){return s.cloneElement(t.node,{key:t.key,prefixCls:h,tabKey:t.key,id:e,animated:f,active:t.key===i,destroyInactiveTabPane:l})}))))}function We(t){var e=t.prefixCls,i=t.forceRender,n=t.className,a=t.style,l=t.id,u=t.active,h=t.animated,d=t.destroyInactiveTabPane,f=t.tabKey,p=t.children,m=s.useState(i),g=Object(r.a)(m,2),v=g[0],y=g[1];s.useEffect((function(){u?y(!0):d&&y(!1)}),[u,d]);var b={};return u||(h?(b.visibility="hidden",b.height=0,b.overflowY="hidden"):b.display="none"),s.createElement("div",{id:l&&"".concat(l,"-panel-").concat(f),role:"tabpanel",tabIndex:u?0:-1,"aria-labelledby":l&&"".concat(l,"-tab-").concat(f),"aria-hidden":!u,style:Object(o.a)(Object(o.a)({},b),a),className:c()("".concat(e,"-tabpane"),u&&"".concat(e,"-tabpane-active"),n)},(u||v||i)&&p)}var Ke=0;var qe=s.forwardRef((function(t,e){var i,l,d=t.id,f=t.prefixCls,p=void 0===f?"rc-tabs":f,m=t.className,g=t.children,v=t.direction,y=t.activeKey,b=t.defaultActiveKey,x=t.editable,S=t.animated,C=t.tabPosition,k=void 0===C?"top":C,E=t.tabBarGutter,w=t.tabBarStyle,T=t.tabBarExtraContent,O=t.locale,L=t.moreIcon,A=t.moreTransitionName,D=t.destroyInactiveTabPane,_=t.renderTabBar,R=t.onChange,I=t.onTabClick,M=t.onTabScroll,N=Object(a.a)(t,["id","prefixCls","className","children","direction","activeKey","defaultActiveKey","editable","animated","tabPosition","tabBarGutter","tabBarStyle","tabBarExtraContent","locale","moreIcon","moreTransitionName","destroyInactiveTabPane","renderTabBar","onChange","onTabClick","onTabScroll"]),P=function(t){return Object(u.a)(t).map((function(t){if(s.isValidElement(t)){var e=void 0!==t.key?String(t.key):void 0;return Object(o.a)(Object(o.a)({key:e},t.props),{},{node:t})}return null})).filter((function(t){return t}))}(g),F="rtl"===v;l=!1===S?{inkBar:!1,tabPane:!1}:Object(o.a)({inkBar:!0,tabPane:!1},!0!==S?S:null);var j=Object(s.useState)(!1),B=Object(r.a)(j,2),U=B[0],H=B[1];Object(s.useEffect)((function(){var t;H((t=navigator.userAgent||navigator.vendor||window.opera,!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(t.substr(0,4)))))}),[]);var G=Object(h.a)((function(){var t;return null===(t=P[0])||void 0===t?void 0:t.key}),{value:y,defaultValue:b}),z=Object(r.a)(G,2),V=z[0],W=z[1],K=Object(s.useState)((function(){return P.findIndex((function(t){return t.key===V}))})),q=Object(r.a)(K,2),Y=q[0],X=q[1];Object(s.useEffect)((function(){var t,e=P.findIndex((function(t){return t.key===V}));-1===e&&(e=Math.max(0,Math.min(Y,P.length-1)),W(null===(t=P[e])||void 0===t?void 0:t.key));X(e)}),[P.map((function(t){return t.key})).join("_"),V,Y]);var $=Object(h.a)(null,{value:d}),Z=Object(r.a)($,2),J=Z[0],Q=Z[1],tt=k;U&&!["left","right"].includes(k)&&(tt="top"),Object(s.useEffect)((function(){d||(Q("rc-tabs-".concat(Ke)),Ke+=1)}),[]);var et,it={id:J,activeKey:V,animated:l,tabPosition:tt,rtl:F,mobile:U},nt=Object(o.a)(Object(o.a)({},it),{},{editable:x,locale:O,moreIcon:L,moreTransitionName:A,tabBarGutter:E,onTabClick:function(t,e){null==I||I(t,e),W(t),null==R||R(t)},onTabScroll:M,extra:T,style:w,panes:g});return et=_?_(nt,ze):s.createElement(ze,Object.assign({},nt)),s.createElement(Be.Provider,{value:{tabs:P,prefixCls:p}},s.createElement("div",Object.assign({ref:e,id:d,className:c()(p,"".concat(p,"-").concat(tt),(i={},Object(n.a)(i,"".concat(p,"-mobile"),U),Object(n.a)(i,"".concat(p,"-editable"),x),Object(n.a)(i,"".concat(p,"-rtl"),F),i),m)},N),et,s.createElement(Ve,Object.assign({destroyInactiveTabPane:D},it,{animated:l}))))}));qe.TabPane=We;var Ye=qe;e.b=Ye},kSUc:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/index.less ***!
|
|
|
\***************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},kqOp:
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/components/Editor/NullMDEditor.js ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return h}));var n=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/extends */"0Owb"),r=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/classCallCheck */"fWQN"),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createClass */"mtLc"),o=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/inherits */"yKVA"),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createSuper */"879j"),l=i(/*! react */"q1tI"),c=i.n(l),u=i(/*! ../markdown-editor */"Ot1p"),h=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(){var t;Object(r.a)(this,i);for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return(t=e.call.apply(e,[this].concat(a))).getChCountBeforeCursor=function(t,e){for(var i=e.line,n=0,r=0;r<i;r++)n+=t.getLine(r).split("▁").length-1;return n+=t.getLine(i).substring(0,e.ch).split("▁").length-1},t.onCMBeforeChange=function(e,i){var n=e.getRange(i.from,i.to),r=0;if(i.text.forEach((function(t){r+=t.split("▁").length-1})),n&&-1!=n.indexOf("▁")){var a=n.split("▁").length-1,o=t.getChCountBeforeCursor(e,i.from);console.log("删除".concat(a,"个, 之前有").concat(o,"个,新增").concat(r,"个")),t.props.deleteEmptyDisabled?i.cancel():t.props.onPlaceholderChange&&t.props.onPlaceholderChange(o,a,r)}else if(r){var s=t.getChCountBeforeCursor(e,i.from);console.log("新增".concat(r,"个,之前有").concat(s,"个")),t.props.onPlaceholderChange&&t.props.onPlaceholderChange(s,0,r)}},t}return Object(a.a)(i,[{key:"render",value:function(){return c.a.createElement(u.a,Object(n.a)({},this.props,{onCMBeforeChange:this.onCMBeforeChange}))}}]),i}(l.Component)},lZu9:
|
|
|
/*!***********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/mode/markdown/markdown.js ***!
|
|
|
\***********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){"use strict";t.defineMode("markdown",(function(e,i){var n=t.getMode(e,"text/html"),r="null"==n.name;void 0===i.highlightFormatting&&(i.highlightFormatting=!1),void 0===i.maxBlockquoteDepth&&(i.maxBlockquoteDepth=0),void 0===i.taskLists&&(i.taskLists=!1),void 0===i.strikethrough&&(i.strikethrough=!1),void 0===i.emoji&&(i.emoji=!1),void 0===i.fencedCodeBlockHighlighting&&(i.fencedCodeBlockHighlighting=!0),void 0===i.fencedCodeBlockDefaultMode&&(i.fencedCodeBlockDefaultMode="text/plain"),void 0===i.xml&&(i.xml=!0),void 0===i.tokenTypeOverrides&&(i.tokenTypeOverrides={});var a={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 o in a)a.hasOwnProperty(o)&&i.tokenTypeOverrides[o]&&(a[o]=i.tokenTypeOverrides[o]);var s=/^([*\-_])(?:\s*\1){2,}\s*$/,l=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,c=/^\[(x| )\](?=\s)/i,u=i.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,h=/^ {0,3}(?:\={1,}|-{2,})\s*$/,d=/^[^#!\[\]*_\\<>` "'(~:]+/,f=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,p=/^\s*\[[^\]]+?\]:.*$/,m=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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]/;function g(t,e,i){return e.f=e.inline=i,i(t,e)}function v(t,e,i){return e.f=e.block=i,i(t,e)}function y(e){if(e.linkTitle=!1,e.linkHref=!1,e.linkText=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,e.f==x){var i=r;if(!i){var a=t.innerMode(n,e.htmlState);i="xml"==a.mode.name&&null===a.state.tagStart&&!a.state.context&&a.state.tokenize.isInText}i&&(e.f=E,e.block=b,e.htmlState=null)}return e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine={stream:null},null}function b(n,r){var o,d=n.column()===r.indentation,m=!(o=r.prevLine.stream)||!/\S/.test(o.string),v=r.indentedCode,y=r.prevLine.hr,b=!1!==r.list,x=(r.listStack[r.listStack.length-1]||0)+3;r.indentedCode=!1;var k=r.indentation;if(null===r.indentationDiff&&(r.indentationDiff=r.indentation,b)){for(r.list=null;k<r.listStack[r.listStack.length-1];)r.listStack.pop(),r.listStack.length?r.indentation=r.listStack[r.listStack.length-1]:r.list=!1;!1!==r.list&&(r.indentationDiff=k-r.listStack[r.listStack.length-1])}var E=!(m||y||r.prevLine.header||b&&v||r.prevLine.fencedCodeEnd),w=(!1===r.list||y||m)&&r.indentation<=x&&n.match(s),T=null;if(r.indentationDiff>=4&&(v||r.prevLine.fencedCodeEnd||r.prevLine.header||m))return n.skipToEnd(),r.indentedCode=!0,a.code;if(n.eatSpace())return null;if(d&&r.indentation<=x&&(T=n.match(u))&&T[1].length<=6)return r.quote=0,r.header=T[1].length,r.thisLine.header=!0,i.highlightFormatting&&(r.formatting="header"),r.f=r.inline,C(r);if(r.indentation<=x&&n.eat(">"))return r.quote=d?1:r.quote+1,i.highlightFormatting&&(r.formatting="quote"),n.eatSpace(),C(r);if(!w&&!r.setext&&d&&r.indentation<=x&&(T=n.match(l))){var O=T[1]?"ol":"ul";return r.indentation=k+n.current().length,r.list=!0,r.quote=0,r.listStack.push(r.indentation),r.em=!1,r.strong=!1,r.code=!1,r.strikethrough=!1,i.taskLists&&n.match(c,!1)&&(r.taskList=!0),r.f=r.inline,i.highlightFormatting&&(r.formatting=["list","list-"+O]),C(r)}return d&&r.indentation<=x&&(T=n.match(f,!0))?(r.quote=0,r.fencedEndRE=new RegExp(T[1]+"+ *$"),r.localMode=i.fencedCodeBlockHighlighting&&function(i){if(t.findModeByName){var n=t.findModeByName(i);n&&(i=n.mime||n.mimes[0])}var r=t.getMode(e,i);return"null"==r.name?null:r}(T[2]||i.fencedCodeBlockDefaultMode),r.localMode&&(r.localState=t.startState(r.localMode)),r.f=r.block=S,i.highlightFormatting&&(r.formatting="code-block"),r.code=-1,C(r)):r.setext||!(E&&b||r.quote||!1!==r.list||r.code||w||p.test(n.string))&&(T=n.lookAhead(1))&&(T=T.match(h))?(r.setext?(r.header=r.setext,r.setext=0,n.skipToEnd(),i.highlightFormatting&&(r.formatting="header")):(r.header="="==T[0].charAt(0)?1:2,r.setext=r.header),r.thisLine.header=!0,r.f=r.inline,C(r)):w?(n.skipToEnd(),r.hr=!0,r.thisLine.hr=!0,a.hr):"["===n.peek()?g(n,r,L):g(n,r,r.inline)}function x(e,i){var a=n.token(e,i.htmlState);if(!r){var o=t.innerMode(n,i.htmlState);("xml"==o.mode.name&&null===o.state.tagStart&&!o.state.context&&o.state.tokenize.isInText||i.md_inside&&e.current().indexOf(">")>-1)&&(i.f=E,i.block=b,i.htmlState=null)}return a}function S(t,e){var n,r=e.listStack[e.listStack.length-1]||0,o=e.indentation<r,s=r+3;return e.fencedEndRE&&e.indentation<=s&&(o||t.match(e.fencedEndRE))?(i.highlightFormatting&&(e.formatting="code-block"),o||(n=C(e)),e.localMode=e.localState=null,e.block=b,e.f=E,e.fencedEndRE=null,e.code=0,e.thisLine.fencedCodeEnd=!0,o?v(t,e,e.block):n):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),a.code)}function C(t){var e=[];if(t.formatting){e.push(a.formatting),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var n=0;n<t.formatting.length;n++)e.push(a.formatting+"-"+t.formatting[n]),"header"===t.formatting[n]&&e.push(a.formatting+"-"+t.formatting[n]+"-"+t.header),"quote"===t.formatting[n]&&(!i.maxBlockquoteDepth||i.maxBlockquoteDepth>=t.quote?e.push(a.formatting+"-"+t.formatting[n]+"-"+t.quote):e.push("error"))}if(t.taskOpen)return e.push("meta"),e.length?e.join(" "):null;if(t.taskClosed)return e.push("property"),e.length?e.join(" "):null;if(t.linkHref?e.push(a.linkHref,"url"):(t.strong&&e.push(a.strong),t.em&&e.push(a.em),t.strikethrough&&e.push(a.strikethrough),t.emoji&&e.push(a.emoji),t.linkText&&e.push(a.linkText),t.code&&e.push(a.code),t.image&&e.push(a.image),t.imageAltText&&e.push(a.imageAltText,"link"),t.imageMarker&&e.push(a.imageMarker)),t.header&&e.push(a.header,a.header+"-"+t.header),t.quote&&(e.push(a.quote),!i.maxBlockquoteDepth||i.maxBlockquoteDepth>=t.quote?e.push(a.quote+"-"+t.quote):e.push(a.quote+"-"+i.maxBlockquoteDepth)),!1!==t.list){var r=(t.listStack.length-1)%3;r?1===r?e.push(a.list2):e.push(a.list3):e.push(a.list1)}return t.trailingSpaceNewLine?e.push("trailing-space-new-line"):t.trailingSpace&&e.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),e.length?e.join(" "):null}function k(t,e){if(t.match(d,!0))return C(e)}function E(e,r){var o=r.text(e,r);if(void 0!==o)return o;if(r.list)return r.list=null,C(r);if(r.taskList)return" "===e.match(c,!0)[1]?r.taskOpen=!0:r.taskClosed=!0,i.highlightFormatting&&(r.formatting="task"),r.taskList=!1,C(r);if(r.taskOpen=!1,r.taskClosed=!1,r.header&&e.match(/^#+$/,!0))return i.highlightFormatting&&(r.formatting="header"),C(r);var s=e.next();if(r.linkTitle){r.linkTitle=!1;var l=s;"("===s&&(l=")");var u="^\\s*(?:[^"+(l=(l+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+l;if(e.match(new RegExp(u),!0))return a.linkHref}if("`"===s){var h=r.formatting;i.highlightFormatting&&(r.formatting="code"),e.eatWhile("`");var d=e.current().length;if(0!=r.code||r.quote&&1!=d){if(d==r.code){var f=C(r);return r.code=0,f}return r.formatting=h,C(r)}return r.code=d,C(r)}if(r.code)return C(r);if("\\"===s&&(e.next(),i.highlightFormatting)){var p=C(r),g=a.formatting+"-escape";return p?p+" "+g:g}if("!"===s&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return r.imageMarker=!0,r.image=!0,i.highlightFormatting&&(r.formatting="image"),C(r);if("["===s&&r.imageMarker&&e.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return r.imageMarker=!1,r.imageAltText=!0,i.highlightFormatting&&(r.formatting="image"),C(r);if("]"===s&&r.imageAltText){i.highlightFormatting&&(r.formatting="image");var p=C(r);return r.imageAltText=!1,r.image=!1,r.inline=r.f=T,p}if("["===s&&!r.image)return r.linkText&&e.match(/^.*?\]/)||(r.linkText=!0,i.highlightFormatting&&(r.formatting="link")),C(r);if("]"===s&&r.linkText){i.highlightFormatting&&(r.formatting="link");var p=C(r);return r.linkText=!1,r.inline=r.f=e.match(/\(.*?\)| ?\[.*?\]/,!1)?T:E,p}if("<"===s&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return r.f=r.inline=w,i.highlightFormatting&&(r.formatting="link"),(p=C(r))?p+=" ":p="",p+a.linkInline;if("<"===s&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return r.f=r.inline=w,i.highlightFormatting&&(r.formatting="link"),(p=C(r))?p+=" ":p="",p+a.linkEmail;if(i.xml&&"<"===s&&e.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var y=e.string.indexOf(">",e.pos);if(-1!=y){var b=e.string.substring(e.start,y);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(b)&&(r.md_inside=!0)}return e.backUp(1),r.htmlState=t.startState(n),v(e,r,x)}if(i.xml&&"<"===s&&e.match(/^\/\w*?>/))return r.md_inside=!1,"tag";if("*"===s||"_"===s){for(var S=1,k=1==e.pos?" ":e.string.charAt(e.pos-2);S<3&&e.eat(s);)S++;var O=e.peek()||" ",L=!/\s/.test(O)&&(!m.test(O)||/\s/.test(k)||m.test(k)),A=!/\s/.test(k)&&(!m.test(k)||/\s/.test(O)||m.test(O)),D=null,_=null;if(S%2&&(r.em||!L||"*"!==s&&A&&!m.test(k)?r.em!=s||!A||"*"!==s&&L&&!m.test(O)||(D=!1):D=!0),S>1&&(r.strong||!L||"*"!==s&&A&&!m.test(k)?r.strong!=s||!A||"*"!==s&&L&&!m.test(O)||(_=!1):_=!0),null!=_||null!=D)return i.highlightFormatting&&(r.formatting=null==D?"strong":null==_?"em":"strong em"),!0===D&&(r.em=s),!0===_&&(r.strong=s),f=C(r),!1===D&&(r.em=!1),!1===_&&(r.strong=!1),f}else if(" "===s&&(e.eat("*")||e.eat("_"))){if(" "===e.peek())return C(r);e.backUp(1)}if(i.strikethrough)if("~"===s&&e.eatWhile(s)){if(r.strikethrough)return i.highlightFormatting&&(r.formatting="strikethrough"),f=C(r),r.strikethrough=!1,f;if(e.match(/^[^\s]/,!1))return r.strikethrough=!0,i.highlightFormatting&&(r.formatting="strikethrough"),C(r)}else if(" "===s&&e.match(/^~~/,!0)){if(" "===e.peek())return C(r);e.backUp(2)}if(i.emoji&&":"===s&&e.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){r.emoji=!0,i.highlightFormatting&&(r.formatting="emoji");var R=C(r);return r.emoji=!1,R}return" "===s&&(e.match(/^ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),C(r)}function w(t,e){if(">"===t.next()){e.f=e.inline=E,i.highlightFormatting&&(e.formatting="link");var n=C(e);return n?n+=" ":n="",n+a.linkInline}return t.match(/^[^>]+/,!0),a.linkInline}function T(t,e){if(t.eatSpace())return null;var n,r=t.next();return"("===r||"["===r?(e.f=e.inline=(n="("===r?")":"]",function(t,e){if(t.next()===n){e.f=e.inline=E,i.highlightFormatting&&(e.formatting="link-string");var r=C(e);return e.linkHref=!1,r}return t.match(O[n]),e.linkHref=!0,C(e)}),i.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,C(e)):"error"}var O={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function L(t,e){return t.match(/^([^\]\\]|\\.)*\]:/,!1)?(e.f=A,t.next(),i.highlightFormatting&&(e.formatting="link"),e.linkText=!0,C(e)):g(t,e,E)}function A(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=D,i.highlightFormatting&&(e.formatting="link");var n=C(e);return e.linkText=!1,n}return t.match(/^([^\]\\]|\\.)+/,!0),a.linkText}function D(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=E,a.linkHref+" url")}var _={startState:function(){return{f:b,prevLine:{stream:null},thisLine:{stream:null},block:b,htmlState:null,indentation:0,inline:E,text:k,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(e){return{f:e.f,prevLine:e.prevLine,thisLine:e.thisLine,block:e.block,htmlState:e.htmlState&&t.copyState(n,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?t.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkText:e.linkText,linkTitle:e.linkTitle,linkHref:e.linkHref,code:e.code,em:e.em,strong:e.strong,strikethrough:e.strikethrough,emoji:e.emoji,header:e.header,setext:e.setext,hr:e.hr,taskList:e.taskList,list:e.list,listStack:e.listStack.slice(0),quote:e.quote,indentedCode:e.indentedCode,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside,fencedEndRE:e.fencedEndRE}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine.stream){if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0))return y(e),null;if(e.prevLine=e.thisLine,e.thisLine={stream:t},e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,!e.localState&&(e.f=e.block,e.f!=x)){var i=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(e.indentation=i,e.indentationDiff=null,i>0)return null}}return e.f(t,e)},innerMode:function(t){return t.block==x?{state:t.htmlState,mode:n}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:_}},indent:function(e,i,r){return e.block==x&&n.indent?n.indent(e.htmlState,i,r):e.localState&&e.localMode.indent?e.localMode.indent(e.localState,i,r):t.Pass},blankLine:y,getType:C,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return _}),"xml"),t.defineMIME("text/markdown","markdown"),t.defineMIME("text/x-markdown","markdown")}(i(/*! ../../lib/codemirror */"VrN/"),i(/*! ../xml/xml */"1eCo"),i(/*! ../meta */"8EBN"))},osHv:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./node_modules/codemirror/addon/fold/xml-fold.js ***!
|
|
|
\********************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){!function(t){"use strict";var e=t.Pos;function i(t,e){return t.line-e.line||t.ch-e.ch}var n="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",r=new RegExp("<(/?)(["+n+"]["+n+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");function a(t,e,i,n){this.line=e,this.ch=i,this.cm=t,this.text=t.getLine(e),this.min=n?Math.max(n.from,t.firstLine()):t.firstLine(),this.max=n?Math.min(n.to-1,t.lastLine()):t.lastLine()}function o(t,i){var n=t.cm.getTokenTypeAt(e(t.line,i));return n&&/\btag\b/.test(n)}function s(t){if(!(t.line>=t.max))return t.ch=0,t.text=t.cm.getLine(++t.line),!0}function l(t){if(!(t.line<=t.min))return t.text=t.cm.getLine(--t.line),t.ch=t.text.length,!0}function c(t){for(;;){var e=t.text.indexOf(">",t.ch);if(-1==e){if(s(t))continue;return}if(o(t,e+1)){var i=t.text.lastIndexOf("/",e),n=i>-1&&!/\S/.test(t.text.slice(i+1,e));return t.ch=e+1,n?"selfClose":"regular"}t.ch=e+1}}function u(t){for(;;){var e=t.ch?t.text.lastIndexOf("<",t.ch-1):-1;if(-1==e){if(l(t))continue;return}if(o(t,e+1)){r.lastIndex=e,t.ch=e;var i=r.exec(t.text);if(i&&i.index==e)return i}else t.ch=e}}function h(t){for(;;){r.lastIndex=t.ch;var e=r.exec(t.text);if(!e){if(s(t))continue;return}if(o(t,e.index+1))return t.ch=e.index+e[0].length,e;t.ch=e.index+1}}function d(t){for(;;){var e=t.ch?t.text.lastIndexOf(">",t.ch-1):-1;if(-1==e){if(l(t))continue;return}if(o(t,e+1)){var i=t.text.lastIndexOf("/",e),n=i>-1&&!/\S/.test(t.text.slice(i+1,e));return t.ch=e+1,n?"selfClose":"regular"}t.ch=e}}function f(t,i){for(var n=[];;){var r,a=h(t),o=t.line,s=t.ch-(a?a[0].length:0);if(!a||!(r=c(t)))return;if("selfClose"!=r)if(a[1]){for(var l=n.length-1;l>=0;--l)if(n[l]==a[2]){n.length=l;break}if(l<0&&(!i||i==a[2]))return{tag:a[2],from:e(o,s),to:e(t.line,t.ch)}}else n.push(a[2])}}function p(t,i){for(var n=[];;){var r=d(t);if(!r)return;if("selfClose"!=r){var a=t.line,o=t.ch,s=u(t);if(!s)return;if(s[1])n.push(s[2]);else{for(var l=n.length-1;l>=0;--l)if(n[l]==s[2]){n.length=l;break}if(l<0&&(!i||i==s[2]))return{tag:s[2],from:e(t.line,t.ch),to:e(a,o)}}}else u(t)}}t.registerHelper("fold","xml",(function(t,n){for(var r=new a(t,n.line,0);;){var o=h(r);if(!o||r.line!=n.line)return;var s=c(r);if(!s)return;if(!o[1]&&"selfClose"!=s){var l=e(r.line,r.ch),u=f(r,o[2]);return u&&i(u.from,l)>0?{from:l,to:u.from}:null}}})),t.findMatchingTag=function(t,n,r){var o=new a(t,n.line,n.ch,r);if(-1!=o.text.indexOf(">")||-1!=o.text.indexOf("<")){var s=c(o),l=s&&e(o.line,o.ch),h=s&&u(o);if(s&&h&&!(i(o,n)>0)){var d={from:e(o.line,o.ch),to:l,tag:h[2]};return"selfClose"==s?{open:d,close:null,at:"open"}:h[1]?{open:p(o,h[2]),close:d,at:"close"}:{open:d,close:f(o=new a(t,l.line,l.ch,r),h[2]),at:"open"}}}},t.findEnclosingTag=function(t,e,i,n){for(var r=new a(t,e.line,e.ch,i);;){var o=p(r,n);if(!o)break;var s=f(new a(t,e.line,e.ch,i),o.tag);if(s)return{open:o,close:s}}},t.scanForClosingTag=function(t,e,i,n){return f(new a(t,e.line,e.ch,n?{from:0,to:n}:null),i)}}(i(/*! ../../lib/codemirror */"VrN/"))},p5ED:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: PreviewAll, default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i(/*! antd/es/button/style */"+L6B");var n=i(/*! antd/es/button */"2/Rp"),r=(i(/*! antd/es/tooltip/style */"5Dmo"),i(/*! antd/es/tooltip */"3S7+")),a=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),o=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator */"9og8"),s=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),l=i(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator */"WmNS"),c=i.n(l),u=i(/*! react */"q1tI"),h=i.n(u),d=i(/*! ./index.less?modules */"vHTk"),f=i.n(d),p=i(/*! @ant-design/icons */"yEEn"),m=i(/*! @/components/monaco-editor */"ZW9T"),g=i(/*! @/utils/util */"1vsH"),v=i(/*! @/service/exercise */"V0Rq"),y=i(/*! @/utils/env */"m3rI");e.a=function(t){t.name;var e=t.data,i=(t.theme,t.type),l=t.filename,d=t.monacoEditor,b=t.className,x=t.style,S=t.close,C=t.onClose,k=t.hasMask,E=t.otherData,w=void 0===E?{}:E,T=Object(u.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),O=Object(s.a)(T,2),L=(O[0],O[1],Object(u.useState)("")),A=Object(s.a)(L,2),D=(A[0],A[1]),_=Object(u.useState)(),R=Object(s.a)(_,2),I=R[0],M=R[1],N=Object(u.useRef)();"office"===i&&Object(g.P)(e).filesize>10485760&&(i="other"),l&&(d.filename=l),Object(u.useEffect)((function(){var t,e,i=null===(t=document.cookie)||void 0===t||null===(e=t.replace(/\s/g,""))||void 0===e?void 0:e.split(";");null==i||i.map((function(t){var e=t.split("=");"_educoder_session"===e[0]&&D(e[1])}))}),[]),Object(u.useEffect)((function(){"office"===i&&P()}),[i]);var P=function(){var t=Object(o.a)(c.a.mark((function t(){var i,n,r;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("data:",e),i=e,e.startsWith("http")||(i=location.origin+i),n=new URL(i).pathname.split("/").pop(),t.next=6,Object(v.U)({attachment_id:n});case 6:r=t.sent,M(r);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),F=function(){e.startsWith("http")||e.startsWith("blob:")?j():Object(g.x)(l||"educoder",e,l)},j=function(){Object(g.v)(l||"educoder",decodeURIComponent(e))};return h.a.createElement("div",{style:Object(a.a)({},x||{}),className:"".concat(k&&f.a.bgBlack," ").concat(i?f.a.wrp:"hide")},S&&h.a.createElement("div",{className:f.a.close,ref:N},h.a.createElement(r.a,{title:"点击下载此文件",getPopupContainer:function(){return N.current}},h.a.createElement("span",{onClick:j},h.a.createElement("i",{className:"icon-quxiaozhiding"}))),h.a.createElement(r.a,{title:"关闭",getPopupContainer:function(){return N.current}},h.a.createElement("span",{className:"",onClick:function(){C(),M(null)}},h.a.createElement("i",{className:"icon-guanbi1"})))),h.a.createElement("div",{className:"".concat(f.a[b]," ").concat(b," ").concat(f.a.monaco," ").concat("txt"===i?"show":"hide")},"txt"===i&&h.a.createElement(m.b,d)),"audio"===i&&h.a.createElement("audio",{src:"".concat((null==e?void 0:e.indexOf("http://"))>-1||(null==e?void 0:e.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(e),autoPlay:!0}),"video"===i&&h.a.createElement(h.a.Fragment,null,(null==e?void 0:e.indexOf("http"))>-1?h.a.createElement("video",{controls:!0,src:"".concat(e),autoPlay:!0}):h.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(e),autoPlay:!0})),"office"===i&&I&&h.a.createElement("iframe",{src:"/react/build/office.html?key=".concat(I.key,"&url=").concat(y.a.API_SERVER+I.url,"&callbackUrl=").concat(y.a.API_SERVER+I.callbackUrl,"&fileType=").concat(I.fileType,"&title=").concat(I.title,"&model=view")}),("xlsx"===i||"doc"===i||"pptx"===i||"docx"===i)&&h.a.createElement("iframe",{src:"/react/build/office.html?key=".concat(w.key,"&url=").concat(y.a.API_SERVER+w.url,"&callbackUrl=").concat(y.a.API_SERVER+w.callbackUrl,"&fileType=").concat(w.fileType,"&title=").concat(w.title,"&model=").concat(w.model)}),"html"===i&&h.a.createElement("iframe",{src:e+"&disposition=inline"}),"pdf"===i&&h.a.createElement("embed",{className:f.a.embed,src:e,type:"application/pdf"}),"image"===i&&h.a.createElement("img",{src:"".concat((null==e?void 0:e.indexOf("http://"))>-1||(null==e?void 0:e.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(e)}),"other"===i&&h.a.createElement("div",null,h.a.createElement(n.a,{type:"primary",size:"large",onClick:F},h.a.createElement(p.a,null),"点击下载")),"download"===i&&h.a.createElement(n.a,{type:"primary",size:"large",onClick:F},h.a.createElement(p.a,null),"点击下载"))}},"p77/":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/codemirror/lib/codemirror.css ***!
|
|
|
\****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){},"rAM+":
|
|
|
/*!*******************************************************************************************************************!*\
|
|
|
!*** ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js ***!
|
|
|
\*******************************************************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var n=i(/*! @babel/runtime/helpers/esm/unsupportedIterableToArray */"Qw5x");function r(t,e){var i;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=Object(n.a)(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==i.return||i.return()}finally{if(l)throw o}}}}},rUJ1:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/marked/src/helpers.js ***!
|
|
|
\********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: escape */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e){const i=/[&<>"']/,n=/[&<>"']/g,r=/[<>"']|&(?!#?\w+;)/,a=/[<>"']|&(?!#?\w+;)/g,o={"&":"&","<":"<",">":">",'"':""","'":"'"},s=t=>o[t];const l=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function c(t){return t.replace(l,(t,e)=>"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):"")}const u=/(^|[^\[])\^/g;const h=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;const f={},p=/^[^:]+:\/*[^/]*$/,m=/^([^:]+:)[\s\S]*$/,g=/^([^:]+:\/*[^/]*)[\s\S]*$/;function v(t,e){f[" "+t]||(p.test(t)?f[" "+t]=t+"/":f[" "+t]=y(t,"/",!0));const i=-1===(t=f[" "+t]).indexOf(":");return"//"===e.substring(0,2)?i?e:t.replace(m,"$1")+e:"/"===e.charAt(0)?i?e:t.replace(g,"$1")+e:t+e}function y(t,e,i){const n=t.length;if(0===n)return"";let r=0;for(;r<n;){const a=t.charAt(n-r-1);if(a!==e||i){if(a===e||!i)break;r++}else r++}return t.substr(0,n-r)}t.exports={escape:function(t,e){if(e){if(i.test(t))return t.replace(n,s)}else if(r.test(t))return t.replace(a,s);return t},unescape:c,edit:function(t,e){t=t.source||t,e=e||"";const i={replace:(e,n)=>(n=(n=n.source||n).replace(u,"$1"),t=t.replace(e,n),i),getRegex:()=>new RegExp(t,e)};return i},cleanUrl:function(t,e,i){if(t){let t;try{t=decodeURIComponent(c(i)).replace(h,"").toLowerCase()}catch(t){return null}if(0===t.indexOf("javascript:")||0===t.indexOf("vbscript:")||0===t.indexOf("data:"))return null}e&&!d.test(i)&&(i=v(e,i));try{i=encodeURI(i).replace(/%25/g,"%")}catch(t){return null}return i},resolveUrl:v,noopTest:{exec:function(){}},merge:function(t){let e,i,n=1;for(;n<arguments.length;n++)for(i in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},splitCells:function(t,e){const i=t.replace(/\|/g,(t,e,i)=>{let n=!1,r=e;for(;--r>=0&&"\\"===i[r];)n=!n;return n?"|":" |"}).split(/ \|/);let n=0;if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(/\\\|/g,"|");return i},rtrim:y,findClosingBracket:function(t,e){if(-1===t.indexOf(e[1]))return-1;const i=t.length;let n=0,r=0;for(;r<i;r++)if("\\"===t[r])r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return-1},checkSanitizeDeprecation:function(t){t&&t.sanitize&&!t.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")}}},t23M:
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/rc-resize-observer/es/index.js ***!
|
|
|
\*****************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(t,e,i){"use strict";var n=i(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ"),r=i(/*! @babel/runtime/helpers/esm/classCallCheck */"1OyB"),a=i(/*! @babel/runtime/helpers/esm/createClass */"vuIU"),o=i(/*! @babel/runtime/helpers/esm/inherits */"Ji7U"),s=i(/*! @babel/runtime/helpers/esm/createSuper */"LK+K"),l=i(/*! react */"q1tI"),c=i(/*! rc-util/es/Dom/findDOMNode */"m+aA"),u=i(/*! rc-util/es/Children/toArray */"Zm9Q"),h=i(/*! rc-util/es/warning */"Kwbf"),d=i(/*! rc-util/es/ref */"c+Xe"),f=i(/*! resize-observer-polyfill */"bdgK"),p=function(t){Object(o.a)(i,t);var e=Object(s.a)(i);function i(){var t;return Object(r.a)(this,i),(t=e.apply(this,arguments)).resizeObserver=null,t.childNode=null,t.currentElement=null,t.state={width:0,height:0,offsetHeight:0,offsetWidth:0},t.onResize=function(e){var i=t.props.onResize,r=e[0].target,a=r.getBoundingClientRect(),o=a.width,s=a.height,l=r.offsetWidth,c=r.offsetHeight,u=Math.floor(o),h=Math.floor(s);if(t.state.width!==u||t.state.height!==h||t.state.offsetWidth!==l||t.state.offsetHeight!==c){var d={width:u,height:h,offsetWidth:l,offsetHeight:c};t.setState(d),i&&Promise.resolve().then((function(){i(Object(n.a)(Object(n.a)({},d),{},{offsetWidth:l,offsetHeight:c}))}))}},t.setChildNode=function(e){t.childNode=e},t}return Object(a.a)(i,[{key:"componentDidMount",value:function(){this.onComponentUpdated()}},{key:"componentDidUpdate",value:function(){this.onComponentUpdated()}},{key:"componentWillUnmount",value:function(){this.destroyObserver()}},{key:"onComponentUpdated",value:function(){if(this.props.disabled)this.destroyObserver();else{var t=Object(c.a)(this.childNode||this);t!==this.currentElement&&(this.destroyObserver(),this.currentElement=t),!this.resizeObserver&&t&&(this.resizeObserver=new f.default(this.onResize),this.resizeObserver.observe(t))}}},{key:"destroyObserver",value:function(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}},{key:"render",value:function(){var t=this.props.children,e=Object(u.a)(t);if(e.length>1)Object(h.a)(!1,"Find more than one child node with `children` in ResizeObserver. Will only observe first one.");else if(0===e.length)return Object(h.a)(!1,"`children` of ResizeObserver is empty. Nothing is in observe."),null;var i=e[0];if(l.isValidElement(i)&&Object(d.c)(i)){var n=i.ref;e[0]=l.cloneElement(i,{ref:Object(d.a)(n,this.setChildNode)})}return 1===e.length?e[0]:e.map((function(t,e){return!l.isValidElement(t)||"key"in t&&null!==t.key?t:l.cloneElement(t,{key:"".concat("rc-observer-key","-").concat(e)})}))}}]),i}(l.Component);p.displayName="ResizeObserver",e.a=p},ulZh:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/hls.js/dist/hls.js ***!
|
|
|
\*****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){var n;"undefined"!=typeof window&&(n=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/eventemitter3/index.js ***!
|
|
|
\*********************************************/
|
|
|
/*! no static exports found */function(t,e,i){"use strict";var n=Object.prototype.hasOwnProperty,r="~";function a(){}function o(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new o(i,n||t,a),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],s]:t._events[l].push(s):(t._events[l]=s,t._eventsCount++),t}function l(t,e){0==--t._eventsCount?t._events=new a:delete t._events[e]}function c(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(r=!1)),c.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)n.call(t,e)&&i.push(r?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},c.prototype.listeners=function(t){var e=r?r+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,o=new Array(a);n<a;n++)o[n]=i[n].fn;return o},c.prototype.listenerCount=function(t){var e=r?r+t:t,i=this._events[e];return i?i.fn?1:i.length:0},c.prototype.emit=function(t,e,i,n,a,o){var s=r?r+t:t;if(!this._events[s])return!1;var l,c,u=this._events[s],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,i),!0;case 4:return u.fn.call(u.context,e,i,n),!0;case 5:return u.fn.call(u.context,e,i,n,a),!0;case 6:return u.fn.call(u.context,e,i,n,a,o),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var d,f=u.length;for(c=0;c<f;c++)switch(u[c].once&&this.removeListener(t,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,e);break;case 3:u[c].fn.call(u[c].context,e,i);break;case 4:u[c].fn.call(u[c].context,e,i,n);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];u[c].fn.apply(u[c].context,l)}}return!0},c.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},c.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},c.prototype.removeListener=function(t,e,i,n){var a=r?r+t:t;if(!this._events[a])return this;if(!e)return l(this,a),this;var o=this._events[a];if(o.fn)o.fn!==e||n&&!o.once||i&&o.context!==i||l(this,a);else{for(var s=0,c=[],u=o.length;s<u;s++)(o[s].fn!==e||n&&!o[s].once||i&&o[s].context!==i)&&c.push(o[s]);c.length?this._events[a]=1===c.length?c[0]:c:l(this,a)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&l(this,e)):(this._events=new a,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t.exports=c},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
|
\*****************************************************/
|
|
|
/*! no static exports found */function(t,e,i){var n,r,a,o,s;n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,r=/^([^\/?#]*)([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(c.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var u=o.path,h=u.substring(0,u.lastIndexOf("/")+1)+a.path;c.path=s.normalizePath(h)}else c.path=o.path,a.params||(c.params=o.params,a.query||(c.query=o.query));return null===c.path&&(c.path=i.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(c)},parseURL:function(t){var e=n.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(o,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s},"./node_modules/webworkify-webpack/index.js":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
|
\**************************************************/
|
|
|
/*! no static exports found */function(t,e,i){function n(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i.oe=function(t){throw console.error(t),t};var n=i(i.s=ENTRY_MODULE);return n.default||n}function r(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(t,e,n){var a={};a[n]=[];var o=e.toString(),s=o.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return a;for(var l,c=s[1],u=new RegExp("(\\\\n|\\W)"+r(c)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=u.exec(o);)"dll-reference"!==l[3]&&a[n].push(l[3]);for(u=new RegExp("\\("+r(c)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=u.exec(o);)t[l[2]]||(a[n].push(l[1]),t[l[2]]=i(l[1]).m),a[l[2]]=a[l[2]]||[],a[l[2]].push(l[4]);for(var h,d=Object.keys(a),f=0;f<d.length;f++)for(var p=0;p<a[d[f]].length;p++)h=a[d[f]][p],isNaN(1*h)||(a[d[f]][p]=1*a[d[f]][p]);return a}function o(t){return Object.keys(t).reduce((function(e,i){return e||t[i].length>0}),!1)}t.exports=function(t,e){e=e||{};var r={main:i.m},s=e.all?{main:Object.keys(r.main)}:function(t,e){for(var i={main:[e]},n={main:[]},r={main:{}};o(i);)for(var s=Object.keys(i),l=0;l<s.length;l++){var c=s[l],u=i[c].pop();if(r[c]=r[c]||{},!r[c][u]&&t[c][u]){r[c][u]=!0,n[c]=n[c]||[],n[c].push(u);for(var h=a(t,t[c][u],c),d=Object.keys(h),f=0;f<d.length;f++)i[d[f]]=i[d[f]]||[],i[d[f]]=i[d[f]].concat(h[d[f]])}}return n}(r,t),l="";Object.keys(s).filter((function(t){return"main"!==t})).forEach((function(t){for(var e=0;s[t][e];)e++;s[t].push(e),r[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+t+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+s[t].map((function(e){return JSON.stringify(e)+": "+r[t][e].toString()})).join(",")+"});\n"})),l=l+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s.main.map((function(t){return JSON.stringify(t)+": "+r.main[t].toString()})).join(",")+"}))(self);";var c=new window.Blob([l],{type:"text/javascript"});if(e.bare)return c;var u=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(c),h=new window.Worker(u);return h.objectURL=u,h}},"./src/config.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/config.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,i){"use strict";i.r(e),i.d(e,"hlsDefaultConfig",(function(){return k})),i.d(e,"mergeConfig",(function(){return E})),i.d(e,"enableStreamingMode",(function(){return w}));var n=i(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),r=i(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),a=i(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),o=i(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),s=i(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=i(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),c=i(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),u=i(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),h=i(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),d=i(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=i(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=i(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),m=i(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),g=i(/*! ./utils/cues */"./src/utils/cues.ts"),v=i(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=i(/*! ./utils/logger */"./src/utils/logger.ts");function b(){return(b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function x(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function S(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?x(Object(i),!0).forEach((function(e){C(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):x(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function C(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var k=S(S({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,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:p.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:n.default,bufferController:l.default,capLevelController:u.default,fpsController:h.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:v.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:g.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}),{},{subtitleStreamController:o.SubtitleStreamController,subtitleTrackController:s.default,timelineController:c.TimelineController,audioStreamController:r.default,audioTrackController:a.default,emeController:d.default,cmcdController:f.default});function E(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return b({},t,e)}function w(t){var e=t.loader;e!==m.default&&e!==p.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(m.fetchSupported)()&&(t.loader=m.default,t.progressive=!0,t.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/abr-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),a=i(/*! ../events */"./src/events.ts"),o=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../types/loader */"./src/types/loader.ts"),c=i(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var h=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new r.default(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e,i,h,d=t.prototype;return d.registerListeners=function(){var t=this.hls;t.on(a.Events.FRAG_LOADING,this.onFragLoading,this),t.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(a.Events.FRAG_LOADING,this.onFragLoading,this),t.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(t,e){var i,n=e.frag;n.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!=(i=e.part)?i:null,this.timer=self.setInterval(this.onCheck,100)))},d.onLevelLoaded=function(t,e){var i=this.hls.config;e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,i=this.hls,r=i.autoLevelEnabled,s=i.config,l=i.media;if(t&&l){var u=e?e.stats:t.stats,h=e?e.duration:t.duration;if(u.aborted)return c.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(r&&!l.paused&&l.playbackRate&&l.readyState){var d=performance.now()-u.loading.start,f=Math.abs(l.playbackRate);if(!(d<=500*h/f)){var p=i.levels,m=i.minAutoLevel,g=p[t.level],v=u.total||Math.max(u.loaded,Math.round(h*g.maxBitrate/8)),y=Math.max(1,u.bwEstimate?u.bwEstimate/8:1e3*u.loaded/d),b=(v-u.loaded)/y,x=l.currentTime,S=(o.BufferHelper.bufferInfo(l,x,s.maxBufferHole).end-x)/f;if(!(S>=2*h/f||b<=S)){var C,k=Number.POSITIVE_INFINITY;for(C=t.level-1;C>m&&!((k=h*p[C].maxBitrate/(6.4*y))<S);C--);if(!(k>=b)){var E=this.bwEstimator.getEstimate();c.logger.warn("Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+C+"\n Current BW estimate: "+(Object(n.isFiniteNumber)(E)?(E/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+k.toFixed(3)+" s\n Time to underbuffer: "+S.toFixed(3)+" s"),i.nextLoadLevel=C,this.bwEstimator.sample(d,u.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),i.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:u})}}}}}},d.onFragLoaded=function(t,e){var i=e.frag,r=e.part;if(i.type===l.PlaylistLevelType.MAIN&&Object(n.isFiniteNumber)(i.sn)){var o=r?r.stats:i.stats,s=r?r.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var c=this.hls.levels[i.level],u=(c.loaded?c.loaded.bytes:0)+o.loaded,h=(c.loaded?c.loaded.duration:0)+s;c.loaded={bytes:u,duration:h},c.realBitrate=Math.round(8*u/h)}if(i.bitrateTest){var d={stats:o,frag:i,part:r,id:i.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,d),i.bitrateTest=!1}}},d.onFragBuffered=function(t,e){var i=e.frag,n=e.part,r=n?n.stats:i.stats;if(!r.aborted&&i.type===l.PlaylistLevelType.MAIN&&"initSegment"!==i.sn){var a=r.parsing.end-r.loading.start;this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},d.onError=function(t,e){switch(e.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,i=this.hls,n=i.maxAutoLevel,r=i.config,a=i.minAutoLevel,s=i.media,l=e?e.duration:t?t.duration:0,u=s?s.currentTime:0,h=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,f=(o.BufferHelper.bufferInfo(s,u,r.maxBufferHole).end-u)/h,p=this.findBestLevel(d,a,n,f,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(p>=0)return p;c.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var m=l?Math.min(l,r.maxStarvationDelay):r.maxStarvationDelay,g=r.abrBandWidthFactor,v=r.abrBandWidthUpFactor;if(!f){var y=this.bitrateTestDelay;y&&(m=(l?Math.min(l,r.maxLoadingDelay):r.maxLoadingDelay)-y,c.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),g=v=1)}return p=this.findBestLevel(d,a,n,f+m,g,v),Math.max(p,0)},d.findBestLevel=function(t,e,i,n,r,a){for(var o,s=this.fragCurrent,l=this.partCurrent,u=this.lastLoadedFragLevel,h=this.hls.levels,d=h[u],f=!(null==d||null===(o=d.details)||void 0===o||!o.live),p=null==d?void 0:d.codecSet,m=l?l.duration:s?s.duration:0,g=i;g>=e;g--){var v=h[g];if(v&&(!p||v.codecSet===p)){var y=v.details,b=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||m,x=void 0;x=g<=u?r*t:a*t;var S=h[g].maxBitrate,C=S*b/x;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+g+"/"+Math.round(x)+"/"+S+"/"+b+"/"+n+"/"+C),x>S&&(!C||f&&!this.bitrateTestDelay||C<n))return g}}return-1},e=t,(i=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(!(-1===t||e&&e.canEstimate()))return t;var i=this.getNextABRAutoLevel();return-1!==t&&(i=Math.min(t,i)),i},set:function(t){this._nextAutoLevel=t}}])&&u(e.prototype,i),h&&u(e,h),t}();e.default=h},"./src/controller/audio-stream-controller.ts":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=i(/*! ../events */"./src/events.ts"),o=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=i(/*! ../types/level */"./src/types/level.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),u=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),h=i(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),d=i(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),m=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),g=i(/*! ../errors */"./src/errors.ts"),v=i(/*! ../utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var x=function(t){var e,i;function x(e,i){var n;return(n=t.call(this,e,i,"[audio-stream-controller]")||this).videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.audioSwitch=!1,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.bufferFlushed=!1,n._registerListeners(),n}i=t,(e=x).prototype=Object.create(i.prototype),e.prototype.constructor=e,b(e,i);var S=x.prototype;return S.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},S._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.BUFFER_RESET,this.onBufferReset,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.BUFFER_RESET,this.onBufferReset,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S.onInitPtsFound=function(t,e){var i=e.frag,n=e.id,a=e.initPTS;if("main"===n){var o=i.cc;this.initPTS[i.cc]=a,this.log("InitPTS for cc: "+o+" found from main: "+a),this.videoTrackCC=o,this.state===r.State.WAITING_INIT_PTS&&this.tick()}},S.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=r.State.STOPPED);var e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,e>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=r.State.IDLE):(this.loadedmetadata=!1,this.state=r.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},S.doTick=function(){switch(this.state){case r.State.IDLE:this.doTickIdle();break;case r.State.WAITING_TRACK:var e,i=this.levels,n=this.trackId,a=null==i||null===(e=i[n])||void 0===e?void 0:e.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=r.State.WAITING_INIT_PTS}break;case r.State.FRAG_LOADING_WAITING_RETRY:var s,l=performance.now(),c=this.retryDate;(!c||l>=c||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=r.State.IDLE);break;case r.State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var h=u.frag,d=u.part,f=u.cache,m=u.complete;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=r.State.FRAG_LOADING;var g={frag:h,part:d,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(g),m&&t.prototype._handleFragmentLoadComplete.call(this,g)}else if(this.videoTrackCC!==this.waitingVideoCC)v.logger.log("Waiting fragment cc ("+h.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var y=this.getLoadPosition(),b=o.BufferHelper.bufferInfo(this.mediaBuffer,y,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,h)<0&&(v.logger.log("Waiting fragment cc ("+h.cc+") @ "+h.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=r.State.IDLE}this.onTickEnd()},S.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=r.State.IDLE)},S.onTickEnd=function(){var t=this.media;if(t&&t.readyState){var e=(this.mediaBuffer?this.mediaBuffer:t).buffered;!this.loadedmetadata&&e.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime}},S.doTickIdle=function(){var t,e,i=this.hls,n=this.levels,o=this.media,s=this.trackId,l=i.config;if(n&&n[s]&&(o||!this.startFragRequested&&l.startFragPrefetch)){var h=n[s].details;if(!h||h.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(h))this.state=r.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,u.ElementaryStreamTypes.AUDIO,c.PlaylistLevelType.AUDIO));var d=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,c.PlaylistLevelType.AUDIO);if(null!==d){var f=d.len,p=this.getMaxBufferLength(),m=this.audioSwitch;if(!(f>=p)||m){if(!m&&this._streamEnded(d,h))return i.trigger(a.Events.BUFFER_EOS,{type:"audio"}),void(this.state=r.State.ENDED);var g=h.fragments[0].start,v=d.end;if(m){var y=this.getLoadPosition();v=y,h.PTSKnown&&y<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),o.currentTime=g+.05)}var b=this.getNextFragment(v,h);b?"identity"!==(null===(t=b.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=b.decryptdata)&&void 0!==e&&e.key?this.loadFragment(b,h,v):this.loadKey(b,h):this.bufferFlushed=!0}}}}},S.getMaxBufferLength=function(){var e=t.prototype.getMaxBufferLength.call(this),i=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,c.PlaylistLevelType.MAIN);return null===i?e:Math.max(e,i.len)},S.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},S.onAudioTracksUpdated=function(t,e){var i=e.audioTracks;this.resetTransmuxer(),this.levels=i.map((function(t){return new l.Level(t)}))},S.onAudioTrackSwitching=function(t,e){var i=!!e.url;this.trackId=e.id;var n=this.fragCurrent;null!=n&&n.loader&&n.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.audioSwitch=!0,this.state=r.State.IDLE):this.state=r.State.STOPPED,this.tick()},S.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},S.onLevelLoaded=function(t,e){this.mainDetails=e.details},S.onAudioTrackLoaded=function(t,e){var i,n=this.levels,a=e.details,o=e.id;if(n){this.log("Track "+o+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var s=n[o],l=0;if(a.live||null!==(i=s.details)&&void 0!==i&&i.live){var c=this.mainDetails;if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed||!c)return;!s.details&&a.hasProgramDateTime&&c.hasProgramDateTime?(Object(m.alignMediaPlaylistByPDT)(a,c),l=a.fragments[0].start):l=this.alignPlaylists(a,s.details)}s.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(s.details,l),this.state!==r.State.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=r.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+o)},S._handleFragmentLoadProgress=function(t){var e,i=t.frag,n=t.part,a=t.payload,o=this.config,s=this.trackId,l=this.levels;if(l){var u=l[s];console.assert(u,"Audio track is defined on fragment load progress");var p=u.details;console.assert(p,"Audio track details are defined on fragment load progress");var m=o.defaultAudioCodec||u.audioCodec||"mp4a.40.2",g=this.transmuxer;g||(g=this.transmuxer=new d.default(this.hls,c.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var y=this.initPTS[i.cc],b=null===(e=i.initSegment)||void 0===e?void 0:e.data;if(void 0!==y){var x=n?n.index:-1,S=-1!==x,C=new f.ChunkMetadata(i.level,i.sn,i.stats.chunkCount,a.byteLength,x,S);g.push(a,b,m,"",i,n,p.totalduration,!1,C,y)}else v.logger.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+s),(this.waitingData=this.waitingData||{frag:i,part:n,cache:new h.default,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=r.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},S._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},S.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},S.onBufferCreated=function(t,e){var i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},S.onFragBuffered=function(t,e){var i=e.frag,n=e.part;i.type===c.PlaylistLevelType.AUDIO&&(this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(n?" p: "+n.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,n)))},S.onError=function(e,i){switch(i.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.AUDIO,i);break;case g.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case g.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==r.State.ERROR&&this.state!==r.State.STOPPED&&(this.state=i.fatal?r.State.ERROR:r.State.IDLE,this.warn(i.details+" while loading frag, switching to "+this.state+" state"));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===i.parent&&(this.state===r.State.PARSING||this.state===r.State.PARSED)){var n=!0,a=this.getFwdBufferInfo(this.mediaBuffer,c.PlaylistLevelType.AUDIO);a&&a.len>.5&&(n=!this.reduceMaxBufferLength(a.len)),n&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},S.onBufferFlushed=function(t,e){e.type===u.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},S._handleTransmuxComplete=function(t){var e,i="audio",n=this.hls,o=t.remuxResult,s=t.chunkMeta,l=this.getCurrentContext(s);if(!l)return this.warn("The loading context changed while buffering fragment "+s.sn+" of level "+s.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(s.level);var c=l.frag,h=l.part,d=o.audio,f=o.text,p=o.id3,m=o.initSegment;if(!this.fragContextChanged(c)){if(this.state=r.State.PARSING,this.audioSwitch&&d&&this.completeAudioSwitch(),null!=m&&m.tracks&&(this._bufferInitSegment(m.tracks,c,s),n.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:i,tracks:m.tracks})),d){var g=d.startPTS,v=d.endPTS,b=d.startDTS,x=d.endDTS;h&&(h.elementaryStreams[u.ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:v,startDTS:b,endDTS:x}),c.setElementaryStreamInfo(u.ElementaryStreamTypes.AUDIO,g,v,b,x),this.bufferFragmentData(d,c,h,s)}if(null!=p&&null!==(e=p.samples)&&void 0!==e&&e.length){var S=y({frag:c,id:i},p);n.trigger(a.Events.FRAG_PARSING_METADATA,S)}if(f){var C=y({frag:c,id:i},f);n.trigger(a.Events.FRAG_PARSING_USERDATA,C)}}},S._bufferInitSegment=function(t,e,i){if(this.state===r.State.PARSING){t.video&&delete t.video;var n=t.audio;if(n){n.levelCodec=n.codec,n.id="audio",this.log("Init audio buffer, container:"+n.container+", codecs[parsed]=["+n.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,t);var o=n.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(a.Events.BUFFER_APPENDING,s)}this.tick()}}},S.loadFragment=function(e,i,a){var o=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||o===s.FragmentState.NOT_LOADED||o===s.FragmentState.PARTIAL)&&("initSegment"===e.sn?this._loadInitSegment(e):i.live&&!Object(n.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=r.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,i,a)))},S.completeAudioSwitch=function(){var e=this.hls,i=this.media,n=this.trackId;i&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})},x}(r.default);e.default=x},"./src/controller/audio-track-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/audio-track-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),o=i(/*! ../types/loader */"./src/types/loader.ts");function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,i;function a(e){var i;return(i=t.call(this,e,"[audio-track-controller]")||this).tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.trackName="",i.selectDefaultTrack=!0,i.registerListeners(),i}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var c,u,h,d=a.prototype;return d.registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(n.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(n.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},d.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},d.onManifestParsed=function(t,e){this.tracks=e.audioTracks||[]},d.onAudioTrackLoaded=function(t,e){var i=e.id,n=e.details,r=this.tracksInGroup[i];if(r){var a=r.details;r.details=e.details,this.log("audioTrack "+i+" loaded ["+n.startSN+"-"+n.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,a))}else this.warn("Invalid audio track id "+i)},d.onLevelLoading=function(t,e){this.switchLevel(e.level)},d.onLevelSwitching=function(t,e){this.switchLevel(e.level)},d.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){var i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i;var r=this.tracks.filter((function(t){return!i||t.groupId===i}));this.selectDefaultTrack&&!r.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=r;var a={audioTracks:r};this.log("Updating audio tracks, "+r.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(n.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},d.onError=function(e,i){t.prototype.onError.call(this,e,i),!i.fatal&&i.context&&i.context.type===o.PlaylistContextType.AUDIO_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},d.setAudioTrack=function(t){var e=this.tracksInGroup;if(t<0||t>=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var i=e[this.trackId];this.log("Now switching to audio-track index "+t);var r=e[t],a=r.id,o=r.groupId,s=void 0===o?"":o,l=r.name,c=r.type,u=r.url;if(this.trackId=t,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(n.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:s,name:l,type:c,url:u}),!r.details||r.details.live){var h=this.switchParams(r.url,null==i?void 0:i.details);this.loadPlaylist(h)}}},d.selectInitialTrack=function(){var t=this.tracksInGroup;console.assert(t.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,i=this.findTrackId(e)||this.findTrackId();-1!==i?this.setAudioTrack(i):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},d.findTrackId=function(t){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},d.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,r=e.groupId,a=e.url;if(t)try{a=t.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(n.Events.AUDIO_TRACK_LOADING,{url:a,id:i,groupId:r,deliveryDirectives:t||null})}},c=a,(u=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&s(c.prototype,u),h&&s(c,h),a}(a.default);e.default=c},"./src/controller/base-playlist-controller.ts":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
|
\****************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return l}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../types/level */"./src/types/level.ts"),a=i(/*! ./level-helper */"./src/controller/level-helper.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ../errors */"./src/errors.ts"),l=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=o.logger.log.bind(o.logger,e+":"),this.warn=o.logger.warn.bind(o.logger,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.onError=function(t,e){e.fatal&&e.type===s.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(t,e){var i=null==e?void 0:e.renditionReports;if(i)for(var a=0;a<i.length;a++){var o=i[a],s=""+o.URI;if(s===t.substr(-s.length)){var l=parseInt(o["LAST-MSN"]),c=parseInt(o["LAST-PART"]);if(e&&this.hls.config.lowLatencyMode){var u=Math.min(e.age-e.partTarget,e.targetduration);void 0!==c&&u>e.partTarget&&(c+=1)}if(Object(n.isFiniteNumber)(l))return new r.HlsUrlParameters(l,Object(n.isFiniteNumber)(c)?c:void 0,r.HlsSkip.No)}}},e.loadPlaylist=function(t){},e.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},e.playlistLoaded=function(t,e,i){var n=this,r=e.details,o=e.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(r.advancedDateTime=Date.now()-s,r.live||null!=i&&i.live){if(r.reloaded(i),i&&this.log("live playlist "+t+" "+(r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:"MISSED")),i&&r.fragments.length>0&&Object(a.mergeDetails)(i,r),!this.canLoad||!r.live)return;var l,c=void 0,u=void 0;if(r.canBlockReload&&r.endSN&&r.advanced){var h=this.hls.config.lowLatencyMode,d=r.lastPartSn,f=r.endSN,p=r.lastPartIndex,m=d===f;-1!==p?(c=m?f+1:d,u=m?h?0:p:p+1):c=f+1;var g=r.age,v=g+r.ageHeader,y=Math.min(v-r.partTarget,1.5*r.targetduration);if(y>0){if(i&&y>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+y+" with playlist age: "+r.age),y=0;else{var b=Math.floor(y/r.targetduration);c+=b,void 0!==u&&(u+=Math.round(y%r.targetduration/r.partTarget)),this.log("CDN Tune-in age: "+r.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+b+" to part "+u)}r.tuneInGoal=y}if(l=this.getDeliveryDirectives(r,e.deliveryDirectives,c,u),h||!m)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(r,e.deliveryDirectives,c,u);var x=Object(a.computeReloadInterval)(r,o);void 0!==c&&r.canBlockReload&&(x-=r.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(x)+" ms"),this.timer=self.setTimeout((function(){return n.loadPlaylist(l)}),x)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,i,n){var a=Object(r.getSkipValue)(t,i);return null!=e&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,a=r.HlsSkip.No),new r.HlsUrlParameters(i,n,a)},e.retryLoadingOrFail=function(t){var e,i=this,n=this.hls.config,r=this.retryCount<n.levelLoadingMaxRetry;if(r)if(this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(e=t.context)&&void 0!==e&&e.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return i.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return r},t}()},"./src/controller/base-stream-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/base-stream-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: State, default */function(t,e,i){"use strict";i.r(e),i.d(e,"State",(function(){return S})),i.d(e,"default",(function(){return C}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../task-loop */"./src/task-loop.ts"),a=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),o=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=i(/*! ../utils/logger */"./src/utils/logger.ts"),l=i(/*! ../events */"./src/events.ts"),c=i(/*! ../errors */"./src/errors.ts"),u=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),h=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=i(/*! ./level-helper */"./src/controller/level-helper.ts"),m=i(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),g=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),v=i(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=i(/*! ../types/loader */"./src/types/loader.ts");function b(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function x(t,e){return(x=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}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"},C=function(t){var e,i;function r(e,i,n){var r;return(r=t.call(this)||this).hls=void 0,r.fragPrevious=null,r.fragCurrent=null,r.fragmentTracker=void 0,r.transmuxer=null,r._state=S.STOPPED,r.media=void 0,r.mediaBuffer=void 0,r.config=void 0,r.bitrateTest=!1,r.lastCurrentTime=0,r.nextLoadPosition=0,r.startPosition=0,r.loadedmetadata=!1,r.fragLoadError=0,r.retryDate=0,r.levels=null,r.fragmentLoader=void 0,r.levelLastLoaded=null,r.startFragRequested=!1,r.decrypter=void 0,r.initPTS=[],r.onvseeking=null,r.onvended=null,r.logPrefix="",r.log=void 0,r.warn=void 0,r.logPrefix=n,r.log=s.logger.log.bind(s.logger,n+":"),r.warn=s.logger.warn.bind(s.logger,n+":"),r.hls=e,r.fragmentLoader=new m.default(e.config),r.fragmentTracker=i,r.config=e.config,r.decrypter=new g.default(e,e.config),e.on(l.Events.KEY_LOADED,r.onKeyLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r)),r}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,x(e,i);var C,k,E,w=r.prototype;return w.doTick=function(){this.onTickEnd()},w.onTickEnd=function(){},w.startLoad=function(t){},w.stopLoad=function(){this.fragmentLoader.abort();var t=this.fragCurrent;t&&this.fragmentTracker.removeFragment(t),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=S.STOPPED},w._streamEnded=function(t,e){var i=this.fragCurrent,n=this.fragmentTracker;if(!e.live&&i&&i.sn===e.endSN&&!t.nextStart){var r=n.getState(i);return r===a.FragmentState.PARTIAL||r===a.FragmentState.OK}return!1},w.onMediaAttached=function(t,e){var i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===S.STOPPED&&this.startLoad(n.startPosition)},w.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},w.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,i=this.media,r=this.mediaBuffer,a=this.state,s=i?i.currentTime:0,l=o.BufferHelper.bufferInfo(r||i,s,t.maxBufferHole);if(this.log("media seeking to "+(Object(n.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+a),a===S.ENDED)this.resetLoadingState();else if(e&&!l.len){var c=t.maxFragLookUpTolerance,u=e.start-c,h=s>e.start+e.duration+c;(s<u||h)&&(h&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.resetLoadingState())}i&&(this.lastCurrentTime=s),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()},w.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},w.onKeyLoaded=function(t,e){if(this.state===S.KEY_LOADING&&e.frag===this.fragCurrent&&this.levels){this.state=S.IDLE;var i=this.levels[e.frag.level].details;i&&this.loadFragment(e.frag,i,e.frag.start)}},w.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},w.onHandlerDestroyed=function(){this.state=S.STOPPED,this.hls.off(l.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,t.prototype.onHandlerDestroyed.call(this)},w.loadKey=function(t,e){this.log("Loading key for "+t.sn+" of ["+e.startSN+"-"+e.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=S.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(l.Events.KEY_LOADING,{frag:t})},w.loadFragment=function(t,e,i){this._loadFragForPlayback(t,e,i)},w._loadFragForPlayback=function(t,e,i){var n=this;this._doFragLoad(t,e,i,(function(e){if(n.fragContextChanged(t))return n.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void n.fragmentTracker.removeFragment(t);t.stats.chunkCount++,n._handleFragmentLoadProgress(e)})).then((function(e){if(e){n.fragLoadError=0;var i=n.state;if(!n.fragContextChanged(t))return"payload"in e&&(n.log("Loaded fragment "+t.sn+" of level "+t.level),n.hls.trigger(l.Events.FRAG_LOADED,e),n.state===S.BACKTRACKING)?(n.fragmentTracker.backtrack(t,e),void n.resetFragmentLoading(t)):void n._handleFragmentLoadComplete(e);(i===S.FRAG_LOADING||i===S.BACKTRACKING||!n.fragCurrent&&i===S.PARSING)&&(n.fragmentTracker.removeFragment(t),n.state=S.IDLE)}})).catch((function(e){n.warn(e),n.resetFragmentLoading(t)}))},w.flushMainBuffer=function(t,e,i){if(void 0===i&&(i=null),t-e){var n={startOffset:t,endOffset:e,type:i};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,n)}},w._loadInitSegment=function(t){var e=this;this._doFragLoad(t).then((function(i){if(!i||e.fragContextChanged(t)||!e.levels)throw new Error("init load aborted");return i})).then((function(i){var n=e.hls,r=i.payload,a=t.decryptdata;if(r&&r.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var o=self.performance.now();return e.decrypter.webCryptoDecrypt(new Uint8Array(r),a.key.buffer,a.iv.buffer).then((function(e){var r=self.performance.now();return n.trigger(l.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:o,tdecrypt:r}}),i.payload=e,i}))}return i})).then((function(i){var n=e.fragCurrent,r=e.hls,a=e.levels;if(!a)throw new Error("init load aborted, missing levels");var o=a[t.level].details;console.assert(o,"Level details are defined when init segment is loaded");var s=t.stats;e.state=S.IDLE,e.fragLoadError=0,t.data=new Uint8Array(i.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),i.frag===n&&r.trigger(l.Events.FRAG_BUFFERED,{stats:s,frag:n,part:null,id:t.type}),e.tick()})).catch((function(i){e.warn(i),e.resetFragmentLoading(t)}))},w.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},w.fragBufferedComplete=function(t,e){var i=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" "+v.default.toString(o.BufferHelper.getBuffered(i))),this.state=S.IDLE,this.tick()},w._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var i=t.frag,n=t.part,r=t.partsLoaded,a=!r||0===r.length||r.some((function(t){return!t})),o=new u.ChunkMetadata(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!a);e.flush(o)}},w._handleFragmentLoadProgress=function(t){},w._doFragLoad=function(t,e,i,r){var a=this;if(void 0===i&&(i=null),!this.levels)throw new Error("frag load aborted, missing levels");if(i=Math.max(t.start,i||0),this.config.lowLatencyMode&&e){var o=e.partList;if(o&&r){i>t.end&&e.fragmentHint&&(t=e.fragmentHint);var s=this.getNextPart(o,t,i);if(s>-1){var c=o[s];return this.log("Loading part sn: "+t.sn+" p: "+c.index+" cc: "+t.cc+" of playlist ["+e.startSN+"-"+e.endSN+"] parts [0-"+s+"-"+(o.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,part:o[s],targetBufferTime:i}),this.doFragPartsLoad(t,o,s,r).catch((function(t){return a.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(o,i))return Promise.resolve(null)}}return this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(e?"of ["+e.startSN+"-"+e.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),Object(n.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragmentLoader.load(t,r).catch((function(t){return a.handleFragLoadError(t)}))},w.doFragPartsLoad=function(t,e,i,n){var r=this;return new Promise((function(a,o){var s=[];!function i(c){var u=e[c];r.fragmentLoader.loadPart(t,u,n).then((function(n){s[u.index]=n;var o=n.part;r.hls.trigger(l.Events.FRAG_LOADED,n);var h=e[c+1];if(!h||h.fragment!==t)return a({frag:t,part:o,partsLoaded:s});i(c+1)})).catch(o)}(i)}))},w.handleFragLoadError=function(t){var e=t.data;return e&&e.details===c.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(l.Events.ERROR,e),null},w._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===S.PARSING){var i=e.frag,n=e.part,r=e.level,a=self.performance.now();i.stats.parsing.end=a,n&&(n.stats.parsing.end=a),this.updateLevelTiming(i,n,r,t.partial)}else this.fragCurrent||(this.state=S.IDLE)},w.getCurrentContext=function(t){var e=this.levels,i=t.level,n=t.sn,r=t.part;if(!e||!e[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var a=e[i],o=r>-1?Object(p.getPartWith)(a,n,r):null,s=o?o.fragment:Object(p.getFragmentWithSN)(a,n,this.fragCurrent);return s?{frag:s,part:o,level:a}:null},w.bufferFragmentData=function(t,e,i,n){if(t&&this.state===S.PARSING){var r=t.data1,a=t.data2,o=r;if(r&&a&&(o=Object(h.appendUint8Array)(r,a)),o&&o.length){var s={type:t.type,frag:e,part:i,chunkMeta:n,parent:e.type,data:o};this.hls.trigger(l.Events.BUFFER_APPENDING,s),t.dropped&&t.independent&&!i&&this.flushBufferGap(e)}}},w.flushBufferGap=function(t){var e=this.media;if(e)if(o.BufferHelper.isBuffered(e,e.currentTime)){var i=e.currentTime,n=o.BufferHelper.bufferInfo(e,i,0),r=t.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),s=Math.max(Math.min(t.start-a,n.end-a),i+a);t.start-s>a&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},w.getFwdBufferInfo=function(t,e){var i=this.config,r=this.getLoadPosition();if(!Object(n.isFiniteNumber)(r))return null;var a=o.BufferHelper.bufferInfo(t,r,i.maxBufferHole);if(0===a.len&&void 0!==a.nextStart){var s=this.fragmentTracker.getBufferedFrag(r,e);if(s&&a.nextStart<s.end)return o.BufferHelper.bufferInfo(t,r,Math.max(a.nextStart,i.maxBufferHole))}return a},w.getMaxBufferLength=function(t){var e,i=this.config;return e=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(e,i.maxMaxBufferLength)},w.reduceMaxBufferLength=function(t){var e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},w.getNextFragment=function(t,e){var i,n,r=e.fragments,a=r.length;if(!a)return null;var o,s=this.config,l=r[0].start;if(e.live){var c=s.initialLiveManifestSize;if(a<c)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+c+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(o=this.getInitialLiveFragment(e,r),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=l&&(o=r[0]);if(!o){var u=s.lowLatencyMode?e.partEnd:e.fragmentEnd;o=this.getFragmentAtPosition(t,u,e)}return null===(i=o)||void 0===i||!i.initSegment||null!==(n=o)&&void 0!==n&&n.initSegment.data||this.bitrateTest||(o=o.initSegment),o},w.getNextPart=function(t,e,i){for(var n=-1,r=!1,a=!0,o=0,s=t.length;o<s;o++){var l=t[o];if(a=a&&!l.independent,n>-1&&i<l.start)break;var c=l.loaded;!c&&(r||l.independent||a)&&l.fragment===e&&(n=o),r=c}return n},w.loadedEndOfParts=function(t,e){var i=t[t.length-1];return i&&e>i.start&&i.loaded},w.getInitialLiveFragment=function(t,e){var i=this.fragPrevious,n=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),n=Object(f.findFragmentByPDT)(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var r=i.sn+1;if(r>=t.startSN&&r<=t.endSN){var a=e[r-t.startSN];i.cc===a.cc&&(n=a,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=Object(f.findFragWithCC)(e,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n},w.getFragmentAtPosition=function(t,e,i){var n,r=this.config,o=this.fragPrevious,s=i.fragments,l=i.endSN,c=i.fragmentHint,u=r.maxFragLookUpTolerance,h=!!(r.lowLatencyMode&&i.partList&&c);if(h&&c&&!this.bitrateTest&&(s=s.concat(c),l=c.sn),t<e){var d=t>e-u?0:u;n=Object(f.findFragmentByPTS)(o,s,t,d)}else n=s[s.length-1];if(n){var p=n.sn-i.startSN,m=o&&n.level===o.level,g=s[p+1];if(this.fragmentTracker.getState(n)===a.FragmentState.BACKTRACKED){n=null;for(var v=p;s[v]&&this.fragmentTracker.getState(s[v])===a.FragmentState.BACKTRACKED;)n=o?s[v--]:s[--v];n||(n=g)}else o&&n.sn===o.sn&&!h&&m&&(n.sn<l&&this.fragmentTracker.getState(g)!==a.FragmentState.OK?(this.log("SN "+n.sn+" just loaded, load next one: "+g.sn),n=g):n=null)}return n},w.synchronizeToLiveEdge=function(t){var e=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,r=i.currentTime,a=t.fragments[0].start,o=t.edge,s=r>=a-e.maxFragLookUpTolerance&&r<=o;if(null!==n&&i.duration>n&&(r<n||!s)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!s&&i.readyState<4||r<o-l)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn("Playback: "+r.toFixed(3)+" is located too far from the end of live sliding playlist: "+o+", reset currentTime to : "+n.toFixed(3)),i.currentTime=n))}}},w.alignPlaylists=function(t,e){var i=this.levels,r=this.levelLastLoaded,a=this.fragPrevious,o=null!==r?i[r]:null,s=t.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,c=!e,u=t.alignedSliding&&Object(n.isFiniteNumber)(l);if(c||!u&&!l){Object(d.alignStream)(a,o,t);var h=t.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+s),h}return l},w.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},w.setStartPosition=function(t,e){var i=this.startPosition;if(i<e&&(i=-1),-1===i||-1===this.lastCurrentTime){var r=t.startTimeOffset;Object(n.isFiniteNumber)(r)?(i=e+r,r<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log("Start time offset "+r+" found in playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},w.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},w.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},w.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=S.IDLE)},w.onFragmentOrKeyLoadError=function(t,e){if(!e.fatal){var i=e.frag;if(i&&i.type===t){var n=this.fragCurrent;console.assert(n&&i.sn===n.sn&&i.level===n.level&&i.urlId===n.urlId,"Frag load error must match current frag to retry");var r=this.config;if(this.fragLoadError+1<=r.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(i.level))return;var a=Math.min(Math.pow(2,this.fragLoadError)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(s.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)}}},w.afterBufferFlushed=function(t,e,i){if(t){var n=o.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===S.ENDED&&this.resetLoadingState()}},w.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},w.resetLiveStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;if(null!=e&&e.live)return this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},w.updateLevelTiming=function(t,e,i,n){var r=this,a=i.details;console.assert(!!a,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(e,o){var s=t.elementaryStreams[o];if(s){var c=s.endPTS-s.startPTS;if(c<=0)return r.warn("Could not parse fragment "+t.sn+" "+o+" duration reliably ("+c+") resetting transmuxer to fallback to playlist timing"),r.resetTransmuxer(),e||!1;var u=n?0:Object(p.updateFragPTSDTS)(a,t,s.startPTS,s.endPTS,s.startDTS,s.endDTS);return r.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:o,frag:t,start:s.startPTS,end:s.endPTS}),!0}return e}),!1)?(this.state=S.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})):this.resetLoadingState()},w.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C=r,(k=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}])&&b(C.prototype,k),E&&b(C,E),r}(r.default)},"./src/controller/buffer-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/buffer-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return f}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../errors */"./src/errors.ts"),s=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=i(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),u=i(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),h=Object(l.getMediaSource)(),d=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=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 t=e.hls,i=e.media,n=e.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),i&&(e.updateMediaElementDuration(),t.trigger(r.Events.MEDIA_ATTACHED,{media:i})),n&&n.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null},e.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.BUFFER_RESET,this.onBufferReset,this),t.on(r.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(r.Events.BUFFER_EOS,this.onBufferEos,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(r.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(r.Events.FRAG_PARSED,this.onFragParsed,this),t.on(r.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.BUFFER_RESET,this.onBufferReset,this),t.off(r.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(r.Events.BUFFER_EOS,this.onBufferEos,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(r.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(r.Events.FRAG_PARSED,this.onFragParsed,this),t.off(r.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new u.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var i=this.media=e.media;if(i&&h){var n=this.mediaSource=new h;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,i=this._objectUrl;if(e){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){a.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):a.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(r.Events.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var i=t.sourceBuffer[e];try{i&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),t.sourceBuffer[e]=void 0)}catch(t){a.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var i=this,n=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(n){var r=i.tracks[t];if(r&&"function"==typeof r.buffer.changeType){var a=e[t],o=a.codec,s=a.levelCodec,l=a.container;if((r.levelCodec||r.codec).replace(d,"$1")!==(s||o).replace(d,"$1")){var c=l+";codecs="+(s||o);i.appendChangeType(t,c)}}}else i.pendingTracks[t]=e[t]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var i=this,n=this.operationQueue,r={execute:function(){var r=i.sourceBuffer[t];r&&(a.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),r.changeType(e)),n.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){a.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};n.append(r,t)},e.onBufferAppending=function(t,e){var i=this,n=this.hls,l=this.operationQueue,c=this.tracks,u=e.data,h=e.type,d=e.frag,f=e.part,p=e.chunkMeta,m=p.buffering[h],g=self.performance.now();m.start=g;var v=d.stats.buffering,y=f?f.stats.buffering:null;0===v.start&&(v.start=g),y&&0===y.start&&(y.start=g);var b=c.audio,x="audio"===h&&1===p.id&&"audio/mpeg"===(null==b?void 0:b.container),S={execute:function(){if(m.executeStart=self.performance.now(),x){var t=i.sourceBuffer[h];if(t){var e=d.start-t.timestampOffset;Math.abs(e)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+d.start+" (delta: "+e+") sn: "+d.sn+")"),t.timestampOffset=d.start)}}i.appendExecutor(u,h)},onStart:function(){},onComplete:function(){var t=self.performance.now();m.executeEnd=m.end=t,0===v.first&&(v.first=t),y&&0===y.first&&(y.first=t);var e=i.sourceBuffer,n={};for(var a in e)n[a]=s.BufferHelper.getBuffered(e[a]);i.appendError=0,i.hls.trigger(r.Events.BUFFER_APPENDED,{type:h,frag:d,part:f,chunkMeta:p,parent:d.type,timeRanges:n})},onError:function(t){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+h+" SourceBuffer",t);var e={type:o.ErrorTypes.MEDIA_ERROR,parent:d.type,details:o.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=o.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,e.details=o.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),n.trigger(r.Events.ERROR,e)}};l.append(S,h)},e.onBufferFlushing=function(t,e){var i=this,n=this.operationQueue,o=function(t){return{execute:i.removeExecutor.bind(i,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(r.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){a.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?n.append(o(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){n.append(o(t),t)}))},e.onFragParsed=function(t,e){var i=this,n=e.frag,o=e.part,s=[],l=o?o.elementaryStreams:n.elementaryStreams;l[c.ElementaryStreamTypes.AUDIOVIDEO]?s.push("audiovideo"):(l[c.ElementaryStreamTypes.AUDIO]&&s.push("audio"),l[c.ElementaryStreamTypes.VIDEO]&&s.push("video")),0===s.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers((function(){var t=self.performance.now();n.stats.buffering.end=t,o&&(o.stats.buffering.end=t);var e=o?o.stats:n.stats;i.hls.trigger(r.Events.FRAG_BUFFERED,{frag:n,part:o,stats:e,id:n.type})}),s)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var i=this;this.getSourceBufferTypes().reduce((function(t,n){var r=i.sourceBuffer[n];return e.type&&e.type!==n||r&&!r.ended&&(r.ended=!0,a.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS")),t&&!(r&&!r.ended)}),!0)&&this.blockBuffers((function(){var t=i.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var i=e.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,i=this.media,a=this.sourceBuffer;if(i&&null!==e){var o=this.getSourceBufferTypes();if(o.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(n.isFiniteNumber)(l)&&!(l<0)){var c=i.currentTime,u=e.levelTargetDuration,h=Math.max(l,u),d=Math.floor(c/u)*u-h;o.forEach((function(i){var n=a[i];if(n){var o=s.BufferHelper.getBuffered(n);o.length>0&&d>o.start(0)&&(t.trigger(r.Events.BACK_BUFFER_REACHED,{bufferEnd:d}),e.live&&t.trigger(r.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d}),t.trigger(r.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:i}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,i=this.media,r=this.mediaSource,o=t.fragments[0].start+t.totalduration,s=i.duration,l=Object(n.isFiniteNumber)(r.duration)?r.duration:0;t.live&&e.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(o>l&&o>s||!Object(n.isFiniteNumber)(s))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+o.toFixed(3)),r.duration=o)}},e.updateSeekableRange=function(t){var e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&null!=e&&e.setLiveSeekableRange){var n=Math.max(0,i[0].start),r=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,r)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,i=this.pendingTracks,n=Object.keys(i).length;if(n&&!t||2===n){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(0===a.length)return void this.hls.trigger(r.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var s in t)if(!e[s]){var l=t[s];if(!l)throw Error("source buffer exists for track "+s+", however track does not");var c=l.levelCodec||l.codec,u=l.container+";codecs="+c;a.logger.log("[buffer-controller]: creating sourceBuffer("+u+")");try{var h=e[s]=i.addSourceBuffer(u),d=s;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[s]={buffer:h,codec:c,container:l.container,levelCodec:l.levelCodec,id:l.id},n++}catch(t){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(r.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:u})}}n&&this.hls.trigger(r.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){a.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(r.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},e.removeExecutor=function(t,e,i){var r=this.media,o=this.mediaSource,s=this.operationQueue,l=this.sourceBuffer[t];if(!r||!o||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void s.shiftAndExecuteNext(t);var c=Object(n.isFiniteNumber)(r.duration)?r.duration:1/0,u=Object(n.isFiniteNumber)(o.duration)?o.duration:1/0,h=Math.max(0,e),d=Math.min(i,c,u);d>h?(a.logger.log("[buffer-controller]: Removing ["+h+","+d+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(h,d)):s.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var i=this.operationQueue,n=this.sourceBuffer[e];if(!n)return a.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(e);n.ended=!1,console.assert(!n.updating,e+" sourceBuffer must not be updating"),n.appendBuffer(t)},e.blockBuffers=function(t,e){var i=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var n=this.operationQueue,r=e.map((function(t){return n.appendBlocker(t)}));Promise.all(r).then((function(){t(),e.forEach((function(t){var e=i.sourceBuffer[t];e&&e.updating||n.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,i){var n=this.sourceBuffer[t];if(n){var r=i.bind(this,t);this.listeners[t].push({event:e,listener:r}),n.addEventListener(e,r)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return r}));var n=i(/*! ../utils/logger */"./src/utils/logger.ts"),r=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var i=this.queues[e];i.push(t),1===i.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,i=new Promise((function(t){e=t})),n={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,t),i},e.executeNext=function(t){var e=this.buffers,i=this.queues,r=e[t],a=i[t];if(a.length){var o=a[0];try{o.execute()}catch(e){n.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(e),r&&r.updating||(a.shift(),this.executeNext(t))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/cap-level-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts");function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=function(){function t(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e,i,a,o=t.prototype;return o.setStreamController=function(t){this.streamController=t},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 t=this.hls;t.on(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},o.unregisterListener=function(){var t=this.hls;t.off(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},o.onFpsDropLevelCapping=function(e,i){t.isLevelAllowed(i.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(i.droppedLevel)},o.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null},o.onManifestParsed=function(t,e){var i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onMediaDetaching=function(){this.stopCapping()},o.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},o.getMaxLevel=function(e){var i=this,n=this.hls.levels;if(!n.length)return-1;var r=n.filter((function(n,r){return t.isLevelAllowed(r,i.restrictedLevels)&&r<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},o.startCapping=function(){this.timer||(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 t=this.media,e={width:0,height:0};if(t){var i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,e.width||e.height||(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e},t.isLevelAllowed=function(t,e){return void 0===e&&(e=[]),-1===e.indexOf(t)},t.getMaxLevelByMediaSize=function(t,e,i){if(!t||!t.length)return-1;for(var n,r,a=t.length-1,o=0;o<t.length;o+=1){var s=t[o];if((s.width>=e||s.height>=i)&&(n=s,!(r=t[o+1])||n.width!==r.width||n.height!==r.height)){a=o;break}}return a},e=t,a=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(i=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&r(e.prototype,i),a&&r(e,a),t}();e.default=a},"./src/controller/cmcd-controller.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/controller/cmcd-controller.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return d}));var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../types/cmcd */"./src/types/cmcd.ts"),a=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function l(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),t}function c(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return u(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?u(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var d=function(){function t(e){var i=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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(t){try{i.apply(t,{ot:r.CMCDObjectType.MANIFEST,su:!i.initialized})}catch(t){o.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,n=i.hls.levels[e.level],a=i.getObjectType(e),s={d:1e3*e.duration,ot:a};a!==r.CMCDObjectType.VIDEO&&a!==r.CMCDObjectType.AUDIO&&a!=r.CMCDObjectType.MUXED||(s.br=n.bitrate/1e3,s.tb=i.getTopBandwidth(a),s.bl=i.getBufferLength(a)),i.apply(t,s)}catch(t){o.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var n=this.config=e.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||t.uuid(),this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(n.Events.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(n.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},e.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function(t,e){var i,n;this.audioBuffer=null===(i=e.tracks.audio)||void 0===i?void 0:i.buffer,this.videoBuffer=null===(n=e.tracks.video)||void 0===n?void 0:n.buffer},e.createData=function(){var t;return{v:r.CMCDVersion,sf:r.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function(e,i){void 0===i&&(i={}),h(i,this.createData());var n=i.ot===r.CMCDObjectType.INIT||i.ot===r.CMCDObjectType.VIDEO||i.ot===r.CMCDObjectType.MUXED;if(this.starved&&n&&(i.bs=!0,i.su=!0,this.starved=!1),null==i.su&&(i.su=this.buffering),this.useHeaders){var a=t.toHeaders(i);if(!Object.keys(a).length)return;e.headers||(e.headers={}),h(e.headers,a)}else{var o=t.toQuery(i);if(!o)return;e.url=t.appendQueryToUri(e.url,o)}},e.getObjectType=function(t){var e=t.type;return"subtitle"===e?r.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?r.CMCDObjectType.INIT:"audio"===e?r.CMCDObjectType.AUDIO:"main"===e?this.hls.audioTracks.length?r.CMCDObjectType.VIDEO:r.CMCDObjectType.MUXED:void 0},e.getTopBandwidth=function(t){for(var e,i=0,n=c(t===r.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels);!(e=n()).done;){var a=e.value;a.bitrate>i&&(i=a.bitrate)}return i>0?i:NaN},e.getBufferLength=function(t){var e=this.hls.media,i=t===r.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return i&&e?1e3*a.BufferHelper.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,i=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new i(t)}var n=t.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(t,i,n){e(t),this.loader.load(t,i,n)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},e.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,i=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new i(t)}var n=t.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(t,i,n){e(t),this.loader.load(t,i,n)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.substr(e.lastIndexOf("/")+1)},t.serialize=function(t){for(var e,i=[],n=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},r=function(t){return Math.round(t)},a=function(t){return 100*r(t/100)},o={br:r,d:r,bl:a,dl:a,mtp:a,nor:function(t){return encodeURIComponent(t)},rtp:a,tb:r},s=c(Object.keys(t||{}).sort());!(e=s()).done;){var l=e.value,u=t[l];if(n(u)&&!("v"===l&&1===u||"pr"==l&&1===u)){var h=o[l];h&&(u=h(u));var d=typeof u,f=void 0;f="ot"===l||"sf"===l||"st"===l?l+"="+u:"boolean"===d?l:"number"===d?l+"="+u:l+"="+JSON.stringify(u),i.push(f)}}return i.join(",")},t.toHeaders=function(e){for(var i={},n=["Object","Request","Session","Status"],r=[{},{},{},{}],a={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},o=0,s=Object.keys(e);o<s.length;o++){var l=s[o];r[null!=a[l]?a[l]:1][l]=e[l]}for(var c=0;c<r.length;c++){var u=t.serialize(r[c]);u&&(i["CMCD-"+n[c]]=u)}return i},t.toQuery=function(e){return"CMCD="+encodeURIComponent(t.serialize(e))},t.appendQueryToUri=function(t,e){if(!e)return t;var i=t.includes("?")?"&":"?";return""+t+i+e},t}()},"./src/controller/eme-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/eme-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var l=function(){function t(t){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=t,this._config=t.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var e,i,l,c=t.prototype;return c.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},c._registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c._unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},c.getLicenseServerUrl=function(t){switch(t){case o.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+t+'"')},c._attemptKeySystemAccess=function(t,e,i){var n=this,r=function(t,e,i,n){switch(t){case o.KeySystems.WIDEVINE:return function(t,e,i){var n={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||""})})),e.forEach((function(t){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||""})})),[n]}(e,i,n);default:throw new Error("Unknown key-system: "+t)}}(t,e,i,this._drmSystemOptions);a.logger.log("Requesting encrypted media key-system access");var s=this.requestMediaKeySystemAccess(t,r);this.mediaKeysPromise=s.then((function(e){return n._onMediaKeySystemAccessObtained(t,e)})),s.catch((function(e){a.logger.error('Failed to obtain key-system "'+t+'" access:',e)}))},c._onMediaKeySystemAccessObtained=function(t,e){var i=this;a.logger.log('Access for key-system "'+t+'" obtained');var n={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t};this._mediaKeysList.push(n);var r=Promise.resolve().then((function(){return e.createMediaKeys()})).then((function(e){return n.mediaKeys=e,a.logger.log('Media-keys created for key-system "'+t+'"'),i._onMediaKeysCreated(),e}));return r.catch((function(t){a.logger.error("Failed to create media-keys:",t)})),r},c._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach((function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),t._onNewMediaKeySession(e.mediaKeysSession))}))},c._onNewMediaKeySession=function(t){var e=this;a.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(i){e._onKeySessionMessage(t,i.message)}),!1)},c._onKeySessionMessage=function(t,e){a.logger.log("Got EME message event, creating license request"),this._requestLicense(e,(function(e){a.logger.log("Received license data (length: "+(e?e.byteLength:e)+"), updating key-session"),t.update(e)}))},c.onMediaEncrypted=function(t){var e=this;if(a.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var i=function(i){e._media&&(e._attemptSetMediaKeys(i),e._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(i).catch(i)},c._attemptSetMediaKeys=function(t){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});a.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},c._generateRequestWithPreferredKeySession=function(t,e){var i=this,o=this._mediaKeysList[0];if(!o)return a.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(o.mediaKeysSessionInitialized)a.logger.warn("Key-Session already initialized but requested again");else{var s=o.mediaKeysSession;if(!s)return a.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!e)return a.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});a.logger.log('Generating key-session request for "'+t+'" init data type'),o.mediaKeysSessionInitialized=!0,s.generateRequest(t,e).then((function(){a.logger.debug("Key-session generation succeeded")})).catch((function(t){a.logger.error("Error generating key-session request:",t),i.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},c._createLicenseXhr=function(t,e,i){var n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,t,e,i);var r=this._licenseXhrSetup;if(r)try{r.call(this.hls,n,t),r=void 0}catch(t){a.logger.error(t)}try{n.readyState||n.open("POST",t,!0),r&&r.call(this.hls,n,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return n},c._onLicenseRequestReadyStageChange=function(t,e,i,o){switch(t.readyState){case 4:if(200===t.status){this._requestLicenseFailureCount=0,a.logger.log("License request succeeded");var s=t.response,l=this._licenseResponseCallback;if(l)try{s=l.call(this.hls,t,e)}catch(t){a.logger.error(t)}o(s)}else{if(a.logger.error("License Request XHR failed ("+e+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var c=3-this._requestLicenseFailureCount+1;a.logger.warn("Retrying license request, "+c+" attempts left"),this._requestLicense(i,o)}}},c._generateLicenseRequestChallenge=function(t,e){switch(t.mediaKeySystemDomain){case o.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},c._requestLicense=function(t,e){a.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i)return a.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var o=this.getLicenseServerUrl(i.mediaKeySystemDomain),s=this._createLicenseXhr(o,t,e);a.logger.log("Sending license request to URL: "+o);var l=this._generateLicenseRequestChallenge(i,t);s.send(l)}catch(t){a.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.KEY_SYSTEM_ERROR,details:r.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},c.onMediaAttached=function(t,e){if(this._emeEnabled){var i=e.media;this._media=i,i.addEventListener("encrypted",this._onMediaEncrypted)}},c.onMediaDetached=function(){var t=this._media,e=this._mediaKeysList;t&&(t.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map((function(t){if(t.mediaKeysSession)return t.mediaKeysSession.close().catch((function(){}))}))).then((function(){return t.setMediaKeys(null)})).catch((function(){})))},c.onManifestParsed=function(t,e){if(this._emeEnabled){var i=e.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),n=e.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(o.KeySystems.WIDEVINE,i,n)}},e=t,(i=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&s(e.prototype,i),l&&s(e,l),t}();e.default=l},"./src/controller/fps-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/fps-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function t(t){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=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,i){var a=performance.now();if(e){if(this.lastTime){var o=a-this.lastTime,s=i-this.lastDroppedFrames,l=e-this.lastDecodedFrames,c=1e3*s/o,u=this.hls;if(u.trigger(n.Events.FPS_DROP,{currentDropped:s,currentDecoded:l,totalDroppedFrames:i}),c>0&&s>u.config.fpsDroppedMonitoringThreshold*l){var h=u.currentLevel;r.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=h)&&(h-=1,u.trigger(n.Events.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=i,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();e.default=a},"./src/controller/fragment-finders.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-finders.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,e,i){"use strict";i.r(e),i.d(e,"findFragmentByPDT",(function(){return a})),i.d(e,"findFragmentByPTS",(function(){return o})),i.d(e,"fragmentWithinToleranceTest",(function(){return s})),i.d(e,"pdtWithinToleranceTest",(function(){return l})),i.d(e,"findFragWithCC",(function(){return c}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function a(t,e,i){if(null===e||!Array.isArray(t)||!t.length||!Object(n.isFiniteNumber)(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;i=i||0;for(var r=0;r<t.length;++r){var a=t[r];if(l(e,i,a))return a}return null}function o(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var a=null;if(t?a=e[t.sn-e[0].sn+1]||null:0===i&&0===e[0].start&&(a=e[0]),a&&0===s(i,n,a))return a;var o=r.default.search(e,s.bind(null,i,n));return o||a}function s(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var n=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=t?1:i.start-n>t&&i.start?-1:0}function l(t,e,i){var n=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>t}function c(t,e){return r.default.search(t,(function(t){return t.cc<e?1:t.cc>e?-1:0}))}},"./src/controller/fragment-tracker.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-tracker.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: FragmentState, FragmentTracker */function(t,e,i){"use strict";i.r(e),i.d(e,"FragmentState",(function(){return n})),i.d(e,"FragmentTracker",(function(){return o}));var n,r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(n||(n={}));var o=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(r.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(r.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(r.Events.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(r.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(r.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(r.Events.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){if(e===a.PlaylistLevelType.MAIN){var i=this.activeFragment,n=this.activeParts;if(!i)return null;if(n)for(var r=n.length;r--;){var o=n[r],s=o?o.end:i.appendedPTS;if(o.start<=t&&void 0!==s&&t<=s)return r>9&&(this.activeParts=n.slice(r-9)),o}else if(i.start<=t&&void 0!==i.appendedPTS&&t<=i.appendedPTS)return i}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var i=this.fragments,n=Object.keys(i),r=n.length;r--;){var a=i[n[r]];if((null==a?void 0:a.body.type)===e&&a.buffered){var o=a.body;if(o.start<=t&&t<=o.end)return o}}return null},e.detectEvictedFragments=function(t,e,i){var n=this;Object.keys(this.fragments).forEach((function(r){var a=n.fragments[r];if(a)if(a.buffered){var o=a.range[t];o&&o.time.some((function(t){var i=!n.isTimeBuffered(t.startPTS,t.endPTS,e);return i&&n.removeFragment(a.body),i}))}else a.body.type===i&&n.removeFragment(a.body)}))},e.detectPartialFragments=function(t){var e=this,i=this.timeRanges,n=t.frag,r=t.part;if(i&&"initSegment"!==n.sn){var a=l(n),o=this.fragments[a];o&&(Object.keys(i).forEach((function(t){var a=n.elementaryStreams[t];if(a){var s=i[t],l=null!==r||!0===a.partial;o.range[t]=e.getBufferedTimes(n,r,l,s)}})),o.backtrack=o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},e.fragBuffered=function(t){var e=l(t),i=this.fragments[e];i&&(i.backtrack=i.loaded=null,i.buffered=!0)},e.getBufferedTimes=function(t,e,i,n){for(var r={time:[],partial:i},a=e?e.start:t.start,o=e?e.end:t.end,s=t.minEndPTS||o,l=t.maxStartPTS||a,c=0;c<n.length;c++){var u=n.start(c)-this.bufferPadding,h=n.end(c)+this.bufferPadding;if(l>=u&&s<=h){r.time.push({startPTS:Math.max(a,n.start(c)),endPTS:Math.min(o,n.end(c))});break}if(a<h&&o>u)r.partial=!0,r.time.push({startPTS:Math.max(a,n.start(c)),endPTS:Math.min(o,n.end(c))});else if(o<=u)break}return r},e.getPartialFragment=function(t){var e,i,n,r=null,a=0,o=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(c){var u=l[c];u&&s(u)&&(i=u.body.start-o,n=u.body.end+o,t>=i&&t<=n&&(e=Math.min(t-i,n-t),a<=e&&(r=u.body,a=e)))})),r},e.getState=function(t){var e=l(t),i=this.fragments[e];return i?i.buffered?s(i)?n.PARTIAL:n.OK:i.backtrack?n.BACKTRACKED:n.APPENDING:n.NOT_LOADED},e.backtrack=function(t,e){var i=l(t),n=this.fragments[i];if(!n||n.backtrack)return null;var r=n.backtrack=e||n.loaded;return n.loaded=null,r},e.getBacktrackData=function(t){var e=l(t),i=this.fragments[e];if(i){var n,r=i.backtrack;if(null!=r&&null!==(n=r.payload)&&void 0!==n&&n.byteLength)return r;this.removeFragment(t)}return null},e.isTimeBuffered=function(t,e,i){for(var n,r,a=0;a<i.length;a++){if(n=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,t>=n&&e<=r)return!0;if(e<=n)return!1}return!1},e.onFragLoaded=function(t,e){var i=e.frag,n=e.part;if("initSegment"!==i.sn&&!i.bitrateTest&&!n){var r=l(i);this.fragments[r]={body:i,loaded:e,backtrack:null,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var i=this,n=e.frag,r=e.part,o=e.timeRanges;if(n.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=n,r){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(r)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach((function(t){var e=o[t];if(i.detectEvictedFragments(t,e),!r)for(var a=0;a<e.length;a++)n.appendedPTS=Math.max(e.end(a),n.appendedPTS||0)}))},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=l(t);return!!this.fragments[e]},e.removeFragmentsInRange=function(t,e,i){var n=this;Object.keys(this.fragments).forEach((function(r){var a=n.fragments[r];if(a&&a.buffered){var o=a.body;o.type===i&&o.start<e&&o.end>t&&n.removeFragment(o)}}))},e.removeFragment=function(t){var e=l(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),delete this.fragments[e]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function s(t){var e,i;return t.buffered&&((null===(e=t.range.video)||void 0===e?void 0:e.partial)||(null===(i=t.range.audio)||void 0===i?void 0:i.partial))}function l(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/gap-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,e,i){"use strict";i.r(e),i.d(e,"STALL_MINIMUM_DURATION_MS",(function(){return s})),i.d(e,"MAX_START_GAP_JUMP",(function(){return l})),i.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return c})),i.d(e,"SKIP_BUFFER_RANGE_START",(function(){return u})),i.d(e,"default",(function(){return h}));var n=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),r=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../events */"./src/events.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=250,l=2,c=.1,u=.05,h=function(){function t(t,e,i,n){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=t,this.media=e,this.fragmentTracker=i,this.hls=n}var e=t.prototype;return e.destroy=function(){this.hls=this.fragmentTracker=this.media=null},e.poll=function(t){var e=this.config,i=this.media,r=this.stalled,a=i.currentTime,c=i.seeking,u=this.seeking&&!c,h=!this.seeking&&c;if(this.seeking=c,a===t){if((h||u)&&(this.stalled=null),!i.paused&&!i.ended&&0!==i.playbackRate&&n.BufferHelper.getBuffered(i).length){var d=n.BufferHelper.bufferInfo(i,a,0),f=d.len>0,p=d.nextStart||0;if(f||p){if(c){var m=d.len>l,g=!p||p-a>l&&!this.fragmentTracker.getPartialFragment(a);if(m||g)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var v,y=Math.max(p,d.start||0)-a,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,x=(null==b||null===(v=b.details)||void 0===v?void 0:v.live)?2*b.details.targetduration:l;if(y>0&&y<=x)return void this._trySkipBufferHole(null)}var S=self.performance.now();if(null!==r){var C=S-r;!c&&C>=s&&this._reportStall(d.len);var k=n.BufferHelper.bufferInfo(i,a,e.maxBufferHole);this._tryFixBufferStall(k,C)}else this.stalled=S}}}else if(this.moved=!0,null!==r){if(this.stallReported){var E=self.performance.now()-r;o.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},e._tryFixBufferStall=function(t,e){var i=this.config,n=this.fragmentTracker,r=this.media.currentTime,a=n.getPartialFragment(r);a&&this._trySkipBufferHole(a)||t.len>i.maxBufferHole&&e>1e3*i.highBufferWatchdogPeriod&&(o.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},e._reportStall=function(t){var e=this.hls,i=this.media;this.stallReported||(this.stallReported=!0,o.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer (buffer="+t+")"),e.trigger(a.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t}))},e._trySkipBufferHole=function(t){for(var e=this.config,i=this.hls,s=this.media,l=s.currentTime,h=0,d=n.BufferHelper.getBuffered(s),f=0;f<d.length;f++){var p=d.start(f);if(l+e.maxBufferHole>=h&&l<p){var m=Math.max(p+u,s.currentTime+c);return o.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+m),this.moved=!0,this.stalled=null,s.currentTime=m,t&&i.trigger(a.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+m,frag:t}),m}h=d.end(f)}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,i=this.media,n=i.currentTime,s=(this.nudgeRetry||0)+1;if(this.nudgeRetry=s,s<t.nudgeMaxRetry){var l=n+s*t.nudgeOffset;o.logger.warn("Nudging 'currentTime' from "+n+" to "+l),i.currentTime=l,e.trigger(a.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else o.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+t.nudgeMaxRetry+" nudges"),e.trigger(a.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},t}()},"./src/controller/id3-track-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/id3-track-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=i(/*! ../demux/id3 */"./src/demux/id3.ts"),o=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners()},e._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(Object(r.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var i=t[e];if("metadata"===i.kind&&"id3"===i.label)return Object(r.sendAddTrackEvent)(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var i=e.frag,n=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var r=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,o=0;o<n.length;o++){var s=a.getID3Frames(n[o].data);if(s){var l=n[o].pts,c=o<n.length-1?n[o+1].pts:i.end;c-l<=0&&(c=l+.25);for(var u=0;u<s.length;u++){var h=s[u];if(!a.isTimeStampFrame(h)){var d=new r(l,c,"");d.value=h,this.id3Track.addCue(d)}}}}}},e.onBufferFlushing=function(t,e){var i=e.startOffset,n=e.endOffset,a=e.type;if(!a||"audio"===a){var o=this.id3Track;o&&Object(r.removeCuesInRange)(o,i,n)}},t}();e.default=o},"./src/controller/latency-controller.ts":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/controller/latency-controller.ts ***!
|
|
|
\**********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return s}));var n=i(/*! ../errors */"./src/errors.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var s=function(){function t(t){var e=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 e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var e,i,s,l=t.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(r.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(r.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(r.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(r.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(r.Events.ERROR,this.onError)},l.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(t,e){var i=e.details;this.levelDetails=i,i.advanced&&this.timeupdate(),!i.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(t,e){e.details===n.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var i=this.computeLatency();if(null!==i){this._latency=i;var n=this.config,r=n.lowLatencyMode,a=n.maxLiveSyncPlaybackRate;if(r&&1!==a){var o=this.targetLatency;if(null!==o){var s=i-o,l=s<Math.min(this.maxLatency,o+e.targetduration);if(e.live&&l&&s>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,a)),u=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;t.playbackRate=Math.min(c,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},l.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},e=t,(i=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,i=t.partHoldBack,n=t.targetduration,r=this.config,a=r.liveSyncDuration,o=r.liveSyncDurationCount,s=r.lowLatencyMode,l=this.hls.userConfig,c=s&&i||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===c)&&(c=void 0!==a?a:o*n);var u=n;return c+Math.min(1*this.stallCount,u)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(null===t||null===e||null===i)return null;var n=i.edge,r=t-e-this.edgeStalled,a=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,r),o)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var i=t.buffered.length;return i?t.buffered.end(i-1):e.edge-this.currentTime}}])&&o(e.prototype,i),s&&o(e,s),t}()},"./src/controller/level-controller.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/level-controller.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return p}));var n=i(/*! ../types/level */"./src/types/level.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../errors */"./src/errors.ts"),o=i(/*! ../utils/codecs */"./src/utils/codecs.ts"),s=i(/*! ./level-helper */"./src/controller/level-helper.ts"),l=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts");function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),p=function(t){var e,i;function l(e){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}i=t,(e=l).prototype=Object.create(i.prototype),e.prototype.constructor=e,d(e,i);var p,m,g,v=l.prototype;return v._registerListeners=function(){var t=this.hls;t.on(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(r.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(r.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(r.Events.ERROR,this.onError,this)},v._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(r.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(r.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(r.Events.ERROR,this.onError,this)},v.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},v.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},v.onManifestLoaded=function(t,e){var i,l,c=[],u=[],h=[],d={},p=!1,m=!1,g=!1;if(e.levels.forEach((function(t){var e=t.attrs;p=p||!(!t.width||!t.height),m=m||!!t.videoCodec,g=g||!!t.audioCodec,f&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var i=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(l=d[i])?l.url.push(t.url):(l=new n.Level(t),d[i]=l,c.push(l)),e&&(e.AUDIO&&Object(s.addGroupId)(l,"audio",e.AUDIO),e.SUBTITLES&&Object(s.addGroupId)(l,"text",e.SUBTITLES))})),(p||m)&&g&&(c=c.filter((function(t){var e=t.videoCodec,i=t.width,n=t.height;return!!e||!(!i||!n)}))),c=c.filter((function(t){var e=t.audioCodec,i=t.videoCodec;return(!e||Object(o.isCodecSupportedInMp4)(e,"audio"))&&(!i||Object(o.isCodecSupportedInMp4)(i,"video"))})),e.audioTracks&&(u=e.audioTracks.filter((function(t){return!t.audioCodec||Object(o.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(s.assignTrackIdsByGroup)(u)),e.subtitles&&(h=e.subtitles,Object(s.assignTrackIdsByGroup)(h)),c.length>0){i=c[0].bitrate,c.sort((function(t,e){return t.bitrate-e.bitrate})),this._levels=c;for(var v=0;v<c.length;v++)if(c[v].bitrate===i){this._firstLevel=v,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+i);break}var y=g&&!m,b={levels:c,audioTracks:u,subtitleTracks:h,firstLevel:this._firstLevel,stats:e.stats,audio:g,video:m,altAudio:!y&&u.some((function(t){return!!t.url}))};this.hls.trigger(r.Events.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(r.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},v.onError=function(e,i){if(t.prototype.onError.call(this,e,i),!i.fatal){var n=i.context,r=this._levels[this.currentLevelIndex];if(n&&(n.type===c.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&n.groupId===r.audioGroupIds[r.urlId]||n.type===c.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&n.groupId===r.textGroupIds[r.urlId]))this.redundantFailover(this.currentLevelIndex);else{var o,s=!1,l=!0;switch(i.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:if(i.frag){var u=this._levels[i.frag.level];u?(u.fragmentError++,u.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=i.frag.level)):o=i.frag.level}break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:n&&(n.deliveryDirectives&&(l=!1),o=n.level),s=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:o=i.level,s=!0}void 0!==o&&this.recoverLevel(i,o,s,l)}}},v.recoverLevel=function(t,e,i,n){var r=t.details,a=this._levels[e];if(a.loadError++,i){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(n){var o=a.url.length;if(o>1&&a.loadError<o)t.levelRetry=!0,this.redundantFailover(e);else if(-1===this.manualLevelIndex){var s=0===e?this._levels.length-1:e-1;this.currentLevelIndex!==s&&0===this._levels[s].loadError&&(this.warn(r+": switch to "+s),t.levelRetry=!0,this.hls.nextAutoLevel=s)}}},v.redundantFailover=function(t){var e=this._levels[t],i=e.url.length;if(i>1){var n=(e.urlId+1)%i;this.warn("Switching to redundant URL-id "+n),this._levels.forEach((function(t){t.urlId=n})),this.level=t}},v.onFragLoaded=function(t,e){var i=e.frag;if(void 0!==i&&i.type===c.PlaylistLevelType.MAIN){var n=this._levels[i.level];void 0!==n&&(n.fragmentError=0,n.loadError=0)}},v.onLevelLoaded=function(t,e){var i,n,r=e.level,a=e.details,o=this._levels[r];if(!o)return this.warn("Invalid level index "+r),void(null!==(n=e.deliveryDirectives)&&void 0!==n&&n.skip&&(a.deltaUpdateFailed=!0));r===this.currentLevelIndex?(0===o.fragmentError&&(o.loadError=0,this.retryCount=0),this.playlistLoaded(r,e,o.details)):null!==(i=e.deliveryDirectives)&&void 0!==i&&i.skip&&(a.deltaUpdateFailed=!0)},v.onAudioTrackSwitched=function(t,e){var i=this.hls.levels[this.currentLevelIndex];if(i&&i.audioGroupIds){for(var n=-1,r=this.hls.audioTracks[e.id].groupId,a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===r){n=a;break}n!==i.urlId&&(i.urlId=n,this.startLoad())}},v.loadPlaylist=function(t){var e=this.currentLevelIndex,i=this._levels[e];if(this.canLoad&&i&&i.url.length>0){var n=i.urlId,a=i.url[n];if(t)try{a=t.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+e+(t?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+n+" "+a),this.clearTimer(),this.hls.trigger(r.Events.LEVEL_LOADING,{url:a,level:e,id:n,deliveryDirectives:t||null})}},v.removeLevel=function(t,e){var i=function(t,i){return i!==e},n=this._levels.filter((function(n,r){return r!==t||n.url.length>1&&void 0!==e&&(n.url=n.url.filter(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0)})).map((function(t,e){var i=t.details;return null!=i&&i.fragments&&i.fragments.forEach((function(t){t.level=e})),t}));this._levels=n,this.hls.trigger(r.Events.LEVELS_UPDATED,{levels:n})},p=l,(m=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e,i=this._levels;if(0!==i.length&&(this.currentLevelIndex!==t||null===(e=i[t])||void 0===e||!e.details)){if(t<0||t>=i.length){var n=t<0;if(this.hls.trigger(r.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:n,reason:"invalid level idx"}),n)return;t=Math.min(t,i.length-1)}this.clearTimer();var o=this.currentLevelIndex,s=i[o],l=i[t];this.log("switching to level "+t+" from "+o),this.currentLevelIndex=t;var c=u({},l,{level:t,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete c._urlId,this.hls.trigger(r.Events.LEVEL_SWITCHING,c);var h=l.details;if(!h||h.live){var d=this.switchParams(l.uri,null==s?void 0:s.details);this.loadPlaylist(d)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&h(p.prototype,m),g&&h(p,g),l}(l.default)},"./src/controller/level-helper.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/controller/level-helper.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,e,i){"use strict";i.r(e),i.d(e,"addGroupId",(function(){return a})),i.d(e,"assignTrackIdsByGroup",(function(){return o})),i.d(e,"updatePTS",(function(){return s})),i.d(e,"updateFragPTSDTS",(function(){return c})),i.d(e,"mergeDetails",(function(){return u})),i.d(e,"mapPartIntersection",(function(){return h})),i.d(e,"mapFragmentIntersection",(function(){return d})),i.d(e,"adjustSliding",(function(){return f})),i.d(e,"addSliding",(function(){return p})),i.d(e,"computeReloadInterval",(function(){return m})),i.d(e,"getFragmentWithSN",(function(){return g})),i.d(e,"getPartWith",(function(){return v}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,e,i){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(i);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(i)}}function o(t){var e={};t.forEach((function(t){var i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++}))}function s(t,e,i){l(t[e],t[i])}function l(t,e){var i=e.startPTS;if(Object(n.isFiniteNumber)(i)){var r,a=0;e.sn>t.sn?(a=i-t.start,r=t):(a=t.start-i,r=e),r.duration!==a&&(r.duration=a)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function c(t,e,i,a,o,s){a-i<=0&&(r.logger.warn("Fragment should have a positive duration",e),a=i+e.duration,s=o+e.duration);var c=i,u=a,h=e.startPTS,d=e.endPTS;if(Object(n.isFiniteNumber)(h)){var f=Math.abs(h-i);Object(n.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(f,e.deltaPTS):e.deltaPTS=f,c=Math.max(i,h),i=Math.min(i,h),o=Math.min(o,e.startDTS),u=Math.min(a,d),a=Math.max(a,d),s=Math.max(s,e.endDTS)}e.duration=a-i;var p=i-e.start;e.appendedPTS=a,e.start=e.startPTS=i,e.maxStartPTS=c,e.startDTS=o,e.endPTS=a,e.minEndPTS=u,e.endDTS=s;var m,g=e.sn;if(!t||g<t.startSN||g>t.endSN)return 0;var v=g-t.startSN,y=t.fragments;for(y[v]=e,m=v;m>0;m--)l(y[m],y[m-1]);for(m=v;m<y.length-1;m++)l(y[m],y[m+1]);return t.fragmentHint&&l(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,p}function u(t,e){for(var i=null,a=t.fragments,o=a.length-1;o>=0;o--){var s=a[o].initSegment;if(s){i=s;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var l,u=0;if(d(t,e,(function(t,r){t.relurl&&(u=t.cc-r.cc),Object(n.isFiniteNumber)(t.startPTS)&&Object(n.isFiniteNumber)(t.endPTS)&&(r.start=r.startPTS=t.startPTS,r.startDTS=t.startDTS,r.appendedPTS=t.appendedPTS,r.maxStartPTS=t.maxStartPTS,r.endPTS=t.endPTS,r.endDTS=t.endDTS,r.minEndPTS=t.minEndPTS,r.duration=t.endPTS-t.startPTS,r.duration&&(l=r),e.PTSKnown=e.alignedSliding=!0),r.elementaryStreams=t.elementaryStreams,r.loader=t.loader,r.stats=t.stats,r.urlId=t.urlId,t.initSegment&&(r.initSegment=t.initSegment,i=t.initSegment)})),i&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=i)||void 0===e?void 0:e.relurl)||(t.initSegment=i)})),e.skippedSegments&&(e.deltaUpdateFailed=e.fragments.some((function(t){return!t})),e.deltaUpdateFailed)){r.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var p=e.skippedSegments;p--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}var m=e.fragments;if(u){r.logger.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<m.length;g++)m[g].cc+=u}e.skippedSegments&&(e.startCC=e.fragments[0].cc),h(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),l?c(e,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):f(t,e),m.length&&(e.totalduration=e.edge-m[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var v=e.advancedDateTime;if(e.advanced&&v){var y=e.edge;e.driftStart||(e.driftStartTime=v,e.driftStart=y),e.driftEndTime=v,e.driftEnd=y}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function h(t,e,i){if(t&&e)for(var n=0,r=0,a=t.length;r<=a;r++){var o=t[r],s=e[r+n];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?i(o,s):n--}}function d(t,e,i){for(var n=e.skippedSegments,r=Math.max(t.startSN,e.startSN)-e.startSN,a=(t.fragmentHint?1:0)+(n?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,o=e.startSN-t.startSN,s=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,c=r;c<=a;c++){var u=l[o+c],h=s[c];n&&!h&&c<n&&(h=e.fragments[c]=u),u&&h&&i(u,h)}}function f(t,e){var i=e.startSN+e.skippedSegments-t.startSN,n=t.fragments;i<0||i>=n.length||p(e,n[i].start)}function p(t,e){if(e){for(var i=t.fragments,n=t.skippedSegments;n<i.length;n++)i[n].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function m(t,e){var i,n=1e3*t.levelTargetDuration,r=n/2,a=t.age,o=a>0&&a<3*n,s=e.loading.end-e.loading.start,l=t.availabilityDelay;if(!1===t.updated)if(o){var c=333*t.misses;i=Math.max(Math.min(r,2*s),c),t.availabilityDelay=(t.availabilityDelay||0)+i}else i=r;else o?(l=Math.min(l||n/2,a),t.availabilityDelay=l,i=l+n-a):i=n-s;return Math.round(i)}function g(t,e,i){if(!t||!t.details)return null;var n=t.details,r=n.fragments[e-n.startSN];return r||((r=n.fragmentHint)&&r.sn===e?r:e<n.startSN&&i&&i.sn===e?i:null)}function v(t,e,i){if(!t||!t.details)return null;var n=t.details.partList;if(n)for(var r=n.length;r--;){var a=n[r];if(a.index===i&&a.fragment.sn===e)return a}return null}},"./src/controller/stream-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/stream-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=i(/*! ../is-supported */"./src/is-supported.ts"),o=i(/*! ../events */"./src/events.ts"),s=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),u=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),h=i(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),d=i(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=i(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=i(/*! ../errors */"./src/errors.ts"),m=i(/*! ../utils/logger */"./src/utils/logger.ts");function g(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var y=function(t){var e,i;function y(e,i){var n;return(n=t.call(this,e,i,"[stream-controller]")||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.stalled=!1,n.couldBacktrack=!1,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}i=t,(e=y).prototype=Object.create(i.prototype),e.prototype.constructor=e,v(e,i);var b,x,S,C=y.prototype;return C._registerListeners=function(){var t=this.hls;t.on(o.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(o.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(o.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(o.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(o.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(o.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(o.Events.ERROR,this.onError,this),t.on(o.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(o.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(o.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(o.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(o.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(o.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C._unregisterListeners=function(){var t=this.hls;t.off(o.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(o.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(o.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(o.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(o.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(o.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(o.Events.ERROR,this.onError,this),t.off(o.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(o.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(o.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(o.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(o.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(o.Events.FRAG_BUFFERED,this.onFragBuffered,this)},C.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},C.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var n=i.startLevel;-1===n&&(i.config.testBandwidth?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=r.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=r.State.STOPPED},C.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},C.doTick=function(){switch(this.state){case r.State.IDLE:this.doTickIdle();break;case r.State.WAITING_LEVEL:var t,e=this.levels,i=this.level,n=null==e||null===(t=e[i])||void 0===t?void 0:t.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=r.State.IDLE;break}break;case r.State.FRAG_LOADING_WAITING_RETRY:var a,o=self.performance.now(),s=this.retryDate;(!s||o>=s||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=r.State.IDLE)}this.onTickEnd()},C.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},C.doTickIdle=function(){var t,e,i=this.hls,n=this.levelLastLoaded,a=this.levels,s=this.media,h=i.config,d=i.nextLoadLevel;if(null!==n&&(s||!this.startFragRequested&&h.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&a&&a[d]){var f=a[d];this.level=i.nextLoadLevel=d;var p=f.details;if(!p||this.state===r.State.WAITING_LEVEL||p.live&&this.levelLastLoaded!==d)this.state=r.State.WAITING_LEVEL;else{var m=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:s,c.PlaylistLevelType.MAIN);if(null!==m&&!(m.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(m,p)){var g={};return this.altAudio&&(g.type="video"),this.hls.trigger(o.Events.BUFFER_EOS,g),void(this.state=r.State.ENDED)}var v=m.end,y=this.getNextFragment(v,p);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn){var b=y.sn-p.startSN;b>1&&(y=p.fragments[b-1],this.fragmentTracker.removeFragment(y))}if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>v){var x=this.audioOnly&&!this.altAudio?u.ElementaryStreamTypes.AUDIO:u.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(s,x,c.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,p)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(t=y.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=y.decryptdata)&&void 0!==e&&e.key?this.loadFragment(y,p,v):this.loadKey(y,p))}}}},C.loadFragment=function(e,i,n){var r,a=this.fragmentTracker.getState(e);if(this.fragCurrent=e,a===l.FragmentState.BACKTRACKED){var o=this.fragmentTracker.getBacktrackData(e);if(o)return this._handleFragmentLoadProgress(o),void this._handleFragmentLoadComplete(o);a=l.FragmentState.NOT_LOADED}a===l.FragmentState.NOT_LOADED||a===l.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,i,n)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null===(r=this.media)||void 0===r?void 0:r.buffered.length)&&this.fragmentTracker.removeAllFragments()},C.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,c.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},C.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,c.PlaylistLevelType.MAIN)},C.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},C.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},C.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var i,n=this.getAppendedFrag(e.currentTime);if(n&&n.start>1&&this.flushMainBuffer(0,n.start-1),!e.paused&&t){var r=t[this.hls.nextLoadLevel],a=this.fragLastKbps;i=a&&this.fragCurrent?this.fragCurrent.duration*r.maxBitrate/(1e3*a)+1:0}else i=0;var o=this.getBufferedFrag(e.currentTime+i);if(o){var s=this.followingBufferedFrag(o);if(s){this.abortCurrentFrag();var l=s.maxStartPTS?s.maxStartPTS:s.start,c=s.duration,u=Math.max(o.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,.5*c),.75*c));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}},C.abortCurrentFrag=function(){var t=this.fragCurrent;this.fragCurrent=null,null!=t&&t.loader&&t.loader.abort(),this.state===r.State.KEY_LOADING&&(this.state=r.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},C.flushMainBuffer=function(e,i){t.prototype.flushMainBuffer.call(this,e,i,this.altAudio?"video":null)},C.onMediaAttached=function(e,i){t.prototype.onMediaAttached.call(this,e,i);var n=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,n,this.fragmentTracker,this.hls)},C.onMediaDetaching=function(){var e=this.media;e&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},C.onMediaPlaying=function(){this.tick()},C.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;Object(n.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},C.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(o.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},C.onManifestParsed=function(t,e){var i,n=!1,r=!1;e.levels.forEach((function(t){(i=t.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(n=!0),-1!==i.indexOf("mp4a.40.5")&&(r=!0))})),this.audioCodecSwitch=n&&r&&!Object(a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},C.onLevelLoading=function(t,e){var i=this.levels;if(i&&this.state===r.State.IDLE){var n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=r.State.WAITING_LEVEL)}},C.onLevelLoaded=function(t,e){var i,n=this.levels,a=e.level,s=e.details,l=s.totalduration;if(n){this.log("Level "+a+" loaded ["+s.startSN+","+s.endSN+"], cc ["+s.startCC+", "+s.endCC+"] duration:"+l);var c=this.fragCurrent;!c||this.state!==r.State.FRAG_LOADING&&this.state!==r.State.FRAG_LOADING_WAITING_RETRY||c.level!==e.level&&c.loader&&(this.state=r.State.IDLE,c.loader.abort());var u=n[a],h=0;if(s.live||null!==(i=u.details)&&void 0!==i&&i.live){if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed)return;h=this.alignPlaylists(s,u.details)}if(u.details=s,this.levelLastLoaded=a,this.hls.trigger(o.Events.LEVEL_UPDATED,{details:s,level:a}),this.state===r.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(s))return;this.state=r.State.IDLE}this.startFragRequested?s.live&&this.synchronizeToLiveEdge(s):this.setStartPosition(s,h),this.tick()}else this.warn("Levels were reset while loading level "+a)},C._handleFragmentLoadProgress=function(t){var e,i=t.frag,n=t.part,r=t.payload,a=this.levels;if(a){var o=a[i.level],s=o.details;if(s){var l=o.videoCodec,u=s.PTSKnown||!s.live,f=null===(e=i.initSegment)||void 0===e?void 0:e.data,p=this._getAudioCodec(o),m=this.transmuxer=this.transmuxer||new h.default(this.hls,c.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=n?n.index:-1,v=-1!==g,y=new d.ChunkMetadata(i.level,i.sn,i.stats.chunkCount,r.byteLength,g,v),b=this.initPTS[i.cc];m.push(r,f,p,l,i,n,s.totalduration,u,y,b)}else this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},C.onAudioTrackSwitching=function(t,e){var i=this.altAudio,n=!!e.url,r=e.id;if(!n){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;null!=a&&a.loader&&(this.log("Switching to main audio track, cancel main fragment load"),a.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var s=this.hls;i&&s.trigger(o.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),s.trigger(o.Events.AUDIO_TRACK_SWITCHED,{id:r})}},C.onAudioTrackSwitched=function(t,e){var i=e.id,n=!!this.hls.audioTracks[i].url;if(n){var r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=n,this.tick()},C.onBufferCreated=function(t,e){var i,n,r=e.tracks,a=!1;for(var o in r){var s=r[o];if("main"===s.id){if(n=o,i=s,"video"===o){var l=r[o];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&i?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},C.onFragBuffered=function(t,e){var i=e.frag,n=e.part;if(!i||i.type===c.PlaylistLevelType.MAIN){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(n?" p: "+n.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===r.State.PARSED&&(this.state=r.State.IDLE));var a=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}},C.onError=function(t,e){switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(c.PlaylistLevelType.MAIN,e);break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==r.State.ERROR&&(e.fatal?(this.warn(""+e.details),this.state=r.State.ERROR):e.levelRetry||this.state!==r.State.WAITING_LEVEL||(this.state=r.State.IDLE));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("main"===e.parent&&(this.state===r.State.PARSING||this.state===r.State.PARSED)){var i=!0,n=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);n&&n.len>.5&&(i=!this.reduceMaxBufferLength(n.len)),i&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},C.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){var i=s.BufferHelper.getBuffered(t);!this.loadedmetadata&&i.length?(this.loadedmetadata=!0,this.seekToStartPos()):e.poll(this.lastCurrentTime),this.lastCurrentTime=t.currentTime}},C.onFragLoadEmergencyAborted=function(){this.state=r.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},C.onBufferFlushed=function(t,e){var i=e.type;if(i!==u.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var n=(i===u.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,i,c.PlaylistLevelType.MAIN)}},C.onLevelsUpdated=function(t,e){this.levels=e.levels},C.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},C.seekToStartPos=function(){var t=this.media,e=t.currentTime,i=this.startPosition;if(i>=0&&e<i){if(t.seeking)return void m.logger.log("could not seek to "+i+", already seeking at "+e);var n=s.BufferHelper.getBuffered(t),r=(n.length?n.start(0):0)-i;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(m.logger.log("adjusting start position by "+r+" to match buffer start"),i+=r,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+e),t.currentTime=i}},C._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},C._loadBitrateTestFrag=function(t){var e=this;this._doFragLoad(t).then((function(i){var n=e.hls;if(i&&!n.nextLoadLevel&&!e.fragContextChanged(t)){e.fragLoadError=0,e.state=r.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var a=t.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(o.Events.FRAG_LOADED,i)}}))},C._handleTransmuxComplete=function(t){var e,i="main",a=this.hls,s=t.remuxResult,l=t.chunkMeta,c=this.getCurrentContext(l);if(!c)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(l.level);var h=c.frag,d=c.part,f=c.level,p=s.video,m=s.text,g=s.id3,v=s.initSegment,y=this.altAudio?void 0:s.audio;if(!this.fragContextChanged(h)){if(this.state=r.State.PARSING,v){v.tracks&&(this._bufferInitSegment(f,v.tracks,h,l),a.trigger(o.Events.FRAG_PARSING_INIT_SEGMENT,{frag:h,id:i,tracks:v.tracks}));var b=v.initPTS,x=v.timescale;Object(n.isFiniteNumber)(b)&&(this.initPTS[h.cc]=b,a.trigger(o.Events.INIT_PTS_FOUND,{frag:h,id:i,initPTS:b,timescale:x}))}if(p&&!1!==s.independent){if(f.details){var S=p.startPTS,C=p.endPTS,k=p.startDTS,E=p.endDTS;if(d)d.elementaryStreams[p.type]={startPTS:S,endPTS:C,startDTS:k,endDTS:E};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){if(this.getLoadPosition()+this.config.maxBufferHole<S)return void this.backtrack(h);h.setElementaryStreamInfo(p.type,h.start,C,h.start,E,!0)}h.setElementaryStreamInfo(p.type,S,C,k,E),this.bufferFragmentData(p,h,d,l)}}else if(!1===s.independent)return void this.backtrack(h);if(y){var w=y.startPTS,T=y.endPTS,O=y.startDTS,L=y.endDTS;d&&(d.elementaryStreams[u.ElementaryStreamTypes.AUDIO]={startPTS:w,endPTS:T,startDTS:O,endDTS:L}),h.setElementaryStreamInfo(u.ElementaryStreamTypes.AUDIO,w,T,O,L),this.bufferFragmentData(y,h,d,l)}if(null!=g&&null!==(e=g.samples)&&void 0!==e&&e.length){var A={frag:h,id:i,samples:g.samples};a.trigger(o.Events.FRAG_PARSING_METADATA,A)}if(m){var D={frag:h,id:i,samples:m.samples};a.trigger(o.Events.FRAG_PARSING_USERDATA,D)}}},C._bufferInitSegment=function(t,e,i,n){var a=this;if(this.state===r.State.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var s=e.audio,l=e.video,c=e.audiovideo;if(s){var u=t.audioCodec,h=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==s.metadata.channelCount&&-1===h.indexOf("firefox")&&(u="mp4a.40.5")),-1!==h.indexOf("android")&&"audio/mpeg"!==s.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),t.audioCodec&&t.audioCodec!==u&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+u+'"'),s.levelCodec=u,s.id="main",this.log("Init audio buffer, container:"+s.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(t.audioCodec||"")+"/"+s.codec+"]")}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+l.codec+"]")),c&&this.log("Init audiovideo buffer, container:"+c.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+c.codec+"]"),this.hls.trigger(o.Events.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var r=e[t].initSegment;null!=r&&r.byteLength&&a.hls.trigger(o.Events.BUFFER_APPENDING,{type:t,data:r,frag:i,part:null,chunkMeta:n,parent:i.type})})),this.tick()}},C.backtrack=function(t){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(t);var e=this.fragmentTracker.backtrack(t);this.fragPrevious=null,this.nextLoadPosition=t.start,e?this.resetFragmentLoading(t):this.state=r.State.BACKTRACKING},C.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var i=t.currentTime;if(s.BufferHelper.isBuffered(t,i)?e=this.getAppendedFrag(i):s.BufferHelper.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){var n=this.fragPlaying,r=e.level;n&&e.sn===n.sn&&n.level===r&&e.urlId===n.urlId||(this.hls.trigger(o.Events.FRAG_CHANGED,{frag:e}),n&&n.level===r||this.hls.trigger(o.Events.LEVEL_SWITCHED,{level:r}),this.fragPlaying=e)}}},b=y,(x=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);return this.followingBufferedFrag(e)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&g(b.prototype,x),S&&g(b,S),y}(r.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: SubtitleStreamController */function(t,e,i){"use strict";i.r(e),i.d(e,"SubtitleStreamController",(function(){return m}));var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../utils/logger */"./src/utils/logger.ts"),a=i(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=i(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),s=i(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),l=i(/*! ./level-helper */"./src/controller/level-helper.ts"),c=i(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=i(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),h=i(/*! ../types/loader */"./src/types/loader.ts"),d=i(/*! ../types/level */"./src/types/level.ts");function f(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){var e,i;function m(e,i){var n;return(n=t.call(this,e,i,"[subtitle-stream-controller]")||this).levels=[],n.currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n._registerListeners(),n}i=t,(e=m).prototype=Object.create(i.prototype),e.prototype.constructor=e,p(e,i);var g,v,y,b=m.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(n.Events.ERROR,this.onError,this),t.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(n.Events.ERROR,this.onError,this),t.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b.startLoad=function(){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.tick()},b.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},b.onLevelLoaded=function(t,e){this.mainDetails=e.details},b.onSubtitleFragProcessed=function(t,e){var i=e.frag,n=e.success;if(this.fragPrevious=i,this.state=u.State.IDLE,n){var r=this.tracksBuffered[this.currentTrackId];if(r){for(var a,o=i.start,s=0;s<r.length;s++)if(o>=r[s].start&&o<=r[s].end){a=r[s];break}var l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},r.push(a)),this.fragmentTracker.fragBuffered(i)}}},b.onBufferFlushing=function(t,e){var i=e.startOffset,n=e.endOffset;if(0===i&&n!==Number.POSITIVE_INFINITY){var r=this.currentTrackId,a=this.levels;if(!a.length||!a[r]||!a[r].details)return;var o=n-a[r].details.targetduration;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach((function(t){for(var e=0;e<t.length;)if(t[e].end<=o)t.shift();else{if(!(t[e].start<o))break;t[e].start=o,e++}})),this.fragmentTracker.removeFragmentsInRange(i,o,h.PlaylistLevelType.SUBTITLE)}},b.onError=function(t,e){var i,n=e.frag;n&&n.type===h.PlaylistLevelType.SUBTITLE&&(null!==(i=this.fragCurrent)&&void 0!==i&&i.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},b.onSubtitleTracksUpdated=function(t,e){var i=this,n=e.subtitleTracks;this.tracksBuffered=[],this.levels=n.map((function(t){return new d.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){i.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},b.onSubtitleTrackSwitch=function(t,e){if(this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId){var i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},b.onSubtitleTrackLoaded=function(t,e){var i,n=e.details,r=e.id,a=this.currentTrackId,c=this.levels;if(c.length){var h=c[a];if(!(r>=c.length||r!==a)&&h){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||null!==(i=h.details)&&void 0!==i&&i.live){var d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;var f=d.fragments[0];h.details?0===this.alignPlaylists(n,h.details)&&f&&Object(l.addSliding)(n,f.start):n.hasProgramDateTime&&d.hasProgramDateTime?Object(s.alignMediaPlaylistByPDT)(n,d):f&&Object(l.addSliding)(n,f.start)}h.details=n,this.levelLastLoaded=r,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&(Object(o.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0))}}},b._handleFragmentLoadComplete=function(t){var e=t.frag,i=t.payload,r=e.decryptdata,a=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&r&&r.key&&r.iv&&"AES-128"===r.method){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).then((function(t){var i=performance.now();a.trigger(n.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:o,tdecrypt:i}})}))}},b.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var t,e=this.currentTrackId,i=this.levels;if(!i.length||!i[e]||!i[e].details)return;var s=i[e].details,l=s.targetduration,h=this.config,d=this.media,f=a.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,d.currentTime-l,h.maxBufferHole),p=f.end;if(f.len>this.getMaxBufferLength()+l)return;console.assert(s,"Subtitle track details are defined on idle subtitle stream controller tick");var m,g=s.fragments,v=g.length,y=s.edge,b=this.fragPrevious;if(p<y){var x=h.maxFragLookUpTolerance;b&&s.hasProgramDateTime&&(m=Object(o.findFragmentByPDT)(g,b.endProgramDateTime,x)),m||!(m=Object(o.findFragmentByPTS)(b,g,p,x))&&b&&b.start<g[0].start&&(m=g[0])}else m=g[v-1];null!==(t=m)&&void 0!==t&&t.encrypted?(r.logger.log("Loading key for "+m.sn),this.state=u.State.KEY_LOADING,this.hls.trigger(n.Events.KEY_LOADING,{frag:m})):m&&this.fragmentTracker.getState(m)===c.FragmentState.NOT_LOADED&&this.loadFragment(m,s,p)}}else this.state=u.State.IDLE},b.loadFragment=function(e,i,n){this.fragCurrent=e,t.prototype.loadFragment.call(this,e,i,n)},g=m,(v=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&f(g.prototype,v),y&&f(g,y),m}(u.default)},"./src/controller/subtitle-track-controller.ts":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
|
\*****************************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=i(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),o=i(/*! ../types/loader */"./src/types/loader.ts");function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var c=function(t){var e,i;function a(e){var i;return(i=t.call(this,e,"[subtitle-track-controller]")||this).media=null,i.tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.trackChangeListener=function(){return i.onTextTracksChanged()},i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i.subtitleDisplay=!0,i.registerListeners(),i}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i);var c,h,d,f=a.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},f.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(n.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(n.Events.ERROR,this.onError,this)},f.onMediaAttached=function(t,e){this.media=e.media,this.media&&(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))},f.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},f.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),u(this.media.textTracks).forEach((function(t){Object(r.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},f.onSubtitleTrackLoaded=function(t,e){var i=e.id,n=e.details,r=this.trackId,a=this.tracksInGroup[r];if(a){var o=a.details;a.details=e.details,this.log("subtitle track "+i+" loaded ["+n.startSN+"-"+n.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,o))}else this.warn("Invalid subtitle track id "+i)},f.onLevelLoading=function(t,e){this.switchLevel(e.level)},f.onLevelSwitching=function(t,e){this.switchLevel(e.level)},f.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var i=e.textGroupIds[e.urlId];if(this.groupId!==i){var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter((function(t){return!i||t.groupId===i}));this.tracksInGroup=a;var o=this.findTrackId(null==r?void 0:r.name)||this.findTrackId();this.groupId=i;var s={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(n.Events.SUBTITLE_TRACKS_UPDATED,s),-1!==o&&this.setSubtitleTrack(o,r)}}},f.findTrackId=function(t){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},f.onError=function(e,i){t.prototype.onError.call(this,e,i),!i.fatal&&i.context&&i.context.type===o.PlaylistContextType.SUBTITLE_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},f.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,r=e.groupId,a=e.url;if(t)try{a=t.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADING,{url:a,id:i,groupId:r,deliveryDirectives:t||null})}},f.toggleTrackModes=function(t){var e=this,i=this.media,n=this.subtitleDisplay,r=this.trackId;if(i){var a=u(i.textTracks),o=a.filter((function(t){return t.groupId===e.groupId}));if(-1===t)[].slice.call(a).forEach((function(t){t.mode="disabled"}));else{var s=o[r];s&&(s.mode="disabled")}var l=o[t];l&&(l.mode=n?"showing":"hidden")}},f.setSubtitleTrack=function(t,e){var i,r=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(i=r[t])&&void 0!==i&&i.details)||t<-1||t>=r.length)){this.clearTimer();var a=r[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,a){var o=a.id,s=a.groupId,l=void 0===s?"":s,c=a.name,u=a.type,h=a.url;this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:l,name:c,type:u,url:h});var d=this.switchParams(a.url,null==e?void 0:e.details);this.loadPlaylist(d)}else this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},f.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=u(this.media.textTracks),i=0;i<e.length;i++)if("hidden"===e[i].mode)t=i;else if("showing"===e[i].mode){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},c=a,(h=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}])&&s(c.prototype,h),d&&s(c,d),a}(a.default);function u(t){for(var e=[],i=0;i<t.length;i++){var n=t[i];"subtitles"===n.kind&&n.label&&e.push(t[i])}return e}e.default=c},"./src/controller/timeline-controller.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/controller/timeline-controller.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: TimelineController */function(t,e,i){"use strict";i.r(e),i.d(e,"TimelineController",(function(){return d}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),o=i(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),s=i(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=i(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),c=i(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),u=i(/*! ../types/loader */"./src/types/loader.ts"),h=i(/*! ../utils/logger */"./src/utils/logger.ts"),d=function(){function t(t){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={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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 e=new o.default(this,"textTrack1"),i=new o.default(this,"textTrack2"),n=new o.default(this,"textTrack3"),s=new o.default(this,"textTrack4");this.cea608Parser1=new a.default(1,e,i),this.cea608Parser2=new a.default(3,n,s)}t.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(r.Events.FRAG_LOADING,this.onFragLoading,this),t.on(r.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(r.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(r.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(r.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(r.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(r.Events.FRAG_LOADING,this.onFragLoading,this),t.off(r.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(r.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(r.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(r.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(r.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,i,n,a){for(var o,s,l,c,u=!1,h=a.length;h--;){var d=a[h],f=(o=d[0],s=d[1],l=e,c=i,Math.min(s,c)-Math.max(o,l));if(f>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],i),u=!0,f/(i-e)>.5))return}if(u||a.push([e,i]),this.config.renderTextTracksNatively){var p=this.captionsTracks[t];this.Cues.newCue(p,e,i,n)}else{var m=this.Cues.newCue(null,e,i,n);this.hls.trigger(r.Events.CUES_PARSED,{type:"captions",cues:m,track:t})}},e.onInitPtsFound=function(t,e){var i=this,n=e.frag,a=e.id,o=e.initPTS,s=e.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[n.cc]=o,this.timescale[n.cc]=s),l.length&&(this.unparsedVttFrags=[],l.forEach((function(t){i.onFragLoaded(r.Events.FRAG_LOADED,t)})))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var i=0;i<e.textTracks.length;i++){var n=e.textTracks[i];if(n[t])return n}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var e=this.captionsProperties,i=this.captionsTracks,n=this.media,r=e[t],a=r.label,o=r.languageCode,s=this.getExistingTrack(t);if(s)i[t]=s,Object(l.clearCurrentCues)(i[t]),Object(l.sendAddTrackEvent)(i[t],n);else{var c=this.createTextTrack("captions",a,o);c&&(c[t]=!0,i[t]=c)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var e=this.captionsProperties[t];if(e){var i={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=i,this.hls.trigger(r.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},e.createTextTrack=function(t,e,i){var n=this.media;if(n)return n.addTextTrack(t,e,i)},e.onMediaAttaching=function(t,e){this.media=e.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(e){Object(l.clearCurrentCues)(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},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())},e._cleanTracks=function(){var t=this.media;if(t){var e=t.textTracks;if(e)for(var i=0;i<e.length;i++)Object(l.clearCurrentCues)(e[i])}},e.onSubtitleTracksUpdated=function(t,e){var i=this;this.textTracks=[];var n=e.subtitleTracks||[],a=n.some((function(t){return t.textCodec===c.IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var o=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,e){var n;if(e<s.length){for(var r=null,a=0;a<s.length;a++)if(f(s[a],t)){r=s[a];break}r&&(n=r)}n?Object(l.clearCurrentCues)(n):(n=i.createTextTrack("subtitles",t.name,t.lang))&&(n.mode="disabled"),n&&(n.groupId=t.groupId,i.textTracks.push(n))}))}else if(!o&&this.tracks&&this.tracks.length){var u=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(r.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},e.onManifestLoaded=function(t,e){var i=this;this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var n="textTrack"+e[1],r=i.captionsProperties[n];r&&(r.label=t.name,t.lang&&(r.languageCode=t.lang),r.media=t)}}))},e.onFragLoading=function(t,e){var i=this.cea608Parser1,n=this.cea608Parser2,r=this.lastSn,a=this.lastPartIndex;if(this.enabled&&i&&n&&e.frag.type===u.PlaylistLevelType.MAIN){var o,s,l=e.frag.sn,c=null!=(o=null==e||null===(s=e.part)||void 0===s?void 0:s.index)?o:-1;l===r+1||l===r&&c===a+1||(i.reset(),n.reset()),this.lastSn=l,this.lastPartIndex=c}},e.onFragLoaded=function(t,e){var i=e.frag,a=e.payload,o=this.initPTS,s=this.unparsedVttFrags;if(i.type===u.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!Object(n.isFiniteNumber)(o[i.cc]))return s.push(e),void(o.length&&this.hls.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var l=i.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var h=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),h&&h.textCodec===c.IMSC1_CODEC?this._parseIMSC1(i,a):this._parseVTTs(i,a,d)}}else this.hls.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,e){var i=this,n=this.hls;Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(e){i._appendCues(e,t.level),n.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(e){h.logger.log("Failed to parse IMSC1: "+e),n.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))},e._parseVTTs=function(t,e,i){var n=this,a=this.hls;Object(s.parseWebVTT)(e,this.initPTS[t.cc],this.timescale[t.cc],i,t.cc,t.start,(function(e){n._appendCues(e,t.level),a.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(i){n._fallbackToIMSC1(t,e),h.logger.log("Failed to parse VTT cue: "+i),a.trigger(r.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:i})}))},e._fallbackToIMSC1=function(t,e){var i=this,n=this.tracks[t.level];n.textCodec||Object(c.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(){n.textCodec=c.IMSC1_CODEC,i._parseIMSC1(t,e)}),(function(){n.textCodec="wvtt"}))},e._appendCues=function(t,e){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[e];if("disabled"===n.mode)return;t.forEach((function(t){return Object(l.addCueToTrack)(n,t)}))}else{var a=this.tracks[e].default?"default":"subtitles"+e;i.trigger(r.Events.CUES_PARSED,{type:"subtitles",cues:t,track:a})}},e.onFragDecrypted=function(t,e){var i=e.frag;if(i.type===u.PlaylistLevelType.SUBTITLE){if(!Object(n.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(e);this.onFragLoaded(r.Events.FRAG_LOADED,e)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){var i=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&i&&n)for(var r=0;r<e.samples.length;r++){var a=e.samples[r].bytes;if(a){var o=this.extractCea608Data(a);i.addData(e.samples[r].pts,o[0]),n.addData(e.samples[r].pts,o[1])}}},e.onBufferFlushing=function(t,e){var i=e.startOffset,n=e.endOffset,r=e.endOffsetSubtitles,a=e.type,o=this.media;if(o&&!(o.currentTime<n)){if(!a||"video"===a){var s=this.captionsTracks;Object.keys(s).forEach((function(t){return Object(l.removeCuesInRange)(s[t],i,n)}))}if(this.config.renderTextTracksNatively&&0===i&&void 0!==r){var c=this.textTracks;Object.keys(c).forEach((function(t){return Object(l.removeCuesInRange)(c[t],i,r)}))}}},e.extractCea608Data=function(t){for(var e=31&t[0],i=2,n=[[],[]],r=0;r<e;r++){var a=t[i++],o=127&t[i++],s=127&t[i++],l=3&a;0===o&&0===s||0!=(4&a)&&(0!==l&&1!==l||(n[l].push(o),n[l].push(s)))}return n},t}();function f(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/crypt/aes-crypto.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var n=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}()},"./src/crypt/aes-decryptor.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: removePadding, default */function(t,e,i){"use strict";i.r(e),i.d(e,"removePadding",(function(){return r})),i.d(e,"default",(function(){return a}));var n=i(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function r(t){var e=t.byteLength,i=e&&new DataView(t.buffer).getUint8(e-1);return i?Object(n.sliceUint8)(t,0,e-i):t}var a=function(){function t(){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 e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),i=new Uint32Array(4),n=0;n<4;n++)i[n]=e.getUint32(4*n);return i},e.initTable=function(){var t=this.sBox,e=this.invSBox,i=this.subMix,n=i[0],r=i[1],a=i[2],o=i[3],s=this.invSubMix,l=s[0],c=s[1],u=s[2],h=s[3],d=new Uint32Array(256),f=0,p=0,m=0;for(m=0;m<256;m++)d[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var g=p^p<<1^p<<2^p<<3^p<<4;g=g>>>8^255&g^99,t[f]=g,e[g]=f;var v=d[f],y=d[v],b=d[y],x=257*d[g]^16843008*g;n[f]=x<<24|x>>>8,r[f]=x<<16|x>>>16,a[f]=x<<8|x>>>24,o[f]=x,x=16843009*b^65537*y^257*v^16843008*f,l[g]=x<<24|x>>>8,c[g]=x<<16|x>>>16,u[g]=x<<8|x>>>24,h[g]=x,f?(f=v^d[d[d[b^v]]],p^=d[d[p]]):f=p=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),i=!0,n=0;n<e.length&&i;)i=e[n]===this.key[n],n++;if(!i){this.key=e;var r=this.keySize=e.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);var a,o,s,l,c=this.ksRows=4*(r+6+1),u=this.keySchedule=new Uint32Array(c),h=this.invKeySchedule=new Uint32Array(c),d=this.sBox,f=this.rcon,p=this.invSubMix,m=p[0],g=p[1],v=p[2],y=p[3];for(a=0;a<c;a++)a<r?s=u[a]=e[a]:(l=s,a%r==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[a/r|0]<<24):r>6&&a%r==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),u[a]=s=(u[a-r]^l)>>>0);for(o=0;o<c;o++)a=c-o,l=3&o?u[a]:u[a-4],h[o]=o<4||a<=4?l:m[d[l>>>24]]^g[d[l>>>16&255]]^v[d[l>>>8&255]]^y[d[255&l]],h[o]=h[o]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,i){for(var n,r,a,o,s,l,c,u,h,d,f,p,m,g,v=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,x=this.invSubMix,S=x[0],C=x[1],k=x[2],E=x[3],w=this.uint8ArrayToUint32Array_(i),T=w[0],O=w[1],L=w[2],A=w[3],D=new Int32Array(t),_=new Int32Array(D.length),R=this.networkToHostOrderSwap;e<D.length;){for(h=R(D[e]),d=R(D[e+1]),f=R(D[e+2]),p=R(D[e+3]),s=h^y[0],l=p^y[1],c=f^y[2],u=d^y[3],m=4,g=1;g<v;g++)n=S[s>>>24]^C[l>>16&255]^k[c>>8&255]^E[255&u]^y[m],r=S[l>>>24]^C[c>>16&255]^k[u>>8&255]^E[255&s]^y[m+1],a=S[c>>>24]^C[u>>16&255]^k[s>>8&255]^E[255&l]^y[m+2],o=S[u>>>24]^C[s>>16&255]^k[l>>8&255]^E[255&c]^y[m+3],s=n,l=r,c=a,u=o,m+=4;n=b[s>>>24]<<24^b[l>>16&255]<<16^b[c>>8&255]<<8^b[255&u]^y[m],r=b[l>>>24]<<24^b[c>>16&255]<<16^b[u>>8&255]<<8^b[255&s]^y[m+1],a=b[c>>>24]<<24^b[u>>16&255]<<16^b[s>>8&255]<<8^b[255&l]^y[m+2],o=b[u>>>24]<<24^b[s>>16&255]<<16^b[l>>8&255]<<8^b[255&c]^y[m+3],_[e]=R(n^T),_[e+1]=R(o^O),_[e+2]=R(a^L),_[e+3]=R(r^A),T=h,O=d,L=f,A=p,e+=4}return _.buffer},t}()},"./src/crypt/decrypter.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/crypt/decrypter.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return c}));var n=i(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),r=i(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),a=i(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=i(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),c=function(){function t(t,e,i){var n=(void 0===i?{}:i).removePKCS7Padding,r=void 0===n||n;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=e,this.removePKCS7Padding=r,r)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(t){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var e=t.prototype;return e.destroy=function(){this.observer=null},e.isSync=function(){return this.config.enableSoftwareAES},e.flush=function(){var t=this.currentResult;if(t){var e=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Object(a.removePadding)(e):e}this.reset()},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,i,n){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),e,i);var r=this.flush();r&&n(r.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),e,i).then(n)},e.softwareDecrypt=function(t,e,i){var n=this.currentIV,r=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(t=Object(s.appendUint8Array)(o,t),this.remainderData=null);var c=this.getValidChunk(t);if(!c.length)return null;n&&(i=n);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new a.default),u.expandKey(e);var h=r;return this.currentResult=u.decrypt(c.buffer,0,i),this.currentIV=Object(l.sliceUint8)(c,-16).buffer,h||null},e.webCryptoDecrypt=function(t,e,i){var a=this,o=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new r.default(o,e)),this.fastAesKey.expandKey().then((function(e){return o?new n.default(o,i).decrypt(t.buffer,e):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return a.onWebCryptoError(n,t,e,i)}))},e.onWebCryptoError=function(t,e,i,n){return o.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(e,i,n)},e.getValidChunk=function(t){var e=t,i=t.length-t.length%16;return i!==t.length&&(e=Object(l.sliceUint8)(t,0,i),this.remainderData=Object(l.sliceUint8)(t,i)),e},e.logOnce=function(t){this.logEnabled&&(o.logger.log("[decrypter.ts]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var n=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/aacdemuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),r=i(/*! ./adts */"./src/demux/adts.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ../demux/id3 */"./src/demux/id3.ts");function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,i;function n(e,i){var n;return(n=t.call(this)||this).observer=void 0,n.config=void 0,n.observer=e,n.config=i,n}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var l=n.prototype;return l.resetInitSegment=function(e,i,n){t.prototype.resetInitSegment.call(this,e,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var e=(o.getID3Data(t,0)||[]).length,i=t.length;e<i;e++)if(r.probe(t,e))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(t,e){return r.canParse(t,e)},l.appendFrame=function(t,e,i){r.initTrackConfig(t,this.observer,e,i,t.manifestCodec);var n=r.appendFrame(t,e,i,this.initPTS,this.frameIndex);if(n&&0===n.missing)return n},n}(n.default);l.minProbeByteLength=9,e.default=l},"./src/demux/adts.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/demux/adts.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,e,i){"use strict";i.r(e),i.d(e,"getAudioConfig",(function(){return o})),i.d(e,"isHeaderPattern",(function(){return s})),i.d(e,"getHeaderLength",(function(){return l})),i.d(e,"getFullFrameLength",(function(){return c})),i.d(e,"canGetFrameLength",(function(){return u})),i.d(e,"isHeader",(function(){return h})),i.d(e,"canParse",(function(){return d})),i.d(e,"probe",(function(){return f})),i.d(e,"initTrackConfig",(function(){return p})),i.d(e,"getFrameDuration",(function(){return m})),i.d(e,"parseFrameHeader",(function(){return g})),i.d(e,"appendFrame",(function(){return v}));var n=i(/*! ../utils/logger */"./src/utils/logger.ts"),r=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../events */"./src/events.ts");function o(t,e,i,o){var s,l,c,u,h=navigator.userAgent.toLowerCase(),d=o,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=1+((192&e[i+2])>>>6);var p=(60&e[i+2])>>>2;if(!(p>f.length-1))return c=(1&e[i+2])<<2,c|=(192&e[i+3])>>>6,n.logger.log("manifest codec:"+o+", ADTS type:"+s+", samplingIndex:"+p),/firefox/i.test(h)?p>=6?(s=5,u=new Array(4),l=p-3):(s=2,u=new Array(2),l=p):-1!==h.indexOf("android")?(s=2,u=new Array(2),l=p):(s=5,u=new Array(4),o&&(-1!==o.indexOf("mp4a.40.29")||-1!==o.indexOf("mp4a.40.5"))||!o&&p>=6?l=p-3:((o&&-1!==o.indexOf("mp4a.40.2")&&(p>=6&&1===c||/vivaldi/i.test(h))||!o&&1===c)&&(s=2,u=new Array(2)),l=p)),u[0]=s<<3,u[0]|=(14&p)>>1,u[1]|=(1&p)<<7,u[1]|=c<<3,5===s&&(u[1]|=(14&l)>>1,u[2]=(1&l)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:f[p],channelCount:c,codec:"mp4a.40."+s,manifestCodec:d};t.trigger(a.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function s(t,e){return 255===t[e]&&240==(246&t[e+1])}function l(t,e){return 1&t[e+1]?7:9}function c(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function u(t,e){return e+5<t.length}function h(t,e){return e+1<t.length&&s(t,e)}function d(t,e){return u(t,e)&&s(t,e)&&c(t,e)<=t.length-e}function f(t,e){if(h(t,e)){var i=l(t,e);if(e+i>=t.length)return!1;var n=c(t,e);if(n<=i)return!1;var r=e+n;return r===t.length||h(t,r)}return!1}function p(t,e,i,r,a){if(!t.samplerate){var s=o(e,i,r,a);if(!s)return;t.config=s.config,t.samplerate=s.samplerate,t.channelCount=s.channelCount,t.codec=s.codec,t.manifestCodec=s.manifestCodec,n.logger.log("parsed codec:"+t.codec+", rate:"+s.samplerate+", channels:"+s.channelCount)}}function m(t){return 9216e4/t}function g(t,e,i,n,r){var a=l(t,e),o=c(t,e);if((o-=a)>0)return{headerLength:a,frameLength:o,stamp:i+n*r}}function v(t,e,i,n,r){var a=g(e,i,n,r,m(t.samplerate));if(a){var o,s=a.frameLength,l=a.headerLength,c=a.stamp,u=l+s,h=Math.max(0,i+u-e.length);h?(o=new Uint8Array(u-l)).set(e.subarray(i+l,e.length),0):o=e.subarray(i+l,i+u);var d={unit:o,pts:c};return h||t.samples.push(d),{sample:d,length:u,missing:h}}}},"./src/demux/base-audio-demuxer.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: initPTSFn, default */function(t,e,i){"use strict";i.r(e),i.d(e,"initPTSFn",(function(){return c}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../demux/id3 */"./src/demux/id3.ts"),a=i(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=i(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),l=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(){},e.resetContiguity=function(){},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,i){},e.demux=function(t,e){this.cachedData&&(t=Object(o.appendUint8Array)(this.cachedData,t),this.cachedData=null);var i,n,l=r.getID3Data(t,0),u=l?l.length:0,h=this._audioTrack,d=this._id3Track,f=l?r.getTimeStamp(l):void 0,p=t.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=c(f,e)),l&&l.length>0&&d.samples.push({pts:this.initPTS,dts:this.initPTS,data:l}),n=this.initPTS;u<p;){if(this.canParse(t,u)){var m=this.appendFrame(h,t,u);m?(this.frameIndex++,n=m.sample.pts,i=u+=m.length):u=p}else r.canParse(t,u)?(l=r.getID3Data(t,u),d.samples.push({pts:n,dts:n,data:l}),i=u+=l.length):u++;if(u===p&&i!==p){var g=Object(s.sliceUint8)(t,i);this.cachedData?this.cachedData=Object(o.appendUint8Array)(this.cachedData,g):this.cachedData=g}}return{audioTrack:h,avcTrack:Object(a.dummyTrack)(),id3Track:d,textTrack:Object(a.dummyTrack)()}},e.demuxSampleAes=function(t,e,i){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(a.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(a.dummyTrack)()}},e.destroy=function(){},t}(),c=function(t,e){return Object(n.isFiniteNumber)(t)?90*t:9e4*e};e.default=l},"./src/demux/chunk-cache.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/demux/chunk-cache.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var n=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,i=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var i=new Uint8Array(e),n=0,r=0;r<t.length;r++){var a=t[r];i.set(a,n),n+=a.length}return i}(e,i),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: dummyTrack */function(t,e,i){"use strict";function n(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}i.r(e),i.d(e,"dummyTrack",(function(){return n}))},"./src/demux/exp-golomb.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/exp-golomb.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../utils/logger */"./src/utils/logger.ts"),r=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,i=t.byteLength-e,n=new Uint8Array(4),r=Math.min(4,e);if(0===r)throw new Error("no bytes available");n.set(t.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r},e.skipBits=function(t){var e;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),i=this.word>>>32-e;return t>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),(e=t-e)>0&&this.bitsAvailable?i<<e|this.readBits(e):i},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,i=8,n=0;n<t;n++)0!==i&&(i=(e+this.readEG()+256)%256),e=0===i?e:i},e.readSPS=function(){var t,e,i,n=0,r=0,a=0,o=0,s=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);s();var m=s();if(l(5),h(3),s(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var g=c();if(3===g&&h(1),f(),f(),h(1),u())for(e=3!==g?8:12,i=0;i<e;i++)u()&&p(i<6?16:64)}f();var v=c();if(0===v)c();else if(1===v)for(h(1),d(),d(),t=c(),i=0;i<t;i++)d();f(),h(1);var y=c(),b=c(),x=l(1);0===x&&h(1),h(1),u()&&(n=c(),r=c(),a=c(),o=c());var S=[1,1];if(u()&&u())switch(s()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[s()<<8|s(),s()<<8|s()]}return{width:Math.ceil(16*(y+1)-2*n-2*r),height:(2-x)*(b+1)*16-(x?2:4)*(a+o),pixelRatio:S}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}();e.default=r},"./src/demux/id3.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/demux/id3.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,e,i){"use strict";i.r(e),i.d(e,"isHeader",(function(){return r})),i.d(e,"isFooter",(function(){return a})),i.d(e,"getID3Data",(function(){return o})),i.d(e,"canParse",(function(){return l})),i.d(e,"getTimeStamp",(function(){return c})),i.d(e,"isTimeStampFrame",(function(){return u})),i.d(e,"getID3Frames",(function(){return d})),i.d(e,"decodeFrame",(function(){return f})),i.d(e,"utf8ArrayToStr",(function(){return y})),i.d(e,"testables",(function(){return b}));var n,r=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},a=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},o=function(t,e){for(var i=e,n=0;r(t,e);)n+=10,n+=s(t,e+6),a(t,e+10)&&(n+=10),e+=n;if(n>0)return t.subarray(i,i+n)},s=function(t,e){var i=0;return i=(127&t[e])<<21,i|=(127&t[e+1])<<14,i|=(127&t[e+2])<<7,i|=127&t[e+3]},l=function(t,e){return r(t,e)&&s(t,e+6)+10<=t.length-e},c=function(t){for(var e=d(t),i=0;i<e.length;i++){var n=e[i];if(u(n))return v(n)}},u=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},h=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),i=s(t,4);return{type:e,size:i,data:t.subarray(10,10+i)}},d=function(t){for(var e=0,i=[];r(t,e);){for(var n=s(t,e+6),o=(e+=10)+n;e+8<o;){var l=h(t.subarray(e)),c=f(l);c&&i.push(c),e+=l.size+10}a(t,e)&&(e+=10)}return i},f=function(t){return"PRIV"===t.type?p(t):"W"===t.type[0]?g(t):m(t)},p=function(t){if(!(t.size<2)){var e=y(t.data,!0),i=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:i.buffer}}},m=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,i=y(t.data.subarray(e),!0);e+=i.length+1;var n=y(t.data.subarray(e));return{key:t.type,info:i,data:n}}var r=y(t.data.subarray(1));return{key:t.type,data:r}}},g=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,i=y(t.data.subarray(e),!0);e+=i.length+1;var n=y(t.data.subarray(e));return{key:t.type,info:i,data:n}}var r=y(t.data);return{key:t.type,data:r}},v=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),i=1&e[3],n=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}},y=function(t,e){void 0===e&&(e=!1);var i=x();if(i){var n=i.decode(t);if(e){var r=n.indexOf("\0");return-1!==r?n.substring(0,r):n}return n.replace(/\0/g,"")}for(var a,o,s,l=t.length,c="",u=0;u<l;){if(0===(a=t[u++])&&e)return c;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(a);break;case 12:case 13:o=t[u++],c+=String.fromCharCode((31&a)<<6|63&o);break;case 14:o=t[u++],s=t[u++],c+=String.fromCharCode((15&a)<<12|(63&o)<<6|(63&s)<<0)}}return c},b={decodeTextFrame:m};function x(){return n||void 0===self.TextDecoder||(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp3demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),r=i(/*! ../demux/id3 */"./src/demux/id3.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,i;function n(){return t.apply(this,arguments)||this}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,s(e,i);var l=n.prototype;return l.resetInitSegment=function(e,i,n){t.prototype.resetInitSegment.call(this,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var e=(r.getID3Data(t,0)||[]).length,i=t.length;e<i;e++)if(o.probe(t,e))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(t,e){return o.canParse(t,e)},l.appendFrame=function(t,e,i){if(null!==this.initPTS)return o.appendFrame(t,e,i,this.initPTS,this.frameIndex)},n}(n.default);l.minProbeByteLength=4,e.default=l},"./src/demux/mp4demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp4demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),r=i(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=function(){function t(t,e){this.remainderData=null,this.config=void 0,this.config=e}var e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(){},e.resetContiguity=function(){},t.probe=function(t){return Object(n.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.demux=function(t){var e=t,i=Object(r.dummyTrack)();if(this.config.progressive){this.remainderData&&(e=Object(n.appendUint8Array)(this.remainderData,t));var a=Object(n.segmentValidRange)(e);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=e;return{audioTrack:Object(r.dummyTrack)(),avcTrack:i,id3Track:Object(r.dummyTrack)(),textTrack:Object(r.dummyTrack)()}},e.flush=function(){var t=Object(r.dummyTrack)();return t.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(r.dummyTrack)(),avcTrack:t,id3Track:Object(r.dummyTrack)(),textTrack:Object(r.dummyTrack)()}},e.demuxSampleAes=function(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}();a.minProbeByteLength=1024,e.default=a},"./src/demux/mpegaudio.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/mpegaudio.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,e,i){"use strict";i.r(e),i.d(e,"appendFrame",(function(){return l})),i.d(e,"parseHeader",(function(){return c})),i.d(e,"isHeaderPattern",(function(){return u})),i.d(e,"isHeader",(function(){return h})),i.d(e,"canParse",(function(){return d})),i.d(e,"probe",(function(){return f}));var n=null,r=[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],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],o=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],s=[0,1,1,4];function l(t,e,i,n,r){if(!(i+24>e.length)){var a=c(e,i);if(a&&i+a.frameLength<=e.length){var o=n+r*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:e.subarray(i,i+a.frameLength),pts:o,dts:o};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(s),{sample:s,length:a.frameLength,missing:0}}}}function c(t,e){var i=t[e+1]>>3&3,l=t[e+1]>>1&3,c=t[e+2]>>4&15,u=t[e+2]>>2&3;if(1!==i&&0!==c&&15!==c&&3!==u){var h=t[e+2]>>1&1,d=t[e+3]>>6,f=1e3*r[14*(3===i?3-l:3===l?3:4)+c-1],p=a[3*(3===i?0:2===i?1:2)+u],m=3===d?1:2,g=o[i][l],v=s[l],y=8*g*v,b=Math.floor(g*f/p+h)*v;if(null===n){var x=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);n=x?parseInt(x[1]):0}return!!n&&n<=87&&2===l&&f>=224e3&&0===d&&(t[e+3]=128|t[e+3]),{sampleRate:p,channelCount:m,frameLength:b,samplesPerFrame:y}}}function u(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function h(t,e){return e+1<t.length&&u(t,e)}function d(t,e){return u(t,e)&&4<=t.length-e}function f(t,e){if(e+1<t.length&&u(t,e)){var i=c(t,e),n=4;null!=i&&i.frameLength&&(n=i.frameLength);var r=e+n;return r===t.length||h(t,r)}return!1}},"./src/demux/sample-aes.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/sample-aes.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),r=i(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),a=function(){function t(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new n.default(t,e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t,e){this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,e)},e.decryptAacSample=function(t,e,i,n){var r=t[e].unit,a=r.subarray(16,r.length-r.length%16),o=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),s=this;this.decryptBuffer(o,(function(a){var o=new Uint8Array(a);r.set(o,16),n||s.decryptAacSamples(t,e+1,i)}))},e.decryptAacSamples=function(t,e,i){for(;;e++){if(e>=t.length)return void i();if(!(t[e].unit.length<32)){var n=this.decrypter.isSync();if(this.decryptAacSample(t,e,i,n),!n)return}}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e),n=0,r=32;r<=t.length-16;r+=160,n+=16)i.set(t.subarray(r,r+16),n);return i},e.getAvcDecryptedUnit=function(t,e){for(var i=new Uint8Array(e),n=0,r=32;r<=t.length-16;r+=160,n+=16)t.set(i.subarray(n,n+16),r);return t},e.decryptAvcSample=function(t,e,i,n,a,o){var s=Object(r.discardEPB)(a.data),l=this.getAvcEncryptedData(s),c=this;this.decryptBuffer(l.buffer,(function(r){a.data=c.getAvcDecryptedUnit(s,r),o||c.decryptAvcSamples(t,e,i+1,n)}))},e.decryptAvcSamples=function(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length)return void n();for(var r=t[e].units;!(i>=r.length);i++){var a=r[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(t,e,i,n,a,o),!o)return}}}},t}();e.default=a},"./src/demux/transmuxer-interface.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return h}));var n=i(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),c=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),u=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},h=function(){function t(t,e,i,l){var h=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=t,this.id=e,this.onTransmuxComplete=i,this.onFlush=l;var d=t.config,f=function(e,i){(i=i||{}).frag=h.frag,i.id=h.id,t.trigger(e,i)};this.observer=new c.EventEmitter,this.observer.on(r.Events.FRAG_DECRYPTED,f),this.observer.on(r.Events.ERROR,f);var p={mp4:u.isTypeSupported("video/mp4"),mpeg:u.isTypeSupported("audio/mpeg"),mp3:u.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(d.enableWorker&&"undefined"!=typeof Worker){var g;o.logger.log("demuxing in webworker");try{g=this.worker=n(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(e){t.trigger(r.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},g.postMessage({cmd:"init",typeSupported:p,vendor:m,id:e,config:JSON.stringify(d)})}catch(t){o.logger.warn("Error in worker:",t),o.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new a.default(this.observer,p,d,m,e),this.worker=null}}else this.transmuxer=new a.default(this.observer,p,d,m,e)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.observer=null},e.push=function(t,e,i,n,r,s,l,c,u,h){var d=this;u.transmuxing.start=self.performance.now();var f=this.transmuxer,p=this.worker,m=s?s.start:r.start,g=r.decryptdata,v=this.frag,y=!(v&&r.cc===v.cc),b=!(v&&u.level===v.level),x=v?u.sn-v.sn:-1,S=this.part?u.part-this.part.index:1,C=!b&&(1===x||0===x&&1===S),k=self.performance.now();(b||x||0===r.stats.parsing.start)&&(r.stats.parsing.start=k),!s||!S&&C||(s.stats.parsing.start=k);var E=new a.TransmuxState(y,C,c,b,m);if(!C||y){o.logger.log("[transmuxer-interface, "+r.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+y+"\n trackSwitch: "+b+"\n contiguous: "+C+"\n accurateTimeOffset: "+c+"\n timeOffset: "+m);var w=new a.TransmuxConfig(i,n,e,l,h);this.configureTransmuxer(w)}if(this.frag=r,this.part=s,p)p.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:u,state:E},t instanceof ArrayBuffer?[t]:[]);else if(f){var T=f.push(t,g,u,E);Object(a.isPromise)(T)?T.then((function(t){d.handleTransmuxComplete(t)})):this.handleTransmuxComplete(T)}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var i=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:t});else if(i){var r=i.flush(t);Object(a.isPromise)(r)?r.then((function(i){e.handleFlushResult(i,t)})):this.handleFlushResult(r,t)}},e.handleFlushResult=function(t,e){var i=this;t.forEach((function(t){i.handleTransmuxComplete(t)})),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,i=this.hls;switch(e.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.worker,i=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):i&&i.configure(t)},e.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return s}));var n=i(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function s(t){var e=new o.EventEmitter,i=function(e,i){t.postMessage({event:e,data:i})};e.on(r.Events.FRAG_DECRYPTED,i),e.on(r.Events.ERROR,i),t.addEventListener("message",(function(r){var o=r.data;switch(o.cmd){case"init":var s=JSON.parse(o.config);t.transmuxer=new n.default(e,o.typeSupported,s,o.vendor,o.id),Object(a.enableLogs)(s.debug),i("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(n.isPromise)(c)?c.then((function(e){l(t,e)})):l(t,c);break;case"flush":var h=o.chunkMeta,d=t.transmuxer.flush(h);Object(n.isPromise)(d)?d.then((function(e){u(t,e,h)})):u(t,d,h)}}))}function l(t,e){if((i=e.remuxResult).audio||i.video||i.text||i.id3||i.initSegment){var i,n=[],r=e.remuxResult,a=r.audio,o=r.video;a&&c(n,a),o&&c(n,o),t.postMessage({event:"transmuxComplete",data:e},n)}}function c(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function u(t,e,i){e.forEach((function(e){l(t,e)})),t.postMessage({event:"flush",data:i})}},"./src/demux/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y})),i.d(e,"isPromise",(function(){return x})),i.d(e,"TransmuxConfig",(function(){return S})),i.d(e,"TransmuxState",(function(){return C}));var n,r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../errors */"./src/errors.ts"),o=i(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),s=i(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=i(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),c=i(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),u=i(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),h=i(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),d=i(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=i(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),p=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),m=i(/*! ../utils/logger */"./src/utils/logger.ts");try{n=self.performance.now.bind(self.performance)}catch(t){m.logger.debug("Unable to use Performance API on this environment"),n=self.Date.now}var g=[{demux:c.default,remux:h.default},{demux:l.default,remux:d.default},{demux:s.default,remux:h.default},{demux:u.default,remux:h.default}],v=1024;g.forEach((function(t){var e=t.demux;v=Math.max(v,e.minProbeByteLength)}));var y=function(){function t(t,e,i,n,r){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 f.default,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=n,this.id=r}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,i,r){var a=this,o=i.transmuxing;o.executeStart=n();var s=new Uint8Array(t),l=this.cache,c=this.config,u=this.currentTransmuxState,h=this.transmuxConfig;r&&(this.currentTransmuxState=r);var d=function(t,e){var i=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(i=e),i}(s,e);if(d&&"AES-128"===d.method){var f=this.getDecrypter();if(!c.enableSoftwareAES)return this.decryptionPromise=f.webCryptoDecrypt(s,d.key.buffer,d.iv.buffer).then((function(t){var e=a.push(t,null,i);return a.decryptionPromise=null,e})),this.decryptionPromise;var m=f.softwareDecrypt(s,d.key.buffer,d.iv.buffer);if(!m)return o.executeEnd=n(),b(i);s=new Uint8Array(m)}var g=r||u,v=g.contiguous,y=g.discontinuity,x=g.trackSwitch,S=g.accurateTimeOffset,C=g.timeOffset,k=h.audioCodec,E=h.videoCodec,w=h.defaultInitPts,T=h.duration,O=h.initSegmentData;if((y||x)&&this.resetInitSegment(O,k,E,T),y&&this.resetInitialTimestamp(w),v||this.resetContiguity(),this.needsProbing(s,y,x)){if(l.dataLength){var L=l.flush();s=Object(p.appendUint8Array)(L,s)}this.configureTransmuxer(s,h)}var A=this.transmux(s,d,C,S,i),D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,o.executeEnd=n(),A},e.flush=function(t){var e=this,i=t.transmuxing;i.executeStart=n();var o=this.decrypter,s=this.cache,l=this.currentTransmuxState,c=this.decryptionPromise;if(c)return c.then((function(){return e.flush(t)}));var u=[],h=l.timeOffset;if(o){var d=o.flush();d&&u.push(this.push(d,null,t))}var f=s.dataLength;s.reset();var p=this.demuxer,m=this.remuxer;if(!p||!m)return f>=v&&this.observer.emit(r.Events.ERROR,r.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),i.executeEnd=n(),[b(t)];var g=p.flush(h);return x(g)?g.then((function(i){return e.flushRemux(u,i,t),u})):(this.flushRemux(u,g,t),u)},e.flushRemux=function(t,e,i){var r=e.audioTrack,a=e.avcTrack,o=e.id3Track,s=e.textTrack,l=this.currentTransmuxState,c=l.accurateTimeOffset,u=l.timeOffset;m.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var h=this.remuxer.remux(r,a,o,s,u,c,!0,this.id);t.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=n()},e.resetInitialTimestamp=function(t){var e=this.demuxer,i=this.remuxer;e&&i&&(e.resetTimeStamp(t),i.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,i,n){var r=this.demuxer,a=this.remuxer;r&&a&&(r.resetInitSegment(e,i,n),a.resetInitSegment(t,e,i))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,i,n,r){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,i,n,r):this.transmuxUnencrypted(t,i,n,r)},e.transmuxUnencrypted=function(t,e,i,n){var r=this.demuxer.demux(t,e,!1,!this.config.progressive),a=r.audioTrack,o=r.avcTrack,s=r.id3Track,l=r.textTrack;return{remuxResult:this.remuxer.remux(a,o,s,l,e,i,!1,this.id),chunkMeta:n}},e.transmuxSampleAes=function(t,e,i,n,r){var a=this;return this.demuxer.demuxSampleAes(t,e,i).then((function(t){return{remuxResult:a.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,i,n,!1,a.id),chunkMeta:r}}))},e.configureTransmuxer=function(t,e){for(var i,n=this.config,r=this.observer,a=this.typeSupported,o=this.vendor,s=e.audioCodec,c=e.defaultInitPts,u=e.duration,h=e.initSegmentData,f=e.videoCodec,p=0,v=g.length;p<v;p++)if(g[p].demux.probe(t)){i=g[p];break}i||(m.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),i={demux:l.default,remux:d.default});var y=this.demuxer,b=this.remuxer,x=i.remux,S=i.demux;b&&b instanceof x||(this.remuxer=new x(r,n,a,o)),y&&y instanceof S||(this.demuxer=new S(r,n,a),this.probe=S.probe),this.resetInitSegment(h,s,f,u),this.resetInitialTimestamp(c)},e.needsProbing=function(t,e,i){return!this.demuxer||!this.remuxer||e||i},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new o.default(this.observer,this.config)),t},t}(),b=function(t){return{remuxResult:{},chunkMeta:t}};function x(t){return"then"in t&&t.then instanceof Function}var S=function(t,e,i,n,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=n,this.defaultInitPts=r},C=function(t,e,i,n,r){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r}},"./src/demux/tsdemuxer.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/tsdemuxer.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: discardEPB, default */function(t,e,i){"use strict";i.r(e),i.d(e,"discardEPB",(function(){return x}));var n=i(/*! ./adts */"./src/demux/adts.ts"),r=i(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),a=i(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),o=i(/*! ./id3 */"./src/demux/id3.ts"),s=i(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=i(/*! ../events */"./src/events.ts"),c=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=i(/*! ../utils/logger */"./src/utils/logger.ts"),h=i(/*! ../errors */"./src/errors.ts"),d={video:1,audio:2,id3:3,text:4},f=function(){function t(t,e,i){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=t,this.config=e,this.typeSupported=i}t.probe=function(e){var i=t.syncOffset(e);return!(i<0||(i&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+i+", junk ahead ?"),0))},t.syncOffset=function(t){for(var e=Math.min(1e3,t.length-564),i=0;i<e;){if(71===t[i]&&71===t[i+188]&&71===t[i+376])return i;i++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:d[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",n),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3",n),this._txtTrack=t.createTrack("text",n),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=e,this.videoCodec=i,this._duration=n},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,i=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},e.demux=function(e,i,n,r){var a;void 0===n&&(n=!1),void 0===r&&(r=!1),n||(this.sampleAes=null);var o=this._avcTrack,s=this._audioTrack,d=this._id3Track,f=o.pid,p=o.pesData,y=s.pid,b=d.pid,x=s.pesData,S=d.pesData,C=!1,k=this.pmtParsed,E=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=Object(c.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),w<188&&!r)return this.remainderData=e,{audioTrack:s,avcTrack:o,id3Track:d,textTrack:this._txtTrack};var T=Math.max(0,t.syncOffset(e));(w-=(w+T)%188)<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var O=T;O<w;O+=188)if(71===e[O]){var L=!!(64&e[O+1]),A=((31&e[O+1])<<8)+e[O+2],D=void 0;if((48&e[O+3])>>4>1){if((D=O+5+e[O+4])===O+188)continue}else D=O+4;switch(A){case f:L&&(p&&(a=v(p))&&this.parseAVCPES(a,!1),p={data:[],size:0}),p&&(p.data.push(e.subarray(D,O+188)),p.size+=O+188-D);break;case y:L&&(x&&(a=v(x))&&(s.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),x={data:[],size:0}),x&&(x.data.push(e.subarray(D,O+188)),x.size+=O+188-D);break;case b:L&&(S&&(a=v(S))&&this.parseID3PES(a),S={data:[],size:0}),S&&(S.data.push(e.subarray(D,O+188)),S.size+=O+188-D);break;case 0:L&&(D+=e[D]+1),E=this._pmtId=m(e,D);break;case E:L&&(D+=e[D]+1);var _=g(e,D,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,n);(f=_.avc)>0&&(o.pid=f),(y=_.audio)>0&&(s.pid=y,s.isAAC=_.isAAC),(b=_.id3)>0&&(d.pid=b),C&&!k&&(u.logger.log("reparse from beginning"),C=!1,O=T-188),k=this.pmtParsed=!0;break;case 17:case 8191:break;default:C=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o.pesData=p,s.pesData=x,d.pesData=S;var R={audioTrack:s,avcTrack:o,id3Track:d,textTrack:this._txtTrack};return r&&this.extractRemainingSamples(R),R},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,i=t.audioTrack,n=t.avcTrack,r=t.id3Track,a=n.pesData,o=i.pesData,s=r.pesData;a&&(e=v(a))?(this.parseAVCPES(e,!0),n.pesData=null):n.pesData=a,o&&(e=v(o))?(i.isAAC?this.parseAACPES(e):this.parseMPEGPES(e),i.pesData=null):(null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=o),s&&(e=v(s))?(this.parseID3PES(e),r.pesData=null):r.pesData=s},e.demuxSampleAes=function(t,e,i){var n=this.demux(t,i,!0,!this.config.progressive),r=this.sampleAes=new s.default(this.observer,this.config,e);return this.decrypt(n,r)},e.decrypt=function(t,e){return new Promise((function(i){var n=t.audioTrack,r=t.avcTrack;n.samples&&n.isAAC?e.decryptAacSamples(n.samples,0,(function(){r.samples?e.decryptAvcSamples(r.samples,0,0,(function(){i(t)})):i(t)})):r.samples&&e.decryptAvcSamples(r.samples,0,0,(function(){i(t)}))}))},e.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},e.parseAVCPES=function(t,e){var i,n=this,r=this._avcTrack,s=this.parseAVCNALu(t.data),l=this.avcSample,c=!1;t.data=null,l&&s.length&&!r.audFound&&(y(l,r),l=this.avcSample=p(!1,t.pts,t.dts,"")),s.forEach((function(e){switch(e.type){case 1:i=!0,l||(l=n.avcSample=p(!0,t.pts,t.dts,"")),l.frame=!0;var s=e.data;if(c&&s.length>4){var u=new a.default(s).readSliceType();2!==u&&4!==u&&7!==u&&9!==u||(l.key=!0)}break;case 5:i=!0,l||(l=n.avcSample=p(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0;var h=new a.default(x(e.data));h.readUByte();for(var d=0,f=0,m=!1,g=0;!m&&h.bytesAvailable>1;){d=0;do{d+=g=h.readUByte()}while(255===g);f=0;do{f+=g=h.readUByte()}while(255===g);if(4===d&&0!==h.bytesAvailable){if(m=!0,181===h.readUByte()&&49===h.readUShort()&&1195456820===h.readUInt()&&3===h.readUByte()){for(var v=h.readUByte(),S=31&v,C=[v,h.readUByte()],k=0;k<S;k++)C.push(h.readUByte()),C.push(h.readUByte()),C.push(h.readUByte());b(n._txtTrack.samples,{type:3,pts:t.pts,bytes:C})}}else if(5===d&&0!==h.bytesAvailable){if(m=!0,f>16){for(var E=[],w=0;w<16;w++)E.push(h.readUByte().toString(16)),3!==w&&5!==w&&7!==w&&9!==w||E.push("-");for(var T=f-16,O=new Uint8Array(T),L=0;L<T;L++)O[L]=h.readUByte();b(n._txtTrack.samples,{pts:t.pts,payloadType:d,uuid:E.join(""),userData:Object(o.utf8ArrayToStr)(O),userDataBytes:O})}}else if(f<h.bytesAvailable)for(var A=0;A<f;A++)h.readUByte()}break;case 7:if(i=!0,c=!0,!r.sps){var D=new a.default(e.data).readSPS();r.width=D.width,r.height=D.height,r.pixelRatio=D.pixelRatio,r.sps=[e.data],r.duration=n._duration;for(var _=e.data.subarray(1,4),R="avc1.",I=0;I<3;I++){var M=_[I].toString(16);M.length<2&&(M="0"+M),R+=M}r.codec=R}break;case 8:i=!0,r.pps||(r.pps=[e.data]);break;case 9:i=!1,r.audFound=!0,l&&y(l,r),l=n.avcSample=p(!1,t.pts,t.dts,"");break;case 12:i=!1;break;default:i=!1,l&&(l.debug+="unknown NAL "+e.type+" ")}l&&i&&l.units.push(e)})),e&&l&&(y(l,r),this.avcSample=null)},e.getLastNalUnit=function(){var t,e,i=this.avcSample;if(!i||0===i.units.length){var n=this._avcTrack.samples;i=n[n.length-1]}if(null!==(t=i)&&void 0!==t&&t.units){var r=i.units;e=r[r.length-1]}return e},e.parseAVCNALu=function(t){var e,i,n=t.byteLength,r=this._avcTrack,a=r.naluState||0,o=a,s=[],l=0,c=-1,u=0;for(-1===a&&(c=0,u=31&t[0],a=0,l=1);l<n;)if(e=t[l++],a)if(1!==a)if(e)if(1===e){if(c>=0){var h={data:t.subarray(c,l-a-1),type:u};s.push(h)}else{var d=this.getLastNalUnit();if(d&&(o&&l<=4-o&&d.state&&(d.data=d.data.subarray(0,d.data.byteLength-o)),(i=l-a-1)>0)){var f=new Uint8Array(d.data.byteLength+i);f.set(d.data,0),f.set(t.subarray(0,i),d.data.byteLength),d.data=f,d.state=0}}l<n?(c=l,u=31&t[l],a=0):a=-1}else a=0;else a=3;else a=e?0:2;else a=e?0:1;if(c>=0&&a>=0){var p={data:t.subarray(c,n),type:u,state:a};s.push(p)}if(0===s.length){var m=this.getLastNalUnit();if(m){var g=new Uint8Array(m.data.byteLength+t.byteLength);g.set(m.data,0),g.set(t,m.data.byteLength),m.data=g}}return r.naluState=a,s},e.parseAACPES=function(t){var e,i,r,a,o,s=0,c=this._audioTrack,d=this.aacOverFlow,f=t.data;if(d){this.aacOverFlow=null;var p=d.sample.unit.byteLength,m=Math.min(d.missing,p),g=p-m;d.sample.unit.set(f.subarray(0,m),g),c.samples.push(d.sample),s=d.missing}for(e=s,i=f.length;e<i-1&&!n.isHeader(f,e);e++);if(e===s||(e<i-1?(r="AAC PES did not start with ADTS header,offset:"+e,a=!1):(r="no ADTS header found in AAC PES",a=!0),u.logger.warn("parsing error:"+r),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:r}),!a)){if(n.initTrackConfig(c,this.observer,f,e,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!d)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var v=n.getFrameDuration(c.samplerate);o=d.sample.pts+v}for(var y=0;e<i;){if(n.isHeader(f,e)){if(e+5<i){var b=n.appendFrame(c,f,e,o,y);if(b){if(!b.missing){e+=b.length,y++;continue}this.aacOverFlow=b}}break}e++}}},e.parseMPEGPES=function(t){var e=t.data,i=e.length,n=0,a=0,o=t.pts;if(void 0!==o)for(;a<i;)if(r.isHeader(e,a)){var s=r.appendFrame(this._audioTrack,e,a,o,n);if(!s)break;a+=s.length,n++}else a++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function p(t,e,i,n){return{key:t,frame:!1,pts:e,dts:i,units:[],debug:n,length:0}}function m(t,e){return(31&t[e+10])<<8|t[e+11]}function g(t,e,i,n){var r={audio:-1,avc:-1,id3:-1,isAAC:!0},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<a;){var o=(31&t[e+1])<<8|t[e+2];switch(t[e]){case 207:if(!n){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===r.audio&&(r.audio=o);break;case 21:-1===r.id3&&(r.id3=o);break;case 219:if(!n){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===r.avc&&(r.avc=o);break;case 3:case 4:i?-1===r.audio&&(r.audio=o,r.isAAC=!1):u.logger.log("MPEG audio found, not supported in this browser");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return r}function v(t){var e,i,n,r,a,o=0,s=t.data;if(!t||0===t.size)return null;for(;s[0].length<19&&s.length>1;){var l=new Uint8Array(s[0].length+s[1].length);l.set(s[0]),l.set(s[1],s[0].length),s[0]=l,s.splice(1,1)}if(1===((e=s[0])[0]<<16)+(e[1]<<8)+e[2]){if((i=(e[4]<<8)+e[5])&&i>t.size-6)return null;var c=e[7];192&c&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&c?r-(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(u.logger.warn(Math.round((r-a)/9e4)+"s delta between PTS and DTS, align them"),r=a):a=r);var h=(n=e[8])+9;if(t.size<=h)return null;t.size-=h;for(var d=new Uint8Array(t.size),f=0,p=s.length;f<p;f++){var m=(e=s[f]).byteLength;if(h){if(h>m){h-=m;continue}e=e.subarray(h),m-=h,h=0}d.set(e,o),o+=m}return i&&(i-=n+3),{data:d,pts:r,dts:a,len:i}}return null}function y(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var i=e.samples,n=i.length;if(!n)return void e.dropped++;var r=i[n-1];t.pts=r.pts,t.dts=r.dts}e.samples.push(t)}t.debug.length&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function b(t,e){var i=t.length;if(i>0){if(e.pts>=t[i-1].pts)t.push(e);else for(var n=i-1;n>=0;n--)if(e.pts<t[n].pts){t.splice(n,0,e);break}}else t.push(e)}function x(t){for(var e=t.byteLength,i=[],n=1;n<e-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return t;var r=e-i.length,a=new Uint8Array(r),o=0;for(n=0;n<r;o++,n++)o===i[0]&&(o++,i.shift()),a[n]=t[o];return a}f.minProbeByteLength=188,e.default=f},"./src/errors.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/errors.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: ErrorTypes, ErrorDetails */function(t,e,i){"use strict";var n,r;i.r(e),i.d(e,"ErrorTypes",(function(){return n})),i.d(e,"ErrorDetails",(function(){return r})),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(n||(n={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(r||(r={}))},"./src/events.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/events.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: Events */function(t,e,i){"use strict";var n;i.r(e),i.d(e,"Events",(function(){return n})),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(n||(n={}))},"./src/hls.ts":
|
|
|
/*!********************!*\
|
|
|
!*** ./src/hls.ts ***!
|
|
|
\********************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return y}));var n=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),r=i(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),a=i(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),o=i(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),s=i(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=i(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),c=i(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),u=i(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),h=i(/*! ./is-supported */"./src/is-supported.ts"),d=i(/*! ./utils/logger */"./src/utils/logger.ts"),f=i(/*! ./config */"./src/config.ts"),p=i(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),m=i(/*! ./events */"./src/events.ts"),g=i(/*! ./errors */"./src/errors.ts");function v(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var y=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.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 i=this.config=Object(f.mergeConfig)(t.DefaultConfig,e);this.userConfig=e,Object(d.enableLogs)(i.debug),this._autoLevelCapping=-1,i.progressive&&Object(f.enableStreamingMode)(i);var n=i.abrController,h=i.bufferController,m=i.capLevelController,g=i.fpsController,v=this.abrController=new n(this),y=this.bufferController=new h(this),b=this.capLevelController=new m(this),x=new g(this),S=new r.default(this),C=new a.default(this),k=new o.default(this),E=this.levelController=new l.default(this),w=new c.FragmentTracker(this),T=this.streamController=new u.default(this,w);b.setStreamController(T),x.setStreamController(T);var O=[E,T];this.networkControllers=O;var L=[S,C,v,y,b,x,k,w];this.audioTrackController=this.createController(i.audioTrackController,null,O),this.createController(i.audioStreamController,w,O),this.subtitleTrackController=this.createController(i.subtitleTrackController,null,O),this.createController(i.subtitleStreamController,w,O),this.createController(i.timelineController,null,L),this.emeController=this.createController(i.emeController,null,L),this.cmcdController=this.createController(i.cmcdController,null,L),this.latencyController=this.createController(s.default,null,L),this.coreComponents=L}t.isSupported=function(){return Object(h.isSupported)()};var e,i,y,b=t.prototype;return b.createController=function(t,e,i){if(t){var n=e?new t(this,e):new t(this);return i&&i.push(n),n}return null},b.on=function(t,e,i){void 0===i&&(i=this),this._emitter.on(t,e,i)},b.once=function(t,e,i){void 0===i&&(i=this),this._emitter.once(t,e,i)},b.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},b.off=function(t,e,i,n){void 0===i&&(i=this),this._emitter.off(t,e,i,n)},b.listeners=function(t){return this._emitter.listeners(t)},b.emit=function(t,e,i){return this._emitter.emit(t,e,i)},b.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){d.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(m.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},b.listenerCount=function(t){return this._emitter.listenerCount(t)},b.destroy=function(){d.logger.log("destroy"),this.trigger(m.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},b.attachMedia=function(t){d.logger.log("attachMedia"),this._media=t,this.trigger(m.Events.MEDIA_ATTACHING,{media:t})},b.detachMedia=function(){d.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},b.loadSource=function(t){this.stopLoad();var e=this.media,i=this.url,r=this.url=n.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});d.logger.log("loadSource:"+r),e&&i&&i!==r&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(m.Events.MANIFEST_LOADING,{url:t})},b.startLoad=function(t){void 0===t&&(t=-1),d.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},b.stopLoad=function(){d.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},b.swapAudioCodec=function(){d.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},b.recoverMediaError=function(){d.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},b.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},e=t,y=[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return g.ErrorTypes}},{key:"ErrorDetails",get:function(){return g.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:f.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}],(i=[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){d.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){d.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){d.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){d.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){d.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(d.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var i=t.length,n=0;n<i;n++)if(t[n].maxBitrate>e)return n;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping;return-1===e&&t&&t.length?t.length-1:e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{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}}])&&v(e.prototype,i),y&&v(e,y),t}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/is-supported.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isSupported, changeTypeSupported */function(t,e,i){"use strict";i.r(e),i.d(e,"isSupported",(function(){return a})),i.d(e,"changeTypeSupported",(function(){return o}));var n=i(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function r(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var t=Object(n.getMediaSource)();if(!t)return!1;var e=r(),i=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!i&&!!a}function o(){var t,e=r();return"function"==typeof(null==e||null===(t=e.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/fragment-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/fragment-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default, LoadError */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return h})),i.d(e,"LoadError",(function(){return f}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../errors */"./src/errors.ts");function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return o(t,arguments,c(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,t)})(t)}function o(t,e,i){return(o=s()?Reflect.construct:function(t,e,i){var n=[null];n.push.apply(n,e);var r=new(Function.bind.apply(t,n));return i&&l(r,i.prototype),r}).apply(null,arguments)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u=Math.pow(2,17),h=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var i=this,n=t.url;if(!n)return Promise.reject(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,o=a.fLoader,s=a.loader;return new Promise((function(n,l){i.loader&&i.loader.destroy();var c=i.loader=t.loader=o?new o(a):new s(a),h=d(t),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:u};t.stats=c.stats,c.load(h,p,{onSuccess:function(e,r,a,o){i.resetLoader(t,c),n({frag:t,part:null,payload:e.data,networkDetails:o})},onError:function(e,n,a){i.resetLoader(t,c),l(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:e,networkDetails:a}))},onAbort:function(e,n,a){i.resetLoader(t,c),l(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:a}))},onTimeout:function(e,n,a){i.resetLoader(t,c),l(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:a}))},onProgress:function(i,n,r,a){e&&e({frag:t,part:null,payload:r,networkDetails:a})}})}))},e.loadPart=function(t,e,i){var n=this;this.abort();var a=this.config,o=a.fLoader,s=a.loader;return new Promise((function(l,c){n.loader&&n.loader.destroy();var h=n.loader=t.loader=o?new o(a):new s(a),p=d(t,e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:u};e.stats=h.stats,h.load(p,m,{onSuccess:function(r,a,o,s){n.resetLoader(t,h),n.updateStatsFromPart(t,e);var c={frag:t,part:e,payload:r.data,networkDetails:s};i(c),l(c)},onError:function(i,a,o){n.resetLoader(t,h),c(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:i,networkDetails:o}))},onAbort:function(i,a,o){t.stats.aborted=e.stats.aborted,n.resetLoader(t,h),c(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,networkDetails:o}))},onTimeout:function(i,a,o){n.resetLoader(t,h),c(new f({type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,networkDetails:o}))}})}))},e.updateStatsFromPart=function(t,e){var i=t.stats,n=e.stats,r=n.total;if(i.loaded+=n.loaded,r){var a=Math.round(t.duration/e.duration),o=Math.min(Math.round(i.loaded/r),a),s=(a-o)*Math.round(i.loaded/o);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);var l=i.loading,c=n.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function d(t,e){void 0===e&&(e=null);var i=e||t,r={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},a=i.byteRangeStartOffset,o=i.byteRangeEndOffset;return Object(n.isFiniteNumber)(a)&&Object(n.isFiniteNumber)(o)&&(r.rangeStart=a,r.rangeEnd=o),r}var f=function(t){var e,i;function n(e){for(var i,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return(i=t.call.apply(t,[this].concat(r))||this).data=void 0,i.data=e,i}return i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,l(e,i),n}(a(Error))},"./src/loader/fragment.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/loader/fragment.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,e,i){"use strict";i.r(e),i.d(e,"ElementaryStreamTypes",(function(){return n})),i.d(e,"BaseSegment",(function(){return f})),i.d(e,"Fragment",(function(){return p})),i.d(e,"Part",(function(){return m}));var n,r=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ./level-key */"./src/loader/level-key.ts"),l=i(/*! ./load-stats */"./src/loader/load-stats.ts");function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(n||(n={}));var f=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[n.AUDIO]=null,e[n.VIDEO]=null,e[n.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var i=t.split("@",2),n=[];1===i.length?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n},d(t,[{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(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),p=function(t){function e(e,i){var n;return(n=t.call(this,i)||this)._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new l.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=e,n}c(e,t);var i=e.prototype;return i.createInitializationVector=function(t){for(var e=new Uint8Array(16),i=12;i<16;i++)e[i]=t>>8*(15-i)&255;return e},i.setDecryptDataFromLevelKey=function(t,e){var i=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((i=s.LevelKey.fromURI(t.uri)).method=t.method,i.iv=this.createInitializationVector(e),i.keyFormat="identity"),i},i.setElementaryStreamInfo=function(t,e,i,n,r,a){void 0===a&&(a=!1);var o=this.elementaryStreams,s=o[t];s?(s.startPTS=Math.min(s.startPTS,e),s.endPTS=Math.max(s.endPTS,i),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,r)):o[t]={startPTS:e,endPTS:i,startDTS:n,endDTS:r,partial:a}},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[n.AUDIO]=null,t[n.VIDEO]=null,t[n.AUDIOVIDEO]=null},d(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var t=this.sn;"number"!=typeof t&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&o.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),t=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,t)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(r.isFiniteNumber)(this.programDateTime))return null;var t=Object(r.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;return!(null===(t=this.decryptdata)||void 0===t||!t.keyFormat||!this.decryptdata.uri)}}]),e}(f),m=function(t){function e(e,i,n,r,a){var o;(o=t.call(this,n)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new l.LoadStats,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=i,o.index=r;var s=e.enumeratedString("BYTERANGE");return s&&o.setByteRange(s,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return c(e,t),d(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(f)},"./src/loader/key-loader.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/key-loader.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return o}));var n=i(/*! ../events */"./src/events.ts"),r=i(/*! ../errors */"./src/errors.ts"),a=i(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function t(t){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){this.hls.on(n.Events.KEY_LOADING,this.onKeyLoading,this)},e._unregisterListeners=function(){this.hls.off(n.Events.KEY_LOADING,this.onKeyLoading)},e.destroy=function(){for(var t in this._unregisterListeners(),this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={}},e.onKeyLoading=function(t,e){var i=e.frag,r=i.type,o=this.loaders[r];if(i.decryptdata){var s=i.decryptdata.uri;if(s!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(o&&(a.logger.warn("abort previous key loader for type:"+r),o.abort()),!s)return void a.logger.warn("key uri is falsy");var c=l.loader,u=i.loader=this.loaders[r]=new c(l);this.decrypturl=s,this.decryptkey=null;var h={url:s,frag:i,responseType:"arraybuffer"},d={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(h,d,f)}else this.decryptkey&&(i.decryptdata.key=this.decryptkey,this.hls.trigger(n.Events.KEY_LOADED,{frag:i}))}else a.logger.warn("Missing decryption data on fragment in onKeyLoading")},e.loadsuccess=function(t,e,i){var r=i.frag;r.decryptdata?(this.decryptkey=r.decryptdata.key=new Uint8Array(t.data),r.loader=null,delete this.loaders[r.type],this.hls.trigger(n.Events.KEY_LOADED,{frag:r})):a.logger.error("after key load, decryptdata unset")},e.loaderror=function(t,e){var i=e.frag,a=i.loader;a&&a.abort(),delete this.loaders[i.type],this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:i,response:t})},e.loadtimeout=function(t,e){var i=e.frag,a=i.loader;a&&a.abort(),delete this.loaders[i.type],this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:i})},t}()},"./src/loader/level-details.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/loader/level-details.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: LevelDetails */function(t,e,i){"use strict";i.r(e),i.d(e,"LevelDetails",(function(){return a}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=function(){function t(t){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=t}var e,i,a;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},e=t,(i=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(n.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&r(e.prototype,i),a&&r(e,a),t}()},"./src/loader/level-key.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/loader/level-key.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: LevelKey */function(t,e,i){"use strict";i.r(e),i.d(e,"LevelKey",(function(){return a}));var n=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=function(){function t(t,e){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=e?Object(n.buildAbsoluteURL)(t,e,{alwaysNormalize:!0}):t}var e,i,a;return t.fromURL=function(e,i){return new t(e,i)},t.fromURI=function(e){return new t(e)},e=t,(i=[{key:"uri",get:function(){return this._uri}}])&&r(e.prototype,i),a&&r(e,a),t}()},"./src/loader/load-stats.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/load-stats.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: LoadStats */function(t,e,i){"use strict";i.r(e),i.d(e,"LoadStats",(function(){return n}));var n=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":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/loader/m3u8-parser.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return g}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=i(/*! ./fragment */"./src/loader/fragment.ts"),o=i(/*! ./level-details */"./src/loader/level-details.ts"),s=i(/*! ./level-key */"./src/loader/level-key.ts"),l=i(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),c=i(/*! ../utils/logger */"./src/utils/logger.ts"),u=i(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,d=/#EXT-X-MEDIA:(.*)/g,f=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=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("|")),m=/\.(mp4|m4s|m4v|m4a)$/i,g=function(){function t(){}return t.findGroup=function(t,e){for(var i=0;i<t.length;i++){var n=t[i];if(n.id===e)return n}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).substr(-4)}return t},t.resolve=function(t,e){return r.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(e,i){var n,r=[],a={},o=!1;for(h.lastIndex=0;null!=(n=h.exec(e));)if(n[1]){var s=new l.AttrList(n[1]),c={attrs:s,bitrate:s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),name:s.NAME,url:t.resolve(n[2],i)},u=s.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),v((s.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),c),c.videoCodec&&-1!==c.videoCodec.indexOf("avc1")&&(c.videoCodec=t.convertAVC1ToAVCOTI(c.videoCodec)),r.push(c)}else if(n[3]){var d=new l.AttrList(n[3]);d["DATA-ID"]&&(o=!0,a[d["DATA-ID"]]=d)}return{levels:r,sessionData:o?a:null}},t.parseMasterPlaylistMedia=function(e,i,n,r){var a;void 0===r&&(r=[]);var o=[],s=0;for(d.lastIndex=0;null!==(a=d.exec(e));){var c=new l.AttrList(a[1]);if(c.TYPE===n){var u={attrs:c,bitrate:0,id:s++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:n,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?t.resolve(c.URI,i):""};if(r.length){var h=t.findGroup(r,u.groupId)||r[0];y(u,h,"audioCodec"),y(u,h,"textCodec")}o.push(u)}}return o},t.parseLevelPlaylist=function(t,e,i,u,h){var d,g,v,y=new o.LevelDetails(e),x=y.fragments,S=null,C=0,k=0,E=0,w=0,T=null,O=new a.Fragment(u,e),L=-1,A=!1;for(f.lastIndex=0,y.m3u8=t;null!==(d=f.exec(t));){A&&(A=!1,(O=new a.Fragment(u,e)).start=E,O.sn=C,O.cc=w,O.level=i,S&&(O.initSegment=S,O.rawProgramDateTime=S.rawProgramDateTime));var D=d[1];if(D){O.duration=parseFloat(D);var _=(" "+d[2]).slice(1);O.title=_||null,O.tagList.push(_?["INF",D,_]:["INF",D])}else if(d[3])Object(n.isFiniteNumber)(O.duration)&&(O.start=E,v&&(O.levelkey=v),O.sn=C,O.level=i,O.cc=w,O.urlId=h,x.push(O),O.relurl=(" "+d[3]).slice(1),b(O,T),T=O,E+=O.duration,C++,k=0,A=!0);else if(d[4]){var R=(" "+d[4]).slice(1);T?O.setByteRange(R,T):O.setByteRange(R)}else if(d[5])O.rawProgramDateTime=(" "+d[5]).slice(1),O.tagList.push(["PROGRAM-DATE-TIME",O.rawProgramDateTime]),-1===L&&(L=x.length);else{if(!(d=d[0].match(p))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(g=1;g<d.length&&void 0===d[g];g++);var I=(" "+d[g]).slice(1),M=(" "+d[g+1]).slice(1),N=d[g+2]?(" "+d[g+2]).slice(1):"";switch(I){case"PLAYLIST-TYPE":y.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":C=y.startSN=parseInt(M);break;case"SKIP":var P=new l.AttrList(M),F=P.decimalInteger("SKIPPED-SEGMENTS");if(Object(n.isFiniteNumber)(F)){y.skippedSegments=F;for(var j=F;j--;)x.unshift(null);C+=F}var B=P.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(y.recentlyRemovedDateranges=B.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(M);break;case"VERSION":y.version=parseInt(M);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(M||N)&&O.tagList.push(N?[M,N]:[M]);break;case"DIS":w++;case"GAP":O.tagList.push([I]);break;case"BITRATE":O.tagList.push([I,M]);break;case"DISCONTINUITY-SEQ":w=parseInt(M);break;case"KEY":var U,H=new l.AttrList(M),G=H.enumeratedString("METHOD"),z=H.URI,V=H.hexadecimalInteger("IV"),W=H.enumeratedString("KEYFORMATVERSIONS"),K=H.enumeratedString("KEYID"),q=null!=(U=H.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){c.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(v=s.LevelKey.fromURL(e,z),z&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(v.method=G,v.keyFormat=q,K&&(v.keyID=K),W&&(v.keyFormatVersions=W),v.iv=V));break;case"START":var Y=new l.AttrList(M).decimalFloatingPoint("TIME-OFFSET");Object(n.isFiniteNumber)(Y)&&(y.startTimeOffset=Y);break;case"MAP":var X=new l.AttrList(M);O.relurl=X.URI,X.BYTERANGE&&O.setByteRange(X.BYTERANGE),O.level=i,O.sn="initSegment",v&&(O.levelkey=v),O.initSegment=null,S=O,A=!0;break;case"SERVER-CONTROL":var $=new l.AttrList(M);y.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),y.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Z=new l.AttrList(M);y.partTarget=Z.decimalFloatingPoint("PART-TARGET");break;case"PART":var J=y.partList;J||(J=y.partList=[]);var Q=k>0?J[J.length-1]:void 0,tt=k++,et=new a.Part(new l.AttrList(M),O,e,tt,Q);J.push(et),O.duration+=et.duration;break;case"PRELOAD-HINT":var it=new l.AttrList(M);y.preloadHint=it;break;case"RENDITION-REPORT":var nt=new l.AttrList(M);y.renditionReports=y.renditionReports||[],y.renditionReports.push(nt);break;default:c.logger.warn("line parsed but not handled: "+d)}}}T&&!T.relurl?(x.pop(),E-=T.duration,y.partList&&(y.fragmentHint=T)):y.partList&&(b(O,T),O.cc=w,y.fragmentHint=O);var rt=x.length,at=x[0],ot=x[rt-1];if((E+=y.skippedSegments*y.targetduration)>0&&rt&&ot){y.averagetargetduration=E/rt;var st=ot.sn;y.endSN="initSegment"!==st?st:0,at&&(y.startCC=at.cc,at.initSegment||y.fragments.every((function(t){return t.relurl&&(e=t.relurl,m.test(null!=(i=null===(n=r.parseURL(e))||void 0===n?void 0:n.path)?i:""));var e,i,n}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(O=new a.Fragment(u,e)).relurl=ot.relurl,O.level=i,O.sn="initSegment",at.initSegment=O,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(E+=y.fragmentHint.duration),y.totalduration=E,y.endCC=w,L>0&&function(t,e){for(var i=t[e],n=e;n--;){var r=t[n];if(!r)return;r.programDateTime=i.programDateTime-1e3*r.duration,i=r}}(x,L),y},t}();function v(t,e){["video","audio","text"].forEach((function(i){var n=t.filter((function(t){return Object(u.isCodecType)(t,i)}));if(n.length){var r=n.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[i+"Codec"]=r.length>0?r[0]:n[0],t=t.filter((function(t){return-1===n.indexOf(t)}))}})),e.unknownCodecs=t}function y(t,e,i){var n=e[i];n&&(t[i]=n)}function b(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Object(n.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/playlist-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../events */"./src/events.ts"),a=i(/*! ../errors */"./src/errors.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=i(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),u=i(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function h(t,e){var i=t.url;return void 0!==i&&0!==i.indexOf("data:")||(i=e.url),i}var d=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(r.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(r.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,i=e.pLoader,n=e.loader,r=new(i||n)(e);return t.loader=r,this.loaders[t.type]=r,r},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var i=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:c.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var i=e.id,n=e.level,r=e.url,a=e.deliveryDirectives;this.load({id:i,groupId:null,level:n,responseType:"text",type:c.PlaylistContextType.LEVEL,url:r,deliveryDirectives:a})},e.onAudioTrackLoading=function(t,e){var i=e.id,n=e.groupId,r=e.url,a=e.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:c.PlaylistContextType.AUDIO_TRACK,url:r,deliveryDirectives:a})},e.onSubtitleTrackLoading=function(t,e){var i=e.id,n=e.groupId,r=e.url,a=e.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:c.PlaylistContextType.SUBTITLE_TRACK,url:r,deliveryDirectives:a})},e.load=function(t){var e,i,n,r,a,s,l=this.hls.config,u=this.getInternalLoader(t);if(u){var h=u.context;if(h&&h.url===t.url)return void o.logger.trace("[playlist-loader]: playlist request ongoing");o.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}switch(t.type){case c.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,r=l.manifestLoadingRetryDelay,a=l.manifestLoadingMaxRetryTimeout;break;case c.PlaylistContextType.LEVEL:case c.PlaylistContextType.AUDIO_TRACK:case c.PlaylistContextType.SUBTITLE_TRACK:i=0,n=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,r=l.levelLoadingRetryDelay,a=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(t),null!==(e=t.deliveryDirectives)&&void 0!==e&&e.part&&(t.type===c.PlaylistContextType.LEVEL&&null!==t.level?s=this.hls.levels[t.level].details:t.type===c.PlaylistContextType.AUDIO_TRACK&&null!==t.id?s=this.hls.audioTracks[t.id].details:t.type===c.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(s=this.hls.subtitleTracks[t.id].details),s)){var d=s.partTarget,f=s.targetduration;d&&f&&(n=Math.min(1e3*Math.max(3*d,.8*f),n))}var p={timeout:n,maxRetry:i,retryDelay:r,maxRetryDelay:a,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(t,p,m)},e.loadsuccess=function(t,e,i,n){if(void 0===n&&(n=null),i.isSidxRequest)return this.handleSidxRequest(t,i),void this.handlePlaylistLoaded(t,e,i,n);this.resetInternalLoader(i.type);var r=t.data;0===r.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),r.indexOf("#EXTINF:")>0||r.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,e,i,n):this.handleMasterPlaylist(t,e,i,n)):this.handleManifestParsingError(t,i,"no EXTM3U delimiter",n)},e.loaderror=function(t,e,i){void 0===i&&(i=null),this.handleNetworkError(e,i,!1,t)},e.loadtimeout=function(t,e,i){void 0===i&&(i=null),this.handleNetworkError(e,i,!0)},e.handleMasterPlaylist=function(t,e,i,n){var a=this.hls,s=t.data,c=h(t,i),d=l.default.parseMasterPlaylist(s,c),f=d.levels,p=d.sessionData;if(f.length){var m=f.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),g=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),v=l.default.parseMasterPlaylistMedia(s,c,"AUDIO",m),y=l.default.parseMasterPlaylistMedia(s,c,"SUBTITLES",g),b=l.default.parseMasterPlaylistMedia(s,c,"CLOSED-CAPTIONS");v.length&&(v.some((function(t){return!t.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(o.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new u.AttrList({}),bitrate:0,url:""}))),a.trigger(r.Events.MANIFEST_LOADED,{levels:f,audioTracks:v,subtitles:y,captions:b,url:c,stats:e,networkDetails:n,sessionData:p})}else this.handleManifestParsingError(t,i,"no level found in manifest",n)},e.handleTrackOrLevelPlaylist=function(t,e,i,o){var s=this.hls,d=i.id,f=i.level,p=i.type,m=h(t,i),g=Object(n.isFiniteNumber)(d)?d:0,v=Object(n.isFiniteNumber)(f)?f:g,y=function(t){switch(t.type){case c.PlaylistContextType.AUDIO_TRACK:return c.PlaylistLevelType.AUDIO;case c.PlaylistContextType.SUBTITLE_TRACK:return c.PlaylistLevelType.SUBTITLE;default:return c.PlaylistLevelType.MAIN}}(i),b=l.default.parseLevelPlaylist(t.data,m,v,y,g);if(b.fragments.length){if(p===c.PlaylistContextType.MANIFEST){var x={attrs:new u.AttrList({}),bitrate:0,details:b,name:"",url:m};s.trigger(r.Events.MANIFEST_LOADED,{levels:[x],audioTracks:[],url:m,stats:e,networkDetails:o,sessionData:null})}if(e.parsing.end=performance.now(),b.needSidxRanges){var S,C=null===(S=b.fragments[0].initSegment)||void 0===S?void 0:S.url;this.load({url:C,isSidxRequest:!0,type:p,level:f,levelDetails:b,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else i.levelDetails=b,this.handlePlaylistLoaded(t,e,i,o)}else s.trigger(r.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:"number"==typeof i.level?i.level:void 0})},e.handleSidxRequest=function(t,e){var i=Object(s.parseSegmentIndex)(new Uint8Array(t.data));if(i){var n=i.references,r=e.levelDetails;n.forEach((function(t,e){var n=t.info,a=r.fragments[e];0===a.byteRange.length&&a.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),a.initSegment&&a.initSegment.setByteRange(String(i.moovEndOffset)+"@0")}))}},e.handleManifestParsingError=function(t,e,i,n){this.hls.trigger(r.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===c.PlaylistContextType.MANIFEST,url:t.url,reason:i,response:t,context:e,networkDetails:n})},e.handleNetworkError=function(t,e,i,n){void 0===i&&(i=!1),o.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var s=a.ErrorDetails.UNKNOWN,l=!1,u=this.getInternalLoader(t);switch(t.type){case c.PlaylistContextType.MANIFEST:s=i?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case c.PlaylistContextType.LEVEL:s=i?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.AUDIO_TRACK:s=i?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case c.PlaylistContextType.SUBTITLE_TRACK:s=i?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(t.type);var h={type:a.ErrorTypes.NETWORK_ERROR,details:s,fatal:l,url:t.url,loader:u,context:t,networkDetails:e};n&&(h.response=n),this.hls.trigger(r.Events.ERROR,h)},e.handlePlaylistLoaded=function(t,e,i,n){var a=i.type,o=i.level,s=i.id,l=i.groupId,u=i.loader,h=i.levelDetails,d=i.deliveryDirectives;if(null!=h&&h.targetduration){if(u)switch(h.live&&(u.getCacheAge&&(h.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(h.ageHeader)||(h.ageHeader=0)),a){case c.PlaylistContextType.MANIFEST:case c.PlaylistContextType.LEVEL:this.hls.trigger(r.Events.LEVEL_LOADED,{details:h,level:o||0,id:s||0,stats:e,networkDetails:n,deliveryDirectives:d});break;case c.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(r.Events.AUDIO_TRACK_LOADED,{details:h,id:s||0,groupId:l||"",stats:e,networkDetails:n,deliveryDirectives:d});break;case c.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(r.Events.SUBTITLE_TRACK_LOADED,{details:h,id:s||0,groupId:l||"",stats:e,networkDetails:n,deliveryDirectives:d})}}else this.handleManifestParsingError(t,i,"invalid target duration",n)},t}();e.default=d},"./src/polyfills/number.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/polyfills/number.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,e,i){"use strict";i.r(e),i.d(e,"isFiniteNumber",(function(){return n})),i.d(e,"MAX_SAFE_INTEGER",(function(){return r}));var n=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},r=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/remux/aac-helper.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=function(){function t(){}return t.getSilentFrame=function(t,e){switch(t){case"mp4a.40.2":if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)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(6===e)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(1===e)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(2===e)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(3===e)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])}},t}();e.default=n},"./src/remux/mp4-generator.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/remux/mp4-generator.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=Math.pow(2,32)-1,r=function(){function t(){}return t.init=function(){var e;for(e in t.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:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var i=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=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]);t.HDLR_TYPES={video:i,audio:n};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=a,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,o,l,o,s),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,r))},t.box=function(t){for(var e=8,i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];for(var a=n.length,o=a;a--;)e+=n[a].byteLength;var s=new Uint8Array(e);for(s[0]=e>>24&255,s[1]=e>>16&255,s[2]=e>>8&255,s[3]=255&e,s.set(t,4),a=0,e=8;a<o;a++)s.set(n[a],e),e+=n[a].byteLength;return s},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,i){i*=e;var r=Math.floor(i/(n+1)),a=Math.floor(i%(n+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,i,n){return t.box(t.types.moof,t.mfhd(e),t.traf(n,i))},t.moov=function(e){for(var i=e.length,n=[];i--;)n[i]=t.trak(e[i]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(n).concat(t.mvex(e)))},t.mvex=function(e){for(var i=e.length,n=[];i--;)n[i]=t.trex(e[i]);return t.box.apply(null,[t.types.mvex].concat(n))},t.mvhd=function(e,i){i*=e;var r=Math.floor(i/(n+1)),a=Math.floor(i%(n+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,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 t.box(t.types.mvhd,o)},t.sdtp=function(e){var i,n,r=e.samples||[],a=new Uint8Array(4+r.length);for(i=0;i<r.length;i++)n=r[i].flags,a[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return t.box(t.types.sdtp,a)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var i,n,r,a=[],o=[];for(i=0;i<e.sps.length;i++)r=(n=e.sps[i]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(n));for(i=0;i<e.pps.length;i++)r=(n=e.pps[i]).byteLength,o.push(r>>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(n));var s=t.box(t.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|e.sps.length].concat(a).concat([e.pps.length]).concat(o))),l=e.width,c=e.height,u=e.pixelRatio[0],h=e.pixelRatio[1];return t.box(t.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,l>>8&255,255&l,c>>8&255,255&c,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]),s,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var i=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,i>>8&255,255&i,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var i=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,i>>8&255,255&i,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var i=e.id,r=e.duration*e.timescale,a=e.width,o=e.height,s=Math.floor(r/(n+1)),l=Math.floor(r%(n+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l,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,a>>8&255,255&a,0,0,o>>8&255,255&o,0,0]))},t.traf=function(e,i){var r=t.sdtp(e),a=e.id,o=Math.floor(i/(n+1)),s=Math.floor(i%(n+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,r.length+16+20+8+16+8+8),r)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var i=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,i){var n,r,a,o,s,l,c=e.samples||[],u=c.length,h=12+16*u,d=new Uint8Array(h);for(i+=8+h,d.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),n=0;n<u;n++)a=(r=c[n]).duration,o=r.size,s=r.flags,l=r.cts,d.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return t.box(t.types.trun,d)},t.initSegment=function(e){t.types||t.init();var i=t.moov(e),n=new Uint8Array(t.FTYP.byteLength+i.byteLength);return n.set(t.FTYP),n.set(i,t.FTYP.byteLength),n},t}();r.types=void 0,r.HDLR_TYPES=void 0,r.STTS=void 0,r.STSC=void 0,r.STCO=void 0,r.STSZ=void 0,r.VMHD=void 0,r.SMHD=void 0,r.STSD=void 0,r.FTYP=void 0,r.DINF=void 0,e.default=r},"./src/remux/mp4-remuxer.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default, normalizePts */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return m})),i.d(e,"normalizePts",(function(){return g}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ./aac-helper */"./src/remux/aac-helper.ts"),a=i(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),o=i(/*! ../events */"./src/events.ts"),s=i(/*! ../errors */"./src/errors.ts"),l=i(/*! ../utils/logger */"./src/utils/logger.ts"),c=i(/*! ../types/loader */"./src/types/loader.ts"),u=i(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var d=null,f=null,p=!1,m=function(){function t(t,e,i,n){if(void 0===n&&(n=""),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=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,null===d){var r=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);d=r?parseInt(r[1]):0}if(null===f){var a=navigator.userAgent.match(/Safari\/(\d+)/i);f=a?parseInt(a[1]):0}p=!!d&&d<75||!!f&&f<600}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,i=t.reduce((function(t,i){var n=i.pts-t;return n<-4294967296?(e=!0,g(t,i.pts)):n>0?t:i.pts}),t[0].pts);return e&&l.logger.debug("PTS rollover detected"),i},e.remux=function(t,e,i,n,r,a,o,s){var u,h,d,f,p,m,v=r,y=r,b=t.pid>-1,x=e.pid>-1,S=e.samples.length,C=t.samples.length>0,k=S>1;if((!b||C)&&(!x||k)||this.ISGenerated||o){this.ISGenerated||(d=this.generateIS(t,e,r));var E=this.isVideoContiguous,w=-1;if(k&&(w=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!E&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,w>0){l.logger.warn("[mp4-remuxer]: Dropped "+w+" out of "+S+" video samples due to a missing keyframe");var T=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(w),e.dropped+=w,y+=(e.samples[0].pts-T)/(e.timescale||9e4)}else-1===w&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),m=!1);if(this.ISGenerated){if(C&&k){var O=this.getVideoStartPts(e.samples),L=(g(t.samples[0].pts,O)-O)/e.inputTimeScale;v+=Math.max(0,L),y+=Math.max(0,-L)}if(C){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,r)),h=this.remuxAudio(t,v,this.isAudioContiguous,a,x||k||s===c.PlaylistLevelType.AUDIO?y:void 0),k){var A=h?h.endPTS-h.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,r)),u=this.remuxVideo(e,y,E,A)}}else k&&(u=this.remuxVideo(e,y,E,0));u&&(u.firstKeyFrame=w,u.independent=-1!==w)}}return this.ISGenerated&&(i.samples.length&&(p=this.remuxID3(i,r)),n.samples.length&&(f=this.remuxText(n,r))),{audio:h,video:u,initSegment:d,independent:m,text:f,id3:p}},e.generateIS=function(t,e,i){var r,o,s,l=t.samples,c=e.samples,u=this.typeSupported,h={},d=!Object(n.isFiniteNumber)(this._initPTS),f="audio/mp4";if(d&&(r=o=1/0),t.config&&l.length&&(t.timescale=t.samplerate,t.isAAC||(u.mpeg?(f="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")),h.audio={id:"audio",container:f,codec:t.codec,initSegment:!t.isAAC&&u.mpeg?new Uint8Array(0):a.default.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(s=t.inputTimeScale,r=o=l[0].pts-Math.round(s*i))),e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:a.default.initSegment([e]),metadata:{width:e.width,height:e.height}},d)){s=e.inputTimeScale;var p=this.getVideoStartPts(c),m=Math.round(s*i);o=Math.min(o,g(c[0].dts,p)-m),r=Math.min(r,p-m)}if(Object.keys(h).length)return this.ISGenerated=!0,d&&(this._initPTS=r,this._initDTS=o),{tracks:h,initPTS:r,timescale:s}},e.remuxVideo=function(t,e,i,n){var r,c,f,m=t.inputTimeScale,y=t.samples,b=[],x=y.length,S=this._initPTS,C=this.nextAvcDts,k=8,E=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,T=0,O=!1;i&&null!==C||(C=e*m-(y[0].pts-g(y[0].dts,y[0].pts)));for(var L=0;L<x;L++){var A=y[L];A.pts=g(A.pts-S,C),A.dts=g(A.dts-S,C),A.dts>A.pts&&(T=Math.max(Math.min(T,A.pts-A.dts),-18e3)),A.dts<y[L>0?L-1:L].dts&&(O=!0)}O&&y.sort((function(t,e){var i=t.dts-e.dts,n=t.pts-e.pts;return i||n})),c=y[0].dts,f=y[y.length-1].dts;var D=Math.round((f-c)/(x-1));if(T<0){if(T<-2*D){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(u.toMsFromMpegTsClock)(-D,!0)+" ms");for(var _=T,R=0;R<x;R++)y[R].dts=_=Math.max(_,y[R].pts-D),y[R].pts=Math.max(_,y[R].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(u.toMsFromMpegTsClock)(T,!0)+" ms to overcome this issue");for(var I=0;I<x;I++)y[I].dts=y[I].dts+T}c=y[0].dts}if(i){var M=c-C,N=M>D;if(N||M<-1){N?l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(M,!0)+" ms ("+M+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(-M,!0)+" ms ("+M+"dts) overlapping between fragments detected"),c=C;var P=y[0].pts-M;y[0].dts=c,y[0].pts=P,l.logger.log("Video: First PTS/DTS adjusted: "+Object(u.toMsFromMpegTsClock)(P,!0)+"/"+Object(u.toMsFromMpegTsClock)(c,!0)+", delta: "+Object(u.toMsFromMpegTsClock)(M,!0)+" ms")}}p&&(c=Math.max(0,c));for(var F=0,j=0,B=0;B<x;B++){for(var U=y[B],H=U.units,G=H.length,z=0,V=0;V<G;V++)z+=H[V].data.length;j+=z,F+=G,U.length=z,U.dts=Math.max(U.dts,c),U.pts=Math.max(U.pts,U.dts,0),E=Math.min(U.pts,E),w=Math.max(U.pts,w)}f=y[x-1].dts;var W,K=j+4*F+8;try{W=new Uint8Array(K)}catch(t){return void this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating video mdat "+K})}var q=new DataView(W.buffer);q.setUint32(0,K),W.set(a.default.types.mdat,4);for(var Y=0;Y<x;Y++){for(var X=y[Y],$=X.units,Z=0,J=0,Q=$.length;J<Q;J++){var tt=$[J],et=tt.data,it=tt.data.byteLength;q.setUint32(k,it),k+=4,W.set(et,k),k+=it,Z+=4+it}if(Y<x-1)r=y[Y+1].dts-X.dts;else{var nt=this.config,rt=X.dts-y[Y>0?Y-1:Y].dts;if(nt.stretchShortVideoTrack&&null!==this.nextAudioPts){var at=Math.floor(nt.maxBufferHole*m),ot=(n?E+n*m:this.nextAudioPts)-X.pts;ot>at?((r=ot-rt)<0&&(r=rt),l.logger.log("[mp4-remuxer]: It is approximately "+ot/90+" ms to the next segment; using duration "+r/90+" ms for the last video frame.")):r=rt}else r=rt}var st=Math.round(X.pts-X.dts);b.push(new v(X.key,r,Z,st))}if(b.length&&d&&d<70){var lt=b[0].flags;lt.dependsOn=2,lt.isNonSync=0}console.assert(void 0!==r,"mp4SampleDuration must be computed"),this.nextAvcDts=C=f+r,this.isVideoContiguous=!0;var ct={data1:a.default.moof(t.sequenceNumber++,c,h({},t,{samples:b})),data2:W,startPTS:E/m,endPTS:(w+r)/m,startDTS:c/m,endDTS:C/m,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(W.length,"MDAT length must not be zero"),ct},e.remuxAudio=function(t,e,i,n,c){var u=t.inputTimeScale,d=u/(t.samplerate?t.samplerate:u),f=t.isAAC?1024:1152,p=f*d,m=this._initPTS,y=!t.isAAC&&this.typeSupported.mpeg,b=[],x=t.samples,S=y?0:8,C=this.nextAudioPts||-1,k=e*u;if(this.isAudioContiguous=i=i||x.length&&C>0&&(n&&Math.abs(k-C)<9e3||Math.abs(g(x[0].pts-m,k)-C)<20*p),x.forEach((function(t){t.pts=g(t.pts-m,k)})),!i||C<0){if(!(x=x.filter((function(t){return t.pts>=0}))).length)return;C=0===c?0:n?Math.max(0,k):x[0].pts}if(t.isAAC)for(var E=void 0!==c,w=this.config.maxAudioFramesDrift,T=0,O=C;T<x.length;T++){var L=x[T],A=L.pts,D=A-O,_=Math.abs(1e3*D/u);if(D<=-w*p&&E)0===T&&(l.logger.warn("Audio frame @ "+(A/u).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/u)+" ms."),this.nextAudioPts=C=O=A);else if(D>=w*p&&_<1e4&&E){var R=Math.round(D/p);(O=A-R*p)<0&&(R--,O+=p),0===T&&(this.nextAudioPts=C=O),l.logger.warn("[mp4-remuxer]: Injecting "+R+" audio frame @ "+(O/u).toFixed(3)+"s due to "+Math.round(1e3*D/u)+" ms gap.");for(var I=0;I<R;I++){var M=Math.max(O,0),N=r.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);N||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),N=L.unit.subarray()),x.splice(T,0,{unit:N,pts:M}),O+=p,T++}}L.pts=O,O+=p}for(var P,F=null,j=null,B=0,U=x.length;U--;)B+=x[U].unit.byteLength;for(var H=0,G=x.length;H<G;H++){var z=x[H],V=z.unit,W=z.pts;if(null!==j)b[H-1].duration=Math.round((W-j)/d);else{if(i&&t.isAAC&&(W=C),F=W,!(B>0))return;B+=S;try{P=new Uint8Array(B)}catch(t){return void this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}y||(new DataView(P.buffer).setUint32(0,B),P.set(a.default.types.mdat,4))}P.set(V,S);var K=V.byteLength;S+=K,b.push(new v(!0,f,K,0)),j=W}var q=b.length;if(q){var Y=b[b.length-1];this.nextAudioPts=C=j+d*Y.duration;var X=y?new Uint8Array(0):a.default.moof(t.sequenceNumber++,F/d,h({},t,{samples:b}));t.samples=[];var $=F/u,Z=C/u,J={data1:X,data2:P,startPTS:$,endPTS:Z,startDTS:$,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(P.length,"MDAT length must not be zero"),J}},e.remuxEmptyAudio=function(t,e,i,n){var a=t.inputTimeScale,o=a/(t.samplerate?t.samplerate:a),s=this.nextAudioPts,c=(null!==s?s:n.startDTS*a)+this._initDTS,u=n.endDTS*a+this._initDTS,h=1024*o,d=Math.ceil((u-c)/h),f=r.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var p=[],m=0;m<d;m++){var g=c+m*h;p.push({unit:f,pts:g,dts:g})}return t.samples=p,this.remuxAudio(t,e,i,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e.remuxID3=function(t,e){var i=t.samples.length;if(i){for(var n=t.inputTimeScale,r=this._initPTS,a=this._initDTS,o=0;o<i;o++){var s=t.samples[o];s.pts=g(s.pts-r,e*n)/n,s.dts=g(s.dts-a,e*n)/n}var l=t.samples;return t.samples=[],{samples:l}}},e.remuxText=function(t,e){var i=t.samples.length;if(i){for(var n=t.inputTimeScale,r=this._initPTS,a=0;a<i;a++){var o=t.samples[a];o.pts=g(o.pts-r,e*n)/n}t.samples.sort((function(t,e){return t.pts-e.pts}));var s=t.samples;return t.samples=[],{samples:s}}},t}();function g(t,e){var i;if(null===e)return t;for(i=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=i;return t}var v=function(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags=new y(t)},y=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=i(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(){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 e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndDTS=null},e.resetNextTimestamp=function(){this.lastEndDTS=null},e.resetInitSegment=function(t,e,i){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(t),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,i=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=Object(r.parseInitSegment)(t);e||(e=c(n.audio,a.ElementaryStreamTypes.AUDIO)),i||(i=c(n.video,a.ElementaryStreamTypes.VIDEO));var s={};n.audio&&n.video?s.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?s.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?s.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},e.remux=function(t,e,i,a,s){var c=this.initPTS,u=this.lastEndDTS,h={audio:void 0,video:void 0,text:a,id3:i,initSegment:void 0};Object(n.isFiniteNumber)(u)||(u=this.lastEndDTS=s||0);var d=e.samples;if(!d||!d.length)return h;var f={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(d),p=this.initData),!p||!p.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(n.isFiniteNumber)(c)||(this.initPTS=f.initPTS=c=l(p,d,u));var m=Object(r.getDuration)(d,p),g=u,v=m+g;Object(r.offsetStartDTS)(p,d,c),m>0?this.lastEndDTS=v:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!p.audio,b=!!p.video,x="";y&&(x+="audio"),b&&(x+="video");var S={data1:d,startPTS:g,startDTS:g,endPTS:v,endDTS:v,type:x,hasAudio:y,hasVideo:b,nb:1,dropped:0};return h.audio="audio"===S.type?S:void 0,h.video="audio"!==S.type?S:void 0,h.text=a,h.id3=i,h.initSegment=f,h},t}(),l=function(t,e,i){return Object(r.getStartDTS)(t,e)-i};function c(t,e){var i=null==t?void 0:t.codec;return i&&i.length>4?i:"hvc1"===i?"hvc1.1.c.L120.90":"av01"===i?"av01.0.04M.08":"avc1"===i||e===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=s},"./src/task-loop.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/task-loop.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var n=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}()},"./src/types/cmcd.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/types/cmcd.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,e,i){"use strict";i.r(e),i.d(e,"CMCDVersion",(function(){return o})),i.d(e,"CMCDObjectType",(function(){return n})),i.d(e,"CMCDStreamingFormat",(function(){return r})),i.d(e,"CMCDStreamType",(function(){return a}));var n,r,a,o=1;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(n||(n={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(r||(r={})),function(t){t.VOD="v",t.LIVE="l"}(a||(a={}))},"./src/types/level.ts":
|
|
|
/*!****************************!*\
|
|
|
!*** ./src/types/level.ts ***!
|
|
|
\****************************/
|
|
|
/*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,e,i){"use strict";function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var r;function a(t,e){var i=t.canSkipUntil,n=t.canSkipDateRanges,a=t.endSN;return i&&(void 0!==e?e-a:0)<i?n?r.v2:r.Yes:r.No}i.r(e),i.d(e,"HlsSkip",(function(){return r})),i.d(e,"getSkipValue",(function(){return a})),i.d(e,"HlsUrlParameters",(function(){return o})),i.d(e,"Level",(function(){return s})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(r||(r={}));var o=function(){function t(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.toString()},t}(),s=function(){function t(t){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=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var e,i,r;return e=t,(i=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.details=void 0,this._urlId=e)}}])&&n(e.prototype,i),r&&n(e,r),t}()},"./src/types/loader.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/types/loader.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,e,i){"use strict";var n,r;i.r(e),i.d(e,"PlaylistContextType",(function(){return n})),i.d(e,"PlaylistLevelType",(function(){return r})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(n||(n={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(r||(r={}))},"./src/types/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/types/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: ChunkMetadata */function(t,e,i){"use strict";i.r(e),i.d(e,"ChunkMetadata",(function(){return n}));var n=function(t,e,i,n,r,a){void 0===n&&(n=0),void 0===r&&(r=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=r,this.partial=a}},"./src/utils/attr-list.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/attr-list.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: AttrList */function(t,e,i){"use strict";i.r(e),i.d(e,"AttrList",(function(){return a}));var n=/^(\d+)x(\d+)$/,r=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function t(e){for(var i in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(i)&&(this[i]=e[i])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var i=new Uint8Array(e.length/2),n=0;n<e.length/2;n++)i[n]=parseInt(e.slice(2*n,2*n+2),16);return i}return null},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var i=this[t];return i?parseFloat(i):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=n.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,i={};for(r.lastIndex=0;null!==(e=r.exec(t));){var n=e[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),i[e[1]]=n}return i},t}()},"./src/utils/binary-search.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/binary-search.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),e.default={search:function(t,e){for(var i=0,n=t.length-1,r=null,a=null;i<=n;){var o=e(a=t[r=(i+n)/2|0]);if(o>0)i=r+1;else{if(!(o<0))return a;n=r-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/buffer-helper.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: BufferHelper */function(t,e,i){"use strict";i.r(e),i.d(e,"BufferHelper",(function(){return a}));var n=i(/*! ./logger */"./src/utils/logger.ts"),r={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function t(){}return t.isBuffered=function(e,i){try{if(e)for(var n=t.getBuffered(e),r=0;r<n.length;r++)if(i>=n.start(r)&&i<=n.end(r))return!0}catch(t){}return!1},t.bufferInfo=function(e,i,n){try{if(e){var r,a=t.getBuffered(e),o=[];for(r=0;r<a.length;r++)o.push({start:a.start(r),end:a.end(r)});return this.bufferedInfo(o,i,n)}}catch(t){}return{len:0,start:i,end:i,nextStart:void 0}},t.bufferedInfo=function(t,e,i){e=Math.max(0,e),t.sort((function(t,e){var i=t.start-e.start;return i||e.end-t.end}));var n=[];if(i)for(var r=0;r<t.length;r++){var a=n.length;if(a){var o=n[a-1].end;t[r].start-o<i?t[r].end>o&&(n[a-1].end=t[r].end):n.push(t[r])}else n.push(t[r])}else n=t;for(var s,l=0,c=e,u=e,h=0;h<n.length;h++){var d=n[h].start,f=n[h].end;if(e+i>=d&&e<f)c=d,l=(u=f)-e;else if(e+i<d){s=d;break}}return{len:l,start:c||0,end:u||0,nextStart:s}},t.getBuffered=function(t){try{return t.buffered}catch(t){return n.logger.log("failed to get media.buffered",t),r}},t}()},"./src/utils/cea-608-parser.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/utils/cea-608-parser.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: Row, CaptionScreen, default */function(t,e,i){"use strict";i.r(e),i.d(e,"Row",(function(){return g})),i.d(e,"CaptionScreen",(function(){return v}));var n,r=i(/*! ../utils/logger */"./src/utils/logger.ts"),a={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},o=function(t){var e=t;return a.hasOwnProperty(t)&&(e=a[t]),String.fromCharCode(e)},s={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},c={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},u={25:2,26:4,29:6,30:8,31:10,27:13,28:15},h=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(n||(n={}));var d=function(){function t(){this.time=null,this.verboseLevel=n.ERROR}return t.prototype.log=function(t,e){this.verboseLevel>=t&&r.logger.log(this.time+" ["+t+"] "+e)},t}(),f=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i].toString(16));return e},p=function(){function t(t,e,i,n,r){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=i||!1,this.background=n||"black",this.flash=r||!1}var e=t.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],i=0;i<e.length;i++){var n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}},e.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),m=function(){function t(t,e,i,n,r,a){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(e,i,n,r,a)}var e=t.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,e){this.uchar=t,this.penState.copy(e)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),g=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var e=0;e<100;e++)this.chars.push(new m);this.logger=t,this.pos=0,this.currPenState=new p}var e=t.prototype;return e.equals=function(t){for(var e=!0,i=0;i<100;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<100;e++)this.chars[e].copy(t.chars[e])},e.isEmpty=function(){for(var t=!0,e=0;e<100;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(n.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(n.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var i=this.pos+1;i<e+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(e)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){t>=144&&this.backSpace();var e=o(t);this.pos>=100?this.logger.log(n.ERROR,"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))},e.clearFromPos=function(t){var e;for(e=t;e<100;e++)this.chars[e].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],e=!0,i=0;i<100;i++){var n=this.chars[i].uchar;" "!==n&&(e=!1),t.push(n)}return e?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),v=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new g(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=t.prototype;return e.reset=function(){for(var t=0;t<15;t++)this.rows[t].clear();this.currRow=14},e.equals=function(t){for(var e=!0,i=0;i<15;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<15;e++)this.rows[e].copy(t.rows[e])},e.isEmpty=function(){for(var t=!0,e=0;e<15;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t},e.backSpace=function(){this.rows[this.currRow].backSpace()},e.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},e.insertChar=function(t){this.rows[this.currRow].insertChar(t)},e.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},e.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},e.setCursor=function(t){this.logger.log(n.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},e.setPAC=function(t){this.logger.log(n.INFO,"pacData = "+JSON.stringify(t));var e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(var i=0;i<15;i++)this.rows[i].clear();var r=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var o=a.rows[r].cueStartTime,s=this.logger.time;if(o&&null!==s&&o<s)for(var l=0;l<this.nrRollUpRows;l++)this.rows[e-this.nrRollUpRows+l+1].copy(a.rows[r+l])}}this.currRow=e;var c=this.rows[this.currRow];if(null!==t.indent){var u=t.indent,h=Math.max(u-1,0);c.setCursor(t.indent),t.color=c.chars[h].penState.foreground}var d={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(d)},e.setBkgData=function(t){this.logger.log(n.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(n.TEXT,this.getDisplayText());var t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(n.INFO,"Rolling up")}else this.logger.log(n.DEBUG,"roll_up but nrRollUpRows not set yet")},e.getDisplayText=function(t){t=t||!1;for(var e=[],i="",n=-1,r=0;r<15;r++){var a=this.rows[r].getTextString();a&&(n=r+1,t?e.push("Row "+n+": '"+a+"'"):e.push(a.trim()))}return e.length>0&&(i=t?"["+e.join(" | ")+"]":e.join("\n")),i},e.getTextAndFormat=function(){return this.rows},t}(),y=function(){function t(t,e,i){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=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new v(i),this.nonDisplayedMemory=new v(i),this.lastOutputScreen=new v(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(n.INFO,"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=0;e<t.length;e++)this.writeScreen.insertChar(t[e]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(n.INFO,i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(n.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(n.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(n.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(n.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(n.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(n.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(n.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(n.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(n.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(n.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(n.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(n.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){if(this.logger.log(n.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(n.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(n.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{var i=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(n.INFO,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),b=function(){function t(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new d;this.channels=[null,new y(t,e,n),new y(t+1,i,n)],this.cmdHistory={a:null,b:null},this.logger=n}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var i,r,a,o=!1;this.logger.time=t;for(var s=0;s<e.length;s+=2)if(r=127&e[s],a=127&e[s+1],0!==r||0!==a){if(this.logger.log(n.DATA,"["+f([e[s],e[s+1]])+"] -> ("+f([r,a])+")"),(i=this.parseCmd(r,a))||(i=this.parseMidrow(r,a)),i||(i=this.parsePAC(r,a)),i||(i=this.parseBackgroundAttributes(r,a)),!i&&(o=this.parseChars(r,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(o):this.logger.log(n.WARNING,"No channel found yet. TEXT-MODE?")}i||o||this.logger.log(n.WARNING,"Couldn't parse cleaned data "+f([r,a])+" orig: "+f([e[s],e[s+1]]))}},e.parseCmd=function(t,e){var i=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(S(t,e,i))return x(null,null,i),this.logger.log(n.DEBUG,"Repeated command ("+f([t,e])+") is dropped"),!0;var r=20===t||21===t||23===t?1:2,a=this.channels[r];return 20===t||21===t||28===t||29===t?32===e?a.ccRCL():33===e?a.ccBS():34===e?a.ccAOF():35===e?a.ccAON():36===e?a.ccDER():37===e?a.ccRU(2):38===e?a.ccRU(3):39===e?a.ccRU(4):40===e?a.ccFON():41===e?a.ccRDC():42===e?a.ccTR():43===e?a.ccRTD():44===e?a.ccEDM():45===e?a.ccCR():46===e?a.ccENM():47===e&&a.ccEOC():a.ccTO(e-32),x(t,e,i),this.currentChannel=r,!0},e.parseMidrow=function(t,e){var i=0;if((17===t||25===t)&&e>=32&&e<=47){if((i=17===t?1:2)!==this.currentChannel)return this.logger.log(n.ERROR,"Mismatch channel in midrow parsing"),!1;var r=this.channels[i];return!!r&&(r.ccMIDROW(e),this.logger.log(n.DEBUG,"MIDROW ("+f([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var i,n=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(S(t,e,n))return x(null,null,n),!0;var r=t<=23?1:2;i=e>=64&&e<=95?1===r?s[t]:c[t]:1===r?l[t]:u[t];var a=this.channels[r];return!!a&&(a.setPAC(this.interpretPAC(i,e)),x(t,e,n),this.currentChannel=r,!0)},e.interpretPAC=function(t,e){var i,n={color:null,italics:!1,indent:null,underline:!1,row:t};return i=e>95?e-96:e-64,n.underline=1==(1&i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n},e.parseChars=function(t,e){var i,r,a=null,s=null;if(t>=25?(i=2,s=t-8):(i=1,s=t),s>=17&&s<=19?(r=17===s?e+80:18===s?e+112:e+144,this.logger.log(n.INFO,"Special char '"+o(r)+"' in channel "+i),a=[r]):t>=32&&t<=127&&(a=0===e?[t]:[t,e]),a){var l=f(a);this.logger.log(n.DEBUG,"Char codes = "+l.join(",")),x(t,e,this.cmdHistory)}return a},e.parseBackgroundAttributes=function(t,e){var i;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var n={};16===t||24===t?(i=Math.floor((e-32)/2),n.background=h[i],e%2==1&&(n.background=n.background+"_semi")):45===e?n.background="transparent":(n.foreground="black",47===e&&(n.underline=!0));var r=t<=23?1:2;return this.channels[r].setBkgData(n),x(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var e=this.channels[t];e&&e.reset()}this.cmdHistory={a:null,b:null}},e.cueSplitAtTime=function(t){for(var e=0;e<this.channels.length;e++){var i=this.channels[e];i&&i.cueSplitAtTime(t)}},t}();function x(t,e,i){i.a=t,i.b=e}function S(t,e,i){return i.a===t&&i.b===e}e.default=b},"./src/utils/codecs.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/codecs.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,e,i){"use strict";i.r(e),i.d(e,"isCodecType",(function(){return r})),i.d(e,"isCodecSupportedInMp4",(function(){return a}));var n={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 r(t,e){var i=n[e];return!!i&&!0===i[t.slice(0,4)]}function a(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/cues.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ./vttparser */"./src/utils/vttparser.ts"),r=i(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),a=i(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),o=/\s/,s={newCue:function(t,e,i,s){for(var l,c,u,h,d,f=[],p=self.VTTCue||self.TextTrackCue,m=0;m<s.rows.length;m++)if(u=!0,h=0,d="",!(l=s.rows[m]).isEmpty()){for(var g=0;g<l.chars.length;g++)o.test(l.chars[g].uchar)&&u?h++:(d+=l.chars[g].uchar,u=!1);l.cueStartTime=e,e===i&&(i+=1e-4),h>=16?h--:h++;var v=Object(n.fixLineBreaks)(d.trim()),y=Object(r.generateCueId)(e,i,v);t&&t.cues&&t.cues.getCueById(y)||((c=new p(e,i,v)).id=y,c.line=m+1,c.align="left",c.position=10+Math.min(80,10*Math.floor(8*h/32)),f.push(c))}return t&&f.length&&(f.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),f.forEach((function(e){return Object(a.addCueToTrack)(t,e)}))),f}};e.default=s},"./src/utils/discontinuities.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/discontinuities.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,e,i){"use strict";i.r(e),i.d(e,"findFirstFragWithCC",(function(){return o})),i.d(e,"shouldAlignOnDiscontinuities",(function(){return s})),i.d(e,"findDiscontinuousReferenceFrag",(function(){return l})),i.d(e,"adjustSlidingStart",(function(){return u})),i.d(e,"alignStream",(function(){return h})),i.d(e,"alignPDT",(function(){return d})),i.d(e,"alignFragmentByPDTDelta",(function(){return f})),i.d(e,"alignMediaPlaylistByPDT",(function(){return p}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ./logger */"./src/utils/logger.ts"),a=i(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function o(t,e){for(var i=null,n=0,r=t.length;n<r;n++){var a=t[n];if(a&&a.cc===e){i=a;break}}return i}function s(t,e,i){return!(!e.details||!(i.endCC>i.startCC||t&&t.cc<i.startCC))}function l(t,e){var i=t.fragments,n=e.fragments;if(n.length&&i.length){var a=o(i,n[0].cc);if(a&&(!a||a.startPTS))return a;r.logger.log("No frag in previous level to align on")}else r.logger.log("No fragments to align")}function c(t,e){if(t){var i=t.start+e;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function u(t,e){for(var i=e.fragments,n=0,r=i.length;n<r;n++)c(i[n],t);e.fragmentHint&&c(e.fragmentHint,t),e.alignedSliding=!0}function h(t,e,i){e&&(function(t,e,i){if(s(t,i,e)){var a=l(i.details,e);a&&Object(n.isFiniteNumber)(a.start)&&(r.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),u(a.start,e))}}(t,i,e),!i.alignedSliding&&e.details&&d(i,e.details),i.alignedSliding||!e.details||i.skippedSegments||Object(a.adjustSliding)(e.details,i))}function d(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var i=e.fragments[0].programDateTime,a=t.fragments[0].programDateTime,o=(a-i)/1e3+e.fragments[0].start;o&&Object(n.isFiniteNumber)(o)&&(r.logger.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),u(o,t))}}function f(t,e){var i=t.programDateTime;if(i){var n=(i-e)/1e3;t.start=t.startPTS=n,t.endPTS=n+t.duration}}function p(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var i=e.fragments[0].programDateTime-1e3*e.fragments[0].start;t.fragments.forEach((function(t){f(t,i)})),t.fragmentHint&&f(t.fragmentHint,i),t.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../utils/ewma */"./src/utils/ewma.ts"),r=function(){function t(t,e,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(t),this.fast_=new n.default(e)}var e=t.prototype;return e.update=function(t,e){var i=this.slow_,r=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new n.default(t,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new n.default(e,r.getEstimate(),r.getTotalWeight()))},e.sample=function(t,e){var i=(t=Math.max(t,this.minDelayMs_))/1e3,n=8*e/i;this.fast_.sample(i,n),this.slow_.sample(i,n)},e.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.destroy=function(){},t}();e.default=r},"./src/utils/ewma.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/ewma.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=function(){function t(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}var e=t.prototype;return e.sample=function(t,e){var i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}();e.default=n},"./src/utils/fetch-loader.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/utils/fetch-loader.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: fetchSupported, default */function(t,e,i){"use strict";i.r(e),i.d(e,"fetchSupported",(function(){return d}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=i(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return s(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function s(t,e,i){return(s=l()?Reflect.construct:function(t,e,i){var n=[null];n.push.apply(n,e);var r=new(Function.bind.apply(t,n));return i&&c(r,i.prototype),r}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function d(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var f=function(){function t(t){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=t.fetchSetup||p,this.controller=new self.AbortController,this.stats=new r.LoadStats}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,i){var r=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(t,e){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(h({},t.headers))};return t.rangeEnd&&i.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),i}(t,this.controller.signal),s=i.onProgress,l="arraybuffer"===t.responseType,c=l?"byteLength":"length";this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){r.abortInternal(),i.onTimeout(a,t,r.response)}),e.timeout),self.fetch(this.request).then((function(i){if(r.response=r.loader=i,!i.ok){var o=i.status,c=i.statusText;throw new m(c||"fetch, bad network response",o,i)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(i.headers.get("Content-Length")||"0"),s&&Object(n.isFiniteNumber)(e.highWaterMark)?r.loadProgressively(i,a,t,e.highWaterMark,s):l?i.arrayBuffer():i.text()})).then((function(o){var l=r.response;self.clearTimeout(r.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=o[c];var u={url:l.url,data:o};s&&!Object(n.isFiniteNumber)(e.highWaterMark)&&s(a,t,o,l),i.onSuccess(u,a,t,l)})).catch((function(e){if(self.clearTimeout(r.requestTimeout),!a.aborted){var n=e.code||0;i.onError({code:n,text:e.message},t,e.details)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.loadProgressively=function(t,e,i,n,r){void 0===n&&(n=0);var o=new a.default,s=t.body.getReader();return function a(){return s.read().then((function(s){if(s.done)return o.dataLength&&r(e,i,o.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,c=l.length;return e.loaded+=c,c<n||o.dataLength?(o.push(l),o.dataLength>=n&&r(e,i,o.flush(),t)):r(e,i,l,t),a()})).catch((function(){return Promise.reject()}))}()},t}();function p(t,e){return new self.Request(t.url,e)}var m=function(t){var e,i;function n(e,i,n){var r;return(r=t.call(this,e)||this).code=void 0,r.details=void 0,r.code=i,r.details=n,r}return i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,c(e,i),n}(o(Error));e.default=f},"./src/utils/imsc1-ttml-parser.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,e,i){"use strict";i.r(e),i.d(e,"IMSC1_CODEC",(function(){return u})),i.d(e,"parseIMSC1",(function(){return p}));var n=i(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),r=i(/*! ./vttparser */"./src/utils/vttparser.ts"),a=i(/*! ./vttcue */"./src/utils/vttcue.ts"),o=i(/*! ../demux/id3 */"./src/demux/id3.ts"),s=i(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=i(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var u="stpp.ttml.im1t",h=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,d=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function p(t,e,i,r,u){var h=Object(n.findBox)(new Uint8Array(t),["mdat"]);if(0!==h.length){var d=h[0],p=Object(o.utf8ArrayToStr)(new Uint8Array(t,d.start,d.end-d.start)),x=Object(s.toTimescaleFromScale)(e,1,i);try{r(function(t,e){var i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(n).reduce((function(t,e){return t[e]=i.getAttribute("ttp:"+e)||n[e],t}),{}),o="preserve"!==i.getAttribute("xml:space"),s=g(m(i,"styling","style")),u=g(m(i,"layout","region")),h=m(i,"body","[begin]");return[].map.call(h,(function(t){var i=function t(e,i){return[].slice.call(e.childNodes).reduce((function(e,n,r){var a;return"br"===n.nodeName&&r?e+"\n":null!==(a=n.childNodes)&&void 0!==a&&a.length?t(n,i):i?e+n.textContent.trim().replace(/\s+/g," "):e+n.textContent}),"")}(t,o);if(!i||!t.hasAttribute("begin"))return null;var n=b(t.getAttribute("begin"),r),h=b(t.getAttribute("dur"),r),d=b(t.getAttribute("end"),r);if(null===n)throw y(t);if(null===d){if(null===h)throw y(t);d=n+h}var p=new a.default(n-e,d-e,i);p.id=Object(l.generateCueId)(p.startTime,p.endTime,p.text);var m=u[t.getAttribute("region")],g=s[t.getAttribute("style")];p.position=10,p.size=80;var x=function(t,e){var i="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(n,r){var a=v(e,i,r)||v(t,i,r);return a&&(n[r]=a),n}),{})}(m,g),S=x.textAlign;if(S){var C=f[S];C&&(p.lineAlign=C),p.align=S}return c(p,x),p})).filter((function(t){return null!==t}))}(p,x))}catch(t){u(t)}}else u(new Error("Could not parse IMSC1 mdat"))}function m(t,e,i){var n=t.getElementsByTagName(e)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function g(t){return t.reduce((function(t,e){var i=e.getAttribute("xml:id");return i&&(t[i]=e),t}),{})}function v(t,e,i){return t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function b(t,e){if(!t)return null;var i=Object(r.parseTimeStamp)(t);return null===i&&(h.test(t)?i=function(t,e){var i=h.exec(t),n=(0|i[4])+(0|i[5])/e.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/e.frameRate}(t,e):d.test(t)&&(i=function(t,e){var i=d.exec(t),n=Number(i[1]);switch(i[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/e.frameRate;case"t":return n/e.tickRate}return n}(t,e))),i}},"./src/utils/logger.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/logger.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: enableLogs, logger */function(t,e,i){"use strict";i.r(e),i.d(e,"enableLogs",(function(){return s})),i.d(e,"logger",(function(){return l}));var n=function(){},r={trace:n,debug:n,log:n,warn:n,info:n,error:n},a=r;function o(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):n}function s(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];i.forEach((function(e){a[e]=t[e]?t[e].bind(t):o(e)}))}(t,"debug","log","info","warn","error");try{a.log()}catch(t){a=r}}else a=r}var l=r},"./src/utils/mediakeys-helper.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,e,i){"use strict";var n;i.r(e),i.d(e,"KeySystems",(function(){return n})),i.d(e,"requestMediaKeySystemAccess",(function(){return r})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(n||(n={}));var r="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/utils/mediasource-helper.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: getMediaSource */function(t,e,i){"use strict";function n(){return self.MediaSource||self.WebKitMediaSource}i.r(e),i.d(e,"getMediaSource",(function(){return n}))},"./src/utils/mp4-tools.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/mp4-tools.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,e,i){"use strict";i.r(e),i.d(e,"bin2str",(function(){return s})),i.d(e,"readUint16",(function(){return l})),i.d(e,"readUint32",(function(){return c})),i.d(e,"writeUint32",(function(){return u})),i.d(e,"findBox",(function(){return h})),i.d(e,"parseSegmentIndex",(function(){return d})),i.d(e,"parseInitSegment",(function(){return f})),i.d(e,"getStartDTS",(function(){return p})),i.d(e,"getDuration",(function(){return m})),i.d(e,"computeRawDurationFromSamples",(function(){return g})),i.d(e,"offsetStartDTS",(function(){return v})),i.d(e,"segmentValidRange",(function(){return y})),i.d(e,"appendUint8Array",(function(){return b}));var n=i(/*! ./typed-array */"./src/utils/typed-array.ts"),r=i(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=Math.pow(2,32)-1,o=[].push;function s(t){return String.fromCharCode.apply(null,t)}function l(t,e){"data"in t&&(e+=t.start,t=t.data);var i=t[e]<<8|t[e+1];return i<0?65536+i:i}function c(t,e){"data"in t&&(e+=t.start,t=t.data);var i=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return i<0?4294967296+i:i}function u(t,e,i){"data"in t&&(e+=t.start,t=t.data),t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function h(t,e){var i,n,r,a=[];if(!e.length)return a;"data"in t?(i=t.data,n=t.start,r=t.end):(n=0,r=(i=t).byteLength);for(var l=n;l<r;){var u=c(i,l),d=u>1?l+u:r;if(s(i.subarray(l+4,l+8))===e[0])if(1===e.length)a.push({data:i,start:l+8,end:d});else{var f=h({data:i,start:l+8,end:d},e.slice(1));f.length&&o.apply(a,f)}l=d}return a}function d(t){var e=h(t,["moov"])[0],i=e?e.end:null,n=h(t,["sidx"]);if(!n||!n[0])return null;var r=[],a=n[0],o=a.data[0],s=0===o?8:16,u=c(a,s);s+=4,s+=0===o?8:16,s+=2;var d=a.end+0,f=l(a,s);s+=2;for(var p=0;p<f;p++){var m=s,g=c(a,m);m+=4;var v=2147483647&g;if(1==(2147483648&g)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=c(a,m);m+=4,r.push({referenceSize:v,subsegmentDuration:y,info:{duration:y/u,start:d,end:d+v-1}}),d+=v,s=m+=4}return{earliestPresentationTime:0,timescale:u,version:o,referencesCount:f,references:r,moovEndOffset:i}}function f(t){for(var e=[],i=h(t,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],o=h(a,["tkhd"])[0];if(o){var l=o.data[o.start],u=0===l?12:20,d=c(o,u),f=h(a,["mdia","mdhd"])[0];if(f){var p=c(f,u=0===(l=f.data[f.start])?12:20),m=h(a,["mdia","hdlr"])[0];if(m){var g=s(m.data.subarray(m.start+8,m.start+12)),v={soun:r.ElementaryStreamTypes.AUDIO,vide:r.ElementaryStreamTypes.VIDEO}[g];if(v){var y=h(a,["mdia","minf","stbl","stsd"])[0],b=void 0;y&&(b=s(y.data.subarray(y.start+12,y.start+16))),e[d]={timescale:p,type:v},e[v]={timescale:p,id:d,codec:b}}}}}}return h(t,["moov","mvex","trex"]).forEach((function(t){var i=c(t,4),n=e[i];n&&(n.default={duration:c(t,12),flags:c(t,20)})})),e}function p(t,e){return h(e,["moof","traf"]).reduce((function(e,i){var n=h(i,["tfdt"])[0],r=n.data[n.start],a=h(i,["tfhd"]).reduce((function(e,i){var a=c(i,4),o=t[a];if(o){var s=c(n,4);1===r&&(s*=Math.pow(2,32),s+=c(n,8));var l=s/(o.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==a&&isFinite(a)&&(null===e||a<e)?a:e}),null)||0}function m(t,e){for(var i=0,n=0,a=0,o=h(t,["moof","traf"]),s=0;s<o.length;s++){var l=o[s],u=h(l,["tfhd"])[0],f=e[c(u,4)];if(f){var p=f.default,m=c(u,0)|(null==p?void 0:p.flags),v=null==p?void 0:p.duration;8&m&&(v=c(u,2&m?12:8));for(var y=f.timescale||9e4,b=h(l,["trun"]),x=0;x<b.length;x++)i=v?v*c(b[x],4):g(b[x]),f.type===r.ElementaryStreamTypes.VIDEO?n+=i/y:f.type===r.ElementaryStreamTypes.AUDIO&&(a+=i/y)}}if(0===n&&0===a){var S=d(t);if(null!=S&&S.references)return S.references.reduce((function(t,e){return t+e.info.duration||0}),0)}return n||a}function g(t){var e=c(t,0),i=8;1&e&&(i+=4),4&e&&(i+=4);for(var n=0,r=c(t,4),a=0;a<r;a++)256&e&&(n+=c(t,i),i+=4),512&e&&(i+=4),1024&e&&(i+=4),2048&e&&(i+=4);return n}function v(t,e,i){h(e,["moof","traf"]).forEach((function(e){h(e,["tfhd"]).forEach((function(n){var r=c(n,4),o=t[r];if(o){var s=o.timescale||9e4;h(e,["tfdt"]).forEach((function(t){var e=t.data[t.start],n=c(t,4);if(0===e)u(t,4,n-i*s);else{n*=Math.pow(2,32),n+=c(t,8),n-=i*s,n=Math.max(n,0);var r=Math.floor(n/(a+1)),o=Math.floor(n%(a+1));u(t,4,r),u(t,8,o)}}))}}))}))}function y(t){var e={valid:null,remainder:null},i=h(t,["moof"]);if(!i)return e;if(i.length<2)return e.remainder=t,e;var r=i[i.length-1];return e.valid=Object(n.sliceUint8)(t,0,r.start-8),e.remainder=Object(n.sliceUint8)(t,r.start-8),e}function b(t,e){var i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}},"./src/utils/output-filter.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/output-filter.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return n}));var n=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function(t,e,i){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[]},t}()},"./src/utils/texttrack-utils.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/texttrack-utils.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,e,i){"use strict";i.r(e),i.d(e,"sendAddTrackEvent",(function(){return r})),i.d(e,"addCueToTrack",(function(){return a})),i.d(e,"clearCurrentCues",(function(){return o})),i.d(e,"removeCuesInRange",(function(){return s})),i.d(e,"getCuesInRange",(function(){return l}));var n=i(/*! ./logger */"./src/utils/logger.ts");function r(t,e){var i;try{i=new Event("addtrack")}catch(t){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function a(t,e){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(i){n.logger.debug("[texttrack-utils]: "+i);var r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,t.addCue(r)}"disabled"===i&&(t.mode=i)}function o(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var i=t.cues.length;i--;)t.removeCue(t.cues[i]);"disabled"===e&&(t.mode=e)}function s(t,e,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var r=l(t.cues,e,i),a=0;a<r.length;a++)t.removeCue(r[a]);"disabled"===n&&(t.mode=n)}function l(t,e,i){var n=[],r=function(t,e){if(e<t[0].startTime)return 0;var i=t.length-1;if(e>t[i].endTime)return-1;for(var n=0,r=i;n<=r;){var a=Math.floor((r+n)/2);if(e<t[a].startTime)r=a-1;else{if(!(e>t[a].startTime&&n<i))return a;n=a+1}}return t[n].startTime-e<e-t[r].startTime?n:r}(t,e);if(r>-1)for(var a=r,o=t.length;a<o;a++){var s=t[a];if(s.startTime>=e&&s.endTime<=i)n.push(s);else if(s.startTime>i)return n}return n}},"./src/utils/time-ranges.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/time-ranges.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),e.default={toString:function(t){for(var e="",i=t.length,n=0;n<i;n++)e+="["+t.start(n).toFixed(3)+","+t.end(n).toFixed(3)+"]";return e}}},"./src/utils/timescale-conversion.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/utils/timescale-conversion.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,e,i){"use strict";function n(t,e,i,n){void 0===i&&(i=1),void 0===n&&(n=!1);var r=t*e*i;return n?Math.round(r):r}function r(t,e,i,r){return void 0===i&&(i=1),void 0===r&&(r=!1),n(t,e,1/i,r)}function a(t,e){return void 0===e&&(e=!1),n(t,1e3,1/9e4,e)}function o(t,e){return void 0===e&&(e=1),n(t,9e4,1/e)}i.r(e),i.d(e,"toTimescaleFromBase",(function(){return n})),i.d(e,"toTimescaleFromScale",(function(){return r})),i.d(e,"toMsFromMpegTsClock",(function(){return a})),i.d(e,"toMpegTsClockFromTimescale",(function(){return o}))},"./src/utils/typed-array.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/typed-array.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: sliceUint8 */function(t,e,i){"use strict";function n(t,e,i){return Uint8Array.prototype.slice?t.slice(e,i):new Uint8Array(Array.prototype.slice.call(t,e,i))}i.r(e),i.d(e,"sliceUint8",(function(){return n}))},"./src/utils/vttcue.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/vttcue.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e),e.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function i(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var i=e.toLowerCase();return!!~t.indexOf(i)&&i}function n(t){return i(e,t)}function r(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var o in a)t[o]=a[o]}return t}function a(e,a,o){var s=this,l={enumerable:!0};s.hasBeenReset=!1;var c="",u=!1,h=e,d=a,f=o,p=null,m="",g=!0,v="auto",y="start",b=50,x="middle",S=50,C="middle";Object.defineProperty(s,"id",r({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(s,"pauseOnExit",r({},l,{get:function(){return u},set:function(t){u=!!t}})),Object.defineProperty(s,"startTime",r({},l,{get:function(){return h},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");h=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",r({},l,{get:function(){return d},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",r({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",r({},l,{get:function(){return p},set:function(t){p=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",r({},l,{get:function(){return m},set:function(e){var n=function(e){return i(t,e)}(e);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");m=n,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",r({},l,{get:function(){return g},set:function(t){g=!!t,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",r({},l,{get:function(){return v},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",r({},l,{get:function(){return y},set:function(t){var e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",r({},l,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",r({},l,{get:function(){return x},set:function(t){var e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");x=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",r({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",r({},l,{get:function(){return C},set:function(t){var e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),s.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/vttparser.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,e,i){"use strict";i.r(e),i.d(e,"parseTimeStamp",(function(){return a})),i.d(e,"fixLineBreaks",(function(){return h})),i.d(e,"VTTParser",(function(){return d}));var n=i(/*! ./vttcue */"./src/utils/vttcue.ts"),r=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function a(t){function e(t,e,i,n){return 3600*(0|t)+60*(0|e)+(0|i)+parseFloat(n||0)}var i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}var o=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,i){for(var n=0;n<i.length;++n)if(e===i[n]){this.set(t,e);break}},e.integer=function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},e.percent=function(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1},t}();function s(t,e,i,n){var r=n?t.split(n):[t];for(var a in r)if("string"==typeof r[a]){var o=r[a].split(i);2===o.length&&e(o[0],o[1])}}var l=new n.default(0,0,""),c="middle"===l.align?"middle":"center";function u(t,e,i){var n=t;function r(){var e=a(t);if(null===e)throw new Error("Malformed timestamp: "+n);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function u(){t=t.replace(/^\s+/,"")}if(u(),e.startTime=r(),u(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);t=t.substr(3),u(),e.endTime=r(),u(),function(t,e){var n=new o;s(t,(function(t,e){var r;switch(t){case"region":for(var a=i.length-1;a>=0;a--)if(i[a].id===e){n.set(t,i[a].region);break}break;case"vertical":n.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),n.integer(t,r[0]),n.percent(t,r[0])&&n.set("snapToLines",!1),n.alt(t,r[0],["auto"]),2===r.length&&n.alt("lineAlign",r[1],["start",c,"end"]);break;case"position":r=e.split(","),n.percent(t,r[0]),2===r.length&&n.alt("positionAlign",r[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,e);break;case"align":n.alt(t,e,["start",c,"end","left","right"])}}),/:/,/\s/),e.region=n.get("region",null),e.vertical=n.get("vertical","");var r=n.get("line","auto");"auto"===r&&-1===l.line&&(r=-1),e.line=r,e.lineAlign=n.get("lineAlign","start"),e.snapToLines=n.get("snapToLines",!0),e.size=n.get("size",100),e.align=n.get("align",c);var a=n.get("position","auto");"auto"===a&&50===l.position&&(a="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=a}(t,e)}function h(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var d=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new r,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var e=this;function i(){var t=e.buffer,i=0;for(t=h(t);i<t.length&&"\r"!==t[i]&&"\n"!==t[i];)++i;var n=t.substr(0,i);return"\r"===t[i]&&++i,"\n"===t[i]&&++i,e.buffer=t.substr(i),n}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{var r="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;var a=(r=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var o=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(o?o=!1:r=i(),e.state){case"HEADER":/:/.test(r)?s(r,(function(t,e){}),/:/):r||(e.state="ID");continue;case"NOTE":r||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){e.state="NOTE";break}if(!r)continue;if(e.cue=new n.default(0,0,""),e.state="CUE",-1===r.indexOf("--\x3e")){e.cue.id=r;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{u(r,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var l=-1!==r.indexOf("--\x3e");if(!r||l&&(o=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=r;continue;case"BADCUE":r||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this},e.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw new Error("Malformed WebVTT signature.")}catch(t){this.onparsingerror&&this.onparsingerror(t)}return this.onflush&&this.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/webvtt-parser.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: generateCueId, parseWebVTT */function(t,e,i){"use strict";i.r(e),i.d(e,"generateCueId",(function(){return h})),i.d(e,"parseWebVTT",(function(){return d}));var n=i(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),r=i(/*! ./vttparser */"./src/utils/vttparser.ts"),a=i(/*! ../demux/id3 */"./src/demux/id3.ts"),o=i(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),s=i(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,c=function(t,e,i){return void 0===i&&(i=0),t.substr(i,e.length)===e},u=function(t){for(var e=5381,i=t.length;i;)e=33*e^t.charCodeAt(--i);return(e>>>0).toString()};function h(t,e,i){return u(t.toString())+u(e.toString())+u(i)}function d(t,e,i,u,d,f,p,m){var g,v=new r.VTTParser,y=Object(a.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),b=[],x=Object(o.toMpegTsClockFromTimescale)(e,i),S="00:00.000",C=0,k=0,E=!0,w=!1;v.oncue=function(t){var e=u[d],i=u.ccOffset,n=(C-x)/9e4;if(null!=e&&e.new&&(void 0!==k?i=u.ccOffset=e.start:function(t,e,i){var n=t[e],r=t[n.prevCC];if(!r||!r.new&&n.new)return t.ccOffset=t.presentationOffset=n.start,void(n.new=!1);for(;null!==(a=r)&&void 0!==a&&a.new;){var a;t.ccOffset+=n.start-r.start,n.new=!1,r=t[(n=r).prevCC]}t.presentationOffset=i}(u,d,n)),n&&(i=n-u.presentationOffset),w){var r=t.endTime-t.startTime,a=Object(s.normalizePts)(9e4*(t.startTime+i-k),9e4*f)/9e4;t.startTime=a,t.endTime=a+r}var o=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(o)),t.id||(t.id=h(t.startTime,t.endTime,o)),t.endTime>0&&b.push(t)},v.onparsingerror=function(t){g=t},v.onflush=function(){g?m(g):p(b)},y.forEach((function(t){if(E){if(c(t,"X-TIMESTAMP-MAP=")){E=!1,w=!0,t.substr(16).split(",").forEach((function(t){c(t,"LOCAL:")?S=t.substr(6):c(t,"MPEGTS:")&&(C=parseInt(t.substr(7)))}));try{k=function(t){var e=parseInt(t.substr(-3)),i=parseInt(t.substr(-6,2)),r=parseInt(t.substr(-9,2)),a=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(n.isFiniteNumber)(e)&&Object(n.isFiniteNumber)(i)&&Object(n.isFiniteNumber)(r)&&Object(n.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*i,e+=6e4*r,e+=36e5*a}(S)/1e3}catch(t){w=!1,g=t}return}""===t&&(E=!1)}v.parse(t+"\n")})),v.flush()}},"./src/utils/xhr-loader.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(t,e,i){"use strict";i.r(e);var n=i(/*! ../utils/logger */"./src/utils/logger.ts"),r=i(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m,o=function(){function t(t){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=t?t.xhrSetup:null,this.stats=new r.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var r=this.xhrSetup;try{if(r)try{r(i,e.url)}catch(t){i.open("GET",e.url,!0),r(i,e.url)}i.readyState||i.open("GET",e.url,!0);var a=this.context.headers;if(a)for(var o in a)i.setRequestHeader(o,a[o])}catch(t){return void this.callbacks.onError({code:i.status,text:t.message},e,i)}e.rangeEnd&&i.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),i.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,i=this.stats;if(t&&e){var r=e.readyState,a=this.config;if(!i.aborted&&r>=2)if(self.clearTimeout(this.requestTimeout),0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),4===r){e.onreadystatechange=null,e.onprogress=null;var o=e.status;if(o>=200&&o<300){var s,l;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),l="arraybuffer"===t.responseType?(s=e.response).byteLength:(s=e.responseText).length,i.loaded=i.total=l,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,t,s,e),!this.callbacks)return;var u={url:e.responseURL,data:s};this.callbacks.onSuccess(u,i,t,e)}else i.retry>=a.maxRetry||o>=400&&o<499?(n.logger.error(o+" while loading "+t.url),this.callbacks.onError({code:o,text:e.statusText},t,e)):(n.logger.warn(o+" while loading "+t.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),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},e.loadtimeout=function(){n.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=o}}).default},t.exports=n())},vHTk:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},xvzu:
|
|
|
/*!*************************************************************************************!*\
|
|
|
!*** ./src/pages/User/Detail/Topics/Exercise/Detail/components/editor.less?modules ***!
|
|
|
\*************************************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){t.exports={flex_box_center:"flex_box_center___11Yx1",flex_space_between:"flex_space_between___3B8wg",flex_box_vertical_center:"flex_box_vertical_center___1cm8r",flex_box_center_end:"flex_box_center_end___2h7Wz",flex_box_column:"flex_box_column___1vJbd",wrap:"wrap___30mNN",modal:"modal___39YWi",titleWrap:"titleWrap___25lJO",required:"required___2_KP9",title:"title___dFjtB",colorGray:"colorGray___3RoHj",choiceWrap:"choiceWrap___14CFD",answer:"answer___10oFr",activeAnswer:"activeAnswer___S76uT",deleteIcon:"deleteIcon___kKaJg",addIcon:"addIcon___3w3u_",editorWrap:"editorWrap___3DrnO",htmlWrap:"htmlWrap___1tGnP",radio:"radio___24YhJ",color333:"color333___1O71o",color999:"color999___xHfER",questionType:"questionType___22Z7J",questionChoices:"questionChoices____Unas"}}}]); |