You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
667 KiB
330 lines
667 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[166,5,7,8],{"30zm":function(Je,Xe,ee){"use strict";var de=ee("jCWc"),F=ee("kPKH"),S=ee("k1fw"),B=ee("tJVT"),_=ee("PpiC"),R=ee("B9cy"),N=ee("Ol7k"),M=ee("lUTK"),O=ee("BvKs"),w=ee("q1tI"),m=ee.n(w),T=ee("Ty5D"),C=ee("55Ip"),b=ee("9kvl"),E=ee("m3rI"),y=ee("kzJb"),c=ee.n(y),r=O.a.SubMenu,a=N.a.Sider,o=N.a.Content,g=function(d){var v=d.messages,h=d.globalSetting,u=d.loading,n=d.user,e=d.dispatch,t=Object(_.a)(d,["messages","globalSetting","loading","user","dispatch"]),f=Object(T.i)(),p=n.userInfo,x=Object(T.h)(),A=v.tidingsList,I=v.privateMessage,U=v.unreadInfo,j=Object(w.useState)({per_page:10,page:1}),z=Object(B.a)(j,2),V=z[0],G=z[1];Object(w.useEffect)(function(){Q()},[f.userId]);var Q=function(){e({type:"messages/unreadMessageInfo",payload:Object(S.a)(Object(S.a)({},V),f)})};return m.a.createElement(F.a,{flex:"264px"},m.a.createElement("aside",{className:c.a.userInfo},m.a.createElement("img",{className:"mt40",src:E.a.IMG_SERVER+"/images/"+(p==null?void 0:p.image_url)}),m.a.createElement("p",{className:"font24 mt10"},p==null?void 0:p.username),m.a.createElement("p",{className:"mt20"},p==null?void 0:p.user_identity)),m.a.createElement("ul",{className:c.a.navInfo},m.a.createElement(C.a,{to:"/messages/".concat(p==null?void 0:p.login,"/user_tidings")},m.a.createElement("li",{className:x.pathname.indexOf("user_tidings")>-1&&c.a.actived},"\u6D88\u606F",!!(U!=null&&U.unread_tiding_count)&&m.a.createElement("span",{className:c.a.newTip},U==null?void 0:U.unread_tiding_count))),m.a.createElement(C.a,{to:"/messages/".concat(p==null?void 0:p.login,"/private_messages")},m.a.createElement("li",{className:(x.pathname.indexOf("private_messages")>-1||x.pathname.indexOf("message_detail")>-1)&&c.a.actived},"\u79C1\u4FE1",!!(U!=null&&U.unread_message_count)&&m.a.createElement("span",{className:c.a.newTip},U==null?void 0:U.unread_message_count)))))};Xe.a=Object(b.a)(function(l){var d=l.messages,v=l.loading,h=l.user,u=l.globalSetting;return{messages:d,globalSetting:u,user:h,loading:v.effects}})(g)},"55Ip":function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return a}),ee.d(Xe,"b",function(){return h});var de=ee("Ty5D"),F=ee("dI71"),S=ee("q1tI"),B=ee.n(S),_=ee("YS25"),R=ee("17x9"),N=ee.n(R),M=ee("wx14"),O=ee("zLVn"),w=ee("9R94"),m=function(n){Object(F.a)(e,n);function e(){for(var f,p=arguments.length,x=new Array(p),A=0;A<p;A++)x[A]=arguments[A];return f=n.call.apply(n,[this].concat(x))||this,f.history=Object(_.a)(f.props),f}var t=e.prototype;return t.render=function(){return B.a.createElement(de.c,{history:this.history,children:this.props.children})},e}(B.a.Component),T=function(n){Object(F.a)(e,n);function e(){for(var f,p=arguments.length,x=new Array(p),A=0;A<p;A++)x[A]=arguments[A];return f=n.call.apply(n,[this].concat(x))||this,f.history=Object(_.b)(f.props),f}var t=e.prototype;return t.render=function(){return B.a.createElement(de.c,{history:this.history,children:this.props.children})},e}(B.a.Component),C=function(e,t){return typeof e=="function"?e(t):e},b=function(e,t){return typeof e=="string"?Object(_.c)(e,null,null,t):e},E=function(e){return e},y=B.a.forwardRef;typeof y=="undefined"&&(y=E);function c(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}var r=y(function(n,e){var t=n.innerRef,f=n.navigate,p=n.onClick,x=Object(O.a)(n,["innerRef","navigate","onClick"]),A=x.target,I=Object(M.a)({},x,{onClick:function(j){try{p&&p(j)}catch(z){throw j.preventDefault(),z}!j.defaultPrevented&&j.button===0&&(!A||A==="_self")&&!c(j)&&(j.preventDefault(),f())}});return E!==y?I.ref=e||t:I.ref=t,B.a.createElement("a",I)}),a=y(function(n,e){var t=n.component,f=t===void 0?r:t,p=n.replace,x=n.to,A=n.innerRef,I=Object(O.a)(n,["component","replace","to","innerRef"]);return B.a.createElement(de.e.Consumer,null,function(U){U||Object(w.a)(!1);var j=U.history,z=b(C(x,U.location),U.location),V=z?j.createHref(z):"",G=Object(M.a)({},I,{href:V,navigate:function(){var ne=C(x,U.location),re=p?j.replace:j.push;re(ne)}});return E!==y?G.ref=e||A:G.innerRef=A,B.a.createElement(f,G)})});if(!1)var o,g;var l=function(e){return e},d=B.a.forwardRef;typeof d=="undefined"&&(d=l);function v(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.filter(function(f){return f}).join(" ")}var h=d(function(n,e){var t=n["aria-current"],f=t===void 0?"page":t,p=n.activeClassName,x=p===void 0?"active":p,A=n.activeStyle,I=n.className,U=n.exact,j=n.isActive,z=n.location,V=n.sensitive,G=n.strict,Q=n.style,ne=n.to,re=n.innerRef,be=Object(O.a)(n,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return B.a.createElement(de.e.Consumer,null,function(se){se||Object(w.a)(!1);var oe=z||se.location,ue=b(C(ne,oe),oe),he=ue.pathname,te=he&&he.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),Y=te?Object(de.f)(oe.pathname,{path:te,exact:U,sensitive:V,strict:G}):null,fe=!!(j?j(Y,oe):Y),Re=fe?v(I,x):I,Le=fe?Object(M.a)({},Q,{},A):Q,xe=Object(M.a)({"aria-current":fe&&f||null,className:Re,style:Le,to:ue},be);return l!==d?xe.ref=e||re:xe.innerRef=re,B.a.createElement(a,xe)})});if(!1)var u},"6+eU":function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return d});var de=ee("wx14"),F=ee("rePB"),S=ee("VTBJ"),B=ee("1OyB"),_=ee("vuIU"),R=ee("Ji7U"),N=ee("LK+K"),M=ee("q1tI"),O=ee.n(M),w=ee("TSYQ"),m=ee.n(w),T=function(h){var u,n="".concat(h.rootPrefixCls,"-item"),e=m()(n,"".concat(n,"-").concat(h.page),(u={},Object(F.a)(u,"".concat(n,"-active"),h.active),Object(F.a)(u,h.className,!!h.className),Object(F.a)(u,"".concat(n,"-disabled"),!h.page),u)),t=function(){h.onClick(h.page)},f=function(x){h.onKeyPress(x,h.onClick,h.page)};return O.a.createElement("li",{title:h.showTitle?h.page:null,className:e,onClick:t,onKeyPress:f,tabIndex:"0"},h.itemRender(h.page,"page",O.a.createElement("a",{rel:"nofollow"},h.page)))},C=T,b={ZERO:48,NINE:57,NUMPAD_ZERO:96,NUMPAD_NINE:105,BACKSPACE:8,DELETE:46,ENTER:13,ARROW_UP:38,ARROW_DOWN:40},E=function(v){Object(R.a)(u,v);var h=Object(N.a)(u);function u(){var n;Object(B.a)(this,u);for(var e=arguments.length,t=new Array(e),f=0;f<e;f++)t[f]=arguments[f];return n=h.call.apply(h,[this].concat(t)),n.state={goInputText:""},n.buildOptionText=function(p){return"".concat(p," ").concat(n.props.locale.items_per_page)},n.changeSize=function(p){n.props.changeSize(Number(p))},n.handleChange=function(p){n.setState({goInputText:p.target.value})},n.handleBlur=function(p){var x=n.props,A=x.goButton,I=x.quickGo,U=x.rootPrefixCls,j=n.state.goInputText;if(A||j==="")return;if(p.relatedTarget&&(p.relatedTarget.className.indexOf("".concat(U,"-prev"))>=0||p.relatedTarget.className.indexOf("".concat(U,"-next"))>=0))return;n.setState({goInputText:""}),I(n.getValidValue())},n.go=function(p){var x=n.state.goInputText;if(x==="")return;(p.keyCode===b.ENTER||p.type==="click")&&(n.setState({goInputText:""}),n.props.quickGo(n.getValidValue()))},n}return Object(_.a)(u,[{key:"getValidValue",value:function(){var e=this.state,t=e.goInputText,f=e.current;return!t||isNaN(t)?f:Number(t)}},{key:"getPageSizeOptions",value:function(){var e=this.props,t=e.pageSize,f=e.pageSizeOptions;return f.some(function(p){return p.toString()===t.toString()})?f:f.concat([t.toString()]).sort(function(p,x){var A=isNaN(Number(p))?0:Number(p),I=isNaN(Number(x))?0:Number(x);return A-I})}},{key:"render",value:function(){var e=this,t=this.props,f=t.pageSize,p=t.locale,x=t.rootPrefixCls,A=t.changeSize,I=t.quickGo,U=t.goButton,j=t.selectComponentClass,z=t.buildOptionText,V=t.selectPrefixCls,G=t.disabled,Q=this.state.goInputText,ne="".concat(x,"-options"),re=j,be=null,se=null,oe=null;if(!A&&!I)return null;var ue=this.getPageSizeOptions();if(A&&re){var he=ue.map(function(te,Y){return O.a.createElement(re.Option,{key:Y,value:te.toString()},(z||e.buildOptionText)(te))});be=O.a.createElement(re,{disabled:G,prefixCls:V,showSearch:!1,className:"".concat(ne,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(f||ue[0]).toString(),onChange:this.changeSize,getPopupContainer:function(Y){return Y.parentNode}},he)}return I&&(U&&(oe=typeof U=="boolean"?O.a.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:G,className:"".concat(ne,"-quick-jumper-button")},p.jump_to_confirm):O.a.createElement("span",{onClick:this.go,onKeyUp:this.go},U)),se=O.a.createElement("div",{className:"".concat(ne,"-quick-jumper")},p.jump_to,O.a.createElement("input",{disabled:G,type:"text",value:Q,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur}),p.page,oe)),O.a.createElement("li",{className:"".concat(ne)},be,se)}}]),u}(O.a.Component);E.defaultProps={pageSizeOptions:["10","20","50","100"]};var y=E,c=ee("N2Kk");function r(){}function a(v){return typeof v=="number"&&isFinite(v)&&Math.floor(v)===v}function o(v,h,u){return u}function g(v,h,u){var n=typeof v=="undefined"?h.pageSize:v;return Math.floor((u.total-1)/n)+1}var l=function(v){Object(R.a)(u,v);var h=Object(N.a)(u);function u(n){var e;Object(B.a)(this,u),e=h.call(this,n),e.getJumpPrevPage=function(){return Math.max(1,e.state.current-(e.props.showLessItems?3:5))},e.getJumpNextPage=function(){return Math.min(g(void 0,e.state,e.props),e.state.current+(e.props.showLessItems?3:5))},e.getItemIcon=function(A,I){var U=e.props.prefixCls,j=A||O.a.createElement("button",{type:"button","aria-label":I,className:"".concat(U,"-item-link")});return typeof A=="function"&&(j=O.a.createElement(A,Object(S.a)({},e.props))),j},e.savePaginationNode=function(A){e.paginationNode=A},e.isValid=function(A){return a(A)&&A!==e.state.current},e.shouldDisplayQuickJumper=function(){var A=e.props,I=A.showQuickJumper,U=A.pageSize,j=A.total;return j<=U?!1:I},e.handleKeyDown=function(A){(A.keyCode===b.ARROW_UP||A.keyCode===b.ARROW_DOWN)&&A.preventDefault()},e.handleKeyUp=function(A){var I=e.getValidValue(A),U=e.state.currentInputValue;I!==U&&e.setState({currentInputValue:I}),A.keyCode===b.ENTER?e.handleChange(I):A.keyCode===b.ARROW_UP?e.handleChange(I-1):A.keyCode===b.ARROW_DOWN&&e.handleChange(I+1)},e.changePageSize=function(A){var I=e.state.current,U=g(A,e.state,e.props);I=I>U?U:I,U===0&&(I=e.state.current),typeof A=="number"&&("pageSize"in e.props||e.setState({pageSize:A}),"current"in e.props||e.setState({current:I,currentInputValue:I})),e.props.onShowSizeChange(I,A),"onChange"in e.props&&e.props.onChange&&e.props.onChange(I,A)},e.handleChange=function(A){var I=e.props.disabled,U=A;if(e.isValid(U)&&!I){var j=g(void 0,e.state,e.props);U>j?U=j:U<1&&(U=1),"current"in e.props||e.setState({current:U,currentInputValue:U});var z=e.state.pageSize;return e.props.onChange(U,z),U}return e.state.current},e.prev=function(){e.hasPrev()&&e.handleChange(e.state.current-1)},e.next=function(){e.hasNext()&&e.handleChange(e.state.current+1)},e.jumpPrev=function(){e.handleChange(e.getJumpPrevPage())},e.jumpNext=function(){e.handleChange(e.getJumpNextPage())},e.hasPrev=function(){return e.state.current>1},e.hasNext=function(){return e.state.current<g(void 0,e.state,e.props)},e.runIfEnter=function(A,I){if(A.key==="Enter"||A.charCode===13){for(var U=arguments.length,j=new Array(U>2?U-2:0),z=2;z<U;z++)j[z-2]=arguments[z];I.apply(void 0,j)}},e.runIfEnterPrev=function(A){e.runIfEnter(A,e.prev)},e.runIfEnterNext=function(A){e.runIfEnter(A,e.next)},e.runIfEnterJumpPrev=function(A){e.runIfEnter(A,e.jumpPrev)},e.runIfEnterJumpNext=function(A){e.runIfEnter(A,e.jumpNext)},e.handleGoTO=function(A){(A.keyCode===b.ENTER||A.type==="click")&&e.handleChange(e.state.currentInputValue)};var t=n.onChange!==r,f="current"in n;f&&!t&&console.warn("Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.");var p=n.defaultCurrent;"current"in n&&(p=n.current);var x=n.defaultPageSize;return"pageSize"in n&&(x=n.pageSize),p=Math.min(p,g(x,void 0,n)),e.state={current:p,currentInputValue:p,pageSize:x},e}return Object(_.a)(u,[{key:"componentDidUpdate",value:function(e,t){var f=this.props.prefixCls;if(t.current!==this.state.current&&this.paginationNode){var p=this.paginationNode.querySelector(".".concat(f,"-item-").concat(t.current));p&&document.activeElement===p&&p.blur()}}},{key:"getValidValue",value:function(e){var t=e.target.value,f=g(void 0,this.state,this.props),p=this.state.currentInputValue,x;return t===""?x=t:isNaN(Number(t))?x=p:t>=f?x=f:x=Number(t),x}},{key:"getShowSizeChanger",value:function(){var e=this.props,t=e.showSizeChanger,f=e.total,p=e.totalBoundaryShowSizeChanger;return typeof t!="undefined"?t:f>p}},{key:"renderPrev",value:function(e){var t=this.props,f=t.prevIcon,p=t.itemRender,x=p(e,"prev",this.getItemIcon(f,"prev page")),A=!this.hasPrev();return Object(M.isValidElement)(x)?Object(M.cloneElement)(x,{disabled:A}):x}},{key:"renderNext",value:function(e){var t=this.props,f=t.nextIcon,p=t.itemRender,x=p(e,"next",this.getItemIcon(f,"next page")),A=!this.hasNext();return Object(M.isValidElement)(x)?Object(M.cloneElement)(x,{disabled:A}):x}},{key:"render",value:function(){var e=this,t=this.props,f=t.prefixCls,p=t.className,x=t.style,A=t.disabled,I=t.hideOnSinglePage,U=t.total,j=t.locale,z=t.showQuickJumper,V=t.showLessItems,G=t.showTitle,Q=t.showTotal,ne=t.simple,re=t.itemRender,be=t.showPrevNextJumpers,se=t.jumpPrevIcon,oe=t.jumpNextIcon,ue=t.selectComponentClass,he=t.selectPrefixCls,te=t.pageSizeOptions,Y=this.state,fe=Y.current,Re=Y.pageSize,Le=Y.currentInputValue;if(I===!0&&U<=Re)return null;var xe=g(void 0,this.state,this.props),Te=[],le=null,ye=null,we=null,De=null,Se=null,pe=z&&z.goButton,me=V?1:2,Fe=fe-1>0?fe-1:0,Pe=fe+1<xe?fe+1:xe,Me=Object.keys(this.props).reduce(function(W,H){return(H.substr(0,5)==="data-"||H.substr(0,5)==="aria-"||H==="role")&&(W[H]=e.props[H]),W},{});if(ne)return pe&&(typeof pe=="boolean"?Se=O.a.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},j.jump_to_confirm):Se=O.a.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},pe),Se=O.a.createElement("li",{title:G?"".concat(j.jump_to).concat(fe,"/").concat(xe):null,className:"".concat(f,"-simple-pager")},Se)),O.a.createElement("ul",Object(de.a)({className:m()(f,"".concat(f,"-simple"),Object(F.a)({},"".concat(f,"-disabled"),A),p),style:x,ref:this.savePaginationNode},Me),O.a.createElement("li",{title:G?j.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:m()("".concat(f,"-prev"),Object(F.a)({},"".concat(f,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(Fe)),O.a.createElement("li",{title:G?"".concat(fe,"/").concat(xe):null,className:"".concat(f,"-simple-pager")},O.a.createElement("input",{type:"text",value:Le,disabled:A,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,size:"3"}),O.a.createElement("span",{className:"".concat(f,"-slash")},"/"),xe),O.a.createElement("li",{title:G?j.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:m()("".concat(f,"-next"),Object(F.a)({},"".concat(f,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(Pe)),Se);if(xe<=3+me*2){var Ie={locale:j,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:G,itemRender:re};xe||Te.push(O.a.createElement(C,Object(de.a)({},Ie,{key:"noPager",page:xe,className:"".concat(f,"-disabled")})));for(var Ne=1;Ne<=xe;Ne+=1){var Ue=fe===Ne;Te.push(O.a.createElement(C,Object(de.a)({},Ie,{key:Ne,page:Ne,active:Ue})))}}else{var ke=V?j.prev_3:j.prev_5,Ae=V?j.next_3:j.next_5;be&&(le=O.a.createElement("li",{title:G?ke:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:m()("".concat(f,"-jump-prev"),Object(F.a)({},"".concat(f,"-jump-prev-custom-icon"),!!se))},re(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(se,"prev page"))),ye=O.a.createElement("li",{title:G?Ae:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:m()("".concat(f,"-jump-next"),Object(F.a)({},"".concat(f,"-jump-next-custom-icon"),!!oe))},re(this.getJumpNextPage(),"jump-next",this.getItemIcon(oe,"next page")))),De=O.a.createElement(C,{locale:j,last:!0,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:xe,page:xe,active:!1,showTitle:G,itemRender:re}),we=O.a.createElement(C,{locale:j,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:G,itemRender:re});var Be=Math.max(1,fe-me),_e=Math.min(fe+me,xe);fe-1<=me&&(_e=1+me*2),xe-fe<=me&&(Be=xe-me*2);for(var ce=Be;ce<=_e;ce+=1){var Ce=fe===ce;Te.push(O.a.createElement(C,{locale:j,rootPrefixCls:f,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:ce,page:ce,active:Ce,showTitle:G,itemRender:re}))}fe-1>=me*2&&fe!==1+2&&(Te[0]=Object(M.cloneElement)(Te[0],{className:"".concat(f,"-item-after-jump-prev")}),Te.unshift(le)),xe-fe>=me*2&&fe!==xe-2&&(Te[Te.length-1]=Object(M.cloneElement)(Te[Te.length-1],{className:"".concat(f,"-item-before-jump-next")}),Te.push(ye)),Be!==1&&Te.unshift(we),_e!==xe&&Te.push(De)}var q=null;Q&&(q=O.a.createElement("li",{className:"".concat(f,"-total-text")},Q(U,[U===0?0:(fe-1)*Re+1,fe*Re>U?U:fe*Re])));var J=!this.hasPrev()||!xe,Z=!this.hasNext()||!xe;return O.a.createElement("ul",Object(de.a)({className:m()(f,p,Object(F.a)({},"".concat(f,"-disabled"),A)),style:x,unselectable:"unselectable",ref:this.savePaginationNode},Me),q,O.a.createElement("li",{title:G?j.prev_page:null,onClick:this.prev,tabIndex:J?null:0,onKeyPress:this.runIfEnterPrev,className:m()("".concat(f,"-prev"),Object(F.a)({},"".concat(f,"-disabled"),J)),"aria-disabled":J},this.renderPrev(Fe)),Te,O.a.createElement("li",{title:G?j.next_page:null,onClick:this.next,tabIndex:Z?null:0,onKeyPress:this.runIfEnterNext,className:m()("".concat(f,"-next"),Object(F.a)({},"".concat(f,"-disabled"),Z)),"aria-disabled":Z},this.renderNext(Pe)),O.a.createElement(y,{disabled:A,locale:j,rootPrefixCls:f,selectComponentClass:ue,selectPrefixCls:he,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:fe,pageSize:Re,pageSizeOptions:te,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:pe}))}}],[{key:"getDerivedStateFromProps",value:function(e,t){var f={};if("current"in e&&(f.current=e.current,e.current!==t.current&&(f.currentInputValue=f.current)),"pageSize"in e&&e.pageSize!==t.pageSize){var p=t.current,x=g(e.pageSize,t,e);p=p>x?x:p,"current"in e||(f.current=p,f.currentInputValue=p),f.pageSize=e.pageSize}return f}}]),u}(O.a.Component);l.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:r,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:r,locale:c.a,style:{},itemRender:o,totalBoundaryShowSizeChanger:50};var d=l},"8hTe":function(Je,Xe,ee){Je.exports={button:"button___1wy9m"}},"9Bee":function(Je,Xe,ee){"use strict";var de=ee("DYRE"),F=ee("zeV3"),S=ee("+L6B"),B=ee("2/Rp"),_=ee("k1fw"),R=ee("9og8"),N=ee("tJVT"),M=ee("WmNS"),O=ee.n(M),w=ee("q1tI"),m=ee.n(w),T=ee("vg9a"),C=ee("DlQD"),b=ee.n(C),E=ee("rUJ1");function y(P,i){var s=P.match(/^(\s+)(?:```)/);if(s===null)return i;var L=s[1];return i.split(`
|
|
`).map(function(k){var D=k.match(/^\s+/);if(D===null)return k;var $=Object(N.a)(D,1),ve=$[0];return ve.length>=L.length?k.slice(L.length):k}).join(`
|
|
`)}var c=[],r=["<ul>"],a=new b.a.Renderer,o=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function g(){c.length=0,r=["<ul>"]}var l={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function d(P,i,s,L){if(i>=P.length||P[i].level<=s)return i;var k=P[i];L.push("<li><a href='#"+k.anchor+"'>"+k.text+"</a>"),i++;var D=[];return i=d(P,i,k.level,D),D.length>0&&(L.push("<ul>"),D.forEach(function($){L.push($)}),L.push("</ul>")),L.push("</li>"),i=d(P,i,s,L),i}function v(){return d(c,0,0,r),r.push("</ul>"),r.join("")}var h={heading:function(i){var s=o.exec(i);if(s)return{type:"heading",raw:s[0],depth:s[1].length,text:s[2]}},fences:function(i){var s=this.rules.block.fences.exec(i);if(s){var L=s[0],k=y(L,s[3]||""),D=s[2]?s[2].trim():s[2];if(["latex","katex","math"].indexOf(D)>=0){var $=e(),ve=k;k=$,t[$]={type:"block",expression:ve}}return{type:"code",raw:L,lang:D,text:k}}}},u=/(?:\${2})([^\n`]+?)(?:\${2})/gi,n=0,e=function(){return"__special_katext_id_".concat(n++,"__")},t={};function f(){return t}function p(){n=0,t={}}function x(P){return P=P.replace(u,function(i,s){var L=e();return t[L]={type:"inline",expression:s},L}),P}var A=a.listitem;a.listitem=function(P){return A(x(P))};var I=a.paragraph;a.paragraph=function(P){return I(x(P))};var U=a.tablecell;a.tablecell=function(P,i){return U(x(P),i)},a.code=function(P,i,s){var L=(i||"").match(/\S*/)[0];return L?["latex","katex","math"].indexOf(L)>=0?"<p class='editormd-tex'>".concat(P,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(i,'">').concat(s?P:Object(E.escape)(P,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(s?P:Object(E.escape)(P,!0))+"</code></pre>"},a.heading=function(P,i,s){var L=this.options.headerPrefix+s.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return c.push({anchor:L,level:i,text:P}),"<h"+i+' id="'+L+'">'+P+"</h"+i+">"},b.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),b.a.use({tokenizer:h,renderer:a});var j=b.a,z=ee("SJMd"),V=ee("ulZh"),G=ee.n(V),Q=ee("m3rI"),ne=ee("Oy/b"),re=ee("p5ED"),be=ee("ErOA");/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var se=function(P,i){return(se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,L){s.__proto__=L}||function(s,L){for(var k in L)Object.prototype.hasOwnProperty.call(L,k)&&(s[k]=L[k])})(P,i)};function oe(P,i){function s(){this.constructor=P}se(P,i),P.prototype=i===null?Object.create(i):(s.prototype=i.prototype,new s)}function ue(P,i,s,L){return new(s||(s=Promise))(function(k,D){function $(He){try{Oe(L.next(He))}catch(Ee){D(Ee)}}function ve(He){try{Oe(L.throw(He))}catch(Ee){D(Ee)}}function Oe(He){var Ee;He.done?k(He.value):(Ee=He.value,Ee instanceof s?Ee:new s(function(Ve){Ve(Ee)})).then($,ve)}Oe((L=L.apply(P,i||[])).next())})}function he(P,i){var s,L,k,D,$={label:0,sent:function(){if(1&k[0])throw k[1];return k[1]},trys:[],ops:[]};return D={next:ve(0),throw:ve(1),return:ve(2)},typeof Symbol=="function"&&(D[Symbol.iterator]=function(){return this}),D;function ve(Oe){return function(He){return function(Ee){if(s)throw new TypeError("Generator is already executing.");for(;$;)try{if(s=1,L&&(k=2&Ee[0]?L.return:Ee[0]?L.throw||((k=L.return)&&k.call(L),0):L.next)&&!(k=k.call(L,Ee[1])).done)return k;switch(L=0,k&&(Ee=[2&Ee[0],k.value]),Ee[0]){case 0:case 1:k=Ee;break;case 4:return $.label++,{value:Ee[1],done:!1};case 5:$.label++,L=Ee[1],Ee=[0];continue;case 7:Ee=$.ops.pop(),$.trys.pop();continue;default:if(!(k=$.trys,(k=k.length>0&&k[k.length-1])||Ee[0]!==6&&Ee[0]!==2)){$=0;continue}if(Ee[0]===3&&(!k||Ee[1]>k[0]&&Ee[1]<k[3])){$.label=Ee[1];break}if(Ee[0]===6&&$.label<k[1]){$.label=k[1],k=Ee;break}if(k&&$.label<k[2]){$.label=k[2],$.ops.push(Ee);break}k[2]&&$.ops.pop(),$.trys.pop();continue}Ee=i.call(P,$)}catch(Ve){Ee=[6,Ve],L=0}finally{s=k=0}if(5&Ee[0])throw Ee[1];return{value:Ee[0]?Ee[1]:void 0,done:!0}}([Oe,He])}}}function te(){for(var P=0,i=0,s=arguments.length;i<s;i++)P+=arguments[i].length;var L=Array(P),k=0;for(i=0;i<s;i++)for(var D=arguments[i],$=0,ve=D.length;$<ve;$++,k++)L[k]=D[$];return L}var Y=function(){function P(){}return P.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},P.setAttributes=function(i,s){for(var L=0,k=s;L<k.length;L++){var D=k[L],$=D[0],ve=D[1];i.setAttribute($,ve)}},P.createRect=function(i,s,L){var k=document.createElementNS("http://www.w3.org/2000/svg","rect");return k.setAttribute("width",i.toString()),k.setAttribute("height",s.toString()),L&&P.setAttributes(k,L),k},P.createLine=function(i,s,L,k,D){var $=document.createElementNS("http://www.w3.org/2000/svg","line");return $.setAttribute("x1",i.toString()),$.setAttribute("y1",s.toString()),$.setAttribute("x2",L.toString()),$.setAttribute("y2",k.toString()),D&&P.setAttributes($,D),$},P.createPolygon=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","polygon");return L.setAttribute("points",i),s&&P.setAttributes(L,s),L},P.createCircle=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","circle");return L.setAttribute("cx",(i/2).toString()),L.setAttribute("cy",(i/2).toString()),L.setAttribute("r",i.toString()),s&&P.setAttributes(L,s),L},P.createEllipse=function(i,s,L){var k=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return k.setAttribute("cx",(i/2).toString()),k.setAttribute("cy",(s/2).toString()),k.setAttribute("rx",(i/2).toString()),k.setAttribute("ry",(s/2).toString()),L&&P.setAttributes(k,L),k},P.createGroup=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","g");return i&&P.setAttributes(s,i),s},P.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},P.createMarker=function(i,s,L,k,D,$,ve){var Oe=document.createElementNS("http://www.w3.org/2000/svg","marker");return P.setAttributes(Oe,[["id",i],["orient",s],["markerWidth",L.toString()],["markerHeight",k.toString()],["refX",D.toString()],["refY",$.toString()]]),Oe.appendChild(ve),Oe},P.createText=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","text");return s.setAttribute("x","0"),s.setAttribute("y","0"),i&&P.setAttributes(s,i),s},P.createTSpan=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","tspan");return L.textContent=i,s&&P.setAttributes(L,s),L},P.createImage=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","image");return i&&P.setAttributes(s,i),s},P.createPoint=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return L.x=i,L.y=s,L},P.createPath=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","path");return L.setAttribute("d",i),s&&P.setAttributes(L,s),L},P}(),fe=function(){function P(){}return P.addKey=function(i){P.key=i},Object.defineProperty(P,"isLicensed",{get:function(){return!!P.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(P.key)},enumerable:!1,configurable:!0}),P}(),Re=function(){function P(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return P.prototype.rasterize=function(i,s,L){var k=this;return new Promise(function(D){var $=L!==void 0?L:document.createElement("canvas");i===null&&(k.markersOnly=!0,k.naturalSize=!1);var ve=document.createElementNS("http://www.w3.org/2000/svg","svg");ve.setAttribute("xmlns","http://www.w3.org/2000/svg"),ve.setAttribute("width",s.width.baseVal.valueAsString),ve.setAttribute("height",s.height.baseVal.valueAsString),ve.setAttribute("viewBox","0 0 "+s.viewBox.baseVal.width.toString()+" "+s.viewBox.baseVal.height.toString()),ve.innerHTML=s.innerHTML,k.naturalSize===!0?(ve.width.baseVal.value=i.naturalWidth,ve.height.baseVal.value=i.naturalHeight):k.width!==void 0&&k.height!==void 0&&(ve.width.baseVal.value=k.width,ve.height.baseVal.value=k.height),$.width=ve.width.baseVal.value,$.height=ve.height.baseVal.value;var Oe=ve.outerHTML,He=$.getContext("2d");k.markersOnly!==!0&&He.drawImage(i,0,0,$.width,$.height);var Ee=window.URL,Ve=new Image($.width,$.height);Ve.setAttribute("crossOrigin","anonymous");var qe=new Blob([Oe],{type:"image/svg+xml"}),it=Ee.createObjectURL(qe);Ve.onload=function(){He.drawImage(Ve,0,0),Ee.revokeObjectURL(it);var gt=$.toDataURL(k.imageType,k.imageQuality);D(gt)},Ve.src=it})},P}(),Le=function(){},xe=function(){function P(i){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+i+"_"}return Object.defineProperty(P.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),P.prototype.addClass=function(i){return this.styleSheet===void 0&&this.addStyleSheet(),i.name=""+this.classNamePrefix+i.localName,this.classes.push(i),this.styleSheet.sheet.insertRule("."+i.name+" {"+i.style+"}",this.styleSheet.sheet.cssRules.length),i},P.prototype.addRule=function(i){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(i),this.styleSheet.sheet.insertRule(i.selector+" {"+i.style+"}",this.styleSheet.sheet.cssRules.length)},P.prototype.addStyleSheet=function(){var i;this.styleSheet=document.createElement("style"),((i=this.styleSheetRoot)!==null&&i!==void 0?i:document.head).appendChild(this.styleSheet),this.addRule(new Te("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Te("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new Te("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new le("fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new le("fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},P.prototype.removeStyleSheet=function(){var i;this.styleSheet&&(((i=this.styleSheetRoot)!==null&&i!==void 0?i:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},P}(),Te=function(P,i){this.selector=P,this.style=i},le=function(P,i){this.localName=P,this.style=i},ye=function(){function P(i,s,L,k,D){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=i,this.displayMode=s,this.markerItems=L,this.uiStyleSettings=k,this.styles=D,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return P.prototype.show=function(i){var s=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=i,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var L=document.createElement("div");L.className=this.toolbarBlockStyleClass.name,L.style.whiteSpace="nowrap",this.uiContainer.appendChild(L),this.addActionButton(L,'<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(L,'<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(L,'<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(L,'<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(L,'<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(L,'<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(L,'<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(L,'<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(D){var $=document.createElement("div");$.className=""+s.toolbarButtonStyleClass.name,$.setAttribute("data-type-name",D.typeName),$.innerHTML=D.icon,$.addEventListener("click",function(){s.markerToolbarButtonClicked($,D)}),s.buttons.push($),s.markerButtons.push($)}),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 k=document.createElement("div");k.className=this.toolbarBlockStyleClass.name,k.style.whiteSpace="nowrap",k.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(k),this.addActionButton(k,'<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(k,'<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()},P.prototype.addButtonClickListener=function(i){this.buttonClickListeners.push(i)},P.prototype.removeButtonClickListener=function(i){this.buttonClickListeners.indexOf(i)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(i),1)},P.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},P.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var i=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var s=0;s<this.markerButtons.length;s++)s<i||s===i&&this.markerButtons.length-1===i?this.markerButtonBlock.appendChild(this.markerButtons[s]):(s===i&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[s]))}},P.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},P.prototype.resetButtonStyles=function(){var i=this;this.buttons.forEach(function(s){s.className=s.className.replace(i.uiStyleSettings.toolbarButtonStyleColorsClassName?i.uiStyleSettings.toolbarButtonStyleColorsClassName:i.toolbarButtonStyleColorsClass.name,"").trim(),s.className=s.className.replace(i.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?i.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:i.toolbarActiveButtonStyleColorsClass.name,"").trim(),s.className+=" "+(i.uiStyleSettings.toolbarButtonStyleColorsClassName?i.uiStyleSettings.toolbarButtonStyleColorsClassName:i.toolbarButtonStyleColorsClass.name)})},P.prototype.addActionButton=function(i,s,L){var k=this,D=document.createElement("div");switch(D.className=""+this.toolbarButtonStyleClass.name,D.innerHTML=s,D.setAttribute("data-action",L),D.addEventListener("click",function(){k.actionToolbarButtonClicked(D,L)}),L){case"select":D.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":D.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":D.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":D.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":D.style.fill=this.uiStyleSettings.closeButtonColor}i.appendChild(D),this.buttons.push(D)},P.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new le("toolbar",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new le("toolbar_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new le("toolbar-block",`
|
|
display: inline-block;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new le("toolbar-overflow-block",`
|
|
position: absolute;
|
|
top: `+this.uiStyleSettings.toolbarHeight+`px;
|
|
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
|
|
z-index: 10;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new le("toolbar-overflow-block_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`));var i=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new le("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*i)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*i)+`px;
|
|
padding: `+i+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new le("toolbar_button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new le("toolbar_active_button",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Te("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new Te("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`))},P.prototype.markerToolbarButtonClicked=function(i,s){this.setActiveButton(i),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(L){return L("marker",s)}),this.markerButtonOverflowBlock.style.display="none"},P.prototype.actionToolbarButtonClicked=function(i,s){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(L){return L("action",s)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},P.prototype.setActiveButton=function(i){this.resetButtonStyles(),i.className=i.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),i.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},P.prototype.setActiveMarkerButton=function(i){var s=this.markerButtons.find(function(L){return L.getAttribute("data-type-name")===i});s&&this.setActiveButton(s)},P.prototype.setCurrentMarker=function(i){var s=this;this.currentMarker=i,this.buttons.filter(function(L){return/delete|notes/.test(L.getAttribute("data-action"))}).forEach(function(L){s.currentMarker===void 0?(L.style.fillOpacity="0.4",L.style.pointerEvents="none"):(L.style.fillOpacity="1",L.style.pointerEvents="all")})},P}(),we=function(){function P(i,s,L,k){this.panels=[],this.panelButtons=[],this.markerjsContainer=i,this.displayMode=s,this.uiStyleSettings=L,this.styles=k,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return P.prototype.addStyles=function(){var i;this.toolboxStyleClass=this.styles.addClass(new le("toolbox",`
|
|
width: 100%;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
font-family: sans-serif;
|
|
`+(this.displayMode==="popup"?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
box-sizing: content-box;
|
|
`+(this.displayMode==="popup"?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
`+(this.displayMode==="inline"?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
|
|
overflow: hidden;
|
|
`)),this.toolboxStyleColorsClass=this.styles.addClass(new le("toolbox_colors",`
|
|
color: `+this.uiStyleSettings.toolboxColor+`;
|
|
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new le("toolbox-button-row",`
|
|
display: flex;
|
|
cursor: default;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new le("toolbox-button-row_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
|
|
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new le("toolbox-panel-row",`
|
|
display: flex;
|
|
`+(this.displayMode==="inline"?"position: absolute;":"")+`
|
|
`+(this.displayMode==="inline"?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+`
|
|
cursor: default;
|
|
height: `+1.5*this.uiStyleSettings.toolbarHeight+`px;
|
|
`+(this.displayMode==="inline"?"width: 100%;":"")+`
|
|
box-sizing: content-box;
|
|
`)),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new le("toolbox-panel-row_colors",`
|
|
background-color: `+((i=this.uiStyleSettings.toolboxBackgroundColor)!==null&&i!==void 0?i:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
|
|
`)),this.toolboxButtonStyleClass=this.styles.addClass(new le("toolbox_button",`
|
|
display: inline-block;
|
|
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
|
|
padding: `+s+`px;
|
|
box-sizing: content-box;
|
|
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new le("toolbox-button_colors",`
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new le("toolbox-active-button_colors",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
|
|
fill: `+this.uiStyleSettings.toolbarColor+`;
|
|
`)),this.styles.addRule(new Te("."+this.toolboxButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
|
|
`)),this.styles.addRule(new Te("."+this.toolboxButtonStyleClass.name+" svg",`
|
|
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
|
|
`))},P.prototype.show=function(i){var s;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=i,this.uiContainer.className=this.toolboxStyleClass.name+" "+((s=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&s!==void 0?s:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},P.prototype.setPanelButtons=function(i){var s,L,k=this;this.panels=i,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((s=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&s!==void 0?s:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((L=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&L!==void 0?L:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(D){var $;D.uiStyleSettings=k.uiStyleSettings;var ve=document.createElement("div");ve.className=k.toolboxButtonStyleClass.name+" "+(($=k.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&$!==void 0?$:k.toolboxButtonStyleColorsClass.name),ve.innerHTML=D.icon,ve.title=D.title,ve.addEventListener("click",function(){k.panelButtonClick(D)}),k.panelButtons.push(ve),k.buttonRow.appendChild(ve)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},P.prototype.panelButtonClick=function(i){var s=this,L=-1;if(i!==this.activePanel){L=this.panels.indexOf(i),this.panelRow.innerHTML="";var k=i.getUi();k.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(k),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=i}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){s.displayMode==="inline"?s.panelRow.style.display="none":s.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(D,$){var ve,Oe;D.className=s.toolboxButtonStyleClass.name+" "+($===L?""+((ve=s.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&ve!==void 0?ve:s.toolboxActiveButtonStyleColorsClass.name):""+((Oe=s.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Oe!==void 0?Oe:s.toolboxButtonStyleColorsClass.name))})},P}(),De=function(P,i){this.title=P,this.icon=i},Se=function(P){function i(s,L,k,D){var $=P.call(this,s,D||'<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 $.colors=[],$.addTransparent=!1,$.colorBoxes=[],$.colors=L,$.currentColor=k,$.setCurrentColor=$.setCurrentColor.bind($),$.getColorBox=$.getColorBox.bind($),$}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");return L.style.overflow="hidden",L.style.whiteSpace="nowrap",this.colors.forEach(function(k){var D=s.getColorBox(k);L.appendChild(D),s.colorBoxes.push(D)}),L},i.prototype.getColorBox=function(s){var L=this,k=this.uiStyleSettings.toolbarHeight/4,D=this.uiStyleSettings.toolbarHeight-k,$=document.createElement("div");$.style.display="inline-block",$.style.boxSizing="content-box",$.style.width=D-2+"px",$.style.height=D-2+"px",$.style.padding="1px",$.style.marginRight="2px",$.style.marginBottom="2px",$.style.borderWidth="2px",$.style.borderStyle="solid",$.style.borderRadius=(D+2)/2+"px",$.style.borderColor=s===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",$.addEventListener("click",function(){L.setCurrentColor(s,$)});var ve=document.createElement("div");return ve.style.display="inline-block",ve.style.width=D-2+"px",ve.style.height=D-2+"px",ve.style.backgroundColor=s,ve.style.borderRadius=D/2+"px",s==="transparent"&&(ve.style.fill=this.uiStyleSettings.toolboxAccentColor,ve.innerHTML=`<svg viewBox="0 0 24 24">
|
|
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
|
|
</svg>`),$.appendChild(ve),$},i.prototype.setCurrentColor=function(s,L){var k=this;this.currentColor=s,this.colorBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(s)},i}(De),pe=function(){function P(i,s,L){this._state="new",this._isSelected=!1,this._container=i,this._overlayContainer=s,this.globalSettings=L,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(P.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),P.prototype.ownsTarget=function(i){return!1},Object.defineProperty(P.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),P.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},P.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},P.prototype.pointerDown=function(i,s){},P.prototype.dblClick=function(i,s){},P.prototype.manipulate=function(i){},P.prototype.pointerUp=function(i){this.stateChanged()},P.prototype.dispose=function(){},P.prototype.addMarkerVisualToContainer=function(i){this.container.childNodes.length>0?this.container.insertBefore(i,this.container.childNodes[0]):this.container.appendChild(i)},P.prototype.getState=function(){return{typeName:P.typeName,state:this.state,notes:this.notes}},P.prototype.restoreState=function(i){this._state=i.state,this.notes=i.notes},P.prototype.scale=function(i,s){},P.prototype.colorChanged=function(i){this.onColorChanged&&this.onColorChanged(i),this.stateChanged()},P.prototype.fillColorChanged=function(i){this.onFillColorChanged&&this.onFillColorChanged(i),this.stateChanged()},P.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var i=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),i.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(i)&&this.onStateChanged(this)}},P.typeName="MarkerBase",P}(),me=function(){function P(){this.findGripByVisual=this.findGripByVisual.bind(this)}return P.prototype.findGripByVisual=function(i){return this.topLeft.ownsTarget(i)?this.topLeft:this.topCenter.ownsTarget(i)?this.topCenter:this.topRight.ownsTarget(i)?this.topRight:this.centerLeft.ownsTarget(i)?this.centerLeft:this.centerRight.ownsTarget(i)?this.centerRight:this.bottomLeft.ownsTarget(i)?this.bottomLeft:this.bottomCenter.ownsTarget(i)?this.bottomCenter:this.bottomRight.ownsTarget(i)?this.bottomRight:void 0},P}(),Fe=function(){function P(){this.GRIP_SIZE=10,this.visual=Y.createGroup(),this.visual.appendChild(Y.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Y.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return P.prototype.ownsTarget=function(i){return i===this.visual||i===this.visual.childNodes[0]||i===this.visual.childNodes[1]},P}(),Pe=function(){function P(){}return P.toITransformMatrix=function(i){return{a:i.a,b:i.b,c:i.c,d:i.d,e:i.e,f:i.f}},P.toSVGMatrix=function(i,s){return i.a=s.a,i.b=s.b,i.c=s.c,i.d=s.d,i.e=s.e,i.f=s.f,i},P}(),Me=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.left=0,D.top=0,D.width=0,D.height=0,D.defaultSize={x:50,y:20},D.offsetX=0,D.offsetY=0,D.rotationAngle=0,D.CB_DISTANCE=10,D._suppressMarkerCreateEvent=!1,D.container.transform.baseVal.appendItem(Y.createTransform()),D.setupControlBox(),D}return oe(i,P),Object.defineProperty(i.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"visual",{get:function(){return this._visual},set:function(s){this._visual=s;var L=Y.createTransform();this._visual.transform.baseVal.appendItem(L)},enumerable:!1,configurable:!0}),i.prototype.ownsTarget=function(s){return!!P.prototype.ownsTarget.call(this,s)||!!(this.controlGrips.findGripByVisual(s)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(s))},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="new"&&(this.left=s.x,this.top=s.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var k=this.unrotatePoint(s);if(this.manipulationStartX=k.x,this.manipulationStartY=k.y,this.offsetX=k.x-this.left,this.offsetY=k.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(L),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(L)){this.activeGrip=this.rotatorGrip;var D=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=D.x-this.width/2,this.top=D.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var $=this.container.transform.baseVal.getItem(0);$.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem($,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},i.prototype.pointerUp=function(s){var L=this.state;P.prototype.pointerUp.call(this,s),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(s),this._state="select",L==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},i.prototype.moveVisual=function(s){this.visual.style.transform="translate("+s.x+"px, "+s.y+"px)"},i.prototype.manipulate=function(s){var L=this.unrotatePoint(s);this.state==="creating"?this.resize(s):this.state==="move"?(this.left=this.manipulationStartLeft+(L.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(L.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(L):this.state==="rotate"&&this.rotate(s)},i.prototype.resize=function(s){var L=this.manipulationStartLeft,k=this.manipulationStartWidth,D=this.manipulationStartTop,$=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:L=this.manipulationStartLeft+s.x-this.manipulationStartX,k=this.manipulationStartWidth+this.manipulationStartLeft-L;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:k=this.manipulationStartWidth+s.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:D=this.manipulationStartTop+s.y-this.manipulationStartY,$=this.manipulationStartHeight+this.manipulationStartTop-D;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:$=this.manipulationStartHeight+s.y-this.manipulationStartY}k>=0?(this.left=L,this.width=k):(this.left=L+k,this.width=-k),$>=0?(this.top=D,this.height=$):(this.top=D+$,this.height=-$),this.setSize()},i.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},i.prototype.rotate=function(s){if(Math.abs(s.x-this.centerX)>.1){var L=Math.sign(s.x-this.centerX);this.rotationAngle=180*Math.atan((s.y-this.centerY)/(s.x-this.centerX))/Math.PI+90*L,this.applyRotation()}},i.prototype.applyRotation=function(){var s=this.container.transform.baseVal.getItem(0);s.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(s,0)},i.prototype.rotatePoint=function(s){if(this.rotationAngle===0)return s;var L=this.container.getCTM(),k=Y.createPoint(s.x,s.y);return{x:(k=k.matrixTransform(L)).x,y:k.y}},i.prototype.unrotatePoint=function(s){if(this.rotationAngle===0)return s;var L=this.container.getCTM();L=L.inverse();var k=Y.createPoint(s.x,s.y);return{x:(k=k.matrixTransform(L)).x,y:k.y}},i.prototype.select=function(){P.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},i.prototype.deselect=function(){P.prototype.deselect.call(this),this.controlBox.style.display="none"},i.prototype.setupControlBox=function(){this.controlBox=Y.createGroup();var s=Y.createTransform();s.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(s),this.container.appendChild(this.controlBox),this.controlRect=Y.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=Y.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 me,this.addControlGrips(),this.controlBox.style.display="none"},i.prototype.adjustControlBox=function(){var s=this.controlBox.transform.baseVal.getItem(0);s.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(s,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},i.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},i.prototype.createGrip=function(){var s=new Fe;return s.visual.transform.baseVal.appendItem(Y.createTransform()),this.controlBox.appendChild(s.visual),s},i.prototype.positionGrips=function(){var s=this.controlGrips.topLeft.GRIP_SIZE,L=-s/2,k=L,D=(this.width+this.CB_DISTANCE)/2-s/2,$=(this.height+this.CB_DISTANCE)/2-s/2,ve=this.height+this.CB_DISTANCE-s/2,Oe=this.width+this.CB_DISTANCE-s/2;this.positionGrip(this.controlGrips.topLeft.visual,L,k),this.positionGrip(this.controlGrips.topCenter.visual,D,k),this.positionGrip(this.controlGrips.topRight.visual,Oe,k),this.positionGrip(this.controlGrips.centerLeft.visual,L,$),this.positionGrip(this.controlGrips.centerRight.visual,Oe,$),this.positionGrip(this.controlGrips.bottomLeft.visual,L,ve),this.positionGrip(this.controlGrips.bottomCenter.visual,D,ve),this.positionGrip(this.controlGrips.bottomRight.visual,Oe,ve),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,D,k-3*this.CB_DISTANCE)},i.prototype.positionGrip=function(s,L,k){var D=s.transform.baseVal.getItem(0);D.setTranslate(L,k),s.transform.baseVal.replaceItem(D,0)},i.prototype.hideControlBox=function(){this.controlBox.style.display="none"},i.prototype.showControlBox=function(){this.controlBox.style.display=""},i.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:Pe.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Pe.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},P.prototype.getState.call(this))},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s);var L=s;this.left=L.left,this.top=L.top,this.width=L.width,this.height=L.height,this.rotationAngle=L.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Pe.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,L.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Pe.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,L.containerTransformMatrix))},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L);var k=this.rotatePoint({x:this.left,y:this.top}),D=this.unrotatePoint({x:k.x*s,y:k.y*L});this.left=D.x,this.top=D.y,this.width=this.width*s,this.height=this.height*L,this.adjustControlBox()},i}(pe),Ie=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.fillColor="transparent",D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.opacity=1,D.setStrokeColor=D.setStrokeColor.bind(D),D.setFillColor=D.setFillColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.createVisual=D.createVisual.bind(D),D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.visual)},i.prototype.createVisual=function(){this.visual=Y.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)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},i.prototype.manipulate=function(s){P.prototype.manipulate.call(this,s)},i.prototype.resize=function(s){P.prototype.resize.call(this,s),this.setSize()},i.prototype.setSize=function(){P.prototype.setSize.call(this),Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},i.prototype.pointerUp=function(s){P.prototype.pointerUp.call(this,s),this.setSize()},i.prototype.setStrokeColor=function(s){this.strokeColor=s,this.visual&&Y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(s),this.stateChanged()},i.prototype.setFillColor=function(s){this.fillColor=s,this.visual&&Y.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},i.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.visual&&Y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},i.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.visual&&Y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},i.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},P.prototype.getState.call(this))},i.prototype.restoreState=function(s){var L=s;this.fillColor=L.fillColor,this.strokeColor=L.strokeColor,this.strokeWidth=L.strokeWidth,this.strokeDasharray=L.strokeDasharray,this.opacity=L.opacity,this.createVisual(),P.prototype.restoreState.call(this,s),this.setSize()},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.setSize()},i.title="Rectangle marker",i}(Me),Ne=function(P){function i(s,L,k,D){var $=P.call(this,s,D||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return $.widths=[],$.widthBoxes=[],$.widths=L,$.currentWidth=k,$.setCurrentWidth=$.setCurrentWidth.bind($),$}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");return L.style.display="flex",L.style.overflow="hidden",L.style.flexGrow="2",this.widths.forEach(function(k){var D=document.createElement("div");D.style.display="flex",D.style.flexGrow="2",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.borderColor=k===s.currentWidth?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentWidth(k,D)}),L.appendChild(D);var $=document.createElement("div");$.innerText=k.toString(),$.style.marginRight="5px",D.appendChild($);var ve=document.createElement("div");ve.style.minHeight="20px",ve.style.flexGrow="2",ve.style.display="flex",ve.style.alignItems="center";var Oe=document.createElement("hr");Oe.style.minWidth="20px",Oe.style.border="0px",Oe.style.borderTop=k+"px solid "+s.uiStyleSettings.toolboxColor,Oe.style.flexGrow="2",ve.appendChild(Oe),D.appendChild(ve),s.widthBoxes.push(D)}),L},i.prototype.setCurrentWidth=function(s,L){var k=this;this.currentWidth=s,this.widthBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},i}(De),Ue=function(P){function i(s,L,k,D){var $=P.call(this,s,D||'<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 $.styles=[],$.styleBoxes=[],$.styles=L,$.currentStyle=k,$.setCurrentStyle=$.setCurrentStyle.bind($),$}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");return L.style.display="flex",L.style.overflow="hidden",L.style.flexGrow="2",this.styles.forEach(function(k){var D=document.createElement("div");D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.overflow="hidden",D.style.maxWidth=100/s.styles.length-5+"%",D.style.borderColor=k===s.currentStyle?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentStyle(k,D)}),L.appendChild(D);var $=document.createElement("div");$.style.minHeight="20px",$.style.flexGrow="2",$.style.overflow="hidden";var ve=`<svg width="100" height="20">
|
|
<line x1="0" y1="10" x2="100" y2="10" stroke="`+s.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(k!==""?'stroke-dasharray="'+k+'"':"")+` />
|
|
</svg>`;$.innerHTML=ve,D.appendChild($),s.styleBoxes.push(D)}),L},i.prototype.setCurrentStyle=function(s,L){var k=this;this.currentStyle=s,this.styleBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},i}(De),ke=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.strokeColor=k.defaultColor,D.strokeWidth=k.defaultStrokeWidth,D.strokeDasharray=k.defaultStrokeDasharray,D.strokePanel=new Se("Line color",k.defaultColorSet,k.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new Ne("Line width",k.defaultStrokeWidths,k.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Ue("Line style",k.defaultStrokeDasharrays,k.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return oe(i,P),Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=P.prototype.getState.call(this);return s.typeName=i.typeName,s},i.typeName="FrameMarker",i.title="Frame marker",i.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',i}(Ie),Ae=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1},Be=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.x1=0,D.y1=0,D.x2=0,D.y2=0,D.defaultLength=50,D.manipulationStartX=0,D.manipulationStartY=0,D.manipulationStartX1=0,D.manipulationStartY1=0,D.manipulationStartX2=0,D.manipulationStartY2=0,D.setupControlBox(),D}return oe(i,P),i.prototype.ownsTarget=function(s){return!!P.prototype.ownsTarget.call(this,s)||!(!this.grip1.ownsTarget(s)&&!this.grip2.ownsTarget(s))},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.manipulationStartX=s.x,this.manipulationStartY=s.y,this.state==="new"&&(this.x1=s.x,this.y1=s.y,this.x2=s.x,this.y2=s.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(L)?this.activeGrip=this.grip1:this.grip2.ownsTarget(L)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},i.prototype.pointerUp=function(s){var L=this.state;P.prototype.pointerUp.call(this,s),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(s),this._state="select",L==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},i.prototype.adjustVisual=function(){},i.prototype.manipulate=function(s){this.state==="creating"?this.resize(s):this.state==="move"?(this.x1=this.manipulationStartX1+s.x-this.manipulationStartX,this.y1=this.manipulationStartY1+s.y-this.manipulationStartY,this.x2=this.manipulationStartX2+s.x-this.manipulationStartX,this.y2=this.manipulationStartY2+s.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(s)},i.prototype.resize=function(s){switch(this.activeGrip){case this.grip1:this.x1=s.x,this.y1=s.y;break;case this.grip2:case void 0:this.x2=s.x,this.y2=s.y}this.adjustVisual(),this.adjustControlBox()},i.prototype.select=function(){P.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},i.prototype.deselect=function(){P.prototype.deselect.call(this),this.controlBox.style.display="none"},i.prototype.setupControlBox=function(){this.controlBox=Y.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},i.prototype.adjustControlBox=function(){this.positionGrips()},i.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},i.prototype.createGrip=function(){var s=new Fe;return s.visual.transform.baseVal.appendItem(Y.createTransform()),this.controlBox.appendChild(s.visual),s},i.prototype.positionGrips=function(){var s=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-s/2,this.y1-s/2),this.positionGrip(this.grip2.visual,this.x2-s/2,this.y2-s/2)},i.prototype.positionGrip=function(s,L,k){var D=s.transform.baseVal.getItem(0);D.setTranslate(L,k),s.transform.baseVal.replaceItem(D,0)},i.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},P.prototype.getState.call(this))},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s);var L=s;this.x1=L.x1,this.y1=L.y1,this.x2=L.x2,this.y2=L.y2},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.x1=this.x1*s,this.y1=this.y1*L,this.x2=this.x2*s,this.y2=this.y2*L,this.adjustVisual(),this.adjustControlBox()},i}(pe),_e=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.setStrokeColor=D.setStrokeColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.strokeColor=k.defaultColor,D.strokeWidth=k.defaultStrokeWidth,D.strokeDasharray=k.defaultStrokeDasharray,D.strokePanel=new Se("Line color",k.defaultColorSet,k.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new Ne("Line width",k.defaultStrokeWidths,k.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Ue("Line style",k.defaultStrokeDasharrays,k.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.selectorLine&&s!==this.visibleLine)},i.prototype.createVisual=function(){this.visual=Y.createGroup(),this.selectorLine=Y.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=Y.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)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},i.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()),Y.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),Y.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),Y.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},i.prototype.setStrokeColor=function(s){this.strokeColor=s,this.adjustVisual(),this.colorChanged(s)},i.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.adjustVisual()},i.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.adjustVisual(),this.stateChanged()},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s);var L=s;this.strokeColor=L.strokeColor,this.strokeWidth=L.strokeWidth,this.strokeDasharray=L.strokeDasharray,this.createVisual(),this.adjustVisual()},i.typeName="LineMarker",i.title="Line marker",i.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',i}(Be),ce=function(P){function i(s,L,k,D){var $=P.call(this,s,D||'<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 $.fonts=[],$.fontBoxes=[],$.fonts=L,$.currentFont=k,$.setCurrentFont=$.setCurrentFont.bind($),$}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");return L.style.overflow="hidden",L.style.flexGrow="2",this.fonts.forEach(function(k){var D=document.createElement("div");D.style.display="inline-block",D.style.alignItems="center",D.style.justifyContent="space-between",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.overflow="hidden",D.style.maxWidth=100/s.fonts.length-5+"%",D.style.borderColor=k===s.currentFont?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentFont(k,D)}),L.appendChild(D);var $=document.createElement("div");$.style.display="flex",$.style.minHeight="20px",$.style.flexGrow="2",$.style.fontFamily=k,$.style.overflow="hidden";var ve=document.createElement("div");ve.style.whiteSpace="nowrap",ve.style.overflow="hidden",ve.style.textOverflow="ellipsis",ve.innerHTML="The quick brown fox jumps over the lazy dog",$.appendChild(ve),D.appendChild($),s.fontBoxes.push(D)}),L},i.prototype.setCurrentFont=function(s,L){var k=this;this.currentFont=s,this.fontBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},i}(De),Ce=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.color="transparent",D.padding=5,D.DEFAULT_TEXT="your text here",D.text=D.DEFAULT_TEXT,D.isMoved=!1,D.color=k.defaultColor,D.fontFamily=k.defaultFontFamily,D.defaultSize={x:100,y:30},D.setColor=D.setColor.bind(D),D.setFont=D.setFont.bind(D),D.renderText=D.renderText.bind(D),D.sizeText=D.sizeText.bind(D),D.textEditDivClicked=D.textEditDivClicked.bind(D),D.showTextEditor=D.showTextEditor.bind(D),D.setSize=D.setSize.bind(D),D.positionTextEditor=D.positionTextEditor.bind(D),D.colorPanel=new Se("Color",k.defaultColorSet,k.defaultColor),D.colorPanel.onColorChanged=D.setColor,D.fontFamilyPanel=new ce("Font",k.defaultFontFamilies,k.defaultFontFamily),D.fontFamilyPanel.onFontChanged=D.setFont,D}return oe(i,P),i.prototype.ownsTarget=function(s){if(P.prototype.ownsTarget.call(this,s)||s===this.visual||s===this.textElement||s===this.bgRectangle)return!0;var L=!1;return this.textElement.childNodes.forEach(function(k){k===s&&(L=!0)}),L},i.prototype.createVisual=function(){this.visual=Y.createGroup(),this.bgRectangle=Y.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=Y.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(Y.createTransform()),this.textElement.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.isMoved=!1,this.pointerDownPoint=s,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},i.prototype.renderText=function(){var s=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(L){s.textElement.appendChild(Y.createTSpan(L.trim()===""?" ":L.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},i.prototype.getTextScale=function(){var s=this.textElement.getBBox(),L=1;if(s.width>0&&s.height>0){var k=(1*this.width-this.width*this.padding*2/100)/s.width,D=(1*this.height-this.height*this.padding*2/100)/s.height;L=Math.min(k,D)}return L},i.prototype.getTextPosition=function(s){var L=this.textElement.getBBox(),k=0,D=0;return L.width>0&&L.height>0&&(k=(this.width-L.width*s)/2,D=this.height/2-L.height*s/2),{x:k,y:D}},i.prototype.sizeText=function(){var s=this.textElement.getBBox(),L=this.getTextScale(),k=this.getTextPosition(L);k.y-=s.y*L,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+k.x+"px, "+k.y+"px) scale("+L+", "+L+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(k.x,k.y),this.textElement.transform.baseVal.getItem(1).setScale(L,L))},i.prototype.manipulate=function(s){P.prototype.manipulate.call(this,s),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(s.x-this.pointerDownPoint.x)>5||Math.abs(s.y-this.pointerDownPoint.y)>5)},i.prototype.resize=function(s){P.prototype.resize.call(this,s),this.isMoved=!0,this.setSize(),this.sizeText()},i.prototype.setSize=function(){P.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},i.prototype.pointerUp=function(s){var L=this.state;L==="creating"&&(this._suppressMarkerCreateEvent=!0),P.prototype.pointerUp.call(this,s),this.setSize(),(L==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},i.prototype.showTextEditor=function(){var s=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(L){L.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var L=Number.parseFloat(s.textEditor.style.fontSize);s.textEditor.clientWidth>=Number.parseInt(s.textEditor.style.maxWidth)&&L>.9;)L-=.1,s.textEditor.style.fontSize=Math.max(L,.9)+"em"}),this.textEditor.addEventListener("keyup",function(L){L.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(L){if(L.clipboardData){var k=L.clipboardData.getData("text"),D=window.getSelection();if(!D.rangeCount)return!1;D.deleteFromDocument(),D.getRangeAt(0).insertNode(document.createTextNode(k)),L.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){s.textEditDivClicked(s.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},i.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var s=this.getTextScale(),L=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),k=this.textElement.getBBox(),D={x:k.width*s,y:k.height*s};L.x-=D.x/2,L.y-=D.y/2,this.textEditor.style.top=L.y+"px",this.textEditor.style.left=L.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-L.x+"px",this.textEditor.style.fontSize=Math.max(16*s,12)+"px",this.textElement.style.display="none"}},i.prototype.textEditDivClicked=function(s){this.text=s.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},i.prototype.select=function(){P.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},i.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),P.prototype.deselect.call(this)},i.prototype.dblClick=function(s,L){P.prototype.dblClick.call(this,s,L),this.showTextEditor()},i.prototype.setColor=function(s){this.textElement&&Y.setAttributes(this.textElement,[["fill",s]]),this.color=s,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(s)},i.prototype.setFont=function(s){this.textElement&&Y.setAttributes(this.textElement,[["font-family",s]]),this.fontFamily=s,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},i.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},i.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){var L=s;this.color=L.color,this.fontFamily=L.fontFamily,this.padding=L.padding,this.text=L.text,this.createVisual(),P.prototype.restoreState.call(this,s),this.setSize()},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.setSize(),this.sizeText(),this.positionTextEditor()},i.typeName="TextMarker",i.title="Text marker",i.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>',i}(Me),q=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.color="transparent",D.lineWidth=3,D.drawing=!1,D.pixelRatio=1,D.color=k.defaultColor,D.lineWidth=k.defaultStrokeWidth,D.pixelRatio=k.freehandPixelRatio,D.setColor=D.setColor.bind(D),D.addCanvas=D.addCanvas.bind(D),D.finishCreation=D.finishCreation.bind(D),D.setLineWidth=D.setLineWidth.bind(D),D.colorPanel=new Se("Color",k.defaultColorSet,k.defaultColor),D.colorPanel.onColorChanged=D.setColor,D.lineWidthPanel=new Ne("Line width",k.defaultStrokeWidths,k.defaultStrokeWidth),D.lineWidthPanel.onWidthChanged=D.setLineWidth,D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.drawingImage)},i.prototype.createVisual=function(){this.visual=Y.createGroup(),this.drawingImage=Y.createImage(),this.visual.appendChild(this.drawingImage);var s=Y.createTransform();this.visual.transform.baseVal.appendItem(s),this.addMarkerVisualToContainer(this.visual)},i.prototype.pointerDown=function(s,L){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(s.x,s.y),this.drawing=!0):P.prototype.pointerDown.call(this,s,L)},i.prototype.manipulate=function(s){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(s.x,s.y),this.canvasContext.stroke()):P.prototype.manipulate.call(this,s)},i.prototype.resize=function(s){P.prototype.resize.call(this,s),Y.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},i.prototype.pointerUp=function(s){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):P.prototype.pointerUp.call(this,s)},i.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)},i.prototype.select=function(){this.state==="creating"&&this.finishCreation(),P.prototype.select.call(this)},i.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),P.prototype.deselect.call(this)},i.prototype.finishCreation=function(){for(var s=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),L=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],k=L[0],D=L[1],$=L[2],ve=L[3],Oe=!1,He=0;He<this.canvasElement.height;He++)for(var Ee=0;Ee<this.canvasElement.width;Ee++)s.data[He*this.canvasElement.width*4+4*Ee+3]>0&&(Oe=!0,He<D&&(D=He),Ee<k&&(k=Ee),He>ve&&(ve=He),Ee>$&&($=Ee));if(Oe){this.left=k/this.pixelRatio,this.top=D/this.pixelRatio,this.width=($-k)/this.pixelRatio,this.height=(ve-D)/this.pixelRatio;var Ve=document.createElement("canvas");Ve.width=$-k,Ve.height=ve-D,Ve.getContext("2d").putImageData(this.canvasContext.getImageData(k,D,$-k,ve-D),0,0),this.drawingImgUrl=Ve.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},i.prototype.setDrawingImage=function(){Y.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),Y.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},i.prototype.setColor=function(s){this.color=s,this.colorChanged(s)},i.prototype.setLineWidth=function(s){this.lineWidth=s},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({drawingImgUrl:this.drawingImgUrl},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){this.createVisual(),P.prototype.restoreState.call(this,s),this.drawingImgUrl=s.drawingImgUrl,this.setDrawingImage()},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.setDrawingImage()},i.typeName="FreehandMarker",i.title="Freehand marker",i.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>',i}(Me),J=function(P){function i(s,L,k){var D=P.call(this,s,k||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return D.typeBoxes=[],D.currentType=L,D.setCurrentType=D.setCurrentType.bind(D),D}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");L.style.display="flex",L.style.overflow="hidden",L.style.flexGrow="2";for(var k=function(ve){var Oe="both";switch(ve){case 0:Oe="both";break;case 1:Oe="start";break;case 2:Oe="end";break;case 3:Oe="none"}var He=document.createElement("div");if(He.style.display="flex",He.style.flexGrow="2",He.style.alignItems="center",He.style.justifyContent="space-between",He.style.padding="5px",He.style.borderWidth="2px",He.style.borderStyle="solid",He.style.borderColor=Oe===D.currentType?D.uiStyleSettings.toolboxAccentColor:"transparent",He.addEventListener("click",function(){s.setCurrentType(Oe,He)}),L.appendChild(He),Oe==="both"||Oe==="start"){var Ee=document.createElement("div");Ee.style.display="flex",Ee.style.alignItems="center",Ee.style.minHeight="20px",Ee.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,5 10,0 10,10" fill="`+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,Ee.style.marginLeft="5px",He.appendChild(Ee)}var Ve=document.createElement("div");Ve.style.display="flex",Ve.style.alignItems="center",Ve.style.minHeight="20px",Ve.style.flexGrow="2";var qe=document.createElement("hr");if(qe.style.minWidth="20px",qe.style.border="0px",qe.style.borderTop="3px solid "+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee"),qe.style.flexGrow="2",Ve.appendChild(qe),He.appendChild(Ve),Oe==="both"||Oe==="end"){var it=document.createElement("div");it.style.display="flex",it.style.alignItems="center",it.style.minHeight="20px",it.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
|
|
<polygon points="0,0 10,5 0,10" fill="`+(D.uiStyleSettings!==void 0?D.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
|
|
</svg>`,it.style.marginRight="5px",He.appendChild(it)}D.typeBoxes.push(He)},D=this,$=0;$<4;$++)k($);return L},i.prototype.setCurrentType=function(s,L){var k=this;this.currentType=s,this.typeBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings!==void 0?k.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},i}(De),Z=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.arrowType="end",D.arrowBaseHeight=10,D.arrowBaseWidth=10,D.getArrowPoints=D.getArrowPoints.bind(D),D.setArrowType=D.setArrowType.bind(D),D.arrowTypePanel=new J("Arrow type","end"),D.arrowTypePanel.onArrowTypeChanged=D.setArrowType,D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.arrow1&&s!==this.arrow2)},i.prototype.getArrowPoints=function(s,L){var k=this.arrowBaseWidth+2*this.strokeWidth,D=this.arrowBaseHeight+2*this.strokeWidth;return s-k/2+","+(L+D/2)+" "+s+","+(L-D/2)+" "+(s+k/2)+","+(L+D/2)},i.prototype.createTips=function(){this.arrow1=Y.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=Y.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(Y.createTransform()),this.visual.appendChild(this.arrow2)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="creating"&&this.createTips()},i.prototype.adjustVisual=function(){if(P.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",Y.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),Y.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var s=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),L=this.arrow1.transform.baseVal.getItem(0);L.setRotate(s,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(L,0);var k=this.arrow2.transform.baseVal.getItem(0);k.setRotate(s+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(k,0)}},i.prototype.setArrowType=function(s){this.arrowType=s,this.adjustVisual(),this.stateChanged()},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({arrowType:this.arrowType},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s);var L=s;this.arrowType=L.arrowType,this.createTips(),this.adjustVisual()},i.typeName="ArrowMarker",i.title="Arrow marker",i.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',i}(_e),W=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.fillColor=k.defaultFillColor,D.strokeWidth=0,D.fillPanel=new Se("Color",k.defaultColorSet,k.defaultFillColor),D.fillPanel.onColorChanged=D.setFillColor,D}return oe(i,P),Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=P.prototype.getState.call(this);return s.typeName=i.typeName,s},i.typeName="CoverMarker",i.title="Cover marker",i.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',i}(Ie),H=function(P){function i(s,L,k,D){var $=P.call(this,s,D||'<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 $.opacities=[],$.opacityBoxes=[],$.opacities=L,$.currentOpacity=k,$.setCurrentOpacity=$.setCurrentOpacity.bind($),$}return oe(i,P),i.prototype.getUi=function(){var s=this,L=document.createElement("div");return L.style.display="flex",L.style.overflow="hidden",L.style.flexGrow="2",L.style.justifyContent="space-between",this.opacities.forEach(function(k){var D=document.createElement("div");D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="center",D.style.padding="5px",D.style.borderWidth="2px",D.style.borderStyle="solid",D.style.borderColor=k===s.currentOpacity?s.uiStyleSettings.toolboxAccentColor:"transparent",D.addEventListener("click",function(){s.setCurrentOpacity(k,D)}),L.appendChild(D);var $=document.createElement("div");$.innerText=100*k+"%",D.appendChild($),s.opacityBoxes.push(D)}),L},i.prototype.setCurrentOpacity=function(s,L){var k=this;this.currentOpacity=s,this.opacityBoxes.forEach(function(D){D.style.borderColor=D===L?k.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},i}(De),K=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.setOpacity=D.setOpacity.bind(D),D.fillColor=k.defaultHighlightColor,D.strokeWidth=0,D.opacity=k.defaultHighlightOpacity,D.fillPanel=new Se("Color",k.defaultColorSet,D.fillColor),D.fillPanel.onColorChanged=D.setFillColor,D.opacityPanel=new H("Opacity",k.defaultOpacitySteps,D.opacity),D.opacityPanel.onOpacityChanged=D.setOpacity,D}return oe(i,P),i.prototype.setOpacity=function(s){this.opacity=s,this.visual&&Y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=P.prototype.getState.call(this);return s.typeName=i.typeName,s},i.typeName="HighlightMarker",i.title="Highlight marker",i.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>',i}(W),X='<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>',ie=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.bgColor="transparent",D.tipPosition={x:0,y:0},D.tipBase1Position={x:0,y:0},D.tipBase2Position={x:0,y:0},D.tipMoving=!1,D.color=k.defaultStrokeColor,D.bgColor=k.defaultFillColor,D.fontFamily=k.defaultFontFamily,D.defaultSize={x:100,y:30},D.setBgColor=D.setBgColor.bind(D),D.getTipPoints=D.getTipPoints.bind(D),D.positionTip=D.positionTip.bind(D),D.setTipPoints=D.setTipPoints.bind(D),D.colorPanel=new Se("Text color",k.defaultColorSet,D.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>'),D.colorPanel.onColorChanged=D.setColor,D.bgColorPanel=new Se("Fill color",k.defaultColorSet,D.bgColor,X),D.bgColorPanel.onColorChanged=D.setBgColor,D.fontFamilyPanel=new ce("Font",k.defaultFontFamilies,k.defaultFontFamily),D.fontFamilyPanel.onFontChanged=D.setFont,D.tipGrip=new Fe,D.tipGrip.visual.transform.baseVal.appendItem(Y.createTransform()),D.controlBox.appendChild(D.tipGrip.visual),D}return oe(i,P),i.prototype.ownsTarget=function(s){return P.prototype.ownsTarget.call(this,s)||this.tipGrip.ownsTarget(s)||this.tip===s},i.prototype.createTip=function(){Y.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=Y.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},i.prototype.pointerDown=function(s,L){this.state==="new"&&P.prototype.pointerDown.call(this,s,L),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(L)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):P.prototype.pointerDown.call(this,s,L)},i.prototype.pointerUp=function(s){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,P.prototype.pointerUp.call(this,s);else{var L=this.state==="creating";P.prototype.pointerUp.call(this,s),this.setTipPoints(L),this.positionTip()}},i.prototype.manipulate=function(s){if(this.tipMoving){var L=this.unrotatePoint(s);this.tipPosition={x:L.x-this.manipulationStartLeft,y:L.y-this.manipulationStartTop},this.positionTip()}else P.prototype.manipulate.call(this,s)},i.prototype.setBgColor=function(s){this.bgRectangle&&this.tip&&(Y.setAttributes(this.bgRectangle,[["fill",s]]),Y.setAttributes(this.tip,[["fill",s]])),this.bgColor=s,this.fillColorChanged(s)},i.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},i.prototype.setTipPoints=function(s){s===void 0&&(s=!1);var L=Math.min(this.height/2,15),k=this.height/5;s&&(this.tipPosition={x:L+k/2,y:this.height+20});var D=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?D<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(k=this.width/5,L=Math.min(this.width/2,15),this.tipBase1Position={x:L,y:0},this.tipBase2Position={x:L+k,y:0}):(this.tipBase1Position={x:0,y:L},this.tipBase2Position={x:0,y:L+k}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?D<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(k=this.width/5,L=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-L-k,y:0},this.tipBase2Position={x:this.width-L,y:0}):(this.tipBase1Position={x:this.width,y:L},this.tipBase2Position={x:this.width,y:L+k}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?D<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(k=this.width/5,L=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-L-k,y:this.height},this.tipBase2Position={x:this.width-L,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-L-k},this.tipBase2Position={x:this.width,y:this.height-L}):D<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(k=this.width/5,L=Math.min(this.width/2,15),this.tipBase1Position={x:L,y:this.height},this.tipBase2Position={x:L+k,y:this.height}):(this.tipBase1Position={x:0,y:this.height-L},this.tipBase2Position={x:0,y:this.height-L-k})},i.prototype.resize=function(s){P.prototype.resize.call(this,s),this.positionTip()},i.prototype.positionTip=function(){Y.setAttributes(this.tip,[["points",this.getTipPoints()]]);var s=this.tipGrip.visual.transform.baseVal.getItem(0);s.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(s,0)},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),i.prototype.select=function(){this.positionTip(),P.prototype.select.call(this)},i.prototype.getState=function(){var s=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){var L=s;this.bgColor=L.bgColor,this.tipPosition=L.tipPosition,P.prototype.restoreState.call(this,s),this.createTip(),this.setTipPoints()},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.tipPosition={x:this.tipPosition.x*s,y:this.tipPosition.y*L},this.positionTip()},i.typeName="CalloutMarker",i.title="Callout marker",i.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>',i}(Ce),ae=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.fillColor="transparent",D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.opacity=1,D.strokeColor=k.defaultColor,D.strokeWidth=k.defaultStrokeWidth,D.strokeDasharray=k.defaultStrokeDasharray,D.fillColor=k.defaultFillColor,D.setStrokeColor=D.setStrokeColor.bind(D),D.setFillColor=D.setFillColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.setOpacity=D.setOpacity.bind(D),D.createVisual=D.createVisual.bind(D),D.strokePanel=new Se("Line color",te(k.defaultColorSet,["transparent"]),k.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.fillPanel=new Se("Fill color",te(k.defaultColorSet,["transparent"]),D.fillColor,X),D.fillPanel.onColorChanged=D.setFillColor,D.strokeWidthPanel=new Ne("Line width",k.defaultStrokeWidths,k.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Ue("Line style",k.defaultStrokeDasharrays,k.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D.opacityPanel=new H("Opacity",k.defaultOpacitySteps,D.opacity),D.opacityPanel.onOpacityChanged=D.setOpacity,D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.visual)},i.prototype.createVisual=function(){this.visual=Y.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)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="new"&&(this.createVisual(),this.moveVisual(s),this._state="creating")},i.prototype.manipulate=function(s){P.prototype.manipulate.call(this,s)},i.prototype.resize=function(s){P.prototype.resize.call(this,s),this.setSize()},i.prototype.setSize=function(){P.prototype.setSize.call(this),Y.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},i.prototype.pointerUp=function(s){P.prototype.pointerUp.call(this,s),this.setSize()},i.prototype.setStrokeColor=function(s){this.strokeColor=s,this.visual&&Y.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(s),this.stateChanged()},i.prototype.setFillColor=function(s){this.fillColor=s,this.visual&&Y.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(s),this.stateChanged()},i.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.visual&&Y.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},i.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.visual&&Y.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},i.prototype.setOpacity=function(s){this.opacity=s,this.visual&&Y.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){var L=s;this.fillColor=L.fillColor,this.strokeColor=L.strokeColor,this.strokeWidth=L.strokeWidth,this.strokeDasharray=L.strokeDasharray,this.opacity=L.opacity,this.createVisual(),P.prototype.restoreState.call(this,s),this.setSize()},i.prototype.scale=function(s,L){P.prototype.scale.call(this,s,L),this.setSize()},i.typeName="EllipseMarker",i.title="Ellipse marker",i.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>',i}(Me),ge=function(P){function i(s,L,k){return P.call(this,s,L,k)||this}return oe(i,P),Object.defineProperty(i.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.tip1&&s!==this.tip2)},i.prototype.createTips=function(){this.tip1=Y.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(Y.createTransform()),this.visual.appendChild(this.tip1),this.tip2=Y.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(Y.createTransform()),this.visual.appendChild(this.tip2)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.state==="creating"&&this.createTips()},i.prototype.adjustVisual=function(){if(P.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(Y.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()]]),Y.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 s=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),L=this.tip1.transform.baseVal.getItem(0);L.setRotate(s,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(L,0);var k=this.tip2.transform.baseVal.getItem(0);k.setRotate(s+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(k,0)}},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=P.prototype.getState.call(this);return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s),this.createTips(),this.adjustVisual()},i.typeName="MeasurementMarker",i.title="Measurement marker",i.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>',i}(_e),je=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.strokePanel.colors=k.defaultColorSet,D.fillColor="transparent",D}return oe(i,P),Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=P.prototype.getState.call(this);return s.typeName=i.typeName,s},i.typeName="EllipseFrameMarker",i.title="Ellipse frame marker",i.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>',i}(ae),ze=function(){function P(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(P.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),P.prototype.addUndoStep=function(i){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(i)||(this.undoStack.push(i),JSON.stringify(this.lastRedoStep)!==JSON.stringify(i)&&this.redoStack.splice(0,this.redoStack.length))},P.prototype.replaceLastUndoStep=function(i){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=i)},P.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},P.prototype.undo=function(){if(this.undoStack.length>1){var i=this.undoStack.pop();return i!==void 0&&this.redoStack.push(i),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},P.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},P}(),We=function(P){function i(s,L,k){var D=P.call(this,s,L,k)||this;return D.strokeColor="transparent",D.strokeWidth=0,D.strokeDasharray="",D.curveX=0,D.curveY=0,D.manipulationStartCurveX=0,D.manipulationStartCurveY=0,D.setStrokeColor=D.setStrokeColor.bind(D),D.setStrokeWidth=D.setStrokeWidth.bind(D),D.setStrokeDasharray=D.setStrokeDasharray.bind(D),D.positionGrips=D.positionGrips.bind(D),D.addControlGrips=D.addControlGrips.bind(D),D.adjustVisual=D.adjustVisual.bind(D),D.setupControlBox=D.setupControlBox.bind(D),D.resize=D.resize.bind(D),D.strokeColor=k.defaultColor,D.strokeWidth=k.defaultStrokeWidth,D.strokeDasharray=k.defaultStrokeDasharray,D.strokePanel=new Se("Line color",k.defaultColorSet,k.defaultColor),D.strokePanel.onColorChanged=D.setStrokeColor,D.strokeWidthPanel=new Ne("Line width",k.defaultStrokeWidths,k.defaultStrokeWidth),D.strokeWidthPanel.onWidthChanged=D.setStrokeWidth,D.strokeStylePanel=new Ue("Line style",k.defaultStrokeDasharrays,k.defaultStrokeDasharray),D.strokeStylePanel.onStyleChanged=D.setStrokeDasharray,D}return oe(i,P),i.prototype.ownsTarget=function(s){return!(!P.prototype.ownsTarget.call(this,s)&&s!==this.visual&&s!==this.selectorCurve&&s!==this.visibleCurve&&!this.curveGrip.ownsTarget(s))},i.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},i.prototype.createVisual=function(){this.visual=Y.createGroup(),this.selectorCurve=Y.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=Y.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)},i.prototype.pointerDown=function(s,L){P.prototype.pointerDown.call(this,s,L),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=s.x,this.curveY=s.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(L)&&(this.activeGrip=this.curveGrip,this._state="resize")},i.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),Y.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),Y.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),Y.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},i.prototype.setupControlBox=function(){P.prototype.setupControlBox.call(this),this.curveControlLine1=Y.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=Y.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)},i.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,P.prototype.addControlGrips.call(this)},i.prototype.positionGrips=function(){P.prototype.positionGrips.call(this);var s=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-s/2,this.curveY-s/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()))},i.prototype.manipulate=function(s){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+s.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+s.y-this.manipulationStartY),P.prototype.manipulate.call(this,s)},i.prototype.resize=function(s){this.activeGrip===this.curveGrip&&(this.curveX=s.x,this.curveY=s.y),P.prototype.resize.call(this,s),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},i.prototype.setStrokeColor=function(s){this.strokeColor=s,this.adjustVisual(),this.colorChanged(s)},i.prototype.setStrokeWidth=function(s){this.strokeWidth=s,this.adjustVisual()},i.prototype.setStrokeDasharray=function(s){this.strokeDasharray=s,this.adjustVisual()},i.prototype.scale=function(s,L){this.curveX=this.curveX*s,this.curveY=this.curveY*L,P.prototype.scale.call(this,s,L)},Object.defineProperty(i.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),i.prototype.getState=function(){var s=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},P.prototype.getState.call(this));return s.typeName=i.typeName,s},i.prototype.restoreState=function(s){P.prototype.restoreState.call(this,s);var L=s;this.strokeColor=L.strokeColor,this.strokeWidth=L.strokeWidth,this.strokeDasharray=L.strokeDasharray,this.curveX=L.curveX,this.curveY=L.curveY,this.createVisual(),this.adjustVisual()},i.typeName="CurveMarker",i.title="Curve marker",i.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>',i}(Be),Ye=function(){function P(i,s){s===void 0&&(s=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=i,this.cancelable=s}return Object.defineProperty(P.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),P.prototype.preventDefault=function(){this._defaultPrevented=!0},P}(),$e=function(P){function i(s,L,k){var D=P.call(this,s,!1)||this;return D.dataUrl=L,D.state=k,D}return oe(i,P),i}(Ye),Ge=function(P){function i(s,L,k){k===void 0&&(k=!1);var D=P.call(this,s,k)||this;return D.marker=L,D}return oe(i,P),i}(Ye),tt=function(){function P(){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 P.prototype.addEventListener=function(i,s){this[i].push(s)},P.prototype.removeEventListener=function(i,s){var L=this[i].indexOf(s);L>-1&&this[i].splice(L,1)},P}(),rt=function(){function P(i){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new Ae,this._isOpen=!1,this.undoRedoManager=new ze,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 tt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=P.instanceCounter++,this.styles=new xe(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=i,this.targetRoot=document.body,this.width=i.clientWidth,this.height=i.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(P.prototype,"ALL_MARKER_TYPES",{get:function(){return[ke,q,Z,Ce,je,ae,K,ie,ge,W,_e,We]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[ke,q,Z,Ce,ae,K,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"BASIC_MARKER_TYPES",{get:function(){return[ke,q,Z,Ce,K]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(i){var s=this;this._availableMarkerTypes.splice(0),i.forEach(function(L){if(typeof L=="string"){var k=s.ALL_MARKER_TYPES.find(function(D){return D.typeName===L});k!==void 0&&s._availableMarkerTypes.push(k)}else s._availableMarkerTypes.push(L)})},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(i){this._zoomLevel=i,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(P.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),P.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),fe.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},P.prototype.show=function(){var i=this;this.styles.styleSheetRoot===void 0&&Le.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Le.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(s){return s(new Ye(i))})},P.prototype.render=function(){return ue(this,void 0,void 0,function(){var i;return he(this,function(s){switch(s.label){case 0:return this.setCurrentMarker(),(i=new Re).naturalSize=this.renderAtNaturalSize,i.imageType=this.renderImageType,i.imageQuality=this.renderImageQuality,i.markersOnly=this.renderMarkersOnly,i.width=this.renderWidth,i.height=this.renderHeight,[4,i.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return s.sent(),[4,i.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,s.sent()]}})})},P.prototype.close=function(i){var s=this;if(i===void 0&&(i=!1),this.isOpen){var L=!1;i||this.eventListeners.beforeclose.forEach(function(k){var D=new Ye(s,!0);k(D),D.defaultPrevented&&(L=!0)}),L||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(k){return k(new Ye(s))}),this.detachEvents(),this._isOpen=!1)}},P.prototype.addMarkersToToolbar=function(){for(var i,s=[],L=0;L<arguments.length;L++)s[L]=arguments[L];(i=this._availableMarkerTypes).push.apply(i,s)},P.prototype.addRenderEventListener=function(i){this.addEventListener("render",function(s){i(s.dataUrl,s.state)})},P.prototype.removeRenderEventListener=function(i){},P.prototype.addCloseEventListener=function(i){this.addEventListener("close",function(){i()})},P.prototype.removeCloseEventListener=function(i){},P.prototype.setupResizeObserver=function(){var i=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){i.resize(i.target.clientWidth,i.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return i.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},P.prototype.onPopupTargetResize=function(){var i=1*this.target.clientWidth/this.target.clientHeight,s=this.editorCanvas.clientWidth/i>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*i:this.editorCanvas.clientWidth,L=s<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/i;this.resize(s,L)},P.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},P.prototype.resize=function(i,s){this._isResizing=!0;var L=i/this.imageWidth,k=s/this.imageHeight;this.imageWidth=Math.round(i),this.imageHeight=Math.round(s),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(L,k),this._isResizing=!1},P.prototype.scaleMarkers=function(i,s){var L,k=this;this._currentMarker&&this._currentMarker instanceof Ce?this._currentMarker.scale(i,s):(L=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(D){D!==k._currentMarker&&D.scale(i,s)}),L!==void 0&&this.setCurrentMarker(L)},P.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"},P.prototype.setTopLeft=function(){var i=this.editingTarget.getBoundingClientRect(),s=this.editorCanvas.getBoundingClientRect();this.left=i.left-s.left,this.top=i.top-s.top},P.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)},P.prototype.addDefs=function(){for(var i,s=[],L=0;L<arguments.length;L++)s[L]=arguments[L];this.defs=Y.createDefs(),this.addDefsToImage(),(i=this.defs).append.apply(i,s)},P.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},P.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)},P.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},P.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},P.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)},P.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},P.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)},P.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 i=document.createElement("a");i.href="https://markerjs.com/",i.target="_blank",i.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>',i.title="Powered by marker.js",i.style.display="grid",i.style.alignItems="center",i.style.justifyItems="center",i.style.padding="3px",i.style.width="20px",i.style.height="20px",this.logoUI.appendChild(i),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},P.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},P.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"},P.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},P.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var i=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=i+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new ye(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new we(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},P.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},P.prototype.removeMarker=function(i){this.markerImage.removeChild(i.container),this.markers.indexOf(i)>-1&&this.markers.splice(this.markers.indexOf(i),1),i.dispose()},P.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},P.prototype.toolbarButtonClicked=function(i,s){if(i==="marker"&&s!==void 0)this.createNewMarker(s);else if(i==="action")switch(s){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},P.prototype.deleteSelectedMarker=function(){var i=this;if(this._currentMarker!==void 0){var s=!1;if(this.eventListeners.markerbeforedelete.forEach(function(k){var D=new Ge(i,i._currentMarker,!0);k(D),D.defaultPrevented&&(s=!0)}),!s){var L=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(k){return k(new Ge(i,L))})}}},P.prototype.clear=function(){var i=this,s=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function($){var ve=new Ge(i,void 0,!0);$(ve),ve.defaultPrevented&&(s=!0)}),!s)){this.setCurrentMarker();for(var L=function($){var ve=k.markers[$];k.setCurrentMarker(k.markers[$]),k._currentMarker.dispose(),k.markerImage.removeChild(k._currentMarker.container),k.markers.splice(k.markers.indexOf(k._currentMarker),1),k.eventListeners.markerdelete.forEach(function(Oe){return Oe(new Ge(i,ve))})},k=this,D=this.markers.length-1;D>=0;D--)L(D);this.addUndoStep()}},Object.defineProperty(P.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),P.prototype.showNotesEditor=function(){var i;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(i=this._currentMarker.notes)!==null&&i!==void 0?i:"",this.overlayContainer.appendChild(this.notesArea))},P.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},P.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},P.prototype.addUndoStep=function(){var i=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var s=this.getState(),L=this.undoRedoManager.getLastUndoStep();if(!L||L.width===s.width&&L.height===s.height){var k=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(s),k<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(D){return D(new Ye(i))})}else this.undoRedoManager.replaceLastUndoStep(s),this.eventListeners.statechange.forEach(function(D){return D(new Ye(i))})}},P.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},P.prototype.undoStep=function(){var i=this,s=this.undoRedoManager.undo();s!==void 0&&(this.restoreState(s),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(L){return L(new Ye(i))}))},P.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},P.prototype.redoStep=function(){var i=this,s=this.undoRedoManager.redo();s!==void 0&&(this.restoreState(s),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(L){return L(new Ye(i))}))},P.prototype.stepZoom=function(){var i=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=i<this.zoomSteps.length-1?this.zoomSteps[i+1]:this.zoomSteps[0]},P.prototype.panTo=function(i){this.contentDiv.scrollBy({left:this.prevPanPoint.x-i.x,top:this.prevPanPoint.y-i.y}),this.prevPanPoint=i},P.prototype.startRenderAndClose=function(){return ue(this,void 0,void 0,function(){var i,s,L=this;return he(this,function(k){switch(k.label){case 0:return[4,this.render()];case 1:return i=k.sent(),s=this.getState(),this.eventListeners.render.forEach(function(D){return D(new $e(L,i,s))}),this.close(!0),[2]}})})},P.prototype.getState=function(i){i===!0&&this.setCurrentMarker();var s={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(L){return s.markers.push(L.getState())}),s},P.prototype.restoreState=function(i){var s=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);i.markers.forEach(function(L){var k=s._availableMarkerTypes.find(function($){return $.typeName===L.typeName});if(k!==void 0){var D=s.addNewMarker(k);D.restoreState(L),s.markers.push(D)}}),i.width&&i.height&&(i.width!==this.imageWidth||i.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/i.width,this.imageHeight/i.height),this.eventListeners.restorestate.forEach(function(L){return L(new Ye(s))})},P.prototype.addNewMarker=function(i){var s=Y.createGroup();return this.markerImage.appendChild(s),new i(s,this.overlayContainer,this.settings)},P.prototype.createNewMarker=function(i){var s,L=this;(s=typeof i=="string"?this._availableMarkerTypes.find(function(k){return k.typeName===i}):i)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(s),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(s.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(k){return k(new Ge(L,L._currentMarker))}))},P.prototype.markerCreated=function(i){var s=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(i),this.setCurrentMarker(i),i instanceof q&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(q):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(L){return L(new Ge(s,s._currentMarker))})},P.prototype.colorChanged=function(i){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=i,this.settings.defaultStrokeColor=i)},P.prototype.fillColorChanged=function(i){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=i)},P.prototype.markerStateChanged=function(i){var s=this;this.eventListeners.markerchange.forEach(function(L){return L(new Ge(s,i))})},P.prototype.setCurrentMarker=function(i){var s=this;this._currentMarker!==i&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(L){return L(new Ge(s,s._currentMarker))})),this._currentMarker=i,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(L){return L(new Ge(s,s._currentMarker))}))},P.prototype.onPointerDown=function(i){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||i.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var s=this.markers.find(function(L){return L.ownsTarget(i.target)});s!==void 0?(this.setCurrentMarker(s),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(i.clientX,i.clientY),i.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:i.clientX,y:i.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(i.clientX,i.clientY))},P.prototype.onDblClick=function(i){if(this._isFocused||this.focus(),this.mode==="select"){var s=this.markers.find(function(L){return L.ownsTarget(i.target)});s!==void 0&&s!==this._currentMarker&&this.setCurrentMarker(s),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(i.clientX,i.clientY),i.target):this.setCurrentMarker()}},P.prototype.onPointerMove=function(i){this.touchPoints!==1&&i.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||i.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(i.clientX,i.clientY)):this.zoomLevel>1&&this.panTo({x:i.clientX,y:i.clientY}))},P.prototype.onPointerUp=function(i){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(i.clientX,i.clientY)),this.isDragging=!1,this.addUndoStep()},P.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},P.prototype.onKeyUp=function(i){this._currentMarker===void 0||this.notesArea!==void 0||i.key!=="Delete"&&i.key!=="Backspace"||this.deleteSelectedMarker()},P.prototype.clientToLocalCoordinates=function(i,s){var L=this.markerImage.getBoundingClientRect();return{x:(i-L.left)/this.zoomLevel,y:(s-L.top)/this.zoomLevel}},P.prototype.onWindowResize=function(){this.positionUI()},P.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var i=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=i+"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()},P.prototype.addLicenseKey=function(i){fe.addKey(i)},P.prototype.addEventListener=function(i,s){this.eventListeners.addEventListener(i,s)},P.prototype.removeEventListener=function(i,s){this.eventListeners.removeEventListener(i,s)},P.prototype.renderState=function(i){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(i),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(P.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),P.prototype.focus=function(){var i=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(s){return s(new Ye(i))}))},P.prototype.blur=function(){var i=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(s){return s(new Ye(i))}))},P.instanceCounter=0,P}();/* **********************************
|
|
cropro version 1.2.0
|
|
@license SEE LICENSE IN LICENSE
|
|
|
|
copyright Alan Mendelevich
|
|
see README and LICENSE for details
|
|
********************************** *//*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */var st=function(P,i){return(st=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,L){s.__proto__=L}||function(s,L){for(var k in L)Object.prototype.hasOwnProperty.call(L,k)&&(s[k]=L[k])})(P,i)};function at(P,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=P}st(P,i),P.prototype=i===null?Object.create(i):(s.prototype=i.prototype,new s)}function Qe(P,i,s,L){return new(s||(s=Promise))(function(k,D){function $(He){try{Oe(L.next(He))}catch(Ee){D(Ee)}}function ve(He){try{Oe(L.throw(He))}catch(Ee){D(Ee)}}function Oe(He){var Ee;He.done?k(He.value):(Ee=He.value,Ee instanceof s?Ee:new s(function(Ve){Ve(Ee)})).then($,ve)}Oe((L=L.apply(P,i||[])).next())})}function pt(P,i){var s,L,k,D,$={label:0,sent:function(){if(1&k[0])throw k[1];return k[1]},trys:[],ops:[]};return D={next:ve(0),throw:ve(1),return:ve(2)},typeof Symbol=="function"&&(D[Symbol.iterator]=function(){return this}),D;function ve(Oe){return function(He){return function(Ee){if(s)throw new TypeError("Generator is already executing.");for(;$;)try{if(s=1,L&&(k=2&Ee[0]?L.return:Ee[0]?L.throw||((k=L.return)&&k.call(L),0):L.next)&&!(k=k.call(L,Ee[1])).done)return k;switch(L=0,k&&(Ee=[2&Ee[0],k.value]),Ee[0]){case 0:case 1:k=Ee;break;case 4:return $.label++,{value:Ee[1],done:!1};case 5:$.label++,L=Ee[1],Ee=[0];continue;case 7:Ee=$.ops.pop(),$.trys.pop();continue;default:if(!(k=$.trys,(k=k.length>0&&k[k.length-1])||Ee[0]!==6&&Ee[0]!==2)){$=0;continue}if(Ee[0]===3&&(!k||Ee[1]>k[0]&&Ee[1]<k[3])){$.label=Ee[1];break}if(Ee[0]===6&&$.label<k[1]){$.label=k[1],k=Ee;break}if(k&&$.label<k[2]){$.label=k[2],$.ops.push(Ee);break}k[2]&&$.ops.pop(),$.trys.pop();continue}Ee=i.call(P,$)}catch(Ve){Ee=[6,Ve],L=0}finally{s=k=0}if(5&Ee[0])throw Ee[1];return{value:Ee[0]?Ee[1]:void 0,done:!0}}([Oe,He])}}}var xt=function(){function P(){}return P.addKey=function(i){P.key=i},Object.defineProperty(P,"isLicensed",{get:function(){return!!P.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(P.key)},enumerable:!1,configurable:!0}),P}(),Ke=function(){function P(){}return P.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},P.setAttributes=function(i,s){for(var L=0,k=s;L<k.length;L++){var D=k[L],$=D[0],ve=D[1];i.setAttribute($,ve)}},P.createRect=function(i,s,L){var k=document.createElementNS("http://www.w3.org/2000/svg","rect");return k.setAttribute("width",i.toString()),k.setAttribute("height",s.toString()),L&&P.setAttributes(k,L),k},P.createLine=function(i,s,L,k,D){var $=document.createElementNS("http://www.w3.org/2000/svg","line");return $.setAttribute("x1",i.toString()),$.setAttribute("y1",s.toString()),$.setAttribute("x2",L.toString()),$.setAttribute("y2",k.toString()),D&&P.setAttributes($,D),$},P.createPolygon=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","polygon");return L.setAttribute("points",i),s&&P.setAttributes(L,s),L},P.createCircle=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","circle");return L.setAttribute("cx",(i/2).toString()),L.setAttribute("cy",(i/2).toString()),L.setAttribute("r",i.toString()),s&&P.setAttributes(L,s),L},P.createEllipse=function(i,s,L){var k=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return k.setAttribute("cx",(i/2).toString()),k.setAttribute("cy",(s/2).toString()),k.setAttribute("rx",(i/2).toString()),k.setAttribute("ry",(s/2).toString()),L&&P.setAttributes(k,L),k},P.createGroup=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","g");return i&&P.setAttributes(s,i),s},P.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},P.createMarker=function(i,s,L,k,D,$,ve){var Oe=document.createElementNS("http://www.w3.org/2000/svg","marker");return P.setAttributes(Oe,[["id",i],["orient",s],["markerWidth",L.toString()],["markerHeight",k.toString()],["refX",D.toString()],["refY",$.toString()]]),Oe.appendChild(ve),Oe},P.createText=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","text");return s.setAttribute("x","0"),s.setAttribute("y","0"),i&&P.setAttributes(s,i),s},P.createTSpan=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","tspan");return L.textContent=i,s&&P.setAttributes(L,s),L},P.createImage=function(i){var s=document.createElementNS("http://www.w3.org/2000/svg","image");return i&&P.setAttributes(s,i),s},P.createPoint=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return L.x=i,L.y=s,L},P.createPath=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg","path");return L.setAttribute("d",i),s&&P.setAttributes(L,s),L},P.createElement=function(i,s){var L=document.createElementNS("http://www.w3.org/2000/svg",i);return s&&P.setAttributes(L,s),L},P.getHollowRectanglePath=function(i,s,L,k,D,$,ve,Oe){return"M"+i+","+s+"V"+(s+k)+"H"+(i+L)+"V"+s+"H"+D+"V"+$+"H"+(D+ve)+"V"+($+Oe)+"H"+D+"V"+s+"Z"},P}(),Tt=function(){function P(i){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+i+"_"}return Object.defineProperty(P.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),P.prototype.addClass=function(i){return this.styleSheet===void 0&&this.addStyleSheet(),i.name=""+this.classNamePrefix+i.localName,this.classes.push(i),this.styleSheet.sheet.insertRule("."+i.name+" {"+i.style+"}",this.styleSheet.sheet.cssRules.length),i},P.prototype.addRule=function(i){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(i),this.styleSheet.sheet.insertRule(i.selector+" {"+i.style+"}",this.styleSheet.sheet.cssRules.length)},P.prototype.addStyleSheet=function(){var i;this.styleSheet=document.createElement("style"),((i=this.styleSheetRoot)!==null&&i!==void 0?i:document.head).appendChild(this.styleSheet),this.addRule(new mt("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new mt("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
`)),this.addRule(new mt("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
`)),this.addClass(new ut("_fade_in",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
|
|
`)),this.addClass(new ut("_fade_out",`
|
|
animation-duration: 0.3s;
|
|
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
|
|
`))},P.prototype.removeStyleSheet=function(){var i;this.styleSheet&&(((i=this.styleSheetRoot)!==null&&i!==void 0?i:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},P}(),mt=function(P,i){this.selector=P,this.style=i},ut=function(P,i){this.localName=P,this.style=i},Pt=function(){function P(){this.blocks=[],this.display=""}return P.prototype.addButtonBlock=function(i){i.className=this.blockClassName,i.buttonClassName=this.buttonClassName,i.buttonColorsClassName=this.buttonColorsClassName,i.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(i)},P.prototype.addElementBlock=function(i){i.className===void 0&&(i.className=this.blockClassName),this.blocks.push(i)},P.prototype.getUI=function(){var i=document.createElement("div");return i.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,i.style.display=this.display,this.blocks.forEach(function(s){return i.appendChild(s.getUI())}),i},P}(),Ot=function(){function P(){}return P.prototype.getUI=function(){var i=document.createElement("div");if(i.className=this.className,this.minWidth!==void 0&&(i.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":i.style.justifyContent="flex-start";break;case"center":i.style.justifyContent="center";break;case"end":i.style.justifyContent="flex-end"}return i.style.whiteSpace="nowrap",i},P}(),St=function(P){function i(){var s=P!==null&&P.apply(this,arguments)||this;return s.buttons=[],s}return at(i,P),i.prototype.addButton=function(s){s.className=this.buttonClassName,s.colorsClassName=this.buttonColorsClassName,s.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(s)},i.prototype.getUI=function(){var s=P.prototype.getUI.call(this);return this.buttons.forEach(function(L){return s.appendChild(L.getUI())}),s},i}(Ot),ct=function(){function P(i,s){this._isActive=!1,this._isHidden=!1,this._icon=i,this.title=s,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(P.prototype,"icon",{get:function(){return this._icon},set:function(i){this._icon=i,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isActive",{get:function(){return this._isActive},set:function(i){this._isActive=i,this.adjustClassName()},enumerable:!1,configurable:!0}),P.prototype.getUI=function(){var i=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 i.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},P.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,"")))},P.prototype.hide=function(){this._isHidden=!0},P}(),It=function(P){function i(){var s=P!==null&&P.apply(this,arguments)||this;return s.elements=[],s}return at(i,P),i.prototype.addElement=function(s){this.elements.push(s)},i.prototype.getUI=function(){var s=P.prototype.getUI.call(this);return this.elements.forEach(function(L){return s.appendChild(L)}),s},i}(Ot),Mt=function(){function P(i,s){this.horizontal=i,this.vertical=s}return Object.defineProperty(P.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),P.prototype.getVerticalLength=function(i){return i/this.ratio},P.prototype.getHorizontalLength=function(i){return i*this.ratio},P}(),Lt=function(){function P(){}return P.getIcon=function(i,s){if(i>0&&s>0){var L=new Mt(i,s),k=L.ratio>=1?20:L.getHorizontalLength(20),D=L.ratio<1?20:L.getVerticalLength(20),$=document.createElementNS("http://www.w3.org/2000/svg","svg");$.setAttribute("xmlns","http://www.w3.org/2000/svg"),$.setAttribute("viewBox","0 0 24 24"),document.body.appendChild($);var ve=Ke.createDefs();$.appendChild(ve);var Oe=Ke.createElement("clipPath",[["id","text-bg-clip"]]);ve.appendChild(Oe);var He=Ke.createPath(Ke.getHollowRectanglePath((24-k)/2,(24-D)/2,k,D,(24-k)/2+2,(24-D)/2+2,k-4,D-4));$.appendChild(He);var Ee=Ke.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ee.appendChild(Ke.createTSpan(i+":"+s)),$.appendChild(Ee);var Ve=Ee.getBBox();Ke.setAttributes(Ee,[["x",((24-Ve.width)/2).toString()],["y",((24-Ve.height)/2-Ve.y).toString()]]);var qe=Ke.createPath(Ke.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Ve.width))/2,(24-Math.ceil(Ve.height))/2,Math.ceil(Ve.width),Math.ceil(Ve.height)));return Oe.appendChild(qe),Ke.setAttributes(He,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild($),$.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>'},P}(),Ft=function(P){function i(s,L,k){var D=P.call(this,s,L)||this;return D.isDropdownOpen=!1,D.onClick=D.dropdownButtonClicked,D.dropdownButtons=k,D}return at(i,P),i.prototype.setupDropdown=function(){var s=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(L){L.className=s.className,L.colorsClassName=s.colorsClassName,s.dropdownBlock.appendChild(L.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},i.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},i.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},i.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},i.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},i.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},i}(ct),Ct=function(){function P(i,s){this.GRIP_SIZE=10,this.color=i,this.fillColor=s,this.visual=Ke.createGroup(),this.visual.appendChild(Ke.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ke.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return P.prototype.ownsTarget=function(i){return i===this.visual||i===this.visual.childNodes[0]||i===this.visual.childNodes[1]},P.prototype.setCenter=function(i,s){this.visual.childNodes.forEach(function(L){return Ke.setAttributes(L,[["cx",i.toString()],["cy",s.toString()]])})},P}(),jt=function(){function P(i,s,L,k){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=i,this.canvasHeight=s,this.margin=L,this.container=k,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(P.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(i){this._aspectRatio=i,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(i){this._isGridVisible=i,this.gridContainer&&Ke.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(i){this._zoomFactor=i,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),P.prototype.open=function(){var i=this;this.cropShadeElement=Ke.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ke.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var s=0;s<this.numberOfGridLines;s++)this.horizontalGridLines.push(Ke.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ke.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(L){return i.gridContainer.appendChild(L)}),this.verticalGridLines.forEach(function(L){return i.gridContainer.appendChild(L)}),this.cropRectElement=Ke.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Ct(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},P.prototype.setCropRectangle=function(i){this.cropRect=i;var s=Object.assign({},this.cropRect);this.zoomFactor!==1&&(s.width=this.cropRect.width*this.zoomFactor,s.height=this.cropRect.height*this.zoomFactor,s.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-s.width/2,s.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-s.height/2),Ke.setAttributes(this.cropRectElement,[["x",s.x.toString()],["y",s.y.toString()],["width",s.width.toString()],["height",s.height.toString()]]);var L=s.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(D,$){var ve=s.y+L*($+1);Ke.setAttributes(D,[["x1",""+s.x],["y1",""+ve],["x2",""+(s.x+s.width)],["y2",""+ve]])});var k=s.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(D,$){var ve=s.x+k*($+1);Ke.setAttributes(D,[["x1",""+ve],["y1",""+s.y],["x2",""+ve],["y2",""+(s.y+s.height)]])}),Ke.setAttributes(this.cropShadeElement,[["d",Ke.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,s.x,s.y,s.width,s.height)]]),this.topLeftGrip.setCenter(s.x,s.y),this.topRightGrip.setCenter(s.x+s.width,s.y),this.bottomLeftGrip.setCenter(s.x,s.y+s.height),this.bottomRightGrip.setCenter(s.x+s.width,s.y+s.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},P.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)},P.prototype.clientToLocalCoordinates=function(i,s){var L=this.container.getBoundingClientRect();return{x:i-L.left+this.margin,y:s-L.top+this.margin}},P.prototype.onPointerDown=function(i){this.container.setPointerCapture(i.pointerId),this.previousPoint=this.clientToLocalCoordinates(i.clientX,i.clientY),this.cropRectElement===i.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(i.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(i.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(i.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(i.target)&&(this.activeGrip=this.bottomRightGrip)},P.prototype.onPointerMove=function(i){if(this.isMoving)this.move(this.clientToLocalCoordinates(i.clientX,i.clientY));else if(this.activeGrip){var s=this.clientToLocalCoordinates(i.clientX,i.clientY);this.resize(s)}i.preventDefault()},P.prototype.onPointerUp=function(i){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(i.pointerId)},P.prototype.move=function(i){var s=i.x-this.previousPoint.x,L=i.y-this.previousPoint.y;this.zoomFactor!==1&&(s=-s/this.zoomFactor,L=-L/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+s),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+L),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=i},P.prototype.resize=function(i){var s=Object.assign({},this.cropRect),L=i.x-this.previousPoint.x,k=i.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:s.x+L<this.margin&&(L=this.margin-s.x),s.x+=L,s.width=this.cropRect.x+this.cropRect.width-s.x;break;case this.bottomRightGrip:case this.topRightGrip:s.width+L>this.canvasWidth*this.zoomFactor&&(L=this.canvasWidth*this.zoomFactor-s.width),s.width+=L}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(s.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(L),s.height=this.aspectRatio.getVerticalLength(s.width)):(s.y+=k,s.height=this.cropRect.y+this.cropRect.height-s.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?s.height=this.aspectRatio.getVerticalLength(s.width):s.height+=k}s.width<10&&(s.x=this.cropRect.x,s.width=10),s.height<10&&(s.y=this.cropRect.y,s.height=10),this.previousPoint=i,s.x>=this.margin&&s.y>=this.margin&&s.x-this.margin+s.width<=this.canvasWidth&&s.y-this.margin+s.height<=this.canvasHeight&&(this.cropRect=s,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},P.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var i=this.cropRect.x+this.cropRect.width/2,s=this.cropRect.y+this.cropRect.height/2,L=this.aspectRatio.getHorizontalLength(this.cropRect.height),k=this.aspectRatio.getVerticalLength(this.cropRect.width);L/this.canvasWidth<k/this.canvasHeight?this.cropRect.width=L:this.cropRect.height=k,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=i-this.cropRect.width/2,this.cropRect.y=s-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)}},P.prototype.getRescaledRect=function(i,s,L,k,D,$){var ve=L/i,Oe=k/s;return{x:(D.x-$)*ve+$,y:(D.y-$)*Oe+$,width:D.width*ve,height:D.height*Oe}},P.prototype.scaleCanvas=function(i,s){var L=this.getRescaledRect(this.canvasWidth,this.canvasHeight,i,s,this.cropRect,this.margin);this.canvasWidth=i,this.canvasHeight=s,this.onCropChange&&this.onCropChange(L),this.setCropRectangle(L)},P}(),Wt=function(){function P(i){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=i,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(P.prototype,"angle",{get:function(){return this._angle},set:function(i){this._angle=i,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),P.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},P.prototype.onPointerDown=function(i){this.controlContainer.setPointerCapture(i.pointerId),this.isDragging=!0,this.previousPoint={x:i.clientX,y:i.clientY}},P.prototype.onPointerMove=function(i){this.isDragging&&(this.onAngleChange&&this.onAngleChange((i.clientX-this.previousPoint.x)/5),this.previousPoint.x=i.clientX)},P.prototype.onPointerUp=function(i){this.isDragging&&this.onAngleChange&&this.onAngleChange((i.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(i.pointerId)},P.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var i=this.angleLabelText.getBBox();Ke.setAttributes(this.angleLabelElement,[["x",((this.width-i.width)/2).toString()],["y",(this.height/2).toString()]])}},P.prototype.positionScaleShape=function(){if(this.scaleShape){var i=this.scaleShape.transform.baseVal.getItem(0);i.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(i,0)}},P.prototype.getVisual=function(){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",this.width+"px"),i.setAttribute("height",this.height+"px"),i.setAttribute("viewBox","0 0 "+this.width+" "+this.height),i.style.flexShrink="0",document.body.appendChild(i);for(var s="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,L=1;L<=this.width/5+10;L++){var k=L%5==0?this.height/3:this.height/6;s+="h4v"+-k+"h1v"+k}s+="v1H0Z",this.scaleShape=Ke.createPath(s);var D=Ke.createTransform();this.scaleShape.transform.baseVal.appendItem(D),i.appendChild(this.scaleShape),this.angleLabelElement=Ke.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ke.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var $=Ke.createTSpan("");return $.innerHTML="°",this.angleLabelElement.appendChild($),i.appendChild(this.angleLabelElement),document.body.removeChild(i),i},P}(),Ht=function(){function P(){this.naturalSize=!1,this.imageType="image/png"}return P.prototype.rasterize=function(i,s,L,k,D,$,ve){var Oe=this;return new Promise(function(He){var Ee=document.createElement("canvas");Ee.width=i.width.baseVal.value-2*k,Ee.height=i.height.baseVal.value-2*k;var Ve=1,qe=1;Oe.naturalSize===!0?(Ve=s.naturalWidth/(i.width.baseVal.value-2*k)/$,qe=s.naturalHeight/(i.height.baseVal.value-2*k)/ve,Ee.width=s.naturalWidth/$,Ee.height=s.naturalHeight/ve):Oe.width!==void 0&&Oe.height!==void 0&&(Ve=Oe.width/L.width,qe=Oe.height/L.height,Ee.width*=Ve,Ee.height*=qe);var it=Ee.getContext("2d");it.translate(Ee.width/2,Ee.height/2),it.rotate(D*Math.PI/180),it.scale($,ve),it.translate(-Ee.width/2,-Ee.height/2),it.drawImage(s,0,0,Ee.width,Ee.height);var gt=document.createElement("canvas");gt.width=L.width*Ve,gt.height=L.height*qe,gt.getContext("2d").putImageData(it.getImageData((L.x-k)*Ve,(L.y-k)*qe,L.width*Ve,L.height*qe),0,0),He(gt.toDataURL(Oe.imageType,Oe.imageQuality))})},P}(),Gt=function(){function P(i){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=P.instanceCounter++,this.styles=new Tt(this.instanceNo),this.target=i,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(P.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(i){this._zoomToCropEnabled=i,i?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(i){this._isGridVisible=i,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"gridLines",{get:function(){return this._gridLines},set:function(i){this._gridLines=i,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(i){this._rotationAngle=i,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"aspectRatio",{get:function(){var i;return(i=this._aspectRatio)!==null&&i!==void 0?i:this.aspectRatios[0]},set:function(i){this._aspectRatio=i},enumerable:!1,configurable:!0}),P.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},P.prototype.show=function(){this.showUI(),this.open()},P.prototype.close=function(i){i===void 0&&(i=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),i||this.closeEventListeners.forEach(function(s){return s()}),this._isOpen=!1)},P.prototype.addRenderEventListener=function(i){this.renderEventListeners.push(i)},P.prototype.removeRenderEventListener=function(i){this.renderEventListeners.indexOf(i)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(i),1)},P.prototype.addCloseEventListener=function(i){this.closeEventListeners.push(i)},P.prototype.removeCloseEventListener=function(i){this.closeEventListeners.indexOf(i)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(i),1)},P.prototype.setupResizeObserver=function(){var i=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){i.resize(i.target.clientWidth,i.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},P.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var i=1*this.target.clientWidth/this.target.clientHeight,s=this.contentDiv.clientWidth/i>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*i:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,L=s+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/i;this.resize(s,L)}},P.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},P.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",Ke.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},P.prototype.resize=function(i,s){this.imageWidth=Math.round(i),this.imageHeight=Math.round(s),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},P.prototype.setEditingTarget=function(){var i=document.createElement("canvas");i.width=this.target.naturalWidth,i.height=this.target.naturalHeight,i.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var s=i.toDataURL();Ke.setAttributes(this.editingTarget,[["href",s]]),this.setEditingTargetSize()},P.prototype.setTopLeft=function(){var i=this.target.getBoundingClientRect(),s=this.editorCanvas.getBoundingClientRect();this.left=i.left-s.left-this.CANVAS_MARGIN,this.top=i.top-s.top-this.CANVAS_MARGIN},P.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=Ke.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ke.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ke.createGroup(),this.editingTargetRotationScaleContainer=Ke.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var i=Ke.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(i);var s=Ke.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(s),this.editingTargetContainer=Ke.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)},P.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},P.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Ke.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new jt(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()},P.prototype.zoomToCrop=function(){if(this.cropRect){var i=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,s=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=i+"px "+s+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-i+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-s+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},P.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)},P.prototype.cropRectChanged=function(i){this.cropRect=i,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},P.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},P.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"},P.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},P.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var i=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,s=this.target.offsetTop>i+this.CANVAS_MARGIN?this.target.offsetTop-(i+this.CANVAS_MARGIN):0;this.coverDiv.style.top=s+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},P.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},P.prototype.addTopToolbar=function(){var i=this;this.topToolbar=new Pt,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 s=new St;s.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(s);var L=[];this.aspectRatios.forEach(function(qe){var it=new ct(Lt.getIcon(qe.horizontal,qe.vertical),qe.horizontal===0&&qe.vertical===0?"FREE":qe.horizontal+":"+qe.vertical);it.onClick=function(){return i.ratioButtonClicked(qe)},L.push(it)}),this.aspectRatioButton=new Ft(Lt.getIcon(0,0),"Aspect ratio",L),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,s.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var k=new ct('<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");k.isActive=this.isGridVisible,k.onClick=function(){i.isGridVisible=!i.isGridVisible,k.isActive=i.isGridVisible},s.addButton(k);var D=new ct('<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(D.isActive=this.zoomToCropEnabled,D.onClick=function(){i.zoomToCropEnabled=!i.zoomToCropEnabled,D.isActive=i.zoomToCropEnabled},s.addButton(D),!xt.isLicensed){var $=new It;this.topToolbar.addElementBlock($);var ve=document.createElement("div");ve.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Oe=document.createElement("a");Oe.style.color="currentColor",Oe.href="https://markerjs.com/products/cropro",Oe.target="_blank",Oe.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>',ve.appendChild(Oe),$.addElement(ve)}var He=new St;He.minWidth=3*this.toolbarHeight+"px",He.contentAlign="end",this.topToolbar.addButtonBlock(He);var Ee=new ct('<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");Ee.onClick=this.startRenderAndClose,He.addButton(Ee),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ee.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Ve=new ct('<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");Ve.onClick=this.close,He.addButton(Ve),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Ve.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},P.prototype.addBottomToolbar=function(){var i=this;this.bottomToolbar=new Pt,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 s=new St;s.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(s);var L=new ct('<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");L.onClick=this.rotateLeftButtonClicked,s.addButton(L);var k=new ct('<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");k.onClick=this.rotateRightButtonClicked,s.addButton(k);var D=new It;D.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(D),this.straightener=new Wt("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(He){i.rotateBy(He),i.straightener.angle=i.rotationAngle},D.addElement(this.straightener.getUI());var $=new St;$.minWidth=2*this.toolbarHeight+"px",$.contentAlign="end",this.bottomToolbar.addButtonBlock($);var ve=new ct('<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");ve.onClick=this.flipHorizontallyButtonClicked,$.addButton(ve);var Oe=new ct('<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");Oe.onClick=this.flipVerticallyButtonClicked,$.addButton(Oe)},P.prototype.ratioButtonClicked=function(i){this.aspectRatio=i,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},P.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Lt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},P.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Mt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},P.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},P.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},P.prototype.restoreState=function(i){if(i){var s=this.cropLayer.getRescaledRect(i.width,i.height,this.imageWidth,this.imageHeight,i.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(s),this.cropRectChanged(s),this.flippedHorizontally=i.flippedHorizontally,this.flippedVertically=i.flippedVertically,this.applyFlip(),this.rotationAngle=i.rotationAngle,this.applyRotation()}},P.prototype.clientToLocalCoordinates=function(i,s){var L=this.cropImage.getBoundingClientRect();return{x:i-L.left,y:s-L.top}},P.prototype.onWindowResize=function(){this.positionUI()},P.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var i=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=i+"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()},P.prototype.rotateLeftButtonClicked=function(){var i=this.rotationAngle-90;this.rotationAngle%90!=0&&(i+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(i)},P.prototype.rotateRightButtonClicked=function(){var i=this.rotationAngle+90;this.rotationAngle%90!=0&&(i-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(i)},P.prototype.rotateTo=function(i){i=(i=i>180?i-360:i)<=-180?i+360:i,this.rotationAngle=i,this.applyRotation()},P.prototype.rotateBy=function(i){this.rotateTo((this.rotationAngle+i)%360)},P.prototype.applyRotation=function(){var i=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var s=this.editingTargetRotationContainer.transform.baseVal.getItem(0);s.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(s,0);var L=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/L.width,this.imageHeight/L.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=i},P.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},P.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},P.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},P.prototype.startRenderAndClose=function(){return Qe(this,void 0,void 0,function(){var i,s;return pt(this,function(L){switch(L.label){case 0:return[4,this.render()];case 1:return i=L.sent(),s=this.getState(),this.renderEventListeners.forEach(function(k){return k(i,s)}),this.close(!0),[2]}})})},P.prototype.render=function(){return Qe(this,void 0,void 0,function(){var i;return pt(this,function(s){switch(s.label){case 0:return(i=new Ht).naturalSize=this.renderAtNaturalSize,i.imageType=this.renderImageType,i.imageQuality=this.renderImageQuality,i.width=this.renderWidth,i.height=this.renderHeight,this.unzoomFromCrop(),Ke.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,i.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 s.sent(),[4,i.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,s.sent()]}})})},P.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new ut("toolbar",`
|
|
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
height: `+this.toolbarHeight+`px;
|
|
box-sizing: content-box;
|
|
overflow: hidden;
|
|
line-height: 0px;
|
|
`)),this.toolbarStyleColorsClass=this.styles.addClass(new ut("toolbar_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarBlockStyleClass=this.styles.addClass(new ut("toolbar-block",`
|
|
display: flex;
|
|
align-items: center;
|
|
box-sizing: content-box;
|
|
`));var i=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ut("toolbar_button",`
|
|
display: inline-block;
|
|
width: `+(this.toolbarHeight-2*i)+`px;
|
|
height: `+(this.toolbarHeight-2*i)+`px;
|
|
padding: `+i+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new ut("toolbar_button_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new ut("toolbar_active_button",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
|
|
`)),this.styles.addRule(new mt("."+this.toolbarButtonStyleClass.name+" svg",`
|
|
height: `+this.toolbarHeight/2+`px;
|
|
`)),this.styles.addRule(new mt("."+this.toolbarButtonStyleColorsClass.name+":hover",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
|
|
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new ut("toolbar_dropdown",`
|
|
position: absolute;
|
|
max-width: `+4*this.toolbarHeight+`px;
|
|
z-index: 20;
|
|
white-space: normal;
|
|
box-sizing: content-box;
|
|
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
|
|
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
|
|
line-height: 0px;
|
|
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new ut("toolbar_dropdown_colors",`
|
|
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
|
|
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new ut("toolbar_straightener_block",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
|
|
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new ut("toolbar_straightener",`
|
|
display: flex;
|
|
overflow: hidden;
|
|
justify-content: center;
|
|
height: `+(this.toolbarHeight-2*i)+`px;
|
|
padding: `+i+`px;
|
|
cursor: default;
|
|
user-select: none;
|
|
box-sizing: content-box;
|
|
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new ut("toolbar_straightener_colors",`
|
|
color: `+this.styles.settings.toolbarColor+`;
|
|
fill: currentColor;
|
|
`))},P.instanceCounter=0,P}(),Kt=ee("8hTe"),kt=ee.n(Kt),zt=/<pre[^>]*>/g;function Vt(P){var i=document.createElement("div");return i.innerHTML=P,i.childNodes.length===0?"":i.childNodes[0].nodeValue}var rr=Xe.a=function(P){var i=P.value,s=i===void 0?"":i,L=P.edit,k=L===void 0?!1:L,D=P.className,$=P.showTextOnly,ve=P.showLines,Oe=P.replaces,He=P.zoomImg,Ee=P.hasMask,Ve=P.style,qe=Ve===void 0?{}:Ve,it=P.stylesPrev,gt=it===void 0?{}:it,vt=String(s),ft=Object(w.useRef)(),yt=Object(w.useRef)(),Xt=Object(w.useState)(""),Nt=Object(N.a)(Xt,2),wt=Nt[0],Et=Nt[1],Yt=Object(w.useState)("office"),Bt=Object(N.a)(Yt,2),$t=Bt[0],At=Bt[1],Jt=function(){var et=new Gt(yt.current);et.displayMode="popup",et.addRenderEventListener(function(){var dt=Object(R.a)(O.a.mark(function Ze(ht){var nt;return O.a.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:return ft.current.style.display="none",lt.next=3,Object(be.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:ht}});case 3:nt=lt.sent,nt!=null&&nt.id&&Oe(yt.current.getAttribute("src").replace(Q.a.API_SERVER,""),"/api/attachments/".concat(nt==null?void 0:nt.id,"?type=").concat(nt.content_type));case 5:case"end":return lt.stop()}},Ze)}));return function(Ze){return dt.apply(this,arguments)}}()),et.show()},Qt=function(){var et=new rt(yt.current);et.settings.displayMode="popup",et.addEventListener("render",function(){var dt=Object(R.a)(O.a.mark(function Ze(ht){var nt;return O.a.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:if(ft.current.style.display="none",!yt.current){lt.next=6;break}return lt.next=4,Object(be.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:ht.dataUrl}});case 4:nt=lt.sent,nt!=null&&nt.id&&Oe(yt.current.getAttribute("src").replace(Q.a.API_SERVER,""),"/api/attachments/".concat(nt==null?void 0:nt.id,"?type=").concat(nt.content_type));case 6:case"end":return lt.stop()}},Ze)}));return function(Ze){return dt.apply(this,arguments)}}()),et.show(),window.markerArea=et},Rt=Object(w.useMemo)(function(){try{var ot=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,et=/\"\/api\/attachments\/|\"\/attachments\/download\//g,dt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;vt=vt.replace(ot,"("+Q.a.API_SERVER+"/api/attachments/").replace(et,'"'+Q.a.API_SERVER+"/api/attachments/").replace(dt,'"'+Q.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
|
|
`),vt=vt.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
|
|
`)}catch(Dt){}var Ze=j(vt),ht=f();if(vt.match(/\[TOC\]/)&&(Ze=Ze.replace("<p>[TOC]</p>",v()),g()),Ze=Ze.replace(/(__special_katext_id_\d+__)/g,function(Dt,lt){var Ut=ht[lt],er=Ut.type,tr=Ut.expression;return Object(ne.renderToString)(Vt(tr)||"",{displayMode:er==="block",throwOnError:!1,output:"html"})}),Ze=Ze.replace(/▁/g,"\u2581\u2581\u2581"),p(),$){var nt=document.createElement("div");return nt.innerHTML=Ze,nt.innerText}return setTimeout(function(){return Zt()},500),Ze},[vt]),bt=Object(w.useRef)();l.WebkitLineClamp=ve,ve&&(qe=Object(_.a)(Object(_.a)({},qe),l));function _t(ot){var et=ot.target;if(et.tagName.toUpperCase()==="IMG"){if(He){var dt=et.getAttribute("src");Et(dt),At("image")}}else if(et.tagName.toUpperCase()==="A"){var Ze=et.getAttribute("href");if(Ze.indexOf("office")>-1)ot.preventDefault(),Et(Ze),At("office");else if(Ze.indexOf("application/pdf")>-1)ot.preventDefault(),Et(Ze),At("pdf");else if(Ze.indexOf("type=text")>-1)ot.preventDefault(),Et(Ze),At("html");else if(Ze.startsWith("#")){ot.preventDefault();var ht=document.getElementById(Ze.replace("#",""));ht&&ht.scrollIntoView(!0)}}}var Zt=function(){var et,dt=(et=bt.current)===null||et===void 0?void 0:et.querySelectorAll("video");dt==null||dt.forEach(function(Ze){if(Ze.oncontextmenu=function(){return!1},Ze.src.indexOf(".m3u8")>-1&&!Ze.canPlayType("application/vnd.apple.mpegurl")){if(G.a.isSupported()){var ht=new G.a;ht.loadSource(Ze.src),ht.attachMedia(Ze)}}})};Object(w.useEffect)(function(){if(bt.current&&Rt&&(Rt.match(zt)&&window.PR.prettyPrint()),bt.current)return bt.current.addEventListener("click",_t),function(){bt.current.removeEventListener("click",_t),p(),g()}},[Rt,bt.current,_t]);var qt=function(et){if(!k)return;et.target.nodeName==="IMG"?(ft.current.style.display="flex",ft.current.style.width=et.target.clientWidth+"px",ft.current.style.height=et.target.clientHeight+"px",ft.current.style.top=et.target.offsetTop+"px",ft.current.style.left=et.target.offsetLeft+"px",yt.current.src=et.target.getAttribute("src")):ft.current.style.display="none"};return m.a.createElement("div",{style:{position:"relative"}},m.a.createElement("div",{ref:bt,style:Object(_.a)({},qe),className:"".concat(D||""," markdown-body ").concat(kt.a.mdBody),onMouseOver:qt,dangerouslySetInnerHTML:{__html:Rt}}),m.a.createElement("div",{ref:ft,className:kt.a.button},m.a.createElement(F.a,null,m.a.createElement(B.a,{onClick:function(){return Jt()}},"\u88C1\u526A"),m.a.createElement(B.a,{onClick:function(){return Qt()}},"\u7F16\u8F91"))),m.a.createElement("img",{ref:yt,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),m.a.createElement(re.a,{close:!0,data:wt,hasMask:Ee,type:wt!=null&&wt.length?$t:"",style:Object(_.a)({},gt),onClose:function(){return Et("")}}))}},BU3w:function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return R});var de=ee("MNnm"),F="rc-util-key";function S(N){if(N.attachTo)return N.attachTo;var M=document.querySelector("head");return M||document.body}function B(N){var M,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(de.a)())return null;var w=document.createElement("style");if((M=O.csp)===null||M===void 0?void 0:M.nonce){var m;w.nonce=(m=O.csp)===null||m===void 0?void 0:m.nonce}w.innerHTML=N;var T=S(O),C=T.firstChild;return O.prepend&&T.prepend?T.prepend(w):O.prepend&&C?T.insertBefore(w,C):T.appendChild(w),w}var _=new Map;function R(N,M){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=S(O);if(!_.has(w)){var m=B("",O),T=m.parentNode;_.set(w,T),T.removeChild(m)}var C=Array.from(_.get(w).children).find(function(r){return r.tagName==="STYLE"&&r[F]===M});if(C){var b,E;if(((b=O.csp)===null||b===void 0?void 0:b.nonce)&&C.nonce!==((E=O.csp)===null||E===void 0?void 0:E.nonce)){var y;C.nonce=(y=O.csp)===null||y===void 0?void 0:y.nonce}return C.innerHTML!==N&&(C.innerHTML=N),C}var c=B(N,O);return c[F]=M,c}},BdwD:function(Je,Xe,ee){"use strict";var de=ee("+L6B"),F=ee("2/Rp"),S=ee("0Owb"),B=ee("k1fw"),_=ee("q1tI"),R=ee.n(_),N=ee("FOrL"),M=ee.n(N),O=function(m){var T=m.buttonProps,C=T===void 0?{}:T,b=m.styles,E=b===void 0?{}:b,y=m.customText,c=m.ButtonText,r=m.ButtonClick,a=m.Buttonclass,o=m.ButtonTwo;return R.a.createElement("section",{className:"tc animated fadeIn",style:Object(B.a)(Object(B.a)({},{color:"#999",margin:"200px auto"}),E)},R.a.createElement("img",{src:M.a}),R.a.createElement("p",{className:"mt20 font14"},y||"\u6682\u65F6\u8FD8\u6CA1\u6709\u76F8\u5173\u6570\u636E\u54E6!"),c&&R.a.createElement(F.a,Object(S.a)({className:a,onClick:r},C),c),o&&o)};Xe.a=O},DlQD:function(Je,Xe,ee){(function(de,F){Je.exports=F()})(this,function(){"use strict";function de(q,J){for(var Z=0;Z<J.length;Z++){var W=J[Z];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(q,W.key,W)}}function F(q,J,Z){return J&&de(q.prototype,J),Z&&de(q,Z),q}function S(q,J){if(!q)return;if(typeof q=="string")return B(q,J);var Z=Object.prototype.toString.call(q).slice(8,-1);if(Z==="Object"&&q.constructor&&(Z=q.constructor.name),Z==="Map"||Z==="Set")return Array.from(q);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return B(q,J)}function B(q,J){(J==null||J>q.length)&&(J=q.length);for(var Z=0,W=new Array(J);Z<J;Z++)W[Z]=q[Z];return W}function _(q,J){var Z;if(typeof Symbol=="undefined"||q[Symbol.iterator]==null){if(Array.isArray(q)||(Z=S(q))||J&&q&&typeof q.length=="number"){Z&&(q=Z);var W=0;return function(){return W>=q.length?{done:!0}:{done:!1,value:q[W++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return Z=q[Symbol.iterator](),Z.next.bind(Z)}function R(q,J){return J={exports:{}},q(J,J.exports),J.exports}var N=R(function(q){function J(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function Z(W){q.exports.defaults=W}q.exports={defaults:J(),getDefaults:J,changeDefaults:Z}}),M=N.defaults,O=N.getDefaults,w=N.changeDefaults,m=/[&<>"']/,T=/[&<>"']/g,C=/[<>"']|&(?!#?\w+;)/,b=/[<>"']|&(?!#?\w+;)/g,E={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(J){return E[J]};function c(q,J){if(J){if(m.test(q))return q.replace(T,y)}else if(C.test(q))return q.replace(b,y);return q}var r=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function a(q){return q.replace(r,function(J,Z){return Z=Z.toLowerCase(),Z==="colon"?":":Z.charAt(0)==="#"?Z.charAt(1)==="x"?String.fromCharCode(parseInt(Z.substring(2),16)):String.fromCharCode(+Z.substring(1)):""})}var o=/(^|[^\[])\^/g;function g(q,J){q=q.source||q,J=J||"";var Z={replace:function(H,K){return K=K.source||K,K=K.replace(o,"$1"),q=q.replace(H,K),Z},getRegex:function(){return new RegExp(q,J)}};return Z}var l=/[^\w:]/g,d=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function v(q,J,Z){if(q){var W;try{W=decodeURIComponent(a(Z)).replace(l,"").toLowerCase()}catch(H){return null}if(W.indexOf("javascript:")===0||W.indexOf("vbscript:")===0||W.indexOf("data:")===0)return null}J&&!d.test(Z)&&(Z=t(J,Z));try{Z=encodeURI(Z).replace(/%25/g,"%")}catch(H){return null}return Z}var h={},u=/^[^:]+:\/*[^/]*$/,n=/^([^:]+:)[\s\S]*$/,e=/^([^:]+:\/*[^/]*)[\s\S]*$/;function t(q,J){h[" "+q]||(u.test(q)?h[" "+q]=q+"/":h[" "+q]=A(q,"/",!0)),q=h[" "+q];var Z=q.indexOf(":")===-1;return J.substring(0,2)==="//"?Z?J:q.replace(n,"$1")+J:J.charAt(0)==="/"?Z?J:q.replace(e,"$1")+J:q+J}var f={exec:function(){}};function p(q){for(var J=1,Z,W;J<arguments.length;J++){Z=arguments[J];for(W in Z)Object.prototype.hasOwnProperty.call(Z,W)&&(q[W]=Z[W])}return q}function x(q,J){var Z=q.replace(/\|/g,function(K,X,ie){for(var ae=!1,ge=X;--ge>=0&&ie[ge]==="\\";)ae=!ae;return ae?"|":" |"}),W=Z.split(/ \|/),H=0;if(W.length>J)W.splice(J);else for(;W.length<J;)W.push("");for(;H<W.length;H++)W[H]=W[H].trim().replace(/\\\|/g,"|");return W}function A(q,J,Z){var W=q.length;if(W===0)return"";for(var H=0;H<W;){var K=q.charAt(W-H-1);if(K===J&&!Z)H++;else if(K!==J&&Z)H++;else break}return q.substr(0,W-H)}function I(q,J){if(q.indexOf(J[1])===-1)return-1;for(var Z=q.length,W=0,H=0;H<Z;H++)if(q[H]==="\\")H++;else if(q[H]===J[0])W++;else if(q[H]===J[1]&&(W--,W<0))return H;return-1}function U(q){q&&q.sanitize&&!q.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var j={escape:c,unescape:a,edit:g,cleanUrl:v,resolveUrl:t,noopTest:f,merge:p,splitCells:x,rtrim:A,findClosingBracket:I,checkSanitizeDeprecation:U},z=N.defaults,V=j.rtrim,G=j.splitCells,Q=j.escape,ne=j.findClosingBracket;function re(q,J,Z){var W=J.href,H=J.title?Q(J.title):null,K=q[1].replace(/\\([\[\]])/g,"$1");return q[0].charAt(0)!=="!"?{type:"link",raw:Z,href:W,title:H,text:K}:{type:"image",raw:Z,href:W,title:H,text:Q(K)}}function be(q,J){var Z=q.match(/^(\s+)(?:```)/);if(Z===null)return J;var W=Z[1];return J.split(`
|
|
`).map(function(H){var K=H.match(/^\s+/);if(K===null)return H;var X=K[0];return X.length>=W.length?H.slice(W.length):H}).join(`
|
|
`)}var se=function(){function q(Z){this.options=Z||z}var J=q.prototype;return J.space=function(W){var H=this.rules.block.newline.exec(W);if(H)return H[0].length>1?{type:"space",raw:H[0]}:{raw:`
|
|
`}},J.code=function(W,H){var K=this.rules.block.code.exec(W);if(K){var X=H[H.length-1];if(X&&X.type==="paragraph")return{raw:K[0],text:K[0].trimRight()};var ie=K[0].replace(/^ {4}/gm,"");return{type:"code",raw:K[0],codeBlockStyle:"indented",text:this.options.pedantic?ie:V(ie,`
|
|
`)}}},J.fences=function(W){var H=this.rules.block.fences.exec(W);if(H){var K=H[0],X=be(K,H[3]||"");return{type:"code",raw:K,lang:H[2]?H[2].trim():H[2],text:X}}},J.heading=function(W){var H=this.rules.block.heading.exec(W);if(H)return{type:"heading",raw:H[0],depth:H[1].length,text:H[2]}},J.nptable=function(W){var H=this.rules.block.nptable.exec(W);if(H){var K={type:"table",header:G(H[1].replace(/^ *| *\| *$/g,"")),align:H[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:H[3]?H[3].replace(/\n$/,"").split(`
|
|
`):[],raw:H[0]};if(K.header.length===K.align.length){var X=K.align.length,ie;for(ie=0;ie<X;ie++)/^ *-+: *$/.test(K.align[ie])?K.align[ie]="right":/^ *:-+: *$/.test(K.align[ie])?K.align[ie]="center":/^ *:-+ *$/.test(K.align[ie])?K.align[ie]="left":K.align[ie]=null;for(X=K.cells.length,ie=0;ie<X;ie++)K.cells[ie]=G(K.cells[ie],K.header.length);return K}}},J.hr=function(W){var H=this.rules.block.hr.exec(W);if(H)return{type:"hr",raw:H[0]}},J.blockquote=function(W){var H=this.rules.block.blockquote.exec(W);if(H){var K=H[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:H[0],text:K}}},J.list=function(W){var H=this.rules.block.list.exec(W);if(H){for(var K=H[0],X=H[2],ie=X.length>1,ae=X[X.length-1]===")",ge={type:"list",raw:K,ordered:ie,start:ie?+X.slice(0,-1):"",loose:!1,items:[]},je=H[0].match(this.rules.block.item),ze=!1,We,Ye,$e,Ge,tt,rt,st,at=je.length,Qe=0;Qe<at;Qe++)We=je[Qe],K=We,Ye=We.length,We=We.replace(/^ *([*+-]|\d+[.)]) */,""),~We.indexOf(`
|
|
`)&&(Ye-=We.length,We=this.options.pedantic?We.replace(/^ {1,4}/gm,""):We.replace(new RegExp("^ {1,"+Ye+"}","gm"),"")),Qe!==at-1&&($e=this.rules.block.bullet.exec(je[Qe+1])[0],(ie?$e.length===1||!ae&&$e[$e.length-1]===")":$e.length>1||this.options.smartLists&&$e!==X)&&(Ge=je.slice(Qe+1).join(`
|
|
`),ge.raw=ge.raw.substring(0,ge.raw.length-Ge.length),Qe=at-1)),tt=ze||/\n\n(?!\s*$)/.test(We),Qe!==at-1&&(ze=We.charAt(We.length-1)===`
|
|
`,tt||(tt=ze)),tt&&(ge.loose=!0),rt=/^\[[ xX]\] /.test(We),st=void 0,rt&&(st=We[1]!==" ",We=We.replace(/^\[[ xX]\] +/,"")),ge.items.push({type:"list_item",raw:K,task:rt,checked:st,loose:tt,text:We});return ge}},J.html=function(W){var H=this.rules.block.html.exec(W);if(H)return{type:this.options.sanitize?"paragraph":"html",raw:H[0],pre:!this.options.sanitizer&&(H[1]==="pre"||H[1]==="script"||H[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(H[0]):Q(H[0]):H[0]}},J.def=function(W){var H=this.rules.block.def.exec(W);if(H){H[3]&&(H[3]=H[3].substring(1,H[3].length-1));var K=H[1].toLowerCase().replace(/\s+/g," ");return{tag:K,raw:H[0],href:H[2],title:H[3]}}},J.table=function(W){var H=this.rules.block.table.exec(W);if(H){var K={type:"table",header:G(H[1].replace(/^ *| *\| *$/g,"")),align:H[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:H[3]?H[3].replace(/\n$/,"").split(`
|
|
`):[]};if(K.header.length===K.align.length){K.raw=H[0];var X=K.align.length,ie;for(ie=0;ie<X;ie++)/^ *-+: *$/.test(K.align[ie])?K.align[ie]="right":/^ *:-+: *$/.test(K.align[ie])?K.align[ie]="center":/^ *:-+ *$/.test(K.align[ie])?K.align[ie]="left":K.align[ie]=null;for(X=K.cells.length,ie=0;ie<X;ie++)K.cells[ie]=G(K.cells[ie].replace(/^ *\| *| *\| *$/g,""),K.header.length);return K}}},J.lheading=function(W){var H=this.rules.block.lheading.exec(W);if(H)return{type:"heading",raw:H[0],depth:H[2].charAt(0)==="="?1:2,text:H[1]}},J.paragraph=function(W){var H=this.rules.block.paragraph.exec(W);if(H)return{type:"paragraph",raw:H[0],text:H[1].charAt(H[1].length-1)===`
|
|
`?H[1].slice(0,-1):H[1]}},J.text=function(W,H){var K=this.rules.block.text.exec(W);if(K){var X=H[H.length-1];return X&&X.type==="text"?{raw:K[0],text:K[0]}:{type:"text",raw:K[0],text:K[0]}}},J.escape=function(W){var H=this.rules.inline.escape.exec(W);if(H)return{type:"escape",raw:H[0],text:Q(H[1])}},J.tag=function(W,H,K){var X=this.rules.inline.tag.exec(W);if(X)return!H&&/^<a /i.test(X[0])?H=!0:H&&/^<\/a>/i.test(X[0])&&(H=!1),!K&&/^<(pre|code|kbd|script)(\s|>)/i.test(X[0])?K=!0:K&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(X[0])&&(K=!1),{type:this.options.sanitize?"text":"html",raw:X[0],inLink:H,inRawBlock:K,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):Q(X[0]):X[0]}},J.link=function(W){var H=this.rules.inline.link.exec(W);if(H){var K=ne(H[2],"()");if(K>-1){var X=H[0].indexOf("!")===0?5:4,ie=X+H[1].length+K;H[2]=H[2].substring(0,K),H[0]=H[0].substring(0,ie).trim(),H[3]=""}var ae=H[2],ge="";if(this.options.pedantic){var je=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ae);je?(ae=je[1],ge=je[3]):ge=""}else ge=H[3]?H[3].slice(1,-1):"";ae=ae.trim().replace(/^<([\s\S]*)>$/,"$1");var ze=re(H,{href:ae&&ae.replace(this.rules.inline._escapes,"$1"),title:ge&&ge.replace(this.rules.inline._escapes,"$1")},H[0]);return ze}},J.reflink=function(W,H){var K;if((K=this.rules.inline.reflink.exec(W))||(K=this.rules.inline.nolink.exec(W))){var X=(K[2]||K[1]).replace(/\s+/g," ");if(X=H[X.toLowerCase()],!X||!X.href){var ie=K[0].charAt(0);return{type:"text",raw:ie,text:ie}}var ae=re(K,X,K[0]);return ae}},J.strong=function(W,H,K){K===void 0&&(K="");var X=this.rules.inline.strong.start.exec(W);if(X&&(!X[1]||X[1]&&(K===""||this.rules.inline.punctuation.exec(K)))){H=H.slice(-1*W.length);var ie=X[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ie.lastIndex=0;for(var ae;(X=ie.exec(H))!=null;)if(ae=this.rules.inline.strong.middle.exec(H.slice(0,X.index+3)),ae)return{type:"strong",raw:W.slice(0,ae[0].length),text:W.slice(2,ae[0].length-2)}}},J.em=function(W,H,K){K===void 0&&(K="");var X=this.rules.inline.em.start.exec(W);if(X&&(!X[1]||X[1]&&(K===""||this.rules.inline.punctuation.exec(K)))){H=H.slice(-1*W.length);var ie=X[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ie.lastIndex=0;for(var ae;(X=ie.exec(H))!=null;)if(ae=this.rules.inline.em.middle.exec(H.slice(0,X.index+2)),ae)return{type:"em",raw:W.slice(0,ae[0].length),text:W.slice(1,ae[0].length-1)}}},J.codespan=function(W){var H=this.rules.inline.code.exec(W);if(H){var K=H[2].replace(/\n/g," "),X=/[^ ]/.test(K),ie=K.startsWith(" ")&&K.endsWith(" ");return X&&ie&&(K=K.substring(1,K.length-1)),K=Q(K,!0),{type:"codespan",raw:H[0],text:K}}},J.br=function(W){var H=this.rules.inline.br.exec(W);if(H)return{type:"br",raw:H[0]}},J.del=function(W){var H=this.rules.inline.del.exec(W);if(H)return{type:"del",raw:H[0],text:H[1]}},J.autolink=function(W,H){var K=this.rules.inline.autolink.exec(W);if(K){var X,ie;return K[2]==="@"?(X=Q(this.options.mangle?H(K[1]):K[1]),ie="mailto:"+X):(X=Q(K[1]),ie=X),{type:"link",raw:K[0],text:X,href:ie,tokens:[{type:"text",raw:X,text:X}]}}},J.url=function(W,H){var K;if(K=this.rules.inline.url.exec(W)){var X,ie;if(K[2]==="@")X=Q(this.options.mangle?H(K[0]):K[0]),ie="mailto:"+X;else{var ae;do ae=K[0],K[0]=this.rules.inline._backpedal.exec(K[0])[0];while(ae!==K[0]);X=Q(K[0]),K[1]==="www."?ie="http://"+X:ie=X}return{type:"link",raw:K[0],text:X,href:ie,tokens:[{type:"text",raw:X,text:X}]}}},J.inlineText=function(W,H,K){var X=this.rules.inline.text.exec(W);if(X){var ie;return H?ie=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):Q(X[0]):X[0]:ie=Q(this.options.smartypants?K(X[0]):X[0]),{type:"text",raw:X[0],text:ie}}},q}(),oe=j.noopTest,ue=j.edit,he=j.merge,te={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:oe,table:oe,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};te._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,te._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,te.def=ue(te.def).replace("label",te._label).replace("title",te._title).getRegex(),te.bullet=/(?:[*+-]|\d{1,9}[.)])/,te.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,te.item=ue(te.item,"gm").replace(/bull/g,te.bullet).getRegex(),te.list=ue(te.list).replace(/bull/g,te.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+te.def.source+")").getRegex(),te._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",te._comment=/<!--(?!-?>)[\s\S]*?-->/,te.html=ue(te.html,"i").replace("comment",te._comment).replace("tag",te._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),te.paragraph=ue(te._paragraph).replace("hr",te.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",te._tag).getRegex(),te.blockquote=ue(te.blockquote).replace("paragraph",te.paragraph).getRegex(),te.normal=he({},te),te.gfm=he({},te.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*|$)"}),te.gfm.nptable=ue(te.gfm.nptable).replace("hr",te.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",te._tag).getRegex(),te.gfm.table=ue(te.gfm.table).replace("hr",te.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",te._tag).getRegex(),te.pedantic=he({},te.normal,{html:ue(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",te._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:oe,paragraph:ue(te.normal._paragraph).replace("hr",te.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",te.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var Y={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:oe,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:oe,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};Y._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",Y.punctuation=ue(Y.punctuation).replace(/punctuation/g,Y._punctuation).getRegex(),Y._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",Y._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",Y.em.start=ue(Y.em.start).replace(/punctuation/g,Y._punctuation).getRegex(),Y.em.middle=ue(Y.em.middle).replace(/punctuation/g,Y._punctuation).replace(/overlapSkip/g,Y._overlapSkip).getRegex(),Y.em.endAst=ue(Y.em.endAst,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.em.endUnd=ue(Y.em.endUnd,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.start=ue(Y.strong.start).replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.middle=ue(Y.strong.middle).replace(/punctuation/g,Y._punctuation).replace(/blockSkip/g,Y._blockSkip).getRegex(),Y.strong.endAst=ue(Y.strong.endAst,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.strong.endUnd=ue(Y.strong.endUnd,"g").replace(/punctuation/g,Y._punctuation).getRegex(),Y.blockSkip=ue(Y._blockSkip,"g").getRegex(),Y.overlapSkip=ue(Y._overlapSkip,"g").getRegex(),Y._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,Y._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,Y._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])?)+(?![-_])/,Y.autolink=ue(Y.autolink).replace("scheme",Y._scheme).replace("email",Y._email).getRegex(),Y._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,Y.tag=ue(Y.tag).replace("comment",te._comment).replace("attribute",Y._attribute).getRegex(),Y._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Y._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,Y._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,Y.link=ue(Y.link).replace("label",Y._label).replace("href",Y._href).replace("title",Y._title).getRegex(),Y.reflink=ue(Y.reflink).replace("label",Y._label).getRegex(),Y.reflinkSearch=ue(Y.reflinkSearch,"g").replace("reflink",Y.reflink).replace("nolink",Y.nolink).getRegex(),Y.normal=he({},Y),Y.pedantic=he({},Y.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:ue(/^!?\[(label)\]\((.*?)\)/).replace("label",Y._label).getRegex(),reflink:ue(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Y._label).getRegex()}),Y.gfm=he({},Y.normal,{escape:ue(Y.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),Y.gfm.url=ue(Y.gfm.url,"i").replace("email",Y.gfm._extended_email).getRegex(),Y.breaks=he({},Y.gfm,{br:ue(Y.br).replace("{2,}","*").getRegex(),text:ue(Y.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var fe={block:te,inline:Y},Re=N.defaults,Le=fe.block,xe=fe.inline;function Te(q){return q.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function le(q){var J="",Z,W,H=q.length;for(Z=0;Z<H;Z++)W=q.charCodeAt(Z),Math.random()>.5&&(W="x"+W.toString(16)),J+="&#"+W+";";return J}var ye=function(){function q(Z){this.tokens=[],this.tokens.links=Object.create(null),this.options=Z||Re,this.options.tokenizer=this.options.tokenizer||new se,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var W={block:Le.normal,inline:xe.normal};this.options.pedantic?(W.block=Le.pedantic,W.inline=xe.pedantic):this.options.gfm&&(W.block=Le.gfm,this.options.breaks?W.inline=xe.breaks:W.inline=xe.gfm),this.tokenizer.rules=W}q.lex=function(W,H){var K=new q(H);return K.lex(W)};var J=q.prototype;return J.lex=function(W){return W=W.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(W,this.tokens,!0),this.inline(this.tokens),this.tokens},J.blockTokens=function(W,H,K){H===void 0&&(H=[]),K===void 0&&(K=!0),W=W.replace(/^ +$/gm,"");for(var X,ie,ae,ge;W;){if(X=this.tokenizer.space(W)){W=W.substring(X.raw.length),X.type&&H.push(X);continue}if(X=this.tokenizer.code(W,H)){W=W.substring(X.raw.length),X.type?H.push(X):(ge=H[H.length-1],ge.raw+=`
|
|
`+X.raw,ge.text+=`
|
|
`+X.text);continue}if(X=this.tokenizer.fences(W)){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.heading(W)){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.nptable(W)){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.hr(W)){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.blockquote(W)){W=W.substring(X.raw.length),X.tokens=this.blockTokens(X.text,[],K),H.push(X);continue}if(X=this.tokenizer.list(W)){for(W=W.substring(X.raw.length),ae=X.items.length,ie=0;ie<ae;ie++)X.items[ie].tokens=this.blockTokens(X.items[ie].text,[],!1);H.push(X);continue}if(X=this.tokenizer.html(W)){W=W.substring(X.raw.length),H.push(X);continue}if(K&&(X=this.tokenizer.def(W))){W=W.substring(X.raw.length),this.tokens.links[X.tag]||(this.tokens.links[X.tag]={href:X.href,title:X.title});continue}if(X=this.tokenizer.table(W)){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.lheading(W)){W=W.substring(X.raw.length),H.push(X);continue}if(K&&(X=this.tokenizer.paragraph(W))){W=W.substring(X.raw.length),H.push(X);continue}if(X=this.tokenizer.text(W,H)){W=W.substring(X.raw.length),X.type?H.push(X):(ge=H[H.length-1],ge.raw+=`
|
|
`+X.raw,ge.text+=`
|
|
`+X.text);continue}if(W){var je="Infinite loop on byte: "+W.charCodeAt(0);if(this.options.silent){console.error(je);break}else throw new Error(je)}}return H},J.inline=function(W){var H,K,X,ie,ae,ge,je=W.length;for(H=0;H<je;H++){ge=W[H];switch(ge.type){case"paragraph":case"text":case"heading":{ge.tokens=[],this.inlineTokens(ge.text,ge.tokens);break}case"table":{for(ge.tokens={header:[],cells:[]},ie=ge.header.length,K=0;K<ie;K++)ge.tokens.header[K]=[],this.inlineTokens(ge.header[K],ge.tokens.header[K]);for(ie=ge.cells.length,K=0;K<ie;K++)for(ae=ge.cells[K],ge.tokens.cells[K]=[],X=0;X<ae.length;X++)ge.tokens.cells[K][X]=[],this.inlineTokens(ae[X],ge.tokens.cells[K][X]);break}case"blockquote":{this.inline(ge.tokens);break}case"list":{for(ie=ge.items.length,K=0;K<ie;K++)this.inline(ge.items[K].tokens);break}}}return W},J.inlineTokens=function(W,H,K,X,ie){H===void 0&&(H=[]),K===void 0&&(K=!1),X===void 0&&(X=!1),ie===void 0&&(ie="");var ae,ge=W,je;if(this.tokens.links){var ze=Object.keys(this.tokens.links);if(ze.length>0)for(;(je=this.tokenizer.rules.inline.reflinkSearch.exec(ge))!=null;)ze.includes(je[0].slice(je[0].lastIndexOf("[")+1,-1))&&(ge=ge.slice(0,je.index)+"["+"a".repeat(je[0].length-2)+"]"+ge.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(je=this.tokenizer.rules.inline.blockSkip.exec(ge))!=null;)ge=ge.slice(0,je.index)+"["+"a".repeat(je[0].length-2)+"]"+ge.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;W;){if(ae=this.tokenizer.escape(W)){W=W.substring(ae.raw.length),H.push(ae);continue}if(ae=this.tokenizer.tag(W,K,X)){W=W.substring(ae.raw.length),K=ae.inLink,X=ae.inRawBlock,H.push(ae);continue}if(ae=this.tokenizer.link(W)){W=W.substring(ae.raw.length),ae.type==="link"&&(ae.tokens=this.inlineTokens(ae.text,[],!0,X)),H.push(ae);continue}if(ae=this.tokenizer.reflink(W,this.tokens.links)){W=W.substring(ae.raw.length),ae.type==="link"&&(ae.tokens=this.inlineTokens(ae.text,[],!0,X)),H.push(ae);continue}if(ae=this.tokenizer.strong(W,ge,ie)){W=W.substring(ae.raw.length),ae.tokens=this.inlineTokens(ae.text,[],K,X),H.push(ae);continue}if(ae=this.tokenizer.em(W,ge,ie)){W=W.substring(ae.raw.length),ae.tokens=this.inlineTokens(ae.text,[],K,X),H.push(ae);continue}if(ae=this.tokenizer.codespan(W)){W=W.substring(ae.raw.length),H.push(ae);continue}if(ae=this.tokenizer.br(W)){W=W.substring(ae.raw.length),H.push(ae);continue}if(ae=this.tokenizer.del(W)){W=W.substring(ae.raw.length),ae.tokens=this.inlineTokens(ae.text,[],K,X),H.push(ae);continue}if(ae=this.tokenizer.autolink(W,le)){W=W.substring(ae.raw.length),H.push(ae);continue}if(!K&&(ae=this.tokenizer.url(W,le))){W=W.substring(ae.raw.length),H.push(ae);continue}if(ae=this.tokenizer.inlineText(W,X,Te)){W=W.substring(ae.raw.length),ie=ae.raw.slice(-1),H.push(ae);continue}if(W){var We="Infinite loop on byte: "+W.charCodeAt(0);if(this.options.silent){console.error(We);break}else throw new Error(We)}}return H},F(q,null,[{key:"rules",get:function(){return{block:Le,inline:xe}}}]),q}(),we=N.defaults,De=j.cleanUrl,Se=j.escape,pe=function(){function q(Z){this.options=Z||we}var J=q.prototype;return J.code=function(W,H,K){var X=(H||"").match(/\S*/)[0];if(this.options.highlight){var ie=this.options.highlight(W,X);ie!=null&&ie!==W&&(K=!0,W=ie)}return X?'<pre><code class="'+this.options.langPrefix+Se(X,!0)+'">'+(K?W:Se(W,!0))+`</code></pre>
|
|
`:"<pre><code>"+(K?W:Se(W,!0))+`</code></pre>
|
|
`},J.blockquote=function(W){return`<blockquote>
|
|
`+W+`</blockquote>
|
|
`},J.html=function(W){return W},J.heading=function(W,H,K,X){return this.options.headerIds?"<h"+H+' id="'+this.options.headerPrefix+X.slug(K)+'">'+W+"</h"+H+`>
|
|
`:"<h"+H+">"+W+"</h"+H+`>
|
|
`},J.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},J.list=function(W,H,K){var X=H?"ol":"ul",ie=H&&K!==1?' start="'+K+'"':"";return"<"+X+ie+`>
|
|
`+W+"</"+X+`>
|
|
`},J.listitem=function(W){return"<li>"+W+`</li>
|
|
`},J.checkbox=function(W){return"<input "+(W?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},J.paragraph=function(W){return"<p>"+W+`</p>
|
|
`},J.table=function(W,H){return H&&(H="<tbody>"+H+"</tbody>"),`<table>
|
|
<thead>
|
|
`+W+`</thead>
|
|
`+H+`</table>
|
|
`},J.tablerow=function(W){return`<tr>
|
|
`+W+`</tr>
|
|
`},J.tablecell=function(W,H){var K=H.header?"th":"td",X=H.align?"<"+K+' align="'+H.align+'">':"<"+K+">";return X+W+"</"+K+`>
|
|
`},J.strong=function(W){return"<strong>"+W+"</strong>"},J.em=function(W){return"<em>"+W+"</em>"},J.codespan=function(W){return"<code>"+W+"</code>"},J.br=function(){return this.options.xhtml?"<br/>":"<br>"},J.del=function(W){return"<del>"+W+"</del>"},J.link=function(W,H,K){if(W=De(this.options.sanitize,this.options.baseUrl,W),W===null)return K;var X='<a href="'+Se(W)+'"';return H&&(X+=' title="'+H+'"'),X+=">"+K+"</a>",X},J.image=function(W,H,K){if(W=De(this.options.sanitize,this.options.baseUrl,W),W===null)return K;var X='<img src="'+W+'" alt="'+K+'"';return H&&(X+=' title="'+H+'"'),X+=this.options.xhtml?"/>":">",X},J.text=function(W){return W},q}(),me=function(){function q(){}var J=q.prototype;return J.strong=function(W){return W},J.em=function(W){return W},J.codespan=function(W){return W},J.del=function(W){return W},J.html=function(W){return W},J.text=function(W){return W},J.link=function(W,H,K){return""+K},J.image=function(W,H,K){return""+K},J.br=function(){return""},q}(),Fe=function(){function q(){this.seen={}}var J=q.prototype;return J.slug=function(W){var H=W.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(H)){var K=H;do this.seen[K]++,H=K+"-"+this.seen[K];while(this.seen.hasOwnProperty(H))}return this.seen[H]=0,H},q}(),Pe=N.defaults,Me=j.unescape,Ie=function(){function q(Z){this.options=Z||Pe,this.options.renderer=this.options.renderer||new pe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new me,this.slugger=new Fe}q.parse=function(W,H){var K=new q(H);return K.parse(W)};var J=q.prototype;return J.parse=function(W,H){H===void 0&&(H=!0);var K="",X,ie,ae,ge,je,ze,We,Ye,$e,Ge,tt,rt,st,at,Qe,pt,xt,Ke,Tt=W.length;for(X=0;X<Tt;X++){Ge=W[X];switch(Ge.type){case"space":continue;case"hr":{K+=this.renderer.hr();continue}case"heading":{K+=this.renderer.heading(this.parseInline(Ge.tokens),Ge.depth,Me(this.parseInline(Ge.tokens,this.textRenderer)),this.slugger);continue}case"code":{K+=this.renderer.code(Ge.text,Ge.lang,Ge.escaped);continue}case"table":{for(Ye="",We="",ge=Ge.header.length,ie=0;ie<ge;ie++)We+=this.renderer.tablecell(this.parseInline(Ge.tokens.header[ie]),{header:!0,align:Ge.align[ie]});for(Ye+=this.renderer.tablerow(We),$e="",ge=Ge.cells.length,ie=0;ie<ge;ie++){for(ze=Ge.tokens.cells[ie],We="",je=ze.length,ae=0;ae<je;ae++)We+=this.renderer.tablecell(this.parseInline(ze[ae]),{header:!1,align:Ge.align[ae]});$e+=this.renderer.tablerow(We)}K+=this.renderer.table(Ye,$e);continue}case"blockquote":{$e=this.parse(Ge.tokens),K+=this.renderer.blockquote($e);continue}case"list":{for(tt=Ge.ordered,rt=Ge.start,st=Ge.loose,ge=Ge.items.length,$e="",ie=0;ie<ge;ie++)Qe=Ge.items[ie],pt=Qe.checked,xt=Qe.task,at="",Qe.task&&(Ke=this.renderer.checkbox(pt),st?Qe.tokens.length>0&&Qe.tokens[0].type==="text"?(Qe.tokens[0].text=Ke+" "+Qe.tokens[0].text,Qe.tokens[0].tokens&&Qe.tokens[0].tokens.length>0&&Qe.tokens[0].tokens[0].type==="text"&&(Qe.tokens[0].tokens[0].text=Ke+" "+Qe.tokens[0].tokens[0].text)):Qe.tokens.unshift({type:"text",text:Ke}):at+=Ke),at+=this.parse(Qe.tokens,st),$e+=this.renderer.listitem(at,xt,pt);K+=this.renderer.list($e,tt,rt);continue}case"html":{K+=this.renderer.html(Ge.text);continue}case"paragraph":{K+=this.renderer.paragraph(this.parseInline(Ge.tokens));continue}case"text":{for($e=Ge.tokens?this.parseInline(Ge.tokens):Ge.text;X+1<Tt&&W[X+1].type==="text";)Ge=W[++X],$e+=`
|
|
`+(Ge.tokens?this.parseInline(Ge.tokens):Ge.text);K+=H?this.renderer.paragraph($e):$e;continue}default:{var mt='Token with "'+Ge.type+'" type was not found.';if(this.options.silent){console.error(mt);return}else throw new Error(mt)}}}return K},J.parseInline=function(W,H){H=H||this.renderer;var K="",X,ie,ae=W.length;for(X=0;X<ae;X++){ie=W[X];switch(ie.type){case"escape":{K+=H.text(ie.text);break}case"html":{K+=H.html(ie.text);break}case"link":{K+=H.link(ie.href,ie.title,this.parseInline(ie.tokens,H));break}case"image":{K+=H.image(ie.href,ie.title,ie.text);break}case"strong":{K+=H.strong(this.parseInline(ie.tokens,H));break}case"em":{K+=H.em(this.parseInline(ie.tokens,H));break}case"codespan":{K+=H.codespan(ie.text);break}case"br":{K+=H.br();break}case"del":{K+=H.del(this.parseInline(ie.tokens,H));break}case"text":{K+=H.text(ie.text);break}default:{var ge='Token with "'+ie.type+'" type was not found.';if(this.options.silent){console.error(ge);return}else throw new Error(ge)}}}return K},q}(),Ne=j.merge,Ue=j.checkSanitizeDeprecation,ke=j.escape,Ae=N.getDefaults,Be=N.changeDefaults,_e=N.defaults;function ce(q,J,Z){if(typeof q=="undefined"||q===null)throw new Error("marked(): input parameter is undefined or null");if(typeof q!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(q)+", string expected");if(typeof J=="function"&&(Z=J,J=null),J=Ne({},ce.defaults,J||{}),Ue(J),Z){var W=J.highlight,H;try{H=ye.lex(q,J)}catch(ae){return Z(ae)}var K=function(ge){var je;if(!ge)try{je=Ie.parse(H,J)}catch(ze){ge=ze}return J.highlight=W,ge?Z(ge):Z(null,je)};if(!W||W.length<3)return K();if(delete J.highlight,!H.length)return K();var X=0;ce.walkTokens(H,function(ae){ae.type==="code"&&(X++,setTimeout(function(){W(ae.text,ae.lang,function(ge,je){if(ge)return K(ge);je!=null&&je!==ae.text&&(ae.text=je,ae.escaped=!0),X--,X===0&&K()})},0))}),X===0&&K();return}try{var ie=ye.lex(q,J);return J.walkTokens&&ce.walkTokens(ie,J.walkTokens),Ie.parse(ie,J)}catch(ae){if(ae.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,J.silent)return"<p>An error occurred:</p><pre>"+ke(ae.message+"",!0)+"</pre>";throw ae}}ce.options=ce.setOptions=function(q){return Ne(ce.defaults,q),Be(ce.defaults),ce},ce.getDefaults=Ae,ce.defaults=_e,ce.use=function(q){var J=Ne({},q);if(q.renderer&&function(){var W=ce.defaults.renderer||new pe,H=function(ie){var ae=W[ie];W[ie]=function(){for(var ge=arguments.length,je=new Array(ge),ze=0;ze<ge;ze++)je[ze]=arguments[ze];var We=q.renderer[ie].apply(W,je);return We===!1&&(We=ae.apply(W,je)),We}};for(var K in q.renderer)H(K);J.renderer=W}(),q.tokenizer&&function(){var W=ce.defaults.tokenizer||new se,H=function(ie){var ae=W[ie];W[ie]=function(){for(var ge=arguments.length,je=new Array(ge),ze=0;ze<ge;ze++)je[ze]=arguments[ze];var We=q.tokenizer[ie].apply(W,je);return We===!1&&(We=ae.apply(W,je)),We}};for(var K in q.tokenizer)H(K);J.tokenizer=W}(),q.walkTokens){var Z=ce.defaults.walkTokens;J.walkTokens=function(W){q.walkTokens(W),Z&&Z(W)}}ce.setOptions(J)},ce.walkTokens=function(q,J){for(var Z=_(q),W;!(W=Z()).done;){var H=W.value;J(H);switch(H.type){case"table":{for(var K=_(H.tokens.header),X;!(X=K()).done;){var ie=X.value;ce.walkTokens(ie,J)}for(var ae=_(H.tokens.cells),ge;!(ge=ae()).done;)for(var je=ge.value,ze=_(je),We;!(We=ze()).done;){var Ye=We.value;ce.walkTokens(Ye,J)}break}case"list":{ce.walkTokens(H.items,J);break}default:H.tokens&&ce.walkTokens(H.tokens,J)}}},ce.Parser=Ie,ce.parser=Ie.parse,ce.Renderer=pe,ce.TextRenderer=me,ce.Lexer=ye,ce.lexer=ye.lex,ce.Tokenizer=se,ce.Slugger=Fe,ce.parse=ce;var Ce=ce;return Ce})},EjUQ:function(Je,Xe,ee){"use strict";ee.r(Xe);var de=ee("DjyN"),F=ee("NUBc"),S=ee("cWXX"),B=ee("/ezw"),_=ee("/zsF"),R=ee("PArb"),N=ee("14J3"),M=ee("BMrR"),O=ee("jCWc"),w=ee("kPKH"),m=ee("k1fw"),T=ee("tJVT"),C=ee("PpiC"),b=ee("B9cy"),E=ee("Ol7k"),y=ee("lUTK"),c=ee("BvKs"),r=ee("q1tI"),a=ee.n(r),o=ee("9kvl"),g=ee("wd/R"),l=ee.n(g),d=ee("m3rI"),v=ee("BdwD"),h=ee("2qtc"),u=ee("kLXV"),n=ee("5NDa"),e=ee("5rEg"),t=ee("jrin"),f=ee("miYZ"),p=ee("tsqr"),x=ee("9og8"),A=ee("y8nQ"),I=ee("Vl3Y"),U=ee("WmNS"),j=ee.n(U),z=ee("5WQS"),V=ee("Ty5D"),G=ee("NDqe"),Q=ee.n(G),ne=function(Re){var Le,xe=Re.messages,Te=Re.loading,le=Re.user,ye=Re.dispatch,we=Object(V.i)(),De=Object(V.h)(),Se=xe.actionTabs,pe=I.a.useForm(),me=Object(T.a)(pe,1),Fe=me[0],Pe=xe.recentContacts,Me=Object(r.useState)(""),Ie=Object(T.a)(Me,2),Ne=Ie[0],Ue=Ie[1],ke=Object(r.useState)([]),Ae=Object(T.a)(ke,2),Be=Ae[0],_e=Ae[1],ce=Object(r.useState)(!1),Ce=Object(T.a)(ce,2),q=Ce[0],J=Ce[1],Z=Object(r.useState)(),W=Object(T.a)(Z,2),H=W[0],K=W[1];Object(r.useEffect)(function(){xe.actionTabs.key==="\u5199\u79C1\u4FE1"&&X()},[xe.actionTabs.key]);var X=function(){var ae=Object(x.a)(j.a.mark(function ge(){var je,ze;return j.a.wrap(function(Ye){for(;;)switch(Ye.prev=Ye.next){case 0:return Ye.next=2,ye({type:"messages/getRecentContacts",payload:{id:le==null||((je=le.userInfo)===null||je===void 0)?void 0:je.user_id,keyword:Ne}});case 2:ze=Ye.sent,_e(Object(m.a)({},ze));case 4:case"end":return Ye.stop()}},ge)}));return function(){return ae.apply(this,arguments)}}(),ie=function(){var ae=Object(x.a)(j.a.mark(function ge(){var je;return j.a.wrap(function(We){for(;;)switch(We.prev=We.next){case 0:if(!(Ne!=="")){We.next=5;break}return We.next=3,ye({type:"messages/getUsersForPrivateMessages",payload:{keyword:Ne}});case 3:je=We.sent,_e(Object(m.a)({},je));case 5:case"end":return We.stop()}},ge)}));return function(){return ae.apply(this,arguments)}}();return Object(r.useEffect)(function(){ie()},[Ne]),a.a.createElement(u.a,{centered:!0,title:"\u5199\u79C1\u4FE1",visible:xe.actionTabs.key==="\u5199\u79C1\u4FE1",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{height:320},onOk:Object(x.a)(j.a.mark(function ae(){var ge,je,ze,We,Ye,$e;return j.a.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return tt.next=2,Fe.validateFields();case 2:return je=Fe.getFieldValue(),ze="/api/course_modules/".concat(we.categoryId,"/add_second_category.json"),tt.next=6,Object(z.g)({content:je.content,target_id:H,userId:le==null||((ge=le.userInfo)===null||ge===void 0)?void 0:ge.user_id});case 6:We=tt.sent,We.status===0&&(p.b.success("\u6DFB\u52A0\u6210\u529F"),ye({type:"messages/setActionTabs",payload:{}}),o.d.push("/messages/".concat(le==null||((Ye=le.userInfo)===null||Ye===void 0)?void 0:Ye.login,"/message_detail?target_ids=").concat(We==null||(($e=We.private_message)===null||$e===void 0)?void 0:$e.receiver_id)));case 8:case"end":return tt.stop()}},ae)})),onCancel:function(){ye({type:"messages/setActionTabs",payload:{}})}},a.a.createElement(I.a,{form:Fe,initialValues:Object(t.a)({},"name","")},a.a.createElement(I.a.Item,{name:"users",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u53D1\u9001\u5BF9\u8C61"}]},a.a.createElement(e.a.Search,{onFocus:function(){return J(!0)},onSearch:function(ge){Ue(ge)},placeholder:"\u53D1\u9001\u7ED9..."})),q&&a.a.createElement(B.a,{loading:Te["messages/getUsersForPrivateMessages"]},a.a.createElement("aside",{className:Q.a.searchWrp,style:{maxHeight:260,overflow:"auto"}},a.a.createElement("p",{className:"c-light-black mt10"},Ne===""?"\u6700\u8FD1\u8054\u7CFB\u4EBA":"\u641C\u7D22\u7ED3\u679C"),Be==null||((Le=Be.users)===null||Le===void 0)?void 0:Le.map(function(ae,ge){return a.a.createElement(M.a,{key:ge,align:"middle",className:"mt15 current",onClick:function(){K(ae.id),Fe.setFieldsValue({users:ae.name}),J(!1)}},a.a.createElement(w.a,{flex:"58px"},a.a.createElement("img",{style:{width:48,borderRadius:48},src:d.a.IMG_SERVER+"/images/"+(ae==null?void 0:ae.image_url),alt:""})),a.a.createElement(w.a,null,ae.name))}))),a.a.createElement(I.a.Item,{rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u53D1\u9001\u5185\u5BB9"}],className:q&&"hide",name:"content"},a.a.createElement(e.a.TextArea,{rows:10,maxLength:200}))))},re=Object(o.a)(function(fe){var Re=fe.messages,Le=fe.loading,xe=fe.user;return{messages:Re,user:xe,loading:Le.effects}})(ne),be=ee("9Bee"),se=ee("30zm"),oe=c.a.SubMenu,ue=E.a.Sider,he=E.a.Content,te=function(Re){var Le,xe,Te=Re.messages,le=Re.globalSetting,ye=Re.loading,we=Re.user,De=Re.dispatch,Se=Object(C.a)(Re,["messages","globalSetting","loading","user","dispatch"]),pe=Se.match.params,me=we.userInfo,Fe=Te.tidingsList,Pe=Te.privateMessage,Me=Object(r.useState)({per_page:10,page:1}),Ie=Object(T.a)(Me,2),Ne=Ie[0],Ue=Ie[1];Object(r.useEffect)(function(){Ne.page=1,ke()},[pe.userId]);var ke=function(){De({type:"messages/getPrivateMessages",payload:Object(m.a)(Object(m.a)({},Ne),pe)})},Ae=function(ce){var Ce,q;Se.history.push("/messages/".concat(we==null||((Ce=we.userInfo)===null||Ce===void 0)?void 0:Ce.login,"/message_detail?target_ids=").concat(ce==null||((q=ce.target)===null||q===void 0)?void 0:q.id))},Be=function(ce){var Ce;Se.history.push("/users/".concat(ce==null||((Ce=ce.target)===null||Ce===void 0)?void 0:Ce.login))};return a.a.createElement("section",{className:Q.a.bg},a.a.createElement("section",{className:"edu-container mt20"},a.a.createElement(M.a,{gutter:[20,20]},a.a.createElement(se.a,null),a.a.createElement(w.a,{flex:"1"},a.a.createElement("aside",{className:"bg-white"},a.a.createElement("aside",{className:"pt30 pl30 pr30 font16"},a.a.createElement(M.a,null,a.a.createElement(w.a,{flex:"1"},"\u5168\u90E8\u79C1\u4FE1"),a.a.createElement(w.a,null,a.a.createElement("span",{className:"c-blue current",onClick:function(){var ce;De({type:"messages/setActionTabs",payload:{key:"\u5199\u79C1\u4FE1",bodyParams:Object(m.a)(Object(m.a)({},Ne),{},{user_id:we==null||((ce=we.userInfo)===null||ce===void 0)?void 0:ce.user_id})}})}},"\u5199\u79C1\u4FE1")))),a.a.createElement(R.a,null),a.a.createElement("aside",{className:Q.a.list},a.a.createElement(B.a,{active:!0,avatar:{size:40},paragraph:{rows:5},loading:ye["messages/getPrivateMessages"]},!(Pe!=null&&(Le=Pe.private_messages)!==null&&Le!==void 0&&Le.length)&&a.a.createElement(v.a,null),Pe==null||((xe=Pe.private_messages)===null||xe===void 0)?void 0:xe.map(function(_e,ce){var Ce,q;return a.a.createElement("aside",null,a.a.createElement(M.a,null,a.a.createElement(w.a,{flex:"58px",onClick:function(){return Be(_e)}},a.a.createElement("img",{src:d.a.IMG_SERVER+"/images/"+(_e==null||((Ce=_e.target)===null||Ce===void 0)?void 0:Ce.image_url),alt:""})),a.a.createElement(w.a,{flex:1},a.a.createElement(M.a,null,a.a.createElement(w.a,{span:24},a.a.createElement(M.a,null,a.a.createElement(w.a,{flex:"1"},a.a.createElement("span",{onClick:function(){return Be(_e)}},_e==null||((q=_e.target)===null||q===void 0)?void 0:q.name),a.a.createElement("span",{className:"ml15"},"\u4E0E\u4F60\u7684\u79C1\u4FE1"),a.a.createElement("span",{className:"c-light-black mr15"},"[",_e==null?void 0:_e.message_count,"\u6761]"),a.a.createElement("span",{className:"ml15 c-light-black"},l()(_e.send_time).fromNow())),a.a.createElement(w.a,null,(_e==null?void 0:_e.unread)&&a.a.createElement("span",{className:Q.a.newlight})))),a.a.createElement(w.a,{span:24,onClick:function(){return Ae(_e)}},a.a.createElement("div",{className:"mt15"},a.a.createElement(be.a,{value:_e.content||""})))))))})))),a.a.createElement("aside",{className:"tc mt20"},!ye["messages/getTidings"]&&a.a.createElement(F.a,{hideOnSinglePage:!0,showSizeChanger:!1,onChange:function(ce){Ne.page=ce,Ue(Object(m.a)({},Ne)),ke()},current:Ne.page||1,total:Pe==null?void 0:Pe.count}))))),a.a.createElement(re,null))},Y=Xe.default=Object(o.a)(function(fe){var Re=fe.messages,Le=fe.loading,xe=fe.user,Te=fe.globalSetting;return{messages:Re,globalSetting:Te,user:xe,loading:Le.effects}})(te)},FOrL:function(Je,Xe,ee){Je.exports=ee.p+"static/nodata.a6b3f948.png"},LdHM:function(Je,Xe,ee){"use strict";ee.d(Xe,"b",function(){return o}),ee.d(Xe,"a",function(){return l});var de=ee("1OyB"),F=ee("vuIU"),S=ee("Ji7U"),B=ee("LK+K"),_=ee("q1tI"),R=ee("rePB"),N=ee("Ff2n"),M=ee("ODXe"),O=ee("4IlW"),w=ee("bX4T"),m=ee("YrtM"),T=ee("TSYQ"),C=ee.n(T),b=ee("+nKL"),E=ee("8OUc"),y=function(G,Q){var ne=G.prefixCls,re=G.id,be=G.flattenOptions,se=G.childrenAsData,oe=G.values,ue=G.searchValue,he=G.multiple,te=G.defaultActiveFirstOption,Y=G.height,fe=G.itemHeight,Re=G.notFoundContent,Le=G.open,xe=G.menuItemSelectedIcon,Te=G.virtual,le=G.onSelect,ye=G.onToggleOpen,we=G.onActiveValue,De=G.onScroll,Se=G.onMouseEnter,pe="".concat(ne,"-item"),me=Object(m.a)(function(){return be},[Le,be],function(Ce,q){return q[0]&&Ce[1]!==q[1]}),Fe=_.useRef(null),Pe=function(q){q.preventDefault()},Me=function(q){Fe.current&&Fe.current.scrollTo({index:q})},Ie=function(q){for(var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Z=me.length,W=0;W<Z;W+=1){var H=(q+W*J+Z)%Z,K=me[H],X=K.group,ie=K.data;if(!X&&!ie.disabled)return H}return-1},Ne=_.useState(function(){return Ie(0)}),Ue=Object(M.a)(Ne,2),ke=Ue[0],Ae=Ue[1],Be=function(q){Ae(q);var J=me[q];if(!J){we(null,-1);return}we(J.data.value,q)};_.useEffect(function(){Be(te!==!1?Ie(0):-1)},[me.length,ue]),_.useEffect(function(){var Ce=setTimeout(function(){if(!he&&Le&&oe.size===1){var q=Array.from(oe)[0],J=me.findIndex(function(Z){var W=Z.data;return W.value===q});Be(J),Me(J)}});return function(){return clearTimeout(Ce)}},[Le]);var _e=function(q){q!==void 0&&le(q,{selected:!oe.has(q)}),he||ye(!1)};if(_.useImperativeHandle(Q,function(){return{onKeyDown:function(q){var J=q.which;switch(J){case O.a.UP:case O.a.DOWN:{var Z=0;if(J===O.a.UP?Z=-1:J===O.a.DOWN&&(Z=1),Z!==0){var W=Ie(ke+Z,Z);Me(W),Be(W)}break}case O.a.ENTER:{var H=me[ke];H&&!H.data.disabled?_e(H.data.value):_e(void 0),Le&&q.preventDefault();break}case O.a.ESC:ye(!1)}},onKeyUp:function(){},scrollTo:function(q){Me(q)}}}),me.length===0)return _.createElement("div",{role:"listbox",id:"".concat(re,"_list"),className:"".concat(pe,"-empty"),onMouseDown:Pe},Re);function ce(Ce){var q=me[Ce];if(!q)return null;var J=q.data||{},Z=J.value,W=J.label,H=J.children,K=Object(w.a)(J,!0),X=se?H:W;return q?_.createElement("div",Object.assign({"aria-label":typeof X=="string"?X:null},K,{key:Ce,role:"option",id:"".concat(re,"_list_").concat(Ce),"aria-selected":oe.has(Z)}),Z):null}return _.createElement(_.Fragment,null,_.createElement("div",{role:"listbox",id:"".concat(re,"_list"),style:{height:0,width:0,overflow:"hidden"}},ce(ke-1),ce(ke),ce(ke+1)),_.createElement(b.a,{itemKey:"key",ref:Fe,data:me,height:Y,itemHeight:fe,fullHeight:!1,onMouseDown:Pe,onScroll:De,virtual:Te,onMouseEnter:Se},function(Ce,q){var J,Z=Ce.group,W=Ce.groupOption,H=Ce.data,K=H.label,X=H.key;if(Z)return _.createElement("div",{className:C()(pe,"".concat(pe,"-group"))},K!==void 0?K:X);var ie=H.disabled,ae=H.value,ge=H.title,je=H.children,ze=H.style,We=H.className,Ye=Object(N.a)(H,["disabled","value","title","children","style","className"]),$e=oe.has(ae),Ge="".concat(pe,"-option"),tt=C()(pe,Ge,We,(J={},Object(R.a)(J,"".concat(Ge,"-grouped"),W),Object(R.a)(J,"".concat(Ge,"-active"),ke===q&&!ie),Object(R.a)(J,"".concat(Ge,"-disabled"),ie),Object(R.a)(J,"".concat(Ge,"-selected"),$e),J)),rt=se?je:K,st=!xe||typeof xe=="function"||$e;return _.createElement("div",Object.assign({},Ye,{"aria-selected":$e,className:tt,title:ge,onMouseMove:function(){if(ke===q||ie)return;Be(q)},onClick:function(){ie||_e(ae)},style:ze}),_.createElement("div",{className:"".concat(Ge,"-content")},rt||ae),_.isValidElement(xe)||$e,st&&_.createElement(E.a,{className:"".concat(pe,"-option-state"),customizeIcon:xe,customizeIconProps:{isSelected:$e}},$e?"\u2713":null))}))},c=_.forwardRef(y);c.displayName="OptionList";var r=c,a=function(){return null};a.isSelectOption=!0;var o=a,g=function(){return null};g.isSelectOptGroup=!0;var l=g,d=ee("VTBJ"),v=ee("Zm9Q");function h(V){var G=V.key,Q=V.props,ne=Q.children,re=Q.value,be=Object(N.a)(Q,["children","value"]);return Object(d.a)({key:G,value:re!==void 0?re:G,children:ne},be)}function u(V){var G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(v.a)(V).map(function(Q,ne){if(!_.isValidElement(Q)||!Q.type)return null;var re=Q.type.isSelectOptGroup,be=Q.key,se=Q.props,oe=se.children,ue=Object(N.a)(se,["children"]);return G||!re?h(Q):Object(d.a)(Object(d.a)({key:"__RC_SELECT_GRP__".concat(be===null?ne:be,"__"),label:be},ue),{},{options:u(oe)})}).filter(function(Q){return Q})}var n=ee("2Qr1"),e=ee("qNPg"),t=ee("U8pU"),f=ee("Kwbf"),p=ee("WKfj");function x(V){var G=V.mode,Q=V.options,ne=V.children,re=V.backfill,be=V.allowClear,se=V.placeholder,oe=V.getInputElement,ue=V.showSearch,he=V.onSearch,te=V.defaultOpen,Y=V.autoFocus,fe=V.labelInValue,Re=V.value,Le=V.inputValue,xe=V.optionLabelProp,Te=G==="multiple"||G==="tags",le=ue!==void 0?ue:Te||G==="combobox",ye=Q||u(ne);if(Object(f.a)(G!=="tags"||ye.every(function(pe){return!pe.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),G==="tags"||G==="combobox"){var we=ye.some(function(pe){return pe.options?pe.options.some(function(me){return typeof("value"in me?me.value:me.key)=="number"}):typeof("value"in pe?pe.value:pe.key)=="number"});Object(f.a)(!we,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(f.a)(G!=="combobox"||!xe,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(f.a)(G==="combobox"||!re,"`backfill` only works with `combobox` mode."),Object(f.a)(G==="combobox"||!oe,"`getInputElement` only work with `combobox` mode."),Object(f.b)(G!=="combobox"||!oe||!be||!se,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),he&&!le&&G!=="combobox"&&G!=="tags"&&Object(f.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(f.b)(!te||Y,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Re!=null){var De=Object(p.d)(Re);Object(f.a)(!fe||De.every(function(pe){return Object(t.a)(pe)==="object"&&("key"in pe||"value"in pe)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(f.a)(!Te||Array.isArray(Re),"`value` should be array when `mode` is `multiple` or `tags`")}if(ne){var Se=null;Object(v.a)(ne).some(function(pe){if(!_.isValidElement(pe)||!pe.type)return!1;var me=pe.type;if(me.isSelectOption)return!1;if(me.isSelectOptGroup){var Fe=Object(v.a)(pe.props.children).every(function(Pe){return!_.isValidElement(Pe)||!pe.type||Pe.type.isSelectOption?!0:(Se=Pe.type,!1)});return!Fe}return Se=me,!0}),Se&&Object(f.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Se.displayName||Se.name||Se,"`.")),Object(f.a)(Le===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var A=x,I=Object(e.a)({prefixCls:"rc-select",components:{optionList:r},convertChildrenToData:u,flattenOptions:n.d,getLabeledValue:n.e,filterOptions:n.b,isValueDisabled:n.g,findValueOption:n.c,warningProps:A,fillOptionsWithMissingValue:n.a}),U=function(V){Object(S.a)(Q,V);var G=Object(B.a)(Q);function Q(){var ne;return Object(de.a)(this,Q),ne=G.apply(this,arguments),ne.selectRef=_.createRef(),ne.focus=function(){ne.selectRef.current.focus()},ne.blur=function(){ne.selectRef.current.blur()},ne}return Object(F.a)(Q,[{key:"render",value:function(){return _.createElement(I,Object.assign({ref:this.selectRef},this.props))}}]),Q}(_.Component);U.Option=o,U.OptGroup=l;var j=U,z=Xe.c=j},NDqe:function(Je,Xe,ee){Je.exports={flex_box_center:"flex_box_center___3oYZ2",flex_space_between:"flex_space_between___1FifH",flex_box_vertical_center:"flex_box_vertical_center___2iDXN",flex_box_center_end:"flex_box_center_end___2rJ_G",flex_box_column:"flex_box_column___3ucki",tabs:"tabs___3aVAD",active:"active___1eCl8",list:"list___2weuP",tags:"tags___10O8v",searchWrp:"searchWrp___xsrqM",newlight:"newlight___1S7Yv"}},SJMd:function(Je,Xe){/**
|
|
* @license
|
|
* Copyright (C) 2006 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/var ee,de,F,S=!1,B,_;window.PR_SHOULD_USE_CONTINUATION=!0;var R,N;(function(){var M=window,O=["break,continue,do,else,for,if,return,while"],w=[O,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],m=[w,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],T=[m,"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"],C=[m,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],b=[m,"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"],E="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",y=[m,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],c="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",r=[O,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],a=[O,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],o=[O,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],g=[T,b,C,y,c,r,a,o],l=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,d="str",v="kwd",h="com",u="typ",n="lit",e="pun",t="pln",f="tag",p="dec",x="src",A="atn",I="atv",U="nocode",j="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(le){for(var ye=0,we=!1,De=!1,Se=0,pe=le.length;Se<pe;++Se){var me=le[Se];if(me.ignoreCase)De=!0;else if(/[a-z]/i.test(me.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){we=!0,De=!1;break}}var Fe={b:8,t:9,n:10,v:11,f:12,r:13};function Pe(ke){var Ae=ke.charCodeAt(0);if(Ae!==92)return Ae;var Be=ke.charAt(1);return Ae=Fe[Be],Ae||("0"<=Be&&Be<="7"?parseInt(ke.substring(1),8):Be==="u"||Be==="x"?parseInt(ke.substring(2),16):ke.charCodeAt(1))}function Me(ke){if(ke<32)return(ke<16?"\\x0":"\\x")+ke.toString(16);var Ae=String.fromCharCode(ke);return Ae==="\\"||Ae==="-"||Ae==="]"||Ae==="^"?"\\"+Ae:Ae}function Ie(ke){var Ae=ke.substring(1,ke.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")),Be=[],_e=Ae[0]==="^",ce=["["];_e&&ce.push("^");for(var Ce=_e?1:0,q=Ae.length;Ce<q;++Ce){var J=Ae[Ce];if(/\\[bdsw]/i.test(J))ce.push(J);else{var Z=Pe(J),W;Ce+2<q&&Ae[Ce+1]==="-"?(W=Pe(Ae[Ce+2]),Ce+=2):W=Z,Be.push([Z,W]),W<65||Z>122||(W<65||Z>90||Be.push([Math.max(65,Z)|32,Math.min(W,90)|32]),W<97||Z>122||Be.push([Math.max(97,Z)&~32,Math.min(W,122)&~32]))}}Be.sort(function(ie,ae){return ie[0]-ae[0]||ae[1]-ie[1]});for(var H=[],K=[],Ce=0;Ce<Be.length;++Ce){var X=Be[Ce];X[0]<=K[1]+1?K[1]=Math.max(K[1],X[1]):H.push(K=X)}for(var Ce=0;Ce<H.length;++Ce){var X=H[Ce];ce.push(Me(X[0])),X[1]>X[0]&&(X[1]+1>X[0]&&ce.push("-"),ce.push(Me(X[1])))}return ce.push("]"),ce.join("")}function Ne(ke){for(var Ae=ke.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")),Be=Ae.length,_e=[],ce=0,Ce=0;ce<Be;++ce){var q=Ae[ce];if(q==="(")++Ce;else if(q.charAt(0)==="\\"){var J=+q.substring(1);J&&(J<=Ce?_e[J]=-1:Ae[ce]=Me(J))}}for(var ce=1;ce<_e.length;++ce)_e[ce]===-1&&(_e[ce]=++ye);for(var ce=0,Ce=0;ce<Be;++ce){var q=Ae[ce];if(q==="(")++Ce,_e[Ce]||(Ae[ce]="(?:");else if(q.charAt(0)==="\\"){var J=+q.substring(1);J&&J<=Ce&&(Ae[ce]="\\"+_e[J])}}for(var ce=0;ce<Be;++ce)Ae[ce]==="^"&&Ae[ce+1]!=="^"&&(Ae[ce]="");if(ke.ignoreCase&&we)for(var ce=0;ce<Be;++ce){var q=Ae[ce],Z=q.charAt(0);q.length>=2&&Z==="["?Ae[ce]=Ie(q):Z!=="\\"&&(Ae[ce]=q.replace(/[a-zA-Z]/g,function(K){var X=K.charCodeAt(0);return"["+String.fromCharCode(X&~32,X|32)+"]"}))}return Ae.join("")}for(var Ue=[],Se=0,pe=le.length;Se<pe;++Se){var me=le[Se];if(me.global||me.multiline)throw new Error(""+me);Ue.push("(?:"+Ne(me)+")")}return new RegExp(Ue.join("|"),De?"gi":"g")}function V(le,ye){var we=/(?:^|\s)nocode(?:\s|$)/,De=[],Se=0,pe=[],me=0;function Fe(Pe){var Me=Pe.nodeType;if(Me==1){if(we.test(Pe.className))return;for(var Ie=Pe.firstChild;Ie;Ie=Ie.nextSibling)Fe(Ie);var Ne=Pe.nodeName.toLowerCase();(Ne==="br"||Ne==="li")&&(De[me]=`
|
|
`,pe[me<<1]=Se++,pe[me++<<1|1]=Pe)}else if(Me==3||Me==4){var Ue=Pe.nodeValue;Ue.length&&(ye?Ue=Ue.replace(/\r\n?/g,`
|
|
`):Ue=Ue.replace(/[ \t\r\n]+/g," "),De[me]=Ue,pe[me<<1]=Se,Se+=Ue.length,pe[me++<<1|1]=Pe)}}return Fe(le),{sourceCode:De.join("").replace(/\n$/,""),spans:pe}}function G(le,ye,we,De,Se){if(!we)return;var pe={sourceNode:le,pre:1,langExtension:null,numberLines:null,sourceCode:we,spans:null,basePos:ye,decorations:null};De(pe),Se.push.apply(Se,pe.decorations)}var Q=/\S/;function ne(le){for(var ye=void 0,we=le.firstChild;we;we=we.nextSibling){var De=we.nodeType;ye=De===1?ye?le:we:De===3&&Q.test(we.nodeValue)?le:ye}return ye===le?void 0:ye}function re(le,ye){var we={},De;(function(){for(var me=le.concat(ye),Fe=[],Pe={},Me=0,Ie=me.length;Me<Ie;++Me){var Ne=me[Me],Ue=Ne[3];if(Ue)for(var ke=Ue.length;--ke>=0;)we[Ue.charAt(ke)]=Ne;var Ae=Ne[1],Be=""+Ae;Pe.hasOwnProperty(Be)||(Fe.push(Ae),Pe[Be]=null)}Fe.push(/[\0-\uffff]/),De=z(Fe)})();var Se=ye.length,pe=function(me){for(var Fe=me.sourceCode,Pe=me.basePos,Me=me.sourceNode,Ie=[Pe,t],Ne=0,Ue=Fe.match(De)||[],ke={},Ae=0,Be=Ue.length;Ae<Be;++Ae){var _e=Ue[Ae],ce=ke[_e],Ce=void 0,q;if(typeof ce=="string")q=!1;else{var J=we[_e.charAt(0)];if(J)Ce=_e.match(J[1]),ce=J[0];else{for(var Z=0;Z<Se;++Z)if(J=ye[Z],Ce=_e.match(J[1]),Ce){ce=J[0];break}Ce||(ce=t)}q=ce.length>=5&&ce.substring(0,5)==="lang-",q&&!(Ce&&typeof Ce[1]=="string")&&(q=!1,ce=x),q||(ke[_e]=ce)}var W=Ne;if(Ne+=_e.length,!q)Ie.push(Pe+W,ce);else{var H=Ce[1],K=_e.indexOf(H),X=K+H.length;Ce[2]&&(X=_e.length-Ce[2].length,K=X-H.length);var ie=ce.substring(5);G(Me,Pe+W,_e.substring(0,K),pe,Ie),G(Me,Pe+W+K,H,Y(ie,H),Ie),G(Me,Pe+W+X,_e.substring(X),pe,Ie)}}me.decorations=Ie};return pe}function be(le){var ye=[],we=[];le.tripleQuotedStrings?ye.push([d,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):le.multiLineStrings?ye.push([d,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ye.push([d,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),le.verbatimStrings&&we.push([d,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var De=le.hashComments;De&&(le.cStyleComments?(De>1?ye.push([h,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ye.push([h,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),we.push([d,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ye.push([h,/^#[^\r\n]*/,null,"#"])),le.cStyleComments&&(we.push([h,/^\/\/[^\r\n]*/,null]),we.push([h,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Se=le.regexLiterals;if(Se){var pe=Se>1?"":`
|
|
\r`,me=pe?".":"[\\S\\s]",Fe="/(?=[^/*"+pe+"])(?:[^/\\x5B\\x5C"+pe+"]|\\x5C"+me+"|\\x5B(?:[^\\x5C\\x5D"+pe+"]|\\x5C"+me+")*(?:\\x5D|$))+/";we.push(["lang-regex",RegExp("^"+j+"("+Fe+")")])}var Pe=le.types;Pe&&we.push([u,Pe]);var Me=(""+le.keywords).replace(/^ | $/g,"");Me.length&&we.push([v,new RegExp("^(?:"+Me.replace(/[\s,]+/g,"|")+")\\b"),null]),ye.push([t,/^\s+/,null,` \r
|
|
\xA0`]);var Ie="^.[^\\s\\w.$@'\"`/\\\\]*";return le.regexLiterals&&(Ie+="(?!s*/)"),we.push([n,/^@[a-z_$][a-z_$@0-9]*/i,null],[u,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[t,/^[a-z_$][a-z_$@0-9]*/i,null],[n,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[t,/^\\[\s\S]?/,null],[e,new RegExp(Ie),null]),re(ye,we)}var se=be({keywords:g,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function oe(le,ye,we){for(var De=/(?:^|\s)nocode(?:\s|$)/,Se=/\r\n?|\n/,pe=le.ownerDocument,me=pe.createElement("li");le.firstChild;)me.appendChild(le.firstChild);var Fe=[me];function Pe(Ae){var Be=Ae.nodeType;if(Be==1&&!De.test(Ae.className))if(Ae.nodeName==="br")Me(Ae),Ae.parentNode&&Ae.parentNode.removeChild(Ae);else for(var _e=Ae.firstChild;_e;_e=_e.nextSibling)Pe(_e);else if((Be==3||Be==4)&&we){var ce=Ae.nodeValue,Ce=ce.match(Se);if(Ce){var q=ce.substring(0,Ce.index);Ae.nodeValue=q;var J=ce.substring(Ce.index+Ce[0].length);if(J){var Z=Ae.parentNode;Z.insertBefore(pe.createTextNode(J),Ae.nextSibling)}Me(Ae),q||Ae.parentNode.removeChild(Ae)}}}function Me(Ae){for(;!Ae.nextSibling;)if(Ae=Ae.parentNode,!Ae)return;function Be(Ce,q){var J=q?Ce.cloneNode(!1):Ce,Z=Ce.parentNode;if(Z){var W=Be(Z,1),H=Ce.nextSibling;W.appendChild(J);for(var K=H;K;K=H)H=K.nextSibling,W.appendChild(K)}return J}for(var _e=Be(Ae.nextSibling,0),ce;(ce=_e.parentNode)&&ce.nodeType===1;)_e=ce;Fe.push(_e)}for(var Ie=0;Ie<Fe.length;++Ie)Pe(Fe[Ie]);ye===(ye|0)&&Fe[0].setAttribute("value",ye);var Ne=pe.createElement("ol");Ne.className="linenums";for(var Ue=Math.max(0,ye-1|0)||0,Ie=0,ke=Fe.length;Ie<ke;++Ie)me=Fe[Ie],me.className="L"+(Ie+Ue)%10,me.firstChild||me.appendChild(pe.createTextNode("\xA0")),Ne.appendChild(me);le.appendChild(Ne)}function ue(le){var ye=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ye=ye&&+ye[1]<=8;var we=/\n/g,De=le.sourceCode,Se=De.length,pe=0,me=le.spans,Fe=me.length,Pe=0,Me=le.decorations,Ie=Me.length,Ne=0;Me[Ie]=Se;var Ue,ke;for(ke=Ue=0;ke<Ie;)Me[ke]!==Me[ke+2]?(Me[Ue++]=Me[ke++],Me[Ue++]=Me[ke++]):ke+=2;for(Ie=Ue,ke=Ue=0;ke<Ie;){for(var Ae=Me[ke],Be=Me[ke+1],_e=ke+2;_e+2<=Ie&&Me[_e+1]===Be;)_e+=2;Me[Ue++]=Ae,Me[Ue++]=Be,ke=_e}Ie=Me.length=Ue;var ce=le.sourceNode,Ce="";ce&&(Ce=ce.style.display,ce.style.display="none");try{for(var q=null;Pe<Fe;){var J=me[Pe],Z=me[Pe+2]||Se,W=Me[Ne+2]||Se,_e=Math.min(Z,W),H=me[Pe+1],K;if(H.nodeType!==1&&(K=De.substring(pe,_e))){ye&&(K=K.replace(we,"\r")),H.nodeValue=K;var X=H.ownerDocument,ie=X.createElement("span");ie.className=Me[Ne+1];var ae=H.parentNode;ae.replaceChild(ie,H),ie.appendChild(H),pe<Z&&(me[Pe+1]=H=X.createTextNode(De.substring(_e,Z)),ae.insertBefore(H,ie.nextSibling))}pe=_e,pe>=Z&&(Pe+=2),pe>=W&&(Ne+=2)}}finally{ce&&(ce.style.display=Ce)}}var he={};function te(le,ye){for(var we=ye.length;--we>=0;){var De=ye[we];he.hasOwnProperty(De)?M.console&&console.warn("cannot override language handler %s",De):he[De]=le}}function Y(le,ye){return le&&he.hasOwnProperty(le)||(le=/^\s*</.test(ye)?"default-markup":"default-code"),he[le]}te(se,["default-code"]),te(re([],[[t,/^[^<?]+/],[p,/^<!\w[^>]*(?:>|$)/],[h,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[e,/^(?:<[%?]|[%?]>)/],["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"]),te(re([[t,/^[\s]+/,null,` \r
|
|
`],[I,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[f,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[A,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[e,/^[=<>\/]+/],["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"]),te(re([],[[I,/^[\s\S]+/]]),["uq.val"]),te(be({keywords:T,hashComments:!0,cStyleComments:!0,types:l}),["c","cc","cpp","cxx","cyc","m"]),te(be({keywords:"null,true,false"}),["json"]),te(be({keywords:b,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:l}),["cs"]),te(be({keywords:C,cStyleComments:!0}),["java"]),te(be({keywords:o,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),te(be({keywords:r,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),te(be({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),te(be({keywords:a,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),te(be({keywords:y,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),te(be({keywords:E,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),te(re([],[[d,/^[\s\S]+/]]),["regex"]);function fe(le){var ye=le.langExtension;try{var we=V(le.sourceNode,le.pre),De=we.sourceCode;le.sourceCode=De,le.spans=we.spans,le.basePos=0,Y(ye,De)(le),ue(le)}catch(Se){M.console&&console.log(Se&&Se.stack||Se)}}function Re(le,ye,we){var De=we||!1,Se=ye||null,pe=document.createElement("div");pe.innerHTML="<pre>"+le+"</pre>",pe=pe.firstChild,De&&oe(pe,De,!0);var me={langExtension:Se,numberLines:De,sourceNode:pe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return fe(me),pe.innerHTML}function Le(le,ye){var we=ye||document.body,De=we.ownerDocument||document;function Se(J){return we.getElementsByTagName(J)}for(var pe=[Se("pre"),Se("code"),Se("xmp")],me=[],Fe=0;Fe<pe.length;++Fe)for(var Pe=0,Me=pe[Fe].length;Pe<Me;++Pe)me.push(pe[Fe][Pe]);pe=null;var Ie=Date;Ie.now||(Ie={now:function(){return+new Date}});var Ne=0,Ue=/\blang(?:uage)?-([\w.]+)(?!\S)/,ke=/\bprettyprint\b/,Ae=/\bprettyprinted\b/,Be=/pre|xmp/i,_e=/^code$/i,ce=/^(?:pre|code|xmp)$/i,Ce={};function q(){for(var J=M.PR_SHOULD_USE_CONTINUATION?Ie.now()+250:Infinity;Ne<me.length&&Ie.now()<J;Ne++){for(var Z=me[Ne],W=Ce,H=Z;H=H.previousSibling;){var K=H.nodeType,X=(K===7||K===8)&&H.nodeValue;if(X?!/^\??prettify\b/.test(X):K!==3||/\S/.test(H.nodeValue))break;if(X){W={},X.replace(/\b(\w+)=([\w:.%+-]+)/g,function(at,Qe,pt){W[Qe]=pt});break}}var ie=Z.className;if((W!==Ce||ke.test(ie))&&!Ae.test(ie)){for(var ae=!1,ge=Z.parentNode;ge;ge=ge.parentNode){var je=ge.tagName;if(ce.test(je)&&ge.className&&ke.test(ge.className)){ae=!0;break}}if(!ae){Z.className+=" prettyprinted";var ze=W.lang;if(!ze){ze=ie.match(Ue);var We;!ze&&(We=ne(Z))&&_e.test(We.tagName)&&(ze=We.className.match(Ue)),ze&&(ze=ze[1])}var Ye;if(Be.test(Z.tagName))Ye=1;else{var $e=Z.currentStyle,Ge=De.defaultView,tt=$e?$e.whiteSpace:Ge&&Ge.getComputedStyle?Ge.getComputedStyle(Z,null).getPropertyValue("white-space"):0;Ye=tt&&tt.substring(0,3)==="pre"}var rt=W.linenums;(rt=rt==="true"||+rt)||(rt=ie.match(/\blinenums\b(?::(\d+))?/),rt=rt?rt[1]&&rt[1].length?+rt[1]:!0:!1),rt&&oe(Z,rt,Ye);var st={langExtension:ze,sourceNode:Z,numberLines:rt,pre:Ye,sourceCode:null,basePos:null,spans:null,decorations:null};fe(st)}}}Ne<me.length?M.setTimeout(q,250):typeof le=="function"&&le()}q()}var xe=M.PR={createSimpleLexer:re,registerLangHandler:te,sourceDecorator:be,PR_ATTRIB_NAME:A,PR_ATTRIB_VALUE:I,PR_COMMENT:h,PR_DECLARATION:p,PR_KEYWORD:v,PR_LITERAL:n,PR_NOCODE:U,PR_PLAIN:t,PR_PUNCTUATION:e,PR_SOURCE:x,PR_STRING:d,PR_TAG:f,PR_TYPE:u,prettyPrintOne:S?M.prettyPrintOne=Re:R=Re,prettyPrint:N=S?M.prettyPrint=Le:N=Le},Te=M.define;typeof Te=="function"&&Te.amd&&Te("google-code-prettify",[],function(){return xe})})()},Y1PL:function(Je,Xe,ee){"use strict";ee.r(Xe),ee.d(Xe,"ResizableTextArea",function(){return ne});var de=ee("wx14"),F=ee("1OyB"),S=ee("vuIU"),B=ee("Ji7U"),_=ee("LK+K"),R=ee("q1tI"),N=ee("VTBJ"),M=ee("rePB"),O=ee("Zm9Q"),w=ee("Kwbf"),m=ee("c+Xe"),T=ee("m+aA"),C=ee("bdgK"),b=new Map;function E(se){se.forEach(function(oe){var ue,he=oe.target;(ue=b.get(he))===null||ue===void 0||ue.forEach(function(te){return te(he)})})}var y=new C.default(E),c=null,r=null;function a(se,oe){b.has(se)||(b.set(se,new Set),y.observe(se)),b.get(se).add(oe)}function o(se,oe){b.has(se)&&(b.get(se).delete(oe),b.get(se).size||(y.unobserve(se),b.delete(se)))}var g=function(se){Object(B.a)(ue,se);var oe=Object(_.a)(ue);function ue(){return Object(F.a)(this,ue),oe.apply(this,arguments)}return Object(S.a)(ue,[{key:"render",value:function(){return this.props.children}}]),ue}(R.Component),l=R.createContext(null);function d(se){var oe=se.children,ue=se.onBatchResize,he=R.useRef(0),te=R.useRef([]),Y=R.useContext(l),fe=R.useCallback(function(Re,Le,xe){he.current+=1;var Te=he.current;te.current.push({size:Re,element:Le,data:xe}),Promise.resolve().then(function(){Te===he.current&&(ue==null||ue(te.current),te.current=[])}),Y==null||Y(Re,Le,xe)},[ue,Y]);return R.createElement(l.Provider,{value:fe},oe)}function v(se){var oe=se.children,ue=se.disabled,he=R.useRef(null),te=R.useRef(null),Y=R.useContext(l),fe=R.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Re=R.isValidElement(oe)&&Object(m.c)(oe),Le=Re?oe.ref:null,xe=R.useMemo(function(){return Object(m.a)(Le,he)},[Le,he]),Te=R.useRef(se);Te.current=se;var le=R.useCallback(function(ye){var we=Te.current,De=we.onResize,Se=we.data,pe=ye.getBoundingClientRect(),me=pe.width,Fe=pe.height,Pe=ye.offsetWidth,Me=ye.offsetHeight,Ie=Math.floor(me),Ne=Math.floor(Fe);if(fe.current.width!==Ie||fe.current.height!==Ne||fe.current.offsetWidth!==Pe||fe.current.offsetHeight!==Me){var Ue={width:Ie,height:Ne,offsetWidth:Pe,offsetHeight:Me};fe.current=Ue;var ke=Pe===Math.round(me)?me:Pe,Ae=Me===Math.round(Fe)?Fe:Me,Be=Object(N.a)(Object(N.a)({},Ue),{},{offsetWidth:ke,offsetHeight:Ae});Y==null||Y(Be,ye,Se),De&&Promise.resolve().then(function(){De(Be,ye)})}},[]);return R.useEffect(function(){var ye=Object(T.a)(he.current)||Object(T.a)(te.current);return ye&&!ue&&a(ye,le),function(){return o(ye,le)}},[he.current,ue]),R.createElement(g,{ref:te},Re?R.cloneElement(oe,{ref:xe}):oe)}var h="rc-observer-key";function u(se){var oe=se.children,ue=Object(O.a)(oe);return ue.map(function(he,te){var Y=(he==null?void 0:he.key)||"".concat(h,"-").concat(te);return R.createElement(v,Object(de.a)({},se,{key:Y}),he)})}u.Collection=d;var n=u,e=ee("bT9E"),t=ee("TSYQ"),f=ee.n(t),p=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,x=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],A={},I;function U(se){var oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,ue=se.getAttribute("id")||se.getAttribute("data-reactid")||se.getAttribute("name");if(oe&&A[ue])return A[ue];var he=window.getComputedStyle(se),te=he.getPropertyValue("box-sizing")||he.getPropertyValue("-moz-box-sizing")||he.getPropertyValue("-webkit-box-sizing"),Y=parseFloat(he.getPropertyValue("padding-bottom"))+parseFloat(he.getPropertyValue("padding-top")),fe=parseFloat(he.getPropertyValue("border-bottom-width"))+parseFloat(he.getPropertyValue("border-top-width")),Re=x.map(function(xe){return"".concat(xe,":").concat(he.getPropertyValue(xe))}).join(";"),Le={sizingStyle:Re,paddingSize:Y,borderSize:fe,boxSizing:te};return oe&&ue&&(A[ue]=Le),Le}function j(se){var oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,he=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;I||(I=document.createElement("textarea"),I.setAttribute("tab-index","-1"),I.setAttribute("aria-hidden","true"),document.body.appendChild(I)),se.getAttribute("wrap")?I.setAttribute("wrap",se.getAttribute("wrap")):I.removeAttribute("wrap");var te=U(se,oe),Y=te.paddingSize,fe=te.borderSize,Re=te.boxSizing,Le=te.sizingStyle;I.setAttribute("style","".concat(Le,";").concat(p)),I.value=se.value||se.placeholder||"";var xe=Number.MIN_SAFE_INTEGER,Te=Number.MAX_SAFE_INTEGER,le=I.scrollHeight,ye;if(Re==="border-box"?le+=fe:Re==="content-box"&&(le-=Y),ue!==null||he!==null){I.value=" ";var we=I.scrollHeight-Y;ue!==null&&(xe=we*ue,Re==="border-box"&&(xe=xe+Y+fe),le=Math.max(xe,le)),he!==null&&(Te=we*he,Re==="border-box"&&(Te=Te+Y+fe),ye=le>Te?"":"hidden",le=Math.min(Te,le))}return{height:le,minHeight:xe,maxHeight:Te,overflowY:ye,resize:"none"}}var z=ee("Gytx"),V=ee.n(z),G;(function(se){se[se.NONE=0]="NONE",se[se.RESIZING=1]="RESIZING",se[se.RESIZED=2]="RESIZED"})(G||(G={}));var Q=function(se){Object(B.a)(ue,se);var oe=Object(_.a)(ue);function ue(he){var te;return Object(F.a)(this,ue),te=oe.call(this,he),te.nextFrameActionId=void 0,te.resizeFrameId=void 0,te.textArea=void 0,te.saveTextArea=function(Y){te.textArea=Y},te.handleResize=function(Y){var fe=te.state.resizeStatus,Re=te.props,Le=Re.autoSize,xe=Re.onResize;if(fe!==G.NONE)return;typeof xe=="function"&&xe(Y),Le&&te.resizeOnNextFrame()},te.resizeOnNextFrame=function(){cancelAnimationFrame(te.nextFrameActionId),te.nextFrameActionId=requestAnimationFrame(te.resizeTextarea)},te.resizeTextarea=function(){var Y=te.props.autoSize;if(!Y||!te.textArea)return;var fe=Y.minRows,Re=Y.maxRows,Le=j(te.textArea,!1,fe,Re);te.setState({textareaStyles:Le,resizeStatus:G.RESIZING},function(){cancelAnimationFrame(te.resizeFrameId),te.resizeFrameId=requestAnimationFrame(function(){te.setState({resizeStatus:G.RESIZED},function(){te.resizeFrameId=requestAnimationFrame(function(){te.setState({resizeStatus:G.NONE}),te.fixFirefoxAutoScroll()})})})})},te.renderTextArea=function(){var Y=te.props,fe=Y.prefixCls,Re=fe===void 0?"rc-textarea":fe,Le=Y.autoSize,xe=Y.onResize,Te=Y.className,le=Y.disabled,ye=te.state,we=ye.textareaStyles,De=ye.resizeStatus,Se=Object(e.a)(te.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),pe=f()(Re,Te,Object(M.a)({},"".concat(Re,"-disabled"),le));"value"in Se&&(Se.value=Se.value||"");var me=Object(N.a)(Object(N.a)(Object(N.a)({},te.props.style),we),De===G.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return R.createElement(n,{onResize:te.handleResize,disabled:!(Le||xe)},R.createElement("textarea",Object(de.a)({},Se,{className:pe,style:me,ref:te.saveTextArea})))},te.state={textareaStyles:{},resizeStatus:G.NONE},te}return Object(S.a)(ue,[{key:"componentDidUpdate",value:function(te){(te.value!==this.props.value||!V()(te.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 te=this.textArea.selectionStart,Y=this.textArea.selectionEnd;this.textArea.setSelectionRange(te,Y)}}catch(fe){}}},{key:"render",value:function(){return this.renderTextArea()}}]),ue}(R.Component),ne=Q,re=function(se){Object(B.a)(ue,se);var oe=Object(_.a)(ue);function ue(he){var te;Object(F.a)(this,ue),te=oe.call(this,he),te.resizableTextArea=void 0,te.focus=function(){te.resizableTextArea.textArea.focus()},te.saveTextArea=function(fe){te.resizableTextArea=fe},te.handleChange=function(fe){var Re=te.props.onChange;te.setValue(fe.target.value,function(){te.resizableTextArea.resizeTextarea()}),Re&&Re(fe)},te.handleKeyDown=function(fe){var Re=te.props,Le=Re.onPressEnter,xe=Re.onKeyDown;fe.keyCode===13&&Le&&Le(fe),xe&&xe(fe)};var Y=typeof he.value=="undefined"||he.value===null?he.defaultValue:he.value;return te.state={value:Y},te}return Object(S.a)(ue,[{key:"setValue",value:function(te,Y){"value"in this.props||this.setState({value:te},Y)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return R.createElement(ne,Object(de.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(te){return"value"in te?{value:te.value}:null}}]),ue}(R.Component),be=Xe.default=re},ZW9T:function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return g});var de=ee("k1fw"),F=ee("miYZ"),S=ee("tsqr"),B=ee("rAM+"),_=ee("tJVT"),R=ee("PpiC"),N=ee("q1tI"),M=ee.n(N),O=ee("bdgK");function w(l,d,v,h,u){var n=d.getWordUntilPosition(v),e={startLineNumber:v.lineNumber,endLineNumber:v.lineNumber,startColumn:n.startColumn,endColumn:n.endColumn},t=h.map(function(f){return{label:f,kind:l.languages.CompletionItemKind.Keyword,insertText:f,insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:e}});return u.map(function(f){t.push(Object(de.a)(Object(de.a)({},f),{},{range:e}))}),t}var m=function(l){var d={label:"ifelse",kind:l.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet},v=["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"];l.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(e,t){var f=w(l,e,t,v,[d]);return{suggestions:f}}});var h=["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"];l.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(e,t){var f=[{label:"print",kind:l.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet}],p=w(l,e,t,h,f);return{suggestions:p}}});var u=["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"];l.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(e,t){var f=[d,{label:"main",kind:l.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:l.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
|
|
`),insertTextRules:l.languages.CompletionItemInsertTextRule.InsertAsSnippet}],p=w(l,e,t,u,f);return{suggestions:p}}})},T="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",C=ee("LvDl");function b(l){return/^\d+$/.test(l)?"".concat(l,"px"):l}function E(){}var y=!1,c={"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 r(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],d=l;if(Array.isArray(l)){for(var v=0;v<l.length;v++){var h=c[l[v]];if(h)return h}return d[0]}return c[d]||d}var a=null,o=Xe.b=function(l){var d=l.width,v=d===void 0?"100%":d,h=l.height,u=h===void 0?"100%":h,n=l.value,e=l.language,t=e===void 0?"javascript":e,f=l.style,p=f===void 0?{}:f,x=l.options,A=x===void 0?{}:x,I=l.overrideServices,U=I===void 0?{}:I,j=l.theme,z=j===void 0?"vs-dark":j,V=l.onEditBlur,G=l.onSave,Q=l.autoHeight,ne=Q===void 0?!1:Q,re=l.forbidCopy,be=re===void 0?!1:re,se=l.onChange,oe=se===void 0?E:se,ue=l.editorDidMount,he=ue===void 0?E:ue,te=l.onFocus,Y=te===void 0?E:te,fe=l.filename,Re=fe===void 0?"educoder.txt":fe,Le=Object(R.a)(l,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),xe=Object(N.useRef)(),Te=Object(N.useRef)({}),le=Object(N.useRef)(),ye=Object(N.useRef)(!1),we=Object(N.useRef)(),De=Object(N.useState)(!1),Se=Object(_.a)(De,2),pe=Se[0],me=Se[1];function Fe(){var K;return xe.current&&(K=new O.default(function(X){var ie=Object(B.a)(X),ae;try{for(ie.s();!(ae=ie.n()).done;){var ge=ae.value;(ge.target.offsetHeight>0||ge.target.offsetWidth>0)&&Te.current.instance.layout()}}catch(je){ie.e(je)}finally{ie.f()}}),K.observe(xe.current)),K}function Pe(){S.b.warn(decodeURIComponent(T))}var Me=function(){var X=Te.current.instance;if(n!=null&&X&&pe){var ie=X.getModel();ie&&n!==ie.getValue()&&(y=!0,ie.setValue(n),X.layout(),y=!1)}};Object(N.useEffect)(function(){le.current&&clearTimeout(le.current),le.current=setTimeout(function(){Me()},500)},[n,pe,Te.current]);function Ie(){var K=Te.current.instance;if(K){var X=K.getSelection(),ie=Te.current.pastePos||{},ae=new a.Range(ie.startLineNumber||X.endLineNumber,ie.startColumn||X.endColumn,ie.endLineNumber||X.endLineNumber,ie.endColumn||X.endColumn);setTimeout(function(){K.executeEdits("",[{range:ae,text:""}])},300)}}function Ne(K){(window.navigator.platform.match("Mac")?K.metaKey:K.ctrlKey)&&K.keyCode==83&&(K.preventDefault(),G())}var Ue=function(){if(ne&&Te.current.instance){var X=Te.current.instance.getContentHeight();W(X<u?u:X)}else W(u)};function ke(K){var X=document.createEvent("MouseEvents");X.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),K.dispatchEvent(X)}function Ae(K,X){var ie=window.URL||window.webkitURL||window,ae=new Blob([X]),ge=document.createElementNS("http://www.w3.org/1999/xhtml","a");ge.href=ie.createObjectURL(ae),ge.download=K,ke(ge)}Object(N.useEffect)(function(){Ue()},[Ue]),Object(N.useEffect)(function(){xe.current&&!pe&&ee.e(27).then(ee.t.bind(null,"M/lh",7)).then(function(K){try{a=K,Te.current.instance=a.editor.create(xe.current,{value:n,language:r(t),theme:z,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},U);var X=Te.current.instance;if(he(X,a),setTimeout(function(){Ue(),Te.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){Ae(Re||"educoder.txt",X.getValue())}})},500),Te.current.subscription=X.onDidChangeModelContent(function(ae){ye.current?clearTimeout(we.current):(Ue(),oe(X.getValue(),ae)),we.current=setTimeout(function(){ye.current=!1},500)}),window.Monaco||m(a),be&&(X.addCommand(a.KeyMod.CtrlCmd|a.KeyMod.Shift|a.KeyCode.KEY_V,function(){return Pe(),null}),X.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KEY_C,function(){return Pe(),null})),window.Monaco=a,V&&X.onDidBlurEditorWidget(function(){V(X.getValue())}),Y&&X.onDidFocusEditorText(function(){Y(X.getValue())}),be){X.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KEY_V,function(){return Pe(),null}),X.onDidPaste(function(ae){Te.current.pastePos=ae});try{window.addEventListener("paste",Ie)}catch(ae){}}var ie=Fe();return me(!0),function(){var ae=Te.current.instance;ae.dispose();var ge=ae.getModel();ge&&ge.dispose(),Te.current.subscription&&Te.current.subscription.dispose(),be&&window.removeEventListener("paste",Ie),ie.unobserve(xe.current)}}catch(ae){}})},[]),Object(N.useEffect)(function(){var K=Te.current.instance;if(K&&pe)return document.addEventListener("keydown",Ne,!1),function(){document.removeEventListener("keydown",Ne)}},[G,pe]),Object(N.useEffect)(function(){var K=Te.current.instance;if(K&&pe){var X=r(t);a.editor.setModelLanguage(K.getModel(),X),console.log("language:",t,K.getModel(),X)}},[t,pe]),Object(N.useEffect)(function(){var K=Te.current.instance;K&&pe&&a.editor.setTheme(z)},[z,pe]),Object(N.useEffect)(function(){var K=Te.current.instance;K&&pe&&(K.updateOptions(Object(de.a)({},A)),setTimeout(function(){K.getModel().updateOptions(Object(de.a)({},A))},200))},[JSON.stringify(A),pe]),Object(N.useEffect)(function(){var K=Te.current.instance;K&&pe&&K.layout()},[v,u,pe]);var Be=Object(N.useState)(b(v)),_e=Object(_.a)(Be,2),ce=_e[0],Ce=_e[1],q=Object(N.useState)(b(u)),J=Object(_.a)(q,2),Z=J[0],W=J[1],H=Object(de.a)(Object(de.a)({},p),{},{width:ce,height:Z});return M.a.createElement("div",{className:"my-monaco-editor",ref:xe,style:H})};function g(l){var d=l.width,v=d===void 0?"100%":d,h=l.height,u=h===void 0?"100%":h,n=l.original,e=l.modified,t=l.language,f=l.options,p=f===void 0?{}:f,x=Object(N.useRef)(),A=Object(N.useState)(null),I=Object(_.a)(A,2),U=I[0],j=I[1];function z(ne){var re;return x.current&&(re=new O.default(function(be){var se=Object(B.a)(be),oe;try{for(se.s();!(oe=se.n()).done;){var ue=oe.value;(ue.target.offsetHeight>0||ue.target.offsetWidth>0)&&ne.layout()}}catch(he){se.e(he)}finally{se.f()}}),re.observe(x.current)),re}Object(N.useEffect)(function(){x.current&&ee.e(27).then(ee.t.bind(null,"M/lh",7)).then(function(ne){a=ne;var re=a.editor.createDiffEditor(x.current,Object(de.a)(Object(de.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},p),{},{wordWrap:!0}));j(re);var be=z(re);return function(){re.dispose();var se=re.getModel();se&&se.dispose(),be.unobserve(x.current)}})},[]),Object(N.useEffect)(function(){U&&U.setModel({original:a.editor.createModel(n,t),modified:a.editor.createModel(e,t)})},[n,e,t,U]);var V=b(v),G=b(u),Q={width:V,height:G};return M.a.createElement("div",{className:"my-diff-editor",ref:x,style:Q})}},ZpRC:function(Je,Xe,ee){"use strict";function de(m){return typeof m=="object"&&m!=null&&m.nodeType===1}function F(m,T){return(!T||m!=="hidden")&&m!=="visible"&&m!=="clip"}function S(m,T){if(m.clientHeight<m.scrollHeight||m.clientWidth<m.scrollWidth){var C=getComputedStyle(m,null);return F(C.overflowY,T)||F(C.overflowX,T)||function(b){var E=function(y){if(!y.ownerDocument||!y.ownerDocument.defaultView)return null;try{return y.ownerDocument.defaultView.frameElement}catch(c){return null}}(b);return!!E&&(E.clientHeight<b.scrollHeight||E.clientWidth<b.scrollWidth)}(m)}return!1}function B(m,T,C,b,E,y,c,r){return y<m&&c>T||y>m&&c<T?0:y<=m&&r<=C||c>=T&&r>=C?y-m-b:c>T&&r<C||y<m&&r>C?c-T+E:0}var _=function(m,T){var C=window,b=T.scrollMode,E=T.block,y=T.inline,c=T.boundary,r=T.skipOverflowHiddenElements,a=typeof c=="function"?c:function(we){return we!==c};if(!de(m))throw new TypeError("Invalid target");for(var o=document.scrollingElement||document.documentElement,g=[],l=m;de(l)&&a(l);){if((l=l.parentElement)===o){g.push(l);break}l!=null&&l===document.body&&S(l)&&!S(document.documentElement)||l!=null&&S(l,r)&&g.push(l)}for(var d=C.visualViewport?C.visualViewport.width:innerWidth,v=C.visualViewport?C.visualViewport.height:innerHeight,h=window.scrollX||pageXOffset,u=window.scrollY||pageYOffset,n=m.getBoundingClientRect(),e=n.height,t=n.width,f=n.top,p=n.right,x=n.bottom,A=n.left,I=E==="start"||E==="nearest"?f:E==="end"?x:f+e/2,U=y==="center"?A+t/2:y==="end"?p:A,j=[],z=0;z<g.length;z++){var V=g[z],G=V.getBoundingClientRect(),Q=G.height,ne=G.width,re=G.top,be=G.right,se=G.bottom,oe=G.left;if(b==="if-needed"&&f>=0&&A>=0&&x<=v&&p<=d&&f>=re&&x<=se&&A>=oe&&p<=be)return j;var ue=getComputedStyle(V),he=parseInt(ue.borderLeftWidth,10),te=parseInt(ue.borderTopWidth,10),Y=parseInt(ue.borderRightWidth,10),fe=parseInt(ue.borderBottomWidth,10),Re=0,Le=0,xe="offsetWidth"in V?V.offsetWidth-V.clientWidth-he-Y:0,Te="offsetHeight"in V?V.offsetHeight-V.clientHeight-te-fe:0;if(o===V)Re=E==="start"?I:E==="end"?I-v:E==="nearest"?B(u,u+v,v,te,fe,u+I,u+I+e,e):I-v/2,Le=y==="start"?U:y==="center"?U-d/2:y==="end"?U-d:B(h,h+d,d,he,Y,h+U,h+U+t,t),Re=Math.max(0,Re+u),Le=Math.max(0,Le+h);else{Re=E==="start"?I-re-te:E==="end"?I-se+fe+Te:E==="nearest"?B(re,se,Q,te,fe+Te,I,I+e,e):I-(re+Q/2)+Te/2,Le=y==="start"?U-oe-he:y==="center"?U-(oe+ne/2)+xe/2:y==="end"?U-be+Y+xe:B(oe,be,ne,he,Y+xe,U,U+t,t);var le=V.scrollLeft,ye=V.scrollTop;I+=ye-(Re=Math.max(0,Math.min(ye+Re,V.scrollHeight-Q+Te))),U+=le-(Le=Math.max(0,Math.min(le+Le,V.scrollWidth-ne+xe)))}j.push({el:V,top:Re,left:Le})}return j};function R(m){return m===Object(m)&&Object.keys(m).length!==0}function N(m,T){T===void 0&&(T="auto");var C="scrollBehavior"in document.body.style;m.forEach(function(b){var E=b.el,y=b.top,c=b.left;E.scroll&&C?E.scroll({top:y,left:c,behavior:T}):(E.scrollTop=y,E.scrollLeft=c)})}function M(m){return m===!1?{block:"end",inline:"nearest"}:R(m)?m:{block:"start",inline:"nearest"}}function O(m,T){var C=!m.ownerDocument.documentElement.contains(m);if(R(T)&&typeof T.behavior=="function")return T.behavior(C?[]:_(m,T));if(C)return;var b=M(T);return N(_(m,b),b.behavior)}var w=Xe.a=O},bT9E:function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return F});var de=ee("VTBJ");function F(S,B){var _=Object(de.a)({},S);return Array.isArray(B)&&B.forEach(function(R){delete _[R]}),_}},kzJb:function(Je,Xe,ee){Je.exports={flex_box_center:"flex_box_center___2qtoc",flex_space_between:"flex_space_between___NF1Yf",flex_box_vertical_center:"flex_box_vertical_center___2qH_j",flex_box_center_end:"flex_box_center_end___22P0N",flex_box_column:"flex_box_column___1IKP8",userInfo:"userInfo___2Dupy",navInfo:"navInfo___3fEvD",actived:"actived___3F322",newTip:"newTip___1Ta-b"}},p5ED:function(Je,Xe,ee){"use strict";var de=ee("+L6B"),F=ee("2/Rp"),S=ee("5Dmo"),B=ee("3S7+"),_=ee("k1fw"),R=ee("9og8"),N=ee("tJVT"),M=ee("WmNS"),O=ee.n(M),w=ee("q1tI"),m=ee.n(w),T=ee("vHTk"),C=ee.n(T),b=ee("yEEn"),E=ee("ZW9T"),y=ee("1vsH"),c=ee("V0Rq"),r=ee("m3rI"),a=function(g){var l=g.name,d=g.data,v=g.theme,h=g.type,u=g.filename,n=g.monacoEditor,e=g.className,t=g.style,f=g.close,p=g.onClose,x=g.hasMask,A=g.otherData,I=A===void 0?{}:A,U=Object(w.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),j=Object(N.a)(U,2),z=j[0],V=j[1],G=Object(w.useState)(""),Q=Object(N.a)(G,2),ne=Q[0],re=Q[1],be=Object(w.useState)(),se=Object(N.a)(be,2),oe=se[0],ue=se[1],he=window.ENV==="build"?"/react/build/office.html":"/office.html",te,Y=1024*1024,fe=10*Y,Re=Object(w.useRef)();h==="office"&&(te=Object(y.R)(d).filesize,te>fe&&(h="other")),u&&(n.filename=u),Object(w.useEffect)(function(){var le,ye,we=(le=document.cookie)===null||le===void 0||((ye=le.replace(/\s/g,""))===null||ye===void 0)?void 0:ye.split(";");we==null||we.map(function(De){var Se=De.split("=");Se[0]==="_educoder_session"&&re(Se[1])})},[]),Object(w.useEffect)(function(){h==="office"&&Le()},[h]);var Le=function(){var le=Object(R.a)(O.a.mark(function ye(){var we,De,Se;return O.a.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:return console.log("data:",d),we=d,d.startsWith("http")||(we=location.origin+we),De=new URL(we).pathname.split("/").pop(),me.next=6,Object(c.U)({attachment_id:De});case 6:Se=me.sent,ue(Se);case 8:case"end":return me.stop()}},ye)}));return function(){return le.apply(this,arguments)}}(),xe=function(){if(d.startsWith("http")||d.startsWith("/api")||d.startsWith("blob:")){Te();return}Object(y.x)(u||"educoder",d,u||"educoder")},Te=function(){Object(y.v)(u||"educoder",decodeURIComponent(d))};return m.a.createElement("div",{style:Object(_.a)({},t||{}),className:"".concat(x&&C.a.bgBlack," ").concat(h?C.a.wrp:"hide")},f&&m.a.createElement("div",{className:C.a.close,ref:Re},m.a.createElement(B.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Re.current}},m.a.createElement("span",{onClick:Te},m.a.createElement("i",{className:"icon-quxiaozhiding"}))),m.a.createElement(B.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Re.current}},m.a.createElement("span",{className:"",onClick:function(){p(),ue(null)}},m.a.createElement("i",{className:"icon-guanbi1"})))),m.a.createElement("div",{className:"".concat(C.a[e]," ").concat(e," ").concat(C.a.monaco," ").concat(h==="txt"?"show":"hide")},h==="txt"&&m.a.createElement(E.b,n)),h==="audio"&&m.a.createElement("audio",{src:"".concat((d==null?void 0:d.indexOf("http://"))>-1||(d==null?void 0:d.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(d),autoPlay:!0}),h==="video"&&m.a.createElement(m.a.Fragment,null,(d==null?void 0:d.indexOf("/api"))>-1?m.a.createElement("video",{controls:!0,src:"".concat(d),autoPlay:!0}):m.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(d),autoPlay:!0})),h==="office"&&oe&&m.a.createElement("iframe",{src:"".concat(he,"?key=").concat(oe.key,"&url=").concat(r.a.API_SERVER+oe.url,"&callbackUrl=").concat(r.a.API_SERVER+oe.callbackUrl,"&fileType=").concat(oe.fileType,"&title=").concat(oe.title,"&model=view")}),(h==="xlsx"||h==="doc"||h==="pptx"||h==="docx")&&m.a.createElement("iframe",{src:"".concat(he,"?key=").concat(I.key,"&url=").concat(r.a.API_SERVER+I.url,"&callbackUrl=").concat(r.a.API_SERVER+I.callbackUrl,"&fileType=").concat(I.fileType,"&title=").concat(I.title,"&model=").concat(I.model)}),h==="html"&&m.a.createElement("iframe",{src:d+"&disposition=inline"}),h==="pdf"&&m.a.createElement("embed",{className:C.a.embed,src:d,type:"application/pdf"}),h==="image"&&m.a.createElement("img",{src:"".concat((d==null?void 0:d.indexOf("http://"))>-1||(d==null?void 0:d.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(d)}),h==="other"&&m.a.createElement("div",null,m.a.createElement(F.a,{type:"primary",size:"large",onClick:xe},m.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),h==="download"&&m.a.createElement(F.a,{type:"primary",size:"large",onClick:xe},m.a.createElement(b.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))};Xe.a=a},"rAM+":function(Je,Xe,ee){"use strict";ee.d(Xe,"a",function(){return F});var de=ee("Qw5x");function F(S,B){var _;if(typeof Symbol=="undefined"||S[Symbol.iterator]==null){if(Array.isArray(S)||(_=Object(de.a)(S))||B&&S&&typeof S.length=="number"){_&&(S=_);var R=0,N=function(){};return{s:N,n:function(){return R>=S.length?{done:!0}:{done:!1,value:S[R++]}},e:function(T){throw T},f:N}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var M=!0,O=!1,w;return{s:function(){_=S[Symbol.iterator]()},n:function(){var T=_.next();return M=T.done,T},e:function(T){O=!0,w=T},f:function(){try{!M&&_.return!=null&&_.return()}finally{if(O)throw w}}}}},rUJ1:function(Je,Xe){const ee=/[&<>"']/,de=/[&<>"']/g,F=/[<>"']|&(?!#?\w+;)/,S=/[<>"']|&(?!#?\w+;)/g,B={"&":"&","<":"<",">":">",'"':""","'":"'"},_=h=>B[h];function R(h,u){if(u){if(ee.test(h))return h.replace(de,_)}else if(F.test(h))return h.replace(S,_);return h}const N=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function M(h){return h.replace(N,(u,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const O=/(^|[^\[])\^/g;function w(h,u){h=h.source||h,u=u||"";const n={replace:(e,t)=>(t=t.source||t,t=t.replace(O,"$1"),h=h.replace(e,t),n),getRegex:()=>new RegExp(h,u)};return n}const m=/[^\w:]/g,T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function C(h,u,n){if(h){let e;try{e=decodeURIComponent(M(n)).replace(m,"").toLowerCase()}catch(t){return null}if(e.indexOf("javascript:")===0||e.indexOf("vbscript:")===0||e.indexOf("data:")===0)return null}u&&!T.test(n)&&(n=r(u,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}const b={},E=/^[^:]+:\/*[^/]*$/,y=/^([^:]+:)[\s\S]*$/,c=/^([^:]+:\/*[^/]*)[\s\S]*$/;function r(h,u){b[" "+h]||(E.test(h)?b[" "+h]=h+"/":b[" "+h]=l(h,"/",!0)),h=b[" "+h];const n=h.indexOf(":")===-1;return u.substring(0,2)==="//"?n?u:h.replace(y,"$1")+u:u.charAt(0)==="/"?n?u:h.replace(c,"$1")+u:h+u}const a={exec:function(){}};function o(h){let u=1,n,e;for(;u<arguments.length;u++){n=arguments[u];for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&(h[e]=n[e])}return h}function g(h,u){const n=h.replace(/\|/g,(f,p,x)=>{let A=!1,I=p;for(;--I>=0&&x[I]==="\\";)A=!A;return A?"|":" |"}),e=n.split(/ \|/);let t=0;if(e.length>u)e.splice(u);else for(;e.length<u;)e.push("");for(;t<e.length;t++)e[t]=e[t].trim().replace(/\\\|/g,"|");return e}function l(h,u,n){const e=h.length;if(e===0)return"";let t=0;for(;t<e;){const f=h.charAt(e-t-1);if(f===u&&!n)t++;else if(f!==u&&n)t++;else break}return h.substr(0,e-t)}function d(h,u){if(h.indexOf(u[1])===-1)return-1;const n=h.length;let e=0,t=0;for(;t<n;t++)if(h[t]==="\\")t++;else if(h[t]===u[0])e++;else if(h[t]===u[1]&&(e--,e<0))return t;return-1}function v(h){h&&h.sanitize&&!h.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")}Je.exports={escape:R,unescape:M,edit:w,cleanUrl:C,resolveUrl:r,noopTest:a,merge:o,splitCells:g,rtrim:l,findClosingBracket:d,checkSanitizeDeprecation:v}},ulZh:function(Je,Xe,ee){typeof window!="undefined"&&function(F,S){Je.exports=S()}(this,function(){return function(de){var F={};function S(B){if(F[B])return F[B].exports;var _=F[B]={i:B,l:!1,exports:{}};return de[B].call(_.exports,_,_.exports,S),_.l=!0,_.exports}return S.m=de,S.c=F,S.d=function(B,_,R){S.o(B,_)||Object.defineProperty(B,_,{enumerable:!0,get:R})},S.r=function(B){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(B,"__esModule",{value:!0})},S.t=function(B,_){if(_&1&&(B=S(B)),_&8)return B;if(_&4&&typeof B=="object"&&B&&B.__esModule)return B;var R=Object.create(null);if(S.r(R),Object.defineProperty(R,"default",{enumerable:!0,value:B}),_&2&&typeof B!="string")for(var N in B)S.d(R,N,function(M){return B[M]}.bind(null,N));return R},S.n=function(B){var _=B&&B.__esModule?function(){return B.default}:function(){return B};return S.d(_,"a",_),_},S.o=function(B,_){return Object.prototype.hasOwnProperty.call(B,_)},S.p="/dist/",S(S.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(de,F,S){"use strict";var B=Object.prototype.hasOwnProperty,_="~";function R(){}Object.create&&(R.prototype=Object.create(null),new R().__proto__||(_=!1));function N(m,T,C){this.fn=m,this.context=T,this.once=C||!1}function M(m,T,C,b,E){if(typeof C!="function")throw new TypeError("The listener must be a function");var y=new N(C,b||m,E),c=_?_+T:T;return m._events[c]?m._events[c].fn?m._events[c]=[m._events[c],y]:m._events[c].push(y):(m._events[c]=y,m._eventsCount++),m}function O(m,T){--m._eventsCount===0?m._events=new R:delete m._events[T]}function w(){this._events=new R,this._eventsCount=0}w.prototype.eventNames=function(){var T=[],C,b;if(this._eventsCount===0)return T;for(b in C=this._events)B.call(C,b)&&T.push(_?b.slice(1):b);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(C)):T},w.prototype.listeners=function(T){var C=_?_+T:T,b=this._events[C];if(!b)return[];if(b.fn)return[b.fn];for(var E=0,y=b.length,c=new Array(y);E<y;E++)c[E]=b[E].fn;return c},w.prototype.listenerCount=function(T){var C=_?_+T:T,b=this._events[C];return b?b.fn?1:b.length:0},w.prototype.emit=function(T,C,b,E,y,c){var r=_?_+T:T;if(!this._events[r])return!1;var a=this._events[r],o=arguments.length,g,l;if(a.fn){a.once&&this.removeListener(T,a.fn,void 0,!0);switch(o){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,C),!0;case 3:return a.fn.call(a.context,C,b),!0;case 4:return a.fn.call(a.context,C,b,E),!0;case 5:return a.fn.call(a.context,C,b,E,y),!0;case 6:return a.fn.call(a.context,C,b,E,y,c),!0}for(l=1,g=new Array(o-1);l<o;l++)g[l-1]=arguments[l];a.fn.apply(a.context,g)}else{var d=a.length,v;for(l=0;l<d;l++){a[l].once&&this.removeListener(T,a[l].fn,void 0,!0);switch(o){case 1:a[l].fn.call(a[l].context);break;case 2:a[l].fn.call(a[l].context,C);break;case 3:a[l].fn.call(a[l].context,C,b);break;case 4:a[l].fn.call(a[l].context,C,b,E);break;default:if(!g)for(v=1,g=new Array(o-1);v<o;v++)g[v-1]=arguments[v];a[l].fn.apply(a[l].context,g)}}}return!0},w.prototype.on=function(T,C,b){return M(this,T,C,b,!1)},w.prototype.once=function(T,C,b){return M(this,T,C,b,!0)},w.prototype.removeListener=function(T,C,b,E){var y=_?_+T:T;if(!this._events[y])return this;if(!C)return O(this,y),this;var c=this._events[y];if(c.fn)c.fn===C&&(!E||c.once)&&(!b||c.context===b)&&O(this,y);else{for(var r=0,a=[],o=c.length;r<o;r++)(c[r].fn!==C||E&&!c[r].once||b&&c[r].context!==b)&&a.push(c[r]);a.length?this._events[y]=a.length===1?a[0]:a:O(this,y)}return this},w.prototype.removeAllListeners=function(T){var C;return T?(C=_?_+T:T,this._events[C]&&O(this,C)):(this._events=new R,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=_,w.EventEmitter=w,de.exports=w},"./node_modules/url-toolkit/src/url-toolkit.js":function(de,F,S){(function(B){var _=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,R=/^([^\/?#]*)([^]*)$/,N=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(w,m,T){if(T=T||{},w=w.trim(),m=m.trim(),!m){if(!T.alwaysNormalize)return w;var C=O.parseURL(w);if(!C)throw new Error("Error trying to parse base URL.");return C.path=O.normalizePath(C.path),O.buildURLFromParts(C)}var b=O.parseURL(m);if(!b)throw new Error("Error trying to parse relative URL.");if(b.scheme)return T.alwaysNormalize?(b.path=O.normalizePath(b.path),O.buildURLFromParts(b)):m;var E=O.parseURL(w);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var y=R.exec(E.path);E.netLoc=y[1],E.path=y[2]}E.netLoc&&!E.path&&(E.path="/");var c={scheme:E.scheme,netLoc:b.netLoc,path:null,params:b.params,query:b.query,fragment:b.fragment};if(!b.netLoc&&(c.netLoc=E.netLoc,b.path[0]!=="/"))if(!b.path)c.path=E.path,b.params||(c.params=E.params,b.query||(c.query=E.query));else{var r=E.path,a=r.substring(0,r.lastIndexOf("/")+1)+b.path;c.path=O.normalizePath(a)}return c.path===null&&(c.path=T.alwaysNormalize?O.normalizePath(b.path):b.path),O.buildURLFromParts(c)},parseURL:function(w){var m=_.exec(w);return m?{scheme:m[1]||"",netLoc:m[2]||"",path:m[3]||"",params:m[4]||"",query:m[5]||"",fragment:m[6]||""}:null},normalizePath:function(w){for(w=w.split("").reverse().join("").replace(N,"");w.length!==(w=w.replace(M,"")).length;);return w.split("").reverse().join("")},buildURLFromParts:function(w){return w.scheme+w.netLoc+w.path+w.params+w.query+w.fragment}};de.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(de,F,S){function B(T){var C={};function b(y){if(C[y])return C[y].exports;var c=C[y]={i:y,l:!1,exports:{}};return T[y].call(c.exports,c,c.exports,b),c.l=!0,c.exports}b.m=T,b.c=C,b.i=function(y){return y},b.d=function(y,c,r){b.o(y,c)||Object.defineProperty(y,c,{configurable:!1,enumerable:!0,get:r})},b.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},b.n=function(y){var c=y&&y.__esModule?function(){return y.default}:function(){return y};return b.d(c,"a",c),c},b.o=function(y,c){return Object.prototype.hasOwnProperty.call(y,c)},b.p="/",b.oe=function(y){throw console.error(y),y};var E=b(b.s=ENTRY_MODULE);return E.default||E}var _="[\\.|\\-|\\+|\\w|/|@]+",R="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+_+").*?\\)";function N(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function M(T){return!isNaN(1*T)}function O(T,C,b){var E={};E[b]=[];var y=C.toString(),c=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!c)return E;for(var r=c[1],a=new RegExp("(\\\\n|\\W)"+N(r)+R,"g"),o;o=a.exec(y);){if(o[3]==="dll-reference")continue;E[b].push(o[3])}for(a=new RegExp("\\("+N(r)+'\\("(dll-reference\\s('+_+'))"\\)\\)'+R,"g");o=a.exec(y);)T[o[2]]||(E[b].push(o[1]),T[o[2]]=S(o[1]).m),E[o[2]]=E[o[2]]||[],E[o[2]].push(o[4]);for(var g=Object.keys(E),l=0;l<g.length;l++)for(var d=0;d<E[g[l]].length;d++)M(E[g[l]][d])&&(E[g[l]][d]=1*E[g[l]][d]);return E}function w(T){var C=Object.keys(T);return C.reduce(function(b,E){return b||T[E].length>0},!1)}function m(T,C){for(var b={main:[C]},E={main:[]},y={main:{}};w(b);)for(var c=Object.keys(b),r=0;r<c.length;r++){var a=c[r],o=b[a],g=o.pop();if(y[a]=y[a]||{},y[a][g]||!T[a][g])continue;y[a][g]=!0,E[a]=E[a]||[],E[a].push(g);for(var l=O(T,T[a][g],a),d=Object.keys(l),v=0;v<d.length;v++)b[d[v]]=b[d[v]]||[],b[d[v]]=b[d[v]].concat(l[d[v]])}return E}de.exports=function(T,C){C=C||{};var b={main:S.m},E=C.all?{main:Object.keys(b.main)}:m(b,T),y="";Object.keys(E).filter(function(g){return g!=="main"}).forEach(function(g){for(var l=0;E[g][l];)l++;E[g].push(l),b[g][l]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+g+" = ("+B.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+E[g].map(function(d){return""+JSON.stringify(d)+": "+b[g][d].toString()}).join(",")+`});
|
|
`}),y=y+"new (("+B.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+E.main.map(function(g){return""+JSON.stringify(g)+": "+b.main[g].toString()}).join(",")+"}))(self);";var c=new window.Blob([y],{type:"text/javascript"});if(C.bare)return c;var r=window.URL||window.webkitURL||window.mozURL||window.msURL,a=r.createObjectURL(c),o=new window.Worker(a);return o.objectURL=a,o}},"./src/config.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"hlsDefaultConfig",function(){return v}),S.d(F,"mergeConfig",function(){return u}),S.d(F,"enableStreamingMode",function(){return n});var B=S("./src/controller/abr-controller.ts"),_=S("./src/controller/audio-stream-controller.ts"),R=S("./src/controller/audio-track-controller.ts"),N=S("./src/controller/subtitle-stream-controller.ts"),M=S("./src/controller/subtitle-track-controller.ts"),O=S("./src/controller/buffer-controller.ts"),w=S("./src/controller/timeline-controller.ts"),m=S("./src/controller/cap-level-controller.ts"),T=S("./src/controller/fps-controller.ts"),C=S("./src/controller/eme-controller.ts"),b=S("./src/controller/cmcd-controller.ts"),E=S("./src/utils/xhr-loader.ts"),y=S("./src/utils/fetch-loader.ts"),c=S("./src/utils/cues.ts"),r=S("./src/utils/mediakeys-helper.ts"),a=S("./src/utils/logger.ts");function o(){return o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var f=arguments[t];for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(e[p]=f[p])}return e},o.apply(this,arguments)}function g(e,t){var f=Object.keys(e);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);t&&(p=p.filter(function(x){return Object.getOwnPropertyDescriptor(e,x).enumerable})),f.push.apply(f,p)}return f}function l(e){for(var t=1;t<arguments.length;t++){var f=arguments[t]!=null?arguments[t]:{};t%2?g(Object(f),!0).forEach(function(p){d(e,p,f[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(f)):g(Object(f)).forEach(function(p){Object.defineProperty(e,p,Object.getOwnPropertyDescriptor(f,p))})}return e}function d(e,t,f){return t in e?Object.defineProperty(e,t,{value:f,enumerable:!0,configurable:!0,writable:!0}):e[t]=f,e}var v=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:B.default,bufferController:O.default,capLevelController:m.default,fpsController:T.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:r.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},h()),{},{subtitleStreamController:N.SubtitleStreamController,subtitleTrackController:M.default,timelineController:w.TimelineController,audioStreamController:_.default,audioTrackController:R.default,emeController:C.default,cmcdController:b.default});function h(){return{cueHandler:c.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function u(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return o({},e,t)}function n(e){var t=e.loader;if(t!==y.default&&t!==E.default)a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{var f=Object(y.fetchSupported)();f&&(e.loader=y.default,e.progressive=!0,e.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/polyfills/number.ts"),_=S("./src/utils/ewma-bandwidth-estimator.ts"),R=S("./src/events.ts"),N=S("./src/utils/buffer-helper.ts"),M=S("./src/errors.ts"),O=S("./src/types/loader.ts"),w=S("./src/utils/logger.ts");function m(b,E){for(var y=0;y<E.length;y++){var c=E[y];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(b,c.key,c)}}function T(b,E,y){return E&&m(b.prototype,E),y&&m(b,y),b}var C=function(){function b(y){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=y;var c=y.config;this.bwEstimator=new _.default(c.abrEwmaSlowVoD,c.abrEwmaFastVoD,c.abrEwmaDefaultEstimate),this.registerListeners()}var E=b.prototype;return E.registerListeners=function(){var c=this.hls;c.on(R.Events.FRAG_LOADING,this.onFragLoading,this),c.on(R.Events.FRAG_LOADED,this.onFragLoaded,this),c.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),c.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(R.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var c=this.hls;c.off(R.Events.FRAG_LOADING,this.onFragLoading,this),c.off(R.Events.FRAG_LOADED,this.onFragLoaded,this),c.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),c.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(R.Events.ERROR,this.onError,this)},E.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},E.onFragLoading=function(c,r){var a=r.frag;if(a.type===O.PlaylistLevelType.MAIN&&!this.timer){var o;this.fragCurrent=a,this.partCurrent=(o=r.part)!=null?o:null,this.timer=self.setInterval(this.onCheck,100)}},E.onLevelLoaded=function(c,r){var a=this.hls.config;r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},E._abandonRulesCheck=function(){var c=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.autoLevelEnabled,g=a.config,l=a.media;if(!c||!l)return;var d=r?r.stats:c.stats,v=r?r.duration:c.duration;if(d.aborted){w.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!o||l.paused||!l.playbackRate||!l.readyState)return;var h=performance.now()-d.loading.start,u=Math.abs(l.playbackRate);if(h<=500*v/u)return;var n=a.levels,e=a.minAutoLevel,t=n[c.level],f=d.total||Math.max(d.loaded,Math.round(v*t.maxBitrate/8)),p=Math.max(1,d.bwEstimate?d.bwEstimate/8:d.loaded*1e3/h),x=(f-d.loaded)/p,A=l.currentTime,I=(N.BufferHelper.bufferInfo(l,A,g.maxBufferHole).end-A)/u;if(I>=2*v/u||x<=I)return;var U=Number.POSITIVE_INFINITY,j;for(j=c.level-1;j>e;j--){var z=n[j].maxBitrate;if(U=v*z/(8*.8*p),U<I)break}if(U>=x)return;var V=this.bwEstimator.getEstimate();w.logger.warn("Fragment "+c.sn+(r?" part "+r.index:"")+" of level "+c.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+j+`
|
|
Current BW estimate: `+(Object(B.isFiniteNumber)(V)?(V/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+U.toFixed(3)+` s
|
|
Time to underbuffer: `+I.toFixed(3)+" s"),a.nextLoadLevel=j,this.bwEstimator.sample(h,d.loaded),this.clearTimer(),c.loader&&(this.fragCurrent=this.partCurrent=null,c.loader.abort()),a.trigger(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:c,part:r,stats:d})},E.onFragLoaded=function(c,r){var a=r.frag,o=r.part;if(a.type===O.PlaylistLevelType.MAIN&&Object(B.isFiniteNumber)(a.sn)){var g=o?o.stats:a.stats,l=o?o.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var d=this.hls.levels[a.level],v=(d.loaded?d.loaded.bytes:0)+g.loaded,h=(d.loaded?d.loaded.duration:0)+l;d.loaded={bytes:v,duration:h},d.realBitrate=Math.round(8*v/h)}if(a.bitrateTest){var u={stats:g,frag:a,part:o,id:a.type};this.onFragBuffered(R.Events.FRAG_BUFFERED,u),a.bitrateTest=!1}}},E.onFragBuffered=function(c,r){var a=r.frag,o=r.part,g=o?o.stats:a.stats;if(g.aborted)return;if(a.type!==O.PlaylistLevelType.MAIN||a.sn==="initSegment")return;var l=g.parsing.end-g.loading.start;this.bwEstimator.sample(l,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0},E.onError=function(c,r){switch(r.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},E.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},E.getNextABRAutoLevel=function(){var c=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.maxAutoLevel,g=a.config,l=a.minAutoLevel,d=a.media,v=r?r.duration:c?c.duration:0,h=d?d.currentTime:0,u=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,e=(N.BufferHelper.bufferInfo(d,h,g.maxBufferHole).end-h)/u,t=this.findBestLevel(n,l,o,e,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(t>=0)return t;w.logger.trace((e?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=v?Math.min(v,g.maxStarvationDelay):g.maxStarvationDelay,p=g.abrBandWidthFactor,x=g.abrBandWidthUpFactor;if(!e){var A=this.bitrateTestDelay;if(A){var I=v?Math.min(v,g.maxLoadingDelay):g.maxLoadingDelay;f=I-A,w.logger.trace("bitrate test took "+Math.round(1e3*A)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),p=x=1}}return t=this.findBestLevel(n,l,o,e+f,p,x),Math.max(t,0)},E.findBestLevel=function(c,r,a,o,g,l){for(var d,v=this.fragCurrent,h=this.partCurrent,u=this.lastLoadedFragLevel,n=this.hls.levels,e=n[u],t=!!(e!=null&&(d=e.details)!==null&&d!==void 0&&d.live),f=e==null?void 0:e.codecSet,p=h?h.duration:v?v.duration:0,x=a;x>=r;x--){var A=n[x];if(!A||f&&A.codecSet!==f)continue;var I=A.details,U=(h?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||p,j=void 0;x<=u?j=g*c:j=l*c;var z=n[x].maxBitrate,V=z*U/j;if(w.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(j)+"/"+z+"/"+U+"/"+o+"/"+V),j>z&&(!V||t&&!this.bitrateTestDelay||V<o))return x}return-1},T(b,[{key:"nextAutoLevel",get:function(){var c=this._nextAutoLevel,r=this.bwEstimator;if(c!==-1&&(!r||!r.canEstimate()))return c;var a=this.getNextABRAutoLevel();return c!==-1&&(a=Math.min(c,a)),a},set:function(c){this._nextAutoLevel=c}}]),b}();F.default=C},"./src/controller/audio-stream-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/polyfills/number.ts"),_=S("./src/controller/base-stream-controller.ts"),R=S("./src/events.ts"),N=S("./src/utils/buffer-helper.ts"),M=S("./src/controller/fragment-tracker.ts"),O=S("./src/types/level.ts"),w=S("./src/types/loader.ts"),m=S("./src/loader/fragment.ts"),T=S("./src/demux/chunk-cache.ts"),C=S("./src/demux/transmuxer-interface.ts"),b=S("./src/types/transmuxer.ts"),E=S("./src/controller/fragment-finders.ts"),y=S("./src/utils/discontinuities.ts"),c=S("./src/errors.ts"),r=S("./src/utils/logger.ts");function a(){return a=Object.assign||function(v){for(var h=1;h<arguments.length;h++){var u=arguments[h];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(v[n]=u[n])}return v},a.apply(this,arguments)}function o(v,h){v.prototype=Object.create(h.prototype),v.prototype.constructor=v,g(v,h)}function g(v,h){return g=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n},g(v,h)}var l=100,d=function(v){o(h,v);function h(n,e){var t;return t=v.call(this,n,e,"[audio-stream-controller]")||this,t.videoBuffer=null,t.videoTrackCC=-1,t.waitingVideoCC=-1,t.audioSwitch=!1,t.trackId=-1,t.waitingData=null,t.mainDetails=null,t.bufferFlushed=!1,t._registerListeners(),t}var u=h.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this),e.on(R.Events.BUFFER_RESET,this.onBufferReset,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(R.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this),e.off(R.Events.BUFFER_RESET,this.onBufferReset,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(R.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onInitPtsFound=function(e,t){var f=t.frag,p=t.id,x=t.initPTS;if(p==="main"){var A=f.cc;this.initPTS[f.cc]=x,this.log("InitPTS for cc: "+A+" found from main: "+x),this.videoTrackCC=A,this.state===_.State.WAITING_INIT_PTS&&this.tick()}},u.startLoad=function(e){if(!this.levels){this.startPosition=e,this.state=_.State.STOPPED;return}var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(l),this.fragLoadError=0,t>0&&e===-1?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=_.State.IDLE):(this.loadedmetadata=!1,this.state=_.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},u.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_TRACK:{var e,t=this.levels,f=this.trackId,p=t==null||((e=t[f])===null||e===void 0)?void 0:e.details;if(p){if(this.waitForCdnTuneIn(p))break;this.state=_.State.WAITING_INIT_PTS}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var x,A=performance.now(),I=this.retryDate;(!I||A>=I||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=_.State.IDLE);break}case _.State.WAITING_INIT_PTS:{var U=this.waitingData;if(U){var j=U.frag,z=U.part,V=U.cache,G=U.complete;if(this.initPTS[j.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.FRAG_LOADING;var Q=V.flush(),ne={frag:j,part:z,payload:Q,networkDetails:null};this._handleFragmentLoadProgress(ne),G&&v.prototype._handleFragmentLoadComplete.call(this,ne)}else if(this.videoTrackCC!==this.waitingVideoCC)r.logger.log("Waiting fragment cc ("+j.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var re=this.getLoadPosition(),be=N.BufferHelper.bufferInfo(this.mediaBuffer,re,this.config.maxBufferHole),se=Object(E.fragmentWithinToleranceTest)(be.end,this.config.maxFragLookUpTolerance,j);se<0&&(r.logger.log("Waiting fragment cc ("+j.cc+") @ "+j.start+" cancelled because another fragment at "+be.end+" is needed"),this.clearWaitingFragment())}}else this.state=_.State.IDLE}}this.onTickEnd()},u.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=_.State.IDLE)},u.onTickEnd=function(){var e=this.media;if(!e||!e.readyState)return;var t=this.mediaBuffer?this.mediaBuffer:e,f=t.buffered;!this.loadedmetadata&&f.length&&(this.loadedmetadata=!0),this.lastCurrentTime=e.currentTime},u.doTickIdle=function(){var e,t,f=this.hls,p=this.levels,x=this.media,A=this.trackId,I=f.config;if(!p||!p[A])return;if(!x&&(this.startFragRequested||!I.startFragPrefetch))return;var U=p[A],j=U.details;if(!j||j.live&&this.levelLastLoaded!==A||this.waitForCdnTuneIn(j)){this.state=_.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,m.ElementaryStreamTypes.AUDIO,w.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,w.PlaylistLevelType.AUDIO);if(z===null)return;var V=z.len,G=this.getMaxBufferLength(),Q=this.audioSwitch;if(V>=G&&!Q)return;if(!Q&&this._streamEnded(z,j)){f.trigger(R.Events.BUFFER_EOS,{type:"audio"}),this.state=_.State.ENDED;return}var ne=j.fragments,re=ne[0].start,be=z.end;if(Q){var se=this.getLoadPosition();be=se,j.PTSKnown&&se<re&&((z.end>re||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=re+.05))}var oe=this.getNextFragment(be,j);if(!oe){this.bufferFlushed=!0;return}((e=oe.decryptdata)===null||e===void 0?void 0:e.keyFormat)==="identity"&&!((t=oe.decryptdata)!==null&&t!==void 0&&t.key)?this.loadKey(oe,j):this.loadFragment(oe,j,be)},u.getMaxBufferLength=function(){var e=v.prototype.getMaxBufferLength.call(this),t=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,w.PlaylistLevelType.MAIN);return t===null?e:Math.max(e,t.len)},u.onMediaDetaching=function(){this.videoBuffer=null,v.prototype.onMediaDetaching.call(this)},u.onAudioTracksUpdated=function(e,t){var f=t.audioTracks;this.resetTransmuxer(),this.levels=f.map(function(p){return new O.Level(p)})},u.onAudioTrackSwitching=function(e,t){var f=!!t.url;this.trackId=t.id;var p=this.fragCurrent;p!=null&&p.loader&&p.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),f?this.setInterval(l):this.resetTransmuxer(),f?(this.audioSwitch=!0,this.state=_.State.IDLE):this.state=_.State.STOPPED,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},u.onLevelLoaded=function(e,t){this.mainDetails=t.details},u.onAudioTrackLoaded=function(e,t){var f,p=this.levels,x=t.details,A=t.id;if(!p){this.warn("Audio tracks were reset while loading level "+A);return}this.log("Track "+A+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var I=p[A],U=0;if(x.live||(f=I.details)!==null&&f!==void 0&&f.live){var j=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!j)return;!I.details&&x.hasProgramDateTime&&j.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(x,j),U=x.fragments[0].start):U=this.alignPlaylists(x,I.details)}I.details=x,this.levelLastLoaded=A,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(I.details,U),this.state===_.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=_.State.IDLE),this.tick()},u._handleFragmentLoadProgress=function(e){var t,f=e.frag,p=e.part,x=e.payload,A=this.config,I=this.trackId,U=this.levels;if(!U){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var j=U[I];console.assert(j,"Audio track is defined on fragment load progress");var z=j.details;console.assert(z,"Audio track details are defined on fragment load progress");var V=A.defaultAudioCodec||j.audioCodec||"mp4a.40.2",G=this.transmuxer;G||(G=this.transmuxer=new C.default(this.hls,w.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var Q=this.initPTS[f.cc],ne=(t=f.initSegment)===null||t===void 0?void 0:t.data;if(Q!==void 0){var re=!1,be=p?p.index:-1,se=be!==-1,oe=new b.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,x.byteLength,be,se);G.push(x,ne,V,"",f,p,z.totalduration,re,oe,Q)}else{r.logger.log("Unknown video PTS for cc "+f.cc+", waiting for video PTS before demuxing audio frag "+f.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+I);var ue=this.waitingData=this.waitingData||{frag:f,part:p,cache:new T.default,complete:!1},he=ue.cache;he.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=_.State.WAITING_INIT_PTS}},u._handleFragmentLoadComplete=function(e){if(this.waitingData){this.waitingData.complete=!0;return}v.prototype._handleFragmentLoadComplete.call(this,e)},u.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},u.onBufferCreated=function(e,t){var f=t.tracks.audio;f&&(this.mediaBuffer=f.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},u.onFragBuffered=function(e,t){var f=t.frag,p=t.part;if(f.type!==w.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(p?" p: "+p.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}f.sn!=="initSegment"&&(this.fragPrevious=f,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(f,p)},u.onError=function(e,t){switch(t.details){case c.ErrorDetails.FRAG_LOAD_ERROR:case c.ErrorDetails.FRAG_LOAD_TIMEOUT:case c.ErrorDetails.KEY_LOAD_ERROR:case c.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.AUDIO,t);break;case c.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case c.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==_.State.ERROR&&this.state!==_.State.STOPPED&&(this.state=t.fatal?_.State.ERROR:_.State.IDLE,this.warn(t.details+" while loading frag, switching to "+this.state+" state"));break;case c.ErrorDetails.BUFFER_FULL_ERROR:if(t.parent==="audio"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var f=!0,p=this.getFwdBufferInfo(this.mediaBuffer,w.PlaylistLevelType.AUDIO);p&&p.len>.5&&(f=!this.reduceMaxBufferLength(p.len)),f&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,v.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},u.onBufferFlushed=function(e,t){var f=t.type;f===m.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},u._handleTransmuxComplete=function(e){var t,f="audio",p=this.hls,x=e.remuxResult,A=e.chunkMeta,I=this.getCurrentContext(A);if(!I){this.warn("The loading context changed while buffering fragment "+A.sn+" of level "+A.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(A.level);return}var U=I.frag,j=I.part,z=x.audio,V=x.text,G=x.id3,Q=x.initSegment;if(this.fragContextChanged(U))return;if(this.state=_.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),Q!=null&&Q.tracks&&(this._bufferInitSegment(Q.tracks,U,A),p.trigger(R.Events.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:f,tracks:Q.tracks})),z){var ne=z.startPTS,re=z.endPTS,be=z.startDTS,se=z.endDTS;j&&(j.elementaryStreams[m.ElementaryStreamTypes.AUDIO]={startPTS:ne,endPTS:re,startDTS:be,endDTS:se}),U.setElementaryStreamInfo(m.ElementaryStreamTypes.AUDIO,ne,re,be,se),this.bufferFragmentData(z,U,j,A)}if(G!=null&&(t=G.samples)!==null&&t!==void 0&&t.length){var oe=a({frag:U,id:f},G);p.trigger(R.Events.FRAG_PARSING_METADATA,oe)}if(V){var ue=a({frag:U,id:f},V);p.trigger(R.Events.FRAG_PARSING_USERDATA,ue)}},u._bufferInitSegment=function(e,t,f){if(this.state!==_.State.PARSING)return;e.video&&delete e.video;var p=e.audio;if(!p)return;p.levelCodec=p.codec,p.id="audio",this.log("Init audio buffer, container:"+p.container+", codecs[parsed]=["+p.codec+"]"),this.hls.trigger(R.Events.BUFFER_CODECS,e);var x=p.initSegment;if(x!=null&&x.byteLength){var A={type:"audio",frag:t,part:null,chunkMeta:f,parent:t.type,data:x};this.hls.trigger(R.Events.BUFFER_APPENDING,A)}this.tick()},u.loadFragment=function(e,t,f){var p=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||p===M.FragmentState.NOT_LOADED||p===M.FragmentState.PARTIAL)&&(e.sn==="initSegment"?this._loadInitSegment(e):t.live&&!Object(B.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=_.State.WAITING_INIT_PTS):(this.startFragRequested=!0,v.prototype.loadFragment.call(this,e,t,f)))},u.completeAudioSwitch=function(){var e=this.hls,t=this.media,f=this.trackId;t&&(this.log("Switching audio track : flushing all audio"),v.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:f})},h}(_.default);F.default=d},"./src/controller/audio-track-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts"),_=S("./src/errors.ts"),R=S("./src/controller/base-playlist-controller.ts"),N=S("./src/types/loader.ts");function M(C,b){for(var E=0;E<b.length;E++){var y=b[E];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(C,y.key,y)}}function O(C,b,E){return b&&M(C.prototype,b),E&&M(C,E),C}function w(C,b){C.prototype=Object.create(b.prototype),C.prototype.constructor=C,m(C,b)}function m(C,b){return m=Object.setPrototypeOf||function(y,c){return y.__proto__=c,y},m(C,b)}var T=function(C){w(b,C);function b(y){var c;return c=C.call(this,y,"[audio-track-controller]")||this,c.tracks=[],c.groupId=null,c.tracksInGroup=[],c.trackId=-1,c.trackName="",c.selectDefaultTrack=!0,c.registerListeners(),c}var E=b.prototype;return E.registerListeners=function(){var c=this.hls;c.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),c.on(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(B.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var c=this.hls;c.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),c.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),c.off(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(B.Events.ERROR,this.onError,this)},E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,C.prototype.destroy.call(this)},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},E.onManifestParsed=function(c,r){this.tracks=r.audioTracks||[]},E.onAudioTrackLoaded=function(c,r){var a=r.id,o=r.details,g=this.tracksInGroup[a];if(!g){this.warn("Invalid audio track id "+a);return}var l=g.details;g.details=r.details,this.log("audioTrack "+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),a===this.trackId&&(this.retryCount=0,this.playlistLoaded(a,r,l))},E.onLevelLoading=function(c,r){this.switchLevel(r.level)},E.onLevelSwitching=function(c,r){this.switchLevel(r.level)},E.switchLevel=function(c){var r=this.hls.levels[c];if(!(r!=null&&r.audioGroupIds))return;var a=r.audioGroupIds[r.urlId];if(this.groupId!==a){this.groupId=a;var o=this.tracks.filter(function(l){return!a||l.groupId===a});this.selectDefaultTrack&&!o.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=o;var g={audioTracks:o};this.log("Updating audio tracks, "+o.length+' track(s) found in "'+a+'" group-id'),this.hls.trigger(B.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}},E.onError=function(c,r){if(C.prototype.onError.call(this,c,r),r.fatal||!r.context)return;r.context.type===N.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},E.setAudioTrack=function(c){var r=this.tracksInGroup;if(c<0||c>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var a=r[this.trackId];this.log("Now switching to audio-track index "+c);var o=r[c],g=o.id,l=o.groupId,d=l===void 0?"":l,v=o.name,h=o.type,u=o.url;if(this.trackId=c,this.trackName=v,this.selectDefaultTrack=!1,this.hls.trigger(B.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:d,name:v,type:h,url:u}),o.details&&!o.details.live)return;var n=this.switchParams(o.url,a==null?void 0:a.details);this.loadPlaylist(n)},E.selectInitialTrack=function(){var c=this.tracksInGroup;console.assert(c.length,"Initial audio track should be selected when tracks are known");var r=this.trackName,a=this.findTrackId(r)||this.findTrackId();a!==-1?this.setAudioTrack(a):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},E.findTrackId=function(c){for(var r=this.tracksInGroup,a=0;a<r.length;a++){var o=r[a];if((!this.selectDefaultTrack||o.default)&&(!c||c===o.name))return o.id}return-1},E.loadPlaylist=function(c){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var a=r.id,o=r.groupId,g=r.url;if(c)try{g=c.addDirectives(g)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist for id: "+a),this.clearTimer(),this.hls.trigger(B.Events.AUDIO_TRACK_LOADING,{url:g,id:a,groupId:o,deliveryDirectives:c||null})}},O(b,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(c){this.selectDefaultTrack=!1,this.setAudioTrack(c)}}]),b}(R.default);F.default=T},"./src/controller/base-playlist-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return O});var B=S("./src/polyfills/number.ts"),_=S("./src/types/level.ts"),R=S("./src/controller/level-helper.ts"),N=S("./src/utils/logger.ts"),M=S("./src/errors.ts"),O=function(){function w(T,C){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=N.logger.log.bind(N.logger,C+":"),this.warn=N.logger.warn.bind(N.logger,C+":"),this.hls=T}var m=w.prototype;return m.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},m.onError=function(C,b){b.fatal&&b.type===M.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},m.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},m.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},m.stopLoad=function(){this.canLoad=!1,this.clearTimer()},m.switchParams=function(C,b){var E=b==null?void 0:b.renditionReports;if(E)for(var y=0;y<E.length;y++){var c=E[y],r=""+c.URI;if(r===C.substr(-r.length)){var a=parseInt(c["LAST-MSN"]),o=parseInt(c["LAST-PART"]);if(b&&this.hls.config.lowLatencyMode){var g=Math.min(b.age-b.partTarget,b.targetduration);o!==void 0&&g>b.partTarget&&(o+=1)}if(Object(B.isFiniteNumber)(a))return new _.HlsUrlParameters(a,Object(B.isFiniteNumber)(o)?o:void 0,_.HlsSkip.No)}}},m.loadPlaylist=function(C){},m.shouldLoadTrack=function(C){return this.canLoad&&C&&!!C.url&&(!C.details||C.details.live)},m.playlistLoaded=function(C,b,E){var y=this,c=b.details,r=b.stats,a=r.loading.end?Math.max(0,self.performance.now()-r.loading.end):0;if(c.advancedDateTime=Date.now()-a,c.live||E!=null&&E.live){if(c.reloaded(E),E&&this.log("live playlist "+C+" "+(c.advanced?"REFRESHED "+c.lastPartSn+"-"+c.lastPartIndex:"MISSED")),E&&c.fragments.length>0&&Object(R.mergeDetails)(E,c),!this.canLoad||!c.live)return;var o,g=void 0,l=void 0;if(c.canBlockReload&&c.endSN&&c.advanced){var d=this.hls.config.lowLatencyMode,v=c.lastPartSn,h=c.endSN,u=c.lastPartIndex,n=u!==-1,e=v===h,t=d?0:u;n?(g=e?h+1:v,l=e?t:u+1):g=h+1;var f=c.age,p=f+c.ageHeader,x=Math.min(p-c.partTarget,c.targetduration*1.5);if(x>0){if(E&&x>E.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+E.tuneInGoal+" to: "+x+" with playlist age: "+c.age),x=0;else{var A=Math.floor(x/c.targetduration);if(g+=A,l!==void 0){var I=Math.round(x%c.targetduration/c.partTarget);l+=I}this.log("CDN Tune-in age: "+c.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+x+" skip sn "+A+" to part "+l)}c.tuneInGoal=x}if(o=this.getDeliveryDirectives(c,b.deliveryDirectives,g,l),d||!e){this.loadPlaylist(o);return}}else o=this.getDeliveryDirectives(c,b.deliveryDirectives,g,l);var U=Object(R.computeReloadInterval)(c,r);g!==void 0&&c.canBlockReload&&(U-=c.partTarget||1),this.log("reload live playlist "+C+" in "+Math.round(U)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(o)},U)}else this.clearTimer()},m.getDeliveryDirectives=function(C,b,E,y){var c=Object(_.getSkipValue)(C,E);return b!=null&&b.skip&&C.deltaUpdateFailed&&(E=b.msn,y=b.part,c=_.HlsSkip.No),new _.HlsUrlParameters(E,y,c)},m.retryLoadingOrFail=function(C){var b=this,E=this.hls.config,y=this.retryCount<E.levelLoadingMaxRetry;if(y){var c;if(this.retryCount++,C.details.indexOf("LoadTimeOut")>-1&&(c=C.context)!==null&&c!==void 0&&c.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+C.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*E.levelLoadingRetryDelay,E.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return b.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+C.details+'"')}}else this.warn('cannot recover from error "'+C.details+'"'),this.clearTimer(),C.fatal=!0;return y},w}()},"./src/controller/base-stream-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"State",function(){return h}),S.d(F,"default",function(){return u});var B=S("./src/polyfills/number.ts"),_=S("./src/task-loop.ts"),R=S("./src/controller/fragment-tracker.ts"),N=S("./src/utils/buffer-helper.ts"),M=S("./src/utils/logger.ts"),O=S("./src/events.ts"),w=S("./src/errors.ts"),m=S("./src/types/transmuxer.ts"),T=S("./src/utils/mp4-tools.ts"),C=S("./src/utils/discontinuities.ts"),b=S("./src/controller/fragment-finders.ts"),E=S("./src/controller/level-helper.ts"),y=S("./src/loader/fragment-loader.ts"),c=S("./src/crypt/decrypter.ts"),r=S("./src/utils/time-ranges.ts"),a=S("./src/types/loader.ts");function o(n,e){for(var t=0;t<e.length;t++){var f=e[t];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(n,f.key,f)}}function g(n,e,t){return e&&o(n.prototype,e),t&&o(n,t),n}function l(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function d(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,v(n,e)}function v(n,e){return v=Object.setPrototypeOf||function(f,p){return f.__proto__=p,f},v(n,e)}var h={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"},u=function(n){d(e,n);function e(f,p,x){var A;return A=n.call(this)||this,A.hls=void 0,A.fragPrevious=null,A.fragCurrent=null,A.fragmentTracker=void 0,A.transmuxer=null,A._state=h.STOPPED,A.media=void 0,A.mediaBuffer=void 0,A.config=void 0,A.bitrateTest=!1,A.lastCurrentTime=0,A.nextLoadPosition=0,A.startPosition=0,A.loadedmetadata=!1,A.fragLoadError=0,A.retryDate=0,A.levels=null,A.fragmentLoader=void 0,A.levelLastLoaded=null,A.startFragRequested=!1,A.decrypter=void 0,A.initPTS=[],A.onvseeking=null,A.onvended=null,A.logPrefix="",A.log=void 0,A.warn=void 0,A.logPrefix=x,A.log=M.logger.log.bind(M.logger,x+":"),A.warn=M.logger.warn.bind(M.logger,x+":"),A.hls=f,A.fragmentLoader=new y.default(f.config),A.fragmentTracker=p,A.config=f.config,A.decrypter=new c.default(f,f.config),f.on(O.Events.KEY_LOADED,A.onKeyLoaded,l(A)),A}var t=e.prototype;return t.doTick=function(){this.onTickEnd()},t.onTickEnd=function(){},t.startLoad=function(p){},t.stopLoad=function(){this.fragmentLoader.abort();var p=this.fragCurrent;p&&this.fragmentTracker.removeFragment(p),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=h.STOPPED},t._streamEnded=function(p,x){var A=this.fragCurrent,I=this.fragmentTracker;if(!x.live&&A&&A.sn===x.endSN&&!p.nextStart){var U=I.getState(A);return U===R.FragmentState.PARTIAL||U===R.FragmentState.OK}return!1},t.onMediaAttached=function(p,x){var A=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),A.addEventListener("seeking",this.onvseeking),A.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===h.STOPPED&&this.startLoad(I.startPosition)},t.onMediaDetaching=function(){var p=this.media;p!=null&&p.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),p&&(p.removeEventListener("seeking",this.onvseeking),p.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var p=this.config,x=this.fragCurrent,A=this.media,I=this.mediaBuffer,U=this.state,j=A?A.currentTime:0,z=N.BufferHelper.bufferInfo(I||A,j,p.maxBufferHole);if(this.log("media seeking to "+(Object(B.isFiniteNumber)(j)?j.toFixed(3):j)+", state: "+U),U===h.ENDED)this.resetLoadingState();else if(x&&!z.len){var V=p.maxFragLookUpTolerance,G=x.start-V,Q=x.start+x.duration+V,ne=j>Q;(j<G||ne)&&(ne&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}A&&(this.lastCurrentTime=j),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=j),this.tickImmediate()},t.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.onKeyLoaded=function(p,x){if(this.state!==h.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=h.IDLE;var A=this.levels[x.frag.level].details;A&&this.loadFragment(x.frag,A,x.frag.start)},t.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},t.onHandlerDestroyed=function(){this.state=h.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,n.prototype.onHandlerDestroyed.call(this)},t.loadKey=function(p,x){this.log("Loading key for "+p.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level),this.state=h.KEY_LOADING,this.fragCurrent=p,this.hls.trigger(O.Events.KEY_LOADING,{frag:p})},t.loadFragment=function(p,x,A){this._loadFragForPlayback(p,x,A)},t._loadFragForPlayback=function(p,x,A){var I=this,U=function(z){if(I.fragContextChanged(p)){I.warn("Fragment "+p.sn+(z.part?" p: "+z.part.index:"")+" of level "+p.level+" was dropped during download."),I.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,I._handleFragmentLoadProgress(z)};this._doFragLoad(p,x,A,U).then(function(j){if(!j)return;I.fragLoadError=0;var z=I.state;if(I.fragContextChanged(p)){(z===h.FRAG_LOADING||z===h.BACKTRACKING||!I.fragCurrent&&z===h.PARSING)&&(I.fragmentTracker.removeFragment(p),I.state=h.IDLE);return}if("payload"in j&&(I.log("Loaded fragment "+p.sn+" of level "+p.level),I.hls.trigger(O.Events.FRAG_LOADED,j),I.state===h.BACKTRACKING)){I.fragmentTracker.backtrack(p,j),I.resetFragmentLoading(p);return}I._handleFragmentLoadComplete(j)}).catch(function(j){I.warn(j),I.resetFragmentLoading(p)})},t.flushMainBuffer=function(p,x,A){if(A===void 0&&(A=null),!(p-x))return;var I={startOffset:p,endOffset:x,type:A};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,I)},t._loadInitSegment=function(p){var x=this;this._doFragLoad(p).then(function(A){if(!A||x.fragContextChanged(p)||!x.levels)throw new Error("init load aborted");return A}).then(function(A){var I=x.hls,U=A.payload,j=p.decryptdata;if(U&&U.byteLength>0&&j&&j.key&&j.iv&&j.method==="AES-128"){var z=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(U),j.key.buffer,j.iv.buffer).then(function(V){var G=self.performance.now();return I.trigger(O.Events.FRAG_DECRYPTED,{frag:p,payload:V,stats:{tstart:z,tdecrypt:G}}),A.payload=V,A})}return A}).then(function(A){var I=x.fragCurrent,U=x.hls,j=x.levels;if(!j)throw new Error("init load aborted, missing levels");var z=j[p.level].details;console.assert(z,"Level details are defined when init segment is loaded");var V=p.stats;x.state=h.IDLE,x.fragLoadError=0,p.data=new Uint8Array(A.payload),V.parsing.start=V.buffering.start=self.performance.now(),V.parsing.end=V.buffering.end=self.performance.now(),A.frag===I&&U.trigger(O.Events.FRAG_BUFFERED,{stats:V,frag:I,part:null,id:p.type}),x.tick()}).catch(function(A){x.warn(A),x.resetFragmentLoading(p)})},t.fragContextChanged=function(p){var x=this.fragCurrent;return!p||!x||p.level!==x.level||p.sn!==x.sn||p.urlId!==x.urlId},t.fragBufferedComplete=function(p,x){var A=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+p.type+" sn: "+p.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level+" "+r.default.toString(N.BufferHelper.getBuffered(A))),this.state=h.IDLE,this.tick()},t._handleFragmentLoadComplete=function(p){var x=this.transmuxer;if(!x)return;var A=p.frag,I=p.part,U=p.partsLoaded,j=!U||U.length===0||U.some(function(V){return!V}),z=new m.ChunkMetadata(A.level,A.sn,A.stats.chunkCount+1,0,I?I.index:-1,!j);x.flush(z)},t._handleFragmentLoadProgress=function(p){},t._doFragLoad=function(p,x,A,I){var U=this;if(A===void 0&&(A=null),!this.levels)throw new Error("frag load aborted, missing levels");if(A=Math.max(p.start,A||0),this.config.lowLatencyMode&&x){var j=x.partList;if(j&&I){A>p.end&&x.fragmentHint&&(p=x.fragmentHint);var z=this.getNextPart(j,p,A);if(z>-1){var V=j[z];return this.log("Loading part sn: "+p.sn+" p: "+V.index+" cc: "+p.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+z+"-"+(j.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(A.toFixed(3))),this.nextLoadPosition=V.start+V.duration,this.state=h.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:p,part:j[z],targetBufferTime:A}),this.doFragPartsLoad(p,j,z,I).catch(function(G){return U.handleFragLoadError(G)})}else if(!p.url||this.loadedEndOfParts(j,A))return Promise.resolve(null)}}return this.log("Loading fragment "+p.sn+" cc: "+p.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(A.toFixed(3))),Object(B.isFiniteNumber)(p.sn)&&!this.bitrateTest&&(this.nextLoadPosition=p.start+p.duration),this.state=h.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:p,targetBufferTime:A}),this.fragmentLoader.load(p,I).catch(function(G){return U.handleFragLoadError(G)})},t.doFragPartsLoad=function(p,x,A,I){var U=this;return new Promise(function(j,z){var V=[],G=function Q(ne){var re=x[ne];U.fragmentLoader.loadPart(p,re,I).then(function(be){V[re.index]=be;var se=be.part;U.hls.trigger(O.Events.FRAG_LOADED,be);var oe=x[ne+1];if(oe&&oe.fragment===p)Q(ne+1);else return j({frag:p,part:se,partsLoaded:V})}).catch(z)};G(A)})},t.handleFragLoadError=function(p){var x=p.data;return x&&x.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(O.Events.ERROR,x),null},t._handleTransmuxerFlush=function(p){var x=this.getCurrentContext(p);if(!x||this.state!==h.PARSING){this.fragCurrent||(this.state=h.IDLE);return}var A=x.frag,I=x.part,U=x.level,j=self.performance.now();A.stats.parsing.end=j,I&&(I.stats.parsing.end=j),this.updateLevelTiming(A,I,U,p.partial)},t.getCurrentContext=function(p){var x=this.levels,A=p.level,I=p.sn,U=p.part;if(!x||!x[A])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+A+". The current chunk will not be buffered."),null;var j=x[A],z=U>-1?Object(E.getPartWith)(j,I,U):null,V=z?z.fragment:Object(E.getFragmentWithSN)(j,I,this.fragCurrent);return V?{frag:V,part:z,level:j}:null},t.bufferFragmentData=function(p,x,A,I){if(!p||this.state!==h.PARSING)return;var U=p.data1,j=p.data2,z=U;if(U&&j&&(z=Object(T.appendUint8Array)(U,j)),!z||!z.length)return;var V={type:p.type,frag:x,part:A,chunkMeta:I,parent:x.type,data:z};this.hls.trigger(O.Events.BUFFER_APPENDING,V),p.dropped&&p.independent&&!A&&this.flushBufferGap(x)},t.flushBufferGap=function(p){var x=this.media;if(!x)return;if(!N.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,p.start);return}var A=x.currentTime,I=N.BufferHelper.bufferInfo(x,A,0),U=p.duration,j=Math.min(this.config.maxFragLookUpTolerance*2,U*.25),z=Math.max(Math.min(p.start-j,I.end-j),A+j);p.start-z>j&&this.flushMainBuffer(z,p.start)},t.getFwdBufferInfo=function(p,x){var A=this.config,I=this.getLoadPosition();if(!Object(B.isFiniteNumber)(I))return null;var U=N.BufferHelper.bufferInfo(p,I,A.maxBufferHole);if(U.len===0&&U.nextStart!==void 0){var j=this.fragmentTracker.getBufferedFrag(I,x);if(j&&U.nextStart<j.end)return N.BufferHelper.bufferInfo(p,I,Math.max(U.nextStart,A.maxBufferHole))}return U},t.getMaxBufferLength=function(p){var x=this.config,A;return p?A=Math.max(8*x.maxBufferSize/p,x.maxBufferLength):A=x.maxBufferLength,Math.min(A,x.maxMaxBufferLength)},t.reduceMaxBufferLength=function(p){var x=this.config,A=p||x.maxBufferLength;return x.maxMaxBufferLength>=A?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},t.getNextFragment=function(p,x){var A,I,U=x.fragments,j=U.length;if(!j)return null;var z=this.config,V=U[0].start,G;if(x.live){var Q=z.initialLiveManifestSize;if(j<Q)return this.warn("Not enough fragments to start playback (have: "+j+", need: "+Q+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(G=this.getInitialLiveFragment(x,U),this.startPosition=G?this.hls.liveSyncPosition||G.start:p)}else p<=V&&(G=U[0]);if(!G){var ne=z.lowLatencyMode?x.partEnd:x.fragmentEnd;G=this.getFragmentAtPosition(p,ne,x)}return(A=G)!==null&&A!==void 0&&A.initSegment&&!((I=G)!==null&&I!==void 0&&I.initSegment.data)&&!this.bitrateTest&&(G=G.initSegment),G},t.getNextPart=function(p,x,A){for(var I=-1,U=!1,j=!0,z=0,V=p.length;z<V;z++){var G=p[z];if(j=j&&!G.independent,I>-1&&A<G.start)break;var Q=G.loaded;!Q&&(U||G.independent||j)&&G.fragment===x&&(I=z),U=Q}return I},t.loadedEndOfParts=function(p,x){var A=p[p.length-1];return A&&x>A.start&&A.loaded},t.getInitialLiveFragment=function(p,x){var A=this.fragPrevious,I=null;if(A){if(p.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+A.programDateTime),I=Object(b.findFragmentByPDT)(x,A.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var U=A.sn+1;if(U>=p.startSN&&U<=p.endSN){var j=x[U-p.startSN];A.cc===j.cc&&(I=j,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(b.findFragWithCC)(x,A.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(I=this.getFragmentAtPosition(z,this.bitrateTest?p.fragmentEnd:p.edge,p))}return I},t.getFragmentAtPosition=function(p,x,A){var I=this.config,U=this.fragPrevious,j=A.fragments,z=A.endSN,V=A.fragmentHint,G=I.maxFragLookUpTolerance,Q=!!(I.lowLatencyMode&&A.partList&&V);Q&&V&&!this.bitrateTest&&(j=j.concat(V),z=V.sn);var ne;if(p<x){var re=p>x-G?0:G;ne=Object(b.findFragmentByPTS)(U,j,p,re)}else ne=j[j.length-1];if(ne){var be=ne.sn-A.startSN,se=U&&ne.level===U.level,oe=j[be+1],ue=this.fragmentTracker.getState(ne);if(ue===R.FragmentState.BACKTRACKED){ne=null;for(var he=be;j[he]&&this.fragmentTracker.getState(j[he])===R.FragmentState.BACKTRACKED;)U?ne=j[he--]:ne=j[--he];ne||(ne=oe)}else U&&ne.sn===U.sn&&!Q&&(se&&(ne.sn<z&&this.fragmentTracker.getState(oe)!==R.FragmentState.OK?(this.log("SN "+ne.sn+" just loaded, load next one: "+oe.sn),ne=oe):ne=null))}return ne},t.synchronizeToLiveEdge=function(p){var x=this.config,A=this.media;if(!A)return;var I=this.hls.liveSyncPosition,U=A.currentTime,j=p.fragments[0].start,z=p.edge,V=U>=j-x.maxFragLookUpTolerance&&U<=z;if(I!==null&&A.duration>I&&(U<I||!V)){var G=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*p.targetduration;(!V&&A.readyState<4||U<z-G)&&(this.loadedmetadata||(this.nextLoadPosition=I),A.readyState&&(this.warn("Playback: "+U.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+I.toFixed(3)),A.currentTime=I))}},t.alignPlaylists=function(p,x){var A=this.levels,I=this.levelLastLoaded,U=this.fragPrevious,j=I!==null?A[I]:null,z=p.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var V=p.fragments[0].start,G=!x,Q=p.alignedSliding&&Object(B.isFiniteNumber)(V);if(G||!Q&&!V){Object(C.alignStream)(U,j,p);var ne=p.fragments[0].start;return this.log("Live playlist sliding: "+ne.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+p.startSN+" prev-sn: "+(U?U.sn:"na")+" fragments: "+z),ne}return V},t.waitForCdnTuneIn=function(p){var x=3;return p.live&&p.canBlockReload&&p.tuneInGoal>Math.max(p.partHoldBack,p.partTarget*x)},t.setStartPosition=function(p,x){var A=this.startPosition;if(A<x&&(A=-1),A===-1||this.lastCurrentTime===-1){var I=p.startTimeOffset;Object(B.isFiniteNumber)(I)?(A=x+I,I<0&&(A+=p.totalduration),A=Math.min(Math.max(x,A),x+p.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+A),this.startPosition=A):p.live?A=this.hls.liveSyncPosition||x:this.startPosition=A=0,this.lastCurrentTime=A}this.nextLoadPosition=A},t.getLoadPosition=function(){var p=this.media,x=0;return this.loadedmetadata&&p?x=p.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},t.handleFragLoadAborted=function(p,x){this.transmuxer&&p.sn!=="initSegment"&&p.stats.aborted&&(this.warn("Fragment "+p.sn+(x?" part"+x.index:"")+" of level "+p.level+" was aborted"),this.resetFragmentLoading(p))},t.resetFragmentLoading=function(p){(!this.fragCurrent||!this.fragContextChanged(p))&&(this.state=h.IDLE)},t.onFragmentOrKeyLoadError=function(p,x){if(x.fatal)return;var A=x.frag;if(!A||A.type!==p)return;var I=this.fragCurrent;console.assert(I&&A.sn===I.sn&&A.level===I.level&&A.urlId===I.urlId,"Frag load error must match current frag to retry");var U=this.config;if(this.fragLoadError+1<=U.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(A.level))return;var j=Math.min(Math.pow(2,this.fragLoadError)*U.fragLoadingRetryDelay,U.fragLoadingMaxRetryTimeout);this.warn("Fragment "+A.sn+" of "+p+" "+A.level+" failed to load, retrying in "+j+"ms"),this.retryDate=self.performance.now()+j,this.fragLoadError++,this.state=h.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(p===a.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=h.IDLE):(M.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=h.ERROR)},t.afterBufferFlushed=function(p,x,A){if(!p)return;var I=N.BufferHelper.getBuffered(p);this.fragmentTracker.detectEvictedFragments(x,I,A),this.state===h.ENDED&&this.resetLoadingState()},t.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=h.IDLE},t.resetLiveStartWhenNotLoaded=function(p){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[p].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},t.updateLevelTiming=function(p,x,A,I){var U=this,j=A.details;console.assert(!!j,"level.details must be defined");var z=Object.keys(p.elementaryStreams).reduce(function(V,G){var Q=p.elementaryStreams[G];if(Q){var ne=Q.endPTS-Q.startPTS;if(ne<=0)return U.warn("Could not parse fragment "+p.sn+" "+G+" duration reliably ("+ne+") resetting transmuxer to fallback to playlist timing"),U.resetTransmuxer(),V||!1;var re=I?0:Object(E.updateFragPTSDTS)(j,p,Q.startPTS,Q.endPTS,Q.startDTS,Q.endDTS);return U.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:j,level:A,drift:re,type:G,frag:p,start:Q.startPTS,end:Q.endPTS}),!0}return V},!1);z?(this.state=h.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:p,part:x})):this.resetLoadingState()},t.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(e,[{key:"state",get:function(){return this._state},set:function(p){var x=this._state;x!==p&&(this._state=p,this.log(x+"->"+p))}}]),e}(_.default)},"./src/controller/buffer-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return b});var B=S("./src/polyfills/number.ts"),_=S("./src/events.ts"),R=S("./src/utils/logger.ts"),N=S("./src/errors.ts"),M=S("./src/utils/buffer-helper.ts"),O=S("./src/utils/mediasource-helper.ts"),w=S("./src/loader/fragment.ts"),m=S("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),C=/([ha]vc.)(?:\.[^.,]+)+/,b=function(){function E(c){var r=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 a=r.hls,o=r.media,g=r.mediaSource;R.logger.log("[buffer-controller]: Media source opened"),o&&(r.updateMediaElementDuration(),a.trigger(_.Events.MEDIA_ATTACHED,{media:o})),g&&g.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){R.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){R.logger.log("[buffer-controller]: Media source ended")},this.hls=c,this._initSourceBuffer(),this.registerListeners()}var y=E.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var r=this.hls;r.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(_.Events.BUFFER_RESET,this.onBufferReset,this),r.on(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.on(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.on(_.Events.BUFFER_EOS,this.onBufferEos,this),r.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.on(_.Events.FRAG_PARSED,this.onFragParsed,this),r.on(_.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var r=this.hls;r.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(_.Events.BUFFER_RESET,this.onBufferReset,this),r.off(_.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.off(_.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.off(_.Events.BUFFER_EOS,this.onBufferEos,this),r.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.off(_.Events.FRAG_PARSED,this.onFragParsed,this),r.off(_.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new m.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(r,a){var o=2;(a.audio&&!a.video||!a.altAudio)&&(o=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=o,this.details=null,R.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(r,a){var o=this.media=a.media;if(o&&T){var g=this.mediaSource=new T;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),o.src=self.URL.createObjectURL(g),this._objectUrl=o.src}},y.onMediaDetaching=function(){var r=this.media,a=this.mediaSource,o=this._objectUrl;if(a){if(R.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(g){R.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),r&&(o&&self.URL.revokeObjectURL(o),r.src===o?(r.removeAttribute("src"),r.load()):R.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(_.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var r=this;this.getSourceBufferTypes().forEach(function(a){var o=r.sourceBuffer[a];try{o&&(r.removeBufferListeners(a),r.mediaSource&&r.mediaSource.removeSourceBuffer(o),r.sourceBuffer[a]=void 0)}catch(g){R.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",g)}}),this._initSourceBuffer()},y.onBufferCodecs=function(r,a){var o=this,g=this.getSourceBufferTypes().length;if(Object.keys(a).forEach(function(l){if(g){var d=o.tracks[l];if(d&&typeof d.buffer.changeType=="function"){var v=a[l],h=v.codec,u=v.levelCodec,n=v.container,e=(d.levelCodec||d.codec).replace(C,"$1"),t=(u||h).replace(C,"$1");if(e!==t){var f=n+";codecs="+(u||h);o.appendChangeType(l,f)}}}else o.pendingTracks[l]=a[l]}),g)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},y.appendChangeType=function(r,a){var o=this,g=this.operationQueue,l={execute:function(){var v=o.sourceBuffer[r];v&&(R.logger.log("[buffer-controller]: changing "+r+" sourceBuffer type to "+a),v.changeType(a)),g.shiftAndExecuteNext(r)},onStart:function(){},onComplete:function(){},onError:function(v){R.logger.warn("[buffer-controller]: Failed to change "+r+" SourceBuffer type",v)}};g.append(l,r)},y.onBufferAppending=function(r,a){var o=this,g=this.hls,l=this.operationQueue,d=this.tracks,v=a.data,h=a.type,u=a.frag,n=a.part,e=a.chunkMeta,t=e.buffering[h],f=self.performance.now();t.start=f;var p=u.stats.buffering,x=n?n.stats.buffering:null;p.start===0&&(p.start=f),x&&x.start===0&&(x.start=f);var A=d.audio,I=h==="audio"&&e.id===1&&(A==null?void 0:A.container)==="audio/mpeg",U={execute:function(){if(t.executeStart=self.performance.now(),I){var z=o.sourceBuffer[h];if(z){var V=u.start-z.timestampOffset;Math.abs(V)>=.1&&(R.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+V+") sn: "+u.sn+")"),z.timestampOffset=u.start)}}o.appendExecutor(v,h)},onStart:function(){},onComplete:function(){var z=self.performance.now();t.executeEnd=t.end=z,p.first===0&&(p.first=z),x&&x.first===0&&(x.first=z);var V=o.sourceBuffer,G={};for(var Q in V)G[Q]=M.BufferHelper.getBuffered(V[Q]);o.appendError=0,o.hls.trigger(_.Events.BUFFER_APPENDED,{type:h,frag:u,part:n,chunkMeta:e,parent:u.type,timeRanges:G})},onError:function(z){R.logger.error("[buffer-controller]: Error encountered while trying to append to the "+h+" SourceBuffer",z);var V={type:N.ErrorTypes.MEDIA_ERROR,parent:u.type,details:N.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?V.details=N.ErrorDetails.BUFFER_FULL_ERROR:(o.appendError++,V.details=N.ErrorDetails.BUFFER_APPEND_ERROR,o.appendError>g.config.appendErrorMaxRetry&&(R.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),V.fatal=!0)),g.trigger(_.Events.ERROR,V)}};l.append(U,h)},y.onBufferFlushing=function(r,a){var o=this,g=this.operationQueue,l=function(v){return{execute:o.removeExecutor.bind(o,v,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){o.hls.trigger(_.Events.BUFFER_FLUSHED,{type:v})},onError:function(u){R.logger.warn("[buffer-controller]: Failed to remove from "+v+" SourceBuffer",u)}}};a.type?g.append(l(a.type),a.type):this.getSourceBufferTypes().forEach(function(d){g.append(l(d),d)})},y.onFragParsed=function(r,a){var o=this,g=a.frag,l=a.part,d=[],v=l?l.elementaryStreams:g.elementaryStreams;v[w.ElementaryStreamTypes.AUDIOVIDEO]?d.push("audiovideo"):(v[w.ElementaryStreamTypes.AUDIO]&&d.push("audio"),v[w.ElementaryStreamTypes.VIDEO]&&d.push("video"));var h=function(){var n=self.performance.now();g.stats.buffering.end=n,l&&(l.stats.buffering.end=n);var e=l?l.stats:g.stats;o.hls.trigger(_.Events.FRAG_BUFFERED,{frag:g,part:l,stats:e,id:g.type})};d.length===0&&R.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(h,d)},y.onFragChanged=function(r,a){this.flushBackBuffer()},y.onBufferEos=function(r,a){var o=this,g=this.getSourceBufferTypes().reduce(function(l,d){var v=o.sourceBuffer[d];return(!a.type||a.type===d)&&(v&&!v.ended&&(v.ended=!0,R.logger.log("[buffer-controller]: "+d+" sourceBuffer now EOS"))),l&&!!(!v||v.ended)},!0);g&&this.blockBuffers(function(){var l=o.mediaSource;if(!l||l.readyState!=="open")return;l.endOfStream()})},y.onLevelUpdated=function(r,a){var o=a.details;if(!o.fragments.length)return;this.details=o,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},y.flushBackBuffer=function(){var r=this.hls,a=this.details,o=this.media,g=this.sourceBuffer;if(!o||a===null)return;var l=this.getSourceBufferTypes();if(!l.length)return;var d=a.live&&r.config.liveBackBufferLength!==null?r.config.liveBackBufferLength:r.config.backBufferLength;if(!Object(B.isFiniteNumber)(d)||d<0)return;var v=o.currentTime,h=a.levelTargetDuration,u=Math.max(d,h),n=Math.floor(v/h)*h-u;l.forEach(function(e){var t=g[e];if(t){var f=M.BufferHelper.getBuffered(t);f.length>0&&n>f.start(0)&&(r.trigger(_.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),a.live&&r.trigger(_.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),r.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:e}))}})},y.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var r=this.details,a=this.hls,o=this.media,g=this.mediaSource,l=r.fragments[0].start+r.totalduration,d=o.duration,v=Object(B.isFiniteNumber)(g.duration)?g.duration:0;r.live&&a.config.liveDurationInfinity?(R.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=Infinity,this.updateSeekableRange(r)):(l>v&&l>d||!Object(B.isFiniteNumber)(d))&&(R.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),g.duration=l)},y.updateSeekableRange=function(r){var a=this.mediaSource,o=r.fragments,g=o.length;if(g&&r.live&&a!==null&&a!==void 0&&a.setLiveSeekableRange){var l=Math.max(0,o[0].start),d=Math.max(l,l+r.totalduration);a.setLiveSeekableRange(l,d)}},y.checkPendingTracks=function(){var r=this.bufferCodecEventsExpected,a=this.operationQueue,o=this.pendingTracks,g=Object.keys(o).length;if(g&&!r||g===2){this.createSourceBuffers(o),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(_.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(d){a.executeNext(d)})}},y.createSourceBuffers=function(r){var a=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var l in r)if(!a[l]){var d=r[l];if(!d)throw Error("source buffer exists for track "+l+", however track does not");var v=d.levelCodec||d.codec,h=d.container+";codecs="+v;R.logger.log("[buffer-controller]: creating sourceBuffer("+h+")");try{var u=a[l]=o.addSourceBuffer(h),n=l;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[l]={buffer:u,codec:v,container:d.container,levelCodec:d.levelCodec,id:d.id},g++}catch(e){R.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(_.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:h})}}g&&this.hls.trigger(_.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(r){var a=this.operationQueue,o=a.current(r);o.onStart()},y._onSBUpdateEnd=function(r){var a=this.operationQueue,o=a.current(r);o.onComplete(),a.shiftAndExecuteNext(r)},y._onSBUpdateError=function(r,a){R.logger.error("[buffer-controller]: "+r+" SourceBuffer error",a),this.hls.trigger(_.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var o=this.operationQueue.current(r);o&&o.onError(a)},y.removeExecutor=function(r,a,o){var g=this.media,l=this.mediaSource,d=this.operationQueue,v=this.sourceBuffer,h=v[r];if(!g||!l||!h){R.logger.warn("[buffer-controller]: Attempting to remove from the "+r+" SourceBuffer, but it does not exist"),d.shiftAndExecuteNext(r);return}var u=Object(B.isFiniteNumber)(g.duration)?g.duration:Infinity,n=Object(B.isFiniteNumber)(l.duration)?l.duration:Infinity,e=Math.max(0,a),t=Math.min(o,u,n);t>e?(R.logger.log("[buffer-controller]: Removing ["+e+","+t+"] from the "+r+" SourceBuffer"),console.assert(!h.updating,r+" sourceBuffer must not be updating"),h.remove(e,t)):d.shiftAndExecuteNext(r)},y.appendExecutor=function(r,a){var o=this.operationQueue,g=this.sourceBuffer,l=g[a];if(!l){R.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(a);return}l.ended=!1,console.assert(!l.updating,a+" sourceBuffer must not be updating"),l.appendBuffer(r)},y.blockBuffers=function(r,a){var o=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length){R.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(r);return}var g=this.operationQueue,l=a.map(function(d){return g.appendBlocker(d)});Promise.all(l).then(function(){r(),a.forEach(function(d){var v=o.sourceBuffer[d];(!v||!v.updating)&&g.shiftAndExecuteNext(d)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(r,a,o){var g=this.sourceBuffer[r];if(!g)return;var l=o.bind(this,r);this.listeners[r].push({event:a,listener:l}),g.addEventListener(a,l)},y.removeBufferListeners=function(r){var a=this.sourceBuffer[r];if(!a)return;this.listeners[r].forEach(function(o){a.removeEventListener(o.event,o.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return _});var B=S("./src/utils/logger.ts"),_=function(){function R(M){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=M}var N=R.prototype;return N.append=function(O,w){var m=this.queues[w];m.push(O),m.length===1&&this.buffers[w]&&this.executeNext(w)},N.insertAbort=function(O,w){var m=this.queues[w];m.unshift(O),this.executeNext(w)},N.appendBlocker=function(O){var w,m=new Promise(function(C){w=C}),T={execute:w,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),m},N.executeNext=function(O){var w=this.buffers,m=this.queues,T=w[O],C=m[O];if(C.length){var b=C[0];try{b.execute()}catch(E){B.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),b.onError(E),(!T||!T.updating)&&(C.shift(),this.executeNext(O))}}},N.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},N.current=function(O){return this.queues[O][0]},R}()},"./src/controller/cap-level-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts");function _(M,O){for(var w=0;w<O.length;w++){var m=O[w];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(M,m.key,m)}}function R(M,O,w){return O&&_(M.prototype,O),w&&_(M,w),M}var N=function(){function M(w){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=w,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=M.prototype;return O.setStreamController=function(m){this.streamController=m},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 m=this.hls;m.on(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.on(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var m=this.hls;m.off(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.off(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(m,T){M.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},O.onMediaAttaching=function(m,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},O.onManifestParsed=function(m,T){var C=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,C.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(m,T){var C=this.hls;C.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(m.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},O.getMaxLevel=function(m){var T=this,C=this.hls.levels;if(!C.length)return-1;var b=C.filter(function(E,y){return M.isLevelAllowed(y,T.restrictedLevels)&&y<=m});return this.clientRect=null,M.getMaxLevelByMediaSize(b,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize()},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,T={width:0,height:0};if(m){var C=m.getBoundingClientRect();T.width=C.width,T.height=C.height,!T.width&&!T.height&&(T.width=C.right-C.left||m.width||0,T.height=C.bottom-C.top||m.height||0)}return this.clientRect=T,T},M.isLevelAllowed=function(m,T){return T===void 0&&(T=[]),T.indexOf(m)===-1},M.getMaxLevelByMediaSize=function(m,T,C){if(!m||!m.length)return-1;for(var b=function(a,o){return o?a.width!==o.width||a.height!==o.height:!0},E=m.length-1,y=0;y<m.length;y+=1){var c=m[y];if((c.width>=T||c.height>=C)&&b(c,m[y+1])){E=y;break}}return E},R(M,[{key:"mediaWidth",get:function(){return this.getDimensions().width*M.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*M.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch(T){}return m}}]),M}();F.default=N},"./src/controller/cmcd-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return b});var B=S("./src/events.ts"),_=S("./src/types/cmcd.ts"),R=S("./src/utils/buffer-helper.ts"),N=S("./src/utils/logger.ts");function M(E,y){for(var c=0;c<y.length;c++){var r=y[c];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(E,r.key,r)}}function O(E,y,c){return y&&M(E.prototype,y),c&&M(E,c),E}function w(E,y){var c=typeof Symbol!="undefined"&&E[Symbol.iterator]||E["@@iterator"];if(c)return(c=c.call(E)).next.bind(c);if(Array.isArray(E)||(c=m(E))||y&&E&&typeof E.length=="number"){c&&(E=c);var r=0;return function(){return r>=E.length?{done:!0}:{done:!1,value:E[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function m(E,y){if(!E)return;if(typeof E=="string")return T(E,y);var c=Object.prototype.toString.call(E).slice(8,-1);if(c==="Object"&&E.constructor&&(c=E.constructor.name),c==="Map"||c==="Set")return Array.from(E);if(c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return T(E,y)}function T(E,y){(y==null||y>E.length)&&(y=E.length);for(var c=0,r=new Array(y);c<y;c++)r[c]=E[c];return r}function C(){return C=Object.assign||function(E){for(var y=1;y<arguments.length;y++){var c=arguments[y];for(var r in c)Object.prototype.hasOwnProperty.call(c,r)&&(E[r]=c[r])}return E},C.apply(this,arguments)}var b=function(){function E(c){var r=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(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(g){try{r.apply(g,{ot:_.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(l){N.logger.warn("Could not generate manifest CMCD data.",l)}},this.applyFragmentData=function(g){try{var l=g.frag,d=r.hls.levels[l.level],v=r.getObjectType(l),h={d:l.duration*1e3,ot:v};(v===_.CMCDObjectType.VIDEO||v===_.CMCDObjectType.AUDIO||v==_.CMCDObjectType.MUXED)&&(h.br=d.bitrate/1e3,h.tb=r.getTopBandwidth(v),h.bl=r.getBufferLength(v)),r.apply(g,h)}catch(u){N.logger.warn("Could not generate segment CMCD data.",u)}},this.hls=c;var a=this.config=c.config,o=a.cmcd;o!=null&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||E.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var y=E.prototype;return y.registerListeners=function(){var r=this.hls;r.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this)},y.unregisterListeners=function(){var r=this.hls;r.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(r,a){this.media=a.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},y.onBufferCreated=function(r,a){var o,g;this.audioBuffer=(o=a.tracks.audio)===null||o===void 0?void 0:o.buffer,this.videoBuffer=(g=a.tracks.video)===null||g===void 0?void 0:g.buffer},y.createData=function(){var r;return{v:_.CMCDVersion,sf:_.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(r=this.media)===null||r===void 0?void 0:r.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},y.apply=function(r,a){a===void 0&&(a={}),C(a,this.createData());var o=a.ot===_.CMCDObjectType.INIT||a.ot===_.CMCDObjectType.VIDEO||a.ot===_.CMCDObjectType.MUXED;if(this.starved&&o&&(a.bs=!0,a.su=!0,this.starved=!1),a.su==null&&(a.su=this.buffering),this.useHeaders){var g=E.toHeaders(a);if(!Object.keys(g).length)return;r.headers||(r.headers={}),C(r.headers,g)}else{var l=E.toQuery(a);if(!l)return;r.url=E.appendQueryToUri(r.url,l)}},y.getObjectType=function(r){var a=r.type;return a==="subtitle"?_.CMCDObjectType.TIMED_TEXT:r.sn==="initSegment"?_.CMCDObjectType.INIT:a==="audio"?_.CMCDObjectType.AUDIO:a==="main"?this.hls.audioTracks.length?_.CMCDObjectType.VIDEO:_.CMCDObjectType.MUXED:void 0},y.getTopBandwidth=function(r){for(var a=0,o=r===_.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,g=w(o),l;!(l=g()).done;){var d=l.value;d.bitrate>a&&(a=d.bitrate)}return a>0?a:NaN},y.getBufferLength=function(r){var a=this.hls.media,o=r===_.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!o||!a)return NaN;var g=R.BufferHelper.bufferInfo(o,a.currentTime,this.config.maxBufferHole);return g.len*1e3},y.createPlaylistLoader=function(){var r=this.config.pLoader,a=this.applyPlaylistData,o=r||this.config.loader;return function(){function g(d){this.loader=void 0,this.loader=new o(d)}var l=g.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(v,h,u){a(v),this.loader.load(v,h,u)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},y.createFragmentLoader=function(){var r=this.config.fLoader,a=this.applyFragmentData,o=r||this.config.loader;return function(){function g(d){this.loader=void 0,this.loader=new o(d)}var l=g.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(v,h,u){a(v),this.loader.load(v,h,u)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},E.uuid=function(){var r=URL.createObjectURL(new Blob),a=r.toString();return URL.revokeObjectURL(r),a.substr(a.lastIndexOf("/")+1)},E.serialize=function(r){for(var a=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},g=function(I){return Math.round(I)},l=function(I){return g(I/100)*100},d=function(I){return encodeURIComponent(I)},v={br:g,d:g,bl:l,dl:l,mtp:l,nor:d,rtp:l,tb:g},h=Object.keys(r||{}).sort(),u=w(h),n;!(n=u()).done;){var e=n.value,t=r[e];if(!o(t))continue;if(e==="v"&&t===1)continue;if(e=="pr"&&t===1)continue;var f=v[e];f&&(t=f(t));var p=typeof t,x=void 0;e==="ot"||e==="sf"||e==="st"?x=e+"="+t:p==="boolean"?x=e:p==="number"?x=e+"="+t:x=e+"="+JSON.stringify(t),a.push(x)}return a.join(",")},E.toHeaders=function(r){for(var a=Object.keys(r),o={},g=["Object","Request","Session","Status"],l=[{},{},{},{}],d={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},v=0,h=a;v<h.length;v++){var u=h[v],n=d[u]!=null?d[u]:1;l[n][u]=r[u]}for(var e=0;e<l.length;e++){var t=E.serialize(l[e]);t&&(o["CMCD-"+g[e]]=t)}return o},E.toQuery=function(r){return"CMCD="+encodeURIComponent(E.serialize(r))},E.appendQueryToUri=function(r,a){if(!a)return r;var o=r.includes("?")?"&":"?";return""+r+o+a},E}()},"./src/controller/eme-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts"),_=S("./src/errors.ts"),R=S("./src/utils/logger.ts"),N=S("./src/utils/mediakeys-helper.ts");function M(b,E){for(var y=0;y<E.length;y++){var c=E[y];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(b,c.key,c)}}function O(b,E,y){return E&&M(b.prototype,E),y&&M(b,y),b}var w=3,m=function(E,y,c){var r={audioCapabilities:[],videoCapabilities:[]};return E.forEach(function(a){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+a+'"',robustness:c.audioRobustness||""})}),y.forEach(function(a){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+a+'"',robustness:c.videoRobustness||""})}),[r]},T=function(E,y,c,r){switch(E){case N.KeySystems.WIDEVINE:return m(y,c,r);default:throw new Error("Unknown key-system: "+E)}},C=function(){function b(y){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=y,this._config=y.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=b.prototype;return E.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},E._registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this)},E._unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this)},E.getLicenseServerUrl=function(c){switch(c){case N.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+c+'"')},E._attemptKeySystemAccess=function(c,r,a){var o=this,g=T(c,r,a,this._drmSystemOptions);R.logger.log("Requesting encrypted media key-system access");var l=this.requestMediaKeySystemAccess(c,g);this.mediaKeysPromise=l.then(function(d){return o._onMediaKeySystemAccessObtained(c,d)}),l.catch(function(d){R.logger.error('Failed to obtain key-system "'+c+'" access:',d)})},E._onMediaKeySystemAccessObtained=function(c,r){var a=this;R.logger.log('Access for key-system "'+c+'" obtained');var o={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:r,mediaKeySystemDomain:c};this._mediaKeysList.push(o);var g=Promise.resolve().then(function(){return r.createMediaKeys()}).then(function(l){return o.mediaKeys=l,R.logger.log('Media-keys created for key-system "'+c+'"'),a._onMediaKeysCreated(),l});return g.catch(function(l){R.logger.error("Failed to create media-keys:",l)}),g},E._onMediaKeysCreated=function(){var c=this;this._mediaKeysList.forEach(function(r){r.mediaKeysSession||(r.mediaKeysSession=r.mediaKeys.createSession(),c._onNewMediaKeySession(r.mediaKeysSession))})},E._onNewMediaKeySession=function(c){var r=this;R.logger.log("New key-system session "+c.sessionId),c.addEventListener("message",function(a){r._onKeySessionMessage(c,a.message)},!1)},E._onKeySessionMessage=function(c,r){R.logger.log("Got EME message event, creating license request"),this._requestLicense(r,function(a){R.logger.log("Received license data (length: "+(a&&a.byteLength)+"), updating key-session"),c.update(a)})},E.onMediaEncrypted=function(c){var r=this;if(R.logger.log('Media is encrypted using "'+c.initDataType+'" init data type'),!this.mediaKeysPromise){R.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var a=function(g){if(!r._media)return;r._attemptSetMediaKeys(g),r._generateRequestWithPreferredKeySession(c.initDataType,c.initData)};this.mediaKeysPromise.then(a).catch(a)},E._attemptSetMediaKeys=function(c){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){R.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}R.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(r.mediaKeys),this._hasSetMediaKeys=!0}},E._generateRequestWithPreferredKeySession=function(c,r){var a=this,o=this._mediaKeysList[0];if(!o){R.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(o.mediaKeysSessionInitialized){R.logger.warn("Key-Session already initialized but requested again");return}var g=o.mediaKeysSession;if(!g){R.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!r){R.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}R.logger.log('Generating key-session request for "'+c+'" init data type'),o.mediaKeysSessionInitialized=!0,g.generateRequest(c,r).then(function(){R.logger.debug("Key-session generation succeeded")}).catch(function(l){R.logger.error("Error generating key-session request:",l),a.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},E._createLicenseXhr=function(c,r,a){var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,o,c,r,a);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,o,c),g=void 0}catch(l){R.logger.error(l)}try{o.readyState||o.open("POST",c,!0),g&&g.call(this.hls,o,c)}catch(l){throw new Error("issue setting up KeySystem license XHR "+l)}return o},E._onLicenseRequestReadyStageChange=function(c,r,a,o){switch(c.readyState){case 4:if(c.status===200){this._requestLicenseFailureCount=0,R.logger.log("License request succeeded");var g=c.response,l=this._licenseResponseCallback;if(l)try{g=l.call(this.hls,c,r)}catch(v){R.logger.error(v)}o(g)}else{if(R.logger.error("License Request XHR failed ("+r+"). Status: "+c.status+" ("+c.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>w){this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var d=w-this._requestLicenseFailureCount+1;R.logger.warn("Retrying license request, "+d+" attempts left"),this._requestLicense(a,o)}break}},E._generateLicenseRequestChallenge=function(c,r){switch(c.mediaKeySystemDomain){case N.KeySystems.WIDEVINE:return r}throw new Error("unsupported key-system: "+c.mediaKeySystemDomain)},E._requestLicense=function(c,r){R.logger.log("Requesting content license for key-system");var a=this._mediaKeysList[0];if(!a){R.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var o=this.getLicenseServerUrl(a.mediaKeySystemDomain),g=this._createLicenseXhr(o,c,r);R.logger.log("Sending license request to URL: "+o);var l=this._generateLicenseRequestChallenge(a,c);g.send(l)}catch(d){R.logger.error("Failure requesting DRM license: "+d),this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.KEY_SYSTEM_ERROR,details:_.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},E.onMediaAttached=function(c,r){if(!this._emeEnabled)return;var a=r.media;this._media=a,a.addEventListener("encrypted",this._onMediaEncrypted)},E.onMediaDetached=function(){var c=this._media,r=this._mediaKeysList;if(!c)return;c.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(r.map(function(a){if(a.mediaKeysSession)return a.mediaKeysSession.close().catch(function(){})})).then(function(){return c.setMediaKeys(null)}).catch(function(){})},E.onManifestParsed=function(c,r){if(!this._emeEnabled)return;var a=r.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),o=r.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(N.KeySystems.WIDEVINE,a,o)},O(b,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),b}();F.default=C},"./src/controller/fps-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts"),_=S("./src/utils/logger.ts"),R=function(){function N(O){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=O,this.registerListeners()}var M=N.prototype;return M.setStreamController=function(w){this.streamController=w},M.registerListeners=function(){this.hls.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},M.unregisterListeners=function(){this.hls.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching)},M.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},M.onMediaAttaching=function(w,m){var T=this.hls.config;if(T.capLevelOnFPSDrop){var C=m.media instanceof self.HTMLVideoElement?m.media:null;this.media=C,C&&typeof C.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},M.checkFPS=function(w,m,T){var C=performance.now();if(m){if(this.lastTime){var b=C-this.lastTime,E=T-this.lastDroppedFrames,y=m-this.lastDecodedFrames,c=1e3*E/b,r=this.hls;if(r.trigger(B.Events.FPS_DROP,{currentDropped:E,currentDecoded:y,totalDroppedFrames:T}),c>0&&E>r.config.fpsDroppedMonitoringThreshold*y){var a=r.currentLevel;_.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(r.autoLevelCapping===-1||r.autoLevelCapping>=a)&&(a=a-1,r.trigger(B.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:r.currentLevel}),r.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=C,this.lastDroppedFrames=T,this.lastDecodedFrames=m}},M.checkFPSInterval=function(){var w=this.media;if(w)if(this.isVideoPlaybackQualityAvailable){var m=w.getVideoPlaybackQuality();this.checkFPS(w,m.totalVideoFrames,m.droppedVideoFrames)}else this.checkFPS(w,w.webkitDecodedFrameCount,w.webkitDroppedFrameCount)},N}();F.default=R},"./src/controller/fragment-finders.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"findFragmentByPDT",function(){return R}),S.d(F,"findFragmentByPTS",function(){return N}),S.d(F,"fragmentWithinToleranceTest",function(){return M}),S.d(F,"pdtWithinToleranceTest",function(){return O}),S.d(F,"findFragWithCC",function(){return w});var B=S("./src/polyfills/number.ts"),_=S("./src/utils/binary-search.ts");function R(m,T,C){if(T===null||!Array.isArray(m)||!m.length||!Object(B.isFiniteNumber)(T))return null;var b=m[0].programDateTime;if(T<(b||0))return null;var E=m[m.length-1].endProgramDateTime;if(T>=(E||0))return null;C=C||0;for(var y=0;y<m.length;++y){var c=m[y];if(O(T,C,c))return c}return null}function N(m,T,C,b){C===void 0&&(C=0),b===void 0&&(b=0);var E=null;if(m?E=T[m.sn-T[0].sn+1]||null:C===0&&T[0].start===0&&(E=T[0]),E&&M(C,b,E)===0)return E;var y=_.default.search(T,M.bind(null,C,b));return y||E}function M(m,T,C){m===void 0&&(m=0),T===void 0&&(T=0);var b=Math.min(T,C.duration+(C.deltaPTS?C.deltaPTS:0));return C.start+C.duration-b<=m?1:C.start-b>m&&C.start?-1:0}function O(m,T,C){var b=Math.min(T,C.duration+(C.deltaPTS?C.deltaPTS:0))*1e3,E=C.endProgramDateTime||0;return E-b>m}function w(m,T){return _.default.search(m,function(C){return C.cc<T?1:C.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"FragmentState",function(){return R}),S.d(F,"FragmentTracker",function(){return N});var B=S("./src/events.ts"),_=S("./src/types/loader.ts"),R;(function(w){w.NOT_LOADED="NOT_LOADED",w.BACKTRACKED="BACKTRACKED",w.APPENDING="APPENDING",w.PARTIAL="PARTIAL",w.OK="OK"})(R||(R={}));var N=function(){function w(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 m=w.prototype;return m._registerListeners=function(){var C=this.hls;C.on(B.Events.BUFFER_APPENDED,this.onBufferAppended,this),C.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this),C.on(B.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var C=this.hls;C.off(B.Events.BUFFER_APPENDED,this.onBufferAppended,this),C.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this),C.off(B.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(C,b){if(b===_.PlaylistLevelType.MAIN){var E=this.activeFragment,y=this.activeParts;if(!E)return null;if(y)for(var c=y.length;c--;){var r=y[c],a=r?r.end:E.appendedPTS;if(r.start<=C&&a!==void 0&&C<=a)return c>9&&(this.activeParts=y.slice(c-9)),r}else if(E.start<=C&&E.appendedPTS!==void 0&&C<=E.appendedPTS)return E}return this.getBufferedFrag(C,b)},m.getBufferedFrag=function(C,b){for(var E=this.fragments,y=Object.keys(E),c=y.length;c--;){var r=E[y[c]];if((r==null?void 0:r.body.type)===b&&r.buffered){var a=r.body;if(a.start<=C&&C<=a.end)return a}}return null},m.detectEvictedFragments=function(C,b,E){var y=this;Object.keys(this.fragments).forEach(function(c){var r=y.fragments[c];if(!r)return;if(!r.buffered){r.body.type===E&&y.removeFragment(r.body);return}var a=r.range[C];if(!a)return;a.time.some(function(o){var g=!y.isTimeBuffered(o.startPTS,o.endPTS,b);return g&&y.removeFragment(r.body),g})})},m.detectPartialFragments=function(C){var b=this,E=this.timeRanges,y=C.frag,c=C.part;if(!E||y.sn==="initSegment")return;var r=O(y),a=this.fragments[r];if(!a)return;Object.keys(E).forEach(function(o){var g=y.elementaryStreams[o];if(!g)return;var l=E[o],d=c!==null||g.partial===!0;a.range[o]=b.getBufferedTimes(y,c,d,l)}),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body)},m.fragBuffered=function(C){var b=O(C),E=this.fragments[b];E&&(E.backtrack=E.loaded=null,E.buffered=!0)},m.getBufferedTimes=function(C,b,E,y){for(var c={time:[],partial:E},r=b?b.start:C.start,a=b?b.end:C.end,o=C.minEndPTS||a,g=C.maxStartPTS||r,l=0;l<y.length;l++){var d=y.start(l)-this.bufferPadding,v=y.end(l)+this.bufferPadding;if(g>=d&&o<=v){c.time.push({startPTS:Math.max(r,y.start(l)),endPTS:Math.min(a,y.end(l))});break}else if(r<v&&a>d)c.partial=!0,c.time.push({startPTS:Math.max(r,y.start(l)),endPTS:Math.min(a,y.end(l))});else if(a<=d)break}return c},m.getPartialFragment=function(C){var b=null,E,y,c,r=0,a=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(g){var l=o[g];if(!l)return;M(l)&&(y=l.body.start-a,c=l.body.end+a,C>=y&&C<=c&&(E=Math.min(C-y,c-C),r<=E&&(b=l.body,r=E)))}),b},m.getState=function(C){var b=O(C),E=this.fragments[b];return E?E.buffered?M(E)?R.PARTIAL:R.OK:E.backtrack?R.BACKTRACKED:R.APPENDING:R.NOT_LOADED},m.backtrack=function(C,b){var E=O(C),y=this.fragments[E];if(!y||y.backtrack)return null;var c=y.backtrack=b||y.loaded;return y.loaded=null,c},m.getBacktrackData=function(C){var b=O(C),E=this.fragments[b];if(E){var y,c=E.backtrack;if(c!=null&&(y=c.payload)!==null&&y!==void 0&&y.byteLength)return c;this.removeFragment(C)}return null},m.isTimeBuffered=function(C,b,E){for(var y,c,r=0;r<E.length;r++){if(y=E.start(r)-this.bufferPadding,c=E.end(r)+this.bufferPadding,C>=y&&b<=c)return!0;if(b<=y)return!1}return!1},m.onFragLoaded=function(C,b){var E=b.frag,y=b.part;if(E.sn==="initSegment"||E.bitrateTest||y)return;var c=O(E);this.fragments[c]={body:E,loaded:b,backtrack:null,buffered:!1,range:Object.create(null)}},m.onBufferAppended=function(C,b){var E=this,y=b.frag,c=b.part,r=b.timeRanges;if(y.type===_.PlaylistLevelType.MAIN)if(this.activeFragment=y,c){var a=this.activeParts;a||(this.activeParts=a=[]),a.push(c)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(o){var g=r[o];if(E.detectEvictedFragments(o,g),!c)for(var l=0;l<g.length;l++)y.appendedPTS=Math.max(g.end(l),y.appendedPTS||0)})},m.onFragBuffered=function(C,b){this.detectPartialFragments(b)},m.hasFragment=function(C){var b=O(C);return!!this.fragments[b]},m.removeFragmentsInRange=function(C,b,E){var y=this;Object.keys(this.fragments).forEach(function(c){var r=y.fragments[c];if(!r)return;if(r.buffered){var a=r.body;a.type===E&&a.start<b&&a.end>C&&y.removeFragment(a)}})},m.removeFragment=function(C){var b=O(C);C.stats.loaded=0,C.clearElementaryStreamInfo(),delete this.fragments[b]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},w}();function M(w){var m,T;return w.buffered&&(((m=w.range.video)===null||m===void 0?void 0:m.partial)||((T=w.range.audio)===null||T===void 0?void 0:T.partial))}function O(w){return w.type+"_"+w.level+"_"+w.urlId+"_"+w.sn}},"./src/controller/gap-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"STALL_MINIMUM_DURATION_MS",function(){return M}),S.d(F,"MAX_START_GAP_JUMP",function(){return O}),S.d(F,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return w}),S.d(F,"SKIP_BUFFER_RANGE_START",function(){return m}),S.d(F,"default",function(){return T});var B=S("./src/utils/buffer-helper.ts"),_=S("./src/errors.ts"),R=S("./src/events.ts"),N=S("./src/utils/logger.ts"),M=250,O=2,w=.1,m=.05,T=function(){function C(E,y,c,r){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=E,this.media=y,this.fragmentTracker=c,this.hls=r}var b=C.prototype;return b.destroy=function(){this.hls=this.fragmentTracker=this.media=null},b.poll=function(y){var c=this.config,r=this.media,a=this.stalled,o=r.currentTime,g=r.seeking,l=this.seeking&&!g,d=!this.seeking&&g;if(this.seeking=g,o!==y){if(this.moved=!0,a!==null){if(this.stallReported){var v=self.performance.now()-a;N.logger.warn("playback not stuck anymore @"+o+", after "+Math.round(v)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((d||l)&&(this.stalled=null),r.paused||r.ended||r.playbackRate===0||!B.BufferHelper.getBuffered(r).length)return;var h=B.BufferHelper.bufferInfo(r,o,0),u=h.len>0,n=h.nextStart||0;if(!u&&!n)return;if(g){var e=h.len>O,t=!n||n-o>O&&!this.fragmentTracker.getPartialFragment(o);if(e||t)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f,p=Math.max(n,h.start||0)-o,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,A=x==null||((f=x.details)===null||f===void 0)?void 0:f.live,I=A?x.details.targetduration*2:O;if(p>0&&p<=I){this._trySkipBufferHole(null);return}}var U=self.performance.now();if(a===null){this.stalled=U;return}var j=U-a;!g&&j>=M&&this._reportStall(h.len);var z=B.BufferHelper.bufferInfo(r,o,c.maxBufferHole);this._tryFixBufferStall(z,j)},b._tryFixBufferStall=function(y,c){var r=this.config,a=this.fragmentTracker,o=this.media,g=o.currentTime,l=a.getPartialFragment(g);if(l){var d=this._trySkipBufferHole(l);if(d)return}y.len>r.maxBufferHole&&c>r.highBufferWatchdogPeriod*1e3&&(N.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},b._reportStall=function(y){var c=this.hls,r=this.media,a=this.stallReported;a||(this.stallReported=!0,N.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+y+")"),c.trigger(R.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},b._trySkipBufferHole=function(y){for(var c=this.config,r=this.hls,a=this.media,o=a.currentTime,g=0,l=B.BufferHelper.getBuffered(a),d=0;d<l.length;d++){var v=l.start(d);if(o+c.maxBufferHole>=g&&o<v){var h=Math.max(v+m,a.currentTime+w);return N.logger.warn("skipping hole, adjusting currentTime from "+o+" to "+h),this.moved=!0,this.stalled=null,a.currentTime=h,y&&r.trigger(R.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+o+" to "+h,frag:y}),h}g=l.end(d)}return 0},b._tryNudgeBuffer=function(){var y=this.config,c=this.hls,r=this.media,a=r.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<y.nudgeMaxRetry){var g=a+o*y.nudgeOffset;N.logger.warn("Nudging 'currentTime' from "+a+" to "+g),r.currentTime=g,c.trigger(R.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else N.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+y.nudgeMaxRetry+" nudges"),c.trigger(R.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},C}()},"./src/controller/id3-track-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts"),_=S("./src/utils/texttrack-utils.ts"),R=S("./src/demux/id3.ts"),N=.25,M=function(){function O(m){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=m,this._registerListeners()}var w=O.prototype;return w.destroy=function(){this._unregisterListeners()},w._registerListeners=function(){var T=this.hls;T.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.on(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w._unregisterListeners=function(){var T=this.hls;T.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w.onMediaAttached=function(T,C){this.media=C.media},w.onMediaDetaching=function(){if(!this.id3Track)return;Object(_.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},w.getID3Track=function(T){if(!this.media)return;for(var C=0;C<T.length;C++){var b=T[C];if(b.kind==="metadata"&&b.label==="id3")return Object(_.sendAddTrackEvent)(b,this.media),b}return this.media.addTextTrack("metadata","id3")},w.onFragParsingMetadata=function(T,C){if(!this.media)return;var b=C.frag,E=C.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var y=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,c=0;c<E.length;c++){var r=R.getID3Frames(E[c].data);if(r){var a=E[c].pts,o=c<E.length-1?E[c+1].pts:b.end,g=o-a;g<=0&&(o=a+N);for(var l=0;l<r.length;l++){var d=r[l];if(!R.isTimeStampFrame(d)){var v=new y(a,o,"");v.value=d,this.id3Track.addCue(v)}}}}},w.onBufferFlushing=function(T,C){var b=C.startOffset,E=C.endOffset,y=C.type;if(!y||y==="audio"){var c=this.id3Track;c&&Object(_.removeCuesInRange)(c,b,E)}},O}();F.default=M},"./src/controller/latency-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return O});var B=S("./src/errors.ts"),_=S("./src/events.ts"),R=S("./src/utils/logger.ts");function N(w,m){for(var T=0;T<m.length;T++){var C=m[T];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function M(w,m,T){return m&&N(w.prototype,m),T&&N(w,T),w}var O=function(){function w(T){var C=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 C.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var m=w.prototype;return m.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},m.registerListeners=function(){this.hls.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){this.hls.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(_.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(_.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(_.Events.ERROR,this.onError)},m.onMediaAttached=function(C,b){this.media=b.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},m.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},m.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},m.onLevelUpdated=function(C,b){var E=b.details;this.levelDetails=E,E.advanced&&this.timeupdate(),!E.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},m.onError=function(C,b){if(b.details!==B.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,R.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},m.timeupdate=function(){var C=this.media,b=this.levelDetails;if(!C||!b)return;this.currentTime=C.currentTime;var E=this.computeLatency();if(E===null)return;this._latency=E;var y=this.config,c=y.lowLatencyMode,r=y.maxLiveSyncPlaybackRate;if(!c||r===1)return;var a=this.targetLatency;if(a===null)return;var o=E-a,g=Math.min(this.maxLatency,a+b.targetduration),l=o<g;if(b.live&&l&&o>.05&&this.forwardBufferLength>1){var d=Math.min(2,Math.max(1,r)),v=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;C.playbackRate=Math.min(d,Math.max(1,v))}else C.playbackRate!==1&&C.playbackRate!==0&&(C.playbackRate=1)},m.estimateLiveEdge=function(){var C=this.levelDetails;return C===null?null:C.edge+C.age},m.computeLatency=function(){var C=this.estimateLiveEdge();return C===null?null:C-this.currentTime},M(w,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var C=this.config,b=this.levelDetails;return C.liveMaxLatencyDuration!==void 0?C.liveMaxLatencyDuration:b?C.liveMaxLatencyDurationCount*b.targetduration:0}},{key:"targetLatency",get:function(){var C=this.levelDetails;if(C===null)return null;var b=C.holdBack,E=C.partHoldBack,y=C.targetduration,c=this.config,r=c.liveSyncDuration,a=c.liveSyncDurationCount,o=c.lowLatencyMode,g=this.hls.userConfig,l=o&&E||b;(g.liveSyncDuration||g.liveSyncDurationCount||l===0)&&(l=r!==void 0?r:a*y);var d=y,v=1;return l+Math.min(this.stallCount*v,d)}},{key:"liveSyncPosition",get:function(){var C=this.estimateLiveEdge(),b=this.targetLatency,E=this.levelDetails;if(C===null||b===null||E===null)return null;var y=E.edge,c=C-b-this.edgeStalled,r=y-E.totalduration,a=y-(this.config.lowLatencyMode&&E.partTarget||E.targetduration);return Math.min(Math.max(r,c),a)}},{key:"drift",get:function(){var C=this.levelDetails;return C===null?1:C.drift}},{key:"edgeStalled",get:function(){var C=this.levelDetails;if(C===null)return 0;var b=(this.config.lowLatencyMode&&C.partTarget||C.targetduration)*3;return Math.max(C.age-b,0)}},{key:"forwardBufferLength",get:function(){var C=this.media,b=this.levelDetails;if(!C||!b)return 0;var E=C.buffered.length;return E?C.buffered.end(E-1):b.edge-this.currentTime}}]),w}()},"./src/controller/level-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return c});var B=S("./src/types/level.ts"),_=S("./src/events.ts"),R=S("./src/errors.ts"),N=S("./src/utils/codecs.ts"),M=S("./src/controller/level-helper.ts"),O=S("./src/controller/base-playlist-controller.ts"),w=S("./src/types/loader.ts");function m(){return m=Object.assign||function(r){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var g in o)Object.prototype.hasOwnProperty.call(o,g)&&(r[g]=o[g])}return r},m.apply(this,arguments)}function T(r,a){for(var o=0;o<a.length;o++){var g=a[o];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(r,g.key,g)}}function C(r,a,o){return a&&T(r.prototype,a),o&&T(r,o),r}function b(r,a){r.prototype=Object.create(a.prototype),r.prototype.constructor=r,E(r,a)}function E(r,a){return E=Object.setPrototypeOf||function(g,l){return g.__proto__=l,g},E(r,a)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),c=function(r){b(a,r);function a(g){var l;return l=r.call(this,g,"[level-controller]")||this,l._levels=[],l._firstLevel=-1,l._startLevel=void 0,l.currentLevelIndex=-1,l.manualLevelIndex=-1,l.onParsedComplete=void 0,l._registerListeners(),l}var o=a.prototype;return o._registerListeners=function(){var l=this.hls;l.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(_.Events.ERROR,this.onError,this)},o._unregisterListeners=function(){var l=this.hls;l.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(_.Events.ERROR,this.onError,this)},o.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,r.prototype.destroy.call(this)},o.startLoad=function(){var l=this._levels;l.forEach(function(d){d.loadError=0}),r.prototype.startLoad.call(this)},o.onManifestLoaded=function(l,d){var v=[],h=[],u=[],n,e={},t,f=!1,p=!1,x=!1;if(d.levels.forEach(function(j){var z=j.attrs;f=f||!!(j.width&&j.height),p=p||!!j.videoCodec,x=x||!!j.audioCodec,y&&j.audioCodec&&j.audioCodec.indexOf("mp4a.40.34")!==-1&&(j.audioCodec=void 0);var V=j.bitrate+"-"+j.attrs.RESOLUTION+"-"+j.attrs.CODECS;t=e[V],t?t.url.push(j.url):(t=new B.Level(j),e[V]=t,v.push(t)),z&&(z.AUDIO&&Object(M.addGroupId)(t,"audio",z.AUDIO),z.SUBTITLES&&Object(M.addGroupId)(t,"text",z.SUBTITLES))}),(f||p)&&x&&(v=v.filter(function(j){var z=j.videoCodec,V=j.width,G=j.height;return!!z||!!(V&&G)})),v=v.filter(function(j){var z=j.audioCodec,V=j.videoCodec;return(!z||Object(N.isCodecSupportedInMp4)(z,"audio"))&&(!V||Object(N.isCodecSupportedInMp4)(V,"video"))}),d.audioTracks&&(h=d.audioTracks.filter(function(j){return!j.audioCodec||Object(N.isCodecSupportedInMp4)(j.audioCodec,"audio")}),Object(M.assignTrackIdsByGroup)(h)),d.subtitles&&(u=d.subtitles,Object(M.assignTrackIdsByGroup)(u)),v.length>0){n=v[0].bitrate,v.sort(function(j,z){return j.bitrate-z.bitrate}),this._levels=v;for(var A=0;A<v.length;A++)if(v[A].bitrate===n){this._firstLevel=A,this.log("manifest loaded, "+v.length+" level(s) found, first bitrate: "+n);break}var I=x&&!p,U={levels:v,audioTracks:h,subtitleTracks:u,firstLevel:this._firstLevel,stats:d.stats,audio:x,video:p,altAudio:!I&&h.some(function(j){return!!j.url})};this.hls.trigger(_.Events.MANIFEST_PARSED,U),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(_.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:d.url,reason:"no level with compatible codecs found in manifest"})},o.onError=function(l,d){if(r.prototype.onError.call(this,l,d),d.fatal)return;var v=d.context,h=this._levels[this.currentLevelIndex];if(v&&(v.type===w.PlaylistContextType.AUDIO_TRACK&&h.audioGroupIds&&v.groupId===h.audioGroupIds[h.urlId]||v.type===w.PlaylistContextType.SUBTITLE_TRACK&&h.textGroupIds&&v.groupId===h.textGroupIds[h.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,n=!0,e;switch(d.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:case R.ErrorDetails.KEY_LOAD_ERROR:case R.ErrorDetails.KEY_LOAD_TIMEOUT:if(d.frag){var t=this._levels[d.frag.level];t?(t.fragmentError++,t.fragmentError>this.hls.config.fragLoadingMaxRetry&&(e=d.frag.level)):e=d.frag.level}break;case R.ErrorDetails.LEVEL_LOAD_ERROR:case R.ErrorDetails.LEVEL_LOAD_TIMEOUT:v&&(v.deliveryDirectives&&(n=!1),e=v.level),u=!0;break;case R.ErrorDetails.REMUX_ALLOC_ERROR:e=d.level,u=!0;break}e!==void 0&&this.recoverLevel(d,e,u,n)},o.recoverLevel=function(l,d,v,h){var u=l.details,n=this._levels[d];if(n.loadError++,v){var e=this.retryLoadingOrFail(l);if(e)l.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(h){var t=n.url.length;if(t>1&&n.loadError<t)l.levelRetry=!0,this.redundantFailover(d);else if(this.manualLevelIndex===-1){var f=d===0?this._levels.length-1:d-1;this.currentLevelIndex!==f&&this._levels[f].loadError===0&&(this.warn(u+": switch to "+f),l.levelRetry=!0,this.hls.nextAutoLevel=f)}}},o.redundantFailover=function(l){var d=this._levels[l],v=d.url.length;if(v>1){var h=(d.urlId+1)%v;this.warn("Switching to redundant URL-id "+h),this._levels.forEach(function(u){u.urlId=h}),this.level=l}},o.onFragLoaded=function(l,d){var v=d.frag;if(v!==void 0&&v.type===w.PlaylistLevelType.MAIN){var h=this._levels[v.level];h!==void 0&&(h.fragmentError=0,h.loadError=0)}},o.onLevelLoaded=function(l,d){var v,h=d.level,u=d.details,n=this._levels[h];if(!n){var e;this.warn("Invalid level index "+h),(e=d.deliveryDirectives)!==null&&e!==void 0&&e.skip&&(u.deltaUpdateFailed=!0);return}h===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(h,d,n.details)):(v=d.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(u.deltaUpdateFailed=!0)},o.onAudioTrackSwitched=function(l,d){var v=this.hls.levels[this.currentLevelIndex];if(!v)return;if(v.audioGroupIds){for(var h=-1,u=this.hls.audioTracks[d.id].groupId,n=0;n<v.audioGroupIds.length;n++)if(v.audioGroupIds[n]===u){h=n;break}h!==v.urlId&&(v.urlId=h,this.startLoad())}},o.loadPlaylist=function(l){var d=this.currentLevelIndex,v=this._levels[d];if(this.canLoad&&v&&v.url.length>0){var h=v.urlId,u=v.url[h];if(l)try{u=l.addDirectives(u)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Attempt loading level index "+d+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+h+" "+u),this.clearTimer(),this.hls.trigger(_.Events.LEVEL_LOADING,{url:u,level:d,id:h,deliveryDirectives:l||null})}},o.removeLevel=function(l,d){var v=function(n,e){return e!==d},h=this._levels.filter(function(u,n){return n!==l?!0:u.url.length>1&&d!==void 0?(u.url=u.url.filter(v),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(v)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(v)),u.urlId=0,!0):!1}).map(function(u,n){var e=u.details;return e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=n}),u});this._levels=h,this.hls.trigger(_.Events.LEVELS_UPDATED,{levels:h})},C(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var d,v=this._levels;if(v.length===0)return;if(this.currentLevelIndex===l&&(d=v[l])!==null&&d!==void 0&&d.details)return;if(l<0||l>=v.length){var h=l<0;if(this.hls.trigger(_.Events.ERROR,{type:R.ErrorTypes.OTHER_ERROR,details:R.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:h,reason:"invalid level idx"}),h)return;l=Math.min(l,v.length-1)}this.clearTimer();var u=this.currentLevelIndex,n=v[u],e=v[l];this.log("switching to level "+l+" from "+u),this.currentLevelIndex=l;var t=m({},e,{level:l,maxBitrate:e.maxBitrate,uri:e.uri,urlId:e.urlId});delete t._urlId,this.hls.trigger(_.Events.LEVEL_SWITCHING,t);var f=e.details;if(!f||f.live){var p=this.switchParams(e.uri,n==null?void 0:n.details);this.loadPlaylist(p)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}else return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}]),a}(O.default)},"./src/controller/level-helper.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"addGroupId",function(){return R}),S.d(F,"assignTrackIdsByGroup",function(){return N}),S.d(F,"updatePTS",function(){return M}),S.d(F,"updateFragPTSDTS",function(){return w}),S.d(F,"mergeDetails",function(){return m}),S.d(F,"mapPartIntersection",function(){return T}),S.d(F,"mapFragmentIntersection",function(){return C}),S.d(F,"adjustSliding",function(){return b}),S.d(F,"addSliding",function(){return E}),S.d(F,"computeReloadInterval",function(){return y}),S.d(F,"getFragmentWithSN",function(){return c}),S.d(F,"getPartWith",function(){return r});var B=S("./src/polyfills/number.ts"),_=S("./src/utils/logger.ts");function R(a,o,g){switch(o){case"audio":a.audioGroupIds||(a.audioGroupIds=[]),a.audioGroupIds.push(g);break;case"text":a.textGroupIds||(a.textGroupIds=[]),a.textGroupIds.push(g);break}}function N(a){var o={};a.forEach(function(g){var l=g.groupId||"";g.id=o[l]=o[l]||0,o[l]++})}function M(a,o,g){var l=a[o],d=a[g];O(l,d)}function O(a,o){var g=o.startPTS;if(Object(B.isFiniteNumber)(g)){var l=0,d;o.sn>a.sn?(l=g-a.start,d=a):(l=a.start-g,d=o),d.duration!==l&&(d.duration=l)}else if(o.sn>a.sn){var v=a.cc===o.cc;v&&a.minEndPTS?o.start=a.start+(a.minEndPTS-a.start):o.start=a.start+a.duration}else o.start=Math.max(a.start-o.duration,0)}function w(a,o,g,l,d,v){var h=l-g;h<=0&&(_.logger.warn("Fragment should have a positive duration",o),l=g+o.duration,v=d+o.duration);var u=g,n=l,e=o.startPTS,t=o.endPTS;if(Object(B.isFiniteNumber)(e)){var f=Math.abs(e-g);Object(B.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(f,o.deltaPTS):o.deltaPTS=f,u=Math.max(g,e),g=Math.min(g,e),d=Math.min(d,o.startDTS),n=Math.min(l,t),l=Math.max(l,t),v=Math.max(v,o.endDTS)}o.duration=l-g;var p=g-o.start;o.appendedPTS=l,o.start=o.startPTS=g,o.maxStartPTS=u,o.startDTS=d,o.endPTS=l,o.minEndPTS=n,o.endDTS=v;var x=o.sn;if(!a||x<a.startSN||x>a.endSN)return 0;var A,I=x-a.startSN,U=a.fragments;for(U[I]=o,A=I;A>0;A--)O(U[A],U[A-1]);for(A=I;A<U.length-1;A++)O(U[A],U[A+1]);return a.fragmentHint&&O(U[U.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,p}function m(a,o){for(var g=null,l=a.fragments,d=l.length-1;d>=0;d--){var v=l[d].initSegment;if(v){g=v;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;var h=0,u;if(C(a,o,function(A,I){A.relurl&&(h=A.cc-I.cc),Object(B.isFiniteNumber)(A.startPTS)&&Object(B.isFiniteNumber)(A.endPTS)&&(I.start=I.startPTS=A.startPTS,I.startDTS=A.startDTS,I.appendedPTS=A.appendedPTS,I.maxStartPTS=A.maxStartPTS,I.endPTS=A.endPTS,I.endDTS=A.endDTS,I.minEndPTS=A.minEndPTS,I.duration=A.endPTS-A.startPTS,I.duration&&(u=I),o.PTSKnown=o.alignedSliding=!0),I.elementaryStreams=A.elementaryStreams,I.loader=A.loader,I.stats=A.stats,I.urlId=A.urlId,A.initSegment&&(I.initSegment=A.initSegment,g=A.initSegment)}),g){var n=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;n.forEach(function(A){var I;(!A.initSegment||A.initSegment.relurl===((I=g)===null||I===void 0?void 0:I.relurl))&&(A.initSegment=g)})}if(o.skippedSegments&&(o.deltaUpdateFailed=o.fragments.some(function(A){return!A}),o.deltaUpdateFailed)){_.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var e=o.skippedSegments;e--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}var t=o.fragments;if(h){_.logger.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<t.length;f++)t[f].cc+=h}o.skippedSegments&&(o.startCC=o.fragments[0].cc),T(a.partList,o.partList,function(A,I){I.elementaryStreams=A.elementaryStreams,I.stats=A.stats}),u?w(o,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):b(a,o),t.length&&(o.totalduration=o.edge-t[0].start),o.driftStartTime=a.driftStartTime,o.driftStart=a.driftStart;var p=o.advancedDateTime;if(o.advanced&&p){var x=o.edge;o.driftStart||(o.driftStartTime=p,o.driftStart=x),o.driftEndTime=p,o.driftEnd=x}else o.driftEndTime=a.driftEndTime,o.driftEnd=a.driftEnd,o.advancedDateTime=a.advancedDateTime}function T(a,o,g){if(a&&o)for(var l=0,d=0,v=a.length;d<=v;d++){var h=a[d],u=o[d+l];h&&u&&h.index===u.index&&h.fragment.sn===u.fragment.sn?g(h,u):l--}}function C(a,o,g){for(var l=o.skippedSegments,d=Math.max(a.startSN,o.startSN)-o.startSN,v=(a.fragmentHint?1:0)+(l?o.endSN:Math.min(a.endSN,o.endSN))-o.startSN,h=o.startSN-a.startSN,u=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,n=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,e=d;e<=v;e++){var t=n[h+e],f=u[e];l&&!f&&e<l&&(f=o.fragments[e]=t),t&&f&&g(t,f)}}function b(a,o){var g=o.startSN+o.skippedSegments-a.startSN,l=a.fragments;if(g<0||g>=l.length)return;E(o,l[g].start)}function E(a,o){if(o){for(var g=a.fragments,l=a.skippedSegments;l<g.length;l++)g[l].start+=o;a.fragmentHint&&(a.fragmentHint.start+=o)}}function y(a,o){var g=1e3*a.levelTargetDuration,l=g/2,d=a.age,v=d>0&&d<g*3,h=o.loading.end-o.loading.start,u,n=a.availabilityDelay;if(a.updated===!1)if(v){var e=333*a.misses;u=Math.max(Math.min(l,h*2),e),a.availabilityDelay=(a.availabilityDelay||0)+u}else u=l;else v?(n=Math.min(n||g/2,d),a.availabilityDelay=n,u=n+g-d):u=g-h;return Math.round(u)}function c(a,o,g){if(!a||!a.details)return null;var l=a.details,d=l.fragments[o-l.startSN];return d||(d=l.fragmentHint,d&&d.sn===o?d:o<l.startSN&&g&&g.sn===o?g:null)}function r(a,o,g){if(!a||!a.details)return null;var l=a.details.partList;if(l)for(var d=l.length;d--;){var v=l[d];if(v.index===g&&v.fragment.sn===o)return v}return null}},"./src/controller/stream-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return l});var B=S("./src/polyfills/number.ts"),_=S("./src/controller/base-stream-controller.ts"),R=S("./src/is-supported.ts"),N=S("./src/events.ts"),M=S("./src/utils/buffer-helper.ts"),O=S("./src/controller/fragment-tracker.ts"),w=S("./src/types/loader.ts"),m=S("./src/loader/fragment.ts"),T=S("./src/demux/transmuxer-interface.ts"),C=S("./src/types/transmuxer.ts"),b=S("./src/controller/gap-controller.ts"),E=S("./src/errors.ts"),y=S("./src/utils/logger.ts");function c(d,v){for(var h=0;h<v.length;h++){var u=v[h];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(d,u.key,u)}}function r(d,v,h){return v&&c(d.prototype,v),h&&c(d,h),d}function a(d,v){d.prototype=Object.create(v.prototype),d.prototype.constructor=d,o(d,v)}function o(d,v){return o=Object.setPrototypeOf||function(u,n){return u.__proto__=n,u},o(d,v)}var g=100,l=function(d){a(v,d);function v(u,n){var e;return e=d.call(this,u,n,"[stream-controller]")||this,e.audioCodecSwap=!1,e.gapController=null,e.level=-1,e._forceStartLoad=!1,e.altAudio=!1,e.audioOnly=!1,e.fragPlaying=null,e.onvplaying=null,e.onvseeked=null,e.fragLastKbps=0,e.stalled=!1,e.couldBacktrack=!1,e.audioCodecSwitch=!1,e.videoBuffer=null,e._registerListeners(),e}var h=v.prototype;return h._registerListeners=function(){var n=this.hls;n.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(N.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(N.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.on(N.Events.ERROR,this.onError,this),n.on(N.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.on(N.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(N.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(N.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.on(N.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h._unregisterListeners=function(){var n=this.hls;n.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(N.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(N.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.off(N.Events.ERROR,this.onError,this),n.off(N.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(N.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.off(N.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(N.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(N.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.off(N.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},h.startLoad=function(n){if(this.levels){var e=this.lastCurrentTime,t=this.hls;if(this.stopLoad(),this.setInterval(g),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var f=t.startLevel;f===-1&&(t.config.testBandwidth?(f=0,this.bitrateTest=!0):f=t.nextAutoLevel),this.level=t.nextLoadLevel=f,this.loadedmetadata=!1}e>0&&n===-1&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),n=e),this.state=_.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()}else this._forceStartLoad=!0,this.state=_.State.STOPPED},h.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case _.State.IDLE:this.doTickIdle();break;case _.State.WAITING_LEVEL:{var n,e=this.levels,t=this.level,f=e==null||((n=e[t])===null||n===void 0)?void 0:n.details;if(f&&(!f.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(f))break;this.state=_.State.IDLE;break}break}case _.State.FRAG_LOADING_WAITING_RETRY:{var p,x=self.performance.now(),A=this.retryDate;(!A||x>=A||(p=this.media)!==null&&p!==void 0&&p.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=_.State.IDLE)}break;default:break}this.onTickEnd()},h.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},h.doTickIdle=function(){var n,e,t=this.hls,f=this.levelLastLoaded,p=this.levels,x=this.media,A=t.config,I=t.nextLoadLevel;if(f===null||!x&&(this.startFragRequested||!A.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!p||!p[I])return;var U=p[I];this.level=t.nextLoadLevel=I;var j=U.details;if(!j||this.state===_.State.WAITING_LEVEL||j.live&&this.levelLastLoaded!==I){this.state=_.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,w.PlaylistLevelType.MAIN);if(z===null)return;var V=z.len,G=this.getMaxBufferLength(U.maxBitrate);if(V>=G)return;if(this._streamEnded(z,j)){var Q={};this.altAudio&&(Q.type="video"),this.hls.trigger(N.Events.BUFFER_EOS,Q),this.state=_.State.ENDED;return}var ne=z.end,re=this.getNextFragment(ne,j);if(this.couldBacktrack&&!this.fragPrevious&&re&&re.sn!=="initSegment"){var be=re.sn-j.startSN;be>1&&(re=j.fragments[be-1],this.fragmentTracker.removeFragment(re))}if(re&&this.fragmentTracker.getState(re)===O.FragmentState.OK&&this.nextLoadPosition>ne){var se=this.audioOnly&&!this.altAudio?m.ElementaryStreamTypes.AUDIO:m.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,se,w.PlaylistLevelType.MAIN),re=this.getNextFragment(this.nextLoadPosition,j)}if(!re)return;re.initSegment&&!re.initSegment.data&&!this.bitrateTest&&(re=re.initSegment),((n=re.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((e=re.decryptdata)!==null&&e!==void 0&&e.key)?this.loadKey(re,j):this.loadFragment(re,j,ne)},h.loadFragment=function(n,e,t){var f,p=this.fragmentTracker.getState(n);if(this.fragCurrent=n,p===O.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(n);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else p=O.FragmentState.NOT_LOADED}p===O.FragmentState.NOT_LOADED||p===O.FragmentState.PARTIAL?n.sn==="initSegment"?this._loadInitSegment(n):this.bitrateTest?(n.bitrateTest=!0,this.log("Fragment "+n.sn+" of level "+n.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(n)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,n,e,t)):p===O.FragmentState.APPENDING?this.reduceMaxBufferLength(n.duration)&&this.fragmentTracker.removeFragment(n):((f=this.media)===null||f===void 0?void 0:f.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},h.getAppendedFrag=function(n){var e=this.fragmentTracker.getAppendedFrag(n,w.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},h.getBufferedFrag=function(n){return this.fragmentTracker.getBufferedFrag(n,w.PlaylistLevelType.MAIN)},h.followingBufferedFrag=function(n){return n?this.getBufferedFrag(n.end+.5):null},h.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.nextLevelSwitch=function(){var n=this.levels,e=this.media;if(e!=null&&e.readyState){var t,f=this.getAppendedFrag(e.currentTime);if(f&&f.start>1&&this.flushMainBuffer(0,f.start-1),!e.paused&&n){var p=this.hls.nextLoadLevel,x=n[p],A=this.fragLastKbps;A&&this.fragCurrent?t=this.fragCurrent.duration*x.maxBitrate/(1e3*A)+1:t=0}else t=0;var I=this.getBufferedFrag(e.currentTime+t);if(I){var U=this.followingBufferedFrag(I);if(U){this.abortCurrentFrag();var j=U.maxStartPTS?U.maxStartPTS:U.start,z=U.duration,V=Math.max(I.end,j+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(V,Number.POSITIVE_INFINITY)}}}},h.abortCurrentFrag=function(){var n=this.fragCurrent;this.fragCurrent=null,n!=null&&n.loader&&n.loader.abort(),this.state===_.State.KEY_LOADING&&(this.state=_.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},h.flushMainBuffer=function(n,e){d.prototype.flushMainBuffer.call(this,n,e,this.altAudio?"video":null)},h.onMediaAttached=function(n,e){d.prototype.onMediaAttached.call(this,n,e);var t=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),t.addEventListener("playing",this.onvplaying),t.addEventListener("seeked",this.onvseeked),this.gapController=new b.default(this.config,t,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var n=this.media;n&&(n.removeEventListener("playing",this.onvplaying),n.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},h.onMediaPlaying=function(){this.tick()},h.onMediaSeeked=function(){var n=this.media,e=n?n.currentTime:null;Object(B.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},h.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(N.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},h.onManifestParsed=function(n,e){var t=!1,f=!1,p;e.levels.forEach(function(x){p=x.audioCodec,p&&(p.indexOf("mp4a.40.2")!==-1&&(t=!0),p.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=t&&f&&!Object(R.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},h.onLevelLoading=function(n,e){var t=this.levels;if(!t||this.state!==_.State.IDLE)return;var f=t[e.level];(!f.details||f.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(f.details))&&(this.state=_.State.WAITING_LEVEL)},h.onLevelLoaded=function(n,e){var t,f=this.levels,p=e.level,x=e.details,A=x.totalduration;if(!f){this.warn("Levels were reset while loading level "+p);return}this.log("Level "+p+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+A);var I=this.fragCurrent;I&&(this.state===_.State.FRAG_LOADING||this.state===_.State.FRAG_LOADING_WAITING_RETRY)&&(I.level!==e.level&&I.loader&&(this.state=_.State.IDLE,I.loader.abort()));var U=f[p],j=0;if(x.live||(t=U.details)!==null&&t!==void 0&&t.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;j=this.alignPlaylists(x,U.details)}if(U.details=x,this.levelLastLoaded=p,this.hls.trigger(N.Events.LEVEL_UPDATED,{details:x,level:p}),this.state===_.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=_.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,j),this.tick()},h._handleFragmentLoadProgress=function(n){var e,t=n.frag,f=n.part,p=n.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var A=x[t.level],I=A.details;if(!I){this.warn("Dropping fragment "+t.sn+" of level "+t.level+" after level details were reset");return}var U=A.videoCodec,j=I.PTSKnown||!I.live,z=(e=t.initSegment)===null||e===void 0?void 0:e.data,V=this._getAudioCodec(A),G=this.transmuxer=this.transmuxer||new T.default(this.hls,w.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),Q=f?f.index:-1,ne=Q!==-1,re=new C.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,p.byteLength,Q,ne),be=this.initPTS[t.cc];G.push(p,z,V,U,t,f,I.totalduration,j,re,be)},h.onAudioTrackSwitching=function(n,e){var t=this.altAudio,f=!!e.url,p=e.id;if(!f){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var A=this.hls;t&&A.trigger(N.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),A.trigger(N.Events.AUDIO_TRACK_SWITCHED,{id:p})}},h.onAudioTrackSwitched=function(n,e){var t=e.id,f=!!this.hls.audioTracks[t].url;if(f){var p=this.videoBuffer;p&&this.mediaBuffer!==p&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=p)}this.altAudio=f,this.tick()},h.onBufferCreated=function(n,e){var t=e.tracks,f,p,x=!1;for(var A in t){var I=t[A];if(I.id==="main"){if(p=A,f=I,A==="video"){var U=t[A];U&&(this.videoBuffer=U.buffer)}}else x=!0}x&&f?(this.log("Alternate track found, use "+p+".buffered to schedule main fragment loading"),this.mediaBuffer=f.buffer):this.mediaBuffer=this.media},h.onFragBuffered=function(n,e){var t=e.frag,f=e.part;if(t&&t.type!==w.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(f?" p: "+f.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state),this.state===_.State.PARSED&&(this.state=_.State.IDLE);return}var p=f?f.stats:t.stats;this.fragLastKbps=Math.round(8*p.total/(p.buffering.end-p.loading.first)),t.sn!=="initSegment"&&(this.fragPrevious=t),this.fragBufferedComplete(t,f)},h.onError=function(n,e){switch(e.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.MAIN,e);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==_.State.ERROR&&(e.fatal?(this.warn(""+e.details),this.state=_.State.ERROR):!e.levelRetry&&this.state===_.State.WAITING_LEVEL&&(this.state=_.State.IDLE));break;case E.ErrorDetails.BUFFER_FULL_ERROR:if(e.parent==="main"&&(this.state===_.State.PARSING||this.state===_.State.PARSED)){var t=!0,f=this.getFwdBufferInfo(this.media,w.PlaylistLevelType.MAIN);f&&f.len>.5&&(t=!this.reduceMaxBufferLength(f.len)),t&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},h.checkBuffer=function(){var n=this.media,e=this.gapController;if(!n||!e||!n.readyState)return;var t=M.BufferHelper.getBuffered(n);!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this.seekToStartPos()):e.poll(this.lastCurrentTime),this.lastCurrentTime=n.currentTime},h.onFragLoadEmergencyAborted=function(){this.state=_.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},h.onBufferFlushed=function(n,e){var t=e.type;if(t!==m.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var f=(t===m.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(f,t,w.PlaylistLevelType.MAIN)}},h.onLevelsUpdated=function(n,e){this.levels=e.levels},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h.seekToStartPos=function(){var n=this.media,e=n.currentTime,t=this.startPosition;if(t>=0&&e<t){if(n.seeking){y.logger.log("could not seek to "+t+", already seeking at "+e);return}var f=M.BufferHelper.getBuffered(n),p=f.length?f.start(0):0,x=p-t;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(y.logger.log("adjusting start position by "+x+" to match buffer start"),t+=x,this.startPosition=t),this.log("seek to target start position "+t+" from current time "+e),n.currentTime=t}},h._getAudioCodec=function(n){var e=this.config.defaultAudioCodec||n.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e},h._loadBitrateTestFrag=function(n){var e=this;this._doFragLoad(n).then(function(t){var f=e.hls;if(!t||f.nextLoadLevel||e.fragContextChanged(n))return;e.fragLoadError=0,e.state=_.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var p=n.stats;p.parsing.start=p.parsing.end=p.buffering.start=p.buffering.end=self.performance.now(),f.trigger(N.Events.FRAG_LOADED,t)})},h._handleTransmuxComplete=function(n){var e,t="main",f=this.hls,p=n.remuxResult,x=n.chunkMeta,A=this.getCurrentContext(x);if(!A){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var I=A.frag,U=A.part,j=A.level,z=p.video,V=p.text,G=p.id3,Q=p.initSegment,ne=this.altAudio?void 0:p.audio;if(this.fragContextChanged(I))return;if(this.state=_.State.PARSING,Q){Q.tracks&&(this._bufferInitSegment(j,Q.tracks,I,x),f.trigger(N.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:t,tracks:Q.tracks}));var re=Q.initPTS,be=Q.timescale;Object(B.isFiniteNumber)(re)&&(this.initPTS[I.cc]=re,f.trigger(N.Events.INIT_PTS_FOUND,{frag:I,id:t,initPTS:re,timescale:be}))}if(z&&p.independent!==!1){if(j.details){var se=z.startPTS,oe=z.endPTS,ue=z.startDTS,he=z.endDTS;if(U)U.elementaryStreams[z.type]={startPTS:se,endPTS:oe,startDTS:ue,endDTS:he};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var te=this.getLoadPosition()+this.config.maxBufferHole;if(te<se){this.backtrack(I);return}I.setElementaryStreamInfo(z.type,I.start,oe,I.start,he,!0)}I.setElementaryStreamInfo(z.type,se,oe,ue,he),this.bufferFragmentData(z,I,U,x)}}else if(p.independent===!1){this.backtrack(I);return}if(ne){var Y=ne.startPTS,fe=ne.endPTS,Re=ne.startDTS,Le=ne.endDTS;U&&(U.elementaryStreams[m.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:fe,startDTS:Re,endDTS:Le}),I.setElementaryStreamInfo(m.ElementaryStreamTypes.AUDIO,Y,fe,Re,Le),this.bufferFragmentData(ne,I,U,x)}if(G!=null&&(e=G.samples)!==null&&e!==void 0&&e.length){var xe={frag:I,id:t,samples:G.samples};f.trigger(N.Events.FRAG_PARSING_METADATA,xe)}if(V){var Te={frag:I,id:t,samples:V.samples};f.trigger(N.Events.FRAG_PARSING_USERDATA,Te)}},h._bufferInitSegment=function(n,e,t,f){var p=this;if(this.state!==_.State.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var x=e.audio,A=e.video,I=e.audiovideo;if(x){var U=n.audioCodec,j=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(U&&(U.indexOf("mp4a.40.5")!==-1?U="mp4a.40.2":U="mp4a.40.5"),x.metadata.channelCount!==1&&j.indexOf("firefox")===-1&&(U="mp4a.40.5")),j.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(U="mp4a.40.2",this.log("Android: force audio codec to "+U)),n.audioCodec&&n.audioCodec!==U&&this.log('Swapping manifest audio codec "'+n.audioCodec+'" for "'+U+'"'),x.levelCodec=U,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(U||"")+"/"+(n.audioCodec||"")+"/"+x.codec+"]")}A&&(A.levelCodec=n.videoCodec,A.id="main",this.log("Init video buffer, container:"+A.container+", codecs[level/parsed]=["+(n.videoCodec||"")+"/"+A.codec+"]")),I&&this.log("Init audiovideo buffer, container:"+I.container+", codecs[level/parsed]=["+(n.attrs.CODECS||"")+"/"+I.codec+"]"),this.hls.trigger(N.Events.BUFFER_CODECS,e),Object.keys(e).forEach(function(z){var V=e[z],G=V.initSegment;G!=null&&G.byteLength&&p.hls.trigger(N.Events.BUFFER_APPENDING,{type:z,data:G,frag:t,part:null,chunkMeta:f,parent:t.type})}),this.tick()},h.backtrack=function(n){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(n);var e=this.fragmentTracker.backtrack(n);this.fragPrevious=null,this.nextLoadPosition=n.start,e?this.resetFragmentLoading(n):this.state=_.State.BACKTRACKING},h.checkFragmentChanged=function(){var n=this.media,e=null;if(n&&n.readyState>1&&n.seeking===!1){var t=n.currentTime;if(M.BufferHelper.isBuffered(n,t)?e=this.getAppendedFrag(t):M.BufferHelper.isBuffered(n,t+.1)&&(e=this.getAppendedFrag(t+.1)),e){var f=this.fragPlaying,p=e.level;(!f||e.sn!==f.sn||f.level!==p||e.urlId!==f.urlId)&&(this.hls.trigger(N.Events.FRAG_CHANGED,{frag:e}),(!f||f.level!==p)&&this.hls.trigger(N.Events.LEVEL_SWITCHED,{level:p}),this.fragPlaying=e)}}},r(v,[{key:"nextLevel",get:function(){var n=this.nextBufferedFrag;return n?n.level:-1}},{key:"currentLevel",get:function(){var n=this.media;if(n){var e=this.getAppendedFrag(n.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var n=this.media;if(n){var e=this.getAppendedFrag(n.currentTime);return this.followingBufferedFrag(e)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),v}(_.default)},"./src/controller/subtitle-stream-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"SubtitleStreamController",function(){return a});var B=S("./src/events.ts"),_=S("./src/utils/logger.ts"),R=S("./src/utils/buffer-helper.ts"),N=S("./src/controller/fragment-finders.ts"),M=S("./src/utils/discontinuities.ts"),O=S("./src/controller/level-helper.ts"),w=S("./src/controller/fragment-tracker.ts"),m=S("./src/controller/base-stream-controller.ts"),T=S("./src/types/loader.ts"),C=S("./src/types/level.ts");function b(o,g){for(var l=0;l<g.length;l++){var d=g[l];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(o,d.key,d)}}function E(o,g,l){return g&&b(o.prototype,g),l&&b(o,l),o}function y(o,g){o.prototype=Object.create(g.prototype),o.prototype.constructor=o,c(o,g)}function c(o,g){return c=Object.setPrototypeOf||function(d,v){return d.__proto__=v,d},c(o,g)}var r=500,a=function(o){y(g,o);function g(d,v){var h;return h=o.call(this,d,v,"[subtitle-stream-controller]")||this,h.levels=[],h.currentTrackId=-1,h.tracksBuffered=[],h.mainDetails=null,h._registerListeners(),h}var l=g.prototype;return l.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},l._registerListeners=function(){var v=this.hls;v.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(B.Events.ERROR,this.onError,this),v.on(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.on(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),v.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.on(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),v.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l._unregisterListeners=function(){var v=this.hls;v.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(B.Events.ERROR,this.onError,this),v.off(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),v.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.off(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),v.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l.startLoad=function(){this.stopLoad(),this.state=m.State.IDLE,this.setInterval(r),this.tick()},l.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},l.onLevelLoaded=function(v,h){this.mainDetails=h.details},l.onSubtitleFragProcessed=function(v,h){var u=h.frag,n=h.success;if(this.fragPrevious=u,this.state=m.State.IDLE,!n)return;var e=this.tracksBuffered[this.currentTrackId];if(!e)return;for(var t,f=u.start,p=0;p<e.length;p++)if(f>=e[p].start&&f<=e[p].end){t=e[p];break}var x=u.start+u.duration;t?t.end=x:(t={start:f,end:x},e.push(t)),this.fragmentTracker.fragBuffered(u)},l.onBufferFlushing=function(v,h){var u=h.startOffset,n=h.endOffset;if(u===0&&n!==Number.POSITIVE_INFINITY){var e=this.currentTrackId,t=this.levels;if(!t.length||!t[e]||!t[e].details)return;var f=t[e].details,p=f.targetduration,x=n-p;if(x<=0)return;h.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(A){for(var I=0;I<A.length;){if(A[I].end<=x){A.shift();continue}else if(A[I].start<x)A[I].start=x;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(u,x,T.PlaylistLevelType.SUBTITLE)}},l.onError=function(v,h){var u,n=h.frag;if(!n||n.type!==T.PlaylistLevelType.SUBTITLE)return;(u=this.fragCurrent)!==null&&u!==void 0&&u.loader&&this.fragCurrent.loader.abort(),this.state=m.State.IDLE},l.onSubtitleTracksUpdated=function(v,h){var u=this,n=h.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(e){return new C.Level(e)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(e){u.tracksBuffered[e.id]=[]}),this.mediaBuffer=null},l.onSubtitleTrackSwitch=function(v,h){if(this.currentTrackId=h.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var u=this.levels[this.currentTrackId];u!=null&&u.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,u&&this.setInterval(r)},l.onSubtitleTrackLoaded=function(v,h){var u,n=h.details,e=h.id,t=this.currentTrackId,f=this.levels;if(!f.length)return;var p=f[t];if(e>=f.length||e!==t||!p)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(u=p.details)!==null&&u!==void 0&&u.live){var x=this.mainDetails;if(n.deltaUpdateFailed||!x)return;var A=x.fragments[0];if(!p.details)n.hasProgramDateTime&&x.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(n,x):A&&Object(O.addSliding)(n,A.start);else{var I=this.alignPlaylists(n,p.details);I===0&&A&&Object(O.addSliding)(n,A.start)}}if(p.details=n,this.levelLastLoaded=e,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===m.State.IDLE){var U=Object(N.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);U||(this.warn("Subtitle playlist not aligned with playback"),p.details=void 0)}},l._handleFragmentLoadComplete=function(v){var h=v.frag,u=v.payload,n=h.decryptdata,e=this.hls;if(this.fragContextChanged(h))return;if(u&&u.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var t=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(u),n.key.buffer,n.iv.buffer).then(function(f){var p=performance.now();e.trigger(B.Events.FRAG_DECRYPTED,{frag:h,payload:f,stats:{tstart:t,tdecrypt:p}})})}},l.doTick=function(){if(!this.media){this.state=m.State.IDLE;return}if(this.state===m.State.IDLE){var v,h=this.currentTrackId,u=this.levels;if(!u.length||!u[h]||!u[h].details)return;var n=u[h].details,e=n.targetduration,t=this.config,f=this.media,p=R.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,f.currentTime-e,t.maxBufferHole),x=p.end,A=p.len,I=this.getMaxBufferLength()+e;if(A>I)return;console.assert(n,"Subtitle track details are defined on idle subtitle stream controller tick");var U=n.fragments,j=U.length,z=n.edge,V,G=this.fragPrevious;if(x<z){var Q=t.maxFragLookUpTolerance;G&&n.hasProgramDateTime&&(V=Object(N.findFragmentByPDT)(U,G.endProgramDateTime,Q)),V||(V=Object(N.findFragmentByPTS)(G,U,x,Q),!V&&G&&G.start<U[0].start&&(V=U[0]))}else V=U[j-1];(v=V)!==null&&v!==void 0&&v.encrypted?(_.logger.log("Loading key for "+V.sn),this.state=m.State.KEY_LOADING,this.hls.trigger(B.Events.KEY_LOADING,{frag:V})):V&&this.fragmentTracker.getState(V)===w.FragmentState.NOT_LOADED&&this.loadFragment(V,n,x)}},l.loadFragment=function(v,h,u){this.fragCurrent=v,o.prototype.loadFragment.call(this,v,h,u)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),g}(m.default)},"./src/controller/subtitle-track-controller.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/events.ts"),_=S("./src/utils/texttrack-utils.ts"),R=S("./src/controller/base-playlist-controller.ts"),N=S("./src/types/loader.ts");function M(b,E){for(var y=0;y<E.length;y++){var c=E[y];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(b,c.key,c)}}function O(b,E,y){return E&&M(b.prototype,E),y&&M(b,y),b}function w(b,E){b.prototype=Object.create(E.prototype),b.prototype.constructor=b,m(b,E)}function m(b,E){return m=Object.setPrototypeOf||function(c,r){return c.__proto__=r,c},m(b,E)}var T=function(b){w(E,b);function E(c){var r;return r=b.call(this,c,"[subtitle-track-controller]")||this,r.media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}var y=E.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,b.prototype.destroy.call(this)},y.registerListeners=function(){var r=this.hls;r.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(B.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var r=this.hls;r.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(B.Events.ERROR,this.onError,this)},y.onMediaAttached=function(r,a){if(this.media=a.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},y.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},y.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var r=C(this.media.textTracks);r.forEach(function(a){Object(_.clearCurrentCues)(a)}),this.subtitleTrack=-1,this.media=null},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(r,a){this.tracks=a.subtitleTracks},y.onSubtitleTrackLoaded=function(r,a){var o=a.id,g=a.details,l=this.trackId,d=this.tracksInGroup[l];if(!d){this.warn("Invalid subtitle track id "+o);return}var v=d.details;d.details=a.details,this.log("subtitle track "+o+" loaded ["+g.startSN+"-"+g.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,a,v))},y.onLevelLoading=function(r,a){this.switchLevel(a.level)},y.onLevelSwitching=function(r,a){this.switchLevel(a.level)},y.switchLevel=function(r){var a=this.hls.levels[r];if(!(a!=null&&a.textGroupIds))return;var o=a.textGroupIds[a.urlId];if(this.groupId!==o){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(h){return!o||h.groupId===o});this.tracksInGroup=l;var d=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=o;var v={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(B.Events.SUBTITLE_TRACKS_UPDATED,v),d!==-1&&this.setSubtitleTrack(d,g)}},y.findTrackId=function(r){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var g=a[o];if((!this.selectDefaultTrack||g.default)&&(!r||r===g.name))return g.id}return-1},y.onError=function(r,a){if(b.prototype.onError.call(this,r,a),a.fatal||!a.context)return;a.context.type===N.PlaylistContextType.SUBTITLE_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},y.loadPlaylist=function(r){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var o=a.id,g=a.groupId,l=a.url;if(r)try{l=r.addDirectives(l)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(B.Events.SUBTITLE_TRACK_LOADING,{url:l,id:o,groupId:g,deliveryDirectives:r||null})}},y.toggleTrackModes=function(r){var a=this,o=this.media,g=this.subtitleDisplay,l=this.trackId;if(!o)return;var d=C(o.textTracks),v=d.filter(function(n){return n.groupId===a.groupId});if(r===-1)[].slice.call(d).forEach(function(n){n.mode="disabled"});else{var h=v[l];h&&(h.mode="disabled")}var u=v[r];u&&(u.mode=g?"showing":"hidden")},y.setSubtitleTrack=function(r,a){var o,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=r;return}if(this.trackId!==r&&this.toggleTrackModes(r),this.trackId===r&&(r===-1||(o=g[r])!==null&&o!==void 0&&o.details)||r<-1||r>=g.length)return;this.clearTimer();var l=g[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,l){var d=l.id,v=l.groupId,h=v===void 0?"":v,u=l.name,n=l.type,e=l.url;this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:d,groupId:h,name:u,type:n,url:e});var t=this.switchParams(l.url,a==null?void 0:a.details);this.loadPlaylist(t)}else this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:r})},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var r=-1,a=C(this.media.textTracks),o=0;o<a.length;o++)if(a[o].mode==="hidden")r=o;else if(a[o].mode==="showing"){r=o;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)},O(E,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,a)}}]),E}(R.default);function C(b){for(var E=[],y=0;y<b.length;y++){var c=b[y];c.kind==="subtitles"&&c.label&&E.push(b[y])}return E}F.default=T},"./src/controller/timeline-controller.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"TimelineController",function(){return C});var B=S("./src/polyfills/number.ts"),_=S("./src/events.ts"),R=S("./src/utils/cea-608-parser.ts"),N=S("./src/utils/output-filter.ts"),M=S("./src/utils/webvtt-parser.ts"),O=S("./src/utils/texttrack-utils.ts"),w=S("./src/utils/imsc1-ttml-parser.ts"),m=S("./src/types/loader.ts"),T=S("./src/utils/logger.ts"),C=function(){function c(a){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=y(),this.captionsProperties=void 0,this.hls=a,this.config=a.config,this.Cues=a.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 o=new N.default(this,"textTrack1"),g=new N.default(this,"textTrack2"),l=new N.default(this,"textTrack3"),d=new N.default(this,"textTrack4");this.cea608Parser1=new R.default(1,o,g),this.cea608Parser2=new R.default(3,l,d)}a.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.on(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),a.on(_.Events.FRAG_LOADING,this.onFragLoading,this),a.on(_.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),a.on(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),a.on(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),a.on(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var r=c.prototype;return r.destroy=function(){var o=this.hls;o.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(_.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.off(_.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(_.Events.FRAG_LOADING,this.onFragLoading,this),o.off(_.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(_.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.off(_.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.off(_.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.off(_.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.off(_.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},r.addCues=function(o,g,l,d,v){for(var h=!1,u=v.length;u--;){var n=v[u],e=E(n[0],n[1],g,l);if(e>=0&&(n[0]=Math.min(n[0],g),n[1]=Math.max(n[1],l),h=!0,e/(l-g)>.5))return}if(h||v.push([g,l]),this.config.renderTextTracksNatively){var t=this.captionsTracks[o];this.Cues.newCue(t,g,l,d)}else{var f=this.Cues.newCue(null,g,l,d);this.hls.trigger(_.Events.CUES_PARSED,{type:"captions",cues:f,track:o})}},r.onInitPtsFound=function(o,g){var l=this,d=g.frag,v=g.id,h=g.initPTS,u=g.timescale,n=this.unparsedVttFrags;v==="main"&&(this.initPTS[d.cc]=h,this.timescale[d.cc]=u),n.length&&(this.unparsedVttFrags=[],n.forEach(function(e){l.onFragLoaded(_.Events.FRAG_LOADED,e)}))},r.getExistingTrack=function(o){var g=this.media;if(g)for(var l=0;l<g.textTracks.length;l++){var d=g.textTracks[l];if(d[o])return d}return null},r.createCaptionsTrack=function(o){this.config.renderTextTracksNatively?this.createNativeTrack(o):this.createNonNativeTrack(o)},r.createNativeTrack=function(o){if(this.captionsTracks[o])return;var g=this.captionsProperties,l=this.captionsTracks,d=this.media,v=g[o],h=v.label,u=v.languageCode,n=this.getExistingTrack(o);if(n)l[o]=n,Object(O.clearCurrentCues)(l[o]),Object(O.sendAddTrackEvent)(l[o],d);else{var e=this.createTextTrack("captions",h,u);e&&(e[o]=!0,l[o]=e)}},r.createNonNativeTrack=function(o){if(this.nonNativeCaptionsTracks[o])return;var g=this.captionsProperties[o];if(!g)return;var l=g.label,d={_id:o,label:l,kind:"captions",default:g.media?!!g.media.default:!1,closedCaptions:g.media};this.nonNativeCaptionsTracks[o]=d,this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[d]})},r.createTextTrack=function(o,g,l){var d=this.media;return d?d.addTextTrack(o,g,l):void 0},r.onMediaAttaching=function(o,g){this.media=g.media,this._cleanTracks()},r.onMediaDetaching=function(){var o=this.captionsTracks;Object.keys(o).forEach(function(g){Object(O.clearCurrentCues)(o[g]),delete o[g]}),this.nonNativeCaptionsTracks={}},r.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=y(),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())},r._cleanTracks=function(){var o=this.media;if(!o)return;var g=o.textTracks;if(g)for(var l=0;l<g.length;l++)Object(O.clearCurrentCues)(g[l])},r.onSubtitleTracksUpdated=function(o,g){var l=this;this.textTracks=[];var d=g.subtitleTracks||[],v=d.some(function(e){return e.textCodec===w.IMSC1_CODEC});if(this.config.enableWebVTT||v&&this.config.enableIMSC1){var h=this.tracks&&d&&this.tracks.length===d.length;if(this.tracks=d||[],this.config.renderTextTracksNatively){var u=this.media?this.media.textTracks:[];this.tracks.forEach(function(e,t){var f;if(t<u.length){for(var p=null,x=0;x<u.length;x++)if(b(u[x],e)){p=u[x];break}p&&(f=p)}f?Object(O.clearCurrentCues)(f):(f=l.createTextTrack("subtitles",e.name,e.lang),f&&(f.mode="disabled")),f&&(f.groupId=e.groupId,l.textTracks.push(f))})}else if(!h&&this.tracks&&this.tracks.length){var n=this.tracks.map(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}});this.hls.trigger(_.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}},r.onManifestLoaded=function(o,g){var l=this;this.config.enableCEA708Captions&&g.captions&&g.captions.forEach(function(d){var v=/(?:CC|SERVICE)([1-4])/.exec(d.instreamId);if(!v)return;var h="textTrack"+v[1],u=l.captionsProperties[h];if(!u)return;u.label=d.name,d.lang&&(u.languageCode=d.lang),u.media=d})},r.onFragLoading=function(o,g){var l=this.cea608Parser1,d=this.cea608Parser2,v=this.lastSn,h=this.lastPartIndex;if(!this.enabled||!(l&&d))return;if(g.frag.type===m.PlaylistLevelType.MAIN){var u,n,e=g.frag.sn,t=(u=g==null||((n=g.part)===null||n===void 0)?void 0:n.index)!=null?u:-1;e===v+1||e===v&&t===h+1||(l.reset(),d.reset()),this.lastSn=e,this.lastPartIndex=t}},r.onFragLoaded=function(o,g){var l=g.frag,d=g.payload,v=this.initPTS,h=this.unparsedVttFrags;if(l.type===m.PlaylistLevelType.SUBTITLE)if(d.byteLength){if(!Object(B.isFiniteNumber)(v[l.cc])){h.push(g),v.length&&this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:new Error("Missing initial subtitle PTS")});return}var u=l.decryptdata;if(u==null||u.key==null||u.method!=="AES-128"){var n=this.tracks[l.level],e=this.vttCCs;e[l.cc]||(e[l.cc]={start:l.start,prevCC:this.prevCC,new:!0},this.prevCC=l.cc),n&&n.textCodec===w.IMSC1_CODEC?this._parseIMSC1(l,d):this._parseVTTs(l,d,e)}}else this.hls.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:new Error("Empty subtitle payload")})},r._parseIMSC1=function(o,g){var l=this,d=this.hls;Object(w.parseIMSC1)(g,this.initPTS[o.cc],this.timescale[o.cc],function(v){l._appendCues(v,o.level),d.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(v){T.logger.log("Failed to parse IMSC1: "+v),d.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:v})})},r._parseVTTs=function(o,g,l){var d=this,v=this.hls;Object(M.parseWebVTT)(g,this.initPTS[o.cc],this.timescale[o.cc],l,o.cc,o.start,function(h){d._appendCues(h,o.level),v.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(h){d._fallbackToIMSC1(o,g),T.logger.log("Failed to parse VTT cue: "+h),v.trigger(_.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:h})})},r._fallbackToIMSC1=function(o,g){var l=this,d=this.tracks[o.level];d.textCodec||Object(w.parseIMSC1)(g,this.initPTS[o.cc],this.timescale[o.cc],function(){d.textCodec=w.IMSC1_CODEC,l._parseIMSC1(o,g)},function(){d.textCodec="wvtt"})},r._appendCues=function(o,g){var l=this.hls;if(this.config.renderTextTracksNatively){var d=this.textTracks[g];if(d.mode==="disabled")return;o.forEach(function(u){return Object(O.addCueToTrack)(d,u)})}else{var v=this.tracks[g],h=v.default?"default":"subtitles"+g;l.trigger(_.Events.CUES_PARSED,{type:"subtitles",cues:o,track:h})}},r.onFragDecrypted=function(o,g){var l=g.frag;if(l.type===m.PlaylistLevelType.SUBTITLE){if(!Object(B.isFiniteNumber)(this.initPTS[l.cc])){this.unparsedVttFrags.push(g);return}this.onFragLoaded(_.Events.FRAG_LOADED,g)}},r.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},r.onFragParsingUserdata=function(o,g){var l=this.cea608Parser1,d=this.cea608Parser2;if(!this.enabled||!(l&&d))return;for(var v=0;v<g.samples.length;v++){var h=g.samples[v].bytes;if(h){var u=this.extractCea608Data(h);l.addData(g.samples[v].pts,u[0]),d.addData(g.samples[v].pts,u[1])}}},r.onBufferFlushing=function(o,g){var l=g.startOffset,d=g.endOffset,v=g.endOffsetSubtitles,h=g.type,u=this.media;if(!u||u.currentTime<d)return;if(!h||h==="video"){var n=this.captionsTracks;Object.keys(n).forEach(function(t){return Object(O.removeCuesInRange)(n[t],l,d)})}if(this.config.renderTextTracksNatively&&(l===0&&v!==void 0)){var e=this.textTracks;Object.keys(e).forEach(function(t){return Object(O.removeCuesInRange)(e[t],l,v)})}},r.extractCea608Data=function(o){for(var g=o[0]&31,l=2,d=[[],[]],v=0;v<g;v++){var h=o[l++],u=127&o[l++],n=127&o[l++],e=(4&h)!==0,t=3&h;if(u===0&&n===0)continue;e&&((t===0||t===1)&&(d[t].push(u),d[t].push(n)))}return d},c}();function b(c,r){return c&&c.label===r.name&&!(c.textTrack1||c.textTrack2)}function E(c,r,a,o){return Math.min(r,o)-Math.max(c,a)}function y(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return B});var B=function(){function _(N,M){this.subtle=void 0,this.aesIV=void 0,this.subtle=N,this.aesIV=M}var R=_.prototype;return R.decrypt=function(M,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,M)},_}()},"./src/crypt/aes-decryptor.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"removePadding",function(){return _}),S.d(F,"default",function(){return R});var B=S("./src/utils/typed-array.ts");function _(N){var M=N.byteLength,O=M&&new DataView(N.buffer).getUint8(M-1);return O?Object(B.sliceUint8)(N,0,M-O):N}var R=function(){function N(){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 M=N.prototype;return M.uint8ArrayToUint32Array_=function(w){for(var m=new DataView(w),T=new Uint32Array(4),C=0;C<4;C++)T[C]=m.getUint32(C*4);return T},M.initTable=function(){var w=this.sBox,m=this.invSBox,T=this.subMix,C=T[0],b=T[1],E=T[2],y=T[3],c=this.invSubMix,r=c[0],a=c[1],o=c[2],g=c[3],l=new Uint32Array(256),d=0,v=0,h=0;for(h=0;h<256;h++)h<128?l[h]=h<<1:l[h]=h<<1^283;for(h=0;h<256;h++){var u=v^v<<1^v<<2^v<<3^v<<4;u=u>>>8^u&255^99,w[d]=u,m[u]=d;var n=l[d],e=l[n],t=l[e],f=l[u]*257^u*16843008;C[d]=f<<24|f>>>8,b[d]=f<<16|f>>>16,E[d]=f<<8|f>>>24,y[d]=f,f=t*16843009^e*65537^n*257^d*16843008,r[u]=f<<24|f>>>8,a[u]=f<<16|f>>>16,o[u]=f<<8|f>>>24,g[u]=f,d?(d=n^l[l[l[t^n]]],v^=l[l[v]]):d=v=1}},M.expandKey=function(w){for(var m=this.uint8ArrayToUint32Array_(w),T=!0,C=0;C<m.length&&T;)T=m[C]===this.key[C],C++;if(T)return;this.key=m;var b=this.keySize=m.length;if(b!==4&&b!==6&&b!==8)throw new Error("Invalid aes key size="+b);var E=this.ksRows=(b+6+1)*4,y,c,r=this.keySchedule=new Uint32Array(E),a=this.invKeySchedule=new Uint32Array(E),o=this.sBox,g=this.rcon,l=this.invSubMix,d=l[0],v=l[1],h=l[2],u=l[3],n,e;for(y=0;y<E;y++){if(y<b){n=r[y]=m[y];continue}e=n,y%b===0?(e=e<<8|e>>>24,e=o[e>>>24]<<24|o[e>>>16&255]<<16|o[e>>>8&255]<<8|o[e&255],e^=g[y/b|0]<<24):b>6&&y%b===4&&(e=o[e>>>24]<<24|o[e>>>16&255]<<16|o[e>>>8&255]<<8|o[e&255]),r[y]=n=(r[y-b]^e)>>>0}for(c=0;c<E;c++)y=E-c,c&3?e=r[y]:e=r[y-4],c<4||y<=4?a[c]=e:a[c]=d[o[e>>>24]]^v[o[e>>>16&255]]^h[o[e>>>8&255]]^u[o[e&255]],a[c]=a[c]>>>0},M.networkToHostOrderSwap=function(w){return w<<24|(w&65280)<<8|(w&16711680)>>8|w>>>24},M.decrypt=function(w,m,T){for(var C=this.keySize+6,b=this.invKeySchedule,E=this.invSBox,y=this.invSubMix,c=y[0],r=y[1],a=y[2],o=y[3],g=this.uint8ArrayToUint32Array_(T),l=g[0],d=g[1],v=g[2],h=g[3],u=new Int32Array(w),n=new Int32Array(u.length),e,t,f,p,x,A,I,U,j,z,V,G,Q,ne,re=this.networkToHostOrderSwap;m<u.length;){for(j=re(u[m]),z=re(u[m+1]),V=re(u[m+2]),G=re(u[m+3]),x=j^b[0],A=G^b[1],I=V^b[2],U=z^b[3],Q=4,ne=1;ne<C;ne++)e=c[x>>>24]^r[A>>16&255]^a[I>>8&255]^o[U&255]^b[Q],t=c[A>>>24]^r[I>>16&255]^a[U>>8&255]^o[x&255]^b[Q+1],f=c[I>>>24]^r[U>>16&255]^a[x>>8&255]^o[A&255]^b[Q+2],p=c[U>>>24]^r[x>>16&255]^a[A>>8&255]^o[I&255]^b[Q+3],x=e,A=t,I=f,U=p,Q=Q+4;e=E[x>>>24]<<24^E[A>>16&255]<<16^E[I>>8&255]<<8^E[U&255]^b[Q],t=E[A>>>24]<<24^E[I>>16&255]<<16^E[U>>8&255]<<8^E[x&255]^b[Q+1],f=E[I>>>24]<<24^E[U>>16&255]<<16^E[x>>8&255]<<8^E[A&255]^b[Q+2],p=E[U>>>24]<<24^E[x>>16&255]<<16^E[A>>8&255]<<8^E[I&255]^b[Q+3],n[m]=re(e^l),n[m+1]=re(p^d),n[m+2]=re(f^v),n[m+3]=re(t^h),l=j,d=z,v=V,h=G,m=m+4}return n.buffer},N}()},"./src/crypt/decrypter.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return m});var B=S("./src/crypt/aes-crypto.ts"),_=S("./src/crypt/fast-aes-key.ts"),R=S("./src/crypt/aes-decryptor.ts"),N=S("./src/utils/logger.ts"),M=S("./src/utils/mp4-tools.ts"),O=S("./src/utils/typed-array.ts"),w=16,m=function(){function T(b,E,y){var c=y===void 0?{}:y,r=c.removePKCS7Padding,a=r===void 0?!0:r;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=b,this.config=E,this.removePKCS7Padding=a,a)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(g){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var C=T.prototype;return C.destroy=function(){this.observer=null},C.isSync=function(){return this.config.enableSoftwareAES},C.flush=function(){var E=this.currentResult;if(!E){this.reset();return}var y=new Uint8Array(E);return this.reset(),this.removePKCS7Padding?Object(R.removePadding)(y):y},C.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},C.decrypt=function(E,y,c,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(E),y,c);var a=this.flush();a&&r(a.buffer)}else this.webCryptoDecrypt(new Uint8Array(E),y,c).then(r)},C.softwareDecrypt=function(E,y,c){var r=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(E=Object(M.appendUint8Array)(o,E),this.remainderData=null);var g=this.getValidChunk(E);if(!g.length)return null;r&&(c=r);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new R.default),l.expandKey(y);var d=a;return this.currentResult=l.decrypt(g.buffer,0,c),this.currentIV=Object(O.sliceUint8)(g,-16).buffer,d||null},C.webCryptoDecrypt=function(E,y,c){var r=this,a=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new _.default(a,y)),this.fastAesKey.expandKey().then(function(o){if(!a)return Promise.reject(new Error("web crypto not initialized"));var g=new B.default(a,c);return g.decrypt(E.buffer,o)}).catch(function(o){return r.onWebCryptoError(o,E,y,c)})},C.onWebCryptoError=function(E,y,c,r){return N.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",E),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,c,r)},C.getValidChunk=function(E){var y=E,c=E.length-E.length%w;return c!==E.length&&(y=Object(O.sliceUint8)(E,0,c),this.remainderData=Object(O.sliceUint8)(E,c)),y},C.logOnce=function(E){if(!this.logEnabled)return;N.logger.log("[decrypter.ts]: "+E),this.logEnabled=!1},T}()},"./src/crypt/fast-aes-key.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return B});var B=function(){function _(N,M){this.subtle=void 0,this.key=void 0,this.subtle=N,this.key=M}var R=_.prototype;return R.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},_}()},"./src/demux/aacdemuxer.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/demux/base-audio-demuxer.ts"),_=S("./src/demux/adts.ts"),R=S("./src/utils/logger.ts"),N=S("./src/demux/id3.ts");function M(m,T){m.prototype=Object.create(T.prototype),m.prototype.constructor=m,O(m,T)}function O(m,T){return O=Object.setPrototypeOf||function(b,E){return b.__proto__=E,b},O(m,T)}var w=function(m){M(T,m);function T(b,E){var y;return y=m.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=b,y.config=E,y}var C=T.prototype;return C.resetInitSegment=function(E,y,c){m.prototype.resetInitSegment.call(this,E,y,c),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:E,duration:c,inputTimeScale:9e4,dropped:0}},T.probe=function(E){if(!E)return!1;for(var y=N.getID3Data(E,0)||[],c=y.length,r=E.length;c<r;c++)if(_.probe(E,c))return R.logger.log("ADTS sync word found !"),!0;return!1},C.canParse=function(E,y){return _.canParse(E,y)},C.appendFrame=function(E,y,c){_.initTrackConfig(E,this.observer,y,c,E.manifestCodec);var r=_.appendFrame(E,y,c,this.initPTS,this.frameIndex);if(r&&r.missing===0)return r},T}(B.default);w.minProbeByteLength=9,F.default=w},"./src/demux/adts.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"getAudioConfig",function(){return N}),S.d(F,"isHeaderPattern",function(){return M}),S.d(F,"getHeaderLength",function(){return O}),S.d(F,"getFullFrameLength",function(){return w}),S.d(F,"canGetFrameLength",function(){return m}),S.d(F,"isHeader",function(){return T}),S.d(F,"canParse",function(){return C}),S.d(F,"probe",function(){return b}),S.d(F,"initTrackConfig",function(){return E}),S.d(F,"getFrameDuration",function(){return y}),S.d(F,"parseFrameHeader",function(){return c}),S.d(F,"appendFrame",function(){return r});var B=S("./src/utils/logger.ts"),_=S("./src/errors.ts"),R=S("./src/events.ts");function N(a,o,g,l){var d,v,h,u,n=navigator.userAgent.toLowerCase(),e=l,t=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];d=((o[g+2]&192)>>>6)+1;var f=(o[g+2]&60)>>>2;if(f>t.length-1){a.trigger(R.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return h=(o[g+2]&1)<<2,h|=(o[g+3]&192)>>>6,B.logger.log("manifest codec:"+l+", ADTS type:"+d+", samplingIndex:"+f),/firefox/i.test(n)?f>=6?(d=5,u=new Array(4),v=f-3):(d=2,u=new Array(2),v=f):n.indexOf("android")!==-1?(d=2,u=new Array(2),v=f):(d=5,u=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&f>=6?v=f-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(f>=6&&h===1||/vivaldi/i.test(n))||!l&&h===1)&&(d=2,u=new Array(2)),v=f)),u[0]=d<<3,u[0]|=(f&14)>>1,u[1]|=(f&1)<<7,u[1]|=h<<3,d===5&&(u[1]|=(v&14)>>1,u[2]=(v&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:t[f],channelCount:h,codec:"mp4a.40."+d,manifestCodec:e}}function M(a,o){return a[o]===255&&(a[o+1]&246)===240}function O(a,o){return a[o+1]&1?7:9}function w(a,o){return(a[o+3]&3)<<11|a[o+4]<<3|(a[o+5]&224)>>>5}function m(a,o){return o+5<a.length}function T(a,o){return o+1<a.length&&M(a,o)}function C(a,o){return m(a,o)&&M(a,o)&&w(a,o)<=a.length-o}function b(a,o){if(T(a,o)){var g=O(a,o);if(o+g>=a.length)return!1;var l=w(a,o);if(l<=g)return!1;var d=o+l;return d===a.length||T(a,d)}return!1}function E(a,o,g,l,d){if(!a.samplerate){var v=N(o,g,l,d);if(!v)return;a.config=v.config,a.samplerate=v.samplerate,a.channelCount=v.channelCount,a.codec=v.codec,a.manifestCodec=v.manifestCodec,B.logger.log("parsed codec:"+a.codec+", rate:"+v.samplerate+", channels:"+v.channelCount)}}function y(a){return 1024*9e4/a}function c(a,o,g,l,d){var v=O(a,o),h=w(a,o);if(h-=v,h>0){var u=g+l*d;return{headerLength:v,frameLength:h,stamp:u}}}function r(a,o,g,l,d){var v=y(a.samplerate),h=c(o,g,l,d,v);if(h){var u=h.frameLength,n=h.headerLength,e=h.stamp,t=n+u,f=Math.max(0,g+t-o.length),p;f?(p=new Uint8Array(t-n),p.set(o.subarray(g+n,o.length),0)):p=o.subarray(g+n,g+t);var x={unit:p,pts:e};return f||a.samples.push(x),{sample:x,length:t,missing:f}}}},"./src/demux/base-audio-demuxer.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"initPTSFn",function(){return w});var B=S("./src/polyfills/number.ts"),_=S("./src/demux/id3.ts"),R=S("./src/demux/dummy-demuxed-track.ts"),N=S("./src/utils/mp4-tools.ts"),M=S("./src/utils/typed-array.ts"),O=function(){function m(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var T=m.prototype;return T.resetInitSegment=function(b,E,y){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},T.resetTimeStamp=function(){},T.resetContiguity=function(){},T.canParse=function(b,E){return!1},T.appendFrame=function(b,E,y){},T.demux=function(b,E){this.cachedData&&(b=Object(N.appendUint8Array)(this.cachedData,b),this.cachedData=null);var y=_.getID3Data(b,0),c=y?y.length:0,r,a,o=this._audioTrack,g=this._id3Track,l=y?_.getTimeStamp(y):void 0,d=b.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=w(l,E)),y&&y.length>0&&g.samples.push({pts:this.initPTS,dts:this.initPTS,data:y}),a=this.initPTS;c<d;){if(this.canParse(b,c)){var v=this.appendFrame(o,b,c);v?(this.frameIndex++,a=v.sample.pts,c+=v.length,r=c):c=d}else _.canParse(b,c)?(y=_.getID3Data(b,c),g.samples.push({pts:a,dts:a,data:y}),c+=y.length,r=c):c++;if(c===d&&r!==d){var h=Object(M.sliceUint8)(b,r);this.cachedData?this.cachedData=Object(N.appendUint8Array)(this.cachedData,h):this.cachedData=h}}return{audioTrack:o,avcTrack:Object(R.dummyTrack)(),id3Track:g,textTrack:Object(R.dummyTrack)()}},T.demuxSampleAes=function(b,E,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},T.flush=function(b){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(R.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(R.dummyTrack)()}},T.destroy=function(){},m}(),w=function(T,C){return Object(B.isFiniteNumber)(T)?T*90:C*9e4};F.default=O},"./src/demux/chunk-cache.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return B});var B=function(){function R(){this.chunks=[],this.dataLength=0}var N=R.prototype;return N.push=function(O){this.chunks.push(O),this.dataLength+=O.length},N.flush=function(){var O=this.chunks,w=this.dataLength,m;if(O.length)O.length===1?m=O[0]:m=_(O,w);else return new Uint8Array(0);return this.reset(),m},N.reset=function(){this.chunks.length=0,this.dataLength=0},R}();function _(R,N){for(var M=new Uint8Array(N),O=0,w=0;w<R.length;w++){var m=R[w];M.set(m,O),O+=m.length}return M}},"./src/demux/dummy-demuxed-track.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"dummyTrack",function(){return B});function B(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/utils/logger.ts"),_=function(){function R(M){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=M,this.bytesAvailable=M.byteLength,this.word=0,this.bitsAvailable=0}var N=R.prototype;return N.loadWord=function(){var O=this.data,w=this.bytesAvailable,m=O.byteLength-w,T=new Uint8Array(4),C=Math.min(4,w);if(C===0)throw new Error("no bytes available");T.set(O.subarray(m,m+C)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=C*8,this.bytesAvailable-=C},N.skipBits=function(O){var w;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,w=O>>3,O-=w>>3,this.bytesAvailable-=w,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},N.readBits=function(O){var w=Math.min(this.bitsAvailable,O),m=this.word>>>32-w;return O>32&&B.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=w,this.bitsAvailable>0?this.word<<=w:this.bytesAvailable>0&&this.loadWord(),w=O-w,w>0&&this.bitsAvailable?m<<w|this.readBits(w):m},N.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},N.skipUEG=function(){this.skipBits(1+this.skipLZ())},N.skipEG=function(){this.skipBits(1+this.skipLZ())},N.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},N.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},N.readBoolean=function(){return this.readBits(1)===1},N.readUByte=function(){return this.readBits(8)},N.readUShort=function(){return this.readBits(16)},N.readUInt=function(){return this.readBits(32)},N.skipScalingList=function(O){for(var w=8,m=8,T,C=0;C<O;C++)m!==0&&(T=this.readEG(),m=(w+T+256)%256),w=m===0?w:m},N.readSPS=function(){var O=0,w=0,m=0,T=0,C,b,E,y=this.readUByte.bind(this),c=this.readBits.bind(this),r=this.readUEG.bind(this),a=this.readBoolean.bind(this),o=this.skipBits.bind(this),g=this.skipEG.bind(this),l=this.skipUEG.bind(this),d=this.skipScalingList.bind(this);y();var v=y();if(c(5),o(3),y(),l(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){var h=r();if(h===3&&o(1),l(),l(),o(1),a())for(b=h!==3?8:12,E=0;E<b;E++)a()&&(E<6?d(16):d(64))}l();var u=r();if(u===0)r();else if(u===1)for(o(1),g(),g(),C=r(),E=0;E<C;E++)g();l(),o(1);var n=r(),e=r(),t=c(1);t===0&&o(1),o(1),a()&&(O=r(),w=r(),m=r(),T=r());var f=[1,1];if(a()&&a()){var p=y();switch(p){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:{f=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((n+1)*16-O*2-w*2),height:(2-t)*(e+1)*16-(t?2:4)*(m+T),pixelRatio:f}},N.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},R}();F.default=_},"./src/demux/id3.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"isHeader",function(){return B}),S.d(F,"isFooter",function(){return _}),S.d(F,"getID3Data",function(){return R}),S.d(F,"canParse",function(){return M}),S.d(F,"getTimeStamp",function(){return O}),S.d(F,"isTimeStampFrame",function(){return w}),S.d(F,"getID3Frames",function(){return T}),S.d(F,"decodeFrame",function(){return C}),S.d(F,"utf8ArrayToStr",function(){return r}),S.d(F,"testables",function(){return a});var B=function(d,v){return v+10<=d.length&&(d[v]===73&&d[v+1]===68&&d[v+2]===51&&(d[v+3]<255&&d[v+4]<255&&(d[v+6]<128&&d[v+7]<128&&d[v+8]<128&&d[v+9]<128)))},_=function(d,v){return v+10<=d.length&&(d[v]===51&&d[v+1]===68&&d[v+2]===73&&(d[v+3]<255&&d[v+4]<255&&(d[v+6]<128&&d[v+7]<128&&d[v+8]<128&&d[v+9]<128)))},R=function(d,v){for(var h=v,u=0;B(d,v);){u+=10;var n=N(d,v+6);u+=n,_(d,v+10)&&(u+=10),v+=u}return u>0?d.subarray(h,h+u):void 0},N=function(d,v){var h=0;return h=(d[v]&127)<<21,h|=(d[v+1]&127)<<14,h|=(d[v+2]&127)<<7,h|=d[v+3]&127,h},M=function(d,v){return B(d,v)&&N(d,v+6)+10<=d.length-v},O=function(d){for(var v=T(d),h=0;h<v.length;h++){var u=v[h];if(w(u))return c(u)}return},w=function(d){return d&&d.key==="PRIV"&&d.info==="com.apple.streaming.transportStreamTimestamp"},m=function(d){var v=String.fromCharCode(d[0],d[1],d[2],d[3]),h=N(d,4),u=10;return{type:v,size:h,data:d.subarray(u,u+h)}},T=function(d){for(var v=0,h=[];B(d,v);){var u=N(d,v+6);v+=10;for(var n=v+u;v+8<n;){var e=m(d.subarray(v)),t=C(e);t&&h.push(t),v+=e.size+10}_(d,v)&&(v+=10)}return h},C=function(d){return d.type==="PRIV"?b(d):d.type[0]==="W"?y(d):E(d)},b=function(d){if(d.size<2)return;var v=r(d.data,!0),h=new Uint8Array(d.data.subarray(v.length+1));return{key:d.type,info:v,data:h.buffer}},E=function(d){if(d.size<2)return;if(d.type==="TXXX"){var v=1,h=r(d.data.subarray(v),!0);v+=h.length+1;var u=r(d.data.subarray(v));return{key:d.type,info:h,data:u}}var n=r(d.data.subarray(1));return{key:d.type,data:n}},y=function(d){if(d.type==="WXXX"){if(d.size<2)return;var v=1,h=r(d.data.subarray(v),!0);v+=h.length+1;var u=r(d.data.subarray(v));return{key:d.type,info:h,data:u}}var n=r(d.data);return{key:d.type,data:n}},c=function(d){if(d.data.byteLength===8){var v=new Uint8Array(d.data),h=v[3]&1,u=(v[4]<<23)+(v[5]<<15)+(v[6]<<7)+v[7];return u/=45,h&&(u+=4772185884e-2),Math.round(u)}return},r=function(d,v){v===void 0&&(v=!1);var h=g();if(h){var u=h.decode(d);if(v){var n=u.indexOf("\0");return n!==-1?u.substring(0,n):u}return u.replace(/\0/g,"")}for(var e=d.length,t,f,p,x="",A=0;A<e;){if(t=d[A++],t===0&&v)return x;if(t===0||t===3)continue;switch(t>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(t);break;case 12:case 13:f=d[A++],x+=String.fromCharCode((t&31)<<6|f&63);break;case 14:f=d[A++],p=d[A++],x+=String.fromCharCode((t&15)<<12|(f&63)<<6|(p&63)<<0);break;default:}}return x},a={decodeTextFrame:E},o;function g(){return!o&&typeof self.TextDecoder!="undefined"&&(o=new self.TextDecoder("utf-8")),o}},"./src/demux/mp3demuxer.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/demux/base-audio-demuxer.ts"),_=S("./src/demux/id3.ts"),R=S("./src/utils/logger.ts"),N=S("./src/demux/mpegaudio.ts");function M(m,T){m.prototype=Object.create(T.prototype),m.prototype.constructor=m,O(m,T)}function O(m,T){return O=Object.setPrototypeOf||function(b,E){return b.__proto__=E,b},O(m,T)}var w=function(m){M(T,m);function T(){return m.apply(this,arguments)||this}var C=T.prototype;return C.resetInitSegment=function(E,y,c){m.prototype.resetInitSegment.call(this,E,y,c),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:E,duration:c,inputTimeScale:9e4,dropped:0}},T.probe=function(E){if(!E)return!1;for(var y=_.getID3Data(E,0)||[],c=y.length,r=E.length;c<r;c++)if(N.probe(E,c))return R.logger.log("MPEG Audio sync word found !"),!0;return!1},C.canParse=function(E,y){return N.canParse(E,y)},C.appendFrame=function(E,y,c){return this.initPTS===null?void 0:N.appendFrame(E,y,c,this.initPTS,this.frameIndex)},T}(B.default);w.minProbeByteLength=4,F.default=w},"./src/demux/mp4demuxer.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/utils/mp4-tools.ts"),_=S("./src/demux/dummy-demuxed-track.ts"),R=function(){function N(O,w){this.remainderData=null,this.config=void 0,this.config=w}var M=N.prototype;return M.resetTimeStamp=function(){},M.resetInitSegment=function(){},M.resetContiguity=function(){},N.probe=function(w){return Object(B.findBox)({data:w,start:0,end:Math.min(w.length,16384)},["moof"]).length>0},M.demux=function(w){var m=w,T=Object(_.dummyTrack)();if(this.config.progressive){this.remainderData&&(m=Object(B.appendUint8Array)(this.remainderData,w));var C=Object(B.segmentValidRange)(m);this.remainderData=C.remainder,T.samples=C.valid||new Uint8Array}else T.samples=m;return{audioTrack:Object(_.dummyTrack)(),avcTrack:T,id3Track:Object(_.dummyTrack)(),textTrack:Object(_.dummyTrack)()}},M.flush=function(){var w=Object(_.dummyTrack)();return w.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(_.dummyTrack)(),avcTrack:w,id3Track:Object(_.dummyTrack)(),textTrack:Object(_.dummyTrack)()}},M.demuxSampleAes=function(w,m,T){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},M.destroy=function(){},N}();R.minProbeByteLength=1024,F.default=R},"./src/demux/mpegaudio.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"appendFrame",function(){return O}),S.d(F,"parseHeader",function(){return w}),S.d(F,"isHeaderPattern",function(){return m}),S.d(F,"isHeader",function(){return T}),S.d(F,"canParse",function(){return C}),S.d(F,"probe",function(){return b});var B=null,_=[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],R=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],N=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],M=[0,1,1,4];function O(E,y,c,r,a){if(c+24>y.length)return;var o=w(y,c);if(o&&c+o.frameLength<=y.length){var g=o.samplesPerFrame*9e4/o.sampleRate,l=r+a*g,d={unit:y.subarray(c,c+o.frameLength),pts:l,dts:l};return E.config=[],E.channelCount=o.channelCount,E.samplerate=o.sampleRate,E.samples.push(d),{sample:d,length:o.frameLength,missing:0}}}function w(E,y){var c=E[y+1]>>3&3,r=E[y+1]>>1&3,a=E[y+2]>>4&15,o=E[y+2]>>2&3;if(c!==1&&a!==0&&a!==15&&o!==3){var g=E[y+2]>>1&1,l=E[y+3]>>6,d=c===3?3-r:r===3?3:4,v=_[d*14+a-1]*1e3,h=c===3?0:c===2?1:2,u=R[h*3+o],n=l===3?1:2,e=N[c][r],t=M[r],f=e*8*t,p=Math.floor(e*v/u+g)*t;if(B===null){var x=navigator.userAgent||"",A=x.match(/Chrome\/(\d+)/i);B=A?parseInt(A[1]):0}var I=!!B&&B<=87;return I&&r===2&&v>=224e3&&l===0&&(E[y+3]=E[y+3]|128),{sampleRate:u,channelCount:n,frameLength:p,samplesPerFrame:f}}}function m(E,y){return E[y]===255&&(E[y+1]&224)===224&&(E[y+1]&6)!==0}function T(E,y){return y+1<E.length&&m(E,y)}function C(E,y){var c=4;return m(E,y)&&c<=E.length-y}function b(E,y){if(y+1<E.length&&m(E,y)){var c=4,r=w(E,y),a=c;r!=null&&r.frameLength&&(a=r.frameLength);var o=y+a;return o===E.length||T(E,o)}return!1}},"./src/demux/sample-aes.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/crypt/decrypter.ts"),_=S("./src/demux/tsdemuxer.ts"),R=function(){function N(O,w,m){this.keyData=void 0,this.decrypter=void 0,this.keyData=m,this.decrypter=new B.default(O,w,{removePKCS7Padding:!1})}var M=N.prototype;return M.decryptBuffer=function(w,m){this.decrypter.decrypt(w,this.keyData.key.buffer,this.keyData.iv.buffer,m)},M.decryptAacSample=function(w,m,T,C){var b=w[m].unit,E=b.subarray(16,b.length-b.length%16),y=E.buffer.slice(E.byteOffset,E.byteOffset+E.length),c=this;this.decryptBuffer(y,function(r){var a=new Uint8Array(r);b.set(a,16),C||c.decryptAacSamples(w,m+1,T)})},M.decryptAacSamples=function(w,m,T){for(;;m++){if(m>=w.length){T();return}if(w[m].unit.length<32)continue;var C=this.decrypter.isSync();if(this.decryptAacSample(w,m,T,C),!C)return}},M.getAvcEncryptedData=function(w){for(var m=Math.floor((w.length-48)/160)*16+16,T=new Int8Array(m),C=0,b=32;b<=w.length-16;b+=160,C+=16)T.set(w.subarray(b,b+16),C);return T},M.getAvcDecryptedUnit=function(w,m){for(var T=new Uint8Array(m),C=0,b=32;b<=w.length-16;b+=160,C+=16)w.set(T.subarray(C,C+16),b);return w},M.decryptAvcSample=function(w,m,T,C,b,E){var y=Object(_.discardEPB)(b.data),c=this.getAvcEncryptedData(y),r=this;this.decryptBuffer(c.buffer,function(a){b.data=r.getAvcDecryptedUnit(y,a),E||r.decryptAvcSamples(w,m,T+1,C)})},M.decryptAvcSamples=function(w,m,T,C){if(w instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;m++,T=0){if(m>=w.length){C();return}for(var b=w[m].units;!(T>=b.length);T++){var E=b[T];if(E.data.length<=48||E.type!==1&&E.type!==5)continue;var y=this.decrypter.isSync();if(this.decryptAvcSample(w,m,T,C,E,y),!y)return}}},N}();F.default=R},"./src/demux/transmuxer-interface.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return b});var B=S("./node_modules/webworkify-webpack/index.js"),_=S.n(B),R=S("./src/events.ts"),N=S("./src/demux/transmuxer.ts"),M=S("./src/utils/logger.ts"),O=S("./src/errors.ts"),w=S("./src/utils/mediasource-helper.ts"),m=S("./node_modules/eventemitter3/index.js"),T=S.n(m),C=Object(w.getMediaSource)()||{isTypeSupported:function(){return!1}},b=function(){function E(c,r,a,o){var g=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=c,this.id=r,this.onTransmuxComplete=a,this.onFlush=o;var l=c.config,d=function(e,t){t=t||{},t.frag=g.frag,t.id=g.id,c.trigger(e,t)};this.observer=new m.EventEmitter,this.observer.on(R.Events.FRAG_DECRYPTED,d),this.observer.on(R.Events.ERROR,d);var v={mp4:C.isTypeSupported("video/mp4"),mpeg:C.isTypeSupported("audio/mpeg"),mp3:C.isTypeSupported('audio/mp4; codecs="mp3"')},h=navigator.vendor;if(l.enableWorker&&typeof Worker!="undefined"){M.logger.log("demuxing in webworker");var u;try{u=this.worker=B("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(n){c.trigger(R.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},u.postMessage({cmd:"init",typeSupported:v,vendor:h,id:r,config:JSON.stringify(l)})}catch(n){M.logger.warn("Error in worker:",n),M.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new N.default(this.observer,v,l,h,r),this.worker=null}}else this.transmuxer=new N.default(this.observer,v,l,h,r)}var y=E.prototype;return y.destroy=function(){var r=this.worker;if(r)r.removeEventListener("message",this.onwmsg),r.terminate(),this.worker=null;else{var a=this.transmuxer;a&&(a.destroy(),this.transmuxer=null)}var o=this.observer;o&&o.removeAllListeners(),this.observer=null},y.push=function(r,a,o,g,l,d,v,h,u,n){var e=this;u.transmuxing.start=self.performance.now();var t=this.transmuxer,f=this.worker,p=d?d.start:l.start,x=l.decryptdata,A=this.frag,I=!(A&&l.cc===A.cc),U=!(A&&u.level===A.level),j=A?u.sn-A.sn:-1,z=this.part?u.part-this.part.index:1,V=!U&&(j===1||j===0&&z===1),G=self.performance.now();(U||j||l.stats.parsing.start===0)&&(l.stats.parsing.start=G),d&&(z||!V)&&(d.stats.parsing.start=G);var Q=new N.TransmuxState(I,V,h,U,p);if(!V||I){M.logger.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
discontinuity: `+I+`
|
|
trackSwitch: `+U+`
|
|
contiguous: `+V+`
|
|
accurateTimeOffset: `+h+`
|
|
timeOffset: `+p);var ne=new N.TransmuxConfig(o,g,a,v,n);this.configureTransmuxer(ne)}if(this.frag=l,this.part=d,f)f.postMessage({cmd:"demux",data:r,decryptdata:x,chunkMeta:u,state:Q},r instanceof ArrayBuffer?[r]:[]);else if(t){var re=t.push(r,x,u,Q);Object(N.isPromise)(re)?re.then(function(be){e.handleTransmuxComplete(be)}):this.handleTransmuxComplete(re)}},y.flush=function(r){var a=this;r.transmuxing.start=self.performance.now();var o=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:r});else if(o){var l=o.flush(r);Object(N.isPromise)(l)?l.then(function(d){a.handleFlushResult(d,r)}):this.handleFlushResult(l,r)}},y.handleFlushResult=function(r,a){var o=this;r.forEach(function(g){o.handleTransmuxComplete(g)}),this.onFlush(a)},y.onWorkerMessage=function(r){var a=r.data,o=this.hls;switch(a.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(a.data);break}case"flush":{this.onFlush(a.data);break}default:{a.data=a.data||{},a.data.frag=this.frag,a.data.id=this.id,o.trigger(a.event,a.data);break}}},y.configureTransmuxer=function(r){var a=this.worker,o=this.transmuxer;a?a.postMessage({cmd:"configure",config:r}):o&&o.configure(r)},y.handleTransmuxComplete=function(r){r.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(r)},E}()},"./src/demux/transmuxer-worker.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return O});var B=S("./src/demux/transmuxer.ts"),_=S("./src/events.ts"),R=S("./src/utils/logger.ts"),N=S("./node_modules/eventemitter3/index.js"),M=S.n(N);function O(b){var E=new N.EventEmitter,y=function(r,a){b.postMessage({event:r,data:a})};E.on(_.Events.FRAG_DECRYPTED,y),E.on(_.Events.ERROR,y),b.addEventListener("message",function(c){var r=c.data;switch(r.cmd){case"init":{var a=JSON.parse(r.config);b.transmuxer=new B.default(E,r.typeSupported,a,r.vendor,r.id),Object(R.enableLogs)(a.debug),y("init",null);break}case"configure":{b.transmuxer.configure(r.config);break}case"demux":{var o=b.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);Object(B.isPromise)(o)?o.then(function(d){w(b,d)}):w(b,o);break}case"flush":{var g=r.chunkMeta,l=b.transmuxer.flush(g);Object(B.isPromise)(l)?l.then(function(d){T(b,d,g)}):T(b,l,g);break}default:break}})}function w(b,E){if(C(E.remuxResult))return;var y=[],c=E.remuxResult,r=c.audio,a=c.video;r&&m(y,r),a&&m(y,a),b.postMessage({event:"transmuxComplete",data:E},y)}function m(b,E){E.data1&&b.push(E.data1.buffer),E.data2&&b.push(E.data2.buffer)}function T(b,E,y){E.forEach(function(c){w(b,c)}),b.postMessage({event:"flush",data:y})}function C(b){return!b.audio&&!b.video&&!b.text&&!b.id3&&!b.initSegment}},"./src/demux/transmuxer.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return a}),S.d(F,"isPromise",function(){return l}),S.d(F,"TransmuxConfig",function(){return d}),S.d(F,"TransmuxState",function(){return v});var B=S("./src/events.ts"),_=S("./src/errors.ts"),R=S("./src/crypt/decrypter.ts"),N=S("./src/demux/aacdemuxer.ts"),M=S("./src/demux/mp4demuxer.ts"),O=S("./src/demux/tsdemuxer.ts"),w=S("./src/demux/mp3demuxer.ts"),m=S("./src/remux/mp4-remuxer.ts"),T=S("./src/remux/passthrough-remuxer.ts"),C=S("./src/demux/chunk-cache.ts"),b=S("./src/utils/mp4-tools.ts"),E=S("./src/utils/logger.ts"),y;try{y=self.performance.now.bind(self.performance)}catch(h){E.logger.debug("Unable to use Performance API on this environment"),y=self.Date.now}var c=[{demux:O.default,remux:m.default},{demux:M.default,remux:T.default},{demux:N.default,remux:m.default},{demux:w.default,remux:m.default}],r=1024;c.forEach(function(h){var u=h.demux;r=Math.max(r,u.minProbeByteLength)});var a=function(){function h(n,e,t,f,p){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 C.default,this.observer=n,this.typeSupported=e,this.config=t,this.vendor=f,this.id=p}var u=h.prototype;return u.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},u.push=function(e,t,f,p){var x=this,A=f.transmuxing;A.executeStart=y();var I=new Uint8Array(e),U=this.cache,j=this.config,z=this.currentTransmuxState,V=this.transmuxConfig;p&&(this.currentTransmuxState=p);var G=o(I,t);if(G&&G.method==="AES-128"){var Q=this.getDecrypter();if(j.enableSoftwareAES){var ne=Q.softwareDecrypt(I,G.key.buffer,G.iv.buffer);if(!ne)return A.executeEnd=y(),g(f);I=new Uint8Array(ne)}else return this.decryptionPromise=Q.webCryptoDecrypt(I,G.key.buffer,G.iv.buffer).then(function(ye){var we=x.push(ye,null,f);return x.decryptionPromise=null,we}),this.decryptionPromise}var re=p||z,be=re.contiguous,se=re.discontinuity,oe=re.trackSwitch,ue=re.accurateTimeOffset,he=re.timeOffset,te=V.audioCodec,Y=V.videoCodec,fe=V.defaultInitPts,Re=V.duration,Le=V.initSegmentData;if((se||oe)&&this.resetInitSegment(Le,te,Y,Re),se&&this.resetInitialTimestamp(fe),be||this.resetContiguity(),this.needsProbing(I,se,oe)){if(U.dataLength){var xe=U.flush();I=Object(b.appendUint8Array)(xe,I)}this.configureTransmuxer(I,V)}var Te=this.transmux(I,G,he,ue,f),le=this.currentTransmuxState;return le.contiguous=!0,le.discontinuity=!1,le.trackSwitch=!1,A.executeEnd=y(),Te},u.flush=function(e){var t=this,f=e.transmuxing;f.executeStart=y();var p=this.decrypter,x=this.cache,A=this.currentTransmuxState,I=this.decryptionPromise;if(I)return I.then(function(){return t.flush(e)});var U=[],j=A.timeOffset;if(p){var z=p.flush();z&&U.push(this.push(z,null,e))}var V=x.dataLength;x.reset();var G=this.demuxer,Q=this.remuxer;if(!G||!Q)return V>=r&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),f.executeEnd=y(),[g(e)];var ne=G.flush(j);return l(ne)?ne.then(function(re){return t.flushRemux(U,re,e),U}):(this.flushRemux(U,ne,e),U)},u.flushRemux=function(e,t,f){var p=t.audioTrack,x=t.avcTrack,A=t.id3Track,I=t.textTrack,U=this.currentTransmuxState,j=U.accurateTimeOffset,z=U.timeOffset;E.logger.log("[transmuxer.ts]: Flushed fragment "+f.sn+(f.part>-1?" p: "+f.part:"")+" of level "+f.level);var V=this.remuxer.remux(p,x,A,I,z,j,!0,this.id);e.push({remuxResult:V,chunkMeta:f}),f.transmuxing.executeEnd=y()},u.resetInitialTimestamp=function(e){var t=this.demuxer,f=this.remuxer;if(!t||!f)return;t.resetTimeStamp(e),f.resetTimeStamp(e)},u.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;if(!e||!t)return;e.resetContiguity(),t.resetNextTimestamp()},u.resetInitSegment=function(e,t,f,p){var x=this.demuxer,A=this.remuxer;if(!x||!A)return;x.resetInitSegment(t,f,p),A.resetInitSegment(e,t,f)},u.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},u.transmux=function(e,t,f,p,x){var A;return t&&t.method==="SAMPLE-AES"?A=this.transmuxSampleAes(e,t,f,p,x):A=this.transmuxUnencrypted(e,f,p,x),A},u.transmuxUnencrypted=function(e,t,f,p){var x=this.demuxer.demux(e,t,!1,!this.config.progressive),A=x.audioTrack,I=x.avcTrack,U=x.id3Track,j=x.textTrack,z=this.remuxer.remux(A,I,U,j,t,f,!1,this.id);return{remuxResult:z,chunkMeta:p}},u.transmuxSampleAes=function(e,t,f,p,x){var A=this;return this.demuxer.demuxSampleAes(e,t,f).then(function(I){var U=A.remuxer.remux(I.audioTrack,I.avcTrack,I.id3Track,I.textTrack,f,p,!1,A.id);return{remuxResult:U,chunkMeta:x}})},u.configureTransmuxer=function(e,t){for(var f=this.config,p=this.observer,x=this.typeSupported,A=this.vendor,I=t.audioCodec,U=t.defaultInitPts,j=t.duration,z=t.initSegmentData,V=t.videoCodec,G,Q=0,ne=c.length;Q<ne;Q++)if(c[Q].demux.probe(e)){G=c[Q];break}G||(E.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),G={demux:M.default,remux:T.default});var re=this.demuxer,be=this.remuxer,se=G.remux,oe=G.demux;(!be||!(be instanceof se))&&(this.remuxer=new se(p,f,x,A)),(!re||!(re instanceof oe))&&(this.demuxer=new oe(p,f,x),this.probe=oe.probe),this.resetInitSegment(z,I,V,j),this.resetInitialTimestamp(U)},u.needsProbing=function(e,t,f){return!this.demuxer||!this.remuxer||t||f},u.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new R.default(this.observer,this.config)),e},h}();function o(h,u){var n=null;return h.byteLength>0&&u!=null&&u.key!=null&&u.iv!==null&&u.method!=null&&(n=u),n}var g=function(u){return{remuxResult:{},chunkMeta:u}};function l(h){return"then"in h&&h.then instanceof Function}var d=function(u,n,e,t,f){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=n,this.initSegmentData=e,this.duration=t,this.defaultInitPts=f},v=function(u,n,e,t,f){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=u,this.contiguous=n,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=f}},"./src/demux/tsdemuxer.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"discardEPB",function(){return g});var B=S("./src/demux/adts.ts"),_=S("./src/demux/mpegaudio.ts"),R=S("./src/demux/exp-golomb.ts"),N=S("./src/demux/id3.ts"),M=S("./src/demux/sample-aes.ts"),O=S("./src/events.ts"),w=S("./src/utils/mp4-tools.ts"),m=S("./src/utils/logger.ts"),T=S("./src/errors.ts"),C={video:1,audio:2,id3:3,text:4},b=function(){function l(v,h,u){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=v,this.config=h,this.typeSupported=u}l.probe=function(h){var u=l.syncOffset(h);return u<0?!1:(u&&m.logger.warn("MPEG2-TS detected but first sync word found @ offset "+u+", junk ahead ?"),!0)},l.syncOffset=function(h){for(var u=Math.min(1e3,h.length-3*188),n=0;n<u;){if(h[n]===71&&h[n+188]===71&&h[n+2*188]===71)return n;n++}return-1},l.createTrack=function(h,u){return{container:h==="video"||h==="audio"?"video/mp2t":void 0,type:h,id:C[h],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:h==="audio"?u:void 0}};var d=l.prototype;return d.resetInitSegment=function(h,u,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video",n),this._audioTrack=l.createTrack("audio",n),this._id3Track=l.createTrack("id3",n),this._txtTrack=l.createTrack("text",n),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=h,this.videoCodec=u,this._duration=n},d.resetTimeStamp=function(){},d.resetContiguity=function(){var h=this._audioTrack,u=this._avcTrack,n=this._id3Track;h&&(h.pesData=null),u&&(u.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},d.demux=function(h,u,n,e){n===void 0&&(n=!1),e===void 0&&(e=!1),n||(this.sampleAes=null);var t,f=this._avcTrack,p=this._audioTrack,x=this._id3Track,A=f.pid,I=f.pesData,U=p.pid,j=x.pid,z=p.pesData,V=x.pesData,G=!1,Q=this.pmtParsed,ne=this._pmtId,re=h.length;if(this.remainderData&&(h=Object(w.appendUint8Array)(this.remainderData,h),re=h.length,this.remainderData=null),re<188&&!e)return this.remainderData=h,{audioTrack:p,avcTrack:f,id3Track:x,textTrack:this._txtTrack};var be=Math.max(0,l.syncOffset(h));re-=(re+be)%188,re<h.byteLength&&!e&&(this.remainderData=new Uint8Array(h.buffer,re,h.buffer.byteLength-re));for(var se=be;se<re;se+=188)if(h[se]===71){var oe=!!(h[se+1]&64),ue=((h[se+1]&31)<<8)+h[se+2],he=(h[se+3]&48)>>4,te=void 0;if(he>1){if(te=se+5+h[se+4],te===se+188)continue}else te=se+4;switch(ue){case A:oe&&(I&&(t=r(I))&&this.parseAVCPES(t,!1),I={data:[],size:0}),I&&(I.data.push(h.subarray(te,se+188)),I.size+=se+188-te);break;case U:oe&&(z&&(t=r(z))&&(p.isAAC?this.parseAACPES(t):this.parseMPEGPES(t)),z={data:[],size:0}),z&&(z.data.push(h.subarray(te,se+188)),z.size+=se+188-te);break;case j:oe&&(V&&(t=r(V))&&this.parseID3PES(t),V={data:[],size:0}),V&&(V.data.push(h.subarray(te,se+188)),V.size+=se+188-te);break;case 0:oe&&(te+=h[te]+1),ne=this._pmtId=y(h,te);break;case ne:{oe&&(te+=h[te]+1);var Y=c(h,te,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,n);A=Y.avc,A>0&&(f.pid=A),U=Y.audio,U>0&&(p.pid=U,p.isAAC=Y.isAAC),j=Y.id3,j>0&&(x.pid=j),G&&!Q&&(m.logger.log("reparse from beginning"),G=!1,se=be-188),Q=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=!0;break}}else this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});f.pesData=I,p.pesData=z,x.pesData=V;var fe={audioTrack:p,avcTrack:f,id3Track:x,textTrack:this._txtTrack};return e&&this.extractRemainingSamples(fe),fe},d.flush=function(){var h=this.remainderData;this.remainderData=null;var u;return h?u=this.demux(h,-1,!1,!0):u={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(u),this.sampleAes?this.decrypt(u,this.sampleAes):u},d.extractRemainingSamples=function(h){var u=h.audioTrack,n=h.avcTrack,e=h.id3Track,t=n.pesData,f=u.pesData,p=e.pesData,x;t&&(x=r(t))?(this.parseAVCPES(x,!0),n.pesData=null):n.pesData=t,f&&(x=r(f))?(u.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),u.pesData=null):(f!=null&&f.size&&m.logger.log("last AAC PES packet truncated,might overlap between fragments"),u.pesData=f),p&&(x=r(p))?(this.parseID3PES(x),e.pesData=null):e.pesData=p},d.demuxSampleAes=function(h,u,n){var e=this.demux(h,n,!0,!this.config.progressive),t=this.sampleAes=new M.default(this.observer,this.config,u);return this.decrypt(e,t)},d.decrypt=function(h,u){return new Promise(function(n){var e=h.audioTrack,t=h.avcTrack;e.samples&&e.isAAC?u.decryptAacSamples(e.samples,0,function(){t.samples?u.decryptAvcSamples(t.samples,0,0,function(){n(h)}):n(h)}):t.samples&&u.decryptAvcSamples(t.samples,0,0,function(){n(h)})})},d.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},d.parseAVCPES=function(h,u){var n=this,e=this._avcTrack,t=this.parseAVCNALu(h.data),f=!1,p=this.avcSample,x,A=!1;h.data=null,p&&t.length&&!e.audFound&&(a(p,e),p=this.avcSample=E(!1,h.pts,h.dts,"")),t.forEach(function(I){switch(I.type){case 1:{x=!0,p||(p=n.avcSample=E(!0,h.pts,h.dts,"")),f&&(p.debug+="NDR "),p.frame=!0;var U=I.data;if(A&&U.length>4){var j=new R.default(U).readSliceType();(j===2||j===4||j===7||j===9)&&(p.key=!0)}break}case 5:x=!0,p||(p=n.avcSample=E(!0,h.pts,h.dts,"")),f&&(p.debug+="IDR "),p.key=!0,p.frame=!0;break;case 6:{x=!0,f&&p&&(p.debug+="SEI ");var z=new R.default(g(I.data));z.readUByte();for(var V=0,G=0,Q=!1,ne=0;!Q&&z.bytesAvailable>1;){V=0;do ne=z.readUByte(),V+=ne;while(ne===255);G=0;do ne=z.readUByte(),G+=ne;while(ne===255);if(V===4&&z.bytesAvailable!==0){Q=!0;var re=z.readUByte();if(re===181){var be=z.readUShort();if(be===49){var se=z.readUInt();if(se===1195456820){var oe=z.readUByte();if(oe===3){for(var ue=z.readUByte(),he=z.readUByte(),te=31&ue,Y=[ue,he],fe=0;fe<te;fe++)Y.push(z.readUByte()),Y.push(z.readUByte()),Y.push(z.readUByte());o(n._txtTrack.samples,{type:3,pts:h.pts,bytes:Y})}}}}}else if(V===5&&z.bytesAvailable!==0){if(Q=!0,G>16){for(var Re=[],Le=0;Le<16;Le++)Re.push(z.readUByte().toString(16)),(Le===3||Le===5||Le===7||Le===9)&&Re.push("-");for(var xe=G-16,Te=new Uint8Array(xe),le=0;le<xe;le++)Te[le]=z.readUByte();o(n._txtTrack.samples,{pts:h.pts,payloadType:V,uuid:Re.join(""),userData:Object(N.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(G<z.bytesAvailable)for(var ye=0;ye<G;ye++)z.readUByte()}break}case 7:if(x=!0,A=!0,f&&p&&(p.debug+="SPS "),!e.sps){var we=new R.default(I.data),De=we.readSPS();e.width=De.width,e.height=De.height,e.pixelRatio=De.pixelRatio,e.sps=[I.data],e.duration=n._duration;for(var Se=I.data.subarray(1,4),pe="avc1.",me=0;me<3;me++){var Fe=Se[me].toString(16);Fe.length<2&&(Fe="0"+Fe),pe+=Fe}e.codec=pe}break;case 8:x=!0,f&&p&&(p.debug+="PPS "),e.pps||(e.pps=[I.data]);break;case 9:x=!1,e.audFound=!0,p&&a(p,e),p=n.avcSample=E(!1,h.pts,h.dts,f?"AUD ":"");break;case 12:x=!1;break;default:x=!1,p&&(p.debug+="unknown NAL "+I.type+" ");break}if(p&&x){var Pe=p.units;Pe.push(I)}}),u&&p&&(a(p,e),this.avcSample=null)},d.getLastNalUnit=function(){var h,u=this.avcSample,n;if(!u||u.units.length===0){var e=this._avcTrack.samples;u=e[e.length-1]}if((h=u)!==null&&h!==void 0&&h.units){var t=u.units;n=t[t.length-1]}return n},d.parseAVCNALu=function(h){var u=h.byteLength,n=this._avcTrack,e=n.naluState||0,t=e,f=[],p=0,x,A,I,U=-1,j=0;for(e===-1&&(U=0,j=h[0]&31,e=0,p=1);p<u;){if(x=h[p++],!e){e=x?0:1;continue}if(e===1){e=x?0:2;continue}if(!x)e=3;else if(x===1){if(U>=0){var z={data:h.subarray(U,p-e-1),type:j};f.push(z)}else{var V=this.getLastNalUnit();if(V&&(t&&p<=4-t&&(V.state&&(V.data=V.data.subarray(0,V.data.byteLength-t))),A=p-e-1,A>0)){var G=new Uint8Array(V.data.byteLength+A);G.set(V.data,0),G.set(h.subarray(0,A),V.data.byteLength),V.data=G,V.state=0}}p<u?(I=h[p]&31,U=p,j=I,e=0):e=-1}else e=0}if(U>=0&&e>=0){var Q={data:h.subarray(U,u),type:j,state:e};f.push(Q)}if(f.length===0){var ne=this.getLastNalUnit();if(ne){var re=new Uint8Array(ne.data.byteLength+h.byteLength);re.set(ne.data,0),re.set(h,ne.data.byteLength),ne.data=re}}return n.naluState=e,f},d.parseAACPES=function(h){var u=0,n=this._audioTrack,e=this.aacOverFlow,t=h.data;if(e){this.aacOverFlow=null;var f=e.sample.unit.byteLength,p=Math.min(e.missing,f),x=f-p;e.sample.unit.set(t.subarray(0,p),x),n.samples.push(e.sample),u=e.missing}var A,I;for(A=u,I=t.length;A<I-1&&!B.isHeader(t,A);A++);if(A!==u){var U,j;if(A<I-1?(U="AAC PES did not start with ADTS header,offset:"+A,j=!1):(U="no ADTS header found in AAC PES",j=!0),m.logger.warn("parsing error:"+U),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:j,reason:U}),j)return}B.initTrackConfig(n,this.observer,t,A,this.audioCodec);var z;if(h.pts!==void 0)z=h.pts;else if(e){var V=B.getFrameDuration(n.samplerate);z=e.sample.pts+V}else{m.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0;A<I;)if(B.isHeader(t,A)){if(A+5<I){var Q=B.appendFrame(n,t,A,z,G);if(Q)if(Q.missing)this.aacOverFlow=Q;else{A+=Q.length,G++;continue}}break}else A++},d.parseMPEGPES=function(h){var u=h.data,n=u.length,e=0,t=0,f=h.pts;if(f===void 0){m.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;t<n;)if(_.isHeader(u,t)){var p=_.appendFrame(this._audioTrack,u,t,f,e);if(p)t+=p.length,e++;else break}else t++},d.parseID3PES=function(h){if(h.pts===void 0){m.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(h)},l}();b.minProbeByteLength=188;function E(l,d,v,h){return{key:l,frame:!1,pts:d,dts:v,units:[],debug:h,length:0}}function y(l,d){return(l[d+10]&31)<<8|l[d+11]}function c(l,d,v,h){var u={audio:-1,avc:-1,id3:-1,isAAC:!0},n=(l[d+1]&15)<<8|l[d+2],e=d+3+n-4,t=(l[d+10]&15)<<8|l[d+11];for(d+=12+t;d<e;){var f=(l[d+1]&31)<<8|l[d+2];switch(l[d]){case 207:if(!h){m.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:u.audio===-1&&(u.audio=f);break;case 21:u.id3===-1&&(u.id3=f);break;case 219:if(!h){m.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:u.avc===-1&&(u.avc=f);break;case 3:case 4:v?u.audio===-1&&(u.audio=f,u.isAAC=!1):m.logger.log("MPEG audio found, not supported in this browser");break;case 36:m.logger.warn("Unsupported HEVC stream type found");break;default:break}d+=((l[d+3]&15)<<8|l[d+4])+5}return u}function r(l){var d=0,v,h,u,n,e,t=l.data;if(!l||l.size===0)return null;for(;t[0].length<19&&t.length>1;){var f=new Uint8Array(t[0].length+t[1].length);f.set(t[0]),f.set(t[1],t[0].length),t[0]=f,t.splice(1,1)}v=t[0];var p=(v[0]<<16)+(v[1]<<8)+v[2];if(p===1){if(h=(v[4]<<8)+v[5],h&&h>l.size-6)return null;var x=v[7];x&192&&(n=(v[9]&14)*536870912+(v[10]&255)*4194304+(v[11]&254)*16384+(v[12]&255)*128+(v[13]&254)/2,x&64?(e=(v[14]&14)*536870912+(v[15]&255)*4194304+(v[16]&254)*16384+(v[17]&255)*128+(v[18]&254)/2,n-e>60*9e4&&(m.logger.warn(Math.round((n-e)/9e4)+"s delta between PTS and DTS, align them"),n=e)):e=n),u=v[8];var A=u+9;if(l.size<=A)return null;l.size-=A;for(var I=new Uint8Array(l.size),U=0,j=t.length;U<j;U++){v=t[U];var z=v.byteLength;if(A)if(A>z){A-=z;continue}else v=v.subarray(A),z-=A,A=0;I.set(v,d),d+=z}return h&&(h-=u+3),{data:I,pts:n,dts:e,len:h}}return null}function a(l,d){if(l.units.length&&l.frame){if(l.pts===void 0){var v=d.samples,h=v.length;if(h){var u=v[h-1];l.pts=u.pts,l.dts=u.dts}else{d.dropped++;return}}d.samples.push(l)}l.debug.length&&m.logger.log(l.pts+"/"+l.dts+":"+l.debug)}function o(l,d){var v=l.length;if(v>0){if(d.pts>=l[v-1].pts)l.push(d);else for(var h=v-1;h>=0;h--)if(d.pts<l[h].pts){l.splice(h,0,d);break}}else l.push(d)}function g(l){for(var d=l.byteLength,v=[],h=1;h<d-2;)l[h]===0&&l[h+1]===0&&l[h+2]===3?(v.push(h+2),h+=2):h++;if(v.length===0)return l;var u=d-v.length,n=new Uint8Array(u),e=0;for(h=0;h<u;e++,h++)e===v[0]&&(e++,v.shift()),n[h]=l[e];return n}F.default=b},"./src/errors.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"ErrorTypes",function(){return B}),S.d(F,"ErrorDetails",function(){return _});var B;(function(R){R.NETWORK_ERROR="networkError",R.MEDIA_ERROR="mediaError",R.KEY_SYSTEM_ERROR="keySystemError",R.MUX_ERROR="muxError",R.OTHER_ERROR="otherError"})(B||(B={}));var _;(function(R){R.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",R.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",R.KEY_SYSTEM_NO_SESSION="keySystemNoSession",R.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",R.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",R.MANIFEST_LOAD_ERROR="manifestLoadError",R.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",R.MANIFEST_PARSING_ERROR="manifestParsingError",R.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",R.LEVEL_EMPTY_ERROR="levelEmptyError",R.LEVEL_LOAD_ERROR="levelLoadError",R.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",R.LEVEL_SWITCH_ERROR="levelSwitchError",R.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",R.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",R.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",R.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",R.FRAG_LOAD_ERROR="fragLoadError",R.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",R.FRAG_DECRYPT_ERROR="fragDecryptError",R.FRAG_PARSING_ERROR="fragParsingError",R.REMUX_ALLOC_ERROR="remuxAllocError",R.KEY_LOAD_ERROR="keyLoadError",R.KEY_LOAD_TIMEOUT="keyLoadTimeOut",R.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",R.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",R.BUFFER_APPEND_ERROR="bufferAppendError",R.BUFFER_APPENDING_ERROR="bufferAppendingError",R.BUFFER_STALLED_ERROR="bufferStalledError",R.BUFFER_FULL_ERROR="bufferFullError",R.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",R.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",R.INTERNAL_EXCEPTION="internalException",R.INTERNAL_ABORTED="aborted",R.UNKNOWN="unknown"})(_||(_={}))},"./src/events.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"Events",function(){return B});var B;(function(_){_.MEDIA_ATTACHING="hlsMediaAttaching",_.MEDIA_ATTACHED="hlsMediaAttached",_.MEDIA_DETACHING="hlsMediaDetaching",_.MEDIA_DETACHED="hlsMediaDetached",_.BUFFER_RESET="hlsBufferReset",_.BUFFER_CODECS="hlsBufferCodecs",_.BUFFER_CREATED="hlsBufferCreated",_.BUFFER_APPENDING="hlsBufferAppending",_.BUFFER_APPENDED="hlsBufferAppended",_.BUFFER_EOS="hlsBufferEos",_.BUFFER_FLUSHING="hlsBufferFlushing",_.BUFFER_FLUSHED="hlsBufferFlushed",_.MANIFEST_LOADING="hlsManifestLoading",_.MANIFEST_LOADED="hlsManifestLoaded",_.MANIFEST_PARSED="hlsManifestParsed",_.LEVEL_SWITCHING="hlsLevelSwitching",_.LEVEL_SWITCHED="hlsLevelSwitched",_.LEVEL_LOADING="hlsLevelLoading",_.LEVEL_LOADED="hlsLevelLoaded",_.LEVEL_UPDATED="hlsLevelUpdated",_.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",_.LEVELS_UPDATED="hlsLevelsUpdated",_.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",_.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",_.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",_.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",_.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",_.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",_.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",_.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",_.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",_.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",_.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",_.CUES_PARSED="hlsCuesParsed",_.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",_.INIT_PTS_FOUND="hlsInitPtsFound",_.FRAG_LOADING="hlsFragLoading",_.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",_.FRAG_LOADED="hlsFragLoaded",_.FRAG_DECRYPTED="hlsFragDecrypted",_.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",_.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",_.FRAG_PARSING_METADATA="hlsFragParsingMetadata",_.FRAG_PARSED="hlsFragParsed",_.FRAG_BUFFERED="hlsFragBuffered",_.FRAG_CHANGED="hlsFragChanged",_.FPS_DROP="hlsFpsDrop",_.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",_.ERROR="hlsError",_.DESTROYING="hlsDestroying",_.KEY_LOADING="hlsKeyLoading",_.KEY_LOADED="hlsKeyLoaded",_.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",_.BACK_BUFFER_REACHED="hlsBackBufferReached"})(B||(B={}))},"./src/hls.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return l});var B=S("./node_modules/url-toolkit/src/url-toolkit.js"),_=S.n(B),R=S("./src/loader/playlist-loader.ts"),N=S("./src/loader/key-loader.ts"),M=S("./src/controller/id3-track-controller.ts"),O=S("./src/controller/latency-controller.ts"),w=S("./src/controller/level-controller.ts"),m=S("./src/controller/fragment-tracker.ts"),T=S("./src/controller/stream-controller.ts"),C=S("./src/is-supported.ts"),b=S("./src/utils/logger.ts"),E=S("./src/config.ts"),y=S("./node_modules/eventemitter3/index.js"),c=S.n(y),r=S("./src/events.ts"),a=S("./src/errors.ts");function o(d,v){for(var h=0;h<v.length;h++){var u=v[h];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(d,u.key,u)}}function g(d,v,h){return v&&o(d.prototype,v),h&&o(d,h),d}var l=function(){d.isSupported=function(){return Object(C.isSupported)()};function d(h){h===void 0&&(h={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.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 u=this.config=Object(E.mergeConfig)(d.DefaultConfig,h);this.userConfig=h,Object(b.enableLogs)(u.debug),this._autoLevelCapping=-1,u.progressive&&Object(E.enableStreamingMode)(u);var n=u.abrController,e=u.bufferController,t=u.capLevelController,f=u.fpsController,p=this.abrController=new n(this),x=this.bufferController=new e(this),A=this.capLevelController=new t(this),I=new f(this),U=new R.default(this),j=new N.default(this),z=new M.default(this),V=this.levelController=new w.default(this),G=new m.FragmentTracker(this),Q=this.streamController=new T.default(this,G);A.setStreamController(Q),I.setStreamController(Q);var ne=[V,Q];this.networkControllers=ne;var re=[U,j,p,x,A,I,z,G];this.audioTrackController=this.createController(u.audioTrackController,null,ne),this.createController(u.audioStreamController,G,ne),this.subtitleTrackController=this.createController(u.subtitleTrackController,null,ne),this.createController(u.subtitleStreamController,G,ne),this.createController(u.timelineController,null,re),this.emeController=this.createController(u.emeController,null,re),this.cmcdController=this.createController(u.cmcdController,null,re),this.latencyController=this.createController(O.default,null,re),this.coreComponents=re}var v=d.prototype;return v.createController=function(u,n,e){if(u){var t=n?new u(this,n):new u(this);return e&&e.push(t),t}return null},v.on=function(u,n,e){e===void 0&&(e=this),this._emitter.on(u,n,e)},v.once=function(u,n,e){e===void 0&&(e=this),this._emitter.once(u,n,e)},v.removeAllListeners=function(u){this._emitter.removeAllListeners(u)},v.off=function(u,n,e,t){e===void 0&&(e=this),this._emitter.off(u,n,e,t)},v.listeners=function(u){return this._emitter.listeners(u)},v.emit=function(u,n,e){return this._emitter.emit(u,n,e)},v.trigger=function(u,n){if(this.config.debug)return this.emit(u,u,n);try{return this.emit(u,u,n)}catch(e){b.logger.error("An internal error happened while handling event "+u+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(r.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:u,error:e})}return!1},v.listenerCount=function(u){return this._emitter.listenerCount(u)},v.destroy=function(){b.logger.log("destroy"),this.trigger(r.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(u){return u.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(u){return u.destroy()}),this.coreComponents.length=0},v.attachMedia=function(u){b.logger.log("attachMedia"),this._media=u,this.trigger(r.Events.MEDIA_ATTACHING,{media:u})},v.detachMedia=function(){b.logger.log("detachMedia"),this.trigger(r.Events.MEDIA_DETACHING,void 0),this._media=null},v.loadSource=function(u){this.stopLoad();var n=this.media,e=this.url,t=this.url=B.buildAbsoluteURL(self.location.href,u,{alwaysNormalize:!0});b.logger.log("loadSource:"+t),n&&e&&e!==t&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(n)),this.trigger(r.Events.MANIFEST_LOADING,{url:u})},v.startLoad=function(u){u===void 0&&(u=-1),b.logger.log("startLoad("+u+")"),this.networkControllers.forEach(function(n){n.startLoad(u)})},v.stopLoad=function(){b.logger.log("stopLoad"),this.networkControllers.forEach(function(u){u.stopLoad()})},v.swapAudioCodec=function(){b.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},v.recoverMediaError=function(){b.logger.log("recoverMediaError");var u=this._media;this.detachMedia(),u&&this.attachMedia(u)},v.removeLevel=function(u,n){n===void 0&&(n=0),this.levelController.removeLevel(u,n)},g(d,[{key:"levels",get:function(){var u=this.levelController.levels;return u||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(u){b.logger.log("set currentLevel:"+u),this.loadLevel=u,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(u){b.logger.log("set nextLevel:"+u),this.levelController.manualLevel=u,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(u){b.logger.log("set loadLevel:"+u),this.levelController.manualLevel=u}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(u){this.levelController.nextLoadLevel=u}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(u){b.logger.log("set firstLevel:"+u),this.levelController.firstLevel=u}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(u){b.logger.log("set startLevel:"+u),u!==-1&&(u=Math.max(u,this.minAutoLevel)),this.levelController.startLevel=u}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(u){var n=!!u;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(u){this._autoLevelCapping!==u&&(b.logger.log("set autoLevelCapping:"+u),this._autoLevelCapping=u)}},{key:"bandwidthEstimate",get:function(){var u=this.abrController.bwEstimator;return u?u.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var u=this.levels,n=this.config.minAutoBitrate;if(!u)return 0;for(var e=u.length,t=0;t<e;t++)if(u[t].maxBitrate>n)return t;return 0}},{key:"maxAutoLevel",get:function(){var u=this.levels,n=this.autoLevelCapping,e;return n===-1&&u&&u.length?e=u.length-1:e=n,e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(u){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,u)}},{key:"audioTracks",get:function(){var u=this.audioTrackController;return u?u.audioTracks:[]}},{key:"audioTrack",get:function(){var u=this.audioTrackController;return u?u.audioTrack:-1},set:function(u){var n=this.audioTrackController;n&&(n.audioTrack=u)}},{key:"subtitleTracks",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTrack:-1},set:function(u){var n=this.subtitleTrackController;n&&(n.subtitleTrack=u)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var u=this.subtitleTrackController;return u?u.subtitleDisplay:!1},set:function(u){var n=this.subtitleTrackController;n&&(n.subtitleDisplay=u)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(u){this.config.lowLatencyMode=u}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return r.Events}},{key:"ErrorTypes",get:function(){return a.ErrorTypes}},{key:"ErrorDetails",get:function(){return a.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:E.hlsDefaultConfig},set:function(u){d.defaultConfig=u}}]),d}();l.defaultConfig=void 0},"./src/is-supported.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"isSupported",function(){return R}),S.d(F,"changeTypeSupported",function(){return N});var B=S("./src/utils/mediasource-helper.ts");function _(){return self.SourceBuffer||self.WebKitSourceBuffer}function R(){var M=Object(B.getMediaSource)();if(!M)return!1;var O=_(),w=M&&typeof M.isTypeSupported=="function"&&M.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),m=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!w&&!!m}function N(){var M,O=_();return typeof(O==null||((M=O.prototype)===null||M===void 0)?void 0:M.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return b}),S.d(F,"LoadError",function(){return y});var B=S("./src/polyfills/number.ts"),_=S("./src/errors.ts");function R(c,r){c.prototype=Object.create(r.prototype),c.prototype.constructor=c,m(c,r)}function N(c){var r=typeof Map=="function"?new Map:void 0;return N=function(o){if(o===null||!w(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(o))return r.get(o);r.set(o,g)}function g(){return M(o,arguments,T(this).constructor)}return g.prototype=Object.create(o.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),m(g,o)},N(c)}function M(c,r,a){return O()?M=Reflect.construct:M=function(g,l,d){var v=[null];v.push.apply(v,l);var h=Function.bind.apply(g,v),u=new h;return d&&m(u,d.prototype),u},M.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(c){return!1}}function w(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function m(c,r){return m=Object.setPrototypeOf||function(o,g){return o.__proto__=g,o},m(c,r)}function T(c){return T=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},T(c)}var C=Math.pow(2,17),b=function(){function c(a){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=a}var r=c.prototype;return r.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},r.abort=function(){this.loader&&this.loader.abort()},r.load=function(o,g){var l=this,d=o.url;if(!d)return Promise.reject(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,networkDetails:null},"Fragment does not have a "+(d?"part list":"url")));this.abort();var v=this.config,h=v.fLoader,u=v.loader;return new Promise(function(n,e){l.loader&&l.loader.destroy();var t=l.loader=o.loader=h?new h(v):new u(v),f=E(o),p={timeout:v.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:v.fragLoadingMaxRetryTimeout,highWaterMark:C};o.stats=t.stats,t.load(f,p,{onSuccess:function(A,I,U,j){l.resetLoader(o,t),n({frag:o,part:null,payload:A.data,networkDetails:j})},onError:function(A,I,U){l.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:A,networkDetails:U}))},onAbort:function(A,I,U){l.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,networkDetails:U}))},onTimeout:function(A,I,U){l.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,networkDetails:U}))},onProgress:function(A,I,U,j){g&&g({frag:o,part:null,payload:U,networkDetails:j})}})})},r.loadPart=function(o,g,l){var d=this;this.abort();var v=this.config,h=v.fLoader,u=v.loader;return new Promise(function(n,e){d.loader&&d.loader.destroy();var t=d.loader=o.loader=h?new h(v):new u(v),f=E(o,g),p={timeout:v.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:v.fragLoadingMaxRetryTimeout,highWaterMark:C};g.stats=t.stats,t.load(f,p,{onSuccess:function(A,I,U,j){d.resetLoader(o,t),d.updateStatsFromPart(o,g);var z={frag:o,part:g,payload:A.data,networkDetails:j};l(z),n(z)},onError:function(A,I,U){d.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,part:g,response:A,networkDetails:U}))},onAbort:function(A,I,U){o.stats.aborted=g.stats.aborted,d.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,part:g,networkDetails:U}))},onTimeout:function(A,I,U){d.resetLoader(o,t),e(new y({type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,part:g,networkDetails:U}))}})})},r.updateStatsFromPart=function(o,g){var l=o.stats,d=g.stats,v=d.total;if(l.loaded+=d.loaded,v){var h=Math.round(o.duration/g.duration),u=Math.min(Math.round(l.loaded/v),h),n=h-u,e=n*Math.round(l.loaded/u);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var t=l.loading,f=d.loading;t.start?t.first+=f.first-f.start:(t.start=f.start,t.first=f.first),t.end=f.end},r.resetLoader=function(o,g){o.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},c}();function E(c,r){r===void 0&&(r=null);var a=r||c,o={frag:c,part:r,responseType:"arraybuffer",url:a.url,headers:{},rangeStart:0,rangeEnd:0},g=a.byteRangeStartOffset,l=a.byteRangeEndOffset;return Object(B.isFiniteNumber)(g)&&Object(B.isFiniteNumber)(l)&&(o.rangeStart=g,o.rangeEnd=l),o}var y=function(c){R(r,c);function r(a){for(var o,g=arguments.length,l=new Array(g>1?g-1:0),d=1;d<g;d++)l[d-1]=arguments[d];return o=c.call.apply(c,[this].concat(l))||this,o.data=void 0,o.data=a,o}return r}(N(Error))},"./src/loader/fragment.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"ElementaryStreamTypes",function(){return b}),S.d(F,"BaseSegment",function(){return E}),S.d(F,"Fragment",function(){return y}),S.d(F,"Part",function(){return c});var B=S("./src/polyfills/number.ts"),_=S("./node_modules/url-toolkit/src/url-toolkit.js"),R=S.n(_),N=S("./src/utils/logger.ts"),M=S("./src/loader/level-key.ts"),O=S("./src/loader/load-stats.ts");function w(r,a){r.prototype=Object.create(a.prototype),r.prototype.constructor=r,m(r,a)}function m(r,a){return m=Object.setPrototypeOf||function(g,l){return g.__proto__=l,g},m(r,a)}function T(r,a){for(var o=0;o<a.length;o++){var g=a[o];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(r,g.key,g)}}function C(r,a,o){return a&&T(r.prototype,a),o&&T(r,o),r}var b;(function(r){r.AUDIO="audio",r.VIDEO="video",r.AUDIOVIDEO="audiovideo"})(b||(b={}));var E=function(){function r(o){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[b.AUDIO]=null,g[b.VIDEO]=null,g[b.AUDIOVIDEO]=null,g),this.baseurl=o}var a=r.prototype;return a.setByteRange=function(g,l){var d=g.split("@",2),v=[];d.length===1?v[0]=l?l.byteRangeEndOffset:0:v[0]=parseInt(d[1]),v[1]=parseInt(d[0])+v[0],this._byteRange=v},C(r,[{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(_.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),r}(),y=function(r){w(a,r);function a(g,l){var d;return d=r.call(this,l)||this,d._decryptdata=null,d.rawProgramDateTime=null,d.programDateTime=null,d.tagList=[],d.duration=0,d.sn=0,d.levelkey=void 0,d.type=void 0,d.loader=null,d.level=-1,d.cc=0,d.startPTS=void 0,d.endPTS=void 0,d.appendedPTS=void 0,d.startDTS=void 0,d.endDTS=void 0,d.start=0,d.deltaPTS=void 0,d.maxStartPTS=void 0,d.minEndPTS=void 0,d.stats=new O.LoadStats,d.urlId=0,d.data=void 0,d.bitrateTest=!1,d.title=null,d.initSegment=null,d.type=g,d}var o=a.prototype;return o.createInitializationVector=function(l){for(var d=new Uint8Array(16),v=12;v<16;v++)d[v]=l>>8*(15-v)&255;return d},o.setDecryptDataFromLevelKey=function(l,d){var v=l;return(l==null?void 0:l.method)==="AES-128"&&l.uri&&!l.iv&&(v=M.LevelKey.fromURI(l.uri),v.method=l.method,v.iv=this.createInitializationVector(d),v.keyFormat="identity"),v},o.setElementaryStreamInfo=function(l,d,v,h,u,n){n===void 0&&(n=!1);var e=this.elementaryStreams,t=e[l];if(!t){e[l]={startPTS:d,endPTS:v,startDTS:h,endDTS:u,partial:n};return}t.startPTS=Math.min(t.startPTS,d),t.endPTS=Math.max(t.endPTS,v),t.startDTS=Math.min(t.startDTS,h),t.endDTS=Math.max(t.endDTS,u)},o.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[b.AUDIO]=null,l[b.VIDEO]=null,l[b.AUDIOVIDEO]=null},C(a,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var l=this.sn;typeof l!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&N.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),l=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,l)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(B.isFiniteNumber)(this.programDateTime))return null;var l=Object(B.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;return!!((l=this.decryptdata)!==null&&l!==void 0&&l.keyFormat&&this.decryptdata.uri)}}]),a}(E),c=function(r){w(a,r);function a(o,g,l,d,v){var h;h=r.call(this,l)||this,h.fragOffset=0,h.duration=0,h.gap=!1,h.independent=!1,h.relurl=void 0,h.fragment=void 0,h.index=void 0,h.stats=new O.LoadStats,h.duration=o.decimalFloatingPoint("DURATION"),h.gap=o.bool("GAP"),h.independent=o.bool("INDEPENDENT"),h.relurl=o.enumeratedString("URI"),h.fragment=g,h.index=d;var u=o.enumeratedString("BYTERANGE");return u&&h.setByteRange(u,v),v&&(h.fragOffset=v.fragOffset+v.duration),h}return C(a,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),a}(E)},"./src/loader/key-loader.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return N});var B=S("./src/events.ts"),_=S("./src/errors.ts"),R=S("./src/utils/logger.ts"),N=function(){function M(w){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=w,this._registerListeners()}var O=M.prototype;return O._registerListeners=function(){this.hls.on(B.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(B.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var m in this.loaders){var T=this.loaders[m];T&&T.destroy()}this.loaders={}},O.onKeyLoading=function(m,T){var C=T.frag,b=C.type,E=this.loaders[b];if(!C.decryptdata){R.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=C.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var c=this.hls.config;if(E&&(R.logger.warn("abort previous key loader for type:"+b),E.abort()),!y){R.logger.warn("key uri is falsy");return}var r=c.loader,a=C.loader=this.loaders[b]=new r(c);this.decrypturl=y,this.decryptkey=null;var o={url:y,frag:C,responseType:"arraybuffer"},g={timeout:c.fragLoadingTimeOut,maxRetry:0,retryDelay:c.fragLoadingRetryDelay,maxRetryDelay:c.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(o,g,l)}else this.decryptkey&&(C.decryptdata.key=this.decryptkey,this.hls.trigger(B.Events.KEY_LOADED,{frag:C}))},O.loadsuccess=function(m,T,C){var b=C.frag;if(!b.decryptdata){R.logger.error("after key load, decryptdata unset");return}this.decryptkey=b.decryptdata.key=new Uint8Array(m.data),b.loader=null,delete this.loaders[b.type],this.hls.trigger(B.Events.KEY_LOADED,{frag:b})},O.loaderror=function(m,T){var C=T.frag,b=C.loader;b&&b.abort(),delete this.loaders[C.type],this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:C,response:m})},O.loadtimeout=function(m,T){var C=T.frag,b=C.loader;b&&b.abort(),delete this.loaders[C.type],this.hls.trigger(B.Events.ERROR,{type:_.ErrorTypes.NETWORK_ERROR,details:_.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:C})},M}()},"./src/loader/level-details.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"LevelDetails",function(){return M});var B=S("./src/polyfills/number.ts");function _(O,w){for(var m=0;m<w.length;m++){var T=w[m];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function R(O,w,m){return w&&_(O.prototype,w),m&&_(O,m),O}var N=10,M=function(){function O(m){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=m}var w=O.prototype;return w.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var C=this.lastPartSn-T.lastPartSn,b=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!b||!!C,this.advanced=this.endSN>T.endSN||C>0||C===0&&b>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},R(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(B.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||N}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var C=this.driftEnd-this.driftStart;return C*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&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(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"LevelKey",function(){return M});var B=S("./node_modules/url-toolkit/src/url-toolkit.js"),_=S.n(B);function R(O,w){for(var m=0;m<w.length;m++){var T=w[m];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function N(O,w,m){return w&&R(O.prototype,w),m&&R(O,m),O}var M=function(){O.fromURL=function(m,T){return new O(m,T)},O.fromURI=function(m){return new O(m)};function O(w,m){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,m?this._uri=Object(B.buildAbsoluteURL)(w,m,{alwaysNormalize:!0}):this._uri=w}return N(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"LoadStats",function(){return B});var B=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return a});var B=S("./src/polyfills/number.ts"),_=S("./node_modules/url-toolkit/src/url-toolkit.js"),R=S.n(_),N=S("./src/loader/fragment.ts"),M=S("./src/loader/level-details.ts"),O=S("./src/loader/level-key.ts"),w=S("./src/utils/attr-list.ts"),m=S("./src/utils/logger.ts"),T=S("./src/utils/codecs.ts"),C=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,b=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=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("|")),c=/\.(mp4|m4s|m4v|m4a)$/i;function r(v){var h,u;return c.test((h=(u=_.parseURL(v))===null||u===void 0?void 0:u.path)!=null?h:"")}var a=function(){function v(){}return v.findGroup=function(u,n){for(var e=0;e<u.length;e++){var t=u[e];if(t.id===n)return t}},v.convertAVC1ToAVCOTI=function(u){var n=u.split(".");if(n.length>2){var e=n.shift()+".";return e+=parseInt(n.shift()).toString(16),e+=("000"+parseInt(n.shift()).toString(16)).substr(-4),e}return u},v.resolve=function(u,n){return _.buildAbsoluteURL(n,u,{alwaysNormalize:!0})},v.parseMasterPlaylist=function(u,n){var e=[],t={},f=!1;C.lastIndex=0;for(var p;(p=C.exec(u))!=null;)if(p[1]){var x=new w.AttrList(p[1]),A={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:v.resolve(p[2],n)},I=x.decimalResolution("RESOLUTION");I&&(A.width=I.width,A.height=I.height),o((x.CODECS||"").split(/[ ,]+/).filter(function(j){return j}),A),A.videoCodec&&A.videoCodec.indexOf("avc1")!==-1&&(A.videoCodec=v.convertAVC1ToAVCOTI(A.videoCodec)),e.push(A)}else if(p[3]){var U=new w.AttrList(p[3]);U["DATA-ID"]&&(f=!0,t[U["DATA-ID"]]=U)}return{levels:e,sessionData:f?t:null}},v.parseMasterPlaylistMedia=function(u,n,e,t){t===void 0&&(t=[]);var f,p=[],x=0;for(b.lastIndex=0;(f=b.exec(u))!==null;){var A=new w.AttrList(f[1]);if(A.TYPE===e){var I={attrs:A,bitrate:0,id:x++,groupId:A["GROUP-ID"],instreamId:A["INSTREAM-ID"],name:A.NAME||A.LANGUAGE||"",type:e,default:A.bool("DEFAULT"),autoselect:A.bool("AUTOSELECT"),forced:A.bool("FORCED"),lang:A.LANGUAGE,url:A.URI?v.resolve(A.URI,n):""};if(t.length){var U=v.findGroup(t,I.groupId)||t[0];g(I,U,"audioCodec"),g(I,U,"textCodec")}p.push(I)}}return p},v.parseLevelPlaylist=function(u,n,e,t,f){var p=new M.LevelDetails(n),x=p.fragments,A=null,I=0,U=0,j=0,z=0,V=null,G=new N.Fragment(t,n),Q,ne,re,be=-1,se=!1;for(E.lastIndex=0,p.m3u8=u;(Q=E.exec(u))!==null;){se&&(se=!1,G=new N.Fragment(t,n),G.start=j,G.sn=I,G.cc=z,G.level=e,A&&(G.initSegment=A,G.rawProgramDateTime=A.rawProgramDateTime));var oe=Q[1];if(oe){G.duration=parseFloat(oe);var ue=(" "+Q[2]).slice(1);G.title=ue||null,G.tagList.push(ue?["INF",oe,ue]:["INF",oe])}else if(Q[3])Object(B.isFiniteNumber)(G.duration)&&(G.start=j,re&&(G.levelkey=re),G.sn=I,G.level=e,G.cc=z,G.urlId=f,x.push(G),G.relurl=(" "+Q[3]).slice(1),d(G,V),V=G,j+=G.duration,I++,U=0,se=!0);else if(Q[4]){var he=(" "+Q[4]).slice(1);V?G.setByteRange(he,V):G.setByteRange(he)}else if(Q[5])G.rawProgramDateTime=(" "+Q[5]).slice(1),G.tagList.push(["PROGRAM-DATE-TIME",G.rawProgramDateTime]),be===-1&&(be=x.length);else{if(Q=Q[0].match(y),!Q){m.logger.warn("No matches on slow regex match for level playlist!");continue}for(ne=1;ne<Q.length&&!(typeof Q[ne]!="undefined");ne++);var te=(" "+Q[ne]).slice(1),Y=(" "+Q[ne+1]).slice(1),fe=Q[ne+2]?(" "+Q[ne+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":p.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":I=p.startSN=parseInt(Y);break;case"SKIP":{var Re=new w.AttrList(Y),Le=Re.decimalInteger("SKIPPED-SEGMENTS");if(Object(B.isFiniteNumber)(Le)){p.skippedSegments=Le;for(var xe=Le;xe--;)x.unshift(null);I+=Le}var Te=Re.enumeratedString("RECENTLY-REMOVED-DATERANGES");Te&&(p.recentlyRemovedDateranges=Te.split(" "));break}case"TARGETDURATION":p.targetduration=parseFloat(Y);break;case"VERSION":p.version=parseInt(Y);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(Y||fe)&&G.tagList.push(fe?[Y,fe]:[Y]);break;case"DIS":z++;case"GAP":G.tagList.push([te]);break;case"BITRATE":G.tagList.push([te,Y]);break;case"DISCONTINUITY-SEQ":z=parseInt(Y);break;case"KEY":{var le,ye=new w.AttrList(Y),we=ye.enumeratedString("METHOD"),De=ye.URI,Se=ye.hexadecimalInteger("IV"),pe=ye.enumeratedString("KEYFORMATVERSIONS"),me=ye.enumeratedString("KEYID"),Fe=(le=ye.enumeratedString("KEYFORMAT"))!=null?le:"identity",Pe=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Pe.indexOf(Fe)>-1){m.logger.warn("Keyformat "+Fe+" is not supported from the manifest");continue}else if(Fe!=="identity")continue;we&&(re=O.LevelKey.fromURL(n,De),De&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(we)>=0&&(re.method=we,re.keyFormat=Fe,me&&(re.keyID=me),pe&&(re.keyFormatVersions=pe),re.iv=Se));break}case"START":{var Me=new w.AttrList(Y),Ie=Me.decimalFloatingPoint("TIME-OFFSET");Object(B.isFiniteNumber)(Ie)&&(p.startTimeOffset=Ie);break}case"MAP":{var Ne=new w.AttrList(Y);G.relurl=Ne.URI,Ne.BYTERANGE&&G.setByteRange(Ne.BYTERANGE),G.level=e,G.sn="initSegment",re&&(G.levelkey=re),G.initSegment=null,A=G,se=!0;break}case"SERVER-CONTROL":{var Ue=new w.AttrList(Y);p.canBlockReload=Ue.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=Ue.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&Ue.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=Ue.optionalFloat("PART-HOLD-BACK",0),p.holdBack=Ue.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ke=new w.AttrList(Y);p.partTarget=ke.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ae=p.partList;Ae||(Ae=p.partList=[]);var Be=U>0?Ae[Ae.length-1]:void 0,_e=U++,ce=new N.Part(new w.AttrList(Y),G,n,_e,Be);Ae.push(ce),G.duration+=ce.duration;break}case"PRELOAD-HINT":{var Ce=new w.AttrList(Y);p.preloadHint=Ce;break}case"RENDITION-REPORT":{var q=new w.AttrList(Y);p.renditionReports=p.renditionReports||[],p.renditionReports.push(q);break}default:m.logger.warn("line parsed but not handled: "+Q);break}}}V&&!V.relurl?(x.pop(),j-=V.duration,p.partList&&(p.fragmentHint=V)):p.partList&&(d(G,V),G.cc=z,p.fragmentHint=G);var J=x.length,Z=x[0],W=x[J-1];if(j+=p.skippedSegments*p.targetduration,j>0&&J&&W){p.averagetargetduration=j/J;var H=W.sn;p.endSN=H!=="initSegment"?H:0,Z&&(p.startCC=Z.cc,Z.initSegment||p.fragments.every(function(K){return K.relurl&&r(K.relurl)})&&(m.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),G=new N.Fragment(t,n),G.relurl=W.relurl,G.level=e,G.sn="initSegment",Z.initSegment=G,p.needSidxRanges=!0))}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(j+=p.fragmentHint.duration),p.totalduration=j,p.endCC=z,be>0&&l(x,be),p},v}();function o(v,h){["video","audio","text"].forEach(function(u){var n=v.filter(function(t){return Object(T.isCodecType)(t,u)});if(n.length){var e=n.filter(function(t){return t.lastIndexOf("avc1",0)===0||t.lastIndexOf("mp4a",0)===0});h[u+"Codec"]=e.length>0?e[0]:n[0],v=v.filter(function(t){return n.indexOf(t)===-1})}}),h.unknownCodecs=v}function g(v,h,u){var n=h[u];n&&(v[u]=n)}function l(v,h){for(var u=v[h],n=h;n--;){var e=v[n];if(!e)return;e.programDateTime=u.programDateTime-e.duration*1e3,u=e}}function d(v,h){v.rawProgramDateTime?v.programDateTime=Date.parse(v.rawProgramDateTime):h!=null&&h.programDateTime&&(v.programDateTime=h.endProgramDateTime),Object(B.isFiniteNumber)(v.programDateTime)||(v.programDateTime=null,v.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/polyfills/number.ts"),_=S("./src/events.ts"),R=S("./src/errors.ts"),N=S("./src/utils/logger.ts"),M=S("./src/utils/mp4-tools.ts"),O=S("./src/loader/m3u8-parser.ts"),w=S("./src/types/loader.ts"),m=S("./src/utils/attr-list.ts");function T(E){var y=E.type;switch(y){case w.PlaylistContextType.AUDIO_TRACK:return w.PlaylistLevelType.AUDIO;case w.PlaylistContextType.SUBTITLE_TRACK:return w.PlaylistLevelType.SUBTITLE;default:return w.PlaylistLevelType.MAIN}}function C(E,y){var c=E.url;return(c===void 0||c.indexOf("data:")===0)&&(c=y.url),c}var b=function(){function E(c){this.hls=void 0,this.loaders=Object.create(null),this.hls=c,this.registerListeners()}var y=E.prototype;return y.registerListeners=function(){var r=this.hls;r.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.on(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var r=this.hls;r.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(_.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(_.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.off(_.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(r){var a=this.hls.config,o=a.pLoader,g=a.loader,l=o||g,d=new l(a);return r.loader=d,this.loaders[r.type]=d,d},y.getInternalLoader=function(r){return this.loaders[r.type]},y.resetInternalLoader=function(r){this.loaders[r]&&delete this.loaders[r]},y.destroyInternalLoaders=function(){for(var r in this.loaders){var a=this.loaders[r];a&&a.destroy(),this.resetInternalLoader(r)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(r,a){var o=a.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:w.PlaylistContextType.MANIFEST,url:o,deliveryDirectives:null})},y.onLevelLoading=function(r,a){var o=a.id,g=a.level,l=a.url,d=a.deliveryDirectives;this.load({id:o,groupId:null,level:g,responseType:"text",type:w.PlaylistContextType.LEVEL,url:l,deliveryDirectives:d})},y.onAudioTrackLoading=function(r,a){var o=a.id,g=a.groupId,l=a.url,d=a.deliveryDirectives;this.load({id:o,groupId:g,level:null,responseType:"text",type:w.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:d})},y.onSubtitleTrackLoading=function(r,a){var o=a.id,g=a.groupId,l=a.url,d=a.deliveryDirectives;this.load({id:o,groupId:g,level:null,responseType:"text",type:w.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:d})},y.load=function(r){var a,o=this.hls.config,g=this.getInternalLoader(r);if(g){var l=g.context;if(l&&l.url===r.url){N.logger.trace("[playlist-loader]: playlist request ongoing");return}N.logger.log("[playlist-loader]: aborting previous loader for type: "+r.type),g.abort()}var d,v,h,u;switch(r.type){case w.PlaylistContextType.MANIFEST:d=o.manifestLoadingMaxRetry,v=o.manifestLoadingTimeOut,h=o.manifestLoadingRetryDelay,u=o.manifestLoadingMaxRetryTimeout;break;case w.PlaylistContextType.LEVEL:case w.PlaylistContextType.AUDIO_TRACK:case w.PlaylistContextType.SUBTITLE_TRACK:d=0,v=o.levelLoadingTimeOut;break;default:d=o.levelLoadingMaxRetry,v=o.levelLoadingTimeOut,h=o.levelLoadingRetryDelay,u=o.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(r),(a=r.deliveryDirectives)!==null&&a!==void 0&&a.part){var n;if(r.type===w.PlaylistContextType.LEVEL&&r.level!==null?n=this.hls.levels[r.level].details:r.type===w.PlaylistContextType.AUDIO_TRACK&&r.id!==null?n=this.hls.audioTracks[r.id].details:r.type===w.PlaylistContextType.SUBTITLE_TRACK&&r.id!==null&&(n=this.hls.subtitleTracks[r.id].details),n){var e=n.partTarget,t=n.targetduration;e&&t&&(v=Math.min(Math.max(e*3,t*.8)*1e3,v))}}var f={timeout:v,maxRetry:d,retryDelay:h,maxRetryDelay:u,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(r,f,p)},y.loadsuccess=function(r,a,o,g){if(g===void 0&&(g=null),o.isSidxRequest){this.handleSidxRequest(r,o),this.handlePlaylistLoaded(r,a,o,g);return}this.resetInternalLoader(o.type);var l=r.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,o,"no EXTM3U delimiter",g);return}a.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(r,a,o,g):this.handleMasterPlaylist(r,a,o,g)},y.loaderror=function(r,a,o){o===void 0&&(o=null),this.handleNetworkError(a,o,!1,r)},y.loadtimeout=function(r,a,o){o===void 0&&(o=null),this.handleNetworkError(a,o,!0)},y.handleMasterPlaylist=function(r,a,o,g){var l=this.hls,d=r.data,v=C(r,o),h=O.default.parseMasterPlaylist(d,v),u=h.levels,n=h.sessionData;if(!u.length){this.handleManifestParsingError(r,o,"no level found in manifest",g);return}var e=u.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),t=u.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),f=O.default.parseMasterPlaylistMedia(d,v,"AUDIO",e),p=O.default.parseMasterPlaylistMedia(d,v,"SUBTITLES",t),x=O.default.parseMasterPlaylistMedia(d,v,"CLOSED-CAPTIONS");if(f.length){var A=f.some(function(I){return!I.url});!A&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(N.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new m.AttrList({}),bitrate:0,url:""}))}l.trigger(_.Events.MANIFEST_LOADED,{levels:u,audioTracks:f,subtitles:p,captions:x,url:v,stats:a,networkDetails:g,sessionData:n})},y.handleTrackOrLevelPlaylist=function(r,a,o,g){var l=this.hls,d=o.id,v=o.level,h=o.type,u=C(r,o),n=Object(B.isFiniteNumber)(d)?d:0,e=Object(B.isFiniteNumber)(v)?v:n,t=T(o),f=O.default.parseLevelPlaylist(r.data,u,e,t,n);if(!f.fragments.length){l.trigger(_.Events.ERROR,{type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof o.level=="number"?o.level:void 0});return}if(h===w.PlaylistContextType.MANIFEST){var p={attrs:new m.AttrList({}),bitrate:0,details:f,name:"",url:u};l.trigger(_.Events.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:a,networkDetails:g,sessionData:null})}if(a.parsing.end=performance.now(),f.needSidxRanges){var x,A=(x=f.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:A,isSidxRequest:!0,type:h,level:v,levelDetails:f,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}o.levelDetails=f,this.handlePlaylistLoaded(r,a,o,g)},y.handleSidxRequest=function(r,a){var o=Object(M.parseSegmentIndex)(new Uint8Array(r.data));if(!o)return;var g=o.references,l=a.levelDetails;g.forEach(function(d,v){var h=d.info,u=l.fragments[v];u.byteRange.length===0&&u.setByteRange(String(1+h.end-h.start)+"@"+String(h.start)),u.initSegment&&u.initSegment.setByteRange(String(o.moovEndOffset)+"@0")})},y.handleManifestParsingError=function(r,a,o,g){this.hls.trigger(_.Events.ERROR,{type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:a.type===w.PlaylistContextType.MANIFEST,url:r.url,reason:o,response:r,context:a,networkDetails:g})},y.handleNetworkError=function(r,a,o,g){o===void 0&&(o=!1),N.logger.warn("[playlist-loader]: A network "+(o?"timeout":"error")+" occurred while loading "+r.type+" level: "+r.level+" id: "+r.id+' group-id: "'+r.groupId+'"');var l=R.ErrorDetails.UNKNOWN,d=!1,v=this.getInternalLoader(r);switch(r.type){case w.PlaylistContextType.MANIFEST:l=o?R.ErrorDetails.MANIFEST_LOAD_TIMEOUT:R.ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case w.PlaylistContextType.LEVEL:l=o?R.ErrorDetails.LEVEL_LOAD_TIMEOUT:R.ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case w.PlaylistContextType.AUDIO_TRACK:l=o?R.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:R.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case w.PlaylistContextType.SUBTITLE_TRACK:l=o?R.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:R.ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1;break}v&&this.resetInternalLoader(r.type);var h={type:R.ErrorTypes.NETWORK_ERROR,details:l,fatal:d,url:r.url,loader:v,context:r,networkDetails:a};g&&(h.response=g),this.hls.trigger(_.Events.ERROR,h)},y.handlePlaylistLoaded=function(r,a,o,g){var l=o.type,d=o.level,v=o.id,h=o.groupId,u=o.loader,n=o.levelDetails,e=o.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(r,o,"invalid target duration",g);return}if(!u)return;n.live&&(u.getCacheAge&&(n.ageHeader=u.getCacheAge()||0),(!u.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0));switch(l){case w.PlaylistContextType.MANIFEST:case w.PlaylistContextType.LEVEL:this.hls.trigger(_.Events.LEVEL_LOADED,{details:n,level:d||0,id:v||0,stats:a,networkDetails:g,deliveryDirectives:e});break;case w.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(_.Events.AUDIO_TRACK_LOADED,{details:n,id:v||0,groupId:h||"",stats:a,networkDetails:g,deliveryDirectives:e});break;case w.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(_.Events.SUBTITLE_TRACK_LOADED,{details:n,id:v||0,groupId:h||"",stats:a,networkDetails:g,deliveryDirectives:e});break}},E}();F.default=b},"./src/polyfills/number.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"isFiniteNumber",function(){return B}),S.d(F,"MAX_SAFE_INTEGER",function(){return _});var B=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},_=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(de,F,S){"use strict";S.r(F);var B=function(){function _(){}return _.getSilentFrame=function(N,M){switch(N){case"mp4a.40.2":if(M===1)return new Uint8Array([0,200,0,128,35,128]);if(M===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(M===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(M===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(M===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(M===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(M===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(M===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(M===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},_}();F.default=B},"./src/remux/mp4-generator.ts":function(de,F,S){"use strict";S.r(F);var B=Math.pow(2,32)-1,_=function(){function R(){}return R.init=function(){R.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var M;for(M in R.types)R.types.hasOwnProperty(M)&&(R.types[M]=[M.charCodeAt(0),M.charCodeAt(1),M.charCodeAt(2),M.charCodeAt(3)]);var O=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),w=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]);R.HDLR_TYPES={video:O,audio:w};var m=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);R.STTS=R.STSC=R.STCO=T,R.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),R.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),R.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),R.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var C=new Uint8Array([105,115,111,109]),b=new Uint8Array([97,118,99,49]),E=new Uint8Array([0,0,0,1]);R.FTYP=R.box(R.types.ftyp,C,E,C,b),R.DINF=R.box(R.types.dinf,R.box(R.types.dref,m))},R.box=function(M){for(var O=8,w=arguments.length,m=new Array(w>1?w-1:0),T=1;T<w;T++)m[T-1]=arguments[T];for(var C=m.length,b=C;C--;)O+=m[C].byteLength;var E=new Uint8Array(O);for(E[0]=O>>24&255,E[1]=O>>16&255,E[2]=O>>8&255,E[3]=O&255,E.set(M,4),C=0,O=8;C<b;C++)E.set(m[C],O),O+=m[C].byteLength;return E},R.hdlr=function(M){return R.box(R.types.hdlr,R.HDLR_TYPES[M])},R.mdat=function(M){return R.box(R.types.mdat,M)},R.mdhd=function(M,O){O*=M;var w=Math.floor(O/(B+1)),m=Math.floor(O%(B+1));return R.box(R.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,w>>24,w>>16&255,w>>8&255,w&255,m>>24,m>>16&255,m>>8&255,m&255,85,196,0,0]))},R.mdia=function(M){return R.box(R.types.mdia,R.mdhd(M.timescale,M.duration),R.hdlr(M.type),R.minf(M))},R.mfhd=function(M){return R.box(R.types.mfhd,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255]))},R.minf=function(M){return M.type==="audio"?R.box(R.types.minf,R.box(R.types.smhd,R.SMHD),R.DINF,R.stbl(M)):R.box(R.types.minf,R.box(R.types.vmhd,R.VMHD),R.DINF,R.stbl(M))},R.moof=function(M,O,w){return R.box(R.types.moof,R.mfhd(M),R.traf(w,O))},R.moov=function(M){for(var O=M.length,w=[];O--;)w[O]=R.trak(M[O]);return R.box.apply(null,[R.types.moov,R.mvhd(M[0].timescale,M[0].duration)].concat(w).concat(R.mvex(M)))},R.mvex=function(M){for(var O=M.length,w=[];O--;)w[O]=R.trex(M[O]);return R.box.apply(null,[R.types.mvex].concat(w))},R.mvhd=function(M,O){O*=M;var w=Math.floor(O/(B+1)),m=Math.floor(O%(B+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,w>>24,w>>16&255,w>>8&255,w&255,m>>24,m>>16&255,m>>8&255,m&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return R.box(R.types.mvhd,T)},R.sdtp=function(M){var O=M.samples||[],w=new Uint8Array(4+O.length),m,T;for(m=0;m<O.length;m++)T=O[m].flags,w[m+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return R.box(R.types.sdtp,w)},R.stbl=function(M){return R.box(R.types.stbl,R.stsd(M),R.box(R.types.stts,R.STTS),R.box(R.types.stsc,R.STSC),R.box(R.types.stsz,R.STSZ),R.box(R.types.stco,R.STCO))},R.avc1=function(M){var O=[],w=[],m,T,C;for(m=0;m<M.sps.length;m++)T=M.sps[m],C=T.byteLength,O.push(C>>>8&255),O.push(C&255),O=O.concat(Array.prototype.slice.call(T));for(m=0;m<M.pps.length;m++)T=M.pps[m],C=T.byteLength,w.push(C>>>8&255),w.push(C&255),w=w.concat(Array.prototype.slice.call(T));var b=R.box(R.types.avcC,new Uint8Array([1,O[3],O[4],O[5],252|3,224|M.sps.length].concat(O).concat([M.pps.length]).concat(w))),E=M.width,y=M.height,c=M.pixelRatio[0],r=M.pixelRatio[1];return R.box(R.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,E>>8&255,E&255,y>>8&255,y&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),b,R.box(R.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),R.box(R.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,r>>24,r>>16&255,r>>8&255,r&255])))},R.esds=function(M){var O=M.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(M.config).concat([6,1,2]))},R.mp4a=function(M){var O=M.samplerate;return R.box(R.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),R.box(R.types.esds,R.esds(M)))},R.mp3=function(M){var O=M.samplerate;return R.box(R.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},R.stsd=function(M){return M.type==="audio"?!M.isAAC&&M.codec==="mp3"?R.box(R.types.stsd,R.STSD,R.mp3(M)):R.box(R.types.stsd,R.STSD,R.mp4a(M)):R.box(R.types.stsd,R.STSD,R.avc1(M))},R.tkhd=function(M){var O=M.id,w=M.duration*M.timescale,m=M.width,T=M.height,C=Math.floor(w/(B+1)),b=Math.floor(w%(B+1));return R.box(R.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255,b>>24,b>>16&255,b>>8&255,b&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,m>>8&255,m&255,0,0,T>>8&255,T&255,0,0]))},R.traf=function(M,O){var w=R.sdtp(M),m=M.id,T=Math.floor(O/(B+1)),C=Math.floor(O%(B+1));return R.box(R.types.traf,R.box(R.types.tfhd,new Uint8Array([0,0,0,0,m>>24,m>>16&255,m>>8&255,m&255])),R.box(R.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,C>>24,C>>16&255,C>>8&255,C&255])),R.trun(M,w.length+16+20+8+16+8+8),w)},R.trak=function(M){return M.duration=M.duration||4294967295,R.box(R.types.trak,R.tkhd(M),R.mdia(M))},R.trex=function(M){var O=M.id;return R.box(R.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},R.trun=function(M,O){var w=M.samples||[],m=w.length,T=12+16*m,C=new Uint8Array(T),b,E,y,c,r,a;for(O+=8+T,C.set([0,0,15,1,m>>>24&255,m>>>16&255,m>>>8&255,m&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),b=0;b<m;b++)E=w[b],y=E.duration,c=E.size,r=E.flags,a=E.cts,C.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.paddingValue<<1|r.isNonSync,r.degradPrio&240<<8,r.degradPrio&15,a>>>24&255,a>>>16&255,a>>>8&255,a&255],12+16*b);return R.box(R.types.trun,C)},R.initSegment=function(M){R.types||R.init();var O=R.moov(M),w=new Uint8Array(R.FTYP.byteLength+O.byteLength);return w.set(R.FTYP),w.set(O,R.FTYP.byteLength),w},R}();_.types=void 0,_.HDLR_TYPES=void 0,_.STTS=void 0,_.STSC=void 0,_.STCO=void 0,_.STSZ=void 0,_.VMHD=void 0,_.SMHD=void 0,_.STSD=void 0,_.FTYP=void 0,_.DINF=void 0,F.default=_},"./src/remux/mp4-remuxer.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return a}),S.d(F,"normalizePts",function(){return o});var B=S("./src/polyfills/number.ts"),_=S("./src/remux/aac-helper.ts"),R=S("./src/remux/mp4-generator.ts"),N=S("./src/events.ts"),M=S("./src/errors.ts"),O=S("./src/utils/logger.ts"),w=S("./src/types/loader.ts"),m=S("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign||function(v){for(var h=1;h<arguments.length;h++){var u=arguments[h];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(v[n]=u[n])}return v},T.apply(this,arguments)}var C=10*1e3,b=1024,E=1152,y=null,c=null,r=!1,a=function(){function v(u,n,e,t){if(t===void 0&&(t=""),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=u,this.config=n,this.typeSupported=e,this.ISGenerated=!1,y===null){var f=navigator.userAgent||"",p=f.match(/Chrome\/(\d+)/i);y=p?parseInt(p[1]):0}if(c===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);c=x?parseInt(x[1]):0}r=!!y&&y<75||!!c&&c<600}var h=v.prototype;return h.destroy=function(){},h.resetTimeStamp=function(n){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=n},h.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},h.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},h.getVideoStartPts=function(n){var e=!1,t=n.reduce(function(f,p){var x=p.pts-f;return x<-4294967296?(e=!0,o(f,p.pts)):x>0?f:p.pts},n[0].pts);return e&&O.logger.debug("PTS rollover detected"),t},h.remux=function(n,e,t,f,p,x,A,I){var U,j,z,V,G,Q,ne=p,re=p,be=n.pid>-1,se=e.pid>-1,oe=e.samples.length,ue=n.samples.length>0,he=oe>1,te=(!be||ue)&&(!se||he)||this.ISGenerated||A;if(te){this.ISGenerated||(z=this.generateIS(n,e,p));var Y=this.isVideoContiguous,fe=-1;if(he&&(fe=g(e.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(Q=!0,fe>0){O.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+oe+" video samples due to a missing keyframe");var Re=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(fe),e.dropped+=fe,re+=(e.samples[0].pts-Re)/(e.timescale||9e4)}else fe===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+oe+" video samples"),Q=!1);if(this.ISGenerated){if(ue&&he){var Le=this.getVideoStartPts(e.samples),xe=o(n.samples[0].pts,Le)-Le,Te=xe/e.inputTimeScale;ne+=Math.max(0,Te),re+=Math.max(0,-Te)}if(ue){if(n.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(n,e,p)),j=this.remuxAudio(n,ne,this.isAudioContiguous,x,se||he||I===w.PlaylistLevelType.AUDIO?re:void 0),he){var le=j?j.endPTS-j.startPTS:0;e.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(n,e,p)),U=this.remuxVideo(e,re,Y,le)}}else he&&(U=this.remuxVideo(e,re,Y,0));U&&(U.firstKeyFrame=fe,U.independent=fe!==-1)}}return this.ISGenerated&&(t.samples.length&&(G=this.remuxID3(t,p)),f.samples.length&&(V=this.remuxText(f,p))),{audio:j,video:U,initSegment:z,independent:Q,text:V,id3:G}},h.generateIS=function(n,e,t){var f=n.samples,p=e.samples,x=this.typeSupported,A={},I=!Object(B.isFiniteNumber)(this._initPTS),U="audio/mp4",j,z,V;if(I&&(j=z=Infinity),n.config&&f.length&&(n.timescale=n.samplerate,n.isAAC||(x.mpeg?(U="audio/mpeg",n.codec=""):x.mp3&&(n.codec="mp3")),A.audio={id:"audio",container:U,codec:n.codec,initSegment:!n.isAAC&&x.mpeg?new Uint8Array(0):R.default.initSegment([n]),metadata:{channelCount:n.channelCount}},I&&(V=n.inputTimeScale,j=z=f[0].pts-Math.round(V*t))),e.sps&&e.pps&&p.length&&(e.timescale=e.inputTimeScale,A.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:R.default.initSegment([e]),metadata:{width:e.width,height:e.height}},I)){V=e.inputTimeScale;var G=this.getVideoStartPts(p),Q=Math.round(V*t);z=Math.min(z,o(p[0].dts,G)-Q),j=Math.min(j,G-Q)}if(Object.keys(A).length)return this.ISGenerated=!0,I&&(this._initPTS=j,this._initDTS=z),{tracks:A,initPTS:j,timescale:V}},h.remuxVideo=function(n,e,t,f){var p=n.inputTimeScale,x=n.samples,A=[],I=x.length,U=this._initPTS,j=this.nextAvcDts,z=8,V,G,Q,ne=Number.POSITIVE_INFINITY,re=Number.NEGATIVE_INFINITY,be=0,se=!1;if(!t||j===null){var oe=e*p,ue=x[0].pts-o(x[0].dts,x[0].pts);j=oe-ue}for(var he=0;he<I;he++){var te=x[he];if(te.pts=o(te.pts-U,j),te.dts=o(te.dts-U,j),te.dts>te.pts){var Y=9e4*.2;be=Math.max(Math.min(be,te.pts-te.dts),-1*Y)}te.dts<x[he>0?he-1:he].dts&&(se=!0)}se&&x.sort(function(Ye,$e){var Ge=Ye.dts-$e.dts,tt=Ye.pts-$e.pts;return Ge||tt}),G=x[0].dts,Q=x[x.length-1].dts;var fe=Math.round((Q-G)/(I-1));if(be<0){if(be<fe*-2){O.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(m.toMsFromMpegTsClock)(-fe,!0)+" ms");for(var Re=be,Le=0;Le<I;Le++)x[Le].dts=Re=Math.max(Re,x[Le].pts-fe),x[Le].pts=Math.max(Re,x[Le].pts)}else{O.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(m.toMsFromMpegTsClock)(be,!0)+" ms to overcome this issue");for(var xe=0;xe<I;xe++)x[xe].dts=x[xe].dts+be}G=x[0].dts}if(t){var Te=G-j,le=Te>fe,ye=Te<-1;if(le||ye){le?O.logger.warn("AVC: "+Object(m.toMsFromMpegTsClock)(Te,!0)+" ms ("+Te+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(m.toMsFromMpegTsClock)(-Te,!0)+" ms ("+Te+"dts) overlapping between fragments detected"),G=j;var we=x[0].pts-Te;x[0].dts=G,x[0].pts=we,O.logger.log("Video: First PTS/DTS adjusted: "+Object(m.toMsFromMpegTsClock)(we,!0)+"/"+Object(m.toMsFromMpegTsClock)(G,!0)+", delta: "+Object(m.toMsFromMpegTsClock)(Te,!0)+" ms")}}r&&(G=Math.max(0,G));for(var De=0,Se=0,pe=0;pe<I;pe++){for(var me=x[pe],Fe=me.units,Pe=Fe.length,Me=0,Ie=0;Ie<Pe;Ie++)Me+=Fe[Ie].data.length;Se+=Me,De+=Pe,me.length=Me,me.dts=Math.max(me.dts,G),me.pts=Math.max(me.pts,me.dts,0),ne=Math.min(me.pts,ne),re=Math.max(me.pts,re)}Q=x[I-1].dts;var Ne=Se+4*De+8,Ue;try{Ue=new Uint8Array(Ne)}catch(Ye){this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ne,reason:"fail allocating video mdat "+Ne});return}var ke=new DataView(Ue.buffer);ke.setUint32(0,Ne),Ue.set(R.default.types.mdat,4);for(var Ae=0;Ae<I;Ae++){for(var Be=x[Ae],_e=Be.units,ce=0,Ce=0,q=_e.length;Ce<q;Ce++){var J=_e[Ce],Z=J.data,W=J.data.byteLength;ke.setUint32(z,W),z+=4,Ue.set(Z,z),z+=W,ce+=4+W}if(Ae<I-1)V=x[Ae+1].dts-Be.dts;else{var H=this.config,K=Be.dts-x[Ae>0?Ae-1:Ae].dts;if(H.stretchShortVideoTrack&&this.nextAudioPts!==null){var X=Math.floor(H.maxBufferHole*p),ie=(f?ne+f*p:this.nextAudioPts)-Be.pts;ie>X?(V=ie-K,V<0&&(V=K),O.logger.log("[mp4-remuxer]: It is approximately "+ie/90+" ms to the next segment; using duration "+V/90+" ms for the last video frame.")):V=K}else V=K}var ae=Math.round(Be.pts-Be.dts);A.push(new l(Be.key,V,ce,ae))}if(A.length&&y&&y<70){var ge=A[0].flags;ge.dependsOn=2,ge.isNonSync=0}console.assert(V!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=j=Q+V,this.isVideoContiguous=!0;var je=R.default.moof(n.sequenceNumber++,G,T({},n,{samples:A})),ze="video",We={data1:je,data2:Ue,startPTS:ne/p,endPTS:(re+V)/p,startDTS:G/p,endDTS:j/p,type:ze,hasAudio:!1,hasVideo:!0,nb:A.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(Ue.length,"MDAT length must not be zero"),We},h.remuxAudio=function(n,e,t,f,p){var x=n.inputTimeScale,A=n.samplerate?n.samplerate:x,I=x/A,U=n.isAAC?b:E,j=U*I,z=this._initPTS,V=!n.isAAC&&this.typeSupported.mpeg,G=[],Q=n.samples,ne=V?0:8,re=this.nextAudioPts||-1,be=e*x;if(this.isAudioContiguous=t=t||Q.length&&re>0&&(f&&Math.abs(be-re)<9e3||Math.abs(o(Q[0].pts-z,be)-re)<20*j),Q.forEach(function(Z){Z.pts=o(Z.pts-z,be)}),!t||re<0){if(Q=Q.filter(function(Z){return Z.pts>=0}),!Q.length)return;p===0?re=0:f?re=Math.max(0,be):re=Q[0].pts}if(n.isAAC)for(var se=p!==void 0,oe=this.config.maxAudioFramesDrift,ue=0,he=re;ue<Q.length;ue++){var te=Q[ue],Y=te.pts,fe=Y-he,Re=Math.abs(1e3*fe/x);if(fe<=-oe*j&&se)ue===0&&(O.logger.warn("Audio frame @ "+(Y/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/x)+" ms."),this.nextAudioPts=re=he=Y);else if(fe>=oe*j&&Re<C&&se){var Le=Math.round(fe/j);he=Y-Le*j,he<0&&(Le--,he+=j),ue===0&&(this.nextAudioPts=re=he),O.logger.warn("[mp4-remuxer]: Injecting "+Le+" audio frame @ "+(he/x).toFixed(3)+"s due to "+Math.round(1e3*fe/x)+" ms gap.");for(var xe=0;xe<Le;xe++){var Te=Math.max(he,0),le=_.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);le||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),le=te.unit.subarray()),Q.splice(ue,0,{unit:le,pts:Te}),he+=j,ue++}}te.pts=he,he+=j}for(var ye=null,we=null,De,Se=0,pe=Q.length;pe--;)Se+=Q[pe].unit.byteLength;for(var me=0,Fe=Q.length;me<Fe;me++){var Pe=Q[me],Me=Pe.unit,Ie=Pe.pts;if(we!==null){var Ne=G[me-1];Ne.duration=Math.round((Ie-we)/I)}else if(t&&n.isAAC&&(Ie=re),ye=Ie,Se>0){Se+=ne;try{De=new Uint8Array(Se)}catch(Z){this.observer.emit(N.Events.ERROR,N.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Se,reason:"fail allocating audio mdat "+Se});return}if(!V){var Ue=new DataView(De.buffer);Ue.setUint32(0,Se),De.set(R.default.types.mdat,4)}}else return;De.set(Me,ne);var ke=Me.byteLength;ne+=ke,G.push(new l(!0,U,ke,0)),we=Ie}var Ae=G.length;if(!Ae)return;var Be=G[G.length-1];this.nextAudioPts=re=we+I*Be.duration;var _e=V?new Uint8Array(0):R.default.moof(n.sequenceNumber++,ye/I,T({},n,{samples:G}));n.samples=[];var ce=ye/x,Ce=re/x,q="audio",J={data1:_e,data2:De,startPTS:ce,endPTS:Ce,startDTS:ce,endDTS:Ce,type:q,hasAudio:!0,hasVideo:!1,nb:Ae};return this.isAudioContiguous=!0,console.assert(De.length,"MDAT length must not be zero"),J},h.remuxEmptyAudio=function(n,e,t,f){var p=n.inputTimeScale,x=n.samplerate?n.samplerate:p,A=p/x,I=this.nextAudioPts,U=(I!==null?I:f.startDTS*p)+this._initDTS,j=f.endDTS*p+this._initDTS,z=A*b,V=Math.ceil((j-U)/z),G=_.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!G){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Q=[],ne=0;ne<V;ne++){var re=U+ne*z;Q.push({unit:G,pts:re,dts:re})}return n.samples=Q,this.remuxAudio(n,e,t,!1)},h.remuxID3=function(n,e){var t=n.samples.length;if(!t)return;for(var f=n.inputTimeScale,p=this._initPTS,x=this._initDTS,A=0;A<t;A++){var I=n.samples[A];I.pts=o(I.pts-p,e*f)/f,I.dts=o(I.dts-x,e*f)/f}var U=n.samples;return n.samples=[],{samples:U}},h.remuxText=function(n,e){var t=n.samples.length;if(!t)return;for(var f=n.inputTimeScale,p=this._initPTS,x=0;x<t;x++){var A=n.samples[x];A.pts=o(A.pts-p,e*f)/f}n.samples.sort(function(U,j){return U.pts-j.pts});var I=n.samples;return n.samples=[],{samples:I}},v}();function o(v,h){var u;if(h===null)return v;for(h<v?u=-8589934592:u=8589934592;Math.abs(v-h)>4294967296;)v+=u;return v}function g(v){for(var h=0;h<v.length;h++)if(v[h].key)return h;return-1}var l=function(h,u,n,e){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=n,this.cts=e,this.flags=new d(h)},d=function(h){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=h?2:1,this.isNonSync=h?0:1}},"./src/remux/passthrough-remuxer.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/polyfills/number.ts"),_=S("./src/utils/mp4-tools.ts"),R=S("./src/loader/fragment.ts"),N=S("./src/utils/logger.ts"),M=function(){function m(){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 T=m.prototype;return T.destroy=function(){},T.resetTimeStamp=function(b){this.initPTS=b,this.lastEndDTS=null},T.resetNextTimestamp=function(){this.lastEndDTS=null},T.resetInitSegment=function(b,E,y){this.audioCodec=E,this.videoCodec=y,this.generateInitSegment(b),this.emitInitSegment=!0},T.generateInitSegment=function(b){var E=this.audioCodec,y=this.videoCodec;if(!b||!b.byteLength){this.initTracks=void 0,this.initData=void 0;return}var c=this.initData=Object(_.parseInitSegment)(b);E||(E=w(c.audio,R.ElementaryStreamTypes.AUDIO)),y||(y=w(c.video,R.ElementaryStreamTypes.VIDEO));var r={};c.audio&&c.video?r.audiovideo={container:"video/mp4",codec:E+","+y,initSegment:b,id:"main"}:c.audio?r.audio={container:"audio/mp4",codec:E,initSegment:b,id:"audio"}:c.video?r.video={container:"video/mp4",codec:y,initSegment:b,id:"main"}:N.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r},T.remux=function(b,E,y,c,r){var a=this.initPTS,o=this.lastEndDTS,g={audio:void 0,video:void 0,text:c,id3:y,initSegment:void 0};Object(B.isFiniteNumber)(o)||(o=this.lastEndDTS=r||0);var l=E.samples;if(!l||!l.length)return g;var d={initPTS:void 0,timescale:1},v=this.initData;if((!v||!v.length)&&(this.generateInitSegment(l),v=this.initData),!v||!v.length)return N.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),g;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1),Object(B.isFiniteNumber)(a)||(this.initPTS=d.initPTS=a=O(v,l,o));var h=Object(_.getDuration)(l,v),u=o,n=h+u;Object(_.offsetStartDTS)(v,l,a),h>0?this.lastEndDTS=n:(N.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var e=!!v.audio,t=!!v.video,f="";e&&(f+="audio"),t&&(f+="video");var p={data1:l,startPTS:u,startDTS:u,endPTS:n,endDTS:n,type:f,hasAudio:e,hasVideo:t,nb:1,dropped:0};return g.audio=p.type==="audio"?p:void 0,g.video=p.type!=="audio"?p:void 0,g.text=c,g.id3=y,g.initSegment=d,g},m}(),O=function(T,C,b){return Object(_.getStartDTS)(T,C)-b};function w(m,T){var C=m==null?void 0:m.codec;return C&&C.length>4?C:C==="hvc1"?"hvc1.1.c.L120.90":C==="av01"?"av01.0.04M.08":C==="avc1"||T===R.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}F.default=M},"./src/task-loop.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return B});var B=function(){function _(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var R=_.prototype;return R.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},R.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},R.onHandlerDestroyed=function(){},R.hasInterval=function(){return!!this._tickInterval},R.hasNextTick=function(){return!!this._tickTimer},R.setInterval=function(M){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,M),!0)},R.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},R.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},R.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},R.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},R.doTick=function(){},_}()},"./src/types/cmcd.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"CMCDVersion",function(){return B}),S.d(F,"CMCDObjectType",function(){return _}),S.d(F,"CMCDStreamingFormat",function(){return R}),S.d(F,"CMCDStreamType",function(){return N});var B=1,_;(function(M){M.MANIFEST="m",M.AUDIO="a",M.VIDEO="v",M.MUXED="av",M.INIT="i",M.CAPTION="c",M.TIMED_TEXT="tt",M.KEY="k",M.OTHER="o"})(_||(_={}));var R;(function(M){M.DASH="d",M.HLS="h",M.SMOOTH="s",M.OTHER="o"})(R||(R={}));var N;(function(M){M.VOD="v",M.LIVE="l"})(N||(N={}))},"./src/types/level.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"HlsSkip",function(){return R}),S.d(F,"getSkipValue",function(){return N}),S.d(F,"HlsUrlParameters",function(){return M}),S.d(F,"Level",function(){return O});function B(w,m){for(var T=0;T<m.length;T++){var C=m[T];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function _(w,m,T){return m&&B(w.prototype,m),T&&B(w,T),w}var R;(function(w){w.No="",w.Yes="YES",w.v2="v2"})(R||(R={}));function N(w,m){var T=w.canSkipUntil,C=w.canSkipDateRanges,b=w.endSN,E=m!==void 0?m-b:0;return T&&E<T?C?R.v2:R.Yes:R.No}var M=function(){function w(T,C,b){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=C,this.skip=b}var m=w.prototype;return m.addDirectives=function(C){var b=new self.URL(C);return this.msn!==void 0&&b.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&b.searchParams.set("_HLS_part",this.part.toString()),this.skip&&b.searchParams.set("_HLS_skip",this.skip),b.toString()},w}(),O=function(){function w(m){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=[m.url],this.attrs=m.attrs,this.bitrate=m.bitrate,m.details&&(this.details=m.details),this.id=m.id||0,this.name=m.name,this.width=m.width||0,this.height=m.height||0,this.audioCodec=m.audioCodec,this.videoCodec=m.videoCodec,this.unknownCodecs=m.unknownCodecs,this.codecSet=[m.videoCodec,m.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return _(w,[{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 C=T%this.url.length;this._urlId!==C&&(this.details=void 0,this._urlId=C)}}]),w}()},"./src/types/loader.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"PlaylistContextType",function(){return B}),S.d(F,"PlaylistLevelType",function(){return _});var B;(function(R){R.MANIFEST="manifest",R.LEVEL="level",R.AUDIO_TRACK="audioTrack",R.SUBTITLE_TRACK="subtitleTrack"})(B||(B={}));var _;(function(R){R.MAIN="main",R.AUDIO="audio",R.SUBTITLE="subtitle"})(_||(_={}))},"./src/types/transmuxer.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"ChunkMetadata",function(){return B});var B=function(N,M,O,w,m,T){w===void 0&&(w=0),m===void 0&&(m=-1),T===void 0&&(T=!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=_(),this.buffering={audio:_(),video:_(),audiovideo:_()},this.level=N,this.sn=M,this.id=O,this.size=w,this.part=m,this.partial=T};function _(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"AttrList",function(){return R});var B=/^(\d+)x(\d+)$/,_=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,R=function(){function N(O){typeof O=="string"&&(O=N.parseAttrList(O));for(var w in O)O.hasOwnProperty(w)&&(this[w]=O[w])}var M=N.prototype;return M.decimalInteger=function(w){var m=parseInt(this[w],10);return m>Number.MAX_SAFE_INTEGER?Infinity:m},M.hexadecimalInteger=function(w){if(this[w]){var m=(this[w]||"0x").slice(2);m=(m.length&1?"0":"")+m;for(var T=new Uint8Array(m.length/2),C=0;C<m.length/2;C++)T[C]=parseInt(m.slice(C*2,C*2+2),16);return T}else return null},M.hexadecimalIntegerAsNumber=function(w){var m=parseInt(this[w],16);return m>Number.MAX_SAFE_INTEGER?Infinity:m},M.decimalFloatingPoint=function(w){return parseFloat(this[w])},M.optionalFloat=function(w,m){var T=this[w];return T?parseFloat(T):m},M.enumeratedString=function(w){return this[w]},M.bool=function(w){return this[w]==="YES"},M.decimalResolution=function(w){var m=B.exec(this[w]);return m===null?void 0:{width:parseInt(m[1],10),height:parseInt(m[2],10)}},N.parseAttrList=function(w){var m,T={},C='"';for(_.lastIndex=0;(m=_.exec(w))!==null;){var b=m[2];b.indexOf(C)===0&&b.lastIndexOf(C)===b.length-1&&(b=b.slice(1,-1)),T[m[1]]=b}return T},N}()},"./src/utils/binary-search.ts":function(de,F,S){"use strict";S.r(F);var B={search:function(R,N){for(var M=0,O=R.length-1,w=null,m=null;M<=O;){w=(M+O)/2|0,m=R[w];var T=N(m);if(T>0)M=w+1;else if(T<0)O=w-1;else return m}return null}};F.default=B},"./src/utils/buffer-helper.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"BufferHelper",function(){return R});var B=S("./src/utils/logger.ts"),_={length:0,start:function(){return 0},end:function(){return 0}},R=function(){function N(){}return N.isBuffered=function(O,w){try{if(O){for(var m=N.getBuffered(O),T=0;T<m.length;T++)if(w>=m.start(T)&&w<=m.end(T))return!0}}catch(C){}return!1},N.bufferInfo=function(O,w,m){try{if(O){var T=N.getBuffered(O),C=[],b;for(b=0;b<T.length;b++)C.push({start:T.start(b),end:T.end(b)});return this.bufferedInfo(C,w,m)}}catch(E){}return{len:0,start:w,end:w,nextStart:void 0}},N.bufferedInfo=function(O,w,m){w=Math.max(0,w),O.sort(function(d,v){var h=d.start-v.start;return h||v.end-d.end});var T=[];if(m)for(var C=0;C<O.length;C++){var b=T.length;if(b){var E=T[b-1].end;O[C].start-E<m?O[C].end>E&&(T[b-1].end=O[C].end):T.push(O[C])}else T.push(O[C])}else T=O;for(var y=0,c,r=w,a=w,o=0;o<T.length;o++){var g=T[o].start,l=T[o].end;if(w+m>=g&&w<l)r=g,a=l,y=a-w;else if(w+m<g){c=g;break}}return{len:y,start:r||0,end:a||0,nextStart:c}},N.getBuffered=function(O){try{return O.buffered}catch(w){return B.logger.log("failed to get media.buffered",w),_}},N}()},"./src/utils/cea-608-parser.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"Row",function(){return a}),S.d(F,"CaptionScreen",function(){return o});var B=S("./src/utils/logger.ts"),_={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},R=function(n){var e=n;return _.hasOwnProperty(n)&&(e=_[n]),String.fromCharCode(e)},N=15,M=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},w={17:2,18:4,21:6,22:8,23:10,19:13,20:15},m={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},C=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],b;(function(u){u[u.ERROR=0]="ERROR",u[u.TEXT=1]="TEXT",u[u.WARNING=2]="WARNING",u[u.INFO=2]="INFO",u[u.DEBUG=3]="DEBUG",u[u.DATA=3]="DATA"})(b||(b={}));var E=function(){function u(){this.time=null,this.verboseLevel=b.ERROR}var n=u.prototype;return n.log=function(t,f){this.verboseLevel>=t&&B.logger.log(this.time+" ["+t+"] "+f)},u}(),y=function(n){for(var e=[],t=0;t<n.length;t++)e.push(n[t].toString(16));return e},c=function(){function u(e,t,f,p,x){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=f||!1,this.background=p||"black",this.flash=x||!1}var n=u.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(t){for(var f=["foreground","underline","italics","background","flash"],p=0;p<f.length;p++){var x=f[p];t.hasOwnProperty(x)&&(this[x]=t[x])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},n.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),r=function(){function u(e,t,f,p,x,A){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new c(t,f,p,x,A)}var n=u.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(t,f){this.uchar=t,this.penState.copy(f)},n.setPenState=function(t){this.penState.copy(t)},n.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},n.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),a=function(){function u(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<M;t++)this.chars.push(new r);this.logger=e,this.pos=0,this.currPenState=new c}var n=u.prototype;return n.equals=function(t){for(var f=!0,p=0;p<M;p++)if(!this.chars[p].equals(t.chars[p])){f=!1;break}return f},n.copy=function(t){for(var f=0;f<M;f++)this.chars[f].copy(t.chars[f])},n.isEmpty=function(){for(var t=!0,f=0;f<M;f++)if(!this.chars[f].isEmpty()){t=!1;break}return t},n.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(b.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>M&&(this.logger.log(b.DEBUG,"Too large cursor position "+this.pos),this.pos=M)},n.moveCursor=function(t){var f=this.pos+t;if(t>1)for(var p=this.pos+1;p<f+1;p++)this.chars[p].setPenState(this.currPenState);this.setCursor(f)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(t){t>=144&&this.backSpace();var f=R(t);if(this.pos>=M){this.logger.log(b.ERROR,"Cannot insert "+t.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(t){var f;for(f=t;f<M;f++)this.chars[f].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var t=[],f=!0,p=0;p<M;p++){var x=this.chars[p].uchar;x!==" "&&(f=!1),t.push(x)}return f?"":t.join("")},n.setPenStyles=function(t){this.currPenState.setStyles(t);var f=this.chars[this.pos];f.setPenState(this.currPenState)},u}(),o=function(){function u(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<N;t++)this.rows.push(new a(e));this.logger=e,this.currRow=N-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=u.prototype;return n.reset=function(){for(var t=0;t<N;t++)this.rows[t].clear();this.currRow=N-1},n.equals=function(t){for(var f=!0,p=0;p<N;p++)if(!this.rows[p].equals(t.rows[p])){f=!1;break}return f},n.copy=function(t){for(var f=0;f<N;f++)this.rows[f].copy(t.rows[f])},n.isEmpty=function(){for(var t=!0,f=0;f<N;f++)if(!this.rows[f].isEmpty()){t=!1;break}return t},n.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},n.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},n.insertChar=function(t){var f=this.rows[this.currRow];f.insertChar(t)},n.setPen=function(t){var f=this.rows[this.currRow];f.setPenStyles(t)},n.moveCursor=function(t){var f=this.rows[this.currRow];f.moveCursor(t)},n.setCursor=function(t){this.logger.log(b.INFO,"setCursor: "+t);var f=this.rows[this.currRow];f.setCursor(t)},n.setPAC=function(t){this.logger.log(b.INFO,"pacData = "+JSON.stringify(t));var f=t.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var p=0;p<N;p++)this.rows[p].clear();var x=this.currRow+1-this.nrRollUpRows,A=this.lastOutputScreen;if(A){var I=A.rows[x].cueStartTime,U=this.logger.time;if(I&&U!==null&&I<U)for(var j=0;j<this.nrRollUpRows;j++)this.rows[f-this.nrRollUpRows+j+1].copy(A.rows[x+j])}}this.currRow=f;var z=this.rows[this.currRow];if(t.indent!==null){var V=t.indent,G=Math.max(V-1,0);z.setCursor(t.indent),t.color=z.chars[G].penState.foreground}var Q={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(Q)},n.setBkgData=function(t){this.logger.log(b.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},n.setRollUpRows=function(t){this.nrRollUpRows=t},n.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(b.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(b.TEXT,this.getDisplayText());var t=this.currRow+1-this.nrRollUpRows,f=this.rows.splice(t,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(b.INFO,"Rolling up")},n.getDisplayText=function(t){t=t||!1;for(var f=[],p="",x=-1,A=0;A<N;A++){var I=this.rows[A].getTextString();I&&(x=A+1,t?f.push("Row "+x+": '"+I+"'"):f.push(I.trim()))}return f.length>0&&(t?p="["+f.join(" | ")+"]":p=f.join(`
|
|
`)),p},n.getTextAndFormat=function(){return this.rows},u}(),g=function(){function u(e,t,f){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new o(f),this.nonDisplayedMemory=new o(f),this.lastOutputScreen=new o(f),this.currRollUpRow=this.displayedMemory.rows[N-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}var n=u.prototype;return n.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[N-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(t){this.outputFilter=t},n.setPAC=function(t){this.writeScreen.setPAC(t)},n.setBkgData=function(t){this.writeScreen.setBkgData(t)},n.setMode=function(t){if(t===this.mode)return;this.mode=t,this.logger.log(b.INFO,"MODE="+t),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t},n.insertChars=function(t){for(var f=0;f<t.length;f++)this.writeScreen.insertChar(t[f]);var p=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(b.INFO,p+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(b.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(b.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){if(this.logger.log(b.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(b.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(t){this.logger.log(b.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},n.ccFON=function(){this.logger.log(b.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(b.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(b.INFO,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(b.INFO,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(b.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(b.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(b.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){if(this.logger.log(b.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(b.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},n.ccTO=function(t){this.logger.log(b.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},n.ccMIDROW=function(t){var f={flash:!1};if(f.underline=t%2===1,f.italics=t>=46,f.italics)f.foreground="white";else{var p=Math.floor(t/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=x[p]}this.logger.log(b.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},n.outputDataUpdate=function(t){t===void 0&&(t=!1);var f=this.logger.time;if(f===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=f:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,f,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},u}(),l=function(){function u(e,t,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var p=new E;this.channels=[null,new g(e,t,p),new g(e+1,f,p)],this.cmdHistory=h(),this.logger=p}var n=u.prototype;return n.getHandler=function(t){return this.channels[t].getHandler()},n.setHandler=function(t,f){this.channels[t].setHandler(f)},n.addData=function(t,f){var p,x,A,I=!1;this.logger.time=t;for(var U=0;U<f.length;U+=2){if(x=f[U]&127,A=f[U+1]&127,x===0&&A===0)continue;if(this.logger.log(b.DATA,"["+y([f[U],f[U+1]])+"] -> ("+y([x,A])+")"),p=this.parseCmd(x,A),p||(p=this.parseMidrow(x,A)),p||(p=this.parsePAC(x,A)),p||(p=this.parseBackgroundAttributes(x,A)),!p&&(I=this.parseChars(x,A),I)){var j=this.currentChannel;if(j&&j>0){var z=this.channels[j];z.insertChars(I)}else this.logger.log(b.WARNING,"No channel found yet. TEXT-MODE?")}!p&&!I&&this.logger.log(b.WARNING,"Couldn't parse cleaned data "+y([x,A])+" orig: "+y([f[U],f[U+1]]))}},n.parseCmd=function(t,f){var p=this.cmdHistory,x=(t===20||t===28||t===21||t===29)&&f>=32&&f<=47,A=(t===23||t===31)&&f>=33&&f<=35;if(!(x||A))return!1;if(v(t,f,p))return d(null,null,p),this.logger.log(b.DEBUG,"Repeated command ("+y([t,f])+") is dropped"),!0;var I=t===20||t===21||t===23?1:2,U=this.channels[I];return t===20||t===21||t===28||t===29?f===32?U.ccRCL():f===33?U.ccBS():f===34?U.ccAOF():f===35?U.ccAON():f===36?U.ccDER():f===37?U.ccRU(2):f===38?U.ccRU(3):f===39?U.ccRU(4):f===40?U.ccFON():f===41?U.ccRDC():f===42?U.ccTR():f===43?U.ccRTD():f===44?U.ccEDM():f===45?U.ccCR():f===46?U.ccENM():f===47&&U.ccEOC():U.ccTO(f-32),d(t,f,p),this.currentChannel=I,!0},n.parseMidrow=function(t,f){var p=0;if((t===17||t===25)&&f>=32&&f<=47){if(t===17?p=1:p=2,p!==this.currentChannel)return this.logger.log(b.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[p];return x?(x.ccMIDROW(f),this.logger.log(b.DEBUG,"MIDROW ("+y([t,f])+")"),!0):!1}return!1},n.parsePAC=function(t,f){var p,x=this.cmdHistory,A=(t>=17&&t<=23||t>=25&&t<=31)&&f>=64&&f<=127,I=(t===16||t===24)&&f>=64&&f<=95;if(!(A||I))return!1;if(v(t,f,x))return d(null,null,x),!0;var U=t<=23?1:2;f>=64&&f<=95?p=U===1?O[t]:m[t]:p=U===1?w[t]:T[t];var j=this.channels[U];return j?(j.setPAC(this.interpretPAC(p,f)),d(t,f,x),this.currentChannel=U,!0):!1},n.interpretPAC=function(t,f){var p,x={color:null,italics:!1,indent:null,underline:!1,row:t};return f>95?p=f-96:p=f-64,x.underline=(p&1)===1,p<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(p/2)]:p<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((p-16)/2)*4,x},n.parseChars=function(t,f){var p,x=null,A=null;if(t>=25?(p=2,A=t-8):(p=1,A=t),A>=17&&A<=19){var I;A===17?I=f+80:A===18?I=f+112:I=f+144,this.logger.log(b.INFO,"Special char '"+R(I)+"' in channel "+p),x=[I]}else t>=32&&t<=127&&(x=f===0?[t]:[t,f]);if(x){var U=y(x);this.logger.log(b.DEBUG,"Char codes = "+U.join(",")),d(t,f,this.cmdHistory)}return x},n.parseBackgroundAttributes=function(t,f){var p=(t===16||t===24)&&f>=32&&f<=47,x=(t===23||t===31)&&f>=45&&f<=47;if(!(p||x))return!1;var A,I={};t===16||t===24?(A=Math.floor((f-32)/2),I.background=C[A],f%2===1&&(I.background=I.background+"_semi")):f===45?I.background="transparent":(I.foreground="black",f===47&&(I.underline=!0));var U=t<=23?1:2,j=this.channels[U];return j.setBkgData(I),d(t,f,this.cmdHistory),!0},n.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var f=this.channels[t];f&&f.reset()}this.cmdHistory=h()},n.cueSplitAtTime=function(t){for(var f=0;f<this.channels.length;f++){var p=this.channels[f];p&&p.cueSplitAtTime(t)}},u}();function d(u,n,e){e.a=u,e.b=n}function v(u,n,e){return e.a===u&&e.b===n}function h(){return{a:null,b:null}}F.default=l},"./src/utils/codecs.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"isCodecType",function(){return _}),S.d(F,"isCodecSupportedInMp4",function(){return R});var B={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function _(N,M){var O=B[M];return!!O&&O[N.slice(0,4)]===!0}function R(N,M){return MediaSource.isTypeSupported((M||"video")+'/mp4;codecs="'+N+'"')}},"./src/utils/cues.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/utils/vttparser.ts"),_=S("./src/utils/webvtt-parser.ts"),R=S("./src/utils/texttrack-utils.ts"),N=/\s/,M={newCue:function(w,m,T,C){for(var b=[],E,y,c,r,a,o=self.VTTCue||self.TextTrackCue,g=0;g<C.rows.length;g++)if(E=C.rows[g],c=!0,r=0,a="",!E.isEmpty()){for(var l=0;l<E.chars.length;l++)N.test(E.chars[l].uchar)&&c?r++:(a+=E.chars[l].uchar,c=!1);E.cueStartTime=m,m===T&&(T+=1e-4),r>=16?r--:r++;var d=Object(B.fixLineBreaks)(a.trim()),v=Object(_.generateCueId)(m,T,d);(!w||!w.cues||!w.cues.getCueById(v))&&(y=new o(m,T,d),y.id=v,y.line=g+1,y.align="left",y.position=10+Math.min(80,Math.floor(r*8/32)*10),b.push(y))}return w&&b.length&&(b.sort(function(h,u){return h.line==="auto"||u.line==="auto"?0:h.line>8&&u.line>8?u.line-h.line:h.line-u.line}),b.forEach(function(h){return Object(R.addCueToTrack)(w,h)})),b}};F.default=M},"./src/utils/discontinuities.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"findFirstFragWithCC",function(){return N}),S.d(F,"shouldAlignOnDiscontinuities",function(){return M}),S.d(F,"findDiscontinuousReferenceFrag",function(){return O}),S.d(F,"adjustSlidingStart",function(){return m}),S.d(F,"alignStream",function(){return T}),S.d(F,"alignPDT",function(){return b}),S.d(F,"alignFragmentByPDTDelta",function(){return E}),S.d(F,"alignMediaPlaylistByPDT",function(){return y});var B=S("./src/polyfills/number.ts"),_=S("./src/utils/logger.ts"),R=S("./src/controller/level-helper.ts");function N(c,r){for(var a=null,o=0,g=c.length;o<g;o++){var l=c[o];if(l&&l.cc===r){a=l;break}}return a}function M(c,r,a){return!!(r.details&&(a.endCC>a.startCC||c&&c.cc<a.startCC))}function O(c,r){var a=c.fragments,o=r.fragments;if(!o.length||!a.length){_.logger.log("No fragments to align");return}var g=N(a,o[0].cc);if(!g||g&&!g.startPTS){_.logger.log("No frag in previous level to align on");return}return g}function w(c,r){if(c){var a=c.start+r;c.start=c.startPTS=a,c.endPTS=a+c.duration}}function m(c,r){for(var a=r.fragments,o=0,g=a.length;o<g;o++)w(a[o],c);r.fragmentHint&&w(r.fragmentHint,c),r.alignedSliding=!0}function T(c,r,a){if(!r)return;C(c,a,r),!a.alignedSliding&&r.details&&b(a,r.details),!a.alignedSliding&&r.details&&!a.skippedSegments&&Object(R.adjustSliding)(r.details,a)}function C(c,r,a){if(M(c,a,r)){var o=O(a.details,r);o&&Object(B.isFiniteNumber)(o.start)&&(_.logger.log("Adjusting PTS using last level due to CC increase within current level "+r.url),m(o.start,r))}}function b(c,r){if(!r.fragments.length||!c.hasProgramDateTime||!r.hasProgramDateTime)return;var a=r.fragments[0].programDateTime,o=c.fragments[0].programDateTime,g=(o-a)/1e3+r.fragments[0].start;g&&Object(B.isFiniteNumber)(g)&&(_.logger.log("Adjusting PTS using programDateTime delta "+(o-a)+"ms, sliding:"+g.toFixed(3)+" "+c.url+" "),m(g,c))}function E(c,r){var a=c.programDateTime;if(!a)return;var o=(a-r)/1e3;c.start=c.startPTS=o,c.endPTS=o+c.duration}function y(c,r){if(!r.fragments.length||!c.hasProgramDateTime||!r.hasProgramDateTime)return;var a=r.fragments[0].programDateTime,o=r.fragments[0].start,g=a-o*1e3;c.fragments.forEach(function(l){E(l,g)}),c.fragmentHint&&E(c.fragmentHint,g),c.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/utils/ewma.ts"),_=function(){function R(M,O,w){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=w,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new B.default(M),this.fast_=new B.default(O)}var N=R.prototype;return N.update=function(O,w){var m=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new B.default(O,m.getEstimate(),m.getTotalWeight())),this.fast_.halfLife!==w&&(this.fast_=new B.default(w,T.getEstimate(),T.getTotalWeight()))},N.sample=function(O,w){O=Math.max(O,this.minDelayMs_);var m=8*w,T=O/1e3,C=m/T;this.fast_.sample(T,C),this.slow_.sample(T,C)},N.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},N.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},N.destroy=function(){},R}();F.default=_},"./src/utils/ewma.ts":function(de,F,S){"use strict";S.r(F);var B=function(){function _(N,M,O){M===void 0&&(M=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=N,this.alpha_=N?Math.exp(Math.log(.5)/N):0,this.estimate_=M,this.totalWeight_=O}var R=_.prototype;return R.sample=function(M,O){var w=Math.pow(this.alpha_,M);this.estimate_=O*(1-w)+w*this.estimate_,this.totalWeight_+=M},R.getTotalWeight=function(){return this.totalWeight_},R.getEstimate=function(){if(this.alpha_){var M=1-Math.pow(this.alpha_,this.totalWeight_);if(M)return this.estimate_/M}return this.estimate_},_}();F.default=B},"./src/utils/fetch-loader.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"fetchSupported",function(){return E});var B=S("./src/polyfills/number.ts"),_=S("./src/loader/load-stats.ts"),R=S("./src/demux/chunk-cache.ts");function N(o,g){o.prototype=Object.create(g.prototype),o.prototype.constructor=o,T(o,g)}function M(o){var g=typeof Map=="function"?new Map:void 0;return M=function(d){if(d===null||!m(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(d))return g.get(d);g.set(d,v)}function v(){return O(d,arguments,C(this).constructor)}return v.prototype=Object.create(d.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),T(v,d)},M(o)}function O(o,g,l){return w()?O=Reflect.construct:O=function(v,h,u){var n=[null];n.push.apply(n,h);var e=Function.bind.apply(v,n),t=new e;return u&&T(t,u.prototype),t},O.apply(null,arguments)}function w(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(o){return!1}}function m(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function T(o,g){return T=Object.setPrototypeOf||function(d,v){return d.__proto__=v,d},T(o,g)}function C(o){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},C(o)}function b(){return b=Object.assign||function(o){for(var g=1;g<arguments.length;g++){var l=arguments[g];for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(o[d]=l[d])}return o},b.apply(this,arguments)}function E(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(o){}return!1}var y=function(){function o(l){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=l.fetchSetup||r,this.controller=new self.AbortController,this.stats=new _.LoadStats}var g=o.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var d=this.response;(!d||!d.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var d;this.abortInternal(),(d=this.callbacks)!==null&&d!==void 0&&d.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(d,v,h){var u=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var e=c(d,this.controller.signal),t=h.onProgress,f=d.responseType==="arraybuffer",p=f?"byteLength":"length";this.context=d,this.config=v,this.callbacks=h,this.request=this.fetchSetup(d,e),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),h.onTimeout(n,d,u.response)},v.timeout),self.fetch(this.request).then(function(x){if(u.response=u.loader=x,!x.ok){var A=x.status,I=x.statusText;throw new a(I||"fetch, bad network response",A,x)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(x.headers.get("Content-Length")||"0"),t&&Object(B.isFiniteNumber)(v.highWaterMark)?u.loadProgressively(x,n,d,v.highWaterMark,t):f?x.arrayBuffer():x.text()}).then(function(x){var A=u.response;self.clearTimeout(u.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=x[p];var I={url:A.url,data:x};t&&!Object(B.isFiniteNumber)(v.highWaterMark)&&t(n,d,x,A),h.onSuccess(I,n,d,A)}).catch(function(x){if(self.clearTimeout(u.requestTimeout),n.aborted)return;var A=x.code||0;h.onError({code:A,text:x.message},d,x.details)})},g.getCacheAge=function(){var d=null;if(this.response){var v=this.response.headers.get("age");d=v?parseFloat(v):null}return d},g.loadProgressively=function(d,v,h,u,n){u===void 0&&(u=0);var e=new R.default,t=d.body.getReader(),f=function p(){return t.read().then(function(x){if(x.done)return e.dataLength&&n(v,h,e.flush(),d),Promise.resolve(new ArrayBuffer(0));var A=x.value,I=A.length;return v.loaded+=I,I<u||e.dataLength?(e.push(A),e.dataLength>=u&&n(v,h,e.flush(),d)):n(v,h,A,d),p()}).catch(function(){return Promise.reject()})};return f()},o}();function c(o,g){var l={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(b({},o.headers))};return o.rangeEnd&&l.headers.set("Range","bytes="+o.rangeStart+"-"+String(o.rangeEnd-1)),l}function r(o,g){return new self.Request(o.url,g)}var a=function(o){N(g,o);function g(l,d,v){var h;return h=o.call(this,l)||this,h.code=void 0,h.details=void 0,h.code=d,h.details=v,h}return g}(M(Error));F.default=y},"./src/utils/imsc1-ttml-parser.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"IMSC1_CODEC",function(){return m}),S.d(F,"parseIMSC1",function(){return E});var B=S("./src/utils/mp4-tools.ts"),_=S("./src/utils/vttparser.ts"),R=S("./src/utils/vttcue.ts"),N=S("./src/demux/id3.ts"),M=S("./src/utils/timescale-conversion.ts"),O=S("./src/utils/webvtt-parser.ts");function w(){return w=Object.assign||function(u){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(u[t]=e[t])}return u},w.apply(this,arguments)}var m="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,C=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,b={left:"start",center:"center",right:"end",start:"start",end:"end"};function E(u,n,e,t,f){var p=Object(B.findBox)(new Uint8Array(u),["mdat"]);if(p.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var x=p[0],A=Object(N.utf8ArrayToStr)(new Uint8Array(u,x.start,x.end-x.start)),I=Object(M.toTimescaleFromScale)(n,1,e);try{t(y(A,I))}catch(U){f(U)}}function y(u,n){var e=new DOMParser,t=e.parseFromString(u,"text/xml"),f=t.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var p={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(p).reduce(function(z,V){return z[V]=f.getAttribute("ttp:"+V)||p[V],z},{}),A=f.getAttribute("xml:space")!=="preserve",I=r(c(f,"styling","style")),U=r(c(f,"layout","region")),j=c(f,"body","[begin]");return[].map.call(j,function(z){var V=a(z,A);if(!V||!z.hasAttribute("begin"))return null;var G=d(z.getAttribute("begin"),x),Q=d(z.getAttribute("dur"),x),ne=d(z.getAttribute("end"),x);if(G===null)throw l(z);if(ne===null){if(Q===null)throw l(z);ne=G+Q}var re=new R.default(G-n,ne-n,V);re.id=Object(O.generateCueId)(re.startTime,re.endTime,re.text);var be=U[z.getAttribute("region")],se=I[z.getAttribute("style")];re.position=10,re.size=80;var oe=o(be,se),ue=oe.textAlign;if(ue){var he=b[ue];he&&(re.lineAlign=he),re.align=ue}return w(re,oe),re}).filter(function(z){return z!==null})}function c(u,n,e){var t=u.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function r(u){return u.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function a(u,n){return[].slice.call(u.childNodes).reduce(function(e,t,f){var p;return t.nodeName==="br"&&f?e+`
|
|
`:(p=t.childNodes)!==null&&p!==void 0&&p.length?a(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function o(u,n){var e="http://www.w3.org/ns/ttml#styling",t=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return t.reduce(function(f,p){var x=g(n,e,p)||g(u,e,p);return x&&(f[p]=x),f},{})}function g(u,n,e){return u.hasAttributeNS(n,e)?u.getAttributeNS(n,e):null}function l(u){return new Error("Could not parse ttml timestamp "+u)}function d(u,n){if(!u)return null;var e=Object(_.parseTimeStamp)(u);return e===null&&(T.test(u)?e=v(u,n):C.test(u)&&(e=h(u,n))),e}function v(u,n){var e=T.exec(u),t=(e[4]|0)+(e[5]|0)/n.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+t/n.frameRate}function h(u,n){var e=C.exec(u),t=Number(e[1]),f=e[2];switch(f){case"h":return t*3600;case"m":return t*60;case"ms":return t*1e3;case"f":return t/n.frameRate;case"t":return t/n.tickRate}return t}},"./src/utils/logger.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"enableLogs",function(){return O}),S.d(F,"logger",function(){return w});var B=function(){},_={trace:B,debug:B,log:B,warn:B,info:B,error:B},R=_;function N(m){var T=self.console[m];return T?T.bind(self.console,"["+m+"] >"):B}function M(m){for(var T=arguments.length,C=new Array(T>1?T-1:0),b=1;b<T;b++)C[b-1]=arguments[b];C.forEach(function(E){R[E]=m[E]?m[E].bind(m):N(E)})}function O(m){if(self.console&&m===!0||typeof m=="object"){M(m,"debug","log","info","warn","error");try{R.log()}catch(T){R=_}}else R=_}var w=R},"./src/utils/mediakeys-helper.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"KeySystems",function(){return B}),S.d(F,"requestMediaKeySystemAccess",function(){return _});var B;(function(R){R.WIDEVINE="com.widevine.alpha",R.PLAYREADY="com.microsoft.playready"})(B||(B={}));var _=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"getMediaSource",function(){return B});function B(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"bin2str",function(){return M}),S.d(F,"readUint16",function(){return O}),S.d(F,"readUint32",function(){return w}),S.d(F,"writeUint32",function(){return m}),S.d(F,"findBox",function(){return T}),S.d(F,"parseSegmentIndex",function(){return C}),S.d(F,"parseInitSegment",function(){return b}),S.d(F,"getStartDTS",function(){return E}),S.d(F,"getDuration",function(){return y}),S.d(F,"computeRawDurationFromSamples",function(){return c}),S.d(F,"offsetStartDTS",function(){return r}),S.d(F,"segmentValidRange",function(){return a}),S.d(F,"appendUint8Array",function(){return o});var B=S("./src/utils/typed-array.ts"),_=S("./src/loader/fragment.ts"),R=Math.pow(2,32)-1,N=[].push;function M(g){return String.fromCharCode.apply(null,g)}function O(g,l){"data"in g&&(l+=g.start,g=g.data);var d=g[l]<<8|g[l+1];return d<0?65536+d:d}function w(g,l){"data"in g&&(l+=g.start,g=g.data);var d=g[l]<<24|g[l+1]<<16|g[l+2]<<8|g[l+3];return d<0?4294967296+d:d}function m(g,l,d){"data"in g&&(l+=g.start,g=g.data),g[l]=d>>24,g[l+1]=d>>16&255,g[l+2]=d>>8&255,g[l+3]=d&255}function T(g,l){var d=[];if(!l.length)return d;var v,h,u;"data"in g?(v=g.data,h=g.start,u=g.end):(v=g,h=0,u=v.byteLength);for(var n=h;n<u;){var e=w(v,n),t=M(v.subarray(n+4,n+8)),f=e>1?n+e:u;if(t===l[0])if(l.length===1)d.push({data:v,start:n+8,end:f});else{var p=T({data:v,start:n+8,end:f},l.slice(1));p.length&&N.apply(d,p)}n=f}return d}function C(g){var l=T(g,["moov"]),d=l[0],v=d?d.end:null,h=T(g,["sidx"]);if(!h||!h[0])return null;var u=[],n=h[0],e=n.data[0],t=e===0?8:16,f=w(n,t);t+=4;var p=0,x=0;e===0?t+=8:t+=16,t+=2;var A=n.end+x,I=O(n,t);t+=2;for(var U=0;U<I;U++){var j=t,z=w(n,j);j+=4;var V=z&2147483647,G=(z&2147483648)>>>31;if(G===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var Q=w(n,j);j+=4,u.push({referenceSize:V,subsegmentDuration:Q,info:{duration:Q/f,start:A,end:A+V-1}}),A+=V,j+=4,t=j}return{earliestPresentationTime:p,timescale:f,version:e,referencesCount:I,references:u,moovEndOffset:v}}function b(g){for(var l=[],d=T(g,["moov","trak"]),v=0;v<d.length;v++){var h=d[v],u=T(h,["tkhd"])[0];if(u){var n=u.data[u.start],e=n===0?12:20,t=w(u,e),f=T(h,["mdia","mdhd"])[0];if(f){n=f.data[f.start],e=n===0?12:20;var p=w(f,e),x=T(h,["mdia","hdlr"])[0];if(x){var A=M(x.data.subarray(x.start+8,x.start+12)),I={soun:_.ElementaryStreamTypes.AUDIO,vide:_.ElementaryStreamTypes.VIDEO}[A];if(I){var U=T(h,["mdia","minf","stbl","stsd"])[0],j=void 0;U&&(j=M(U.data.subarray(U.start+12,U.start+16))),l[t]={timescale:p,type:I},l[I]={timescale:p,id:t,codec:j}}}}}}var z=T(g,["moov","mvex","trex"]);return z.forEach(function(V){var G=w(V,4),Q=l[G];Q&&(Q.default={duration:w(V,12),flags:w(V,20)})}),l}function E(g,l){return T(l,["moof","traf"]).reduce(function(d,v){var h=T(v,["tfdt"])[0],u=h.data[h.start],n=T(v,["tfhd"]).reduce(function(e,t){var f=w(t,4),p=g[f];if(p){var x=w(h,4);u===1&&(x*=Math.pow(2,32),x+=w(h,8));var A=p.timescale||9e4,I=x/A;if(isFinite(I)&&(e===null||I<e))return I}return e},null);return n!==null&&isFinite(n)&&(d===null||n<d)?n:d},null)||0}function y(g,l){for(var d=0,v=0,h=0,u=T(g,["moof","traf"]),n=0;n<u.length;n++){var e=u[n],t=T(e,["tfhd"])[0],f=w(t,4),p=l[f];if(!p)continue;var x=p.default,A=w(t,0)|(x==null?void 0:x.flags),I=x==null?void 0:x.duration;A&8&&(A&2?I=w(t,12):I=w(t,8));for(var U=p.timescale||9e4,j=T(e,["trun"]),z=0;z<j.length;z++){if(I){var V=w(j[z],4);d=I*V}else d=c(j[z]);p.type===_.ElementaryStreamTypes.VIDEO?v+=d/U:p.type===_.ElementaryStreamTypes.AUDIO&&(h+=d/U)}}if(v===0&&h===0){var G=C(g);if(G!=null&&G.references)return G.references.reduce(function(Q,ne){return Q+ne.info.duration||0},0)}return v||h}function c(g){var l=w(g,0),d=8;l&1&&(d+=4),l&4&&(d+=4);for(var v=0,h=w(g,4),u=0;u<h;u++){if(l&256){var n=w(g,d);v+=n,d+=4}l&512&&(d+=4),l&1024&&(d+=4),l&2048&&(d+=4)}return v}function r(g,l,d){T(l,["moof","traf"]).forEach(function(v){T(v,["tfhd"]).forEach(function(h){var u=w(h,4),n=g[u];if(!n)return;var e=n.timescale||9e4;T(v,["tfdt"]).forEach(function(t){var f=t.data[t.start],p=w(t,4);if(f===0)m(t,4,p-d*e);else{p*=Math.pow(2,32),p+=w(t,8),p-=d*e,p=Math.max(p,0);var x=Math.floor(p/(R+1)),A=Math.floor(p%(R+1));m(t,4,x),m(t,8,A)}})})})}function a(g){var l={valid:null,remainder:null},d=T(g,["moof"]);if(d){if(d.length<2)return l.remainder=g,l}else return l;var v=d[d.length-1];return l.valid=Object(B.sliceUint8)(g,0,v.start-8),l.remainder=Object(B.sliceUint8)(g,v.start-8),l}function o(g,l){var d=new Uint8Array(g.length+l.length);return d.set(g),d.set(l,g.length),d}},"./src/utils/output-filter.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"default",function(){return B});var B=function(){function _(N,M){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=N,this.trackName=M}var R=_.prototype;return R.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},R.newCue=function(M,O,w){(this.startTime===null||this.startTime>M)&&(this.startTime=M),this.endTime=O,this.screen=w,this.timelineController.createCaptionsTrack(this.trackName)},R.reset=function(){this.cueRanges=[]},_}()},"./src/utils/texttrack-utils.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"sendAddTrackEvent",function(){return _}),S.d(F,"addCueToTrack",function(){return R}),S.d(F,"clearCurrentCues",function(){return N}),S.d(F,"removeCuesInRange",function(){return M}),S.d(F,"getCuesInRange",function(){return w});var B=S("./src/utils/logger.ts");function _(m,T){var C;try{C=new Event("addtrack")}catch(b){C=document.createEvent("Event"),C.initEvent("addtrack",!1,!1)}C.track=m,T.dispatchEvent(C)}function R(m,T){var C=m.mode;if(C==="disabled"&&(m.mode="hidden"),m.cues&&!m.cues.getCueById(T.id))try{if(m.addCue(T),!m.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(E){B.logger.debug("[texttrack-utils]: "+E);var b=new self.TextTrackCue(T.startTime,T.endTime,T.text);b.id=T.id,m.addCue(b)}C==="disabled"&&(m.mode=C)}function N(m){var T=m.mode;if(T==="disabled"&&(m.mode="hidden"),m.cues)for(var C=m.cues.length;C--;)m.removeCue(m.cues[C]);T==="disabled"&&(m.mode=T)}function M(m,T,C){var b=m.mode;if(b==="disabled"&&(m.mode="hidden"),m.cues&&m.cues.length>0)for(var E=w(m.cues,T,C),y=0;y<E.length;y++)m.removeCue(E[y]);b==="disabled"&&(m.mode=b)}function O(m,T){if(T<m[0].startTime)return 0;var C=m.length-1;if(T>m[C].endTime)return-1;for(var b=0,E=C;b<=E;){var y=Math.floor((E+b)/2);if(T<m[y].startTime)E=y-1;else if(T>m[y].startTime&&b<C)b=y+1;else return y}return m[b].startTime-T<T-m[E].startTime?b:E}function w(m,T,C){var b=[],E=O(m,T);if(E>-1)for(var y=E,c=m.length;y<c;y++){var r=m[y];if(r.startTime>=T&&r.endTime<=C)b.push(r);else if(r.startTime>C)return b}return b}},"./src/utils/time-ranges.ts":function(de,F,S){"use strict";S.r(F);var B={toString:function(R){for(var N="",M=R.length,O=0;O<M;O++)N+="["+R.start(O).toFixed(3)+","+R.end(O).toFixed(3)+"]";return N}};F.default=B},"./src/utils/timescale-conversion.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"toTimescaleFromBase",function(){return _}),S.d(F,"toTimescaleFromScale",function(){return R}),S.d(F,"toMsFromMpegTsClock",function(){return N}),S.d(F,"toMpegTsClockFromTimescale",function(){return M});var B=9e4;function _(O,w,m,T){m===void 0&&(m=1),T===void 0&&(T=!1);var C=O*w*m;return T?Math.round(C):C}function R(O,w,m,T){return m===void 0&&(m=1),T===void 0&&(T=!1),_(O,w,1/m,T)}function N(O,w){return w===void 0&&(w=!1),_(O,1e3,1/B,w)}function M(O,w){return w===void 0&&(w=1),_(O,B,1/w)}},"./src/utils/typed-array.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"sliceUint8",function(){return B});function B(_,R,N){return Uint8Array.prototype.slice?_.slice(R,N):new Uint8Array(Array.prototype.slice.call(_,R,N))}},"./src/utils/vttcue.ts":function(de,F,S){"use strict";S.r(F),F.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var B=["","lr","rl"],_=["start","middle","end","left","right"];function R(m,T){if(typeof T!="string")return!1;if(!Array.isArray(m))return!1;var C=T.toLowerCase();return~m.indexOf(C)?C:!1}function N(m){return R(B,m)}function M(m){return R(_,m)}function O(m){for(var T=arguments.length,C=new Array(T>1?T-1:0),b=1;b<T;b++)C[b-1]=arguments[b];for(var E=1;E<arguments.length;E++){var y=arguments[E];for(var c in y)m[c]=y[c]}return m}function w(m,T,C){var b=this,E={enumerable:!0};b.hasBeenReset=!1;var y="",c=!1,r=m,a=T,o=C,g=null,l="",d=!0,v="auto",h="start",u=50,n="middle",e=50,t="middle";Object.defineProperty(b,"id",O({},E,{get:function(){return y},set:function(p){y=""+p}})),Object.defineProperty(b,"pauseOnExit",O({},E,{get:function(){return c},set:function(p){c=!!p}})),Object.defineProperty(b,"startTime",O({},E,{get:function(){return r},set:function(p){if(typeof p!="number")throw new TypeError("Start time must be set to a number.");r=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"endTime",O({},E,{get:function(){return a},set:function(p){if(typeof p!="number")throw new TypeError("End time must be set to a number.");a=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"text",O({},E,{get:function(){return o},set:function(p){o=""+p,this.hasBeenReset=!0}})),Object.defineProperty(b,"region",O({},E,{get:function(){return g},set:function(p){g=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"vertical",O({},E,{get:function(){return l},set:function(p){var x=N(p);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=x,this.hasBeenReset=!0}})),Object.defineProperty(b,"snapToLines",O({},E,{get:function(){return d},set:function(p){d=!!p,this.hasBeenReset=!0}})),Object.defineProperty(b,"line",O({},E,{get:function(){return v},set:function(p){if(typeof p!="number"&&p!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");v=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"lineAlign",O({},E,{get:function(){return h},set:function(p){var x=M(p);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");h=x,this.hasBeenReset=!0}})),Object.defineProperty(b,"position",O({},E,{get:function(){return u},set:function(p){if(p<0||p>100)throw new Error("Position must be between 0 and 100.");u=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"positionAlign",O({},E,{get:function(){return n},set:function(p){var x=M(p);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");n=x,this.hasBeenReset=!0}})),Object.defineProperty(b,"size",O({},E,{get:function(){return e},set:function(p){if(p<0||p>100)throw new Error("Size must be between 0 and 100.");e=p,this.hasBeenReset=!0}})),Object.defineProperty(b,"align",O({},E,{get:function(){return t},set:function(p){var x=M(p);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");t=x,this.hasBeenReset=!0}})),b.displayState=void 0}return w.prototype.getCueAsHTML=function(){var m=self.WebVTT;return m.convertCueToDOMTree(self,this.text)},w}()},"./src/utils/vttparser.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"parseTimeStamp",function(){return R}),S.d(F,"fixLineBreaks",function(){return T}),S.d(F,"VTTParser",function(){return C});var B=S("./src/utils/vttcue.ts"),_=function(){function b(){}var E=b.prototype;return E.decode=function(c,r){if(!c)return"";if(typeof c!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(c))},b}();function R(b){function E(c,r,a,o){return(c|0)*3600+(r|0)*60+(a|0)+parseFloat(o||0)}var y=b.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?E(y[2],y[3],0,y[4]):E(y[1],y[2],y[3],y[4]):null}var N=function(){function b(){this.values=Object.create(null)}var E=b.prototype;return E.set=function(c,r){!this.get(c)&&r!==""&&(this.values[c]=r)},E.get=function(c,r,a){return a?this.has(c)?this.values[c]:r[a]:this.has(c)?this.values[c]:r},E.has=function(c){return c in this.values},E.alt=function(c,r,a){for(var o=0;o<a.length;++o)if(r===a[o]){this.set(c,r);break}},E.integer=function(c,r){/^-?\d+$/.test(r)&&this.set(c,parseInt(r,10))},E.percent=function(c,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var a=parseFloat(r);if(a>=0&&a<=100)return this.set(c,a),!0}return!1},b}();function M(b,E,y,c){var r=c?b.split(c):[b];for(var a in r){if(typeof r[a]!="string")continue;var o=r[a].split(y);if(o.length!==2)continue;var g=o[0],l=o[1];E(g,l)}}var O=new B.default(0,0,""),w=O.align==="middle"?"middle":"center";function m(b,E,y){var c=b;function r(){var g=R(b);if(g===null)throw new Error("Malformed timestamp: "+c);return b=b.replace(/^[^\sa-zA-Z-]+/,""),g}function a(g,l){var d=new N;M(g,function(u,n){var e;switch(u){case"region":for(var t=y.length-1;t>=0;t--)if(y[t].id===n){d.set(u,y[t].region);break}break;case"vertical":d.alt(u,n,["rl","lr"]);break;case"line":e=n.split(","),d.integer(u,e[0]),d.percent(u,e[0])&&d.set("snapToLines",!1),d.alt(u,e[0],["auto"]),e.length===2&&d.alt("lineAlign",e[1],["start",w,"end"]);break;case"position":e=n.split(","),d.percent(u,e[0]),e.length===2&&d.alt("positionAlign",e[1],["start",w,"end","line-left","line-right","auto"]);break;case"size":d.percent(u,n);break;case"align":d.alt(u,n,["start",w,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");var v=d.get("line","auto");v==="auto"&&O.line===-1&&(v=-1),l.line=v,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",w);var h=d.get("position","auto");h==="auto"&&O.position===50&&(h=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=h}function o(){b=b.replace(/^\s+/,"")}if(o(),E.startTime=r(),o(),b.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+c);b=b.substr(3),o(),E.endTime=r(),o(),a(b,E)}function T(b){return b.replace(/<br(?: \/)?>/gi,`
|
|
`)}var C=function(){function b(){this.state="INITIAL",this.buffer="",this.decoder=new _,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var E=b.prototype;return E.parse=function(c){var r=this;c&&(r.buffer+=r.decoder.decode(c,{stream:!0}));function a(){var h=r.buffer,u=0;for(h=T(h);u<h.length&&h[u]!=="\r"&&h[u]!==`
|
|
`;)++u;var n=h.substr(0,u);return h[u]==="\r"&&++u,h[u]===`
|
|
`&&++u,r.buffer=h.substr(u),n}function o(h){M(h,function(u,n){},/:/)}try{var g="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;g=a();var l=g.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var d=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;d?d=!1:g=a();switch(r.state){case"HEADER":/:/.test(g)?o(g):g||(r.state="ID");continue;case"NOTE":g||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){r.state="NOTE";break}if(!g)continue;if(r.cue=new B.default(0,0,""),r.state="CUE",g.indexOf("-->")===-1){r.cue.id=g;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{m(g,r.cue,r.regionList)}catch(h){r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var v=g.indexOf("-->")!==-1;if(!g||v&&(d=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
|
|
`),r.cue.text+=g}continue;case"BADCUE":g||(r.state="ID")}}}catch(h){r.state==="CUETEXT"&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},E.flush=function(){var c=this;try{if((c.cue||c.state==="HEADER")&&(c.buffer+=`
|
|
|
|
`,c.parse()),c.state==="INITIAL"||c.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){c.onparsingerror&&c.onparsingerror(r)}return c.onflush&&c.onflush(),this},b}()},"./src/utils/webvtt-parser.ts":function(de,F,S){"use strict";S.r(F),S.d(F,"generateCueId",function(){return C}),S.d(F,"parseWebVTT",function(){return E});var B=S("./src/polyfills/number.ts"),_=S("./src/utils/vttparser.ts"),R=S("./src/demux/id3.ts"),N=S("./src/utils/timescale-conversion.ts"),M=S("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,w=function(c,r,a){return a===void 0&&(a=0),c.substr(a,r.length)===r},m=function(c){var r=parseInt(c.substr(-3)),a=parseInt(c.substr(-6,2)),o=parseInt(c.substr(-9,2)),g=c.length>9?parseInt(c.substr(0,c.indexOf(":"))):0;if(!Object(B.isFiniteNumber)(r)||!Object(B.isFiniteNumber)(a)||!Object(B.isFiniteNumber)(o)||!Object(B.isFiniteNumber)(g))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+c);return r+=1e3*a,r+=60*1e3*o,r+=60*60*1e3*g,r},T=function(c){for(var r=5381,a=c.length;a;)r=r*33^c.charCodeAt(--a);return(r>>>0).toString()};function C(y,c,r){return T(y.toString())+T(c.toString())+T(r)}var b=function(c,r,a){var o=c[r],g=c[o.prevCC];if(!g||!g.new&&o.new){c.ccOffset=c.presentationOffset=o.start,o.new=!1;return}for(;(l=g)!==null&&l!==void 0&&l.new;){var l;c.ccOffset+=o.start-g.start,o.new=!1,o=g,g=c[o.prevCC]}c.presentationOffset=a};function E(y,c,r,a,o,g,l,d){var v=new _.VTTParser,h=Object(R.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(O,`
|
|
`).split(`
|
|
`),u=[],n=Object(N.toMpegTsClockFromTimescale)(c,r),e="00:00.000",t=0,f=0,p,x=!0,A=!1;v.oncue=function(I){var U=a[o],j=a.ccOffset,z=(t-n)/9e4;if(U!=null&&U.new&&(f!==void 0?j=a.ccOffset=U.start:b(a,o,z)),z&&(j=z-a.presentationOffset),A){var V=I.endTime-I.startTime,G=Object(M.normalizePts)((I.startTime+j-f)*9e4,g*9e4)/9e4;I.startTime=G,I.endTime=G+V}var Q=I.text.trim();I.text=decodeURIComponent(encodeURIComponent(Q)),I.id||(I.id=C(I.startTime,I.endTime,Q)),I.endTime>0&&u.push(I)},v.onparsingerror=function(I){p=I},v.onflush=function(){if(p){d(p);return}l(u)},h.forEach(function(I){if(x)if(w(I,"X-TIMESTAMP-MAP=")){x=!1,A=!0,I.substr(16).split(",").forEach(function(U){w(U,"LOCAL:")?e=U.substr(6):w(U,"MPEGTS:")&&(t=parseInt(U.substr(7)))});try{f=m(e)/1e3}catch(U){A=!1,p=U}return}else I===""&&(x=!1);v.parse(I+`
|
|
`)}),v.flush()}},"./src/utils/xhr-loader.ts":function(de,F,S){"use strict";S.r(F);var B=S("./src/utils/logger.ts"),_=S("./src/loader/load-stats.ts"),R=/^age:\s*[\d.]+\s*$/m,N=function(){function M(w){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=w?w.xhrSetup:null,this.stats=new _.LoadStats,this.retryDelay=0}var O=M.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var m=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),m&&(m.onreadystatechange=null,m.onprogress=null,m.readyState!==4&&(this.stats.aborted=!0,m.abort()))},O.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(m,T,C){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=m,this.config=T,this.callbacks=C,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var m=this.config,T=this.context;if(!m)return;var C=this.loader=new self.XMLHttpRequest,b=this.stats;b.loading.first=0,b.loaded=0;var E=this.xhrSetup;try{if(E)try{E(C,T.url)}catch(r){C.open("GET",T.url,!0),E(C,T.url)}C.readyState||C.open("GET",T.url,!0);var y=this.context.headers;if(y)for(var c in y)C.setRequestHeader(c,y[c])}catch(r){this.callbacks.onError({code:C.status,text:r.message},T,C);return}T.rangeEnd&&C.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),C.onreadystatechange=this.readystatechange.bind(this),C.onprogress=this.loadprogress.bind(this),C.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout),C.send()},O.readystatechange=function(){var m=this.context,T=this.loader,C=this.stats;if(!m||!T)return;var b=T.readyState,E=this.config;if(C.aborted)return;if(b>=2)if(self.clearTimeout(this.requestTimeout),C.loading.first===0&&(C.loading.first=Math.max(self.performance.now(),C.loading.start)),b===4){T.onreadystatechange=null,T.onprogress=null;var y=T.status;if(y>=200&&y<300){C.loading.end=Math.max(self.performance.now(),C.loading.first);var c,r;if(m.responseType==="arraybuffer"?(c=T.response,r=c.byteLength):(c=T.responseText,r=c.length),C.loaded=C.total=r,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(C,m,c,T),!this.callbacks)return;var o={url:T.responseURL,data:c};this.callbacks.onSuccess(o,C,m,T)}else C.retry>=E.maxRetry||y>=400&&y<499?(B.logger.error(y+" while loading "+m.url),this.callbacks.onError({code:y,text:T.statusText},m,T)):(B.logger.warn(y+" while loading "+m.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,E.maxRetryDelay),C.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout)},O.loadtimeout=function(){B.logger.warn("timeout while loading "+this.context.url);var m=this.callbacks;m&&(this.abortInternal(),m.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(m){var T=this.stats;T.loaded=m.loaded,m.lengthComputable&&(T.total=m.total)},O.getCacheAge=function(){var m=null;if(this.loader&&R.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");m=T?parseFloat(T):null}return m},M}();F.default=N}}).default})},vHTk:function(Je,Xe,ee){Je.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);
|