You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__RestFul.04ce41ec.async.js

330 lines
696 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[204,5,7],{"55Ip":function(nt,We,J){"use strict";J.d(We,"a",function(){return a}),J.d(We,"b",function(){return c});var ce=J("Ty5D"),U=J("dI71"),S=J("q1tI"),B=J.n(S),O=J("YS25"),A=J("17x9"),_=J.n(A),M=J("wx14"),L=J("zLVn"),w=J("9R94"),y=function(r){Object(U.a)(t,r);function t(){for(var m,g=arguments.length,T=new Array(g),P=0;P<g;P++)T[P]=arguments[P];return m=r.call.apply(r,[this].concat(T))||this,m.history=Object(O.a)(m.props),m}var s=t.prototype;return s.render=function(){return B.a.createElement(ce.c,{history:this.history,children:this.props.children})},t}(B.a.Component),x=function(r){Object(U.a)(t,r);function t(){for(var m,g=arguments.length,T=new Array(g),P=0;P<g;P++)T[P]=arguments[P];return m=r.call.apply(r,[this].concat(T))||this,m.history=Object(O.b)(m.props),m}var s=t.prototype;return s.render=function(){return B.a.createElement(ce.c,{history:this.history,children:this.props.children})},t}(B.a.Component),C=function(t,s){return typeof t=="function"?t(s):t},E=function(t,s){return typeof t=="string"?Object(O.c)(t,null,null,s):t},b=function(t){return t},v=B.a.forwardRef;typeof v=="undefined"&&(v=b);function h(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}var e=v(function(r,t){var s=r.innerRef,m=r.navigate,g=r.onClick,T=Object(L.a)(r,["innerRef","navigate","onClick"]),P=T.target,I=Object(M.a)({},T,{onClick:function(K){try{g&&g(K)}catch(V){throw K.preventDefault(),V}!K.defaultPrevented&&K.button===0&&(!P||P==="_self")&&!h(K)&&(K.preventDefault(),m())}});return b!==v?I.ref=t||s:I.ref=s,B.a.createElement("a",I)}),a=v(function(r,t){var s=r.component,m=s===void 0?e:s,g=r.replace,T=r.to,P=r.innerRef,I=Object(L.a)(r,["component","replace","to","innerRef"]);return B.a.createElement(ce.e.Consumer,null,function(F){F||Object(w.a)(!1);var K=F.history,V=E(C(T,F.location),F.location),Q=V?K.createHref(V):"",Z=Object(M.a)({},I,{href:Q,navigate:function(){var pe=C(T,F.location),ae=g?K.replace:K.push;ae(pe)}});return b!==v?Z.ref=t||P:Z.innerRef=P,B.a.createElement(m,Z)})});if(!1)var o,f;var d=function(t){return t},u=B.a.forwardRef;typeof u=="undefined"&&(u=d);function p(){for(var r=arguments.length,t=new Array(r),s=0;s<r;s++)t[s]=arguments[s];return t.filter(function(m){return m}).join(" ")}var c=u(function(r,t){var s=r["aria-current"],m=s===void 0?"page":s,g=r.activeClassName,T=g===void 0?"active":g,P=r.activeStyle,I=r.className,F=r.exact,K=r.isActive,V=r.location,Q=r.sensitive,Z=r.strict,ie=r.style,pe=r.to,ae=r.innerRef,de=Object(L.a)(r,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return B.a.createElement(ce.e.Consumer,null,function(le){le||Object(w.a)(!1);var $=V||le.location,Y=E(C(pe,$),$),ne=Y.pathname,z=ne&&ne.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),H=z?Object(ce.f)($.pathname,{path:z,exact:F,sensitive:Q,strict:Z}):null,me=!!(K?K(H,$):H),Le=me?p(I,T):I,Oe=me?Object(M.a)({},ie,{},P):ie,Ae=Object(M.a)({"aria-current":me&&m||null,className:Le,style:Oe,to:Y},de);return d!==u?Ae.ref=t||ae:Ae.innerRef=ae,B.a.createElement(a,Ae)})});if(!1)var i},"815F":function(nt,We,J){"use strict";J.d(We,"e",function(){return _}),J.d(We,"c",function(){return L}),J.d(We,"d",function(){return w}),J.d(We,"a",function(){return x}),J.d(We,"f",function(){return C}),J.d(We,"b",function(){return E});var ce=J("KQm4"),U=J("VTBJ"),S=J("Ff2n"),B=J("Zm9Q"),O=J("Kwbf"),A=J("OZM5");function _(b,v){return b!=null?b:v}function M(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],v=new Map;function h(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";(e||[]).forEach(function(o){var f=o.key,d=o.children;Object(O.a)(f!=null,"Tree node must have a certain key: [".concat(a).concat(f,"]"));var u=String(f);Object(O.a)(!v.has(u)||f===null||f===void 0,"Same 'key' exist in the Tree: ".concat(u)),v.set(u,!0),h(d,"".concat(a).concat(u," > "))})}h(b)}function L(b){function v(h){var e=Object(B.a)(h);return e.map(function(a){if(!Object(A.i)(a))return Object(O.a)(!a,"Tree/TreeNode can only accept TreeNode as children."),null;var o=a.key,f=a.props,d=f.children,u=Object(S.a)(f,["children"]),p=Object(U.a)({key:o},u),c=v(d);return c.length&&(p.children=c),p}).filter(function(a){return a})}return v(b)}function w(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],h=new Set(v===!0?[]:v),e=[];function a(o){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return o.map(function(d,u){var p=Object(A.h)(f?f.pos:"0",u),c=_(d.key,p),i=Object(U.a)(Object(U.a)({},d),{},{parent:f,pos:p,children:null,data:d,isStart:[].concat(Object(ce.a)(f?f.isStart:[]),[u===0]),isEnd:[].concat(Object(ce.a)(f?f.isEnd:[]),[u===o.length-1])});return e.push(i),v===!0||h.has(c)?i.children=a(d.children||[],i):i.children=[],i})}return a(b),e}function y(b,v,h){var e;h?typeof h=="string"?e=function(f){return f[h]}:typeof h=="function"&&(e=function(f){return h(f)}):e=function(f,d){return _(f.key,d)};function a(o,f,d){var u=o?o.children:b,p=o?Object(A.h)(d.pos,f):"0";if(o){var c=e(o,p),i={node:o,index:f,pos:p,key:c,parentPos:d.node?d.pos:null,level:d.level+1};v(i)}u&&u.forEach(function(r,t){a(r,t,{node:o,pos:p,level:d?d.level+1:-1})})}a(null)}function x(b){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=v.initWrapper,e=v.processEntity,a=v.onProcessFinished,o=arguments.length>2?arguments[2]:void 0,f={},d={},u={posEntities:f,keyEntities:d};return h&&(u=h(u)||u),y(b,function(p){var c=p.node,i=p.index,r=p.pos,t=p.key,s=p.parentPos,m=p.level,g={node:c,index:i,key:t,pos:r,level:m},T=_(t,r);f[r]=g,d[T]=g,g.parent=f[s],g.parent&&(g.parent.children=g.parent.children||[],g.parent.children.push(g)),e&&e(g,u)},o),a&&a(u),u}function C(b,v){var h=v.expandedKeys,e=v.selectedKeys,a=v.loadedKeys,o=v.loadingKeys,f=v.checkedKeys,d=v.halfCheckedKeys,u=v.dragOverNodeKey,p=v.dropPosition,c=v.keyEntities,i=c[b],r={eventKey:b,expanded:h.indexOf(b)!==-1,selected:e.indexOf(b)!==-1,loaded:a.indexOf(b)!==-1,loading:o.indexOf(b)!==-1,checked:f.indexOf(b)!==-1,halfChecked:d.indexOf(b)!==-1,pos:String(i?i.pos:""),dragOver:u===b&&p===0,dragOverGapTop:u===b&&p===-1,dragOverGapBottom:u===b&&p===1};return r}function E(b){var v=b.data,h=b.expanded,e=b.selected,a=b.checked,o=b.loaded,f=b.loading,d=b.halfChecked,u=b.dragOver,p=b.dragOverGapTop,c=b.dragOverGapBottom,i=b.pos,r=b.active,t=Object(U.a)(Object(U.a)({},v),{},{expanded:h,selected:e,checked:a,loaded:o,loading:f,halfChecked:d,dragOver:u,dragOverGapTop:p,dragOverGapBottom:c,pos:i,active:r});return"props"in t||Object.defineProperty(t,"props",{get:function(){return Object(O.a)(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),b}}),t}},"8Jsi":function(nt,We,J){"use strict";J.d(We,"d",function(){return s}),J.d(We,"a",function(){return Oe}),J.d(We,"b",function(){return Re}),J.d(We,"c",function(){return Ae});var ce=J("1OyB"),U=J("vuIU"),S=J("Ji7U"),B=J("LK+K"),O=J("KQm4"),A=J("U8pU"),_=J("ODXe"),M=J("VTBJ"),L=J("q1tI"),w=J("qNPg"),y=J("2Qr1"),x=J("815F"),C=J("NvD2"),E=J("wPlo"),b=J("6cGi"),v=J("Kwbf"),h=J("4IlW"),e=J("YrtM"),a=J("fAei"),o=L.createContext(null);function f(se,ue){if(!se)return!0;var be=se.data,Ee=be.disabled,Ce=be.disableCheckbox;switch(ue){case"select":return Ee;case"checkbox":return Ee||Ce}return!1}function d(se,ue){var be=L.useCallback(function(Ce){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"select",ve=arguments.length>2?arguments[2]:void 0,Ie=se.get(Ce);return!ve&&f(Ie,Te)?null:Ie},[se]),Ee=L.useCallback(function(Ce){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"select",ve=arguments.length>2?arguments[2]:void 0,Ie=ue.get(Ce);return!ve&&f(Ie,Te)?null:Ie},[ue]);return[be,Ee]}function u(se){return L.useMemo(function(){var ue=new Map,be=new Map;return se.forEach(function(Ee){ue.set(Ee.key,Ee),be.set(Ee.data.value,Ee)}),[ue,be]},[se])}var p={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},c=function(ue,be){var Ee=ue.prefixCls,Ce=ue.height,Te=ue.itemHeight,ve=ue.virtual,Ie=ue.options,Be=ue.flattenOptions,ge=ue.multiple,Me=ue.searchValue,re=ue.onSelect,q=ue.onToggleOpen,te=ue.open,j=ue.notFoundContent,W=ue.onMouseEnter,G=L.useContext(o),X=G.checkable,oe=G.checkedKeys,he=G.halfCheckedKeys,ke=G.treeExpandedKeys,He=G.treeDefaultExpandAll,$e=G.treeDefaultExpandedKeys,ze=G.onTreeExpand,Ze=G.treeIcon,et=G.showTreeIcon,Xe=G.switcherIcon,mt=G.treeLine,rt=G.treeNodeFilterProp,vt=G.loadData,ct=G.treeLoadedKeys,qe=G.treeMotion,yt=G.onTreeLoad,bt=L.useRef(),Ve=Object(e.a)(function(){return Ie},[te,Ie],function(je,we){return we[0]&&je[1]!==we[1]}),wt=u(Be),at=Object(_.a)(wt,2),ut=at[0],At=at[1],St=d(ut,At),Rt=Object(_.a)(St,2),it=Rt[0],Qe=Rt[1],Ye=L.useMemo(function(){return oe.map(function(je){var we=Qe(je);return we?we.key:null})},[oe]),ot=L.useMemo(function(){return X?{checked:Ye,halfChecked:he}:null},[Ye,he,X]);L.useEffect(function(){if(te&&!ge&&Ye.length){var je;(je=bt.current)===null||je===void 0||je.scrollTo({key:Ye[0]})}},[te]);var dt=String(Me).toLowerCase(),tt=function(we){return dt?String(we[rt]).toLowerCase().includes(dt):!1},st=L.useState($e),ft=Object(_.a)(st,2),Ot=ft[0],Ft=ft[1],_t=L.useState(null),Wt=Object(_.a)(_t,2),jt=Wt[0],Vt=Wt[1],Ht=L.useMemo(function(){return ke?Object(O.a)(ke):Me?jt:Ot},[Ot,jt,dt,ke]);L.useEffect(function(){Me&&Vt(Be.map(function(je){return je.key}))},[Me]);var k=function(we){Ft(we),Vt(we),ze&&ze(we)},n=function(we){we.preventDefault()},l=function(we,Ge){var Ke=Ge.node.key,Je=it(Ke,X?"checkbox":"select");Je!==null&&re(Je.data.value,{selected:!oe.includes(Je.data.value)}),ge||q(!1)},D=L.useState(null),N=Object(_.a)(D,2),R=N[0],ee=N[1],De=it(R);if(L.useImperativeHandle(be,function(){return{onKeyDown:function(we){var Ge,Ke=we.which;switch(Ke){case h.a.UP:case h.a.DOWN:case h.a.LEFT:case h.a.RIGHT:(Ge=bt.current)===null||Ge===void 0||Ge.onKeyDown(we);break;case h.a.ENTER:{De!==null&&l(null,{node:{key:R},selected:!oe.includes(De.data.value)});break}case h.a.ESC:q(!1)}},onKeyUp:function(){}}}),Ve.length===0)return L.createElement("div",{role:"listbox",className:"".concat(Ee,"-empty"),onMouseDown:n},j);var Ue={};return ct&&(Ue.loadedKeys=ct),Ht&&(Ue.expandedKeys=Ht),L.createElement("div",{onMouseDown:n,onMouseEnter:W},De&&te&&L.createElement("span",{style:p,"aria-live":"assertive"},De.data.value),L.createElement(a.b,Object.assign({ref:bt,focusable:!1,prefixCls:"".concat(Ee,"-tree"),treeData:Ve,height:Ce,itemHeight:Te,virtual:ve,multiple:ge,icon:Ze,showIcon:et,switcherIcon:Xe,showLine:mt,loadData:Me?null:vt,motion:qe,checkable:X,checkStrictly:!0,checkedKeys:ot,selectedKeys:X?[]:Ye,defaultExpandAll:He},Ue,{onActiveChange:ee,onSelect:l,onCheck:l,onExpand:k,onLoad:yt,filterTreeNode:tt})))},i=L.forwardRef(c);i.displayName="OptionList";var r=i,t=function(){return null},s=t,m=J("Ff2n"),g=J("Zm9Q");function T(se){return Object(g.a)(se).map(function(ue){if(!L.isValidElement(ue)||!ue.type)return null;var be=ue.key,Ee=ue.props,Ce=Ee.children,Te=Ee.value,ve=Object(m.a)(Ee,["children","value"]),Ie=Object(M.a)({key:be,value:Te},ve),Be=T(Ce);return Be.length&&(Ie.children=Be),Ie}).filter(function(ue){return ue})}function P(se){if(!se)return se;var ue=Object(M.a)({},se);return"props"in ue||Object.defineProperty(ue,"props",{get:function(){return Object(v.a)(!1,"New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."),ue}}),ue}function I(se,ue,be,Ee,Ce){var Te=null,ve=null;function Ie(){function Be(ge){var Me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"0",re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return ge.map(function(q,te){var j="".concat(Me,"-").concat(te),W=be.includes(q.value),G=Be(q.children||[],j,W),X=L.createElement(s,Object.assign({},q),G.map(function(he){return he.node}));if(ue===q.value&&(Te=X),W){var oe={pos:j,node:X,children:G};return re||ve.push(oe),oe}return null}).filter(function(q){return q})}ve||(ve=[],Be(Ee),ve.sort(function(ge,Me){var re=ge.node.props.value,q=Me.node.props.value,te=be.indexOf(re),j=be.indexOf(q);return te-j}))}Object.defineProperty(se,"triggerNode",{get:function(){return Object(v.a)(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),Ie(),Te}}),Object.defineProperty(se,"allCheckedNodes",{get:function(){return Object(v.a)(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),Ie(),Ce?ve:ve.map(function(ge){var Me=ge.node;return Me})}})}function F(se){return Array.isArray(se)?se:se!==void 0?[se]:[]}function K(se,ue){var be=new Map;return ue.forEach(function(Ee){var Ce=Ee.data;be.set(Ce.value,Ce)}),se.map(function(Ee){return P(be.get(Ee))})}function V(se,ue){var be=K([se],ue)[0];return be?be.disabled:!1}function Q(se){return se.disabled||se.disableCheckbox||se.checkable===!1}function Z(se){for(var ue=se.parent,be=0,Ee=ue;Ee;)Ee=Ee.parent,be+=1;return be}function ie(se){function ue(Ee){return(Ee||[]).map(function(Ce){var Te=Ce.value,ve=Ce.key,Ie=Ce.children,Be=Object(M.a)(Object(M.a)({},Ce),{},{key:"key"in Ce?ve:Te});return Ie&&(Be.children=ue(Ie)),Be})}var be=Object(x.d)(ue(se),!0);return be.map(function(Ee){return{key:Ee.data.key,data:Ee.data,level:Z(Ee)}})}function pe(se){return function(ue,be){var Ee=be[se];return String(Ee).toLowerCase().includes(String(ue).toLowerCase())}}function ae(se,ue,be){var Ee=be.optionFilterProp,Ce=be.filterOption;if(Ce===!1)return ue;var Te;typeof Ce=="function"?Te=Ce:Te=pe(Ee);function ve(Ie){var Be=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Ie.map(function(ge){var Me=ge.children,re=Be||Te(se,P(ge)),q=ve(Me||[],re);return re||q.length?Object(M.a)(Object(M.a)({},ge),{},{children:q}):null}).filter(function(ge){return ge})}return ve(ue)}function de(se,ue,be,Ee){var Ce=new Map;return F(ue).forEach(function(Te){Te&&Object(A.a)(Te)==="object"&&"value"in Te&&Ce.set(Te.value,Te)}),se.map(function(Te){var ve={value:Te},Ie=be(Te,"select",!0),Be=Ie?Ee(Ie.data):Te;if(Ce.has(Te)){var ge=Ce.get(Te);ve.label="label"in ge?ge.label:Be,"halfChecked"in ge&&(ve.halfChecked=ge.halfChecked)}else ve.label=Be;return ve})}function le(se,ue){var be=new Set(se);return be.add(ue),Array.from(be)}function $(se,ue){var be=new Set(se);return be.delete(ue),Array.from(be)}function Y(se){var ue=se.searchPlaceholder,be=se.treeCheckStrictly,Ee=se.treeCheckable,Ce=se.labelInValue,Te=se.value,ve=se.multiple;Object(v.a)(!ue,"`searchPlaceholder` has been removed."),be&&Ce===!1&&Object(v.a)(!1,"`treeCheckStrictly` will force set `labelInValue` to `true`."),(Ce||be)&&Object(v.a)(F(Te).every(function(Ie){return Ie&&Object(A.a)(Ie)==="object"&&"value"in Ie}),"Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."),be||ve||Ee?Object(v.a)(!Te||Array.isArray(Te),"`value` should be an array when `TreeSelect` is checkable or multiple."):Object(v.a)(!Array.isArray(Te),"`value` should not be array when `TreeSelect` is single mode.")}var ne=Y,z=10;function H(se,ue){var be=ue.id,Ee=ue.pId,Ce=ue.rootPId,Te={},ve=[],Ie=se.map(function(Be){var ge=Object(M.a)({},Be),Me=ge[be];return Te[Me]=ge,ge.key=ge.key||Me,ge});return Ie.forEach(function(Be){var ge=Be[Ee],Me=Te[ge];Me&&(Me.children=Me.children||[],Me.children.push(Be)),(ge===Ce||!Me&&Ce===null)&&ve.push(Be)}),ve}function me(se,ue){var be=0,Ee=new Set;function Ce(Te){return(Te||[]).map(function(ve){var Ie=ve.key,Be=ve.value,ge=ve.children,Me=Object(m.a)(ve,["key","value","children"]),re="value"in ve?Be:Ie,q=Object(M.a)(Object(M.a)({},Me),{},{key:Ie!=null?Ie:re,value:re,title:ue(ve)});return"children"in ve&&(q.children=Ce(ge)),q})}return Ce(se)}function Le(se,ue,be){var Ee=be.getLabelProp,Ce=be.simpleMode,Te=L.useRef({});return se?(Te.current.formatTreeData=Te.current.treeData===se?Te.current.formatTreeData:me(Ce?H(se,Object(M.a)({id:"id",pId:"pId",rootPId:null},Ce!==!0?Ce:{})):se,Ee),Te.current.treeData=se):Te.current.formatTreeData=Te.current.children===ue?Te.current.formatTreeData:me(T(ue),Ee),Te.current.formatTreeData}var Oe="SHOW_ALL",Ae="SHOW_PARENT",Re="SHOW_CHILD";function fe(se,ue,be){var Ee=new Set(se);return ue===Re?se.filter(function(Ce){var Te=be[Ce];return!(Te&&Te.children&&Te.children.every(function(ve){var Ie=ve.node;return Q(Ie)||Ee.has(Ie.key)}))}):ue===Ae?se.filter(function(Ce){var Te=be[Ce],ve=Te?Te.parent:null;return!(ve&&!Q(ve.node)&&Ee.has(ve.node.key))}):se}function ye(se,ue){var be=ue.value,Ee=ue.getEntityByValue,Ce=ue.getEntityByKey,Te=ue.treeConduction,ve=ue.showCheckedStrategy,Ie=ue.conductKeyEntities,Be=ue.getLabelProp;return L.useMemo(function(){var ge=se;if(Te){var Me=fe(se.map(function(re){var q=Ee(re);return q?q.key:re}),ve,Ie);ge=Me.map(function(re){var q=Ce(re);return q?q.data.value:re})}return de(ge,be,Ee,Be)},[se,be,Te,ve,Ee])}var xe=["expandedKeys","treeData","treeCheckable","showCheckedStrategy","searchPlaceholder","treeLine","treeIcon","showTreeIcon","switcherIcon","treeNodeFilterProp","filterTreeNode","dropdownPopupAlign","treeDefaultExpandAll","treeCheckStrictly","treeExpandedKeys","treeLoadedKeys","treeMotion","onTreeExpand","onTreeLoad","loadData","treeDataSimpleMode","treeNodeLabelProp","treeDefaultExpandedKeys"],Se=Object(w.a)({prefixCls:"rc-tree-select",components:{optionList:r},convertChildrenToData:function(){return null},flattenOptions:ie,getLabeledValue:y.e,filterOptions:ae,isValueDisabled:V,findValueOption:K,omitDOMProps:function(ue){var be=Object(M.a)({},ue);return xe.forEach(function(Ee){delete be[Ee]}),be}});Se.displayName="Select";var Ne=L.forwardRef(function(se,ue){var be=se.multiple,Ee=se.treeCheckable,Ce=se.treeCheckStrictly,Te=se.showCheckedStrategy,ve=Te===void 0?"SHOW_CHILD":Te,Ie=se.labelInValue,Be=se.loadData,ge=se.treeLoadedKeys,Me=se.treeNodeFilterProp,re=Me===void 0?"value":Me,q=se.treeNodeLabelProp,te=se.treeDataSimpleMode,j=se.treeData,W=se.treeExpandedKeys,G=se.treeDefaultExpandedKeys,X=se.treeDefaultExpandAll,oe=se.children,he=se.treeIcon,ke=se.showTreeIcon,He=se.switcherIcon,$e=se.treeLine,ze=se.treeMotion,Ze=se.filterTreeNode,et=se.dropdownPopupAlign,Xe=se.onChange,mt=se.onTreeExpand,rt=se.onTreeLoad,vt=se.onDropdownVisibleChange,ct=se.onSelect,qe=se.onDeselect,yt=Ee||Ce,bt=be||yt,Ve=Ee&&!Ce,wt=Ce||Ie,at=L.useRef(null);L.useImperativeHandle(ue,function(){return{focus:at.current.focus,blur:at.current.blur}});var ut=function(Ke){return j&&Ke.label||Ke.title},At=function(Ke){return q?Ke[q]:ut(Ke)},St=Le(j,oe,{getLabelProp:ut,simpleMode:te}),Rt=Object(L.useMemo)(function(){return ie(St)},[St]),it=u(Rt),Qe=Object(_.a)(it,2),Ye=Qe[0],ot=Qe[1],dt=d(Ye,ot),tt=Object(_.a)(dt,2),st=tt[0],ft=tt[1],Ot=Object(L.useMemo)(function(){return Ve?Object(x.a)(St):{keyEntities:null}},[St,Ee,Ce]),Ft=Ot.keyEntities,_t=Object(b.a)(se.defaultValue,{value:se.value}),Wt=Object(_.a)(_t,2),jt=Wt[0],Vt=Wt[1],Ht=function(Ke){var Je=[],xt=[];return Ke.forEach(function(gt){ft(gt)?xt.push(gt):Je.push(gt)}),{missingRawValues:Je,existRawValues:xt}},k=Object(L.useMemo)(function(){var Ge=[],Ke=[];if(F(jt).forEach(function(pt){if(pt&&Object(A.a)(pt)==="object"&&"value"in pt)if(pt.halfChecked&&Ce){var Lt=ft(pt.value);Ge.push(Lt?Lt.key:pt.value)}else Ke.push(pt.value);else Ke.push(pt)}),Ve){var Je=Ht(Ke),xt=Je.missingRawValues,gt=Je.existRawValues,Et=gt.map(function(pt){return ft(pt).key}),Ct=Object(C.a)(Et,!0,Ft),Kt=Ct.checkedKeys,Nt=Ct.halfCheckedKeys;return[[].concat(Object(O.a)(xt),Object(O.a)(Kt.map(function(pt){return st(pt).data.value}))),Nt]}return[Ke,Ge]},[jt,bt,wt,Ee,Ce]),n=Object(_.a)(k,2),l=n[0],D=n[1],N=ye(l,{treeConduction:Ve,value:jt,showCheckedStrategy:ve,conductKeyEntities:Ft,getEntityByValue:ft,getEntityByKey:st,getLabelProp:At}),R=function(Ke,Je,xt){if(Vt(bt?Ke:Ke[0]),Xe){var gt=Ke;if(Ve&&ve!=="SHOW_ALL"){var Et=Ke.map(function(Dt){var It=ft(Dt);return It?It.key:Dt}),Ct=fe(Et,ve,Ft);gt=Ct.map(function(Dt){var It=st(Dt);return It?It.data.value:Dt})}var Kt=Je||{triggerValue:void 0,selected:void 0},Nt=Kt.triggerValue,pt=Kt.selected,Lt=wt?de(gt,jt,ft,At):gt;if(Ce){var Gt=D.map(function(Dt){var It=st(Dt);return It?It.data.value:Dt}).filter(function(Dt){return!gt.includes(Dt)});Lt=[].concat(Object(O.a)(Lt),Object(O.a)(de(Gt,jt,ft,At)))}var kt={preValue:N,triggerValue:Nt},Xt=!0;(Ce||xt==="selection"&&!pt)&&(Xt=!1),I(kt,Nt,Ke,St,Xt),yt?kt.checked=pt:kt.selected=pt,Xe(bt?Lt:Lt[0],wt?null:gt.map(function(Dt){var It=ft(Dt);return It?At(It.data):null}),kt)}},ee=function(Ke,Je,xt){var gt=Ke;if(!bt)R([Ke],{selected:!0,triggerValue:Ke},xt);else{var Et=le(l,Ke);if(Ve){var Ct=Ht(Et),Kt=Ct.missingRawValues,Nt=Ct.existRawValues,pt=Nt.map(function(kt){return ft(kt).key}),Lt=Object(C.a)(pt,!0,Ft),Gt=Lt.checkedKeys;Et=[].concat(Object(O.a)(Kt),Object(O.a)(Gt.map(function(kt){return st(kt).data.value})))}R(Et,{selected:!0,triggerValue:Ke},xt)}ct&&ct(gt,Je)},De=function(Ke,Je,xt){var gt=Ke,Et=$(l,Ke);if(Ve){var Ct=Ht(Et),Kt=Ct.missingRawValues,Nt=Ct.existRawValues,pt=Nt.map(function(kt){return ft(kt).key}),Lt=Object(C.a)(pt,{checked:!1,halfCheckedKeys:D},Ft),Gt=Lt.checkedKeys;Et=[].concat(Object(O.a)(Kt),Object(O.a)(Gt.map(function(kt){return st(kt).data.value})))}R(Et,{selected:!1,triggerValue:Ke},xt),qe&&qe(gt,Je)},Ue=function(){R([],null,"clear")},je=L.useCallback(function(Ge){if(vt){var Ke={};Object.defineProperty(Ke,"documentClickClose",{get:function(){return Object(v.a)(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),vt(Ge,Ke)}},[vt]),we={optionLabelProp:null,optionFilterProp:re,dropdownAlign:et,internalProps:{mark:E.a,onClear:Ue,skipTriggerChange:!0,skipTriggerSelect:!0,onRawSelect:ee,onRawDeselect:De}};return"filterTreeNode"in se&&(we.filterOption=Ze),L.createElement(o.Provider,{value:{checkable:yt,loadData:Be,treeLoadedKeys:ge,onTreeLoad:rt,checkedKeys:l,halfCheckedKeys:D,treeDefaultExpandAll:X,treeExpandedKeys:W,treeDefaultExpandedKeys:G,onTreeExpand:mt,treeIcon:he,treeMotion:ze,showTreeIcon:ke,switcherIcon:He,treeLine:$e,treeNodeFilterProp:re}},L.createElement(Se,Object.assign({ref:at,mode:bt?"multiple":null},se,we,{value:N,labelInValue:!0,options:St,onChange:null,onSelect:null,onDeselect:null,onDropdownVisibleChange:je})))}),Pe=function(se){Object(S.a)(be,se);var ue=Object(B.a)(be);function be(){var Ee;return Object(ce.a)(this,be),Ee=ue.apply(this,arguments),Ee.selectRef=L.createRef(),Ee.focus=function(){Ee.selectRef.current.focus()},Ee.blur=function(){Ee.selectRef.current.blur()},Ee}return Object(U.a)(be,[{key:"render",value:function(){return L.createElement(Ne,Object.assign({ref:this.selectRef},this.props))}}]),be}(L.Component);Pe.TreeNode=s,Pe.SHOW_ALL=Oe,Pe.SHOW_PARENT=Ae,Pe.SHOW_CHILD=Re;var _e=Pe,Fe=We.e=_e},"8hTe":function(nt,We,J){nt.exports={button:"button___1wy9m"}},"9Bee":function(nt,We,J){"use strict";var ce=J("DYRE"),U=J("zeV3"),S=J("+L6B"),B=J("2/Rp"),O=J("k1fw"),A=J("9og8"),_=J("tJVT"),M=J("WmNS"),L=J.n(M),w=J("q1tI"),y=J.n(w),x=J("vg9a"),C=J("DlQD"),E=J.n(C),b=J("rUJ1");function v(k,n){var l=k.match(/^(\s+)(?:```)/);if(l===null)return n;var D=l[1];return n.split(`
`).map(function(N){var R=N.match(/^\s+/);if(R===null)return N;var ee=Object(_.a)(R,1),De=ee[0];return De.length>=D.length?N.slice(D.length):N}).join(`
`)}var h=[],e=["<ul>"],a=new E.a.Renderer,o=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function f(){h.length=0,e=["<ul>"]}var d={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function u(k,n,l,D){if(n>=k.length||k[n].level<=l)return n;var N=k[n];D.push("<li><a href='#"+N.anchor+"'>"+N.text+"</a>"),n++;var R=[];return n=u(k,n,N.level,R),R.length>0&&(D.push("<ul>"),R.forEach(function(ee){D.push(ee)}),D.push("</ul>")),D.push("</li>"),n=u(k,n,l,D),n}function p(){return u(h,0,0,e),e.push("</ul>"),e.join("")}var c={heading:function(n){var l=o.exec(n);if(l)return{type:"heading",raw:l[0],depth:l[1].length,text:l[2]}},fences:function(n){var l=this.rules.block.fences.exec(n);if(l){var D=l[0],N=v(D,l[3]||""),R=l[2]?l[2].trim():l[2];if(["latex","katex","math"].indexOf(R)>=0){var ee=t(),De=N;N=ee,s[ee]={type:"block",expression:De}}return{type:"code",raw:D,lang:R,text:N}}}},i=/(?:\${2})([^\n`]+?)(?:\${2})/gi,r=0,t=function(){return"__special_katext_id_".concat(r++,"__")},s={};function m(){return s}function g(){r=0,s={}}function T(k){return k=k.replace(i,function(n,l){var D=t();return s[D]={type:"inline",expression:l},D}),k}var P=a.listitem;a.listitem=function(k){return P(T(k))};var I=a.paragraph;a.paragraph=function(k){return I(T(k))};var F=a.tablecell;a.tablecell=function(k,n){return F(T(k),n)},a.code=function(k,n,l){var D=(n||"").match(/\S*/)[0];return D?["latex","katex","math"].indexOf(D)>=0?"<p class='editormd-tex'>".concat(k,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(n,'">').concat(l?k:Object(b.escape)(k,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(l?k:Object(b.escape)(k,!0))+"</code></pre>"},a.heading=function(k,n,l){var D=this.options.headerPrefix+l.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return h.push({anchor:D,level:n,text:k}),"<h"+n+' id="'+D+'">'+k+"</h"+n+">"},E.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),E.a.use({tokenizer:c,renderer:a});var K=E.a,V=J("SJMd"),Q=J("ulZh"),Z=J.n(Q),ie=J("m3rI"),pe=J("Oy/b"),ae=J("p5ED"),de=J("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 le=function(k,n){return(le=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,D){l.__proto__=D}||function(l,D){for(var N in D)Object.prototype.hasOwnProperty.call(D,N)&&(l[N]=D[N])})(k,n)};function $(k,n){function l(){this.constructor=k}le(k,n),k.prototype=n===null?Object.create(n):(l.prototype=n.prototype,new l)}function Y(k,n,l,D){return new(l||(l=Promise))(function(N,R){function ee(je){try{Ue(D.next(je))}catch(we){R(we)}}function De(je){try{Ue(D.throw(je))}catch(we){R(we)}}function Ue(je){var we;je.done?N(je.value):(we=je.value,we instanceof l?we:new l(function(Ge){Ge(we)})).then(ee,De)}Ue((D=D.apply(k,n||[])).next())})}function ne(k,n){var l,D,N,R,ee={label:0,sent:function(){if(1&N[0])throw N[1];return N[1]},trys:[],ops:[]};return R={next:De(0),throw:De(1),return:De(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function De(Ue){return function(je){return function(we){if(l)throw new TypeError("Generator is already executing.");for(;ee;)try{if(l=1,D&&(N=2&we[0]?D.return:we[0]?D.throw||((N=D.return)&&N.call(D),0):D.next)&&!(N=N.call(D,we[1])).done)return N;switch(D=0,N&&(we=[2&we[0],N.value]),we[0]){case 0:case 1:N=we;break;case 4:return ee.label++,{value:we[1],done:!1};case 5:ee.label++,D=we[1],we=[0];continue;case 7:we=ee.ops.pop(),ee.trys.pop();continue;default:if(!(N=ee.trys,(N=N.length>0&&N[N.length-1])||we[0]!==6&&we[0]!==2)){ee=0;continue}if(we[0]===3&&(!N||we[1]>N[0]&&we[1]<N[3])){ee.label=we[1];break}if(we[0]===6&&ee.label<N[1]){ee.label=N[1],N=we;break}if(N&&ee.label<N[2]){ee.label=N[2],ee.ops.push(we);break}N[2]&&ee.ops.pop(),ee.trys.pop();continue}we=n.call(k,ee)}catch(Ge){we=[6,Ge],D=0}finally{l=N=0}if(5&we[0])throw we[1];return{value:we[0]?we[1]:void 0,done:!0}}([Ue,je])}}}function z(){for(var k=0,n=0,l=arguments.length;n<l;n++)k+=arguments[n].length;var D=Array(k),N=0;for(n=0;n<l;n++)for(var R=arguments[n],ee=0,De=R.length;ee<De;ee++,N++)D[N]=R[ee];return D}var H=function(){function k(){}return k.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},k.setAttributes=function(n,l){for(var D=0,N=l;D<N.length;D++){var R=N[D],ee=R[0],De=R[1];n.setAttribute(ee,De)}},k.createRect=function(n,l,D){var N=document.createElementNS("http://www.w3.org/2000/svg","rect");return N.setAttribute("width",n.toString()),N.setAttribute("height",l.toString()),D&&k.setAttributes(N,D),N},k.createLine=function(n,l,D,N,R){var ee=document.createElementNS("http://www.w3.org/2000/svg","line");return ee.setAttribute("x1",n.toString()),ee.setAttribute("y1",l.toString()),ee.setAttribute("x2",D.toString()),ee.setAttribute("y2",N.toString()),R&&k.setAttributes(ee,R),ee},k.createPolygon=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",n),l&&k.setAttributes(D,l),D},k.createCircle=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(n/2).toString()),D.setAttribute("cy",(n/2).toString()),D.setAttribute("r",n.toString()),l&&k.setAttributes(D,l),D},k.createEllipse=function(n,l,D){var N=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return N.setAttribute("cx",(n/2).toString()),N.setAttribute("cy",(l/2).toString()),N.setAttribute("rx",(n/2).toString()),N.setAttribute("ry",(l/2).toString()),D&&k.setAttributes(N,D),N},k.createGroup=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","g");return n&&k.setAttributes(l,n),l},k.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},k.createMarker=function(n,l,D,N,R,ee,De){var Ue=document.createElementNS("http://www.w3.org/2000/svg","marker");return k.setAttributes(Ue,[["id",n],["orient",l],["markerWidth",D.toString()],["markerHeight",N.toString()],["refX",R.toString()],["refY",ee.toString()]]),Ue.appendChild(De),Ue},k.createText=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","text");return l.setAttribute("x","0"),l.setAttribute("y","0"),n&&k.setAttributes(l,n),l},k.createTSpan=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=n,l&&k.setAttributes(D,l),D},k.createImage=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","image");return n&&k.setAttributes(l,n),l},k.createPoint=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=n,D.y=l,D},k.createPath=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",n),l&&k.setAttributes(D,l),D},k}(),me=function(){function k(){}return k.addKey=function(n){k.key=n},Object.defineProperty(k,"isLicensed",{get:function(){return!!k.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(k.key)},enumerable:!1,configurable:!0}),k}(),Le=function(){function k(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return k.prototype.rasterize=function(n,l,D){var N=this;return new Promise(function(R){var ee=D!==void 0?D:document.createElement("canvas");n===null&&(N.markersOnly=!0,N.naturalSize=!1);var De=document.createElementNS("http://www.w3.org/2000/svg","svg");De.setAttribute("xmlns","http://www.w3.org/2000/svg"),De.setAttribute("width",l.width.baseVal.valueAsString),De.setAttribute("height",l.height.baseVal.valueAsString),De.setAttribute("viewBox","0 0 "+l.viewBox.baseVal.width.toString()+" "+l.viewBox.baseVal.height.toString()),De.innerHTML=l.innerHTML,N.naturalSize===!0?(De.width.baseVal.value=n.naturalWidth,De.height.baseVal.value=n.naturalHeight):N.width!==void 0&&N.height!==void 0&&(De.width.baseVal.value=N.width,De.height.baseVal.value=N.height),ee.width=De.width.baseVal.value,ee.height=De.height.baseVal.value;var Ue=De.outerHTML,je=ee.getContext("2d");N.markersOnly!==!0&&je.drawImage(n,0,0,ee.width,ee.height);var we=window.URL,Ge=new Image(ee.width,ee.height);Ge.setAttribute("crossOrigin","anonymous");var Ke=new Blob([Ue],{type:"image/svg+xml"}),Je=we.createObjectURL(Ke);Ge.onload=function(){je.drawImage(Ge,0,0),we.revokeObjectURL(Je);var xt=ee.toDataURL(N.imageType,N.imageQuality);R(xt)},Ge.src=Je})},k}(),Oe=function(){},Ae=function(){function k(n){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+n+"_"}return Object.defineProperty(k.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(k.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(k.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),k.prototype.addClass=function(n){return this.styleSheet===void 0&&this.addStyleSheet(),n.name=""+this.classNamePrefix+n.localName,this.classes.push(n),this.styleSheet.sheet.insertRule("."+n.name+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length),n},k.prototype.addRule=function(n){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(n),this.styleSheet.sheet.insertRule(n.selector+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length)},k.prototype.addStyleSheet=function(){var n;this.styleSheet=document.createElement("style"),((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).appendChild(this.styleSheet),this.addRule(new Re("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Re("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new fe("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new fe("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},k.prototype.removeStyleSheet=function(){var n;this.styleSheet&&(((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},k}(),Re=function(k,n){this.selector=k,this.style=n},fe=function(k,n){this.localName=k,this.style=n},ye=function(){function k(n,l,D,N,R){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=n,this.displayMode=l,this.markerItems=D,this.uiStyleSettings=N,this.styles=R,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return k.prototype.show=function(n){var l=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=n,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var D=document.createElement("div");D.className=this.toolbarBlockStyleClass.name,D.style.whiteSpace="nowrap",this.uiContainer.appendChild(D),this.addActionButton(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(D,'<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(R){var ee=document.createElement("div");ee.className=""+l.toolbarButtonStyleClass.name,ee.setAttribute("data-type-name",R.typeName),ee.innerHTML=R.icon,ee.addEventListener("click",function(){l.markerToolbarButtonClicked(ee,R)}),l.buttons.push(ee),l.markerButtons.push(ee)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var N=document.createElement("div");N.className=this.toolbarBlockStyleClass.name,N.style.whiteSpace="nowrap",N.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(N),this.addActionButton(N,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(N,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},k.prototype.addButtonClickListener=function(n){this.buttonClickListeners.push(n)},k.prototype.removeButtonClickListener=function(n){this.buttonClickListeners.indexOf(n)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(n),1)},k.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},k.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var n=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var l=0;l<this.markerButtons.length;l++)l<n||l===n&&this.markerButtons.length-1===n?this.markerButtonBlock.appendChild(this.markerButtons[l]):(l===n&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[l]))}},k.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")},k.prototype.resetButtonStyles=function(){var n=this;this.buttons.forEach(function(l){l.className=l.className.replace(n.uiStyleSettings.toolbarButtonStyleColorsClassName?n.uiStyleSettings.toolbarButtonStyleColorsClassName:n.toolbarButtonStyleColorsClass.name,"").trim(),l.className=l.className.replace(n.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?n.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:n.toolbarActiveButtonStyleColorsClass.name,"").trim(),l.className+=" "+(n.uiStyleSettings.toolbarButtonStyleColorsClassName?n.uiStyleSettings.toolbarButtonStyleColorsClassName:n.toolbarButtonStyleColorsClass.name)})},k.prototype.addActionButton=function(n,l,D){var N=this,R=document.createElement("div");switch(R.className=""+this.toolbarButtonStyleClass.name,R.innerHTML=l,R.setAttribute("data-action",D),R.addEventListener("click",function(){N.actionToolbarButtonClicked(R,D)}),D){case"select":R.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":R.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":R.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":R.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":R.style.fill=this.uiStyleSettings.closeButtonColor}n.appendChild(R),this.buttons.push(R)},k.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new fe("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 fe("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new fe("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new fe("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 fe("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var n=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new fe("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*n)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*n)+`px;
padding: `+n+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Re("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},k.prototype.markerToolbarButtonClicked=function(n,l){this.setActiveButton(n),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("marker",l)}),this.markerButtonOverflowBlock.style.display="none"},k.prototype.actionToolbarButtonClicked=function(n,l){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(D){return D("action",l)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},k.prototype.setActiveButton=function(n){this.resetButtonStyles(),n.className=n.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),n.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},k.prototype.setActiveMarkerButton=function(n){var l=this.markerButtons.find(function(D){return D.getAttribute("data-type-name")===n});l&&this.setActiveButton(l)},k.prototype.setCurrentMarker=function(n){var l=this;this.currentMarker=n,this.buttons.filter(function(D){return/delete|notes/.test(D.getAttribute("data-action"))}).forEach(function(D){l.currentMarker===void 0?(D.style.fillOpacity="0.4",D.style.pointerEvents="none"):(D.style.fillOpacity="1",D.style.pointerEvents="all")})},k}(),xe=function(){function k(n,l,D,N){this.panels=[],this.panelButtons=[],this.markerjsContainer=n,this.displayMode=l,this.uiStyleSettings=D,this.styles=N,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return k.prototype.addStyles=function(){var n;this.toolboxStyleClass=this.styles.addClass(new fe("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 fe("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var l=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new fe("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new fe("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new fe("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 fe("toolbox-panel-row_colors",`
background-color: `+((n=this.uiStyleSettings.toolboxBackgroundColor)!==null&&n!==void 0?n:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new fe("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*l)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*l)+`px;
padding: `+l+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new fe("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Re("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},k.prototype.show=function(n){var l;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=n,this.uiContainer.className=this.toolboxStyleClass.name+" "+((l=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&l!==void 0?l:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},k.prototype.setPanelButtons=function(n){var l,D,N=this;this.panels=n,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((l=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&l!==void 0?l:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((D=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&D!==void 0?D:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(R){var ee;R.uiStyleSettings=N.uiStyleSettings;var De=document.createElement("div");De.className=N.toolboxButtonStyleClass.name+" "+((ee=N.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&ee!==void 0?ee:N.toolboxButtonStyleColorsClass.name),De.innerHTML=R.icon,De.title=R.title,De.addEventListener("click",function(){N.panelButtonClick(R)}),N.panelButtons.push(De),N.buttonRow.appendChild(De)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},k.prototype.panelButtonClick=function(n){var l=this,D=-1;if(n!==this.activePanel){D=this.panels.indexOf(n),this.panelRow.innerHTML="";var N=n.getUi();N.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(N),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=n}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){l.displayMode==="inline"?l.panelRow.style.display="none":l.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(R,ee){var De,Ue;R.className=l.toolboxButtonStyleClass.name+" "+(ee===D?""+((De=l.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&De!==void 0?De:l.toolboxActiveButtonStyleColorsClass.name):""+((Ue=l.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ue!==void 0?Ue:l.toolboxButtonStyleColorsClass.name))})},k}(),Se=function(k,n){this.title=k,this.icon=n},Ne=function(k){function n(l,D,N,R){var ee=k.call(this,l,R||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return ee.colors=[],ee.addTransparent=!1,ee.colorBoxes=[],ee.colors=D,ee.currentColor=N,ee.setCurrentColor=ee.setCurrentColor.bind(ee),ee.getColorBox=ee.getColorBox.bind(ee),ee}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.whiteSpace="nowrap",this.colors.forEach(function(N){var R=l.getColorBox(N);D.appendChild(R),l.colorBoxes.push(R)}),D},n.prototype.getColorBox=function(l){var D=this,N=this.uiStyleSettings.toolbarHeight/4,R=this.uiStyleSettings.toolbarHeight-N,ee=document.createElement("div");ee.style.display="inline-block",ee.style.boxSizing="content-box",ee.style.width=R-2+"px",ee.style.height=R-2+"px",ee.style.padding="1px",ee.style.marginRight="2px",ee.style.marginBottom="2px",ee.style.borderWidth="2px",ee.style.borderStyle="solid",ee.style.borderRadius=(R+2)/2+"px",ee.style.borderColor=l===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",ee.addEventListener("click",function(){D.setCurrentColor(l,ee)});var De=document.createElement("div");return De.style.display="inline-block",De.style.width=R-2+"px",De.style.height=R-2+"px",De.style.backgroundColor=l,De.style.borderRadius=R/2+"px",l==="transparent"&&(De.style.fill=this.uiStyleSettings.toolboxAccentColor,De.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>`),ee.appendChild(De),ee},n.prototype.setCurrentColor=function(l,D){var N=this;this.currentColor=l,this.colorBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(l)},n}(Se),Pe=function(){function k(n,l,D){this._state="new",this._isSelected=!1,this._container=n,this._overlayContainer=l,this.globalSettings=D,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(k.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),k.prototype.ownsTarget=function(n){return!1},Object.defineProperty(k.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),k.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},k.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},k.prototype.pointerDown=function(n,l){},k.prototype.dblClick=function(n,l){},k.prototype.manipulate=function(n){},k.prototype.pointerUp=function(n){this.stateChanged()},k.prototype.dispose=function(){},k.prototype.addMarkerVisualToContainer=function(n){this.container.childNodes.length>0?this.container.insertBefore(n,this.container.childNodes[0]):this.container.appendChild(n)},k.prototype.getState=function(){return{typeName:k.typeName,state:this.state,notes:this.notes}},k.prototype.restoreState=function(n){this._state=n.state,this.notes=n.notes},k.prototype.scale=function(n,l){},k.prototype.colorChanged=function(n){this.onColorChanged&&this.onColorChanged(n),this.stateChanged()},k.prototype.fillColorChanged=function(n){this.onFillColorChanged&&this.onFillColorChanged(n),this.stateChanged()},k.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var n=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),n.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(n)&&this.onStateChanged(this)}},k.typeName="MarkerBase",k}(),_e=function(){function k(){this.findGripByVisual=this.findGripByVisual.bind(this)}return k.prototype.findGripByVisual=function(n){return this.topLeft.ownsTarget(n)?this.topLeft:this.topCenter.ownsTarget(n)?this.topCenter:this.topRight.ownsTarget(n)?this.topRight:this.centerLeft.ownsTarget(n)?this.centerLeft:this.centerRight.ownsTarget(n)?this.centerRight:this.bottomLeft.ownsTarget(n)?this.bottomLeft:this.bottomCenter.ownsTarget(n)?this.bottomCenter:this.bottomRight.ownsTarget(n)?this.bottomRight:void 0},k}(),Fe=function(){function k(){this.GRIP_SIZE=10,this.visual=H.createGroup(),this.visual.appendChild(H.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(H.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return k.prototype.ownsTarget=function(n){return n===this.visual||n===this.visual.childNodes[0]||n===this.visual.childNodes[1]},k}(),se=function(){function k(){}return k.toITransformMatrix=function(n){return{a:n.a,b:n.b,c:n.c,d:n.d,e:n.e,f:n.f}},k.toSVGMatrix=function(n,l){return n.a=l.a,n.b=l.b,n.c=l.c,n.d=l.d,n.e=l.e,n.f=l.f,n},k}(),ue=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.left=0,R.top=0,R.width=0,R.height=0,R.defaultSize={x:50,y:20},R.offsetX=0,R.offsetY=0,R.rotationAngle=0,R.CB_DISTANCE=10,R._suppressMarkerCreateEvent=!1,R.container.transform.baseVal.appendItem(H.createTransform()),R.setupControlBox(),R}return $(n,k),Object.defineProperty(n.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"visual",{get:function(){return this._visual},set:function(l){this._visual=l;var D=H.createTransform();this._visual.transform.baseVal.appendItem(D)},enumerable:!1,configurable:!0}),n.prototype.ownsTarget=function(l){return!!k.prototype.ownsTarget.call(this,l)||!!(this.controlGrips.findGripByVisual(l)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(l))},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="new"&&(this.left=l.x,this.top=l.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var N=this.unrotatePoint(l);if(this.manipulationStartX=N.x,this.manipulationStartY=N.y,this.offsetX=N.x-this.left,this.offsetY=N.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(D),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(D)){this.activeGrip=this.rotatorGrip;var R=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=R.x-this.width/2,this.top=R.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var ee=this.container.transform.baseVal.getItem(0);ee.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(ee,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},n.prototype.pointerUp=function(l){var D=this.state;k.prototype.pointerUp.call(this,l),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(l),this._state="select",D==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},n.prototype.moveVisual=function(l){this.visual.style.transform="translate("+l.x+"px, "+l.y+"px)"},n.prototype.manipulate=function(l){var D=this.unrotatePoint(l);this.state==="creating"?this.resize(l):this.state==="move"?(this.left=this.manipulationStartLeft+(D.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(D.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(D):this.state==="rotate"&&this.rotate(l)},n.prototype.resize=function(l){var D=this.manipulationStartLeft,N=this.manipulationStartWidth,R=this.manipulationStartTop,ee=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:D=this.manipulationStartLeft+l.x-this.manipulationStartX,N=this.manipulationStartWidth+this.manipulationStartLeft-D;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:N=this.manipulationStartWidth+l.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:R=this.manipulationStartTop+l.y-this.manipulationStartY,ee=this.manipulationStartHeight+this.manipulationStartTop-R;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:ee=this.manipulationStartHeight+l.y-this.manipulationStartY}N>=0?(this.left=D,this.width=N):(this.left=D+N,this.width=-N),ee>=0?(this.top=R,this.height=ee):(this.top=R+ee,this.height=-ee),this.setSize()},n.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},n.prototype.rotate=function(l){if(Math.abs(l.x-this.centerX)>.1){var D=Math.sign(l.x-this.centerX);this.rotationAngle=180*Math.atan((l.y-this.centerY)/(l.x-this.centerX))/Math.PI+90*D,this.applyRotation()}},n.prototype.applyRotation=function(){var l=this.container.transform.baseVal.getItem(0);l.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(l,0)},n.prototype.rotatePoint=function(l){if(this.rotationAngle===0)return l;var D=this.container.getCTM(),N=H.createPoint(l.x,l.y);return{x:(N=N.matrixTransform(D)).x,y:N.y}},n.prototype.unrotatePoint=function(l){if(this.rotationAngle===0)return l;var D=this.container.getCTM();D=D.inverse();var N=H.createPoint(l.x,l.y);return{x:(N=N.matrixTransform(D)).x,y:N.y}},n.prototype.select=function(){k.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},n.prototype.deselect=function(){k.prototype.deselect.call(this),this.controlBox.style.display="none"},n.prototype.setupControlBox=function(){this.controlBox=H.createGroup();var l=H.createTransform();l.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(l),this.container.appendChild(this.controlBox),this.controlRect=H.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=H.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 _e,this.addControlGrips(),this.controlBox.style.display="none"},n.prototype.adjustControlBox=function(){var l=this.controlBox.transform.baseVal.getItem(0);l.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(l,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()},n.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()},n.prototype.createGrip=function(){var l=new Fe;return l.visual.transform.baseVal.appendItem(H.createTransform()),this.controlBox.appendChild(l.visual),l},n.prototype.positionGrips=function(){var l=this.controlGrips.topLeft.GRIP_SIZE,D=-l/2,N=D,R=(this.width+this.CB_DISTANCE)/2-l/2,ee=(this.height+this.CB_DISTANCE)/2-l/2,De=this.height+this.CB_DISTANCE-l/2,Ue=this.width+this.CB_DISTANCE-l/2;this.positionGrip(this.controlGrips.topLeft.visual,D,N),this.positionGrip(this.controlGrips.topCenter.visual,R,N),this.positionGrip(this.controlGrips.topRight.visual,Ue,N),this.positionGrip(this.controlGrips.centerLeft.visual,D,ee),this.positionGrip(this.controlGrips.centerRight.visual,Ue,ee),this.positionGrip(this.controlGrips.bottomLeft.visual,D,De),this.positionGrip(this.controlGrips.bottomCenter.visual,R,De),this.positionGrip(this.controlGrips.bottomRight.visual,Ue,De),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,R,N-3*this.CB_DISTANCE)},n.prototype.positionGrip=function(l,D,N){var R=l.transform.baseVal.getItem(0);R.setTranslate(D,N),l.transform.baseVal.replaceItem(R,0)},n.prototype.hideControlBox=function(){this.controlBox.style.display="none"},n.prototype.showControlBox=function(){this.controlBox.style.display=""},n.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:se.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:se.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},k.prototype.getState.call(this))},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l);var D=l;this.left=D.left,this.top=D.top,this.width=D.width,this.height=D.height,this.rotationAngle=D.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(se.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,D.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(se.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,D.containerTransformMatrix))},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D);var N=this.rotatePoint({x:this.left,y:this.top}),R=this.unrotatePoint({x:N.x*l,y:N.y*D});this.left=R.x,this.top=R.y,this.width=this.width*l,this.height=this.height*D,this.adjustControlBox()},n}(Pe),be=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.fillColor="transparent",R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.opacity=1,R.setStrokeColor=R.setStrokeColor.bind(R),R.setFillColor=R.setFillColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.createVisual=R.createVisual.bind(R),R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.visual)},n.prototype.createVisual=function(){this.visual=H.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)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="new"&&(this.createVisual(),this.moveVisual(l),this._state="creating")},n.prototype.manipulate=function(l){k.prototype.manipulate.call(this,l)},n.prototype.resize=function(l){k.prototype.resize.call(this,l),this.setSize()},n.prototype.setSize=function(){k.prototype.setSize.call(this),H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},n.prototype.pointerUp=function(l){k.prototype.pointerUp.call(this,l),this.setSize()},n.prototype.setStrokeColor=function(l){this.strokeColor=l,this.visual&&H.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(l),this.stateChanged()},n.prototype.setFillColor=function(l){this.fillColor=l,this.visual&&H.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},n.prototype.setStrokeWidth=function(l){this.strokeWidth=l,this.visual&&H.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},n.prototype.setStrokeDasharray=function(l){this.strokeDasharray=l,this.visual&&H.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},n.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},k.prototype.getState.call(this))},n.prototype.restoreState=function(l){var D=l;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),k.prototype.restoreState.call(this,l),this.setSize()},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.setSize()},n.title="Rectangle marker",n}(ue),Ee=function(k){function n(l,D,N,R){var ee=k.call(this,l,R||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return ee.widths=[],ee.widthBoxes=[],ee.widths=D,ee.currentWidth=N,ee.setCurrentWidth=ee.setCurrentWidth.bind(ee),ee}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.widths.forEach(function(N){var R=document.createElement("div");R.style.display="flex",R.style.flexGrow="2",R.style.alignItems="center",R.style.justifyContent="space-between",R.style.padding="5px",R.style.borderWidth="2px",R.style.borderStyle="solid",R.style.borderColor=N===l.currentWidth?l.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){l.setCurrentWidth(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.innerText=N.toString(),ee.style.marginRight="5px",R.appendChild(ee);var De=document.createElement("div");De.style.minHeight="20px",De.style.flexGrow="2",De.style.display="flex",De.style.alignItems="center";var Ue=document.createElement("hr");Ue.style.minWidth="20px",Ue.style.border="0px",Ue.style.borderTop=N+"px solid "+l.uiStyleSettings.toolboxColor,Ue.style.flexGrow="2",De.appendChild(Ue),R.appendChild(De),l.widthBoxes.push(R)}),D},n.prototype.setCurrentWidth=function(l,D){var N=this;this.currentWidth=l,this.widthBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},n}(Se),Ce=function(k){function n(l,D,N,R){var ee=k.call(this,l,R||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return ee.styles=[],ee.styleBoxes=[],ee.styles=D,ee.currentStyle=N,ee.setCurrentStyle=ee.setCurrentStyle.bind(ee),ee}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",this.styles.forEach(function(N){var R=document.createElement("div");R.style.display="flex",R.style.alignItems="center",R.style.justifyContent="space-between",R.style.padding="5px",R.style.borderWidth="2px",R.style.borderStyle="solid",R.style.overflow="hidden",R.style.maxWidth=100/l.styles.length-5+"%",R.style.borderColor=N===l.currentStyle?l.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){l.setCurrentStyle(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.style.minHeight="20px",ee.style.flexGrow="2",ee.style.overflow="hidden";var De=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+l.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(N!==""?'stroke-dasharray="'+N+'"':"")+` />
</svg>`;ee.innerHTML=De,R.appendChild(ee),l.styleBoxes.push(R)}),D},n.prototype.setCurrentStyle=function(l,D){var N=this;this.currentStyle=l,this.styleBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},n}(Se),Te=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ne("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new Ee("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,k),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=k.prototype.getState.call(this);return l.typeName=n.typeName,l},n.typeName="FrameMarker",n.title="Frame marker",n.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',n}(be),ve=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},Ie=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.x1=0,R.y1=0,R.x2=0,R.y2=0,R.defaultLength=50,R.manipulationStartX=0,R.manipulationStartY=0,R.manipulationStartX1=0,R.manipulationStartY1=0,R.manipulationStartX2=0,R.manipulationStartY2=0,R.setupControlBox(),R}return $(n,k),n.prototype.ownsTarget=function(l){return!!k.prototype.ownsTarget.call(this,l)||!(!this.grip1.ownsTarget(l)&&!this.grip2.ownsTarget(l))},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.manipulationStartX=l.x,this.manipulationStartY=l.y,this.state==="new"&&(this.x1=l.x,this.y1=l.y,this.x2=l.x,this.y2=l.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(D)?this.activeGrip=this.grip1:this.grip2.ownsTarget(D)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},n.prototype.pointerUp=function(l){var D=this.state;k.prototype.pointerUp.call(this,l),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(l),this._state="select",D==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},n.prototype.adjustVisual=function(){},n.prototype.manipulate=function(l){this.state==="creating"?this.resize(l):this.state==="move"?(this.x1=this.manipulationStartX1+l.x-this.manipulationStartX,this.y1=this.manipulationStartY1+l.y-this.manipulationStartY,this.x2=this.manipulationStartX2+l.x-this.manipulationStartX,this.y2=this.manipulationStartY2+l.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(l)},n.prototype.resize=function(l){switch(this.activeGrip){case this.grip1:this.x1=l.x,this.y1=l.y;break;case this.grip2:case void 0:this.x2=l.x,this.y2=l.y}this.adjustVisual(),this.adjustControlBox()},n.prototype.select=function(){k.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},n.prototype.deselect=function(){k.prototype.deselect.call(this),this.controlBox.style.display="none"},n.prototype.setupControlBox=function(){this.controlBox=H.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},n.prototype.adjustControlBox=function(){this.positionGrips()},n.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},n.prototype.createGrip=function(){var l=new Fe;return l.visual.transform.baseVal.appendItem(H.createTransform()),this.controlBox.appendChild(l.visual),l},n.prototype.positionGrips=function(){var l=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-l/2,this.y1-l/2),this.positionGrip(this.grip2.visual,this.x2-l/2,this.y2-l/2)},n.prototype.positionGrip=function(l,D,N){var R=l.transform.baseVal.getItem(0);R.setTranslate(D,N),l.transform.baseVal.replaceItem(R,0)},n.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},k.prototype.getState.call(this))},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l);var D=l;this.x1=D.x1,this.y1=D.y1,this.x2=D.x2,this.y2=D.y2},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.x1=this.x1*l,this.y1=this.y1*D,this.x2=this.x2*l,this.y2=this.y2*D,this.adjustVisual(),this.adjustControlBox()},n}(Pe),Be=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.setStrokeColor=R.setStrokeColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ne("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new Ee("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.visual&&l!==this.selectorLine&&l!==this.visibleLine)},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.selectorLine=H.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=H.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)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},n.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()),H.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),H.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),H.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},n.prototype.setStrokeColor=function(l){this.strokeColor=l,this.adjustVisual(),this.colorChanged(l)},n.prototype.setStrokeWidth=function(l){this.strokeWidth=l,this.adjustVisual()},n.prototype.setStrokeDasharray=function(l){this.strokeDasharray=l,this.adjustVisual(),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l);var D=l;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.createVisual(),this.adjustVisual()},n.typeName="LineMarker",n.title="Line marker",n.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',n}(Ie),ge=function(k){function n(l,D,N,R){var ee=k.call(this,l,R||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return ee.fonts=[],ee.fontBoxes=[],ee.fonts=D,ee.currentFont=N,ee.setCurrentFont=ee.setCurrentFont.bind(ee),ee}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");return D.style.overflow="hidden",D.style.flexGrow="2",this.fonts.forEach(function(N){var R=document.createElement("div");R.style.display="inline-block",R.style.alignItems="center",R.style.justifyContent="space-between",R.style.padding="5px",R.style.borderWidth="2px",R.style.borderStyle="solid",R.style.overflow="hidden",R.style.maxWidth=100/l.fonts.length-5+"%",R.style.borderColor=N===l.currentFont?l.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){l.setCurrentFont(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.style.display="flex",ee.style.minHeight="20px",ee.style.flexGrow="2",ee.style.fontFamily=N,ee.style.overflow="hidden";var De=document.createElement("div");De.style.whiteSpace="nowrap",De.style.overflow="hidden",De.style.textOverflow="ellipsis",De.innerHTML="The quick brown fox jumps over the lazy dog",ee.appendChild(De),R.appendChild(ee),l.fontBoxes.push(R)}),D},n.prototype.setCurrentFont=function(l,D){var N=this;this.currentFont=l,this.fontBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},n}(Se),Me=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.color="transparent",R.padding=5,R.DEFAULT_TEXT="your text here",R.text=R.DEFAULT_TEXT,R.isMoved=!1,R.color=N.defaultColor,R.fontFamily=N.defaultFontFamily,R.defaultSize={x:100,y:30},R.setColor=R.setColor.bind(R),R.setFont=R.setFont.bind(R),R.renderText=R.renderText.bind(R),R.sizeText=R.sizeText.bind(R),R.textEditDivClicked=R.textEditDivClicked.bind(R),R.showTextEditor=R.showTextEditor.bind(R),R.setSize=R.setSize.bind(R),R.positionTextEditor=R.positionTextEditor.bind(R),R.colorPanel=new Ne("Color",N.defaultColorSet,N.defaultColor),R.colorPanel.onColorChanged=R.setColor,R.fontFamilyPanel=new ge("Font",N.defaultFontFamilies,N.defaultFontFamily),R.fontFamilyPanel.onFontChanged=R.setFont,R}return $(n,k),n.prototype.ownsTarget=function(l){if(k.prototype.ownsTarget.call(this,l)||l===this.visual||l===this.textElement||l===this.bgRectangle)return!0;var D=!1;return this.textElement.childNodes.forEach(function(N){N===l&&(D=!0)}),D},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.bgRectangle=H.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=H.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(H.createTransform()),this.textElement.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.isMoved=!1,this.pointerDownPoint=l,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(l),this._state="creating")},n.prototype.renderText=function(){var l=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(D){l.textElement.appendChild(H.createTSpan(D.trim()===""?" ":D.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},n.prototype.getTextScale=function(){var l=this.textElement.getBBox(),D=1;if(l.width>0&&l.height>0){var N=(1*this.width-this.width*this.padding*2/100)/l.width,R=(1*this.height-this.height*this.padding*2/100)/l.height;D=Math.min(N,R)}return D},n.prototype.getTextPosition=function(l){var D=this.textElement.getBBox(),N=0,R=0;return D.width>0&&D.height>0&&(N=(this.width-D.width*l)/2,R=this.height/2-D.height*l/2),{x:N,y:R}},n.prototype.sizeText=function(){var l=this.textElement.getBBox(),D=this.getTextScale(),N=this.getTextPosition(D);N.y-=l.y*D,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+N.x+"px, "+N.y+"px) scale("+D+", "+D+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(N.x,N.y),this.textElement.transform.baseVal.getItem(1).setScale(D,D))},n.prototype.manipulate=function(l){k.prototype.manipulate.call(this,l),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(l.x-this.pointerDownPoint.x)>5||Math.abs(l.y-this.pointerDownPoint.y)>5)},n.prototype.resize=function(l){k.prototype.resize.call(this,l),this.isMoved=!0,this.setSize(),this.sizeText()},n.prototype.setSize=function(){k.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},n.prototype.pointerUp=function(l){var D=this.state;D==="creating"&&(this._suppressMarkerCreateEvent=!0),k.prototype.pointerUp.call(this,l),this.setSize(),(D==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},n.prototype.showTextEditor=function(){var l=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(D){D.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var D=Number.parseFloat(l.textEditor.style.fontSize);l.textEditor.clientWidth>=Number.parseInt(l.textEditor.style.maxWidth)&&D>.9;)D-=.1,l.textEditor.style.fontSize=Math.max(D,.9)+"em"}),this.textEditor.addEventListener("keyup",function(D){D.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(D){if(D.clipboardData){var N=D.clipboardData.getData("text"),R=window.getSelection();if(!R.rangeCount)return!1;R.deleteFromDocument(),R.getRangeAt(0).insertNode(document.createTextNode(N)),D.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){l.textEditDivClicked(l.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},n.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var l=this.getTextScale(),D=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),N=this.textElement.getBBox(),R={x:N.width*l,y:N.height*l};D.x-=R.x/2,D.y-=R.y/2,this.textEditor.style.top=D.y+"px",this.textEditor.style.left=D.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-D.x+"px",this.textEditor.style.fontSize=Math.max(16*l,12)+"px",this.textElement.style.display="none"}},n.prototype.textEditDivClicked=function(l){this.text=l.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},n.prototype.select=function(){k.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},n.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),k.prototype.deselect.call(this)},n.prototype.dblClick=function(l,D){k.prototype.dblClick.call(this,l,D),this.showTextEditor()},n.prototype.setColor=function(l){this.textElement&&H.setAttributes(this.textElement,[["fill",l]]),this.color=l,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(l)},n.prototype.setFont=function(l){this.textElement&&H.setAttributes(this.textElement,[["font-family",l]]),this.fontFamily=l,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},n.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},n.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){var D=l;this.color=D.color,this.fontFamily=D.fontFamily,this.padding=D.padding,this.text=D.text,this.createVisual(),k.prototype.restoreState.call(this,l),this.setSize()},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.setSize(),this.sizeText(),this.positionTextEditor()},n.typeName="TextMarker",n.title="Text marker",n.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>',n}(ue),re=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.color="transparent",R.lineWidth=3,R.drawing=!1,R.pixelRatio=1,R.color=N.defaultColor,R.lineWidth=N.defaultStrokeWidth,R.pixelRatio=N.freehandPixelRatio,R.setColor=R.setColor.bind(R),R.addCanvas=R.addCanvas.bind(R),R.finishCreation=R.finishCreation.bind(R),R.setLineWidth=R.setLineWidth.bind(R),R.colorPanel=new Ne("Color",N.defaultColorSet,N.defaultColor),R.colorPanel.onColorChanged=R.setColor,R.lineWidthPanel=new Ee("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.lineWidthPanel.onWidthChanged=R.setLineWidth,R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.visual&&l!==this.drawingImage)},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.drawingImage=H.createImage(),this.visual.appendChild(this.drawingImage);var l=H.createTransform();this.visual.transform.baseVal.appendItem(l),this.addMarkerVisualToContainer(this.visual)},n.prototype.pointerDown=function(l,D){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(l.x,l.y),this.drawing=!0):k.prototype.pointerDown.call(this,l,D)},n.prototype.manipulate=function(l){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(l.x,l.y),this.canvasContext.stroke()):k.prototype.manipulate.call(this,l)},n.prototype.resize=function(l){k.prototype.resize.call(this,l),H.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},n.prototype.pointerUp=function(l){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):k.prototype.pointerUp.call(this,l)},n.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)},n.prototype.select=function(){this.state==="creating"&&this.finishCreation(),k.prototype.select.call(this)},n.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),k.prototype.deselect.call(this)},n.prototype.finishCreation=function(){for(var l=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),D=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],N=D[0],R=D[1],ee=D[2],De=D[3],Ue=!1,je=0;je<this.canvasElement.height;je++)for(var we=0;we<this.canvasElement.width;we++)l.data[je*this.canvasElement.width*4+4*we+3]>0&&(Ue=!0,je<R&&(R=je),we<N&&(N=we),je>De&&(De=je),we>ee&&(ee=we));if(Ue){this.left=N/this.pixelRatio,this.top=R/this.pixelRatio,this.width=(ee-N)/this.pixelRatio,this.height=(De-R)/this.pixelRatio;var Ge=document.createElement("canvas");Ge.width=ee-N,Ge.height=De-R,Ge.getContext("2d").putImageData(this.canvasContext.getImageData(N,R,ee-N,De-R),0,0),this.drawingImgUrl=Ge.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},n.prototype.setDrawingImage=function(){H.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),H.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},n.prototype.setColor=function(l){this.color=l,this.colorChanged(l)},n.prototype.setLineWidth=function(l){this.lineWidth=l},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({drawingImgUrl:this.drawingImgUrl},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){this.createVisual(),k.prototype.restoreState.call(this,l),this.drawingImgUrl=l.drawingImgUrl,this.setDrawingImage()},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.setDrawingImage()},n.typeName="FreehandMarker",n.title="Freehand marker",n.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>',n}(ue),q=function(k){function n(l,D,N){var R=k.call(this,l,N||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return R.typeBoxes=[],R.currentType=D,R.setCurrentType=R.setCurrentType.bind(R),R}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2";for(var N=function(De){var Ue="both";switch(De){case 0:Ue="both";break;case 1:Ue="start";break;case 2:Ue="end";break;case 3:Ue="none"}var je=document.createElement("div");if(je.style.display="flex",je.style.flexGrow="2",je.style.alignItems="center",je.style.justifyContent="space-between",je.style.padding="5px",je.style.borderWidth="2px",je.style.borderStyle="solid",je.style.borderColor=Ue===R.currentType?R.uiStyleSettings.toolboxAccentColor:"transparent",je.addEventListener("click",function(){l.setCurrentType(Ue,je)}),D.appendChild(je),Ue==="both"||Ue==="start"){var we=document.createElement("div");we.style.display="flex",we.style.alignItems="center",we.style.minHeight="20px",we.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="`+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,we.style.marginLeft="5px",je.appendChild(we)}var Ge=document.createElement("div");Ge.style.display="flex",Ge.style.alignItems="center",Ge.style.minHeight="20px",Ge.style.flexGrow="2";var Ke=document.createElement("hr");if(Ke.style.minWidth="20px",Ke.style.border="0px",Ke.style.borderTop="3px solid "+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee"),Ke.style.flexGrow="2",Ge.appendChild(Ke),je.appendChild(Ge),Ue==="both"||Ue==="end"){var Je=document.createElement("div");Je.style.display="flex",Je.style.alignItems="center",Je.style.minHeight="20px",Je.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="`+(R.uiStyleSettings!==void 0?R.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Je.style.marginRight="5px",je.appendChild(Je)}R.typeBoxes.push(je)},R=this,ee=0;ee<4;ee++)N(ee);return D},n.prototype.setCurrentType=function(l,D){var N=this;this.currentType=l,this.typeBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings!==void 0?N.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},n}(Se),te=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.arrowType="end",R.arrowBaseHeight=10,R.arrowBaseWidth=10,R.getArrowPoints=R.getArrowPoints.bind(R),R.setArrowType=R.setArrowType.bind(R),R.arrowTypePanel=new q("Arrow type","end"),R.arrowTypePanel.onArrowTypeChanged=R.setArrowType,R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.arrow1&&l!==this.arrow2)},n.prototype.getArrowPoints=function(l,D){var N=this.arrowBaseWidth+2*this.strokeWidth,R=this.arrowBaseHeight+2*this.strokeWidth;return l-N/2+","+(D+R/2)+" "+l+","+(D-R/2)+" "+(l+N/2)+","+(D+R/2)},n.prototype.createTips=function(){this.arrow1=H.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=H.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(H.createTransform()),this.visual.appendChild(this.arrow2)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="creating"&&this.createTips()},n.prototype.adjustVisual=function(){if(k.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",H.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),H.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var l=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),D=this.arrow1.transform.baseVal.getItem(0);D.setRotate(l,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(D,0);var N=this.arrow2.transform.baseVal.getItem(0);N.setRotate(l+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(N,0)}},n.prototype.setArrowType=function(l){this.arrowType=l,this.adjustVisual(),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({arrowType:this.arrowType},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l);var D=l;this.arrowType=D.arrowType,this.createTips(),this.adjustVisual()},n.typeName="ArrowMarker",n.title="Arrow marker",n.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',n}(Be),j=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.fillColor=N.defaultFillColor,R.strokeWidth=0,R.fillPanel=new Ne("Color",N.defaultColorSet,N.defaultFillColor),R.fillPanel.onColorChanged=R.setFillColor,R}return $(n,k),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=k.prototype.getState.call(this);return l.typeName=n.typeName,l},n.typeName="CoverMarker",n.title="Cover marker",n.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',n}(be),W=function(k){function n(l,D,N,R){var ee=k.call(this,l,R||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return ee.opacities=[],ee.opacityBoxes=[],ee.opacities=D,ee.currentOpacity=N,ee.setCurrentOpacity=ee.setCurrentOpacity.bind(ee),ee}return $(n,k),n.prototype.getUi=function(){var l=this,D=document.createElement("div");return D.style.display="flex",D.style.overflow="hidden",D.style.flexGrow="2",D.style.justifyContent="space-between",this.opacities.forEach(function(N){var R=document.createElement("div");R.style.display="flex",R.style.alignItems="center",R.style.justifyContent="center",R.style.padding="5px",R.style.borderWidth="2px",R.style.borderStyle="solid",R.style.borderColor=N===l.currentOpacity?l.uiStyleSettings.toolboxAccentColor:"transparent",R.addEventListener("click",function(){l.setCurrentOpacity(N,R)}),D.appendChild(R);var ee=document.createElement("div");ee.innerText=100*N+"%",R.appendChild(ee),l.opacityBoxes.push(R)}),D},n.prototype.setCurrentOpacity=function(l,D){var N=this;this.currentOpacity=l,this.opacityBoxes.forEach(function(R){R.style.borderColor=R===D?N.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},n}(Se),G=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.setOpacity=R.setOpacity.bind(R),R.fillColor=N.defaultHighlightColor,R.strokeWidth=0,R.opacity=N.defaultHighlightOpacity,R.fillPanel=new Ne("Color",N.defaultColorSet,R.fillColor),R.fillPanel.onColorChanged=R.setFillColor,R.opacityPanel=new W("Opacity",N.defaultOpacitySteps,R.opacity),R.opacityPanel.onOpacityChanged=R.setOpacity,R}return $(n,k),n.prototype.setOpacity=function(l){this.opacity=l,this.visual&&H.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=k.prototype.getState.call(this);return l.typeName=n.typeName,l},n.typeName="HighlightMarker",n.title="Highlight marker",n.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>',n}(j),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>',oe=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.bgColor="transparent",R.tipPosition={x:0,y:0},R.tipBase1Position={x:0,y:0},R.tipBase2Position={x:0,y:0},R.tipMoving=!1,R.color=N.defaultStrokeColor,R.bgColor=N.defaultFillColor,R.fontFamily=N.defaultFontFamily,R.defaultSize={x:100,y:30},R.setBgColor=R.setBgColor.bind(R),R.getTipPoints=R.getTipPoints.bind(R),R.positionTip=R.positionTip.bind(R),R.setTipPoints=R.setTipPoints.bind(R),R.colorPanel=new Ne("Text color",N.defaultColorSet,R.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),R.colorPanel.onColorChanged=R.setColor,R.bgColorPanel=new Ne("Fill color",N.defaultColorSet,R.bgColor,X),R.bgColorPanel.onColorChanged=R.setBgColor,R.fontFamilyPanel=new ge("Font",N.defaultFontFamilies,N.defaultFontFamily),R.fontFamilyPanel.onFontChanged=R.setFont,R.tipGrip=new Fe,R.tipGrip.visual.transform.baseVal.appendItem(H.createTransform()),R.controlBox.appendChild(R.tipGrip.visual),R}return $(n,k),n.prototype.ownsTarget=function(l){return k.prototype.ownsTarget.call(this,l)||this.tipGrip.ownsTarget(l)||this.tip===l},n.prototype.createTip=function(){H.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=H.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},n.prototype.pointerDown=function(l,D){this.state==="new"&&k.prototype.pointerDown.call(this,l,D),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(D)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):k.prototype.pointerDown.call(this,l,D)},n.prototype.pointerUp=function(l){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,k.prototype.pointerUp.call(this,l);else{var D=this.state==="creating";k.prototype.pointerUp.call(this,l),this.setTipPoints(D),this.positionTip()}},n.prototype.manipulate=function(l){if(this.tipMoving){var D=this.unrotatePoint(l);this.tipPosition={x:D.x-this.manipulationStartLeft,y:D.y-this.manipulationStartTop},this.positionTip()}else k.prototype.manipulate.call(this,l)},n.prototype.setBgColor=function(l){this.bgRectangle&&this.tip&&(H.setAttributes(this.bgRectangle,[["fill",l]]),H.setAttributes(this.tip,[["fill",l]])),this.bgColor=l,this.fillColorChanged(l)},n.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},n.prototype.setTipPoints=function(l){l===void 0&&(l=!1);var D=Math.min(this.height/2,15),N=this.height/5;l&&(this.tipPosition={x:D+N/2,y:this.height+20});var R=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?R<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:0},this.tipBase2Position={x:D+N,y:0}):(this.tipBase1Position={x:0,y:D},this.tipBase2Position={x:0,y:D+N}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?R<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-N,y:0},this.tipBase2Position={x:this.width-D,y:0}):(this.tipBase1Position={x:this.width,y:D},this.tipBase2Position={x:this.width,y:D+N}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?R<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-D-N,y:this.height},this.tipBase2Position={x:this.width-D,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-D-N},this.tipBase2Position={x:this.width,y:this.height-D}):R<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(N=this.width/5,D=Math.min(this.width/2,15),this.tipBase1Position={x:D,y:this.height},this.tipBase2Position={x:D+N,y:this.height}):(this.tipBase1Position={x:0,y:this.height-D},this.tipBase2Position={x:0,y:this.height-D-N})},n.prototype.resize=function(l){k.prototype.resize.call(this,l),this.positionTip()},n.prototype.positionTip=function(){H.setAttributes(this.tip,[["points",this.getTipPoints()]]);var l=this.tipGrip.visual.transform.baseVal.getItem(0);l.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(l,0)},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),n.prototype.select=function(){this.positionTip(),k.prototype.select.call(this)},n.prototype.getState=function(){var l=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){var D=l;this.bgColor=D.bgColor,this.tipPosition=D.tipPosition,k.prototype.restoreState.call(this,l),this.createTip(),this.setTipPoints()},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.tipPosition={x:this.tipPosition.x*l,y:this.tipPosition.y*D},this.positionTip()},n.typeName="CalloutMarker",n.title="Callout marker",n.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>',n}(Me),he=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.fillColor="transparent",R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.opacity=1,R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.fillColor=N.defaultFillColor,R.setStrokeColor=R.setStrokeColor.bind(R),R.setFillColor=R.setFillColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.setOpacity=R.setOpacity.bind(R),R.createVisual=R.createVisual.bind(R),R.strokePanel=new Ne("Line color",z(N.defaultColorSet,["transparent"]),N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.fillPanel=new Ne("Fill color",z(N.defaultColorSet,["transparent"]),R.fillColor,X),R.fillPanel.onColorChanged=R.setFillColor,R.strokeWidthPanel=new Ee("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R.opacityPanel=new W("Opacity",N.defaultOpacitySteps,R.opacity),R.opacityPanel.onOpacityChanged=R.setOpacity,R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.visual)},n.prototype.createVisual=function(){this.visual=H.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)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="new"&&(this.createVisual(),this.moveVisual(l),this._state="creating")},n.prototype.manipulate=function(l){k.prototype.manipulate.call(this,l)},n.prototype.resize=function(l){k.prototype.resize.call(this,l),this.setSize()},n.prototype.setSize=function(){k.prototype.setSize.call(this),H.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},n.prototype.pointerUp=function(l){k.prototype.pointerUp.call(this,l),this.setSize()},n.prototype.setStrokeColor=function(l){this.strokeColor=l,this.visual&&H.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(l),this.stateChanged()},n.prototype.setFillColor=function(l){this.fillColor=l,this.visual&&H.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(l),this.stateChanged()},n.prototype.setStrokeWidth=function(l){this.strokeWidth=l,this.visual&&H.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},n.prototype.setStrokeDasharray=function(l){this.strokeDasharray=l,this.visual&&H.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},n.prototype.setOpacity=function(l){this.opacity=l,this.visual&&H.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){var D=l;this.fillColor=D.fillColor,this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.opacity=D.opacity,this.createVisual(),k.prototype.restoreState.call(this,l),this.setSize()},n.prototype.scale=function(l,D){k.prototype.scale.call(this,l,D),this.setSize()},n.typeName="EllipseMarker",n.title="Ellipse marker",n.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>',n}(ue),ke=function(k){function n(l,D,N){return k.call(this,l,D,N)||this}return $(n,k),Object.defineProperty(n.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.tip1&&l!==this.tip2)},n.prototype.createTips=function(){this.tip1=H.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(H.createTransform()),this.visual.appendChild(this.tip1),this.tip2=H.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(H.createTransform()),this.visual.appendChild(this.tip2)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.state==="creating"&&this.createTips()},n.prototype.adjustVisual=function(){if(k.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(H.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()]]),H.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 l=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),D=this.tip1.transform.baseVal.getItem(0);D.setRotate(l,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(D,0);var N=this.tip2.transform.baseVal.getItem(0);N.setRotate(l+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(N,0)}},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=k.prototype.getState.call(this);return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l),this.createTips(),this.adjustVisual()},n.typeName="MeasurementMarker",n.title="Measurement marker",n.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>',n}(Be),He=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.strokePanel.colors=N.defaultColorSet,R.fillColor="transparent",R}return $(n,k),Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=k.prototype.getState.call(this);return l.typeName=n.typeName,l},n.typeName="EllipseFrameMarker",n.title="Ellipse frame marker",n.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>',n}(he),$e=function(){function k(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(k.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),k.prototype.addUndoStep=function(n){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(n)||(this.undoStack.push(n),JSON.stringify(this.lastRedoStep)!==JSON.stringify(n)&&this.redoStack.splice(0,this.redoStack.length))},k.prototype.replaceLastUndoStep=function(n){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=n)},k.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},k.prototype.undo=function(){if(this.undoStack.length>1){var n=this.undoStack.pop();return n!==void 0&&this.redoStack.push(n),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},k.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},k}(),ze=function(k){function n(l,D,N){var R=k.call(this,l,D,N)||this;return R.strokeColor="transparent",R.strokeWidth=0,R.strokeDasharray="",R.curveX=0,R.curveY=0,R.manipulationStartCurveX=0,R.manipulationStartCurveY=0,R.setStrokeColor=R.setStrokeColor.bind(R),R.setStrokeWidth=R.setStrokeWidth.bind(R),R.setStrokeDasharray=R.setStrokeDasharray.bind(R),R.positionGrips=R.positionGrips.bind(R),R.addControlGrips=R.addControlGrips.bind(R),R.adjustVisual=R.adjustVisual.bind(R),R.setupControlBox=R.setupControlBox.bind(R),R.resize=R.resize.bind(R),R.strokeColor=N.defaultColor,R.strokeWidth=N.defaultStrokeWidth,R.strokeDasharray=N.defaultStrokeDasharray,R.strokePanel=new Ne("Line color",N.defaultColorSet,N.defaultColor),R.strokePanel.onColorChanged=R.setStrokeColor,R.strokeWidthPanel=new Ee("Line width",N.defaultStrokeWidths,N.defaultStrokeWidth),R.strokeWidthPanel.onWidthChanged=R.setStrokeWidth,R.strokeStylePanel=new Ce("Line style",N.defaultStrokeDasharrays,N.defaultStrokeDasharray),R.strokeStylePanel.onStyleChanged=R.setStrokeDasharray,R}return $(n,k),n.prototype.ownsTarget=function(l){return!(!k.prototype.ownsTarget.call(this,l)&&l!==this.visual&&l!==this.selectorCurve&&l!==this.visibleCurve&&!this.curveGrip.ownsTarget(l))},n.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},n.prototype.createVisual=function(){this.visual=H.createGroup(),this.selectorCurve=H.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=H.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)},n.prototype.pointerDown=function(l,D){k.prototype.pointerDown.call(this,l,D),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=l.x,this.curveY=l.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(D)&&(this.activeGrip=this.curveGrip,this._state="resize")},n.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),H.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),H.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),H.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},n.prototype.setupControlBox=function(){k.prototype.setupControlBox.call(this),this.curveControlLine1=H.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=H.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)},n.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,k.prototype.addControlGrips.call(this)},n.prototype.positionGrips=function(){k.prototype.positionGrips.call(this);var l=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-l/2,this.curveY-l/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()))},n.prototype.manipulate=function(l){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+l.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+l.y-this.manipulationStartY),k.prototype.manipulate.call(this,l)},n.prototype.resize=function(l){this.activeGrip===this.curveGrip&&(this.curveX=l.x,this.curveY=l.y),k.prototype.resize.call(this,l),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},n.prototype.setStrokeColor=function(l){this.strokeColor=l,this.adjustVisual(),this.colorChanged(l)},n.prototype.setStrokeWidth=function(l){this.strokeWidth=l,this.adjustVisual()},n.prototype.setStrokeDasharray=function(l){this.strokeDasharray=l,this.adjustVisual()},n.prototype.scale=function(l,D){this.curveX=this.curveX*l,this.curveY=this.curveY*D,k.prototype.scale.call(this,l,D)},Object.defineProperty(n.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),n.prototype.getState=function(){var l=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},k.prototype.getState.call(this));return l.typeName=n.typeName,l},n.prototype.restoreState=function(l){k.prototype.restoreState.call(this,l);var D=l;this.strokeColor=D.strokeColor,this.strokeWidth=D.strokeWidth,this.strokeDasharray=D.strokeDasharray,this.curveX=D.curveX,this.curveY=D.curveY,this.createVisual(),this.adjustVisual()},n.typeName="CurveMarker",n.title="Curve marker",n.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>',n}(Ie),Ze=function(){function k(n,l){l===void 0&&(l=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=n,this.cancelable=l}return Object.defineProperty(k.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),k.prototype.preventDefault=function(){this._defaultPrevented=!0},k}(),et=function(k){function n(l,D,N){var R=k.call(this,l,!1)||this;return R.dataUrl=D,R.state=N,R}return $(n,k),n}(Ze),Xe=function(k){function n(l,D,N){N===void 0&&(N=!1);var R=k.call(this,l,N)||this;return R.marker=D,R}return $(n,k),n}(Ze),mt=function(){function k(){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 k.prototype.addEventListener=function(n,l){this[n].push(l)},k.prototype.removeEventListener=function(n,l){var D=this[n].indexOf(l);D>-1&&this[n].splice(D,1)},k}(),rt=function(){function k(n){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new ve,this._isOpen=!1,this.undoRedoManager=new $e,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 mt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=k.instanceCounter++,this.styles=new Ae(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=n,this.targetRoot=document.body,this.width=n.clientWidth,this.height=n.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(k.prototype,"ALL_MARKER_TYPES",{get:function(){return[Te,re,te,Me,He,he,G,oe,ke,j,Be,ze]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Te,re,te,Me,he,G,oe]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Te,re,te,Me,G]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(n){var l=this;this._availableMarkerTypes.splice(0),n.forEach(function(D){if(typeof D=="string"){var N=l.ALL_MARKER_TYPES.find(function(R){return R.typeName===D});N!==void 0&&l._availableMarkerTypes.push(N)}else l._availableMarkerTypes.push(D)})},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(n){this._zoomLevel=n,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(k.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),k.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),me.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},k.prototype.show=function(){var n=this;this.styles.styleSheetRoot===void 0&&Oe.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Oe.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(l){return l(new Ze(n))})},k.prototype.render=function(){return Y(this,void 0,void 0,function(){var n;return ne(this,function(l){switch(l.label){case 0:return this.setCurrentMarker(),(n=new Le).naturalSize=this.renderAtNaturalSize,n.imageType=this.renderImageType,n.imageQuality=this.renderImageQuality,n.markersOnly=this.renderMarkersOnly,n.width=this.renderWidth,n.height=this.renderHeight,[4,n.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return l.sent(),[4,n.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,l.sent()]}})})},k.prototype.close=function(n){var l=this;if(n===void 0&&(n=!1),this.isOpen){var D=!1;n||this.eventListeners.beforeclose.forEach(function(N){var R=new Ze(l,!0);N(R),R.defaultPrevented&&(D=!0)}),D||(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(N){return N(new Ze(l))}),this.detachEvents(),this._isOpen=!1)}},k.prototype.addMarkersToToolbar=function(){for(var n,l=[],D=0;D<arguments.length;D++)l[D]=arguments[D];(n=this._availableMarkerTypes).push.apply(n,l)},k.prototype.addRenderEventListener=function(n){this.addEventListener("render",function(l){n(l.dataUrl,l.state)})},k.prototype.removeRenderEventListener=function(n){},k.prototype.addCloseEventListener=function(n){this.addEventListener("close",function(){n()})},k.prototype.removeCloseEventListener=function(n){},k.prototype.setupResizeObserver=function(){var n=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){n.resize(n.target.clientWidth,n.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return n.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},k.prototype.onPopupTargetResize=function(){var n=1*this.target.clientWidth/this.target.clientHeight,l=this.editorCanvas.clientWidth/n>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*n:this.editorCanvas.clientWidth,D=l<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/n;this.resize(l,D)},k.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},k.prototype.resize=function(n,l){this._isResizing=!0;var D=n/this.imageWidth,N=l/this.imageHeight;this.imageWidth=Math.round(n),this.imageHeight=Math.round(l),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(D,N),this._isResizing=!1},k.prototype.scaleMarkers=function(n,l){var D,N=this;this._currentMarker&&this._currentMarker instanceof Me?this._currentMarker.scale(n,l):(D=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(R){R!==N._currentMarker&&R.scale(n,l)}),D!==void 0&&this.setCurrentMarker(D)},k.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"},k.prototype.setTopLeft=function(){var n=this.editingTarget.getBoundingClientRect(),l=this.editorCanvas.getBoundingClientRect();this.left=n.left-l.left,this.top=n.top-l.top},k.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)},k.prototype.addDefs=function(){for(var n,l=[],D=0;D<arguments.length;D++)l[D]=arguments[D];this.defs=H.createDefs(),this.addDefsToImage(),(n=this.defs).append.apply(n,l)},k.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},k.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)},k.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},k.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},k.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)},k.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},k.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)},k.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 n=document.createElement("a");n.href="https://markerjs.com/",n.target="_blank",n.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>',n.title="Powered by marker.js",n.style.display="grid",n.style.alignItems="center",n.style.justifyItems="center",n.style.padding="3px",n.style.width="20px",n.style.height="20px",this.logoUI.appendChild(n),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},k.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")},k.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"},k.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},k.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 n=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=n+"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 xe(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},k.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},k.prototype.removeMarker=function(n){this.markerImage.removeChild(n.container),this.markers.indexOf(n)>-1&&this.markers.splice(this.markers.indexOf(n),1),n.dispose()},k.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())},k.prototype.toolbarButtonClicked=function(n,l){if(n==="marker"&&l!==void 0)this.createNewMarker(l);else if(n==="action")switch(l){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()}},k.prototype.deleteSelectedMarker=function(){var n=this;if(this._currentMarker!==void 0){var l=!1;if(this.eventListeners.markerbeforedelete.forEach(function(N){var R=new Xe(n,n._currentMarker,!0);N(R),R.defaultPrevented&&(l=!0)}),!l){var D=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(N){return N(new Xe(n,D))})}}},k.prototype.clear=function(){var n=this,l=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(ee){var De=new Xe(n,void 0,!0);ee(De),De.defaultPrevented&&(l=!0)}),!l)){this.setCurrentMarker();for(var D=function(ee){var De=N.markers[ee];N.setCurrentMarker(N.markers[ee]),N._currentMarker.dispose(),N.markerImage.removeChild(N._currentMarker.container),N.markers.splice(N.markers.indexOf(N._currentMarker),1),N.eventListeners.markerdelete.forEach(function(Ue){return Ue(new Xe(n,De))})},N=this,R=this.markers.length-1;R>=0;R--)D(R);this.addUndoStep()}},Object.defineProperty(k.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),k.prototype.showNotesEditor=function(){var n;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=(n=this._currentMarker.notes)!==null&&n!==void 0?n:"",this.overlayContainer.appendChild(this.notesArea))},k.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)},k.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},k.prototype.addUndoStep=function(){var n=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var l=this.getState(),D=this.undoRedoManager.getLastUndoStep();if(!D||D.width===l.width&&D.height===l.height){var N=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(l),N<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(R){return R(new Ze(n))})}else this.undoRedoManager.replaceLastUndoStep(l),this.eventListeners.statechange.forEach(function(R){return R(new Ze(n))})}},k.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},k.prototype.undoStep=function(){var n=this,l=this.undoRedoManager.undo();l!==void 0&&(this.restoreState(l),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Ze(n))}))},k.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},k.prototype.redoStep=function(){var n=this,l=this.undoRedoManager.redo();l!==void 0&&(this.restoreState(l),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(D){return D(new Ze(n))}))},k.prototype.stepZoom=function(){var n=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=n<this.zoomSteps.length-1?this.zoomSteps[n+1]:this.zoomSteps[0]},k.prototype.panTo=function(n){this.contentDiv.scrollBy({left:this.prevPanPoint.x-n.x,top:this.prevPanPoint.y-n.y}),this.prevPanPoint=n},k.prototype.startRenderAndClose=function(){return Y(this,void 0,void 0,function(){var n,l,D=this;return ne(this,function(N){switch(N.label){case 0:return[4,this.render()];case 1:return n=N.sent(),l=this.getState(),this.eventListeners.render.forEach(function(R){return R(new et(D,n,l))}),this.close(!0),[2]}})})},k.prototype.getState=function(n){n===!0&&this.setCurrentMarker();var l={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(D){return l.markers.push(D.getState())}),l},k.prototype.restoreState=function(n){var l=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);n.markers.forEach(function(D){var N=l._availableMarkerTypes.find(function(ee){return ee.typeName===D.typeName});if(N!==void 0){var R=l.addNewMarker(N);R.restoreState(D),l.markers.push(R)}}),n.width&&n.height&&(n.width!==this.imageWidth||n.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/n.width,this.imageHeight/n.height),this.eventListeners.restorestate.forEach(function(D){return D(new Ze(l))})},k.prototype.addNewMarker=function(n){var l=H.createGroup();return this.markerImage.appendChild(l),new n(l,this.overlayContainer,this.settings)},k.prototype.createNewMarker=function(n){var l,D=this;(l=typeof n=="string"?this._availableMarkerTypes.find(function(N){return N.typeName===n}):n)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(l),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(l.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(N){return N(new Xe(D,D._currentMarker))}))},k.prototype.markerCreated=function(n){var l=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(n),this.setCurrentMarker(n),n instanceof re&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(re):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(D){return D(new Xe(l,l._currentMarker))})},k.prototype.colorChanged=function(n){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=n,this.settings.defaultStrokeColor=n)},k.prototype.fillColorChanged=function(n){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=n)},k.prototype.markerStateChanged=function(n){var l=this;this.eventListeners.markerchange.forEach(function(D){return D(new Xe(l,n))})},k.prototype.setCurrentMarker=function(n){var l=this;this._currentMarker!==n&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(D){return D(new Xe(l,l._currentMarker))})),this._currentMarker=n,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(D){return D(new Xe(l,l._currentMarker))}))},k.prototype.onPointerDown=function(n){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||n.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var l=this.markers.find(function(D){return D.ownsTarget(n.target)});l!==void 0?(this.setCurrentMarker(l),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(n.clientX,n.clientY),n.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:n.clientX,y:n.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(n.clientX,n.clientY))},k.prototype.onDblClick=function(n){if(this._isFocused||this.focus(),this.mode==="select"){var l=this.markers.find(function(D){return D.ownsTarget(n.target)});l!==void 0&&l!==this._currentMarker&&this.setCurrentMarker(l),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(n.clientX,n.clientY),n.target):this.setCurrentMarker()}},k.prototype.onPointerMove=function(n){this.touchPoints!==1&&n.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||n.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(n.clientX,n.clientY)):this.zoomLevel>1&&this.panTo({x:n.clientX,y:n.clientY}))},k.prototype.onPointerUp=function(n){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(n.clientX,n.clientY)),this.isDragging=!1,this.addUndoStep()},k.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},k.prototype.onKeyUp=function(n){this._currentMarker===void 0||this.notesArea!==void 0||n.key!=="Delete"&&n.key!=="Backspace"||this.deleteSelectedMarker()},k.prototype.clientToLocalCoordinates=function(n,l){var D=this.markerImage.getBoundingClientRect();return{x:(n-D.left)/this.zoomLevel,y:(l-D.top)/this.zoomLevel}},k.prototype.onWindowResize=function(){this.positionUI()},k.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var n=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=n+"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()},k.prototype.addLicenseKey=function(n){me.addKey(n)},k.prototype.addEventListener=function(n,l){this.eventListeners.addEventListener(n,l)},k.prototype.removeEventListener=function(n,l){this.eventListeners.removeEventListener(n,l)},k.prototype.renderState=function(n){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(n),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(k.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),k.prototype.focus=function(){var n=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(l){return l(new Ze(n))}))},k.prototype.blur=function(){var n=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(l){return l(new Ze(n))}))},k.instanceCounter=0,k}();/* **********************************
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 vt=function(k,n){return(vt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,D){l.__proto__=D}||function(l,D){for(var N in D)Object.prototype.hasOwnProperty.call(D,N)&&(l[N]=D[N])})(k,n)};function ct(k,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function l(){this.constructor=k}vt(k,n),k.prototype=n===null?Object.create(n):(l.prototype=n.prototype,new l)}function qe(k,n,l,D){return new(l||(l=Promise))(function(N,R){function ee(je){try{Ue(D.next(je))}catch(we){R(we)}}function De(je){try{Ue(D.throw(je))}catch(we){R(we)}}function Ue(je){var we;je.done?N(je.value):(we=je.value,we instanceof l?we:new l(function(Ge){Ge(we)})).then(ee,De)}Ue((D=D.apply(k,n||[])).next())})}function yt(k,n){var l,D,N,R,ee={label:0,sent:function(){if(1&N[0])throw N[1];return N[1]},trys:[],ops:[]};return R={next:De(0),throw:De(1),return:De(2)},typeof Symbol=="function"&&(R[Symbol.iterator]=function(){return this}),R;function De(Ue){return function(je){return function(we){if(l)throw new TypeError("Generator is already executing.");for(;ee;)try{if(l=1,D&&(N=2&we[0]?D.return:we[0]?D.throw||((N=D.return)&&N.call(D),0):D.next)&&!(N=N.call(D,we[1])).done)return N;switch(D=0,N&&(we=[2&we[0],N.value]),we[0]){case 0:case 1:N=we;break;case 4:return ee.label++,{value:we[1],done:!1};case 5:ee.label++,D=we[1],we=[0];continue;case 7:we=ee.ops.pop(),ee.trys.pop();continue;default:if(!(N=ee.trys,(N=N.length>0&&N[N.length-1])||we[0]!==6&&we[0]!==2)){ee=0;continue}if(we[0]===3&&(!N||we[1]>N[0]&&we[1]<N[3])){ee.label=we[1];break}if(we[0]===6&&ee.label<N[1]){ee.label=N[1],N=we;break}if(N&&ee.label<N[2]){ee.label=N[2],ee.ops.push(we);break}N[2]&&ee.ops.pop(),ee.trys.pop();continue}we=n.call(k,ee)}catch(Ge){we=[6,Ge],D=0}finally{l=N=0}if(5&we[0])throw we[1];return{value:we[0]?we[1]:void 0,done:!0}}([Ue,je])}}}var bt=function(){function k(){}return k.addKey=function(n){k.key=n},Object.defineProperty(k,"isLicensed",{get:function(){return!!k.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(k.key)},enumerable:!1,configurable:!0}),k}(),Ve=function(){function k(){}return k.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},k.setAttributes=function(n,l){for(var D=0,N=l;D<N.length;D++){var R=N[D],ee=R[0],De=R[1];n.setAttribute(ee,De)}},k.createRect=function(n,l,D){var N=document.createElementNS("http://www.w3.org/2000/svg","rect");return N.setAttribute("width",n.toString()),N.setAttribute("height",l.toString()),D&&k.setAttributes(N,D),N},k.createLine=function(n,l,D,N,R){var ee=document.createElementNS("http://www.w3.org/2000/svg","line");return ee.setAttribute("x1",n.toString()),ee.setAttribute("y1",l.toString()),ee.setAttribute("x2",D.toString()),ee.setAttribute("y2",N.toString()),R&&k.setAttributes(ee,R),ee},k.createPolygon=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","polygon");return D.setAttribute("points",n),l&&k.setAttributes(D,l),D},k.createCircle=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","circle");return D.setAttribute("cx",(n/2).toString()),D.setAttribute("cy",(n/2).toString()),D.setAttribute("r",n.toString()),l&&k.setAttributes(D,l),D},k.createEllipse=function(n,l,D){var N=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return N.setAttribute("cx",(n/2).toString()),N.setAttribute("cy",(l/2).toString()),N.setAttribute("rx",(n/2).toString()),N.setAttribute("ry",(l/2).toString()),D&&k.setAttributes(N,D),N},k.createGroup=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","g");return n&&k.setAttributes(l,n),l},k.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},k.createMarker=function(n,l,D,N,R,ee,De){var Ue=document.createElementNS("http://www.w3.org/2000/svg","marker");return k.setAttributes(Ue,[["id",n],["orient",l],["markerWidth",D.toString()],["markerHeight",N.toString()],["refX",R.toString()],["refY",ee.toString()]]),Ue.appendChild(De),Ue},k.createText=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","text");return l.setAttribute("x","0"),l.setAttribute("y","0"),n&&k.setAttributes(l,n),l},k.createTSpan=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","tspan");return D.textContent=n,l&&k.setAttributes(D,l),D},k.createImage=function(n){var l=document.createElementNS("http://www.w3.org/2000/svg","image");return n&&k.setAttributes(l,n),l},k.createPoint=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return D.x=n,D.y=l,D},k.createPath=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg","path");return D.setAttribute("d",n),l&&k.setAttributes(D,l),D},k.createElement=function(n,l){var D=document.createElementNS("http://www.w3.org/2000/svg",n);return l&&k.setAttributes(D,l),D},k.getHollowRectanglePath=function(n,l,D,N,R,ee,De,Ue){return"M"+n+","+l+"V"+(l+N)+"H"+(n+D)+"V"+l+"H"+R+"V"+ee+"H"+(R+De)+"V"+(ee+Ue)+"H"+R+"V"+l+"Z"},k}(),wt=function(){function k(n){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+n+"_"}return Object.defineProperty(k.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(k.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(k.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),k.prototype.addClass=function(n){return this.styleSheet===void 0&&this.addStyleSheet(),n.name=""+this.classNamePrefix+n.localName,this.classes.push(n),this.styleSheet.sheet.insertRule("."+n.name+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length),n},k.prototype.addRule=function(n){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(n),this.styleSheet.sheet.insertRule(n.selector+" {"+n.style+"}",this.styleSheet.sheet.cssRules.length)},k.prototype.addStyleSheet=function(){var n;this.styleSheet=document.createElement("style"),((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).appendChild(this.styleSheet),this.addRule(new at("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new at("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new at("@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;
`))},k.prototype.removeStyleSheet=function(){var n;this.styleSheet&&(((n=this.styleSheetRoot)!==null&&n!==void 0?n:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},k}(),at=function(k,n){this.selector=k,this.style=n},ut=function(k,n){this.localName=k,this.style=n},At=function(){function k(){this.blocks=[],this.display=""}return k.prototype.addButtonBlock=function(n){n.className=this.blockClassName,n.buttonClassName=this.buttonClassName,n.buttonColorsClassName=this.buttonColorsClassName,n.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(n)},k.prototype.addElementBlock=function(n){n.className===void 0&&(n.className=this.blockClassName),this.blocks.push(n)},k.prototype.getUI=function(){var n=document.createElement("div");return n.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,n.style.display=this.display,this.blocks.forEach(function(l){return n.appendChild(l.getUI())}),n},k}(),St=function(){function k(){}return k.prototype.getUI=function(){var n=document.createElement("div");if(n.className=this.className,this.minWidth!==void 0&&(n.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":n.style.justifyContent="flex-start";break;case"center":n.style.justifyContent="center";break;case"end":n.style.justifyContent="flex-end"}return n.style.whiteSpace="nowrap",n},k}(),Rt=function(k){function n(){var l=k!==null&&k.apply(this,arguments)||this;return l.buttons=[],l}return ct(n,k),n.prototype.addButton=function(l){l.className=this.buttonClassName,l.colorsClassName=this.buttonColorsClassName,l.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(l)},n.prototype.getUI=function(){var l=k.prototype.getUI.call(this);return this.buttons.forEach(function(D){return l.appendChild(D.getUI())}),l},n}(St),it=function(){function k(n,l){this._isActive=!1,this._isHidden=!1,this._icon=n,this.title=l,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(k.prototype,"icon",{get:function(){return this._icon},set:function(n){this._icon=n,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isActive",{get:function(){return this._isActive},set:function(n){this._isActive=n,this.adjustClassName()},enumerable:!1,configurable:!0}),k.prototype.getUI=function(){var n=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 n.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},k.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,"")))},k.prototype.hide=function(){this._isHidden=!0},k}(),Qe=function(k){function n(){var l=k!==null&&k.apply(this,arguments)||this;return l.elements=[],l}return ct(n,k),n.prototype.addElement=function(l){this.elements.push(l)},n.prototype.getUI=function(){var l=k.prototype.getUI.call(this);return this.elements.forEach(function(D){return l.appendChild(D)}),l},n}(St),Ye=function(){function k(n,l){this.horizontal=n,this.vertical=l}return Object.defineProperty(k.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),k.prototype.getVerticalLength=function(n){return n/this.ratio},k.prototype.getHorizontalLength=function(n){return n*this.ratio},k}(),ot=function(){function k(){}return k.getIcon=function(n,l){if(n>0&&l>0){var D=new Ye(n,l),N=D.ratio>=1?20:D.getHorizontalLength(20),R=D.ratio<1?20:D.getVerticalLength(20),ee=document.createElementNS("http://www.w3.org/2000/svg","svg");ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),ee.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ee);var De=Ve.createDefs();ee.appendChild(De);var Ue=Ve.createElement("clipPath",[["id","text-bg-clip"]]);De.appendChild(Ue);var je=Ve.createPath(Ve.getHollowRectanglePath((24-N)/2,(24-R)/2,N,R,(24-N)/2+2,(24-R)/2+2,N-4,R-4));ee.appendChild(je);var we=Ve.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);we.appendChild(Ve.createTSpan(n+":"+l)),ee.appendChild(we);var Ge=we.getBBox();Ve.setAttributes(we,[["x",((24-Ge.width)/2).toString()],["y",((24-Ge.height)/2-Ge.y).toString()]]);var Ke=Ve.createPath(Ve.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Ge.width))/2,(24-Math.ceil(Ge.height))/2,Math.ceil(Ge.width),Math.ceil(Ge.height)));return Ue.appendChild(Ke),Ve.setAttributes(je,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ee),ee.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>'},k}(),dt=function(k){function n(l,D,N){var R=k.call(this,l,D)||this;return R.isDropdownOpen=!1,R.onClick=R.dropdownButtonClicked,R.dropdownButtons=N,R}return ct(n,k),n.prototype.setupDropdown=function(){var l=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(D){D.className=l.className,D.colorsClassName=l.colorsClassName,l.dropdownBlock.appendChild(D.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},n.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},n.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},n.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},n.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},n.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},n}(it),tt=function(){function k(n,l){this.GRIP_SIZE=10,this.color=n,this.fillColor=l,this.visual=Ve.createGroup(),this.visual.appendChild(Ve.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(Ve.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return k.prototype.ownsTarget=function(n){return n===this.visual||n===this.visual.childNodes[0]||n===this.visual.childNodes[1]},k.prototype.setCenter=function(n,l){this.visual.childNodes.forEach(function(D){return Ve.setAttributes(D,[["cx",n.toString()],["cy",l.toString()]])})},k}(),st=function(){function k(n,l,D,N){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=n,this.canvasHeight=l,this.margin=D,this.container=N,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(k.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(n){this._aspectRatio=n,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(n){this._isGridVisible=n,this.gridContainer&&Ve.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(n){this._zoomFactor=n,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),k.prototype.open=function(){var n=this;this.cropShadeElement=Ve.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=Ve.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var l=0;l<this.numberOfGridLines;l++)this.horizontalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(Ve.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(D){return n.gridContainer.appendChild(D)}),this.verticalGridLines.forEach(function(D){return n.gridContainer.appendChild(D)}),this.cropRectElement=Ve.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new tt(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},k.prototype.setCropRectangle=function(n){this.cropRect=n;var l=Object.assign({},this.cropRect);this.zoomFactor!==1&&(l.width=this.cropRect.width*this.zoomFactor,l.height=this.cropRect.height*this.zoomFactor,l.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-l.width/2,l.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-l.height/2),Ve.setAttributes(this.cropRectElement,[["x",l.x.toString()],["y",l.y.toString()],["width",l.width.toString()],["height",l.height.toString()]]);var D=l.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(R,ee){var De=l.y+D*(ee+1);Ve.setAttributes(R,[["x1",""+l.x],["y1",""+De],["x2",""+(l.x+l.width)],["y2",""+De]])});var N=l.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(R,ee){var De=l.x+N*(ee+1);Ve.setAttributes(R,[["x1",""+De],["y1",""+l.y],["x2",""+De],["y2",""+(l.y+l.height)]])}),Ve.setAttributes(this.cropShadeElement,[["d",Ve.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,l.x,l.y,l.width,l.height)]]),this.topLeftGrip.setCenter(l.x,l.y),this.topRightGrip.setCenter(l.x+l.width,l.y),this.bottomLeftGrip.setCenter(l.x,l.y+l.height),this.bottomRightGrip.setCenter(l.x+l.width,l.y+l.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},k.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)},k.prototype.clientToLocalCoordinates=function(n,l){var D=this.container.getBoundingClientRect();return{x:n-D.left+this.margin,y:l-D.top+this.margin}},k.prototype.onPointerDown=function(n){this.container.setPointerCapture(n.pointerId),this.previousPoint=this.clientToLocalCoordinates(n.clientX,n.clientY),this.cropRectElement===n.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(n.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(n.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(n.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(n.target)&&(this.activeGrip=this.bottomRightGrip)},k.prototype.onPointerMove=function(n){if(this.isMoving)this.move(this.clientToLocalCoordinates(n.clientX,n.clientY));else if(this.activeGrip){var l=this.clientToLocalCoordinates(n.clientX,n.clientY);this.resize(l)}n.preventDefault()},k.prototype.onPointerUp=function(n){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(n.pointerId)},k.prototype.move=function(n){var l=n.x-this.previousPoint.x,D=n.y-this.previousPoint.y;this.zoomFactor!==1&&(l=-l/this.zoomFactor,D=-D/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+l),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+D),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=n},k.prototype.resize=function(n){var l=Object.assign({},this.cropRect),D=n.x-this.previousPoint.x,N=n.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:l.x+D<this.margin&&(D=this.margin-l.x),l.x+=D,l.width=this.cropRect.x+this.cropRect.width-l.x;break;case this.bottomRightGrip:case this.topRightGrip:l.width+D>this.canvasWidth*this.zoomFactor&&(D=this.canvasWidth*this.zoomFactor-l.width),l.width+=D}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(l.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(D),l.height=this.aspectRatio.getVerticalLength(l.width)):(l.y+=N,l.height=this.cropRect.y+this.cropRect.height-l.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?l.height=this.aspectRatio.getVerticalLength(l.width):l.height+=N}l.width<10&&(l.x=this.cropRect.x,l.width=10),l.height<10&&(l.y=this.cropRect.y,l.height=10),this.previousPoint=n,l.x>=this.margin&&l.y>=this.margin&&l.x-this.margin+l.width<=this.canvasWidth&&l.y-this.margin+l.height<=this.canvasHeight&&(this.cropRect=l,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},k.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var n=this.cropRect.x+this.cropRect.width/2,l=this.cropRect.y+this.cropRect.height/2,D=this.aspectRatio.getHorizontalLength(this.cropRect.height),N=this.aspectRatio.getVerticalLength(this.cropRect.width);D/this.canvasWidth<N/this.canvasHeight?this.cropRect.width=D:this.cropRect.height=N,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=n-this.cropRect.width/2,this.cropRect.y=l-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)}},k.prototype.getRescaledRect=function(n,l,D,N,R,ee){var De=D/n,Ue=N/l;return{x:(R.x-ee)*De+ee,y:(R.y-ee)*Ue+ee,width:R.width*De,height:R.height*Ue}},k.prototype.scaleCanvas=function(n,l){var D=this.getRescaledRect(this.canvasWidth,this.canvasHeight,n,l,this.cropRect,this.margin);this.canvasWidth=n,this.canvasHeight=l,this.onCropChange&&this.onCropChange(D),this.setCropRectangle(D)},k}(),ft=function(){function k(n){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=n,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(k.prototype,"angle",{get:function(){return this._angle},set:function(n){this._angle=n,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),k.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},k.prototype.onPointerDown=function(n){this.controlContainer.setPointerCapture(n.pointerId),this.isDragging=!0,this.previousPoint={x:n.clientX,y:n.clientY}},k.prototype.onPointerMove=function(n){this.isDragging&&(this.onAngleChange&&this.onAngleChange((n.clientX-this.previousPoint.x)/5),this.previousPoint.x=n.clientX)},k.prototype.onPointerUp=function(n){this.isDragging&&this.onAngleChange&&this.onAngleChange((n.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(n.pointerId)},k.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var n=this.angleLabelText.getBBox();Ve.setAttributes(this.angleLabelElement,[["x",((this.width-n.width)/2).toString()],["y",(this.height/2).toString()]])}},k.prototype.positionScaleShape=function(){if(this.scaleShape){var n=this.scaleShape.transform.baseVal.getItem(0);n.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(n,0)}},k.prototype.getVisual=function(){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",this.width+"px"),n.setAttribute("height",this.height+"px"),n.setAttribute("viewBox","0 0 "+this.width+" "+this.height),n.style.flexShrink="0",document.body.appendChild(n);for(var l="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,D=1;D<=this.width/5+10;D++){var N=D%5==0?this.height/3:this.height/6;l+="h4v"+-N+"h1v"+N}l+="v1H0Z",this.scaleShape=Ve.createPath(l);var R=Ve.createTransform();this.scaleShape.transform.baseVal.appendItem(R),n.appendChild(this.scaleShape),this.angleLabelElement=Ve.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=Ve.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ee=Ve.createTSpan("");return ee.innerHTML="&deg;",this.angleLabelElement.appendChild(ee),n.appendChild(this.angleLabelElement),document.body.removeChild(n),n},k}(),Ot=function(){function k(){this.naturalSize=!1,this.imageType="image/png"}return k.prototype.rasterize=function(n,l,D,N,R,ee,De){var Ue=this;return new Promise(function(je){var we=document.createElement("canvas");we.width=n.width.baseVal.value-2*N,we.height=n.height.baseVal.value-2*N;var Ge=1,Ke=1;Ue.naturalSize===!0?(Ge=l.naturalWidth/(n.width.baseVal.value-2*N)/ee,Ke=l.naturalHeight/(n.height.baseVal.value-2*N)/De,we.width=l.naturalWidth/ee,we.height=l.naturalHeight/De):Ue.width!==void 0&&Ue.height!==void 0&&(Ge=Ue.width/D.width,Ke=Ue.height/D.height,we.width*=Ge,we.height*=Ke);var Je=we.getContext("2d");Je.translate(we.width/2,we.height/2),Je.rotate(R*Math.PI/180),Je.scale(ee,De),Je.translate(-we.width/2,-we.height/2),Je.drawImage(l,0,0,we.width,we.height);var xt=document.createElement("canvas");xt.width=D.width*Ge,xt.height=D.height*Ke,xt.getContext("2d").putImageData(Je.getImageData((D.x-N)*Ge,(D.y-N)*Ke,D.width*Ge,D.height*Ke),0,0),je(xt.toDataURL(Ue.imageType,Ue.imageQuality))})},k}(),Ft=function(){function k(n){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=k.instanceCounter++,this.styles=new wt(this.instanceNo),this.target=n,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(k.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(n){this._zoomToCropEnabled=n,n?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(n){this._isGridVisible=n,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"gridLines",{get:function(){return this._gridLines},set:function(n){this._gridLines=n,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(n){this._rotationAngle=n,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"aspectRatio",{get:function(){var n;return(n=this._aspectRatio)!==null&&n!==void 0?n:this.aspectRatios[0]},set:function(n){this._aspectRatio=n},enumerable:!1,configurable:!0}),k.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},k.prototype.show=function(){this.showUI(),this.open()},k.prototype.close=function(n){n===void 0&&(n=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),n||this.closeEventListeners.forEach(function(l){return l()}),this._isOpen=!1)},k.prototype.addRenderEventListener=function(n){this.renderEventListeners.push(n)},k.prototype.removeRenderEventListener=function(n){this.renderEventListeners.indexOf(n)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(n),1)},k.prototype.addCloseEventListener=function(n){this.closeEventListeners.push(n)},k.prototype.removeCloseEventListener=function(n){this.closeEventListeners.indexOf(n)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(n),1)},k.prototype.setupResizeObserver=function(){var n=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){n.resize(n.target.clientWidth,n.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))},k.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var n=1*this.target.clientWidth/this.target.clientHeight,l=this.contentDiv.clientWidth/n>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*n:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,D=l+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/n;this.resize(l,D)}},k.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},k.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",Ve.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},k.prototype.resize=function(n,l){this.imageWidth=Math.round(n),this.imageHeight=Math.round(l),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()},k.prototype.setEditingTarget=function(){var n=document.createElement("canvas");n.width=this.target.naturalWidth,n.height=this.target.naturalHeight,n.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var l=n.toDataURL();Ve.setAttributes(this.editingTarget,[["href",l]]),this.setEditingTargetSize()},k.prototype.setTopLeft=function(){var n=this.target.getBoundingClientRect(),l=this.editorCanvas.getBoundingClientRect();this.left=n.left-l.left-this.CANVAS_MARGIN,this.top=n.top-l.top-this.CANVAS_MARGIN},k.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=Ve.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=Ve.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer=Ve.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var n=Ve.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(n);var l=Ve.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(l),this.editingTargetContainer=Ve.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)},k.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},k.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=Ve.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new st(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()},k.prototype.zoomToCrop=function(){if(this.cropRect){var n=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,l=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=n+"px "+l+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-n+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-l+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},k.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)},k.prototype.cropRectChanged=function(n){this.cropRect=n,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},k.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},k.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"},k.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},k.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 n=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,l=this.target.offsetTop>n+this.CANVAS_MARGIN?this.target.offsetTop-(n+this.CANVAS_MARGIN):0;this.coverDiv.style.top=l+"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},k.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},k.prototype.addTopToolbar=function(){var n=this;this.topToolbar=new At,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 l=new Rt;l.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(l);var D=[];this.aspectRatios.forEach(function(Ke){var Je=new it(ot.getIcon(Ke.horizontal,Ke.vertical),Ke.horizontal===0&&Ke.vertical===0?"FREE":Ke.horizontal+":"+Ke.vertical);Je.onClick=function(){return n.ratioButtonClicked(Ke)},D.push(Je)}),this.aspectRatioButton=new dt(ot.getIcon(0,0),"Aspect ratio",D),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,l.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var N=new it('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");N.isActive=this.isGridVisible,N.onClick=function(){n.isGridVisible=!n.isGridVisible,N.isActive=n.isGridVisible},l.addButton(N);var R=new it('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(R.isActive=this.zoomToCropEnabled,R.onClick=function(){n.zoomToCropEnabled=!n.zoomToCropEnabled,R.isActive=n.zoomToCropEnabled},l.addButton(R),!bt.isLicensed){var ee=new Qe;this.topToolbar.addElementBlock(ee);var De=document.createElement("div");De.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ue=document.createElement("a");Ue.style.color="currentColor",Ue.href="https://markerjs.com/products/cropro",Ue.target="_blank",Ue.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>',De.appendChild(Ue),ee.addElement(De)}var je=new Rt;je.minWidth=3*this.toolbarHeight+"px",je.contentAlign="end",this.topToolbar.addButtonBlock(je);var we=new it('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");we.onClick=this.startRenderAndClose,je.addButton(we),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(we.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Ge=new it('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");Ge.onClick=this.close,je.addButton(Ge),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Ge.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},k.prototype.addBottomToolbar=function(){var n=this;this.bottomToolbar=new At,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 l=new Rt;l.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(l);var D=new it('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");D.onClick=this.rotateLeftButtonClicked,l.addButton(D);var N=new it('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");N.onClick=this.rotateRightButtonClicked,l.addButton(N);var R=new Qe;R.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(R),this.straightener=new ft("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(je){n.rotateBy(je),n.straightener.angle=n.rotationAngle},R.addElement(this.straightener.getUI());var ee=new Rt;ee.minWidth=2*this.toolbarHeight+"px",ee.contentAlign="end",this.bottomToolbar.addButtonBlock(ee);var De=new it('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");De.onClick=this.flipHorizontallyButtonClicked,ee.addButton(De);var Ue=new it('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");Ue.onClick=this.flipVerticallyButtonClicked,ee.addButton(Ue)},k.prototype.ratioButtonClicked=function(n){this.aspectRatio=n,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},k.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=ot.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},k.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Ye(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},k.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},k.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},k.prototype.restoreState=function(n){if(n){var l=this.cropLayer.getRescaledRect(n.width,n.height,this.imageWidth,this.imageHeight,n.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(l),this.cropRectChanged(l),this.flippedHorizontally=n.flippedHorizontally,this.flippedVertically=n.flippedVertically,this.applyFlip(),this.rotationAngle=n.rotationAngle,this.applyRotation()}},k.prototype.clientToLocalCoordinates=function(n,l){var D=this.cropImage.getBoundingClientRect();return{x:n-D.left,y:l-D.top}},k.prototype.onWindowResize=function(){this.positionUI()},k.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var n=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=n+"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()},k.prototype.rotateLeftButtonClicked=function(){var n=this.rotationAngle-90;this.rotationAngle%90!=0&&(n+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(n)},k.prototype.rotateRightButtonClicked=function(){var n=this.rotationAngle+90;this.rotationAngle%90!=0&&(n-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(n)},k.prototype.rotateTo=function(n){n=(n=n>180?n-360:n)<=-180?n+360:n,this.rotationAngle=n,this.applyRotation()},k.prototype.rotateBy=function(n){this.rotateTo((this.rotationAngle+n)%360)},k.prototype.applyRotation=function(){var n=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var l=this.editingTargetRotationContainer.transform.baseVal.getItem(0);l.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(l,0);var D=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/D.width,this.imageHeight/D.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=n},k.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},k.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},k.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},k.prototype.startRenderAndClose=function(){return qe(this,void 0,void 0,function(){var n,l;return yt(this,function(D){switch(D.label){case 0:return[4,this.render()];case 1:return n=D.sent(),l=this.getState(),this.renderEventListeners.forEach(function(N){return N(n,l)}),this.close(!0),[2]}})})},k.prototype.render=function(){return qe(this,void 0,void 0,function(){var n;return yt(this,function(l){switch(l.label){case 0:return(n=new Ot).naturalSize=this.renderAtNaturalSize,n.imageType=this.renderImageType,n.imageQuality=this.renderImageQuality,n.width=this.renderWidth,n.height=this.renderHeight,this.unzoomFromCrop(),Ve.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,n.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 l.sent(),[4,n.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,l.sent()]}})})},k.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 n=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ut("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*n)+`px;
height: `+(this.toolbarHeight-2*n)+`px;
padding: `+n+`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 at("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new at("."+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*n)+`px;
padding: `+n+`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;
`))},k.instanceCounter=0,k}(),_t=J("8hTe"),Wt=J.n(_t),jt=/<pre[^>]*>/g;function Vt(k){var n=document.createElement("div");return n.innerHTML=k,n.childNodes.length===0?"":n.childNodes[0].nodeValue}var Ht=We.a=function(k){var n=k.value,l=n===void 0?"":n,D=k.edit,N=D===void 0?!1:D,R=k.className,ee=k.showTextOnly,De=k.showLines,Ue=k.replaces,je=k.zoomImg,we=k.hasMask,Ge=k.style,Ke=Ge===void 0?{}:Ge,Je=k.stylesPrev,xt=Je===void 0?{}:Je,gt=String(l),Et=Object(w.useRef)(),Ct=Object(w.useRef)(),Kt=Object(w.useState)(""),Nt=Object(_.a)(Kt,2),pt=Nt[0],Lt=Nt[1],Gt=Object(w.useState)("office"),kt=Object(_.a)(Gt,2),Xt=kt[0],Dt=kt[1],It=function(){var ht=new Ft(Ct.current);ht.displayMode="popup",ht.addRenderEventListener(function(){var Bt=Object(A.a)(L.a.mark(function lt(Ut){var Tt;return L.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:return Et.current.style.display="none",Mt.next=3,Object(de.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Ut}});case 3:Tt=Mt.sent,Tt!=null&&Tt.id&&Ue(Ct.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Tt==null?void 0:Tt.id,"?type=").concat(Tt.content_type));case 5:case"end":return Mt.stop()}},lt)}));return function(lt){return Bt.apply(this,arguments)}}()),ht.show()},Jt=function(){var ht=new rt(Ct.current);ht.settings.displayMode="popup",ht.addEventListener("render",function(){var Bt=Object(A.a)(L.a.mark(function lt(Ut){var Tt;return L.a.wrap(function(Mt){for(;;)switch(Mt.prev=Mt.next){case 0:if(Et.current.style.display="none",!Ct.current){Mt.next=6;break}return Mt.next=4,Object(de.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Ut.dataUrl}});case 4:Tt=Mt.sent,Tt!=null&&Tt.id&&Ue(Ct.current.getAttribute("src").replace(ie.a.API_SERVER,""),"/api/attachments/".concat(Tt==null?void 0:Tt.id,"?type=").concat(Tt.content_type));case 6:case"end":return Mt.stop()}},lt)}));return function(lt){return Bt.apply(this,arguments)}}()),ht.show(),window.markerArea=ht},$t=Object(w.useMemo)(function(){try{var Pt=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,ht=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Bt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;gt=gt.replace(Pt,"("+ie.a.API_SERVER+"/api/attachments/").replace(ht,'"'+ie.a.API_SERVER+"/api/attachments/").replace(Bt,'"'+ie.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,`
`),gt=gt.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
`)}catch(Zt){}var lt=K(gt),Ut=m();if(gt.match(/\[TOC\]/)&&(lt=lt.replace("<p>[TOC]</p>",p()),f()),lt=lt.replace(/(__special_katext_id_\d+__)/g,function(Zt,Mt){var Qt=Ut[Mt],tr=Qt.type,rr=Qt.expression;return Object(pe.renderToString)(Vt(rr)||"",{displayMode:tr==="block",throwOnError:!1,output:"html"})}),lt=lt.replace(/▁/g,"\u2581\u2581\u2581"),g(),ee){var Tt=document.createElement("div");return Tt.innerHTML=lt,Tt.innerText}return setTimeout(function(){return qt()},500),lt},[gt]),zt=Object(w.useRef)();d.WebkitLineClamp=De,De&&(Ke=Object(O.a)(Object(O.a)({},Ke),d));function Yt(Pt){var ht=Pt.target;if(ht.tagName.toUpperCase()==="IMG"){if(je){var Bt=ht.getAttribute("src");Lt(Bt),Dt("image")}}else if(ht.tagName.toUpperCase()==="A"){var lt=ht.getAttribute("href");if(lt.indexOf("office")>-1)Pt.preventDefault(),Lt(lt),Dt("office");else if(lt.indexOf("application/pdf")>-1)Pt.preventDefault(),Lt(lt),Dt("pdf");else if(lt.indexOf("type=text")>-1)Pt.preventDefault(),Lt(lt),Dt("html");else if(lt.startsWith("#")){Pt.preventDefault();var Ut=document.getElementById(lt.replace("#",""));Ut&&Ut.scrollIntoView(!0)}}}var qt=function(){var ht,Bt=(ht=zt.current)===null||ht===void 0?void 0:ht.querySelectorAll("video");Bt==null||Bt.forEach(function(lt){if(lt.oncontextmenu=function(){return!1},lt.src.indexOf(".m3u8")>-1&&!lt.canPlayType("application/vnd.apple.mpegurl")){if(Z.a.isSupported()){var Ut=new Z.a;Ut.loadSource(lt.src),Ut.attachMedia(lt)}}})};Object(w.useEffect)(function(){if(zt.current&&$t&&($t.match(jt)&&window.PR.prettyPrint()),zt.current)return zt.current.addEventListener("click",Yt),function(){zt.current.removeEventListener("click",Yt),g(),f()}},[$t,zt.current,Yt]);var er=function(ht){if(!N)return;ht.target.nodeName==="IMG"?(Et.current.style.display="flex",Et.current.style.width=ht.target.clientWidth+"px",Et.current.style.height=ht.target.clientHeight+"px",Et.current.style.top=ht.target.offsetTop+"px",Et.current.style.left=ht.target.offsetLeft+"px",Ct.current.src=ht.target.getAttribute("src")):Et.current.style.display="none"};return y.a.createElement("div",{style:{position:"relative"}},y.a.createElement("div",{ref:zt,style:Object(O.a)({},Ke),className:"".concat(R||""," markdown-body ").concat(Wt.a.mdBody),onMouseOver:er,dangerouslySetInnerHTML:{__html:$t}}),y.a.createElement("div",{ref:Et,className:Wt.a.button},y.a.createElement(U.a,null,y.a.createElement(B.a,{onClick:function(){return It()}},"\u88C1\u526A"),y.a.createElement(B.a,{onClick:function(){return Jt()}},"\u7F16\u8F91"))),y.a.createElement("img",{ref:Ct,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),y.a.createElement(ae.a,{close:!0,data:pt,hasMask:we,type:pt!=null&&pt.length?Xt:"",style:Object(O.a)({},xt),onClose:function(){return Lt("")}}))}},BU3w:function(nt,We,J){"use strict";J.d(We,"a",function(){return A});var ce=J("MNnm"),U="rc-util-key";function S(_){if(_.attachTo)return _.attachTo;var M=document.querySelector("head");return M||document.body}function B(_){var M,L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(ce.a)())return null;var w=document.createElement("style");if((M=L.csp)===null||M===void 0?void 0:M.nonce){var y;w.nonce=(y=L.csp)===null||y===void 0?void 0:y.nonce}w.innerHTML=_;var x=S(L),C=x.firstChild;return L.prepend&&x.prepend?x.prepend(w):L.prepend&&C?x.insertBefore(w,C):x.appendChild(w),w}var O=new Map;function A(_,M){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=S(L);if(!O.has(w)){var y=B("",L),x=y.parentNode;O.set(w,x),x.removeChild(y)}var C=Array.from(O.get(w).children).find(function(e){return e.tagName==="STYLE"&&e[U]===M});if(C){var E,b;if(((E=L.csp)===null||E===void 0?void 0:E.nonce)&&C.nonce!==((b=L.csp)===null||b===void 0?void 0:b.nonce)){var v;C.nonce=(v=L.csp)===null||v===void 0?void 0:v.nonce}return C.innerHTML!==_&&(C.innerHTML=_),C}var h=B(_,L);return h[U]=M,h}},DlQD:function(nt,We,J){(function(ce,U){nt.exports=U()})(this,function(){"use strict";function ce(re,q){for(var te=0;te<q.length;te++){var j=q[te];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(re,j.key,j)}}function U(re,q,te){return q&&ce(re.prototype,q),te&&ce(re,te),re}function S(re,q){if(!re)return;if(typeof re=="string")return B(re,q);var te=Object.prototype.toString.call(re).slice(8,-1);if(te==="Object"&&re.constructor&&(te=re.constructor.name),te==="Map"||te==="Set")return Array.from(re);if(te==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(te))return B(re,q)}function B(re,q){(q==null||q>re.length)&&(q=re.length);for(var te=0,j=new Array(q);te<q;te++)j[te]=re[te];return j}function O(re,q){var te;if(typeof Symbol=="undefined"||re[Symbol.iterator]==null){if(Array.isArray(re)||(te=S(re))||q&&re&&typeof re.length=="number"){te&&(re=te);var j=0;return function(){return j>=re.length?{done:!0}:{done:!1,value:re[j++]}}}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 te=re[Symbol.iterator](),te.next.bind(te)}function A(re,q){return q={exports:{}},re(q,q.exports),q.exports}var _=A(function(re){function q(){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 te(j){re.exports.defaults=j}re.exports={defaults:q(),getDefaults:q,changeDefaults:te}}),M=_.defaults,L=_.getDefaults,w=_.changeDefaults,y=/[&<>"']/,x=/[&<>"']/g,C=/[<>"']|&(?!#?\w+;)/,E=/[<>"']|&(?!#?\w+;)/g,b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},v=function(q){return b[q]};function h(re,q){if(q){if(y.test(re))return re.replace(x,v)}else if(C.test(re))return re.replace(E,v);return re}var e=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function a(re){return re.replace(e,function(q,te){return te=te.toLowerCase(),te==="colon"?":":te.charAt(0)==="#"?te.charAt(1)==="x"?String.fromCharCode(parseInt(te.substring(2),16)):String.fromCharCode(+te.substring(1)):""})}var o=/(^|[^\[])\^/g;function f(re,q){re=re.source||re,q=q||"";var te={replace:function(W,G){return G=G.source||G,G=G.replace(o,"$1"),re=re.replace(W,G),te},getRegex:function(){return new RegExp(re,q)}};return te}var d=/[^\w:]/g,u=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function p(re,q,te){if(re){var j;try{j=decodeURIComponent(a(te)).replace(d,"").toLowerCase()}catch(W){return null}if(j.indexOf("javascript:")===0||j.indexOf("vbscript:")===0||j.indexOf("data:")===0)return null}q&&!u.test(te)&&(te=s(q,te));try{te=encodeURI(te).replace(/%25/g,"%")}catch(W){return null}return te}var c={},i=/^[^:]+:\/*[^/]*$/,r=/^([^:]+:)[\s\S]*$/,t=/^([^:]+:\/*[^/]*)[\s\S]*$/;function s(re,q){c[" "+re]||(i.test(re)?c[" "+re]=re+"/":c[" "+re]=P(re,"/",!0)),re=c[" "+re];var te=re.indexOf(":")===-1;return q.substring(0,2)==="//"?te?q:re.replace(r,"$1")+q:q.charAt(0)==="/"?te?q:re.replace(t,"$1")+q:re+q}var m={exec:function(){}};function g(re){for(var q=1,te,j;q<arguments.length;q++){te=arguments[q];for(j in te)Object.prototype.hasOwnProperty.call(te,j)&&(re[j]=te[j])}return re}function T(re,q){var te=re.replace(/\|/g,function(G,X,oe){for(var he=!1,ke=X;--ke>=0&&oe[ke]==="\\";)he=!he;return he?"|":" |"}),j=te.split(/ \|/),W=0;if(j.length>q)j.splice(q);else for(;j.length<q;)j.push("");for(;W<j.length;W++)j[W]=j[W].trim().replace(/\\\|/g,"|");return j}function P(re,q,te){var j=re.length;if(j===0)return"";for(var W=0;W<j;){var G=re.charAt(j-W-1);if(G===q&&!te)W++;else if(G!==q&&te)W++;else break}return re.substr(0,j-W)}function I(re,q){if(re.indexOf(q[1])===-1)return-1;for(var te=re.length,j=0,W=0;W<te;W++)if(re[W]==="\\")W++;else if(re[W]===q[0])j++;else if(re[W]===q[1]&&(j--,j<0))return W;return-1}function F(re){re&&re.sanitize&&!re.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 K={escape:h,unescape:a,edit:f,cleanUrl:p,resolveUrl:s,noopTest:m,merge:g,splitCells:T,rtrim:P,findClosingBracket:I,checkSanitizeDeprecation:F},V=_.defaults,Q=K.rtrim,Z=K.splitCells,ie=K.escape,pe=K.findClosingBracket;function ae(re,q,te){var j=q.href,W=q.title?ie(q.title):null,G=re[1].replace(/\\([\[\]])/g,"$1");return re[0].charAt(0)!=="!"?{type:"link",raw:te,href:j,title:W,text:G}:{type:"image",raw:te,href:j,title:W,text:ie(G)}}function de(re,q){var te=re.match(/^(\s+)(?:```)/);if(te===null)return q;var j=te[1];return q.split(`
`).map(function(W){var G=W.match(/^\s+/);if(G===null)return W;var X=G[0];return X.length>=j.length?W.slice(j.length):W}).join(`
`)}var le=function(){function re(te){this.options=te||V}var q=re.prototype;return q.space=function(j){var W=this.rules.block.newline.exec(j);if(W)return W[0].length>1?{type:"space",raw:W[0]}:{raw:`
`}},q.code=function(j,W){var G=this.rules.block.code.exec(j);if(G){var X=W[W.length-1];if(X&&X.type==="paragraph")return{raw:G[0],text:G[0].trimRight()};var oe=G[0].replace(/^ {4}/gm,"");return{type:"code",raw:G[0],codeBlockStyle:"indented",text:this.options.pedantic?oe:Q(oe,`
`)}}},q.fences=function(j){var W=this.rules.block.fences.exec(j);if(W){var G=W[0],X=de(G,W[3]||"");return{type:"code",raw:G,lang:W[2]?W[2].trim():W[2],text:X}}},q.heading=function(j){var W=this.rules.block.heading.exec(j);if(W)return{type:"heading",raw:W[0],depth:W[1].length,text:W[2]}},q.nptable=function(j){var W=this.rules.block.nptable.exec(j);if(W){var G={type:"table",header:Z(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
`):[],raw:W[0]};if(G.header.length===G.align.length){var X=G.align.length,oe;for(oe=0;oe<X;oe++)/^ *-+: *$/.test(G.align[oe])?G.align[oe]="right":/^ *:-+: *$/.test(G.align[oe])?G.align[oe]="center":/^ *:-+ *$/.test(G.align[oe])?G.align[oe]="left":G.align[oe]=null;for(X=G.cells.length,oe=0;oe<X;oe++)G.cells[oe]=Z(G.cells[oe],G.header.length);return G}}},q.hr=function(j){var W=this.rules.block.hr.exec(j);if(W)return{type:"hr",raw:W[0]}},q.blockquote=function(j){var W=this.rules.block.blockquote.exec(j);if(W){var G=W[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:W[0],text:G}}},q.list=function(j){var W=this.rules.block.list.exec(j);if(W){for(var G=W[0],X=W[2],oe=X.length>1,he=X[X.length-1]===")",ke={type:"list",raw:G,ordered:oe,start:oe?+X.slice(0,-1):"",loose:!1,items:[]},He=W[0].match(this.rules.block.item),$e=!1,ze,Ze,et,Xe,mt,rt,vt,ct=He.length,qe=0;qe<ct;qe++)ze=He[qe],G=ze,Ze=ze.length,ze=ze.replace(/^ *([*+-]|\d+[.)]) */,""),~ze.indexOf(`
`)&&(Ze-=ze.length,ze=this.options.pedantic?ze.replace(/^ {1,4}/gm,""):ze.replace(new RegExp("^ {1,"+Ze+"}","gm"),"")),qe!==ct-1&&(et=this.rules.block.bullet.exec(He[qe+1])[0],(oe?et.length===1||!he&&et[et.length-1]===")":et.length>1||this.options.smartLists&&et!==X)&&(Xe=He.slice(qe+1).join(`
`),ke.raw=ke.raw.substring(0,ke.raw.length-Xe.length),qe=ct-1)),mt=$e||/\n\n(?!\s*$)/.test(ze),qe!==ct-1&&($e=ze.charAt(ze.length-1)===`
`,mt||(mt=$e)),mt&&(ke.loose=!0),rt=/^\[[ xX]\] /.test(ze),vt=void 0,rt&&(vt=ze[1]!==" ",ze=ze.replace(/^\[[ xX]\] +/,"")),ke.items.push({type:"list_item",raw:G,task:rt,checked:vt,loose:mt,text:ze});return ke}},q.html=function(j){var W=this.rules.block.html.exec(j);if(W)return{type:this.options.sanitize?"paragraph":"html",raw:W[0],pre:!this.options.sanitizer&&(W[1]==="pre"||W[1]==="script"||W[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(W[0]):ie(W[0]):W[0]}},q.def=function(j){var W=this.rules.block.def.exec(j);if(W){W[3]&&(W[3]=W[3].substring(1,W[3].length-1));var G=W[1].toLowerCase().replace(/\s+/g," ");return{tag:G,raw:W[0],href:W[2],title:W[3]}}},q.table=function(j){var W=this.rules.block.table.exec(j);if(W){var G={type:"table",header:Z(W[1].replace(/^ *| *\| *$/g,"")),align:W[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:W[3]?W[3].replace(/\n$/,"").split(`
`):[]};if(G.header.length===G.align.length){G.raw=W[0];var X=G.align.length,oe;for(oe=0;oe<X;oe++)/^ *-+: *$/.test(G.align[oe])?G.align[oe]="right":/^ *:-+: *$/.test(G.align[oe])?G.align[oe]="center":/^ *:-+ *$/.test(G.align[oe])?G.align[oe]="left":G.align[oe]=null;for(X=G.cells.length,oe=0;oe<X;oe++)G.cells[oe]=Z(G.cells[oe].replace(/^ *\| *| *\| *$/g,""),G.header.length);return G}}},q.lheading=function(j){var W=this.rules.block.lheading.exec(j);if(W)return{type:"heading",raw:W[0],depth:W[2].charAt(0)==="="?1:2,text:W[1]}},q.paragraph=function(j){var W=this.rules.block.paragraph.exec(j);if(W)return{type:"paragraph",raw:W[0],text:W[1].charAt(W[1].length-1)===`
`?W[1].slice(0,-1):W[1]}},q.text=function(j,W){var G=this.rules.block.text.exec(j);if(G){var X=W[W.length-1];return X&&X.type==="text"?{raw:G[0],text:G[0]}:{type:"text",raw:G[0],text:G[0]}}},q.escape=function(j){var W=this.rules.inline.escape.exec(j);if(W)return{type:"escape",raw:W[0],text:ie(W[1])}},q.tag=function(j,W,G){var X=this.rules.inline.tag.exec(j);if(X)return!W&&/^<a /i.test(X[0])?W=!0:W&&/^<\/a>/i.test(X[0])&&(W=!1),!G&&/^<(pre|code|kbd|script)(\s|>)/i.test(X[0])?G=!0:G&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(X[0])&&(G=!1),{type:this.options.sanitize?"text":"html",raw:X[0],inLink:W,inRawBlock:G,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):ie(X[0]):X[0]}},q.link=function(j){var W=this.rules.inline.link.exec(j);if(W){var G=pe(W[2],"()");if(G>-1){var X=W[0].indexOf("!")===0?5:4,oe=X+W[1].length+G;W[2]=W[2].substring(0,G),W[0]=W[0].substring(0,oe).trim(),W[3]=""}var he=W[2],ke="";if(this.options.pedantic){var He=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(he);He?(he=He[1],ke=He[3]):ke=""}else ke=W[3]?W[3].slice(1,-1):"";he=he.trim().replace(/^<([\s\S]*)>$/,"$1");var $e=ae(W,{href:he&&he.replace(this.rules.inline._escapes,"$1"),title:ke&&ke.replace(this.rules.inline._escapes,"$1")},W[0]);return $e}},q.reflink=function(j,W){var G;if((G=this.rules.inline.reflink.exec(j))||(G=this.rules.inline.nolink.exec(j))){var X=(G[2]||G[1]).replace(/\s+/g," ");if(X=W[X.toLowerCase()],!X||!X.href){var oe=G[0].charAt(0);return{type:"text",raw:oe,text:oe}}var he=ae(G,X,G[0]);return he}},q.strong=function(j,W,G){G===void 0&&(G="");var X=this.rules.inline.strong.start.exec(j);if(X&&(!X[1]||X[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){W=W.slice(-1*j.length);var oe=X[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;oe.lastIndex=0;for(var he;(X=oe.exec(W))!=null;)if(he=this.rules.inline.strong.middle.exec(W.slice(0,X.index+3)),he)return{type:"strong",raw:j.slice(0,he[0].length),text:j.slice(2,he[0].length-2)}}},q.em=function(j,W,G){G===void 0&&(G="");var X=this.rules.inline.em.start.exec(j);if(X&&(!X[1]||X[1]&&(G===""||this.rules.inline.punctuation.exec(G)))){W=W.slice(-1*j.length);var oe=X[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;oe.lastIndex=0;for(var he;(X=oe.exec(W))!=null;)if(he=this.rules.inline.em.middle.exec(W.slice(0,X.index+2)),he)return{type:"em",raw:j.slice(0,he[0].length),text:j.slice(1,he[0].length-1)}}},q.codespan=function(j){var W=this.rules.inline.code.exec(j);if(W){var G=W[2].replace(/\n/g," "),X=/[^ ]/.test(G),oe=G.startsWith(" ")&&G.endsWith(" ");return X&&oe&&(G=G.substring(1,G.length-1)),G=ie(G,!0),{type:"codespan",raw:W[0],text:G}}},q.br=function(j){var W=this.rules.inline.br.exec(j);if(W)return{type:"br",raw:W[0]}},q.del=function(j){var W=this.rules.inline.del.exec(j);if(W)return{type:"del",raw:W[0],text:W[1]}},q.autolink=function(j,W){var G=this.rules.inline.autolink.exec(j);if(G){var X,oe;return G[2]==="@"?(X=ie(this.options.mangle?W(G[1]):G[1]),oe="mailto:"+X):(X=ie(G[1]),oe=X),{type:"link",raw:G[0],text:X,href:oe,tokens:[{type:"text",raw:X,text:X}]}}},q.url=function(j,W){var G;if(G=this.rules.inline.url.exec(j)){var X,oe;if(G[2]==="@")X=ie(this.options.mangle?W(G[0]):G[0]),oe="mailto:"+X;else{var he;do he=G[0],G[0]=this.rules.inline._backpedal.exec(G[0])[0];while(he!==G[0]);X=ie(G[0]),G[1]==="www."?oe="http://"+X:oe=X}return{type:"link",raw:G[0],text:X,href:oe,tokens:[{type:"text",raw:X,text:X}]}}},q.inlineText=function(j,W,G){var X=this.rules.inline.text.exec(j);if(X){var oe;return W?oe=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(X[0]):ie(X[0]):X[0]:oe=ie(this.options.smartypants?G(X[0]):X[0]),{type:"text",raw:X[0],text:oe}}},re}(),$=K.noopTest,Y=K.edit,ne=K.merge,z={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:$,table:$,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};z._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,z._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,z.def=Y(z.def).replace("label",z._label).replace("title",z._title).getRegex(),z.bullet=/(?:[*+-]|\d{1,9}[.)])/,z.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,z.item=Y(z.item,"gm").replace(/bull/g,z.bullet).getRegex(),z.list=Y(z.list).replace(/bull/g,z.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+z.def.source+")").getRegex(),z._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",z._comment=/<!--(?!-?>)[\s\S]*?-->/,z.html=Y(z.html,"i").replace("comment",z._comment).replace("tag",z._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),z.paragraph=Y(z._paragraph).replace("hr",z.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",z._tag).getRegex(),z.blockquote=Y(z.blockquote).replace("paragraph",z.paragraph).getRegex(),z.normal=ne({},z),z.gfm=ne({},z.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*|$)"}),z.gfm.nptable=Y(z.gfm.nptable).replace("hr",z.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",z._tag).getRegex(),z.gfm.table=Y(z.gfm.table).replace("hr",z.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",z._tag).getRegex(),z.pedantic=ne({},z.normal,{html:Y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",z._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:$,paragraph:Y(z.normal._paragraph).replace("hr",z.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",z.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var H={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:$,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:$,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};H._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",H.punctuation=Y(H.punctuation).replace(/punctuation/g,H._punctuation).getRegex(),H._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",H._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",H.em.start=Y(H.em.start).replace(/punctuation/g,H._punctuation).getRegex(),H.em.middle=Y(H.em.middle).replace(/punctuation/g,H._punctuation).replace(/overlapSkip/g,H._overlapSkip).getRegex(),H.em.endAst=Y(H.em.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.em.endUnd=Y(H.em.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.start=Y(H.strong.start).replace(/punctuation/g,H._punctuation).getRegex(),H.strong.middle=Y(H.strong.middle).replace(/punctuation/g,H._punctuation).replace(/blockSkip/g,H._blockSkip).getRegex(),H.strong.endAst=Y(H.strong.endAst,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.strong.endUnd=Y(H.strong.endUnd,"g").replace(/punctuation/g,H._punctuation).getRegex(),H.blockSkip=Y(H._blockSkip,"g").getRegex(),H.overlapSkip=Y(H._overlapSkip,"g").getRegex(),H._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,H._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,H._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])?)+(?![-_])/,H.autolink=Y(H.autolink).replace("scheme",H._scheme).replace("email",H._email).getRegex(),H._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,H.tag=Y(H.tag).replace("comment",z._comment).replace("attribute",H._attribute).getRegex(),H._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,H._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,H._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,H.link=Y(H.link).replace("label",H._label).replace("href",H._href).replace("title",H._title).getRegex(),H.reflink=Y(H.reflink).replace("label",H._label).getRegex(),H.reflinkSearch=Y(H.reflinkSearch,"g").replace("reflink",H.reflink).replace("nolink",H.nolink).getRegex(),H.normal=ne({},H),H.pedantic=ne({},H.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:Y(/^!?\[(label)\]\((.*?)\)/).replace("label",H._label).getRegex(),reflink:Y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",H._label).getRegex()}),H.gfm=ne({},H.normal,{escape:Y(H.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),H.gfm.url=Y(H.gfm.url,"i").replace("email",H.gfm._extended_email).getRegex(),H.breaks=ne({},H.gfm,{br:Y(H.br).replace("{2,}","*").getRegex(),text:Y(H.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var me={block:z,inline:H},Le=_.defaults,Oe=me.block,Ae=me.inline;function Re(re){return re.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 fe(re){var q="",te,j,W=re.length;for(te=0;te<W;te++)j=re.charCodeAt(te),Math.random()>.5&&(j="x"+j.toString(16)),q+="&#"+j+";";return q}var ye=function(){function re(te){this.tokens=[],this.tokens.links=Object.create(null),this.options=te||Le,this.options.tokenizer=this.options.tokenizer||new le,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var j={block:Oe.normal,inline:Ae.normal};this.options.pedantic?(j.block=Oe.pedantic,j.inline=Ae.pedantic):this.options.gfm&&(j.block=Oe.gfm,this.options.breaks?j.inline=Ae.breaks:j.inline=Ae.gfm),this.tokenizer.rules=j}re.lex=function(j,W){var G=new re(W);return G.lex(j)};var q=re.prototype;return q.lex=function(j){return j=j.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(j,this.tokens,!0),this.inline(this.tokens),this.tokens},q.blockTokens=function(j,W,G){W===void 0&&(W=[]),G===void 0&&(G=!0),j=j.replace(/^ +$/gm,"");for(var X,oe,he,ke;j;){if(X=this.tokenizer.space(j)){j=j.substring(X.raw.length),X.type&&W.push(X);continue}if(X=this.tokenizer.code(j,W)){j=j.substring(X.raw.length),X.type?W.push(X):(ke=W[W.length-1],ke.raw+=`
`+X.raw,ke.text+=`
`+X.text);continue}if(X=this.tokenizer.fences(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.heading(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.nptable(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.hr(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.blockquote(j)){j=j.substring(X.raw.length),X.tokens=this.blockTokens(X.text,[],G),W.push(X);continue}if(X=this.tokenizer.list(j)){for(j=j.substring(X.raw.length),he=X.items.length,oe=0;oe<he;oe++)X.items[oe].tokens=this.blockTokens(X.items[oe].text,[],!1);W.push(X);continue}if(X=this.tokenizer.html(j)){j=j.substring(X.raw.length),W.push(X);continue}if(G&&(X=this.tokenizer.def(j))){j=j.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(j)){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.lheading(j)){j=j.substring(X.raw.length),W.push(X);continue}if(G&&(X=this.tokenizer.paragraph(j))){j=j.substring(X.raw.length),W.push(X);continue}if(X=this.tokenizer.text(j,W)){j=j.substring(X.raw.length),X.type?W.push(X):(ke=W[W.length-1],ke.raw+=`
`+X.raw,ke.text+=`
`+X.text);continue}if(j){var He="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(He);break}else throw new Error(He)}}return W},q.inline=function(j){var W,G,X,oe,he,ke,He=j.length;for(W=0;W<He;W++){ke=j[W];switch(ke.type){case"paragraph":case"text":case"heading":{ke.tokens=[],this.inlineTokens(ke.text,ke.tokens);break}case"table":{for(ke.tokens={header:[],cells:[]},oe=ke.header.length,G=0;G<oe;G++)ke.tokens.header[G]=[],this.inlineTokens(ke.header[G],ke.tokens.header[G]);for(oe=ke.cells.length,G=0;G<oe;G++)for(he=ke.cells[G],ke.tokens.cells[G]=[],X=0;X<he.length;X++)ke.tokens.cells[G][X]=[],this.inlineTokens(he[X],ke.tokens.cells[G][X]);break}case"blockquote":{this.inline(ke.tokens);break}case"list":{for(oe=ke.items.length,G=0;G<oe;G++)this.inline(ke.items[G].tokens);break}}}return j},q.inlineTokens=function(j,W,G,X,oe){W===void 0&&(W=[]),G===void 0&&(G=!1),X===void 0&&(X=!1),oe===void 0&&(oe="");var he,ke=j,He;if(this.tokens.links){var $e=Object.keys(this.tokens.links);if($e.length>0)for(;(He=this.tokenizer.rules.inline.reflinkSearch.exec(ke))!=null;)$e.includes(He[0].slice(He[0].lastIndexOf("[")+1,-1))&&(ke=ke.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(He=this.tokenizer.rules.inline.blockSkip.exec(ke))!=null;)ke=ke.slice(0,He.index)+"["+"a".repeat(He[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;j;){if(he=this.tokenizer.escape(j)){j=j.substring(he.raw.length),W.push(he);continue}if(he=this.tokenizer.tag(j,G,X)){j=j.substring(he.raw.length),G=he.inLink,X=he.inRawBlock,W.push(he);continue}if(he=this.tokenizer.link(j)){j=j.substring(he.raw.length),he.type==="link"&&(he.tokens=this.inlineTokens(he.text,[],!0,X)),W.push(he);continue}if(he=this.tokenizer.reflink(j,this.tokens.links)){j=j.substring(he.raw.length),he.type==="link"&&(he.tokens=this.inlineTokens(he.text,[],!0,X)),W.push(he);continue}if(he=this.tokenizer.strong(j,ke,oe)){j=j.substring(he.raw.length),he.tokens=this.inlineTokens(he.text,[],G,X),W.push(he);continue}if(he=this.tokenizer.em(j,ke,oe)){j=j.substring(he.raw.length),he.tokens=this.inlineTokens(he.text,[],G,X),W.push(he);continue}if(he=this.tokenizer.codespan(j)){j=j.substring(he.raw.length),W.push(he);continue}if(he=this.tokenizer.br(j)){j=j.substring(he.raw.length),W.push(he);continue}if(he=this.tokenizer.del(j)){j=j.substring(he.raw.length),he.tokens=this.inlineTokens(he.text,[],G,X),W.push(he);continue}if(he=this.tokenizer.autolink(j,fe)){j=j.substring(he.raw.length),W.push(he);continue}if(!G&&(he=this.tokenizer.url(j,fe))){j=j.substring(he.raw.length),W.push(he);continue}if(he=this.tokenizer.inlineText(j,X,Re)){j=j.substring(he.raw.length),oe=he.raw.slice(-1),W.push(he);continue}if(j){var ze="Infinite loop on byte: "+j.charCodeAt(0);if(this.options.silent){console.error(ze);break}else throw new Error(ze)}}return W},U(re,null,[{key:"rules",get:function(){return{block:Oe,inline:Ae}}}]),re}(),xe=_.defaults,Se=K.cleanUrl,Ne=K.escape,Pe=function(){function re(te){this.options=te||xe}var q=re.prototype;return q.code=function(j,W,G){var X=(W||"").match(/\S*/)[0];if(this.options.highlight){var oe=this.options.highlight(j,X);oe!=null&&oe!==j&&(G=!0,j=oe)}return X?'<pre><code class="'+this.options.langPrefix+Ne(X,!0)+'">'+(G?j:Ne(j,!0))+`</code></pre>
`:"<pre><code>"+(G?j:Ne(j,!0))+`</code></pre>
`},q.blockquote=function(j){return`<blockquote>
`+j+`</blockquote>
`},q.html=function(j){return j},q.heading=function(j,W,G,X){return this.options.headerIds?"<h"+W+' id="'+this.options.headerPrefix+X.slug(G)+'">'+j+"</h"+W+`>
`:"<h"+W+">"+j+"</h"+W+`>
`},q.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},q.list=function(j,W,G){var X=W?"ol":"ul",oe=W&&G!==1?' start="'+G+'"':"";return"<"+X+oe+`>
`+j+"</"+X+`>
`},q.listitem=function(j){return"<li>"+j+`</li>
`},q.checkbox=function(j){return"<input "+(j?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},q.paragraph=function(j){return"<p>"+j+`</p>
`},q.table=function(j,W){return W&&(W="<tbody>"+W+"</tbody>"),`<table>
<thead>
`+j+`</thead>
`+W+`</table>
`},q.tablerow=function(j){return`<tr>
`+j+`</tr>
`},q.tablecell=function(j,W){var G=W.header?"th":"td",X=W.align?"<"+G+' align="'+W.align+'">':"<"+G+">";return X+j+"</"+G+`>
`},q.strong=function(j){return"<strong>"+j+"</strong>"},q.em=function(j){return"<em>"+j+"</em>"},q.codespan=function(j){return"<code>"+j+"</code>"},q.br=function(){return this.options.xhtml?"<br/>":"<br>"},q.del=function(j){return"<del>"+j+"</del>"},q.link=function(j,W,G){if(j=Se(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var X='<a href="'+Ne(j)+'"';return W&&(X+=' title="'+W+'"'),X+=">"+G+"</a>",X},q.image=function(j,W,G){if(j=Se(this.options.sanitize,this.options.baseUrl,j),j===null)return G;var X='<img src="'+j+'" alt="'+G+'"';return W&&(X+=' title="'+W+'"'),X+=this.options.xhtml?"/>":">",X},q.text=function(j){return j},re}(),_e=function(){function re(){}var q=re.prototype;return q.strong=function(j){return j},q.em=function(j){return j},q.codespan=function(j){return j},q.del=function(j){return j},q.html=function(j){return j},q.text=function(j){return j},q.link=function(j,W,G){return""+G},q.image=function(j,W,G){return""+G},q.br=function(){return""},re}(),Fe=function(){function re(){this.seen={}}var q=re.prototype;return q.slug=function(j){var W=j.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(W)){var G=W;do this.seen[G]++,W=G+"-"+this.seen[G];while(this.seen.hasOwnProperty(W))}return this.seen[W]=0,W},re}(),se=_.defaults,ue=K.unescape,be=function(){function re(te){this.options=te||se,this.options.renderer=this.options.renderer||new Pe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new _e,this.slugger=new Fe}re.parse=function(j,W){var G=new re(W);return G.parse(j)};var q=re.prototype;return q.parse=function(j,W){W===void 0&&(W=!0);var G="",X,oe,he,ke,He,$e,ze,Ze,et,Xe,mt,rt,vt,ct,qe,yt,bt,Ve,wt=j.length;for(X=0;X<wt;X++){Xe=j[X];switch(Xe.type){case"space":continue;case"hr":{G+=this.renderer.hr();continue}case"heading":{G+=this.renderer.heading(this.parseInline(Xe.tokens),Xe.depth,ue(this.parseInline(Xe.tokens,this.textRenderer)),this.slugger);continue}case"code":{G+=this.renderer.code(Xe.text,Xe.lang,Xe.escaped);continue}case"table":{for(Ze="",ze="",ke=Xe.header.length,oe=0;oe<ke;oe++)ze+=this.renderer.tablecell(this.parseInline(Xe.tokens.header[oe]),{header:!0,align:Xe.align[oe]});for(Ze+=this.renderer.tablerow(ze),et="",ke=Xe.cells.length,oe=0;oe<ke;oe++){for($e=Xe.tokens.cells[oe],ze="",He=$e.length,he=0;he<He;he++)ze+=this.renderer.tablecell(this.parseInline($e[he]),{header:!1,align:Xe.align[he]});et+=this.renderer.tablerow(ze)}G+=this.renderer.table(Ze,et);continue}case"blockquote":{et=this.parse(Xe.tokens),G+=this.renderer.blockquote(et);continue}case"list":{for(mt=Xe.ordered,rt=Xe.start,vt=Xe.loose,ke=Xe.items.length,et="",oe=0;oe<ke;oe++)qe=Xe.items[oe],yt=qe.checked,bt=qe.task,ct="",qe.task&&(Ve=this.renderer.checkbox(yt),vt?qe.tokens.length>0&&qe.tokens[0].type==="text"?(qe.tokens[0].text=Ve+" "+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=Ve+" "+qe.tokens[0].tokens[0].text)):qe.tokens.unshift({type:"text",text:Ve}):ct+=Ve),ct+=this.parse(qe.tokens,vt),et+=this.renderer.listitem(ct,bt,yt);G+=this.renderer.list(et,mt,rt);continue}case"html":{G+=this.renderer.html(Xe.text);continue}case"paragraph":{G+=this.renderer.paragraph(this.parseInline(Xe.tokens));continue}case"text":{for(et=Xe.tokens?this.parseInline(Xe.tokens):Xe.text;X+1<wt&&j[X+1].type==="text";)Xe=j[++X],et+=`
`+(Xe.tokens?this.parseInline(Xe.tokens):Xe.text);G+=W?this.renderer.paragraph(et):et;continue}default:{var at='Token with "'+Xe.type+'" type was not found.';if(this.options.silent){console.error(at);return}else throw new Error(at)}}}return G},q.parseInline=function(j,W){W=W||this.renderer;var G="",X,oe,he=j.length;for(X=0;X<he;X++){oe=j[X];switch(oe.type){case"escape":{G+=W.text(oe.text);break}case"html":{G+=W.html(oe.text);break}case"link":{G+=W.link(oe.href,oe.title,this.parseInline(oe.tokens,W));break}case"image":{G+=W.image(oe.href,oe.title,oe.text);break}case"strong":{G+=W.strong(this.parseInline(oe.tokens,W));break}case"em":{G+=W.em(this.parseInline(oe.tokens,W));break}case"codespan":{G+=W.codespan(oe.text);break}case"br":{G+=W.br();break}case"del":{G+=W.del(this.parseInline(oe.tokens,W));break}case"text":{G+=W.text(oe.text);break}default:{var ke='Token with "'+oe.type+'" type was not found.';if(this.options.silent){console.error(ke);return}else throw new Error(ke)}}}return G},re}(),Ee=K.merge,Ce=K.checkSanitizeDeprecation,Te=K.escape,ve=_.getDefaults,Ie=_.changeDefaults,Be=_.defaults;function ge(re,q,te){if(typeof re=="undefined"||re===null)throw new Error("marked(): input parameter is undefined or null");if(typeof re!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(re)+", string expected");if(typeof q=="function"&&(te=q,q=null),q=Ee({},ge.defaults,q||{}),Ce(q),te){var j=q.highlight,W;try{W=ye.lex(re,q)}catch(he){return te(he)}var G=function(ke){var He;if(!ke)try{He=be.parse(W,q)}catch($e){ke=$e}return q.highlight=j,ke?te(ke):te(null,He)};if(!j||j.length<3)return G();if(delete q.highlight,!W.length)return G();var X=0;ge.walkTokens(W,function(he){he.type==="code"&&(X++,setTimeout(function(){j(he.text,he.lang,function(ke,He){if(ke)return G(ke);He!=null&&He!==he.text&&(he.text=He,he.escaped=!0),X--,X===0&&G()})},0))}),X===0&&G();return}try{var oe=ye.lex(re,q);return q.walkTokens&&ge.walkTokens(oe,q.walkTokens),be.parse(oe,q)}catch(he){if(he.message+=`
Please report this to https://github.com/markedjs/marked.`,q.silent)return"<p>An error occurred:</p><pre>"+Te(he.message+"",!0)+"</pre>";throw he}}ge.options=ge.setOptions=function(re){return Ee(ge.defaults,re),Ie(ge.defaults),ge},ge.getDefaults=ve,ge.defaults=Be,ge.use=function(re){var q=Ee({},re);if(re.renderer&&function(){var j=ge.defaults.renderer||new Pe,W=function(oe){var he=j[oe];j[oe]=function(){for(var ke=arguments.length,He=new Array(ke),$e=0;$e<ke;$e++)He[$e]=arguments[$e];var ze=re.renderer[oe].apply(j,He);return ze===!1&&(ze=he.apply(j,He)),ze}};for(var G in re.renderer)W(G);q.renderer=j}(),re.tokenizer&&function(){var j=ge.defaults.tokenizer||new le,W=function(oe){var he=j[oe];j[oe]=function(){for(var ke=arguments.length,He=new Array(ke),$e=0;$e<ke;$e++)He[$e]=arguments[$e];var ze=re.tokenizer[oe].apply(j,He);return ze===!1&&(ze=he.apply(j,He)),ze}};for(var G in re.tokenizer)W(G);q.tokenizer=j}(),re.walkTokens){var te=ge.defaults.walkTokens;q.walkTokens=function(j){re.walkTokens(j),te&&te(j)}}ge.setOptions(q)},ge.walkTokens=function(re,q){for(var te=O(re),j;!(j=te()).done;){var W=j.value;q(W);switch(W.type){case"table":{for(var G=O(W.tokens.header),X;!(X=G()).done;){var oe=X.value;ge.walkTokens(oe,q)}for(var he=O(W.tokens.cells),ke;!(ke=he()).done;)for(var He=ke.value,$e=O(He),ze;!(ze=$e()).done;){var Ze=ze.value;ge.walkTokens(Ze,q)}break}case"list":{ge.walkTokens(W.items,q);break}default:W.tokens&&ge.walkTokens(W.tokens,q)}}},ge.Parser=be,ge.parser=be.parse,ge.Renderer=Pe,ge.TextRenderer=_e,ge.Lexer=ye,ge.lexer=ye.lex,ge.Tokenizer=le,ge.Slugger=Fe,ge.parse=ge;var Me=ge;return Me})},Etsf:function(nt,We,J){"use strict";J.r(We);var ce=J("5Dmo"),U=J("3S7+"),S=J("14J3"),B=J("BMrR"),O=J("jCWc"),A=J("kPKH"),_=J("sPJy"),M=J("bE4q"),L=J("k1fw"),w=J("9og8"),y=J("y8nQ"),x=J("Vl3Y"),C=J("tJVT"),E=J("PpiC"),b=J("WmNS"),v=J.n(b),h=J("q1tI"),e=J.n(h),a=J("55Ip"),o=J("9kvl"),f=J("9Bee"),d=J("xKgJ"),u=J("U/Y8"),p=J.n(u),c=J("Q9mQ"),i=J("diRs"),r=J("miYZ"),t=J("tsqr"),s=J("2qtc"),m=J("kLXV"),g=J("oBTY"),T=J("ozfa"),P=J("MJZm"),I=J("5NDa"),F=J("5rEg"),K=J("jrin"),V=J("nRaC"),Q=J("5RzL"),Z=J("ErOA"),ie=J("Ty5D"),pe=Q.a.TreeNode,ae=function(xe){var Se=xe.restful,Ne=xe.loading,Pe=xe.dispatch,_e=Object(ie.i)(),Fe=Object(ie.h)(),se=Object(h.useState)(!1),ue=Object(C.a)(se,2),be=ue[0],Ee=ue[1],Ce=Object(h.useState)(),Te=Object(C.a)(Ce,2),ve=Te[0],Ie=Te[1],Be=Se.actionTabs,ge=x.a.useForm(),Me=Object(C.a)(ge,1),re=Me[0];return Object(h.useEffect)(function(){Se.actionTabs.key=="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"&&re.resetFields()},[Se.actionTabs.key]),Se.actionTabs.key!=="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"?null:e.a.createElement(m.a,{centered:!0,title:"\u65B0\u5EFA\u76EE\u5F55",visible:Se.actionTabs.key==="\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{minHeight:150},confirmLoading:be,onOk:Object(w.a)(v.a.mark(function q(){var te,j,W;return v.a.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,re.validateFields();case 2:return te=re.getFieldValue(),Ee(!0),j="/api/restfuls.json",X.next=7,Object(Z.a)(j,{method:"post",body:Object(L.a)({file_type:1},te)});case 7:W=X.sent,W.status===0&&(t.b.success("\u6DFB\u52A0\u6210\u529F"),Pe({type:"restful/setActionTabs",payload:{}}),Pe({type:"restful/getRestful"})),Ee(!1);case 10:case"end":return X.stop()}},q)})),onCancel:function(){Pe({type:"restful/setActionTabs",payload:{}})}},e.a.createElement("div",{className:"pl30 pr30"},e.a.createElement(x.a,{form:re,initialValues:Object(K.a)({},"name","")},e.a.createElement(x.a.Item,{name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u76EE\u5F55\u540D\u79F0"}]},e.a.createElement(B.a,{className:"mt30"},e.a.createElement(A.a,{flex:"80px",className:"font14"},"\u76EE\u5F55\u540D\u79F0\uFF1A"),e.a.createElement(A.a,{flex:"1"},e.a.createElement(F.a,{placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26 ",maxLength:60})))))))},de=Object(o.a)(function(ye){var xe=ye.restful,Se=ye.loading;return{restful:xe,loading:Se}})(ae),le=Q.a.TreeNode,$=function(xe){var Se=xe.restful,Ne=xe.loading,Pe=xe.dispatch,_e=Object(ie.i)(),Fe=Object(ie.h)(),se=Object(h.useState)(!1),ue=Object(C.a)(se,2),be=ue[0],Ee=ue[1],Ce=Object(h.useState)(),Te=Object(C.a)(Ce,2),ve=Te[0],Ie=Te[1],Be=Se.actionTabs,ge=x.a.useForm(),Me=Object(C.a)(ge,1),re=Me[0];return Object(h.useEffect)(function(){Se.actionTabs.key=="\u91CD\u547D\u540D"&&(re.resetFields(),re.setFieldsValue({name:Se.actionTabs.data.title}))},[Se.actionTabs.key]),Se.actionTabs.key!=="\u91CD\u547D\u540D"?null:e.a.createElement(m.a,{centered:!0,title:"\u91CD\u547D\u540D",visible:Se.actionTabs.key==="\u91CD\u547D\u540D",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",bodyStyle:{minHeight:150},confirmLoading:be,onOk:Object(w.a)(v.a.mark(function q(){var te,j,W;return v.a.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,re.validateFields();case 2:return te=re.getFieldValue(),Ee(!0),j="/api/restfuls/".concat(Se.actionTabs.data.id,".json"),X.next=7,Object(Z.a)(j,{method:"put",body:Object(L.a)({file_type:1},te)});case 7:W=X.sent,W.status===0&&(t.b.success("\u4FEE\u6539\u6210\u529F"),Pe({type:"restful/setActionTabs",payload:{}}),Pe({type:"restful/getRestful"})),Ee(!1);case 10:case"end":return X.stop()}},q)})),onCancel:function(){Pe({type:"restful/setActionTabs",payload:{}})}},e.a.createElement("div",{className:"pl30 pr30"},e.a.createElement(x.a,{form:re,initialValues:Object(K.a)({},"name","")},e.a.createElement(B.a,{className:"mt30"},e.a.createElement(A.a,{flex:"80px",className:"font14"},"\u76EE\u5F55\u540D\u79F0\uFF1A"),e.a.createElement(A.a,{flex:"1"},e.a.createElement(x.a.Item,{name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u65B0\u540D\u79F0"}]},e.a.createElement(F.a,{placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26 ",maxLength:60})))))))},Y=Object(o.a)(function(ye){var xe=ye.restful,Se=ye.loading;return{restful:xe,loading:Se}})($),ne=J("s7vb"),z=J("P48q"),H=J.n(z),me=F.a.Search,Le=P.a.DirectoryTree,Oe=function(xe){var Se=xe.user,Ne=xe.globalSetting,Pe=xe.loading,_e=xe.dispatch,Fe=xe.restful,se=Object(E.a)(xe,["user","globalSetting","loading","dispatch","restful"]),ue=Object(h.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),be=Object(C.a)(ue,2),Ee=be[0],Ce=be[1],Te=Object(h.useState)(!0),ve=Object(C.a)(Te,2),Ie=ve[0],Be=ve[1],ge=x.a.useForm(),Me=Object(C.a)(ge,1),re=Me[0],q=Object(h.useState)(""),te=Object(C.a)(q,2),j=te[0],W=te[1],G=Object(h.useState)([{id:1,name:"\u65B0\u5EFA\u6587\u4EF6"},{id:2,name:"\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"},{id:3,name:"\u91CD\u547D\u540D"},{id:4,name:"\u7F16\u8F91"},{id:5,name:"\u5220\u9664"}]),X=Object(C.a)(G,1),oe=X[0],he=Object(h.useState)([]),ke=Object(C.a)(he,2),He=ke[0],$e=ke[1],ze=Object(h.useState)([]),Ze=Object(C.a)(ze,2),et=Ze[0],Xe=Ze[1],mt=Object(h.useState)(!1),rt=Object(C.a)(mt,2),vt=rt[0],ct=rt[1],qe=Object(h.useState)([]),yt=Object(C.a)(qe,2),bt=yt[0],Ve=yt[1];Object(h.useEffect)(function(){var it;if((it=Fe.restful)!==null&&it!==void 0&&it.data){var Qe,Ye,ot;Ve(Object(g.a)((Qe=Fe.restful)===null||Qe===void 0?void 0:Qe.data));var dt=0,tt;if((Ye=Fe.restful)===null||Ye===void 0||((ot=Ye.data)===null||ot===void 0)||ot.map(function(st){var ft;st.id==se.match.params.id&&(dt=st.id),st.file_type==0&&!tt&&(tt=st.id),st==null||((ft=st.children)===null||ft===void 0)||ft.map(function(Ot){tt||(tt=Ot.id),Ot.id==se.match.params.id&&(dt=st.id)}),!st.children&&!tt&&(tt=st.id)}),!se.match.params.id&&tt){se.history.push("/ch/rest/".concat(tt));return}dt&&setTimeout(function(){$e([dt]),Xe([Number(se.match.params.id||tt)])},200)}},[Fe.restful]);var wt=function(Qe,Ye){Ye.node.file_type===0?se.history.push("/ch/rest/".concat(Qe[0])):Xe(Object(g.a)(Qe)),console.log("Trigger Select",Qe,Ye)},at=function(Qe){$e(Qe),console.log("Trigger Expand",Qe)},ut=function(Qe){return e.a.createElement("div",null,oe.map(function(Ye,ot){return e.a.createElement("p",{key:Ye.id,className:"current",onClick:function(){switch(Ye.id){case 1:se.history.push("/ch/rest/edit/".concat(Qe.id,"/0"));break;case 2:case 3:_e({type:"restful/setActionTabs",payload:{key:Ye.name,data:Qe}});break;case 4:document.location.href="/ch/rest/edit/".concat(Qe.pid||0,"/").concat(Qe.id);break;case 5:m.a.confirm({title:"\u63D0\u793A",content:"\u662F\u5426\u786E\u5B9A\u5220\u9664\uFF1F",onOk:function(){var tt=Object(w.a)(v.a.mark(function ft(){var Ot;return v.a.wrap(function(_t){for(;;)switch(_t.prev=_t.next){case 0:return _t.next=2,Object(ne.a)({id:Qe.id});case 2:Ot=_t.sent,(Ot==null?void 0:Ot.status)==0&&(t.b.success("\u5220\u9664\u6210\u529F"),_e({type:"restful/getRestful"}));case 4:case"end":return _t.stop()}},ft)}));function st(){return tt.apply(this,arguments)}return st}()});break}}},Ye.name)}).filter(function(Ye){return!!Ye}).filter(function(Ye){return Qe.pid||Qe.file_type==0?Ye.key>3:Ye.key!=4}))},At=function it(Qe){return Qe.map(function(Ye){var ot=Ye.title.indexOf(j),dt=Ye.title.substr(0,ot),tt=Ye.title.substr(ot+j.length),st=e.a.createElement("span",null,dt,e.a.createElement("span",{className:"c-blue"},j),tt,Object(d.o)()&&e.a.createElement(i.a,{placement:"right",title:j,content:function(){return ut(Ye)},trigger:"hover"},e.a.createElement("span",{className:"iconfont icon-sandian ".concat(H.a.actions)})));if(j!==""){var ft;if(ot===-1&&!((ft=Ye.children)!==null&&ft!==void 0&&ft.length))return null}return Ye.children&&Ye.file_type===1?Object(L.a)(Object(L.a)({},Ye),{},{title:st,key:Ye.key,children:it(Ye.children)}):Object(L.a)(Object(L.a)({},Ye),{},{title:st,key:Ye.key,isLeaf:!0})}).filter(function(Ye){return!!Ye})},St=function it(Qe,Ye){for(var ot,dt=0;dt<Ye.length;dt++){var tt=Ye[dt];tt.children&&(tt.children.some(function(st){return st.key===Qe})?ot=tt.key:it(Qe,tt.children)&&(ot=it(Qe,tt.children)))}return ot},Rt=function(Qe){var Ye=Qe.target.value,ot=bt.map(function(dt){if(dt!=null&&dt.children){var tt;return dt!=null&&(tt=dt.children.filter(function(st){return st.title.indexOf(Ye)>-1}))!==null&&tt!==void 0&&tt.length?dt.id:null}return null});W(Ye),ct(!0),console.log("expandedKeys:",ot),$e(ot)};return console.log("loop(treeData):",At(bt)),e.a.createElement("div",{className:H.a.tree},e.a.createElement(me,{style:{marginBottom:8},placeholder:"\u8F93\u5165\u5173\u952E\u5B57\u68C0\u7D22",onChange:Rt}),e.a.createElement(Le,{multiple:!0,defaultExpandAll:!0,onSelect:wt,onExpand:at,expandedKeys:He,selectedKeys:et,autoExpandParent:vt,treeData:At(bt)}),e.a.createElement(de,null),e.a.createElement(Y,null))},Ae=Object(o.a)(function(ye){var xe=ye.user,Se=ye.loading,Ne=ye.globalSetting,Pe=ye.restful;return{user:xe,globalSetting:Ne,restful:Pe,loading:Se.models.index}})(Oe),Re=function(xe){var Se,Ne,Pe=xe.user,_e=xe.globalSetting,Fe=xe.loading,se=xe.dispatch,ue=xe.restful,be=Object(E.a)(xe,["user","globalSetting","loading","dispatch","restful"]),Ee=Object(h.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),Ce=Object(C.a)(Ee,2),Te=Ce[0],ve=Ce[1],Ie=Object(h.useState)(!0),Be=Object(C.a)(Ie,2),ge=Be[0],Me=Be[1],re=x.a.useForm(),q=Object(C.a)(re,1),te=q[0],j=be.match.params,W=function(){var oe=Object(w.a)(v.a.mark(function he(){return v.a.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:se({type:"restful/getRestful"}),j.id&&se({type:"restful/getRestfulDetail",payload:Object(L.a)({},j)});case 2:case"end":return He.stop()}},he)}));return function(){return oe.apply(this,arguments)}}();Object(h.useEffect)(function(){Me(!0),W()},[j.id]);var G=function(){se({type:"restful/setActionTabs",payload:{key:"\u65B0\u5EFA\u540C\u7EA7\u76EE\u5F55"}})},X=function(){var he;if((he=ue.restful)!==null&&he!==void 0&&he.data){var ke,He,$e=0;return(ke=ue.restful)===null||ke===void 0||((He=ke.data)===null||He===void 0)||He.map(function(ze){var Ze;ze==null||((Ze=ze.children)===null||Ze===void 0)||Ze.map(function(et){et.id==be.match.params.id&&($e=ze.id)}),!ze.children&&!$e&&($e=ze.id)}),$e}return 0};return e.a.createElement("section",null,e.a.createElement("aside",{className:"edu-container mt20"},e.a.createElement(M.a,null,e.a.createElement(M.a.Item,null,e.a.createElement(a.a,{to:"/"},"\u9996\u9875")),e.a.createElement(M.a.Item,null,e.a.createElement(a.a,{to:"/ch/rest"},"API\u6587\u6863"))),e.a.createElement("div",{className:"mt20"},e.a.createElement(B.a,{gutter:[20,20]},e.a.createElement(A.a,{flex:"300px"},e.a.createElement(Ae,be)),e.a.createElement(A.a,{flex:"1"},e.a.createElement("div",{className:p.a.info},e.a.createElement("h1",{style:{fontSize:28,paddingBottom:15,borderBottom:"1px solid #eaeaea",textAlign:"center"}},(Se=ue.restfulDetail)===null||Se===void 0?void 0:Se.name),e.a.createElement(f.a,{value:(Ne=ue.restfulDetail)===null||Ne===void 0?void 0:Ne.description}))))),Object(d.o)()&&e.a.createElement("div",{className:p.a.bar},e.a.createElement(B.a,null,!!X()&&e.a.createElement(A.a,null,e.a.createElement(U.a,{title:"\u7F16\u8F91\u6587\u4EF6"},e.a.createElement(a.a,{to:"/ch/rest/edit/".concat(X(),"/").concat(be.match.params.id),className:"icon-zhongmingming current"}))),e.a.createElement(A.a,null,e.a.createElement(U.a,{title:"\u6DFB\u52A0\u6587\u4EF6"},e.a.createElement(a.a,{to:"/ch/rest/edit/".concat(X(),"/0"),className:"icon-tianjiatimu current"}))),e.a.createElement(A.a,null,e.a.createElement(U.a,{title:"\u65B0\u5EFA\u6587\u4EF6\u5939"},e.a.createElement("span",{className:"icon-wenjianjia1 current",onClick:G})))))))},fe=We.default=Object(o.a)(function(ye){var xe=ye.user,Se=ye.loading,Ne=ye.globalSetting,Pe=ye.restful;return{user:xe,globalSetting:Ne,restful:Pe,loading:Se.models.index}})(Re)},NvD2:function(nt,We,J){"use strict";J.d(We,"a",function(){return A});var ce=J("Kwbf");function U(_,M){var L=new Set;return _.forEach(function(w){M.has(w)||L.add(w)}),L}function S(_){var M=_||{},L=M.disabled,w=M.disableCheckbox,y=M.checkable;return!!(L||w)||y===!1}function B(_,M,L,w){for(var y=new Set(_),x=new Set,C=0;C<=L;C+=1){var E=M.get(C)||new Set;E.forEach(function(e){var a=e.key,o=e.node,f=e.children,d=f===void 0?[]:f;y.has(a)&&!w(o)&&d.filter(function(u){return!w(u.node)}).forEach(function(u){y.add(u.key)})})}for(var b=new Set,v=L;v>=0;v-=1){var h=M.get(v)||new Set;h.forEach(function(e){var a=e.parent,o=e.node;if(w(o)||!e.parent||b.has(e.parent.key))return;if(w(e.parent.node)){b.add(a.key);return}var f=!0,d=!1;(a.children||[]).filter(function(u){return!w(u.node)}).forEach(function(u){var p=u.key,c=y.has(p);f&&!c&&(f=!1),!d&&(c||x.has(p))&&(d=!0)}),f&&y.add(a.key),d&&x.add(a.key),b.add(a.key)})}return{checkedKeys:Array.from(y),halfCheckedKeys:Array.from(U(x,y))}}function O(_,M,L,w,y){for(var x=new Set(_),C=new Set(M),E=0;E<=w;E+=1){var b=L.get(E)||new Set;b.forEach(function(a){var o=a.key,f=a.node,d=a.children,u=d===void 0?[]:d;!x.has(o)&&!C.has(o)&&!y(f)&&u.filter(function(p){return!y(p.node)}).forEach(function(p){x.delete(p.key)})})}C=new Set;for(var v=new Set,h=w;h>=0;h-=1){var e=L.get(h)||new Set;e.forEach(function(a){var o=a.parent,f=a.node;if(y(f)||!a.parent||v.has(a.parent.key))return;if(y(a.parent.node)){v.add(o.key);return}var d=!0,u=!1;(o.children||[]).filter(function(p){return!y(p.node)}).forEach(function(p){var c=p.key,i=x.has(c);d&&!i&&(d=!1),!u&&(i||C.has(c))&&(u=!0)}),d||x.delete(o.key),u&&C.add(o.key),v.add(o.key)})}return{checkedKeys:Array.from(x),halfCheckedKeys:Array.from(U(C,x))}}function A(_,M,L,w){var y=[],x;w?x=w:x=S;var C=new Set(_.filter(function(h){var e=!!L[h];return e||y.push(h),e})),E=new Map,b=0;Object.keys(L).forEach(function(h){var e=L[h],a=e.level,o=E.get(a);o||(o=new Set,E.set(a,o)),o.add(e),b=Math.max(b,a)}),Object(ce.a)(!y.length,"Tree missing follow keys: ".concat(y.slice(0,100).map(function(h){return"'".concat(h,"'")}).join(", ")));var v;return M===!0?v=B(C,E,b,x):v=O(C,M.halfCheckedKeys,E,b,x),v}},OZM5:function(nt,We,J){"use strict";J.d(We,"b",function(){return w}),J.d(We,"a",function(){return y}),J.d(We,"k",function(){return x}),J.d(We,"h",function(){return C}),J.d(We,"i",function(){return E}),J.d(We,"g",function(){return b}),J.d(We,"c",function(){return v}),J.d(We,"d",function(){return h}),J.d(We,"j",function(){return o}),J.d(We,"e",function(){return f}),J.d(We,"f",function(){return d});var ce=J("KQm4"),U=J("U8pU"),S=J("Ff2n"),B=J("q1tI"),O=J.n(B),A=J("Kwbf"),_=J("WaYH"),M=.25,L=2;function w(u,p){var c=u.slice(),i=c.indexOf(p);return i>=0&&c.splice(i,1),c}function y(u,p){var c=u.slice();return c.indexOf(p)===-1&&c.push(p),c}function x(u){return u.split("-")}function C(u,p){return"".concat(u,"-").concat(p)}function E(u){return u&&u.type&&u.type.isTreeNode}function b(u,p){var c=[u],i=p[u];function r(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];t.forEach(function(s){var m=s.key,g=s.children;c.push(m),r(g)})}return r(i.children),c}function v(u,p){var c=u.clientY,i=p.selectHandle.getBoundingClientRect(),r=i.top,t=i.bottom,s=i.height,m=Math.max(s*M,L);return c<=r+m?-1:c>=t-m?1:0}function h(u,p){if(!u)return;var c=p.multiple;return c?u.slice():u.length?[u[0]]:u}var e=function(p){return p};function a(u,p){if(!u)return[];var c=p||{},i=c.processProps,r=i===void 0?e:i,t=Array.isArray(u)?u:[u];return t.map(function(s){var m=s.children,g=Object(S.a)(s,["children"]),T=a(m,p);return O.a.createElement(_.a,Object.assign({},r(g)),T)})}function o(u){if(!u)return null;var p;if(Array.isArray(u))p={checkedKeys:u,halfCheckedKeys:void 0};else if(Object(U.a)(u)==="object")p={checkedKeys:u.checked||void 0,halfCheckedKeys:u.halfChecked||void 0};else return Object(A.a)(!1,"`checkedKeys` is not an array or an object"),null;return p}function f(u,p){var c=new Set;function i(r){if(c.has(r))return;var t=p[r];if(!t)return;c.add(r);var s=t.parent,m=t.node;if(m.disabled)return;s&&i(s.key)}return(u||[]).forEach(function(r){i(r)}),Object(ce.a)(c)}function d(u){var p={};return Object.keys(u).forEach(function(c){(c.startsWith("data-")||c.startsWith("aria-"))&&(p[c]=u[c])}),p}},P48q:function(nt,We,J){nt.exports={flex_box_center:"flex_box_center___BHtvi",flex_space_between:"flex_space_between___1noDr",flex_box_vertical_center:"flex_box_vertical_center___2UDAc",flex_box_center_end:"flex_box_center_end___2j8--",flex_box_column:"flex_box_column___3X60k",tree:"tree___2kCYs",actions:"actions___10Q_6"}},SJMd:function(nt,We){/**
* @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 J,ce,U,S=!1,B,O;window.PR_SHOULD_USE_CONTINUATION=!0;var A,_;(function(){var M=window,L=["break,continue,do,else,for,if,return,while"],w=[L,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],y=[w,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],x=[y,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],C=[y,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],E=[y,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],b="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",v=[y,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],h="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",e=[L,"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=[L,"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=[L,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],f=[x,E,C,v,h,e,a,o],d=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,u="str",p="kwd",c="com",i="typ",r="lit",t="pun",s="pln",m="tag",g="dec",T="src",P="atn",I="atv",F="nocode",K="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function V(fe){for(var ye=0,xe=!1,Se=!1,Ne=0,Pe=fe.length;Ne<Pe;++Ne){var _e=fe[Ne];if(_e.ignoreCase)Se=!0;else if(/[a-z]/i.test(_e.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){xe=!0,Se=!1;break}}var Fe={b:8,t:9,n:10,v:11,f:12,r:13};function se(Te){var ve=Te.charCodeAt(0);if(ve!==92)return ve;var Ie=Te.charAt(1);return ve=Fe[Ie],ve||("0"<=Ie&&Ie<="7"?parseInt(Te.substring(1),8):Ie==="u"||Ie==="x"?parseInt(Te.substring(2),16):Te.charCodeAt(1))}function ue(Te){if(Te<32)return(Te<16?"\\x0":"\\x")+Te.toString(16);var ve=String.fromCharCode(Te);return ve==="\\"||ve==="-"||ve==="]"||ve==="^"?"\\"+ve:ve}function be(Te){var ve=Te.substring(1,Te.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")),Ie=[],Be=ve[0]==="^",ge=["["];Be&&ge.push("^");for(var Me=Be?1:0,re=ve.length;Me<re;++Me){var q=ve[Me];if(/\\[bdsw]/i.test(q))ge.push(q);else{var te=se(q),j;Me+2<re&&ve[Me+1]==="-"?(j=se(ve[Me+2]),Me+=2):j=te,Ie.push([te,j]),j<65||te>122||(j<65||te>90||Ie.push([Math.max(65,te)|32,Math.min(j,90)|32]),j<97||te>122||Ie.push([Math.max(97,te)&~32,Math.min(j,122)&~32]))}}Ie.sort(function(oe,he){return oe[0]-he[0]||he[1]-oe[1]});for(var W=[],G=[],Me=0;Me<Ie.length;++Me){var X=Ie[Me];X[0]<=G[1]+1?G[1]=Math.max(G[1],X[1]):W.push(G=X)}for(var Me=0;Me<W.length;++Me){var X=W[Me];ge.push(ue(X[0])),X[1]>X[0]&&(X[1]+1>X[0]&&ge.push("-"),ge.push(ue(X[1])))}return ge.push("]"),ge.join("")}function Ee(Te){for(var ve=Te.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")),Ie=ve.length,Be=[],ge=0,Me=0;ge<Ie;++ge){var re=ve[ge];if(re==="(")++Me;else if(re.charAt(0)==="\\"){var q=+re.substring(1);q&&(q<=Me?Be[q]=-1:ve[ge]=ue(q))}}for(var ge=1;ge<Be.length;++ge)Be[ge]===-1&&(Be[ge]=++ye);for(var ge=0,Me=0;ge<Ie;++ge){var re=ve[ge];if(re==="(")++Me,Be[Me]||(ve[ge]="(?:");else if(re.charAt(0)==="\\"){var q=+re.substring(1);q&&q<=Me&&(ve[ge]="\\"+Be[q])}}for(var ge=0;ge<Ie;++ge)ve[ge]==="^"&&ve[ge+1]!=="^"&&(ve[ge]="");if(Te.ignoreCase&&xe)for(var ge=0;ge<Ie;++ge){var re=ve[ge],te=re.charAt(0);re.length>=2&&te==="["?ve[ge]=be(re):te!=="\\"&&(ve[ge]=re.replace(/[a-zA-Z]/g,function(G){var X=G.charCodeAt(0);return"["+String.fromCharCode(X&~32,X|32)+"]"}))}return ve.join("")}for(var Ce=[],Ne=0,Pe=fe.length;Ne<Pe;++Ne){var _e=fe[Ne];if(_e.global||_e.multiline)throw new Error(""+_e);Ce.push("(?:"+Ee(_e)+")")}return new RegExp(Ce.join("|"),Se?"gi":"g")}function Q(fe,ye){var xe=/(?:^|\s)nocode(?:\s|$)/,Se=[],Ne=0,Pe=[],_e=0;function Fe(se){var ue=se.nodeType;if(ue==1){if(xe.test(se.className))return;for(var be=se.firstChild;be;be=be.nextSibling)Fe(be);var Ee=se.nodeName.toLowerCase();(Ee==="br"||Ee==="li")&&(Se[_e]=`
`,Pe[_e<<1]=Ne++,Pe[_e++<<1|1]=se)}else if(ue==3||ue==4){var Ce=se.nodeValue;Ce.length&&(ye?Ce=Ce.replace(/\r\n?/g,`
`):Ce=Ce.replace(/[ \t\r\n]+/g," "),Se[_e]=Ce,Pe[_e<<1]=Ne,Ne+=Ce.length,Pe[_e++<<1|1]=se)}}return Fe(fe),{sourceCode:Se.join("").replace(/\n$/,""),spans:Pe}}function Z(fe,ye,xe,Se,Ne){if(!xe)return;var Pe={sourceNode:fe,pre:1,langExtension:null,numberLines:null,sourceCode:xe,spans:null,basePos:ye,decorations:null};Se(Pe),Ne.push.apply(Ne,Pe.decorations)}var ie=/\S/;function pe(fe){for(var ye=void 0,xe=fe.firstChild;xe;xe=xe.nextSibling){var Se=xe.nodeType;ye=Se===1?ye?fe:xe:Se===3&&ie.test(xe.nodeValue)?fe:ye}return ye===fe?void 0:ye}function ae(fe,ye){var xe={},Se;(function(){for(var _e=fe.concat(ye),Fe=[],se={},ue=0,be=_e.length;ue<be;++ue){var Ee=_e[ue],Ce=Ee[3];if(Ce)for(var Te=Ce.length;--Te>=0;)xe[Ce.charAt(Te)]=Ee;var ve=Ee[1],Ie=""+ve;se.hasOwnProperty(Ie)||(Fe.push(ve),se[Ie]=null)}Fe.push(/[\0-\uffff]/),Se=V(Fe)})();var Ne=ye.length,Pe=function(_e){for(var Fe=_e.sourceCode,se=_e.basePos,ue=_e.sourceNode,be=[se,s],Ee=0,Ce=Fe.match(Se)||[],Te={},ve=0,Ie=Ce.length;ve<Ie;++ve){var Be=Ce[ve],ge=Te[Be],Me=void 0,re;if(typeof ge=="string")re=!1;else{var q=xe[Be.charAt(0)];if(q)Me=Be.match(q[1]),ge=q[0];else{for(var te=0;te<Ne;++te)if(q=ye[te],Me=Be.match(q[1]),Me){ge=q[0];break}Me||(ge=s)}re=ge.length>=5&&ge.substring(0,5)==="lang-",re&&!(Me&&typeof Me[1]=="string")&&(re=!1,ge=T),re||(Te[Be]=ge)}var j=Ee;if(Ee+=Be.length,!re)be.push(se+j,ge);else{var W=Me[1],G=Be.indexOf(W),X=G+W.length;Me[2]&&(X=Be.length-Me[2].length,G=X-W.length);var oe=ge.substring(5);Z(ue,se+j,Be.substring(0,G),Pe,be),Z(ue,se+j+G,W,H(oe,W),be),Z(ue,se+j+X,Be.substring(X),Pe,be)}}_e.decorations=be};return Pe}function de(fe){var ye=[],xe=[];fe.tripleQuotedStrings?ye.push([u,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):fe.multiLineStrings?ye.push([u,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ye.push([u,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),fe.verbatimStrings&&xe.push([u,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Se=fe.hashComments;Se&&(fe.cStyleComments?(Se>1?ye.push([c,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ye.push([c,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),xe.push([u,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ye.push([c,/^#[^\r\n]*/,null,"#"])),fe.cStyleComments&&(xe.push([c,/^\/\/[^\r\n]*/,null]),xe.push([c,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Ne=fe.regexLiterals;if(Ne){var Pe=Ne>1?"":`
\r`,_e=Pe?".":"[\\S\\s]",Fe="/(?=[^/*"+Pe+"])(?:[^/\\x5B\\x5C"+Pe+"]|\\x5C"+_e+"|\\x5B(?:[^\\x5C\\x5D"+Pe+"]|\\x5C"+_e+")*(?:\\x5D|$))+/";xe.push(["lang-regex",RegExp("^"+K+"("+Fe+")")])}var se=fe.types;se&&xe.push([i,se]);var ue=(""+fe.keywords).replace(/^ | $/g,"");ue.length&&xe.push([p,new RegExp("^(?:"+ue.replace(/[\s,]+/g,"|")+")\\b"),null]),ye.push([s,/^\s+/,null,` \r
\xA0`]);var be="^.[^\\s\\w.$@'\"`/\\\\]*";return fe.regexLiterals&&(be+="(?!s*/)"),xe.push([r,/^@[a-z_$][a-z_$@0-9]*/i,null],[i,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[s,/^[a-z_$][a-z_$@0-9]*/i,null],[r,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[s,/^\\[\s\S]?/,null],[t,new RegExp(be),null]),ae(ye,xe)}var le=de({keywords:f,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function $(fe,ye,xe){for(var Se=/(?:^|\s)nocode(?:\s|$)/,Ne=/\r\n?|\n/,Pe=fe.ownerDocument,_e=Pe.createElement("li");fe.firstChild;)_e.appendChild(fe.firstChild);var Fe=[_e];function se(ve){var Ie=ve.nodeType;if(Ie==1&&!Se.test(ve.className))if(ve.nodeName==="br")ue(ve),ve.parentNode&&ve.parentNode.removeChild(ve);else for(var Be=ve.firstChild;Be;Be=Be.nextSibling)se(Be);else if((Ie==3||Ie==4)&&xe){var ge=ve.nodeValue,Me=ge.match(Ne);if(Me){var re=ge.substring(0,Me.index);ve.nodeValue=re;var q=ge.substring(Me.index+Me[0].length);if(q){var te=ve.parentNode;te.insertBefore(Pe.createTextNode(q),ve.nextSibling)}ue(ve),re||ve.parentNode.removeChild(ve)}}}function ue(ve){for(;!ve.nextSibling;)if(ve=ve.parentNode,!ve)return;function Ie(Me,re){var q=re?Me.cloneNode(!1):Me,te=Me.parentNode;if(te){var j=Ie(te,1),W=Me.nextSibling;j.appendChild(q);for(var G=W;G;G=W)W=G.nextSibling,j.appendChild(G)}return q}for(var Be=Ie(ve.nextSibling,0),ge;(ge=Be.parentNode)&&ge.nodeType===1;)Be=ge;Fe.push(Be)}for(var be=0;be<Fe.length;++be)se(Fe[be]);ye===(ye|0)&&Fe[0].setAttribute("value",ye);var Ee=Pe.createElement("ol");Ee.className="linenums";for(var Ce=Math.max(0,ye-1|0)||0,be=0,Te=Fe.length;be<Te;++be)_e=Fe[be],_e.className="L"+(be+Ce)%10,_e.firstChild||_e.appendChild(Pe.createTextNode("\xA0")),Ee.appendChild(_e);fe.appendChild(Ee)}function Y(fe){var ye=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ye=ye&&+ye[1]<=8;var xe=/\n/g,Se=fe.sourceCode,Ne=Se.length,Pe=0,_e=fe.spans,Fe=_e.length,se=0,ue=fe.decorations,be=ue.length,Ee=0;ue[be]=Ne;var Ce,Te;for(Te=Ce=0;Te<be;)ue[Te]!==ue[Te+2]?(ue[Ce++]=ue[Te++],ue[Ce++]=ue[Te++]):Te+=2;for(be=Ce,Te=Ce=0;Te<be;){for(var ve=ue[Te],Ie=ue[Te+1],Be=Te+2;Be+2<=be&&ue[Be+1]===Ie;)Be+=2;ue[Ce++]=ve,ue[Ce++]=Ie,Te=Be}be=ue.length=Ce;var ge=fe.sourceNode,Me="";ge&&(Me=ge.style.display,ge.style.display="none");try{for(var re=null;se<Fe;){var q=_e[se],te=_e[se+2]||Ne,j=ue[Ee+2]||Ne,Be=Math.min(te,j),W=_e[se+1],G;if(W.nodeType!==1&&(G=Se.substring(Pe,Be))){ye&&(G=G.replace(xe,"\r")),W.nodeValue=G;var X=W.ownerDocument,oe=X.createElement("span");oe.className=ue[Ee+1];var he=W.parentNode;he.replaceChild(oe,W),oe.appendChild(W),Pe<te&&(_e[se+1]=W=X.createTextNode(Se.substring(Be,te)),he.insertBefore(W,oe.nextSibling))}Pe=Be,Pe>=te&&(se+=2),Pe>=j&&(Ee+=2)}}finally{ge&&(ge.style.display=Me)}}var ne={};function z(fe,ye){for(var xe=ye.length;--xe>=0;){var Se=ye[xe];ne.hasOwnProperty(Se)?M.console&&console.warn("cannot override language handler %s",Se):ne[Se]=fe}}function H(fe,ye){return fe&&ne.hasOwnProperty(fe)||(fe=/^\s*</.test(ye)?"default-markup":"default-code"),ne[fe]}z(le,["default-code"]),z(ae([],[[s,/^[^<?]+/],[g,/^<!\w[^>]*(?:>|$)/],[c,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[t,/^(?:<[%?]|[%?]>)/],["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"]),z(ae([[s,/^[\s]+/,null,` \r
`],[I,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[t,/^[=<>\/]+/],["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"]),z(ae([],[[I,/^[\s\S]+/]]),["uq.val"]),z(de({keywords:x,hashComments:!0,cStyleComments:!0,types:d}),["c","cc","cpp","cxx","cyc","m"]),z(de({keywords:"null,true,false"}),["json"]),z(de({keywords:E,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:d}),["cs"]),z(de({keywords:C,cStyleComments:!0}),["java"]),z(de({keywords:o,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),z(de({keywords:e,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),z(de({keywords:h,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),z(de({keywords:a,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),z(de({keywords:v,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),z(de({keywords:b,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),z(ae([],[[u,/^[\s\S]+/]]),["regex"]);function me(fe){var ye=fe.langExtension;try{var xe=Q(fe.sourceNode,fe.pre),Se=xe.sourceCode;fe.sourceCode=Se,fe.spans=xe.spans,fe.basePos=0,H(ye,Se)(fe),Y(fe)}catch(Ne){M.console&&console.log(Ne&&Ne.stack||Ne)}}function Le(fe,ye,xe){var Se=xe||!1,Ne=ye||null,Pe=document.createElement("div");Pe.innerHTML="<pre>"+fe+"</pre>",Pe=Pe.firstChild,Se&&$(Pe,Se,!0);var _e={langExtension:Ne,numberLines:Se,sourceNode:Pe,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return me(_e),Pe.innerHTML}function Oe(fe,ye){var xe=ye||document.body,Se=xe.ownerDocument||document;function Ne(q){return xe.getElementsByTagName(q)}for(var Pe=[Ne("pre"),Ne("code"),Ne("xmp")],_e=[],Fe=0;Fe<Pe.length;++Fe)for(var se=0,ue=Pe[Fe].length;se<ue;++se)_e.push(Pe[Fe][se]);Pe=null;var be=Date;be.now||(be={now:function(){return+new Date}});var Ee=0,Ce=/\blang(?:uage)?-([\w.]+)(?!\S)/,Te=/\bprettyprint\b/,ve=/\bprettyprinted\b/,Ie=/pre|xmp/i,Be=/^code$/i,ge=/^(?:pre|code|xmp)$/i,Me={};function re(){for(var q=M.PR_SHOULD_USE_CONTINUATION?be.now()+250:Infinity;Ee<_e.length&&be.now()<q;Ee++){for(var te=_e[Ee],j=Me,W=te;W=W.previousSibling;){var G=W.nodeType,X=(G===7||G===8)&&W.nodeValue;if(X?!/^\??prettify\b/.test(X):G!==3||/\S/.test(W.nodeValue))break;if(X){j={},X.replace(/\b(\w+)=([\w:.%+-]+)/g,function(ct,qe,yt){j[qe]=yt});break}}var oe=te.className;if((j!==Me||Te.test(oe))&&!ve.test(oe)){for(var he=!1,ke=te.parentNode;ke;ke=ke.parentNode){var He=ke.tagName;if(ge.test(He)&&ke.className&&Te.test(ke.className)){he=!0;break}}if(!he){te.className+=" prettyprinted";var $e=j.lang;if(!$e){$e=oe.match(Ce);var ze;!$e&&(ze=pe(te))&&Be.test(ze.tagName)&&($e=ze.className.match(Ce)),$e&&($e=$e[1])}var Ze;if(Ie.test(te.tagName))Ze=1;else{var et=te.currentStyle,Xe=Se.defaultView,mt=et?et.whiteSpace:Xe&&Xe.getComputedStyle?Xe.getComputedStyle(te,null).getPropertyValue("white-space"):0;Ze=mt&&mt.substring(0,3)==="pre"}var rt=j.linenums;(rt=rt==="true"||+rt)||(rt=oe.match(/\blinenums\b(?::(\d+))?/),rt=rt?rt[1]&&rt[1].length?+rt[1]:!0:!1),rt&&$(te,rt,Ze);var vt={langExtension:$e,sourceNode:te,numberLines:rt,pre:Ze,sourceCode:null,basePos:null,spans:null,decorations:null};me(vt)}}}Ee<_e.length?M.setTimeout(re,250):typeof fe=="function"&&fe()}re()}var Ae=M.PR={createSimpleLexer:ae,registerLangHandler:z,sourceDecorator:de,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:I,PR_COMMENT:c,PR_DECLARATION:g,PR_KEYWORD:p,PR_LITERAL:r,PR_NOCODE:F,PR_PLAIN:s,PR_PUNCTUATION:t,PR_SOURCE:T,PR_STRING:u,PR_TAG:m,PR_TYPE:i,prettyPrintOne:S?M.prettyPrintOne=Le:A=Le,prettyPrint:_=S?M.prettyPrint=Oe:_=Oe},Re=M.define;typeof Re=="function"&&Re.amd&&Re("google-code-prettify",[],function(){return Ae})})()},"U/Y8":function(nt,We,J){nt.exports={flex_box_center:"flex_box_center___2aRVA",flex_space_between:"flex_space_between___12c3F",flex_box_vertical_center:"flex_box_vertical_center___30OYS",flex_box_center_end:"flex_box_center_end___12QBt",flex_box_column:"flex_box_column___t6urT",info:"info___2BaCz",bar:"bar___3Aega"}},WaYH:function(nt,We,J){"use strict";var ce=J("rePB"),U=J("Ff2n"),S=J("VTBJ"),B=J("1OyB"),O=J("vuIU"),A=J("JX7q"),_=J("Ji7U"),M=J("LK+K"),L=J("q1tI"),w=J("TSYQ"),y=J.n(w),x=J("sboe"),C=J("OZM5"),E=function(p){var c=p.prefixCls,i=p.level,r=p.isStart,t=p.isEnd;if(!i)return null;for(var s="".concat(c,"-indent-unit"),m=[],g=0;g<i;g+=1){var T;m.push(L.createElement("span",{key:g,className:y()(s,(T={},Object(ce.a)(T,"".concat(s,"-start"),r[g+1]),Object(ce.a)(T,"".concat(s,"-end"),t[g+1]),Object(ce.a)(T,"".concat(s,"-end-first-level"),!g&&t[0]),T))}))}return L.createElement("span",{"aria-hidden":"true",className:"".concat(c,"-indent")},m)},b=E,v=J("815F"),h="open",e="close",a="---",o=function(u){Object(_.a)(c,u);var p=Object(M.a)(c);function c(){var i;return Object(B.a)(this,c),i=p.apply(this,arguments),i.state={dragNodeHighlight:!1},i.onSelectorClick=function(r){var t=i.props.context.onNodeClick;t(r,Object(v.b)(i.props)),i.isSelectable()?i.onSelect(r):i.onCheck(r)},i.onSelectorDoubleClick=function(r){var t=i.props.context.onNodeDoubleClick;t(r,Object(v.b)(i.props))},i.onSelect=function(r){if(i.isDisabled())return;var t=i.props.context.onNodeSelect;r.preventDefault(),t(r,Object(v.b)(i.props))},i.onCheck=function(r){if(i.isDisabled())return;var t=i.props,s=t.disableCheckbox,m=t.checked,g=i.props.context.onNodeCheck;if(!i.isCheckable()||s)return;r.preventDefault();var T=!m;g(r,Object(v.b)(i.props),T)},i.onMouseEnter=function(r){var t=i.props.context.onNodeMouseEnter;t(r,Object(v.b)(i.props))},i.onMouseLeave=function(r){var t=i.props.context.onNodeMouseLeave;t(r,Object(v.b)(i.props))},i.onContextMenu=function(r){var t=i.props.context.onNodeContextMenu;t(r,Object(v.b)(i.props))},i.onDragStart=function(r){var t=i.props.context.onNodeDragStart;r.stopPropagation(),i.setState({dragNodeHighlight:!0}),t(r,Object(A.a)(i));try{r.dataTransfer.setData("text/plain","")}catch(s){}},i.onDragEnter=function(r){var t=i.props.context.onNodeDragEnter;r.preventDefault(),r.stopPropagation(),t(r,Object(A.a)(i))},i.onDragOver=function(r){var t=i.props.context.onNodeDragOver;r.preventDefault(),r.stopPropagation(),t(r,Object(A.a)(i))},i.onDragLeave=function(r){var t=i.props.context.onNodeDragLeave;r.stopPropagation(),t(r,Object(A.a)(i))},i.onDragEnd=function(r){var t=i.props.context.onNodeDragEnd;r.stopPropagation(),i.setState({dragNodeHighlight:!1}),t(r,Object(A.a)(i))},i.onDrop=function(r){var t=i.props.context.onNodeDrop;r.preventDefault(),r.stopPropagation(),i.setState({dragNodeHighlight:!1}),t(r,Object(A.a)(i))},i.onExpand=function(r){var t=i.props.context.onNodeExpand;t(r,Object(v.b)(i.props))},i.setSelectHandle=function(r){i.selectHandle=r},i.getNodeState=function(){var r=i.props.expanded;return i.isLeaf()?null:r?h:e},i.hasChildren=function(){var r=i.props.eventKey,t=i.props.context.keyEntities,s=t[r]||{},m=s.children;return!!(m||[]).length},i.isLeaf=function(){var r=i.props,t=r.isLeaf,s=r.loaded,m=i.props.context.loadData,g=i.hasChildren();return t===!1?!1:t||!m&&!g||m&&s&&!g},i.isDisabled=function(){var r=i.props.disabled,t=i.props.context.disabled;return!!(t||r)},i.isCheckable=function(){var r=i.props.checkable,t=i.props.context.checkable;return!t||r===!1?!1:t},i.syncLoadData=function(r){var t=r.expanded,s=r.loading,m=r.loaded,g=i.props.context,T=g.loadData,P=g.onNodeLoad;if(s)return;T&&t&&!i.isLeaf()&&(!i.hasChildren()&&!m&&P(Object(v.b)(i.props)))},i.renderSwitcher=function(){var r=i.props,t=r.expanded,s=r.switcherIcon,m=i.props.context,g=m.prefixCls,T=m.switcherIcon,P=s||T;if(i.isLeaf())return L.createElement("span",{className:y()("".concat(g,"-switcher"),"".concat(g,"-switcher-noop"))},typeof P=="function"?P(Object(S.a)(Object(S.a)({},i.props),{},{isLeaf:!0})):P);var I=y()("".concat(g,"-switcher"),"".concat(g,"-switcher_").concat(t?h:e));return L.createElement("span",{onClick:i.onExpand,className:I},typeof P=="function"?P(Object(S.a)(Object(S.a)({},i.props),{},{isLeaf:!1})):P)},i.renderCheckbox=function(){var r=i.props,t=r.checked,s=r.halfChecked,m=r.disableCheckbox,g=i.props.context.prefixCls,T=i.isDisabled(),P=i.isCheckable();if(!P)return null;var I=typeof P!="boolean"?P:null;return L.createElement("span",{className:y()("".concat(g,"-checkbox"),t&&"".concat(g,"-checkbox-checked"),!t&&s&&"".concat(g,"-checkbox-indeterminate"),(T||m)&&"".concat(g,"-checkbox-disabled")),onClick:i.onCheck},I)},i.renderIcon=function(){var r=i.props.loading,t=i.props.context.prefixCls;return L.createElement("span",{className:y()("".concat(t,"-iconEle"),"".concat(t,"-icon__").concat(i.getNodeState()||"docu"),r&&"".concat(t,"-icon_loading"))})},i.renderSelector=function(){var r=i.state.dragNodeHighlight,t=i.props,s=t.title,m=t.selected,g=t.icon,T=t.loading,P=t.data,I=i.props.context,F=I.prefixCls,K=I.showIcon,V=I.icon,Q=I.draggable,Z=I.loadData,ie=I.titleRender,pe=i.isDisabled(),ae="".concat(F,"-node-content-wrapper"),de;if(K){var le=g||V;de=le?L.createElement("span",{className:y()("".concat(F,"-iconEle"),"".concat(F,"-icon__customize"))},typeof le=="function"?le(i.props):le):i.renderIcon()}else Z&&T&&(de=i.renderIcon());var $;typeof s=="function"?$=s(P):ie?$=ie(P):$=s;var Y=L.createElement("span",{className:"".concat(F,"-title")},$);return L.createElement("span",{ref:i.setSelectHandle,title:typeof s=="string"?s:"",className:y()("".concat(ae),"".concat(ae,"-").concat(i.getNodeState()||"normal"),!pe&&(m||r)&&"".concat(F,"-node-selected"),!pe&&Q&&"draggable"),draggable:!pe&&Q||void 0,"aria-grabbed":!pe&&Q||void 0,onMouseEnter:i.onMouseEnter,onMouseLeave:i.onMouseLeave,onContextMenu:i.onContextMenu,onClick:i.onSelectorClick,onDoubleClick:i.onSelectorDoubleClick,onDragStart:Q?i.onDragStart:void 0},de,Y)},i}return Object(O.a)(c,[{key:"componentDidMount",value:function(){this.syncLoadData(this.props)}},{key:"componentDidUpdate",value:function(){this.syncLoadData(this.props)}},{key:"isSelectable",value:function(){var r=this.props.selectable,t=this.props.context.selectable;return typeof r=="boolean"?r:t}},{key:"render",value:function(){var r,t=this.props,s=t.eventKey,m=t.className,g=t.style,T=t.dragOver,P=t.dragOverGapTop,I=t.dragOverGapBottom,F=t.isLeaf,K=t.isStart,V=t.isEnd,Q=t.expanded,Z=t.selected,ie=t.checked,pe=t.halfChecked,ae=t.loading,de=t.domRef,le=t.active,$=t.onMouseMove,Y=Object(U.a)(t,["eventKey","className","style","dragOver","dragOverGapTop","dragOverGapBottom","isLeaf","isStart","isEnd","expanded","selected","checked","halfChecked","loading","domRef","active","onMouseMove"]),ne=this.props.context,z=ne.prefixCls,H=ne.filterTreeNode,me=ne.draggable,Le=ne.keyEntities,Oe=this.isDisabled(),Ae=Object(C.f)(Y),Re=Le[s]||{},fe=Re.level,ye=V[V.length-1];return L.createElement("div",Object.assign({ref:de,className:y()(m,"".concat(z,"-treenode"),(r={},Object(ce.a)(r,"".concat(z,"-treenode-disabled"),Oe),Object(ce.a)(r,"".concat(z,"-treenode-switcher-").concat(Q?"open":"close"),!F),Object(ce.a)(r,"".concat(z,"-treenode-checkbox-checked"),ie),Object(ce.a)(r,"".concat(z,"-treenode-checkbox-indeterminate"),pe),Object(ce.a)(r,"".concat(z,"-treenode-selected"),Z),Object(ce.a)(r,"".concat(z,"-treenode-loading"),ae),Object(ce.a)(r,"".concat(z,"-treenode-active"),le),Object(ce.a)(r,"".concat(z,"-treenode-leaf-last"),ye),Object(ce.a)(r,"drag-over",!Oe&&T),Object(ce.a)(r,"drag-over-gap-top",!Oe&&P),Object(ce.a)(r,"drag-over-gap-bottom",!Oe&&I),Object(ce.a)(r,"filter-node",H&&H(Object(v.b)(this.props))),r)),style:g,onDragEnter:me?this.onDragEnter:void 0,onDragOver:me?this.onDragOver:void 0,onDragLeave:me?this.onDragLeave:void 0,onDrop:me?this.onDrop:void 0,onDragEnd:me?this.onDragEnd:void 0,onMouseMove:$},Ae),L.createElement(b,{prefixCls:z,level:fe,isStart:K,isEnd:V}),this.renderSwitcher(),this.renderCheckbox(),this.renderSelector())}}]),c}(L.Component),f=function(p){return L.createElement(x.a.Consumer,null,function(c){return L.createElement(o,Object.assign({},p,{context:c}))})};f.displayName="TreeNode",f.defaultProps={title:a},f.isTreeNode=1;var d=We.a=f},Y1PL:function(nt,We,J){"use strict";J.r(We),J.d(We,"ResizableTextArea",function(){return pe});var ce=J("wx14"),U=J("1OyB"),S=J("vuIU"),B=J("Ji7U"),O=J("LK+K"),A=J("q1tI"),_=J("VTBJ"),M=J("rePB"),L=J("Zm9Q"),w=J("Kwbf"),y=J("c+Xe"),x=J("m+aA"),C=J("bdgK"),E=new Map;function b(le){le.forEach(function($){var Y,ne=$.target;(Y=E.get(ne))===null||Y===void 0||Y.forEach(function(z){return z(ne)})})}var v=new C.default(b),h=null,e=null;function a(le,$){E.has(le)||(E.set(le,new Set),v.observe(le)),E.get(le).add($)}function o(le,$){E.has(le)&&(E.get(le).delete($),E.get(le).size||(v.unobserve(le),E.delete(le)))}var f=function(le){Object(B.a)(Y,le);var $=Object(O.a)(Y);function Y(){return Object(U.a)(this,Y),$.apply(this,arguments)}return Object(S.a)(Y,[{key:"render",value:function(){return this.props.children}}]),Y}(A.Component),d=A.createContext(null);function u(le){var $=le.children,Y=le.onBatchResize,ne=A.useRef(0),z=A.useRef([]),H=A.useContext(d),me=A.useCallback(function(Le,Oe,Ae){ne.current+=1;var Re=ne.current;z.current.push({size:Le,element:Oe,data:Ae}),Promise.resolve().then(function(){Re===ne.current&&(Y==null||Y(z.current),z.current=[])}),H==null||H(Le,Oe,Ae)},[Y,H]);return A.createElement(d.Provider,{value:me},$)}function p(le){var $=le.children,Y=le.disabled,ne=A.useRef(null),z=A.useRef(null),H=A.useContext(d),me=A.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Le=A.isValidElement($)&&Object(y.c)($),Oe=Le?$.ref:null,Ae=A.useMemo(function(){return Object(y.a)(Oe,ne)},[Oe,ne]),Re=A.useRef(le);Re.current=le;var fe=A.useCallback(function(ye){var xe=Re.current,Se=xe.onResize,Ne=xe.data,Pe=ye.getBoundingClientRect(),_e=Pe.width,Fe=Pe.height,se=ye.offsetWidth,ue=ye.offsetHeight,be=Math.floor(_e),Ee=Math.floor(Fe);if(me.current.width!==be||me.current.height!==Ee||me.current.offsetWidth!==se||me.current.offsetHeight!==ue){var Ce={width:be,height:Ee,offsetWidth:se,offsetHeight:ue};me.current=Ce;var Te=se===Math.round(_e)?_e:se,ve=ue===Math.round(Fe)?Fe:ue,Ie=Object(_.a)(Object(_.a)({},Ce),{},{offsetWidth:Te,offsetHeight:ve});H==null||H(Ie,ye,Ne),Se&&Promise.resolve().then(function(){Se(Ie,ye)})}},[]);return A.useEffect(function(){var ye=Object(x.a)(ne.current)||Object(x.a)(z.current);return ye&&!Y&&a(ye,fe),function(){return o(ye,fe)}},[ne.current,Y]),A.createElement(f,{ref:z},Le?A.cloneElement($,{ref:Ae}):$)}var c="rc-observer-key";function i(le){var $=le.children,Y=Object(L.a)($);return Y.map(function(ne,z){var H=(ne==null?void 0:ne.key)||"".concat(c,"-").concat(z);return A.createElement(p,Object(ce.a)({},le,{key:H}),ne)})}i.Collection=u;var r=i,t=J("bT9E"),s=J("TSYQ"),m=J.n(s),g=`
min-height:0 !important;
max-height:none !important;
height:0 !important;
visibility:hidden !important;
overflow:hidden !important;
position:absolute !important;
z-index:-1000 !important;
top:0 !important;
right:0 !important
`,T=["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"],P={},I;function F(le){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Y=le.getAttribute("id")||le.getAttribute("data-reactid")||le.getAttribute("name");if($&&P[Y])return P[Y];var ne=window.getComputedStyle(le),z=ne.getPropertyValue("box-sizing")||ne.getPropertyValue("-moz-box-sizing")||ne.getPropertyValue("-webkit-box-sizing"),H=parseFloat(ne.getPropertyValue("padding-bottom"))+parseFloat(ne.getPropertyValue("padding-top")),me=parseFloat(ne.getPropertyValue("border-bottom-width"))+parseFloat(ne.getPropertyValue("border-top-width")),Le=T.map(function(Ae){return"".concat(Ae,":").concat(ne.getPropertyValue(Ae))}).join(";"),Oe={sizingStyle:Le,paddingSize:H,borderSize:me,boxSizing:z};return $&&Y&&(P[Y]=Oe),Oe}function K(le){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,ne=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)),le.getAttribute("wrap")?I.setAttribute("wrap",le.getAttribute("wrap")):I.removeAttribute("wrap");var z=F(le,$),H=z.paddingSize,me=z.borderSize,Le=z.boxSizing,Oe=z.sizingStyle;I.setAttribute("style","".concat(Oe,";").concat(g)),I.value=le.value||le.placeholder||"";var Ae=Number.MIN_SAFE_INTEGER,Re=Number.MAX_SAFE_INTEGER,fe=I.scrollHeight,ye;if(Le==="border-box"?fe+=me:Le==="content-box"&&(fe-=H),Y!==null||ne!==null){I.value=" ";var xe=I.scrollHeight-H;Y!==null&&(Ae=xe*Y,Le==="border-box"&&(Ae=Ae+H+me),fe=Math.max(Ae,fe)),ne!==null&&(Re=xe*ne,Le==="border-box"&&(Re=Re+H+me),ye=fe>Re?"":"hidden",fe=Math.min(Re,fe))}return{height:fe,minHeight:Ae,maxHeight:Re,overflowY:ye,resize:"none"}}var V=J("Gytx"),Q=J.n(V),Z;(function(le){le[le.NONE=0]="NONE",le[le.RESIZING=1]="RESIZING",le[le.RESIZED=2]="RESIZED"})(Z||(Z={}));var ie=function(le){Object(B.a)(Y,le);var $=Object(O.a)(Y);function Y(ne){var z;return Object(U.a)(this,Y),z=$.call(this,ne),z.nextFrameActionId=void 0,z.resizeFrameId=void 0,z.textArea=void 0,z.saveTextArea=function(H){z.textArea=H},z.handleResize=function(H){var me=z.state.resizeStatus,Le=z.props,Oe=Le.autoSize,Ae=Le.onResize;if(me!==Z.NONE)return;typeof Ae=="function"&&Ae(H),Oe&&z.resizeOnNextFrame()},z.resizeOnNextFrame=function(){cancelAnimationFrame(z.nextFrameActionId),z.nextFrameActionId=requestAnimationFrame(z.resizeTextarea)},z.resizeTextarea=function(){var H=z.props.autoSize;if(!H||!z.textArea)return;var me=H.minRows,Le=H.maxRows,Oe=K(z.textArea,!1,me,Le);z.setState({textareaStyles:Oe,resizeStatus:Z.RESIZING},function(){cancelAnimationFrame(z.resizeFrameId),z.resizeFrameId=requestAnimationFrame(function(){z.setState({resizeStatus:Z.RESIZED},function(){z.resizeFrameId=requestAnimationFrame(function(){z.setState({resizeStatus:Z.NONE}),z.fixFirefoxAutoScroll()})})})})},z.renderTextArea=function(){var H=z.props,me=H.prefixCls,Le=me===void 0?"rc-textarea":me,Oe=H.autoSize,Ae=H.onResize,Re=H.className,fe=H.disabled,ye=z.state,xe=ye.textareaStyles,Se=ye.resizeStatus,Ne=Object(t.a)(z.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Pe=m()(Le,Re,Object(M.a)({},"".concat(Le,"-disabled"),fe));"value"in Ne&&(Ne.value=Ne.value||"");var _e=Object(_.a)(Object(_.a)(Object(_.a)({},z.props.style),xe),Se===Z.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return A.createElement(r,{onResize:z.handleResize,disabled:!(Oe||Ae)},A.createElement("textarea",Object(ce.a)({},Ne,{className:Pe,style:_e,ref:z.saveTextArea})))},z.state={textareaStyles:{},resizeStatus:Z.NONE},z}return Object(S.a)(Y,[{key:"componentDidUpdate",value:function(z){(z.value!==this.props.value||!Q()(z.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 z=this.textArea.selectionStart,H=this.textArea.selectionEnd;this.textArea.setSelectionRange(z,H)}}catch(me){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Y}(A.Component),pe=ie,ae=function(le){Object(B.a)(Y,le);var $=Object(O.a)(Y);function Y(ne){var z;Object(U.a)(this,Y),z=$.call(this,ne),z.resizableTextArea=void 0,z.focus=function(){z.resizableTextArea.textArea.focus()},z.saveTextArea=function(me){z.resizableTextArea=me},z.handleChange=function(me){var Le=z.props.onChange;z.setValue(me.target.value,function(){z.resizableTextArea.resizeTextarea()}),Le&&Le(me)},z.handleKeyDown=function(me){var Le=z.props,Oe=Le.onPressEnter,Ae=Le.onKeyDown;me.keyCode===13&&Oe&&Oe(me),Ae&&Ae(me)};var H=typeof ne.value=="undefined"||ne.value===null?ne.defaultValue:ne.value;return z.state={value:H},z}return Object(S.a)(Y,[{key:"setValue",value:function(z,H){"value"in this.props||this.setState({value:z},H)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return A.createElement(pe,Object(ce.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(z){return"value"in z?{value:z.value}:null}}]),Y}(A.Component),de=We.default=ae},ZW9T:function(nt,We,J){"use strict";J.d(We,"a",function(){return f});var ce=J("k1fw"),U=J("miYZ"),S=J("tsqr"),B=J("rAM+"),O=J("tJVT"),A=J("PpiC"),_=J("q1tI"),M=J.n(_),L=J("bdgK");function w(d,u,p,c,i){var r=u.getWordUntilPosition(p),t={startLineNumber:p.lineNumber,endLineNumber:p.lineNumber,startColumn:r.startColumn,endColumn:r.endColumn},s=c.map(function(m){return{label:m,kind:d.languages.CompletionItemKind.Keyword,insertText:m,insertTextRules:d.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:t}});return i.map(function(m){s.push(Object(ce.a)(Object(ce.a)({},m),{},{range:t}))}),s}var y=function(d){var u={label:"ifelse",kind:d.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
`),insertTextRules:d.languages.CompletionItemInsertTextRule.InsertAsSnippet},p=["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"];d.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(t,s){var m=w(d,t,s,p,[u]);return{suggestions:m}}});var c=["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"];d.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(t,s){var m=[{label:"print",kind:d.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
`),insertTextRules:d.languages.CompletionItemInsertTextRule.InsertAsSnippet}],g=w(d,t,s,c,m);return{suggestions:g}}});var i=["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"];d.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(t,s){var m=[u,{label:"main",kind:d.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
`),insertTextRules:d.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:d.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
`),insertTextRules:d.languages.CompletionItemInsertTextRule.InsertAsSnippet}],g=w(d,t,s,i,m);return{suggestions:g}}})},x="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",C=J("LvDl");function E(d){return/^\d+$/.test(d)?"".concat(d,"px"):d}function b(){}var v=!1,h={"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 e(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],u=d;if(Array.isArray(d)){for(var p=0;p<d.length;p++){var c=h[d[p]];if(c)return c}return u[0]}return h[u]||u}var a=null,o=We.b=function(d){var u=d.width,p=u===void 0?"100%":u,c=d.height,i=c===void 0?"100%":c,r=d.value,t=d.language,s=t===void 0?"javascript":t,m=d.style,g=m===void 0?{}:m,T=d.options,P=T===void 0?{}:T,I=d.overrideServices,F=I===void 0?{}:I,K=d.theme,V=K===void 0?"vs-dark":K,Q=d.onEditBlur,Z=d.onSave,ie=d.autoHeight,pe=ie===void 0?!1:ie,ae=d.forbidCopy,de=ae===void 0?!1:ae,le=d.onChange,$=le===void 0?b:le,Y=d.editorDidMount,ne=Y===void 0?b:Y,z=d.onFocus,H=z===void 0?b:z,me=d.filename,Le=me===void 0?"educoder.txt":me,Oe=Object(A.a)(d,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Ae=Object(_.useRef)(),Re=Object(_.useRef)({}),fe=Object(_.useRef)(),ye=Object(_.useRef)(!1),xe=Object(_.useRef)(),Se=Object(_.useState)(!1),Ne=Object(O.a)(Se,2),Pe=Ne[0],_e=Ne[1];function Fe(){var G;return Ae.current&&(G=new L.default(function(X){var oe=Object(B.a)(X),he;try{for(oe.s();!(he=oe.n()).done;){var ke=he.value;(ke.target.offsetHeight>0||ke.target.offsetWidth>0)&&Re.current.instance.layout()}}catch(He){oe.e(He)}finally{oe.f()}}),G.observe(Ae.current)),G}function se(){S.b.warn(decodeURIComponent(x))}var ue=function(){var X=Re.current.instance;if(r!=null&&X&&Pe){var oe=X.getModel();oe&&r!==oe.getValue()&&(v=!0,oe.setValue(r),X.layout(),v=!1)}};Object(_.useEffect)(function(){fe.current&&clearTimeout(fe.current),fe.current=setTimeout(function(){ue()},500)},[r,Pe,Re.current]);function be(){var G=Re.current.instance;if(G){var X=G.getSelection(),oe=Re.current.pastePos||{},he=new a.Range(oe.startLineNumber||X.endLineNumber,oe.startColumn||X.endColumn,oe.endLineNumber||X.endLineNumber,oe.endColumn||X.endColumn);setTimeout(function(){G.executeEdits("",[{range:he,text:""}])},300)}}function Ee(G){(window.navigator.platform.match("Mac")?G.metaKey:G.ctrlKey)&&G.keyCode==83&&(G.preventDefault(),Z())}var Ce=function(){if(pe&&Re.current.instance){var X=Re.current.instance.getContentHeight();j(X<i?i:X)}else j(i)};function Te(G){var X=document.createEvent("MouseEvents");X.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),G.dispatchEvent(X)}function ve(G,X){var oe=window.URL||window.webkitURL||window,he=new Blob([X]),ke=document.createElementNS("http://www.w3.org/1999/xhtml","a");ke.href=oe.createObjectURL(he),ke.download=G,Te(ke)}Object(_.useEffect)(function(){Ce()},[Ce]),Object(_.useEffect)(function(){Ae.current&&!Pe&&J.e(27).then(J.t.bind(null,"M/lh",7)).then(function(G){try{a=G,Re.current.instance=a.editor.create(Ae.current,{value:r,language:e(s),theme:V,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},F);var X=Re.current.instance;if(ne(X,a),setTimeout(function(){Ce(),Re.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){ve(Le||"educoder.txt",X.getValue())}})},500),Re.current.subscription=X.onDidChangeModelContent(function(he){ye.current?clearTimeout(xe.current):(Ce(),$(X.getValue(),he)),xe.current=setTimeout(function(){ye.current=!1},500)}),window.Monaco||y(a),de&&(X.addCommand(a.KeyMod.CtrlCmd|a.KeyMod.Shift|a.KeyCode.KEY_V,function(){return se(),null}),X.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KEY_C,function(){return se(),null})),window.Monaco=a,Q&&X.onDidBlurEditorWidget(function(){Q(X.getValue())}),H&&X.onDidFocusEditorText(function(){H(X.getValue())}),de){X.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KEY_V,function(){return se(),null}),X.onDidPaste(function(he){Re.current.pastePos=he});try{window.addEventListener("paste",be)}catch(he){}}var oe=Fe();return _e(!0),function(){var he=Re.current.instance;he.dispose();var ke=he.getModel();ke&&ke.dispose(),Re.current.subscription&&Re.current.subscription.dispose(),de&&window.removeEventListener("paste",be),oe.unobserve(Ae.current)}}catch(he){}})},[]),Object(_.useEffect)(function(){var G=Re.current.instance;if(G&&Pe)return document.addEventListener("keydown",Ee,!1),function(){document.removeEventListener("keydown",Ee)}},[Z,Pe]),Object(_.useEffect)(function(){var G=Re.current.instance;if(G&&Pe){var X=e(s);a.editor.setModelLanguage(G.getModel(),X),console.log("language:",s,G.getModel(),X)}},[s,Pe]),Object(_.useEffect)(function(){var G=Re.current.instance;G&&Pe&&a.editor.setTheme(V)},[V,Pe]),Object(_.useEffect)(function(){var G=Re.current.instance;G&&Pe&&(G.updateOptions(Object(ce.a)({},P)),setTimeout(function(){G.getModel().updateOptions(Object(ce.a)({},P))},200))},[JSON.stringify(P),Pe]),Object(_.useEffect)(function(){var G=Re.current.instance;G&&Pe&&G.layout()},[p,i,Pe]);var Ie=Object(_.useState)(E(p)),Be=Object(O.a)(Ie,2),ge=Be[0],Me=Be[1],re=Object(_.useState)(E(i)),q=Object(O.a)(re,2),te=q[0],j=q[1],W=Object(ce.a)(Object(ce.a)({},g),{},{width:ge,height:te});return M.a.createElement("div",{className:"my-monaco-editor",ref:Ae,style:W})};function f(d){var u=d.width,p=u===void 0?"100%":u,c=d.height,i=c===void 0?"100%":c,r=d.original,t=d.modified,s=d.language,m=d.options,g=m===void 0?{}:m,T=Object(_.useRef)(),P=Object(_.useState)(null),I=Object(O.a)(P,2),F=I[0],K=I[1];function V(pe){var ae;return T.current&&(ae=new L.default(function(de){var le=Object(B.a)(de),$;try{for(le.s();!($=le.n()).done;){var Y=$.value;(Y.target.offsetHeight>0||Y.target.offsetWidth>0)&&pe.layout()}}catch(ne){le.e(ne)}finally{le.f()}}),ae.observe(T.current)),ae}Object(_.useEffect)(function(){T.current&&J.e(27).then(J.t.bind(null,"M/lh",7)).then(function(pe){a=pe;var ae=a.editor.createDiffEditor(T.current,Object(ce.a)(Object(ce.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},g),{},{wordWrap:!0}));K(ae);var de=V(ae);return function(){ae.dispose();var le=ae.getModel();le&&le.dispose(),de.unobserve(T.current)}})},[]),Object(_.useEffect)(function(){F&&F.setModel({original:a.editor.createModel(r,s),modified:a.editor.createModel(t,s)})},[r,t,s,F]);var Q=E(p),Z=E(i),ie={width:Q,height:Z};return M.a.createElement("div",{className:"my-diff-editor",ref:T,style:ie})}},ZpRC:function(nt,We,J){"use strict";function ce(y){return typeof y=="object"&&y!=null&&y.nodeType===1}function U(y,x){return(!x||y!=="hidden")&&y!=="visible"&&y!=="clip"}function S(y,x){if(y.clientHeight<y.scrollHeight||y.clientWidth<y.scrollWidth){var C=getComputedStyle(y,null);return U(C.overflowY,x)||U(C.overflowX,x)||function(E){var b=function(v){if(!v.ownerDocument||!v.ownerDocument.defaultView)return null;try{return v.ownerDocument.defaultView.frameElement}catch(h){return null}}(E);return!!b&&(b.clientHeight<E.scrollHeight||b.clientWidth<E.scrollWidth)}(y)}return!1}function B(y,x,C,E,b,v,h,e){return v<y&&h>x||v>y&&h<x?0:v<=y&&e<=C||h>=x&&e>=C?v-y-E:h>x&&e<C||v<y&&e>C?h-x+b:0}var O=function(y,x){var C=window,E=x.scrollMode,b=x.block,v=x.inline,h=x.boundary,e=x.skipOverflowHiddenElements,a=typeof h=="function"?h:function(xe){return xe!==h};if(!ce(y))throw new TypeError("Invalid target");for(var o=document.scrollingElement||document.documentElement,f=[],d=y;ce(d)&&a(d);){if((d=d.parentElement)===o){f.push(d);break}d!=null&&d===document.body&&S(d)&&!S(document.documentElement)||d!=null&&S(d,e)&&f.push(d)}for(var u=C.visualViewport?C.visualViewport.width:innerWidth,p=C.visualViewport?C.visualViewport.height:innerHeight,c=window.scrollX||pageXOffset,i=window.scrollY||pageYOffset,r=y.getBoundingClientRect(),t=r.height,s=r.width,m=r.top,g=r.right,T=r.bottom,P=r.left,I=b==="start"||b==="nearest"?m:b==="end"?T:m+t/2,F=v==="center"?P+s/2:v==="end"?g:P,K=[],V=0;V<f.length;V++){var Q=f[V],Z=Q.getBoundingClientRect(),ie=Z.height,pe=Z.width,ae=Z.top,de=Z.right,le=Z.bottom,$=Z.left;if(E==="if-needed"&&m>=0&&P>=0&&T<=p&&g<=u&&m>=ae&&T<=le&&P>=$&&g<=de)return K;var Y=getComputedStyle(Q),ne=parseInt(Y.borderLeftWidth,10),z=parseInt(Y.borderTopWidth,10),H=parseInt(Y.borderRightWidth,10),me=parseInt(Y.borderBottomWidth,10),Le=0,Oe=0,Ae="offsetWidth"in Q?Q.offsetWidth-Q.clientWidth-ne-H:0,Re="offsetHeight"in Q?Q.offsetHeight-Q.clientHeight-z-me:0;if(o===Q)Le=b==="start"?I:b==="end"?I-p:b==="nearest"?B(i,i+p,p,z,me,i+I,i+I+t,t):I-p/2,Oe=v==="start"?F:v==="center"?F-u/2:v==="end"?F-u:B(c,c+u,u,ne,H,c+F,c+F+s,s),Le=Math.max(0,Le+i),Oe=Math.max(0,Oe+c);else{Le=b==="start"?I-ae-z:b==="end"?I-le+me+Re:b==="nearest"?B(ae,le,ie,z,me+Re,I,I+t,t):I-(ae+ie/2)+Re/2,Oe=v==="start"?F-$-ne:v==="center"?F-($+pe/2)+Ae/2:v==="end"?F-de+H+Ae:B($,de,pe,ne,H+Ae,F,F+s,s);var fe=Q.scrollLeft,ye=Q.scrollTop;I+=ye-(Le=Math.max(0,Math.min(ye+Le,Q.scrollHeight-ie+Re))),F+=fe-(Oe=Math.max(0,Math.min(fe+Oe,Q.scrollWidth-pe+Ae)))}K.push({el:Q,top:Le,left:Oe})}return K};function A(y){return y===Object(y)&&Object.keys(y).length!==0}function _(y,x){x===void 0&&(x="auto");var C="scrollBehavior"in document.body.style;y.forEach(function(E){var b=E.el,v=E.top,h=E.left;b.scroll&&C?b.scroll({top:v,left:h,behavior:x}):(b.scrollTop=v,b.scrollLeft=h)})}function M(y){return y===!1?{block:"end",inline:"nearest"}:A(y)?y:{block:"start",inline:"nearest"}}function L(y,x){var C=!y.ownerDocument.documentElement.contains(y);if(A(x)&&typeof x.behavior=="function")return x.behavior(C?[]:O(y,x));if(C)return;var E=M(x);return _(O(y,E),E.behavior)}var w=We.a=L},bT9E:function(nt,We,J){"use strict";J.d(We,"a",function(){return U});var ce=J("VTBJ");function U(S,B){var O=Object(ce.a)({},S);return Array.isArray(B)&&B.forEach(function(A){delete O[A]}),O}},fAei:function(nt,We,J){"use strict";J.d(We,"a",function(){return o.a});var ce=J("rePB"),U=J("VTBJ"),S=J("KQm4"),B=J("1OyB"),O=J("vuIU"),A=J("Ji7U"),_=J("LK+K"),M=J("q1tI"),L=J("4IlW"),w=J("Kwbf"),y=J("TSYQ"),x=J.n(y),C=J("sboe"),E=J("OZM5"),b=J("815F"),v=J("ODXe"),h=J("Ff2n"),e=J("+nKL"),a=J("8XRh"),o=J("WaYH"),f=function(de,le){var $=de.className,Y=de.style,ne=de.motion,z=de.motionNodes,H=de.motionType,me=de.onMotionStart,Le=de.onMotionEnd,Oe=de.active,Ae=de.treeNodeRequiredProps,Re=Object(h.a)(de,["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"]),fe=M.useState(!0),ye=Object(v.a)(fe,2),xe=ye[0],Se=ye[1],Ne=M.useContext(C.a),Pe=Ne.prefixCls,_e=M.useRef(!1),Fe=function(){_e.current||Le(),_e.current=!0};return Object(M.useEffect)(function(){z&&H==="hide"&&xe&&Se(!1)},[z]),Object(M.useEffect)(function(){return z&&me(),function(){z&&Fe()}},[]),z?M.createElement(a.default,Object.assign({ref:le,visible:xe},ne,{motionAppear:H==="show",onAppearEnd:Fe,onLeaveEnd:Fe}),function(se,ue){var be=se.className,Ee=se.style;return M.createElement("div",{ref:ue,className:x()("".concat(Pe,"-treenode-motion"),be),style:Ee},z.map(function(Ce){var Te=Ce.data,ve=Te.key,Ie=Object(h.a)(Te,["key"]),Be=Ce.isStart,ge=Ce.isEnd;delete Ie.children;var Me=Object(b.f)(ve,Ae);return M.createElement(o.a,Object.assign({},Ie,Me,{active:Oe,data:Ce.data,key:ve,isStart:Be,isEnd:ge}))}))}):M.createElement(o.a,Object.assign({domRef:le,className:$,style:Y},Re,{active:Oe}))};f.displayName="MotionTreeNode";var d=M.forwardRef(f),u=d;function p(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],le=ae.length,$=de.length;if(Math.abs(le-$)!==1)return{add:!1,key:null};function Y(ne,z){var H=new Map;ne.forEach(function(Le){H.set(Le,!0)});var me=z.filter(function(Le){return!H.has(Le)});return me.length===1?me[0]:null}return le<$?{add:!0,key:Y(ae,de)}:{add:!1,key:Y(de,ae)}}function c(ae,de,le){var $=ae.findIndex(function(H){var me=H.data;return me.key===le}),Y=ae[$+1],ne=de.findIndex(function(H){var me=H.data;return me.key===le});if(Y){var z=de.findIndex(function(H){var me=H.data;return me.key===Y.data.key});return de.slice(ne+1,z)}return de.slice(ne+1)}var i={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},r=function(){},t="RC_TREE_MOTION_".concat(Math.random()),s={key:t},m={key:t,level:0,index:0,pos:"0",node:s},g={parent:null,children:[],pos:m.pos,data:s,isStart:[],isEnd:[]};function T(ae,de,le,$){return de===!1||!le?ae:ae.slice(0,Math.ceil(le/$)+1)}function P(ae){var de=ae.data.key,le=ae.pos;return Object(b.e)(de,le)}function I(ae){for(var de=String(ae.data.key),le=ae;le.parent;)le=le.parent,de="".concat(le.data.key," > ").concat(de);return de}var F=function(de,le){var $=de.prefixCls,Y=de.data,ne=de.selectable,z=de.checkable,H=de.expandedKeys,me=de.selectedKeys,Le=de.checkedKeys,Oe=de.loadedKeys,Ae=de.loadingKeys,Re=de.halfCheckedKeys,fe=de.keyEntities,ye=de.disabled,xe=de.dragging,Se=de.dragOverNodeKey,Ne=de.dropPosition,Pe=de.motion,_e=de.height,Fe=de.itemHeight,se=de.virtual,ue=de.focusable,be=de.activeItem,Ee=de.focused,Ce=de.tabIndex,Te=de.onKeyDown,ve=de.onFocus,Ie=de.onBlur,Be=de.onActiveChange,ge=de.onListChangeStart,Me=de.onListChangeEnd,re=Object(h.a)(de,["prefixCls","data","selectable","checkable","expandedKeys","selectedKeys","checkedKeys","loadedKeys","loadingKeys","halfCheckedKeys","keyEntities","disabled","dragging","dragOverNodeKey","dropPosition","motion","height","itemHeight","virtual","focusable","activeItem","focused","tabIndex","onKeyDown","onFocus","onBlur","onActiveChange","onListChangeStart","onListChangeEnd"]),q=M.useRef(null);M.useImperativeHandle(le,function(){return{scrollTo:function(ut){q.current.scrollTo(ut)}}});var te=M.useState(H),j=Object(v.a)(te,2),W=j[0],G=j[1],X=M.useState(Y),oe=Object(v.a)(X,2),he=oe[0],ke=oe[1],He=M.useState(Y),$e=Object(v.a)(He,2),ze=$e[0],Ze=$e[1],et=M.useState([]),Xe=Object(v.a)(et,2),mt=Xe[0],rt=Xe[1],vt=M.useState(null),ct=Object(v.a)(vt,2),qe=ct[0],yt=ct[1];function bt(){ke(Y),Ze(Y),rt([]),yt(null),Me()}M.useEffect(function(){G(H);var at=p(W,H);if(at.key!==null)if(at.add){var ut=he.findIndex(function(Ye){var ot=Ye.data.key;return ot===at.key}),At=T(c(he,Y,at.key),se,_e,Fe),St=he.slice();St.splice(ut+1,0,g),Ze(St),rt(At),yt("show")}else{var Rt=Y.findIndex(function(Ye){var ot=Ye.data.key;return ot===at.key}),it=T(c(Y,he,at.key),se,_e,Fe),Qe=Y.slice();Qe.splice(Rt+1,0,g),Ze(Qe),rt(it),yt("hide")}else he!==Y&&(ke(Y),Ze(Y))},[H,Y]),M.useEffect(function(){xe||bt()},[xe]);var Ve=Pe?ze:Y,wt={expandedKeys:H,selectedKeys:me,loadedKeys:Oe,loadingKeys:Ae,checkedKeys:Le,halfCheckedKeys:Re,dragOverNodeKey:Se,dropPosition:Ne,keyEntities:fe};return M.createElement(M.Fragment,null,Ee&&be&&M.createElement("span",{style:i,"aria-live":"assertive"},I(be)),M.createElement("div",{role:"tree"},M.createElement("input",{style:i,disabled:ue===!1||ye,tabIndex:ue!==!1?Ce:null,onKeyDown:Te,onFocus:ve,onBlur:Ie,value:"",onChange:r})),M.createElement(e.a,Object.assign({},re,{data:Ve,itemKey:P,height:_e,fullHeight:!1,virtual:se,itemHeight:Fe,prefixCls:"".concat($,"-list"),ref:q}),function(at){var ut=at.pos,At=at.data,St=At.key,Rt=Object(h.a)(At,["key"]),it=at.isStart,Qe=at.isEnd,Ye=Object(b.e)(St,ut);delete Rt.children;var ot=Object(b.f)(Ye,wt);return M.createElement(u,Object.assign({},Rt,ot,{active:be&&St===be.data.key,pos:ut,data:at.data,isStart:it,isEnd:Qe,motion:Pe,motionNodes:St===t?mt:null,motionType:qe,onMotionStart:ge,onMotionEnd:bt,treeNodeRequiredProps:wt,onMouseMove:function(){Be(null)}}))}))},K=M.forwardRef(F);K.displayName="NodeList";var V=K,Q=J("NvD2"),Z=function(ae){Object(A.a)(le,ae);var de=Object(_.a)(le);function le(){var $;return Object(B.a)(this,le),$=de.apply(this,arguments),$.destroyed=!1,$.state={keyEntities:{},selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],dragging:!1,dragNodesKeys:[],dragOverNodeKey:null,dropPosition:null,treeData:[],flattenNodes:[],focused:!1,activeKey:null,listChanging:!1,prevProps:null},$.listRef=M.createRef(),$.onNodeDragStart=function(Y,ne){var z=$.state,H=z.expandedKeys,me=z.keyEntities,Le=$.props.onDragStart,Oe=ne.props.eventKey;$.dragNode=ne;var Ae=Object(E.b)(H,Oe);$.setState({dragging:!0,dragNodesKeys:Object(E.g)(Oe,me)}),$.setExpandedKeys(Ae),Le&&Le({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragEnter=function(Y,ne){var z=$.state,H=z.expandedKeys,me=z.keyEntities,Le=z.dragNodesKeys,Oe=$.props.onDragEnter,Ae=ne.props,Re=Ae.pos,fe=Ae.eventKey;if(!$.dragNode||Le.indexOf(fe)!==-1)return;var ye=Object(E.c)(Y,ne);if($.dragNode.props.eventKey===fe&&ye===0){$.setState({dragOverNodeKey:"",dropPosition:null});return}setTimeout(function(){$.setState({dragOverNodeKey:fe,dropPosition:ye}),$.delayedDragEnterLogic||($.delayedDragEnterLogic={}),Object.keys($.delayedDragEnterLogic).forEach(function(xe){clearTimeout($.delayedDragEnterLogic[xe])}),$.delayedDragEnterLogic[Re]=window.setTimeout(function(){if(!$.state.dragging)return;var xe=Object(S.a)(H),Se=me[fe];Se&&(Se.children||[]).length&&(xe=Object(E.a)(H,fe)),"expandedKeys"in $.props||$.setExpandedKeys(xe),Oe&&Oe({event:Y,node:Object(b.b)(ne.props),expandedKeys:xe})},400)},0)},$.onNodeDragOver=function(Y,ne){var z=$.state.dragNodesKeys,H=$.props.onDragOver,me=ne.props.eventKey;if(z.indexOf(me)!==-1)return;if($.dragNode&&me===$.state.dragOverNodeKey){var Le=Object(E.c)(Y,ne);if(Le===$.state.dropPosition)return;$.setState({dropPosition:Le})}H&&H({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragLeave=function(Y,ne){var z=$.props.onDragLeave;$.setState({dragOverNodeKey:""}),z&&z({event:Y,node:Object(b.b)(ne.props)})},$.onNodeDragEnd=function(Y,ne){var z=$.props.onDragEnd;$.setState({dragOverNodeKey:""}),$.cleanDragState(),z&&z({event:Y,node:Object(b.b)(ne.props)}),$.dragNode=null},$.onNodeDrop=function(Y,ne){var z=$.state,H=z.dragNodesKeys,me=H===void 0?[]:H,Le=z.dropPosition,Oe=$.props.onDrop,Ae=ne.props,Re=Ae.eventKey,fe=Ae.pos;if($.setState({dragOverNodeKey:""}),$.cleanDragState(),me.indexOf(Re)!==-1){Object(w.a)(!1,"Can not drop to dragNode(include it's children node)");return}var ye=Object(E.k)(fe),xe={event:Y,node:Object(b.b)(ne.props),dragNode:$.dragNode?Object(b.b)($.dragNode.props):null,dragNodesKeys:me.slice(),dropPosition:Le+Number(ye[ye.length-1]),dropToGap:!1};Le!==0&&(xe.dropToGap=!0),Oe&&Oe(xe),$.dragNode=null},$.cleanDragState=function(){var Y=$.state.dragging;Y&&$.setState({dragging:!1})},$.onNodeClick=function(Y,ne){var z=$.props.onClick;z&&z(Y,ne)},$.onNodeDoubleClick=function(Y,ne){var z=$.props.onDoubleClick;z&&z(Y,ne)},$.onNodeSelect=function(Y,ne){var z=$.state.selectedKeys,H=$.state.keyEntities,me=$.props,Le=me.onSelect,Oe=me.multiple,Ae=ne.selected,Re=ne.key,fe=!Ae;fe?Oe?z=Object(E.a)(z,Re):z=[Re]:z=Object(E.b)(z,Re);var ye=z.map(function(xe){var Se=H[xe];return Se?Se.node:null}).filter(function(xe){return xe});$.setUncontrolledState({selectedKeys:z}),Le&&Le(z,{event:"select",selected:fe,node:ne,selectedNodes:ye,nativeEvent:Y.nativeEvent})},$.onNodeCheck=function(Y,ne,z){var H=$.state,me=H.keyEntities,Le=H.checkedKeys,Oe=H.halfCheckedKeys,Ae=$.props,Re=Ae.checkStrictly,fe=Ae.onCheck,ye=ne.key,xe,Se={event:"check",node:ne,checked:z,nativeEvent:Y.nativeEvent};if(Re){var Ne=z?Object(E.a)(Le,ye):Object(E.b)(Le,ye),Pe=Object(E.b)(Oe,ye);xe={checked:Ne,halfChecked:Pe},Se.checkedNodes=Ne.map(function(Ee){return me[Ee]}).filter(function(Ee){return Ee}).map(function(Ee){return Ee.node}),$.setUncontrolledState({checkedKeys:Ne})}else{var _e=Object(Q.a)([].concat(Object(S.a)(Le),[ye]),!0,me),Fe=_e.checkedKeys,se=_e.halfCheckedKeys;if(!z){var ue=new Set(Fe);ue.delete(ye);var be=Object(Q.a)(Array.from(ue),{checked:!1,halfCheckedKeys:se},me);Fe=be.checkedKeys,se=be.halfCheckedKeys}xe=Fe,Se.checkedNodes=[],Se.checkedNodesPositions=[],Se.halfCheckedKeys=se,Fe.forEach(function(Ee){var Ce=me[Ee];if(!Ce)return;var Te=Ce.node,ve=Ce.pos;Se.checkedNodes.push(Te),Se.checkedNodesPositions.push({node:Te,pos:ve})}),$.setUncontrolledState({checkedKeys:Fe},!1,{halfCheckedKeys:se})}fe&&fe(xe,Se)},$.onNodeLoad=function(Y){return new Promise(function(ne){$.setState(function(z){var H=z.loadedKeys,me=H===void 0?[]:H,Le=z.loadingKeys,Oe=Le===void 0?[]:Le,Ae=$.props,Re=Ae.loadData,fe=Ae.onLoad,ye=Y.key;if(!Re||me.indexOf(ye)!==-1||Oe.indexOf(ye)!==-1)return{};var xe=Re(Y);return xe.then(function(){var Se=$.state,Ne=Se.loadedKeys,Pe=Se.loadingKeys,_e=Object(E.a)(Ne,ye),Fe=Object(E.b)(Pe,ye);fe&&fe(_e,{event:"load",node:Y}),$.setUncontrolledState({loadedKeys:_e}),$.setState({loadingKeys:Fe}),ne()}),{loadingKeys:Object(E.a)(Oe,ye)}})})},$.onNodeMouseEnter=function(Y,ne){var z=$.props.onMouseEnter;z&&z({event:Y,node:ne})},$.onNodeMouseLeave=function(Y,ne){var z=$.props.onMouseLeave;z&&z({event:Y,node:ne})},$.onNodeContextMenu=function(Y,ne){var z=$.props.onRightClick;z&&(Y.preventDefault(),z({event:Y,node:ne}))},$.onFocus=function(){var Y=$.props.onFocus;$.setState({focused:!0}),Y&&Y.apply(void 0,arguments)},$.onBlur=function(){var Y=$.props.onBlur;$.setState({focused:!1}),$.onActiveChange(null),Y&&Y.apply(void 0,arguments)},$.getTreeNodeRequiredProps=function(){var Y=$.state,ne=Y.expandedKeys,z=Y.selectedKeys,H=Y.loadedKeys,me=Y.loadingKeys,Le=Y.checkedKeys,Oe=Y.halfCheckedKeys,Ae=Y.dragOverNodeKey,Re=Y.dropPosition,fe=Y.keyEntities;return{expandedKeys:ne||[],selectedKeys:z||[],loadedKeys:H||[],loadingKeys:me||[],checkedKeys:Le||[],halfCheckedKeys:Oe||[],dragOverNodeKey:Ae,dropPosition:Re,keyEntities:fe}},$.setExpandedKeys=function(Y){var ne=$.state.treeData,z=Object(b.d)(ne,Y);$.setUncontrolledState({expandedKeys:Y,flattenNodes:z},!0)},$.onNodeExpand=function(Y,ne){var z=$.state.expandedKeys,H=$.state.listChanging,me=$.props,Le=me.onExpand,Oe=me.loadData,Ae=ne.key,Re=ne.expanded;if(H)return;var fe=z.indexOf(Ae),ye=!Re;if(Object(w.a)(Re&&fe!==-1||!Re&&fe===-1,"Expand state not sync with index check"),ye?z=Object(E.a)(z,Ae):z=Object(E.b)(z,Ae),$.setExpandedKeys(z),Le&&Le(z,{node:ne,expanded:ye,nativeEvent:Y.nativeEvent}),ye&&Oe){var xe=$.onNodeLoad(ne);xe&&xe.then(function(){var Se=Object(b.d)($.state.treeData,z);$.setUncontrolledState({flattenNodes:Se})})}},$.onListChangeStart=function(){$.setUncontrolledState({listChanging:!0})},$.onListChangeEnd=function(){setTimeout(function(){$.setUncontrolledState({listChanging:!1})})},$.onActiveChange=function(Y){var ne=$.state.activeKey,z=$.props.onActiveChange;if(ne===Y)return;$.setState({activeKey:Y}),Y!==null&&$.scrollTo({key:Y}),z&&z(Y)},$.getActiveItem=function(){var Y=$.state,ne=Y.activeKey,z=Y.flattenNodes;return ne===null?null:z.find(function(H){var me=H.data.key;return me===ne})||null},$.offsetActiveKey=function(Y){var ne=$.state,z=ne.flattenNodes,H=ne.activeKey,me=z.findIndex(function(Ae){var Re=Ae.data.key;return Re===H});me===-1&&Y<0&&(me=z.length),me=(me+Y+z.length)%z.length;var Le=z[me];if(Le){var Oe=Le.data.key;$.onActiveChange(Oe)}else $.onActiveChange(null)},$.onKeyDown=function(Y){var ne=$.state,z=ne.activeKey,H=ne.expandedKeys,me=ne.checkedKeys,Le=$.props,Oe=Le.onKeyDown,Ae=Le.checkable,Re=Le.selectable;switch(Y.which){case L.a.UP:{$.offsetActiveKey(-1),Y.preventDefault();break}case L.a.DOWN:{$.offsetActiveKey(1),Y.preventDefault();break}}var fe=$.getActiveItem();if(fe&&fe.data){var ye=$.getTreeNodeRequiredProps(),xe=fe.data.isLeaf===!1||!!(fe.data.children||[]).length,Se=Object(b.b)(Object(U.a)(Object(U.a)({},Object(b.f)(z,ye)),{},{data:fe.data,active:!0}));switch(Y.which){case L.a.LEFT:{xe&&H.includes(z)?$.onNodeExpand({},Se):fe.parent&&$.onActiveChange(fe.parent.data.key),Y.preventDefault();break}case L.a.RIGHT:{xe&&!H.includes(z)?$.onNodeExpand({},Se):fe.children&&fe.children.length&&$.onActiveChange(fe.children[0].data.key),Y.preventDefault();break}case L.a.ENTER:case L.a.SPACE:{Ae&&!Se.disabled&&Se.checkable!==!1&&!Se.disableCheckbox?$.onNodeCheck({},Se,!me.includes(z)):!Ae&&Re&&!Se.disabled&&Se.selectable!==!1&&$.onNodeSelect({},Se);break}}}Oe&&Oe(Y)},$.setUncontrolledState=function(Y){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if($.destroyed)return;var H=!1,me=!0,Le={};Object.keys(Y).forEach(function(Oe){if(Oe in $.props){me=!1;return}H=!0,Le[Oe]=Y[Oe]}),H&&(!ne||me)&&$.setState(Object(U.a)(Object(U.a)({},Le),z))},$.scrollTo=function(Y){$.listRef.current.scrollTo(Y)},$}return Object(O.a)(le,[{key:"componentWillUnmount",value:function(){this.destroyed=!0}},{key:"render",value:function(){var Y,ne=this.state,z=ne.focused,H=ne.flattenNodes,me=ne.keyEntities,Le=ne.dragging,Oe=ne.activeKey,Ae=this.props,Re=Ae.prefixCls,fe=Ae.className,ye=Ae.style,xe=Ae.showLine,Se=Ae.focusable,Ne=Ae.tabIndex,Pe=Ne===void 0?0:Ne,_e=Ae.selectable,Fe=Ae.showIcon,se=Ae.icon,ue=Ae.switcherIcon,be=Ae.draggable,Ee=Ae.checkable,Ce=Ae.checkStrictly,Te=Ae.disabled,ve=Ae.motion,Ie=Ae.loadData,Be=Ae.filterTreeNode,ge=Ae.height,Me=Ae.itemHeight,re=Ae.virtual,q=Ae.titleRender,te=Ae.onContextMenu,j=Object(E.f)(this.props);return M.createElement(C.a.Provider,{value:{prefixCls:Re,selectable:_e,showIcon:Fe,icon:se,switcherIcon:ue,draggable:be,checkable:Ee,checkStrictly:Ce,disabled:Te,keyEntities:me,loadData:Ie,filterTreeNode:Be,titleRender:q,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop}},M.createElement("div",{className:x()(Re,fe,(Y={},Object(ce.a)(Y,"".concat(Re,"-show-line"),xe),Object(ce.a)(Y,"".concat(Re,"-focused"),z),Object(ce.a)(Y,"".concat(Re,"-active-focused"),Oe!==null),Y))},M.createElement(V,Object.assign({ref:this.listRef,prefixCls:Re,style:ye,data:H,disabled:Te,selectable:_e,checkable:!!Ee,motion:ve,dragging:Le,height:ge,itemHeight:Me,virtual:re,focusable:Se,focused:z,tabIndex:Pe,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:te},this.getTreeNodeRequiredProps(),j))))}}],[{key:"getDerivedStateFromProps",value:function(Y,ne){var z=ne.prevProps,H={prevProps:Y};function me(se){return!z&&se in Y||z&&z[se]!==Y[se]}var Le;if(me("treeData")?Le=Y.treeData:me("children")&&(Object(w.a)(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),Le=Object(b.c)(Y.children)),Le){H.treeData=Le;var Oe=Object(b.a)(Le);H.keyEntities=Object(U.a)(Object(ce.a)({},t,m),Oe.keyEntities)}var Ae=H.keyEntities||ne.keyEntities;if(me("expandedKeys")||z&&me("autoExpandParent"))H.expandedKeys=Y.autoExpandParent||!z&&Y.defaultExpandParent?Object(E.e)(Y.expandedKeys,Ae):Y.expandedKeys;else if(!z&&Y.defaultExpandAll){var Re=Object(U.a)({},Ae);delete Re[t],H.expandedKeys=Object.keys(Re).map(function(se){return Re[se].key})}else!z&&Y.defaultExpandedKeys&&(H.expandedKeys=Y.autoExpandParent||Y.defaultExpandParent?Object(E.e)(Y.defaultExpandedKeys,Ae):Y.defaultExpandedKeys);if(H.expandedKeys||delete H.expandedKeys,Le||H.expandedKeys){var fe=Object(b.d)(Le||ne.treeData,H.expandedKeys||ne.expandedKeys);H.flattenNodes=fe}if(Y.selectable&&(me("selectedKeys")?H.selectedKeys=Object(E.d)(Y.selectedKeys,Y):!z&&Y.defaultSelectedKeys&&(H.selectedKeys=Object(E.d)(Y.defaultSelectedKeys,Y))),Y.checkable){var ye;if(me("checkedKeys")?ye=Object(E.j)(Y.checkedKeys)||{}:!z&&Y.defaultCheckedKeys?ye=Object(E.j)(Y.defaultCheckedKeys)||{}:Le&&(ye=Object(E.j)(Y.checkedKeys)||{checkedKeys:ne.checkedKeys,halfCheckedKeys:ne.halfCheckedKeys}),ye){var xe=ye,Se=xe.checkedKeys,Ne=Se===void 0?[]:Se,Pe=xe.halfCheckedKeys,_e=Pe===void 0?[]:Pe;if(!Y.checkStrictly){var Fe=Object(Q.a)(Ne,!0,Ae);Ne=Fe.checkedKeys,_e=Fe.halfCheckedKeys}H.checkedKeys=Ne,H.halfCheckedKeys=_e}}return me("loadedKeys")&&(H.loadedKeys=Y.loadedKeys),H}}]),le}(M.Component);Z.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[]},Z.TreeNode=o.a;var ie=Z,pe=We.b=ie},p5ED:function(nt,We,J){"use strict";var ce=J("+L6B"),U=J("2/Rp"),S=J("5Dmo"),B=J("3S7+"),O=J("k1fw"),A=J("tJVT"),_=J("q1tI"),M=J.n(_),L=J("vHTk"),w=J.n(L),y=J("yEEn"),x=J("ZW9T"),C=J("1vsH"),E=J("m3rI");We.a=function(b){var v=b.name,h=b.data,e=b.theme,a=b.type,o=b.filename,f=b.monacoEditor,d=b.className,u=b.style,p=b.close,c=b.onClose,i=b.hasMask,r=b.otherData,t=Object(_.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),s=Object(A.a)(t,2),m=s[0],g=s[1],T=Object(_.useState)(""),P=Object(A.a)(T,2),I=P[0],F=P[1],K,V=1024*1024,Q=10*V,Z=Object(_.useRef)();a==="office"&&(K=Object(C.R)(h).filesize,K>Q&&(a="other")),o&&(f.filename=o),Object(_.useEffect)(function(){var ae,de,le=(ae=document.cookie)===null||ae===void 0||((de=ae.replace(/\s/g,""))===null||de===void 0)?void 0:de.split(";");le==null||le.map(function($){var Y=$.split("=");Y[0]==="_educoder_session"&&F(Y[1])})},[]);var ie=function(){if(h.startsWith("http")||h.startsWith("blob:")){pe();return}Object(C.x)(o||"educoder",h,o)},pe=function(){Object(C.v)(o||"educoder",decodeURIComponent(h))};return M.a.createElement("div",{style:Object(O.a)({},u||{}),className:"".concat(i&&w.a.bgBlack," ").concat(a?w.a.wrp:"hide")},p&&M.a.createElement("div",{className:w.a.close,ref:Z},M.a.createElement(B.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Z.current}},M.a.createElement("span",{onClick:pe},M.a.createElement("i",{className:"icon-quxiaozhiding"}))),M.a.createElement(B.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Z.current}},M.a.createElement("span",{className:"",onClick:c},M.a.createElement("i",{className:"icon-guanbi1"})))),M.a.createElement("div",{className:"".concat(w.a[d]," ").concat(d," ").concat(w.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&M.a.createElement(x.b,f)),a==="audio"&&M.a.createElement("audio",{src:"".concat((h==null?void 0:h.indexOf("http://"))>-1||(h==null?void 0:h.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(h),autoPlay:!0}),a==="video"&&M.a.createElement(M.a.Fragment,null,(h==null?void 0:h.indexOf("http"))>-1?M.a.createElement("video",{controls:!0,src:"".concat(h),autoPlay:!0}):M.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(h),autoPlay:!0})),a==="office"&&M.a.createElement("iframe",{src:"https://view.officeapps.live.com/op/embed.aspx?src=".concat(h,"?").concat(encodeURIComponent("disposition=office&token=".concat(I)))}),(a==="xlsx"||a==="doc"||a==="pptx"||a==="docx")&&M.a.createElement("iframe",{src:"/react/build/office.html?key=".concat(r.key,"&url=").concat(E.a.API_SERVER+r.url,"&callbackUrl=").concat(E.a.API_SERVER+r.callbackUrl,"&fileType=").concat(r.fileType,"&title=").concat(r.title,"&model=").concat(r.model)}),a==="html"&&M.a.createElement("iframe",{src:h+"&disposition=inline"}),a==="pdf"&&M.a.createElement("embed",{className:w.a.embed,src:h,type:"application/pdf"}),a==="image"&&M.a.createElement("img",{src:"".concat((h==null?void 0:h.indexOf("http://"))>-1||(h==null?void 0:h.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(h)}),a==="other"&&M.a.createElement("div",null,M.a.createElement(U.a,{type:"primary",size:"large",onClick:ie},M.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),a==="download"&&M.a.createElement(U.a,{type:"primary",size:"large",onClick:ie},M.a.createElement(y.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"rAM+":function(nt,We,J){"use strict";J.d(We,"a",function(){return U});var ce=J("Qw5x");function U(S,B){var O;if(typeof Symbol=="undefined"||S[Symbol.iterator]==null){if(Array.isArray(S)||(O=Object(ce.a)(S))||B&&S&&typeof S.length=="number"){O&&(S=O);var A=0,_=function(){};return{s:_,n:function(){return A>=S.length?{done:!0}:{done:!1,value:S[A++]}},e:function(x){throw x},f:_}}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,L=!1,w;return{s:function(){O=S[Symbol.iterator]()},n:function(){var x=O.next();return M=x.done,x},e:function(x){L=!0,w=x},f:function(){try{!M&&O.return!=null&&O.return()}finally{if(L)throw w}}}}},rUJ1:function(nt,We){const J=/[&<>"']/,ce=/[&<>"']/g,U=/[<>"']|&(?!#?\w+;)/,S=/[<>"']|&(?!#?\w+;)/g,B={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},O=c=>B[c];function A(c,i){if(i){if(J.test(c))return c.replace(ce,O)}else if(U.test(c))return c.replace(S,O);return c}const _=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function M(c){return c.replace(_,(i,r)=>(r=r.toLowerCase(),r==="colon"?":":r.charAt(0)==="#"?r.charAt(1)==="x"?String.fromCharCode(parseInt(r.substring(2),16)):String.fromCharCode(+r.substring(1)):""))}const L=/(^|[^\[])\^/g;function w(c,i){c=c.source||c,i=i||"";const r={replace:(t,s)=>(s=s.source||s,s=s.replace(L,"$1"),c=c.replace(t,s),r),getRegex:()=>new RegExp(c,i)};return r}const y=/[^\w:]/g,x=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function C(c,i,r){if(c){let t;try{t=decodeURIComponent(M(r)).replace(y,"").toLowerCase()}catch(s){return null}if(t.indexOf("javascript:")===0||t.indexOf("vbscript:")===0||t.indexOf("data:")===0)return null}i&&!x.test(r)&&(r=e(i,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(t){return null}return r}const E={},b=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function e(c,i){E[" "+c]||(b.test(c)?E[" "+c]=c+"/":E[" "+c]=d(c,"/",!0)),c=E[" "+c];const r=c.indexOf(":")===-1;return i.substring(0,2)==="//"?r?i:c.replace(v,"$1")+i:i.charAt(0)==="/"?r?i:c.replace(h,"$1")+i:c+i}const a={exec:function(){}};function o(c){let i=1,r,t;for(;i<arguments.length;i++){r=arguments[i];for(t in r)Object.prototype.hasOwnProperty.call(r,t)&&(c[t]=r[t])}return c}function f(c,i){const r=c.replace(/\|/g,(m,g,T)=>{let P=!1,I=g;for(;--I>=0&&T[I]==="\\";)P=!P;return P?"|":" |"}),t=r.split(/ \|/);let s=0;if(t.length>i)t.splice(i);else for(;t.length<i;)t.push("");for(;s<t.length;s++)t[s]=t[s].trim().replace(/\\\|/g,"|");return t}function d(c,i,r){const t=c.length;if(t===0)return"";let s=0;for(;s<t;){const m=c.charAt(t-s-1);if(m===i&&!r)s++;else if(m!==i&&r)s++;else break}return c.substr(0,t-s)}function u(c,i){if(c.indexOf(i[1])===-1)return-1;const r=c.length;let t=0,s=0;for(;s<r;s++)if(c[s]==="\\")s++;else if(c[s]===i[0])t++;else if(c[s]===i[1]&&(t--,t<0))return s;return-1}function p(c){c&&c.sanitize&&!c.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")}nt.exports={escape:A,unescape:M,edit:w,cleanUrl:C,resolveUrl:e,noopTest:a,merge:o,splitCells:f,rtrim:d,findClosingBracket:u,checkSanitizeDeprecation:p}},sboe:function(nt,We,J){"use strict";J.d(We,"a",function(){return S});var ce=J("q1tI"),U=J.n(ce),S=ce.createContext(null)},ulZh:function(nt,We,J){typeof window!="undefined"&&function(U,S){nt.exports=S()}(this,function(){return function(ce){var U={};function S(B){if(U[B])return U[B].exports;var O=U[B]={i:B,l:!1,exports:{}};return ce[B].call(O.exports,O,O.exports,S),O.l=!0,O.exports}return S.m=ce,S.c=U,S.d=function(B,O,A){S.o(B,O)||Object.defineProperty(B,O,{enumerable:!0,get:A})},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,O){if(O&1&&(B=S(B)),O&8)return B;if(O&4&&typeof B=="object"&&B&&B.__esModule)return B;var A=Object.create(null);if(S.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:B}),O&2&&typeof B!="string")for(var _ in B)S.d(A,_,function(M){return B[M]}.bind(null,_));return A},S.n=function(B){var O=B&&B.__esModule?function(){return B.default}:function(){return B};return S.d(O,"a",O),O},S.o=function(B,O){return Object.prototype.hasOwnProperty.call(B,O)},S.p="/dist/",S(S.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ce,U,S){"use strict";var B=Object.prototype.hasOwnProperty,O="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(O=!1));function _(y,x,C){this.fn=y,this.context=x,this.once=C||!1}function M(y,x,C,E,b){if(typeof C!="function")throw new TypeError("The listener must be a function");var v=new _(C,E||y,b),h=O?O+x:x;return y._events[h]?y._events[h].fn?y._events[h]=[y._events[h],v]:y._events[h].push(v):(y._events[h]=v,y._eventsCount++),y}function L(y,x){--y._eventsCount===0?y._events=new A:delete y._events[x]}function w(){this._events=new A,this._eventsCount=0}w.prototype.eventNames=function(){var x=[],C,E;if(this._eventsCount===0)return x;for(E in C=this._events)B.call(C,E)&&x.push(O?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(C)):x},w.prototype.listeners=function(x){var C=O?O+x:x,E=this._events[C];if(!E)return[];if(E.fn)return[E.fn];for(var b=0,v=E.length,h=new Array(v);b<v;b++)h[b]=E[b].fn;return h},w.prototype.listenerCount=function(x){var C=O?O+x:x,E=this._events[C];return E?E.fn?1:E.length:0},w.prototype.emit=function(x,C,E,b,v,h){var e=O?O+x:x;if(!this._events[e])return!1;var a=this._events[e],o=arguments.length,f,d;if(a.fn){a.once&&this.removeListener(x,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,E),!0;case 4:return a.fn.call(a.context,C,E,b),!0;case 5:return a.fn.call(a.context,C,E,b,v),!0;case 6:return a.fn.call(a.context,C,E,b,v,h),!0}for(d=1,f=new Array(o-1);d<o;d++)f[d-1]=arguments[d];a.fn.apply(a.context,f)}else{var u=a.length,p;for(d=0;d<u;d++){a[d].once&&this.removeListener(x,a[d].fn,void 0,!0);switch(o){case 1:a[d].fn.call(a[d].context);break;case 2:a[d].fn.call(a[d].context,C);break;case 3:a[d].fn.call(a[d].context,C,E);break;case 4:a[d].fn.call(a[d].context,C,E,b);break;default:if(!f)for(p=1,f=new Array(o-1);p<o;p++)f[p-1]=arguments[p];a[d].fn.apply(a[d].context,f)}}}return!0},w.prototype.on=function(x,C,E){return M(this,x,C,E,!1)},w.prototype.once=function(x,C,E){return M(this,x,C,E,!0)},w.prototype.removeListener=function(x,C,E,b){var v=O?O+x:x;if(!this._events[v])return this;if(!C)return L(this,v),this;var h=this._events[v];if(h.fn)h.fn===C&&(!b||h.once)&&(!E||h.context===E)&&L(this,v);else{for(var e=0,a=[],o=h.length;e<o;e++)(h[e].fn!==C||b&&!h[e].once||E&&h[e].context!==E)&&a.push(h[e]);a.length?this._events[v]=a.length===1?a[0]:a:L(this,v)}return this},w.prototype.removeAllListeners=function(x){var C;return x?(C=O?O+x:x,this._events[C]&&L(this,C)):(this._events=new A,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=O,w.EventEmitter=w,ce.exports=w},"./node_modules/url-toolkit/src/url-toolkit.js":function(ce,U,S){(function(B){var O=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,A=/^([^\/?#]*)([^]*)$/,_=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(w,y,x){if(x=x||{},w=w.trim(),y=y.trim(),!y){if(!x.alwaysNormalize)return w;var C=L.parseURL(w);if(!C)throw new Error("Error trying to parse base URL.");return C.path=L.normalizePath(C.path),L.buildURLFromParts(C)}var E=L.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=L.normalizePath(E.path),L.buildURLFromParts(E)):y;var b=L.parseURL(w);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var v=A.exec(b.path);b.netLoc=v[1],b.path=v[2]}b.netLoc&&!b.path&&(b.path="/");var h={scheme:b.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(h.netLoc=b.netLoc,E.path[0]!=="/"))if(!E.path)h.path=b.path,E.params||(h.params=b.params,E.query||(h.query=b.query));else{var e=b.path,a=e.substring(0,e.lastIndexOf("/")+1)+E.path;h.path=L.normalizePath(a)}return h.path===null&&(h.path=x.alwaysNormalize?L.normalizePath(E.path):E.path),L.buildURLFromParts(h)},parseURL:function(w){var y=O.exec(w);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(w){for(w=w.split("").reverse().join("").replace(_,"");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}};ce.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(ce,U,S){function B(x){var C={};function E(v){if(C[v])return C[v].exports;var h=C[v]={i:v,l:!1,exports:{}};return x[v].call(h.exports,h,h.exports,E),h.l=!0,h.exports}E.m=x,E.c=C,E.i=function(v){return v},E.d=function(v,h,e){E.o(v,h)||Object.defineProperty(v,h,{configurable:!1,enumerable:!0,get:e})},E.r=function(v){Object.defineProperty(v,"__esModule",{value:!0})},E.n=function(v){var h=v&&v.__esModule?function(){return v.default}:function(){return v};return E.d(h,"a",h),h},E.o=function(v,h){return Object.prototype.hasOwnProperty.call(v,h)},E.p="/",E.oe=function(v){throw console.error(v),v};var b=E(E.s=ENTRY_MODULE);return b.default||b}var O="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+O+").*?\\)";function _(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function M(x){return!isNaN(1*x)}function L(x,C,E){var b={};b[E]=[];var v=C.toString(),h=v.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return b;for(var e=h[1],a=new RegExp("(\\\\n|\\W)"+_(e)+A,"g"),o;o=a.exec(v);){if(o[3]==="dll-reference")continue;b[E].push(o[3])}for(a=new RegExp("\\("+_(e)+'\\("(dll-reference\\s('+O+'))"\\)\\)'+A,"g");o=a.exec(v);)x[o[2]]||(b[E].push(o[1]),x[o[2]]=S(o[1]).m),b[o[2]]=b[o[2]]||[],b[o[2]].push(o[4]);for(var f=Object.keys(b),d=0;d<f.length;d++)for(var u=0;u<b[f[d]].length;u++)M(b[f[d]][u])&&(b[f[d]][u]=1*b[f[d]][u]);return b}function w(x){var C=Object.keys(x);return C.reduce(function(E,b){return E||x[b].length>0},!1)}function y(x,C){for(var E={main:[C]},b={main:[]},v={main:{}};w(E);)for(var h=Object.keys(E),e=0;e<h.length;e++){var a=h[e],o=E[a],f=o.pop();if(v[a]=v[a]||{},v[a][f]||!x[a][f])continue;v[a][f]=!0,b[a]=b[a]||[],b[a].push(f);for(var d=L(x,x[a][f],a),u=Object.keys(d),p=0;p<u.length;p++)E[u[p]]=E[u[p]]||[],E[u[p]]=E[u[p]].concat(d[u[p]])}return b}ce.exports=function(x,C){C=C||{};var E={main:S.m},b=C.all?{main:Object.keys(E.main)}:y(E,x),v="";Object.keys(b).filter(function(f){return f!=="main"}).forEach(function(f){for(var d=0;b[f][d];)d++;b[f].push(d),E[f][d]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",v=v+"var "+f+" = ("+B.toString().replace("ENTRY_MODULE",JSON.stringify(d))+")({"+b[f].map(function(u){return""+JSON.stringify(u)+": "+E[f][u].toString()}).join(",")+`});
`}),v=v+"new (("+B.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+b.main.map(function(f){return""+JSON.stringify(f)+": "+E.main[f].toString()}).join(",")+"}))(self);";var h=new window.Blob([v],{type:"text/javascript"});if(C.bare)return h;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,a=e.createObjectURL(h),o=new window.Worker(a);return o.objectURL=a,o}},"./src/config.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"hlsDefaultConfig",function(){return p}),S.d(U,"mergeConfig",function(){return i}),S.d(U,"enableStreamingMode",function(){return r});var B=S("./src/controller/abr-controller.ts"),O=S("./src/controller/audio-stream-controller.ts"),A=S("./src/controller/audio-track-controller.ts"),_=S("./src/controller/subtitle-stream-controller.ts"),M=S("./src/controller/subtitle-track-controller.ts"),L=S("./src/controller/buffer-controller.ts"),w=S("./src/controller/timeline-controller.ts"),y=S("./src/controller/cap-level-controller.ts"),x=S("./src/controller/fps-controller.ts"),C=S("./src/controller/eme-controller.ts"),E=S("./src/controller/cmcd-controller.ts"),b=S("./src/utils/xhr-loader.ts"),v=S("./src/utils/fetch-loader.ts"),h=S("./src/utils/cues.ts"),e=S("./src/utils/mediakeys-helper.ts"),a=S("./src/utils/logger.ts");function o(){return o=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var m=arguments[s];for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(t[g]=m[g])}return t},o.apply(this,arguments)}function f(t,s){var m=Object.keys(t);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(t);s&&(g=g.filter(function(T){return Object.getOwnPropertyDescriptor(t,T).enumerable})),m.push.apply(m,g)}return m}function d(t){for(var s=1;s<arguments.length;s++){var m=arguments[s]!=null?arguments[s]:{};s%2?f(Object(m),!0).forEach(function(g){u(t,g,m[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(m)):f(Object(m)).forEach(function(g){Object.defineProperty(t,g,Object.getOwnPropertyDescriptor(m,g))})}return t}function u(t,s,m){return s in t?Object.defineProperty(t,s,{value:m,enumerable:!0,configurable:!0,writable:!0}):t[s]=m,t}var p=d(d({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:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:B.default,bufferController:L.default,capLevelController:y.default,fpsController:x.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:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},c()),{},{subtitleStreamController:_.SubtitleStreamController,subtitleTrackController:M.default,timelineController:w.TimelineController,audioStreamController:O.default,audioTrackController:A.default,emeController:C.default,cmcdController:E.default});function c(){return{cueHandler:h.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function i(t,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return o({},t,s)}function r(t){var s=t.loader;if(s!==v.default&&s!==b.default)a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var m=Object(v.fetchSupported)();m&&(t.loader=v.default,t.progressive=!0,t.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/polyfills/number.ts"),O=S("./src/utils/ewma-bandwidth-estimator.ts"),A=S("./src/events.ts"),_=S("./src/utils/buffer-helper.ts"),M=S("./src/errors.ts"),L=S("./src/types/loader.ts"),w=S("./src/utils/logger.ts");function y(E,b){for(var v=0;v<b.length;v++){var h=b[v];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function x(E,b,v){return b&&y(E.prototype,b),v&&y(E,v),E}var C=function(){function E(v){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=v;var h=v.config;this.bwEstimator=new O.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var b=E.prototype;return b.registerListeners=function(){var h=this.hls;h.on(A.Events.FRAG_LOADING,this.onFragLoading,this),h.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(A.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var h=this.hls;h.off(A.Events.FRAG_LOADING,this.onFragLoading,this),h.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(A.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(h,e){var a=e.frag;if(a.type===L.PlaylistLevelType.MAIN&&!this.timer){var o;this.fragCurrent=a,this.partCurrent=(o=e.part)!=null?o:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(h,e){var a=this.hls.config;e.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var h=this.fragCurrent,e=this.partCurrent,a=this.hls,o=a.autoLevelEnabled,f=a.config,d=a.media;if(!h||!d)return;var u=e?e.stats:h.stats,p=e?e.duration:h.duration;if(u.aborted){w.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!o||d.paused||!d.playbackRate||!d.readyState)return;var c=performance.now()-u.loading.start,i=Math.abs(d.playbackRate);if(c<=500*p/i)return;var r=a.levels,t=a.minAutoLevel,s=r[h.level],m=u.total||Math.max(u.loaded,Math.round(p*s.maxBitrate/8)),g=Math.max(1,u.bwEstimate?u.bwEstimate/8:u.loaded*1e3/c),T=(m-u.loaded)/g,P=d.currentTime,I=(_.BufferHelper.bufferInfo(d,P,f.maxBufferHole).end-P)/i;if(I>=2*p/i||T<=I)return;var F=Number.POSITIVE_INFINITY,K;for(K=h.level-1;K>t;K--){var V=r[K].maxBitrate;if(F=p*V/(8*.8*g),F<I)break}if(F>=T)return;var Q=this.bwEstimator.getEstimate();w.logger.warn("Fragment "+h.sn+(e?" part "+e.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
Current BW estimate: `+(Object(B.isFiniteNumber)(Q)?(Q/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+T.toFixed(3)+` s
Estimated load time for the next fragment: `+F.toFixed(3)+` s
Time to underbuffer: `+I.toFixed(3)+" s"),a.nextLoadLevel=K,this.bwEstimator.sample(c,u.loaded),this.clearTimer(),h.loader&&(this.fragCurrent=this.partCurrent=null,h.loader.abort()),a.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:e,stats:u})},b.onFragLoaded=function(h,e){var a=e.frag,o=e.part;if(a.type===L.PlaylistLevelType.MAIN&&Object(B.isFiniteNumber)(a.sn)){var f=o?o.stats:a.stats,d=o?o.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[a.level],p=(u.loaded?u.loaded.bytes:0)+f.loaded,c=(u.loaded?u.loaded.duration:0)+d;u.loaded={bytes:p,duration:c},u.realBitrate=Math.round(8*p/c)}if(a.bitrateTest){var i={stats:f,frag:a,part:o,id:a.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,i),a.bitrateTest=!1}}},b.onFragBuffered=function(h,e){var a=e.frag,o=e.part,f=o?o.stats:a.stats;if(f.aborted)return;if(a.type!==L.PlaylistLevelType.MAIN||a.sn==="initSegment")return;var d=f.parsing.end-f.loading.start;this.bwEstimator.sample(d,f.loaded),f.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0},b.onError=function(h,e){switch(e.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var h=this.fragCurrent,e=this.partCurrent,a=this.hls,o=a.maxAutoLevel,f=a.config,d=a.minAutoLevel,u=a.media,p=e?e.duration:h?h.duration:0,c=u?u.currentTime:0,i=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():f.abrEwmaDefaultEstimate,t=(_.BufferHelper.bufferInfo(u,c,f.maxBufferHole).end-c)/i,s=this.findBestLevel(r,d,o,t,f.abrBandWidthFactor,f.abrBandWidthUpFactor);if(s>=0)return s;w.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var m=p?Math.min(p,f.maxStarvationDelay):f.maxStarvationDelay,g=f.abrBandWidthFactor,T=f.abrBandWidthUpFactor;if(!t){var P=this.bitrateTestDelay;if(P){var I=p?Math.min(p,f.maxLoadingDelay):f.maxLoadingDelay;m=I-P,w.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),g=T=1}}return s=this.findBestLevel(r,d,o,t+m,g,T),Math.max(s,0)},b.findBestLevel=function(h,e,a,o,f,d){for(var u,p=this.fragCurrent,c=this.partCurrent,i=this.lastLoadedFragLevel,r=this.hls.levels,t=r[i],s=!!(t!=null&&(u=t.details)!==null&&u!==void 0&&u.live),m=t==null?void 0:t.codecSet,g=c?c.duration:p?p.duration:0,T=a;T>=e;T--){var P=r[T];if(!P||m&&P.codecSet!==m)continue;var I=P.details,F=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||g,K=void 0;T<=i?K=f*h:K=d*h;var V=r[T].maxBitrate,Q=V*F/K;if(w.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+T+"/"+Math.round(K)+"/"+V+"/"+F+"/"+o+"/"+Q),K>V&&(!Q||s&&!this.bitrateTestDelay||Q<o))return T}return-1},x(E,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,e=this.bwEstimator;if(h!==-1&&(!e||!e.canEstimate()))return h;var a=this.getNextABRAutoLevel();return h!==-1&&(a=Math.min(h,a)),a},set:function(h){this._nextAutoLevel=h}}]),E}();U.default=C},"./src/controller/audio-stream-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/polyfills/number.ts"),O=S("./src/controller/base-stream-controller.ts"),A=S("./src/events.ts"),_=S("./src/utils/buffer-helper.ts"),M=S("./src/controller/fragment-tracker.ts"),L=S("./src/types/level.ts"),w=S("./src/types/loader.ts"),y=S("./src/loader/fragment.ts"),x=S("./src/demux/chunk-cache.ts"),C=S("./src/demux/transmuxer-interface.ts"),E=S("./src/types/transmuxer.ts"),b=S("./src/controller/fragment-finders.ts"),v=S("./src/utils/discontinuities.ts"),h=S("./src/errors.ts"),e=S("./src/utils/logger.ts");function a(){return a=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(p[r]=i[r])}return p},a.apply(this,arguments)}function o(p,c){p.prototype=Object.create(c.prototype),p.prototype.constructor=p,f(p,c)}function f(p,c){return f=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r},f(p,c)}var d=100,u=function(p){o(c,p);function c(r,t){var s;return s=p.call(this,r,t,"[audio-stream-controller]")||this,s.videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.audioSwitch=!1,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.bufferFlushed=!1,s._registerListeners(),s}var i=c.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var t=this.hls;t.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(A.Events.ERROR,this.onError,this),t.on(A.Events.BUFFER_RESET,this.onBufferReset,this),t.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(A.Events.ERROR,this.onError,this),t.off(A.Events.BUFFER_RESET,this.onBufferReset,this),t.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(t,s){var m=s.frag,g=s.id,T=s.initPTS;if(g==="main"){var P=m.cc;this.initPTS[m.cc]=T,this.log("InitPTS for cc: "+P+" found from main: "+T),this.videoTrackCC=P,this.state===O.State.WAITING_INIT_PTS&&this.tick()}},i.startLoad=function(t){if(!this.levels){this.startPosition=t,this.state=O.State.STOPPED;return}var s=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,s>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),this.state=O.State.IDLE):(this.loadedmetadata=!1,this.state=O.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},i.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_TRACK:{var t,s=this.levels,m=this.trackId,g=s==null||((t=s[m])===null||t===void 0)?void 0:t.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=O.State.WAITING_INIT_PTS}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var T,P=performance.now(),I=this.retryDate;(!I||P>=I||(T=this.media)!==null&&T!==void 0&&T.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=O.State.IDLE);break}case O.State.WAITING_INIT_PTS:{var F=this.waitingData;if(F){var K=F.frag,V=F.part,Q=F.cache,Z=F.complete;if(this.initPTS[K.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.FRAG_LOADING;var ie=Q.flush(),pe={frag:K,part:V,payload:ie,networkDetails:null};this._handleFragmentLoadProgress(pe),Z&&p.prototype._handleFragmentLoadComplete.call(this,pe)}else if(this.videoTrackCC!==this.waitingVideoCC)e.logger.log("Waiting fragment cc ("+K.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ae=this.getLoadPosition(),de=_.BufferHelper.bufferInfo(this.mediaBuffer,ae,this.config.maxBufferHole),le=Object(b.fragmentWithinToleranceTest)(de.end,this.config.maxFragLookUpTolerance,K);le<0&&(e.logger.log("Waiting fragment cc ("+K.cc+") @ "+K.start+" cancelled because another fragment at "+de.end+" is needed"),this.clearWaitingFragment())}}else this.state=O.State.IDLE}}this.onTickEnd()},i.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=O.State.IDLE)},i.onTickEnd=function(){var t=this.media;if(!t||!t.readyState)return;var s=this.mediaBuffer?this.mediaBuffer:t,m=s.buffered;!this.loadedmetadata&&m.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime},i.doTickIdle=function(){var t,s,m=this.hls,g=this.levels,T=this.media,P=this.trackId,I=m.config;if(!g||!g[P])return;if(!T&&(this.startFragRequested||!I.startFragPrefetch))return;var F=g[P],K=F.details;if(!K||K.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(K)){this.state=O.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,w.PlaylistLevelType.AUDIO));var V=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,w.PlaylistLevelType.AUDIO);if(V===null)return;var Q=V.len,Z=this.getMaxBufferLength(),ie=this.audioSwitch;if(Q>=Z&&!ie)return;if(!ie&&this._streamEnded(V,K)){m.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=O.State.ENDED;return}var pe=K.fragments,ae=pe[0].start,de=V.end;if(ie){var le=this.getLoadPosition();de=le,K.PTSKnown&&le<ae&&((V.end>ae||V.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),T.currentTime=ae+.05))}var $=this.getNextFragment(de,K);if(!$){this.bufferFlushed=!0;return}((t=$.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((s=$.decryptdata)!==null&&s!==void 0&&s.key)?this.loadKey($,K):this.loadFragment($,K,de)},i.getMaxBufferLength=function(){var t=p.prototype.getMaxBufferLength.call(this),s=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,w.PlaylistLevelType.MAIN);return s===null?t:Math.max(t,s.len)},i.onMediaDetaching=function(){this.videoBuffer=null,p.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(t,s){var m=s.audioTracks;this.resetTransmuxer(),this.levels=m.map(function(g){return new L.Level(g)})},i.onAudioTrackSwitching=function(t,s){var m=!!s.url;this.trackId=s.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),m?this.setInterval(d):this.resetTransmuxer(),m?(this.audioSwitch=!0,this.state=O.State.IDLE):this.state=O.State.STOPPED,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(t,s){this.mainDetails=s.details},i.onAudioTrackLoaded=function(t,s){var m,g=this.levels,T=s.details,P=s.id;if(!g){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+T.startSN+","+T.endSN+"],duration:"+T.totalduration);var I=g[P],F=0;if(T.live||(m=I.details)!==null&&m!==void 0&&m.live){var K=this.mainDetails;if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed||!K)return;!I.details&&T.hasProgramDateTime&&K.hasProgramDateTime?(Object(v.alignMediaPlaylistByPDT)(T,K),F=T.fragments[0].start):F=this.alignPlaylists(T,I.details)}I.details=T,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!T.live)&&this.setStartPosition(I.details,F),this.state===O.State.WAITING_TRACK&&!this.waitForCdnTuneIn(T)&&(this.state=O.State.IDLE),this.tick()},i._handleFragmentLoadProgress=function(t){var s,m=t.frag,g=t.part,T=t.payload,P=this.config,I=this.trackId,F=this.levels;if(!F){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+m.sn+" of level "+m.level+" will not be buffered");return}var K=F[I];console.assert(K,"Audio track is defined on fragment load progress");var V=K.details;console.assert(V,"Audio track details are defined on fragment load progress");var Q=P.defaultAudioCodec||K.audioCodec||"mp4a.40.2",Z=this.transmuxer;Z||(Z=this.transmuxer=new C.default(this.hls,w.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ie=this.initPTS[m.cc],pe=(s=m.initSegment)===null||s===void 0?void 0:s.data;if(ie!==void 0){var ae=!1,de=g?g.index:-1,le=de!==-1,$=new E.ChunkMetadata(m.level,m.sn,m.stats.chunkCount,T.byteLength,de,le);Z.push(T,pe,Q,"",m,g,V.totalduration,ae,$,ie)}else{e.logger.log("Unknown video PTS for cc "+m.cc+", waiting for video PTS before demuxing audio frag "+m.sn+" of ["+V.startSN+" ,"+V.endSN+"],track "+I);var Y=this.waitingData=this.waitingData||{frag:m,part:g,cache:new x.default,complete:!1},ne=Y.cache;ne.push(new Uint8Array(T)),this.waitingVideoCC=this.videoTrackCC,this.state=O.State.WAITING_INIT_PTS}},i._handleFragmentLoadComplete=function(t){if(this.waitingData){this.waitingData.complete=!0;return}p.prototype._handleFragmentLoadComplete.call(this,t)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(t,s){var m=s.tracks.audio;m&&(this.mediaBuffer=m.buffer),s.tracks.video&&(this.videoBuffer=s.tracks.video.buffer)},i.onFragBuffered=function(t,s){var m=s.frag,g=s.part;if(m.type!==w.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(m)){this.warn("Fragment "+m.sn+(g?" p: "+g.index:"")+" of level "+m.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}m.sn!=="initSegment"&&(this.fragPrevious=m,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(m,g)},i.onError=function(t,s){switch(s.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.AUDIO,s);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==O.State.ERROR&&this.state!==O.State.STOPPED&&(this.state=s.fatal?O.State.ERROR:O.State.IDLE,this.warn(s.details+" while loading frag, switching to "+this.state+" state"));break;case h.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="audio"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var m=!0,g=this.getFwdBufferInfo(this.mediaBuffer,w.PlaylistLevelType.AUDIO);g&&g.len>.5&&(m=!this.reduceMaxBufferLength(g.len)),m&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,p.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},i.onBufferFlushed=function(t,s){var m=s.type;m===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},i._handleTransmuxComplete=function(t){var s,m="audio",g=this.hls,T=t.remuxResult,P=t.chunkMeta,I=this.getCurrentContext(P);if(!I){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var F=I.frag,K=I.part,V=T.audio,Q=T.text,Z=T.id3,ie=T.initSegment;if(this.fragContextChanged(F))return;if(this.state=O.State.PARSING,this.audioSwitch&&V&&this.completeAudioSwitch(),ie!=null&&ie.tracks&&(this._bufferInitSegment(ie.tracks,F,P),g.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:m,tracks:ie.tracks})),V){var pe=V.startPTS,ae=V.endPTS,de=V.startDTS,le=V.endDTS;K&&(K.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:pe,endPTS:ae,startDTS:de,endDTS:le}),F.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,pe,ae,de,le),this.bufferFragmentData(V,F,K,P)}if(Z!=null&&(s=Z.samples)!==null&&s!==void 0&&s.length){var $=a({frag:F,id:m},Z);g.trigger(A.Events.FRAG_PARSING_METADATA,$)}if(Q){var Y=a({frag:F,id:m},Q);g.trigger(A.Events.FRAG_PARSING_USERDATA,Y)}},i._bufferInitSegment=function(t,s,m){if(this.state!==O.State.PARSING)return;t.video&&delete t.video;var g=t.audio;if(!g)return;g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,t);var T=g.initSegment;if(T!=null&&T.byteLength){var P={type:"audio",frag:s,part:null,chunkMeta:m,parent:s.type,data:T};this.hls.trigger(A.Events.BUFFER_APPENDING,P)}this.tick()},i.loadFragment=function(t,s,m){var g=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||g===M.FragmentState.NOT_LOADED||g===M.FragmentState.PARTIAL)&&(t.sn==="initSegment"?this._loadInitSegment(t):s.live&&!Object(B.isFiniteNumber)(this.initPTS[t.cc])?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=O.State.WAITING_INIT_PTS):(this.startFragRequested=!0,p.prototype.loadFragment.call(this,t,s,m)))},i.completeAudioSwitch=function(){var t=this.hls,s=this.media,m=this.trackId;s&&(this.log("Switching audio track : flushing all audio"),p.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:m})},c}(O.default);U.default=u},"./src/controller/audio-track-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts"),O=S("./src/errors.ts"),A=S("./src/controller/base-playlist-controller.ts"),_=S("./src/types/loader.ts");function M(C,E){for(var b=0;b<E.length;b++){var v=E[b];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(C,v.key,v)}}function L(C,E,b){return E&&M(C.prototype,E),b&&M(C,b),C}function w(C,E){C.prototype=Object.create(E.prototype),C.prototype.constructor=C,y(C,E)}function y(C,E){return y=Object.setPrototypeOf||function(v,h){return v.__proto__=h,v},y(C,E)}var x=function(C){w(E,C);function E(v){var h;return h=C.call(this,v,"[audio-track-controller]")||this,h.tracks=[],h.groupId=null,h.tracksInGroup=[],h.trackId=-1,h.trackName="",h.selectDefaultTrack=!0,h.registerListeners(),h}var b=E.prototype;return b.registerListeners=function(){var h=this.hls;h.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),h.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.on(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(B.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var h=this.hls;h.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),h.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),h.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),h.off(B.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(B.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,C.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(h,e){this.tracks=e.audioTracks||[]},b.onAudioTrackLoaded=function(h,e){var a=e.id,o=e.details,f=this.tracksInGroup[a];if(!f){this.warn("Invalid audio track id "+a);return}var d=f.details;f.details=e.details,this.log("audioTrack "+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),a===this.trackId&&(this.retryCount=0,this.playlistLoaded(a,e,d))},b.onLevelLoading=function(h,e){this.switchLevel(e.level)},b.onLevelSwitching=function(h,e){this.switchLevel(e.level)},b.switchLevel=function(h){var e=this.hls.levels[h];if(!(e!=null&&e.audioGroupIds))return;var a=e.audioGroupIds[e.urlId];if(this.groupId!==a){this.groupId=a;var o=this.tracks.filter(function(d){return!a||d.groupId===a});this.selectDefaultTrack&&!o.some(function(d){return d.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=o;var f={audioTracks:o};this.log("Updating audio tracks, "+o.length+' track(s) found in "'+a+'" group-id'),this.hls.trigger(B.Events.AUDIO_TRACKS_UPDATED,f),this.selectInitialTrack()}},b.onError=function(h,e){if(C.prototype.onError.call(this,h,e),e.fatal||!e.context)return;e.context.type===_.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},b.setAudioTrack=function(h){var e=this.tracksInGroup;if(h<0||h>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var a=e[this.trackId];this.log("Now switching to audio-track index "+h);var o=e[h],f=o.id,d=o.groupId,u=d===void 0?"":d,p=o.name,c=o.type,i=o.url;if(this.trackId=h,this.trackName=p,this.selectDefaultTrack=!1,this.hls.trigger(B.Events.AUDIO_TRACK_SWITCHING,{id:f,groupId:u,name:p,type:c,url:i}),o.details&&!o.details.live)return;var r=this.switchParams(o.url,a==null?void 0:a.details);this.loadPlaylist(r)},b.selectInitialTrack=function(){var h=this.tracksInGroup;console.assert(h.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,a=this.findTrackId(e)||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:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(h){for(var e=this.tracksInGroup,a=0;a<e.length;a++){var o=e[a];if((!this.selectDefaultTrack||o.default)&&(!h||h===o.name))return o.id}return-1},b.loadPlaylist=function(h){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var a=e.id,o=e.groupId,f=e.url;if(h)try{f=h.addDirectives(f)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("loading audio-track playlist for id: "+a),this.clearTimer(),this.hls.trigger(B.Events.AUDIO_TRACK_LOADING,{url:f,id:a,groupId:o,deliveryDirectives:h||null})}},L(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(h){this.selectDefaultTrack=!1,this.setAudioTrack(h)}}]),E}(A.default);U.default=x},"./src/controller/base-playlist-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return L});var B=S("./src/polyfills/number.ts"),O=S("./src/types/level.ts"),A=S("./src/controller/level-helper.ts"),_=S("./src/utils/logger.ts"),M=S("./src/errors.ts"),L=function(){function w(x,C){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=_.logger.log.bind(_.logger,C+":"),this.warn=_.logger.warn.bind(_.logger,C+":"),this.hls=x}var y=w.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(C,E){E.fatal&&E.type===M.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(C,E){var b=E==null?void 0:E.renditionReports;if(b)for(var v=0;v<b.length;v++){var h=b[v],e=""+h.URI;if(e===C.substr(-e.length)){var a=parseInt(h["LAST-MSN"]),o=parseInt(h["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var f=Math.min(E.age-E.partTarget,E.targetduration);o!==void 0&&f>E.partTarget&&(o+=1)}if(Object(B.isFiniteNumber)(a))return new O.HlsUrlParameters(a,Object(B.isFiniteNumber)(o)?o:void 0,O.HlsSkip.No)}}},y.loadPlaylist=function(C){},y.shouldLoadTrack=function(C){return this.canLoad&&C&&!!C.url&&(!C.details||C.details.live)},y.playlistLoaded=function(C,E,b){var v=this,h=E.details,e=E.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(h.advancedDateTime=Date.now()-a,h.live||b!=null&&b.live){if(h.reloaded(b),b&&this.log("live playlist "+C+" "+(h.advanced?"REFRESHED "+h.lastPartSn+"-"+h.lastPartIndex:"MISSED")),b&&h.fragments.length>0&&Object(A.mergeDetails)(b,h),!this.canLoad||!h.live)return;var o,f=void 0,d=void 0;if(h.canBlockReload&&h.endSN&&h.advanced){var u=this.hls.config.lowLatencyMode,p=h.lastPartSn,c=h.endSN,i=h.lastPartIndex,r=i!==-1,t=p===c,s=u?0:i;r?(f=t?c+1:p,d=t?s:i+1):f=c+1;var m=h.age,g=m+h.ageHeader,T=Math.min(g-h.partTarget,h.targetduration*1.5);if(T>0){if(b&&T>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+T+" with playlist age: "+h.age),T=0;else{var P=Math.floor(T/h.targetduration);if(f+=P,d!==void 0){var I=Math.round(T%h.targetduration/h.partTarget);d+=I}this.log("CDN Tune-in age: "+h.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+T+" skip sn "+P+" to part "+d)}h.tuneInGoal=T}if(o=this.getDeliveryDirectives(h,E.deliveryDirectives,f,d),u||!t){this.loadPlaylist(o);return}}else o=this.getDeliveryDirectives(h,E.deliveryDirectives,f,d);var F=Object(A.computeReloadInterval)(h,e);f!==void 0&&h.canBlockReload&&(F-=h.partTarget||1),this.log("reload live playlist "+C+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return v.loadPlaylist(o)},F)}else this.clearTimer()},y.getDeliveryDirectives=function(C,E,b,v){var h=Object(O.getSkipValue)(C,b);return E!=null&&E.skip&&C.deltaUpdateFailed&&(b=E.msn,v=E.part,h=O.HlsSkip.No),new O.HlsUrlParameters(b,v,h)},y.retryLoadingOrFail=function(C){var E=this,b=this.hls.config,v=this.retryCount<b.levelLoadingMaxRetry;if(v){var h;if(this.retryCount++,C.details.indexOf("LoadTimeOut")>-1&&(h=C.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+C.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+C.details+'"')}}else this.warn('cannot recover from error "'+C.details+'"'),this.clearTimer(),C.fatal=!0;return v},w}()},"./src/controller/base-stream-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"State",function(){return c}),S.d(U,"default",function(){return i});var B=S("./src/polyfills/number.ts"),O=S("./src/task-loop.ts"),A=S("./src/controller/fragment-tracker.ts"),_=S("./src/utils/buffer-helper.ts"),M=S("./src/utils/logger.ts"),L=S("./src/events.ts"),w=S("./src/errors.ts"),y=S("./src/types/transmuxer.ts"),x=S("./src/utils/mp4-tools.ts"),C=S("./src/utils/discontinuities.ts"),E=S("./src/controller/fragment-finders.ts"),b=S("./src/controller/level-helper.ts"),v=S("./src/loader/fragment-loader.ts"),h=S("./src/crypt/decrypter.ts"),e=S("./src/utils/time-ranges.ts"),a=S("./src/types/loader.ts");function o(r,t){for(var s=0;s<t.length;s++){var m=t[s];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(r,m.key,m)}}function f(r,t,s){return t&&o(r.prototype,t),s&&o(r,s),r}function d(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function u(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,p(r,t)}function p(r,t){return p=Object.setPrototypeOf||function(m,g){return m.__proto__=g,m},p(r,t)}var c={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"},i=function(r){u(t,r);function t(m,g,T){var P;return P=r.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=c.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=T,P.log=M.logger.log.bind(M.logger,T+":"),P.warn=M.logger.warn.bind(M.logger,T+":"),P.hls=m,P.fragmentLoader=new v.default(m.config),P.fragmentTracker=g,P.config=m.config,P.decrypter=new h.default(m,m.config),m.on(L.Events.KEY_LOADED,P.onKeyLoaded,d(P)),P}var s=t.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(g){},s.stopLoad=function(){this.fragmentLoader.abort();var g=this.fragCurrent;g&&this.fragmentTracker.removeFragment(g),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},s._streamEnded=function(g,T){var P=this.fragCurrent,I=this.fragmentTracker;if(!T.live&&P&&P.sn===T.endSN&&!g.nextStart){var F=I.getState(P);return F===A.FragmentState.PARTIAL||F===A.FragmentState.OK}return!1},s.onMediaAttached=function(g,T){var P=this.media=this.mediaBuffer=T.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},s.onMediaDetaching=function(){var g=this.media;g!=null&&g.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),g&&(g.removeEventListener("seeking",this.onvseeking),g.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},s.onMediaSeeking=function(){var g=this.config,T=this.fragCurrent,P=this.media,I=this.mediaBuffer,F=this.state,K=P?P.currentTime:0,V=_.BufferHelper.bufferInfo(I||P,K,g.maxBufferHole);if(this.log("media seeking to "+(Object(B.isFiniteNumber)(K)?K.toFixed(3):K)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(T&&!V.len){var Q=g.maxFragLookUpTolerance,Z=T.start-Q,ie=T.start+T.duration+Q,pe=K>ie;(K<Z||pe)&&(pe&&T.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=K),!this.loadedmetadata&&!V.len&&(this.nextLoadPosition=this.startPosition=K),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onKeyLoaded=function(g,T){if(this.state!==c.KEY_LOADING||T.frag!==this.fragCurrent||!this.levels)return;this.state=c.IDLE;var P=this.levels[T.frag.level].details;P&&this.loadFragment(T.frag,P,T.frag.start)},s.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},s.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,r.prototype.onHandlerDestroyed.call(this)},s.loadKey=function(g,T){this.log("Loading key for "+g.sn+" of ["+T.startSN+"-"+T.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level),this.state=c.KEY_LOADING,this.fragCurrent=g,this.hls.trigger(L.Events.KEY_LOADING,{frag:g})},s.loadFragment=function(g,T,P){this._loadFragForPlayback(g,T,P)},s._loadFragForPlayback=function(g,T,P){var I=this,F=function(V){if(I.fragContextChanged(g)){I.warn("Fragment "+g.sn+(V.part?" p: "+V.part.index:"")+" of level "+g.level+" was dropped during download."),I.fragmentTracker.removeFragment(g);return}g.stats.chunkCount++,I._handleFragmentLoadProgress(V)};this._doFragLoad(g,T,P,F).then(function(K){if(!K)return;I.fragLoadError=0;var V=I.state;if(I.fragContextChanged(g)){(V===c.FRAG_LOADING||V===c.BACKTRACKING||!I.fragCurrent&&V===c.PARSING)&&(I.fragmentTracker.removeFragment(g),I.state=c.IDLE);return}if("payload"in K&&(I.log("Loaded fragment "+g.sn+" of level "+g.level),I.hls.trigger(L.Events.FRAG_LOADED,K),I.state===c.BACKTRACKING)){I.fragmentTracker.backtrack(g,K),I.resetFragmentLoading(g);return}I._handleFragmentLoadComplete(K)}).catch(function(K){I.warn(K),I.resetFragmentLoading(g)})},s.flushMainBuffer=function(g,T,P){if(P===void 0&&(P=null),!(g-T))return;var I={startOffset:g,endOffset:T,type:P};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,I)},s._loadInitSegment=function(g){var T=this;this._doFragLoad(g).then(function(P){if(!P||T.fragContextChanged(g)||!T.levels)throw new Error("init load aborted");return P}).then(function(P){var I=T.hls,F=P.payload,K=g.decryptdata;if(F&&F.byteLength>0&&K&&K.key&&K.iv&&K.method==="AES-128"){var V=self.performance.now();return T.decrypter.webCryptoDecrypt(new Uint8Array(F),K.key.buffer,K.iv.buffer).then(function(Q){var Z=self.performance.now();return I.trigger(L.Events.FRAG_DECRYPTED,{frag:g,payload:Q,stats:{tstart:V,tdecrypt:Z}}),P.payload=Q,P})}return P}).then(function(P){var I=T.fragCurrent,F=T.hls,K=T.levels;if(!K)throw new Error("init load aborted, missing levels");var V=K[g.level].details;console.assert(V,"Level details are defined when init segment is loaded");var Q=g.stats;T.state=c.IDLE,T.fragLoadError=0,g.data=new Uint8Array(P.payload),Q.parsing.start=Q.buffering.start=self.performance.now(),Q.parsing.end=Q.buffering.end=self.performance.now(),P.frag===I&&F.trigger(L.Events.FRAG_BUFFERED,{stats:Q,frag:I,part:null,id:g.type}),T.tick()}).catch(function(P){T.warn(P),T.resetFragmentLoading(g)})},s.fragContextChanged=function(g){var T=this.fragCurrent;return!g||!T||g.level!==T.level||g.sn!==T.sn||g.urlId!==T.urlId},s.fragBufferedComplete=function(g,T){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(T?" part: "+T.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+e.default.toString(_.BufferHelper.getBuffered(P))),this.state=c.IDLE,this.tick()},s._handleFragmentLoadComplete=function(g){var T=this.transmuxer;if(!T)return;var P=g.frag,I=g.part,F=g.partsLoaded,K=!F||F.length===0||F.some(function(Q){return!Q}),V=new y.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,I?I.index:-1,!K);T.flush(V)},s._handleFragmentLoadProgress=function(g){},s._doFragLoad=function(g,T,P,I){var F=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(g.start,P||0),this.config.lowLatencyMode&&T){var K=T.partList;if(K&&I){P>g.end&&T.fragmentHint&&(g=T.fragmentHint);var V=this.getNextPart(K,g,P);if(V>-1){var Q=K[V];return this.log("Loading part sn: "+g.sn+" p: "+Q.index+" cc: "+g.cc+" of playlist ["+T.startSN+"-"+T.endSN+"] parts [0-"+V+"-"+(K.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=Q.start+Q.duration,this.state=c.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:g,part:K[V],targetBufferTime:P}),this.doFragPartsLoad(g,K,V,I).catch(function(Z){return F.handleFragLoadError(Z)})}else if(!g.url||this.loadedEndOfParts(K,P))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(T?"of ["+T.startSN+"-"+T.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),Object(B.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=c.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:g,targetBufferTime:P}),this.fragmentLoader.load(g,I).catch(function(Z){return F.handleFragLoadError(Z)})},s.doFragPartsLoad=function(g,T,P,I){var F=this;return new Promise(function(K,V){var Q=[],Z=function ie(pe){var ae=T[pe];F.fragmentLoader.loadPart(g,ae,I).then(function(de){Q[ae.index]=de;var le=de.part;F.hls.trigger(L.Events.FRAG_LOADED,de);var $=T[pe+1];if($&&$.fragment===g)ie(pe+1);else return K({frag:g,part:le,partsLoaded:Q})}).catch(V)};Z(P)})},s.handleFragLoadError=function(g){var T=g.data;return T&&T.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(T.frag,T.part):this.hls.trigger(L.Events.ERROR,T),null},s._handleTransmuxerFlush=function(g){var T=this.getCurrentContext(g);if(!T||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var P=T.frag,I=T.part,F=T.level,K=self.performance.now();P.stats.parsing.end=K,I&&(I.stats.parsing.end=K),this.updateLevelTiming(P,I,F,g.partial)},s.getCurrentContext=function(g){var T=this.levels,P=g.level,I=g.sn,F=g.part;if(!T||!T[P])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+P+". The current chunk will not be buffered."),null;var K=T[P],V=F>-1?Object(b.getPartWith)(K,I,F):null,Q=V?V.fragment:Object(b.getFragmentWithSN)(K,I,this.fragCurrent);return Q?{frag:Q,part:V,level:K}:null},s.bufferFragmentData=function(g,T,P,I){if(!g||this.state!==c.PARSING)return;var F=g.data1,K=g.data2,V=F;if(F&&K&&(V=Object(x.appendUint8Array)(F,K)),!V||!V.length)return;var Q={type:g.type,frag:T,part:P,chunkMeta:I,parent:T.type,data:V};this.hls.trigger(L.Events.BUFFER_APPENDING,Q),g.dropped&&g.independent&&!P&&this.flushBufferGap(T)},s.flushBufferGap=function(g){var T=this.media;if(!T)return;if(!_.BufferHelper.isBuffered(T,T.currentTime)){this.flushMainBuffer(0,g.start);return}var P=T.currentTime,I=_.BufferHelper.bufferInfo(T,P,0),F=g.duration,K=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),V=Math.max(Math.min(g.start-K,I.end-K),P+K);g.start-V>K&&this.flushMainBuffer(V,g.start)},s.getFwdBufferInfo=function(g,T){var P=this.config,I=this.getLoadPosition();if(!Object(B.isFiniteNumber)(I))return null;var F=_.BufferHelper.bufferInfo(g,I,P.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var K=this.fragmentTracker.getBufferedFrag(I,T);if(K&&F.nextStart<K.end)return _.BufferHelper.bufferInfo(g,I,Math.max(F.nextStart,P.maxBufferHole))}return F},s.getMaxBufferLength=function(g){var T=this.config,P;return g?P=Math.max(8*T.maxBufferSize/g,T.maxBufferLength):P=T.maxBufferLength,Math.min(P,T.maxMaxBufferLength)},s.reduceMaxBufferLength=function(g){var T=this.config,P=g||T.maxBufferLength;return T.maxMaxBufferLength>=P?(T.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+T.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(g,T){var P,I,F=T.fragments,K=F.length;if(!K)return null;var V=this.config,Q=F[0].start,Z;if(T.live){var ie=V.initialLiveManifestSize;if(K<ie)return this.warn("Not enough fragments to start playback (have: "+K+", need: "+ie+")"),null;!T.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Z=this.getInitialLiveFragment(T,F),this.startPosition=Z?this.hls.liveSyncPosition||Z.start:g)}else g<=Q&&(Z=F[0]);if(!Z){var pe=V.lowLatencyMode?T.partEnd:T.fragmentEnd;Z=this.getFragmentAtPosition(g,pe,T)}return(P=Z)!==null&&P!==void 0&&P.initSegment&&!((I=Z)!==null&&I!==void 0&&I.initSegment.data)&&!this.bitrateTest&&(Z=Z.initSegment),Z},s.getNextPart=function(g,T,P){for(var I=-1,F=!1,K=!0,V=0,Q=g.length;V<Q;V++){var Z=g[V];if(K=K&&!Z.independent,I>-1&&P<Z.start)break;var ie=Z.loaded;!ie&&(F||Z.independent||K)&&Z.fragment===T&&(I=V),F=ie}return I},s.loadedEndOfParts=function(g,T){var P=g[g.length-1];return P&&T>P.start&&P.loaded},s.getInitialLiveFragment=function(g,T){var P=this.fragPrevious,I=null;if(P){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),I=Object(E.findFragmentByPDT)(T,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var F=P.sn+1;if(F>=g.startSN&&F<=g.endSN){var K=T[F-g.startSN];P.cc===K.cc&&(I=K,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(T,P.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var V=this.hls.liveSyncPosition;V!==null&&(I=this.getFragmentAtPosition(V,this.bitrateTest?g.fragmentEnd:g.edge,g))}return I},s.getFragmentAtPosition=function(g,T,P){var I=this.config,F=this.fragPrevious,K=P.fragments,V=P.endSN,Q=P.fragmentHint,Z=I.maxFragLookUpTolerance,ie=!!(I.lowLatencyMode&&P.partList&&Q);ie&&Q&&!this.bitrateTest&&(K=K.concat(Q),V=Q.sn);var pe;if(g<T){var ae=g>T-Z?0:Z;pe=Object(E.findFragmentByPTS)(F,K,g,ae)}else pe=K[K.length-1];if(pe){var de=pe.sn-P.startSN,le=F&&pe.level===F.level,$=K[de+1],Y=this.fragmentTracker.getState(pe);if(Y===A.FragmentState.BACKTRACKED){pe=null;for(var ne=de;K[ne]&&this.fragmentTracker.getState(K[ne])===A.FragmentState.BACKTRACKED;)F?pe=K[ne--]:pe=K[--ne];pe||(pe=$)}else F&&pe.sn===F.sn&&!ie&&(le&&(pe.sn<V&&this.fragmentTracker.getState($)!==A.FragmentState.OK?(this.log("SN "+pe.sn+" just loaded, load next one: "+$.sn),pe=$):pe=null))}return pe},s.synchronizeToLiveEdge=function(g){var T=this.config,P=this.media;if(!P)return;var I=this.hls.liveSyncPosition,F=P.currentTime,K=g.fragments[0].start,V=g.edge,Q=F>=K-T.maxFragLookUpTolerance&&F<=V;if(I!==null&&P.duration>I&&(F<I||!Q)){var Z=T.liveMaxLatencyDuration!==void 0?T.liveMaxLatencyDuration:T.liveMaxLatencyDurationCount*g.targetduration;(!Q&&P.readyState<4||F<V-Z)&&(this.loadedmetadata||(this.nextLoadPosition=I),P.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+V+", reset currentTime to : "+I.toFixed(3)),P.currentTime=I))}},s.alignPlaylists=function(g,T){var P=this.levels,I=this.levelLastLoaded,F=this.fragPrevious,K=I!==null?P[I]:null,V=g.fragments.length;if(!V)return this.warn("No fragments in live playlist"),0;var Q=g.fragments[0].start,Z=!T,ie=g.alignedSliding&&Object(B.isFiniteNumber)(Q);if(Z||!ie&&!Q){Object(C.alignStream)(F,K,g);var pe=g.fragments[0].start;return this.log("Live playlist sliding: "+pe.toFixed(2)+" start-sn: "+(T?T.startSN:"na")+"->"+g.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+V),pe}return Q},s.waitForCdnTuneIn=function(g){var T=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*T)},s.setStartPosition=function(g,T){var P=this.startPosition;if(P<T&&(P=-1),P===-1||this.lastCurrentTime===-1){var I=g.startTimeOffset;Object(B.isFiniteNumber)(I)?(P=T+I,I<0&&(P+=g.totalduration),P=Math.min(Math.max(T,P),T+g.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+P),this.startPosition=P):g.live?P=this.hls.liveSyncPosition||T:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},s.getLoadPosition=function(){var g=this.media,T=0;return this.loadedmetadata&&g?T=g.currentTime:this.nextLoadPosition&&(T=this.nextLoadPosition),T},s.handleFragLoadAborted=function(g,T){this.transmuxer&&g.sn!=="initSegment"&&g.stats.aborted&&(this.warn("Fragment "+g.sn+(T?" part"+T.index:"")+" of level "+g.level+" was aborted"),this.resetFragmentLoading(g))},s.resetFragmentLoading=function(g){(!this.fragCurrent||!this.fragContextChanged(g))&&(this.state=c.IDLE)},s.onFragmentOrKeyLoadError=function(g,T){if(T.fatal)return;var P=T.frag;if(!P||P.type!==g)return;var I=this.fragCurrent;console.assert(I&&P.sn===I.sn&&P.level===I.level&&P.urlId===I.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var K=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+g+" "+P.level+" failed to load, retrying in "+K+"ms"),this.retryDate=self.performance.now()+K,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else T.levelRetry?(g===a.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(M.logger.error(T.details+" reaches max retry, redispatch as fatal ..."),T.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)},s.afterBufferFlushed=function(g,T,P){if(!g)return;var I=_.BufferHelper.getBuffered(g);this.fragmentTracker.detectEvictedFragments(T,I,P),this.state===c.ENDED&&this.resetLoadingState()},s.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},s.resetLiveStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var T=this.levels?this.levels[g].details:null;if(T!=null&&T.live)return this.startPosition=-1,this.setStartPosition(T,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},s.updateLevelTiming=function(g,T,P,I){var F=this,K=P.details;console.assert(!!K,"level.details must be defined");var V=Object.keys(g.elementaryStreams).reduce(function(Q,Z){var ie=g.elementaryStreams[Z];if(ie){var pe=ie.endPTS-ie.startPTS;if(pe<=0)return F.warn("Could not parse fragment "+g.sn+" "+Z+" duration reliably ("+pe+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),Q||!1;var ae=I?0:Object(b.updateFragPTSDTS)(K,g,ie.startPTS,ie.endPTS,ie.startDTS,ie.endDTS);return F.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:K,level:P,drift:ae,type:Z,frag:g,start:ie.startPTS,end:ie.endPTS}),!0}return Q},!1);V?(this.state=c.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:g,part:T})):this.resetLoadingState()},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},f(t,[{key:"state",get:function(){return this._state},set:function(g){var T=this._state;T!==g&&(this._state=g,this.log(T+"->"+g))}}]),t}(O.default)},"./src/controller/buffer-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return E});var B=S("./src/polyfills/number.ts"),O=S("./src/events.ts"),A=S("./src/utils/logger.ts"),_=S("./src/errors.ts"),M=S("./src/utils/buffer-helper.ts"),L=S("./src/utils/mediasource-helper.ts"),w=S("./src/loader/fragment.ts"),y=S("./src/controller/buffer-operation-queue.ts"),x=Object(L.getMediaSource)(),C=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function b(h){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var a=e.hls,o=e.media,f=e.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),o&&(e.updateMediaElementDuration(),a.trigger(O.Events.MEDIA_ATTACHED,{media:o})),f&&f.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=h,this._initSourceBuffer(),this.registerListeners()}var v=b.prototype;return v.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},v.destroy=function(){this.unregisterListeners(),this.details=null},v.registerListeners=function(){var e=this.hls;e.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.Events.BUFFER_RESET,this.onBufferReset,this),e.on(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.Events.BUFFER_EOS,this.onBufferEos,this),e.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.Events.FRAG_PARSED,this.onFragParsed,this),e.on(O.Events.FRAG_CHANGED,this.onFragChanged,this)},v.unregisterListeners=function(){var e=this.hls;e.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.Events.BUFFER_RESET,this.onBufferReset,this),e.off(O.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.Events.BUFFER_EOS,this.onBufferEos,this),e.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.Events.FRAG_PARSED,this.onFragParsed,this),e.off(O.Events.FRAG_CHANGED,this.onFragChanged,this)},v._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},v.onManifestParsed=function(e,a){var o=2;(a.audio&&!a.video||!a.altAudio)&&(o=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=o,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},v.onMediaAttaching=function(e,a){var o=this.media=a.media;if(o&&x){var f=this.mediaSource=new x;f.addEventListener("sourceopen",this._onMediaSourceOpen),f.addEventListener("sourceended",this._onMediaSourceEnded),f.addEventListener("sourceclose",this._onMediaSourceClose),o.src=self.URL.createObjectURL(f),this._objectUrl=o.src}},v.onMediaDetaching=function(){var e=this.media,a=this.mediaSource,o=this._objectUrl;if(a){if(A.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(f){A.logger.warn("[buffer-controller]: onMediaDetaching: "+f.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(o&&self.URL.revokeObjectURL(o),e.src===o?(e.removeAttribute("src"),e.load()):A.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(O.Events.MEDIA_DETACHED,void 0)},v.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(a){var o=e.sourceBuffer[a];try{o&&(e.removeBufferListeners(a),e.mediaSource&&e.mediaSource.removeSourceBuffer(o),e.sourceBuffer[a]=void 0)}catch(f){A.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",f)}}),this._initSourceBuffer()},v.onBufferCodecs=function(e,a){var o=this,f=this.getSourceBufferTypes().length;if(Object.keys(a).forEach(function(d){if(f){var u=o.tracks[d];if(u&&typeof u.buffer.changeType=="function"){var p=a[d],c=p.codec,i=p.levelCodec,r=p.container,t=(u.levelCodec||u.codec).replace(C,"$1"),s=(i||c).replace(C,"$1");if(t!==s){var m=r+";codecs="+(i||c);o.appendChangeType(d,m)}}}else o.pendingTracks[d]=a[d]}),f)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},v.appendChangeType=function(e,a){var o=this,f=this.operationQueue,d={execute:function(){var p=o.sourceBuffer[e];p&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+a),p.changeType(a)),f.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(p){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",p)}};f.append(d,e)},v.onBufferAppending=function(e,a){var o=this,f=this.hls,d=this.operationQueue,u=this.tracks,p=a.data,c=a.type,i=a.frag,r=a.part,t=a.chunkMeta,s=t.buffering[c],m=self.performance.now();s.start=m;var g=i.stats.buffering,T=r?r.stats.buffering:null;g.start===0&&(g.start=m),T&&T.start===0&&(T.start=m);var P=u.audio,I=c==="audio"&&t.id===1&&(P==null?void 0:P.container)==="audio/mpeg",F={execute:function(){if(s.executeStart=self.performance.now(),I){var V=o.sourceBuffer[c];if(V){var Q=i.start-V.timestampOffset;Math.abs(Q)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+i.start+" (delta: "+Q+") sn: "+i.sn+")"),V.timestampOffset=i.start)}}o.appendExecutor(p,c)},onStart:function(){},onComplete:function(){var V=self.performance.now();s.executeEnd=s.end=V,g.first===0&&(g.first=V),T&&T.first===0&&(T.first=V);var Q=o.sourceBuffer,Z={};for(var ie in Q)Z[ie]=M.BufferHelper.getBuffered(Q[ie]);o.appendError=0,o.hls.trigger(O.Events.BUFFER_APPENDED,{type:c,frag:i,part:r,chunkMeta:t,parent:i.type,timeRanges:Z})},onError:function(V){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",V);var Q={type:_.ErrorTypes.MEDIA_ERROR,parent:i.type,details:_.ErrorDetails.BUFFER_APPEND_ERROR,err:V,fatal:!1};V.code===DOMException.QUOTA_EXCEEDED_ERR?Q.details=_.ErrorDetails.BUFFER_FULL_ERROR:(o.appendError++,Q.details=_.ErrorDetails.BUFFER_APPEND_ERROR,o.appendError>f.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+f.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),Q.fatal=!0)),f.trigger(O.Events.ERROR,Q)}};d.append(F,c)},v.onBufferFlushing=function(e,a){var o=this,f=this.operationQueue,d=function(p){return{execute:o.removeExecutor.bind(o,p,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){o.hls.trigger(O.Events.BUFFER_FLUSHED,{type:p})},onError:function(i){A.logger.warn("[buffer-controller]: Failed to remove from "+p+" SourceBuffer",i)}}};a.type?f.append(d(a.type),a.type):this.getSourceBufferTypes().forEach(function(u){f.append(d(u),u)})},v.onFragParsed=function(e,a){var o=this,f=a.frag,d=a.part,u=[],p=d?d.elementaryStreams:f.elementaryStreams;p[w.ElementaryStreamTypes.AUDIOVIDEO]?u.push("audiovideo"):(p[w.ElementaryStreamTypes.AUDIO]&&u.push("audio"),p[w.ElementaryStreamTypes.VIDEO]&&u.push("video"));var c=function(){var r=self.performance.now();f.stats.buffering.end=r,d&&(d.stats.buffering.end=r);var t=d?d.stats:f.stats;o.hls.trigger(O.Events.FRAG_BUFFERED,{frag:f,part:d,stats:t,id:f.type})};u.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+f.type+" level: "+f.level+" sn: "+f.sn),this.blockBuffers(c,u)},v.onFragChanged=function(e,a){this.flushBackBuffer()},v.onBufferEos=function(e,a){var o=this,f=this.getSourceBufferTypes().reduce(function(d,u){var p=o.sourceBuffer[u];return(!a.type||a.type===u)&&(p&&!p.ended&&(p.ended=!0,A.logger.log("[buffer-controller]: "+u+" sourceBuffer now EOS"))),d&&!!(!p||p.ended)},!0);f&&this.blockBuffers(function(){var d=o.mediaSource;if(!d||d.readyState!=="open")return;d.endOfStream()})},v.onLevelUpdated=function(e,a){var o=a.details;if(!o.fragments.length)return;this.details=o,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},v.flushBackBuffer=function(){var e=this.hls,a=this.details,o=this.media,f=this.sourceBuffer;if(!o||a===null)return;var d=this.getSourceBufferTypes();if(!d.length)return;var u=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!Object(B.isFiniteNumber)(u)||u<0)return;var p=o.currentTime,c=a.levelTargetDuration,i=Math.max(u,c),r=Math.floor(p/c)*c-i;d.forEach(function(t){var s=f[t];if(s){var m=M.BufferHelper.getBuffered(s);m.length>0&&r>m.start(0)&&(e.trigger(O.Events.BACK_BUFFER_REACHED,{bufferEnd:r}),a.live&&e.trigger(O.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r}),e.trigger(O.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:t}))}})},v.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var e=this.details,a=this.hls,o=this.media,f=this.mediaSource,d=e.fragments[0].start+e.totalduration,u=o.duration,p=Object(B.isFiniteNumber)(f.duration)?f.duration:0;e.live&&a.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),f.duration=Infinity,this.updateSeekableRange(e)):(d>p&&d>u||!Object(B.isFiniteNumber)(u))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+d.toFixed(3)),f.duration=d)},v.updateSeekableRange=function(e){var a=this.mediaSource,o=e.fragments,f=o.length;if(f&&e.live&&a!==null&&a!==void 0&&a.setLiveSeekableRange){var d=Math.max(0,o[0].start),u=Math.max(d,d+e.totalduration);a.setLiveSeekableRange(d,u)}},v.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,a=this.operationQueue,o=this.pendingTracks,f=Object.keys(o).length;if(f&&!e||f===2){this.createSourceBuffers(o),this.pendingTracks={};var d=this.getSourceBufferTypes();if(d.length===0){this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}d.forEach(function(u){a.executeNext(u)})}},v.createSourceBuffers=function(e){var a=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var f=0;for(var d in e)if(!a[d]){var u=e[d];if(!u)throw Error("source buffer exists for track "+d+", however track does not");var p=u.levelCodec||u.codec,c=u.container+";codecs="+p;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var i=a[d]=o.addSourceBuffer(c),r=d;this.addBufferListener(r,"updatestart",this._onSBUpdateStart),this.addBufferListener(r,"updateend",this._onSBUpdateEnd),this.addBufferListener(r,"error",this._onSBUpdateError),this.tracks[d]={buffer:i,codec:p,container:u.container,levelCodec:u.levelCodec,id:u.id},f++}catch(t){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:c})}}f&&this.hls.trigger(O.Events.BUFFER_CREATED,{tracks:this.tracks})},v._onSBUpdateStart=function(e){var a=this.operationQueue,o=a.current(e);o.onStart()},v._onSBUpdateEnd=function(e){var a=this.operationQueue,o=a.current(e);o.onComplete(),a.shiftAndExecuteNext(e)},v._onSBUpdateError=function(e,a){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var o=this.operationQueue.current(e);o&&o.onError(a)},v.removeExecutor=function(e,a,o){var f=this.media,d=this.mediaSource,u=this.operationQueue,p=this.sourceBuffer,c=p[e];if(!f||!d||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(e);return}var i=Object(B.isFiniteNumber)(f.duration)?f.duration:Infinity,r=Object(B.isFiniteNumber)(d.duration)?d.duration:Infinity,t=Math.max(0,a),s=Math.min(o,i,r);s>t?(A.logger.log("[buffer-controller]: Removing ["+t+","+s+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(t,s)):u.shiftAndExecuteNext(e)},v.appendExecutor=function(e,a){var o=this.operationQueue,f=this.sourceBuffer,d=f[a];if(!d){A.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(a);return}d.ended=!1,console.assert(!d.updating,a+" sourceBuffer must not be updating"),d.appendBuffer(e)},v.blockBuffers=function(e,a){var o=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(e);return}var f=this.operationQueue,d=a.map(function(u){return f.appendBlocker(u)});Promise.all(d).then(function(){e(),a.forEach(function(u){var p=o.sourceBuffer[u];(!p||!p.updating)&&f.shiftAndExecuteNext(u)})})},v.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},v.addBufferListener=function(e,a,o){var f=this.sourceBuffer[e];if(!f)return;var d=o.bind(this,e);this.listeners[e].push({event:a,listener:d}),f.addEventListener(a,d)},v.removeBufferListeners=function(e){var a=this.sourceBuffer[e];if(!a)return;this.listeners[e].forEach(function(o){a.removeEventListener(o.event,o.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return O});var B=S("./src/utils/logger.ts"),O=function(){function A(M){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=M}var _=A.prototype;return _.append=function(L,w){var y=this.queues[w];y.push(L),y.length===1&&this.buffers[w]&&this.executeNext(w)},_.insertAbort=function(L,w){var y=this.queues[w];y.unshift(L),this.executeNext(w)},_.appendBlocker=function(L){var w,y=new Promise(function(C){w=C}),x={execute:w,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,L),y},_.executeNext=function(L){var w=this.buffers,y=this.queues,x=w[L],C=y[L];if(C.length){var E=C[0];try{E.execute()}catch(b){B.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(b),(!x||!x.updating)&&(C.shift(),this.executeNext(L))}}},_.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},_.current=function(L){return this.queues[L][0]},A}()},"./src/controller/cap-level-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts");function O(M,L){for(var w=0;w<L.length;w++){var y=L[w];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(M,y.key,y)}}function A(M,L,w){return L&&O(M.prototype,L),w&&O(M,w),M}var _=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 L=M.prototype;return L.setStreamController=function(y){this.streamController=y},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var y=this.hls;y.on(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var y=this.hls;y.off(B.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(B.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(B.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(y,x){M.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},L.onMediaAttaching=function(y,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},L.onManifestParsed=function(y,x){var C=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,C.config.capLevelToPlayerSize&&x.video&&this.startCapping()},L.onBufferCodecs=function(y,x){var C=this.hls;C.config.capLevelToPlayerSize&&x.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(y.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},L.getMaxLevel=function(y){var x=this,C=this.hls.levels;if(!C.length)return-1;var E=C.filter(function(b,v){return M.isLevelAllowed(v,x.restrictedLevels)&&v<=y});return this.clientRect=null,M.getMaxLevelByMediaSize(E,this.mediaWidth,this.mediaHeight)},L.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()},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,x={width:0,height:0};if(y){var C=y.getBoundingClientRect();x.width=C.width,x.height=C.height,!x.width&&!x.height&&(x.width=C.right-C.left||y.width||0,x.height=C.bottom-C.top||y.height||0)}return this.clientRect=x,x},M.isLevelAllowed=function(y,x){return x===void 0&&(x=[]),x.indexOf(y)===-1},M.getMaxLevelByMediaSize=function(y,x,C){if(!y||!y.length)return-1;for(var E=function(a,o){return o?a.width!==o.width||a.height!==o.height:!0},b=y.length-1,v=0;v<y.length;v+=1){var h=y[v];if((h.width>=x||h.height>=C)&&E(h,y[v+1])){b=v;break}}return b},A(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 y=1;try{y=self.devicePixelRatio}catch(x){}return y}}]),M}();U.default=_},"./src/controller/cmcd-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return E});var B=S("./src/events.ts"),O=S("./src/types/cmcd.ts"),A=S("./src/utils/buffer-helper.ts"),_=S("./src/utils/logger.ts");function M(b,v){for(var h=0;h<v.length;h++){var e=v[h];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}}function L(b,v,h){return v&&M(b.prototype,v),h&&M(b,h),b}function w(b,v){var h=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(h)return(h=h.call(b)).next.bind(h);if(Array.isArray(b)||(h=y(b))||v&&b&&typeof b.length=="number"){h&&(b=h);var e=0;return function(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(b,v){if(!b)return;if(typeof b=="string")return x(b,v);var h=Object.prototype.toString.call(b).slice(8,-1);if(h==="Object"&&b.constructor&&(h=b.constructor.name),h==="Map"||h==="Set")return Array.from(b);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return x(b,v)}function x(b,v){(v==null||v>b.length)&&(v=b.length);for(var h=0,e=new Array(v);h<v;h++)e[h]=b[h];return e}function C(){return C=Object.assign||function(b){for(var v=1;v<arguments.length;v++){var h=arguments[v];for(var e in h)Object.prototype.hasOwnProperty.call(h,e)&&(b[e]=h[e])}return b},C.apply(this,arguments)}var E=function(){function b(h){var e=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(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(f){try{e.apply(f,{ot:O.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(d){_.logger.warn("Could not generate manifest CMCD data.",d)}},this.applyFragmentData=function(f){try{var d=f.frag,u=e.hls.levels[d.level],p=e.getObjectType(d),c={d:d.duration*1e3,ot:p};(p===O.CMCDObjectType.VIDEO||p===O.CMCDObjectType.AUDIO||p==O.CMCDObjectType.MUXED)&&(c.br=u.bitrate/1e3,c.tb=e.getTopBandwidth(p),c.bl=e.getBufferLength(p)),e.apply(f,c)}catch(i){_.logger.warn("Could not generate segment CMCD data.",i)}},this.hls=h;var a=this.config=h.config,o=a.cmcd;o!=null&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||b.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var v=b.prototype;return v.registerListeners=function(){var e=this.hls;e.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this)},v.unregisterListeners=function(){var e=this.hls;e.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(B.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},v.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},v.onMediaAttached=function(e,a){this.media=a.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},v.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},v.onBufferCreated=function(e,a){var o,f;this.audioBuffer=(o=a.tracks.audio)===null||o===void 0?void 0:o.buffer,this.videoBuffer=(f=a.tracks.video)===null||f===void 0?void 0:f.buffer},v.createData=function(){var e;return{v:O.CMCDVersion,sf:O.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},v.apply=function(e,a){a===void 0&&(a={}),C(a,this.createData());var o=a.ot===O.CMCDObjectType.INIT||a.ot===O.CMCDObjectType.VIDEO||a.ot===O.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 f=b.toHeaders(a);if(!Object.keys(f).length)return;e.headers||(e.headers={}),C(e.headers,f)}else{var d=b.toQuery(a);if(!d)return;e.url=b.appendQueryToUri(e.url,d)}},v.getObjectType=function(e){var a=e.type;return a==="subtitle"?O.CMCDObjectType.TIMED_TEXT:e.sn==="initSegment"?O.CMCDObjectType.INIT:a==="audio"?O.CMCDObjectType.AUDIO:a==="main"?this.hls.audioTracks.length?O.CMCDObjectType.VIDEO:O.CMCDObjectType.MUXED:void 0},v.getTopBandwidth=function(e){for(var a=0,o=e===O.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,f=w(o),d;!(d=f()).done;){var u=d.value;u.bitrate>a&&(a=u.bitrate)}return a>0?a:NaN},v.getBufferLength=function(e){var a=this.hls.media,o=e===O.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!o||!a)return NaN;var f=A.BufferHelper.bufferInfo(o,a.currentTime,this.config.maxBufferHole);return f.len*1e3},v.createPlaylistLoader=function(){var e=this.config.pLoader,a=this.applyPlaylistData,o=e||this.config.loader;return function(){function f(u){this.loader=void 0,this.loader=new o(u)}var d=f.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(p,c,i){a(p),this.loader.load(p,c,i)},L(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},v.createFragmentLoader=function(){var e=this.config.fLoader,a=this.applyFragmentData,o=e||this.config.loader;return function(){function f(u){this.loader=void 0,this.loader=new o(u)}var d=f.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(p,c,i){a(p),this.loader.load(p,c,i)},L(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},b.uuid=function(){var e=URL.createObjectURL(new Blob),a=e.toString();return URL.revokeObjectURL(e),a.substr(a.lastIndexOf("/")+1)},b.serialize=function(e){for(var a=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},f=function(I){return Math.round(I)},d=function(I){return f(I/100)*100},u=function(I){return encodeURIComponent(I)},p={br:f,d:f,bl:d,dl:d,mtp:d,nor:u,rtp:d,tb:f},c=Object.keys(e||{}).sort(),i=w(c),r;!(r=i()).done;){var t=r.value,s=e[t];if(!o(s))continue;if(t==="v"&&s===1)continue;if(t=="pr"&&s===1)continue;var m=p[t];m&&(s=m(s));var g=typeof s,T=void 0;t==="ot"||t==="sf"||t==="st"?T=t+"="+s:g==="boolean"?T=t:g==="number"?T=t+"="+s:T=t+"="+JSON.stringify(s),a.push(T)}return a.join(",")},b.toHeaders=function(e){for(var a=Object.keys(e),o={},f=["Object","Request","Session","Status"],d=[{},{},{},{}],u={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},p=0,c=a;p<c.length;p++){var i=c[p],r=u[i]!=null?u[i]:1;d[r][i]=e[i]}for(var t=0;t<d.length;t++){var s=b.serialize(d[t]);s&&(o["CMCD-"+f[t]]=s)}return o},b.toQuery=function(e){return"CMCD="+encodeURIComponent(b.serialize(e))},b.appendQueryToUri=function(e,a){if(!a)return e;var o=e.includes("?")?"&":"?";return""+e+o+a},b}()},"./src/controller/eme-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts"),O=S("./src/errors.ts"),A=S("./src/utils/logger.ts"),_=S("./src/utils/mediakeys-helper.ts");function M(E,b){for(var v=0;v<b.length;v++){var h=b[v];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function L(E,b,v){return b&&M(E.prototype,b),v&&M(E,v),E}var w=3,y=function(b,v,h){var e={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(a){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+a+'"',robustness:h.audioRobustness||""})}),v.forEach(function(a){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+a+'"',robustness:h.videoRobustness||""})}),[e]},x=function(b,v,h,e){switch(b){case _.KeySystems.WIDEVINE:return y(v,h,e);default:throw new Error("Unknown key-system: "+b)}},C=function(){function E(v){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=v,this._config=v.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 b=E.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._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)},b._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)},b.getLicenseServerUrl=function(h){switch(h){case _.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+h+'"')},b._attemptKeySystemAccess=function(h,e,a){var o=this,f=x(h,e,a,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var d=this.requestMediaKeySystemAccess(h,f);this.mediaKeysPromise=d.then(function(u){return o._onMediaKeySystemAccessObtained(h,u)}),d.catch(function(u){A.logger.error('Failed to obtain key-system "'+h+'" access:',u)})},b._onMediaKeySystemAccessObtained=function(h,e){var a=this;A.logger.log('Access for key-system "'+h+'" obtained');var o={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:h};this._mediaKeysList.push(o);var f=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(d){return o.mediaKeys=d,A.logger.log('Media-keys created for key-system "'+h+'"'),a._onMediaKeysCreated(),d});return f.catch(function(d){A.logger.error("Failed to create media-keys:",d)}),f},b._onMediaKeysCreated=function(){var h=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),h._onNewMediaKeySession(e.mediaKeysSession))})},b._onNewMediaKeySession=function(h){var e=this;A.logger.log("New key-system session "+h.sessionId),h.addEventListener("message",function(a){e._onKeySessionMessage(h,a.message)},!1)},b._onKeySessionMessage=function(h,e){A.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(a){A.logger.log("Received license data (length: "+(a&&a.byteLength)+"), updating key-session"),h.update(a)})},b.onMediaEncrypted=function(h){var e=this;if(A.logger.log('Media is encrypted using "'+h.initDataType+'" init data type'),!this.mediaKeysPromise){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var a=function(f){if(!e._media)return;e._attemptSetMediaKeys(f),e._generateRequestWithPreferredKeySession(h.initDataType,h.initData)};this.mediaKeysPromise.then(a).catch(a)},b._attemptSetMediaKeys=function(h){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(h,e){var a=this,o=this._mediaKeysList[0];if(!o){A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(o.mediaKeysSessionInitialized){A.logger.warn("Key-Session already initialized but requested again");return}var f=o.mediaKeysSession;if(!f){A.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){A.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}A.logger.log('Generating key-session request for "'+h+'" init data type'),o.mediaKeysSessionInitialized=!0,f.generateRequest(h,e).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(d){A.logger.error("Error generating key-session request:",d),a.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(h,e,a){var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,o,h,e,a);var f=this._licenseXhrSetup;if(f)try{f.call(this.hls,o,h),f=void 0}catch(d){A.logger.error(d)}try{o.readyState||o.open("POST",h,!0),f&&f.call(this.hls,o,h)}catch(d){throw new Error("issue setting up KeySystem license XHR "+d)}return o},b._onLicenseRequestReadyStageChange=function(h,e,a,o){switch(h.readyState){case 4:if(h.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var f=h.response,d=this._licenseResponseCallback;if(d)try{f=d.call(this.hls,h,e)}catch(p){A.logger.error(p)}o(f)}else{if(A.logger.error("License Request XHR failed ("+e+"). Status: "+h.status+" ("+h.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>w){this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var u=w-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(a,o)}break}},b._generateLicenseRequestChallenge=function(h,e){switch(h.mediaKeySystemDomain){case _.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+h.mediaKeySystemDomain)},b._requestLicense=function(h,e){A.logger.log("Requesting content license for key-system");var a=this._mediaKeysList[0];if(!a){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var o=this.getLicenseServerUrl(a.mediaKeySystemDomain),f=this._createLicenseXhr(o,h,e);A.logger.log("Sending license request to URL: "+o);var d=this._generateLicenseRequestChallenge(a,h);f.send(d)}catch(u){A.logger.error("Failure requesting DRM license: "+u),this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.KEY_SYSTEM_ERROR,details:O.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(h,e){if(!this._emeEnabled)return;var a=e.media;this._media=a,a.addEventListener("encrypted",this._onMediaEncrypted)},b.onMediaDetached=function(){var h=this._media,e=this._mediaKeysList;if(!h)return;h.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(a){if(a.mediaKeysSession)return a.mediaKeysSession.close().catch(function(){})})).then(function(){return h.setMediaKeys(null)}).catch(function(){})},b.onManifestParsed=function(h,e){if(!this._emeEnabled)return;var a=e.levels.map(function(f){return f.audioCodec}).filter(function(f){return!!f}),o=e.levels.map(function(f){return f.videoCodec}).filter(function(f){return!!f});this._attemptKeySystemAccess(_.KeySystems.WIDEVINE,a,o)},L(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();U.default=C},"./src/controller/fps-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts"),O=S("./src/utils/logger.ts"),A=function(){function _(L){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=L,this.registerListeners()}var M=_.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,y){var x=this.hls.config;if(x.capLevelOnFPSDrop){var C=y.media instanceof self.HTMLVideoElement?y.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),x.fpsDroppedMonitoringPeriod)}},M.checkFPS=function(w,y,x){var C=performance.now();if(y){if(this.lastTime){var E=C-this.lastTime,b=x-this.lastDroppedFrames,v=y-this.lastDecodedFrames,h=1e3*b/E,e=this.hls;if(e.trigger(B.Events.FPS_DROP,{currentDropped:b,currentDecoded:v,totalDroppedFrames:x}),h>0&&b>e.config.fpsDroppedMonitoringThreshold*v){var a=e.currentLevel;O.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=a)&&(a=a-1,e.trigger(B.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:e.currentLevel}),e.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=C,this.lastDroppedFrames=x,this.lastDecodedFrames=y}},M.checkFPSInterval=function(){var w=this.media;if(w)if(this.isVideoPlaybackQualityAvailable){var y=w.getVideoPlaybackQuality();this.checkFPS(w,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(w,w.webkitDecodedFrameCount,w.webkitDroppedFrameCount)},_}();U.default=A},"./src/controller/fragment-finders.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"findFragmentByPDT",function(){return A}),S.d(U,"findFragmentByPTS",function(){return _}),S.d(U,"fragmentWithinToleranceTest",function(){return M}),S.d(U,"pdtWithinToleranceTest",function(){return L}),S.d(U,"findFragWithCC",function(){return w});var B=S("./src/polyfills/number.ts"),O=S("./src/utils/binary-search.ts");function A(y,x,C){if(x===null||!Array.isArray(y)||!y.length||!Object(B.isFiniteNumber)(x))return null;var E=y[0].programDateTime;if(x<(E||0))return null;var b=y[y.length-1].endProgramDateTime;if(x>=(b||0))return null;C=C||0;for(var v=0;v<y.length;++v){var h=y[v];if(L(x,C,h))return h}return null}function _(y,x,C,E){C===void 0&&(C=0),E===void 0&&(E=0);var b=null;if(y?b=x[y.sn-x[0].sn+1]||null:C===0&&x[0].start===0&&(b=x[0]),b&&M(C,E,b)===0)return b;var v=O.default.search(x,M.bind(null,C,E));return v||b}function M(y,x,C){y===void 0&&(y=0),x===void 0&&(x=0);var E=Math.min(x,C.duration+(C.deltaPTS?C.deltaPTS:0));return C.start+C.duration-E<=y?1:C.start-E>y&&C.start?-1:0}function L(y,x,C){var E=Math.min(x,C.duration+(C.deltaPTS?C.deltaPTS:0))*1e3,b=C.endProgramDateTime||0;return b-E>y}function w(y,x){return O.default.search(y,function(C){return C.cc<x?1:C.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"FragmentState",function(){return A}),S.d(U,"FragmentTracker",function(){return _});var B=S("./src/events.ts"),O=S("./src/types/loader.ts"),A;(function(w){w.NOT_LOADED="NOT_LOADED",w.BACKTRACKED="BACKTRACKED",w.APPENDING="APPENDING",w.PARTIAL="PARTIAL",w.OK="OK"})(A||(A={}));var _=function(){function w(x){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=x,this._registerListeners()}var y=w.prototype;return y._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)},y._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)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(C,E){if(E===O.PlaylistLevelType.MAIN){var b=this.activeFragment,v=this.activeParts;if(!b)return null;if(v)for(var h=v.length;h--;){var e=v[h],a=e?e.end:b.appendedPTS;if(e.start<=C&&a!==void 0&&C<=a)return h>9&&(this.activeParts=v.slice(h-9)),e}else if(b.start<=C&&b.appendedPTS!==void 0&&C<=b.appendedPTS)return b}return this.getBufferedFrag(C,E)},y.getBufferedFrag=function(C,E){for(var b=this.fragments,v=Object.keys(b),h=v.length;h--;){var e=b[v[h]];if((e==null?void 0:e.body.type)===E&&e.buffered){var a=e.body;if(a.start<=C&&C<=a.end)return a}}return null},y.detectEvictedFragments=function(C,E,b){var v=this;Object.keys(this.fragments).forEach(function(h){var e=v.fragments[h];if(!e)return;if(!e.buffered){e.body.type===b&&v.removeFragment(e.body);return}var a=e.range[C];if(!a)return;a.time.some(function(o){var f=!v.isTimeBuffered(o.startPTS,o.endPTS,E);return f&&v.removeFragment(e.body),f})})},y.detectPartialFragments=function(C){var E=this,b=this.timeRanges,v=C.frag,h=C.part;if(!b||v.sn==="initSegment")return;var e=L(v),a=this.fragments[e];if(!a)return;Object.keys(b).forEach(function(o){var f=v.elementaryStreams[o];if(!f)return;var d=b[o],u=h!==null||f.partial===!0;a.range[o]=E.getBufferedTimes(v,h,u,d)}),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body)},y.fragBuffered=function(C){var E=L(C),b=this.fragments[E];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},y.getBufferedTimes=function(C,E,b,v){for(var h={time:[],partial:b},e=E?E.start:C.start,a=E?E.end:C.end,o=C.minEndPTS||a,f=C.maxStartPTS||e,d=0;d<v.length;d++){var u=v.start(d)-this.bufferPadding,p=v.end(d)+this.bufferPadding;if(f>=u&&o<=p){h.time.push({startPTS:Math.max(e,v.start(d)),endPTS:Math.min(a,v.end(d))});break}else if(e<p&&a>u)h.partial=!0,h.time.push({startPTS:Math.max(e,v.start(d)),endPTS:Math.min(a,v.end(d))});else if(a<=u)break}return h},y.getPartialFragment=function(C){var E=null,b,v,h,e=0,a=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(f){var d=o[f];if(!d)return;M(d)&&(v=d.body.start-a,h=d.body.end+a,C>=v&&C<=h&&(b=Math.min(C-v,h-C),e<=b&&(E=d.body,e=b)))}),E},y.getState=function(C){var E=L(C),b=this.fragments[E];return b?b.buffered?M(b)?A.PARTIAL:A.OK:b.backtrack?A.BACKTRACKED:A.APPENDING:A.NOT_LOADED},y.backtrack=function(C,E){var b=L(C),v=this.fragments[b];if(!v||v.backtrack)return null;var h=v.backtrack=E||v.loaded;return v.loaded=null,h},y.getBacktrackData=function(C){var E=L(C),b=this.fragments[E];if(b){var v,h=b.backtrack;if(h!=null&&(v=h.payload)!==null&&v!==void 0&&v.byteLength)return h;this.removeFragment(C)}return null},y.isTimeBuffered=function(C,E,b){for(var v,h,e=0;e<b.length;e++){if(v=b.start(e)-this.bufferPadding,h=b.end(e)+this.bufferPadding,C>=v&&E<=h)return!0;if(E<=v)return!1}return!1},y.onFragLoaded=function(C,E){var b=E.frag,v=E.part;if(b.sn==="initSegment"||b.bitrateTest||v)return;var h=L(b);this.fragments[h]={body:b,loaded:E,backtrack:null,buffered:!1,range:Object.create(null)}},y.onBufferAppended=function(C,E){var b=this,v=E.frag,h=E.part,e=E.timeRanges;if(v.type===O.PlaylistLevelType.MAIN)if(this.activeFragment=v,h){var a=this.activeParts;a||(this.activeParts=a=[]),a.push(h)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(o){var f=e[o];if(b.detectEvictedFragments(o,f),!h)for(var d=0;d<f.length;d++)v.appendedPTS=Math.max(f.end(d),v.appendedPTS||0)})},y.onFragBuffered=function(C,E){this.detectPartialFragments(E)},y.hasFragment=function(C){var E=L(C);return!!this.fragments[E]},y.removeFragmentsInRange=function(C,E,b){var v=this;Object.keys(this.fragments).forEach(function(h){var e=v.fragments[h];if(!e)return;if(e.buffered){var a=e.body;a.type===b&&a.start<E&&a.end>C&&v.removeFragment(a)}})},y.removeFragment=function(C){var E=L(C);C.stats.loaded=0,C.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},w}();function M(w){var y,x;return w.buffered&&(((y=w.range.video)===null||y===void 0?void 0:y.partial)||((x=w.range.audio)===null||x===void 0?void 0:x.partial))}function L(w){return w.type+"_"+w.level+"_"+w.urlId+"_"+w.sn}},"./src/controller/gap-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"STALL_MINIMUM_DURATION_MS",function(){return M}),S.d(U,"MAX_START_GAP_JUMP",function(){return L}),S.d(U,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return w}),S.d(U,"SKIP_BUFFER_RANGE_START",function(){return y}),S.d(U,"default",function(){return x});var B=S("./src/utils/buffer-helper.ts"),O=S("./src/errors.ts"),A=S("./src/events.ts"),_=S("./src/utils/logger.ts"),M=250,L=2,w=.1,y=.05,x=function(){function C(b,v,h,e){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=b,this.media=v,this.fragmentTracker=h,this.hls=e}var E=C.prototype;return E.destroy=function(){this.hls=this.fragmentTracker=this.media=null},E.poll=function(v){var h=this.config,e=this.media,a=this.stalled,o=e.currentTime,f=e.seeking,d=this.seeking&&!f,u=!this.seeking&&f;if(this.seeking=f,o!==v){if(this.moved=!0,a!==null){if(this.stallReported){var p=self.performance.now()-a;_.logger.warn("playback not stuck anymore @"+o+", after "+Math.round(p)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||d)&&(this.stalled=null),e.paused||e.ended||e.playbackRate===0||!B.BufferHelper.getBuffered(e).length)return;var c=B.BufferHelper.bufferInfo(e,o,0),i=c.len>0,r=c.nextStart||0;if(!i&&!r)return;if(f){var t=c.len>L,s=!r||r-o>L&&!this.fragmentTracker.getPartialFragment(o);if(t||s)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,g=Math.max(r,c.start||0)-o,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=T==null||((m=T.details)===null||m===void 0)?void 0:m.live,I=P?T.details.targetduration*2:L;if(g>0&&g<=I){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(a===null){this.stalled=F;return}var K=F-a;!f&&K>=M&&this._reportStall(c.len);var V=B.BufferHelper.bufferInfo(e,o,h.maxBufferHole);this._tryFixBufferStall(V,K)},E._tryFixBufferStall=function(v,h){var e=this.config,a=this.fragmentTracker,o=this.media,f=o.currentTime,d=a.getPartialFragment(f);if(d){var u=this._trySkipBufferHole(d);if(u)return}v.len>e.maxBufferHole&&h>e.highBufferWatchdogPeriod*1e3&&(_.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},E._reportStall=function(v){var h=this.hls,e=this.media,a=this.stallReported;a||(this.stallReported=!0,_.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+v+")"),h.trigger(A.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:v}))},E._trySkipBufferHole=function(v){for(var h=this.config,e=this.hls,a=this.media,o=a.currentTime,f=0,d=B.BufferHelper.getBuffered(a),u=0;u<d.length;u++){var p=d.start(u);if(o+h.maxBufferHole>=f&&o<p){var c=Math.max(p+y,a.currentTime+w);return _.logger.warn("skipping hole, adjusting currentTime from "+o+" to "+c),this.moved=!0,this.stalled=null,a.currentTime=c,v&&e.trigger(A.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+o+" to "+c,frag:v}),c}f=d.end(u)}return 0},E._tryNudgeBuffer=function(){var v=this.config,h=this.hls,e=this.media,a=e.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<v.nudgeMaxRetry){var f=a+o*v.nudgeOffset;_.logger.warn("Nudging 'currentTime' from "+a+" to "+f),e.currentTime=f,h.trigger(A.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else _.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+v.nudgeMaxRetry+" nudges"),h.trigger(A.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},C}()},"./src/controller/id3-track-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts"),O=S("./src/utils/texttrack-utils.ts"),A=S("./src/demux/id3.ts"),_=.25,M=function(){function L(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var w=L.prototype;return w.destroy=function(){this._unregisterListeners()},w._registerListeners=function(){var x=this.hls;x.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.on(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w._unregisterListeners=function(){var x=this.hls;x.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),x.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),x.off(B.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),x.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},w.onMediaAttached=function(x,C){this.media=C.media},w.onMediaDetaching=function(){if(!this.id3Track)return;Object(O.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},w.getID3Track=function(x){if(!this.media)return;for(var C=0;C<x.length;C++){var E=x[C];if(E.kind==="metadata"&&E.label==="id3")return Object(O.sendAddTrackEvent)(E,this.media),E}return this.media.addTextTrack("metadata","id3")},w.onFragParsingMetadata=function(x,C){if(!this.media)return;var E=C.frag,b=C.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var v=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,h=0;h<b.length;h++){var e=A.getID3Frames(b[h].data);if(e){var a=b[h].pts,o=h<b.length-1?b[h+1].pts:E.end,f=o-a;f<=0&&(o=a+_);for(var d=0;d<e.length;d++){var u=e[d];if(!A.isTimeStampFrame(u)){var p=new v(a,o,"");p.value=u,this.id3Track.addCue(p)}}}}},w.onBufferFlushing=function(x,C){var E=C.startOffset,b=C.endOffset,v=C.type;if(!v||v==="audio"){var h=this.id3Track;h&&Object(O.removeCuesInRange)(h,E,b)}},L}();U.default=M},"./src/controller/latency-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return L});var B=S("./src/errors.ts"),O=S("./src/events.ts"),A=S("./src/utils/logger.ts");function _(w,y){for(var x=0;x<y.length;x++){var C=y[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function M(w,y,x){return y&&_(w.prototype,y),x&&_(w,x),w}var L=function(){function w(x){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=x,this.config=x.config,this.registerListeners()}var y=w.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(O.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(O.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(O.Events.ERROR,this.onError)},y.onMediaAttached=function(C,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(C,E){var b=E.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(C,E){if(E.details!==B.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},y.timeupdate=function(){var C=this.media,E=this.levelDetails;if(!C||!E)return;this.currentTime=C.currentTime;var b=this.computeLatency();if(b===null)return;this._latency=b;var v=this.config,h=v.lowLatencyMode,e=v.maxLiveSyncPlaybackRate;if(!h||e===1)return;var a=this.targetLatency;if(a===null)return;var o=b-a,f=Math.min(this.maxLatency,a+E.targetduration),d=o<f;if(E.live&&d&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,e)),p=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;C.playbackRate=Math.min(u,Math.max(1,p))}else C.playbackRate!==1&&C.playbackRate!==0&&(C.playbackRate=1)},y.estimateLiveEdge=function(){var C=this.levelDetails;return C===null?null:C.edge+C.age},y.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,E=this.levelDetails;return C.liveMaxLatencyDuration!==void 0?C.liveMaxLatencyDuration:E?C.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var C=this.levelDetails;if(C===null)return null;var E=C.holdBack,b=C.partHoldBack,v=C.targetduration,h=this.config,e=h.liveSyncDuration,a=h.liveSyncDurationCount,o=h.lowLatencyMode,f=this.hls.userConfig,d=o&&b||E;(f.liveSyncDuration||f.liveSyncDurationCount||d===0)&&(d=e!==void 0?e:a*v);var u=v,p=1;return d+Math.min(this.stallCount*p,u)}},{key:"liveSyncPosition",get:function(){var C=this.estimateLiveEdge(),E=this.targetLatency,b=this.levelDetails;if(C===null||E===null||b===null)return null;var v=b.edge,h=C-E-this.edgeStalled,e=v-b.totalduration,a=v-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(e,h),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 E=(this.config.lowLatencyMode&&C.partTarget||C.targetduration)*3;return Math.max(C.age-E,0)}},{key:"forwardBufferLength",get:function(){var C=this.media,E=this.levelDetails;if(!C||!E)return 0;var b=C.buffered.length;return b?C.buffered.end(b-1):E.edge-this.currentTime}}]),w}()},"./src/controller/level-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return h});var B=S("./src/types/level.ts"),O=S("./src/events.ts"),A=S("./src/errors.ts"),_=S("./src/utils/codecs.ts"),M=S("./src/controller/level-helper.ts"),L=S("./src/controller/base-playlist-controller.ts"),w=S("./src/types/loader.ts");function y(){return y=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var f in o)Object.prototype.hasOwnProperty.call(o,f)&&(e[f]=o[f])}return e},y.apply(this,arguments)}function x(e,a){for(var o=0;o<a.length;o++){var f=a[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(e,f.key,f)}}function C(e,a,o){return a&&x(e.prototype,a),o&&x(e,o),e}function E(e,a){e.prototype=Object.create(a.prototype),e.prototype.constructor=e,b(e,a)}function b(e,a){return b=Object.setPrototypeOf||function(f,d){return f.__proto__=d,f},b(e,a)}var v=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(e){E(a,e);function a(f){var d;return d=e.call(this,f,"[level-controller]")||this,d._levels=[],d._firstLevel=-1,d._startLevel=void 0,d.currentLevelIndex=-1,d.manualLevelIndex=-1,d.onParsedComplete=void 0,d._registerListeners(),d}var o=a.prototype;return o._registerListeners=function(){var d=this.hls;d.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(O.Events.ERROR,this.onError,this)},o._unregisterListeners=function(){var d=this.hls;d.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(O.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(O.Events.ERROR,this.onError,this)},o.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},o.startLoad=function(){var d=this._levels;d.forEach(function(u){u.loadError=0}),e.prototype.startLoad.call(this)},o.onManifestLoaded=function(d,u){var p=[],c=[],i=[],r,t={},s,m=!1,g=!1,T=!1;if(u.levels.forEach(function(K){var V=K.attrs;m=m||!!(K.width&&K.height),g=g||!!K.videoCodec,T=T||!!K.audioCodec,v&&K.audioCodec&&K.audioCodec.indexOf("mp4a.40.34")!==-1&&(K.audioCodec=void 0);var Q=K.bitrate+"-"+K.attrs.RESOLUTION+"-"+K.attrs.CODECS;s=t[Q],s?s.url.push(K.url):(s=new B.Level(K),t[Q]=s,p.push(s)),V&&(V.AUDIO&&Object(M.addGroupId)(s,"audio",V.AUDIO),V.SUBTITLES&&Object(M.addGroupId)(s,"text",V.SUBTITLES))}),(m||g)&&T&&(p=p.filter(function(K){var V=K.videoCodec,Q=K.width,Z=K.height;return!!V||!!(Q&&Z)})),p=p.filter(function(K){var V=K.audioCodec,Q=K.videoCodec;return(!V||Object(_.isCodecSupportedInMp4)(V,"audio"))&&(!Q||Object(_.isCodecSupportedInMp4)(Q,"video"))}),u.audioTracks&&(c=u.audioTracks.filter(function(K){return!K.audioCodec||Object(_.isCodecSupportedInMp4)(K.audioCodec,"audio")}),Object(M.assignTrackIdsByGroup)(c)),u.subtitles&&(i=u.subtitles,Object(M.assignTrackIdsByGroup)(i)),p.length>0){r=p[0].bitrate,p.sort(function(K,V){return K.bitrate-V.bitrate}),this._levels=p;for(var P=0;P<p.length;P++)if(p[P].bitrate===r){this._firstLevel=P,this.log("manifest loaded, "+p.length+" level(s) found, first bitrate: "+r);break}var I=T&&!g,F={levels:p,audioTracks:c,subtitleTracks:i,firstLevel:this._firstLevel,stats:u.stats,audio:T,video:g,altAudio:!I&&c.some(function(K){return!!K.url})};this.hls.trigger(O.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(O.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:u.url,reason:"no level with compatible codecs found in manifest"})},o.onError=function(d,u){if(e.prototype.onError.call(this,d,u),u.fatal)return;var p=u.context,c=this._levels[this.currentLevelIndex];if(p&&(p.type===w.PlaylistContextType.AUDIO_TRACK&&c.audioGroupIds&&p.groupId===c.audioGroupIds[c.urlId]||p.type===w.PlaylistContextType.SUBTITLE_TRACK&&c.textGroupIds&&p.groupId===c.textGroupIds[c.urlId])){this.redundantFailover(this.currentLevelIndex);return}var i=!1,r=!0,t;switch(u.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:if(u.frag){var s=this._levels[u.frag.level];s?(s.fragmentError++,s.fragmentError>this.hls.config.fragLoadingMaxRetry&&(t=u.frag.level)):t=u.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:p&&(p.deliveryDirectives&&(r=!1),t=p.level),i=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:t=u.level,i=!0;break}t!==void 0&&this.recoverLevel(u,t,i,r)},o.recoverLevel=function(d,u,p,c){var i=d.details,r=this._levels[u];if(r.loadError++,p){var t=this.retryLoadingOrFail(d);if(t)d.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var s=r.url.length;if(s>1&&r.loadError<s)d.levelRetry=!0,this.redundantFailover(u);else if(this.manualLevelIndex===-1){var m=u===0?this._levels.length-1:u-1;this.currentLevelIndex!==m&&this._levels[m].loadError===0&&(this.warn(i+": switch to "+m),d.levelRetry=!0,this.hls.nextAutoLevel=m)}}},o.redundantFailover=function(d){var u=this._levels[d],p=u.url.length;if(p>1){var c=(u.urlId+1)%p;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(i){i.urlId=c}),this.level=d}},o.onFragLoaded=function(d,u){var p=u.frag;if(p!==void 0&&p.type===w.PlaylistLevelType.MAIN){var c=this._levels[p.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},o.onLevelLoaded=function(d,u){var p,c=u.level,i=u.details,r=this._levels[c];if(!r){var t;this.warn("Invalid level index "+c),(t=u.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(i.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(r.fragmentError===0&&(r.loadError=0,this.retryCount=0),this.playlistLoaded(c,u,r.details)):(p=u.deliveryDirectives)!==null&&p!==void 0&&p.skip&&(i.deltaUpdateFailed=!0)},o.onAudioTrackSwitched=function(d,u){var p=this.hls.levels[this.currentLevelIndex];if(!p)return;if(p.audioGroupIds){for(var c=-1,i=this.hls.audioTracks[u.id].groupId,r=0;r<p.audioGroupIds.length;r++)if(p.audioGroupIds[r]===i){c=r;break}c!==p.urlId&&(p.urlId=c,this.startLoad())}},o.loadPlaylist=function(d){var u=this.currentLevelIndex,p=this._levels[u];if(this.canLoad&&p&&p.url.length>0){var c=p.urlId,i=p.url[c];if(d)try{i=d.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+u+(d?" at sn "+d.msn+" part "+d.part:"")+" with URL-id "+c+" "+i),this.clearTimer(),this.hls.trigger(O.Events.LEVEL_LOADING,{url:i,level:u,id:c,deliveryDirectives:d||null})}},o.removeLevel=function(d,u){var p=function(r,t){return t!==u},c=this._levels.filter(function(i,r){return r!==d?!0:i.url.length>1&&u!==void 0?(i.url=i.url.filter(p),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(p)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(p)),i.urlId=0,!0):!1}).map(function(i,r){var t=i.details;return t!=null&&t.fragments&&t.fragments.forEach(function(s){s.level=r}),i});this._levels=c,this.hls.trigger(O.Events.LEVELS_UPDATED,{levels:c})},C(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(d){var u,p=this._levels;if(p.length===0)return;if(this.currentLevelIndex===d&&(u=p[d])!==null&&u!==void 0&&u.details)return;if(d<0||d>=p.length){var c=d<0;if(this.hls.trigger(O.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:d,fatal:c,reason:"invalid level idx"}),c)return;d=Math.min(d,p.length-1)}this.clearTimer();var i=this.currentLevelIndex,r=p[i],t=p[d];this.log("switching to level "+d+" from "+i),this.currentLevelIndex=d;var s=y({},t,{level:d,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete s._urlId,this.hls.trigger(O.Events.LEVEL_SWITCHING,s);var m=t.details;if(!m||m.live){var g=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(g)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(d){this.manualLevelIndex=d,this._startLevel===void 0&&(this._startLevel=d),d!==-1&&(this.level=d)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(d){this._firstLevel=d}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var d=this.hls.config.startLevel;return d!==void 0?d:this._firstLevel}else return this._startLevel},set:function(d){this._startLevel=d}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(d){this.level=d,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=d)}}]),a}(L.default)},"./src/controller/level-helper.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"addGroupId",function(){return A}),S.d(U,"assignTrackIdsByGroup",function(){return _}),S.d(U,"updatePTS",function(){return M}),S.d(U,"updateFragPTSDTS",function(){return w}),S.d(U,"mergeDetails",function(){return y}),S.d(U,"mapPartIntersection",function(){return x}),S.d(U,"mapFragmentIntersection",function(){return C}),S.d(U,"adjustSliding",function(){return E}),S.d(U,"addSliding",function(){return b}),S.d(U,"computeReloadInterval",function(){return v}),S.d(U,"getFragmentWithSN",function(){return h}),S.d(U,"getPartWith",function(){return e});var B=S("./src/polyfills/number.ts"),O=S("./src/utils/logger.ts");function A(a,o,f){switch(o){case"audio":a.audioGroupIds||(a.audioGroupIds=[]),a.audioGroupIds.push(f);break;case"text":a.textGroupIds||(a.textGroupIds=[]),a.textGroupIds.push(f);break}}function _(a){var o={};a.forEach(function(f){var d=f.groupId||"";f.id=o[d]=o[d]||0,o[d]++})}function M(a,o,f){var d=a[o],u=a[f];L(d,u)}function L(a,o){var f=o.startPTS;if(Object(B.isFiniteNumber)(f)){var d=0,u;o.sn>a.sn?(d=f-a.start,u=a):(d=a.start-f,u=o),u.duration!==d&&(u.duration=d)}else if(o.sn>a.sn){var p=a.cc===o.cc;p&&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,f,d,u,p){var c=d-f;c<=0&&(O.logger.warn("Fragment should have a positive duration",o),d=f+o.duration,p=u+o.duration);var i=f,r=d,t=o.startPTS,s=o.endPTS;if(Object(B.isFiniteNumber)(t)){var m=Math.abs(t-f);Object(B.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(m,o.deltaPTS):o.deltaPTS=m,i=Math.max(f,t),f=Math.min(f,t),u=Math.min(u,o.startDTS),r=Math.min(d,s),d=Math.max(d,s),p=Math.max(p,o.endDTS)}o.duration=d-f;var g=f-o.start;o.appendedPTS=d,o.start=o.startPTS=f,o.maxStartPTS=i,o.startDTS=u,o.endPTS=d,o.minEndPTS=r,o.endDTS=p;var T=o.sn;if(!a||T<a.startSN||T>a.endSN)return 0;var P,I=T-a.startSN,F=a.fragments;for(F[I]=o,P=I;P>0;P--)L(F[P],F[P-1]);for(P=I;P<F.length-1;P++)L(F[P],F[P+1]);return a.fragmentHint&&L(F[F.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,g}function y(a,o){for(var f=null,d=a.fragments,u=d.length-1;u>=0;u--){var p=d[u].initSegment;if(p){f=p;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;var c=0,i;if(C(a,o,function(P,I){P.relurl&&(c=P.cc-I.cc),Object(B.isFiniteNumber)(P.startPTS)&&Object(B.isFiniteNumber)(P.endPTS)&&(I.start=I.startPTS=P.startPTS,I.startDTS=P.startDTS,I.appendedPTS=P.appendedPTS,I.maxStartPTS=P.maxStartPTS,I.endPTS=P.endPTS,I.endDTS=P.endDTS,I.minEndPTS=P.minEndPTS,I.duration=P.endPTS-P.startPTS,I.duration&&(i=I),o.PTSKnown=o.alignedSliding=!0),I.elementaryStreams=P.elementaryStreams,I.loader=P.loader,I.stats=P.stats,I.urlId=P.urlId,P.initSegment&&(I.initSegment=P.initSegment,f=P.initSegment)}),f){var r=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;r.forEach(function(P){var I;(!P.initSegment||P.initSegment.relurl===((I=f)===null||I===void 0?void 0:I.relurl))&&(P.initSegment=f)})}if(o.skippedSegments&&(o.deltaUpdateFailed=o.fragments.some(function(P){return!P}),o.deltaUpdateFailed)){O.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var t=o.skippedSegments;t--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}var s=o.fragments;if(c){O.logger.warn("discontinuity sliding from playlist, take drift into account");for(var m=0;m<s.length;m++)s[m].cc+=c}o.skippedSegments&&(o.startCC=o.fragments[0].cc),x(a.partList,o.partList,function(P,I){I.elementaryStreams=P.elementaryStreams,I.stats=P.stats}),i?w(o,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):E(a,o),s.length&&(o.totalduration=o.edge-s[0].start),o.driftStartTime=a.driftStartTime,o.driftStart=a.driftStart;var g=o.advancedDateTime;if(o.advanced&&g){var T=o.edge;o.driftStart||(o.driftStartTime=g,o.driftStart=T),o.driftEndTime=g,o.driftEnd=T}else o.driftEndTime=a.driftEndTime,o.driftEnd=a.driftEnd,o.advancedDateTime=a.advancedDateTime}function x(a,o,f){if(a&&o)for(var d=0,u=0,p=a.length;u<=p;u++){var c=a[u],i=o[u+d];c&&i&&c.index===i.index&&c.fragment.sn===i.fragment.sn?f(c,i):d--}}function C(a,o,f){for(var d=o.skippedSegments,u=Math.max(a.startSN,o.startSN)-o.startSN,p=(a.fragmentHint?1:0)+(d?o.endSN:Math.min(a.endSN,o.endSN))-o.startSN,c=o.startSN-a.startSN,i=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,r=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,t=u;t<=p;t++){var s=r[c+t],m=i[t];d&&!m&&t<d&&(m=o.fragments[t]=s),s&&m&&f(s,m)}}function E(a,o){var f=o.startSN+o.skippedSegments-a.startSN,d=a.fragments;if(f<0||f>=d.length)return;b(o,d[f].start)}function b(a,o){if(o){for(var f=a.fragments,d=a.skippedSegments;d<f.length;d++)f[d].start+=o;a.fragmentHint&&(a.fragmentHint.start+=o)}}function v(a,o){var f=1e3*a.levelTargetDuration,d=f/2,u=a.age,p=u>0&&u<f*3,c=o.loading.end-o.loading.start,i,r=a.availabilityDelay;if(a.updated===!1)if(p){var t=333*a.misses;i=Math.max(Math.min(d,c*2),t),a.availabilityDelay=(a.availabilityDelay||0)+i}else i=d;else p?(r=Math.min(r||f/2,u),a.availabilityDelay=r,i=r+f-u):i=f-c;return Math.round(i)}function h(a,o,f){if(!a||!a.details)return null;var d=a.details,u=d.fragments[o-d.startSN];return u||(u=d.fragmentHint,u&&u.sn===o?u:o<d.startSN&&f&&f.sn===o?f:null)}function e(a,o,f){if(!a||!a.details)return null;var d=a.details.partList;if(d)for(var u=d.length;u--;){var p=d[u];if(p.index===f&&p.fragment.sn===o)return p}return null}},"./src/controller/stream-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return d});var B=S("./src/polyfills/number.ts"),O=S("./src/controller/base-stream-controller.ts"),A=S("./src/is-supported.ts"),_=S("./src/events.ts"),M=S("./src/utils/buffer-helper.ts"),L=S("./src/controller/fragment-tracker.ts"),w=S("./src/types/loader.ts"),y=S("./src/loader/fragment.ts"),x=S("./src/demux/transmuxer-interface.ts"),C=S("./src/types/transmuxer.ts"),E=S("./src/controller/gap-controller.ts"),b=S("./src/errors.ts"),v=S("./src/utils/logger.ts");function h(u,p){for(var c=0;c<p.length;c++){var i=p[c];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(u,i.key,i)}}function e(u,p,c){return p&&h(u.prototype,p),c&&h(u,c),u}function a(u,p){u.prototype=Object.create(p.prototype),u.prototype.constructor=u,o(u,p)}function o(u,p){return o=Object.setPrototypeOf||function(i,r){return i.__proto__=r,i},o(u,p)}var f=100,d=function(u){a(p,u);function p(i,r){var t;return t=u.call(this,i,r,"[stream-controller]")||this,t.audioCodecSwap=!1,t.gapController=null,t.level=-1,t._forceStartLoad=!1,t.altAudio=!1,t.audioOnly=!1,t.fragPlaying=null,t.onvplaying=null,t.onvseeked=null,t.fragLastKbps=0,t.stalled=!1,t.couldBacktrack=!1,t.audioCodecSwitch=!1,t.videoBuffer=null,t._registerListeners(),t}var c=p.prototype;return c._registerListeners=function(){var r=this.hls;r.on(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(_.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(_.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(_.Events.ERROR,this.onError,this),r.on(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(_.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(_.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var r=this.hls;r.off(_.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(_.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(_.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(_.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(_.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(_.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(_.Events.ERROR,this.onError,this),r.off(_.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(_.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(_.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(_.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(_.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(_.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(r){if(this.levels){var t=this.lastCurrentTime,s=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var m=s.startLevel;m===-1&&(s.config.testBandwidth?(m=0,this.bitrateTest=!0):m=s.nextAutoLevel),this.level=s.nextLoadLevel=m,this.loadedmetadata=!1}t>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),r=t),this.state=O.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=O.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,u.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case O.State.IDLE:this.doTickIdle();break;case O.State.WAITING_LEVEL:{var r,t=this.levels,s=this.level,m=t==null||((r=t[s])===null||r===void 0)?void 0:r.details;if(m&&(!m.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(m))break;this.state=O.State.IDLE;break}break}case O.State.FRAG_LOADING_WAITING_RETRY:{var g,T=self.performance.now(),P=this.retryDate;(!P||T>=P||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=O.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){u.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var r,t,s=this.hls,m=this.levelLastLoaded,g=this.levels,T=this.media,P=s.config,I=s.nextLoadLevel;if(m===null||!T&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!g||!g[I])return;var F=g[I];this.level=s.nextLoadLevel=I;var K=F.details;if(!K||this.state===O.State.WAITING_LEVEL||K.live&&this.levelLastLoaded!==I){this.state=O.State.WAITING_LEVEL;return}var V=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:T,w.PlaylistLevelType.MAIN);if(V===null)return;var Q=V.len,Z=this.getMaxBufferLength(F.maxBitrate);if(Q>=Z)return;if(this._streamEnded(V,K)){var ie={};this.altAudio&&(ie.type="video"),this.hls.trigger(_.Events.BUFFER_EOS,ie),this.state=O.State.ENDED;return}var pe=V.end,ae=this.getNextFragment(pe,K);if(this.couldBacktrack&&!this.fragPrevious&&ae&&ae.sn!=="initSegment"){var de=ae.sn-K.startSN;de>1&&(ae=K.fragments[de-1],this.fragmentTracker.removeFragment(ae))}if(ae&&this.fragmentTracker.getState(ae)===L.FragmentState.OK&&this.nextLoadPosition>pe){var le=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(T,le,w.PlaylistLevelType.MAIN),ae=this.getNextFragment(this.nextLoadPosition,K)}if(!ae)return;ae.initSegment&&!ae.initSegment.data&&!this.bitrateTest&&(ae=ae.initSegment),((r=ae.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((t=ae.decryptdata)!==null&&t!==void 0&&t.key)?this.loadKey(ae,K):this.loadFragment(ae,K,pe)},c.loadFragment=function(r,t,s){var m,g=this.fragmentTracker.getState(r);if(this.fragCurrent=r,g===L.FragmentState.BACKTRACKED){var T=this.fragmentTracker.getBacktrackData(r);if(T){this._handleFragmentLoadProgress(T),this._handleFragmentLoadComplete(T);return}else g=L.FragmentState.NOT_LOADED}g===L.FragmentState.NOT_LOADED||g===L.FragmentState.PARTIAL?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(r.bitrateTest=!0,this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,r,t,s)):g===L.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((m=this.media)===null||m===void 0?void 0:m.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(r){var t=this.fragmentTracker.getAppendedFrag(r,w.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},c.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,w.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var r=this.levels,t=this.media;if(t!=null&&t.readyState){var s,m=this.getAppendedFrag(t.currentTime);if(m&&m.start>1&&this.flushMainBuffer(0,m.start-1),!t.paused&&r){var g=this.hls.nextLoadLevel,T=r[g],P=this.fragLastKbps;P&&this.fragCurrent?s=this.fragCurrent.duration*T.maxBitrate/(1e3*P)+1:s=0}else s=0;var I=this.getBufferedFrag(t.currentTime+s);if(I){var F=this.followingBufferedFrag(I);if(F){this.abortCurrentFrag();var K=F.maxStartPTS?F.maxStartPTS:F.start,V=F.duration,Q=Math.max(I.end,K+Math.min(Math.max(V-this.config.maxFragLookUpTolerance,V*.5),V*.75));this.flushMainBuffer(Q,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var r=this.fragCurrent;this.fragCurrent=null,r!=null&&r.loader&&r.loader.abort(),this.state===O.State.KEY_LOADING&&(this.state=O.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(r,t){u.prototype.flushMainBuffer.call(this,r,t,this.altAudio?"video":null)},c.onMediaAttached=function(r,t){u.prototype.onMediaAttached.call(this,r,t);var s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,s,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var r=this.media;r&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),u.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var r=this.media,t=r?r.currentTime:null;Object(B.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(_.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},c.onManifestParsed=function(r,t){var s=!1,m=!1,g;t.levels.forEach(function(T){g=T.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(s=!0),g.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=s&&m&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},c.onLevelLoading=function(r,t){var s=this.levels;if(!s||this.state!==O.State.IDLE)return;var m=s[t.level];(!m.details||m.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(m.details))&&(this.state=O.State.WAITING_LEVEL)},c.onLevelLoaded=function(r,t){var s,m=this.levels,g=t.level,T=t.details,P=T.totalduration;if(!m){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+T.startSN+","+T.endSN+"], cc ["+T.startCC+", "+T.endCC+"] duration:"+P);var I=this.fragCurrent;I&&(this.state===O.State.FRAG_LOADING||this.state===O.State.FRAG_LOADING_WAITING_RETRY)&&(I.level!==t.level&&I.loader&&(this.state=O.State.IDLE,I.loader.abort()));var F=m[g],K=0;if(T.live||(s=F.details)!==null&&s!==void 0&&s.live){if(T.fragments[0]||(T.deltaUpdateFailed=!0),T.deltaUpdateFailed)return;K=this.alignPlaylists(T,F.details)}if(F.details=T,this.levelLastLoaded=g,this.hls.trigger(_.Events.LEVEL_UPDATED,{details:T,level:g}),this.state===O.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(T))return;this.state=O.State.IDLE}this.startFragRequested?T.live&&this.synchronizeToLiveEdge(T):this.setStartPosition(T,K),this.tick()},c._handleFragmentLoadProgress=function(r){var t,s=r.frag,m=r.part,g=r.payload,T=this.levels;if(!T){this.warn("Levels were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var P=T[s.level],I=P.details;if(!I){this.warn("Dropping fragment "+s.sn+" of level "+s.level+" after level details were reset");return}var F=P.videoCodec,K=I.PTSKnown||!I.live,V=(t=s.initSegment)===null||t===void 0?void 0:t.data,Q=this._getAudioCodec(P),Z=this.transmuxer=this.transmuxer||new x.default(this.hls,w.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ie=m?m.index:-1,pe=ie!==-1,ae=new C.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,g.byteLength,ie,pe),de=this.initPTS[s.cc];Z.push(g,V,Q,F,s,m,I.totalduration,K,ae,de)},c.onAudioTrackSwitching=function(r,t){var s=this.altAudio,m=!!t.url,g=t.id;if(!m){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var T=this.fragCurrent;T!=null&&T.loader&&(this.log("Switching to main audio track, cancel main fragment load"),T.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;s&&P.trigger(_.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(_.Events.AUDIO_TRACK_SWITCHED,{id:g})}},c.onAudioTrackSwitched=function(r,t){var s=t.id,m=!!this.hls.audioTracks[s].url;if(m){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=m,this.tick()},c.onBufferCreated=function(r,t){var s=t.tracks,m,g,T=!1;for(var P in s){var I=s[P];if(I.id==="main"){if(g=P,m=I,P==="video"){var F=s[P];F&&(this.videoBuffer=F.buffer)}}else T=!0}T&&m?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=m.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(r,t){var s=t.frag,m=t.part;if(s&&s.type!==w.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(m?" p: "+m.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state),this.state===O.State.PARSED&&(this.state=O.State.IDLE);return}var g=m?m.stats:s.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,m)},c.onError=function(r,t){switch(t.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w.PlaylistLevelType.MAIN,t);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==O.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=O.State.ERROR):!t.levelRetry&&this.state===O.State.WAITING_LEVEL&&(this.state=O.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(t.parent==="main"&&(this.state===O.State.PARSING||this.state===O.State.PARSED)){var s=!0,m=this.getFwdBufferInfo(this.media,w.PlaylistLevelType.MAIN);m&&m.len>.5&&(s=!this.reduceMaxBufferLength(m.len)),s&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var r=this.media,t=this.gapController;if(!r||!t||!r.readyState)return;var s=M.BufferHelper.getBuffered(r);!this.loadedmetadata&&s.length?(this.loadedmetadata=!0,this.seekToStartPos()):t.poll(this.lastCurrentTime),this.lastCurrentTime=r.currentTime},c.onFragLoadEmergencyAborted=function(){this.state=O.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(r,t){var s=t.type;if(s!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var m=(s===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(m,s,w.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(r,t){this.levels=t.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var r=this.media,t=r.currentTime,s=this.startPosition;if(s>=0&&t<s){if(r.seeking){v.logger.log("could not seek to "+s+", already seeking at "+t);return}var m=M.BufferHelper.getBuffered(r),g=m.length?m.start(0):0,T=g-s;T>0&&(T<this.config.maxBufferHole||T<this.config.maxFragLookUpTolerance)&&(v.logger.log("adjusting start position by "+T+" to match buffer start"),s+=T,this.startPosition=s),this.log("seek to target start position "+s+" from current time "+t),r.currentTime=s}},c._getAudioCodec=function(r){var t=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t},c._loadBitrateTestFrag=function(r){var t=this;this._doFragLoad(r).then(function(s){var m=t.hls;if(!s||m.nextLoadLevel||t.fragContextChanged(r))return;t.fragLoadError=0,t.state=O.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var g=r.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),m.trigger(_.Events.FRAG_LOADED,s)})},c._handleTransmuxComplete=function(r){var t,s="main",m=this.hls,g=r.remuxResult,T=r.chunkMeta,P=this.getCurrentContext(T);if(!P){this.warn("The loading context changed while buffering fragment "+T.sn+" of level "+T.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(T.level);return}var I=P.frag,F=P.part,K=P.level,V=g.video,Q=g.text,Z=g.id3,ie=g.initSegment,pe=this.altAudio?void 0:g.audio;if(this.fragContextChanged(I))return;if(this.state=O.State.PARSING,ie){ie.tracks&&(this._bufferInitSegment(K,ie.tracks,I,T),m.trigger(_.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:s,tracks:ie.tracks}));var ae=ie.initPTS,de=ie.timescale;Object(B.isFiniteNumber)(ae)&&(this.initPTS[I.cc]=ae,m.trigger(_.Events.INIT_PTS_FOUND,{frag:I,id:s,initPTS:ae,timescale:de}))}if(V&&g.independent!==!1){if(K.details){var le=V.startPTS,$=V.endPTS,Y=V.startDTS,ne=V.endDTS;if(F)F.elementaryStreams[V.type]={startPTS:le,endPTS:$,startDTS:Y,endDTS:ne};else if(V.firstKeyFrame&&V.independent&&(this.couldBacktrack=!0),V.dropped&&V.independent){var z=this.getLoadPosition()+this.config.maxBufferHole;if(z<le){this.backtrack(I);return}I.setElementaryStreamInfo(V.type,I.start,$,I.start,ne,!0)}I.setElementaryStreamInfo(V.type,le,$,Y,ne),this.bufferFragmentData(V,I,F,T)}}else if(g.independent===!1){this.backtrack(I);return}if(pe){var H=pe.startPTS,me=pe.endPTS,Le=pe.startDTS,Oe=pe.endDTS;F&&(F.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:H,endPTS:me,startDTS:Le,endDTS:Oe}),I.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,H,me,Le,Oe),this.bufferFragmentData(pe,I,F,T)}if(Z!=null&&(t=Z.samples)!==null&&t!==void 0&&t.length){var Ae={frag:I,id:s,samples:Z.samples};m.trigger(_.Events.FRAG_PARSING_METADATA,Ae)}if(Q){var Re={frag:I,id:s,samples:Q.samples};m.trigger(_.Events.FRAG_PARSING_USERDATA,Re)}},c._bufferInitSegment=function(r,t,s,m){var g=this;if(this.state!==O.State.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var T=t.audio,P=t.video,I=t.audiovideo;if(T){var F=r.audioCodec,K=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),T.metadata.channelCount!==1&&K.indexOf("firefox")===-1&&(F="mp4a.40.5")),K.indexOf("android")!==-1&&T.container!=="audio/mpeg"&&(F="mp4a.40.2",this.log("Android: force audio codec to "+F)),r.audioCodec&&r.audioCodec!==F&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+F+'"'),T.levelCodec=F,T.id="main",this.log("Init audio buffer, container:"+T.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(r.audioCodec||"")+"/"+T.codec+"]")}P&&(P.levelCodec=r.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+P.codec+"]")),I&&this.log("Init audiovideo buffer, container:"+I.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+I.codec+"]"),this.hls.trigger(_.Events.BUFFER_CODECS,t),Object.keys(t).forEach(function(V){var Q=t[V],Z=Q.initSegment;Z!=null&&Z.byteLength&&g.hls.trigger(_.Events.BUFFER_APPENDING,{type:V,data:Z,frag:s,part:null,chunkMeta:m,parent:s.type})}),this.tick()},c.backtrack=function(r){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(r);var t=this.fragmentTracker.backtrack(r);this.fragPrevious=null,this.nextLoadPosition=r.start,t?this.resetFragmentLoading(r):this.state=O.State.BACKTRACKING},c.checkFragmentChanged=function(){var r=this.media,t=null;if(r&&r.readyState>1&&r.seeking===!1){var s=r.currentTime;if(M.BufferHelper.isBuffered(r,s)?t=this.getAppendedFrag(s):M.BufferHelper.isBuffered(r,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){var m=this.fragPlaying,g=t.level;(!m||t.sn!==m.sn||m.level!==g||t.urlId!==m.urlId)&&(this.hls.trigger(_.Events.FRAG_CHANGED,{frag:t}),(!m||m.level!==g)&&this.hls.trigger(_.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=t)}}},e(p,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentLevel",get:function(){var r=this.media;if(r){var t=this.getAppendedFrag(r.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var r=this.media;if(r){var t=this.getAppendedFrag(r.currentTime);return this.followingBufferedFrag(t)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),p}(O.default)},"./src/controller/subtitle-stream-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"SubtitleStreamController",function(){return a});var B=S("./src/events.ts"),O=S("./src/utils/logger.ts"),A=S("./src/utils/buffer-helper.ts"),_=S("./src/controller/fragment-finders.ts"),M=S("./src/utils/discontinuities.ts"),L=S("./src/controller/level-helper.ts"),w=S("./src/controller/fragment-tracker.ts"),y=S("./src/controller/base-stream-controller.ts"),x=S("./src/types/loader.ts"),C=S("./src/types/level.ts");function E(o,f){for(var d=0;d<f.length;d++){var u=f[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(o,u.key,u)}}function b(o,f,d){return f&&E(o.prototype,f),d&&E(o,d),o}function v(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,h(o,f)}function h(o,f){return h=Object.setPrototypeOf||function(u,p){return u.__proto__=p,u},h(o,f)}var e=500,a=function(o){v(f,o);function f(u,p){var c;return c=o.call(this,u,p,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var d=f.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var p=this.hls;p.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(B.Events.ERROR,this.onError,this),p.on(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.on(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.on(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},d._unregisterListeners=function(){var p=this.hls;p.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(B.Events.ERROR,this.onError,this),p.off(B.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.off(B.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.off(B.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.off(B.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},d.startLoad=function(){this.stopLoad(),this.state=y.State.IDLE,this.setInterval(e),this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},d.onLevelLoaded=function(p,c){this.mainDetails=c.details},d.onSubtitleFragProcessed=function(p,c){var i=c.frag,r=c.success;if(this.fragPrevious=i,this.state=y.State.IDLE,!r)return;var t=this.tracksBuffered[this.currentTrackId];if(!t)return;for(var s,m=i.start,g=0;g<t.length;g++)if(m>=t[g].start&&m<=t[g].end){s=t[g];break}var T=i.start+i.duration;s?s.end=T:(s={start:m,end:T},t.push(s)),this.fragmentTracker.fragBuffered(i)},d.onBufferFlushing=function(p,c){var i=c.startOffset,r=c.endOffset;if(i===0&&r!==Number.POSITIVE_INFINITY){var t=this.currentTrackId,s=this.levels;if(!s.length||!s[t]||!s[t].details)return;var m=s[t].details,g=m.targetduration,T=r-g;if(T<=0)return;c.endOffsetSubtitles=Math.max(0,T),this.tracksBuffered.forEach(function(P){for(var I=0;I<P.length;){if(P[I].end<=T){P.shift();continue}else if(P[I].start<T)P[I].start=T;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(i,T,x.PlaylistLevelType.SUBTITLE)}},d.onError=function(p,c){var i,r=c.frag;if(!r||r.type!==x.PlaylistLevelType.SUBTITLE)return;(i=this.fragCurrent)!==null&&i!==void 0&&i.loader&&this.fragCurrent.loader.abort(),this.state=y.State.IDLE},d.onSubtitleTracksUpdated=function(p,c){var i=this,r=c.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(t){return new C.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){i.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},d.onSubtitleTrackSwitch=function(p,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(e)},d.onSubtitleTrackLoaded=function(p,c){var i,r=c.details,t=c.id,s=this.currentTrackId,m=this.levels;if(!m.length)return;var g=m[s];if(t>=m.length||t!==s||!g)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||(i=g.details)!==null&&i!==void 0&&i.live){var T=this.mainDetails;if(r.deltaUpdateFailed||!T)return;var P=T.fragments[0];if(!g.details)r.hasProgramDateTime&&T.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(r,T):P&&Object(L.addSliding)(r,P.start);else{var I=this.alignPlaylists(r,g.details);I===0&&P&&Object(L.addSliding)(r,P.start)}}if(g.details=r,this.levelLastLoaded=t,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===y.State.IDLE){var F=Object(_.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}},d._handleFragmentLoadComplete=function(p){var c=p.frag,i=p.payload,r=c.decryptdata,t=this.hls;if(this.fragContextChanged(c))return;if(i&&i.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).then(function(m){var g=performance.now();t.trigger(B.Events.FRAG_DECRYPTED,{frag:c,payload:m,stats:{tstart:s,tdecrypt:g}})})}},d.doTick=function(){if(!this.media){this.state=y.State.IDLE;return}if(this.state===y.State.IDLE){var p,c=this.currentTrackId,i=this.levels;if(!i.length||!i[c]||!i[c].details)return;var r=i[c].details,t=r.targetduration,s=this.config,m=this.media,g=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,m.currentTime-t,s.maxBufferHole),T=g.end,P=g.len,I=this.getMaxBufferLength()+t;if(P>I)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var F=r.fragments,K=F.length,V=r.edge,Q,Z=this.fragPrevious;if(T<V){var ie=s.maxFragLookUpTolerance;Z&&r.hasProgramDateTime&&(Q=Object(_.findFragmentByPDT)(F,Z.endProgramDateTime,ie)),Q||(Q=Object(_.findFragmentByPTS)(Z,F,T,ie),!Q&&Z&&Z.start<F[0].start&&(Q=F[0]))}else Q=F[K-1];(p=Q)!==null&&p!==void 0&&p.encrypted?(O.logger.log("Loading key for "+Q.sn),this.state=y.State.KEY_LOADING,this.hls.trigger(B.Events.KEY_LOADING,{frag:Q})):Q&&this.fragmentTracker.getState(Q)===w.FragmentState.NOT_LOADED&&this.loadFragment(Q,r,T)}},d.loadFragment=function(p,c,i){this.fragCurrent=p,o.prototype.loadFragment.call(this,p,c,i)},b(f,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),f}(y.default)},"./src/controller/subtitle-track-controller.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/events.ts"),O=S("./src/utils/texttrack-utils.ts"),A=S("./src/controller/base-playlist-controller.ts"),_=S("./src/types/loader.ts");function M(E,b){for(var v=0;v<b.length;v++){var h=b[v];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(E,h.key,h)}}function L(E,b,v){return b&&M(E.prototype,b),v&&M(E,v),E}function w(E,b){E.prototype=Object.create(b.prototype),E.prototype.constructor=E,y(E,b)}function y(E,b){return y=Object.setPrototypeOf||function(h,e){return h.__proto__=e,h},y(E,b)}var x=function(E){w(b,E);function b(h){var e;return e=E.call(this,h,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e.subtitleDisplay=!0,e.registerListeners(),e}var v=b.prototype;return v.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},v.registerListeners=function(){var e=this.hls;e.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(B.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var e=this.hls;e.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(B.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(B.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(B.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(B.Events.ERROR,this.onError,this)},v.onMediaAttached=function(e,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)},v.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},v.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 e=C(this.media.textTracks);e.forEach(function(a){Object(O.clearCurrentCues)(a)}),this.subtitleTrack=-1,this.media=null},v.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},v.onManifestParsed=function(e,a){this.tracks=a.subtitleTracks},v.onSubtitleTrackLoaded=function(e,a){var o=a.id,f=a.details,d=this.trackId,u=this.tracksInGroup[d];if(!u){this.warn("Invalid subtitle track id "+o);return}var p=u.details;u.details=a.details,this.log("subtitle track "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,a,p))},v.onLevelLoading=function(e,a){this.switchLevel(a.level)},v.onLevelSwitching=function(e,a){this.switchLevel(a.level)},v.switchLevel=function(e){var a=this.hls.levels[e];if(!(a!=null&&a.textGroupIds))return;var o=a.textGroupIds[a.urlId];if(this.groupId!==o){var f=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,d=this.tracks.filter(function(c){return!o||c.groupId===o});this.tracksInGroup=d;var u=this.findTrackId(f==null?void 0:f.name)||this.findTrackId();this.groupId=o;var p={subtitleTracks:d};this.log("Updating subtitle tracks, "+d.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(B.Events.SUBTITLE_TRACKS_UPDATED,p),u!==-1&&this.setSubtitleTrack(u,f)}},v.findTrackId=function(e){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var f=a[o];if((!this.selectDefaultTrack||f.default)&&(!e||e===f.name))return f.id}return-1},v.onError=function(e,a){if(E.prototype.onError.call(this,e,a),a.fatal||!a.context)return;a.context.type===_.PlaylistContextType.SUBTITLE_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},v.loadPlaylist=function(e){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var o=a.id,f=a.groupId,d=a.url;if(e)try{d=e.addDirectives(d)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(B.Events.SUBTITLE_TRACK_LOADING,{url:d,id:o,groupId:f,deliveryDirectives:e||null})}},v.toggleTrackModes=function(e){var a=this,o=this.media,f=this.subtitleDisplay,d=this.trackId;if(!o)return;var u=C(o.textTracks),p=u.filter(function(r){return r.groupId===a.groupId});if(e===-1)[].slice.call(u).forEach(function(r){r.mode="disabled"});else{var c=p[d];c&&(c.mode="disabled")}var i=p[e];i&&(i.mode=f?"showing":"hidden")},v.setSubtitleTrack=function(e,a){var o,f=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(o=f[e])!==null&&o!==void 0&&o.details)||e<-1||e>=f.length)return;this.clearTimer();var d=f[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,d){var u=d.id,p=d.groupId,c=p===void 0?"":p,i=d.name,r=d.type,t=d.url;this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:u,groupId:c,name:i,type:r,url:t});var s=this.switchParams(d.url,a==null?void 0:a.details);this.loadPlaylist(s)}else this.hls.trigger(B.Events.SUBTITLE_TRACK_SWITCH,{id:e})},v.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var e=-1,a=C(this.media.textTracks),o=0;o<a.length;o++)if(a[o].mode==="hidden")e=o;else if(a[o].mode==="showing"){e=o;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)},L(b,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,a)}}]),b}(A.default);function C(E){for(var b=[],v=0;v<E.length;v++){var h=E[v];h.kind==="subtitles"&&h.label&&b.push(E[v])}return b}U.default=x},"./src/controller/timeline-controller.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"TimelineController",function(){return C});var B=S("./src/polyfills/number.ts"),O=S("./src/events.ts"),A=S("./src/utils/cea-608-parser.ts"),_=S("./src/utils/output-filter.ts"),M=S("./src/utils/webvtt-parser.ts"),L=S("./src/utils/texttrack-utils.ts"),w=S("./src/utils/imsc1-ttml-parser.ts"),y=S("./src/types/loader.ts"),x=S("./src/utils/logger.ts"),C=function(){function h(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=v(),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 _.default(this,"textTrack1"),f=new _.default(this,"textTrack2"),d=new _.default(this,"textTrack3"),u=new _.default(this,"textTrack4");this.cea608Parser1=new A.default(1,o,f),this.cea608Parser2=new A.default(3,d,u)}a.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.on(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),a.on(O.Events.FRAG_LOADING,this.onFragLoading,this),a.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),a.on(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),a.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),a.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=h.prototype;return e.destroy=function(){var o=this.hls;o.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.off(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(O.Events.FRAG_LOADING,this.onFragLoading,this),o.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(O.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.off(O.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.off(O.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(o,f,d,u,p){for(var c=!1,i=p.length;i--;){var r=p[i],t=b(r[0],r[1],f,d);if(t>=0&&(r[0]=Math.min(r[0],f),r[1]=Math.max(r[1],d),c=!0,t/(d-f)>.5))return}if(c||p.push([f,d]),this.config.renderTextTracksNatively){var s=this.captionsTracks[o];this.Cues.newCue(s,f,d,u)}else{var m=this.Cues.newCue(null,f,d,u);this.hls.trigger(O.Events.CUES_PARSED,{type:"captions",cues:m,track:o})}},e.onInitPtsFound=function(o,f){var d=this,u=f.frag,p=f.id,c=f.initPTS,i=f.timescale,r=this.unparsedVttFrags;p==="main"&&(this.initPTS[u.cc]=c,this.timescale[u.cc]=i),r.length&&(this.unparsedVttFrags=[],r.forEach(function(t){d.onFragLoaded(O.Events.FRAG_LOADED,t)}))},e.getExistingTrack=function(o){var f=this.media;if(f)for(var d=0;d<f.textTracks.length;d++){var u=f.textTracks[d];if(u[o])return u}return null},e.createCaptionsTrack=function(o){this.config.renderTextTracksNatively?this.createNativeTrack(o):this.createNonNativeTrack(o)},e.createNativeTrack=function(o){if(this.captionsTracks[o])return;var f=this.captionsProperties,d=this.captionsTracks,u=this.media,p=f[o],c=p.label,i=p.languageCode,r=this.getExistingTrack(o);if(r)d[o]=r,Object(L.clearCurrentCues)(d[o]),Object(L.sendAddTrackEvent)(d[o],u);else{var t=this.createTextTrack("captions",c,i);t&&(t[o]=!0,d[o]=t)}},e.createNonNativeTrack=function(o){if(this.nonNativeCaptionsTracks[o])return;var f=this.captionsProperties[o];if(!f)return;var d=f.label,u={_id:o,label:d,kind:"captions",default:f.media?!!f.media.default:!1,closedCaptions:f.media};this.nonNativeCaptionsTracks[o]=u,this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})},e.createTextTrack=function(o,f,d){var u=this.media;return u?u.addTextTrack(o,f,d):void 0},e.onMediaAttaching=function(o,f){this.media=f.media,this._cleanTracks()},e.onMediaDetaching=function(){var o=this.captionsTracks;Object.keys(o).forEach(function(f){Object(L.clearCurrentCues)(o[f]),delete o[f]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=v(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function(){var o=this.media;if(!o)return;var f=o.textTracks;if(f)for(var d=0;d<f.length;d++)Object(L.clearCurrentCues)(f[d])},e.onSubtitleTracksUpdated=function(o,f){var d=this;this.textTracks=[];var u=f.subtitleTracks||[],p=u.some(function(t){return t.textCodec===w.IMSC1_CODEC});if(this.config.enableWebVTT||p&&this.config.enableIMSC1){var c=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var i=this.media?this.media.textTracks:[];this.tracks.forEach(function(t,s){var m;if(s<i.length){for(var g=null,T=0;T<i.length;T++)if(E(i[T],t)){g=i[T];break}g&&(m=g)}m?Object(L.clearCurrentCues)(m):(m=d.createTextTrack("subtitles",t.name,t.lang),m&&(m.mode="disabled")),m&&(m.groupId=t.groupId,d.textTracks.push(m))})}else if(!c&&this.tracks&&this.tracks.length){var r=this.tracks.map(function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}});this.hls.trigger(O.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r})}}},e.onManifestLoaded=function(o,f){var d=this;this.config.enableCEA708Captions&&f.captions&&f.captions.forEach(function(u){var p=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!p)return;var c="textTrack"+p[1],i=d.captionsProperties[c];if(!i)return;i.label=u.name,u.lang&&(i.languageCode=u.lang),i.media=u})},e.onFragLoading=function(o,f){var d=this.cea608Parser1,u=this.cea608Parser2,p=this.lastSn,c=this.lastPartIndex;if(!this.enabled||!(d&&u))return;if(f.frag.type===y.PlaylistLevelType.MAIN){var i,r,t=f.frag.sn,s=(i=f==null||((r=f.part)===null||r===void 0)?void 0:r.index)!=null?i:-1;t===p+1||t===p&&s===c+1||(d.reset(),u.reset()),this.lastSn=t,this.lastPartIndex=s}},e.onFragLoaded=function(o,f){var d=f.frag,u=f.payload,p=this.initPTS,c=this.unparsedVttFrags;if(d.type===y.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!Object(B.isFiniteNumber)(p[d.cc])){c.push(f),p.length&&this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Missing initial subtitle PTS")});return}var i=d.decryptdata;if(i==null||i.key==null||i.method!=="AES-128"){var r=this.tracks[d.level],t=this.vttCCs;t[d.cc]||(t[d.cc]={start:d.start,prevCC:this.prevCC,new:!0},this.prevCC=d.cc),r&&r.textCodec===w.IMSC1_CODEC?this._parseIMSC1(d,u):this._parseVTTs(d,u,t)}}else this.hls.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(o,f){var d=this,u=this.hls;Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(p){d._appendCues(p,o.level),u.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(p){x.logger.log("Failed to parse IMSC1: "+p),u.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:p})})},e._parseVTTs=function(o,f,d){var u=this,p=this.hls;Object(M.parseWebVTT)(f,this.initPTS[o.cc],this.timescale[o.cc],d,o.cc,o.start,function(c){u._appendCues(c,o.level),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(c){u._fallbackToIMSC1(o,f),x.logger.log("Failed to parse VTT cue: "+c),p.trigger(O.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:c})})},e._fallbackToIMSC1=function(o,f){var d=this,u=this.tracks[o.level];u.textCodec||Object(w.parseIMSC1)(f,this.initPTS[o.cc],this.timescale[o.cc],function(){u.textCodec=w.IMSC1_CODEC,d._parseIMSC1(o,f)},function(){u.textCodec="wvtt"})},e._appendCues=function(o,f){var d=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[f];if(u.mode==="disabled")return;o.forEach(function(i){return Object(L.addCueToTrack)(u,i)})}else{var p=this.tracks[f],c=p.default?"default":"subtitles"+f;d.trigger(O.Events.CUES_PARSED,{type:"subtitles",cues:o,track:c})}},e.onFragDecrypted=function(o,f){var d=f.frag;if(d.type===y.PlaylistLevelType.SUBTITLE){if(!Object(B.isFiniteNumber)(this.initPTS[d.cc])){this.unparsedVttFrags.push(f);return}this.onFragLoaded(O.Events.FRAG_LOADED,f)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(o,f){var d=this.cea608Parser1,u=this.cea608Parser2;if(!this.enabled||!(d&&u))return;for(var p=0;p<f.samples.length;p++){var c=f.samples[p].bytes;if(c){var i=this.extractCea608Data(c);d.addData(f.samples[p].pts,i[0]),u.addData(f.samples[p].pts,i[1])}}},e.onBufferFlushing=function(o,f){var d=f.startOffset,u=f.endOffset,p=f.endOffsetSubtitles,c=f.type,i=this.media;if(!i||i.currentTime<u)return;if(!c||c==="video"){var r=this.captionsTracks;Object.keys(r).forEach(function(s){return Object(L.removeCuesInRange)(r[s],d,u)})}if(this.config.renderTextTracksNatively&&(d===0&&p!==void 0)){var t=this.textTracks;Object.keys(t).forEach(function(s){return Object(L.removeCuesInRange)(t[s],d,p)})}},e.extractCea608Data=function(o){for(var f=o[0]&31,d=2,u=[[],[]],p=0;p<f;p++){var c=o[d++],i=127&o[d++],r=127&o[d++],t=(4&c)!==0,s=3&c;if(i===0&&r===0)continue;t&&((s===0||s===1)&&(u[s].push(i),u[s].push(r)))}return u},h}();function E(h,e){return h&&h.label===e.name&&!(h.textTrack1||h.textTrack2)}function b(h,e,a,o){return Math.min(e,o)-Math.max(h,a)}function v(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return B});var B=function(){function O(_,M){this.subtle=void 0,this.aesIV=void 0,this.subtle=_,this.aesIV=M}var A=O.prototype;return A.decrypt=function(M,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,M)},O}()},"./src/crypt/aes-decryptor.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"removePadding",function(){return O}),S.d(U,"default",function(){return A});var B=S("./src/utils/typed-array.ts");function O(_){var M=_.byteLength,L=M&&new DataView(_.buffer).getUint8(M-1);return L?Object(B.sliceUint8)(_,0,M-L):_}var A=function(){function _(){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=_.prototype;return M.uint8ArrayToUint32Array_=function(w){for(var y=new DataView(w),x=new Uint32Array(4),C=0;C<4;C++)x[C]=y.getUint32(C*4);return x},M.initTable=function(){var w=this.sBox,y=this.invSBox,x=this.subMix,C=x[0],E=x[1],b=x[2],v=x[3],h=this.invSubMix,e=h[0],a=h[1],o=h[2],f=h[3],d=new Uint32Array(256),u=0,p=0,c=0;for(c=0;c<256;c++)c<128?d[c]=c<<1:d[c]=c<<1^283;for(c=0;c<256;c++){var i=p^p<<1^p<<2^p<<3^p<<4;i=i>>>8^i&255^99,w[u]=i,y[i]=u;var r=d[u],t=d[r],s=d[t],m=d[i]*257^i*16843008;C[u]=m<<24|m>>>8,E[u]=m<<16|m>>>16,b[u]=m<<8|m>>>24,v[u]=m,m=s*16843009^t*65537^r*257^u*16843008,e[i]=m<<24|m>>>8,a[i]=m<<16|m>>>16,o[i]=m<<8|m>>>24,f[i]=m,u?(u=r^d[d[d[s^r]]],p^=d[d[p]]):u=p=1}},M.expandKey=function(w){for(var y=this.uint8ArrayToUint32Array_(w),x=!0,C=0;C<y.length&&x;)x=y[C]===this.key[C],C++;if(x)return;this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var b=this.ksRows=(E+6+1)*4,v,h,e=this.keySchedule=new Uint32Array(b),a=this.invKeySchedule=new Uint32Array(b),o=this.sBox,f=this.rcon,d=this.invSubMix,u=d[0],p=d[1],c=d[2],i=d[3],r,t;for(v=0;v<b;v++){if(v<E){r=e[v]=y[v];continue}t=r,v%E===0?(t=t<<8|t>>>24,t=o[t>>>24]<<24|o[t>>>16&255]<<16|o[t>>>8&255]<<8|o[t&255],t^=f[v/E|0]<<24):E>6&&v%E===4&&(t=o[t>>>24]<<24|o[t>>>16&255]<<16|o[t>>>8&255]<<8|o[t&255]),e[v]=r=(e[v-E]^t)>>>0}for(h=0;h<b;h++)v=b-h,h&3?t=e[v]:t=e[v-4],h<4||v<=4?a[h]=t:a[h]=u[o[t>>>24]]^p[o[t>>>16&255]]^c[o[t>>>8&255]]^i[o[t&255]],a[h]=a[h]>>>0},M.networkToHostOrderSwap=function(w){return w<<24|(w&65280)<<8|(w&16711680)>>8|w>>>24},M.decrypt=function(w,y,x){for(var C=this.keySize+6,E=this.invKeySchedule,b=this.invSBox,v=this.invSubMix,h=v[0],e=v[1],a=v[2],o=v[3],f=this.uint8ArrayToUint32Array_(x),d=f[0],u=f[1],p=f[2],c=f[3],i=new Int32Array(w),r=new Int32Array(i.length),t,s,m,g,T,P,I,F,K,V,Q,Z,ie,pe,ae=this.networkToHostOrderSwap;y<i.length;){for(K=ae(i[y]),V=ae(i[y+1]),Q=ae(i[y+2]),Z=ae(i[y+3]),T=K^E[0],P=Z^E[1],I=Q^E[2],F=V^E[3],ie=4,pe=1;pe<C;pe++)t=h[T>>>24]^e[P>>16&255]^a[I>>8&255]^o[F&255]^E[ie],s=h[P>>>24]^e[I>>16&255]^a[F>>8&255]^o[T&255]^E[ie+1],m=h[I>>>24]^e[F>>16&255]^a[T>>8&255]^o[P&255]^E[ie+2],g=h[F>>>24]^e[T>>16&255]^a[P>>8&255]^o[I&255]^E[ie+3],T=t,P=s,I=m,F=g,ie=ie+4;t=b[T>>>24]<<24^b[P>>16&255]<<16^b[I>>8&255]<<8^b[F&255]^E[ie],s=b[P>>>24]<<24^b[I>>16&255]<<16^b[F>>8&255]<<8^b[T&255]^E[ie+1],m=b[I>>>24]<<24^b[F>>16&255]<<16^b[T>>8&255]<<8^b[P&255]^E[ie+2],g=b[F>>>24]<<24^b[T>>16&255]<<16^b[P>>8&255]<<8^b[I&255]^E[ie+3],r[y]=ae(t^d),r[y+1]=ae(g^u),r[y+2]=ae(m^p),r[y+3]=ae(s^c),d=K,u=V,p=Q,c=Z,y=y+4}return r.buffer},_}()},"./src/crypt/decrypter.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return y});var B=S("./src/crypt/aes-crypto.ts"),O=S("./src/crypt/fast-aes-key.ts"),A=S("./src/crypt/aes-decryptor.ts"),_=S("./src/utils/logger.ts"),M=S("./src/utils/mp4-tools.ts"),L=S("./src/utils/typed-array.ts"),w=16,y=function(){function x(E,b,v){var h=v===void 0?{}:v,e=h.removePKCS7Padding,a=e===void 0?!0:e;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=E,this.config=b,this.removePKCS7Padding=a,a)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(f){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var C=x.prototype;return C.destroy=function(){this.observer=null},C.isSync=function(){return this.config.enableSoftwareAES},C.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var v=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(v):v},C.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},C.decrypt=function(b,v,h,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),v,h);var a=this.flush();a&&e(a.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),v,h).then(e)},C.softwareDecrypt=function(b,v,h){var e=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(b=Object(M.appendUint8Array)(o,b),this.remainderData=null);var f=this.getValidChunk(b);if(!f.length)return null;e&&(h=e);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new A.default),d.expandKey(v);var u=a;return this.currentResult=d.decrypt(f.buffer,0,h),this.currentIV=Object(L.sliceUint8)(f,-16).buffer,u||null},C.webCryptoDecrypt=function(b,v,h){var e=this,a=this.subtle;return(this.key!==v||!this.fastAesKey)&&(this.key=v,this.fastAesKey=new O.default(a,v)),this.fastAesKey.expandKey().then(function(o){if(!a)return Promise.reject(new Error("web crypto not initialized"));var f=new B.default(a,h);return f.decrypt(b.buffer,o)}).catch(function(o){return e.onWebCryptoError(o,b,v,h)})},C.onWebCryptoError=function(b,v,h,e){return _.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(v,h,e)},C.getValidChunk=function(b){var v=b,h=b.length-b.length%w;return h!==b.length&&(v=Object(L.sliceUint8)(b,0,h),this.remainderData=Object(L.sliceUint8)(b,h)),v},C.logOnce=function(b){if(!this.logEnabled)return;_.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1},x}()},"./src/crypt/fast-aes-key.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return B});var B=function(){function O(_,M){this.subtle=void 0,this.key=void 0,this.subtle=_,this.key=M}var A=O.prototype;return A.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},O}()},"./src/demux/aacdemuxer.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/demux/base-audio-demuxer.ts"),O=S("./src/demux/adts.ts"),A=S("./src/utils/logger.ts"),_=S("./src/demux/id3.ts");function M(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,L(y,x)}function L(y,x){return L=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},L(y,x)}var w=function(y){M(x,y);function x(E,b){var v;return v=y.call(this)||this,v.observer=void 0,v.config=void 0,v.observer=E,v.config=b,v}var C=x.prototype;return C.resetInitSegment=function(b,v,h){y.prototype.resetInitSegment.call(this,b,v,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:h,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var v=_.getID3Data(b,0)||[],h=v.length,e=b.length;h<e;h++)if(O.probe(b,h))return A.logger.log("ADTS sync word found !"),!0;return!1},C.canParse=function(b,v){return O.canParse(b,v)},C.appendFrame=function(b,v,h){O.initTrackConfig(b,this.observer,v,h,b.manifestCodec);var e=O.appendFrame(b,v,h,this.initPTS,this.frameIndex);if(e&&e.missing===0)return e},x}(B.default);w.minProbeByteLength=9,U.default=w},"./src/demux/adts.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"getAudioConfig",function(){return _}),S.d(U,"isHeaderPattern",function(){return M}),S.d(U,"getHeaderLength",function(){return L}),S.d(U,"getFullFrameLength",function(){return w}),S.d(U,"canGetFrameLength",function(){return y}),S.d(U,"isHeader",function(){return x}),S.d(U,"canParse",function(){return C}),S.d(U,"probe",function(){return E}),S.d(U,"initTrackConfig",function(){return b}),S.d(U,"getFrameDuration",function(){return v}),S.d(U,"parseFrameHeader",function(){return h}),S.d(U,"appendFrame",function(){return e});var B=S("./src/utils/logger.ts"),O=S("./src/errors.ts"),A=S("./src/events.ts");function _(a,o,f,d){var u,p,c,i,r=navigator.userAgent.toLowerCase(),t=d,s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=((o[f+2]&192)>>>6)+1;var m=(o[f+2]&60)>>>2;if(m>s.length-1){a.trigger(A.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+m});return}return c=(o[f+2]&1)<<2,c|=(o[f+3]&192)>>>6,B.logger.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+m),/firefox/i.test(r)?m>=6?(u=5,i=new Array(4),p=m-3):(u=2,i=new Array(2),p=m):r.indexOf("android")!==-1?(u=2,i=new Array(2),p=m):(u=5,i=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&m>=6?p=m-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(m>=6&&c===1||/vivaldi/i.test(r))||!d&&c===1)&&(u=2,i=new Array(2)),p=m)),i[0]=u<<3,i[0]|=(m&14)>>1,i[1]|=(m&1)<<7,i[1]|=c<<3,u===5&&(i[1]|=(p&14)>>1,i[2]=(p&1)<<7,i[2]|=2<<2,i[3]=0),{config:i,samplerate:s[m],channelCount:c,codec:"mp4a.40."+u,manifestCodec:t}}function M(a,o){return a[o]===255&&(a[o+1]&246)===240}function L(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 y(a,o){return o+5<a.length}function x(a,o){return o+1<a.length&&M(a,o)}function C(a,o){return y(a,o)&&M(a,o)&&w(a,o)<=a.length-o}function E(a,o){if(x(a,o)){var f=L(a,o);if(o+f>=a.length)return!1;var d=w(a,o);if(d<=f)return!1;var u=o+d;return u===a.length||x(a,u)}return!1}function b(a,o,f,d,u){if(!a.samplerate){var p=_(o,f,d,u);if(!p)return;a.config=p.config,a.samplerate=p.samplerate,a.channelCount=p.channelCount,a.codec=p.codec,a.manifestCodec=p.manifestCodec,B.logger.log("parsed codec:"+a.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function v(a){return 1024*9e4/a}function h(a,o,f,d,u){var p=L(a,o),c=w(a,o);if(c-=p,c>0){var i=f+d*u;return{headerLength:p,frameLength:c,stamp:i}}}function e(a,o,f,d,u){var p=v(a.samplerate),c=h(o,f,d,u,p);if(c){var i=c.frameLength,r=c.headerLength,t=c.stamp,s=r+i,m=Math.max(0,f+s-o.length),g;m?(g=new Uint8Array(s-r),g.set(o.subarray(f+r,o.length),0)):g=o.subarray(f+r,f+s);var T={unit:g,pts:t};return m||a.samples.push(T),{sample:T,length:s,missing:m}}}},"./src/demux/base-audio-demuxer.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"initPTSFn",function(){return w});var B=S("./src/polyfills/number.ts"),O=S("./src/demux/id3.ts"),A=S("./src/demux/dummy-demuxed-track.ts"),_=S("./src/utils/mp4-tools.ts"),M=S("./src/utils/typed-array.ts"),L=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var x=y.prototype;return x.resetInitSegment=function(E,b,v){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},x.resetTimeStamp=function(){},x.resetContiguity=function(){},x.canParse=function(E,b){return!1},x.appendFrame=function(E,b,v){},x.demux=function(E,b){this.cachedData&&(E=Object(_.appendUint8Array)(this.cachedData,E),this.cachedData=null);var v=O.getID3Data(E,0),h=v?v.length:0,e,a,o=this._audioTrack,f=this._id3Track,d=v?O.getTimeStamp(v):void 0,u=E.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=w(d,b)),v&&v.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:v}),a=this.initPTS;h<u;){if(this.canParse(E,h)){var p=this.appendFrame(o,E,h);p?(this.frameIndex++,a=p.sample.pts,h+=p.length,e=h):h=u}else O.canParse(E,h)?(v=O.getID3Data(E,h),f.samples.push({pts:a,dts:a,data:v}),h+=v.length,e=h):h++;if(h===u&&e!==u){var c=Object(M.sliceUint8)(E,e);this.cachedData?this.cachedData=Object(_.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:o,avcTrack:Object(A.dummyTrack)(),id3Track:f,textTrack:Object(A.dummyTrack)()}},x.demuxSampleAes=function(E,b,v){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},x.flush=function(E){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(A.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(A.dummyTrack)()}},x.destroy=function(){},y}(),w=function(x,C){return Object(B.isFiniteNumber)(x)?x*90:C*9e4};U.default=L},"./src/demux/chunk-cache.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return B});var B=function(){function A(){this.chunks=[],this.dataLength=0}var _=A.prototype;return _.push=function(L){this.chunks.push(L),this.dataLength+=L.length},_.flush=function(){var L=this.chunks,w=this.dataLength,y;if(L.length)L.length===1?y=L[0]:y=O(L,w);else return new Uint8Array(0);return this.reset(),y},_.reset=function(){this.chunks.length=0,this.dataLength=0},A}();function O(A,_){for(var M=new Uint8Array(_),L=0,w=0;w<A.length;w++){var y=A[w];M.set(y,L),L+=y.length}return M}},"./src/demux/dummy-demuxed-track.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"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(ce,U,S){"use strict";S.r(U);var B=S("./src/utils/logger.ts"),O=function(){function A(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 _=A.prototype;return _.loadWord=function(){var L=this.data,w=this.bytesAvailable,y=L.byteLength-w,x=new Uint8Array(4),C=Math.min(4,w);if(C===0)throw new Error("no bytes available");x.set(L.subarray(y,y+C)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=C*8,this.bytesAvailable-=C},_.skipBits=function(L){var w;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,w=L>>3,L-=w>>3,this.bytesAvailable-=w,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},_.readBits=function(L){var w=Math.min(this.bitsAvailable,L),y=this.word>>>32-w;return L>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=L-w,w>0&&this.bitsAvailable?y<<w|this.readBits(w):y},_.skipLZ=function(){var L;for(L=0;L<this.bitsAvailable;++L)if((this.word&2147483648>>>L)!==0)return this.word<<=L,this.bitsAvailable-=L,L;return this.loadWord(),L+this.skipLZ()},_.skipUEG=function(){this.skipBits(1+this.skipLZ())},_.skipEG=function(){this.skipBits(1+this.skipLZ())},_.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},_.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},_.readBoolean=function(){return this.readBits(1)===1},_.readUByte=function(){return this.readBits(8)},_.readUShort=function(){return this.readBits(16)},_.readUInt=function(){return this.readBits(32)},_.skipScalingList=function(L){for(var w=8,y=8,x,C=0;C<L;C++)y!==0&&(x=this.readEG(),y=(w+x+256)%256),w=y===0?w:y},_.readSPS=function(){var L=0,w=0,y=0,x=0,C,E,b,v=this.readUByte.bind(this),h=this.readBits.bind(this),e=this.readUEG.bind(this),a=this.readBoolean.bind(this),o=this.skipBits.bind(this),f=this.skipEG.bind(this),d=this.skipUEG.bind(this),u=this.skipScalingList.bind(this);v();var p=v();if(h(5),o(3),v(),d(),p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var c=e();if(c===3&&o(1),d(),d(),o(1),a())for(E=c!==3?8:12,b=0;b<E;b++)a()&&(b<6?u(16):u(64))}d();var i=e();if(i===0)e();else if(i===1)for(o(1),f(),f(),C=e(),b=0;b<C;b++)f();d(),o(1);var r=e(),t=e(),s=h(1);s===0&&o(1),o(1),a()&&(L=e(),w=e(),y=e(),x=e());var m=[1,1];if(a()&&a()){var g=v();switch(g){case 1:m=[1,1];break;case 2:m=[12,11];break;case 3:m=[10,11];break;case 4:m=[16,11];break;case 5:m=[40,33];break;case 6:m=[24,11];break;case 7:m=[20,11];break;case 8:m=[32,11];break;case 9:m=[80,33];break;case 10:m=[18,11];break;case 11:m=[15,11];break;case 12:m=[64,33];break;case 13:m=[160,99];break;case 14:m=[4,3];break;case 15:m=[3,2];break;case 16:m=[2,1];break;case 255:{m=[v()<<8|v(),v()<<8|v()];break}}}return{width:Math.ceil((r+1)*16-L*2-w*2),height:(2-s)*(t+1)*16-(s?2:4)*(y+x),pixelRatio:m}},_.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();U.default=O},"./src/demux/id3.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"isHeader",function(){return B}),S.d(U,"isFooter",function(){return O}),S.d(U,"getID3Data",function(){return A}),S.d(U,"canParse",function(){return M}),S.d(U,"getTimeStamp",function(){return L}),S.d(U,"isTimeStampFrame",function(){return w}),S.d(U,"getID3Frames",function(){return x}),S.d(U,"decodeFrame",function(){return C}),S.d(U,"utf8ArrayToStr",function(){return e}),S.d(U,"testables",function(){return a});var B=function(u,p){return p+10<=u.length&&(u[p]===73&&u[p+1]===68&&u[p+2]===51&&(u[p+3]<255&&u[p+4]<255&&(u[p+6]<128&&u[p+7]<128&&u[p+8]<128&&u[p+9]<128)))},O=function(u,p){return p+10<=u.length&&(u[p]===51&&u[p+1]===68&&u[p+2]===73&&(u[p+3]<255&&u[p+4]<255&&(u[p+6]<128&&u[p+7]<128&&u[p+8]<128&&u[p+9]<128)))},A=function(u,p){for(var c=p,i=0;B(u,p);){i+=10;var r=_(u,p+6);i+=r,O(u,p+10)&&(i+=10),p+=i}return i>0?u.subarray(c,c+i):void 0},_=function(u,p){var c=0;return c=(u[p]&127)<<21,c|=(u[p+1]&127)<<14,c|=(u[p+2]&127)<<7,c|=u[p+3]&127,c},M=function(u,p){return B(u,p)&&_(u,p+6)+10<=u.length-p},L=function(u){for(var p=x(u),c=0;c<p.length;c++){var i=p[c];if(w(i))return h(i)}return},w=function(u){return u&&u.key==="PRIV"&&u.info==="com.apple.streaming.transportStreamTimestamp"},y=function(u){var p=String.fromCharCode(u[0],u[1],u[2],u[3]),c=_(u,4),i=10;return{type:p,size:c,data:u.subarray(i,i+c)}},x=function(u){for(var p=0,c=[];B(u,p);){var i=_(u,p+6);p+=10;for(var r=p+i;p+8<r;){var t=y(u.subarray(p)),s=C(t);s&&c.push(s),p+=t.size+10}O(u,p)&&(p+=10)}return c},C=function(u){return u.type==="PRIV"?E(u):u.type[0]==="W"?v(u):b(u)},E=function(u){if(u.size<2)return;var p=e(u.data,!0),c=new Uint8Array(u.data.subarray(p.length+1));return{key:u.type,info:p,data:c.buffer}},b=function(u){if(u.size<2)return;if(u.type==="TXXX"){var p=1,c=e(u.data.subarray(p),!0);p+=c.length+1;var i=e(u.data.subarray(p));return{key:u.type,info:c,data:i}}var r=e(u.data.subarray(1));return{key:u.type,data:r}},v=function(u){if(u.type==="WXXX"){if(u.size<2)return;var p=1,c=e(u.data.subarray(p),!0);p+=c.length+1;var i=e(u.data.subarray(p));return{key:u.type,info:c,data:i}}var r=e(u.data);return{key:u.type,data:r}},h=function(u){if(u.data.byteLength===8){var p=new Uint8Array(u.data),c=p[3]&1,i=(p[4]<<23)+(p[5]<<15)+(p[6]<<7)+p[7];return i/=45,c&&(i+=4772185884e-2),Math.round(i)}return},e=function(u,p){p===void 0&&(p=!1);var c=f();if(c){var i=c.decode(u);if(p){var r=i.indexOf("\0");return r!==-1?i.substring(0,r):i}return i.replace(/\0/g,"")}for(var t=u.length,s,m,g,T="",P=0;P<t;){if(s=u[P++],s===0&&p)return T;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:T+=String.fromCharCode(s);break;case 12:case 13:m=u[P++],T+=String.fromCharCode((s&31)<<6|m&63);break;case 14:m=u[P++],g=u[P++],T+=String.fromCharCode((s&15)<<12|(m&63)<<6|(g&63)<<0);break;default:}}return T},a={decodeTextFrame:b},o;function f(){return!o&&typeof self.TextDecoder!="undefined"&&(o=new self.TextDecoder("utf-8")),o}},"./src/demux/mp3demuxer.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/demux/base-audio-demuxer.ts"),O=S("./src/demux/id3.ts"),A=S("./src/utils/logger.ts"),_=S("./src/demux/mpegaudio.ts");function M(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,L(y,x)}function L(y,x){return L=Object.setPrototypeOf||function(E,b){return E.__proto__=b,E},L(y,x)}var w=function(y){M(x,y);function x(){return y.apply(this,arguments)||this}var C=x.prototype;return C.resetInitSegment=function(b,v,h){y.prototype.resetInitSegment.call(this,b,v,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:h,inputTimeScale:9e4,dropped:0}},x.probe=function(b){if(!b)return!1;for(var v=O.getID3Data(b,0)||[],h=v.length,e=b.length;h<e;h++)if(_.probe(b,h))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},C.canParse=function(b,v){return _.canParse(b,v)},C.appendFrame=function(b,v,h){return this.initPTS===null?void 0:_.appendFrame(b,v,h,this.initPTS,this.frameIndex)},x}(B.default);w.minProbeByteLength=4,U.default=w},"./src/demux/mp4demuxer.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/utils/mp4-tools.ts"),O=S("./src/demux/dummy-demuxed-track.ts"),A=function(){function _(L,w){this.remainderData=null,this.config=void 0,this.config=w}var M=_.prototype;return M.resetTimeStamp=function(){},M.resetInitSegment=function(){},M.resetContiguity=function(){},_.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 y=w,x=Object(O.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object(B.appendUint8Array)(this.remainderData,w));var C=Object(B.segmentValidRange)(y);this.remainderData=C.remainder,x.samples=C.valid||new Uint8Array}else x.samples=y;return{audioTrack:Object(O.dummyTrack)(),avcTrack:x,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},M.flush=function(){var w=Object(O.dummyTrack)();return w.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(O.dummyTrack)(),avcTrack:w,id3Track:Object(O.dummyTrack)(),textTrack:Object(O.dummyTrack)()}},M.demuxSampleAes=function(w,y,x){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},M.destroy=function(){},_}();A.minProbeByteLength=1024,U.default=A},"./src/demux/mpegaudio.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"appendFrame",function(){return L}),S.d(U,"parseHeader",function(){return w}),S.d(U,"isHeaderPattern",function(){return y}),S.d(U,"isHeader",function(){return x}),S.d(U,"canParse",function(){return C}),S.d(U,"probe",function(){return E});var B=null,O=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],M=[0,1,1,4];function L(b,v,h,e,a){if(h+24>v.length)return;var o=w(v,h);if(o&&h+o.frameLength<=v.length){var f=o.samplesPerFrame*9e4/o.sampleRate,d=e+a*f,u={unit:v.subarray(h,h+o.frameLength),pts:d,dts:d};return b.config=[],b.channelCount=o.channelCount,b.samplerate=o.sampleRate,b.samples.push(u),{sample:u,length:o.frameLength,missing:0}}}function w(b,v){var h=b[v+1]>>3&3,e=b[v+1]>>1&3,a=b[v+2]>>4&15,o=b[v+2]>>2&3;if(h!==1&&a!==0&&a!==15&&o!==3){var f=b[v+2]>>1&1,d=b[v+3]>>6,u=h===3?3-e:e===3?3:4,p=O[u*14+a-1]*1e3,c=h===3?0:h===2?1:2,i=A[c*3+o],r=d===3?1:2,t=_[h][e],s=M[e],m=t*8*s,g=Math.floor(t*p/i+f)*s;if(B===null){var T=navigator.userAgent||"",P=T.match(/Chrome\/(\d+)/i);B=P?parseInt(P[1]):0}var I=!!B&&B<=87;return I&&e===2&&p>=224e3&&d===0&&(b[v+3]=b[v+3]|128),{sampleRate:i,channelCount:r,frameLength:g,samplesPerFrame:m}}}function y(b,v){return b[v]===255&&(b[v+1]&224)===224&&(b[v+1]&6)!==0}function x(b,v){return v+1<b.length&&y(b,v)}function C(b,v){var h=4;return y(b,v)&&h<=b.length-v}function E(b,v){if(v+1<b.length&&y(b,v)){var h=4,e=w(b,v),a=h;e!=null&&e.frameLength&&(a=e.frameLength);var o=v+a;return o===b.length||x(b,o)}return!1}},"./src/demux/sample-aes.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/crypt/decrypter.ts"),O=S("./src/demux/tsdemuxer.ts"),A=function(){function _(L,w,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new B.default(L,w,{removePKCS7Padding:!1})}var M=_.prototype;return M.decryptBuffer=function(w,y){this.decrypter.decrypt(w,this.keyData.key.buffer,this.keyData.iv.buffer,y)},M.decryptAacSample=function(w,y,x,C){var E=w[y].unit,b=E.subarray(16,E.length-E.length%16),v=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),h=this;this.decryptBuffer(v,function(e){var a=new Uint8Array(e);E.set(a,16),C||h.decryptAacSamples(w,y+1,x)})},M.decryptAacSamples=function(w,y,x){for(;;y++){if(y>=w.length){x();return}if(w[y].unit.length<32)continue;var C=this.decrypter.isSync();if(this.decryptAacSample(w,y,x,C),!C)return}},M.getAvcEncryptedData=function(w){for(var y=Math.floor((w.length-48)/160)*16+16,x=new Int8Array(y),C=0,E=32;E<=w.length-16;E+=160,C+=16)x.set(w.subarray(E,E+16),C);return x},M.getAvcDecryptedUnit=function(w,y){for(var x=new Uint8Array(y),C=0,E=32;E<=w.length-16;E+=160,C+=16)w.set(x.subarray(C,C+16),E);return w},M.decryptAvcSample=function(w,y,x,C,E,b){var v=Object(O.discardEPB)(E.data),h=this.getAvcEncryptedData(v),e=this;this.decryptBuffer(h.buffer,function(a){E.data=e.getAvcDecryptedUnit(v,a),b||e.decryptAvcSamples(w,y,x+1,C)})},M.decryptAvcSamples=function(w,y,x,C){if(w instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,x=0){if(y>=w.length){C();return}for(var E=w[y].units;!(x>=E.length);x++){var b=E[x];if(b.data.length<=48||b.type!==1&&b.type!==5)continue;var v=this.decrypter.isSync();if(this.decryptAvcSample(w,y,x,C,b,v),!v)return}}},_}();U.default=A},"./src/demux/transmuxer-interface.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return E});var B=S("./node_modules/webworkify-webpack/index.js"),O=S.n(B),A=S("./src/events.ts"),_=S("./src/demux/transmuxer.ts"),M=S("./src/utils/logger.ts"),L=S("./src/errors.ts"),w=S("./src/utils/mediasource-helper.ts"),y=S("./node_modules/eventemitter3/index.js"),x=S.n(y),C=Object(w.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function b(h,e,a,o){var f=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=h,this.id=e,this.onTransmuxComplete=a,this.onFlush=o;var d=h.config,u=function(t,s){s=s||{},s.frag=f.frag,s.id=f.id,h.trigger(t,s)};this.observer=new y.EventEmitter,this.observer.on(A.Events.FRAG_DECRYPTED,u),this.observer.on(A.Events.ERROR,u);var p={mp4:C.isTypeSupported("video/mp4"),mpeg:C.isTypeSupported("audio/mpeg"),mp3:C.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(d.enableWorker&&typeof Worker!="undefined"){M.logger.log("demuxing in webworker");var i;try{i=this.worker=B("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),i.addEventListener("message",this.onwmsg),i.onerror=function(r){h.trigger(A.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(r.message+" ("+r.filename+":"+r.lineno+")")})},i.postMessage({cmd:"init",typeSupported:p,vendor:c,id:e,config:JSON.stringify(d)})}catch(r){M.logger.warn("Error in worker:",r),M.logger.error("Error while initializing DemuxerWorker, fallback to inline"),i&&self.URL.revokeObjectURL(i.objectURL),this.transmuxer=new _.default(this.observer,p,d,c,e),this.worker=null}}else this.transmuxer=new _.default(this.observer,p,d,c,e)}var v=b.prototype;return v.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.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},v.push=function(e,a,o,f,d,u,p,c,i,r){var t=this;i.transmuxing.start=self.performance.now();var s=this.transmuxer,m=this.worker,g=u?u.start:d.start,T=d.decryptdata,P=this.frag,I=!(P&&d.cc===P.cc),F=!(P&&i.level===P.level),K=P?i.sn-P.sn:-1,V=this.part?i.part-this.part.index:1,Q=!F&&(K===1||K===0&&V===1),Z=self.performance.now();(F||K||d.stats.parsing.start===0)&&(d.stats.parsing.start=Z),u&&(V||!Q)&&(u.stats.parsing.start=Z);var ie=new _.TransmuxState(I,Q,c,F,g);if(!Q||I){M.logger.log("[transmuxer-interface, "+d.type+"]: Starting new transmux session for sn: "+i.sn+" p: "+i.part+" level: "+i.level+" id: "+i.id+`
discontinuity: `+I+`
trackSwitch: `+F+`
contiguous: `+Q+`
accurateTimeOffset: `+c+`
timeOffset: `+g);var pe=new _.TransmuxConfig(o,f,a,p,r);this.configureTransmuxer(pe)}if(this.frag=d,this.part=u,m)m.postMessage({cmd:"demux",data:e,decryptdata:T,chunkMeta:i,state:ie},e instanceof ArrayBuffer?[e]:[]);else if(s){var ae=s.push(e,T,i,ie);Object(_.isPromise)(ae)?ae.then(function(de){t.handleTransmuxComplete(de)}):this.handleTransmuxComplete(ae)}},v.flush=function(e){var a=this;e.transmuxing.start=self.performance.now();var o=this.transmuxer,f=this.worker;if(f)f.postMessage({cmd:"flush",chunkMeta:e});else if(o){var d=o.flush(e);Object(_.isPromise)(d)?d.then(function(u){a.handleFlushResult(u,e)}):this.handleFlushResult(d,e)}},v.handleFlushResult=function(e,a){var o=this;e.forEach(function(f){o.handleTransmuxComplete(f)}),this.onFlush(a)},v.onWorkerMessage=function(e){var a=e.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}}},v.configureTransmuxer=function(e){var a=this.worker,o=this.transmuxer;a?a.postMessage({cmd:"configure",config:e}):o&&o.configure(e)},v.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},b}()},"./src/demux/transmuxer-worker.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return L});var B=S("./src/demux/transmuxer.ts"),O=S("./src/events.ts"),A=S("./src/utils/logger.ts"),_=S("./node_modules/eventemitter3/index.js"),M=S.n(_);function L(E){var b=new _.EventEmitter,v=function(e,a){E.postMessage({event:e,data:a})};b.on(O.Events.FRAG_DECRYPTED,v),b.on(O.Events.ERROR,v),E.addEventListener("message",function(h){var e=h.data;switch(e.cmd){case"init":{var a=JSON.parse(e.config);E.transmuxer=new B.default(b,e.typeSupported,a,e.vendor,e.id),Object(A.enableLogs)(a.debug),v("init",null);break}case"configure":{E.transmuxer.configure(e.config);break}case"demux":{var o=E.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(B.isPromise)(o)?o.then(function(u){w(E,u)}):w(E,o);break}case"flush":{var f=e.chunkMeta,d=E.transmuxer.flush(f);Object(B.isPromise)(d)?d.then(function(u){x(E,u,f)}):x(E,d,f);break}default:break}})}function w(E,b){if(C(b.remuxResult))return;var v=[],h=b.remuxResult,e=h.audio,a=h.video;e&&y(v,e),a&&y(v,a),E.postMessage({event:"transmuxComplete",data:b},v)}function y(E,b){b.data1&&E.push(b.data1.buffer),b.data2&&E.push(b.data2.buffer)}function x(E,b,v){b.forEach(function(h){w(E,h)}),E.postMessage({event:"flush",data:v})}function C(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return a}),S.d(U,"isPromise",function(){return d}),S.d(U,"TransmuxConfig",function(){return u}),S.d(U,"TransmuxState",function(){return p});var B=S("./src/events.ts"),O=S("./src/errors.ts"),A=S("./src/crypt/decrypter.ts"),_=S("./src/demux/aacdemuxer.ts"),M=S("./src/demux/mp4demuxer.ts"),L=S("./src/demux/tsdemuxer.ts"),w=S("./src/demux/mp3demuxer.ts"),y=S("./src/remux/mp4-remuxer.ts"),x=S("./src/remux/passthrough-remuxer.ts"),C=S("./src/demux/chunk-cache.ts"),E=S("./src/utils/mp4-tools.ts"),b=S("./src/utils/logger.ts"),v;try{v=self.performance.now.bind(self.performance)}catch(c){b.logger.debug("Unable to use Performance API on this environment"),v=self.Date.now}var h=[{demux:L.default,remux:y.default},{demux:M.default,remux:x.default},{demux:_.default,remux:y.default},{demux:w.default,remux:y.default}],e=1024;h.forEach(function(c){var i=c.demux;e=Math.max(e,i.minProbeByteLength)});var a=function(){function c(r,t,s,m,g){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new C.default,this.observer=r,this.typeSupported=t,this.config=s,this.vendor=m,this.id=g}var i=c.prototype;return i.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},i.push=function(t,s,m,g){var T=this,P=m.transmuxing;P.executeStart=v();var I=new Uint8Array(t),F=this.cache,K=this.config,V=this.currentTransmuxState,Q=this.transmuxConfig;g&&(this.currentTransmuxState=g);var Z=o(I,s);if(Z&&Z.method==="AES-128"){var ie=this.getDecrypter();if(K.enableSoftwareAES){var pe=ie.softwareDecrypt(I,Z.key.buffer,Z.iv.buffer);if(!pe)return P.executeEnd=v(),f(m);I=new Uint8Array(pe)}else return this.decryptionPromise=ie.webCryptoDecrypt(I,Z.key.buffer,Z.iv.buffer).then(function(ye){var xe=T.push(ye,null,m);return T.decryptionPromise=null,xe}),this.decryptionPromise}var ae=g||V,de=ae.contiguous,le=ae.discontinuity,$=ae.trackSwitch,Y=ae.accurateTimeOffset,ne=ae.timeOffset,z=Q.audioCodec,H=Q.videoCodec,me=Q.defaultInitPts,Le=Q.duration,Oe=Q.initSegmentData;if((le||$)&&this.resetInitSegment(Oe,z,H,Le),le&&this.resetInitialTimestamp(me),de||this.resetContiguity(),this.needsProbing(I,le,$)){if(F.dataLength){var Ae=F.flush();I=Object(E.appendUint8Array)(Ae,I)}this.configureTransmuxer(I,Q)}var Re=this.transmux(I,Z,ne,Y,m),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,P.executeEnd=v(),Re},i.flush=function(t){var s=this,m=t.transmuxing;m.executeStart=v();var g=this.decrypter,T=this.cache,P=this.currentTransmuxState,I=this.decryptionPromise;if(I)return I.then(function(){return s.flush(t)});var F=[],K=P.timeOffset;if(g){var V=g.flush();V&&F.push(this.push(V,null,t))}var Q=T.dataLength;T.reset();var Z=this.demuxer,ie=this.remuxer;if(!Z||!ie)return Q>=e&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=v(),[f(t)];var pe=Z.flush(K);return d(pe)?pe.then(function(ae){return s.flushRemux(F,ae,t),F}):(this.flushRemux(F,pe,t),F)},i.flushRemux=function(t,s,m){var g=s.audioTrack,T=s.avcTrack,P=s.id3Track,I=s.textTrack,F=this.currentTransmuxState,K=F.accurateTimeOffset,V=F.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var Q=this.remuxer.remux(g,T,P,I,V,K,!0,this.id);t.push({remuxResult:Q,chunkMeta:m}),m.transmuxing.executeEnd=v()},i.resetInitialTimestamp=function(t){var s=this.demuxer,m=this.remuxer;if(!s||!m)return;s.resetTimeStamp(t),m.resetTimeStamp(t)},i.resetContiguity=function(){var t=this.demuxer,s=this.remuxer;if(!t||!s)return;t.resetContiguity(),s.resetNextTimestamp()},i.resetInitSegment=function(t,s,m,g){var T=this.demuxer,P=this.remuxer;if(!T||!P)return;T.resetInitSegment(s,m,g),P.resetInitSegment(t,s,m)},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(t,s,m,g,T){var P;return s&&s.method==="SAMPLE-AES"?P=this.transmuxSampleAes(t,s,m,g,T):P=this.transmuxUnencrypted(t,m,g,T),P},i.transmuxUnencrypted=function(t,s,m,g){var T=this.demuxer.demux(t,s,!1,!this.config.progressive),P=T.audioTrack,I=T.avcTrack,F=T.id3Track,K=T.textTrack,V=this.remuxer.remux(P,I,F,K,s,m,!1,this.id);return{remuxResult:V,chunkMeta:g}},i.transmuxSampleAes=function(t,s,m,g,T){var P=this;return this.demuxer.demuxSampleAes(t,s,m).then(function(I){var F=P.remuxer.remux(I.audioTrack,I.avcTrack,I.id3Track,I.textTrack,m,g,!1,P.id);return{remuxResult:F,chunkMeta:T}})},i.configureTransmuxer=function(t,s){for(var m=this.config,g=this.observer,T=this.typeSupported,P=this.vendor,I=s.audioCodec,F=s.defaultInitPts,K=s.duration,V=s.initSegmentData,Q=s.videoCodec,Z,ie=0,pe=h.length;ie<pe;ie++)if(h[ie].demux.probe(t)){Z=h[ie];break}Z||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Z={demux:M.default,remux:x.default});var ae=this.demuxer,de=this.remuxer,le=Z.remux,$=Z.demux;(!de||!(de instanceof le))&&(this.remuxer=new le(g,m,T,P)),(!ae||!(ae instanceof $))&&(this.demuxer=new $(g,m,T),this.probe=$.probe),this.resetInitSegment(V,I,Q,K),this.resetInitialTimestamp(F)},i.needsProbing=function(t,s,m){return!this.demuxer||!this.remuxer||s||m},i.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new A.default(this.observer,this.config)),t},c}();function o(c,i){var r=null;return c.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(r=i),r}var f=function(i){return{remuxResult:{},chunkMeta:i}};function d(c){return"then"in c&&c.then instanceof Function}var u=function(i,r,t,s,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=r,this.initSegmentData=t,this.duration=s,this.defaultInitPts=m},p=function(i,r,t,s,m){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=i,this.contiguous=r,this.accurateTimeOffset=t,this.trackSwitch=s,this.timeOffset=m}},"./src/demux/tsdemuxer.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"discardEPB",function(){return f});var B=S("./src/demux/adts.ts"),O=S("./src/demux/mpegaudio.ts"),A=S("./src/demux/exp-golomb.ts"),_=S("./src/demux/id3.ts"),M=S("./src/demux/sample-aes.ts"),L=S("./src/events.ts"),w=S("./src/utils/mp4-tools.ts"),y=S("./src/utils/logger.ts"),x=S("./src/errors.ts"),C={video:1,audio:2,id3:3,text:4},E=function(){function d(p,c,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=p,this.config=c,this.typeSupported=i}d.probe=function(c){var i=d.syncOffset(c);return i<0?!1:(i&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+i+", junk ahead ?"),!0)},d.syncOffset=function(c){for(var i=Math.min(1e3,c.length-3*188),r=0;r<i;){if(c[r]===71&&c[r+188]===71&&c[r+2*188]===71)return r;r++}return-1},d.createTrack=function(c,i){return{container:c==="video"||c==="audio"?"video/mp2t":void 0,type:c,id:C[c],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:c==="audio"?i:void 0}};var u=d.prototype;return u.resetInitSegment=function(c,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=d.createTrack("video",r),this._audioTrack=d.createTrack("audio",r),this._id3Track=d.createTrack("id3",r),this._txtTrack=d.createTrack("text",r),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=c,this.videoCodec=i,this._duration=r},u.resetTimeStamp=function(){},u.resetContiguity=function(){var c=this._audioTrack,i=this._avcTrack,r=this._id3Track;c&&(c.pesData=null),i&&(i.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},u.demux=function(c,i,r,t){r===void 0&&(r=!1),t===void 0&&(t=!1),r||(this.sampleAes=null);var s,m=this._avcTrack,g=this._audioTrack,T=this._id3Track,P=m.pid,I=m.pesData,F=g.pid,K=T.pid,V=g.pesData,Q=T.pesData,Z=!1,ie=this.pmtParsed,pe=this._pmtId,ae=c.length;if(this.remainderData&&(c=Object(w.appendUint8Array)(this.remainderData,c),ae=c.length,this.remainderData=null),ae<188&&!t)return this.remainderData=c,{audioTrack:g,avcTrack:m,id3Track:T,textTrack:this._txtTrack};var de=Math.max(0,d.syncOffset(c));ae-=(ae+de)%188,ae<c.byteLength&&!t&&(this.remainderData=new Uint8Array(c.buffer,ae,c.buffer.byteLength-ae));for(var le=de;le<ae;le+=188)if(c[le]===71){var $=!!(c[le+1]&64),Y=((c[le+1]&31)<<8)+c[le+2],ne=(c[le+3]&48)>>4,z=void 0;if(ne>1){if(z=le+5+c[le+4],z===le+188)continue}else z=le+4;switch(Y){case P:$&&(I&&(s=e(I))&&this.parseAVCPES(s,!1),I={data:[],size:0}),I&&(I.data.push(c.subarray(z,le+188)),I.size+=le+188-z);break;case F:$&&(V&&(s=e(V))&&(g.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),V={data:[],size:0}),V&&(V.data.push(c.subarray(z,le+188)),V.size+=le+188-z);break;case K:$&&(Q&&(s=e(Q))&&this.parseID3PES(s),Q={data:[],size:0}),Q&&(Q.data.push(c.subarray(z,le+188)),Q.size+=le+188-z);break;case 0:$&&(z+=c[z]+1),pe=this._pmtId=v(c,z);break;case pe:{$&&(z+=c[z]+1);var H=h(c,z,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,r);P=H.avc,P>0&&(m.pid=P),F=H.audio,F>0&&(g.pid=F,g.isAAC=H.isAAC),K=H.id3,K>0&&(T.pid=K),Z&&!ie&&(y.logger.log("reparse from beginning"),Z=!1,le=de-188),ie=this.pmtParsed=!0;break}case 17:case 8191:break;default:Z=!0;break}}else this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});m.pesData=I,g.pesData=V,T.pesData=Q;var me={audioTrack:g,avcTrack:m,id3Track:T,textTrack:this._txtTrack};return t&&this.extractRemainingSamples(me),me},u.flush=function(){var c=this.remainderData;this.remainderData=null;var i;return c?i=this.demux(c,-1,!1,!0):i={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(i),this.sampleAes?this.decrypt(i,this.sampleAes):i},u.extractRemainingSamples=function(c){var i=c.audioTrack,r=c.avcTrack,t=c.id3Track,s=r.pesData,m=i.pesData,g=t.pesData,T;s&&(T=e(s))?(this.parseAVCPES(T,!0),r.pesData=null):r.pesData=s,m&&(T=e(m))?(i.isAAC?this.parseAACPES(T):this.parseMPEGPES(T),i.pesData=null):(m!=null&&m.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=m),g&&(T=e(g))?(this.parseID3PES(T),t.pesData=null):t.pesData=g},u.demuxSampleAes=function(c,i,r){var t=this.demux(c,r,!0,!this.config.progressive),s=this.sampleAes=new M.default(this.observer,this.config,i);return this.decrypt(t,s)},u.decrypt=function(c,i){return new Promise(function(r){var t=c.audioTrack,s=c.avcTrack;t.samples&&t.isAAC?i.decryptAacSamples(t.samples,0,function(){s.samples?i.decryptAvcSamples(s.samples,0,0,function(){r(c)}):r(c)}):s.samples&&i.decryptAvcSamples(s.samples,0,0,function(){r(c)})})},u.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},u.parseAVCPES=function(c,i){var r=this,t=this._avcTrack,s=this.parseAVCNALu(c.data),m=!1,g=this.avcSample,T,P=!1;c.data=null,g&&s.length&&!t.audFound&&(a(g,t),g=this.avcSample=b(!1,c.pts,c.dts,"")),s.forEach(function(I){switch(I.type){case 1:{T=!0,g||(g=r.avcSample=b(!0,c.pts,c.dts,"")),m&&(g.debug+="NDR "),g.frame=!0;var F=I.data;if(P&&F.length>4){var K=new A.default(F).readSliceType();(K===2||K===4||K===7||K===9)&&(g.key=!0)}break}case 5:T=!0,g||(g=r.avcSample=b(!0,c.pts,c.dts,"")),m&&(g.debug+="IDR "),g.key=!0,g.frame=!0;break;case 6:{T=!0,m&&g&&(g.debug+="SEI ");var V=new A.default(f(I.data));V.readUByte();for(var Q=0,Z=0,ie=!1,pe=0;!ie&&V.bytesAvailable>1;){Q=0;do pe=V.readUByte(),Q+=pe;while(pe===255);Z=0;do pe=V.readUByte(),Z+=pe;while(pe===255);if(Q===4&&V.bytesAvailable!==0){ie=!0;var ae=V.readUByte();if(ae===181){var de=V.readUShort();if(de===49){var le=V.readUInt();if(le===1195456820){var $=V.readUByte();if($===3){for(var Y=V.readUByte(),ne=V.readUByte(),z=31&Y,H=[Y,ne],me=0;me<z;me++)H.push(V.readUByte()),H.push(V.readUByte()),H.push(V.readUByte());o(r._txtTrack.samples,{type:3,pts:c.pts,bytes:H})}}}}}else if(Q===5&&V.bytesAvailable!==0){if(ie=!0,Z>16){for(var Le=[],Oe=0;Oe<16;Oe++)Le.push(V.readUByte().toString(16)),(Oe===3||Oe===5||Oe===7||Oe===9)&&Le.push("-");for(var Ae=Z-16,Re=new Uint8Array(Ae),fe=0;fe<Ae;fe++)Re[fe]=V.readUByte();o(r._txtTrack.samples,{pts:c.pts,payloadType:Q,uuid:Le.join(""),userData:Object(_.utf8ArrayToStr)(Re),userDataBytes:Re})}}else if(Z<V.bytesAvailable)for(var ye=0;ye<Z;ye++)V.readUByte()}break}case 7:if(T=!0,P=!0,m&&g&&(g.debug+="SPS "),!t.sps){var xe=new A.default(I.data),Se=xe.readSPS();t.width=Se.width,t.height=Se.height,t.pixelRatio=Se.pixelRatio,t.sps=[I.data],t.duration=r._duration;for(var Ne=I.data.subarray(1,4),Pe="avc1.",_e=0;_e<3;_e++){var Fe=Ne[_e].toString(16);Fe.length<2&&(Fe="0"+Fe),Pe+=Fe}t.codec=Pe}break;case 8:T=!0,m&&g&&(g.debug+="PPS "),t.pps||(t.pps=[I.data]);break;case 9:T=!1,t.audFound=!0,g&&a(g,t),g=r.avcSample=b(!1,c.pts,c.dts,m?"AUD ":"");break;case 12:T=!1;break;default:T=!1,g&&(g.debug+="unknown NAL "+I.type+" ");break}if(g&&T){var se=g.units;se.push(I)}}),i&&g&&(a(g,t),this.avcSample=null)},u.getLastNalUnit=function(){var c,i=this.avcSample,r;if(!i||i.units.length===0){var t=this._avcTrack.samples;i=t[t.length-1]}if((c=i)!==null&&c!==void 0&&c.units){var s=i.units;r=s[s.length-1]}return r},u.parseAVCNALu=function(c){var i=c.byteLength,r=this._avcTrack,t=r.naluState||0,s=t,m=[],g=0,T,P,I,F=-1,K=0;for(t===-1&&(F=0,K=c[0]&31,t=0,g=1);g<i;){if(T=c[g++],!t){t=T?0:1;continue}if(t===1){t=T?0:2;continue}if(!T)t=3;else if(T===1){if(F>=0){var V={data:c.subarray(F,g-t-1),type:K};m.push(V)}else{var Q=this.getLastNalUnit();if(Q&&(s&&g<=4-s&&(Q.state&&(Q.data=Q.data.subarray(0,Q.data.byteLength-s))),P=g-t-1,P>0)){var Z=new Uint8Array(Q.data.byteLength+P);Z.set(Q.data,0),Z.set(c.subarray(0,P),Q.data.byteLength),Q.data=Z,Q.state=0}}g<i?(I=c[g]&31,F=g,K=I,t=0):t=-1}else t=0}if(F>=0&&t>=0){var ie={data:c.subarray(F,i),type:K,state:t};m.push(ie)}if(m.length===0){var pe=this.getLastNalUnit();if(pe){var ae=new Uint8Array(pe.data.byteLength+c.byteLength);ae.set(pe.data,0),ae.set(c,pe.data.byteLength),pe.data=ae}}return r.naluState=t,m},u.parseAACPES=function(c){var i=0,r=this._audioTrack,t=this.aacOverFlow,s=c.data;if(t){this.aacOverFlow=null;var m=t.sample.unit.byteLength,g=Math.min(t.missing,m),T=m-g;t.sample.unit.set(s.subarray(0,g),T),r.samples.push(t.sample),i=t.missing}var P,I;for(P=i,I=s.length;P<I-1&&!B.isHeader(s,P);P++);if(P!==i){var F,K;if(P<I-1?(F="AAC PES did not start with ADTS header,offset:"+P,K=!1):(F="no ADTS header found in AAC PES",K=!0),y.logger.warn("parsing error:"+F),this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:K,reason:F}),K)return}B.initTrackConfig(r,this.observer,s,P,this.audioCodec);var V;if(c.pts!==void 0)V=c.pts;else if(t){var Q=B.getFrameDuration(r.samplerate);V=t.sample.pts+Q}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Z=0;P<I;)if(B.isHeader(s,P)){if(P+5<I){var ie=B.appendFrame(r,s,P,V,Z);if(ie)if(ie.missing)this.aacOverFlow=ie;else{P+=ie.length,Z++;continue}}break}else P++},u.parseMPEGPES=function(c){var i=c.data,r=i.length,t=0,s=0,m=c.pts;if(m===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;s<r;)if(O.isHeader(i,s)){var g=O.appendFrame(this._audioTrack,i,s,m,t);if(g)s+=g.length,t++;else break}else s++},u.parseID3PES=function(c){if(c.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(c)},d}();E.minProbeByteLength=188;function b(d,u,p,c){return{key:d,frame:!1,pts:u,dts:p,units:[],debug:c,length:0}}function v(d,u){return(d[u+10]&31)<<8|d[u+11]}function h(d,u,p,c){var i={audio:-1,avc:-1,id3:-1,isAAC:!0},r=(d[u+1]&15)<<8|d[u+2],t=u+3+r-4,s=(d[u+10]&15)<<8|d[u+11];for(u+=12+s;u<t;){var m=(d[u+1]&31)<<8|d[u+2];switch(d[u]){case 207:if(!c){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:i.audio===-1&&(i.audio=m);break;case 21:i.id3===-1&&(i.id3=m);break;case 219:if(!c){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:i.avc===-1&&(i.avc=m);break;case 3:case 4:p?i.audio===-1&&(i.audio=m,i.isAAC=!1):y.logger.log("MPEG audio found, not supported in this browser");break;case 36:y.logger.warn("Unsupported HEVC stream type found");break;default:break}u+=((d[u+3]&15)<<8|d[u+4])+5}return i}function e(d){var u=0,p,c,i,r,t,s=d.data;if(!d||d.size===0)return null;for(;s[0].length<19&&s.length>1;){var m=new Uint8Array(s[0].length+s[1].length);m.set(s[0]),m.set(s[1],s[0].length),s[0]=m,s.splice(1,1)}p=s[0];var g=(p[0]<<16)+(p[1]<<8)+p[2];if(g===1){if(c=(p[4]<<8)+p[5],c&&c>d.size-6)return null;var T=p[7];T&192&&(r=(p[9]&14)*536870912+(p[10]&255)*4194304+(p[11]&254)*16384+(p[12]&255)*128+(p[13]&254)/2,T&64?(t=(p[14]&14)*536870912+(p[15]&255)*4194304+(p[16]&254)*16384+(p[17]&255)*128+(p[18]&254)/2,r-t>60*9e4&&(y.logger.warn(Math.round((r-t)/9e4)+"s delta between PTS and DTS, align them"),r=t)):t=r),i=p[8];var P=i+9;if(d.size<=P)return null;d.size-=P;for(var I=new Uint8Array(d.size),F=0,K=s.length;F<K;F++){p=s[F];var V=p.byteLength;if(P)if(P>V){P-=V;continue}else p=p.subarray(P),V-=P,P=0;I.set(p,u),u+=V}return c&&(c-=i+3),{data:I,pts:r,dts:t,len:c}}return null}function a(d,u){if(d.units.length&&d.frame){if(d.pts===void 0){var p=u.samples,c=p.length;if(c){var i=p[c-1];d.pts=i.pts,d.dts=i.dts}else{u.dropped++;return}}u.samples.push(d)}d.debug.length&&y.logger.log(d.pts+"/"+d.dts+":"+d.debug)}function o(d,u){var p=d.length;if(p>0){if(u.pts>=d[p-1].pts)d.push(u);else for(var c=p-1;c>=0;c--)if(u.pts<d[c].pts){d.splice(c,0,u);break}}else d.push(u)}function f(d){for(var u=d.byteLength,p=[],c=1;c<u-2;)d[c]===0&&d[c+1]===0&&d[c+2]===3?(p.push(c+2),c+=2):c++;if(p.length===0)return d;var i=u-p.length,r=new Uint8Array(i),t=0;for(c=0;c<i;t++,c++)t===p[0]&&(t++,p.shift()),r[c]=d[t];return r}U.default=E},"./src/errors.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"ErrorTypes",function(){return B}),S.d(U,"ErrorDetails",function(){return O});var B;(function(A){A.NETWORK_ERROR="networkError",A.MEDIA_ERROR="mediaError",A.KEY_SYSTEM_ERROR="keySystemError",A.MUX_ERROR="muxError",A.OTHER_ERROR="otherError"})(B||(B={}));var O;(function(A){A.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",A.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",A.KEY_SYSTEM_NO_SESSION="keySystemNoSession",A.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",A.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",A.MANIFEST_LOAD_ERROR="manifestLoadError",A.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",A.MANIFEST_PARSING_ERROR="manifestParsingError",A.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",A.LEVEL_EMPTY_ERROR="levelEmptyError",A.LEVEL_LOAD_ERROR="levelLoadError",A.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",A.LEVEL_SWITCH_ERROR="levelSwitchError",A.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",A.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",A.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",A.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",A.FRAG_LOAD_ERROR="fragLoadError",A.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",A.FRAG_DECRYPT_ERROR="fragDecryptError",A.FRAG_PARSING_ERROR="fragParsingError",A.REMUX_ALLOC_ERROR="remuxAllocError",A.KEY_LOAD_ERROR="keyLoadError",A.KEY_LOAD_TIMEOUT="keyLoadTimeOut",A.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",A.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",A.BUFFER_APPEND_ERROR="bufferAppendError",A.BUFFER_APPENDING_ERROR="bufferAppendingError",A.BUFFER_STALLED_ERROR="bufferStalledError",A.BUFFER_FULL_ERROR="bufferFullError",A.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",A.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",A.INTERNAL_EXCEPTION="internalException",A.INTERNAL_ABORTED="aborted",A.UNKNOWN="unknown"})(O||(O={}))},"./src/events.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"Events",function(){return B});var B;(function(O){O.MEDIA_ATTACHING="hlsMediaAttaching",O.MEDIA_ATTACHED="hlsMediaAttached",O.MEDIA_DETACHING="hlsMediaDetaching",O.MEDIA_DETACHED="hlsMediaDetached",O.BUFFER_RESET="hlsBufferReset",O.BUFFER_CODECS="hlsBufferCodecs",O.BUFFER_CREATED="hlsBufferCreated",O.BUFFER_APPENDING="hlsBufferAppending",O.BUFFER_APPENDED="hlsBufferAppended",O.BUFFER_EOS="hlsBufferEos",O.BUFFER_FLUSHING="hlsBufferFlushing",O.BUFFER_FLUSHED="hlsBufferFlushed",O.MANIFEST_LOADING="hlsManifestLoading",O.MANIFEST_LOADED="hlsManifestLoaded",O.MANIFEST_PARSED="hlsManifestParsed",O.LEVEL_SWITCHING="hlsLevelSwitching",O.LEVEL_SWITCHED="hlsLevelSwitched",O.LEVEL_LOADING="hlsLevelLoading",O.LEVEL_LOADED="hlsLevelLoaded",O.LEVEL_UPDATED="hlsLevelUpdated",O.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",O.LEVELS_UPDATED="hlsLevelsUpdated",O.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",O.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",O.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",O.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",O.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",O.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",O.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",O.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",O.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",O.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",O.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",O.CUES_PARSED="hlsCuesParsed",O.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",O.INIT_PTS_FOUND="hlsInitPtsFound",O.FRAG_LOADING="hlsFragLoading",O.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",O.FRAG_LOADED="hlsFragLoaded",O.FRAG_DECRYPTED="hlsFragDecrypted",O.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",O.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",O.FRAG_PARSING_METADATA="hlsFragParsingMetadata",O.FRAG_PARSED="hlsFragParsed",O.FRAG_BUFFERED="hlsFragBuffered",O.FRAG_CHANGED="hlsFragChanged",O.FPS_DROP="hlsFpsDrop",O.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",O.ERROR="hlsError",O.DESTROYING="hlsDestroying",O.KEY_LOADING="hlsKeyLoading",O.KEY_LOADED="hlsKeyLoaded",O.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",O.BACK_BUFFER_REACHED="hlsBackBufferReached"})(B||(B={}))},"./src/hls.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return d});var B=S("./node_modules/url-toolkit/src/url-toolkit.js"),O=S.n(B),A=S("./src/loader/playlist-loader.ts"),_=S("./src/loader/key-loader.ts"),M=S("./src/controller/id3-track-controller.ts"),L=S("./src/controller/latency-controller.ts"),w=S("./src/controller/level-controller.ts"),y=S("./src/controller/fragment-tracker.ts"),x=S("./src/controller/stream-controller.ts"),C=S("./src/is-supported.ts"),E=S("./src/utils/logger.ts"),b=S("./src/config.ts"),v=S("./node_modules/eventemitter3/index.js"),h=S.n(v),e=S("./src/events.ts"),a=S("./src/errors.ts");function o(u,p){for(var c=0;c<p.length;c++){var i=p[c];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(u,i.key,i)}}function f(u,p,c){return p&&o(u.prototype,p),c&&o(u,c),u}var d=function(){u.isSupported=function(){return Object(C.isSupported)()};function u(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new v.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var i=this.config=Object(b.mergeConfig)(u.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(i.debug),this._autoLevelCapping=-1,i.progressive&&Object(b.enableStreamingMode)(i);var r=i.abrController,t=i.bufferController,s=i.capLevelController,m=i.fpsController,g=this.abrController=new r(this),T=this.bufferController=new t(this),P=this.capLevelController=new s(this),I=new m(this),F=new A.default(this),K=new _.default(this),V=new M.default(this),Q=this.levelController=new w.default(this),Z=new y.FragmentTracker(this),ie=this.streamController=new x.default(this,Z);P.setStreamController(ie),I.setStreamController(ie);var pe=[Q,ie];this.networkControllers=pe;var ae=[F,K,g,T,P,I,V,Z];this.audioTrackController=this.createController(i.audioTrackController,null,pe),this.createController(i.audioStreamController,Z,pe),this.subtitleTrackController=this.createController(i.subtitleTrackController,null,pe),this.createController(i.subtitleStreamController,Z,pe),this.createController(i.timelineController,null,ae),this.emeController=this.createController(i.emeController,null,ae),this.cmcdController=this.createController(i.cmcdController,null,ae),this.latencyController=this.createController(L.default,null,ae),this.coreComponents=ae}var p=u.prototype;return p.createController=function(i,r,t){if(i){var s=r?new i(this,r):new i(this);return t&&t.push(s),s}return null},p.on=function(i,r,t){t===void 0&&(t=this),this._emitter.on(i,r,t)},p.once=function(i,r,t){t===void 0&&(t=this),this._emitter.once(i,r,t)},p.removeAllListeners=function(i){this._emitter.removeAllListeners(i)},p.off=function(i,r,t,s){t===void 0&&(t=this),this._emitter.off(i,r,t,s)},p.listeners=function(i){return this._emitter.listeners(i)},p.emit=function(i,r,t){return this._emitter.emit(i,r,t)},p.trigger=function(i,r){if(this.config.debug)return this.emit(i,i,r);try{return this.emit(i,i,r)}catch(t){E.logger.error("An internal error happened while handling event "+i+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(e.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:i,error:t})}return!1},p.listenerCount=function(i){return this._emitter.listenerCount(i)},p.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(i){return i.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(i){return i.destroy()}),this.coreComponents.length=0},p.attachMedia=function(i){E.logger.log("attachMedia"),this._media=i,this.trigger(e.Events.MEDIA_ATTACHING,{media:i})},p.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},p.loadSource=function(i){this.stopLoad();var r=this.media,t=this.url,s=this.url=B.buildAbsoluteURL(self.location.href,i,{alwaysNormalize:!0});E.logger.log("loadSource:"+s),r&&t&&t!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(r)),this.trigger(e.Events.MANIFEST_LOADING,{url:i})},p.startLoad=function(i){i===void 0&&(i=-1),E.logger.log("startLoad("+i+")"),this.networkControllers.forEach(function(r){r.startLoad(i)})},p.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(i){i.stopLoad()})},p.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},p.recoverMediaError=function(){E.logger.log("recoverMediaError");var i=this._media;this.detachMedia(),i&&this.attachMedia(i)},p.removeLevel=function(i,r){r===void 0&&(r=0),this.levelController.removeLevel(i,r)},f(u,[{key:"levels",get:function(){var i=this.levelController.levels;return i||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(i){E.logger.log("set currentLevel:"+i),this.loadLevel=i,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(i){E.logger.log("set nextLevel:"+i),this.levelController.manualLevel=i,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(i){E.logger.log("set loadLevel:"+i),this.levelController.manualLevel=i}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(i){this.levelController.nextLoadLevel=i}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(i){E.logger.log("set firstLevel:"+i),this.levelController.firstLevel=i}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(i){E.logger.log("set startLevel:"+i),i!==-1&&(i=Math.max(i,this.minAutoLevel)),this.levelController.startLevel=i}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(i){var r=!!i;r!==this.config.capLevelToPlayerSize&&(r?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=r)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(i){this._autoLevelCapping!==i&&(E.logger.log("set autoLevelCapping:"+i),this._autoLevelCapping=i)}},{key:"bandwidthEstimate",get:function(){var i=this.abrController.bwEstimator;return i?i.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var i=this.levels,r=this.config.minAutoBitrate;if(!i)return 0;for(var t=i.length,s=0;s<t;s++)if(i[s].maxBitrate>r)return s;return 0}},{key:"maxAutoLevel",get:function(){var i=this.levels,r=this.autoLevelCapping,t;return r===-1&&i&&i.length?t=i.length-1:t=r,t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(i){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,i)}},{key:"audioTracks",get:function(){var i=this.audioTrackController;return i?i.audioTracks:[]}},{key:"audioTrack",get:function(){var i=this.audioTrackController;return i?i.audioTrack:-1},set:function(i){var r=this.audioTrackController;r&&(r.audioTrack=i)}},{key:"subtitleTracks",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTrack:-1},set:function(i){var r=this.subtitleTrackController;r&&(r.subtitleTrack=i)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var i=this.subtitleTrackController;return i?i.subtitleDisplay:!1},set:function(i){var r=this.subtitleTrackController;r&&(r.subtitleDisplay=i)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(i){this.config.lowLatencyMode=i}},{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 e.Events}},{key:"ErrorTypes",get:function(){return a.ErrorTypes}},{key:"ErrorDetails",get:function(){return a.ErrorDetails}},{key:"DefaultConfig",get:function(){return u.defaultConfig?u.defaultConfig:b.hlsDefaultConfig},set:function(i){u.defaultConfig=i}}]),u}();d.defaultConfig=void 0},"./src/is-supported.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"isSupported",function(){return A}),S.d(U,"changeTypeSupported",function(){return _});var B=S("./src/utils/mediasource-helper.ts");function O(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var M=Object(B.getMediaSource)();if(!M)return!1;var L=O(),w=M&&typeof M.isTypeSupported=="function"&&M.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!w&&!!y}function _(){var M,L=O();return typeof(L==null||((M=L.prototype)===null||M===void 0)?void 0:M.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return E}),S.d(U,"LoadError",function(){return v});var B=S("./src/polyfills/number.ts"),O=S("./src/errors.ts");function A(h,e){h.prototype=Object.create(e.prototype),h.prototype.constructor=h,y(h,e)}function _(h){var e=typeof Map=="function"?new Map:void 0;return _=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 e!="undefined"){if(e.has(o))return e.get(o);e.set(o,f)}function f(){return M(o,arguments,x(this).constructor)}return f.prototype=Object.create(o.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),y(f,o)},_(h)}function M(h,e,a){return L()?M=Reflect.construct:M=function(f,d,u){var p=[null];p.push.apply(p,d);var c=Function.bind.apply(f,p),i=new c;return u&&y(i,u.prototype),i},M.apply(null,arguments)}function L(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(h){return!1}}function w(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function y(h,e){return y=Object.setPrototypeOf||function(o,f){return o.__proto__=f,o},y(h,e)}function x(h){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},x(h)}var C=Math.pow(2,17),E=function(){function h(a){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=a}var e=h.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(o,f){var d=this,u=o.url;if(!u)return Promise.reject(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,networkDetails:null},"Fragment does not have a "+(u?"part list":"url")));this.abort();var p=this.config,c=p.fLoader,i=p.loader;return new Promise(function(r,t){d.loader&&d.loader.destroy();var s=d.loader=o.loader=c?new c(p):new i(p),m=b(o),g={timeout:p.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:p.fragLoadingMaxRetryTimeout,highWaterMark:C};o.stats=s.stats,s.load(m,g,{onSuccess:function(P,I,F,K){d.resetLoader(o,s),r({frag:o,part:null,payload:P.data,networkDetails:K})},onError:function(P,I,F){d.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:P,networkDetails:F}))},onAbort:function(P,I,F){d.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,networkDetails:F}))},onTimeout:function(P,I,F){d.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,networkDetails:F}))},onProgress:function(P,I,F,K){f&&f({frag:o,part:null,payload:F,networkDetails:K})}})})},e.loadPart=function(o,f,d){var u=this;this.abort();var p=this.config,c=p.fLoader,i=p.loader;return new Promise(function(r,t){u.loader&&u.loader.destroy();var s=u.loader=o.loader=c?new c(p):new i(p),m=b(o,f),g={timeout:p.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:p.fragLoadingMaxRetryTimeout,highWaterMark:C};f.stats=s.stats,s.load(m,g,{onSuccess:function(P,I,F,K){u.resetLoader(o,s),u.updateStatsFromPart(o,f);var V={frag:o,part:f,payload:P.data,networkDetails:K};d(V),r(V)},onError:function(P,I,F){u.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,part:f,response:P,networkDetails:F}))},onAbort:function(P,I,F){o.stats.aborted=f.stats.aborted,u.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,part:f,networkDetails:F}))},onTimeout:function(P,I,F){u.resetLoader(o,s),t(new v({type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,part:f,networkDetails:F}))}})})},e.updateStatsFromPart=function(o,f){var d=o.stats,u=f.stats,p=u.total;if(d.loaded+=u.loaded,p){var c=Math.round(o.duration/f.duration),i=Math.min(Math.round(d.loaded/p),c),r=c-i,t=r*Math.round(d.loaded/i);d.total=d.loaded+t}else d.total=Math.max(d.loaded,d.total);var s=d.loading,m=u.loading;s.start?s.first+=m.first-m.start:(s.start=m.start,s.first=m.first),s.end=m.end},e.resetLoader=function(o,f){o.loader=null,this.loader===f&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),f.destroy()},h}();function b(h,e){e===void 0&&(e=null);var a=e||h,o={frag:h,part:e,responseType:"arraybuffer",url:a.url,headers:{},rangeStart:0,rangeEnd:0},f=a.byteRangeStartOffset,d=a.byteRangeEndOffset;return Object(B.isFiniteNumber)(f)&&Object(B.isFiniteNumber)(d)&&(o.rangeStart=f,o.rangeEnd=d),o}var v=function(h){A(e,h);function e(a){for(var o,f=arguments.length,d=new Array(f>1?f-1:0),u=1;u<f;u++)d[u-1]=arguments[u];return o=h.call.apply(h,[this].concat(d))||this,o.data=void 0,o.data=a,o}return e}(_(Error))},"./src/loader/fragment.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"ElementaryStreamTypes",function(){return E}),S.d(U,"BaseSegment",function(){return b}),S.d(U,"Fragment",function(){return v}),S.d(U,"Part",function(){return h});var B=S("./src/polyfills/number.ts"),O=S("./node_modules/url-toolkit/src/url-toolkit.js"),A=S.n(O),_=S("./src/utils/logger.ts"),M=S("./src/loader/level-key.ts"),L=S("./src/loader/load-stats.ts");function w(e,a){e.prototype=Object.create(a.prototype),e.prototype.constructor=e,y(e,a)}function y(e,a){return y=Object.setPrototypeOf||function(f,d){return f.__proto__=d,f},y(e,a)}function x(e,a){for(var o=0;o<a.length;o++){var f=a[o];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(e,f.key,f)}}function C(e,a,o){return a&&x(e.prototype,a),o&&x(e,o),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var b=function(){function e(o){var f;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(f={},f[E.AUDIO]=null,f[E.VIDEO]=null,f[E.AUDIOVIDEO]=null,f),this.baseurl=o}var a=e.prototype;return a.setByteRange=function(f,d){var u=f.split("@",2),p=[];u.length===1?p[0]=d?d.byteRangeEndOffset:0:p[0]=parseInt(u[1]),p[1]=parseInt(u[0])+p[0],this._byteRange=p},C(e,[{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(O.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(f){this._url=f}}]),e}(),v=function(e){w(a,e);function a(f,d){var u;return u=e.call(this,d)||this,u._decryptdata=null,u.rawProgramDateTime=null,u.programDateTime=null,u.tagList=[],u.duration=0,u.sn=0,u.levelkey=void 0,u.type=void 0,u.loader=null,u.level=-1,u.cc=0,u.startPTS=void 0,u.endPTS=void 0,u.appendedPTS=void 0,u.startDTS=void 0,u.endDTS=void 0,u.start=0,u.deltaPTS=void 0,u.maxStartPTS=void 0,u.minEndPTS=void 0,u.stats=new L.LoadStats,u.urlId=0,u.data=void 0,u.bitrateTest=!1,u.title=null,u.initSegment=null,u.type=f,u}var o=a.prototype;return o.createInitializationVector=function(d){for(var u=new Uint8Array(16),p=12;p<16;p++)u[p]=d>>8*(15-p)&255;return u},o.setDecryptDataFromLevelKey=function(d,u){var p=d;return(d==null?void 0:d.method)==="AES-128"&&d.uri&&!d.iv&&(p=M.LevelKey.fromURI(d.uri),p.method=d.method,p.iv=this.createInitializationVector(u),p.keyFormat="identity"),p},o.setElementaryStreamInfo=function(d,u,p,c,i,r){r===void 0&&(r=!1);var t=this.elementaryStreams,s=t[d];if(!s){t[d]={startPTS:u,endPTS:p,startDTS:c,endDTS:i,partial:r};return}s.startPTS=Math.min(s.startPTS,u),s.endPTS=Math.max(s.endPTS,p),s.startDTS=Math.min(s.startDTS,c),s.endDTS=Math.max(s.endDTS,i)},o.clearElementaryStreamInfo=function(){var d=this.elementaryStreams;d[E.AUDIO]=null,d[E.VIDEO]=null,d[E.AUDIOVIDEO]=null},C(a,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var d=this.sn;typeof d!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&_.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),d=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,d)}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 d=Object(B.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+d*1e3}},{key:"encrypted",get:function(){var d;return!!((d=this.decryptdata)!==null&&d!==void 0&&d.keyFormat&&this.decryptdata.uri)}}]),a}(b),h=function(e){w(a,e);function a(o,f,d,u,p){var c;c=e.call(this,d)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new L.LoadStats,c.duration=o.decimalFloatingPoint("DURATION"),c.gap=o.bool("GAP"),c.independent=o.bool("INDEPENDENT"),c.relurl=o.enumeratedString("URI"),c.fragment=f,c.index=u;var i=o.enumeratedString("BYTERANGE");return i&&c.setByteRange(i,p),p&&(c.fragOffset=p.fragOffset+p.duration),c}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 f=this.elementaryStreams;return!!(f.audio||f.video||f.audiovideo)}}]),a}(b)},"./src/loader/key-loader.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return _});var B=S("./src/events.ts"),O=S("./src/errors.ts"),A=S("./src/utils/logger.ts"),_=function(){function M(w){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=w,this._registerListeners()}var L=M.prototype;return L._registerListeners=function(){this.hls.on(B.Events.KEY_LOADING,this.onKeyLoading,this)},L._unregisterListeners=function(){this.hls.off(B.Events.KEY_LOADING,this.onKeyLoading)},L.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var x=this.loaders[y];x&&x.destroy()}this.loaders={}},L.onKeyLoading=function(y,x){var C=x.frag,E=C.type,b=this.loaders[E];if(!C.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var v=C.decryptdata.uri;if(v!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(b&&(A.logger.warn("abort previous key loader for type:"+E),b.abort()),!v){A.logger.warn("key uri is falsy");return}var e=h.loader,a=C.loader=this.loaders[E]=new e(h);this.decrypturl=v,this.decryptkey=null;var o={url:v,frag:C,responseType:"arraybuffer"},f={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(o,f,d)}else this.decryptkey&&(C.decryptdata.key=this.decryptkey,this.hls.trigger(B.Events.KEY_LOADED,{frag:C}))},L.loadsuccess=function(y,x,C){var E=C.frag;if(!E.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(B.Events.KEY_LOADED,{frag:E})},L.loaderror=function(y,x){var C=x.frag,E=C.loader;E&&E.abort(),delete this.loaders[C.type],this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:C,response:y})},L.loadtimeout=function(y,x){var C=x.frag,E=C.loader;E&&E.abort(),delete this.loaders[C.type],this.hls.trigger(B.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:C})},M}()},"./src/loader/level-details.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"LevelDetails",function(){return M});var B=S("./src/polyfills/number.ts");function O(L,w){for(var y=0;y<w.length;y++){var x=w[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(L,x.key,x)}}function A(L,w,y){return w&&O(L.prototype,w),y&&O(L,y),L}var _=10,M=function(){function L(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=y}var w=L.prototype;return w.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var C=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!C,this.advanced=this.endSN>x.endSN||C>0||C===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},A(L,[{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||_}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var C=this.driftEnd-this.driftStart;return C*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"LevelKey",function(){return M});var B=S("./node_modules/url-toolkit/src/url-toolkit.js"),O=S.n(B);function A(L,w){for(var y=0;y<w.length;y++){var x=w[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(L,x.key,x)}}function _(L,w,y){return w&&A(L.prototype,w),y&&A(L,y),L}var M=function(){L.fromURL=function(y,x){return new L(y,x)},L.fromURI=function(y){return new L(y)};function L(w,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(B.buildAbsoluteURL)(w,y,{alwaysNormalize:!0}):this._uri=w}return _(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"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(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return a});var B=S("./src/polyfills/number.ts"),O=S("./node_modules/url-toolkit/src/url-toolkit.js"),A=S.n(O),_=S("./src/loader/fragment.ts"),M=S("./src/loader/level-details.ts"),L=S("./src/loader/level-key.ts"),w=S("./src/utils/attr-list.ts"),y=S("./src/utils/logger.ts"),x=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,E=/#EXT-X-MEDIA:(.*)/g,b=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),v=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),h=/\.(mp4|m4s|m4v|m4a)$/i;function e(p){var c,i;return h.test((c=(i=O.parseURL(p))===null||i===void 0?void 0:i.path)!=null?c:"")}var a=function(){function p(){}return p.findGroup=function(i,r){for(var t=0;t<i.length;t++){var s=i[t];if(s.id===r)return s}},p.convertAVC1ToAVCOTI=function(i){var r=i.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4),t}return i},p.resolve=function(i,r){return O.buildAbsoluteURL(r,i,{alwaysNormalize:!0})},p.parseMasterPlaylist=function(i,r){var t=[],s={},m=!1;C.lastIndex=0;for(var g;(g=C.exec(i))!=null;)if(g[1]){var T=new w.AttrList(g[1]),P={attrs:T,bitrate:T.decimalInteger("AVERAGE-BANDWIDTH")||T.decimalInteger("BANDWIDTH"),name:T.NAME,url:p.resolve(g[2],r)},I=T.decimalResolution("RESOLUTION");I&&(P.width=I.width,P.height=I.height),o((T.CODECS||"").split(/[ ,]+/).filter(function(K){return K}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=p.convertAVC1ToAVCOTI(P.videoCodec)),t.push(P)}else if(g[3]){var F=new w.AttrList(g[3]);F["DATA-ID"]&&(m=!0,s[F["DATA-ID"]]=F)}return{levels:t,sessionData:m?s:null}},p.parseMasterPlaylistMedia=function(i,r,t,s){s===void 0&&(s=[]);var m,g=[],T=0;for(E.lastIndex=0;(m=E.exec(i))!==null;){var P=new w.AttrList(m[1]);if(P.TYPE===t){var I={attrs:P,bitrate:0,id:T++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:t,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?p.resolve(P.URI,r):""};if(s.length){var F=p.findGroup(s,I.groupId)||s[0];f(I,F,"audioCodec"),f(I,F,"textCodec")}g.push(I)}}return g},p.parseLevelPlaylist=function(i,r,t,s,m){var g=new M.LevelDetails(r),T=g.fragments,P=null,I=0,F=0,K=0,V=0,Q=null,Z=new _.Fragment(s,r),ie,pe,ae,de=-1,le=!1;for(b.lastIndex=0,g.m3u8=i;(ie=b.exec(i))!==null;){le&&(le=!1,Z=new _.Fragment(s,r),Z.start=K,Z.sn=I,Z.cc=V,Z.level=t,P&&(Z.initSegment=P,Z.rawProgramDateTime=P.rawProgramDateTime));var $=ie[1];if($){Z.duration=parseFloat($);var Y=(" "+ie[2]).slice(1);Z.title=Y||null,Z.tagList.push(Y?["INF",$,Y]:["INF",$])}else if(ie[3])Object(B.isFiniteNumber)(Z.duration)&&(Z.start=K,ae&&(Z.levelkey=ae),Z.sn=I,Z.level=t,Z.cc=V,Z.urlId=m,T.push(Z),Z.relurl=(" "+ie[3]).slice(1),u(Z,Q),Q=Z,K+=Z.duration,I++,F=0,le=!0);else if(ie[4]){var ne=(" "+ie[4]).slice(1);Q?Z.setByteRange(ne,Q):Z.setByteRange(ne)}else if(ie[5])Z.rawProgramDateTime=(" "+ie[5]).slice(1),Z.tagList.push(["PROGRAM-DATE-TIME",Z.rawProgramDateTime]),de===-1&&(de=T.length);else{if(ie=ie[0].match(v),!ie){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(pe=1;pe<ie.length&&!(typeof ie[pe]!="undefined");pe++);var z=(" "+ie[pe]).slice(1),H=(" "+ie[pe+1]).slice(1),me=ie[pe+2]?(" "+ie[pe+2]).slice(1):"";switch(z){case"PLAYLIST-TYPE":g.type=H.toUpperCase();break;case"MEDIA-SEQUENCE":I=g.startSN=parseInt(H);break;case"SKIP":{var Le=new w.AttrList(H),Oe=Le.decimalInteger("SKIPPED-SEGMENTS");if(Object(B.isFiniteNumber)(Oe)){g.skippedSegments=Oe;for(var Ae=Oe;Ae--;)T.unshift(null);I+=Oe}var Re=Le.enumeratedString("RECENTLY-REMOVED-DATERANGES");Re&&(g.recentlyRemovedDateranges=Re.split(" "));break}case"TARGETDURATION":g.targetduration=parseFloat(H);break;case"VERSION":g.version=parseInt(H);break;case"EXTM3U":break;case"ENDLIST":g.live=!1;break;case"#":(H||me)&&Z.tagList.push(me?[H,me]:[H]);break;case"DIS":V++;case"GAP":Z.tagList.push([z]);break;case"BITRATE":Z.tagList.push([z,H]);break;case"DISCONTINUITY-SEQ":V=parseInt(H);break;case"KEY":{var fe,ye=new w.AttrList(H),xe=ye.enumeratedString("METHOD"),Se=ye.URI,Ne=ye.hexadecimalInteger("IV"),Pe=ye.enumeratedString("KEYFORMATVERSIONS"),_e=ye.enumeratedString("KEYID"),Fe=(fe=ye.enumeratedString("KEYFORMAT"))!=null?fe:"identity",se=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(se.indexOf(Fe)>-1){y.logger.warn("Keyformat "+Fe+" is not supported from the manifest");continue}else if(Fe!=="identity")continue;xe&&(ae=L.LevelKey.fromURL(r,Se),Se&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(xe)>=0&&(ae.method=xe,ae.keyFormat=Fe,_e&&(ae.keyID=_e),Pe&&(ae.keyFormatVersions=Pe),ae.iv=Ne));break}case"START":{var ue=new w.AttrList(H),be=ue.decimalFloatingPoint("TIME-OFFSET");Object(B.isFiniteNumber)(be)&&(g.startTimeOffset=be);break}case"MAP":{var Ee=new w.AttrList(H);Z.relurl=Ee.URI,Ee.BYTERANGE&&Z.setByteRange(Ee.BYTERANGE),Z.level=t,Z.sn="initSegment",ae&&(Z.levelkey=ae),Z.initSegment=null,P=Z,le=!0;break}case"SERVER-CONTROL":{var Ce=new w.AttrList(H);g.canBlockReload=Ce.bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=Ce.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&Ce.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=Ce.optionalFloat("PART-HOLD-BACK",0),g.holdBack=Ce.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Te=new w.AttrList(H);g.partTarget=Te.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ve=g.partList;ve||(ve=g.partList=[]);var Ie=F>0?ve[ve.length-1]:void 0,Be=F++,ge=new _.Part(new w.AttrList(H),Z,r,Be,Ie);ve.push(ge),Z.duration+=ge.duration;break}case"PRELOAD-HINT":{var Me=new w.AttrList(H);g.preloadHint=Me;break}case"RENDITION-REPORT":{var re=new w.AttrList(H);g.renditionReports=g.renditionReports||[],g.renditionReports.push(re);break}default:y.logger.warn("line parsed but not handled: "+ie);break}}}Q&&!Q.relurl?(T.pop(),K-=Q.duration,g.partList&&(g.fragmentHint=Q)):g.partList&&(u(Z,Q),Z.cc=V,g.fragmentHint=Z);var q=T.length,te=T[0],j=T[q-1];if(K+=g.skippedSegments*g.targetduration,K>0&&q&&j){g.averagetargetduration=K/q;var W=j.sn;g.endSN=W!=="initSegment"?W:0,te&&(g.startCC=te.cc,te.initSegment||g.fragments.every(function(G){return G.relurl&&e(G.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Z=new _.Fragment(s,r),Z.relurl=j.relurl,Z.level=t,Z.sn="initSegment",te.initSegment=Z,g.needSidxRanges=!0))}else g.endSN=0,g.startCC=0;return g.fragmentHint&&(K+=g.fragmentHint.duration),g.totalduration=K,g.endCC=V,de>0&&d(T,de),g},p}();function o(p,c){["video","audio","text"].forEach(function(i){var r=p.filter(function(s){return Object(x.isCodecType)(s,i)});if(r.length){var t=r.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});c[i+"Codec"]=t.length>0?t[0]:r[0],p=p.filter(function(s){return r.indexOf(s)===-1})}}),c.unknownCodecs=p}function f(p,c,i){var r=c[i];r&&(p[i]=r)}function d(p,c){for(var i=p[c],r=c;r--;){var t=p[r];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function u(p,c){p.rawProgramDateTime?p.programDateTime=Date.parse(p.rawProgramDateTime):c!=null&&c.programDateTime&&(p.programDateTime=c.endProgramDateTime),Object(B.isFiniteNumber)(p.programDateTime)||(p.programDateTime=null,p.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/polyfills/number.ts"),O=S("./src/events.ts"),A=S("./src/errors.ts"),_=S("./src/utils/logger.ts"),M=S("./src/utils/mp4-tools.ts"),L=S("./src/loader/m3u8-parser.ts"),w=S("./src/types/loader.ts"),y=S("./src/utils/attr-list.ts");function x(b){var v=b.type;switch(v){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(b,v){var h=b.url;return(h===void 0||h.indexOf("data:")===0)&&(h=v.url),h}var E=function(){function b(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var v=b.prototype;return v.registerListeners=function(){var e=this.hls;e.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},v.unregisterListeners=function(){var e=this.hls;e.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(O.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},v.createInternalLoader=function(e){var a=this.hls.config,o=a.pLoader,f=a.loader,d=o||f,u=new d(a);return e.loader=u,this.loaders[e.type]=u,u},v.getInternalLoader=function(e){return this.loaders[e.type]},v.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},v.destroyInternalLoaders=function(){for(var e in this.loaders){var a=this.loaders[e];a&&a.destroy(),this.resetInternalLoader(e)}},v.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},v.onManifestLoading=function(e,a){var o=a.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:w.PlaylistContextType.MANIFEST,url:o,deliveryDirectives:null})},v.onLevelLoading=function(e,a){var o=a.id,f=a.level,d=a.url,u=a.deliveryDirectives;this.load({id:o,groupId:null,level:f,responseType:"text",type:w.PlaylistContextType.LEVEL,url:d,deliveryDirectives:u})},v.onAudioTrackLoading=function(e,a){var o=a.id,f=a.groupId,d=a.url,u=a.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.AUDIO_TRACK,url:d,deliveryDirectives:u})},v.onSubtitleTrackLoading=function(e,a){var o=a.id,f=a.groupId,d=a.url,u=a.deliveryDirectives;this.load({id:o,groupId:f,level:null,responseType:"text",type:w.PlaylistContextType.SUBTITLE_TRACK,url:d,deliveryDirectives:u})},v.load=function(e){var a,o=this.hls.config,f=this.getInternalLoader(e);if(f){var d=f.context;if(d&&d.url===e.url){_.logger.trace("[playlist-loader]: playlist request ongoing");return}_.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),f.abort()}var u,p,c,i;switch(e.type){case w.PlaylistContextType.MANIFEST:u=o.manifestLoadingMaxRetry,p=o.manifestLoadingTimeOut,c=o.manifestLoadingRetryDelay,i=o.manifestLoadingMaxRetryTimeout;break;case w.PlaylistContextType.LEVEL:case w.PlaylistContextType.AUDIO_TRACK:case w.PlaylistContextType.SUBTITLE_TRACK:u=0,p=o.levelLoadingTimeOut;break;default:u=o.levelLoadingMaxRetry,p=o.levelLoadingTimeOut,c=o.levelLoadingRetryDelay,i=o.levelLoadingMaxRetryTimeout;break}if(f=this.createInternalLoader(e),(a=e.deliveryDirectives)!==null&&a!==void 0&&a.part){var r;if(e.type===w.PlaylistContextType.LEVEL&&e.level!==null?r=this.hls.levels[e.level].details:e.type===w.PlaylistContextType.AUDIO_TRACK&&e.id!==null?r=this.hls.audioTracks[e.id].details:e.type===w.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(r=this.hls.subtitleTracks[e.id].details),r){var t=r.partTarget,s=r.targetduration;t&&s&&(p=Math.min(Math.max(t*3,s*.8)*1e3,p))}}var m={timeout:p,maxRetry:u,retryDelay:c,maxRetryDelay:i,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};f.load(e,m,g)},v.loadsuccess=function(e,a,o,f){if(f===void 0&&(f=null),o.isSidxRequest){this.handleSidxRequest(e,o),this.handlePlaylistLoaded(e,a,o,f);return}this.resetInternalLoader(o.type);var d=e.data;if(d.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,o,"no EXTM3U delimiter",f);return}a.parsing.start=performance.now(),d.indexOf("#EXTINF:")>0||d.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,a,o,f):this.handleMasterPlaylist(e,a,o,f)},v.loaderror=function(e,a,o){o===void 0&&(o=null),this.handleNetworkError(a,o,!1,e)},v.loadtimeout=function(e,a,o){o===void 0&&(o=null),this.handleNetworkError(a,o,!0)},v.handleMasterPlaylist=function(e,a,o,f){var d=this.hls,u=e.data,p=C(e,o),c=L.default.parseMasterPlaylist(u,p),i=c.levels,r=c.sessionData;if(!i.length){this.handleManifestParsingError(e,o,"no level found in manifest",f);return}var t=i.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),s=i.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),m=L.default.parseMasterPlaylistMedia(u,p,"AUDIO",t),g=L.default.parseMasterPlaylistMedia(u,p,"SUBTITLES",s),T=L.default.parseMasterPlaylistMedia(u,p,"CLOSED-CAPTIONS");if(m.length){var P=m.some(function(I){return!I.url});!P&&i[0].audioCodec&&!i[0].attrs.AUDIO&&(_.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}d.trigger(O.Events.MANIFEST_LOADED,{levels:i,audioTracks:m,subtitles:g,captions:T,url:p,stats:a,networkDetails:f,sessionData:r})},v.handleTrackOrLevelPlaylist=function(e,a,o,f){var d=this.hls,u=o.id,p=o.level,c=o.type,i=C(e,o),r=Object(B.isFiniteNumber)(u)?u:0,t=Object(B.isFiniteNumber)(p)?p:r,s=x(o),m=L.default.parseLevelPlaylist(e.data,i,t,s,r);if(!m.fragments.length){d.trigger(O.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:i,reason:"no fragments found in level",level:typeof o.level=="number"?o.level:void 0});return}if(c===w.PlaylistContextType.MANIFEST){var g={attrs:new y.AttrList({}),bitrate:0,details:m,name:"",url:i};d.trigger(O.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:i,stats:a,networkDetails:f,sessionData:null})}if(a.parsing.end=performance.now(),m.needSidxRanges){var T,P=(T=m.fragments[0].initSegment)===null||T===void 0?void 0:T.url;this.load({url:P,isSidxRequest:!0,type:c,level:p,levelDetails:m,id:u,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}o.levelDetails=m,this.handlePlaylistLoaded(e,a,o,f)},v.handleSidxRequest=function(e,a){var o=Object(M.parseSegmentIndex)(new Uint8Array(e.data));if(!o)return;var f=o.references,d=a.levelDetails;f.forEach(function(u,p){var c=u.info,i=d.fragments[p];i.byteRange.length===0&&i.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),i.initSegment&&i.initSegment.setByteRange(String(o.moovEndOffset)+"@0")})},v.handleManifestParsingError=function(e,a,o,f){this.hls.trigger(O.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:a.type===w.PlaylistContextType.MANIFEST,url:e.url,reason:o,response:e,context:a,networkDetails:f})},v.handleNetworkError=function(e,a,o,f){o===void 0&&(o=!1),_.logger.warn("[playlist-loader]: A network "+(o?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var d=A.ErrorDetails.UNKNOWN,u=!1,p=this.getInternalLoader(e);switch(e.type){case w.PlaylistContextType.MANIFEST:d=o?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case w.PlaylistContextType.LEVEL:d=o?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case w.PlaylistContextType.AUDIO_TRACK:d=o?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case w.PlaylistContextType.SUBTITLE_TRACK:d=o?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1;break}p&&this.resetInternalLoader(e.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:d,fatal:u,url:e.url,loader:p,context:e,networkDetails:a};f&&(c.response=f),this.hls.trigger(O.Events.ERROR,c)},v.handlePlaylistLoaded=function(e,a,o,f){var d=o.type,u=o.level,p=o.id,c=o.groupId,i=o.loader,r=o.levelDetails,t=o.deliveryDirectives;if(!(r!=null&&r.targetduration)){this.handleManifestParsingError(e,o,"invalid target duration",f);return}if(!i)return;r.live&&(i.getCacheAge&&(r.ageHeader=i.getCacheAge()||0),(!i.getCacheAge||isNaN(r.ageHeader))&&(r.ageHeader=0));switch(d){case w.PlaylistContextType.MANIFEST:case w.PlaylistContextType.LEVEL:this.hls.trigger(O.Events.LEVEL_LOADED,{details:r,level:u||0,id:p||0,stats:a,networkDetails:f,deliveryDirectives:t});break;case w.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(O.Events.AUDIO_TRACK_LOADED,{details:r,id:p||0,groupId:c||"",stats:a,networkDetails:f,deliveryDirectives:t});break;case w.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADED,{details:r,id:p||0,groupId:c||"",stats:a,networkDetails:f,deliveryDirectives:t});break}},b}();U.default=E},"./src/polyfills/number.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"isFiniteNumber",function(){return B}),S.d(U,"MAX_SAFE_INTEGER",function(){return O});var B=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},O=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ce,U,S){"use strict";S.r(U);var B=function(){function O(){}return O.getSilentFrame=function(_,M){switch(_){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},O}();U.default=B},"./src/remux/mp4-generator.ts":function(ce,U,S){"use strict";S.r(U);var B=Math.pow(2,32)-1,O=function(){function A(){}return A.init=function(){A.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 A.types)A.types.hasOwnProperty(M)&&(A.types[M]=[M.charCodeAt(0),M.charCodeAt(1),M.charCodeAt(2),M.charCodeAt(3)]);var L=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]);A.HDLR_TYPES={video:L,audio:w};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=x,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var C=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,C,b,C,E),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,y))},A.box=function(M){for(var L=8,w=arguments.length,y=new Array(w>1?w-1:0),x=1;x<w;x++)y[x-1]=arguments[x];for(var C=y.length,E=C;C--;)L+=y[C].byteLength;var b=new Uint8Array(L);for(b[0]=L>>24&255,b[1]=L>>16&255,b[2]=L>>8&255,b[3]=L&255,b.set(M,4),C=0,L=8;C<E;C++)b.set(y[C],L),L+=y[C].byteLength;return b},A.hdlr=function(M){return A.box(A.types.hdlr,A.HDLR_TYPES[M])},A.mdat=function(M){return A.box(A.types.mdat,M)},A.mdhd=function(M,L){L*=M;var w=Math.floor(L/(B+1)),y=Math.floor(L%(B+1));return A.box(A.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,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},A.mdia=function(M){return A.box(A.types.mdia,A.mdhd(M.timescale,M.duration),A.hdlr(M.type),A.minf(M))},A.mfhd=function(M){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255]))},A.minf=function(M){return M.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(M)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(M))},A.moof=function(M,L,w){return A.box(A.types.moof,A.mfhd(M),A.traf(w,L))},A.moov=function(M){for(var L=M.length,w=[];L--;)w[L]=A.trak(M[L]);return A.box.apply(null,[A.types.moov,A.mvhd(M[0].timescale,M[0].duration)].concat(w).concat(A.mvex(M)))},A.mvex=function(M){for(var L=M.length,w=[];L--;)w[L]=A.trex(M[L]);return A.box.apply(null,[A.types.mvex].concat(w))},A.mvhd=function(M,L){L*=M;var w=Math.floor(L/(B+1)),y=Math.floor(L%(B+1)),x=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,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,x)},A.sdtp=function(M){var L=M.samples||[],w=new Uint8Array(4+L.length),y,x;for(y=0;y<L.length;y++)x=L[y].flags,w[y+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return A.box(A.types.sdtp,w)},A.stbl=function(M){return A.box(A.types.stbl,A.stsd(M),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))},A.avc1=function(M){var L=[],w=[],y,x,C;for(y=0;y<M.sps.length;y++)x=M.sps[y],C=x.byteLength,L.push(C>>>8&255),L.push(C&255),L=L.concat(Array.prototype.slice.call(x));for(y=0;y<M.pps.length;y++)x=M.pps[y],C=x.byteLength,w.push(C>>>8&255),w.push(C&255),w=w.concat(Array.prototype.slice.call(x));var E=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],252|3,224|M.sps.length].concat(L).concat([M.pps.length]).concat(w))),b=M.width,v=M.height,h=M.pixelRatio[0],e=M.pixelRatio[1];return A.box(A.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,b>>8&255,b&255,v>>8&255,v&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]),E,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,e>>24,e>>16&255,e>>8&255,e&255])))},A.esds=function(M){var L=M.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(M.config).concat([6,1,2]))},A.mp4a=function(M){var L=M.samplerate;return A.box(A.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,L>>8&255,L&255,0,0]),A.box(A.types.esds,A.esds(M)))},A.mp3=function(M){var L=M.samplerate;return A.box(A.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,L>>8&255,L&255,0,0]))},A.stsd=function(M){return M.type==="audio"?!M.isAAC&&M.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(M)):A.box(A.types.stsd,A.STSD,A.mp4a(M)):A.box(A.types.stsd,A.STSD,A.avc1(M))},A.tkhd=function(M){var L=M.id,w=M.duration*M.timescale,y=M.width,x=M.height,C=Math.floor(w/(B+1)),E=Math.floor(w%(B+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,L&255,0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,x>>8&255,x&255,0,0]))},A.traf=function(M,L){var w=A.sdtp(M),y=M.id,x=Math.floor(L/(B+1)),C=Math.floor(L%(B+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,C>>24,C>>16&255,C>>8&255,C&255])),A.trun(M,w.length+16+20+8+16+8+8),w)},A.trak=function(M){return M.duration=M.duration||4294967295,A.box(A.types.trak,A.tkhd(M),A.mdia(M))},A.trex=function(M){var L=M.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(M,L){var w=M.samples||[],y=w.length,x=12+16*y,C=new Uint8Array(x),E,b,v,h,e,a;for(L+=8+x,C.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),E=0;E<y;E++)b=w[E],v=b.duration,h=b.size,e=b.flags,a=b.cts,C.set([v>>>24&255,v>>>16&255,v>>>8&255,v&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,a>>>24&255,a>>>16&255,a>>>8&255,a&255],12+16*E);return A.box(A.types.trun,C)},A.initSegment=function(M){A.types||A.init();var L=A.moov(M),w=new Uint8Array(A.FTYP.byteLength+L.byteLength);return w.set(A.FTYP),w.set(L,A.FTYP.byteLength),w},A}();O.types=void 0,O.HDLR_TYPES=void 0,O.STTS=void 0,O.STSC=void 0,O.STCO=void 0,O.STSZ=void 0,O.VMHD=void 0,O.SMHD=void 0,O.STSD=void 0,O.FTYP=void 0,O.DINF=void 0,U.default=O},"./src/remux/mp4-remuxer.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return a}),S.d(U,"normalizePts",function(){return o});var B=S("./src/polyfills/number.ts"),O=S("./src/remux/aac-helper.ts"),A=S("./src/remux/mp4-generator.ts"),_=S("./src/events.ts"),M=S("./src/errors.ts"),L=S("./src/utils/logger.ts"),w=S("./src/types/loader.ts"),y=S("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(p[r]=i[r])}return p},x.apply(this,arguments)}var C=10*1e3,E=1024,b=1152,v=null,h=null,e=!1,a=function(){function p(i,r,t,s){if(s===void 0&&(s=""),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=i,this.config=r,this.typeSupported=t,this.ISGenerated=!1,v===null){var m=navigator.userAgent||"",g=m.match(/Chrome\/(\d+)/i);v=g?parseInt(g[1]):0}if(h===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);h=T?parseInt(T[1]):0}e=!!v&&v<75||!!h&&h<600}var c=p.prototype;return c.destroy=function(){},c.resetTimeStamp=function(r){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=r},c.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(r){var t=!1,s=r.reduce(function(m,g){var T=g.pts-m;return T<-4294967296?(t=!0,o(m,g.pts)):T>0?m:g.pts},r[0].pts);return t&&L.logger.debug("PTS rollover detected"),s},c.remux=function(r,t,s,m,g,T,P,I){var F,K,V,Q,Z,ie,pe=g,ae=g,de=r.pid>-1,le=t.pid>-1,$=t.samples.length,Y=r.samples.length>0,ne=$>1,z=(!de||Y)&&(!le||ne)||this.ISGenerated||P;if(z){this.ISGenerated||(V=this.generateIS(r,t,g));var H=this.isVideoContiguous,me=-1;if(ne&&(me=f(t.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(ie=!0,me>0){L.logger.warn("[mp4-remuxer]: Dropped "+me+" out of "+$+" video samples due to a missing keyframe");var Le=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(me),t.dropped+=me,ae+=(t.samples[0].pts-Le)/(t.timescale||9e4)}else me===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+$+" video samples"),ie=!1);if(this.ISGenerated){if(Y&&ne){var Oe=this.getVideoStartPts(t.samples),Ae=o(r.samples[0].pts,Oe)-Oe,Re=Ae/t.inputTimeScale;pe+=Math.max(0,Re),ae+=Math.max(0,-Re)}if(Y){if(r.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),V=this.generateIS(r,t,g)),K=this.remuxAudio(r,pe,this.isAudioContiguous,T,le||ne||I===w.PlaylistLevelType.AUDIO?ae:void 0),ne){var fe=K?K.endPTS-K.startPTS:0;t.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),V=this.generateIS(r,t,g)),F=this.remuxVideo(t,ae,H,fe)}}else ne&&(F=this.remuxVideo(t,ae,H,0));F&&(F.firstKeyFrame=me,F.independent=me!==-1)}}return this.ISGenerated&&(s.samples.length&&(Z=this.remuxID3(s,g)),m.samples.length&&(Q=this.remuxText(m,g))),{audio:K,video:F,initSegment:V,independent:ie,text:Q,id3:Z}},c.generateIS=function(r,t,s){var m=r.samples,g=t.samples,T=this.typeSupported,P={},I=!Object(B.isFiniteNumber)(this._initPTS),F="audio/mp4",K,V,Q;if(I&&(K=V=Infinity),r.config&&m.length&&(r.timescale=r.samplerate,r.isAAC||(T.mpeg?(F="audio/mpeg",r.codec=""):T.mp3&&(r.codec="mp3")),P.audio={id:"audio",container:F,codec:r.codec,initSegment:!r.isAAC&&T.mpeg?new Uint8Array(0):A.default.initSegment([r]),metadata:{channelCount:r.channelCount}},I&&(Q=r.inputTimeScale,K=V=m[0].pts-Math.round(Q*s))),t.sps&&t.pps&&g.length&&(t.timescale=t.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:A.default.initSegment([t]),metadata:{width:t.width,height:t.height}},I)){Q=t.inputTimeScale;var Z=this.getVideoStartPts(g),ie=Math.round(Q*s);V=Math.min(V,o(g[0].dts,Z)-ie),K=Math.min(K,Z-ie)}if(Object.keys(P).length)return this.ISGenerated=!0,I&&(this._initPTS=K,this._initDTS=V),{tracks:P,initPTS:K,timescale:Q}},c.remuxVideo=function(r,t,s,m){var g=r.inputTimeScale,T=r.samples,P=[],I=T.length,F=this._initPTS,K=this.nextAvcDts,V=8,Q,Z,ie,pe=Number.POSITIVE_INFINITY,ae=Number.NEGATIVE_INFINITY,de=0,le=!1;if(!s||K===null){var $=t*g,Y=T[0].pts-o(T[0].dts,T[0].pts);K=$-Y}for(var ne=0;ne<I;ne++){var z=T[ne];if(z.pts=o(z.pts-F,K),z.dts=o(z.dts-F,K),z.dts>z.pts){var H=9e4*.2;de=Math.max(Math.min(de,z.pts-z.dts),-1*H)}z.dts<T[ne>0?ne-1:ne].dts&&(le=!0)}le&&T.sort(function(Ze,et){var Xe=Ze.dts-et.dts,mt=Ze.pts-et.pts;return Xe||mt}),Z=T[0].dts,ie=T[T.length-1].dts;var me=Math.round((ie-Z)/(I-1));if(de<0){if(de<me*-2){L.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-me,!0)+" ms");for(var Le=de,Oe=0;Oe<I;Oe++)T[Oe].dts=Le=Math.max(Le,T[Oe].pts-me),T[Oe].pts=Math.max(Le,T[Oe].pts)}else{L.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(de,!0)+" ms to overcome this issue");for(var Ae=0;Ae<I;Ae++)T[Ae].dts=T[Ae].dts+de}Z=T[0].dts}if(s){var Re=Z-K,fe=Re>me,ye=Re<-1;if(fe||ye){fe?L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms ("+Re+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-Re,!0)+" ms ("+Re+"dts) overlapping between fragments detected"),Z=K;var xe=T[0].pts-Re;T[0].dts=Z,T[0].pts=xe,L.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(xe,!0)+"/"+Object(y.toMsFromMpegTsClock)(Z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(Re,!0)+" ms")}}e&&(Z=Math.max(0,Z));for(var Se=0,Ne=0,Pe=0;Pe<I;Pe++){for(var _e=T[Pe],Fe=_e.units,se=Fe.length,ue=0,be=0;be<se;be++)ue+=Fe[be].data.length;Ne+=ue,Se+=se,_e.length=ue,_e.dts=Math.max(_e.dts,Z),_e.pts=Math.max(_e.pts,_e.dts,0),pe=Math.min(_e.pts,pe),ae=Math.max(_e.pts,ae)}ie=T[I-1].dts;var Ee=Ne+4*Se+8,Ce;try{Ce=new Uint8Array(Ee)}catch(Ze){this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating video mdat "+Ee});return}var Te=new DataView(Ce.buffer);Te.setUint32(0,Ee),Ce.set(A.default.types.mdat,4);for(var ve=0;ve<I;ve++){for(var Ie=T[ve],Be=Ie.units,ge=0,Me=0,re=Be.length;Me<re;Me++){var q=Be[Me],te=q.data,j=q.data.byteLength;Te.setUint32(V,j),V+=4,Ce.set(te,V),V+=j,ge+=4+j}if(ve<I-1)Q=T[ve+1].dts-Ie.dts;else{var W=this.config,G=Ie.dts-T[ve>0?ve-1:ve].dts;if(W.stretchShortVideoTrack&&this.nextAudioPts!==null){var X=Math.floor(W.maxBufferHole*g),oe=(m?pe+m*g:this.nextAudioPts)-Ie.pts;oe>X?(Q=oe-G,Q<0&&(Q=G),L.logger.log("[mp4-remuxer]: It is approximately "+oe/90+" ms to the next segment; using duration "+Q/90+" ms for the last video frame.")):Q=G}else Q=G}var he=Math.round(Ie.pts-Ie.dts);P.push(new d(Ie.key,Q,ge,he))}if(P.length&&v&&v<70){var ke=P[0].flags;ke.dependsOn=2,ke.isNonSync=0}console.assert(Q!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=K=ie+Q,this.isVideoContiguous=!0;var He=A.default.moof(r.sequenceNumber++,Z,x({},r,{samples:P})),$e="video",ze={data1:He,data2:Ce,startPTS:pe/g,endPTS:(ae+Q)/g,startDTS:Z/g,endDTS:K/g,type:$e,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:r.dropped};return r.samples=[],r.dropped=0,console.assert(Ce.length,"MDAT length must not be zero"),ze},c.remuxAudio=function(r,t,s,m,g){var T=r.inputTimeScale,P=r.samplerate?r.samplerate:T,I=T/P,F=r.isAAC?E:b,K=F*I,V=this._initPTS,Q=!r.isAAC&&this.typeSupported.mpeg,Z=[],ie=r.samples,pe=Q?0:8,ae=this.nextAudioPts||-1,de=t*T;if(this.isAudioContiguous=s=s||ie.length&&ae>0&&(m&&Math.abs(de-ae)<9e3||Math.abs(o(ie[0].pts-V,de)-ae)<20*K),ie.forEach(function(te){te.pts=o(te.pts-V,de)}),!s||ae<0){if(ie=ie.filter(function(te){return te.pts>=0}),!ie.length)return;g===0?ae=0:m?ae=Math.max(0,de):ae=ie[0].pts}if(r.isAAC)for(var le=g!==void 0,$=this.config.maxAudioFramesDrift,Y=0,ne=ae;Y<ie.length;Y++){var z=ie[Y],H=z.pts,me=H-ne,Le=Math.abs(1e3*me/T);if(me<=-$*K&&le)Y===0&&(L.logger.warn("Audio frame @ "+(H/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*me/T)+" ms."),this.nextAudioPts=ae=ne=H);else if(me>=$*K&&Le<C&&le){var Oe=Math.round(me/K);ne=H-Oe*K,ne<0&&(Oe--,ne+=K),Y===0&&(this.nextAudioPts=ae=ne),L.logger.warn("[mp4-remuxer]: Injecting "+Oe+" audio frame @ "+(ne/T).toFixed(3)+"s due to "+Math.round(1e3*me/T)+" ms gap.");for(var Ae=0;Ae<Oe;Ae++){var Re=Math.max(ne,0),fe=O.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);fe||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),fe=z.unit.subarray()),ie.splice(Y,0,{unit:fe,pts:Re}),ne+=K,Y++}}z.pts=ne,ne+=K}for(var ye=null,xe=null,Se,Ne=0,Pe=ie.length;Pe--;)Ne+=ie[Pe].unit.byteLength;for(var _e=0,Fe=ie.length;_e<Fe;_e++){var se=ie[_e],ue=se.unit,be=se.pts;if(xe!==null){var Ee=Z[_e-1];Ee.duration=Math.round((be-xe)/I)}else if(s&&r.isAAC&&(be=ae),ye=be,Ne>0){Ne+=pe;try{Se=new Uint8Array(Ne)}catch(te){this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:M.ErrorTypes.MUX_ERROR,details:M.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ne,reason:"fail allocating audio mdat "+Ne});return}if(!Q){var Ce=new DataView(Se.buffer);Ce.setUint32(0,Ne),Se.set(A.default.types.mdat,4)}}else return;Se.set(ue,pe);var Te=ue.byteLength;pe+=Te,Z.push(new d(!0,F,Te,0)),xe=be}var ve=Z.length;if(!ve)return;var Ie=Z[Z.length-1];this.nextAudioPts=ae=xe+I*Ie.duration;var Be=Q?new Uint8Array(0):A.default.moof(r.sequenceNumber++,ye/I,x({},r,{samples:Z}));r.samples=[];var ge=ye/T,Me=ae/T,re="audio",q={data1:Be,data2:Se,startPTS:ge,endPTS:Me,startDTS:ge,endDTS:Me,type:re,hasAudio:!0,hasVideo:!1,nb:ve};return this.isAudioContiguous=!0,console.assert(Se.length,"MDAT length must not be zero"),q},c.remuxEmptyAudio=function(r,t,s,m){var g=r.inputTimeScale,T=r.samplerate?r.samplerate:g,P=g/T,I=this.nextAudioPts,F=(I!==null?I:m.startDTS*g)+this._initDTS,K=m.endDTS*g+this._initDTS,V=P*E,Q=Math.ceil((K-F)/V),Z=O.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!Z){L.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ie=[],pe=0;pe<Q;pe++){var ae=F+pe*V;ie.push({unit:Z,pts:ae,dts:ae})}return r.samples=ie,this.remuxAudio(r,t,s,!1)},c.remuxID3=function(r,t){var s=r.samples.length;if(!s)return;for(var m=r.inputTimeScale,g=this._initPTS,T=this._initDTS,P=0;P<s;P++){var I=r.samples[P];I.pts=o(I.pts-g,t*m)/m,I.dts=o(I.dts-T,t*m)/m}var F=r.samples;return r.samples=[],{samples:F}},c.remuxText=function(r,t){var s=r.samples.length;if(!s)return;for(var m=r.inputTimeScale,g=this._initPTS,T=0;T<s;T++){var P=r.samples[T];P.pts=o(P.pts-g,t*m)/m}r.samples.sort(function(F,K){return F.pts-K.pts});var I=r.samples;return r.samples=[],{samples:I}},p}();function o(p,c){var i;if(c===null)return p;for(c<p?i=-8589934592:i=8589934592;Math.abs(p-c)>4294967296;)p+=i;return p}function f(p){for(var c=0;c<p.length;c++)if(p[c].key)return c;return-1}var d=function(c,i,r,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=r,this.cts=t,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/polyfills/number.ts"),O=S("./src/utils/mp4-tools.ts"),A=S("./src/loader/fragment.ts"),_=S("./src/utils/logger.ts"),M=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var x=y.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndDTS=null},x.resetNextTimestamp=function(){this.lastEndDTS=null},x.resetInitSegment=function(E,b,v){this.audioCodec=b,this.videoCodec=v,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var b=this.audioCodec,v=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var h=this.initData=Object(O.parseInitSegment)(E);b||(b=w(h.audio,A.ElementaryStreamTypes.AUDIO)),v||(v=w(h.video,A.ElementaryStreamTypes.VIDEO));var e={};h.audio&&h.video?e.audiovideo={container:"video/mp4",codec:b+","+v,initSegment:E,id:"main"}:h.audio?e.audio={container:"audio/mp4",codec:b,initSegment:E,id:"audio"}:h.video?e.video={container:"video/mp4",codec:v,initSegment:E,id:"main"}:_.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},x.remux=function(E,b,v,h,e){var a=this.initPTS,o=this.lastEndDTS,f={audio:void 0,video:void 0,text:h,id3:v,initSegment:void 0};Object(B.isFiniteNumber)(o)||(o=this.lastEndDTS=e||0);var d=b.samples;if(!d||!d.length)return f;var u={initPTS:void 0,timescale:1},p=this.initData;if((!p||!p.length)&&(this.generateInitSegment(d),p=this.initData),!p||!p.length)return _.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1),Object(B.isFiniteNumber)(a)||(this.initPTS=u.initPTS=a=L(p,d,o));var c=Object(O.getDuration)(d,p),i=o,r=c+i;Object(O.offsetStartDTS)(p,d,a),c>0?this.lastEndDTS=r:(_.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var t=!!p.audio,s=!!p.video,m="";t&&(m+="audio"),s&&(m+="video");var g={data1:d,startPTS:i,startDTS:i,endPTS:r,endDTS:r,type:m,hasAudio:t,hasVideo:s,nb:1,dropped:0};return f.audio=g.type==="audio"?g:void 0,f.video=g.type!=="audio"?g:void 0,f.text=h,f.id3=v,f.initSegment=u,f},y}(),L=function(x,C,E){return Object(O.getStartDTS)(x,C)-E};function w(y,x){var C=y==null?void 0:y.codec;return C&&C.length>4?C:C==="hvc1"?"hvc1.1.c.L120.90":C==="av01"?"av01.0.04M.08":C==="avc1"||x===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}U.default=M},"./src/task-loop.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return B});var B=function(){function O(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=O.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(M){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,M),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},O}()},"./src/types/cmcd.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"CMCDVersion",function(){return B}),S.d(U,"CMCDObjectType",function(){return O}),S.d(U,"CMCDStreamingFormat",function(){return A}),S.d(U,"CMCDStreamType",function(){return _});var B=1,O;(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"})(O||(O={}));var A;(function(M){M.DASH="d",M.HLS="h",M.SMOOTH="s",M.OTHER="o"})(A||(A={}));var _;(function(M){M.VOD="v",M.LIVE="l"})(_||(_={}))},"./src/types/level.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"HlsSkip",function(){return A}),S.d(U,"getSkipValue",function(){return _}),S.d(U,"HlsUrlParameters",function(){return M}),S.d(U,"Level",function(){return L});function B(w,y){for(var x=0;x<y.length;x++){var C=y[x];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}function O(w,y,x){return y&&B(w.prototype,y),x&&B(w,x),w}var A;(function(w){w.No="",w.Yes="YES",w.v2="v2"})(A||(A={}));function _(w,y){var x=w.canSkipUntil,C=w.canSkipDateRanges,E=w.endSN,b=y!==void 0?y-E:0;return x&&b<x?C?A.v2:A.Yes:A.No}var M=function(){function w(x,C,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=C,this.skip=E}var y=w.prototype;return y.addDirectives=function(C){var E=new self.URL(C);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},w}(),L=function(){function w(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return O(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(x){var C=x%this.url.length;this._urlId!==C&&(this.details=void 0,this._urlId=C)}}]),w}()},"./src/types/loader.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"PlaylistContextType",function(){return B}),S.d(U,"PlaylistLevelType",function(){return O});var B;(function(A){A.MANIFEST="manifest",A.LEVEL="level",A.AUDIO_TRACK="audioTrack",A.SUBTITLE_TRACK="subtitleTrack"})(B||(B={}));var O;(function(A){A.MAIN="main",A.AUDIO="audio",A.SUBTITLE="subtitle"})(O||(O={}))},"./src/types/transmuxer.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"ChunkMetadata",function(){return B});var B=function(_,M,L,w,y,x){w===void 0&&(w=0),y===void 0&&(y=-1),x===void 0&&(x=!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=O(),this.buffering={audio:O(),video:O(),audiovideo:O()},this.level=_,this.sn=M,this.id=L,this.size=w,this.part=y,this.partial=x};function O(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"AttrList",function(){return A});var B=/^(\d+)x(\d+)$/,O=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function _(L){typeof L=="string"&&(L=_.parseAttrList(L));for(var w in L)L.hasOwnProperty(w)&&(this[w]=L[w])}var M=_.prototype;return M.decimalInteger=function(w){var y=parseInt(this[w],10);return y>Number.MAX_SAFE_INTEGER?Infinity:y},M.hexadecimalInteger=function(w){if(this[w]){var y=(this[w]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var x=new Uint8Array(y.length/2),C=0;C<y.length/2;C++)x[C]=parseInt(y.slice(C*2,C*2+2),16);return x}else return null},M.hexadecimalIntegerAsNumber=function(w){var y=parseInt(this[w],16);return y>Number.MAX_SAFE_INTEGER?Infinity:y},M.decimalFloatingPoint=function(w){return parseFloat(this[w])},M.optionalFloat=function(w,y){var x=this[w];return x?parseFloat(x):y},M.enumeratedString=function(w){return this[w]},M.bool=function(w){return this[w]==="YES"},M.decimalResolution=function(w){var y=B.exec(this[w]);return y===null?void 0:{width:parseInt(y[1],10),height:parseInt(y[2],10)}},_.parseAttrList=function(w){var y,x={},C='"';for(O.lastIndex=0;(y=O.exec(w))!==null;){var E=y[2];E.indexOf(C)===0&&E.lastIndexOf(C)===E.length-1&&(E=E.slice(1,-1)),x[y[1]]=E}return x},_}()},"./src/utils/binary-search.ts":function(ce,U,S){"use strict";S.r(U);var B={search:function(A,_){for(var M=0,L=A.length-1,w=null,y=null;M<=L;){w=(M+L)/2|0,y=A[w];var x=_(y);if(x>0)M=w+1;else if(x<0)L=w-1;else return y}return null}};U.default=B},"./src/utils/buffer-helper.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"BufferHelper",function(){return A});var B=S("./src/utils/logger.ts"),O={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function _(){}return _.isBuffered=function(L,w){try{if(L){for(var y=_.getBuffered(L),x=0;x<y.length;x++)if(w>=y.start(x)&&w<=y.end(x))return!0}}catch(C){}return!1},_.bufferInfo=function(L,w,y){try{if(L){var x=_.getBuffered(L),C=[],E;for(E=0;E<x.length;E++)C.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(C,w,y)}}catch(b){}return{len:0,start:w,end:w,nextStart:void 0}},_.bufferedInfo=function(L,w,y){w=Math.max(0,w),L.sort(function(u,p){var c=u.start-p.start;return c||p.end-u.end});var x=[];if(y)for(var C=0;C<L.length;C++){var E=x.length;if(E){var b=x[E-1].end;L[C].start-b<y?L[C].end>b&&(x[E-1].end=L[C].end):x.push(L[C])}else x.push(L[C])}else x=L;for(var v=0,h,e=w,a=w,o=0;o<x.length;o++){var f=x[o].start,d=x[o].end;if(w+y>=f&&w<d)e=f,a=d,v=a-w;else if(w+y<f){h=f;break}}return{len:v,start:e||0,end:a||0,nextStart:h}},_.getBuffered=function(L){try{return L.buffered}catch(w){return B.logger.log("failed to get media.buffered",w),O}},_}()},"./src/utils/cea-608-parser.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"Row",function(){return a}),S.d(U,"CaptionScreen",function(){return o});var B=S("./src/utils/logger.ts"),O={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},A=function(r){var t=r;return O.hasOwnProperty(r)&&(t=O[r]),String.fromCharCode(t)},_=15,M=100,L={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},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},C=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(i){i[i.ERROR=0]="ERROR",i[i.TEXT=1]="TEXT",i[i.WARNING=2]="WARNING",i[i.INFO=2]="INFO",i[i.DEBUG=3]="DEBUG",i[i.DATA=3]="DATA"})(E||(E={}));var b=function(){function i(){this.time=null,this.verboseLevel=E.ERROR}var r=i.prototype;return r.log=function(s,m){this.verboseLevel>=s&&B.logger.log(this.time+" ["+s+"] "+m)},i}(),v=function(r){for(var t=[],s=0;s<r.length;s++)t.push(r[s].toString(16));return t},h=function(){function i(t,s,m,g,T){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=s||!1,this.italics=m||!1,this.background=g||"black",this.flash=T||!1}var r=i.prototype;return r.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(s){for(var m=["foreground","underline","italics","background","flash"],g=0;g<m.length;g++){var T=m[g];s.hasOwnProperty(T)&&(this[T]=s[T])}},r.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},r.equals=function(s){return this.foreground===s.foreground&&this.underline===s.underline&&this.italics===s.italics&&this.background===s.background&&this.flash===s.flash},r.copy=function(s){this.foreground=s.foreground,this.underline=s.underline,this.italics=s.italics,this.background=s.background,this.flash=s.flash},r.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},i}(),e=function(){function i(t,s,m,g,T,P){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new h(s,m,g,T,P)}var r=i.prototype;return r.reset=function(){this.uchar=" ",this.penState.reset()},r.setChar=function(s,m){this.uchar=s,this.penState.copy(m)},r.setPenState=function(s){this.penState.copy(s)},r.equals=function(s){return this.uchar===s.uchar&&this.penState.equals(s.penState)},r.copy=function(s){this.uchar=s.uchar,this.penState.copy(s.penState)},r.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},i}(),a=function(){function i(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var s=0;s<M;s++)this.chars.push(new e);this.logger=t,this.pos=0,this.currPenState=new h}var r=i.prototype;return r.equals=function(s){for(var m=!0,g=0;g<M;g++)if(!this.chars[g].equals(s.chars[g])){m=!1;break}return m},r.copy=function(s){for(var m=0;m<M;m++)this.chars[m].copy(s.chars[m])},r.isEmpty=function(){for(var s=!0,m=0;m<M;m++)if(!this.chars[m].isEmpty()){s=!1;break}return s},r.setCursor=function(s){this.pos!==s&&(this.pos=s),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>M&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=M)},r.moveCursor=function(s){var m=this.pos+s;if(s>1)for(var g=this.pos+1;g<m+1;g++)this.chars[g].setPenState(this.currPenState);this.setCursor(m)},r.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},r.insertChar=function(s){s>=144&&this.backSpace();var m=A(s);if(this.pos>=M){this.logger.log(E.ERROR,"Cannot insert "+s.toString(16)+" ("+m+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(m,this.currPenState),this.moveCursor(1)},r.clearFromPos=function(s){var m;for(m=s;m<M;m++)this.chars[m].reset()},r.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},r.clearToEndOfRow=function(){this.clearFromPos(this.pos)},r.getTextString=function(){for(var s=[],m=!0,g=0;g<M;g++){var T=this.chars[g].uchar;T!==" "&&(m=!1),s.push(T)}return m?"":s.join("")},r.setPenStyles=function(s){this.currPenState.setStyles(s);var m=this.chars[this.pos];m.setPenState(this.currPenState)},i}(),o=function(){function i(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var s=0;s<_;s++)this.rows.push(new a(t));this.logger=t,this.currRow=_-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var r=i.prototype;return r.reset=function(){for(var s=0;s<_;s++)this.rows[s].clear();this.currRow=_-1},r.equals=function(s){for(var m=!0,g=0;g<_;g++)if(!this.rows[g].equals(s.rows[g])){m=!1;break}return m},r.copy=function(s){for(var m=0;m<_;m++)this.rows[m].copy(s.rows[m])},r.isEmpty=function(){for(var s=!0,m=0;m<_;m++)if(!this.rows[m].isEmpty()){s=!1;break}return s},r.backSpace=function(){var s=this.rows[this.currRow];s.backSpace()},r.clearToEndOfRow=function(){var s=this.rows[this.currRow];s.clearToEndOfRow()},r.insertChar=function(s){var m=this.rows[this.currRow];m.insertChar(s)},r.setPen=function(s){var m=this.rows[this.currRow];m.setPenStyles(s)},r.moveCursor=function(s){var m=this.rows[this.currRow];m.moveCursor(s)},r.setCursor=function(s){this.logger.log(E.INFO,"setCursor: "+s);var m=this.rows[this.currRow];m.setCursor(s)},r.setPAC=function(s){this.logger.log(E.INFO,"pacData = "+JSON.stringify(s));var m=s.row-1;if(this.nrRollUpRows&&m<this.nrRollUpRows-1&&(m=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==m){for(var g=0;g<_;g++)this.rows[g].clear();var T=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var I=P.rows[T].cueStartTime,F=this.logger.time;if(I&&F!==null&&I<F)for(var K=0;K<this.nrRollUpRows;K++)this.rows[m-this.nrRollUpRows+K+1].copy(P.rows[T+K])}}this.currRow=m;var V=this.rows[this.currRow];if(s.indent!==null){var Q=s.indent,Z=Math.max(Q-1,0);V.setCursor(s.indent),s.color=V.chars[Z].penState.foreground}var ie={foreground:s.color,underline:s.underline,italics:s.italics,background:"black",flash:!1};this.setPen(ie)},r.setBkgData=function(s){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(s)),this.backSpace(),this.setPen(s),this.insertChar(32)},r.setRollUpRows=function(s){this.nrRollUpRows=s},r.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var s=this.currRow+1-this.nrRollUpRows,m=this.rows.splice(s,1)[0];m.clear(),this.rows.splice(this.currRow,0,m),this.logger.log(E.INFO,"Rolling up")},r.getDisplayText=function(s){s=s||!1;for(var m=[],g="",T=-1,P=0;P<_;P++){var I=this.rows[P].getTextString();I&&(T=P+1,s?m.push("Row "+T+": '"+I+"'"):m.push(I.trim()))}return m.length>0&&(s?g="["+m.join(" | ")+"]":g=m.join(`
`)),g},r.getTextAndFormat=function(){return this.rows},i}(),f=function(){function i(t,s,m){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=s,this.mode=null,this.verbose=0,this.displayedMemory=new o(m),this.nonDisplayedMemory=new o(m),this.lastOutputScreen=new o(m),this.currRollUpRow=this.displayedMemory.rows[_-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=m}var r=i.prototype;return r.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[_-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},r.getHandler=function(){return this.outputFilter},r.setHandler=function(s){this.outputFilter=s},r.setPAC=function(s){this.writeScreen.setPAC(s)},r.setBkgData=function(s){this.writeScreen.setBkgData(s)},r.setMode=function(s){if(s===this.mode)return;this.mode=s,this.logger.log(E.INFO,"MODE="+s),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=s},r.insertChars=function(s){for(var m=0;m<s.length;m++)this.writeScreen.insertChar(s[m]);var g=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,g+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},r.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},r.ccBS=function(){if(this.logger.log(E.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},r.ccAOF=function(){},r.ccAON=function(){},r.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},r.ccRU=function(s){this.logger.log(E.INFO,"RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},r.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},r.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},r.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},r.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},r.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},r.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},r.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},r.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},r.ccTO=function(s){this.logger.log(E.INFO,"TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},r.ccMIDROW=function(s){var m={flash:!1};if(m.underline=s%2===1,m.italics=s>=46,m.italics)m.foreground="white";else{var g=Math.floor(s/2)-16,T=["white","green","blue","cyan","red","yellow","magenta"];m.foreground=T[g]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(m)),this.writeScreen.setPen(m)},r.outputDataUpdate=function(s){s===void 0&&(s=!1);var m=this.logger.time;if(m===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=m:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,m,this.lastOutputScreen),s&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:m),this.lastOutputScreen.copy(this.displayedMemory))},r.cueSplitAtTime=function(s){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,s,this.displayedMemory),this.cueStartTime=s))},i}(),d=function(){function i(t,s,m){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new b;this.channels=[null,new f(t,s,g),new f(t+1,m,g)],this.cmdHistory=c(),this.logger=g}var r=i.prototype;return r.getHandler=function(s){return this.channels[s].getHandler()},r.setHandler=function(s,m){this.channels[s].setHandler(m)},r.addData=function(s,m){var g,T,P,I=!1;this.logger.time=s;for(var F=0;F<m.length;F+=2){if(T=m[F]&127,P=m[F+1]&127,T===0&&P===0)continue;if(this.logger.log(E.DATA,"["+v([m[F],m[F+1]])+"] -> ("+v([T,P])+")"),g=this.parseCmd(T,P),g||(g=this.parseMidrow(T,P)),g||(g=this.parsePAC(T,P)),g||(g=this.parseBackgroundAttributes(T,P)),!g&&(I=this.parseChars(T,P),I)){var K=this.currentChannel;if(K&&K>0){var V=this.channels[K];V.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+v([T,P])+" orig: "+v([m[F],m[F+1]]))}},r.parseCmd=function(s,m){var g=this.cmdHistory,T=(s===20||s===28||s===21||s===29)&&m>=32&&m<=47,P=(s===23||s===31)&&m>=33&&m<=35;if(!(T||P))return!1;if(p(s,m,g))return u(null,null,g),this.logger.log(E.DEBUG,"Repeated command ("+v([s,m])+") is dropped"),!0;var I=s===20||s===21||s===23?1:2,F=this.channels[I];return s===20||s===21||s===28||s===29?m===32?F.ccRCL():m===33?F.ccBS():m===34?F.ccAOF():m===35?F.ccAON():m===36?F.ccDER():m===37?F.ccRU(2):m===38?F.ccRU(3):m===39?F.ccRU(4):m===40?F.ccFON():m===41?F.ccRDC():m===42?F.ccTR():m===43?F.ccRTD():m===44?F.ccEDM():m===45?F.ccCR():m===46?F.ccENM():m===47&&F.ccEOC():F.ccTO(m-32),u(s,m,g),this.currentChannel=I,!0},r.parseMidrow=function(s,m){var g=0;if((s===17||s===25)&&m>=32&&m<=47){if(s===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var T=this.channels[g];return T?(T.ccMIDROW(m),this.logger.log(E.DEBUG,"MIDROW ("+v([s,m])+")"),!0):!1}return!1},r.parsePAC=function(s,m){var g,T=this.cmdHistory,P=(s>=17&&s<=23||s>=25&&s<=31)&&m>=64&&m<=127,I=(s===16||s===24)&&m>=64&&m<=95;if(!(P||I))return!1;if(p(s,m,T))return u(null,null,T),!0;var F=s<=23?1:2;m>=64&&m<=95?g=F===1?L[s]:y[s]:g=F===1?w[s]:x[s];var K=this.channels[F];return K?(K.setPAC(this.interpretPAC(g,m)),u(s,m,T),this.currentChannel=F,!0):!1},r.interpretPAC=function(s,m){var g,T={color:null,italics:!1,indent:null,underline:!1,row:s};return m>95?g=m-96:g=m-64,T.underline=(g&1)===1,g<=13?T.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(T.italics=!0,T.color="white"):T.indent=Math.floor((g-16)/2)*4,T},r.parseChars=function(s,m){var g,T=null,P=null;if(s>=25?(g=2,P=s-8):(g=1,P=s),P>=17&&P<=19){var I;P===17?I=m+80:P===18?I=m+112:I=m+144,this.logger.log(E.INFO,"Special char '"+A(I)+"' in channel "+g),T=[I]}else s>=32&&s<=127&&(T=m===0?[s]:[s,m]);if(T){var F=v(T);this.logger.log(E.DEBUG,"Char codes = "+F.join(",")),u(s,m,this.cmdHistory)}return T},r.parseBackgroundAttributes=function(s,m){var g=(s===16||s===24)&&m>=32&&m<=47,T=(s===23||s===31)&&m>=45&&m<=47;if(!(g||T))return!1;var P,I={};s===16||s===24?(P=Math.floor((m-32)/2),I.background=C[P],m%2===1&&(I.background=I.background+"_semi")):m===45?I.background="transparent":(I.foreground="black",m===47&&(I.underline=!0));var F=s<=23?1:2,K=this.channels[F];return K.setBkgData(I),u(s,m,this.cmdHistory),!0},r.reset=function(){for(var s=0;s<Object.keys(this.channels).length;s++){var m=this.channels[s];m&&m.reset()}this.cmdHistory=c()},r.cueSplitAtTime=function(s){for(var m=0;m<this.channels.length;m++){var g=this.channels[m];g&&g.cueSplitAtTime(s)}},i}();function u(i,r,t){t.a=i,t.b=r}function p(i,r,t){return t.a===i&&t.b===r}function c(){return{a:null,b:null}}U.default=d},"./src/utils/codecs.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"isCodecType",function(){return O}),S.d(U,"isCodecSupportedInMp4",function(){return A});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 O(_,M){var L=B[M];return!!L&&L[_.slice(0,4)]===!0}function A(_,M){return MediaSource.isTypeSupported((M||"video")+'/mp4;codecs="'+_+'"')}},"./src/utils/cues.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/utils/vttparser.ts"),O=S("./src/utils/webvtt-parser.ts"),A=S("./src/utils/texttrack-utils.ts"),_=/\s/,M={newCue:function(w,y,x,C){for(var E=[],b,v,h,e,a,o=self.VTTCue||self.TextTrackCue,f=0;f<C.rows.length;f++)if(b=C.rows[f],h=!0,e=0,a="",!b.isEmpty()){for(var d=0;d<b.chars.length;d++)_.test(b.chars[d].uchar)&&h?e++:(a+=b.chars[d].uchar,h=!1);b.cueStartTime=y,y===x&&(x+=1e-4),e>=16?e--:e++;var u=Object(B.fixLineBreaks)(a.trim()),p=Object(O.generateCueId)(y,x,u);(!w||!w.cues||!w.cues.getCueById(p))&&(v=new o(y,x,u),v.id=p,v.line=f+1,v.align="left",v.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(v))}return w&&E.length&&(E.sort(function(c,i){return c.line==="auto"||i.line==="auto"?0:c.line>8&&i.line>8?i.line-c.line:c.line-i.line}),E.forEach(function(c){return Object(A.addCueToTrack)(w,c)})),E}};U.default=M},"./src/utils/discontinuities.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"findFirstFragWithCC",function(){return _}),S.d(U,"shouldAlignOnDiscontinuities",function(){return M}),S.d(U,"findDiscontinuousReferenceFrag",function(){return L}),S.d(U,"adjustSlidingStart",function(){return y}),S.d(U,"alignStream",function(){return x}),S.d(U,"alignPDT",function(){return E}),S.d(U,"alignFragmentByPDTDelta",function(){return b}),S.d(U,"alignMediaPlaylistByPDT",function(){return v});var B=S("./src/polyfills/number.ts"),O=S("./src/utils/logger.ts"),A=S("./src/controller/level-helper.ts");function _(h,e){for(var a=null,o=0,f=h.length;o<f;o++){var d=h[o];if(d&&d.cc===e){a=d;break}}return a}function M(h,e,a){return!!(e.details&&(a.endCC>a.startCC||h&&h.cc<a.startCC))}function L(h,e){var a=h.fragments,o=e.fragments;if(!o.length||!a.length){O.logger.log("No fragments to align");return}var f=_(a,o[0].cc);if(!f||f&&!f.startPTS){O.logger.log("No frag in previous level to align on");return}return f}function w(h,e){if(h){var a=h.start+e;h.start=h.startPTS=a,h.endPTS=a+h.duration}}function y(h,e){for(var a=e.fragments,o=0,f=a.length;o<f;o++)w(a[o],h);e.fragmentHint&&w(e.fragmentHint,h),e.alignedSliding=!0}function x(h,e,a){if(!e)return;C(h,a,e),!a.alignedSliding&&e.details&&E(a,e.details),!a.alignedSliding&&e.details&&!a.skippedSegments&&Object(A.adjustSliding)(e.details,a)}function C(h,e,a){if(M(h,a,e)){var o=L(a.details,e);o&&Object(B.isFiniteNumber)(o.start)&&(O.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(o.start,e))}}function E(h,e){if(!e.fragments.length||!h.hasProgramDateTime||!e.hasProgramDateTime)return;var a=e.fragments[0].programDateTime,o=h.fragments[0].programDateTime,f=(o-a)/1e3+e.fragments[0].start;f&&Object(B.isFiniteNumber)(f)&&(O.logger.log("Adjusting PTS using programDateTime delta "+(o-a)+"ms, sliding:"+f.toFixed(3)+" "+h.url+" "),y(f,h))}function b(h,e){var a=h.programDateTime;if(!a)return;var o=(a-e)/1e3;h.start=h.startPTS=o,h.endPTS=o+h.duration}function v(h,e){if(!e.fragments.length||!h.hasProgramDateTime||!e.hasProgramDateTime)return;var a=e.fragments[0].programDateTime,o=e.fragments[0].start,f=a-o*1e3;h.fragments.forEach(function(d){b(d,f)}),h.fragmentHint&&b(h.fragmentHint,f),h.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/utils/ewma.ts"),O=function(){function A(M,L,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(L)}var _=A.prototype;return _.update=function(L,w){var y=this.slow_,x=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new B.default(L,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==w&&(this.fast_=new B.default(w,x.getEstimate(),x.getTotalWeight()))},_.sample=function(L,w){L=Math.max(L,this.minDelayMs_);var y=8*w,x=L/1e3,C=y/x;this.fast_.sample(x,C),this.slow_.sample(x,C)},_.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},_.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},_.destroy=function(){},A}();U.default=O},"./src/utils/ewma.ts":function(ce,U,S){"use strict";S.r(U);var B=function(){function O(_,M,L){M===void 0&&(M=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=_,this.alpha_=_?Math.exp(Math.log(.5)/_):0,this.estimate_=M,this.totalWeight_=L}var A=O.prototype;return A.sample=function(M,L){var w=Math.pow(this.alpha_,M);this.estimate_=L*(1-w)+w*this.estimate_,this.totalWeight_+=M},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var M=1-Math.pow(this.alpha_,this.totalWeight_);if(M)return this.estimate_/M}return this.estimate_},O}();U.default=B},"./src/utils/fetch-loader.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"fetchSupported",function(){return b});var B=S("./src/polyfills/number.ts"),O=S("./src/loader/load-stats.ts"),A=S("./src/demux/chunk-cache.ts");function _(o,f){o.prototype=Object.create(f.prototype),o.prototype.constructor=o,x(o,f)}function M(o){var f=typeof Map=="function"?new Map:void 0;return M=function(u){if(u===null||!y(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof f!="undefined"){if(f.has(u))return f.get(u);f.set(u,p)}function p(){return L(u,arguments,C(this).constructor)}return p.prototype=Object.create(u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),x(p,u)},M(o)}function L(o,f,d){return w()?L=Reflect.construct:L=function(p,c,i){var r=[null];r.push.apply(r,c);var t=Function.bind.apply(p,r),s=new t;return i&&x(s,i.prototype),s},L.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 y(o){return Function.toString.call(o).indexOf("[native code]")!==-1}function x(o,f){return x=Object.setPrototypeOf||function(u,p){return u.__proto__=p,u},x(o,f)}function C(o){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},C(o)}function E(){return E=Object.assign||function(o){for(var f=1;f<arguments.length;f++){var d=arguments[f];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(o[u]=d[u])}return o},E.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(o){}return!1}var v=function(){function o(d){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=d.fetchSetup||e,this.controller=new self.AbortController,this.stats=new O.LoadStats}var f=o.prototype;return f.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},f.abortInternal=function(){var u=this.response;(!u||!u.ok)&&(this.stats.aborted=!0,this.controller.abort())},f.abort=function(){var u;this.abortInternal(),(u=this.callbacks)!==null&&u!==void 0&&u.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},f.load=function(u,p,c){var i=this,r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();var t=h(u,this.controller.signal),s=c.onProgress,m=u.responseType==="arraybuffer",g=m?"byteLength":"length";this.context=u,this.config=p,this.callbacks=c,this.request=this.fetchSetup(u,t),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){i.abortInternal(),c.onTimeout(r,u,i.response)},p.timeout),self.fetch(this.request).then(function(T){if(i.response=i.loader=T,!T.ok){var P=T.status,I=T.statusText;throw new a(I||"fetch, bad network response",P,T)}return r.loading.first=Math.max(self.performance.now(),r.loading.start),r.total=parseInt(T.headers.get("Content-Length")||"0"),s&&Object(B.isFiniteNumber)(p.highWaterMark)?i.loadProgressively(T,r,u,p.highWaterMark,s):m?T.arrayBuffer():T.text()}).then(function(T){var P=i.response;self.clearTimeout(i.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first),r.loaded=r.total=T[g];var I={url:P.url,data:T};s&&!Object(B.isFiniteNumber)(p.highWaterMark)&&s(r,u,T,P),c.onSuccess(I,r,u,P)}).catch(function(T){if(self.clearTimeout(i.requestTimeout),r.aborted)return;var P=T.code||0;c.onError({code:P,text:T.message},u,T.details)})},f.getCacheAge=function(){var u=null;if(this.response){var p=this.response.headers.get("age");u=p?parseFloat(p):null}return u},f.loadProgressively=function(u,p,c,i,r){i===void 0&&(i=0);var t=new A.default,s=u.body.getReader(),m=function g(){return s.read().then(function(T){if(T.done)return t.dataLength&&r(p,c,t.flush(),u),Promise.resolve(new ArrayBuffer(0));var P=T.value,I=P.length;return p.loaded+=I,I<i||t.dataLength?(t.push(P),t.dataLength>=i&&r(p,c,t.flush(),u)):r(p,c,P,u),g()}).catch(function(){return Promise.reject()})};return m()},o}();function h(o,f){var d={method:"GET",mode:"cors",credentials:"same-origin",signal:f,headers:new self.Headers(E({},o.headers))};return o.rangeEnd&&d.headers.set("Range","bytes="+o.rangeStart+"-"+String(o.rangeEnd-1)),d}function e(o,f){return new self.Request(o.url,f)}var a=function(o){_(f,o);function f(d,u,p){var c;return c=o.call(this,d)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=p,c}return f}(M(Error));U.default=v},"./src/utils/imsc1-ttml-parser.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"IMSC1_CODEC",function(){return y}),S.d(U,"parseIMSC1",function(){return b});var B=S("./src/utils/mp4-tools.ts"),O=S("./src/utils/vttparser.ts"),A=S("./src/utils/vttcue.ts"),_=S("./src/demux/id3.ts"),M=S("./src/utils/timescale-conversion.ts"),L=S("./src/utils/webvtt-parser.ts");function w(){return w=Object.assign||function(i){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},w.apply(this,arguments)}var y="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,C=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(i,r,t,s,m){var g=Object(B.findBox)(new Uint8Array(i),["mdat"]);if(g.length===0){m(new Error("Could not parse IMSC1 mdat"));return}var T=g[0],P=Object(_.utf8ArrayToStr)(new Uint8Array(i,T.start,T.end-T.start)),I=Object(M.toTimescaleFromScale)(r,1,t);try{s(v(P,I))}catch(F){m(F)}}function v(i,r){var t=new DOMParser,s=t.parseFromString(i,"text/xml"),m=s.getElementsByTagName("tt")[0];if(!m)throw new Error("Invalid ttml");var g={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},T=Object.keys(g).reduce(function(V,Q){return V[Q]=m.getAttribute("ttp:"+Q)||g[Q],V},{}),P=m.getAttribute("xml:space")!=="preserve",I=e(h(m,"styling","style")),F=e(h(m,"layout","region")),K=h(m,"body","[begin]");return[].map.call(K,function(V){var Q=a(V,P);if(!Q||!V.hasAttribute("begin"))return null;var Z=u(V.getAttribute("begin"),T),ie=u(V.getAttribute("dur"),T),pe=u(V.getAttribute("end"),T);if(Z===null)throw d(V);if(pe===null){if(ie===null)throw d(V);pe=Z+ie}var ae=new A.default(Z-r,pe-r,Q);ae.id=Object(L.generateCueId)(ae.startTime,ae.endTime,ae.text);var de=F[V.getAttribute("region")],le=I[V.getAttribute("style")];ae.position=10,ae.size=80;var $=o(de,le),Y=$.textAlign;if(Y){var ne=E[Y];ne&&(ae.lineAlign=ne),ae.align=Y}return w(ae,$),ae}).filter(function(V){return V!==null})}function h(i,r,t){var s=i.getElementsByTagName(r)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function e(i){return i.reduce(function(r,t){var s=t.getAttribute("xml:id");return s&&(r[s]=t),r},{})}function a(i,r){return[].slice.call(i.childNodes).reduce(function(t,s,m){var g;return s.nodeName==="br"&&m?t+`
`:(g=s.childNodes)!==null&&g!==void 0&&g.length?a(s,r):r?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function o(i,r){var t="http://www.w3.org/ns/ttml#styling",s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return s.reduce(function(m,g){var T=f(r,t,g)||f(i,t,g);return T&&(m[g]=T),m},{})}function f(i,r,t){return i.hasAttributeNS(r,t)?i.getAttributeNS(r,t):null}function d(i){return new Error("Could not parse ttml timestamp "+i)}function u(i,r){if(!i)return null;var t=Object(O.parseTimeStamp)(i);return t===null&&(x.test(i)?t=p(i,r):C.test(i)&&(t=c(i,r))),t}function p(i,r){var t=x.exec(i),s=(t[4]|0)+(t[5]|0)/r.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/r.frameRate}function c(i,r){var t=C.exec(i),s=Number(t[1]),m=t[2];switch(m){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/r.frameRate;case"t":return s/r.tickRate}return s}},"./src/utils/logger.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"enableLogs",function(){return L}),S.d(U,"logger",function(){return w});var B=function(){},O={trace:B,debug:B,log:B,warn:B,info:B,error:B},A=O;function _(y){var x=self.console[y];return x?x.bind(self.console,"["+y+"] >"):B}function M(y){for(var x=arguments.length,C=new Array(x>1?x-1:0),E=1;E<x;E++)C[E-1]=arguments[E];C.forEach(function(b){A[b]=y[b]?y[b].bind(y):_(b)})}function L(y){if(self.console&&y===!0||typeof y=="object"){M(y,"debug","log","info","warn","error");try{A.log()}catch(x){A=O}}else A=O}var w=A},"./src/utils/mediakeys-helper.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"KeySystems",function(){return B}),S.d(U,"requestMediaKeySystemAccess",function(){return O});var B;(function(A){A.WIDEVINE="com.widevine.alpha",A.PLAYREADY="com.microsoft.playready"})(B||(B={}));var O=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"getMediaSource",function(){return B});function B(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"bin2str",function(){return M}),S.d(U,"readUint16",function(){return L}),S.d(U,"readUint32",function(){return w}),S.d(U,"writeUint32",function(){return y}),S.d(U,"findBox",function(){return x}),S.d(U,"parseSegmentIndex",function(){return C}),S.d(U,"parseInitSegment",function(){return E}),S.d(U,"getStartDTS",function(){return b}),S.d(U,"getDuration",function(){return v}),S.d(U,"computeRawDurationFromSamples",function(){return h}),S.d(U,"offsetStartDTS",function(){return e}),S.d(U,"segmentValidRange",function(){return a}),S.d(U,"appendUint8Array",function(){return o});var B=S("./src/utils/typed-array.ts"),O=S("./src/loader/fragment.ts"),A=Math.pow(2,32)-1,_=[].push;function M(f){return String.fromCharCode.apply(null,f)}function L(f,d){"data"in f&&(d+=f.start,f=f.data);var u=f[d]<<8|f[d+1];return u<0?65536+u:u}function w(f,d){"data"in f&&(d+=f.start,f=f.data);var u=f[d]<<24|f[d+1]<<16|f[d+2]<<8|f[d+3];return u<0?4294967296+u:u}function y(f,d,u){"data"in f&&(d+=f.start,f=f.data),f[d]=u>>24,f[d+1]=u>>16&255,f[d+2]=u>>8&255,f[d+3]=u&255}function x(f,d){var u=[];if(!d.length)return u;var p,c,i;"data"in f?(p=f.data,c=f.start,i=f.end):(p=f,c=0,i=p.byteLength);for(var r=c;r<i;){var t=w(p,r),s=M(p.subarray(r+4,r+8)),m=t>1?r+t:i;if(s===d[0])if(d.length===1)u.push({data:p,start:r+8,end:m});else{var g=x({data:p,start:r+8,end:m},d.slice(1));g.length&&_.apply(u,g)}r=m}return u}function C(f){var d=x(f,["moov"]),u=d[0],p=u?u.end:null,c=x(f,["sidx"]);if(!c||!c[0])return null;var i=[],r=c[0],t=r.data[0],s=t===0?8:16,m=w(r,s);s+=4;var g=0,T=0;t===0?s+=8:s+=16,s+=2;var P=r.end+T,I=L(r,s);s+=2;for(var F=0;F<I;F++){var K=s,V=w(r,K);K+=4;var Q=V&2147483647,Z=(V&2147483648)>>>31;if(Z===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ie=w(r,K);K+=4,i.push({referenceSize:Q,subsegmentDuration:ie,info:{duration:ie/m,start:P,end:P+Q-1}}),P+=Q,K+=4,s=K}return{earliestPresentationTime:g,timescale:m,version:t,referencesCount:I,references:i,moovEndOffset:p}}function E(f){for(var d=[],u=x(f,["moov","trak"]),p=0;p<u.length;p++){var c=u[p],i=x(c,["tkhd"])[0];if(i){var r=i.data[i.start],t=r===0?12:20,s=w(i,t),m=x(c,["mdia","mdhd"])[0];if(m){r=m.data[m.start],t=r===0?12:20;var g=w(m,t),T=x(c,["mdia","hdlr"])[0];if(T){var P=M(T.data.subarray(T.start+8,T.start+12)),I={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[P];if(I){var F=x(c,["mdia","minf","stbl","stsd"])[0],K=void 0;F&&(K=M(F.data.subarray(F.start+12,F.start+16))),d[s]={timescale:g,type:I},d[I]={timescale:g,id:s,codec:K}}}}}}var V=x(f,["moov","mvex","trex"]);return V.forEach(function(Q){var Z=w(Q,4),ie=d[Z];ie&&(ie.default={duration:w(Q,12),flags:w(Q,20)})}),d}function b(f,d){return x(d,["moof","traf"]).reduce(function(u,p){var c=x(p,["tfdt"])[0],i=c.data[c.start],r=x(p,["tfhd"]).reduce(function(t,s){var m=w(s,4),g=f[m];if(g){var T=w(c,4);i===1&&(T*=Math.pow(2,32),T+=w(c,8));var P=g.timescale||9e4,I=T/P;if(isFinite(I)&&(t===null||I<t))return I}return t},null);return r!==null&&isFinite(r)&&(u===null||r<u)?r:u},null)||0}function v(f,d){for(var u=0,p=0,c=0,i=x(f,["moof","traf"]),r=0;r<i.length;r++){var t=i[r],s=x(t,["tfhd"])[0],m=w(s,4),g=d[m];if(!g)continue;var T=g.default,P=w(s,0)|(T==null?void 0:T.flags),I=T==null?void 0:T.duration;P&8&&(P&2?I=w(s,12):I=w(s,8));for(var F=g.timescale||9e4,K=x(t,["trun"]),V=0;V<K.length;V++){if(I){var Q=w(K[V],4);u=I*Q}else u=h(K[V]);g.type===O.ElementaryStreamTypes.VIDEO?p+=u/F:g.type===O.ElementaryStreamTypes.AUDIO&&(c+=u/F)}}if(p===0&&c===0){var Z=C(f);if(Z!=null&&Z.references)return Z.references.reduce(function(ie,pe){return ie+pe.info.duration||0},0)}return p||c}function h(f){var d=w(f,0),u=8;d&1&&(u+=4),d&4&&(u+=4);for(var p=0,c=w(f,4),i=0;i<c;i++){if(d&256){var r=w(f,u);p+=r,u+=4}d&512&&(u+=4),d&1024&&(u+=4),d&2048&&(u+=4)}return p}function e(f,d,u){x(d,["moof","traf"]).forEach(function(p){x(p,["tfhd"]).forEach(function(c){var i=w(c,4),r=f[i];if(!r)return;var t=r.timescale||9e4;x(p,["tfdt"]).forEach(function(s){var m=s.data[s.start],g=w(s,4);if(m===0)y(s,4,g-u*t);else{g*=Math.pow(2,32),g+=w(s,8),g-=u*t,g=Math.max(g,0);var T=Math.floor(g/(A+1)),P=Math.floor(g%(A+1));y(s,4,T),y(s,8,P)}})})})}function a(f){var d={valid:null,remainder:null},u=x(f,["moof"]);if(u){if(u.length<2)return d.remainder=f,d}else return d;var p=u[u.length-1];return d.valid=Object(B.sliceUint8)(f,0,p.start-8),d.remainder=Object(B.sliceUint8)(f,p.start-8),d}function o(f,d){var u=new Uint8Array(f.length+d.length);return u.set(f),u.set(d,f.length),u}},"./src/utils/output-filter.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"default",function(){return B});var B=function(){function O(_,M){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=_,this.trackName=M}var A=O.prototype;return A.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},A.newCue=function(M,L,w){(this.startTime===null||this.startTime>M)&&(this.startTime=M),this.endTime=L,this.screen=w,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},O}()},"./src/utils/texttrack-utils.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"sendAddTrackEvent",function(){return O}),S.d(U,"addCueToTrack",function(){return A}),S.d(U,"clearCurrentCues",function(){return _}),S.d(U,"removeCuesInRange",function(){return M}),S.d(U,"getCuesInRange",function(){return w});var B=S("./src/utils/logger.ts");function O(y,x){var C;try{C=new Event("addtrack")}catch(E){C=document.createEvent("Event"),C.initEvent("addtrack",!1,!1)}C.track=y,x.dispatchEvent(C)}function A(y,x){var C=y.mode;if(C==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(x.id))try{if(y.addCue(x),!y.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(b){B.logger.debug("[texttrack-utils]: "+b);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,y.addCue(E)}C==="disabled"&&(y.mode=C)}function _(y){var x=y.mode;if(x==="disabled"&&(y.mode="hidden"),y.cues)for(var C=y.cues.length;C--;)y.removeCue(y.cues[C]);x==="disabled"&&(y.mode=x)}function M(y,x,C){var E=y.mode;if(E==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var b=w(y.cues,x,C),v=0;v<b.length;v++)y.removeCue(b[v]);E==="disabled"&&(y.mode=E)}function L(y,x){if(x<y[0].startTime)return 0;var C=y.length-1;if(x>y[C].endTime)return-1;for(var E=0,b=C;E<=b;){var v=Math.floor((b+E)/2);if(x<y[v].startTime)b=v-1;else if(x>y[v].startTime&&E<C)E=v+1;else return v}return y[E].startTime-x<x-y[b].startTime?E:b}function w(y,x,C){var E=[],b=L(y,x);if(b>-1)for(var v=b,h=y.length;v<h;v++){var e=y[v];if(e.startTime>=x&&e.endTime<=C)E.push(e);else if(e.startTime>C)return E}return E}},"./src/utils/time-ranges.ts":function(ce,U,S){"use strict";S.r(U);var B={toString:function(A){for(var _="",M=A.length,L=0;L<M;L++)_+="["+A.start(L).toFixed(3)+","+A.end(L).toFixed(3)+"]";return _}};U.default=B},"./src/utils/timescale-conversion.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"toTimescaleFromBase",function(){return O}),S.d(U,"toTimescaleFromScale",function(){return A}),S.d(U,"toMsFromMpegTsClock",function(){return _}),S.d(U,"toMpegTsClockFromTimescale",function(){return M});var B=9e4;function O(L,w,y,x){y===void 0&&(y=1),x===void 0&&(x=!1);var C=L*w*y;return x?Math.round(C):C}function A(L,w,y,x){return y===void 0&&(y=1),x===void 0&&(x=!1),O(L,w,1/y,x)}function _(L,w){return w===void 0&&(w=!1),O(L,1e3,1/B,w)}function M(L,w){return w===void 0&&(w=1),O(L,B,1/w)}},"./src/utils/typed-array.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"sliceUint8",function(){return B});function B(O,A,_){return Uint8Array.prototype.slice?O.slice(A,_):new Uint8Array(Array.prototype.slice.call(O,A,_))}},"./src/utils/vttcue.ts":function(ce,U,S){"use strict";S.r(U),U.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var B=["","lr","rl"],O=["start","middle","end","left","right"];function A(y,x){if(typeof x!="string")return!1;if(!Array.isArray(y))return!1;var C=x.toLowerCase();return~y.indexOf(C)?C:!1}function _(y){return A(B,y)}function M(y){return A(O,y)}function L(y){for(var x=arguments.length,C=new Array(x>1?x-1:0),E=1;E<x;E++)C[E-1]=arguments[E];for(var b=1;b<arguments.length;b++){var v=arguments[b];for(var h in v)y[h]=v[h]}return y}function w(y,x,C){var E=this,b={enumerable:!0};E.hasBeenReset=!1;var v="",h=!1,e=y,a=x,o=C,f=null,d="",u=!0,p="auto",c="start",i=50,r="middle",t=50,s="middle";Object.defineProperty(E,"id",L({},b,{get:function(){return v},set:function(g){v=""+g}})),Object.defineProperty(E,"pauseOnExit",L({},b,{get:function(){return h},set:function(g){h=!!g}})),Object.defineProperty(E,"startTime",L({},b,{get:function(){return e},set:function(g){if(typeof g!="number")throw new TypeError("Start time must be set to a number.");e=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",L({},b,{get:function(){return a},set:function(g){if(typeof g!="number")throw new TypeError("End time must be set to a number.");a=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",L({},b,{get:function(){return o},set:function(g){o=""+g,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",L({},b,{get:function(){return f},set:function(g){f=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",L({},b,{get:function(){return d},set:function(g){var T=_(g);if(T===!1)throw new SyntaxError("An invalid or illegal string was specified.");d=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",L({},b,{get:function(){return u},set:function(g){u=!!g,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",L({},b,{get:function(){return p},set:function(g){if(typeof g!="number"&&g!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");p=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",L({},b,{get:function(){return c},set:function(g){var T=M(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");c=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",L({},b,{get:function(){return i},set:function(g){if(g<0||g>100)throw new Error("Position must be between 0 and 100.");i=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",L({},b,{get:function(){return r},set:function(g){var T=M(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");r=T,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",L({},b,{get:function(){return t},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");t=g,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",L({},b,{get:function(){return s},set:function(g){var T=M(g);if(!T)throw new SyntaxError("An invalid or illegal string was specified.");s=T,this.hasBeenReset=!0}})),E.displayState=void 0}return w.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},w}()},"./src/utils/vttparser.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"parseTimeStamp",function(){return A}),S.d(U,"fixLineBreaks",function(){return x}),S.d(U,"VTTParser",function(){return C});var B=S("./src/utils/vttcue.ts"),O=function(){function E(){}var b=E.prototype;return b.decode=function(h,e){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},E}();function A(E){function b(h,e,a,o){return(h|0)*3600+(e|0)*60+(a|0)+parseFloat(o||0)}var v=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return v?parseFloat(v[2])>59?b(v[2],v[3],0,v[4]):b(v[1],v[2],v[3],v[4]):null}var _=function(){function E(){this.values=Object.create(null)}var b=E.prototype;return b.set=function(h,e){!this.get(h)&&e!==""&&(this.values[h]=e)},b.get=function(h,e,a){return a?this.has(h)?this.values[h]:e[a]:this.has(h)?this.values[h]:e},b.has=function(h){return h in this.values},b.alt=function(h,e,a){for(var o=0;o<a.length;++o)if(e===a[o]){this.set(h,e);break}},b.integer=function(h,e){/^-?\d+$/.test(e)&&this.set(h,parseInt(e,10))},b.percent=function(h,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var a=parseFloat(e);if(a>=0&&a<=100)return this.set(h,a),!0}return!1},E}();function M(E,b,v,h){var e=h?E.split(h):[E];for(var a in e){if(typeof e[a]!="string")continue;var o=e[a].split(v);if(o.length!==2)continue;var f=o[0],d=o[1];b(f,d)}}var L=new B.default(0,0,""),w=L.align==="middle"?"middle":"center";function y(E,b,v){var h=E;function e(){var f=A(E);if(f===null)throw new Error("Malformed timestamp: "+h);return E=E.replace(/^[^\sa-zA-Z-]+/,""),f}function a(f,d){var u=new _;M(f,function(i,r){var t;switch(i){case"region":for(var s=v.length-1;s>=0;s--)if(v[s].id===r){u.set(i,v[s].region);break}break;case"vertical":u.alt(i,r,["rl","lr"]);break;case"line":t=r.split(","),u.integer(i,t[0]),u.percent(i,t[0])&&u.set("snapToLines",!1),u.alt(i,t[0],["auto"]),t.length===2&&u.alt("lineAlign",t[1],["start",w,"end"]);break;case"position":t=r.split(","),u.percent(i,t[0]),t.length===2&&u.alt("positionAlign",t[1],["start",w,"end","line-left","line-right","auto"]);break;case"size":u.percent(i,r);break;case"align":u.alt(i,r,["start",w,"end","left","right"]);break}},/:/,/\s/),d.region=u.get("region",null),d.vertical=u.get("vertical","");var p=u.get("line","auto");p==="auto"&&L.line===-1&&(p=-1),d.line=p,d.lineAlign=u.get("lineAlign","start"),d.snapToLines=u.get("snapToLines",!0),d.size=u.get("size",100),d.align=u.get("align",w);var c=u.get("position","auto");c==="auto"&&L.position===50&&(c=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=c}function o(){E=E.replace(/^\s+/,"")}if(o(),b.startTime=e(),o(),E.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);E=E.substr(3),o(),b.endTime=e(),o(),a(E,b)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
`)}var C=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new O,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=E.prototype;return b.parse=function(h){var e=this;h&&(e.buffer+=e.decoder.decode(h,{stream:!0}));function a(){var c=e.buffer,i=0;for(c=x(c);i<c.length&&c[i]!=="\r"&&c[i]!==`
`;)++i;var r=c.substr(0,i);return c[i]==="\r"&&++i,c[i]===`
`&&++i,e.buffer=c.substr(i),r}function o(c){M(c,function(i,r){},/:/)}try{var f="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;f=a();var d=f.match(/^()?WEBVTT([ \t].*)?$/);if(!d||!d[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var u=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;u?u=!1:f=a();switch(e.state){case"HEADER":/:/.test(f)?o(f):f||(e.state="ID");continue;case"NOTE":f||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(f)){e.state="NOTE";break}if(!f)continue;if(e.cue=new B.default(0,0,""),e.state="CUE",f.indexOf("-->")===-1){e.cue.id=f;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(f,e.cue,e.regionList)}catch(c){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var p=f.indexOf("-->")!==-1;if(!f||p&&(u=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
`),e.cue.text+=f}continue;case"BADCUE":f||(e.state="ID")}}}catch(c){e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
`,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){h.onparsingerror&&h.onparsingerror(e)}return h.onflush&&h.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(ce,U,S){"use strict";S.r(U),S.d(U,"generateCueId",function(){return C}),S.d(U,"parseWebVTT",function(){return b});var B=S("./src/polyfills/number.ts"),O=S("./src/utils/vttparser.ts"),A=S("./src/demux/id3.ts"),_=S("./src/utils/timescale-conversion.ts"),M=S("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,w=function(h,e,a){return a===void 0&&(a=0),h.substr(a,e.length)===e},y=function(h){var e=parseInt(h.substr(-3)),a=parseInt(h.substr(-6,2)),o=parseInt(h.substr(-9,2)),f=h.length>9?parseInt(h.substr(0,h.indexOf(":"))):0;if(!Object(B.isFiniteNumber)(e)||!Object(B.isFiniteNumber)(a)||!Object(B.isFiniteNumber)(o)||!Object(B.isFiniteNumber)(f))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return e+=1e3*a,e+=60*1e3*o,e+=60*60*1e3*f,e},x=function(h){for(var e=5381,a=h.length;a;)e=e*33^h.charCodeAt(--a);return(e>>>0).toString()};function C(v,h,e){return x(v.toString())+x(h.toString())+x(e)}var E=function(h,e,a){var o=h[e],f=h[o.prevCC];if(!f||!f.new&&o.new){h.ccOffset=h.presentationOffset=o.start,o.new=!1;return}for(;(d=f)!==null&&d!==void 0&&d.new;){var d;h.ccOffset+=o.start-f.start,o.new=!1,o=f,f=h[o.prevCC]}h.presentationOffset=a};function b(v,h,e,a,o,f,d,u){var p=new O.VTTParser,c=Object(A.utf8ArrayToStr)(new Uint8Array(v)).trim().replace(L,`
`).split(`
`),i=[],r=Object(_.toMpegTsClockFromTimescale)(h,e),t="00:00.000",s=0,m=0,g,T=!0,P=!1;p.oncue=function(I){var F=a[o],K=a.ccOffset,V=(s-r)/9e4;if(F!=null&&F.new&&(m!==void 0?K=a.ccOffset=F.start:E(a,o,V)),V&&(K=V-a.presentationOffset),P){var Q=I.endTime-I.startTime,Z=Object(M.normalizePts)((I.startTime+K-m)*9e4,f*9e4)/9e4;I.startTime=Z,I.endTime=Z+Q}var ie=I.text.trim();I.text=decodeURIComponent(encodeURIComponent(ie)),I.id||(I.id=C(I.startTime,I.endTime,ie)),I.endTime>0&&i.push(I)},p.onparsingerror=function(I){g=I},p.onflush=function(){if(g){u(g);return}d(i)},c.forEach(function(I){if(T)if(w(I,"X-TIMESTAMP-MAP=")){T=!1,P=!0,I.substr(16).split(",").forEach(function(F){w(F,"LOCAL:")?t=F.substr(6):w(F,"MPEGTS:")&&(s=parseInt(F.substr(7)))});try{m=y(t)/1e3}catch(F){P=!1,g=F}return}else I===""&&(T=!1);p.parse(I+`
`)}),p.flush()}},"./src/utils/xhr-loader.ts":function(ce,U,S){"use strict";S.r(U);var B=S("./src/utils/logger.ts"),O=S("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,_=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 O.LoadStats,this.retryDelay=0}var L=M.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},L.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(y,x,C){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=x,this.callbacks=C,this.retryDelay=x.retryDelay,this.loadInternal()},L.loadInternal=function(){var y=this.config,x=this.context;if(!y)return;var C=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var b=this.xhrSetup;try{if(b)try{b(C,x.url)}catch(e){C.open("GET",x.url,!0),b(C,x.url)}C.readyState||C.open("GET",x.url,!0);var v=this.context.headers;if(v)for(var h in v)C.setRequestHeader(h,v[h])}catch(e){this.callbacks.onError({code:C.status,text:e.message},x,C);return}x.rangeEnd&&C.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),C.onreadystatechange=this.readystatechange.bind(this),C.onprogress=this.loadprogress.bind(this),C.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),C.send()},L.readystatechange=function(){var y=this.context,x=this.loader,C=this.stats;if(!y||!x)return;var E=x.readyState,b=this.config;if(C.aborted)return;if(E>=2)if(self.clearTimeout(this.requestTimeout),C.loading.first===0&&(C.loading.first=Math.max(self.performance.now(),C.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var v=x.status;if(v>=200&&v<300){C.loading.end=Math.max(self.performance.now(),C.loading.first);var h,e;if(y.responseType==="arraybuffer"?(h=x.response,e=h.byteLength):(h=x.responseText,e=h.length),C.loaded=C.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(C,y,h,x),!this.callbacks)return;var o={url:x.responseURL,data:h};this.callbacks.onSuccess(o,C,y,x)}else C.retry>=b.maxRetry||v>=400&&v<499?(B.logger.error(v+" while loading "+y.url),this.callbacks.onError({code:v,text:x.statusText},y,x)):(B.logger.warn(v+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,b.maxRetryDelay),C.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)},L.loadtimeout=function(){B.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(y){var x=this.stats;x.loaded=y.loaded,y.lengthComputable&&(x.total=y.total)},L.getCacheAge=function(){var y=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");y=x?parseFloat(x):null}return y},M}();U.default=_}}).default})},vHTk:function(nt,We,J){nt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);