|
|
(self.webpackChunk=self.webpackChunk||[]).push([[8411],{65030:function(e,t,n){"use strict";n.d(t,{Z:function(){return j}});var i=n(33885),r=n(42978),s=n(75931),a=n(43403),o=n(92310),l=n.n(o),c=n(29301),u=n(76846),h=n(96452),d=n(6089),p=n(80402),f=n(34280),m=n(49658),g=n(59301),_=n(54476),y=n(77900),v=n(8654);function b(e){var t=e.prefixCls,n=e.align,i=e.arrow,r=e.arrowPos,s=i||{},a=s.className,o=s.content,c=r.x,u=void 0===c?0:c,h=r.y,d=void 0===h?0:h,p=g.useRef();if(!n||!n.points)return null;var f={position:"absolute"};if(!1!==n.autoArrow){var m=n.points[0],_=n.points[1],y=m[0],v=m[1],b=_[0],w=_[1];y!==b&&["t","b"].includes(y)?"t"===y?f.top=0:f.bottom=0:f.top=d,v!==w&&["l","r"].includes(v)?"l"===v?f.left=0:f.right=0:f.left=u}return g.createElement("div",{ref:p,className:l()("".concat(t,"-arrow"),a),style:f},o)}function w(e){var t=e.prefixCls,n=e.open,i=e.zIndex,r=e.mask,s=e.motion;return r?g.createElement(y.default,(0,_.Z)({},s,{motionAppear:!0,visible:n,removeOnLeave:!0}),(function(e){var n=e.className;return g.createElement("div",{style:{zIndex:i},className:l()("".concat(t,"-mask"),n)})})):null}var x=g.memo((function(e){return e.children}),(function(e,t){return t.cache}));var k=g.forwardRef((function(e,t){var n=e.popup,s=e.className,a=e.prefixCls,o=e.style,u=e.target,h=e.onVisibleChanged,d=e.open,p=e.keepDom,m=e.fresh,k=e.onClick,S=e.mask,E=e.arrow,T=e.arrowPos,C=e.align,L=e.motion,A=e.maskMotion,D=e.forceRender,M=e.getPopupContainer,R=e.autoDestroy,I=e.portal,P=e.zIndex,O=e.onMouseEnter,F=e.onMouseLeave,N=e.onPointerEnter,B=e.onPointerDownCapture,$=e.ready,K=e.offsetX,U=e.offsetY,z=e.offsetR,V=e.offsetB,q=e.onAlign,G=e.onPrepare,H=e.stretch,j=e.targetWidth,W=e.targetHeight,Z="function"==typeof n?n():n,Y=d||p,X=(null==M?void 0:M.length)>0,J=g.useState(!M||!X),Q=(0,r.Z)(J,2),ee=Q[0],te=Q[1];if((0,f.Z)((function(){!ee&&X&&u&&te(!0)}),[ee,X,u]),!ee)return null;var ne="auto",ie={left:"-1000vw",top:"-1000vh",right:ne,bottom:ne};if($||!d){var re,se=C.points,ae=C.dynamicInset||(null===(re=C._experimental)||void 0===re?void 0:re.dynamicInset),oe=ae&&"r"===se[0][1],le=ae&&"b"===se[0][0];oe?(ie.right=z,ie.left=ne):(ie.left=K,ie.right=ne),le?(ie.bottom=V,ie.top=ne):(ie.top=U,ie.bottom=ne)}var ce={};return H&&(H.includes("height")&&W?ce.height=W:H.includes("minHeight")&&W&&(ce.minHeight=W),H.includes("width")&&j?ce.width=j:H.includes("minWidth")&&j&&(ce.minWidth=j)),d||(ce.pointerEvents="none"),g.createElement(I,{open:D||Y,getContainer:M&&function(){return M(u)},autoDestroy:R},g.createElement(w,{prefixCls:a,open:d,zIndex:P,mask:S,motion:A}),g.createElement(c.Z,{onResize:q,disabled:!d},(function(e){return g.createElement(y.default,(0,_.Z)({motionAppear:!0,motionEnter:!0,motionLeave:!0,removeOnLeave:!1,forceRender:D,leavedClassName:"".concat(a,"-hidden")},L,{onAppearPrepare:G,onEnterPrepare:G,visible:d,onVisibleChanged:function(e){var t;null==L||null===(t=L.onVisibleChanged)||void 0===t||t.call(L,e),h(e)}}),(function(n,r){var c=n.className,u=n.style,h=l()(a,c,s);return g.createElement("div",{ref:(0,v.sQ)(e,t,r),className:h,style:(0,i.Z)((0,i.Z)((0,i.Z)((0,i.Z)({"--arrow-x":"".concat(T.x||0,"px"),"--arrow-y":"".concat(T.y||0,"px")},ie),ce),u),{},{boxSizing:"border-box",zIndex:P},o),onMouseEnter:O,onMouseLeave:F,onPointerEnter:N,onClick:k,onPointerDownCapture:B},E&&g.createElement(b,{prefixCls:a,arrow:E,arrowPos:T,align:C}),g.createElement(x,{cache:!d&&!m},Z))}))})))}));var S=g.forwardRef((function(e,t){var n=e.children,i=e.getTriggerDOMNode,r=(0,v.Yr)(n),s=g.useCallback((function(e){(0,v.mH)(t,i?i(e):e)}),[i]),a=(0,v.x1)(s,(0,v.C4)(n));return r?g.cloneElement(n,{ref:a}):n})),E=g.createContext(null);function T(e){return e?Array.isArray(e)?e:[e]:[]}function C(e,t,n,i){return g.useMemo((function(){var r=T(null!=n?n:t),s=T(null!=i?i:t),a=new Set(r),o=new Set(s);return e&&(a.has("hover")&&(a.delete("hover"),a.add("click")),o.has("hover")&&(o.delete("hover"),o.add("click"))),[a,o]}),[e,t,n,i])}var L=n(29194);function A(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0;return n?e[0]===t[0]:e[0]===t[0]&&e[1]===t[1]}function D(e,t,n,i){for(var r=n.points,s=Object.keys(e),a=0;a<s.length;a+=1){var o,l=s[a];if(A(null===(o=e[l])||void 0===o?void 0:o.points,r,i))return"".concat(t,"-placement-").concat(l)}return""}function M(e,t,n,i){return t||(n?{motionName:"".concat(e,"-").concat(n)}:i?{motionName:i}:null)}function R(e){return e.ownerDocument.defaultView}function I(e){for(var t=[],n=null==e?void 0:e.parentElement,i=["hidden","scroll","clip","auto"];n;){var r=R(n).getComputedStyle(n);[r.overflowX,r.overflowY,r.overflow].some((function(e){return i.includes(e)}))&&t.push(n),n=n.parentElement}return t}function P(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Number.isNaN(e)?t:e}function O(e){return P(parseFloat(e),0)}function F(e,t){var n=(0,i.Z)({},e);return(t||[]).forEach((function(e){if(!(e instanceof HTMLBodyElement||e instanceof HTMLHtmlElement)){var t=R(e).getComputedStyle(e),i=t.overflow,r=t.overflowClipMargin,s=t.borderTopWidth,a=t.borderBottomWidth,o=t.borderLeftWidth,l=t.borderRightWidth,c=e.getBoundingClientRect(),u=e.offsetHeight,h=e.clientHeight,d=e.offsetWidth,p=e.clientWidth,f=O(s),m=O(a),g=O(o),_=O(l),y=P(Math.round(c.width/d*1e3)/1e3),v=P(Math.round(c.height/u*1e3)/1e3),b=(d-p-g-_)*y,w=(u-h-f-m)*v,x=f*v,k=m*v,S=g*y,E=_*y,T=0,C=0;if("clip"===i){var L=O(r);T=L*y,C=L*v}var A=c.x+S-T,D=c.y+x-C,M=A+c.width+2*T-S-E-b,I=D+c.height+2*C-x-k-w;n.left=Math.max(n.left,A),n.top=Math.max(n.top,D),n.right=Math.min(n.right,M),n.bottom=Math.min(n.bottom,I)}})),n}function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n="".concat(t),i=n.match(/^(.*)\%$/);return i?e*(parseFloat(i[1])/100):parseFloat(n)}function B(e,t){var n=t||[],i=(0,r.Z)(n,2),s=i[0],a=i[1];return[N(e.width,s),N(e.height,a)]}function $(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return[e[0],e[1]]}function K(e,t){var n,i=t[0],r=t[1];return n="t"===i?e.y:"b"===i?e.y+e.height:e.y+e.height/2,{x:"l"===r?e.x:"r"===r?e.x+e.width:e.x+e.width/2,y:n}}function U(e,t){var n={t:"b",b:"t",l:"r",r:"l"};return e.map((function(e,i){return i===t?n[e]||"c":e})).join("")}function z(e,t,n,s,a,o,l){var c=g.useState({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:a[s]||{}}),h=(0,r.Z)(c,2),p=h[0],m=h[1],_=g.useRef(0),y=g.useMemo((function(){return t?I(t):[]}),[t]),v=g.useRef({});e||(v.current={});var b=(0,d.Z)((function(){if(t&&n&&e){var c,h,d,p,f,g=t,_=g.ownerDocument,b=R(g),w=b.getComputedStyle(g).position,x=g.style.left,k=g.style.top,S=g.style.right,E=g.style.bottom,T=g.style.overflow,C=(0,i.Z)((0,i.Z)({},a[s]),o),A=_.createElement("div");if(null===(c=g.parentElement)||void 0===c||c.appendChild(A),A.style.left="".concat(g.offsetLeft,"px"),A.style.top="".concat(g.offsetTop,"px"),A.style.position=w,A.style.height="".concat(g.offsetHeight,"px"),A.style.width="".concat(g.offsetWidth,"px"),g.style.left="0",g.style.top="0",g.style.right="auto",g.style.bottom="auto",g.style.overflow="hidden",Array.isArray(n))f={x:n[0],y:n[1],width:0,height:0};else{var D,M,I=n.getBoundingClientRect();I.x=null!==(D=I.x)&&void 0!==D?D:I.left,I.y=null!==(M=I.y)&&void 0!==M?M:I.top,f={x:I.x,y:I.y,width:I.width,height:I.height}}var O=g.getBoundingClientRect(),N=b.getComputedStyle(g),z=N.height,V=N.width;O.x=null!==(h=O.x)&&void 0!==h?h:O.left,O.y=null!==(d=O.y)&&void 0!==d?d:O.top;var q=_.documentElement,G=q.clientWidth,H=q.clientHeight,j=q.scrollWidth,W=q.scrollHeight,Z=q.scrollTop,Y=q.scrollLeft,X=O.height,J=O.width,Q=f.height,ee=f.width,te={left:0,top:0,right:G,bottom:H},ne={left:-Y,top:-Z,right:j-Y,bottom:W-Z},ie=C.htmlRegion,re="visible",se="visibleFirst";"scroll"!==ie&&ie!==se&&(ie=re);var ae=ie===se,oe=F(ne,y),le=F(te,y),ce=ie===re?le:oe,ue=ae?le:ce;g.style.left="auto",g.style.top="auto",g.style.right="0",g.style.bottom="0";var he=g.getBoundingClientRect();g.style.left=x,g.style.top=k,g.style.right=S,g.style.bottom=E,g.style.overflow=T,null===(p=g.parentElement)||void 0===p||p.removeChild(A);var de=P(Math.round(J/parseFloat(V)*1e3)/1e3),pe=P(Math.round(X/parseFloat(z)*1e3)/1e3);if(0===de||0===pe||(0,u.Sh)(n)&&!(0,L.Z)(n))return;var fe=C.offset,me=C.targetOffset,ge=B(O,fe),_e=(0,r.Z)(ge,2),ye=_e[0],ve=_e[1],be=B(f,me),we=(0,r.Z)(be,2),xe=we[0],ke=we[1];f.x-=xe,f.y-=ke;var Se=C.points||[],Ee=(0,r.Z)(Se,2),Te=Ee[0],Ce=$(Ee[1]),Le=$(Te),Ae=K(f,Ce),De=K(O,Le),Me=(0,i.Z)({},C),Re=Ae.x-De.x+ye,Ie=Ae.y-De.y+ve;function Tt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ce,i=O.x+e,r=O.y+t,s=i+J,a=r+X,o=Math.max(i,n.left),l=Math.max(r,n.top),c=Math.min(s,n.right),u=Math.min(a,n.bottom);return Math.max(0,(c-o)*(u-l))}var Pe,Oe,Fe,Ne,Be=Tt(Re,Ie),$e=Tt(Re,Ie,le),Ke=K(f,["t","l"]),Ue=K(O,["t","l"]),ze=K(f,["b","r"]),Ve=K(O,["b","r"]),qe=C.overflow||{},Ge=qe.adjustX,He=qe.adjustY,je=qe.shiftX,We=qe.shiftY,Ze=function(e){return"boolean"==typeof e?e:e>=0};function Ct(){Pe=O.y+Ie,Oe=Pe+X,Fe=O.x+Re,Ne=Fe+J}Ct();var Ye=Ze(He),Xe=Le[0]===Ce[0];if(Ye&&"t"===Le[0]&&(Oe>ue.bottom||v.current.bt)){var Je=Ie;Xe?Je-=X-Q:Je=Ke.y-Ve.y-ve;var Qe=Tt(Re,Je),et=Tt(Re,Je,le);Qe>Be||Qe===Be&&(!ae||et>=$e)?(v.current.bt=!0,Ie=Je,ve=-ve,Me.points=[U(Le,0),U(Ce,0)]):v.current.bt=!1}if(Ye&&"b"===Le[0]&&(Pe<ue.top||v.current.tb)){var tt=Ie;Xe?tt+=X-Q:tt=ze.y-Ue.y-ve;var nt=Tt(Re,tt),it=Tt(Re,tt,le);nt>Be||nt===Be&&(!ae||it>=$e)?(v.current.tb=!0,Ie=tt,ve=-ve,Me.points=[U(Le,0),U(Ce,0)]):v.current.tb=!1}var rt=Ze(Ge),st=Le[1]===Ce[1];if(rt&&"l"===Le[1]&&(Ne>ue.right||v.current.rl)){var at=Re;st?at-=J-ee:at=Ke.x-Ve.x-ye;var ot=Tt(at,Ie),lt=Tt(at,Ie,le);ot>Be||ot===Be&&(!ae||lt>=$e)?(v.current.rl=!0,Re=at,ye=-ye,Me.points=[U(Le,1),U(Ce,1)]):v.current.rl=!1}if(rt&&"r"===Le[1]&&(Fe<ue.left||v.current.lr)){var ct=Re;st?ct+=J-ee:ct=ze.x-Ue.x-ye;var ut=Tt(ct,Ie),ht=Tt(ct,Ie,le);ut>Be||ut===Be&&(!ae||ht>=$e)?(v.current.lr=!0,Re=ct,ye=-ye,Me.points=[U(Le,1),U(Ce,1)]):v.current.lr=!1}Ct();var dt=!0===je?0:je;"number"==typeof dt&&(Fe<le.left&&(Re-=Fe-le.left-ye,f.x+ee<le.left+dt&&(Re+=f.x-le.left+ee-dt)),Ne>le.right&&(Re-=Ne-le.right-ye,f.x>le.right-dt&&(Re+=f.x-le.right+dt)));var pt=!0===We?0:We;"number"==typeof pt&&(Pe<le.top&&(Ie-=Pe-le.top-ve,f.y+Q<le.top+pt&&(Ie+=f.y-le.top+Q-pt)),Oe>le.bottom&&(Ie-=Oe-le.bottom-ve,f.y>le.bottom-pt&&(Ie+=f.y-le.bottom+pt)));var ft=O.x+Re,mt=ft+J,gt=O.y+Ie,_t=gt+X,yt=f.x,vt=yt+ee,bt=f.y,wt=bt+Q,xt=(Math.max(ft,yt)+Math.min(mt,vt))/2-ft,kt=(Math.max(gt,bt)+Math.min(_t,wt))/2-gt;null==l||l(t,Me);var St=he.right-O.x-(Re+O.width),Et=he.bottom-O.y-(Ie+O.height);1===de&&(Re=Math.round(Re),St=Math.round(St)),1===pe&&(Ie=Math.round(Ie),Et=Math.round(Et)),m({ready:!0,offsetX:Re/de,offsetY:Ie/pe,offsetR:St/de,offsetB:Et/pe,arrowX:xt/de,arrowY:kt/pe,scaleX:de,scaleY:pe,align:Me})}})),w=function(){m((function(e){return(0,i.Z)((0,i.Z)({},e),{},{ready:!1})}))};return(0,f.Z)(w,[s]),(0,f.Z)((function(){e||w()}),[e]),[p.ready,p.offsetX,p.offsetY,p.offsetR,p.offsetB,p.arrowX,p.arrowY,p.scaleX,p.scaleY,p.align,function(){_.current+=1;var e=_.current;Promise.resolve().then((function(){_.current===e&&b()}))}]}var V=n(94480);function q(e,t,n,i,r){(0,f.Z)((function(){if(e&&t&&n){var s=n,a=I(t),o=I(s),l=R(s),c=new Set([l].concat((0,V.Z)(a),(0,V.Z)(o)));function u(){i(),r()}return c.forEach((function(e){e.addEventListener("scroll",u,{passive:!0})})),l.addEventListener("resize",u,{passive:!0}),i(),function(){c.forEach((function(e){e.removeEventListener("scroll",u),l.removeEventListener("resize",u)}))}}}),[e,t,n])}n(48736);function G(e,t,n,i,r,s,a,o){var l=g.useRef(e);l.current=e;var c=g.useRef(!1);return g.useEffect((function(){if(t&&i&&(!r||s)){var e=function(){c.current=!1},u=function(e){var t;!l.current||a((null===(t=e.composedPath)||void 0===t||null===(t=t.call(e))||void 0===t?void 0:t[0])||e.target)||c.current||o(!1)},d=R(i);d.addEventListener("pointerdown",e,!0),d.addEventListener("mousedown",u,!0),d.addEventListener("contextmenu",u,!0);var p=(0,h.A)(n);return p&&(p.addEventListener("mousedown",u,!0),p.addEventListener("contextmenu",u,!0)),function(){d.removeEventListener("pointerdown",e,!0),d.removeEventListener("mousedown",u,!0),d.removeEventListener("contextmenu",u,!0),p&&(p.removeEventListener("mousedown",u,!0),p.removeEventListener("contextmenu",u,!0))}}}),[t,n,i,r,s]),function(){c.current=!0}}var H=["prefixCls","children","action","showAction","hideAction","popupVisible","defaultPopupVisible","onPopupVisibleChange","afterPopupVisibleChange","mouseEnterDelay","mouseLeaveDelay","focusDelay","blurDelay","mask","maskClosable","getPopupContainer","forceRender","autoDestroy","destroyPopupOnHide","popup","popupClassName","popupStyle","popupPlacement","builtinPlacements","popupAlign","zIndex","stretch","getPopupClassNameFromAlign","fresh","alignPoint","onPopupClick","onPopupAlign","arrow","popupMotion","maskMotion","popupTransitionName","popupAnimation","maskTransitionName","maskAnimation","className","getTriggerDOMNode"];var j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a.Z,t=g.forwardRef((function(t,n){var a=t.prefixCls,o=void 0===a?"rc-trigger-popup":a,_=t.children,y=t.action,v=void 0===y?"hover":y,b=t.showAction,w=t.hideAction,x=t.popupVisible,T=t.defaultPopupVisible,L=t.onPopupVisibleChange,A=t.afterPopupVisibleChange,R=t.mouseEnterDelay,I=t.mouseLeaveDelay,P=void 0===I?.1:I,O=t.focusDelay,F=t.blurDelay,N=t.mask,B=t.maskClosable,$=void 0===B||B,K=t.getPopupContainer,U=t.forceRender,V=t.autoDestroy,j=t.destroyPopupOnHide,W=t.popup,Z=t.popupClassName,Y=t.popupStyle,X=t.popupPlacement,J=t.builtinPlacements,Q=void 0===J?{}:J,ee=t.popupAlign,te=t.zIndex,ne=t.stretch,ie=t.getPopupClassNameFromAlign,re=t.fresh,se=t.alignPoint,ae=t.onPopupClick,oe=t.onPopupAlign,le=t.arrow,ce=t.popupMotion,ue=t.maskMotion,he=t.popupTransitionName,de=t.popupAnimation,pe=t.maskTransitionName,fe=t.maskAnimation,me=t.className,ge=t.getTriggerDOMNode,_e=(0,s.Z)(t,H),ye=V||j||!1,ve=g.useState(!1),be=(0,r.Z)(ve,2),we=be[0],xe=be[1];(0,f.Z)((function(){xe((0,m.Z)())}),[]);var ke=g.useRef({}),Se=g.useContext(E),Ee=g.useMemo((function(){return{registerSubPopup:function(e,t){ke.current[e]=t,null==Se||Se.registerSubPopup(e,t)}}}),[Se]),Te=(0,p.Z)(),Ce=g.useState(null),Le=(0,r.Z)(Ce,2),Ae=Le[0],De=Le[1],Me=g.useRef(null),Re=(0,d.Z)((function(e){Me.current=e,(0,u.Sh)(e)&&Ae!==e&&De(e),null==Se||Se.registerSubPopup(Te,e)})),Ie=g.useState(null),Pe=(0,r.Z)(Ie,2),Oe=Pe[0],Fe=Pe[1],Ne=g.useRef(null),Be=(0,d.Z)((function(e){(0,u.Sh)(e)&&Oe!==e&&(Fe(e),Ne.current=e)})),$e=g.Children.only(_),Ke=(null==$e?void 0:$e.props)||{},Ue={},ze=(0,d.Z)((function(e){var t,n,i=Oe;return(null==i?void 0:i.contains(e))||(null===(t=(0,h.A)(i))||void 0===t?void 0:t.host)===e||e===i||(null==Ae?void 0:Ae.contains(e))||(null===(n=(0,h.A)(Ae))||void 0===n?void 0:n.host)===e||e===Ae||Object.values(ke.current).some((function(t){return(null==t?void 0:t.contains(e))||e===t}))})),Ve=M(o,ce,de,he),qe=M(o,ue,fe,pe),Ge=g.useState(T||!1),He=(0,r.Z)(Ge,2),je=He[0],We=He[1],Ze=null!=x?x:je,Ye=(0,d.Z)((function(e){void 0===x&&We(e)}));(0,f.Z)((function(){We(x||!1)}),[x]);var Xe=g.useRef(Ze);Xe.current=Ze;var Je=g.useRef([]);Je.current=[];var Qe=(0,d.Z)((function(e){var t;Ye(e),(null!==(t=Je.current[Je.current.length-1])&&void 0!==t?t:Ze)!==e&&(Je.current.push(e),null==L||L(e))})),et=g.useRef(),tt=function(){clearTimeout(et.current)},nt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;tt(),0===t?Qe(e):et.current=setTimeout((function(){Qe(e)}),1e3*t)};g.useEffect((function(){return tt}),[]);var it=g.useState(!1),rt=(0,r.Z)(it,2),st=rt[0],at=rt[1];(0,f.Z)((function(e){e&&!Ze||at(!0)}),[Ze]);var ot=g.useState(null),lt=(0,r.Z)(ot,2),ct=lt[0],ut=lt[1],ht=g.useState(null),dt=(0,r.Z)(ht,2),pt=dt[0],ft=dt[1],mt=function(e){ft([e.clientX,e.clientY])},gt=z(Ze,Ae,se&&null!==pt?pt:Oe,X,Q,ee,oe),_t=(0,r.Z)(gt,11),yt=_t[0],vt=_t[1],bt=_t[2],wt=_t[3],xt=_t[4],kt=_t[5],St=_t[6],Et=_t[7],Tt=_t[8],Ct=_t[9],Lt=_t[10],At=C(we,v,b,w),Dt=(0,r.Z)(At,2),Mt=Dt[0],Rt=Dt[1],It=Mt.has("click"),Pt=Rt.has("click")||Rt.has("contextMenu"),Ot=(0,d.Z)((function(){st||Lt()}));q(Ze,Oe,Ae,Ot,(function(){Xe.current&&se&&Pt&&nt(!1)})),(0,f.Z)((function(){Ot()}),[pt,X]),(0,f.Z)((function(){!Ze||null!=Q&&Q[X]||Ot()}),[JSON.stringify(ee)]);var Ft=g.useMemo((function(){var e=D(Q,o,Ct,se);return l()(e,null==ie?void 0:ie(Ct))}),[Ct,ie,Q,o,se]);g.useImperativeHandle(n,(function(){return{nativeElement:Ne.current,popupElement:Me.current,forceAlign:Ot}}));var Nt=g.useState(0),Bt=(0,r.Z)(Nt,2),$t=Bt[0],Kt=Bt[1],Ut=g.useState(0),zt=(0,r.Z)(Ut,2),Vt=zt[0],qt=zt[1],Gt=function(){if(ne&&Oe){var e=Oe.getBoundingClientRect();Kt(e.width),qt(e.height)}};function Ht(e,t,n,i){Ue[e]=function(r){var s;null==i||i(r),nt(t,n);for(var a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];null===(s=Ke[e])||void 0===s||s.call.apply(s,[Ke,r].concat(o))}}(0,f.Z)((function(){ct&&(Lt(),ct(),ut(null))}),[ct]),(It||Pt)&&(Ue.onClick=function(e){var t;Xe.current&&Pt?nt(!1):!Xe.current&&It&&(mt(e),nt(!0));for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];null===(t=Ke.onClick)||void 0===t||t.call.apply(t,[Ke,e].concat(i))});var jt,Wt,Zt=G(Ze,Pt,Oe,Ae,N,$,ze,nt),Yt=Mt.has("hover"),Xt=Rt.has("hover");Yt&&(Ht("onMouseEnter",!0,R,(function(e){mt(e)})),Ht("onPointerEnter",!0,R,(function(e){mt(e)})),jt=function(e){(Ze||st)&&null!=Ae&&Ae.contains(e.target)&&nt(!0,R)},se&&(Ue.onMouseMove=function(e){var t;null===(t=Ke.onMouseMove)||void 0===t||t.call(Ke,e)})),Xt&&(Ht("onMouseLeave",!1,P),Ht("onPointerLeave",!1,P),Wt=function(){nt(!1,P)}),Mt.has("focus")&&Ht("onFocus",!0,O),Rt.has("focus")&&Ht("onBlur",!1,F),Mt.has("contextMenu")&&(Ue.onContextMenu=function(e){var t;Xe.current&&Rt.has("contextMenu")?nt(!1):(mt(e),nt(!0)),e.preventDefault();for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];null===(t=Ke.onContextMenu)||void 0===t||t.call.apply(t,[Ke,e].concat(i))}),me&&(Ue.className=l()(Ke.className,me));var Jt=g.useRef(!1);Jt.current||(Jt.current=U||Ze||st);var Qt=(0,i.Z)((0,i.Z)({},Ke),Ue),en={};["onContextMenu","onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur"].forEach((function(e){_e[e]&&(en[e]=function(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];null===(t=Qt[e])||void 0===t||t.call.apply(t,[Qt].concat(i)),_e[e].apply(_e,i)})}));var tn=g.cloneElement($e,(0,i.Z)((0,i.Z)({},Qt),en)),nn={x:kt,y:St},rn=le?(0,i.Z)({},!0!==le?le:{}):null;return g.createElement(g.Fragment,null,g.createElement(c.Z,{disabled:!Ze,ref:Be,onResize:function(){Gt(),Ot()}},g.createElement(S,{getTriggerDOMNode:ge},tn)),Jt.current&&g.createElement(E.Provider,{value:Ee},g.createElement(k,{portal:e,ref:Re,prefixCls:o,popup:W,className:l()(Z,Ft),style:Y,target:Oe,onMouseEnter:jt,onMouseLeave:Wt,onPointerEnter:jt,zIndex:te,open:Ze,keepDom:st,fresh:re,onClick:ae,onPointerDownCapture:Zt,mask:N,motion:Ve,maskMotion:qe,onVisibleChanged:function(e){at(!1),Lt(),null==A||A(e)},onPrepare:function(){return new Promise((function(e){Gt(),ut((function(){return e}))}))},forceRender:U,autoDestroy:ye,getPopupContainer:K,align:Ct,arrow:rn,arrowPos:nn,ready:yt,offsetX:vt,offsetY:bt,offsetR:wt,offsetB:xt,onAlign:Ot,stretch:ne,targetWidth:$t/Et,targetHeight:Vt/Tt})))}));return t}(a.Z)},64018:function(){window.PR_SHOULD_USE_CONTINUATION=!0,function(){var e=window,t=["break,continue,do,else,for,if,return,while"],n=[[t,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],i=[n,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],r=[n,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],s=[n,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],a=[n,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],o="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",l=[t,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],c=[t,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],u=[t,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],h=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,d="str",p="com",f="typ",m="lit",g="pun",_="pln",y="atv";function v(e,t,n,i,r){if(n){var s={sourceNode:e,pre:1,langExtension:null,numberLines:null,sourceCode:n,spans:null,basePos:t,decorations:null};i(s),r.push.apply(r,s.decorations)}}var b=/\S/;function w(e){for(var t=void 0,n=e.firstChild;n;n=n.nextSibling){var i=n.nodeType;t=1===i?t?e:n:3===i&&b.test(n.nodeValue)?e:t}return t===e?void 0:t}function x(e,t){var n,i={};!function(){for(var r=e.concat(t),s=[],a={},o=0,l=r.length;o<l;++o){var c=r[o],u=c[3];if(u)for(var h=u.length;--h>=0;)i[u.charAt(h)]=c;var d=c[1],p=""+d;a.hasOwnProperty(p)||(s.push(d),a[p]=null)}s.push(/[\0-\uffff]/),n=function(e){for(var t=0,n=!1,i=!1,r=0,s=e.length;r<s;++r)if((d=e[r]).ignoreCase)i=!0;else if(/[a-z]/i.test(d.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){n=!0,i=!1;break}var a={b:8,t:9,n:10,v:11,f:12,r:13};function o(e){var t=e.charCodeAt(0);if(92!==t)return t;var n=e.charAt(1);return(t=a[n])||("0"<=n&&n<="7"?parseInt(e.substring(1),8):"u"===n||"x"===n?parseInt(e.substring(2),16):e.charCodeAt(1))}function l(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);var t=String.fromCharCode(e);return"\\"===t||"-"===t||"]"===t||"^"===t?"\\"+t:t}function c(e){var t=e.substring(1,e.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")),n=[],i="^"===t[0],r=["["];i&&r.push("^");for(var s=i?1:0,a=t.length;s<a;++s){var c=t[s];if(/\\[bdsw]/i.test(c))r.push(c);else{var u,h=o(c);s+2<a&&"-"===t[s+1]?(u=o(t[s+2]),s+=2):u=h,n.push([h,u]),u<65||h>122||(u<65||h>90||n.push([32|Math.max(65,h),32|Math.min(u,90)]),u<97||h>122||n.push([-33&Math.max(97,h),-33&Math.min(u,122)]))}}n.sort((function(e,t){return e[0]-t[0]||t[1]-e[1]}));var d=[],p=[];for(s=0;s<n.length;++s)(f=n[s])[0]<=p[1]+1?p[1]=Math.max(p[1],f[1]):d.push(p=f);for(s=0;s<d.length;++s){var f=d[s];r.push(l(f[0])),f[1]>f[0]&&(f[1]+1>f[0]&&r.push("-"),r.push(l(f[1])))}return r.push("]"),r.join("")}function u(e){for(var i=e.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),r=i.length,s=[],a=0,o=0;a<r;++a)"("===(h=i[a])?++o:"\\"===h.charAt(0)&&(u=+h.substring(1))&&(u<=o?s[u]=-1:i[a]=l(u));for(a=1;a<s.length;++a)-1===s[a]&&(s[a]=++t);for(a=0,o=0;a<r;++a)if("("===(h=i[a]))s[++o]||(i[a]="(?:");else if("\\"===h.charAt(0)){var u;(u=+h.substring(1))&&u<=o&&(i[a]="\\"+s[u])}for(a=0;a<r;++a)"^"===i[a]&&"^"!==i[a+1]&&(i[a]="");if(e.ignoreCase&&n)for(a=0;a<r;++a){var h,d=(h=i[a]).charAt(0);h.length>=2&&"["===d?i[a]=c(h):"\\"!==d&&(i[a]=h.replace(/[a-zA-Z]/g,(function(e){var t=e.charCodeAt(0);return"["+String.fromCharCode(-33&t,32|t)+"]"})))}return i.join("")}var h=[];for(r=0,s=e.length;r<s;++r){var d;if((d=e[r]).global||d.multiline)throw new Error(""+d);h.push("(?:"+u(d)+")")}return new RegExp(h.join("|"),i?"gi":"g")}(s)}();var r=t.length,s=function(e){for(var a=e.sourceCode,o=e.basePos,l=e.sourceNode,c=[o,_],u=0,h=a.match(n)||[],d={},p=0,f=h.length;p<f;++p){var m,g=h[p],y=d[g],b=void 0;if("string"==typeof y)m=!1;else{var w=i[g.charAt(0)];if(w)b=g.match(w[1]),y=w[0];else{for(var x=0;x<r;++x)if(w=t[x],b=g.match(w[1])){y=w[0];break}b||(y=_)}!(m=y.length>=5&&"lang-"===y.substring(0,5))||b&&"string"==typeof b[1]||(m=!1,y="src"),m||(d[g]=y)}var k=u;if(u+=g.length,m){var S=b[1],E=g.indexOf(S),T=E+S.length;b[2]&&(E=(T=g.length-b[2].length)-S.length);var C=y.substring(5);v(l,o+k,g.substring(0,E),s,c),v(l,o+k+E,S,L(C,S),c),v(l,o+k+T,g.substring(T),s,c)}else c.push(o+k,y)}e.decorations=c};return s}function k(e){var t=[],n=[];e.tripleQuotedStrings?t.push([d,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):e.multiLineStrings?t.push([d,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):t.push([d,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),e.verbatimStrings&&n.push([d,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var i=e.hashComments;i&&(e.cStyleComments?(i>1?t.push([p,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):t.push([p,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),n.push([d,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):t.push([p,/^#[^\r\n]*/,null,"#"])),e.cStyleComments&&(n.push([p,/^\/\/[^\r\n]*/,null]),n.push([p,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var r=e.regexLiterals;if(r){var s=r>1?"":"\n\r",a=s?".":"[\\S\\s]",o="/(?=[^/*"+s+"])(?:[^/\\x5B\\x5C"+s+"]|\\x5C"+a+"|\\x5B(?:[^\\x5C\\x5D"+s+"]|\\x5C"+a+")*(?:\\x5D|$))+/";n.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+o+")")])}var l=e.types;l&&n.push([f,l]);var c=(""+e.keywords).replace(/^ | $/g,"");c.length&&n.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]),t.push([_,/^\s+/,null," \r\n\t "]);var u="^.[^\\s\\w.$@'\"`/\\\\]*";return e.regexLiterals&&(u+="(?!s*/)"),n.push([m,/^@[a-z_$][a-z_$@0-9]*/i,null],[f,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[_,/^[a-z_$][a-z_$@0-9]*/i,null],[m,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[_,/^\\[\s\S]?/,null],[g,new RegExp(u),null]),x(t,n)}var S=k({keywords:[i,s,r,a,o,l,c,u],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function E(e,t,n){for(var i=/(?:^|\s)nocode(?:\s|$)/,r=/\r\n?|\n/,s=e.ownerDocument,a=s.createElement("li");e.firstChild;)a.appendChild(e.firstChild);var o=[a];function l(e){var t=e.nodeType;if(1!=t||i.test(e.className)){if((3==t||4==t)&&n){var a=e.nodeValue,o=a.match(r);if(o){var u=a.substring(0,o.index);e.nodeValue=u;var h=a.substring(o.index+o[0].length);if(h)e.parentNode.insertBefore(s.createTextNode(h),e.nextSibling);c(e),u||e.parentNode.removeChild(e)}}}else if("br"===e.nodeName)c(e),e.parentNode&&e.parentNode.removeChild(e);else for(var d=e.firstChild;d;d=d.nextSibling)l(d)}function c(e){for(;!e.nextSibling;)if(!(e=e.parentNode))return;for(var t,n=function e(t,n){var i=n?t.cloneNode(!1):t,r=t.parentNode;if(r){var s=e(r,1),a=t.nextSibling;s.appendChild(i);for(var o=a;o;o=a)a=o.nextSibling,s.appendChild(o)}return i}(e.nextSibling,0);(t=n.parentNode)&&1===t.nodeType;)n=t;o.push(n)}for(var u=0;u<o.length;++u)l(o[u]);t===(0|t)&&o[0].setAttribute("value",t);var h=s.createElement("ol");h.className="linenums";for(var d=Math.max(0,t-1|0)||0,p=(u=0,o.length);u<p;++u)(a=o[u]).className="L"+(u+d)%10,a.firstChild||a.appendChild(s.createTextNode(" ")),h.appendChild(a);e.appendChild(h)}var T={};function C(t,n){for(var i=n.length;--i>=0;){var r=n[i];T.hasOwnProperty(r)?e.console&&console.warn("cannot override language handler %s",r):T[r]=t}}function L(e,t){return e&&T.hasOwnProperty(e)||(e=/^\s*</.test(t)?"default-markup":"default-code"),T[e]}function A(t){var n,i,r,s,a,o,l,c=t.langExtension;try{var u=(n=t.sourceNode,i=t.pre,r=/(?:^|\s)nocode(?:\s|$)/,s=[],a=0,o=[],l=0,function e(t){var n=t.nodeType;if(1==n){if(r.test(t.className))return;for(var c=t.firstChild;c;c=c.nextSibling)e(c);var u=t.nodeName.toLowerCase();"br"!==u&&"li"!==u||(s[l]="\n",o[l<<1]=a++,o[l++<<1|1]=t)}else if(3==n||4==n){var h=t.nodeValue;h.length&&(h=i?h.replace(/\r\n?/g,"\n"):h.replace(/[ \t\r\n]+/g," "),s[l]=h,o[l<<1]=a,a+=h.length,o[l++<<1|1]=t)}}(n),{sourceCode:s.join("").replace(/\n$/,""),spans:o}),h=u.sourceCode;t.sourceCode=h,t.spans=u.spans,t.basePos=0,L(c,h)(t),function(e){var t=/\bMSIE\s(\d+)/.exec(navigator.userAgent);t=t&&+t[1]<=8;var n,i,r=/\n/g,s=e.sourceCode,a=s.length,o=0,l=e.spans,c=l.length,u=0,h=e.decorations,d=h.length,p=0;for(h[d]=a,i=n=0;i<d;)h[i]!==h[i+2]?(h[n++]=h[i++],h[n++]=h[i++]):i+=2;for(d=n,i=n=0;i<d;){for(var f=h[i],m=h[i+1],g=i+2;g+2<=d&&h[g+1]===m;)g+=2;h[n++]=f,h[n++]=m,i=g}d=h.length=n;var _=e.sourceNode,y="";_&&(y=_.style.display,_.style.display="none");try{for(;u<c;){l[u];var v,b=l[u+2]||a,w=h[p+2]||a,x=(g=Math.min(b,w),l[u+1]);if(1!==x.nodeType&&(v=s.substring(o,g))){t&&(v=v.replace(r,"\r")),x.nodeValue=v;var k=x.ownerDocument,S=k.createElement("span");S.className=h[p+1];var E=x.parentNode;E.replaceChild(S,x),S.appendChild(x),o<b&&(l[u+1]=x=k.createTextNode(s.substring(g,b)),E.insertBefore(x,S.nextSibling))}(o=g)>=b&&(u+=2),o>=w&&(p+=2)}}finally{_&&(_.style.display=y)}}(t)}catch(t){e.console&&console.log(t&&t.stack||t)}}function D(e,t,n){var i=n||!1,r=t||null,s=document.createElement("div");return s.innerHTML="<pre>"+e+"</pre>",s=s.firstChild,i&&E(s,i,!0),A({langExtension:r,numberLines:i,sourceNode:s,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null}),s.innerHTML}function M(t,n){var i=n||document.body,r=i.ownerDocument||document;function s(e){return i.getElementsByTagName(e)}for(var a=[s("pre"),s("code"),s("xmp")],o=[],l=0;l<a.length;++l)for(var c=0,u=a[l].length;c<u;++c)o.push(a[l][c]);a=null;var h=Date;h.now||(h={now:function(){return+new Date}});var d=0,p=/\blang(?:uage)?-([\w.]+)(?!\S)/,f=/\bprettyprint\b/,m=/\bprettyprinted\b/,g=/pre|xmp/i,_=/^code$/i,y=/^(?:pre|code|xmp)$/i,v={};!function n(){for(var i=e.PR_SHOULD_USE_CONTINUATION?h.now()+250:1/0;d<o.length&&h.now()<i;d++){for(var s=o[d],a=v,l=s;l=l.previousSibling;){var c=l.nodeType,u=(7===c||8===c)&&l.nodeValue;if(u?!/^\??prettify\b/.test(u):3!==c||/\S/.test(l.nodeValue))break;if(u){a={},u.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(e,t,n){a[t]=n}));break}}var b=s.className;if((a!==v||f.test(b))&&!m.test(b)){for(var x=!1,k=s.parentNode;k;k=k.parentNode){var S=k.tagName;if(y.test(S)&&k.className&&f.test(k.className)){x=!0;break}}if(!x){s.className+=" prettyprinted";var T,C,L=a.lang;if(!L)!(L=b.match(p))&&(T=w(s))&&_.test(T.tagName)&&(L=T.className.match(p)),L&&(L=L[1]);if(g.test(s.tagName))C=1;else{var D=s.currentStyle,M=r.defaultView,R=D?D.whiteSpace:M&&M.getComputedStyle?M.getComputedStyle(s,null).getPropertyValue("white-space"):0;C=R&&"pre"===R.substring(0,3)}var I=a.linenums;(I="true"===I||+I)||(I=!!(I=b.match(/\blinenums\b(?::(\d+))?/))&&(!I[1]||!I[1].length||+I[1])),I&&E(s,I,C),A({langExtension:L,sourceNode:s,numberLines:I,pre:C,sourceCode:null,basePos:null,spans:null,decorations:null})}}}d<o.length?e.setTimeout(n,250):"function"==typeof t&&t()}()}C(S,["default-code"]),C(x([],[[_,/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],[p,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[g,/^(?:<[%?]|[%?]>)/],["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"]),C(x([[_,/^[\s]+/,null," \t\r\n"],[y,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[g,/^[=<>\/]+/],["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"]),C(x([],[[y,/^[\s\S]+/]]),["uq.val"]),C(k({keywords:i,hashComments:!0,cStyleComments:!0,types:h}),["c","cc","cpp","cxx","cyc","m"]),C(k({keywords:"null,true,false"}),["json"]),C(k({keywords:s,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:h}),["cs"]),C(k({keywords:r,cStyleComments:!0}),["java"]),C(k({keywords:u,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),C(k({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),C(k({keywords:o,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),C(k({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),C(k({keywords:a,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),C(k({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),C(x([],[[d,/^[\s\S]+/]]),["regex"]);var R=e.PR={createSimpleLexer:x,registerLangHandler:C,sourceDecorator:k,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:y,PR_COMMENT:p,PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:m,PR_NOCODE:"nocode",PR_PLAIN:_,PR_PUNCTUATION:g,PR_SOURCE:"src",PR_STRING:d,PR_TAG:"tag",PR_TYPE:f,prettyPrintOne:D,prettyPrint:M},I=e.define;"function"==typeof I&&I.amd&&I("google-code-prettify",[],(function(){return R}))}()},25769:function(e,t,n){"use strict";var i=n(98040),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var n,s,a,o,l,c,u=!1;t||(t={}),n=t.debug||!1;try{if(a=i(),o=document.createRange(),l=document.getSelection(),(c=document.createElement("span")).textContent=e,c.ariaHidden="true",c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",(function(i){if(i.stopPropagation(),t.format)if(i.preventDefault(),void 0===i.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var s=r[t.format]||r.default;window.clipboardData.setData(s,e)}else i.clipboardData.clearData(),i.clipboardData.setData(t.format,e);t.onCopy&&(i.preventDefault(),t.onCopy(i.clipboardData))})),document.body.appendChild(c),o.selectNodeContents(c),l.addRange(o),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");u=!0}catch(i){n&&console.error("unable to copy using execCommand: ",i),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(i){n&&console.error("unable to copy using clipboardData: ",i),n&&console.error("falling back to prompt"),s=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(s,e)}}finally{l&&("function"==typeof l.removeRange?l.removeRange(o):l.removeAllRanges()),c&&document.body.removeChild(c),a()}return u}},53184:function(e,t,n){"use strict";var i,r;i=[n(58553),n(87804),n(40998)],void 0===(r=function(e,t,n){return function(e,t,n){var i=function(t,n){return e.js_beautify(t,n)};return i.js=e.js_beautify,i.css=t.css_beautify,i.html=n.html_beautify,i.js_beautify=e.js_beautify,i.css_beautify=t.css_beautify,i.html_beautify=n.html_beautify,i}(e,t,n)}.apply(t,i))||(e.exports=r)},87804:function(e,t){var n;!function(){var i;!function(){"use strict";var e=[,,function(e){function t(e){this.__parent=e,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function n(e,t){this.__cache=[""],this.__indent_size=e.indent_size,this.__indent_string=e.indent_char,e.indent_with_tabs||(this.__indent_string=new Array(e.indent_size+1).join(e.indent_char)),t=t||"",e.indent_level>0&&(t=new Array(e.indent_level+1).join(this.__indent_string)),this.__base_string=t,this.__base_string_length=t.length}function i(e,i){this.__indent_cache=new n(e,i),this.raw=!1,this._end_with_newline=e.end_with_newline,this.indent_size=e.indent_size,this.wrap_line_length=e.wrap_line_length,this.indent_empty_lines=e.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new t(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}t.prototype.clone_empty=function(){var e=new t(this.__parent);return e.set_indent(this.__indent_count,this.__alignment_count),e},t.prototype.item=function(e){return e<0?this.__items[this.__items.length+e]:this.__items[e]},t.prototype.has_match=function(e){for(var t=this.__items.length-1;t>=0;t--)if(this.__items[t].match(e))return!0;return!1},t.prototype.set_indent=function(e,t){this.is_empty()&&(this.__indent_count=e||0,this.__alignment_count=t||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var e=this.__parent.current_line;return e.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),e.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),e.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===e.__items[0]&&(e.__items.splice(0,1),e.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return 0===this.__items.length},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(e){this.__items.push(e);var t=e.lastIndexOf("\n");-1!==t?this.__character_count=e.length-t:this.__character_count+=e.length},t.prototype.pop=function(){var e=null;return this.is_empty()||(e=this.__items.pop(),this.__character_count-=e.length),e},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;" "===this.last();)this.__items.pop(),this.__character_count-=1},t.prototype.toString=function(){var e="";return this.is_empty()?this.__parent.indent_empty_lines&&(e=this.__parent.get_indent_string(this.__indent_count)):(e=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),e+=this.__items.join("")),e},n.prototype.get_indent_size=function(e,t){var n=this.__base_string_length;return t=t||0,e<0&&(n=0),n+=e*this.__indent_size,n+=t},n.prototype.get_indent_string=function(e,t){var n=this.__base_string;return t=t||0,e<0&&(e=0,n=""),t+=e*this.__indent_size,this.__ensure_cache(t),n+=this.__cache[t]},n.prototype.__ensure_cache=function(e){for(;e>=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var e=this.__cache.length,t=0,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},i.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},i.prototype.get_line_number=function(){return this.__lines.length},i.prototype.get_indent_string=function(e,t){return this.__indent_cache.get_indent_string(e,t)},i.prototype.get_indent_size=function(e,t){return this.__indent_cache.get_indent_size(e,t)},i.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},i.prototype.add_new_line=function(e){return!(this.is_empty()||!e&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},i.prototype.get_code=function(e){this.trim(!0);var t=this.current_line.pop();t&&("\n"===t[t.length-1]&&(t=t.replace(/\n+$/g,"")),this.current_line.push(t)),this._end_with_newline&&this.__add_outputline();var n=this.__lines.join("\n");return"\n"!==e&&(n=n.replace(/[\n]/g,e)),n},i.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},i.prototype.set_indent=function(e,t){return e=e||0,t=t||0,this.next_line.set_indent(e,t),this.__lines.length>1?(this.current_line.set_indent(e,t),!0):(this.current_line.set_indent(),!1)},i.prototype.add_raw_token=function(e){for(var t=0;t<e.newlines;t++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(e.whitespace_before),this.current_line.push(e.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},i.prototype.add_token=function(e){this.__add_space_before_token(),this.current_line.push(e),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},i.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},i.prototype.remove_indent=function(e){for(var t=this.__lines.length;e<t;)this.__lines[e]._remove_indent(),e++;this.current_line._remove_wrap_indent()},i.prototype.trim=function(e){for(e=void 0!==e&&e,this.current_line.trim();e&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},i.prototype.just_added_newline=function(){return this.current_line.is_empty()},i.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},i.prototype.ensure_empty_line_above=function(e,n){for(var i=this.__lines.length-2;i>=0;){var r=this.__lines[i];if(r.is_empty())break;if(0!==r.item(0).indexOf(e)&&r.item(-1)!==n){this.__lines.splice(i+1,0,new t(this)),this.previous_line=this.__lines[this.__lines.length-2];break}i--}},e.exports.Output=i},,,,function(e){function t(e,t){this.raw_options=n(e,t),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs","\t"===this.indent_char),this.indent_with_tabs&&(this.indent_char="\t",1===this.indent_size&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","angular","django","erb","handlebars","php","smarty"],["auto"])}function n(e,t){var n,r={};for(n in e=i(e))n!==t&&(r[n]=e[n]);if(t&&e[t])for(n in e[t])r[n]=e[t][n];return r}function i(e){var t,n={};for(t in e){n[t.replace(/-/g,"_")]=e[t]}return n}t.prototype._get_array=function(e,t){var n=this.raw_options[e],i=t||[];return"object"==typeof n?null!==n&&"function"==typeof n.concat&&(i=n.concat()):"string"==typeof n&&(i=n.split(/[^a-zA-Z0-9_\/\-]+/)),i},t.prototype._get_boolean=function(e,t){var n=this.raw_options[e];return void 0===n?!!t:!!n},t.prototype._get_characters=function(e,t){var n=this.raw_options[e],i=t||"";return"string"==typeof n&&(i=n.replace(/\\r/,"\r").replace(/\\n/,"\n").replace(/\\t/,"\t")),i},t.prototype._get_number=function(e,t){var n=this.raw_options[e];t=parseInt(t,10),isNaN(t)&&(t=0);var i=parseInt(n,10);return isNaN(i)&&(i=t),i},t.prototype._get_selection=function(e,t,n){var i=this._get_selection_list(e,t,n);if(1!==i.length)throw new Error("Invalid Option Value: The option '"+e+"' can only be one of the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i[0]},t.prototype._get_selection_list=function(e,t,n){if(!t||0===t.length)throw new Error("Selection list cannot be empty.");if(n=n||[t[0]],!this._is_valid_selection(n,t))throw new Error("Invalid Default Value!");var i=this._get_array(e,n);if(!this._is_valid_selection(i,t))throw new Error("Invalid Option Value: The option '"+e+"' can contain only the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i},t.prototype._is_valid_selection=function(e,t){return e.length&&t.length&&!e.some((function(e){return-1===t.indexOf(e)}))},e.exports.Options=t,e.exports.normalizeOpts=i,e.exports.mergeOpts=n},,function(e){var t=RegExp.prototype.hasOwnProperty("sticky");function n(e){this.__input=e||"",this.__input_length=this.__input.length,this.__position=0}n.prototype.restart=function(){this.__position=0},n.prototype.back=function(){this.__position>0&&(this.__position-=1)},n.prototype.hasNext=function(){return this.__position<this.__input_length},n.prototype.next=function(){var e=null;return this.hasNext()&&(e=this.__input.charAt(this.__position),this.__position+=1),e},n.prototype.peek=function(e){var t=null;return e=e||0,(e+=this.__position)>=0&&e<this.__input_length&&(t=this.__input.charAt(e)),t},n.prototype.__match=function(e,n){e.lastIndex=n;var i=e.exec(this.__input);return!i||t&&e.sticky||i.index!==n&&(i=null),i},n.prototype.test=function(e,t){return t=t||0,(t+=this.__position)>=0&&t<this.__input_length&&!!this.__match(e,t)},n.prototype.testChar=function(e,t){var n=this.peek(t);return e.lastIndex=0,null!==n&&e.test(n)},n.prototype.match=function(e){var t=this.__match(e,this.__position);return t?this.__position+=t[0].length:t=null,t},n.prototype.read=function(e,t,n){var i,r="";return e&&(i=this.match(e))&&(r+=i[0]),!t||!i&&e||(r+=this.readUntil(t,n)),r},n.prototype.readUntil=function(e,t){var n,i=this.__position;e.lastIndex=this.__position;var r=e.exec(this.__input);return r?(i=r.index,t&&(i+=r[0].length)):i=this.__input_length,n=this.__input.substring(this.__position,i),this.__position=i,n},n.prototype.readUntilAfter=function(e){return this.readUntil(e,!0)},n.prototype.get_regexp=function(e,n){var i=null,r="g";return n&&t&&(r="y"),"string"==typeof e&&""!==e?i=new RegExp(e,r):e&&(i=new RegExp(e.source,r)),i},n.prototype.get_literal_regexp=function(e){return RegExp(e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},n.prototype.peekUntilAfter=function(e){var t=this.__position,n=this.readUntilAfter(e);return this.__position=t,n},n.prototype.lookBack=function(e){var t=this.__position-1;return t>=e.length&&this.__input.substring(t-e.length,t).toLowerCase()===e},e.exports.InputScanner=n},,,,,function(e){function t(e,t){e="string"==typeof e?e:e.source,t="string"==typeof t?t:t.source,this.__directives_block_pattern=new RegExp(e+/ beautify( \w+[:]\w+)+ /.source+t,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(e+/\sbeautify\signore:end\s/.source+t,"g")}t.prototype.get_directives=function(e){if(!e.match(this.__directives_block_pattern))return null;var t={};this.__directive_pattern.lastIndex=0;for(var n=this.__directive_pattern.exec(e);n;)t[n[1]]=n[2],n=this.__directive_pattern.exec(e);return t},t.prototype.readIgnored=function(e){return e.readUntilAfter(this.__directives_end_ignore_pattern)},e.exports.Directives=t},,function(e,t,n){var i=n(16).Beautifier,r=n(17).Options;e.exports=function(e,t){return new i(e,t).beautify()},e.exports.defaultOptions=function(){return new r}},function(e,t,n){var i=n(17).Options,r=n(2).Output,s=n(8).InputScanner,a=new(0,n(13).Directives)(/\/\*/,/\*\//),o=/\r\n|[\r\n]/,l=/\r\n|[\r\n]/g,c=/\s/,u=/(?:\s|\n)+/g,h=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,d=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function p(e,t){this._source_text=e||"",this._options=new i(t),this._ch=null,this._input=null,this.NESTED_AT_RULE={page:!0,"font-face":!0,keyframes:!0,media:!0,supports:!0,document:!0},this.CONDITIONAL_GROUP_RULE={media:!0,supports:!0,document:!0},this.NON_SEMICOLON_NEWLINE_PROPERTY=["grid-template-areas","grid-template"]}p.prototype.eatString=function(e){var t="";for(this._ch=this._input.next();this._ch;){if(t+=this._ch,"\\"===this._ch)t+=this._input.next();else if(-1!==e.indexOf(this._ch)||"\n"===this._ch)break;this._ch=this._input.next()}return t},p.prototype.eatWhitespace=function(e){for(var t=c.test(this._input.peek()),n=0;c.test(this._input.peek());)this._ch=this._input.next(),e&&"\n"===this._ch&&(0===n||n<this._options.max_preserve_newlines)&&(n++,this._output.add_new_line(!0));return t},p.prototype.foundNestedPseudoClass=function(){for(var e=0,t=1,n=this._input.peek(t);n;){if("{"===n)return!0;if("("===n)e+=1;else if(")"===n){if(0===e)return!1;e-=1}else if(";"===n||"}"===n)return!1;t++,n=this._input.peek(t)}return!1},p.prototype.print_string=function(e){this._output.set_indent(this._indentLevel),this._output.non_breaking_space=!0,this._output.add_token(e)},p.prototype.preserveSingleSpace=function(e){e&&(this._output.space_before_token=!0)},p.prototype.indent=function(){this._indentLevel++},p.prototype.outdent=function(){this._indentLevel>0&&this._indentLevel--},p.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var e=this._source_text,t=this._options.eol;"auto"===t&&(t="\n",e&&o.test(e||"")&&(t=e.match(o)[0]));var n=(e=e.replace(l,"\n")).match(/^[\t ]*/)[0];this._output=new r(this._options,n),this._input=new s(e),this._indentLevel=0,this._nestedLevel=0,this._ch=null;for(var i,p,f=0,m=!1,g=!1,_=!1,y=!1,v=!1,b=this._ch,w=!1;i=""!==this._input.read(u),p=b,this._ch=this._input.next(),"\\"===this._ch&&this._input.hasNext()&&(this._ch+=this._input.next()),b=this._ch,this._ch;)if("/"===this._ch&&"*"===this._input.peek()){this._output.add_new_line(),this._input.back();var x=this._input.read(h),k=a.get_directives(x);k&&"start"===k.ignore&&(x+=a.readIgnored(this._input)),this.print_string(x),this.eatWhitespace(!0),this._output.add_new_line()}else if("/"===this._ch&&"/"===this._input.peek())this._output.space_before_token=!0,this._input.back(),this.print_string(this._input.read(d)),this.eatWhitespace(!0);else if("$"===this._ch){this.preserveSingleSpace(i),this.print_string(this._ch);var S=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);S.match(/[ :]$/)&&(S=this.eatString(": ").replace(/\s+$/,""),this.print_string(S),this._output.space_before_token=!0),0===f&&-1!==S.indexOf(":")&&(g=!0,this.indent())}else if("@"===this._ch)if(this.preserveSingleSpace(i),"{"===this._input.peek())this.print_string(this._ch+this.eatString("}"));else{this.print_string(this._ch);var E=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);E.match(/[ :]$/)&&(E=this.eatString(": ").replace(/\s+$/,""),this.print_string(E),this._output.space_before_token=!0),0===f&&-1!==E.indexOf(":")?(g=!0,this.indent()):E in this.NESTED_AT_RULE?(this._nestedLevel+=1,E in this.CONDITIONAL_GROUP_RULE&&(_=!0)):0!==f||g||(y=!0)}else if("#"===this._ch&&"{"===this._input.peek())this.preserveSingleSpace(i),this.print_string(this._ch+this.eatString("}"));else if("{"===this._ch)g&&(g=!1,this.outdent()),y=!1,_?(_=!1,m=this._indentLevel>=this._nestedLevel):m=this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&m&&this._output.previous_line&&"{"!==this._output.previous_line.item(-1)&&this._output.ensure_empty_line_above("/",","),this._output.space_before_token=!0,"expand"===this._options.brace_style?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):("("===p?this._output.space_before_token=!1:","!==p&&this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line();else if("}"===this._ch)this.outdent(),this._output.add_new_line(),"{"===p&&this._output.trim(!0),g&&(this.outdent(),g=!1),this.print_string(this._ch),m=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&"}"!==this._input.peek()&&this._output.add_new_line(!0),")"===this._input.peek()&&(this._output.trim(!0),"expand"===this._options.brace_style&&this._output.add_new_line(!0));else if(":"===this._ch){for(var T=0;T<this.NON_SEMICOLON_NEWLINE_PROPERTY.length;T++)if(this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[T])){w=!0;break}!m&&!_||this._input.lookBack("&")||this.foundNestedPseudoClass()||this._input.lookBack("(")||y||0!==f?(this._input.lookBack(" ")&&(this._output.space_before_token=!0),":"===this._input.peek()?(this._ch=this._input.next(),this.print_string("::")):this.print_string(":")):(this.print_string(":"),g||(g=!0,this._output.space_before_token=!0,this.eatWhitespace(!0),this.indent()))}else if('"'===this._ch||"'"===this._ch){var C='"'===p||"'"===p;this.preserveSingleSpace(C||i),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)}else if(";"===this._ch)w=!1,0===f?(g&&(this.outdent(),g=!1),y=!1,this.print_string(this._ch),this.eatWhitespace(!0),"/"!==this._input.peek()&&this._output.add_new_line()):(this.print_string(this._ch),this.eatWhitespace(!0),this._output.space_before_token=!0);else if("("===this._ch)if(this._input.lookBack("url"))this.print_string(this._ch),this.eatWhitespace(),f++,this.indent(),this._ch=this._input.next(),")"===this._ch||'"'===this._ch||"'"===this._ch?this._input.back():this._ch&&(this.print_string(this._ch+this.eatString(")")),f&&(f--,this.outdent()));else{var L=!1;this._input.lookBack("with")&&(L=!0),this.preserveSingleSpace(i||L),this.print_string(this._ch),g&&"$"===p&&this._options.selector_separator_newline?(this._output.add_new_line(),v=!0):(this.eatWhitespace(),f++,this.indent())}else if(")"===this._ch)f&&(f--,this.outdent()),v&&";"===this._input.peek()&&this._options.selector_separator_newline&&(v=!1,this.outdent(),this._output.add_new_line()),this.print_string(this._ch);else if(","===this._ch)this.print_string(this._ch),this.eatWhitespace(!0),!this._options.selector_separator_newline||g&&!v||0!==f||y?this._output.space_before_token=!0:this._output.add_new_line();else if(">"!==this._ch&&"+"!==this._ch&&"~"!==this._ch||g||0!==f)if("]"===this._ch)this.print_string(this._ch);else if("["===this._ch)this.preserveSingleSpace(i),this.print_string(this._ch);else if("="===this._ch)this.eatWhitespace(),this.print_string("="),c.test(this._ch)&&(this._ch="");else if("!"!==this._ch||this._input.lookBack("\\")){var A='"'===p||"'"===p;this.preserveSingleSpace(A||i),this.print_string(this._ch),!this._output.just_added_newline()&&"\n"===this._input.peek()&&w&&this._output.add_new_line()}else this._output.space_before_token=!0,this.print_string(this._ch);else this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&c.test(this._ch)&&(this._ch=""));return this._output.get_code(t)},e.exports.Beautifier=p},function(e,t,n){var i=n(6).Options;function r(e){i.call(this,e,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0);var t=this._get_boolean("space_around_selector_separator");this.space_around_combinator=this._get_boolean("space_around_combinator")||t;var n=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_style="collapse";for(var r=0;r<n.length;r++)"expand"!==n[r]?this.brace_style="collapse":this.brace_style=n[r]}r.prototype=new i,e.exports.Options=r}],t={};var n=function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}(15);i=n}();var r=i;void 0===(n=function(){return{css_beautify:r}}.apply(t,[]))||(e.exports=n)}()},40998:function(e,t,n){var i,r;!function(){var s;!function(){"use strict";var e=[,,function(e){function t(e){this.__parent=e,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function n(e,t){this.__cache=[""],this.__indent_size=e.indent_size,this.__indent_string=e.indent_char,e.indent_with_tabs||(this.__indent_string=new Array(e.indent_size+1).join(e.indent_char)),t=t||"",e.indent_level>0&&(t=new Array(e.indent_level+1).join(this.__indent_string)),this.__base_string=t,this.__base_string_length=t.length}function i(e,i){this.__indent_cache=new n(e,i),this.raw=!1,this._end_with_newline=e.end_with_newline,this.indent_size=e.indent_size,this.wrap_line_length=e.wrap_line_length,this.indent_empty_lines=e.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new t(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}t.prototype.clone_empty=function(){var e=new t(this.__parent);return e.set_indent(this.__indent_count,this.__alignment_count),e},t.prototype.item=function(e){return e<0?this.__items[this.__items.length+e]:this.__items[e]},t.prototype.has_match=function(e){for(var t=this.__items.length-1;t>=0;t--)if(this.__items[t].match(e))return!0;return!1},t.prototype.set_indent=function(e,t){this.is_empty()&&(this.__indent_count=e||0,this.__alignment_count=t||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var e=this.__parent.current_line;return e.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),e.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),e.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===e.__items[0]&&(e.__items.splice(0,1),e.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return 0===this.__items.length},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(e){this.__items.push(e);var t=e.lastIndexOf("\n");-1!==t?this.__character_count=e.length-t:this.__character_count+=e.length},t.prototype.pop=function(){var e=null;return this.is_empty()||(e=this.__items.pop(),this.__character_count-=e.length),e},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;" "===this.last();)this.__items.pop(),this.__character_count-=1},t.prototype.toString=function(){var e="";return this.is_empty()?this.__parent.indent_empty_lines&&(e=this.__parent.get_indent_string(this.__indent_count)):(e=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),e+=this.__items.join("")),e},n.prototype.get_indent_size=function(e,t){var n=this.__base_string_length;return t=t||0,e<0&&(n=0),n+=e*this.__indent_size,n+=t},n.prototype.get_indent_string=function(e,t){var n=this.__base_string;return t=t||0,e<0&&(e=0,n=""),t+=e*this.__indent_size,this.__ensure_cache(t),n+=this.__cache[t]},n.prototype.__ensure_cache=function(e){for(;e>=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var e=this.__cache.length,t=0,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},i.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},i.prototype.get_line_number=function(){return this.__lines.length},i.prototype.get_indent_string=function(e,t){return this.__indent_cache.get_indent_string(e,t)},i.prototype.get_indent_size=function(e,t){return this.__indent_cache.get_indent_size(e,t)},i.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},i.prototype.add_new_line=function(e){return!(this.is_empty()||!e&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},i.prototype.get_code=function(e){this.trim(!0);var t=this.current_line.pop();t&&("\n"===t[t.length-1]&&(t=t.replace(/\n+$/g,"")),this.current_line.push(t)),this._end_with_newline&&this.__add_outputline();var n=this.__lines.join("\n");return"\n"!==e&&(n=n.replace(/[\n]/g,e)),n},i.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},i.prototype.set_indent=function(e,t){return e=e||0,t=t||0,this.next_line.set_indent(e,t),this.__lines.length>1?(this.current_line.set_indent(e,t),!0):(this.current_line.set_indent(),!1)},i.prototype.add_raw_token=function(e){for(var t=0;t<e.newlines;t++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(e.whitespace_before),this.current_line.push(e.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},i.prototype.add_token=function(e){this.__add_space_before_token(),this.current_line.push(e),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},i.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},i.prototype.remove_indent=function(e){for(var t=this.__lines.length;e<t;)this.__lines[e]._remove_indent(),e++;this.current_line._remove_wrap_indent()},i.prototype.trim=function(e){for(e=void 0!==e&&e,this.current_line.trim();e&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},i.prototype.just_added_newline=function(){return this.current_line.is_empty()},i.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},i.prototype.ensure_empty_line_above=function(e,n){for(var i=this.__lines.length-2;i>=0;){var r=this.__lines[i];if(r.is_empty())break;if(0!==r.item(0).indexOf(e)&&r.item(-1)!==n){this.__lines.splice(i+1,0,new t(this)),this.previous_line=this.__lines[this.__lines.length-2];break}i--}},e.exports.Output=i},function(e){e.exports.Token=function(e,t,n,i){this.type=e,this.text=t,this.comments_before=null,this.newlines=n||0,this.whitespace_before=i||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}},,,function(e){function t(e,t){this.raw_options=n(e,t),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs","\t"===this.indent_char),this.indent_with_tabs&&(this.indent_char="\t",1===this.indent_size&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","angular","django","erb","handlebars","php","smarty"],["auto"])}function n(e,t){var n,r={};for(n in e=i(e))n!==t&&(r[n]=e[n]);if(t&&e[t])for(n in e[t])r[n]=e[t][n];return r}function i(e){var t,n={};for(t in e){n[t.replace(/-/g,"_")]=e[t]}return n}t.prototype._get_array=function(e,t){var n=this.raw_options[e],i=t||[];return"object"==typeof n?null!==n&&"function"==typeof n.concat&&(i=n.concat()):"string"==typeof n&&(i=n.split(/[^a-zA-Z0-9_\/\-]+/)),i},t.prototype._get_boolean=function(e,t){var n=this.raw_options[e];return void 0===n?!!t:!!n},t.prototype._get_characters=function(e,t){var n=this.raw_options[e],i=t||"";return"string"==typeof n&&(i=n.replace(/\\r/,"\r").replace(/\\n/,"\n").replace(/\\t/,"\t")),i},t.prototype._get_number=function(e,t){var n=this.raw_options[e];t=parseInt(t,10),isNaN(t)&&(t=0);var i=parseInt(n,10);return isNaN(i)&&(i=t),i},t.prototype._get_selection=function(e,t,n){var i=this._get_selection_list(e,t,n);if(1!==i.length)throw new Error("Invalid Option Value: The option '"+e+"' can only be one of the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i[0]},t.prototype._get_selection_list=function(e,t,n){if(!t||0===t.length)throw new Error("Selection list cannot be empty.");if(n=n||[t[0]],!this._is_valid_selection(n,t))throw new Error("Invalid Default Value!");var i=this._get_array(e,n);if(!this._is_valid_selection(i,t))throw new Error("Invalid Option Value: The option '"+e+"' can contain only the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i},t.prototype._is_valid_selection=function(e,t){return e.length&&t.length&&!e.some((function(e){return-1===t.indexOf(e)}))},e.exports.Options=t,e.exports.normalizeOpts=i,e.exports.mergeOpts=n},,function(e){var t=RegExp.prototype.hasOwnProperty("sticky");function n(e){this.__input=e||"",this.__input_length=this.__input.length,this.__position=0}n.prototype.restart=function(){this.__position=0},n.prototype.back=function(){this.__position>0&&(this.__position-=1)},n.prototype.hasNext=function(){return this.__position<this.__input_length},n.prototype.next=function(){var e=null;return this.hasNext()&&(e=this.__input.charAt(this.__position),this.__position+=1),e},n.prototype.peek=function(e){var t=null;return e=e||0,(e+=this.__position)>=0&&e<this.__input_length&&(t=this.__input.charAt(e)),t},n.prototype.__match=function(e,n){e.lastIndex=n;var i=e.exec(this.__input);return!i||t&&e.sticky||i.index!==n&&(i=null),i},n.prototype.test=function(e,t){return t=t||0,(t+=this.__position)>=0&&t<this.__input_length&&!!this.__match(e,t)},n.prototype.testChar=function(e,t){var n=this.peek(t);return e.lastIndex=0,null!==n&&e.test(n)},n.prototype.match=function(e){var t=this.__match(e,this.__position);return t?this.__position+=t[0].length:t=null,t},n.prototype.read=function(e,t,n){var i,r="";return e&&(i=this.match(e))&&(r+=i[0]),!t||!i&&e||(r+=this.readUntil(t,n)),r},n.prototype.readUntil=function(e,t){var n,i=this.__position;e.lastIndex=this.__position;var r=e.exec(this.__input);return r?(i=r.index,t&&(i+=r[0].length)):i=this.__input_length,n=this.__input.substring(this.__position,i),this.__position=i,n},n.prototype.readUntilAfter=function(e){return this.readUntil(e,!0)},n.prototype.get_regexp=function(e,n){var i=null,r="g";return n&&t&&(r="y"),"string"==typeof e&&""!==e?i=new RegExp(e,r):e&&(i=new RegExp(e.source,r)),i},n.prototype.get_literal_regexp=function(e){return RegExp(e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},n.prototype.peekUntilAfter=function(e){var t=this.__position,n=this.readUntilAfter(e);return this.__position=t,n},n.prototype.lookBack=function(e){var t=this.__position-1;return t>=e.length&&this.__input.substring(t-e.length,t).toLowerCase()===e},e.exports.InputScanner=n},function(e,t,n){var i=n(8).InputScanner,r=n(3).Token,s=n(10).TokenStream,a=n(11).WhitespacePattern,o={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},l=function(e,t){this._input=new i(e),this._options=t||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new a(this._input)};l.prototype.tokenize=function(){var e;this._input.restart(),this.__tokens=new s,this._reset();for(var t=new r(o.START,""),n=null,i=[],a=new s;t.type!==o.EOF;){for(e=this._get_next_token(t,n);this._is_comment(e);)a.add(e),e=this._get_next_token(t,n);a.isEmpty()||(e.comments_before=a,a=new s),e.parent=n,this._is_opening(e)?(i.push(n),n=e):n&&this._is_closing(e,n)&&(e.opened=n,n.closed=e,n=i.pop(),e.parent=n),e.previous=t,t.next=e,this.__tokens.add(e),t=e}return this.__tokens},l.prototype._is_first_token=function(){return this.__tokens.isEmpty()},l.prototype._reset=function(){},l.prototype._get_next_token=function(e,t){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(o.RAW,n):this._create_token(o.EOF,"")},l.prototype._is_comment=function(e){return!1},l.prototype._is_opening=function(e){return!1},l.prototype._is_closing=function(e,t){return!1},l.prototype._create_token=function(e,t){return new r(e,t,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},l.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},e.exports.Tokenizer=l,e.exports.TOKEN=o},function(e){function t(e){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=e}t.prototype.restart=function(){this.__position=0},t.prototype.isEmpty=function(){return 0===this.__tokens_length},t.prototype.hasNext=function(){return this.__position<this.__tokens_length},t.prototype.next=function(){var e=null;return this.hasNext()&&(e=this.__tokens[this.__position],this.__position+=1),e},t.prototype.peek=function(e){var t=null;return e=e||0,(e+=this.__position)>=0&&e<this.__tokens_length&&(t=this.__tokens[e]),t},t.prototype.add=function(e){this.__parent_token&&(e.parent=this.__parent_token),this.__tokens.push(e),this.__tokens_length+=1},e.exports.TokenStream=t},function(e,t,n){var i=n(12).Pattern;function r(e,t){i.call(this,e,t),t?this._line_regexp=this._input.get_regexp(t._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}r.prototype=new i,r.prototype.__set_whitespace_patterns=function(e,t){e+="\\t ",t+="\\n\\r",this._match_pattern=this._input.get_regexp("["+e+t+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+t+"]")},r.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var e=this._input.read(this._match_pattern);if(" "===e)this.whitespace_before_token=" ";else if(e){var t=this.__split(this._newline_regexp,e);this.newline_count=t.length-1,this.whitespace_before_token=t[this.newline_count]}return e},r.prototype.matching=function(e,t){var n=this._create();return n.__set_whitespace_patterns(e,t),n._update(),n},r.prototype._create=function(){return new r(this._input,this)},r.prototype.__split=function(e,t){e.lastIndex=0;for(var n=0,i=[],r=e.exec(t);r;)i.push(t.substring(n,r.index)),n=r.index+r[0].length,r=e.exec(t);return n<t.length?i.push(t.substring(n,t.length)):i.push(""),i},e.exports.WhitespacePattern=r},function(e){function t(e,t){this._input=e,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,t&&(this._starting_pattern=this._input.get_regexp(t._starting_pattern,!0),this._match_pattern=this._input.get_regexp(t._match_pattern,!0),this._until_pattern=this._input.get_regexp(t._until_pattern),this._until_after=t._until_after)}t.prototype.read=function(){var e=this._input.read(this._starting_pattern);return this._starting_pattern&&!e||(e+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),e},t.prototype.read_match=function(){return this._input.match(this._match_pattern)},t.prototype.until_after=function(e){var t=this._create();return t._until_after=!0,t._until_pattern=this._input.get_regexp(e),t._update(),t},t.prototype.until=function(e){var t=this._create();return t._until_after=!1,t._until_pattern=this._input.get_regexp(e),t._update(),t},t.prototype.starting_with=function(e){var t=this._create();return t._starting_pattern=this._input.get_regexp(e,!0),t._update(),t},t.prototype.matching=function(e){var t=this._create();return t._match_pattern=this._input.get_regexp(e,!0),t._update(),t},t.prototype._create=function(){return new t(this._input,this)},t.prototype._update=function(){},e.exports.Pattern=t},function(e){function t(e,t){e="string"==typeof e?e:e.source,t="string"==typeof t?t:t.source,this.__directives_block_pattern=new RegExp(e+/ beautify( \w+[:]\w+)+ /.source+t,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(e+/\sbeautify\signore:end\s/.source+t,"g")}t.prototype.get_directives=function(e){if(!e.match(this.__directives_block_pattern))return null;var t={};this.__directive_pattern.lastIndex=0;for(var n=this.__directive_pattern.exec(e);n;)t[n[1]]=n[2],n=this.__directive_pattern.exec(e);return t},t.prototype.readIgnored=function(e){return e.readUntilAfter(this.__directives_end_ignore_pattern)},e.exports.Directives=t},function(e,t,n){var i=n(12).Pattern,r={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1,angular:!1};function s(e,t){i.call(this,e,t),this.__template_pattern=null,this._disabled=Object.assign({},r),this._excluded=Object.assign({},r),t&&(this.__template_pattern=this._input.get_regexp(t.__template_pattern),this._excluded=Object.assign(this._excluded,t._excluded),this._disabled=Object.assign(this._disabled,t._disabled));var n=new i(e);this.__patterns={handlebars_comment:n.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:n.starting_with(/{{{/).until_after(/}}}/),handlebars:n.starting_with(/{{/).until_after(/}}/),php:n.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:n.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:n.starting_with(/{%/).until_after(/%}/),django_value:n.starting_with(/{{/).until_after(/}}/),django_comment:n.starting_with(/{#/).until_after(/#}/),smarty:n.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:n.starting_with(/{\*/).until_after(/\*}/),smarty_literal:n.starting_with(/{literal}/).until_after(/{\/literal}/)}}s.prototype=new i,s.prototype._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(e){var t=this._create();return t._disabled[e]=!0,t._update(),t},s.prototype.read_options=function(e){var t=this._create();for(var n in r)t._disabled[n]=-1===e.templating.indexOf(n);return t._update(),t},s.prototype.exclude=function(e){var t=this._create();return t._excluded[e]=!0,t._update(),t},s.prototype.read=function(){var e="";e=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern);for(var t=this._read_template();t;)this._match_pattern?t+=this._input.read(this._match_pattern):t+=this._input.readUntil(this.__template_pattern),e+=t,t=this._read_template();return this._until_after&&(e+=this._input.readUntilAfter(this._until_pattern)),e},s.prototype.__set_templated_pattern=function(){var e=[];this._disabled.php||e.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||e.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.angular||e.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||e.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(e.push(this.__patterns.django._starting_pattern.source),e.push(this.__patterns.django_value._starting_pattern.source),e.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||e.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&e.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+e.join("|")+")")},s.prototype._read_template=function(){var e="",t=this._input.peek();if("<"===t){var n=this._input.peek(1);this._disabled.php||this._excluded.php||"?"!==n||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==n||(e=e||this.__patterns.erb.read())}else"{"===t&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()),this._excluded.django||(e=(e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=(e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read()));return e},e.exports.TemplatablePattern=s},,,,function(e,t,n){var i=n(19).Beautifier,r=n(20).Options;e.exports=function(e,t,n,r){return new i(e,t,n,r).beautify()},e.exports.defaultOptions=function(){return new r}},function(e,t,n){var i=n(20).Options,r=n(2).Output,s=n(21).Tokenizer,a=n(21).TOKEN,o=/\r\n|[\r\n]/,l=/\r\n|[\r\n]/g,c=function(e,t){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=e.max_preserve_newlines,this.preserve_newlines=e.preserve_newlines,this._output=new r(e,t)};c.prototype.current_line_has_match=function(e){return this._output.current_line.has_match(e)},c.prototype.set_space_before_token=function(e,t){this._output.space_before_token=e,this._output.non_breaking_space=t},c.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},c.prototype.add_raw_token=function(e){this._output.add_raw_token(e)},c.prototype.print_preserved_newlines=function(e){var t=0;e.type!==a.TEXT&&e.previous.type!==a.TEXT&&(t=e.newlines?1:0),this.preserve_newlines&&(t=e.newlines<this.max_preserve_newlines+1?e.newlines:this.max_preserve_newlines+1);for(var n=0;n<t;n++)this.print_newline(n>0);return 0!==t},c.prototype.traverse_whitespace=function(e){return!(!e.whitespace_before&&!e.newlines)&&(this.print_preserved_newlines(e)||(this._output.space_before_token=!0),!0)},c.prototype.previous_token_wrapped=function(){return this._output.previous_token_wrapped},c.prototype.print_newline=function(e){this._output.add_new_line(e)},c.prototype.print_token=function(e){e.text&&(this._output.set_indent(this.indent_level,this.alignment_size),this._output.add_token(e.text))},c.prototype.indent=function(){this.indent_level++},c.prototype.deindent=function(){this.indent_level>0&&(this.indent_level--,this._output.set_indent(this.indent_level,this.alignment_size))},c.prototype.get_full_indent=function(e){return(e=this.indent_level+(e||0))<1?"":this._output.get_indent_string(e)};var u=function(e,t){var n=null,i=null;return t.closed?("script"===e?n="text/javascript":"style"===e&&(n="text/css"),n=function(e){for(var t=null,n=e.next;n.type!==a.EOF&&e.closed!==n;){if(n.type===a.ATTRIBUTE&&"type"===n.text){n.next&&n.next.type===a.EQUALS&&n.next.next&&n.next.next.type===a.VALUE&&(t=n.next.next.text);break}n=n.next}return t}(t)||n,n.search("text/css")>-1?i="css":n.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/)>-1?i="javascript":n.search(/(text|application|dojo)\/(x-)?(html)/)>-1?i="html":n.search(/test\/null/)>-1&&(i="null"),i):null};function h(e,t){return-1!==t.indexOf(e)}function d(e,t,n){this.parent=e||null,this.tag=t?t.tag_name:"",this.indent_level=n||0,this.parser_token=t||null}function p(e){this._printer=e,this._current_frame=null}function f(e,t,n,r){this._source_text=e||"",t=t||{},this._js_beautify=n,this._css_beautify=r,this._tag_stack=null;var s=new i(t,"html");this._options=s,this._is_wrap_attributes_force="force"===this._options.wrap_attributes.substr(0,"force".length),this._is_wrap_attributes_force_expand_multiline="force-expand-multiline"===this._options.wrap_attributes,this._is_wrap_attributes_force_aligned="force-aligned"===this._options.wrap_attributes,this._is_wrap_attributes_aligned_multiple="aligned-multiple"===this._options.wrap_attributes,this._is_wrap_attributes_preserve="preserve"===this._options.wrap_attributes.substr(0,"preserve".length),this._is_wrap_attributes_preserve_aligned="preserve-aligned"===this._options.wrap_attributes}p.prototype.get_parser_token=function(){return this._current_frame?this._current_frame.parser_token:null},p.prototype.record_tag=function(e){var t=new d(this._current_frame,e,this._printer.indent_level);this._current_frame=t},p.prototype._try_pop_frame=function(e){var t=null;return e&&(t=e.parser_token,this._printer.indent_level=e.indent_level,this._current_frame=e.parent),t},p.prototype._get_frame=function(e,t){for(var n=this._current_frame;n&&-1===e.indexOf(n.tag);){if(t&&-1!==t.indexOf(n.tag)){n=null;break}n=n.parent}return n},p.prototype.try_pop=function(e,t){var n=this._get_frame([e],t);return this._try_pop_frame(n)},p.prototype.indent_to_tag=function(e){var t=this._get_frame(e);t&&(this._printer.indent_level=t.indent_level)},f.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var e=this._source_text,t=this._options.eol;"auto"===this._options.eol&&(t="\n",e&&o.test(e)&&(t=e.match(o)[0]));var n=(e=e.replace(l,"\n")).match(/^[\t ]*/)[0],i={text:"",type:""},r=new m(this._options),u=new c(this._options,n),h=new s(e,this._options).tokenize();this._tag_stack=new p(u);for(var d=null,f=h.next();f.type!==a.EOF;)f.type===a.TAG_OPEN||f.type===a.COMMENT?r=d=this._handle_tag_open(u,f,r,i,h):f.type===a.ATTRIBUTE||f.type===a.EQUALS||f.type===a.VALUE||f.type===a.TEXT&&!r.tag_complete?d=this._handle_inside_tag(u,f,r,i):f.type===a.TAG_CLOSE?d=this._handle_tag_close(u,f,r):f.type===a.TEXT?d=this._handle_text(u,f,r):f.type===a.CONTROL_FLOW_OPEN?d=this._handle_control_flow_open(u,f):f.type===a.CONTROL_FLOW_CLOSE?d=this._handle_control_flow_close(u,f):u.add_raw_token(f),i=d,f=h.next();return u._output.get_code(t)},f.prototype._handle_control_flow_open=function(e,t){var n={text:t.text,type:t.type};return e.set_space_before_token(t.newlines||""!==t.whitespace_before,!0),t.newlines?e.print_preserved_newlines(t):e.set_space_before_token(t.newlines||""!==t.whitespace_before,!0),e.print_token(t),e.indent(),n},f.prototype._handle_control_flow_close=function(e,t){var n={text:t.text,type:t.type};return e.deindent(),t.newlines?e.print_preserved_newlines(t):e.set_space_before_token(t.newlines||""!==t.whitespace_before,!0),e.print_token(t),n},f.prototype._handle_tag_close=function(e,t,n){var i={text:t.text,type:t.type};return e.alignment_size=0,n.tag_complete=!0,e.set_space_before_token(t.newlines||""!==t.whitespace_before,!0),n.is_unformatted?e.add_raw_token(t):("<"===n.tag_start_char&&(e.set_space_before_token("/"===t.text[0],!0),this._is_wrap_attributes_force_expand_multiline&&n.has_wrapped_attrs&&e.print_newline(!1)),e.print_token(t)),!n.indent_content||n.is_unformatted||n.is_content_unformatted||(e.indent(),n.indent_content=!1),n.is_inline_element||n.is_unformatted||n.is_content_unformatted||e.set_wrap_point(),i},f.prototype._handle_inside_tag=function(e,t,n,i){var r=n.has_wrapped_attrs,s={text:t.text,type:t.type};return e.set_space_before_token(t.newlines||""!==t.whitespace_before,!0),n.is_unformatted?e.add_raw_token(t):"{"===n.tag_start_char&&t.type===a.TEXT?e.print_preserved_newlines(t)?(t.newlines=0,e.add_raw_token(t)):e.print_token(t):(t.type===a.ATTRIBUTE?e.set_space_before_token(!0):(t.type===a.EQUALS||t.type===a.VALUE&&t.previous.type===a.EQUALS)&&e.set_space_before_token(!1),t.type===a.ATTRIBUTE&&"<"===n.tag_start_char&&((this._is_wrap_attributes_preserve||this._is_wrap_attributes_preserve_aligned)&&(e.traverse_whitespace(t),r=r||0!==t.newlines),this._is_wrap_attributes_force&&n.attr_count>=this._options.wrap_attributes_min_attrs&&(i.type!==a.TAG_OPEN||this._is_wrap_attributes_force_expand_multiline)&&(e.print_newline(!1),r=!0)),e.print_token(t),r=r||e.previous_token_wrapped(),n.has_wrapped_attrs=r),s},f.prototype._handle_text=function(e,t,n){var i={text:t.text,type:"TK_CONTENT"};return n.custom_beautifier_name?this._print_custom_beatifier_text(e,t,n):n.is_unformatted||n.is_content_unformatted?e.add_raw_token(t):(e.traverse_whitespace(t),e.print_token(t)),i},f.prototype._print_custom_beatifier_text=function(e,t,n){var i=this;if(""!==t.text){var r,s=t.text,a=1,o="",l="";"javascript"===n.custom_beautifier_name&&"function"==typeof this._js_beautify?r=this._js_beautify:"css"===n.custom_beautifier_name&&"function"==typeof this._css_beautify?r=this._css_beautify:"html"===n.custom_beautifier_name&&(r=function(e,t){return new f(e,t,i._js_beautify,i._css_beautify).beautify()}),"keep"===this._options.indent_scripts?a=0:"separate"===this._options.indent_scripts&&(a=-e.indent_level);var c=e.get_full_indent(a);if(s=s.replace(/\n[ \t]*$/,""),"html"!==n.custom_beautifier_name&&"<"===s[0]&&s.match(/^(<!--|<!\[CDATA\[)/)){var u=/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(s);if(!u)return void e.add_raw_token(t);o=c+u[1]+"\n",s=u[4],u[5]&&(l=c+u[5]),s=s.replace(/\n[ \t]*$/,""),(u[2]||-1!==u[3].indexOf("\n"))&&(u=u[3].match(/[ \t]+$/))&&(t.whitespace_before=u[0])}if(s)if(r){var h=function(){this.eol="\n"};h.prototype=this._options.raw_options,s=r(c+s,new h)}else{var d=t.whitespace_before;d&&(s=s.replace(new RegExp("\n("+d+")?","g"),"\n")),s=c+s.replace(/\n/g,"\n"+c)}o&&(s=s?o+s+"\n"+l:o+l),e.print_newline(!1),s&&(t.text=s,t.whitespace_before="",t.newlines=0,e.add_raw_token(t),e.print_newline(!0))}},f.prototype._handle_tag_open=function(e,t,n,i,r){var s=this._get_tag_open_token(t);if(!n.is_unformatted&&!n.is_content_unformatted||n.is_empty_element||t.type!==a.TAG_OPEN||s.is_start_tag?(e.traverse_whitespace(t),this._set_tag_position(e,t,s,n,i),s.is_inline_element||e.set_wrap_point(),e.print_token(t)):(e.add_raw_token(t),s.start_tag_token=this._tag_stack.try_pop(s.tag_name)),s.is_start_tag&&this._is_wrap_attributes_force){var o,l=0;do{(o=r.peek(l)).type===a.ATTRIBUTE&&(s.attr_count+=1),l+=1}while(o.type!==a.EOF&&o.type!==a.TAG_CLOSE)}return(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(s.alignment_size=t.text.length+1),s.tag_complete||s.is_unformatted||(e.alignment_size=s.alignment_size),s};var m=function(e,t,n){if(this.parent=t||null,this.text="",this.type="TK_TAG_OPEN",this.tag_name="",this.is_inline_element=!1,this.is_unformatted=!1,this.is_content_unformatted=!1,this.is_empty_element=!1,this.is_start_tag=!1,this.is_end_tag=!1,this.indent_content=!1,this.multiline_content=!1,this.custom_beautifier_name=null,this.start_tag_token=null,this.attr_count=0,this.has_wrapped_attrs=!1,this.alignment_size=0,this.tag_complete=!1,this.tag_start_char="",this.tag_check="",n){var i;this.tag_start_char=n.text[0],this.text=n.text,"<"===this.tag_start_char?(i=n.text.match(/^<([^\s>]*)/),this.tag_check=i?i[1]:""):(i=n.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=i?i[1]:"",(n.text.startsWith("{{#>")||n.text.startsWith("{{~#>"))&&">"===this.tag_check[0]&&(">"===this.tag_check&&null!==n.next?this.tag_check=n.next.text.split(" ")[0]:this.tag_check=n.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),n.type===a.COMMENT&&(this.tag_complete=!0),this.is_start_tag="/"!==this.tag_check.charAt(0),this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||n.closed&&"/>"===n.closed.text;var r=2;"{"===this.tag_start_char&&this.text.length>=3&&"~"===this.text.charAt(2)&&(r=3),this.is_end_tag=this.is_end_tag||"{"===this.tag_start_char&&(!e.indent_handlebars||this.text.length<3||/[^#\^]/.test(this.text.charAt(r)))}else this.tag_complete=!0};f.prototype._get_tag_open_token=function(e){var t=new m(this._options,this._tag_stack.get_parser_token(),e);return t.alignment_size=this._options.wrap_attributes_indent_size,t.is_end_tag=t.is_end_tag||h(t.tag_check,this._options.void_elements),t.is_empty_element=t.tag_complete||t.is_start_tag&&t.is_end_tag,t.is_unformatted=!t.tag_complete&&h(t.tag_check,this._options.unformatted),t.is_content_unformatted=!t.is_empty_element&&h(t.tag_check,this._options.content_unformatted),t.is_inline_element=h(t.tag_name,this._options.inline)||this._options.inline_custom_elements&&t.tag_name.includes("-")||"{"===t.tag_start_char,t},f.prototype._set_tag_position=function(e,t,n,i,r){if(n.is_empty_element||(n.is_end_tag?n.start_tag_token=this._tag_stack.try_pop(n.tag_name):(this._do_optional_end_element(n)&&(n.is_inline_element||e.print_newline(!1)),this._tag_stack.record_tag(n),"script"!==n.tag_name&&"style"!==n.tag_name||n.is_unformatted||n.is_content_unformatted||(n.custom_beautifier_name=u(n.tag_check,t)))),h(n.tag_check,this._options.extra_liners)&&(e.print_newline(!1),e._output.just_added_blankline()||e.print_newline(!0)),n.is_empty_element){if("{"===n.tag_start_char&&"else"===n.tag_check)this._tag_stack.indent_to_tag(["if","unless","each"]),n.indent_content=!0,e.current_line_has_match(/{{#if/)||e.print_newline(!1);"!--"===n.tag_name&&r.type===a.TAG_CLOSE&&i.is_end_tag&&-1===n.text.indexOf("\n")||(n.is_inline_element||n.is_unformatted||e.print_newline(!1),this._calcluate_parent_multiline(e,n))}else if(n.is_end_tag){var s=!1;s=(s=n.start_tag_token&&n.start_tag_token.multiline_content)||!n.is_inline_element&&!(i.is_inline_element||i.is_unformatted)&&!(r.type===a.TAG_CLOSE&&n.start_tag_token===i)&&"TK_CONTENT"!==r.type,(n.is_content_unformatted||n.is_unformatted)&&(s=!1),s&&e.print_newline(!1)}else n.indent_content=!n.custom_beautifier_name,"<"===n.tag_start_char&&("html"===n.tag_name?n.indent_content=this._options.indent_inner_html:"head"===n.tag_name?n.indent_content=this._options.indent_head_inner_html:"body"===n.tag_name&&(n.indent_content=this._options.indent_body_inner_html)),n.is_inline_element||n.is_unformatted||"TK_CONTENT"===r.type&&!n.is_content_unformatted||e.print_newline(!1),this._calcluate_parent_multiline(e,n)},f.prototype._calcluate_parent_multiline=function(e,t){!t.parent||!e._output.just_added_newline()||(t.is_inline_element||t.is_unformatted)&&t.parent.is_inline_element||(t.parent.multiline_content=!0)};var g=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","menu","nav","ol","p","pre","section","table","ul"],_=["a","audio","del","ins","map","noscript","video"];f.prototype._do_optional_end_element=function(e){var t=null;if(!e.is_empty_element&&e.is_start_tag&&e.parent){if("body"===e.tag_name)t=t||this._tag_stack.try_pop("head");else if("li"===e.tag_name)t=t||this._tag_stack.try_pop("li",["ol","ul","menu"]);else if("dd"===e.tag_name||"dt"===e.tag_name)t=(t=t||this._tag_stack.try_pop("dt",["dl"]))||this._tag_stack.try_pop("dd",["dl"]);else if("p"===e.parent.tag_name&&-1!==g.indexOf(e.tag_name)){var n=e.parent.parent;n&&-1!==_.indexOf(n.tag_name)||(t=t||this._tag_stack.try_pop("p"))}else"rp"===e.tag_name||"rt"===e.tag_name?t=(t=t||this._tag_stack.try_pop("rt",["ruby","rtc"]))||this._tag_stack.try_pop("rp",["ruby","rtc"]):"optgroup"===e.tag_name?t=t||this._tag_stack.try_pop("optgroup",["select"]):"option"===e.tag_name?t=t||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):"colgroup"===e.tag_name?t=t||this._tag_stack.try_pop("caption",["table"]):"thead"===e.tag_name?t=(t=t||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]):"tbody"===e.tag_name||"tfoot"===e.tag_name?t=(t=(t=(t=t||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("thead",["table"]))||this._tag_stack.try_pop("tbody",["table"]):"tr"===e.tag_name?t=(t=(t=t||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"]):"th"!==e.tag_name&&"td"!==e.tag_name||(t=(t=t||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]))||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return e.parent=this._tag_stack.get_parser_token(),t}},e.exports.Beautifier=f},function(e,t,n){var i=n(6).Options;function r(e){i.call(this,e,"html"),1===this.templating.length&&"auto"===this.templating[0]&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_min_attrs=this._get_number("wrap_attributes_min_attrs",2),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.inline_custom_elements=this._get_boolean("inline_custom_elements",!0),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}r.prototype=new i,e.exports.Options=r},function(e,t,n){var i=n(9).Tokenizer,r=n(9).TOKEN,s=n(13).Directives,a=n(14).TemplatablePattern,o=n(12).Pattern,l={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",CONTROL_FLOW_OPEN:"TK_CONTROL_FLOW_OPEN",CONTROL_FLOW_CLOSE:"TK_CONTROL_FLOW_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:r.START,RAW:r.RAW,EOF:r.EOF},c=new s(/<\!--/,/-->/),u=function(e,t){i.call(this,e,t),this._current_tag_name="";var n=new a(this._input).read_options(this._options),r=new o(this._input);if(this.__patterns={word:n.until(/[\n\r\t <]/),word_control_flow_close_excluded:n.until(/[\n\r\t <}]/),single_quote:n.until_after(/'/),double_quote:n.until_after(/"/),attribute:n.until(/[\n\r\t =>]|\/>/),element_name:n.until(/[\n\r\t >\/]/),angular_control_flow_start:r.matching(/\@[a-zA-Z]+[^({]*[({]/),handlebars_comment:r.starting_with(/{{!--/).until_after(/--}}/),handlebars:r.starting_with(/{{/).until_after(/}}/),handlebars_open:r.until(/[\n\r\t }]/),handlebars_raw_close:r.until(/}}/),comment:r.starting_with(/<!--/).until_after(/-->/),cdata:r.starting_with(/<!\[CDATA\[/).until_after(/]]>/),conditional_comment:r.starting_with(/<!\[/).until_after(/]>/),processing:r.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars"),this.__patterns.word_control_flow_close_excluded=this.__patterns.word_control_flow_close_excluded.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter){var s=this._input.get_literal_regexp(this._options.unformatted_content_delimiter);this.__patterns.unformatted_content_delimiter=r.matching(s).until_after(s)}};(u.prototype=new i)._is_comment=function(e){return!1},u.prototype._is_opening=function(e){return e.type===l.TAG_OPEN||e.type===l.CONTROL_FLOW_OPEN},u.prototype._is_closing=function(e,t){return e.type===l.TAG_CLOSE&&t&&((">"===e.text||"/>"===e.text)&&"<"===t.text[0]||"}}"===e.text&&"{"===t.text[0]&&"{"===t.text[1])||e.type===l.CONTROL_FLOW_CLOSE&&"}"===e.text&&t.text.endsWith("{")},u.prototype._reset=function(){this._current_tag_name=""},u.prototype._get_next_token=function(e,t){var n=null;this._readWhitespace();var i=this._input.peek();return null===i?this._create_token(l.EOF,""):n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n||this._read_open_handlebars(i,t))||this._read_attribute(i,e,t))||this._read_close(i,t))||this._read_script_and_style(i,e))||this._read_control_flows(i,t))||this._read_raw_content(i,e,t))||this._read_content_word(i,t))||this._read_comment_or_cdata(i))||this._read_processing(i))||this._read_open(i,t))||this._create_token(l.UNKNOWN,this._input.next())},u.prototype._read_comment_or_cdata=function(e){var t=null,n=null,i=null;"<"===e&&("!"===this._input.peek(1)&&((n=this.__patterns.comment.read())?(i=c.get_directives(n))&&"start"===i.ignore&&(n+=c.readIgnored(this._input)):n=this.__patterns.cdata.read()),n&&((t=this._create_token(l.COMMENT,n)).directives=i));return t},u.prototype._read_processing=function(e){var t=null,n=null;if("<"===e){var i=this._input.peek(1);"!"!==i&&"?"!==i||(n=(n=this.__patterns.conditional_comment.read())||this.__patterns.processing.read()),n&&((t=this._create_token(l.COMMENT,n)).directives=null)}return t},u.prototype._read_open=function(e,t){var n=null,i=null;return t&&t.type!==l.CONTROL_FLOW_OPEN||"<"===e&&(n=this._input.next(),"/"===this._input.peek()&&(n+=this._input.next()),n+=this.__patterns.element_name.read(),i=this._create_token(l.TAG_OPEN,n)),i},u.prototype._read_open_handlebars=function(e,t){var n=null,i=null;return t&&t.type!==l.CONTROL_FLOW_OPEN||(this._options.templating.includes("angular")||this._options.indent_handlebars)&&"{"===e&&"{"===this._input.peek(1)&&(this._options.indent_handlebars&&"!"===this._input.peek(2)?(n=(n=this.__patterns.handlebars_comment.read())||this.__patterns.handlebars.read(),i=this._create_token(l.COMMENT,n)):(n=this.__patterns.handlebars_open.read(),i=this._create_token(l.TAG_OPEN,n))),i},u.prototype._read_control_flows=function(e,t){var n="",i=null;if(!this._options.templating.includes("angular"))return i;if("@"===e){if(""===(n=this.__patterns.angular_control_flow_start.read()))return i;for(var r=n.endsWith("(")?1:0,s=0;!n.endsWith("{")||r!==s;){var a=this._input.next();if(null===a)break;"("===a?r++:")"===a&&s++,n+=a}i=this._create_token(l.CONTROL_FLOW_OPEN,n)}else"}"===e&&t&&t.type===l.CONTROL_FLOW_OPEN&&(n=this._input.next(),i=this._create_token(l.CONTROL_FLOW_CLOSE,n));return i},u.prototype._read_close=function(e,t){var n=null,i=null;return t&&t.type===l.TAG_OPEN&&("<"===t.text[0]&&(">"===e||"/"===e&&">"===this._input.peek(1))?(n=this._input.next(),"/"===e&&(n+=this._input.next()),i=this._create_token(l.TAG_CLOSE,n)):"{"===t.text[0]&&"}"===e&&"}"===this._input.peek(1)&&(this._input.next(),this._input.next(),i=this._create_token(l.TAG_CLOSE,"}}"))),i},u.prototype._read_attribute=function(e,t,n){var i=null,r="";if(n&&"<"===n.text[0])if("="===e)i=this._create_token(l.EQUALS,this._input.next());else if('"'===e||"'"===e){var s=this._input.next();s+='"'===e?this.__patterns.double_quote.read():this.__patterns.single_quote.read(),i=this._create_token(l.VALUE,s)}else(r=this.__patterns.attribute.read())&&(i=t.type===l.EQUALS?this._create_token(l.VALUE,r):this._create_token(l.ATTRIBUTE,r));return i},u.prototype._is_content_unformatted=function(e){return-1===this._options.void_elements.indexOf(e)&&(-1!==this._options.content_unformatted.indexOf(e)||-1!==this._options.unformatted.indexOf(e))},u.prototype._read_raw_content=function(e,t,n){var i="";if(n&&"{"===n.text[0])i=this.__patterns.handlebars_raw_close.read();else if(t.type===l.TAG_CLOSE&&"<"===t.opened.text[0]&&"/"!==t.text[0]){var r=t.opened.text.substr(1).toLowerCase();this._is_content_unformatted(r)&&(i=this._input.readUntil(new RegExp("</"+r+"[\\n\\r\\t ]*?>","ig")))}return i?this._create_token(l.TEXT,i):null},u.prototype._read_script_and_style=function(e,t){if(t.type===l.TAG_CLOSE&&"<"===t.opened.text[0]&&"/"!==t.text[0]){var n=t.opened.text.substr(1).toLowerCase();if("script"===n||"style"===n){var i=this._read_comment_or_cdata(e);if(i)return i.type=l.TEXT,i;var r=this._input.readUntil(new RegExp("</"+n+"[\\n\\r\\t ]*?>","ig"));if(r)return this._create_token(l.TEXT,r)}}return null},u.prototype._read_content_word=function(e,t){var n="";return this._options.unformatted_content_delimiter&&e===this._options.unformatted_content_delimiter[0]&&(n=this.__patterns.unformatted_content_delimiter.read()),n||(n=t&&t.type===l.CONTROL_FLOW_OPEN?this.__patterns.word_control_flow_close_excluded.read():this.__patterns.word.read()),n?this._create_token(l.TEXT,n):null},e.exports.Tokenizer=u,e.exports.TOKEN=l}],t={};var n=function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}(18);s=n}();var a=s;i=[n,n(58553),n(87804)],r=function(e){var t=n(58553),i=n(87804);return{html_beautify:function(e,n){return a(e,n,t.js_beautify,i.css_beautify)}}}.apply(t,i),void 0===r||(e.exports=r)}()},58553:function(e,t){var n;!function(){var i;!function(){"use strict";var e=[function(e,t,n){var i=n(1).Beautifier,r=n(5).Options;e.exports=function(e,t){return new i(e,t).beautify()},e.exports.defaultOptions=function(){return new r}},function(e,t,n){var i=n(2).Output,r=n(3).Token,s=n(4),a=n(5).Options,o=n(7).Tokenizer,l=n(7).line_starters,c=n(7).positionable_operators,u=n(7).TOKEN;function h(e,t){return-1!==t.indexOf(e)}function d(e,t){return e&&e.type===u.RESERVED&&e.text===t}function p(e,t){return e&&e.type===u.RESERVED&&h(e.text,t)}var f=["case","return","do","if","throw","else","await","break","continue","async"],m=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].replace(/-/g,"_")]=e[n];return t}(["before-newline","after-newline","preserve-newline"]),g=[m.before_newline,m.preserve_newline],_="BlockStatement",y="Statement",v="ObjectLiteral",b="ArrayLiteral",w="ForInitializer",x="Conditional",k="Expression";function S(e,t){t.multiline_frame||t.mode===w||t.mode===x||e.remove_indent(t.start_line_index)}function E(e){return e===b}function T(e){return h(e,[k,w,x])}function C(e,t){t=t||{},this._source_text=e||"",this._output=null,this._tokens=null,this._last_last_text=null,this._flags=null,this._previous_flags=null,this._flag_store=null,this._options=new a(t)}C.prototype.create_flags=function(e,t){var n=0;return e&&(n=e.indentation_level,!this._output.just_added_newline()&&e.line_indent_level>n&&(n=e.line_indent_level)),{mode:t,parent:e,last_token:e?e.last_token:new r(u.START_BLOCK,""),last_word:e?e.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,class_start_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,case_block:!1,indentation_level:n,alignment:0,line_indent_level:e?e.line_indent_level:n,start_line_index:this._output.get_line_number(),ternary_depth:0}},C.prototype._reset=function(e){var t=e.match(/^[\t ]*/)[0];this._last_last_text="",this._output=new i(this._options,t),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(_);var n=new o(e,this._options);return this._tokens=n.tokenize(),e},C.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var e=this._reset(this._source_text),t=this._options.eol;"auto"===this._options.eol&&(t="\n",e&&s.lineBreak.test(e||"")&&(t=e.match(s.lineBreak)[0]));for(var n=this._tokens.next();n;)this.handle_token(n),this._last_last_text=this._flags.last_token.text,this._flags.last_token=n,n=this._tokens.next();return this._output.get_code(t)},C.prototype.handle_token=function(e,t){e.type===u.START_EXPR?this.handle_start_expr(e):e.type===u.END_EXPR?this.handle_end_expr(e):e.type===u.START_BLOCK?this.handle_start_block(e):e.type===u.END_BLOCK?this.handle_end_block(e):e.type===u.WORD||e.type===u.RESERVED?this.handle_word(e):e.type===u.SEMICOLON?this.handle_semicolon(e):e.type===u.STRING?this.handle_string(e):e.type===u.EQUALS?this.handle_equals(e):e.type===u.OPERATOR?this.handle_operator(e):e.type===u.COMMA?this.handle_comma(e):e.type===u.BLOCK_COMMENT?this.handle_block_comment(e,t):e.type===u.COMMENT?this.handle_comment(e,t):e.type===u.DOT?this.handle_dot(e):e.type===u.EOF?this.handle_eof(e):(e.type,u.UNKNOWN,this.handle_unknown(e,t))},C.prototype.handle_whitespace_and_comments=function(e,t){var n=e.newlines,i=this._options.keep_array_indentation&&E(this._flags.mode);if(e.comments_before)for(var r=e.comments_before.next();r;)this.handle_whitespace_and_comments(r,t),this.handle_token(r,t),r=e.comments_before.next();if(i)for(var s=0;s<n;s+=1)this.print_newline(s>0,t);else if(this._options.max_preserve_newlines&&n>this._options.max_preserve_newlines&&(n=this._options.max_preserve_newlines),this._options.preserve_newlines&&n>1){this.print_newline(!1,t);for(var a=1;a<n;a+=1)this.print_newline(!0,t)}};var L=["async","break","continue","return","throw","yield"];C.prototype.allow_wrap_or_preserved_newline=function(e,t){if(t=void 0!==t&&t,!this._output.just_added_newline()){var n=this._options.preserve_newlines&&e.newlines||t;if(h(this._flags.last_token.text,c)||h(e.text,c)){var i=h(this._flags.last_token.text,c)&&h(this._options.operator_position,g)||h(e.text,c);n=n&&i}if(n)this.print_newline(!1,!0);else if(this._options.wrap_line_length){if(p(this._flags.last_token,L))return;this._output.set_wrap_point()}}},C.prototype.print_newline=function(e,t){if(!t&&";"!==this._flags.last_token.text&&","!==this._flags.last_token.text&&"="!==this._flags.last_token.text&&(this._flags.last_token.type!==u.OPERATOR||"--"===this._flags.last_token.text||"++"===this._flags.last_token.text))for(var n=this._tokens.peek();!(this._flags.mode!==y||this._flags.if_block&&d(n,"else")||this._flags.do_block);)this.restore_mode();this._output.add_new_line(e)&&(this._flags.multiline_frame=!0)},C.prototype.print_token_line_indentation=function(e){this._output.just_added_newline()&&(this._options.keep_array_indentation&&e.newlines&&("["===e.text||E(this._flags.mode))?(this._output.current_line.set_indent(-1),this._output.current_line.push(e.whitespace_before),this._output.space_before_token=!1):this._output.set_indent(this._flags.indentation_level,this._flags.alignment)&&(this._flags.line_indent_level=this._flags.indentation_level))},C.prototype.print_token=function(e){if(this._output.raw)this._output.add_raw_token(e);else{if(this._options.comma_first&&e.previous&&e.previous.type===u.COMMA&&this._output.just_added_newline()&&","===this._output.previous_line.last()){var t=this._output.previous_line.pop();this._output.previous_line.is_empty()&&(this._output.previous_line.push(t),this._output.trim(!0),this._output.current_line.pop(),this._output.trim()),this.print_token_line_indentation(e),this._output.add_token(","),this._output.space_before_token=!0}this.print_token_line_indentation(e),this._output.non_breaking_space=!0,this._output.add_token(e.text),this._output.previous_token_wrapped&&(this._flags.multiline_frame=!0)}},C.prototype.indent=function(){this._flags.indentation_level+=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},C.prototype.deindent=function(){this._flags.indentation_level>0&&(!this._flags.parent||this._flags.indentation_level>this._flags.parent.indentation_level)&&(this._flags.indentation_level-=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},C.prototype.set_mode=function(e){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,e),this._flags=this.create_flags(this._previous_flags,e),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},C.prototype.restore_mode=function(){this._flag_store.length>0&&(this._previous_flags=this._flags,this._flags=this._flag_store.pop(),this._previous_flags.mode===y&&S(this._output,this._previous_flags),this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},C.prototype.start_of_object_property=function(){return this._flags.parent.mode===v&&this._flags.mode===y&&(":"===this._flags.last_token.text&&0===this._flags.ternary_depth||p(this._flags.last_token,["get","set"]))},C.prototype.start_of_statement=function(e){var t=!1;return!!(t=(t=(t=(t=(t=(t=(t=t||p(this._flags.last_token,["var","let","const"])&&e.type===u.WORD)||d(this._flags.last_token,"do"))||!(this._flags.parent.mode===v&&this._flags.mode===y)&&p(this._flags.last_token,L)&&!e.newlines)||d(this._flags.last_token,"else")&&!(d(e,"if")&&!e.comments_before))||this._flags.last_token.type===u.END_EXPR&&(this._previous_flags.mode===w||this._previous_flags.mode===x))||this._flags.last_token.type===u.WORD&&this._flags.mode===_&&!this._flags.in_case&&!("--"===e.text||"++"===e.text)&&"function"!==this._last_last_text&&e.type!==u.WORD&&e.type!==u.RESERVED)||this._flags.mode===v&&(":"===this._flags.last_token.text&&0===this._flags.ternary_depth||p(this._flags.last_token,["get","set"])))&&(this.set_mode(y),this.indent(),this.handle_whitespace_and_comments(e,!0),this.start_of_object_property()||this.allow_wrap_or_preserved_newline(e,p(e,["do","for","if","while"])),!0)},C.prototype.handle_start_expr=function(e){this.start_of_statement(e)||this.handle_whitespace_and_comments(e);var t=k;if("["===e.text){if(this._flags.last_token.type===u.WORD||")"===this._flags.last_token.text)return p(this._flags.last_token,l)&&(this._output.space_before_token=!0),this.print_token(e),this.set_mode(t),this.indent(),void(this._options.space_in_paren&&(this._output.space_before_token=!0));t=b,E(this._flags.mode)&&("["!==this._flags.last_token.text&&(","!==this._flags.last_token.text||"]"!==this._last_last_text&&"}"!==this._last_last_text)||this._options.keep_array_indentation||this.print_newline()),h(this._flags.last_token.type,[u.START_EXPR,u.END_EXPR,u.WORD,u.OPERATOR,u.DOT])||(this._output.space_before_token=!0)}else{if(this._flags.last_token.type===u.RESERVED)"for"===this._flags.last_token.text?(this._output.space_before_token=this._options.space_before_conditional,t=w):h(this._flags.last_token.text,["if","while","switch"])?(this._output.space_before_token=this._options.space_before_conditional,t=x):h(this._flags.last_word,["await","async"])?this._output.space_before_token=!0:"import"===this._flags.last_token.text&&""===e.whitespace_before?this._output.space_before_token=!1:(h(this._flags.last_token.text,l)||"catch"===this._flags.last_token.text)&&(this._output.space_before_token=!0);else if(this._flags.last_token.type===u.EQUALS||this._flags.last_token.type===u.OPERATOR)this.start_of_object_property()||this.allow_wrap_or_preserved_newline(e);else if(this._flags.last_token.type===u.WORD){this._output.space_before_token=!1;var n=this._tokens.peek(-3);if(this._options.space_after_named_function&&n){var i=this._tokens.peek(-4);p(n,["async","function"])||"*"===n.text&&p(i,["async","function"])?this._output.space_before_token=!0:this._flags.mode===v?"{"!==n.text&&","!==n.text&&("*"!==n.text||"{"!==i.text&&","!==i.text)||(this._output.space_before_token=!0):this._flags.parent&&this._flags.parent.class_start_block&&(this._output.space_before_token=!0)}}else this.allow_wrap_or_preserved_newline(e);(this._flags.last_token.type===u.RESERVED&&("function"===this._flags.last_word||"typeof"===this._flags.last_word)||"*"===this._flags.last_token.text&&(h(this._last_last_text,["function","yield"])||this._flags.mode===v&&h(this._last_last_text,["{",","])))&&(this._output.space_before_token=this._options.space_after_anon_function)}";"===this._flags.last_token.text||this._flags.last_token.type===u.START_BLOCK?this.print_newline():this._flags.last_token.type!==u.END_EXPR&&this._flags.last_token.type!==u.START_EXPR&&this._flags.last_token.type!==u.END_BLOCK&&"."!==this._flags.last_token.text&&this._flags.last_token.type!==u.COMMA||this.allow_wrap_or_preserved_newline(e,e.newlines),this.print_token(e),this.set_mode(t),this._options.space_in_paren&&(this._output.space_before_token=!0),this.indent()},C.prototype.handle_end_expr=function(e){for(;this._flags.mode===y;)this.restore_mode();this.handle_whitespace_and_comments(e),this._flags.multiline_frame&&this.allow_wrap_or_preserved_newline(e,"]"===e.text&&E(this._flags.mode)&&!this._options.keep_array_indentation),this._options.space_in_paren&&(this._flags.last_token.type!==u.START_EXPR||this._options.space_in_empty_paren?this._output.space_before_token=!0:(this._output.trim(),this._output.space_before_token=!1)),this.deindent(),this.print_token(e),this.restore_mode(),S(this._output,this._previous_flags),this._flags.do_while&&this._previous_flags.mode===x&&(this._previous_flags.mode=k,this._flags.do_block=!1,this._flags.do_while=!1)},C.prototype.handle_start_block=function(e){this.handle_whitespace_and_comments(e);var t=this._tokens.peek(),n=this._tokens.peek(1);"switch"===this._flags.last_word&&this._flags.last_token.type===u.END_EXPR?(this.set_mode(_),this._flags.in_case_statement=!0):this._flags.case_body?this.set_mode(_):n&&(h(n.text,[":",","])&&h(t.type,[u.STRING,u.WORD,u.RESERVED])||h(t.text,["get","set","..."])&&h(n.type,[u.WORD,u.RESERVED]))?h(this._last_last_text,["class","interface"])&&!h(n.text,[":",","])?this.set_mode(_):this.set_mode(v):this._flags.last_token.type===u.OPERATOR&&"=>"===this._flags.last_token.text?this.set_mode(_):h(this._flags.last_token.type,[u.EQUALS,u.START_EXPR,u.COMMA,u.OPERATOR])||p(this._flags.last_token,["return","throw","import","default"])?this.set_mode(v):this.set_mode(_),this._flags.last_token&&p(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0);var i=!t.comments_before&&"}"===t.text,r=i&&"function"===this._flags.last_word&&this._flags.last_token.type===u.END_EXPR;if(this._options.brace_preserve_inline){var s=0,a=null;this._flags.inline_frame=!0;do{if(s+=1,(a=this._tokens.peek(s-1)).newlines){this._flags.inline_frame=!1;break}}while(a.type!==u.EOF&&(a.type!==u.END_BLOCK||a.opened!==e))}("expand"===this._options.brace_style||"none"===this._options.brace_style&&e.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==u.OPERATOR&&(r||this._flags.last_token.type===u.EQUALS||p(this._flags.last_token,f)&&"else"!==this._flags.last_token.text)?this._output.space_before_token=!0:this.print_newline(!1,!0):(!E(this._previous_flags.mode)||this._flags.last_token.type!==u.START_EXPR&&this._flags.last_token.type!==u.COMMA||((this._flags.last_token.type===u.COMMA||this._options.space_in_paren)&&(this._output.space_before_token=!0),(this._flags.last_token.type===u.COMMA||this._flags.last_token.type===u.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(e),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==u.OPERATOR&&this._flags.last_token.type!==u.START_EXPR&&(h(this._flags.last_token.type,[u.START_BLOCK,u.SEMICOLON])&&!this._flags.inline_frame?this.print_newline():this._output.space_before_token=!0)),this.print_token(e),this.indent(),i||this._options.brace_preserve_inline&&this._flags.inline_frame||this.print_newline()},C.prototype.handle_end_block=function(e){for(this.handle_whitespace_and_comments(e);this._flags.mode===y;)this.restore_mode();var t=this._flags.last_token.type===u.START_BLOCK;this._flags.inline_frame&&!t?this._output.space_before_token=!0:"expand"===this._options.brace_style?t||this.print_newline():t||(E(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(e)},C.prototype.handle_word=function(e){if(e.type===u.RESERVED)if(h(e.text,["set","get"])&&this._flags.mode!==v)e.type=u.WORD;else if("import"===e.text&&h(this._tokens.peek().text,["(","."]))e.type=u.WORD;else if(h(e.text,["as","from"])&&!this._flags.import_block)e.type=u.WORD;else if(this._flags.mode===v){":"===this._tokens.peek().text&&(e.type=u.WORD)}if(this.start_of_statement(e)?p(this._flags.last_token,["var","let","const"])&&e.type===u.WORD&&(this._flags.declaration_statement=!0):!e.newlines||T(this._flags.mode)||this._flags.last_token.type===u.OPERATOR&&"--"!==this._flags.last_token.text&&"++"!==this._flags.last_token.text||this._flags.last_token.type===u.EQUALS||!this._options.preserve_newlines&&p(this._flags.last_token,["var","let","const","set","get"])?this.handle_whitespace_and_comments(e):(this.handle_whitespace_and_comments(e),this.print_newline()),this._flags.do_block&&!this._flags.do_while){if(d(e,"while"))return this._output.space_before_token=!0,this.print_token(e),this._output.space_before_token=!0,void(this._flags.do_while=!0);this.print_newline(),this._flags.do_block=!1}if(this._flags.if_block)if(!this._flags.else_block&&d(e,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===y;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}if(this._flags.in_case_statement&&p(e,["case","default"]))return this.print_newline(),this._flags.case_block||!this._flags.case_body&&!this._options.jslint_happy||this.deindent(),this._flags.case_body=!1,this.print_token(e),void(this._flags.in_case=!0);if(this._flags.last_token.type!==u.COMMA&&this._flags.last_token.type!==u.START_EXPR&&this._flags.last_token.type!==u.EQUALS&&this._flags.last_token.type!==u.OPERATOR||this.start_of_object_property()||h(this._flags.last_token.text,["+","-"])&&":"===this._last_last_text&&this._flags.parent.mode===v||this.allow_wrap_or_preserved_newline(e),d(e,"function"))return(h(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!h(this._flags.last_token.text,["(","[","{",":","=",","])&&this._flags.last_token.type!==u.OPERATOR)&&(this._output.just_added_blankline()||e.comments_before||(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===u.RESERVED||this._flags.last_token.type===u.WORD?p(this._flags.last_token,["get","set","new","export"])||p(this._flags.last_token,L)||d(this._flags.last_token,"default")&&"export"===this._last_last_text||"declare"===this._flags.last_token.text?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===u.OPERATOR||"="===this._flags.last_token.text?this._output.space_before_token=!0:(this._flags.multiline_frame||!T(this._flags.mode)&&!E(this._flags.mode))&&this.print_newline(),this.print_token(e),void(this._flags.last_word=e.text);var t="NONE";(this._flags.last_token.type===u.END_BLOCK?this._previous_flags.inline_frame?t="SPACE":p(e,["else","catch","finally","from"])?"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&e.newlines?t="NEWLINE":(t="SPACE",this._output.space_before_token=!0):t="NEWLINE":this._flags.last_token.type===u.SEMICOLON&&this._flags.mode===_?t="NEWLINE":this._flags.last_token.type===u.SEMICOLON&&T(this._flags.mode)?t="SPACE":this._flags.last_token.type===u.STRING?t="NEWLINE":this._flags.last_token.type===u.RESERVED||this._flags.last_token.type===u.WORD||"*"===this._flags.last_token.text&&(h(this._last_last_text,["function","yield"])||this._flags.mode===v&&h(this._last_last_text,["{",","]))?t="SPACE":this._flags.last_token.type===u.START_BLOCK?t=this._flags.inline_frame?"SPACE":"NEWLINE":this._flags.last_token.type===u.END_EXPR&&(this._output.space_before_token=!0,t="NEWLINE"),p(e,l)&&")"!==this._flags.last_token.text&&(t=this._flags.inline_frame||"else"===this._flags.last_token.text||"export"===this._flags.last_token.text?"SPACE":"NEWLINE"),p(e,["else","catch","finally"]))?(this._flags.last_token.type!==u.END_BLOCK||this._previous_flags.mode!==_||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&e.newlines)&&!this._flags.inline_frame?this.print_newline():(this._output.trim(!0),"}"!==this._output.current_line.last()&&this.print_newline(),this._output.space_before_token=!0):"NEWLINE"===t?p(this._flags.last_token,f)||"declare"===this._flags.last_token.text&&p(e,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==u.END_EXPR?this._flags.last_token.type===u.START_EXPR&&p(e,["var","let","const"])||":"===this._flags.last_token.text||(d(e,"if")&&d(e.previous,"else")?this._output.space_before_token=!0:this.print_newline()):p(e,l)&&")"!==this._flags.last_token.text&&this.print_newline():this._flags.multiline_frame&&E(this._flags.mode)&&","===this._flags.last_token.text&&"}"===this._last_last_text?this.print_newline():"SPACE"===t&&(this._output.space_before_token=!0);!e.previous||e.previous.type!==u.WORD&&e.previous.type!==u.RESERVED||(this._output.space_before_token=!0),this.print_token(e),this._flags.last_word=e.text,e.type===u.RESERVED&&("do"===e.text?this._flags.do_block=!0:"if"===e.text?this._flags.if_block=!0:"import"===e.text?this._flags.import_block=!0:this._flags.import_block&&d(e,"from")&&(this._flags.import_block=!1))},C.prototype.handle_semicolon=function(e){this.start_of_statement(e)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(e);for(var t=this._tokens.peek();!(this._flags.mode!==y||this._flags.if_block&&d(t,"else")||this._flags.do_block);)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(e)},C.prototype.handle_string=function(e){(!e.text.startsWith("`")||0!==e.newlines||""!==e.whitespace_before||")"!==e.previous.text&&this._flags.last_token.type!==u.WORD)&&(this.start_of_statement(e)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(e),this._flags.last_token.type===u.RESERVED||this._flags.last_token.type===u.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===u.COMMA||this._flags.last_token.type===u.START_EXPR||this._flags.last_token.type===u.EQUALS||this._flags.last_token.type===u.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(e):!e.text.startsWith("`")||this._flags.last_token.type!==u.END_EXPR||"]"!==e.previous.text&&")"!==e.previous.text||0!==e.newlines?this.print_newline():this._output.space_before_token=!0)),this.print_token(e)},C.prototype.handle_equals=function(e){this.start_of_statement(e)||this.handle_whitespace_and_comments(e),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(e),this._output.space_before_token=!0},C.prototype.handle_comma=function(e){this.handle_whitespace_and_comments(e,!0),this.print_token(e),this._output.space_before_token=!0,this._flags.declaration_statement?(T(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(e)):this._flags.mode===v||this._flags.mode===y&&this._flags.parent.mode===v?(this._flags.mode===y&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(e)},C.prototype.handle_operator=function(e){var t="*"===e.text&&(p(this._flags.last_token,["function","yield"])||h(this._flags.last_token.type,[u.START_BLOCK,u.COMMA,u.END_BLOCK,u.SEMICOLON])),n=h(e.text,["-","+"])&&(h(this._flags.last_token.type,[u.START_BLOCK,u.START_EXPR,u.EQUALS,u.OPERATOR])||h(this._flags.last_token.text,l)||","===this._flags.last_token.text);if(this.start_of_statement(e));else{var i=!t;this.handle_whitespace_and_comments(e,i)}if("*"!==e.text||this._flags.last_token.type!==u.DOT)if("::"!==e.text)if(h(e.text,["-","+"])&&this.start_of_object_property())this.print_token(e);else{if(this._flags.last_token.type===u.OPERATOR&&h(this._options.operator_position,g)&&this.allow_wrap_or_preserved_newline(e),":"===e.text&&this._flags.in_case)return this.print_token(e),this._flags.in_case=!1,this._flags.case_body=!0,void(this._tokens.peek().type!==u.START_BLOCK?(this.indent(),this.print_newline(),this._flags.case_block=!1):(this._flags.case_block=!0,this._output.space_before_token=!0));var r=!0,s=!0,a=!1;if(":"===e.text?0===this._flags.ternary_depth?r=!1:(this._flags.ternary_depth-=1,a=!0):"?"===e.text&&(this._flags.ternary_depth+=1),!n&&!t&&this._options.preserve_newlines&&h(e.text,c)){var o=":"===e.text,d=o&&a,v=o&&!a;switch(this._options.operator_position){case m.before_newline:return this._output.space_before_token=!v,this.print_token(e),o&&!d||this.allow_wrap_or_preserved_newline(e),void(this._output.space_before_token=!0);case m.after_newline:return this._output.space_before_token=!0,!o||d?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(e):this._output.space_before_token=!1,this.print_token(e),void(this._output.space_before_token=!0);case m.preserve_newline:return v||this.allow_wrap_or_preserved_newline(e),r=!(this._output.just_added_newline()||v),this._output.space_before_token=r,this.print_token(e),void(this._output.space_before_token=!0)}}if(t){this.allow_wrap_or_preserved_newline(e),r=!1;var b=this._tokens.peek();s=b&&h(b.type,[u.WORD,u.RESERVED])}else if("..."===e.text)this.allow_wrap_or_preserved_newline(e),r=this._flags.last_token.type===u.START_BLOCK,s=!1;else if(h(e.text,["--","++","!","~"])||n){if(this._flags.last_token.type!==u.COMMA&&this._flags.last_token.type!==u.START_EXPR||this.allow_wrap_or_preserved_newline(e),r=!1,s=!1,e.newlines&&("--"===e.text||"++"===e.text||"~"===e.text)){var w=p(this._flags.last_token,f)&&e.newlines;w&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(w,!0)}";"===this._flags.last_token.text&&T(this._flags.mode)&&(r=!0),this._flags.last_token.type===u.RESERVED?r=!0:this._flags.last_token.type===u.END_EXPR?r=!("]"===this._flags.last_token.text&&("--"===e.text||"++"===e.text)):this._flags.last_token.type===u.OPERATOR&&(r=h(e.text,["--","-","++","+"])&&h(this._flags.last_token.text,["--","-","++","+"]),h(e.text,["+","-"])&&h(this._flags.last_token.text,["--","++"])&&(s=!0)),(this._flags.mode!==_||this._flags.inline_frame)&&this._flags.mode!==y||"{"!==this._flags.last_token.text&&";"!==this._flags.last_token.text||this.print_newline()}this._output.space_before_token=this._output.space_before_token||r,this.print_token(e),this._output.space_before_token=s}else this.print_token(e);else this.print_token(e)},C.prototype.handle_block_comment=function(e,t){return this._output.raw?(this._output.add_raw_token(e),void(e.directives&&"end"===e.directives.preserve&&(this._output.raw=this._options.test_output_raw))):e.directives?(this.print_newline(!1,t),this.print_token(e),"start"===e.directives.preserve&&(this._output.raw=!0),void this.print_newline(!1,!0)):s.newline.test(e.text)||e.newlines?void this.print_block_commment(e,t):(this._output.space_before_token=!0,this.print_token(e),void(this._output.space_before_token=!0))},C.prototype.print_block_commment=function(e,t){var n,i=function(e){for(var t=[],n=(e=e.replace(s.allLineBreaks,"\n")).indexOf("\n");-1!==n;)t.push(e.substring(0,n)),n=(e=e.substring(n+1)).indexOf("\n");return e.length&&t.push(e),t}(e.text),r=!1,a=!1,o=e.whitespace_before,l=o.length;if(this.print_newline(!1,t),this.print_token_line_indentation(e),this._output.add_token(i[0]),this.print_newline(!1,t),i.length>1){for(r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].trim().charAt(0)!==t)return!1;return!0}(i=i.slice(1),"*"),a=function(e,t){for(var n,i=0,r=e.length;i<r;i++)if((n=e[i])&&0!==n.indexOf(t))return!1;return!0}(i,o),r&&(this._flags.alignment=1),n=0;n<i.length;n++)r?(this.print_token_line_indentation(e),this._output.add_token(i[n].replace(/^\s+/g,""))):a&&i[n]?(this.print_token_line_indentation(e),this._output.add_token(i[n].substring(l))):(this._output.current_line.set_indent(-1),this._output.add_token(i[n])),this.print_newline(!1,t);this._flags.alignment=0}},C.prototype.handle_comment=function(e,t){e.newlines?this.print_newline(!1,t):this._output.trim(!0),this._output.space_before_token=!0,this.print_token(e),this.print_newline(!1,t)},C.prototype.handle_dot=function(e){this.start_of_statement(e)||this.handle_whitespace_and_comments(e,!0),this._flags.last_token.text.match("^[0-9]+$")&&(this._output.space_before_token=!0),p(this._flags.last_token,f)?this._output.space_before_token=!1:this.allow_wrap_or_preserved_newline(e,")"===this._flags.last_token.text&&this._options.break_chained_methods),this._options.unindent_chained_methods&&this._output.just_added_newline()&&this.deindent(),this.print_token(e)},C.prototype.handle_unknown=function(e,t){this.print_token(e),"\n"===e.text[e.text.length-1]&&this.print_newline(!1,t)},C.prototype.handle_eof=function(e){for(;this._flags.mode===y;)this.restore_mode();this.handle_whitespace_and_comments(e)},e.exports.Beautifier=C},function(e){function t(e){this.__parent=e,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function n(e,t){this.__cache=[""],this.__indent_size=e.indent_size,this.__indent_string=e.indent_char,e.indent_with_tabs||(this.__indent_string=new Array(e.indent_size+1).join(e.indent_char)),t=t||"",e.indent_level>0&&(t=new Array(e.indent_level+1).join(this.__indent_string)),this.__base_string=t,this.__base_string_length=t.length}function i(e,i){this.__indent_cache=new n(e,i),this.raw=!1,this._end_with_newline=e.end_with_newline,this.indent_size=e.indent_size,this.wrap_line_length=e.wrap_line_length,this.indent_empty_lines=e.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new t(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}t.prototype.clone_empty=function(){var e=new t(this.__parent);return e.set_indent(this.__indent_count,this.__alignment_count),e},t.prototype.item=function(e){return e<0?this.__items[this.__items.length+e]:this.__items[e]},t.prototype.has_match=function(e){for(var t=this.__items.length-1;t>=0;t--)if(this.__items[t].match(e))return!0;return!1},t.prototype.set_indent=function(e,t){this.is_empty()&&(this.__indent_count=e||0,this.__alignment_count=t||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var e=this.__parent.current_line;return e.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),e.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),e.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===e.__items[0]&&(e.__items.splice(0,1),e.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return 0===this.__items.length},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(e){this.__items.push(e);var t=e.lastIndexOf("\n");-1!==t?this.__character_count=e.length-t:this.__character_count+=e.length},t.prototype.pop=function(){var e=null;return this.is_empty()||(e=this.__items.pop(),this.__character_count-=e.length),e},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;" "===this.last();)this.__items.pop(),this.__character_count-=1},t.prototype.toString=function(){var e="";return this.is_empty()?this.__parent.indent_empty_lines&&(e=this.__parent.get_indent_string(this.__indent_count)):(e=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),e+=this.__items.join("")),e},n.prototype.get_indent_size=function(e,t){var n=this.__base_string_length;return t=t||0,e<0&&(n=0),n+=e*this.__indent_size,n+=t},n.prototype.get_indent_string=function(e,t){var n=this.__base_string;return t=t||0,e<0&&(e=0,n=""),t+=e*this.__indent_size,this.__ensure_cache(t),n+=this.__cache[t]},n.prototype.__ensure_cache=function(e){for(;e>=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var e=this.__cache.length,t=0,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},i.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},i.prototype.get_line_number=function(){return this.__lines.length},i.prototype.get_indent_string=function(e,t){return this.__indent_cache.get_indent_string(e,t)},i.prototype.get_indent_size=function(e,t){return this.__indent_cache.get_indent_size(e,t)},i.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},i.prototype.add_new_line=function(e){return!(this.is_empty()||!e&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},i.prototype.get_code=function(e){this.trim(!0);var t=this.current_line.pop();t&&("\n"===t[t.length-1]&&(t=t.replace(/\n+$/g,"")),this.current_line.push(t)),this._end_with_newline&&this.__add_outputline();var n=this.__lines.join("\n");return"\n"!==e&&(n=n.replace(/[\n]/g,e)),n},i.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},i.prototype.set_indent=function(e,t){return e=e||0,t=t||0,this.next_line.set_indent(e,t),this.__lines.length>1?(this.current_line.set_indent(e,t),!0):(this.current_line.set_indent(),!1)},i.prototype.add_raw_token=function(e){for(var t=0;t<e.newlines;t++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(e.whitespace_before),this.current_line.push(e.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},i.prototype.add_token=function(e){this.__add_space_before_token(),this.current_line.push(e),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},i.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},i.prototype.remove_indent=function(e){for(var t=this.__lines.length;e<t;)this.__lines[e]._remove_indent(),e++;this.current_line._remove_wrap_indent()},i.prototype.trim=function(e){for(e=void 0!==e&&e,this.current_line.trim();e&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},i.prototype.just_added_newline=function(){return this.current_line.is_empty()},i.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},i.prototype.ensure_empty_line_above=function(e,n){for(var i=this.__lines.length-2;i>=0;){var r=this.__lines[i];if(r.is_empty())break;if(0!==r.item(0).indexOf(e)&&r.item(-1)!==n){this.__lines.splice(i+1,0,new t(this)),this.previous_line=this.__lines[this.__lines.length-2];break}i--}},e.exports.Output=i},function(e){e.exports.Token=function(e,t,n,i){this.type=e,this.text=t,this.comments_before=null,this.newlines=n||0,this.whitespace_before=i||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null}},function(e,t){var n="\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a",i="\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc",r="\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f",s="\\\\u[0-9a-fA-F]{4}|\\\\u\\{[0-9a-fA-F]+\\}",a="(?:"+s+"|[\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a"+i+"])",o="(?:"+s+"|["+n+i+r+"])*";t.identifier=new RegExp(a+o,"g"),t.identifierStart=new RegExp(a),t.identifierMatch=new RegExp("(?:"+s+"|["+n+i+r+"])+");t.newline=/[\n\r\u2028\u2029]/,t.lineBreak=new RegExp("\r\n|"+t.newline.source),t.allLineBreaks=new RegExp(t.lineBreak.source,"g")},function(e,t,n){var i=n(6).Options,r=["before-newline","after-newline","preserve-newline"];function s(e){i.call(this,e,"js");var t=this.raw_options.brace_style||null;"expand-strict"===t?this.raw_options.brace_style="expand":"collapse-preserve-inline"===t?this.raw_options.brace_style="collapse,preserve-inline":void 0!==this.raw_options.braces_on_own_line&&(this.raw_options.brace_style=this.raw_options.braces_on_own_line?"expand":"collapse");var n=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_preserve_inline=!1,this.brace_style="collapse";for(var s=0;s<n.length;s++)"preserve-inline"===n[s]?this.brace_preserve_inline=!0:this.brace_style=n[s];this.unindent_chained_methods=this._get_boolean("unindent_chained_methods"),this.break_chained_methods=this._get_boolean("break_chained_methods"),this.space_in_paren=this._get_boolean("space_in_paren"),this.space_in_empty_paren=this._get_boolean("space_in_empty_paren"),this.jslint_happy=this._get_boolean("jslint_happy"),this.space_after_anon_function=this._get_boolean("space_after_anon_function"),this.space_after_named_function=this._get_boolean("space_after_named_function"),this.keep_array_indentation=this._get_boolean("keep_array_indentation"),this.space_before_conditional=this._get_boolean("space_before_conditional",!0),this.unescape_strings=this._get_boolean("unescape_strings"),this.e4x=this._get_boolean("e4x"),this.comma_first=this._get_boolean("comma_first"),this.operator_position=this._get_selection("operator_position",r),this.test_output_raw=this._get_boolean("test_output_raw"),this.jslint_happy&&(this.space_after_anon_function=!0)}s.prototype=new i,e.exports.Options=s},function(e){function t(e,t){this.raw_options=n(e,t),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs","\t"===this.indent_char),this.indent_with_tabs&&(this.indent_char="\t",1===this.indent_size&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","angular","django","erb","handlebars","php","smarty"],["auto"])}function n(e,t){var n,r={};for(n in e=i(e))n!==t&&(r[n]=e[n]);if(t&&e[t])for(n in e[t])r[n]=e[t][n];return r}function i(e){var t,n={};for(t in e){n[t.replace(/-/g,"_")]=e[t]}return n}t.prototype._get_array=function(e,t){var n=this.raw_options[e],i=t||[];return"object"==typeof n?null!==n&&"function"==typeof n.concat&&(i=n.concat()):"string"==typeof n&&(i=n.split(/[^a-zA-Z0-9_\/\-]+/)),i},t.prototype._get_boolean=function(e,t){var n=this.raw_options[e];return void 0===n?!!t:!!n},t.prototype._get_characters=function(e,t){var n=this.raw_options[e],i=t||"";return"string"==typeof n&&(i=n.replace(/\\r/,"\r").replace(/\\n/,"\n").replace(/\\t/,"\t")),i},t.prototype._get_number=function(e,t){var n=this.raw_options[e];t=parseInt(t,10),isNaN(t)&&(t=0);var i=parseInt(n,10);return isNaN(i)&&(i=t),i},t.prototype._get_selection=function(e,t,n){var i=this._get_selection_list(e,t,n);if(1!==i.length)throw new Error("Invalid Option Value: The option '"+e+"' can only be one of the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i[0]},t.prototype._get_selection_list=function(e,t,n){if(!t||0===t.length)throw new Error("Selection list cannot be empty.");if(n=n||[t[0]],!this._is_valid_selection(n,t))throw new Error("Invalid Default Value!");var i=this._get_array(e,n);if(!this._is_valid_selection(i,t))throw new Error("Invalid Option Value: The option '"+e+"' can contain only the following values:\n"+t+"\nYou passed in: '"+this.raw_options[e]+"'");return i},t.prototype._is_valid_selection=function(e,t){return e.length&&t.length&&!e.some((function(e){return-1===t.indexOf(e)}))},e.exports.Options=t,e.exports.normalizeOpts=i,e.exports.mergeOpts=n},function(e,t,n){var i=n(8).InputScanner,r=n(9).Tokenizer,s=n(9).TOKEN,a=n(13).Directives,o=n(4),l=n(12).Pattern,c=n(14).TemplatablePattern;function u(e,t){return-1!==t.indexOf(e)}var h={START_EXPR:"TK_START_EXPR",END_EXPR:"TK_END_EXPR",START_BLOCK:"TK_START_BLOCK",END_BLOCK:"TK_END_BLOCK",WORD:"TK_WORD",RESERVED:"TK_RESERVED",SEMICOLON:"TK_SEMICOLON",STRING:"TK_STRING",EQUALS:"TK_EQUALS",OPERATOR:"TK_OPERATOR",COMMA:"TK_COMMA",BLOCK_COMMENT:"TK_BLOCK_COMMENT",COMMENT:"TK_COMMENT",DOT:"TK_DOT",UNKNOWN:"TK_UNKNOWN",START:s.START,RAW:s.RAW,EOF:s.EOF},d=new a(/\/\*/,/\*\//),p=/0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/,f=/[0-9]/,m=/[^\d\.]/,g=">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),_=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";_=(_="\\?\\.(?!\\d) "+(_=_.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"))).replace(/ /g,"|");var y,v=new RegExp(_),b="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),w=b.concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),x=new RegExp("^(?:"+w.join("|")+")$"),k=function(e,t){r.call(this,e,t),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source);var n=new l(this._input),i=new c(this._input).read_options(this._options);this.__patterns={template:i,identifier:i.starting_with(o.identifier).matching(o.identifierMatch),number:n.matching(p),punct:n.matching(v),comment:n.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:n.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:n.matching(/<!--/),html_comment_end:n.matching(/-->/),include:n.starting_with(/#include/).until_after(o.lineBreak),shebang:n.starting_with(/#!/).until_after(o.lineBreak),xml:n.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),single_quote:i.until(/['\\\n\r\u2028\u2029]/),double_quote:i.until(/["\\\n\r\u2028\u2029]/),template_text:i.until(/[`\\$]/),template_expression:i.until(/[`}\\]/)}};(k.prototype=new r)._is_comment=function(e){return e.type===h.COMMENT||e.type===h.BLOCK_COMMENT||e.type===h.UNKNOWN},k.prototype._is_opening=function(e){return e.type===h.START_BLOCK||e.type===h.START_EXPR},k.prototype._is_closing=function(e,t){return(e.type===h.END_BLOCK||e.type===h.END_EXPR)&&t&&("]"===e.text&&"["===t.text||")"===e.text&&"("===t.text||"}"===e.text&&"{"===t.text)},k.prototype._reset=function(){y=!1},k.prototype._get_next_token=function(e,t){var n=null;this._readWhitespace();var i=this._input.peek();return null===i?this._create_token(h.EOF,""):n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n||this._read_non_javascript(i))||this._read_string(i))||this._read_pair(i,this._input.peek(1)))||this._read_word(e))||this._read_singles(i))||this._read_comment(i))||this._read_regexp(i,e))||this._read_xml(i,e))||this._read_punctuation())||this._create_token(h.UNKNOWN,this._input.next())},k.prototype._read_word=function(e){var t;return""!==(t=this.__patterns.identifier.read())?(t=t.replace(o.allLineBreaks,"\n"),e.type!==h.DOT&&(e.type!==h.RESERVED||"set"!==e.text&&"get"!==e.text)&&x.test(t)?"in"!==t&&"of"!==t||e.type!==h.WORD&&e.type!==h.STRING?this._create_token(h.RESERVED,t):this._create_token(h.OPERATOR,t):this._create_token(h.WORD,t)):""!==(t=this.__patterns.number.read())?this._create_token(h.WORD,t):void 0},k.prototype._read_singles=function(e){var t=null;return"("===e||"["===e?t=this._create_token(h.START_EXPR,e):")"===e||"]"===e?t=this._create_token(h.END_EXPR,e):"{"===e?t=this._create_token(h.START_BLOCK,e):"}"===e?t=this._create_token(h.END_BLOCK,e):";"===e?t=this._create_token(h.SEMICOLON,e):"."===e&&m.test(this._input.peek(1))?t=this._create_token(h.DOT,e):","===e&&(t=this._create_token(h.COMMA,e)),t&&this._input.next(),t},k.prototype._read_pair=function(e,t){var n=null;return"#"===e&&"{"===t&&(n=this._create_token(h.START_BLOCK,e+t)),n&&(this._input.next(),this._input.next()),n},k.prototype._read_punctuation=function(){var e=this.__patterns.punct.read();if(""!==e)return"="===e?this._create_token(h.EQUALS,e):"?."===e?this._create_token(h.DOT,e):this._create_token(h.OPERATOR,e)},k.prototype._read_non_javascript=function(e){var t="";if("#"===e){if(this._is_first_token()&&(t=this.__patterns.shebang.read()))return this._create_token(h.UNKNOWN,t.trim()+"\n");if(t=this.__patterns.include.read())return this._create_token(h.UNKNOWN,t.trim()+"\n");e=this._input.next();var n="#";if(this._input.hasNext()&&this._input.testChar(f)){do{n+=e=this._input.next()}while(this._input.hasNext()&&"#"!==e&&"="!==e);return"#"===e||("["===this._input.peek()&&"]"===this._input.peek(1)?(n+="[]",this._input.next(),this._input.next()):"{"===this._input.peek()&&"}"===this._input.peek(1)&&(n+="{}",this._input.next(),this._input.next())),this._create_token(h.WORD,n)}this._input.back()}else if("<"===e&&this._is_first_token()){if(t=this.__patterns.html_comment_start.read()){for(;this._input.hasNext()&&!this._input.testChar(o.newline);)t+=this._input.next();return y=!0,this._create_token(h.COMMENT,t)}}else if(y&&"-"===e&&(t=this.__patterns.html_comment_end.read()))return y=!1,this._create_token(h.COMMENT,t);return null},k.prototype._read_comment=function(e){var t=null;if("/"===e){var n="";if("*"===this._input.peek(1)){n=this.__patterns.block_comment.read();var i=d.get_directives(n);i&&"start"===i.ignore&&(n+=d.readIgnored(this._input)),n=n.replace(o.allLineBreaks,"\n"),(t=this._create_token(h.BLOCK_COMMENT,n)).directives=i}else"/"===this._input.peek(1)&&(n=this.__patterns.comment.read(),t=this._create_token(h.COMMENT,n))}return t},k.prototype._read_string=function(e){if("`"===e||"'"===e||'"'===e){var t=this._input.next();return this.has_char_escapes=!1,t+="`"===e?this._read_string_recursive("`",!0,"${"):this._read_string_recursive(e),this.has_char_escapes&&this._options.unescape_strings&&(t=function(e){var t="",n=0,r=new i(e),s=null;for(;r.hasNext();)if((s=r.match(/([\s]|[^\\]|\\\\)+/g))&&(t+=s[0]),"\\"===r.peek()){if(r.next(),"x"===r.peek())s=r.match(/x([0-9A-Fa-f]{2})/g);else{if("u"!==r.peek()){t+="\\",r.hasNext()&&(t+=r.next());continue}(s=r.match(/u([0-9A-Fa-f]{4})/g))||(s=r.match(/u\{([0-9A-Fa-f]+)\}/g))}if(!s)return e;if((n=parseInt(s[1],16))>126&&n<=255&&0===s[0].indexOf("x"))return e;t+=n>=0&&n<32||n>1114111?"\\"+s[0]:34===n||39===n||92===n?"\\"+String.fromCharCode(n):String.fromCharCode(n)}return t}(t)),this._input.peek()===e&&(t+=this._input.next()),t=t.replace(o.allLineBreaks,"\n"),this._create_token(h.STRING,t)}return null},k.prototype._allow_regexp_or_xml=function(e){return e.type===h.RESERVED&&u(e.text,["return","case","throw","else","do","typeof","yield"])||e.type===h.END_EXPR&&")"===e.text&&e.opened.previous.type===h.RESERVED&&u(e.opened.previous.text,["if","while","for"])||u(e.type,[h.COMMENT,h.START_EXPR,h.START_BLOCK,h.START,h.END_BLOCK,h.OPERATOR,h.EQUALS,h.EOF,h.SEMICOLON,h.COMMA])},k.prototype._read_regexp=function(e,t){if("/"===e&&this._allow_regexp_or_xml(t)){for(var n=this._input.next(),i=!1,r=!1;this._input.hasNext()&&(i||r||this._input.peek()!==e)&&!this._input.testChar(o.newline);)n+=this._input.peek(),i?i=!1:(i="\\"===this._input.peek(),"["===this._input.peek()?r=!0:"]"===this._input.peek()&&(r=!1)),this._input.next();return this._input.peek()===e&&(n+=this._input.next(),n+=this._input.read(o.identifier)),this._create_token(h.STRING,n)}return null},k.prototype._read_xml=function(e,t){if(this._options.e4x&&"<"===e&&this._allow_regexp_or_xml(t)){var n="",i=this.__patterns.xml.read_match();if(i){for(var r=i[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}"),s=0===r.indexOf("{"),a=0;i;){var l=!!i[1],c=i[2];if(!(!!i[i.length-1]||"![CDATA["===c.slice(0,8))&&(c===r||s&&c.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(l?--a:++a),n+=i[0],a<=0)break;i=this.__patterns.xml.read_match()}return i||(n+=this._input.match(/[\s\S]*/g)[0]),n=n.replace(o.allLineBreaks,"\n"),this._create_token(h.STRING,n)}}return null},k.prototype._read_string_recursive=function(e,t,n){var i,r;"'"===e?r=this.__patterns.single_quote:'"'===e?r=this.__patterns.double_quote:"`"===e?r=this.__patterns.template_text:"}"===e&&(r=this.__patterns.template_expression);for(var s=r.read(),a="";this._input.hasNext();){if((a=this._input.next())===e||!t&&o.newline.test(a)){this._input.back();break}"\\"===a&&this._input.hasNext()?("x"===(i=this._input.peek())||"u"===i?this.has_char_escapes=!0:"\r"===i&&"\n"===this._input.peek(1)&&this._input.next(),a+=this._input.next()):n&&("${"===n&&"$"===a&&"{"===this._input.peek()&&(a+=this._input.next()),n===a&&(a+="`"===e?this._read_string_recursive("}",t,"`"):this._read_string_recursive("`",t,"${"),this._input.hasNext()&&(a+=this._input.next()))),s+=a+=r.read()}return s},e.exports.Tokenizer=k,e.exports.TOKEN=h,e.exports.positionable_operators=g.slice(),e.exports.line_starters=b.slice()},function(e){var t=RegExp.prototype.hasOwnProperty("sticky");function n(e){this.__input=e||"",this.__input_length=this.__input.length,this.__position=0}n.prototype.restart=function(){this.__position=0},n.prototype.back=function(){this.__position>0&&(this.__position-=1)},n.prototype.hasNext=function(){return this.__position<this.__input_length},n.prototype.next=function(){var e=null;return this.hasNext()&&(e=this.__input.charAt(this.__position),this.__position+=1),e},n.prototype.peek=function(e){var t=null;return e=e||0,(e+=this.__position)>=0&&e<this.__input_length&&(t=this.__input.charAt(e)),t},n.prototype.__match=function(e,n){e.lastIndex=n;var i=e.exec(this.__input);return!i||t&&e.sticky||i.index!==n&&(i=null),i},n.prototype.test=function(e,t){return t=t||0,(t+=this.__position)>=0&&t<this.__input_length&&!!this.__match(e,t)},n.prototype.testChar=function(e,t){var n=this.peek(t);return e.lastIndex=0,null!==n&&e.test(n)},n.prototype.match=function(e){var t=this.__match(e,this.__position);return t?this.__position+=t[0].length:t=null,t},n.prototype.read=function(e,t,n){var i,r="";return e&&(i=this.match(e))&&(r+=i[0]),!t||!i&&e||(r+=this.readUntil(t,n)),r},n.prototype.readUntil=function(e,t){var n,i=this.__position;e.lastIndex=this.__position;var r=e.exec(this.__input);return r?(i=r.index,t&&(i+=r[0].length)):i=this.__input_length,n=this.__input.substring(this.__position,i),this.__position=i,n},n.prototype.readUntilAfter=function(e){return this.readUntil(e,!0)},n.prototype.get_regexp=function(e,n){var i=null,r="g";return n&&t&&(r="y"),"string"==typeof e&&""!==e?i=new RegExp(e,r):e&&(i=new RegExp(e.source,r)),i},n.prototype.get_literal_regexp=function(e){return RegExp(e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},n.prototype.peekUntilAfter=function(e){var t=this.__position,n=this.readUntilAfter(e);return this.__position=t,n},n.prototype.lookBack=function(e){var t=this.__position-1;return t>=e.length&&this.__input.substring(t-e.length,t).toLowerCase()===e},e.exports.InputScanner=n},function(e,t,n){var i=n(8).InputScanner,r=n(3).Token,s=n(10).TokenStream,a=n(11).WhitespacePattern,o={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},l=function(e,t){this._input=new i(e),this._options=t||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new a(this._input)};l.prototype.tokenize=function(){var e;this._input.restart(),this.__tokens=new s,this._reset();for(var t=new r(o.START,""),n=null,i=[],a=new s;t.type!==o.EOF;){for(e=this._get_next_token(t,n);this._is_comment(e);)a.add(e),e=this._get_next_token(t,n);a.isEmpty()||(e.comments_before=a,a=new s),e.parent=n,this._is_opening(e)?(i.push(n),n=e):n&&this._is_closing(e,n)&&(e.opened=n,n.closed=e,n=i.pop(),e.parent=n),e.previous=t,t.next=e,this.__tokens.add(e),t=e}return this.__tokens},l.prototype._is_first_token=function(){return this.__tokens.isEmpty()},l.prototype._reset=function(){},l.prototype._get_next_token=function(e,t){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(o.RAW,n):this._create_token(o.EOF,"")},l.prototype._is_comment=function(e){return!1},l.prototype._is_opening=function(e){return!1},l.prototype._is_closing=function(e,t){return!1},l.prototype._create_token=function(e,t){return new r(e,t,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},l.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},e.exports.Tokenizer=l,e.exports.TOKEN=o},function(e){function t(e){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=e}t.prototype.restart=function(){this.__position=0},t.prototype.isEmpty=function(){return 0===this.__tokens_length},t.prototype.hasNext=function(){return this.__position<this.__tokens_length},t.prototype.next=function(){var e=null;return this.hasNext()&&(e=this.__tokens[this.__position],this.__position+=1),e},t.prototype.peek=function(e){var t=null;return e=e||0,(e+=this.__position)>=0&&e<this.__tokens_length&&(t=this.__tokens[e]),t},t.prototype.add=function(e){this.__parent_token&&(e.parent=this.__parent_token),this.__tokens.push(e),this.__tokens_length+=1},e.exports.TokenStream=t},function(e,t,n){var i=n(12).Pattern;function r(e,t){i.call(this,e,t),t?this._line_regexp=this._input.get_regexp(t._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}r.prototype=new i,r.prototype.__set_whitespace_patterns=function(e,t){e+="\\t ",t+="\\n\\r",this._match_pattern=this._input.get_regexp("["+e+t+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+t+"]")},r.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var e=this._input.read(this._match_pattern);if(" "===e)this.whitespace_before_token=" ";else if(e){var t=this.__split(this._newline_regexp,e);this.newline_count=t.length-1,this.whitespace_before_token=t[this.newline_count]}return e},r.prototype.matching=function(e,t){var n=this._create();return n.__set_whitespace_patterns(e,t),n._update(),n},r.prototype._create=function(){return new r(this._input,this)},r.prototype.__split=function(e,t){e.lastIndex=0;for(var n=0,i=[],r=e.exec(t);r;)i.push(t.substring(n,r.index)),n=r.index+r[0].length,r=e.exec(t);return n<t.length?i.push(t.substring(n,t.length)):i.push(""),i},e.exports.WhitespacePattern=r},function(e){function t(e,t){this._input=e,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,t&&(this._starting_pattern=this._input.get_regexp(t._starting_pattern,!0),this._match_pattern=this._input.get_regexp(t._match_pattern,!0),this._until_pattern=this._input.get_regexp(t._until_pattern),this._until_after=t._until_after)}t.prototype.read=function(){var e=this._input.read(this._starting_pattern);return this._starting_pattern&&!e||(e+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),e},t.prototype.read_match=function(){return this._input.match(this._match_pattern)},t.prototype.until_after=function(e){var t=this._create();return t._until_after=!0,t._until_pattern=this._input.get_regexp(e),t._update(),t},t.prototype.until=function(e){var t=this._create();return t._until_after=!1,t._until_pattern=this._input.get_regexp(e),t._update(),t},t.prototype.starting_with=function(e){var t=this._create();return t._starting_pattern=this._input.get_regexp(e,!0),t._update(),t},t.prototype.matching=function(e){var t=this._create();return t._match_pattern=this._input.get_regexp(e,!0),t._update(),t},t.prototype._create=function(){return new t(this._input,this)},t.prototype._update=function(){},e.exports.Pattern=t},function(e){function t(e,t){e="string"==typeof e?e:e.source,t="string"==typeof t?t:t.source,this.__directives_block_pattern=new RegExp(e+/ beautify( \w+[:]\w+)+ /.source+t,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(e+/\sbeautify\signore:end\s/.source+t,"g")}t.prototype.get_directives=function(e){if(!e.match(this.__directives_block_pattern))return null;var t={};this.__directive_pattern.lastIndex=0;for(var n=this.__directive_pattern.exec(e);n;)t[n[1]]=n[2],n=this.__directive_pattern.exec(e);return t},t.prototype.readIgnored=function(e){return e.readUntilAfter(this.__directives_end_ignore_pattern)},e.exports.Directives=t},function(e,t,n){var i=n(12).Pattern,r={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1,angular:!1};function s(e,t){i.call(this,e,t),this.__template_pattern=null,this._disabled=Object.assign({},r),this._excluded=Object.assign({},r),t&&(this.__template_pattern=this._input.get_regexp(t.__template_pattern),this._excluded=Object.assign(this._excluded,t._excluded),this._disabled=Object.assign(this._disabled,t._disabled));var n=new i(e);this.__patterns={handlebars_comment:n.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:n.starting_with(/{{{/).until_after(/}}}/),handlebars:n.starting_with(/{{/).until_after(/}}/),php:n.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:n.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:n.starting_with(/{%/).until_after(/%}/),django_value:n.starting_with(/{{/).until_after(/}}/),django_comment:n.starting_with(/{#/).until_after(/#}/),smarty:n.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:n.starting_with(/{\*/).until_after(/\*}/),smarty_literal:n.starting_with(/{literal}/).until_after(/{\/literal}/)}}s.prototype=new i,s.prototype._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(e){var t=this._create();return t._disabled[e]=!0,t._update(),t},s.prototype.read_options=function(e){var t=this._create();for(var n in r)t._disabled[n]=-1===e.templating.indexOf(n);return t._update(),t},s.prototype.exclude=function(e){var t=this._create();return t._excluded[e]=!0,t._update(),t},s.prototype.read=function(){var e="";e=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern);for(var t=this._read_template();t;)this._match_pattern?t+=this._input.read(this._match_pattern):t+=this._input.readUntil(this.__template_pattern),e+=t,t=this._read_template();return this._until_after&&(e+=this._input.readUntilAfter(this._until_pattern)),e},s.prototype.__set_templated_pattern=function(){var e=[];this._disabled.php||e.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||e.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.angular||e.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||e.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(e.push(this.__patterns.django._starting_pattern.source),e.push(this.__patterns.django_value._starting_pattern.source),e.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||e.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&e.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+e.join("|")+")")},s.prototype._read_template=function(){var e="",t=this._input.peek();if("<"===t){var n=this._input.peek(1);this._disabled.php||this._excluded.php||"?"!==n||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==n||(e=e||this.__patterns.erb.read())}else"{"===t&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()),this._excluded.django||(e=(e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=(e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read()));return e},e.exports.TemplatablePattern=s}],t={};var n=function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}(0);i=n}();var r=i;void 0===(n=function(){return{js_beautify:r}}.apply(t,[]))||(e.exports=n)}()},32834:function(e){e.exports=function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function t(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function r(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=n(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s={exports:{}};function a(){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 o(e){s.exports.defaults=e}s.exports={defaults:a(),getDefaults:a,changeDefaults:o};var l=/[&<>"']/,c=/[&<>"']/g,u=/[<>"']|&(?!#?\w+;)/,h=/[<>"']|&(?!#?\w+;)/g,d={"&":"&","<":"<",">":">",'"':""","'":"'"},p=function(e){return d[e]};function f(e,t){if(t){if(l.test(e))return e.replace(c,p)}else if(u.test(e))return e.replace(h,p);return e}var m=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function g(e){return e.replace(m,(function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""}))}var _=/(^|[^\[])\^/g;function y(e,t){e=e.source||e,t=t||"";var n={replace:function(t,i){return i=(i=i.source||i).replace(_,"$1"),e=e.replace(t,i),n},getRegex:function(){return new RegExp(e,t)}};return n}var v=/[^\w:]/g,b=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function w(e,t,n){if(e){var i;try{i=decodeURIComponent(g(n)).replace(v,"").toLowerCase()}catch(e){return null}if(0===i.indexOf("javascript:")||0===i.indexOf("vbscript:")||0===i.indexOf("data:"))return null}t&&!b.test(n)&&(n=T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}var x={},k=/^[^:]+:\/*[^/]*$/,S=/^([^:]+:)[\s\S]*$/,E=/^([^:]+:\/*[^/]*)[\s\S]*$/;function T(e,t){x[" "+e]||(k.test(e)?x[" "+e]=e+"/":x[" "+e]=A(e,"/",!0));var n=-1===(e=x[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(S,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(E,"$1")+t:e+t}function C(e){for(var t,n,i=1;i<arguments.length;i++)for(n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function L(e,t){var n=e.replace(/\|/g,(function(e,t,n){for(var i=!1,r=t;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"})).split(/ \|/),i=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n}function A(e,t,n){var i=e.length;if(0===i)return"";for(var r=0;r<i;){var s=e.charAt(i-r-1);if(s!==t||n){if(s===t||!n)break;r++}else r++}return e.substr(0,i-r)}function D(e,t){if(-1===e.indexOf(t[1]))return-1;for(var n=e.length,i=0,r=0;r<n;r++)if("\\"===e[r])r++;else if(e[r]===t[0])i++;else if(e[r]===t[1]&&--i<0)return r;return-1}function M(e){e&&e.sanitize&&!e.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")}function R(e,t){if(t<1)return"";for(var n="";t>1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}var I={escape:f,unescape:g,edit:y,cleanUrl:w,resolveUrl:T,noopTest:{exec:function(){}},merge:C,splitCells:L,rtrim:A,findClosingBracket:D,checkSanitizeDeprecation:M,repeatString:R},P=s.exports.defaults,O=I.rtrim,F=I.splitCells,N=I.escape,B=I.findClosingBracket;function $(e,t,n){var i=t.href,r=t.title?N(t.title):null,s=e[1].replace(/\\([\[\]])/g,"$1");return"!"!==e[0].charAt(0)?{type:"link",raw:n,href:i,title:r,text:s}:{type:"image",raw:n,href:i,title:r,text:N(s)}}function K(e,t){var n=e.match(/^(\s+)(?:```)/);if(null===n)return t;var i=n[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:t[0].length>=i.length?e.slice(i.length):e})).join("\n")}var U=function(){function e(e){this.options=e||P}var t=e.prototype;return t.space=function(e){var t=this.rules.block.newline.exec(e);if(t)return t[0].length>1?{type:"space",raw:t[0]}:{raw:"\n"}},t.code=function(e){var t=this.rules.block.code.exec(e);if(t){var n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:O(n,"\n")}}},t.fences=function(e){var t=this.rules.block.fences.exec(e);if(t){var n=t[0],i=K(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim():t[2],text:i}}},t.heading=function(e){var t=this.rules.block.heading.exec(e);if(t){var n=t[2].trim();if(/#$/.test(n)){var i=O(n,"#");this.options.pedantic?n=i.trim():i&&!/ $/.test(i)||(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n}}},t.nptable=function(e){var t=this.rules.block.nptable.exec(e);if(t){var n={type:"table",header:F(t[1].replace(/^ *| *\| *$/g,"")),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:t[3]?t[3].replace(/\n$/,"").split("\n"):[],raw:t[0]};if(n.header.length===n.align.length){var i,r=n.align.length;for(i=0;i<r;i++)/^ *-+: *$/.test(n.align[i])?n.align[i]="right":/^ *:-+: *$/.test(n.align[i])?n.align[i]="center":/^ *:-+ *$/.test(n.align[i])?n.align[i]="left":n.align[i]=null;for(r=n.cells.length,i=0;i<r;i++)n.cells[i]=F(n.cells[i],n.header.length);return n}}},t.hr=function(e){var t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}},t.blockquote=function(e){var t=this.rules.block.blockquote.exec(e);if(t){var n=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],text:n}}},t.list=function(e){var t=this.rules.block.list.exec(e);if(t){var n,i,r,s,a,o,l,c,u,h=t[0],d=t[2],p=d.length>1,f={type:"list",raw:h,ordered:p,start:p?+d.slice(0,-1):"",loose:!1,items:[]},m=t[0].match(this.rules.block.item),g=!1,_=m.length;r=this.rules.block.listItemStart.exec(m[0]);for(var y=0;y<_;y++){if(h=n=m[y],this.options.pedantic||(u=n.match(new RegExp("\\n\\s*\\n {0,"+(r[0].length-1)+"}\\S")))&&(a=n.length-u.index+m.slice(y+1).join("\n").length,f.raw=f.raw.substring(0,f.raw.length-a),h=n=n.substring(0,u.index),_=y+1),y!==_-1){if(s=this.rules.block.listItemStart.exec(m[y+1]),this.options.pedantic?s[1].length>r[1].length:s[1].length>=r[0].length||s[1].length>3){m.splice(y,2,m[y]+(!this.options.pedantic&&s[1].length<r[0].length&&!m[y].match(/\n$/)?"":"\n")+m[y+1]),y--,_--;continue}(!this.options.pedantic||this.options.smartLists?s[2][s[2].length-1]!==d[d.length-1]:p===(1===s[2].length))&&(a=m.slice(y+1).join("\n").length,f.raw=f.raw.substring(0,f.raw.length-a),y=_-1),r=s}i=n.length,~(n=n.replace(/^ *([*+-]|\d+[.)]) ?/,"")).indexOf("\n ")&&(i-=n.length,n=this.options.pedantic?n.replace(/^ {1,4}/gm,""):n.replace(new RegExp("^ {1,"+i+"}","gm"),"")),n=O(n,"\n"),y!==_-1&&(h+="\n"),o=g||/\n\n(?!\s*$)/.test(h),y!==_-1&&(g="\n\n"===h.slice(-2),o||(o=g)),o&&(f.loose=!0),this.options.gfm&&(c=void 0,(l=/^\[[ xX]\] /.test(n))&&(c=" "!==n[1],n=n.replace(/^\[[ xX]\] +/,""))),f.items.push({type:"list_item",raw:h,task:l,checked:c,loose:o,text:n})}return f}},t.html=function(e){var t=this.rules.block.html.exec(e);if(t)return{type:this.options.sanitize?"paragraph":"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):N(t[0]):t[0]}},t.def=function(e){var t=this.rules.block.def.exec(e);if(t)return t[3]&&(t[3]=t[3].substring(1,t[3].length-1)),{type:"def",tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}},t.table=function(e){var t=this.rules.block.table.exec(e);if(t){var n={type:"table",header:F(t[1].replace(/^ *| *\| *$/g,"")),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:t[3]?t[3].replace(/\n$/,"").split("\n"):[]};if(n.header.length===n.align.length){n.raw=t[0];var i,r=n.align.length;for(i=0;i<r;i++)/^ *-+: *$/.test(n.align[i])?n.align[i]="right":/^ *:-+: *$/.test(n.align[i])?n.align[i]="center":/^ *:-+ *$/.test(n.align[i])?n.align[i]="left":n.align[i]=null;for(r=n.cells.length,i=0;i<r;i++)n.cells[i]=F(n.cells[i].replace(/^ *\| *| *\| *$/g,""),n.header.length);return n}}},t.lheading=function(e){var t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1]}},t.paragraph=function(e){var t=this.rules.block.paragraph.exec(e);if(t)return{type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1]}},t.text=function(e){var t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0]}},t.escape=function(e){var t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:N(t[1])}},t.tag=function(e,t,n){var i=this.rules.inline.tag.exec(e);if(i)return!t&&/^<a /i.test(i[0])?t=!0:t&&/^<\/a>/i.test(i[0])&&(t=!1),!n&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?n=!0:n&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(n=!1),{type:this.options.sanitize?"text":"html",raw:i[0],inLink:t,inRawBlock:n,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):N(i[0]):i[0]}},t.link=function(e){var t=this.rules.inline.link.exec(e);if(t){var n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;var i=O(n.slice(0,-1),"\\");if((n.length-i.length)%2==0)return}else{var r=B(t[2],"()");if(r>-1){var s=(0===t[0].indexOf("!")?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,s).trim(),t[3]=""}}var a=t[2],o="";if(this.options.pedantic){var l=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(a);l&&(a=l[1],o=l[3])}else o=t[3]?t[3].slice(1,-1):"";return a=a.trim(),/^</.test(a)&&(a=this.options.pedantic&&!/>$/.test(n)?a.slice(1):a.slice(1,-1)),$(t,{href:a?a.replace(this.rules.inline._escapes,"$1"):a,title:o?o.replace(this.rules.inline._escapes,"$1"):o},t[0])}},t.reflink=function(e,t){var n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){var i=(n[2]||n[1]).replace(/\s+/g," ");if(!(i=t[i.toLowerCase()])||!i.href){var r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return $(n,i,n[0])}},t.emStrong=function(e,t,n){void 0===n&&(n="");var i=this.rules.inline.emStrong.lDelim.exec(e);if(i&&(!i[3]||!n.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/))){var r=i[1]||i[2]||"";if(!r||r&&(""===n||this.rules.inline.punctuation.exec(n))){var s,a,o=i[0].length-1,l=o,c=0,u="*"===i[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+o);null!=(i=u.exec(t));)if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6])if(a=s.length,i[3]||i[4])l+=a;else if(!((i[5]||i[6])&&o%3)||(o+a)%3){if(!((l-=a)>0))return a=Math.min(a,a+l+c),Math.min(o,a)%2?{type:"em",raw:e.slice(0,o+i.index+a+1),text:e.slice(1,o+i.index+a)}:{type:"strong",raw:e.slice(0,o+i.index+a+1),text:e.slice(2,o+i.index+a-1)}}else c+=a}}},t.codespan=function(e){var t=this.rules.inline.code.exec(e);if(t){var n=t[2].replace(/\n/g," "),i=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return i&&r&&(n=n.substring(1,n.length-1)),n=N(n,!0),{type:"codespan",raw:t[0],text:n}}},t.br=function(e){var t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}},t.del=function(e){var t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2]}},t.autolink=function(e,t){var n,i,r=this.rules.inline.autolink.exec(e);if(r)return i="@"===r[2]?"mailto:"+(n=N(this.options.mangle?t(r[1]):r[1])):n=N(r[1]),{type:"link",raw:r[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}},t.url=function(e,t){var n;if(n=this.rules.inline.url.exec(e)){var i,r;if("@"===n[2])r="mailto:"+(i=N(this.options.mangle?t(n[0]):n[0]));else{var s;do{s=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(s!==n[0]);i=N(n[0]),r="www."===n[1]?"http://"+i:i}return{type:"link",raw:n[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}},t.inlineText=function(e,t,n){var i,r=this.rules.inline.text.exec(e);if(r)return i=t?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):N(r[0]):r[0]:N(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}},e}(),z=I.noopTest,V=I.edit,q=I.merge,G={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\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})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\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 *)+\\n|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:z,table:z,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};G.def=V(G.def).replace("label",G._label).replace("title",G._title).getRegex(),G.bullet=/(?:[*+-]|\d{1,9}[.)])/,G.item=/^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/,G.item=V(G.item,"gm").replace(/bull/g,G.bullet).getRegex(),G.listItemStart=V(/^( *)(bull) */).replace("bull",G.bullet).getRegex(),G.list=V(G.list).replace(/bull/g,G.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+G.def.source+")").getRegex(),G._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",G._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,G.html=V(G.html,"i").replace("comment",G._comment).replace("tag",G._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),G.paragraph=V(G._paragraph).replace("hr",G.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",G._tag).getRegex(),G.blockquote=V(G.blockquote).replace("paragraph",G.paragraph).getRegex(),G.normal=q({},G),G.gfm=q({},G.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n {0,3}([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n {0,3}\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),G.gfm.nptable=V(G.gfm.nptable).replace("hr",G.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",G._tag).getRegex(),G.gfm.table=V(G.gfm.table).replace("hr",G.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",G._tag).getRegex(),G.pedantic=q({},G.normal,{html:V("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",G._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+|$)/,fences:z,paragraph:V(G.normal._paragraph).replace("hr",G.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",G.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var H={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:z,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(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/\_\_[^_*]*?\*[^_*]*?\_\_|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/\*\*[^_*]*?\_[^_*]*?\*\*|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:z,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};H.punctuation=V(H.punctuation).replace(/punctuation/g,H._punctuation).getRegex(),H.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,H.escapedEmSt=/\\\*|\\_/g,H._comment=V(G._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),H.emStrong.lDelim=V(H.emStrong.lDelim).replace(/punct/g,H._punctuation).getRegex(),H.emStrong.rDelimAst=V(H.emStrong.rDelimAst,"g").replace(/punct/g,H._punctuation).getRegex(),H.emStrong.rDelimUnd=V(H.emStrong.rDelimUnd,"g").replace(/punct/g,H._punctuation).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=V(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=V(H.tag).replace("comment",H._comment).replace("attribute",H._attribute).getRegex(),H._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,H._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,H._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,H.link=V(H.link).replace("label",H._label).replace("href",H._href).replace("title",H._title).getRegex(),H.reflink=V(H.reflink).replace("label",H._label).getRegex(),H.reflinkSearch=V(H.reflinkSearch,"g").replace("reflink",H.reflink).replace("nolink",H.nolink).getRegex(),H.normal=q({},H),H.pedantic=q({},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:V(/^!?\[(label)\]\((.*?)\)/).replace("label",H._label).getRegex(),reflink:V(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",H._label).getRegex()}),H.gfm=q({},H.normal,{escape:V(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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),H.gfm.url=V(H.gfm.url,"i").replace("email",H.gfm._extended_email).getRegex(),H.breaks=q({},H.gfm,{br:V(H.br).replace("{2,}","*").getRegex(),text:V(H.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var j={block:G,inline:H},W=U,Z=s.exports.defaults,Y=j.block,X=j.inline,J=I.repeatString;function Q(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function ee(e){var t,n,i="",r=e.length;for(t=0;t<r;t++)n=e.charCodeAt(t),Math.random()>.5&&(n="x"+n.toString(16)),i+="&#"+n+";";return i}var te=function(){function e(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Z,this.options.tokenizer=this.options.tokenizer||new W,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var t={block:Y.normal,inline:X.normal};this.options.pedantic?(t.block=Y.pedantic,t.inline=X.pedantic):this.options.gfm&&(t.block=Y.gfm,this.options.breaks?t.inline=X.breaks:t.inline=X.gfm),this.tokenizer.rules=t}e.lex=function(t,n){return new e(n).lex(t)},e.lexInline=function(t,n){return new e(n).inlineTokens(t)};var n=e.prototype;return n.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens,!0),this.inline(this.tokens),this.tokens},n.blockTokens=function(e,t,n){var i,r,s,a;for(void 0===t&&(t=[]),void 0===n&&(n=!0),this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),i.type&&t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),(a=t[t.length-1])&&"paragraph"===a.type?(a.raw+="\n"+i.raw,a.text+="\n"+i.text):t.push(i);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.nptable(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),i.tokens=this.blockTokens(i.text,[],n),t.push(i);else if(i=this.tokenizer.list(e)){for(e=e.substring(i.raw.length),s=i.items.length,r=0;r<s;r++)i.items[r].tokens=this.blockTokens(i.items[r].text,[],!1);t.push(i)}else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(n&&(i=this.tokenizer.def(e)))e=e.substring(i.raw.length),this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else if(n&&(i=this.tokenizer.paragraph(e)))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),(a=t[t.length-1])&&"text"===a.type?(a.raw+="\n"+i.raw,a.text+="\n"+i.text):t.push(i);else if(e){var o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}throw new Error(o)}return t},n.inline=function(e){var t,n,i,r,s,a,o=e.length;for(t=0;t<o;t++)switch((a=e[t]).type){case"paragraph":case"text":case"heading":a.tokens=[],this.inlineTokens(a.text,a.tokens);break;case"table":for(a.tokens={header:[],cells:[]},r=a.header.length,n=0;n<r;n++)a.tokens.header[n]=[],this.inlineTokens(a.header[n],a.tokens.header[n]);for(r=a.cells.length,n=0;n<r;n++)for(s=a.cells[n],a.tokens.cells[n]=[],i=0;i<s.length;i++)a.tokens.cells[n][i]=[],this.inlineTokens(s[i],a.tokens.cells[n][i]);break;case"blockquote":this.inline(a.tokens);break;case"list":for(r=a.items.length,n=0;n<r;n++)this.inline(a.items[n].tokens)}return e},n.inlineTokens=function(e,t,n,i){var r,s;void 0===t&&(t=[]),void 0===n&&(n=!1),void 0===i&&(i=!1);var a,o,l,c=e;if(this.tokens.links){var u=Object.keys(this.tokens.links);if(u.length>0)for(;null!=(a=this.tokenizer.rules.inline.reflinkSearch.exec(c));)u.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(c=c.slice(0,a.index)+"["+J("a",a[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(a=this.tokenizer.rules.inline.blockSkip.exec(c));)c=c.slice(0,a.index)+"["+J("a",a[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(a=this.tokenizer.rules.inline.escapedEmSt.exec(c));)c=c.slice(0,a.index)+"++"+c.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(o||(l=""),o=!1,r=this.tokenizer.escape(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.tag(e,n,i)){e=e.substring(r.raw.length),n=r.inLink,i=r.inRawBlock;var h=t[t.length-1];h&&"text"===r.type&&"text"===h.type?(h.raw+=r.raw,h.text+=r.text):t.push(r)}else if(r=this.tokenizer.link(e))e=e.substring(r.raw.length),"link"===r.type&&(r.tokens=this.inlineTokens(r.text,[],!0,i)),t.push(r);else if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);var d=t[t.length-1];"link"===r.type?(r.tokens=this.inlineTokens(r.text,[],!0,i),t.push(r)):d&&"text"===r.type&&"text"===d.type?(d.raw+=r.raw,d.text+=r.text):t.push(r)}else if(r=this.tokenizer.emStrong(e,c,l))e=e.substring(r.raw.length),r.tokens=this.inlineTokens(r.text,[],n,i),t.push(r);else if(r=this.tokenizer.codespan(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.br(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.del(e))e=e.substring(r.raw.length),r.tokens=this.inlineTokens(r.text,[],n,i),t.push(r);else if(r=this.tokenizer.autolink(e,ee))e=e.substring(r.raw.length),t.push(r);else if(n||!(r=this.tokenizer.url(e,ee))){if(r=this.tokenizer.inlineText(e,i,Q))e=e.substring(r.raw.length),"_"!==r.raw.slice(-1)&&(l=r.raw.slice(-1)),o=!0,(s=t[t.length-1])&&"text"===s.type?(s.raw+=r.raw,s.text+=r.text):t.push(r);else if(e){var p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}throw new Error(p)}}else e=e.substring(r.raw.length),t.push(r);return t},t(e,null,[{key:"rules",get:function(){return{block:Y,inline:X}}}]),e}(),ne=s.exports.defaults,ie=I.cleanUrl,re=I.escape,se=function(){function e(e){this.options=e||ne}var t=e.prototype;return t.code=function(e,t,n){var i=(t||"").match(/\S*/)[0];if(this.options.highlight){var r=this.options.highlight(e,i);null!=r&&r!==e&&(n=!0,e=r)}return e=e.replace(/\n$/,"")+"\n",i?'<pre><code class="'+this.options.langPrefix+re(i,!0)+'">'+(n?e:re(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:re(e,!0))+"</code></pre>\n"},t.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},t.html=function(e){return e},t.heading=function(e,t,n,i){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+i.slug(n)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},t.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},t.list=function(e,t,n){var i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+i+">\n"},t.listitem=function(e){return"<li>"+e+"</li>\n"},t.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},t.paragraph=function(e){return"<p>"+e+"</p>\n"},t.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"},t.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},t.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},t.strong=function(e){return"<strong>"+e+"</strong>"},t.em=function(e){return"<em>"+e+"</em>"},t.codespan=function(e){return"<code>"+e+"</code>"},t.br=function(){return this.options.xhtml?"<br/>":"<br>"},t.del=function(e){return"<del>"+e+"</del>"},t.link=function(e,t,n){if(null===(e=ie(this.options.sanitize,this.options.baseUrl,e)))return n;var i='<a href="'+re(e)+'"';return t&&(i+=' title="'+t+'"'),i+=">"+n+"</a>"},t.image=function(e,t,n){if(null===(e=ie(this.options.sanitize,this.options.baseUrl,e)))return n;var i='<img src="'+e+'" alt="'+n+'"';return t&&(i+=' title="'+t+'"'),i+=this.options.xhtml?"/>":">"},t.text=function(e){return e},e}(),ae=function(){function e(){}var t=e.prototype;return t.strong=function(e){return e},t.em=function(e){return e},t.codespan=function(e){return e},t.del=function(e){return e},t.html=function(e){return e},t.text=function(e){return e},t.link=function(e,t,n){return""+n},t.image=function(e,t,n){return""+n},t.br=function(){return""},e}(),oe=function(){function e(){this.seen={}}var t=e.prototype;return t.serialize=function(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},t.getNextSafeSlug=function(e,t){var n=e,i=0;if(this.seen.hasOwnProperty(n)){i=this.seen[e];do{n=e+"-"+ ++i}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=i,this.seen[n]=0),n},t.slug=function(e,t){void 0===t&&(t={});var n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)},e}(),le=se,ce=ae,ue=oe,he=s.exports.defaults,de=I.unescape,pe=te,fe=function(){function e(e){this.options=e||he,this.options.renderer=this.options.renderer||new le,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ce,this.slugger=new ue}e.parse=function(t,n){return new e(n).parse(t)},e.parseInline=function(t,n){return new e(n).parseInline(t)};var t=e.prototype;return t.parse=function(e,t){void 0===t&&(t=!0);var n,i,r,s,a,o,l,c,u,h,d,p,f,m,g,_,y,v,b="",w=e.length;for(n=0;n<w;n++)switch((h=e[n]).type){case"space":continue;case"hr":b+=this.renderer.hr();continue;case"heading":b+=this.renderer.heading(this.parseInline(h.tokens),h.depth,de(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue;case"code":b+=this.renderer.code(h.text,h.lang,h.escaped);continue;case"table":for(c="",l="",s=h.header.length,i=0;i<s;i++)l+=this.renderer.tablecell(this.parseInline(h.tokens.header[i]),{header:!0,align:h.align[i]});for(c+=this.renderer.tablerow(l),u="",s=h.cells.length,i=0;i<s;i++){for(l="",a=(o=h.tokens.cells[i]).length,r=0;r<a;r++)l+=this.renderer.tablecell(this.parseInline(o[r]),{header:!1,align:h.align[r]});u+=this.renderer.tablerow(l)}b+=this.renderer.table(c,u);continue;case"blockquote":u=this.parse(h.tokens),b+=this.renderer.blockquote(u);continue;case"list":for(d=h.ordered,p=h.start,f=h.loose,s=h.items.length,u="",i=0;i<s;i++)_=(g=h.items[i]).checked,y=g.task,m="",g.task&&(v=this.renderer.checkbox(_),f?g.tokens.length>0&&"text"===g.tokens[0].type?(g.tokens[0].text=v+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&"text"===g.tokens[0].tokens[0].type&&(g.tokens[0].tokens[0].text=v+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:v}):m+=v),m+=this.parse(g.tokens,f),u+=this.renderer.listitem(m,y,_);b+=this.renderer.list(u,d,p);continue;case"html":b+=this.renderer.html(h.text);continue;case"paragraph":b+=this.renderer.paragraph(this.parseInline(h.tokens));continue;case"text":for(u=h.tokens?this.parseInline(h.tokens):h.text;n+1<w&&"text"===e[n+1].type;)u+="\n"+((h=e[++n]).tokens?this.parseInline(h.tokens):h.text);b+=t?this.renderer.paragraph(u):u;continue;default:var x='Token with "'+h.type+'" type was not found.';if(this.options.silent)return void console.error(x);throw new Error(x)}return b},t.parseInline=function(e,t){t=t||this.renderer;var n,i,r="",s=e.length;for(n=0;n<s;n++)switch((i=e[n]).type){case"escape":case"text":r+=t.text(i.text);break;case"html":r+=t.html(i.text);break;case"link":r+=t.link(i.href,i.title,this.parseInline(i.tokens,t));break;case"image":r+=t.image(i.href,i.title,i.text);break;case"strong":r+=t.strong(this.parseInline(i.tokens,t));break;case"em":r+=t.em(this.parseInline(i.tokens,t));break;case"codespan":r+=t.codespan(i.text);break;case"br":r+=t.br();break;case"del":r+=t.del(this.parseInline(i.tokens,t));break;default:var a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return void console.error(a);throw new Error(a)}return r},e}(),me=U,ge=se,_e=ae,ye=oe,ve=I.merge,be=I.checkSanitizeDeprecation,we=I.escape,xe=s.exports.getDefaults,ke=s.exports.changeDefaults,Se=s.exports.defaults;function Ee(e,t,n){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(n=t,t=null),t=ve({},Ee.defaults,t||{}),be(t),n){var i,r=t.highlight;try{i=pe.lex(e,t)}catch(e){return n(e)}var s=function(e){var s;if(!e)try{t.walkTokens&&Ee.walkTokens(i,t.walkTokens),s=fe.parse(i,t)}catch(t){e=t}return t.highlight=r,e?n(e):n(null,s)};if(!r||r.length<3)return s();if(delete t.highlight,!i.length)return s();var a=0;return Ee.walkTokens(i,(function(e){"code"===e.type&&(a++,setTimeout((function(){r(e.text,e.lang,(function(t,n){if(t)return s(t);null!=n&&n!==e.text&&(e.text=n,e.escaped=!0),0==--a&&s()}))}),0))})),void(0===a&&s())}try{var o=pe.lex(e,t);return t.walkTokens&&Ee.walkTokens(o,t.walkTokens),fe.parse(o,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+we(e.message+"",!0)+"</pre>";throw e}}return Ee.options=Ee.setOptions=function(e){return ve(Ee.defaults,e),ke(Ee.defaults),Ee},Ee.getDefaults=xe,Ee.defaults=Se,Ee.use=function(e){var t=ve({},e);if(e.renderer&&function(){var n=Ee.defaults.renderer||new ge,i=function(t){var i=n[t];n[t]=function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];var o=e.renderer[t].apply(n,s);return!1===o&&(o=i.apply(n,s)),o}};for(var r in e.renderer)i(r);t.renderer=n}(),e.tokenizer&&function(){var n=Ee.defaults.tokenizer||new me,i=function(t){var i=n[t];n[t]=function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];var o=e.tokenizer[t].apply(n,s);return!1===o&&(o=i.apply(n,s)),o}};for(var r in e.tokenizer)i(r);t.tokenizer=n}(),e.walkTokens){var n=Ee.defaults.walkTokens;t.walkTokens=function(t){e.walkTokens(t),n&&n(t)}}Ee.setOptions(t)},Ee.walkTokens=function(e,t){for(var n,i=r(e);!(n=i()).done;){var s=n.value;switch(t(s),s.type){case"table":for(var a,o=r(s.tokens.header);!(a=o()).done;){var l=a.value;Ee.walkTokens(l,t)}for(var c,u=r(s.tokens.cells);!(c=u()).done;)for(var h,d=r(c.value);!(h=d()).done;){var p=h.value;Ee.walkTokens(p,t)}break;case"list":Ee.walkTokens(s.items,t);break;default:s.tokens&&Ee.walkTokens(s.tokens,t)}}},Ee.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");t=ve({},Ee.defaults,t||{}),be(t);try{var n=pe.lexInline(e,t);return t.walkTokens&&Ee.walkTokens(n,t.walkTokens),fe.parseInline(n,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+we(e.message+"",!0)+"</pre>";throw e}},Ee.Parser=fe,Ee.parser=fe.parse,Ee.Renderer=ge,Ee.TextRenderer=_e,Ee.Lexer=pe,Ee.lexer=pe.lex,Ee.Tokenizer=me,Ee.Slugger=ye,Ee.parse=Ee,Ee}()},11690:function(e){const t=/[&<>"']/,n=/[&<>"']/g,i=/[<>"']|&(?!#?\w+;)/,r=/[<>"']|&(?!#?\w+;)/g,s={"&":"&","<":"<",">":">",'"':""","'":"'"},a=e=>s[e];const o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function l(e){return e.replace(o,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const c=/(^|[^\[])\^/g;const u=/[^\w:]/g,h=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;const d={},p=/^[^:]+:\/*[^/]*$/,f=/^([^:]+:)[\s\S]*$/,m=/^([^:]+:\/*[^/]*)[\s\S]*$/;function g(e,t){d[" "+e]||(p.test(e)?d[" "+e]=e+"/":d[" "+e]=_(e,"/",!0));const n=-1===(e=d[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(f,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(m,"$1")+t:e+t}function _(e,t,n){const i=e.length;if(0===i)return"";let r=0;for(;r<i;){const s=e.charAt(i-r-1);if(s!==t||n){if(s===t||!n)break;r++}else r++}return e.substr(0,i-r)}e.exports={escape:function(e,s){if(s){if(t.test(e))return e.replace(n,a)}else if(i.test(e))return e.replace(r,a);return e},unescape:l,edit:function(e,t){e=e.source||e,t=t||"";const n={replace:(t,i)=>(i=(i=i.source||i).replace(c,"$1"),e=e.replace(t,i),n),getRegex:()=>new RegExp(e,t)};return n},cleanUrl:function(e,t,n){if(e){let e;try{e=decodeURIComponent(l(n)).replace(u,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!h.test(n)&&(n=g(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n},resolveUrl:g,noopTest:{exec:function(){}},merge:function(e){let t,n,i=1;for(;i<arguments.length;i++)for(n in t=arguments[i],t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},splitCells:function(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let i=!1,r=t;for(;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"})).split(/ \|/);let i=0;if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n},rtrim:_,findClosingBracket:function(e,t){if(-1===e.indexOf(t[1]))return-1;const n=e.length;let i=0,r=0;for(;r<n;r++)if("\\"===e[r])r++;else if(e[r]===t[0])i++;else if(e[r]===t[1]&&(i--,i<0))return r;return-1},checkSanitizeDeprecation:function(e){e&&e.sanitize&&!e.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")},repeatString:function(e,t){if(t<1)return"";let n="";for(;t>1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}}},75918:function(e,t,n){"use strict";n.d(t,{Wi:function(){return l},Z0:function(){return c},aU:function(){return o},eZ:function(){return h},wY:function(){return u}});var i=n(4348),r=n(69323),s=n(13268),a=function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function a(e){try{l(i.next(e))}catch(e){s(e)}}function o(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((i=i.apply(e,t||[])).next())}))};class o extends r.JT{constructor(e,t="",n="",r=!0,s){super(),this._onDidChange=this._register(new i.Q5),this.onDidChange=this._onDidChange.event,this._enabled=!0,this._id=e,this._label=t,this._cssClass=n,this._enabled=r,this._actionCallback=s}get id(){return this._id}get label(){return this._label}set label(e){this._setLabel(e)}_setLabel(e){this._label!==e&&(this._label=e,this._onDidChange.fire({label:e}))}get tooltip(){return this._tooltip||""}set tooltip(e){this._setTooltip(e)}_setTooltip(e){this._tooltip!==e&&(this._tooltip=e,this._onDidChange.fire({tooltip:e}))}get class(){return this._cssClass}set class(e){this._setClass(e)}_setClass(e){this._cssClass!==e&&(this._cssClass=e,this._onDidChange.fire({class:e}))}get enabled(){return this._enabled}set enabled(e){this._setEnabled(e)}_setEnabled(e){this._enabled!==e&&(this._enabled=e,this._onDidChange.fire({enabled:e}))}get checked(){return this._checked}set checked(e){this._setChecked(e)}_setChecked(e){this._checked!==e&&(this._checked=e,this._onDidChange.fire({checked:e}))}run(e,t){return a(this,void 0,void 0,(function*(){this._actionCallback&&(yield this._actionCallback(e))}))}}class l extends r.JT{constructor(){super(...arguments),this._onBeforeRun=this._register(new i.Q5),this.onBeforeRun=this._onBeforeRun.event,this._onDidRun=this._register(new i.Q5),this.onDidRun=this._onDidRun.event}run(e,t){return a(this,void 0,void 0,(function*(){if(!e.enabled)return;let n;this._onBeforeRun.fire({action:e});try{yield this.runAction(e,t)}catch(e){n=e}this._onDidRun.fire({action:e,error:n})}))}runAction(e,t){return a(this,void 0,void 0,(function*(){yield e.run(t)}))}}class c extends o{constructor(e){super(c.ID,e,e?"separator text":"separator"),this.checked=!1,this.enabled=!1}}c.ID="vs.actions.separator";class u{constructor(e,t,n,i){this.tooltip="",this.enabled=!0,this.checked=!1,this.id=e,this.label=t,this.class=i,this._actions=n}get actions(){return this._actions}dispose(){}run(){return a(this,void 0,void 0,(function*(){}))}}class h extends o{constructor(){super(h.ID,s.N("submenu.empty","(empty)"),void 0,!1)}}h.ID="vs.actions.empty"},76068:function(e,t,n){"use strict";function i(e,t){if(!e)throw new Error(t?`Assertion failed (${t})`:"Assertion Failed")}n.d(t,{ok:function(){return i}})},52615:function(e,t,n){"use strict";n.d(t,{CM:function(){return a},JL:function(){return o},dT:function(){return c},fK:function(){return s},lA:function(){return l}});var i=n(4348);const r=new class{constructor(){this._icons=new Map,this._onDidRegister=new i.Q5}add(e){const t=this._icons.get(e.id);t?e.description?t.description=e.description:console.error(`Duplicate registration of codicon ${e.id}`):(this._icons.set(e.id,e),this._onDidRegister.fire(e))}get(e){return this._icons.get(e)}get all(){return this._icons.values()}get onDidRegister(){return this._onDidRegister.event}},s=r;function a(e,t){return new l(e,t)}function o(e){return e?e.replace(/\$\((.*?)\)/g,((e,t)=>` ${t} `)).trim():""}class l{constructor(e,t,n){this.id=e,this.definition=t,this.description=n,r.add(this)}get classNames(){return"codicon codicon-"+this.id}get classNamesArray(){return["codicon","codicon-"+this.id]}get cssSelector(){return".codicon.codicon-"+this.id}}var c;!function(e){e.iconNameSegment="[A-Za-z0-9]+",e.iconNameExpression="[A-Za-z0-9\\-]+",e.iconModifierExpression="~[A-Za-z]+";const t=new RegExp(`^(${e.iconNameExpression})(${e.iconModifierExpression})?$`);function n(e){if(e instanceof l)return["codicon","codicon-"+e.id];const i=t.exec(e.id);if(!i)return n(l.error);let[,r,s]=i;const a=["codicon","codicon-"+r];return s&&a.push("codicon-modifier-"+s.substr(1)),a}e.asClassNameArray=n,e.asClassName=function(e){return n(e).join(" ")},e.asCSSSelector=function(e){return"."+n(e).join(".")}}(c||(c={})),function(e){e.add=new e("add",{fontCharacter:"\\ea60"}),e.plus=new e("plus",e.add.definition),e.gistNew=new e("gist-new",e.add.definition),e.repoCreate=new e("repo-create",e.add.definition),e.lightbulb=new e("lightbulb",{fontCharacter:"\\ea61"}),e.lightBulb=new e("light-bulb",{fontCharacter:"\\ea61"}),e.repo=new e("repo",{fontCharacter:"\\ea62"}),e.repoDelete=new e("repo-delete",{fontCharacter:"\\ea62"}),e.gistFork=new e("gist-fork",{fontCharacter:"\\ea63"}),e.repoForked=new e("repo-forked",{fontCharacter:"\\ea63"}),e.gitPullRequest=new e("git-pull-request",{fontCharacter:"\\ea64"}),e.gitPullRequestAbandoned=new e("git-pull-request-abandoned",{fontCharacter:"\\ea64"}),e.recordKeys=new e("record-keys",{fontCharacter:"\\ea65"}),e.keyboard=new e("keyboard",{fontCharacter:"\\ea65"}),e.tag=new e("tag",{fontCharacter:"\\ea66"}),e.tagAdd=new e("tag-add",{fontCharacter:"\\ea66"}),e.tagRemove=new e("tag-remove",{fontCharacter:"\\ea66"}),e.person=new e("person",{fontCharacter:"\\ea67"}),e.personFollow=new e("person-follow",{fontCharacter:"\\ea67"}),e.personOutline=new e("person-outline",{fontCharacter:"\\ea67"}),e.personFilled=new e("person-filled",{fontCharacter:"\\ea67"}),e.gitBranch=new e("git-branch",{fontCharacter:"\\ea68"}),e.gitBranchCreate=new e("git-branch-create",{fontCharacter:"\\ea68"}),e.gitBranchDelete=new e("git-branch-delete",{fontCharacter:"\\ea68"}),e.sourceControl=new e("source-control",{fontCharacter:"\\ea68"}),e.mirror=new e("mirror",{fontCharacter:"\\ea69"}),e.mirrorPublic=new e("mirror-public",{fontCharacter:"\\ea69"}),e.star=new e("star",{fontCharacter:"\\ea6a"}),e.starAdd=new e("star-add",{fontCharacter:"\\ea6a"}),e.starDelete=new e("star-delete",{fontCharacter:"\\ea6a"}),e.starEmpty=new e("star-empty",{fontCharacter:"\\ea6a"}),e.comment=new e("comment",{fontCharacter:"\\ea6b"}),e.commentAdd=new e("comment-add",{fontCharacter:"\\ea6b"}),e.alert=new e("alert",{fontCharacter:"\\ea6c"}),e.warning=new e("warning",{fontCharacter:"\\ea6c"}),e.search=new e("search",{fontCharacter:"\\ea6d"}),e.searchSave=new e("search-save",{fontCharacter:"\\ea6d"}),e.logOut=new e("log-out",{fontCharacter:"\\ea6e"}),e.signOut=new e("sign-out",{fontCharacter:"\\ea6e"}),e.logIn=new e("log-in",{fontCharacter:"\\ea6f"}),e.signIn=new e("sign-in",{fontCharacter:"\\ea6f"}),e.eye=new e("eye",{fontCharacter:"\\ea70"}),e.eyeUnwatch=new e("eye-unwatch",{fontCharacter:"\\ea70"}),e.eyeWatch=new e("eye-watch",{fontCharacter:"\\ea70"}),e.circleFilled=new e("circle-filled",{fontCharacter:"\\ea71"}),e.primitiveDot=new e("primitive-dot",{fontCharacter:"\\ea71"}),e.closeDirty=new e("close-dirty",{fontCharacter:"\\ea71"}),e.debugBreakpoint=new e("debug-breakpoint",{fontCharacter:"\\ea71"}),e.debugBreakpointDisabled=new e("debug-breakpoint-disabled",{fontCharacter:"\\ea71"}),e.debugHint=new e("debug-hint",{fontCharacter:"\\ea71"}),e.primitiveSquare=new e("primitive-square",{fontCharacter:"\\ea72"}),e.edit=new e("edit",{fontCharacter:"\\ea73"}),e.pencil=new e("pencil",{fontCharacter:"\\ea73"}),e.info=new e("info",{fontCharacter:"\\ea74"}),e.issueOpened=new e("issue-opened",{fontCharacter:"\\ea74"}),e.gistPrivate=new e("gist-private",{fontCharacter:"\\ea75"}),e.gitForkPrivate=new e("git-fork-private",{fontCharacter:"\\ea75"}),e.lock=new e("lock",{fontCharacter:"\\ea75"}),e.mirrorPrivate=new e("mirror-private",{fontCharacter:"\\ea75"}),e.close=new e("close",{fontCharacter:"\\ea76"}),e.removeClose=new e("remove-close",{fontCharacter:"\\ea76"}),e.x=new e("x",{fontCharacter:"\\ea76"}),e.repoSync=new e("repo-sync",{fontCharacter:"\\ea77"}),e.sync=new e("sync",{fontCharacter:"\\ea77"}),e.clone=new e("clone",{fontCharacter:"\\ea78"}),e.desktopDownload=new e("desktop-download",{fontCharacter:"\\ea78"}),e.beaker=new e("beaker",{fontCharacter:"\\ea79"}),e.microscope=new e("microscope",{fontCharacter:"\\ea79"}),e.vm=new e("vm",{fontCharacter:"\\ea7a"}),e.deviceDesktop=new e("device-desktop",{fontCharacter:"\\ea7a"}),e.file=new e("file",{fontCharacter:"\\ea7b"}),e.fileText=new e("file-text",{fontCharacter:"\\ea7b"}),e.more=new e("more",{fontCharacter:"\\ea7c"}),e.ellipsis=new e("ellipsis",{fontCharacter:"\\ea7c"}),e.kebabHorizontal=new e("kebab-horizontal",{fontCharacter:"\\ea7c"}),e.mailReply=new e("mail-reply",{fontCharacter:"\\ea7d"}),e.reply=new e("reply",{fontCharacter:"\\ea7d"}),e.organization=new e("organization",{fontCharacter:"\\ea7e"}),e.organizationFilled=new e("organization-filled",{fontCharacter:"\\ea7e"}),e.organizationOutline=new e("organization-outline",{fontCharacter:"\\ea7e"}),e.newFile=new e("new-file",{fontCharacter:"\\ea7f"}),e.fileAdd=new e("file-add",{fontCharacter:"\\ea7f"}),e.newFolder=new e("new-folder",{fontCharacter:"\\ea80"}),e.fileDirectoryCreate=new e("file-directory-create",{fontCharacter:"\\ea80"}),e.trash=new e("trash",{fontCharacter:"\\ea81"}),e.trashcan=new e("trashcan",{fontCharacter:"\\ea81"}),e.history=new e("history",{fontCharacter:"\\ea82"}),e.clock=new e("clock",{fontCharacter:"\\ea82"}),e.folder=new e("folder",{fontCharacter:"\\ea83"}),e.fileDirectory=new e("file-directory",{fontCharacter:"\\ea83"}),e.symbolFolder=new e("symbol-folder",{fontCharacter:"\\ea83"}),e.logoGithub=new e("logo-github",{fontCharacter:"\\ea84"}),e.markGithub=new e("mark-github",{fontCharacter:"\\ea84"}),e.github=new e("github",{fontCharacter:"\\ea84"}),e.terminal=new e("terminal",{fontCharacter:"\\ea85"}),e.console=new e("console",{fontCharacter:"\\ea85"}),e.repl=new e("repl",{fontCharacter:"\\ea85"}),e.zap=new e("zap",{fontCharacter:"\\ea86"}),e.symbolEvent=new e("symbol-event",{fontCharacter:"\\ea86"}),e.error=new e("error",{fontCharacter:"\\ea87"}),e.stop=new e("stop",{fontCharacter:"\\ea87"}),e.variable=new e("variable",{fontCharacter:"\\ea88"}),e.symbolVariable=new e("symbol-variable",{fontCharacter:"\\ea88"}),e.array=new e("array",{fontCharacter:"\\ea8a"}),e.symbolArray=new e("symbol-array",{fontCharacter:"\\ea8a"}),e.symbolModule=new e("symbol-module",{fontCharacter:"\\ea8b"}),e.symbolPackage=new e("symbol-package",{fontCharacter:"\\ea8b"}),e.symbolNamespace=new e("symbol-namespace",{fontCharacter:"\\ea8b"}),e.symbolObject=new e("symbol-object",{fontCharacter:"\\ea8b"}),e.symbolMethod=new e("symbol-method",{fontCharacter:"\\ea8c"}),e.symbolFunction=new e("symbol-function",{fontCharacter:"\\ea8c"}),e.symbolConstructor=new e("symbol-constructor",{fontCharacter:"\\ea8c"}),e.symbolBoolean=new e("symbol-boolean",{fontCharacter:"\\ea8f"}),e.symbolNull=new e("symbol-null",{fontCharacter:"\\ea8f"}),e.symbolNumeric=new e("symbol-numeric",{fontCharacter:"\\ea90"}),e.symbolNumber=new e("symbol-number",{fontCharacter:"\\ea90"}),e.symbolStructure=new e("symbol-structure",{fontCharacter:"\\ea91"}),e.symbolStruct=new e("symbol-struct",{fontCharacter:"\\ea91"}),e.symbolParameter=new e("symbol-parameter",{fontCharacter:"\\ea92"}),e.symbolTypeParameter=new e("symbol-type-parameter",{fontCharacter:"\\ea92"}),e.symbolKey=new e("symbol-key",{fontCharacter:"\\ea93"}),e.symbolText=new e("symbol-text",{fontCharacter:"\\ea93"}),e.symbolReference=new e("symbol-reference",{fontCharacter:"\\ea94"}),e.goToFile=new e("go-to-file",{fontCharacter:"\\ea94"}),e.symbolEnum=new e("symbol-enum",{fontCharacter:"\\ea95"}),e.symbolValue=new e("symbol-value",{fontCharacter:"\\ea95"}),e.symbolRuler=new e("symbol-ruler",{fontCharacter:"\\ea96"}),e.symbolUnit=new e("symbol-unit",{fontCharacter:"\\ea96"}),e.activateBreakpoints=new e("activate-breakpoints",{fontCharacter:"\\ea97"}),e.archive=new e("archive",{fontCharacter:"\\ea98"}),e.arrowBoth=new e("arrow-both",{fontCharacter:"\\ea99"}),e.arrowDown=new e("arrow-down",{fontCharacter:"\\ea9a"}),e.arrowLeft=new e("arrow-left",{fontCharacter:"\\ea9b"}),e.arrowRight=new e("arrow-right",{fontCharacter:"\\ea9c"}),e.arrowSmallDown=new e("arrow-small-down",{fontCharacter:"\\ea9d"}),e.arrowSmallLeft=new e("arrow-small-left",{fontCharacter:"\\ea9e"}),e.arrowSmallRight=new e("arrow-small-right",{fontCharacter:"\\ea9f"}),e.arrowSmallUp=new e("arrow-small-up",{fontCharacter:"\\eaa0"}),e.arrowUp=new e("arrow-up",{fontCharacter:"\\eaa1"}),e.bell=new e("bell",{fontCharacter:"\\eaa2"}),e.bold=new e("bold",{fontCharacter:"\\eaa3"}),e.book=new e("book",{fontCharacter:"\\eaa4"}),e.bookmark=new e("bookmark",{fontCharacter:"\\eaa5"}),e.debugBreakpointConditionalUnverified=new e("debug-breakpoint-conditional-unverified",{fontCharacter:"\\eaa6"}),e.debugBreakpointConditional=new e("debug-breakpoint-conditional",{fontCharacter:"\\eaa7"}),e.debugBreakpointConditionalDisabled=new e("debug-breakpoint-conditional-disabled",{fontCharacter:"\\eaa7"}),e.debugBreakpointDataUnverified=new e("debug-breakpoint-data-unverified",{fontCharacter:"\\eaa8"}),e.debugBreakpointData=new e("debug-breakpoint-data",{fontCharacter:"\\eaa9"}),e.debugBreakpointDataDisabled=new e("debug-breakpoint-data-disabled",{fontCharacter:"\\eaa9"}),e.debugBreakpointLogUnverified=new e("debug-breakpoint-log-unverified",{fontCharacter:"\\eaaa"}),e.debugBreakpointLog=new e("debug-breakpoint-log",{fontCharacter:"\\eaab"}),e.debugBreakpointLogDisabled=new e("debug-breakpoint-log-disabled",{fontCharacter:"\\eaab"}),e.briefcase=new e("briefcase",{fontCharacter:"\\eaac"}),e.broadcast=new e("broadcast",{fontCharacter:"\\eaad"}),e.browser=new e("browser",{fontCharacter:"\\eaae"}),e.bug=new e("bug",{fontCharacter:"\\eaaf"}),e.calendar=new e("calendar",{fontCharacter:"\\eab0"}),e.caseSensitive=new e("case-sensitive",{fontCharacter:"\\eab1"}),e.check=new e("check",{fontCharacter:"\\eab2"}),e.checklist=new e("checklist",{fontCharacter:"\\eab3"}),e.chevronDown=new e("chevron-down",{fontCharacter:"\\eab4"}),e.dropDownButton=new e("drop-down-button",e.chevronDown.definition),e.chevronLeft=new e("chevron-left",{fontCharacter:"\\eab5"}),e.chevronRight=new e("chevron-right",{fontCharacter:"\\eab6"}),e.chevronUp=new e("chevron-up",{fontCharacter:"\\eab7"}),e.chromeClose=new e("chrome-close",{fontCharacter:"\\eab8"}),e.chromeMaximize=new e("chrome-maximize",{fontCharacter:"\\eab9"}),e.chromeMinimize=new e("chrome-minimize",{fontCharacter:"\\eaba"}),e.chromeRestore=new e("chrome-restore",{fontCharacter:"\\eabb"}),e.circleOutline=new e("circle-outline",{fontCharacter:"\\eabc"}),e.debugBreakpointUnverified=new e("debug-breakpoint-unverified",{fontCharacter:"\\eabc"}),e.circleSlash=new e("circle-slash",{fontCharacter:"\\eabd"}),e.circuitBoard=new e("circuit-board",{fontCharacter:"\\eabe"}),e.clearAll=new e("clear-all",{fontCharacter:"\\eabf"}),e.clippy=new e("clippy",{fontCharacter:"\\eac0"}),e.closeAll=new e("close-all",{fontCharacter:"\\eac1"}),e.cloudDownload=new e("cloud-download",{fontCharacter:"\\eac2"}),e.cloudUpload=new e("cloud-upload",{fontCharacter:"\\eac3"}),e.code=new e("code",{fontCharacter:"\\eac4"}),e.collapseAll=new e("collapse-all",{fontCharacter:"\\eac5"}),e.colorMode=new e("color-mode",{fontCharacter:"\\eac6"}),e.commentDiscussion=new e("comment-discussion",{fontCharacter:"\\eac7"}),e.compareChanges=new e("compare-changes",{fontCharacter:"\\eafd"}),e.creditCard=new e("credit-card",{fontCharacter:"\\eac9"}),e.dash=new e("dash",{fontCharacter:"\\eacc"}),e.dashboard=new e("dashboard",{fontCharacter:"\\eacd"}),e.database=new e("database",{fontCharacter:"\\eace"}),e.debugContinue=new e("debug-continue",{fontCharacter:"\\eacf"}),e.debugDisconnect=new e("debug-disconnect",{fontCharacter:"\\ead0"}),e.debugPause=new e("debug-pause",{fontCharacter:"\\ead1"}),e.debugRestart=new e("debug-restart",{fontCharacter:"\\ead2"}),e.debugStart=new e("debug-start",{fontCharacter:"\\ead3"}),e.debugStepInto=new e("debug-step-into",{fontCharacter:"\\ead4"}),e.debugStepOut=new e("debug-step-out",{fontCharacter:"\\ead5"}),e.debugStepOver=new e("debug-step-over",{fontCharacter:"\\ead6"}),e.debugStop=new e("debug-stop",{fontCharacter:"\\ead7"}),e.debug=new e("debug",{fontCharacter:"\\ead8"}),e.deviceCameraVideo=new e("device-camera-video",{fontCharacter:"\\ead9"}),e.deviceCamera=new e("device-camera",{fontCharacter:"\\eada"}),e.deviceMobile=new e("device-mobile",{fontCharacter:"\\eadb"}),e.diffAdded=new e("diff-added",{fontCharacter:"\\eadc"}),e.diffIgnored=new e("diff-ignored",{fontCharacter:"\\eadd"}),e.diffModified=new e("diff-modified",{fontCharacter:"\\eade"}),e.diffRemoved=new e("diff-removed",{fontCharacter:"\\eadf"}),e.diffRenamed=new e("diff-renamed",{fontCharacter:"\\eae0"}),e.diff=new e("diff",{fontCharacter:"\\eae1"}),e.discard=new e("discard",{fontCharacter:"\\eae2"}),e.editorLayout=new e("editor-layout",{fontCharacter:"\\eae3"}),e.emptyWindow=new e("empty-window",{fontCharacter:"\\eae4"}),e.exclude=new e("exclude",{fontCharacter:"\\eae5"}),e.extensions=new e("extensions",{fontCharacter:"\\eae6"}),e.eyeClosed=new e("eye-closed",{fontCharacter:"\\eae7"}),e.fileBinary=new e("file-binary",{fontCharacter:"\\eae8"}),e.fileCode=new e("file-code",{fontCharacter:"\\eae9"}),e.fileMedia=new e("file-media",{fontCharacter:"\\eaea"}),e.filePdf=new e("file-pdf",{fontCharacter:"\\eaeb"}),e.fileSubmodule=new e("file-submodule",{fontCharacter:"\\eaec"}),e.fileSymlinkDirectory=new e("file-symlink-directory",{fontCharacter:"\\eaed"}),e.fileSymlinkFile=new e("file-symlink-file",{fontCharacter:"\\eaee"}),e.fileZip=new e("file-zip",{fontCharacter:"\\eaef"}),e.files=new e("files",{fontCharacter:"\\eaf0"}),e.filter=new e("filter",{fontCharacter:"\\eaf1"}),e.flame=new e("flame",{fontCharacter:"\\eaf2"}),e.foldDown=new e("fold-down",{fontCharacter:"\\eaf3"}),e.foldUp=new e("fold-up",{fontCharacter:"\\eaf4"}),e.fold=new e("fold",{fontCharacter:"\\eaf5"}),e.folderActive=new e("folder-active",{fontCharacter:"\\eaf6"}),e.folderOpened=new e("folder-opened",{fontCharacter:"\\eaf7"}),e.gear=new e("gear",{fontCharacter:"\\eaf8"}),e.gift=new e("gift",{fontCharacter:"\\eaf9"}),e.gistSecret=new e("gist-secret",{fontCharacter:"\\eafa"}),e.gist=new e("gist",{fontCharacter:"\\eafb"}),e.gitCommit=new e("git-commit",{fontCharacter:"\\eafc"}),e.gitCompare=new e("git-compare",{fontCharacter:"\\eafd"}),e.gitMerge=new e("git-merge",{fontCharacter:"\\eafe"}),e.githubAction=new e("github-action",{fontCharacter:"\\eaff"}),e.githubAlt=new e("github-alt",{fontCharacter:"\\eb00"}),e.globe=new e("globe",{fontCharacter:"\\eb01"}),e.grabber=new e("grabber",{fontCharacter:"\\eb02"}),e.graph=new e("graph",{fontCharacter:"\\eb03"}),e.gripper=new e("gripper",{fontCharacter:"\\eb04"}),e.heart=new e("heart",{fontCharacter:"\\eb05"}),e.home=new e("home",{fontCharacter:"\\eb06"}),e.horizontalRule=new e("horizontal-rule",{fontCharacter:"\\eb07"}),e.hubot=new e("hubot",{fontCharacter:"\\eb08"}),e.inbox=new e("inbox",{fontCharacter:"\\eb09"}),e.issueClosed=new e("issue-closed",{fontCharacter:"\\eba4"}),e.issueReopened=new e("issue-reopened",{fontCharacter:"\\eb0b"}),e.issues=new e("issues",{fontCharacter:"\\eb0c"}),e.italic=new e("italic",{fontCharacter:"\\eb0d"}),e.jersey=new e("jersey",{fontCharacter:"\\eb0e"}),e.json=new e("json",{fontCharacter:"\\eb0f"}),e.kebabVertical=new e("kebab-vertical",{fontCharacter:"\\eb10"}),e.key=new e("key",{fontCharacter:"\\eb11"}),e.law=new e("law",{fontCharacter:"\\eb12"}),e.lightbulbAutofix=new e("lightbulb-autofix",{fontCharacter:"\\eb13"}),e.linkExternal=new e("link-external",{fontCharacter:"\\eb14"}),e.link=new e("link",{fontCharacter:"\\eb15"}),e.listOrdered=new e("list-ordered",{fontCharacter:"\\eb16"}),e.listUnordered=new e("list-unordered",{fontCharacter:"\\eb17"}),e.liveShare=new e("live-share",{fontCharacter:"\\eb18"}),e.loading=new e("loading",{fontCharacter:"\\eb19"}),e.location=new e("location",{fontCharacter:"\\eb1a"}),e.mailRead=new e("mail-read",{fontCharacter:"\\eb1b"}),e.mail=new e("mail",{fontCharacter:"\\eb1c"}),e.markdown=new e("markdown",{fontCharacter:"\\eb1d"}),e.megaphone=new e("megaphone",{fontCharacter:"\\eb1e"}),e.mention=new e("mention",{fontCharacter:"\\eb1f"}),e.milestone=new e("milestone",{fontCharacter:"\\eb20"}),e.mortarBoard=new e("mortar-board",{fontCharacter:"\\eb21"}),e.move=new e("move",{fontCharacter:"\\eb22"}),e.multipleWindows=new e("multiple-windows",{fontCharacter:"\\eb23"}),e.mute=new e("mute",{fontCharacter:"\\eb24"}),e.noNewline=new e("no-newline",{fontCharacter:"\\eb25"}),e.note=new e("note",{fontCharacter:"\\eb26"}),e.octoface=new e("octoface",{fontCharacter:"\\eb27"}),e.openPreview=new e("open-preview",{fontCharacter:"\\eb28"}),e.package_=new e("package",{fontCharacter:"\\eb29"}),e.paintcan=new e("paintcan",{fontCharacter:"\\eb2a"}),e.pin=new e("pin",{fontCharacter:"\\eb2b"}),e.play=new e("play",{fontCharacter:"\\eb2c"}),e.run=new e("run",{fontCharacter:"\\eb2c"}),e.plug=new e("plug",{fontCharacter:"\\eb2d"}),e.preserveCase=new e("preserve-case",{fontCharacter:"\\eb2e"}),e.preview=new e("preview",{fontCharacter:"\\eb2f"}),e.project=new e("project",{fontCharacter:"\\eb30"}),e.pulse=new e("pulse",{fontCharacter:"\\eb31"}),e.question=new e("question",{fontCharacter:"\\eb32"}),e.quote=new e("quote",{fontCharacter:"\\eb33"}),e.radioTower=new e("radio-tower",{fontCharacter:"\\eb34"}),e.reactions=new e("reactions",{fontCharacter:"\\eb35"}),e.references=new e("references",{fontCharacter:"\\eb36"}),e.refresh=new e("refresh",{fontCharacter:"\\eb37"}),e.regex=new e("regex",{fontCharacter:"\\eb38"}),e.remoteExplorer=new e("remote-explorer",{fontCharacter:"\\eb39"}),e.remote=new e("remote",{fontCharacter:"\\eb3a"}),e.remove=new e("remove",{fontCharacter:"\\eb3b"}),e.replaceAll=new e("replace-all",{fontCharacter:"\\eb3c"}),e.replace=new e("replace",{fontCharacter:"\\eb3d"}),e.repoClone=new e("repo-clone",{fontCharacter:"\\eb3e"}),e.repoForcePush=new e("repo-force-push",{fontCharacter:"\\eb3f"}),e.repoPull=new e("repo-pull",{fontCharacter:"\\eb40"}),e.repoPush=new e("repo-push",{fontCharacter:"\\eb41"}),e.report=new e("report",{fontCharacter:"\\eb42"}),e.requestChanges=new e("request-changes",{fontCharacter:"\\eb43"}),e.rocket=new e("rocket",{fontCharacter:"\\eb44"}),e.rootFolderOpened=new e("root-folder-opened",{fontCharacter:"\\eb45"}),e.rootFolder=new e("root-folder",{fontCharacter:"\\eb46"}),e.rss=new e("rss",{fontCharacter:"\\eb47"}),e.ruby=new e("ruby",{fontCharacter:"\\eb48"}),e.saveAll=new e("save-all",{fontCharacter:"\\eb49"}),e.saveAs=new e("save-as",{fontCharacter:"\\eb4a"}),e.save=new e("save",{fontCharacter:"\\eb4b"}),e.screenFull=new e("screen-full",{fontCharacter:"\\eb4c"}),e.screenNormal=new e("screen-normal",{fontCharacter:"\\eb4d"}),e.searchStop=new e("search-stop",{fontCharacter:"\\eb4e"}),e.server=new e("server",{fontCharacter:"\\eb50"}),e.settingsGear=new e("settings-gear",{fontCharacter:"\\eb51"}),e.settings=new e("settings",{fontCharacter:"\\eb52"}),e.shield=new e("shield",{fontCharacter:"\\eb53"}),e.smiley=new e("smiley",{fontCharacter:"\\eb54"}),e.sortPrecedence=new e("sort-precedence",{fontCharacter:"\\eb55"}),e.splitHorizontal=new e("split-horizontal",{fontCharacter:"\\eb56"}),e.splitVertical=new e("split-vertical",{fontCharacter:"\\eb57"}),e.squirrel=new e("squirrel",{fontCharacter:"\\eb58"}),e.starFull=new e("star-full",{fontCharacter:"\\eb59"}),e.starHalf=new e("star-half",{fontCharacter:"\\eb5a"}),e.symbolClass=new e("symbol-class",{fontCharacter:"\\eb5b"}),e.symbolColor=new e("symbol-color",{fontCharacter:"\\eb5c"}),e.symbolConstant=new e("symbol-constant",{fontCharacter:"\\eb5d"}),e.symbolEnumMember=new e("symbol-enum-member",{fontCharacter:"\\eb5e"}),e.symbolField=new e("symbol-field",{fontCharacter:"\\eb5f"}),e.symbolFile=new e("symbol-file",{fontCharacter:"\\eb60"}),e.symbolInterface=new e("symbol-interface",{fontCharacter:"\\eb61"}),e.symbolKeyword=new e("symbol-keyword",{fontCharacter:"\\eb62"}),e.symbolMisc=new e("symbol-misc",{fontCharacter:"\\eb63"}),e.symbolOperator=new e("symbol-operator",{fontCharacter:"\\eb64"}),e.symbolProperty=new e("symbol-property",{fontCharacter:"\\eb65"}),e.wrench=new e("wrench",{fontCharacter:"\\eb65"}),e.wrenchSubaction=new e("wrench-subaction",{fontCharacter:"\\eb65"}),e.symbolSnippet=new e("symbol-snippet",{fontCharacter:"\\eb66"}),e.tasklist=new e("tasklist",{fontCharacter:"\\eb67"}),e.telescope=new e("telescope",{fontCharacter:"\\eb68"}),e.textSize=new e("text-size",{fontCharacter:"\\eb69"}),e.threeBars=new e("three-bars",{fontCharacter:"\\eb6a"}),e.thumbsdown=new e("thumbsdown",{fontCharacter:"\\eb6b"}),e.thumbsup=new e("thumbsup",{fontCharacter:"\\eb6c"}),e.tools=new e("tools",{fontCharacter:"\\eb6d"}),e.triangleDown=new e("triangle-down",{fontCharacter:"\\eb6e"}),e.triangleLeft=new e("triangle-left",{fontCharacter:"\\eb6f"}),e.triangleRight=new e("triangle-right",{fontCharacter:"\\eb70"}),e.triangleUp=new e("triangle-up",{fontCharacter:"\\eb71"}),e.twitter=new e("twitter",{fontCharacter:"\\eb72"}),e.unfold=new e("unfold",{fontCharacter:"\\eb73"}),e.unlock=new e("unlock",{fontCharacter:"\\eb74"}),e.unmute=new e("unmute",{fontCharacter:"\\eb75"}),e.unverified=new e("unverified",{fontCharacter:"\\eb76"}),e.verified=new e("verified",{fontCharacter:"\\eb77"}),e.versions=new e("versions",{fontCharacter:"\\eb78"}),e.vmActive=new e("vm-active",{fontCharacter:"\\eb79"}),e.vmOutline=new e("vm-outline",{fontCharacter:"\\eb7a"}),e.vmRunning=new e("vm-running",{fontCharacter:"\\eb7b"}),e.watch=new e("watch",{fontCharacter:"\\eb7c"}),e.whitespace=new e("whitespace",{fontCharacter:"\\eb7d"}),e.wholeWord=new e("whole-word",{fontCharacter:"\\eb7e"}),e.window=new e("window",{fontCharacter:"\\eb7f"}),e.wordWrap=new e("word-wrap",{fontCharacter:"\\eb80"}),e.zoomIn=new e("zoom-in",{fontCharacter:"\\eb81"}),e.zoomOut=new e("zoom-out",{fontCharacter:"\\eb82"}),e.listFilter=new e("list-filter",{fontCharacter:"\\eb83"}),e.listFlat=new e("list-flat",{fontCharacter:"\\eb84"}),e.listSelection=new e("list-selection",{fontCharacter:"\\eb85"}),e.selection=new e("selection",{fontCharacter:"\\eb85"}),e.listTree=new e("list-tree",{fontCharacter:"\\eb86"}),e.debugBreakpointFunctionUnverified=new e("debug-breakpoint-function-unverified",{fontCharacter:"\\eb87"}),e.debugBreakpointFunction=new e("debug-breakpoint-function",{fontCharacter:"\\eb88"}),e.debugBreakpointFunctionDisabled=new e("debug-breakpoint-function-disabled",{fontCharacter:"\\eb88"}),e.debugStackframeActive=new e("debug-stackframe-active",{fontCharacter:"\\eb89"}),e.debugStackframeDot=new e("debug-stackframe-dot",{fontCharacter:"\\eb8a"}),e.debugStackframe=new e("debug-stackframe",{fontCharacter:"\\eb8b"}),e.debugStackframeFocused=new e("debug-stackframe-focused",{fontCharacter:"\\eb8b"}),e.debugBreakpointUnsupported=new e("debug-breakpoint-unsupported",{fontCharacter:"\\eb8c"}),e.symbolString=new e("symbol-string",{fontCharacter:"\\eb8d"}),e.debugReverseContinue=new e("debug-reverse-continue",{fontCharacter:"\\eb8e"}),e.debugStepBack=new e("debug-step-back",{fontCharacter:"\\eb8f"}),e.debugRestartFrame=new e("debug-restart-frame",{fontCharacter:"\\eb90"}),e.callIncoming=new e("call-incoming",{fontCharacter:"\\eb92"}),e.callOutgoing=new e("call-outgoing",{fontCharacter:"\\eb93"}),e.menu=new e("menu",{fontCharacter:"\\eb94"}),e.expandAll=new e("expand-all",{fontCharacter:"\\eb95"}),e.feedback=new e("feedback",{fontCharacter:"\\eb96"}),e.groupByRefType=new e("group-by-ref-type",{fontCharacter:"\\eb97"}),e.ungroupByRefType=new e("ungroup-by-ref-type",{fontCharacter:"\\eb98"}),e.account=new e("account",{fontCharacter:"\\eb99"}),e.bellDot=new e("bell-dot",{fontCharacter:"\\eb9a"}),e.debugConsole=new e("debug-console",{fontCharacter:"\\eb9b"}),e.library=new e("library",{fontCharacter:"\\eb9c"}),e.output=new e("output",{fontCharacter:"\\eb9d"}),e.runAll=new e("run-all",{fontCharacter:"\\eb9e"}),e.syncIgnored=new e("sync-ignored",{fontCharacter:"\\eb9f"}),e.pinned=new e("pinned",{fontCharacter:"\\eba0"}),e.githubInverted=new e("github-inverted",{fontCharacter:"\\eba1"}),e.debugAlt=new e("debug-alt",{fontCharacter:"\\eb91"}),e.serverProcess=new e("server-process",{fontCharacter:"\\eba2"}),e.serverEnvironment=new e("server-environment",{fontCharacter:"\\eba3"}),e.pass=new e("pass",{fontCharacter:"\\eba4"}),e.stopCircle=new e("stop-circle",{fontCharacter:"\\eba5"}),e.playCircle=new e("play-circle",{fontCharacter:"\\eba6"}),e.record=new e("record",{fontCharacter:"\\eba7"}),e.debugAltSmall=new e("debug-alt-small",{fontCharacter:"\\eba8"}),e.vmConnect=new e("vm-connect",{fontCharacter:"\\eba9"}),e.cloud=new e("cloud",{fontCharacter:"\\ebaa"}),e.merge=new e("merge",{fontCharacter:"\\ebab"}),e.exportIcon=new e("export",{fontCharacter:"\\ebac"}),e.graphLeft=new e("graph-left",{fontCharacter:"\\ebad"}),e.magnet=new e("magnet",{fontCharacter:"\\ebae"}),e.notebook=new e("notebook",{fontCharacter:"\\ebaf"}),e.redo=new e("redo",{fontCharacter:"\\ebb0"}),e.checkAll=new e("check-all",{fontCharacter:"\\ebb1"}),e.pinnedDirty=new e("pinned-dirty",{fontCharacter:"\\ebb2"}),e.passFilled=new e("pass-filled",{fontCharacter:"\\ebb3"}),e.circleLargeFilled=new e("circle-large-filled",{fontCharacter:"\\ebb4"}),e.circleLargeOutline=new e("circle-large-outline",{fontCharacter:"\\ebb5"}),e.combine=new e("combine",{fontCharacter:"\\ebb6"}),e.gather=new e("gather",{fontCharacter:"\\ebb6"}),e.table=new e("table",{fontCharacter:"\\ebb7"}),e.variableGroup=new e("variable-group",{fontCharacter:"\\ebb8"}),e.typeHierarchy=new e("type-hierarchy",{fontCharacter:"\\ebb9"}),e.typeHierarchySub=new e("type-hierarchy-sub",{fontCharacter:"\\ebba"}),e.typeHierarchySuper=new e("type-hierarchy-super",{fontCharacter:"\\ebbb"}),e.gitPullRequestCreate=new e("git-pull-request-create",{fontCharacter:"\\ebbc"}),e.runAbove=new e("run-above",{fontCharacter:"\\ebbd"}),e.runBelow=new e("run-below",{fontCharacter:"\\ebbe"}),e.notebookTemplate=new e("notebook-template",{fontCharacter:"\\ebbf"}),e.debugRerun=new e("debug-rerun",{fontCharacter:"\\ebc0"}),e.workspaceTrusted=new e("workspace-trusted",{fontCharacter:"\\ebc1"}),e.workspaceUntrusted=new e("workspace-untrusted",{fontCharacter:"\\ebc2"}),e.workspaceUnspecified=new e("workspace-unspecified",{fontCharacter:"\\ebc3"}),e.terminalCmd=new e("terminal-cmd",{fontCharacter:"\\ebc4"}),e.terminalDebian=new e("terminal-debian",{fontCharacter:"\\ebc5"}),e.terminalLinux=new e("terminal-linux",{fontCharacter:"\\ebc6"}),e.terminalPowershell=new e("terminal-powershell",{fontCharacter:"\\ebc7"}),e.terminalTmux=new e("terminal-tmux",{fontCharacter:"\\ebc8"}),e.terminalUbuntu=new e("terminal-ubuntu",{fontCharacter:"\\ebc9"}),e.terminalBash=new e("terminal-bash",{fontCharacter:"\\ebca"}),e.arrowSwap=new e("arrow-swap",{fontCharacter:"\\ebcb"}),e.copy=new e("copy",{fontCharacter:"\\ebcc"}),e.personAdd=new e("person-add",{fontCharacter:"\\ebcd"}),e.filterFilled=new e("filter-filled",{fontCharacter:"\\ebce"}),e.wand=new e("wand",{fontCharacter:"\\ebcf"}),e.debugLineByLine=new e("debug-line-by-line",{fontCharacter:"\\ebd0"}),e.inspect=new e("inspect",{fontCharacter:"\\ebd1"}),e.layers=new e("layers",{fontCharacter:"\\ebd2"}),e.layersDot=new e("layers-dot",{fontCharacter:"\\ebd3"}),e.layersActive=new e("layers-active",{fontCharacter:"\\ebd4"}),e.compass=new e("compass",{fontCharacter:"\\ebd5"}),e.compassDot=new e("compass-dot",{fontCharacter:"\\ebd6"}),e.compassActive=new e("compass-active",{fontCharacter:"\\ebd7"}),e.azure=new e("azure",{fontCharacter:"\\ebd8"}),e.issueDraft=new e("issue-draft",{fontCharacter:"\\ebd9"}),e.gitPullRequestClosed=new e("git-pull-request-closed",{fontCharacter:"\\ebda"}),e.gitPullRequestDraft=new e("git-pull-request-draft",{fontCharacter:"\\ebdb"}),e.debugAll=new e("debug-all",{fontCharacter:"\\ebdc"}),e.debugCoverage=new e("debug-coverage",{fontCharacter:"\\ebdd"}),e.runErrors=new e("run-errors",{fontCharacter:"\\ebde"}),e.folderLibrary=new e("folder-library",{fontCharacter:"\\ebdf"}),e.debugContinueSmall=new e("debug-continue-small",{fontCharacter:"\\ebe0"}),e.beakerStop=new e("beaker-stop",{fontCharacter:"\\ebe1"}),e.graphLine=new e("graph-line",{fontCharacter:"\\ebe2"}),e.graphScatter=new e("graph-scatter",{fontCharacter:"\\ebe3"}),e.pieChart=new e("pie-chart",{fontCharacter:"\\ebe4"}),e.bracket=new e("bracket",e.json.definition),e.bracketDot=new e("bracket-dot",{fontCharacter:"\\ebe5"}),e.bracketError=new e("bracket-error",{fontCharacter:"\\ebe6"}),e.lockSmall=new e("lock-small",{fontCharacter:"\\ebe7"}),e.azureDevops=new e("azure-devops",{fontCharacter:"\\ebe8"}),e.verifiedFilled=new e("verified-filled",{fontCharacter:"\\ebe9"})}(l||(l={}))},79881:function(e,t,n){"use strict";n.d(t,{B8:function(){return d},Cp:function(){return s},F0:function(){return c},L6:function(){return h},VV:function(){return l},b1:function(){return u},dL:function(){return r},ri:function(){return a}});const i=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout((()=>{if(e.stack)throw new Error(e.message+"\n\n"+e.stack);throw e}),0)}}emit(e){this.listeners.forEach((t=>{t(e)}))}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function r(e){l(e)||i.onUnexpectedError(e)}function s(e){l(e)||i.onUnexpectedExternalError(e)}function a(e){if(e instanceof Error){let{name:t,message:n}=e;return{$isError:!0,name:t,message:n,stack:e.stacktrace||e.stack}}return e}const o="Canceled";function l(e){return e instanceof Error&&e.name===o&&e.message===o}function c(){const e=new Error(o);return e.name=e.message,e}function u(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")}function h(e){return e?new Error(`Illegal state: ${e}`):new Error("Illegal state")}class d extends Error{constructor(e){super("NotSupported"),e&&(this.message=e)}}},4348:function(e,t,n){"use strict";n.d(t,{D0:function(){return h},E7:function(){return d},K3:function(){return u},Q5:function(){return c},ZD:function(){return p},ju:function(){return i}});var i,r=n(79881),s=n(69323),a=n(34502),o=n(95830);!function(e){function t(e){return(t,n=null,i)=>{let r,s=!1;return r=e((e=>{if(!s)return r?r.dispose():s=!0,t.call(n,e)}),null,i),s&&r.dispose(),r}}function n(e,t){return o(((n,i=null,r)=>e((e=>n.call(i,t(e))),null,r)))}function i(e,t){return o(((n,i=null,r)=>e((e=>{t(e),n.call(i,e)}),null,r)))}function r(e,t){return o(((n,i=null,r)=>e((e=>t(e)&&n.call(i,e)),null,r)))}function a(e,t,i){let r=i;return n(e,(e=>(r=t(r,e),r)))}function o(e){let t;const n=new c({onFirstListenerAdd(){t=e(n.fire,n)},onLastListenerRemove(){t.dispose()}});return n.event}function l(e,t,n=100,i=!1,r){let s,a,o,l=0;const u=new c({leakWarningThreshold:r,onFirstListenerAdd(){s=e((e=>{l++,a=t(a,e),i&&!o&&(u.fire(a),a=void 0),clearTimeout(o),o=setTimeout((()=>{const e=a;a=void 0,o=void 0,(!i||l>1)&&u.fire(e),l=0}),n)}))},onLastListenerRemove(){s.dispose()}});return u.event}function u(e,t=((e,t)=>e===t)){let n,i=!0;return r(e,(e=>{const r=i||!t(e,n);return i=!1,n=e,r}))}e.None=()=>s.JT.None,e.once=t,e.map=n,e.forEach=i,e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,n=null,i)=>(0,s.F8)(...e.map((e=>e((e=>t.call(n,e)),null,i))))},e.reduce=a,e.debounce=l,e.latch=u,e.split=function(t,n){return[e.filter(t,n),e.filter(t,(e=>!n(e)))]},e.buffer=function(e,t=!1,n=[]){let i=n.slice(),r=e((e=>{i?i.push(e):a.fire(e)}));const s=()=>{i&&i.forEach((e=>a.fire(e))),i=null},a=new c({onFirstListenerAdd(){r||(r=e((e=>a.fire(e))))},onFirstListenerDidAdd(){i&&(t?setTimeout(s):s())},onLastListenerRemove(){r&&r.dispose(),r=null}});return a.event};class h{constructor(e){this.event=e}map(e){return new h(n(this.event,e))}forEach(e){return new h(i(this.event,e))}filter(e){return new h(r(this.event,e))}reduce(e,t){return new h(a(this.event,e,t))}latch(){return new h(u(this.event))}debounce(e,t=100,n=!1,i){return new h(l(this.event,e,t,n,i))}on(e,t,n){return this.event(e,t,n)}once(e,n,i){return t(this.event)(e,n,i)}}e.chain=function(e){return new h(e)},e.fromNodeEventEmitter=function(e,t,n=(e=>e)){const i=(...e)=>r.fire(n(...e)),r=new c({onFirstListenerAdd:()=>e.on(t,i),onLastListenerRemove:()=>e.removeListener(t,i)});return r.event},e.fromDOMEventEmitter=function(e,t,n=(e=>e)){const i=(...e)=>r.fire(n(...e)),r=new c({onFirstListenerAdd:()=>e.addEventListener(t,i),onLastListenerRemove:()=>e.removeEventListener(t,i)});return r.event},e.toPromise=function(e){return new Promise((n=>t(e)(n)))}}(i||(i={}));class l{constructor(e){this._listenerCount=0,this._invocationCount=0,this._elapsedOverall=0,this._name=`${e}_${l._idPool++}`}start(e){this._stopWatch=new o.G(!0),this._listenerCount=e}stop(){if(this._stopWatch){const e=this._stopWatch.elapsed();this._elapsedOverall+=e,this._invocationCount+=1,console.info(`did FIRE ${this._name}: elapsed_ms: ${e.toFixed(5)}, listener: ${this._listenerCount} (elapsed_overall: ${this._elapsedOverall.toFixed(2)}, invocations: ${this._invocationCount})`),this._stopWatch=void 0}}}l._idPool=0;class c{constructor(e){var t;this._disposed=!1,this._options=e,this._leakageMon=void 0,this._perfMon=(null===(t=this._options)||void 0===t?void 0:t._profName)?new l(this._options._profName):void 0}get event(){return this._event||(this._event=(e,t,n)=>{var i;this._listeners||(this._listeners=new a.S);const r=this._listeners.isEmpty();r&&this._options&&this._options.onFirstListenerAdd&&this._options.onFirstListenerAdd(this);const o=this._listeners.push(t?[e,t]:e);r&&this._options&&this._options.onFirstListenerDidAdd&&this._options.onFirstListenerDidAdd(this),this._options&&this._options.onListenerDidAdd&&this._options.onListenerDidAdd(this,e,t);const l=null===(i=this._leakageMon)||void 0===i?void 0:i.check(this._listeners.size),c=(0,s.OF)((()=>{if(l&&l(),!this._disposed&&(o(),this._options&&this._options.onLastListenerRemove)){this._listeners&&!this._listeners.isEmpty()||this._options.onLastListenerRemove(this)}}));return n instanceof s.SL?n.add(c):Array.isArray(n)&&n.push(c),c}),this._event}fire(e){var t,n;if(this._listeners){this._deliveryQueue||(this._deliveryQueue=new a.S);for(let t of this._listeners)this._deliveryQueue.push([t,e]);for(null===(t=this._perfMon)||void 0===t||t.start(this._deliveryQueue.size);this._deliveryQueue.size>0;){const[e,t]=this._deliveryQueue.shift();try{"function"==typeof e?e.call(void 0,t):e[0].call(e[1],t)}catch(e){(0,r.dL)(e)}}null===(n=this._perfMon)||void 0===n||n.stop()}}dispose(){var e,t,n,i,r;this._disposed||(this._disposed=!0,null===(e=this._listeners)||void 0===e||e.clear(),null===(t=this._deliveryQueue)||void 0===t||t.clear(),null===(i=null===(n=this._options)||void 0===n?void 0:n.onLastListenerRemove)||void 0===i||i.call(n),null===(r=this._leakageMon)||void 0===r||r.dispose())}}class u extends c{constructor(e){super(e),this._isPaused=0,this._eventQueue=new a.S,this._mergeFn=null==e?void 0:e.merge}pause(){this._isPaused++}resume(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){const e=Array.from(this._eventQueue);this._eventQueue.clear(),super.fire(this._mergeFn(e))}else for(;!this._isPaused&&0!==this._eventQueue.size;)super.fire(this._eventQueue.shift())}fire(e){this._listeners&&(0!==this._isPaused?this._eventQueue.push(e):super.fire(e))}}class h extends u{constructor(e){var t;super(e),this._delay=null!==(t=e.delay)&&void 0!==t?t:100}fire(e){this._handle||(this.pause(),this._handle=setTimeout((()=>{this._handle=void 0,this.resume()}),this._delay)),super.fire(e)}}class d{constructor(){this.buffers=[]}wrapEvent(e){return(t,n,i)=>e((e=>{const i=this.buffers[this.buffers.length-1];i?i.push((()=>t.call(n,e))):t.call(n,e)}),void 0,i)}bufferEvents(e){const t=[];this.buffers.push(t);const n=e();return this.buffers.pop(),t.forEach((e=>e())),n}}class p{constructor(){this.listening=!1,this.inputEvent=i.None,this.inputEventListener=s.JT.None,this.emitter=new c({onFirstListenerDidAdd:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onLastListenerRemove:()=>{this.listening=!1,this.inputEventListener.dispose()}}),this.event=this.emitter.event}set input(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}}},17845:function(e,t,n){"use strict";function i(e){const t=this;let n,i=!1;return function(){return i||(i=!0,n=e.apply(t,arguments)),n}}n.d(t,{I:function(){return i}})},88226:function(e,t,n){"use strict";var i;n.d(t,{$:function(){return i}}),function(e){e.is=function(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]};const t=Object.freeze([]);e.empty=function(){return t},e.single=function*(e){yield e},e.from=function(e){return e||t},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){for(const n of e)if(t(n))return!0;return!1},e.find=function(e,t){for(const n of e)if(t(n))return n},e.filter=function*(e,t){for(const n of e)t(n)&&(yield n)},e.map=function*(e,t){let n=0;for(const i of e)yield t(i,n++)},e.concat=function*(...e){for(const t of e)for(const e of t)yield e},e.concatNested=function*(e){for(const t of e)for(const e of t)yield e},e.reduce=function(e,t,n){let i=n;for(const n of e)i=t(i,n);return i},e.slice=function*(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]},e.consume=function(t,n=Number.POSITIVE_INFINITY){const i=[];if(0===n)return[i,t];const r=t[Symbol.iterator]();for(let t=0;t<n;t++){const t=r.next();if(t.done)return[i,e.empty()];i.push(t.value)}return[i,{[Symbol.iterator](){return r}}]},e.equals=function(e,t,n=((e,t)=>e===t)){const i=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){const e=i.next(),t=r.next();if(e.done!==t.done)return!1;if(e.done)return!0;if(!n(e.value,t.value))return!1}}}(i||(i={}))},69323:function(e,t,n){"use strict";n.d(t,{B9:function(){return d},F8:function(){return p},JT:function(){return g},Jz:function(){return y},OF:function(){return f},SL:function(){return m},Wf:function(){return h},XK:function(){return _},dk:function(){return c}});var i=n(17845),r=n(88226);let s=null;function a(e){return null==s||s.trackDisposable(e),e}function o(e){null==s||s.markAsDisposed(e)}function l(e,t){null==s||s.setParent(e,t)}function c(e){return null==s||s.markAsSingleton(e),e}class u extends Error{constructor(e){super(`Encountered errors while disposing of store. Errors: [${e.join(", ")}]`),this.errors=e}}function h(e){return"function"==typeof e.dispose&&0===e.dispose.length}function d(e){if(r.$.is(e)){let t=[];for(const n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(1===t.length)throw t[0];if(t.length>1)throw new u(t);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function p(...e){const t=f((()=>d(e)));return function(e,t){if(s)for(const n of e)s.setParent(n,t)}(e,t),t}function f(e){const t=a({dispose:(0,i.I)((()=>{o(t),e()}))});return t}class m{constructor(){this._toDispose=new Set,this._isDisposed=!1,a(this)}dispose(){this._isDisposed||(o(this),this._isDisposed=!0,this.clear())}clear(){try{d(this._toDispose.values())}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return l(e,this),this._isDisposed?m.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}}m.DISABLE_DISPOSED_WARNING=!1;class g{constructor(){this._store=new m,a(this),l(this._store,this)}dispose(){o(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}}g.None=Object.freeze({dispose(){}});class _{constructor(){this._isDisposed=!1,a(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null===(t=this._value)||void 0===t||t.dispose(),e&&l(e,this),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,o(this),null===(e=this._value)||void 0===e||e.dispose(),this._value=void 0}clearAndLeak(){const e=this._value;return this._value=void 0,e&&l(e,null),e}}class y{constructor(e){this.object=e}dispose(){}}},34502:function(e,t,n){"use strict";n.d(t,{S:function(){return r}});class i{constructor(e){this.element=e,this.next=i.Undefined,this.prev=i.Undefined}}i.Undefined=new i(void 0);class r{constructor(){this._first=i.Undefined,this._last=i.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===i.Undefined}clear(){let e=this._first;for(;e!==i.Undefined;){const t=e.next;e.prev=i.Undefined,e.next=i.Undefined,e=t}this._first=i.Undefined,this._last=i.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){const n=new i(e);if(this._first===i.Undefined)this._first=n,this._last=n;else if(t){const e=this._last;this._last=n,n.prev=e,e.next=n}else{const e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==i.Undefined){const e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==i.Undefined){const e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==i.Undefined&&e.next!==i.Undefined){const t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===i.Undefined&&e.next===i.Undefined?(this._first=i.Undefined,this._last=i.Undefined):e.next===i.Undefined?(this._last=this._last.prev,this._last.next=i.Undefined):e.prev===i.Undefined&&(this._first=this._first.next,this._first.prev=i.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==i.Undefined;)yield e.element,e=e.next}}},23345:function(e,t,n){"use strict";n.d(t,{$L:function(){return E},ED:function(){return w},IJ:function(){return k},OS:function(){return A},WE:function(){return C},dz:function(){return x},gn:function(){return T},li:function(){return _},r:function(){return R},tY:function(){return S},xS:function(){return L}});var i,r=n(97671);const s="en";let a,o,l=!1,c=!1,u=!1,h=!1,d=!1,p=!1,f=!1,m=null,g=null;const _="object"==typeof self?self:"object"==typeof n.g?n.g:{};let y;void 0!==_.vscode&&void 0!==_.vscode.process?y=_.vscode.process:void 0!==r&&(y=r);const v="string"==typeof(null===(i=null==y?void 0:y.versions)||void 0===i?void 0:i.electron)&&"renderer"===y.type;if("object"!=typeof navigator||v)if("object"==typeof y){l="win32"===y.platform,c="darwin"===y.platform,u="linux"===y.platform,h=u&&!!y.env.SNAP&&!!y.env.SNAP_REVISION,a=s,m=s;const e=y.env.VSCODE_NLS_CONFIG;if(e)try{const t=JSON.parse(e),n=t.availableLanguages["*"];a=t.locale,m=n||s,g=t._translationsConfigFile}catch(e){}d=!0}else console.error("Unable to resolve platform.");else o=navigator.userAgent,l=o.indexOf("Windows")>=0,c=o.indexOf("Macintosh")>=0,f=(o.indexOf("Macintosh")>=0||o.indexOf("iPad")>=0||o.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,u=o.indexOf("Linux")>=0,p=!0,a=navigator.language,m=a;let b=0;c?b=1:l?b=3:u&&(b=2);const w=l,x=c,k=u,S=d,E=p,T=f,C=o,L=function(){if(_.setImmediate)return _.setImmediate.bind(_);if("function"==typeof _.postMessage&&!_.importScripts){let e=[];_.addEventListener("message",(t=>{if(t.data&&t.data.vscodeSetImmediateId)for(let n=0,i=e.length;n<i;n++){const i=e[n];if(i.id===t.data.vscodeSetImmediateId)return e.splice(n,1),void i.callback()}}));let t=0;return n=>{const i=++t;e.push({id:i,callback:n}),_.postMessage({vscodeSetImmediateId:i},"*")}}if("function"==typeof(null==y?void 0:y.nextTick))return y.nextTick.bind(y);const e=Promise.resolve();return t=>e.then(t)}(),A=c||f?2:l?1:3;let D=!0,M=!1;function R(){if(!M){M=!0;const e=new Uint8Array(2);e[0]=1,e[1]=2;const t=new Uint16Array(e.buffer);D=513===t[0]}return D}},95830:function(e,t,n){"use strict";n.d(t,{G:function(){return s}});var i=n(23345);const r=i.li.performance&&"function"==typeof i.li.performance.now;class s{constructor(e){this._highResolution=r&&e,this._startTime=this._now(),this._stopTime=-1}static create(e=!0){return new s(e)}stop(){this._stopTime=this._now()}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}_now(){return this._highResolution?i.li.performance.now():Date.now()}}},82983:function(e,t,n){"use strict";function i(e){return!e||"string"!=typeof e||0===e.trim().length}n.d(t,{$i:function(){return z},C8:function(){return j},GF:function(){return p},HO:function(){return F},IO:function(){return f},K7:function(){return H},Kw:function(){return Y},LC:function(){return _},Mh:function(){return L},P1:function(){return A},PJ:function(){return X},Qe:function(){return V},R1:function(){return d},RP:function(){return K},S6:function(){return J},TT:function(){return w},Ut:function(){return B},V8:function(){return y},WU:function(){return s},YK:function(){return M},YU:function(){return a},ZG:function(){return D},ZH:function(){return I},ab:function(){return q},c1:function(){return W},df:function(){return E},ec:function(){return o},fi:function(){return Q},fy:function(){return l},j3:function(){return c},j_:function(){return k},m5:function(){return i},mK:function(){return S},mr:function(){return m},oH:function(){return te},oL:function(){return u},ok:function(){return C},ow:function(){return v},qq:function(){return T},qu:function(){return b},rL:function(){return R},uS:function(){return Z},un:function(){return h},uq:function(){return g},vH:function(){return O},xe:function(){return G},zY:function(){return x}});const r=/{(\d+)}/g;function s(e,...t){return 0===t.length?e:e.replace(r,(function(e,n){const i=parseInt(n,10);return isNaN(i)||i<0||i>=t.length?e:t[i]}))}function a(e){return e.replace(/[<>&]/g,(function(e){switch(e){case"<":return"<";case">":return">";case"&":return"&";default:return e}}))}function o(e){return e.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g,"\\$&")}function l(e,t=" "){return u(c(e,t),t)}function c(e,t){if(!e||!t)return e;const n=t.length;if(0===n||0===e.length)return e;let i=0;for(;e.indexOf(t,i)===i;)i+=n;return e.substring(i)}function u(e,t){if(!e||!t)return e;const n=t.length,i=e.length;if(0===n||0===i)return e;let r=i,s=-1;for(;s=e.lastIndexOf(t,r-1),-1!==s&&s+n===r;){if(0===s)return"";r=s}return e.substring(0,r)}function h(e){return e.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&").replace(/[\*]/g,".*")}function d(e){return e.replace(/\*/g,"")}function p(e,t,n={}){if(!e)throw new Error("Cannot create regex from empty string");t||(e=o(e)),n.wholeWord&&(/\B/.test(e.charAt(0))||(e="\\b"+e),/\B/.test(e.charAt(e.length-1))||(e+="\\b"));let i="";return n.global&&(i+="g"),n.matchCase||(i+="i"),n.multiline&&(i+="m"),n.unicode&&(i+="u"),new RegExp(e,i)}function f(e){if("^"===e.source||"^$"===e.source||"$"===e.source||"^\\s*$"===e.source)return!1;return!(!e.exec("")||0!==e.lastIndex)}function m(e){return(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")}function g(e){return e.split(/\r\n|\r|\n/)}function _(e){for(let t=0,n=e.length;t<n;t++){const n=e.charCodeAt(t);if(32!==n&&9!==n)return t}return-1}function y(e,t=0,n=e.length){for(let i=t;i<n;i++){const n=e.charCodeAt(i);if(32!==n&&9!==n)return e.substring(t,i)}return e.substring(t,n)}function v(e,t=e.length-1){for(let n=t;n>=0;n--){const t=e.charCodeAt(n);if(32!==t&&9!==t)return n}return-1}function b(e,t){return e<t?-1:e>t?1:0}function w(e,t,n=0,i=e.length,r=0,s=t.length){for(;n<i&&r<s;n++,r++){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(i<s)return-1;if(i>s)return 1}const a=i-n,o=s-r;return a<o?-1:a>o?1:0}function x(e,t){return k(e,t,0,e.length,0,t.length)}function k(e,t,n=0,i=e.length,r=0,s=t.length){for(;n<i&&r<s;n++,r++){let a=e.charCodeAt(n),o=t.charCodeAt(r);if(a===o)continue;if(a>=128||o>=128)return w(e.toLowerCase(),t.toLowerCase(),n,i,r,s);S(a)&&(a-=32),S(o)&&(o-=32);const l=a-o;if(0!==l)return l}const a=i-n,o=s-r;return a<o?-1:a>o?1:0}function S(e){return e>=97&&e<=122}function E(e){return e>=65&&e<=90}function T(e,t){return e.length===t.length&&0===k(e,t)}function C(e,t){const n=t.length;return!(t.length>e.length)&&0===k(e,t,0,n)}function L(e,t){let n,i=Math.min(e.length,t.length);for(n=0;n<i;n++)if(e.charCodeAt(n)!==t.charCodeAt(n))return n;return i}function A(e,t){let n,i=Math.min(e.length,t.length);const r=e.length-1,s=t.length-1;for(n=0;n<i;n++)if(e.charCodeAt(r-n)!==t.charCodeAt(s-n))return n;return i}function D(e){return 55296<=e&&e<=56319}function M(e){return 56320<=e&&e<=57343}function R(e,t){return t-56320+(e-55296<<10)+65536}function I(e,t,n){const i=e.charCodeAt(n);if(D(i)&&n+1<t){const t=e.charCodeAt(n+1);if(M(t))return R(i,t)}return i}function P(e,t){const n=e.charCodeAt(t-1);if(M(n)&&t>1){const i=e.charCodeAt(t-2);if(D(i))return R(i,n)}return n}function O(e,t){const n=ee.getInstance(),i=t,r=e.length,s=I(e,r,t);t+=s>=65536?2:1;let a=n.getGraphemeBreakType(s);for(;t<r;){const i=I(e,r,t),s=n.getGraphemeBreakType(i);if(Q(a,s))break;t+=i>=65536?2:1,a=s}return t-i}function F(e,t){const n=ee.getInstance(),i=t,r=P(e,t);t-=r>=65536?2:1;let s=n.getGraphemeBreakType(r);for(;t>0;){const i=P(e,t),r=n.getGraphemeBreakType(i);if(Q(r,s))break;t-=i>=65536?2:1,s=r}return i-t}const N=/(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u08BD\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE33\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDCFF]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD50-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;function B(e){return N.test(e)}const $=/(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD00-\uDDFF\uDE70-\uDED6])/;function K(e){return $.test(e)}const U=/^[\t\n\r\x20-\x7E]*$/;function z(e){return U.test(e)}const V=/[\u2028\u2029]/;function q(e){return V.test(e)}function G(e){for(let t=0,n=e.length;t<n;t++)if(H(e.charCodeAt(t)))return!0;return!1}function H(e){return(e=+e)>=11904&&e<=55215||e>=63744&&e<=64255||e>=65281&&e<=65374}function j(e){return e>=127462&&e<=127487||8986===e||8987===e||9200===e||9203===e||e>=9728&&e<=10175||11088===e||11093===e||e>=127744&&e<=128591||e>=128640&&e<=128764||e>=128992&&e<=129003||e>=129280&&e<=129535||e>=129648&&e<=129750}const W=String.fromCharCode(65279);function Z(e){return!!(e&&e.length>0&&65279===e.charCodeAt(0))}function Y(e,t=!1){return!!e&&(t&&(e=e.replace(/\\./g,"")),e.toLowerCase()!==e)}function X(e){return(e%=52)<26?String.fromCharCode(97+e):String.fromCharCode(65+e-26)}function J(e){return ee.getInstance().getGraphemeBreakType(e)}function Q(e,t){return 0===e?5!==t&&7!==t:(2!==e||3!==t)&&(4===e||2===e||3===e||(4===t||2===t||3===t||(8!==e||8!==t&&9!==t&&11!==t&&12!==t)&&((11!==e&&9!==e||9!==t&&10!==t)&&((12!==e&&10!==e||10!==t)&&(5!==t&&13!==t&&(7!==t&&(1!==e&&((13!==e||14!==t)&&(6!==e||6!==t)))))))))}class ee{constructor(){this._data=JSON.parse("[0,0,0,51592,51592,11,44424,44424,11,72251,72254,5,7150,7150,7,48008,48008,11,55176,55176,11,128420,128420,14,3276,3277,5,9979,9980,14,46216,46216,11,49800,49800,11,53384,53384,11,70726,70726,5,122915,122916,5,129320,129327,14,2558,2558,5,5906,5908,5,9762,9763,14,43360,43388,8,45320,45320,11,47112,47112,11,48904,48904,11,50696,50696,11,52488,52488,11,54280,54280,11,70082,70083,1,71350,71350,7,73111,73111,5,127892,127893,14,128726,128727,14,129473,129474,14,2027,2035,5,2901,2902,5,3784,3789,5,6754,6754,5,8418,8420,5,9877,9877,14,11088,11088,14,44008,44008,5,44872,44872,11,45768,45768,11,46664,46664,11,47560,47560,11,48456,48456,11,49352,49352,11,50248,50248,11,51144,51144,11,52040,52040,11,52936,52936,11,53832,53832,11,54728,54728,11,69811,69814,5,70459,70460,5,71096,71099,7,71998,71998,5,72874,72880,5,119149,119149,7,127374,127374,14,128335,128335,14,128482,128482,14,128765,128767,14,129399,129400,14,129680,129685,14,1476,1477,5,2377,2380,7,2759,2760,5,3137,3140,7,3458,3459,7,4153,4154,5,6432,6434,5,6978,6978,5,7675,7679,5,9723,9726,14,9823,9823,14,9919,9923,14,10035,10036,14,42736,42737,5,43596,43596,5,44200,44200,11,44648,44648,11,45096,45096,11,45544,45544,11,45992,45992,11,46440,46440,11,46888,46888,11,47336,47336,11,47784,47784,11,48232,48232,11,48680,48680,11,49128,49128,11,49576,49576,11,50024,50024,11,50472,50472,11,50920,50920,11,51368,51368,11,51816,51816,11,52264,52264,11,52712,52712,11,53160,53160,11,53608,53608,11,54056,54056,11,54504,54504,11,54952,54952,11,68108,68111,5,69933,69940,5,70197,70197,7,70498,70499,7,70845,70845,5,71229,71229,5,71727,71735,5,72154,72155,5,72344,72345,5,73023,73029,5,94095,94098,5,121403,121452,5,126981,127182,14,127538,127546,14,127990,127990,14,128391,128391,14,128445,128449,14,128500,128505,14,128752,128752,14,129160,129167,14,129356,129356,14,129432,129442,14,129648,129651,14,129751,131069,14,173,173,4,1757,1757,1,2274,2274,1,2494,2494,5,2641,2641,5,2876,2876,5,3014,3016,7,3262,3262,7,3393,3396,5,3570,3571,7,3968,3972,5,4228,4228,7,6086,6086,5,6679,6680,5,6912,6915,5,7080,7081,5,7380,7392,5,8252,8252,14,9096,9096,14,9748,9749,14,9784,9786,14,9833,9850,14,9890,9894,14,9938,9938,14,9999,9999,14,10085,10087,14,12349,12349,14,43136,43137,7,43454,43456,7,43755,43755,7,44088,44088,11,44312,44312,11,44536,44536,11,44760,44760,11,44984,44984,11,45208,45208,11,45432,45432,11,45656,45656,11,45880,45880,11,46104,46104,11,46328,46328,11,46552,46552,11,46776,46776,11,47000,47000,11,47224,47224,11,47448,47448,11,47672,47672,11,47896,47896,11,48120,48120,11,48344,48344,11,48568,48568,11,48792,48792,11,49016,49016,11,49240,49240,11,49464,49464,11,49688,49688,11,49912,49912,11,50136,50136,11,50360,50360,11,50584,50584,11,50808,50808,11,51032,51032,11,51256,51256,11,51480,51480,11,51704,51704,11,51928,51928,11,52152,52152,11,52376,52376,11,52600,52600,11,52824,52824,11,53048,53048,11,53272,53272,11,53496,53496,11,53720,53720,11,53944,53944,11,54168,54168,11,54392,54392,11,54616,54616,11,54840,54840,11,55064,55064,11,65438,65439,5,69633,69633,5,69837,69837,1,70018,70018,7,70188,70190,7,70368,70370,7,70465,70468,7,70712,70719,5,70835,70840,5,70850,70851,5,71132,71133,5,71340,71340,7,71458,71461,5,71985,71989,7,72002,72002,7,72193,72202,5,72281,72283,5,72766,72766,7,72885,72886,5,73104,73105,5,92912,92916,5,113824,113827,4,119173,119179,5,121505,121519,5,125136,125142,5,127279,127279,14,127489,127490,14,127570,127743,14,127900,127901,14,128254,128254,14,128369,128370,14,128400,128400,14,128425,128432,14,128468,128475,14,128489,128494,14,128715,128720,14,128745,128745,14,128759,128760,14,129004,129023,14,129296,129304,14,129340,129342,14,129388,129392,14,129404,129407,14,129454,129455,14,129485,129487,14,129659,129663,14,129719,129727,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2363,2363,7,2402,2403,5,2507,2508,7,2622,2624,7,2691,2691,7,2786,2787,5,2881,2884,5,3006,3006,5,3072,3072,5,3170,3171,5,3267,3268,7,3330,3331,7,3406,3406,1,3538,3540,5,3655,3662,5,3897,3897,5,4038,4038,5,4184,4185,5,4352,4447,8,6068,6069,5,6155,6157,5,6448,6449,7,6742,6742,5,6783,6783,5,6966,6970,5,7042,7042,7,7143,7143,7,7212,7219,5,7412,7412,5,8206,8207,4,8294,8303,4,8596,8601,14,9410,9410,14,9742,9742,14,9757,9757,14,9770,9770,14,9794,9794,14,9828,9828,14,9855,9855,14,9882,9882,14,9900,9903,14,9929,9933,14,9963,9967,14,9987,9988,14,10006,10006,14,10062,10062,14,10175,10175,14,11744,11775,5,42607,42607,5,43043,43044,7,43263,43263,5,43444,43445,7,43569,43570,5,43698,43700,5,43766,43766,5,44032,44032,11,44144,44144,11,44256,44256,11,44368,44368,11,44480,44480,11,44592,44592,11,44704,44704,11,44816,44816,11,44928,44928,11,45040,45040,11,45152,45152,11,45264,45264,11,45376,45376,11,45488,45488,11,45600,45600,11,45712,45712,11,45824,45824,11,45936,45936,11,46048,46048,11,46160,46160,11,46272,46272,11,46384,46384,11,46496,46496,11,46608,46608,11,46720,46720,11,46832,46832,11,46944,46944,11,47056,47056,11,47168,47168,11,47280,47280,11,47392,47392,11,47504,47504,11,47616,47616,11,47728,47728,11,47840,47840,11,47952,47952,11,48064,48064,11,48176,48176,11,48288,48288,11,48400,48400,11,48512,48512,11,48624,48624,11,48736,48736,11,48848,48848,11,48960,48960,11,49072,49072,11,49184,49184,11,49296,49296,11,49408,49408,11,49520,49520,11,49632,49632,11,49744,49744,11,49856,49856,11,49968,49968,11,50080,50080,11,50192,50192,11,50304,50304,11,50416,50416,11,50528,50528,11,50640,50640,11,50752,50752,11,50864,50864,11,50976,50976,11,51088,51088,11,51200,51200,11,51312,51312,11,51424,51424,11,51536,51536,11,51648,51648,11,51760,51760,11,51872,51872,11,51984,51984,11,52096,52096,11,52208,52208,11,52320,52320,11,52432,52432,11,52544,52544,11,52656,52656,11,52768,52768,11,52880,52880,11,52992,52992,11,53104,53104,11,53216,53216,11,53328,53328,11,53440,53440,11,53552,53552,11,53664,53664,11,53776,53776,11,53888,53888,11,54000,54000,11,54112,54112,11,54224,54224,11,54336,54336,11,54448,54448,11,54560,54560,11,54672,54672,11,54784,54784,11,54896,54896,11,55008,55008,11,55120,55120,11,64286,64286,5,66272,66272,5,68900,68903,5,69762,69762,7,69817,69818,5,69927,69931,5,70003,70003,5,70070,70078,5,70094,70094,7,70194,70195,7,70206,70206,5,70400,70401,5,70463,70463,7,70475,70477,7,70512,70516,5,70722,70724,5,70832,70832,5,70842,70842,5,70847,70848,5,71088,71089,7,71102,71102,7,71219,71226,5,71231,71232,5,71342,71343,7,71453,71455,5,71463,71467,5,71737,71738,5,71995,71996,5,72000,72000,7,72145,72147,7,72160,72160,5,72249,72249,7,72273,72278,5,72330,72342,5,72752,72758,5,72850,72871,5,72882,72883,5,73018,73018,5,73031,73031,5,73109,73109,5,73461,73462,7,94031,94031,5,94192,94193,7,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,126976,126979,14,127184,127231,14,127344,127345,14,127405,127461,14,127514,127514,14,127561,127567,14,127778,127779,14,127896,127896,14,127985,127986,14,127995,127999,5,128326,128328,14,128360,128366,14,128378,128378,14,128394,128397,14,128405,128406,14,128422,128423,14,128435,128443,14,128453,128464,14,128479,128480,14,128484,128487,14,128496,128498,14,128640,128709,14,128723,128724,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129096,129103,14,129292,129292,14,129311,129311,14,129329,129330,14,129344,129349,14,129360,129374,14,129394,129394,14,129402,129402,14,129413,129425,14,129445,129450,14,129466,129471,14,129483,129483,14,129511,129535,14,129653,129655,14,129667,129670,14,129705,129711,14,129731,129743,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2307,2307,7,2366,2368,7,2382,2383,7,2434,2435,7,2497,2500,5,2519,2519,5,2563,2563,7,2631,2632,5,2677,2677,5,2750,2752,7,2763,2764,7,2817,2817,5,2879,2879,5,2891,2892,7,2914,2915,5,3008,3008,5,3021,3021,5,3076,3076,5,3146,3149,5,3202,3203,7,3264,3265,7,3271,3272,7,3298,3299,5,3390,3390,5,3402,3404,7,3426,3427,5,3535,3535,5,3544,3550,7,3635,3635,7,3763,3763,7,3893,3893,5,3953,3966,5,3981,3991,5,4145,4145,7,4157,4158,5,4209,4212,5,4237,4237,5,4520,4607,10,5970,5971,5,6071,6077,5,6089,6099,5,6277,6278,5,6439,6440,5,6451,6456,7,6683,6683,5,6744,6750,5,6765,6770,7,6846,6846,5,6964,6964,5,6972,6972,5,7019,7027,5,7074,7077,5,7083,7085,5,7146,7148,7,7154,7155,7,7222,7223,5,7394,7400,5,7416,7417,5,8204,8204,5,8233,8233,4,8288,8292,4,8413,8416,5,8482,8482,14,8986,8987,14,9193,9203,14,9654,9654,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9775,14,9792,9792,14,9800,9811,14,9825,9826,14,9831,9831,14,9852,9853,14,9872,9873,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9936,9936,14,9941,9960,14,9974,9974,14,9982,9985,14,9992,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10145,10145,14,11013,11015,14,11503,11505,5,12334,12335,5,12951,12951,14,42612,42621,5,43014,43014,5,43047,43047,7,43204,43205,5,43335,43345,5,43395,43395,7,43450,43451,7,43561,43566,5,43573,43574,5,43644,43644,5,43710,43711,5,43758,43759,7,44005,44005,5,44012,44012,7,44060,44060,11,44116,44116,11,44172,44172,11,44228,44228,11,44284,44284,11,44340,44340,11,44396,44396,11,44452,44452,11,44508,44508,11,44564,44564,11,44620,44620,11,44676,44676,11,44732,44732,11,44788,44788,11,44844,44844,11,44900,44900,11,44956,44956,11,45012,45012,11,45068,45068,11,45124,45124,11,45180,45180,11,45236,45236,11,45292,45292,11,45348,45348,11,45404,45404,11,45460,45460,11,45516,45516,11,45572,45572,11,45628,45628,11,45684,45684,11,45740,45740,11,45796,45796,11,45852,45852,11,45908,45908,11,45964,45964,11,46020,46020,11,46076,46076,11,46132,46132,11,46188,46188,11,46244,46244,11,46300,46300,11,46356,46356,11,46412,46412,11,46468,46468,11,46524,46524,11,46580,46580,11,46636,46636,11,46692,46692,11,46748,46748,11,46804,46804,11,46860,46860,11,46916,46916,11,46972,46972,11,47028,47028,11,47084,47084,11,47140,47140,11,47196,47196,11,47252,47252,11,47308,47308,11,47364,47364,11,47420,47420,11,47476,47476,11,47532,47532,11,47588,47588,11,47644,47644,11,47700,47700,11,47756,47756,11,47812,47812,11,47868,47868,11,47924,47924,11,47980,47980,11,48036,48036,11,48092,48092,11,48148,48148,11,48204,48204,11,48260,48260,11,48316,48316,11,48372,48372,11,48428,48428,11,48484,48484,11,48540,48540,11,48596,48596,11,48652,48652,11,48708,48708,11,48764,48764,11,48820,48820,11,48876,48876,11,48932,48932,11,48988,48988,11,49044,49044,11,49100,49100,11,49156,49156,11,49212,49212,11,49268,49268,11,49324,49324,11,49380,49380,11,49436,49436,11,49492,49492,11,49548,49548,11,49604,49604,11,49660,49660,11,49716,49716,11,49772,49772,11,49828,49828,11,49884,49884,11,49940,49940,11,49996,49996,11,50052,50052,11,50108,50108,11,50164,50164,11,50220,50220,11,50276,50276,11,50332,50332,11,50388,50388,11,50444,50444,11,50500,50500,11,50556,50556,11,50612,50612,11,50668,50668,11,50724,50724,11,50780,50780,11,50836,50836,11,50892,50892,11,50948,50948,11,51004,51004,11,51060,51060,11,51116,51116,11,51172,51172,11,51228,51228,11,51284,51284,11,51340,51340,11,51396,51396,11,51452,51452,11,51508,51508,11,51564,51564,11,51620,51620,11,51676,51676,11,51732,51732,11,51788,51788,11,51844,51844,11,51900,51900,11,51956,51956,11,52012,52012,11,52068,52068,11,52124,52124,11,52180,52180,11,52236,52236,11,52292,52292,11,52348,52348,11,52404,52404,11,52460,52460,11,52516,52516,11,52572,52572,11,52628,52628,11,52684,52684,11,52740,52740,11,52796,52796,11,52852,52852,11,52908,52908,11,52964,52964,11,53020,53020,11,53076,53076,11,53132,53132,11,53188,53188,11,53244,53244,11,53300,53300,11,53356,53356,11,53412,53412,11,53468,53468,11,53524,53524,11,53580,53580,11,53636,53636,11,53692,53692,11,53748,53748,11,53804,53804,11,53860,53860,11,53916,53916,11,53972,53972,11,54028,54028,11,54084,54084,11,54140,54140,11,54196,54196,11,54252,54252,11,54308,54308,11,54364,54364,11,54420,54420,11,54476,54476,11,54532,54532,11,54588,54588,11,54644,54644,11,54700,54700,11,54756,54756,11,54812,54812,11,54868,54868,11,54924,54924,11,54980,54980,11,55036,55036,11,55092,55092,11,55148,55148,11,55216,55238,9,65056,65071,5,65529,65531,4,68097,68099,5,68159,68159,5,69446,69456,5,69688,69702,5,69808,69810,7,69815,69816,7,69821,69821,1,69888,69890,5,69932,69932,7,69957,69958,7,70016,70017,5,70067,70069,7,70079,70080,7,70089,70092,5,70095,70095,5,70191,70193,5,70196,70196,5,70198,70199,5,70367,70367,5,70371,70378,5,70402,70403,7,70462,70462,5,70464,70464,5,70471,70472,7,70487,70487,5,70502,70508,5,70709,70711,7,70720,70721,7,70725,70725,7,70750,70750,5,70833,70834,7,70841,70841,7,70843,70844,7,70846,70846,7,70849,70849,7,71087,71087,5,71090,71093,5,71100,71101,5,71103,71104,5,71216,71218,7,71227,71228,7,71230,71230,7,71339,71339,5,71341,71341,5,71344,71349,5,71351,71351,5,71456,71457,7,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123628,123631,5,125252,125258,5,126980,126980,14,127183,127183,14,127245,127247,14,127340,127343,14,127358,127359,14,127377,127386,14,127462,127487,6,127491,127503,14,127535,127535,14,127548,127551,14,127568,127569,14,127744,127777,14,127780,127891,14,127894,127895,14,127897,127899,14,127902,127984,14,127987,127989,14,127991,127994,14,128000,128253,14,128255,128317,14,128329,128334,14,128336,128359,14,128367,128368,14,128371,128377,14,128379,128390,14,128392,128393,14,128398,128399,14,128401,128404,14,128407,128419,14,128421,128421,14,128424,128424,14,128433,128434,14,128444,128444,14,128450,128452,14,128465,128467,14,128476,128478,14,128481,128481,14,128483,128483,14,128488,128488,14,128495,128495,14,128499,128499,14,128506,128591,14,128710,128714,14,128721,128722,14,128725,128725,14,128728,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129664,129666,14,129671,129679,14,129686,129704,14,129712,129718,14,129728,129730,14,129744,129750,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2259,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3134,3136,5,3142,3144,5,3157,3158,5,3201,3201,5,3260,3260,5,3263,3263,5,3266,3266,5,3270,3270,5,3274,3275,7,3285,3286,5,3328,3329,5,3387,3388,5,3391,3392,7,3398,3400,7,3405,3405,5,3415,3415,5,3457,3457,5,3530,3530,5,3536,3537,7,3542,3542,5,3551,3551,5,3633,3633,5,3636,3642,5,3761,3761,5,3764,3772,5,3864,3865,5,3895,3895,5,3902,3903,7,3967,3967,7,3974,3975,5,3993,4028,5,4141,4144,5,4146,4151,5,4155,4156,7,4182,4183,7,4190,4192,5,4226,4226,5,4229,4230,5,4253,4253,5,4448,4519,9,4957,4959,5,5938,5940,5,6002,6003,5,6070,6070,7,6078,6085,7,6087,6088,7,6109,6109,5,6158,6158,4,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6848,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7673,5,8203,8203,4,8205,8205,13,8232,8232,4,8234,8238,4,8265,8265,14,8293,8293,4,8400,8412,5,8417,8417,5,8421,8432,5,8505,8505,14,8617,8618,14,9000,9000,14,9167,9167,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9776,9783,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9935,14,9937,9937,14,9939,9940,14,9961,9962,14,9968,9973,14,9975,9978,14,9981,9981,14,9986,9986,14,9989,9989,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10084,14,10133,10135,14,10160,10160,14,10548,10549,14,11035,11036,14,11093,11093,14,11647,11647,5,12330,12333,5,12336,12336,14,12441,12442,5,12953,12953,14,42608,42610,5,42654,42655,5,43010,43010,5,43019,43019,5,43045,43046,5,43052,43052,5,43188,43203,7,43232,43249,5,43302,43309,5,43346,43347,7,43392,43394,5,43443,43443,5,43446,43449,5,43452,43453,5,43493,43493,5,43567,43568,7,43571,43572,7,43587,43587,5,43597,43597,7,43696,43696,5,43703,43704,5,43713,43713,5,43756,43757,5,43765,43765,7,44003,44004,7,44006,44007,7,44009,44010,7,44013,44013,5,44033,44059,12,44061,44087,12,44089,44115,12,44117,44143,12,44145,44171,12,44173,44199,12,44201,44227,12,44229,44255,12,44257,44283,12,44285,44311,12,44313,44339,12,44341,44367,12,44369,44395,12,44397,44423,12,44425,44451,12,44453,44479,12,44481,44507,12,44509,44535,12,44537,44563,12,44565,44591,12,44593,44619,12,44621,44647,12,44649,44675,12,44677,44703,12,44705,44731,12,44733,44759,12,44761,44787,12,44789,44815,12,44817,44843,12,44845,44871,12,44873,44899,12,44901,44927,12,44929,44955,12,44957,44983,12,44985,45011,12,45013,45039,12,45041,45067,12,45069,45095,12,45097,45123,12,45125,45151,12,45153,45179,12,45181,45207,12,45209,45235,12,45237,45263,12,45265,45291,12,45293,45319,12,45321,45347,12,45349,45375,12,45377,45403,12,45405,45431,12,45433,45459,12,45461,45487,12,45489,45515,12,45517,45543,12,45545,45571,12,45573,45599,12,45601,45627,12,45629,45655,12,45657,45683,12,45685,45711,12,45713,45739,12,45741,45767,12,45769,45795,12,45797,45823,12,45825,45851,12,45853,45879,12,45881,45907,12,45909,45935,12,45937,45963,12,45965,45991,12,45993,46019,12,46021,46047,12,46049,46075,12,46077,46103,12,46105,46131,12,46133,46159,12,46161,46187,12,46189,46215,12,46217,46243,12,46245,46271,12,46273,46299,12,46301,46327,12,46329,46355,12,46357,46383,12,46385,46411,12,46413,46439,12,46441,46467,12,46469,46495,12,46497,46523,12,46525,46551,12,46553,46579,12,46581,46607,12,46609,46635,12,46637,46663,12,46665,46691,12,46693,46719,12,46721,46747,12,46749,46775,12,46777,46803,12,46805,46831,12,46833,46859,12,46861,46887,12,46889,46915,12,46917,46943,12,46945,46971,12,46973,46999,12,47001,47027,12,47029,47055,12,47057,47083,12,47085,47111,12,47113,47139,12,47141,47167,12,47169,47195,12,47197,47223,12,47225,47251,12,47253,47279,12,47281,47307,12,47309,47335,12,47337,47363,12,47365,47391,12,47393,47419,12,47421,47447,12,47449,47475,12,47477,47503,12,47505,47531,12,47533,47559,12,47561,47587,12,47589,47615,12,47617,47643,12,47645,47671,12,47673,47699,12,47701,47727,12,47729,47755,12,47757,47783,12,47785,47811,12,47813,47839,12,47841,47867,12,47869,47895,12,47897,47923,12,47925,47951,12,47953,47979,12,47981,48007,12,48009,48035,12,48037,48063,12,48065,48091,12,48093,48119,12,48121,48147,12,48149,48175,12,48177,48203,12,48205,48231,12,48233,48259,12,48261,48287,12,48289,48315,12,48317,48343,12,48345,48371,12,48373,48399,12,48401,48427,12,48429,48455,12,48457,48483,12,48485,48511,12,48513,48539,12,48541,48567,12,48569,48595,12,48597,48623,12,48625,48651,12,48653,48679,12,48681,48707,12,48709,48735,12,48737,48763,12,48765,48791,12,48793,48819,12,48821,48847,12,48849,48875,12,48877,48903,12,48905,48931,12,48933,48959,12,48961,48987,12,48989,49015,12,49017,49043,12,49045,49071,12,49073,49099,12,49101,49127,12,49129,49155,12,49157,49183,12,49185,49211,12,49213,49239,12,49241,49267,12,49269,49295,12,49297,49323,12,49325,49351,12,49353,49379,12,49381,49407,12,49409,49435,12,49437,49463,12,49465,49491,12,49493,49519,12,49521,49547,12,49549,49575,12,49577,49603,12,49605,49631,12,49633,49659,12,49661,49687,12,49689,49715,12,49717,49743,12,49745,49771,12,49773,49799,12,49801,49827,12,49829,49855,12,49857,49883,12,49885,49911,12,49913,49939,12,49941,49967,12,49969,49995,12,49997,50023,12,50025,50051,12,50053,50079,12,50081,50107,12,50109,50135,12,50137,50163,12,50165,50191,12,50193,50219,12,50221,50247,12,50249,50275,12,50277,50303,12,50305,50331,12,50333,50359,12,50361,50387,12,50389,50415,12,50417,50443,12,50445,50471,12,50473,50499,12,50501,50527,12,50529,50555,12,50557,50583,12,50585,50611,12,50613,50639,12,50641,50667,12,50669,50695,12,50697,50723,12,50725,50751,12,50753,50779,12,50781,50807,12,50809,50835,12,50837,50863,12,50865,50891,12,50893,50919,12,50921,50947,12,50949,50975,12,50977,51003,12,51005,51031,12,51033,51059,12,51061,51087,12,51089,51115,12,51117,51143,12,51145,51171,12,51173,51199,12,51201,51227,12,51229,51255,12,51257,51283,12,51285,51311,12,51313,51339,12,51341,51367,12,51369,51395,12,51397,51423,12,51425,51451,12,51453,51479,12,51481,51507,12,51509,51535,12,51537,51563,12,51565,51591,12,51593,51619,12,51621,51647,12,51649,51675,12,51677,51703,12,51705,51731,12,51733,51759,12,51761,51787,12,51789,51815,12,51817,51843,12,51845,51871,12,51873,51899,12,51901,51927,12,51929,51955,12,51957,51983,12,51985,52011,12,52013,52039,12,52041,52067,12,52069,52095,12,52097,52123,12,52125,52151,12,52153,52179,12,52181,52207,12,52209,52235,12,52237,52263,12,52265,52291,12,52293,52319,12,52321,52347,12,52349,52375,12,52377,52403,12,52405,52431,12,52433,52459,12,52461,52487,12,52489,52515,12,52517,52543,12,52545,52571,12,52573,52599,12,52601,52627,12,52629,52655,12,52657,52683,12,52685,52711,12,52713,52739,12,52741,52767,12,52769,52795,12,52797,52823,12,52825,52851,12,52853,52879,12,52881,52907,12,52909,52935,12,52937,52963,12,52965,52991,12,52993,53019,12,53021,53047,12,53049,53075,12,53077,53103,12,53105,53131,12,53133,53159,12,53161,53187,12,53189,53215,12,53217,53243,12,53245,53271,12,53273,53299,12,53301,53327,12,53329,53355,12,53357,53383,12,53385,53411,12,53413,53439,12,53441,53467,12,53469,53495,12,53497,53523,12,53525,53551,12,53553,53579,12,53581,53607,12,53609,53635,12,53637,53663,12,53665,53691,12,53693,53719,12,53721,53747,12,53749,53775,12,53777,53803,12,53805,53831,12,53833,53859,12,53861,53887,12,53889,53915,12,53917,53943,12,53945,53971,12,53973,53999,12,54001,54027,12,54029,54055,12,54057,54083,12,54085,54111,12,54113,54139,12,54141,54167,12,54169,54195,12,54197,54223,12,54225,54251,12,54253,54279,12,54281,54307,12,54309,54335,12,54337,54363,12,54365,54391,12,54393,54419,12,54421,54447,12,54449,54475,12,54477,54503,12,54505,54531,12,54533,54559,12,54561,54587,12,54589,54615,12,54617,54643,12,54645,54671,12,54673,54699,12,54701,54727,12,54729,54755,12,54757,54783,12,54785,54811,12,54813,54839,12,54841,54867,12,54869,54895,12,54897,54923,12,54925,54951,12,54953,54979,12,54981,55007,12,55009,55035,12,55037,55063,12,55065,55091,12,55093,55119,12,55121,55147,12,55149,55175,12,55177,55203,12,55243,55291,10,65024,65039,5,65279,65279,4,65520,65528,4,66045,66045,5,66422,66426,5,68101,68102,5,68152,68154,5,68325,68326,5,69291,69292,5,69632,69632,7,69634,69634,7,69759,69761,5]")}static getInstance(){return ee._INSTANCE||(ee._INSTANCE=new ee),ee._INSTANCE}getGraphemeBreakType(e){if(e<32)return 10===e?3:13===e?2:4;if(e<127)return 0;const t=this._data,n=t.length/3;let i=1;for(;i<=n;)if(e<t[3*i])i*=2;else{if(!(e>t[3*i+1]))return t[3*i+2];i=2*i+1}return 0}}function te(e,t){if(0===e)return 0;const n=function(e,t){let n=P(t,e);e-=ne(n);for(;ie(n)||65039===n||8419===n;){if(0===e)return;n=P(t,e),e-=ne(n)}if(!j(n))return;if(e>=0){const n=P(t,e);8205===n&&(e-=ne(n))}return e}(e,t);if(void 0!==n)return n;return e-=ne(P(t,e))}function ne(e){return e>=65536?2:1}function ie(e){return 127995<=e&&e<=127999}ee._INSTANCE=null},72999:function(e,t,n){"use strict";function i(e){return Array.isArray(e)}function r(e){return"string"==typeof e}function s(e){return!("object"!=typeof e||null===e||Array.isArray(e)||e instanceof RegExp||e instanceof Date)}function a(e){return"number"==typeof e&&!isNaN(e)}function o(e){return!0===e||!1===e}function l(e){return void 0===e}function c(e){return!u(e)}function u(e){return l(e)||null===e}function h(e,t){if(!e)throw new Error(t?`Unexpected type, expected '${t}'`:"Unexpected type")}function d(e){if(u(e))throw new Error("Assertion Failed: argument is undefined or null");return e}function p(e){return"function"==typeof e}function f(e,t){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++)m(e[i],t[i])}function m(e,t){if(r(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(p(t)){try{if(e instanceof t)return}catch(e){}if(!u(e)&&e.constructor===t)return;if(1===t.length&&!0===t.call(void 0,e))return;throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}function g(e){const t=[];for(const n of function(e){let t=[],n=Object.getPrototypeOf(e);for(;Object.prototype!==n;)t=t.concat(Object.getOwnPropertyNames(n)),n=Object.getPrototypeOf(n);return t}(e))"function"==typeof e[n]&&t.push(n);return t}function _(e,t){const n=e=>function(){const n=Array.prototype.slice.call(arguments,0);return t(e,n)};let i={};for(const t of e)i[t]=n(t);return i}function y(e){return null===e?void 0:e}function v(e,t="Unreachable"){throw new Error(t)}n.d(t,{$E:function(){return g},$K:function(){return c},D8:function(){return f},HD:function(){return r},IU:function(){return _},Jp:function(){return u},Kn:function(){return s},cW:function(){return d},f6:function(){return y},hj:function(){return a},jn:function(){return o},kJ:function(){return i},mf:function(){return p},o8:function(){return l},p_:function(){return h},vE:function(){return v}})},13268:function(e,t,n){"use strict";function i(e,t,...n){return function(e,t){let n;return n=0===t.length?e:e.replace(/\{(\d+)\}/g,(function(e,n){const i=n[0];return void 0!==t[i]?t[i]:e})),n}(t,n)}n.d(t,{N:function(){return i}})},96236:function(e,t,n){"use strict";n.d(t,{BH:function(){return y},NZ:function(){return v},U8:function(){return b},co:function(){return _},eH:function(){return g},vr:function(){return m}});var i=n(75918),r=n(52615),s=n(4348),a=n(88226),o=n(69323),l=n(34502),c=n(35884),u=n(90689),h=n(16925),d=n(49055),p=function(e,t,n,i){var r,s=arguments.length,a=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(s<3?r(a):s>3?r(t,n,a):r(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a},f=function(e,t){return function(n,i){t(n,i,e)}};function m(e){return void 0!==e.command}class g{constructor(e){this.id=g._idPool++,this._debugName=e}}g._idPool=0,g.CommandPalette=new g("CommandPalette"),g.EditorContext=new g("EditorContext"),g.SimpleEditorContext=new g("SimpleEditorContext"),g.EditorContextCopy=new g("EditorContextCopy"),g.EditorContextPeek=new g("EditorContextPeek"),g.MenubarEditMenu=new g("MenubarEditMenu"),g.MenubarCopy=new g("MenubarCopy"),g.MenubarGoMenu=new g("MenubarGoMenu"),g.MenubarSelectionMenu=new g("MenubarSelectionMenu"),g.InlineCompletionsActions=new g("InlineCompletionsActions");const _=(0,h.yh)("menuService"),y=new class{constructor(){this._commands=new Map,this._menuItems=new Map,this._onDidChangeMenu=new s.Q5,this.onDidChangeMenu=this._onDidChangeMenu.event,this._commandPaletteChangeEvent={has:e=>e===g.CommandPalette}}addCommand(e){return this.addCommands(a.$.single(e))}addCommands(e){for(const t of e)this._commands.set(t.id,t);return this._onDidChangeMenu.fire(this._commandPaletteChangeEvent),(0,o.OF)((()=>{let t=!1;for(const n of e)t=this._commands.delete(n.id)||t;t&&this._onDidChangeMenu.fire(this._commandPaletteChangeEvent)}))}getCommand(e){return this._commands.get(e)}getCommands(){const e=new Map;return this._commands.forEach(((t,n)=>e.set(n,t))),e}appendMenuItem(e,t){return this.appendMenuItems(a.$.single({id:e,item:t}))}appendMenuItems(e){const t=new Set,n=new l.S;for(const{id:i,item:r}of e){let e=this._menuItems.get(i);e||(e=new l.S,this._menuItems.set(i,e)),n.push(e.push(r)),t.add(i)}return this._onDidChangeMenu.fire(t),(0,o.OF)((()=>{if(n.size>0){for(let e of n)e();this._onDidChangeMenu.fire(t),n.clear()}}))}getMenuItems(e){let t;return t=this._menuItems.has(e)?[...this._menuItems.get(e)]:[],e===g.CommandPalette&&this._appendImplicitItems(t),t}_appendImplicitItems(e){const t=new Set;for(const n of e)m(n)&&(t.add(n.command.id),n.alt&&t.add(n.alt.id));this._commands.forEach(((n,i)=>{t.has(i)||e.push({command:n})}))}};class v extends i.wY{constructor(e,t,n,i){super(`submenuitem.${e.submenu.id}`,"string"==typeof e.title?e.title:e.title.value,[],"submenu"),this.item=e,this._menuService=t,this._contextKeyService=n,this._options=i}get actions(){const e=[],t=this._menuService.createMenu(this.item.submenu,this._contextKeyService),n=t.getActions(this._options);t.dispose();for(const[,t]of n)t.length>0&&(e.push(...t),e.push(new i.Z0));return e.length&&e.pop(),e}}let b=class e{constructor(t,n,i,s,a){var o,l;if(this._commandService=a,this.id=t.id,this.label=(null==i?void 0:i.renderShortTitle)&&t.shortTitle?"string"==typeof t.shortTitle?t.shortTitle:t.shortTitle.value:"string"==typeof t.title?t.title:t.title.value,this.tooltip=null!==(l="string"==typeof t.tooltip?t.tooltip:null===(o=t.tooltip)||void 0===o?void 0:o.value)&&void 0!==l?l:"",this.enabled=!t.precondition||s.contextMatchesRules(t.precondition),this.checked=void 0,t.toggled){const e=t.toggled.condition?t.toggled:{condition:t.toggled};this.checked=s.contextMatchesRules(e.condition),this.checked&&e.tooltip&&(this.tooltip="string"==typeof e.tooltip?e.tooltip:e.tooltip.value),e.title&&(this.label="string"==typeof e.title?e.title:e.title.value)}this.item=t,this.alt=n?new e(n,void 0,i,s,a):void 0,this._options=i,d.kS.isThemeIcon(t.icon)&&(this.class=r.dT.asClassName(t.icon))}dispose(){}run(...e){var t,n;let i=[];return(null===(t=this._options)||void 0===t?void 0:t.arg)&&(i=[...i,this._options.arg]),(null===(n=this._options)||void 0===n?void 0:n.shouldForwardArgs)&&(i=[...i,...e]),this._commandService.executeCommand(this.id,...i)}};b=p([f(3,u.i6),f(4,c.H)],b)},35884:function(e,t,n){"use strict";n.d(t,{H:function(){return l},P:function(){return c}});var i=n(4348),r=n(88226),s=n(69323),a=n(34502),o=n(72999);const l=(0,n(16925).yh)("commandService"),c=new class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new i.Q5,this.onDidRegisterCommand=this._onDidRegisterCommand.event}registerCommand(e,t){if(!e)throw new Error("invalid command");if("string"==typeof e){if(!t)throw new Error("invalid command");return this.registerCommand({id:e,handler:t})}if(e.description){const t=[];for(let n of e.description.args)t.push(n.constraint);const n=e.handler;e.handler=function(e,...i){return(0,o.D8)(i,t),n(e,...i)}}const{id:n}=e;let i=this._commands.get(n);i||(i=new a.S,this._commands.set(n,i));let r=i.unshift(e),l=(0,s.OF)((()=>{r();const e=this._commands.get(n);(null==e?void 0:e.isEmpty())&&this._commands.delete(n)}));return this._onDidRegisterCommand.fire(n),l}registerCommandAlias(e,t){return c.registerCommand(e,((e,...n)=>e.get(l).executeCommand(t,...n)))}getCommand(e){const t=this._commands.get(e);if(t&&!t.isEmpty())return r.$.first(t)}getCommands(){const e=new Map;for(const t of this._commands.keys()){const n=this.getCommand(t);n&&e.set(t,n)}return e}};c.registerCommand("noop",(()=>{}))},90689:function(e,t,n){"use strict";n.d(t,{Ao:function(){return c},Eq:function(){return R},Fb:function(){return u},K8:function(){return O},i6:function(){return M},uy:function(){return D}});var i=n(23345),r=n(82983),s=n(16925);let a=i.WE||"";const o=new Map;o.set("false",!1),o.set("true",!0),o.set("isMac",i.dz),o.set("isLinux",i.IJ),o.set("isWindows",i.ED),o.set("isWeb",i.$L),o.set("isMacNative",i.dz&&!i.$L),o.set("isEdge",a.indexOf("Edg/")>=0),o.set("isFirefox",a.indexOf("Firefox")>=0),o.set("isChrome",a.indexOf("Chrome")>=0),o.set("isSafari",a.indexOf("Safari")>=0);const l=Object.prototype.hasOwnProperty;class c{static has(e){return f.create(e)}static equals(e,t){return m.create(e,t)}static regex(e,t){return E.create(e,t)}static not(e){return v.create(e)}static and(...e){return L.create(e,null)}static or(...e){return A.create(e,null,!0)}static deserialize(e,t=!1){if(e)return this._deserializeOrExpression(e,t)}static _deserializeOrExpression(e,t){let n=e.split("||");return A.create(n.map((e=>this._deserializeAndExpression(e,t))),null,!0)}static _deserializeAndExpression(e,t){let n=e.split("&&");return L.create(n.map((e=>this._deserializeOne(e,t))),null)}static _deserializeOne(e,t){if((e=e.trim()).indexOf("!=")>=0){let n=e.split("!=");return y.create(n[0].trim(),this._deserializeValue(n[1],t))}if(e.indexOf("==")>=0){let n=e.split("==");return m.create(n[0].trim(),this._deserializeValue(n[1],t))}if(e.indexOf("=~")>=0){let n=e.split("=~");return E.create(n[0].trim(),this._deserializeRegexValue(n[1],t))}if(e.indexOf(" in ")>=0){let t=e.split(" in ");return g.create(t[0].trim(),t[1].trim())}if(/^[^<=>]+>=[^<=>]+$/.test(e)){const t=e.split(">=");return x.create(t[0].trim(),t[1].trim())}if(/^[^<=>]+>[^<=>]+$/.test(e)){const t=e.split(">");return w.create(t[0].trim(),t[1].trim())}if(/^[^<=>]+<=[^<=>]+$/.test(e)){const t=e.split("<=");return S.create(t[0].trim(),t[1].trim())}if(/^[^<=>]+<[^<=>]+$/.test(e)){const t=e.split("<");return k.create(t[0].trim(),t[1].trim())}return/^\!\s*/.test(e)?v.create(e.substr(1).trim()):f.create(e)}static _deserializeValue(e,t){if("true"===(e=e.trim()))return!0;if("false"===e)return!1;let n=/^'([^']*)'$/.exec(e);return n?n[1].trim():e}static _deserializeRegexValue(e,t){if((0,r.m5)(e)){if(t)throw new Error("missing regexp-value for =~-expression");return console.warn("missing regexp-value for =~-expression"),null}let n=e.indexOf("/"),i=e.lastIndexOf("/");if(n===i||n<0){if(t)throw new Error(`bad regexp-value '${e}', missing /-enclosure`);return console.warn(`bad regexp-value '${e}', missing /-enclosure`),null}let s=e.slice(n+1,i),a="i"===e[i+1]?"i":"";try{return new RegExp(s,a)}catch(n){if(t)throw new Error(`bad regexp-value '${e}', parse error: ${n}`);return console.warn(`bad regexp-value '${e}', parse error: ${n}`),null}}}function u(e,t){const n=e?e.substituteConstants():void 0,i=t?t.substituteConstants():void 0;return!n&&!i||!(!n||!i)&&n.equals(i)}function h(e,t){return e.cmp(t)}class d{constructor(){this.type=0}cmp(e){return this.type-e.type}equals(e){return e.type===this.type}substituteConstants(){return this}evaluate(e){return!1}serialize(){return"false"}keys(){return[]}negate(){return p.INSTANCE}}d.INSTANCE=new d;class p{constructor(){this.type=1}cmp(e){return this.type-e.type}equals(e){return e.type===this.type}substituteConstants(){return this}evaluate(e){return!0}serialize(){return"true"}keys(){return[]}negate(){return d.INSTANCE}}p.INSTANCE=new p;class f{constructor(e,t){this.key=e,this.negated=t,this.type=2}static create(e,t=null){const n=o.get(e);return"boolean"==typeof n?n?p.INSTANCE:d.INSTANCE:new f(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:I(this.key,e.key)}equals(e){return e.type===this.type&&this.key===e.key}substituteConstants(){const e=o.get(this.key);return"boolean"==typeof e?e?p.INSTANCE:d.INSTANCE:this}evaluate(e){return!!e.getValue(this.key)}serialize(){return this.key}keys(){return[this.key]}negate(){return this.negated||(this.negated=v.create(this.key,this)),this.negated}}class m{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=4}static create(e,t,n=null){if("boolean"==typeof t)return t?f.create(e,n):v.create(e,n);const i=o.get(e);if("boolean"==typeof i){return t===(i?"true":"false")?p.INSTANCE:d.INSTANCE}return new m(e,t,n)}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){const e=o.get(this.key);if("boolean"==typeof e){const t=e?"true":"false";return this.value===t?p.INSTANCE:d.INSTANCE}return this}evaluate(e){return e.getValue(this.key)==this.value}serialize(){return`${this.key} == '${this.value}'`}keys(){return[this.key]}negate(){return this.negated||(this.negated=y.create(this.key,this.value,this)),this.negated}}class g{constructor(e,t){this.key=e,this.valueKey=t,this.type=10,this.negated=null}static create(e,t){return new g(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.valueKey,e.key,e.valueKey)}equals(e){return e.type===this.type&&(this.key===e.key&&this.valueKey===e.valueKey)}substituteConstants(){return this}evaluate(e){const t=e.getValue(this.valueKey),n=e.getValue(this.key);return Array.isArray(t)?t.indexOf(n)>=0:"string"==typeof n&&"object"==typeof t&&null!==t&&l.call(t,n)}serialize(){return`${this.key} in '${this.valueKey}'`}keys(){return[this.key,this.valueKey]}negate(){return this.negated||(this.negated=_.create(this)),this.negated}}class _{constructor(e){this._actual=e,this.type=11}static create(e){return new _(e)}cmp(e){return e.type!==this.type?this.type-e.type:this._actual.cmp(e._actual)}equals(e){return e.type===this.type&&this._actual.equals(e._actual)}substituteConstants(){return this}evaluate(e){return!this._actual.evaluate(e)}serialize(){throw new Error("Method not implemented.")}keys(){return this._actual.keys()}negate(){return this._actual}}class y{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=5}static create(e,t,n=null){if("boolean"==typeof t)return t?v.create(e,n):f.create(e,n);const i=o.get(e);if("boolean"==typeof i){return t===(i?"true":"false")?d.INSTANCE:p.INSTANCE}return new y(e,t,n)}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){const e=o.get(this.key);if("boolean"==typeof e){const t=e?"true":"false";return this.value===t?d.INSTANCE:p.INSTANCE}return this}evaluate(e){return e.getValue(this.key)!=this.value}serialize(){return`${this.key} != '${this.value}'`}keys(){return[this.key]}negate(){return this.negated||(this.negated=m.create(this.key,this.value,this)),this.negated}}class v{constructor(e,t){this.key=e,this.negated=t,this.type=3}static create(e,t=null){const n=o.get(e);return"boolean"==typeof n?n?d.INSTANCE:p.INSTANCE:new v(e,t)}cmp(e){return e.type!==this.type?this.type-e.type:I(this.key,e.key)}equals(e){return e.type===this.type&&this.key===e.key}substituteConstants(){const e=o.get(this.key);return"boolean"==typeof e?e?d.INSTANCE:p.INSTANCE:this}evaluate(e){return!e.getValue(this.key)}serialize(){return`!${this.key}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=f.create(this.key,this)),this.negated}}function b(e,t){if("string"==typeof e){const t=parseFloat(e);isNaN(t)||(e=t)}return"string"==typeof e||"number"==typeof e?t(e):d.INSTANCE}class w{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=12}static create(e,t,n=null){return b(t,(t=>new w(e,t,n)))}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){return this}evaluate(e){return"string"!=typeof this.value&&parseFloat(e.getValue(this.key))>this.value}serialize(){return`${this.key} > ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=S.create(this.key,this.value,this)),this.negated}}class x{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=13}static create(e,t,n=null){return b(t,(t=>new x(e,t,n)))}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){return this}evaluate(e){return"string"!=typeof this.value&&parseFloat(e.getValue(this.key))>=this.value}serialize(){return`${this.key} >= ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=k.create(this.key,this.value,this)),this.negated}}class k{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=14}static create(e,t,n=null){return b(t,(t=>new k(e,t,n)))}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){return this}evaluate(e){return"string"!=typeof this.value&&parseFloat(e.getValue(this.key))<this.value}serialize(){return`${this.key} < ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=x.create(this.key,this.value,this)),this.negated}}class S{constructor(e,t,n){this.key=e,this.value=t,this.negated=n,this.type=15}static create(e,t,n=null){return b(t,(t=>new S(e,t,n)))}cmp(e){return e.type!==this.type?this.type-e.type:P(this.key,this.value,e.key,e.value)}equals(e){return e.type===this.type&&(this.key===e.key&&this.value===e.value)}substituteConstants(){return this}evaluate(e){return"string"!=typeof this.value&&parseFloat(e.getValue(this.key))<=this.value}serialize(){return`${this.key} <= ${this.value}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=w.create(this.key,this.value,this)),this.negated}}class E{constructor(e,t){this.key=e,this.regexp=t,this.type=7,this.negated=null}static create(e,t){return new E(e,t)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.key<e.key)return-1;if(this.key>e.key)return 1;const t=this.regexp?this.regexp.source:"",n=e.regexp?e.regexp.source:"";return t<n?-1:t>n?1:0}equals(e){if(e.type===this.type){const t=this.regexp?this.regexp.source:"",n=e.regexp?e.regexp.source:"";return this.key===e.key&&t===n}return!1}substituteConstants(){return this}evaluate(e){let t=e.getValue(this.key);return!!this.regexp&&this.regexp.test(t)}serialize(){const e=this.regexp?`/${this.regexp.source}/${this.regexp.ignoreCase?"i":""}`:"/invalid/";return`${this.key} =~ ${e}`}keys(){return[this.key]}negate(){return this.negated||(this.negated=T.create(this)),this.negated}}class T{constructor(e){this._actual=e,this.type=8}static create(e){return new T(e)}cmp(e){return e.type!==this.type?this.type-e.type:this._actual.cmp(e._actual)}equals(e){return e.type===this.type&&this._actual.equals(e._actual)}substituteConstants(){return this}evaluate(e){return!this._actual.evaluate(e)}serialize(){throw new Error("Method not implemented.")}keys(){return this._actual.keys()}negate(){return this._actual}}function C(e){let t=null;for(let n=0,i=e.length;n<i;n++){const i=e[n].substituteConstants();if(e[n]!==i&&null===t){t=[];for(let i=0;i<n;i++)t[i]=e[i]}null!==t&&(t[n]=i)}return null===t?e:t}class L{constructor(e,t){this.expr=e,this.negated=t,this.type=6}static create(e,t){return L._normalizeArr(e,t)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.expr.length<e.expr.length)return-1;if(this.expr.length>e.expr.length)return 1;for(let t=0,n=this.expr.length;t<n;t++){const n=h(this.expr[t],e.expr[t]);if(0!==n)return n}return 0}equals(e){if(e.type===this.type){if(this.expr.length!==e.expr.length)return!1;for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].equals(e.expr[t]))return!1;return!0}return!1}substituteConstants(){const e=C(this.expr);return e===this.expr?this:L.create(e,this.negated)}evaluate(e){for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].evaluate(e))return!1;return!0}static _normalizeArr(e,t){const n=[];let i=!1;for(const t of e)if(t)if(1!==t.type){if(0===t.type)return d.INSTANCE;6!==t.type?n.push(t):n.push(...t.expr)}else i=!0;if(0===n.length&&i)return p.INSTANCE;if(0!==n.length){if(1===n.length)return n[0];n.sort(h);for(let e=1;e<n.length;e++)n[e-1].equals(n[e])&&(n.splice(e,1),e--);if(1===n.length)return n[0];for(;n.length>1;){const e=n[n.length-1];if(9!==e.type)break;n.pop();const t=n.pop(),i=0===n.length,r=A.create(e.expr.map((e=>L.create([e,t],null))),null,i);r&&(n.push(r),n.sort(h))}return 1===n.length?n[0]:new L(n,t)}}serialize(){return this.expr.map((e=>e.serialize())).join(" && ")}keys(){const e=[];for(let t of this.expr)e.push(...t.keys());return e}negate(){if(!this.negated){const e=[];for(let t of this.expr)e.push(t.negate());this.negated=A.create(e,this,!0)}return this.negated}}class A{constructor(e,t){this.expr=e,this.negated=t,this.type=9}static create(e,t,n){return A._normalizeArr(e,t,n)}cmp(e){if(e.type!==this.type)return this.type-e.type;if(this.expr.length<e.expr.length)return-1;if(this.expr.length>e.expr.length)return 1;for(let t=0,n=this.expr.length;t<n;t++){const n=h(this.expr[t],e.expr[t]);if(0!==n)return n}return 0}equals(e){if(e.type===this.type){if(this.expr.length!==e.expr.length)return!1;for(let t=0,n=this.expr.length;t<n;t++)if(!this.expr[t].equals(e.expr[t]))return!1;return!0}return!1}substituteConstants(){const e=C(this.expr);return e===this.expr?this:A.create(e,this.negated,!1)}evaluate(e){for(let t=0,n=this.expr.length;t<n;t++)if(this.expr[t].evaluate(e))return!0;return!1}static _normalizeArr(e,t,n){let i=[],r=!1;if(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];if(n)if(0!==n.type){if(1===n.type)return p.INSTANCE;9!==n.type?i.push(n):i=i.concat(n.expr)}else r=!0}if(0===i.length&&r)return d.INSTANCE;i.sort(h)}if(0!==i.length){if(1===i.length)return i[0];for(let e=1;e<i.length;e++)i[e-1].equals(i[e])&&(i.splice(e,1),e--);if(1===i.length)return i[0];if(n){for(let e=0;e<i.length;e++)for(let t=e+1;t<i.length;t++)O(i[e],i[t])&&(i.splice(t,1),t--);if(1===i.length)return i[0]}return new A(i,t)}}serialize(){return this.expr.map((e=>e.serialize())).join(" || ")}keys(){const e=[];for(let t of this.expr)e.push(...t.keys());return e}negate(){if(!this.negated){let e=[];for(let t of this.expr)e.push(t.negate());for(;e.length>1;){const t=e.shift(),n=e.shift(),i=[];for(const e of F(t))for(const t of F(n))i.push(L.create([e,t],null));const r=0===e.length;e.unshift(A.create(i,null,r))}this.negated=e[0]}return this.negated}}class D extends f{constructor(e,t,n){super(e,null),this._defaultValue=t,"object"==typeof n?D._info.push(Object.assign(Object.assign({},n),{key:e})):!0!==n&&D._info.push({key:e,description:n,type:null!=t?typeof t:void 0})}static all(){return D._info.values()}bindTo(e){return e.createKey(this.key,this._defaultValue)}getValue(e){return e.getContextKeyValue(this.key)}toNegated(){return this.negate()}isEqualTo(e){return m.create(this.key,e)}}D._info=[];const M=(0,s.yh)("contextKeyService"),R="setContext";function I(e,t){return e<t?-1:e>t?1:0}function P(e,t,n,i){return e<n?-1:e>n?1:t<i?-1:t>i?1:0}function O(e,t){if(6===t.type&&9!==e.type&&6!==e.type)for(const n of t.expr)if(e.equals(n))return!0;const n=F(e.negate()).concat(F(t));n.sort(h);for(let e=0;e<n.length;e++){const t=n[e].negate();for(let i=e+1;i<n.length;i++){const e=n[i];if(t.equals(e))return!0}}return!1}function F(e){return 9===e.type?e.expr:[e]}},16925:function(e,t,n){"use strict";var i;n.d(t,{I8:function(){return i},TG:function(){return r},jt:function(){return o},yh:function(){return a}}),function(e){e.serviceIds=new Map,e.DI_TARGET="$di$target",e.DI_DEPENDENCIES="$di$dependencies",e.getServiceDependencies=function(t){return t[e.DI_DEPENDENCIES]||[]}}(i||(i={}));const r=a("instantiationService");function s(e,t,n,r){t[i.DI_TARGET]===t?t[i.DI_DEPENDENCIES].push({id:e,index:n,optional:r}):(t[i.DI_DEPENDENCIES]=[{id:e,index:n,optional:r}],t[i.DI_TARGET]=t)}function a(e){if(i.serviceIds.has(e))return i.serviceIds.get(e);const t=function(e,n,i){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");s(t,e,i,!1)};return t.toString=()=>e,i.serviceIds.set(e,t),t}function o(e){return function(t,n,i){if(3!==arguments.length)throw new Error("@optional-decorator can only be used to decorate a parameter");s(e,t,i,!0)}}},44650:function(e,t,n){"use strict";n.d(t,{B:function(){return s}});var i=n(76068),r=n(72999);const s=new class{constructor(){this.data=new Map}add(e,t){i.ok(r.HD(e)),i.ok(r.Kn(t)),i.ok(!this.data.has(e),"There is already an extension with this id"),this.data.set(e,t)}as(e){return this.data.get(e)||null}}},66213:function(e,t,n){"use strict";var i;n.d(t,{e:function(){return i}}),function(e){e.DARK="dark",e.LIGHT="light",e.HIGH_CONTRAST="hc"}(i||(i={}))},49055:function(e,t,n){"use strict";n.d(t,{EN:function(){return d},IP:function(){return f},Ic:function(){return g},XE:function(){return c},bB:function(){return _},kS:function(){return h},m6:function(){return p}});var i=n(52615),r=n(4348),s=n(69323),a=n(16925),o=n(44650),l=n(66213);const c=(0,a.yh)("themeService");var u,h;function d(e){return{id:e}}function p(e){switch(e){case l.e.DARK:return"vs-dark";case l.e.HIGH_CONTRAST:return"hc-black";default:return"vs"}}!function(e){e.isThemeColor=function(e){return e&&"object"==typeof e&&"string"==typeof e.id}}(u||(u={})),function(e){e.isThemeIcon=function(e){return e&&"object"==typeof e&&"string"==typeof e.id&&(void 0===e.color||u.isThemeColor(e.color))};const t=new RegExp(`^\\$\\((${i.dT.iconNameExpression}(?:${i.dT.iconModifierExpression})?)\\)$`);e.fromString=function(e){const n=t.exec(e);if(!n)return;let[,i]=n;return{id:i}},e.modify=function(e,t){let n=e.id;const i=n.lastIndexOf("~");return-1!==i&&(n=n.substring(0,i)),t&&(n=`${n}~${t}`),{id:n}},e.isEqual=function(e,t){var n,i;return e.id===t.id&&(null===(n=e.color)||void 0===n?void 0:n.id)===(null===(i=t.color)||void 0===i?void 0:i.id)},e.asThemeIcon=function(e,t){return{id:e.id,color:t?d(t):void 0}},e.asClassNameArray=i.dT.asClassNameArray,e.asClassName=i.dT.asClassName,e.asCSSSelector=i.dT.asCSSSelector}(h||(h={}));const f={ThemingContribution:"base.contributions.theming"};let m=new class{constructor(){this.themingParticipants=[],this.themingParticipants=[],this.onThemingParticipantAddedEmitter=new r.Q5}onColorThemeChange(e){return this.themingParticipants.push(e),this.onThemingParticipantAddedEmitter.fire(e),(0,s.OF)((()=>{const t=this.themingParticipants.indexOf(e);this.themingParticipants.splice(t,1)}))}getThemingParticipants(){return this.themingParticipants}};function g(e){return m.onColorThemeChange(e)}o.B.add(f.ThemingContribution,m);class _ extends s.JT{constructor(e){super(),this.themeService=e,this.theme=e.getColorTheme(),this._register(this.themeService.onDidColorThemeChange((e=>this.onThemeChange(e))))}onThemeChange(e){this.theme=e,this.updateStyles()}updateStyles(){}}},16632:function(e,t,n){"use strict";var i=n(54476),r=n(33885),s=n(20068),a=n(42978),o=n(75931),l=n(92310),c=n.n(l),u=n(18929),h=n(59301),d=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],p=(0,h.forwardRef)((function(e,t){var n=e.prefixCls,l=void 0===n?"rc-checkbox":n,p=e.className,f=e.style,m=e.checked,g=e.disabled,_=e.defaultChecked,y=void 0!==_&&_,v=e.type,b=void 0===v?"checkbox":v,w=e.title,x=e.onChange,k=(0,o.Z)(e,d),S=(0,h.useRef)(null),E=(0,h.useRef)(null),T=(0,u.Z)(y,{value:m}),C=(0,a.Z)(T,2),L=C[0],A=C[1];(0,h.useImperativeHandle)(t,(function(){return{focus:function(e){var t;null===(t=S.current)||void 0===t||t.focus(e)},blur:function(){var e;null===(e=S.current)||void 0===e||e.blur()},input:S.current,nativeElement:E.current}}));var D=c()(l,p,(0,s.Z)((0,s.Z)({},"".concat(l,"-checked"),L),"".concat(l,"-disabled"),g));return h.createElement("span",{className:D,title:w,style:f,ref:E},h.createElement("input",(0,i.Z)({},k,{className:"".concat(l,"-input"),ref:S,onChange:function(t){g||("checked"in e||A(t.target.checked),null==x||x({target:(0,r.Z)((0,r.Z)({},e),{},{type:b,checked:t.target.checked}),stopPropagation:function(){t.stopPropagation()},preventDefault:function(){t.preventDefault()},nativeEvent:t.nativeEvent}))},disabled:g,checked:!!L,type:b})),h.createElement("span",{className:"".concat(l,"-inner")}))}));t.Z=p},96478:function(e,t,n){"use strict";n.d(t,{Z:function(){return x}});var i=n(54476),r=n(20068),s=n(42978),a=n(75931),o=n(65030),l=n(92310),c=n.n(l),u=n(8654),h=n(59301),d=n(10228),p=n(16089),f=d.Z.ESC,m=d.Z.TAB;var g=(0,h.forwardRef)((function(e,t){var n=e.overlay,i=e.arrow,r=e.prefixCls,s=(0,h.useMemo)((function(){return"function"==typeof n?n():n}),[n]),a=(0,u.sQ)(t,(0,u.C4)(s));return h.createElement(h.Fragment,null,i&&h.createElement("div",{className:"".concat(r,"-arrow")}),h.cloneElement(s,{ref:(0,u.Yr)(s)?a:void 0}))})),_={adjustX:1,adjustY:1},y=[0,0],v={topLeft:{points:["bl","tl"],overflow:_,offset:[0,-4],targetOffset:y},top:{points:["bc","tc"],overflow:_,offset:[0,-4],targetOffset:y},topRight:{points:["br","tr"],overflow:_,offset:[0,-4],targetOffset:y},bottomLeft:{points:["tl","bl"],overflow:_,offset:[0,4],targetOffset:y},bottom:{points:["tc","bc"],overflow:_,offset:[0,4],targetOffset:y},bottomRight:{points:["tr","br"],overflow:_,offset:[0,4],targetOffset:y}},b=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function w(e,t){var n,l=e.arrow,d=void 0!==l&&l,_=e.prefixCls,y=void 0===_?"rc-dropdown":_,w=e.transitionName,x=e.animation,k=e.align,S=e.placement,E=void 0===S?"bottomLeft":S,T=e.placements,C=void 0===T?v:T,L=e.getPopupContainer,A=e.showAction,D=e.hideAction,M=e.overlayClassName,R=e.overlayStyle,I=e.visible,P=e.trigger,O=void 0===P?["hover"]:P,F=e.autoFocus,N=e.overlay,B=e.children,$=e.onVisibleChange,K=(0,a.Z)(e,b),U=h.useState(),z=(0,s.Z)(U,2),V=z[0],q=z[1],G="visible"in e?I:V,H=h.useRef(null),j=h.useRef(null),W=h.useRef(null);h.useImperativeHandle(t,(function(){return H.current}));var Z=function(e){q(e),null==$||$(e)};!function(e){var t=e.visible,n=e.triggerRef,i=e.onVisibleChange,r=e.autoFocus,s=e.overlayRef,a=h.useRef(!1),o=function(){var e,r;t&&(null===(e=n.current)||void 0===e||null===(r=e.focus)||void 0===r||r.call(e),null==i||i(!1))},l=function(){var e;return!(null===(e=s.current)||void 0===e||!e.focus||(s.current.focus(),a.current=!0,0))},c=function(e){switch(e.keyCode){case f:o();break;case m:var t=!1;a.current||(t=l()),t?e.preventDefault():o()}};h.useEffect((function(){return t?(window.addEventListener("keydown",c),r&&(0,p.Z)(l,3),function(){window.removeEventListener("keydown",c),a.current=!1}):function(){a.current=!1}}),[t])}({visible:G,triggerRef:W,onVisibleChange:Z,autoFocus:F,overlayRef:j});var Y,X,J,Q=function(){return h.createElement(g,{ref:j,overlay:N,prefixCls:y,arrow:d})},ee=h.cloneElement(B,{className:c()(null===(n=B.props)||void 0===n?void 0:n.className,G&&(Y=e.openClassName,void 0!==Y?Y:"".concat(y,"-open"))),ref:(0,u.Yr)(B)?(0,u.sQ)(W,(0,u.C4)(B)):void 0}),te=D;return te||-1===O.indexOf("contextMenu")||(te=["click"]),h.createElement(o.Z,(0,i.Z)({builtinPlacements:C},K,{prefixCls:y,ref:H,popupClassName:c()(M,(0,r.Z)({},"".concat(y,"-show-arrow"),d)),popupStyle:R,action:O,showAction:A,hideAction:te,popupPlacement:E,popupAlign:k,popupTransitionName:w,popupAnimation:x,popupVisible:G,stretch:(X=e.minOverlayWidthMatchTrigger,J=e.alignPoint,("minOverlayWidthMatchTrigger"in e?X:!J)?"minWidth":""),popup:"function"==typeof N?Q:Q(),onPopupVisibleChange:Z,onPopupClick:function(t){var n=e.onOverlayClick;q(!1),n&&n(t)},getPopupContainer:L}),ee)}var x=h.forwardRef(w)},20922:function(e,t,n){"use strict";n.d(t,{Z:function(){return K}});var i=n(54476),r=n(20068),s=n(76190),a=n(42978),o=n(75931),l=n(67732),c=n(83652);function u(){return"function"==typeof BigInt}function h(e){return!e&&0!==e&&!Number.isNaN(e)||!String(e).trim()}function d(e){var t=e.trim(),n=t.startsWith("-");n&&(t=t.slice(1)),(t=t.replace(/(\.\d*[^0])0*$/,"$1").replace(/\.0*$/,"").replace(/^0+/,"")).startsWith(".")&&(t="0".concat(t));var i=t||"0",r=i.split("."),s=r[0]||"0",a=r[1]||"0";"0"===s&&"0"===a&&(n=!1);var o=n?"-":"";return{negative:n,negativeStr:o,trimStr:i,integerStr:s,decimalStr:a,fullStr:"".concat(o).concat(i)}}function p(e){var t=String(e);return!Number.isNaN(Number(t))&&t.includes("e")}function f(e){var t=String(e);if(p(e)){var n=Number(t.slice(t.indexOf("e-")+2)),i=t.match(/\.(\d+)/);return null!=i&&i[1]&&(n+=i[1].length),n}return t.includes(".")&&g(t)?t.length-t.indexOf(".")-1:0}function m(e){var t=String(e);if(p(e)){if(e>Number.MAX_SAFE_INTEGER)return String(u()?BigInt(e).toString():Number.MAX_SAFE_INTEGER);if(e<Number.MIN_SAFE_INTEGER)return String(u()?BigInt(e).toString():Number.MIN_SAFE_INTEGER);t=e.toFixed(f(t))}return d(t).fullStr}function g(e){return"number"==typeof e?!Number.isNaN(e):!!e&&(/^\s*-?\d+(\.\d+)?\s*$/.test(e)||/^\s*-?\d+\.\s*$/.test(e)||/^\s*-?\.\d+\s*$/.test(e))}var _=function(){function e(t){if((0,l.Z)(this,e),(0,r.Z)(this,"origin",""),(0,r.Z)(this,"negative",void 0),(0,r.Z)(this,"integer",void 0),(0,r.Z)(this,"decimal",void 0),(0,r.Z)(this,"decimalLen",void 0),(0,r.Z)(this,"empty",void 0),(0,r.Z)(this,"nan",void 0),h(t))this.empty=!0;else if(this.origin=String(t),"-"===t||Number.isNaN(t))this.nan=!0;else{var n=t;if(p(n)&&(n=Number(n)),g(n="string"==typeof n?n:m(n))){var i=d(n);this.negative=i.negative;var s=i.trimStr.split(".");this.integer=BigInt(s[0]);var a=s[1]||"0";this.decimal=BigInt(a),this.decimalLen=a.length}else this.nan=!0}}return(0,c.Z)(e,[{key:"getMark",value:function(){return this.negative?"-":""}},{key:"getIntegerStr",value:function(){return this.integer.toString()}},{key:"getDecimalStr",value:function(){return this.decimal.toString().padStart(this.decimalLen,"0")}},{key:"alignDecimal",value:function(e){var t="".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(e,"0"));return BigInt(t)}},{key:"negate",value:function(){var t=new e(this.toString());return t.negative=!t.negative,t}},{key:"cal",value:function(t,n,i){var r=Math.max(this.getDecimalStr().length,t.getDecimalStr().length),s=n(this.alignDecimal(r),t.alignDecimal(r)).toString(),a=i(r),o=d(s),l=o.negativeStr,c=o.trimStr,u="".concat(l).concat(c.padStart(a+1,"0"));return new e("".concat(u.slice(0,-a),".").concat(u.slice(-a)))}},{key:"add",value:function(t){if(this.isInvalidate())return new e(t);var n=new e(t);return n.isInvalidate()?this:this.cal(n,(function(e,t){return e+t}),(function(e){return e}))}},{key:"multi",value:function(t){var n=new e(t);return this.isInvalidate()||n.isInvalidate()?new e(NaN):this.cal(n,(function(e,t){return e*t}),(function(e){return 2*e}))}},{key:"isEmpty",value:function(){return this.empty}},{key:"isNaN",value:function(){return this.nan}},{key:"isInvalidate",value:function(){return this.isEmpty()||this.isNaN()}},{key:"equals",value:function(e){return this.toString()===(null==e?void 0:e.toString())}},{key:"lessEquals",value:function(e){return this.add(e.negate().toString()).toNumber()<=0}},{key:"toNumber",value:function(){return this.isNaN()?NaN:Number(this.toString())}},{key:"toString",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return e?this.isInvalidate()?"":d("".concat(this.getMark()).concat(this.getIntegerStr(),".").concat(this.getDecimalStr())).fullStr:this.origin}}]),e}(),y=function(){function e(t){(0,l.Z)(this,e),(0,r.Z)(this,"origin",""),(0,r.Z)(this,"number",void 0),(0,r.Z)(this,"empty",void 0),h(t)?this.empty=!0:(this.origin=String(t),this.number=Number(t))}return(0,c.Z)(e,[{key:"negate",value:function(){return new e(-this.toNumber())}},{key:"add",value:function(t){if(this.isInvalidate())return new e(t);var n=Number(t);if(Number.isNaN(n))return this;var i=this.number+n;if(i>Number.MAX_SAFE_INTEGER)return new e(Number.MAX_SAFE_INTEGER);if(i<Number.MIN_SAFE_INTEGER)return new e(Number.MIN_SAFE_INTEGER);var r=Math.max(f(this.number),f(n));return new e(i.toFixed(r))}},{key:"multi",value:function(t){var n=Number(t);if(this.isInvalidate()||Number.isNaN(n))return new e(NaN);var i=this.number*n;if(i>Number.MAX_SAFE_INTEGER)return new e(Number.MAX_SAFE_INTEGER);if(i<Number.MIN_SAFE_INTEGER)return new e(Number.MIN_SAFE_INTEGER);var r=Math.max(f(this.number),f(n));return new e(i.toFixed(r))}},{key:"isEmpty",value:function(){return this.empty}},{key:"isNaN",value:function(){return Number.isNaN(this.number)}},{key:"isInvalidate",value:function(){return this.isEmpty()||this.isNaN()}},{key:"equals",value:function(e){return this.toNumber()===(null==e?void 0:e.toNumber())}},{key:"lessEquals",value:function(e){return this.add(e.negate().toString()).toNumber()<=0}},{key:"toNumber",value:function(){return this.number}},{key:"toString",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return e?this.isInvalidate()?"":m(this.number):this.origin}}]),e}();function v(e){return u()?new _(e):new y(e)}function b(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(""===e)return"";var r=d(e),s=r.negativeStr,a=r.integerStr,o=r.decimalStr,l="".concat(t).concat(o),c="".concat(s).concat(a);if(n>=0){var u=Number(o[n]);if(u>=5&&!i){var h=v(e).add("".concat(s,"0.").concat("0".repeat(n)).concat(10-u));return b(h.toString(),t,n,i)}return 0===n?c:"".concat(c).concat(t).concat(o.padEnd(n,"0").slice(0,n))}return".0"===l?c:"".concat(c).concat(l)}var w=v,x=n(92310),k=n.n(x),S=n(36901),E=n(34280);var T=n(8654),C=n(59301),L=n(48736);var A=n(49658),D=function(){var e=(0,C.useState)(!1),t=(0,a.Z)(e,2),n=t[0],i=t[1];return(0,E.Z)((function(){i((0,A.Z)())}),[]),n},M=n(16089);function R(e){var t=e.prefixCls,n=e.upNode,s=e.downNode,a=e.upDisabled,o=e.downDisabled,l=e.onStep,c=C.useRef(),u=C.useRef([]),h=C.useRef();h.current=l;var d=function(){clearTimeout(c.current)},p=function(e,t){e.preventDefault(),d(),h.current(t),c.current=setTimeout((function e(){h.current(t),c.current=setTimeout(e,200)}),600)};if(C.useEffect((function(){return function(){d(),u.current.forEach((function(e){return M.Z.cancel(e)}))}}),[]),D())return null;var f="".concat(t,"-handler"),m=k()(f,"".concat(f,"-up"),(0,r.Z)({},"".concat(f,"-up-disabled"),a)),g=k()(f,"".concat(f,"-down"),(0,r.Z)({},"".concat(f,"-down-disabled"),o)),_=function(){return u.current.push((0,M.Z)(d))},y={unselectable:"on",role:"button",onMouseUp:_,onMouseLeave:_};return C.createElement("div",{className:"".concat(f,"-wrap")},C.createElement("span",(0,i.Z)({},y,{onMouseDown:function(e){p(e,!0)},"aria-label":"Increase Value","aria-disabled":a,className:m}),n||C.createElement("span",{unselectable:"on",className:"".concat(t,"-handler-up-inner")})),C.createElement("span",(0,i.Z)({},y,{onMouseDown:function(e){p(e,!1)},"aria-label":"Decrease Value","aria-disabled":o,className:g}),s||C.createElement("span",{unselectable:"on",className:"".concat(t,"-handler-down-inner")})))}function I(e){var t="number"==typeof e?m(e):d(e).fullStr;return t.includes(".")?d(t.replace(/(\d)\.(\d)/g,"$1$2.")).fullStr:e+"0"}var P=n(30292),O=["prefixCls","className","style","min","max","step","defaultValue","value","disabled","readOnly","upHandler","downHandler","keyboard","changeOnWheel","controls","classNames","stringMode","parser","formatter","precision","decimalSeparator","onChange","onInput","onPressEnter","onStep","changeOnBlur","domRef"],F=["disabled","style","prefixCls","value","prefix","suffix","addonBefore","addonAfter","className","classNames"],N=function(e,t){return e||t.isEmpty()?t.toString():t.toNumber()},B=function(e){var t=w(e);return t.isInvalidate()?null:t},$=C.forwardRef((function(e,t){var n=e.prefixCls,l=e.className,c=e.style,u=e.min,h=e.max,d=e.step,p=void 0===d?1:d,_=e.defaultValue,y=e.value,v=e.disabled,x=e.readOnly,S=e.upHandler,A=e.downHandler,D=e.keyboard,P=e.changeOnWheel,F=void 0!==P&&P,$=e.controls,K=void 0===$||$,U=(e.classNames,e.stringMode),z=e.parser,V=e.formatter,q=e.precision,G=e.decimalSeparator,H=e.onChange,j=e.onInput,W=e.onPressEnter,Z=e.onStep,Y=e.changeOnBlur,X=void 0===Y||Y,J=e.domRef,Q=(0,o.Z)(e,O),ee="".concat(n,"-input"),te=C.useRef(null),ne=C.useState(!1),ie=(0,a.Z)(ne,2),re=ie[0],se=ie[1],ae=C.useRef(!1),oe=C.useRef(!1),le=C.useRef(!1),ce=C.useState((function(){return w(null!=y?y:_)})),ue=(0,a.Z)(ce,2),he=ue[0],de=ue[1];var pe=C.useCallback((function(e,t){if(!t)return q>=0?q:Math.max(f(e),f(p))}),[q,p]),fe=C.useCallback((function(e){var t=String(e);if(z)return z(t);var n=t;return G&&(n=n.replace(G,".")),n.replace(/[^\w.-]+/g,"")}),[z,G]),me=C.useRef(""),ge=C.useCallback((function(e,t){if(V)return V(e,{userTyping:t,input:String(me.current)});var n="number"==typeof e?m(e):e;if(!t){var i=pe(n,t);if(g(n)&&(G||i>=0))n=b(n,G||".",i)}return n}),[V,pe,G]),_e=C.useState((function(){var e=null!=_?_:y;return he.isInvalidate()&&["string","number"].includes((0,s.Z)(e))?Number.isNaN(e)?"":e:ge(he.toString(),!1)})),ye=(0,a.Z)(_e,2),ve=ye[0],be=ye[1];function we(e,t){be(ge(e.isInvalidate()?e.toString(!1):e.toString(!t),t))}me.current=ve;var xe,ke,Se,Ee,Te,Ce=C.useMemo((function(){return B(h)}),[h,q]),Le=C.useMemo((function(){return B(u)}),[u,q]),Ae=C.useMemo((function(){return!(!Ce||!he||he.isInvalidate())&&Ce.lessEquals(he)}),[Ce,he]),De=C.useMemo((function(){return!(!Le||!he||he.isInvalidate())&&he.lessEquals(Le)}),[Le,he]),Me=(xe=te.current,ke=re,Se=(0,C.useRef)(null),[function(){try{var e=xe.selectionStart,t=xe.selectionEnd,n=xe.value,i=n.substring(0,e),r=n.substring(t);Se.current={start:e,end:t,value:n,beforeTxt:i,afterTxt:r}}catch(e){}},function(){if(xe&&Se.current&&ke)try{var e=xe.value,t=Se.current,n=t.beforeTxt,i=t.afterTxt,r=t.start,s=e.length;if(e.startsWith(n))s=n.length;else if(e.endsWith(i))s=e.length-Se.current.afterTxt.length;else{var a=n[r-1],o=e.indexOf(a,r-1);-1!==o&&(s=o+1)}xe.setSelectionRange(s,s)}catch(e){(0,L.ZP)(!1,"Something warning of cursor restore. Please fire issue about this: ".concat(e.message))}}]),Re=(0,a.Z)(Me,2),Ie=Re[0],Pe=Re[1],Oe=function(e){return Ce&&!e.lessEquals(Ce)?Ce:Le&&!Le.lessEquals(e)?Le:null},Fe=function(e){return!Oe(e)},Ne=function(e,t){var n,i=e,r=Fe(i)||i.isEmpty();if(i.isEmpty()||t||(i=Oe(i)||i,r=!0),!x&&!v&&r){var s=i.toString(),a=pe(s,t);return a>=0&&(i=w(b(s,".",a)),Fe(i)||(i=w(b(s,".",a,!0)))),i.equals(he)||(n=i,void 0===y&&de(n),null==H||H(i.isEmpty()?null:N(U,i)),void 0===y&&we(i,t)),i}return he},Be=(Ee=(0,C.useRef)(0),Te=function(){M.Z.cancel(Ee.current)},(0,C.useEffect)((function(){return Te}),[]),function(e){Te(),Ee.current=(0,M.Z)((function(){e()}))}),$e=function e(t){if(Ie(),me.current=t,be(t),!oe.current){var n=fe(t),i=w(n);i.isNaN()||Ne(i,!0)}null==j||j(t),Be((function(){var n=t;z||(n=t.replace(/。/g,".")),n!==t&&e(n)}))},Ke=function(e){var t;if(!(e&&Ae||!e&&De)){ae.current=!1;var n=w(le.current?I(p):p);e||(n=n.negate());var i=(he||w(0)).add(n.toString()),r=Ne(i,!1);null==Z||Z(N(U,r),{offset:le.current?I(p):p,type:e?"up":"down"}),null===(t=te.current)||void 0===t||t.focus()}},Ue=function(e){var t,n=w(fe(ve));t=n.isNaN()?Ne(he,e):Ne(n,e),void 0!==y?we(he,!1):t.isNaN()||we(t,!1)};C.useEffect((function(){if(F&&re){var e=function(e){Ke(e.deltaY<0),e.preventDefault()},t=te.current;if(t)return t.addEventListener("wheel",e,{passive:!1}),function(){return t.removeEventListener("wheel",e)}}}));return(0,E.o)((function(){he.isInvalidate()||we(he,!1)}),[q,V]),(0,E.o)((function(){var e=w(y);de(e);var t=w(fe(ve));e.equals(t)&&ae.current&&!V||we(e,ae.current)}),[y]),(0,E.o)((function(){V&&Pe()}),[ve]),C.createElement("div",{ref:J,className:k()(n,l,(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(n,"-focused"),re),"".concat(n,"-disabled"),v),"".concat(n,"-readonly"),x),"".concat(n,"-not-a-number"),he.isNaN()),"".concat(n,"-out-of-range"),!he.isInvalidate()&&!Fe(he))),style:c,onFocus:function(){se(!0)},onBlur:function(){X&&Ue(!1),se(!1),ae.current=!1},onKeyDown:function(e){var t=e.key,n=e.shiftKey;ae.current=!0,le.current=n,"Enter"===t&&(oe.current||(ae.current=!1),Ue(!1),null==W||W(e)),!1!==D&&!oe.current&&["Up","ArrowUp","Down","ArrowDown"].includes(t)&&(Ke("Up"===t||"ArrowUp"===t),e.preventDefault())},onKeyUp:function(){ae.current=!1,le.current=!1},onCompositionStart:function(){oe.current=!0},onCompositionEnd:function(){oe.current=!1,$e(te.current.value)},onBeforeInput:function(){ae.current=!0}},K&&C.createElement(R,{prefixCls:n,upNode:S,downNode:A,upDisabled:Ae,downDisabled:De,onStep:Ke}),C.createElement("div",{className:"".concat(ee,"-wrap")},C.createElement("input",(0,i.Z)({autoComplete:"off",role:"spinbutton","aria-valuemin":u,"aria-valuemax":h,"aria-valuenow":he.isInvalidate()?null:he.toString(),step:p},Q,{ref:(0,T.sQ)(te,t),className:ee,value:ve,onChange:function(e){$e(e.target.value)},disabled:v,readOnly:x}))))}));var K=C.forwardRef((function(e,t){var n=e.disabled,r=e.style,s=e.prefixCls,a=void 0===s?"rc-input-number":s,l=e.value,c=e.prefix,u=e.suffix,h=e.addonBefore,d=e.addonAfter,p=e.className,f=e.classNames,m=(0,o.Z)(e,F),g=C.useRef(null),_=C.useRef(null),y=C.useRef(null),v=function(e){y.current&&(0,P.nH)(y.current,e)};return C.useImperativeHandle(t,(function(){return e=y.current,t={focus:v,nativeElement:g.current.nativeElement||_.current},"undefined"!=typeof Proxy&&e?new Proxy(e,{get:function(e,n){if(t[n])return t[n];var i=e[n];return"function"==typeof i?i.bind(e):i}}):e;var e,t})),C.createElement(S.BaseInput,{className:p,triggerFocus:v,prefixCls:a,value:l,disabled:n,style:r,prefix:c,suffix:u,addonAfter:d,addonBefore:h,classNames:f,components:{affixWrapper:"div",groupWrapper:"div",wrapper:"div",groupAddon:"div"},ref:g},C.createElement($,(0,i.Z)({prefixCls:a,disabled:n,ref:y,domRef:_,className:null==f?void 0:f.input},m)))}))},66003:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var i=n(75931),r=n(33885),s=n(76190),a=n(59301),o=["show"];function l(e,t){return a.useMemo((function(){var n={};t&&(n.show="object"===(0,s.Z)(t)&&t.formatter?t.formatter:!!t);var a=n=(0,r.Z)((0,r.Z)({},n),e),l=a.show,c=(0,i.Z)(a,o);return(0,r.Z)((0,r.Z)({},c),{},{show:!!l,showFormatter:"function"==typeof l?l:void 0,strategy:c.strategy||function(e){return e.length}})}),[e,t])}},36901:function(e,t,n){"use strict";n.r(t),n.d(t,{BaseInput:function(){return h},default:function(){return v}});var i=n(33885),r=n(54476),s=n(20068),a=n(76190),o=n(92310),l=n.n(o),c=n(59301),u=n(30292),h=c.forwardRef((function(e,t){var n,o,h,d=e.inputElement,p=e.children,f=e.prefixCls,m=e.prefix,g=e.suffix,_=e.addonBefore,y=e.addonAfter,v=e.className,b=e.style,w=e.disabled,x=e.readOnly,k=e.focused,S=e.triggerFocus,E=e.allowClear,T=e.value,C=e.handleReset,L=e.hidden,A=e.classes,D=e.classNames,M=e.dataAttrs,R=e.styles,I=e.components,P=e.onClear,O=null!=p?p:d,F=(null==I?void 0:I.affixWrapper)||"span",N=(null==I?void 0:I.groupWrapper)||"span",B=(null==I?void 0:I.wrapper)||"span",$=(null==I?void 0:I.groupAddon)||"span",K=(0,c.useRef)(null),U=(0,u.X3)(e),z=(0,c.cloneElement)(O,{value:T,className:l()(null===(n=O.props)||void 0===n?void 0:n.className,!U&&(null==D?void 0:D.variant))||null}),V=(0,c.useRef)(null);if(c.useImperativeHandle(t,(function(){return{nativeElement:V.current||K.current}})),U){var q=null;if(E){var G=!w&&!x&&T,H="".concat(f,"-clear-icon"),j="object"===(0,a.Z)(E)&&null!=E&&E.clearIcon?E.clearIcon:"✖";q=c.createElement("button",{type:"button",tabIndex:-1,onClick:function(e){null==C||C(e),null==P||P()},onMouseDown:function(e){return e.preventDefault()},className:l()(H,(0,s.Z)((0,s.Z)({},"".concat(H,"-hidden"),!G),"".concat(H,"-has-suffix"),!!g))},j)}var W="".concat(f,"-affix-wrapper"),Z=l()(W,(0,s.Z)((0,s.Z)((0,s.Z)((0,s.Z)((0,s.Z)({},"".concat(f,"-disabled"),w),"".concat(W,"-disabled"),w),"".concat(W,"-focused"),k),"".concat(W,"-readonly"),x),"".concat(W,"-input-with-clear-btn"),g&&E&&T),null==A?void 0:A.affixWrapper,null==D?void 0:D.affixWrapper,null==D?void 0:D.variant),Y=(g||E)&&c.createElement("span",{className:l()("".concat(f,"-suffix"),null==D?void 0:D.suffix),style:null==R?void 0:R.suffix},q,g);z=c.createElement(F,(0,r.Z)({className:Z,style:null==R?void 0:R.affixWrapper,onClick:function(e){var t;null!==(t=K.current)&&void 0!==t&&t.contains(e.target)&&(null==S||S())}},null==M?void 0:M.affixWrapper,{ref:K}),m&&c.createElement("span",{className:l()("".concat(f,"-prefix"),null==D?void 0:D.prefix),style:null==R?void 0:R.prefix},m),z,Y)}if((0,u.He)(e)){var X="".concat(f,"-group"),J="".concat(X,"-addon"),Q="".concat(X,"-wrapper"),ee=l()("".concat(f,"-wrapper"),X,null==A?void 0:A.wrapper,null==D?void 0:D.wrapper),te=l()(Q,(0,s.Z)({},"".concat(Q,"-disabled"),w),null==A?void 0:A.group,null==D?void 0:D.groupWrapper);z=c.createElement(N,{className:te,ref:V},c.createElement(B,{className:ee},_&&c.createElement($,{className:J},_),z,y&&c.createElement($,{className:J},y)))}return c.cloneElement(z,{className:l()(null===(o=z.props)||void 0===o?void 0:o.className,v)||null,style:(0,i.Z)((0,i.Z)({},null===(h=z.props)||void 0===h?void 0:h.style),b),hidden:L})})),d=n(94480),p=n(42978),f=n(75931),m=n(18929),g=n(2738),_=n(66003),y=["autoComplete","onChange","onFocus","onBlur","onPressEnter","onKeyDown","onKeyUp","prefixCls","disabled","htmlSize","className","maxLength","suffix","showCount","count","type","classes","classNames","styles","onCompositionStart","onCompositionEnd"],v=(0,c.forwardRef)((function(e,t){var n=e.autoComplete,a=e.onChange,o=e.onFocus,v=e.onBlur,b=e.onPressEnter,w=e.onKeyDown,x=e.onKeyUp,k=e.prefixCls,S=void 0===k?"rc-input":k,E=e.disabled,T=e.htmlSize,C=e.className,L=e.maxLength,A=e.suffix,D=e.showCount,M=e.count,R=e.type,I=void 0===R?"text":R,P=e.classes,O=e.classNames,F=e.styles,N=e.onCompositionStart,B=e.onCompositionEnd,$=(0,f.Z)(e,y),K=(0,c.useState)(!1),U=(0,p.Z)(K,2),z=U[0],V=U[1],q=(0,c.useRef)(!1),G=(0,c.useRef)(!1),H=(0,c.useRef)(null),j=(0,c.useRef)(null),W=function(e){H.current&&(0,u.nH)(H.current,e)},Z=(0,m.Z)(e.defaultValue,{value:e.value}),Y=(0,p.Z)(Z,2),X=Y[0],J=Y[1],Q=null==X?"":String(X),ee=(0,c.useState)(null),te=(0,p.Z)(ee,2),ne=te[0],ie=te[1],re=(0,_.Z)(M,D),se=re.max||L,ae=re.strategy(Q),oe=!!se&&ae>se;(0,c.useImperativeHandle)(t,(function(){var e;return{focus:W,blur:function(){var e;null===(e=H.current)||void 0===e||e.blur()},setSelectionRange:function(e,t,n){var i;null===(i=H.current)||void 0===i||i.setSelectionRange(e,t,n)},select:function(){var e;null===(e=H.current)||void 0===e||e.select()},input:H.current,nativeElement:(null===(e=j.current)||void 0===e?void 0:e.nativeElement)||H.current}})),(0,c.useEffect)((function(){G.current&&(G.current=!1),V((function(e){return(!e||!E)&&e}))}),[E]);var le=function(e,t,n){var i,r,s=t;if(!q.current&&re.exceedFormatter&&re.max&&re.strategy(t)>re.max)t!==(s=re.exceedFormatter(t,{max:re.max}))&&ie([(null===(i=H.current)||void 0===i?void 0:i.selectionStart)||0,(null===(r=H.current)||void 0===r?void 0:r.selectionEnd)||0]);else if("compositionEnd"===n.source)return;J(s),H.current&&(0,u.rJ)(H.current,e,a,s)};(0,c.useEffect)((function(){var e;ne&&(null===(e=H.current)||void 0===e||e.setSelectionRange.apply(e,(0,d.Z)(ne)))}),[ne]);var ce,ue=function(e){le(e,e.target.value,{source:"change"})},he=function(e){q.current=!1,le(e,e.currentTarget.value,{source:"compositionEnd"}),null==B||B(e)},de=function(e){b&&"Enter"===e.key&&!G.current&&(G.current=!0,b(e)),null==w||w(e)},pe=function(e){"Enter"===e.key&&(G.current=!1),null==x||x(e)},fe=function(e){V(!0),null==o||o(e)},me=function(e){G.current&&(G.current=!1),V(!1),null==v||v(e)},ge=oe&&"".concat(S,"-out-of-range");return c.createElement(h,(0,r.Z)({},$,{prefixCls:S,className:l()(C,ge),handleReset:function(e){J(""),W(),H.current&&(0,u.rJ)(H.current,e,a)},value:Q,focused:z,triggerFocus:W,suffix:function(){var e=Number(se)>0;if(A||re.show){var t=re.showFormatter?re.showFormatter({value:Q,count:ae,maxLength:se}):"".concat(ae).concat(e?" / ".concat(se):"");return c.createElement(c.Fragment,null,re.show&&c.createElement("span",{className:l()("".concat(S,"-show-count-suffix"),(0,s.Z)({},"".concat(S,"-show-count-has-suffix"),!!A),null==O?void 0:O.count),style:(0,i.Z)({},null==F?void 0:F.count)},t),A)}return null}(),disabled:E,classes:P,classNames:O,styles:F}),(ce=(0,g.Z)(e,["prefixCls","onPressEnter","addonBefore","addonAfter","prefix","suffix","allowClear","defaultValue","showCount","count","classes","htmlSize","styles","classNames","onClear"]),c.createElement("input",(0,r.Z)({autoComplete:n},ce,{onChange:ue,onFocus:fe,onBlur:me,onKeyDown:de,onKeyUp:pe,className:l()(S,(0,s.Z)({},"".concat(S,"-disabled"),E),null==O?void 0:O.input),style:null==F?void 0:F.input,ref:H,size:T,type:I,onCompositionStart:function(e){q.current=!0,null==N||N(e)},onCompositionEnd:he}))))}))},30292:function(e,t,n){"use strict";function i(e){return!(!e.addonBefore&&!e.addonAfter)}function r(e){return!!(e.prefix||e.suffix||e.allowClear)}function s(e,t,n){var i=t.cloneNode(!0),r=Object.create(e,{target:{value:i},currentTarget:{value:i}});return i.value=n,"number"==typeof t.selectionStart&&"number"==typeof t.selectionEnd&&(i.selectionStart=t.selectionStart,i.selectionEnd=t.selectionEnd),i.setSelectionRange=function(){t.setSelectionRange.apply(t,arguments)},r}function a(e,t,n,i){if(n){var r=t;"click"!==t.type?"file"===e.type||void 0===i?n(r):n(r=s(t,e,i)):n(r=s(t,e,""))}}function o(e,t){if(e){e.focus(t);var n=(t||{}).cursor;if(n){var i=e.value.length;switch(n){case"start":e.setSelectionRange(0,0);break;case"end":e.setSelectionRange(i,i);break;default:e.setSelectionRange(0,i)}}}}n.d(t,{He:function(){return i},X3:function(){return r},nH:function(){return o},rJ:function(){return a}})},28321:function(e,t,n){"use strict";n.d(t,{iz:function(){return Ke},ck:function(){return ve},BW:function(){return Ve},sN:function(){return ve},Wd:function(){return Be},ZP:function(){return Xe},Xl:function(){return L}});var i=n(54476),r=n(20068),s=n(33885),a=n(94480),o=n(42978),l=n(75931),c=n(92310),u=n.n(c),h=n(83836),d=n(18929),p=n(13697),f=n(48736),m=n(59301),g=n(4676),_=m.createContext(null);function y(e,t){return void 0===e?null:"".concat(e,"-").concat(t)}function v(e){return y(m.useContext(_),e)}var b=n(80547),w=["children","locked"],x=m.createContext(null);function k(e){var t=e.children,n=e.locked,i=(0,l.Z)(e,w),r=m.useContext(x),a=(0,b.Z)((function(){return e=r,t=i,n=(0,s.Z)({},e),Object.keys(t).forEach((function(e){var i=t[e];void 0!==i&&(n[e]=i)})),n;var e,t,n}),[r,i],(function(e,t){return!(n||e[0]===t[0]&&(0,p.Z)(e[1],t[1],!0))}));return m.createElement(x.Provider,{value:a},t)}var S=[],E=m.createContext(null);function T(){return m.useContext(E)}var C=m.createContext(S);function L(e){var t=m.useContext(C);return m.useMemo((function(){return void 0!==e?[].concat((0,a.Z)(t),[e]):t}),[t,e])}var A=m.createContext(null),D=m.createContext({}),M=n(29194);function R(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,M.Z)(e)){var n=e.nodeName.toLowerCase(),i=["input","select","textarea","button"].includes(n)||e.isContentEditable||"a"===n&&!!e.getAttribute("href"),r=e.getAttribute("tabindex"),s=Number(r),a=null;return r&&!Number.isNaN(s)?a=s:i&&null===a&&(a=0),i&&e.disabled&&(a=null),null!==a&&(a>=0||t&&a<0)}return!1}function I(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=(0,a.Z)(e.querySelectorAll("*")).filter((function(e){return R(e,t)}));return R(e,t)&&n.unshift(e),n}var P=n(10228),O=n(16089),F=P.Z.LEFT,N=P.Z.RIGHT,B=P.Z.UP,$=P.Z.DOWN,K=P.Z.ENTER,U=P.Z.ESC,z=P.Z.HOME,V=P.Z.END,q=[B,$,F,N];function G(e,t){return I(e,!0).filter((function(e){return t.has(e)}))}function H(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(!e)return null;var r=G(e,t),s=r.length,a=r.findIndex((function(e){return n===e}));return i<0?-1===a?a=s-1:a-=1:i>0&&(a+=1),r[a=(a+s)%s]}var j=function(e,t){var n=new Set,i=new Map,r=new Map;return e.forEach((function(e){var s=document.querySelector("[data-menu-id='".concat(y(t,e),"']"));s&&(n.add(s),r.set(s,e),i.set(e,s))})),{elements:n,key2element:i,element2key:r}};function W(e,t,n,i,s,a,o,l,c,u){var h=m.useRef(),d=m.useRef();d.current=t;var p=function(){O.Z.cancel(h.current)};return m.useEffect((function(){return function(){p()}}),[]),function(f){var m=f.which;if([].concat(q,[K,U,z,V]).includes(m)){var g=a(),_=j(g,i),y=_,v=y.elements,b=y.key2element,w=y.element2key,x=function(e,t){for(var n=e||document.activeElement;n;){if(t.has(n))return n;n=n.parentElement}return null}(b.get(t),v),k=w.get(x),S=function(e,t,n,i){var s,a="prev",o="next",l="children",c="parent";if("inline"===e&&i===K)return{inlineTrigger:!0};var u=(0,r.Z)((0,r.Z)({},B,a),$,o),h=(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},F,n?o:a),N,n?a:o),$,l),K,l),d=(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},B,a),$,o),K,l),U,c),F,n?l:c),N,n?c:l);switch(null===(s={inline:u,horizontal:h,vertical:d,inlineSub:u,horizontalSub:d,verticalSub:d}["".concat(e).concat(t?"":"Sub")])||void 0===s?void 0:s[i]){case a:return{offset:-1,sibling:!0};case o:return{offset:1,sibling:!0};case c:return{offset:-1,sibling:!1};case l:return{offset:1,sibling:!1};default:return null}}(e,1===o(k,!0).length,n,m);if(!S&&m!==z&&m!==V)return;(q.includes(m)||[z,V].includes(m))&&f.preventDefault();var E=function(e){if(e){var t=e,n=e.querySelector("a");null!=n&&n.getAttribute("href")&&(t=n);var i=w.get(e);l(i),p(),h.current=(0,O.Z)((function(){d.current===i&&t.focus()}))}};if([z,V].includes(m)||S.sibling||!x){var T,C,L=G(T=x&&"inline"!==e?function(e){for(var t=e;t;){if(t.getAttribute("data-menu-list"))return t;t=t.parentElement}return null}(x):s.current,v);C=m===z?L[0]:m===V?L[L.length-1]:H(T,v,x,S.offset),E(C)}else if(S.inlineTrigger)c(k);else if(S.offset>0)c(k,!0),p(),h.current=(0,O.Z)((function(){_=j(g,i);var e=x.getAttribute("aria-controls"),t=H(document.getElementById(e),_.elements);E(t)}),5);else if(S.offset<0){var A=o(k,!0),D=A[A.length-2],M=b.get(D);c(D,!1),E(M)}}null==u||u(f)}}var Z="__RC_UTIL_PATH_SPLIT__",Y=function(e){return e.join(Z)},X="rc-menu-more";function J(){var e=m.useState({}),t=(0,o.Z)(e,2)[1],n=(0,m.useRef)(new Map),i=(0,m.useRef)(new Map),r=m.useState([]),s=(0,o.Z)(r,2),l=s[0],c=s[1],u=(0,m.useRef)(0),h=(0,m.useRef)(!1),d=(0,m.useCallback)((function(e,r){var s=Y(r);i.current.set(s,e),n.current.set(e,s),u.current+=1;var a,o=u.current;a=function(){o===u.current&&(h.current||t({}))},Promise.resolve().then(a)}),[]),p=(0,m.useCallback)((function(e,t){var r=Y(t);i.current.delete(r),n.current.delete(e)}),[]),f=(0,m.useCallback)((function(e){c(e)}),[]),g=(0,m.useCallback)((function(e,t){var i=n.current.get(e)||"",r=i.split(Z);return t&&l.includes(r[0])&&r.unshift(X),r}),[l]),_=(0,m.useCallback)((function(e,t){return e.filter((function(e){return void 0!==e})).some((function(e){return g(e,!0).includes(t)}))}),[g]),y=(0,m.useCallback)((function(e){var t="".concat(n.current.get(e)).concat(Z),r=new Set;return(0,a.Z)(i.current.keys()).forEach((function(e){e.startsWith(t)&&r.add(i.current.get(e))})),r}),[]);return m.useEffect((function(){return function(){h.current=!0}}),[]),{registerPath:d,unregisterPath:p,refreshOverflowKeys:f,isSubPathKey:_,getKeyPath:g,getKeys:function(){var e=(0,a.Z)(n.current.keys());return l.length&&e.push(X),e},getSubPathKeys:y}}function Q(e){var t=m.useRef(e);t.current=e;var n=m.useCallback((function(){for(var e,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return null===(e=t.current)||void 0===e?void 0:e.call.apply(e,[t].concat(i))}),[]);return e?n:void 0}var ee=Math.random().toFixed(5).toString().slice(2),te=0;var ne=n(67732),ie=n(83652),re=n(42403),se=n(158),ae=n(2738),oe=n(8654);function le(e,t,n,i){var r=m.useContext(x),s=r.activeKey,a=r.onActive,o=r.onInactive,l={active:s===e};return t||(l.onMouseEnter=function(t){null==n||n({key:e,domEvent:t}),a(e)},l.onMouseLeave=function(t){null==i||i({key:e,domEvent:t}),o(e)}),l}function ce(e){var t=m.useContext(x),n=t.mode,i=t.rtl,r=t.inlineIndent;if("inline"!==n)return null;return i?{paddingRight:e*r}:{paddingLeft:e*r}}function ue(e){var t,n=e.icon,i=e.props,r=e.children;return null===n||!1===n?null:("function"==typeof n?t=m.createElement(n,(0,s.Z)({},i)):"boolean"!=typeof n&&(t=n),t||r||null)}var he=["item"];function de(e){var t=e.item,n=(0,l.Z)(e,he);return Object.defineProperty(n,"item",{get:function(){return(0,f.ZP)(!1,"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."),t}}),n}var pe=["title","attribute","elementRef"],fe=["style","className","eventKey","warnKey","disabled","itemIcon","children","role","onMouseEnter","onMouseLeave","onClick","onKeyDown","onFocus"],me=["active"],ge=function(e){(0,re.Z)(n,e);var t=(0,se.Z)(n);function n(){return(0,ne.Z)(this,n),t.apply(this,arguments)}return(0,ie.Z)(n,[{key:"render",value:function(){var e=this.props,t=e.title,n=e.attribute,r=e.elementRef,s=(0,l.Z)(e,pe),a=(0,ae.Z)(s,["eventKey","popupClassName","popupOffset","onTitleClick"]);return(0,f.ZP)(!n,"`attribute` of Menu.Item is deprecated. Please pass attribute directly."),m.createElement(h.Z.Item,(0,i.Z)({},n,{title:"string"==typeof t?t:void 0},a,{ref:r}))}}]),n}(m.Component),_e=m.forwardRef((function(e,t){var n=e.style,o=e.className,c=e.eventKey,h=(e.warnKey,e.disabled),d=e.itemIcon,p=e.children,f=e.role,g=e.onMouseEnter,_=e.onMouseLeave,y=e.onClick,b=e.onKeyDown,w=e.onFocus,k=(0,l.Z)(e,fe),S=v(c),E=m.useContext(x),T=E.prefixCls,C=E.onItemClick,A=E.disabled,M=E.overflowDisabled,R=E.itemIcon,I=E.selectedKeys,O=E.onActive,F=m.useContext(D)._internalRenderMenuItem,N="".concat(T,"-item"),B=m.useRef(),$=m.useRef(),K=A||h,U=(0,oe.x1)(t,$),z=L(c);var V=function(e){return{key:c,keyPath:(0,a.Z)(z).reverse(),item:B.current,domEvent:e}},q=d||R,G=le(c,K,g,_),H=G.active,j=(0,l.Z)(G,me),W=I.includes(c),Z=ce(z.length),Y={};"option"===e.role&&(Y["aria-selected"]=W);var X=m.createElement(ge,(0,i.Z)({ref:B,elementRef:U,role:null===f?"none":f||"menuitem",tabIndex:h?null:-1,"data-menu-id":M&&S?null:S},(0,ae.Z)(k,["extra"]),j,Y,{component:"li","aria-disabled":h,style:(0,s.Z)((0,s.Z)({},Z),n),className:u()(N,(0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(N,"-active"),H),"".concat(N,"-selected"),W),"".concat(N,"-disabled"),K),o),onClick:function(e){if(!K){var t=V(e);null==y||y(de(t)),C(t)}},onKeyDown:function(e){if(null==b||b(e),e.which===P.Z.ENTER){var t=V(e);null==y||y(de(t)),C(t)}},onFocus:function(e){O(c),null==w||w(e)}}),p,m.createElement(ue,{props:(0,s.Z)((0,s.Z)({},e),{},{isSelected:W}),icon:q}));return F&&(X=F(X,e,{selected:W})),X}));function ye(e,t){var n=e.eventKey,r=T(),s=L(n);return m.useEffect((function(){if(r)return r.registerPath(n,s),function(){r.unregisterPath(n,s)}}),[s]),r?null:m.createElement(_e,(0,i.Z)({},e,{ref:t}))}var ve=m.forwardRef(ye),be=["className","children"],we=function(e,t){var n=e.className,r=e.children,s=(0,l.Z)(e,be),a=m.useContext(x),o=a.prefixCls,c=a.mode,h=a.rtl;return m.createElement("ul",(0,i.Z)({className:u()(o,h&&"".concat(o,"-rtl"),"".concat(o,"-sub"),"".concat(o,"-").concat("inline"===c?"inline":"vertical"),n),role:"menu"},s,{"data-menu-list":!0,ref:t}),r)},xe=m.forwardRef(we);xe.displayName="SubMenuList";var ke=xe,Se=n(11592);function Ee(e,t){return(0,Se.Z)(e).map((function(e,n){if(m.isValidElement(e)){var i,r,s=e.key,o=null!==(i=null===(r=e.props)||void 0===r?void 0:r.eventKey)&&void 0!==i?i:s;null==o&&(o="tmp_key-".concat([].concat((0,a.Z)(t),[n]).join("-")));var l={key:o,eventKey:o};return m.cloneElement(e,l)}return e}))}var Te=n(65030),Ce={adjustX:1,adjustY:1},Le={topLeft:{points:["bl","tl"],overflow:Ce},topRight:{points:["br","tr"],overflow:Ce},bottomLeft:{points:["tl","bl"],overflow:Ce},bottomRight:{points:["tr","br"],overflow:Ce},leftTop:{points:["tr","tl"],overflow:Ce},leftBottom:{points:["br","bl"],overflow:Ce},rightTop:{points:["tl","tr"],overflow:Ce},rightBottom:{points:["bl","br"],overflow:Ce}},Ae={topLeft:{points:["bl","tl"],overflow:Ce},topRight:{points:["br","tr"],overflow:Ce},bottomLeft:{points:["tl","bl"],overflow:Ce},bottomRight:{points:["tr","br"],overflow:Ce},rightTop:{points:["tr","tl"],overflow:Ce},rightBottom:{points:["br","bl"],overflow:Ce},leftTop:{points:["tl","tr"],overflow:Ce},leftBottom:{points:["bl","br"],overflow:Ce}};function De(e,t,n){return t||(n?n[e]||n.other:void 0)}var Me={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"};function Re(e){var t=e.prefixCls,n=e.visible,i=e.children,a=e.popup,l=e.popupStyle,c=e.popupClassName,h=e.popupOffset,d=e.disabled,p=e.mode,f=e.onVisibleChange,g=m.useContext(x),_=g.getPopupContainer,y=g.rtl,v=g.subMenuOpenDelay,b=g.subMenuCloseDelay,w=g.builtinPlacements,k=g.triggerSubMenuAction,S=g.forceSubMenuRender,E=g.rootClassName,T=g.motion,C=g.defaultMotions,L=m.useState(!1),A=(0,o.Z)(L,2),D=A[0],M=A[1],R=y?(0,s.Z)((0,s.Z)({},Ae),w):(0,s.Z)((0,s.Z)({},Le),w),I=Me[p],P=De(p,T,C),F=m.useRef(P);"inline"!==p&&(F.current=P);var N=(0,s.Z)((0,s.Z)({},F.current),{},{leavedClassName:"".concat(t,"-hidden"),removeOnLeave:!1,motionAppear:!0}),B=m.useRef();return m.useEffect((function(){return B.current=(0,O.Z)((function(){M(n)})),function(){O.Z.cancel(B.current)}}),[n]),m.createElement(Te.Z,{prefixCls:t,popupClassName:u()("".concat(t,"-popup"),(0,r.Z)({},"".concat(t,"-rtl"),y),c,E),stretch:"horizontal"===p?"minWidth":null,getPopupContainer:_,builtinPlacements:R,popupPlacement:I,popupVisible:D,popup:a,popupStyle:l,popupAlign:h&&{offset:h},action:d?[]:[k],mouseEnterDelay:v,mouseLeaveDelay:b,onPopupVisibleChange:f,forceRender:S,popupMotion:N,fresh:!0},i)}var Ie=n(77900);function Pe(e){var t=e.id,n=e.open,r=e.keyPath,a=e.children,l="inline",c=m.useContext(x),u=c.prefixCls,h=c.forceSubMenuRender,d=c.motion,p=c.defaultMotions,f=c.mode,g=m.useRef(!1);g.current=f===l;var _=m.useState(!g.current),y=(0,o.Z)(_,2),v=y[0],b=y[1],w=!!g.current&&n;m.useEffect((function(){g.current&&b(!1)}),[f]);var S=(0,s.Z)({},De(l,d,p));r.length>1&&(S.motionAppear=!1);var E=S.onVisibleChanged;return S.onVisibleChanged=function(e){return g.current||e||b(!0),null==E?void 0:E(e)},v?null:m.createElement(k,{mode:l,locked:!g.current},m.createElement(Ie.default,(0,i.Z)({visible:w},S,{forceRender:h,removeOnLeave:!1,leavedClassName:"".concat(u,"-hidden")}),(function(e){var n=e.className,i=e.style;return m.createElement(ke,{id:t,className:n,style:i},a)})))}var Oe=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","popupStyle","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],Fe=["active"],Ne=m.forwardRef((function(e,t){var n=e.style,a=e.className,c=e.title,d=e.eventKey,p=(e.warnKey,e.disabled),f=e.internalPopupClose,g=e.children,_=e.itemIcon,y=e.expandIcon,b=e.popupClassName,w=e.popupOffset,S=e.popupStyle,E=e.onClick,T=e.onMouseEnter,C=e.onMouseLeave,M=e.onTitleClick,R=e.onTitleMouseEnter,I=e.onTitleMouseLeave,P=(0,l.Z)(e,Oe),O=v(d),F=m.useContext(x),N=F.prefixCls,B=F.mode,$=F.openKeys,K=F.disabled,U=F.overflowDisabled,z=F.activeKey,V=F.selectedKeys,q=F.itemIcon,G=F.expandIcon,H=F.onItemClick,j=F.onOpenChange,W=F.onActive,Z=m.useContext(D)._internalRenderSubMenuItem,Y=m.useContext(A).isSubPathKey,X=L(),J="".concat(N,"-submenu"),ee=K||p,te=m.useRef(),ne=m.useRef();var ie=null!=_?_:q,re=null!=y?y:G,se=$.includes(d),ae=!U&&se,oe=Y(V,d),he=le(d,ee,R,I),pe=he.active,fe=(0,l.Z)(he,Fe),me=m.useState(!1),ge=(0,o.Z)(me,2),_e=ge[0],ye=ge[1],ve=function(e){ee||ye(e)},be=m.useMemo((function(){return pe||"inline"!==B&&(_e||Y([z],d))}),[B,pe,z,_e,d,Y]),we=ce(X.length),xe=Q((function(e){null==E||E(de(e)),H(e)})),Se=O&&"".concat(O,"-popup"),Ee=m.useMemo((function(){return m.createElement(ue,{icon:"horizontal"!==B?re:void 0,props:(0,s.Z)((0,s.Z)({},e),{},{isOpen:ae,isSubMenu:!0})},m.createElement("i",{className:"".concat(J,"-arrow")}))}),[B,re,e,ae,J]),Te=m.createElement("div",(0,i.Z)({role:"menuitem",style:we,className:"".concat(J,"-title"),tabIndex:ee?null:-1,ref:te,title:"string"==typeof c?c:null,"data-menu-id":U&&O?null:O,"aria-expanded":ae,"aria-haspopup":!0,"aria-controls":Se,"aria-disabled":ee,onClick:function(e){ee||(null==M||M({key:d,domEvent:e}),"inline"===B&&j(d,!se))},onFocus:function(){W(d)}},fe),c,Ee),Ce=m.useRef(B);if("inline"!==B&&X.length>1?Ce.current="vertical":Ce.current=B,!U){var Le=Ce.current;Te=m.createElement(Re,{mode:Le,prefixCls:J,visible:!f&&ae&&"inline"!==B,popupClassName:b,popupOffset:w,popupStyle:S,popup:m.createElement(k,{mode:"horizontal"===Le?"vertical":Le},m.createElement(ke,{id:Se,ref:ne},g)),disabled:ee,onVisibleChange:function(e){"inline"!==B&&j(d,e)}},Te)}var Ae=m.createElement(h.Z.Item,(0,i.Z)({ref:t,role:"none"},P,{component:"li",style:n,className:u()(J,"".concat(J,"-").concat(B),a,(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(J,"-open"),ae),"".concat(J,"-active"),be),"".concat(J,"-selected"),oe),"".concat(J,"-disabled"),ee)),onMouseEnter:function(e){ve(!0),null==T||T({key:d,domEvent:e})},onMouseLeave:function(e){ve(!1),null==C||C({key:d,domEvent:e})}}),Te,!U&&m.createElement(Pe,{id:Se,open:ae,keyPath:X},g));return Z&&(Ae=Z(Ae,e,{selected:oe,active:be,open:ae,disabled:ee})),m.createElement(k,{onItemClick:xe,mode:"horizontal"===B?"vertical":B,itemIcon:ie,expandIcon:re},Ae)}));var Be=m.forwardRef((function(e,t){var n,r=e.eventKey,s=e.children,a=L(r),o=Ee(s,a),l=T();return m.useEffect((function(){if(l)return l.registerPath(r,a),function(){l.unregisterPath(r,a)}}),[a]),n=l?o:m.createElement(Ne,(0,i.Z)({ref:t},e),o),m.createElement(C.Provider,{value:a},n)})),$e=n(76190);function Ke(e){var t=e.className,n=e.style,i=m.useContext(x).prefixCls;return T()?null:m.createElement("li",{role:"separator",className:u()("".concat(i,"-item-divider"),t),style:n})}var Ue=["className","title","eventKey","children"],ze=m.forwardRef((function(e,t){var n=e.className,r=e.title,s=(e.eventKey,e.children),a=(0,l.Z)(e,Ue),o=m.useContext(x).prefixCls,c="".concat(o,"-item-group");return m.createElement("li",(0,i.Z)({ref:t,role:"presentation"},a,{onClick:function(e){return e.stopPropagation()},className:u()(c,n)}),m.createElement("div",{role:"presentation",className:"".concat(c,"-title"),title:"string"==typeof r?r:void 0},r),m.createElement("ul",{role:"group",className:"".concat(c,"-list")},s))}));var Ve=m.forwardRef((function(e,t){var n=e.eventKey,r=Ee(e.children,L(n));return T()?r:m.createElement(ze,(0,i.Z)({ref:t},(0,ae.Z)(e,["warnKey"])),r)})),qe=["label","children","key","type","extra"];function Ge(e,t,n){var r=t.item,s=t.group,a=t.submenu,o=t.divider;return(e||[]).map((function(e,c){if(e&&"object"===(0,$e.Z)(e)){var u=e,h=u.label,d=u.children,p=u.key,f=u.type,g=u.extra,_=(0,l.Z)(u,qe),y=null!=p?p:"tmp-".concat(c);return d||"group"===f?"group"===f?m.createElement(s,(0,i.Z)({key:y},_,{title:h}),Ge(d,t,n)):m.createElement(a,(0,i.Z)({key:y},_,{title:h}),Ge(d,t,n)):"divider"===f?m.createElement(o,(0,i.Z)({key:y},_)):m.createElement(r,(0,i.Z)({key:y},_,{extra:g}),h,(!!g||0===g)&&m.createElement("span",{className:"".concat(n,"-item-extra")},g))}return null})).filter((function(e){return e}))}function He(e,t,n,i,r){var a=e,o=(0,s.Z)({divider:Ke,item:ve,group:Ve,submenu:Be},i);return t&&(a=Ge(t,o,r)),Ee(a,n)}var je=["prefixCls","rootClassName","style","className","tabIndex","items","children","direction","id","mode","inlineCollapsed","disabled","disabledOverflow","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","defaultOpenKeys","openKeys","activeKey","defaultActiveFirst","selectable","multiple","defaultSelectedKeys","selectedKeys","onSelect","onDeselect","inlineIndent","motion","defaultMotions","triggerSubMenuAction","builtinPlacements","itemIcon","expandIcon","overflowedIndicator","overflowedIndicatorPopupClassName","getPopupContainer","onClick","onOpenChange","onKeyDown","openAnimation","openTransitionName","_internalRenderMenuItem","_internalRenderSubMenuItem","_internalComponents"],We=[],Ze=m.forwardRef((function(e,t){var n,c=e,f=c.prefixCls,y=void 0===f?"rc-menu":f,v=c.rootClassName,b=c.style,w=c.className,x=c.tabIndex,S=void 0===x?0:x,T=c.items,C=c.children,L=c.direction,M=c.id,R=c.mode,I=void 0===R?"vertical":R,P=c.inlineCollapsed,O=c.disabled,F=c.disabledOverflow,N=c.subMenuOpenDelay,B=void 0===N?.1:N,$=c.subMenuCloseDelay,K=void 0===$?.1:$,U=c.forceSubMenuRender,z=c.defaultOpenKeys,V=c.openKeys,q=c.activeKey,H=c.defaultActiveFirst,Z=c.selectable,Y=void 0===Z||Z,ne=c.multiple,ie=void 0!==ne&&ne,re=c.defaultSelectedKeys,se=c.selectedKeys,ae=c.onSelect,oe=c.onDeselect,le=c.inlineIndent,ce=void 0===le?24:le,ue=c.motion,he=c.defaultMotions,pe=c.triggerSubMenuAction,fe=void 0===pe?"hover":pe,me=c.builtinPlacements,ge=c.itemIcon,_e=c.expandIcon,ye=c.overflowedIndicator,be=void 0===ye?"...":ye,we=c.overflowedIndicatorPopupClassName,xe=c.getPopupContainer,ke=c.onClick,Se=c.onOpenChange,Ee=c.onKeyDown,Te=(c.openAnimation,c.openTransitionName,c._internalRenderMenuItem),Ce=c._internalRenderSubMenuItem,Le=c._internalComponents,Ae=(0,l.Z)(c,je),De=m.useMemo((function(){return[He(C,T,We,Le,y),He(C,T,We,{},y)]}),[C,T,Le]),Me=(0,o.Z)(De,2),Re=Me[0],Ie=Me[1],Pe=m.useState(!1),Oe=(0,o.Z)(Pe,2),Fe=Oe[0],Ne=Oe[1],$e=m.useRef(),Ke=function(e){var t=(0,d.Z)(e,{value:e}),n=(0,o.Z)(t,2),i=n[0],r=n[1];return m.useEffect((function(){te+=1;var e="".concat(ee,"-").concat(te);r("rc-menu-uuid-".concat(e))}),[]),i}(M),Ue="rtl"===L;var ze=(0,d.Z)(z,{value:V,postState:function(e){return e||We}}),Ve=(0,o.Z)(ze,2),qe=Ve[0],Ge=Ve[1],Ze=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];function n(){Ge(e),null==Se||Se(e)}t?(0,g.flushSync)(n):n()},Ye=m.useState(qe),Xe=(0,o.Z)(Ye,2),Je=Xe[0],Qe=Xe[1],et=m.useRef(!1),tt=m.useMemo((function(){return"inline"!==I&&"vertical"!==I||!P?[I,!1]:["vertical",P]}),[I,P]),nt=(0,o.Z)(tt,2),it=nt[0],rt=nt[1],st="inline"===it,at=m.useState(it),ot=(0,o.Z)(at,2),lt=ot[0],ct=ot[1],ut=m.useState(rt),ht=(0,o.Z)(ut,2),dt=ht[0],pt=ht[1];m.useEffect((function(){ct(it),pt(rt),et.current&&(st?Ge(Je):Ze(We))}),[it,rt]);var ft=m.useState(0),mt=(0,o.Z)(ft,2),gt=mt[0],_t=mt[1],yt=gt>=Re.length-1||"horizontal"!==lt||F;m.useEffect((function(){st&&Qe(qe)}),[qe]),m.useEffect((function(){return et.current=!0,function(){et.current=!1}}),[]);var vt=J(),bt=vt.registerPath,wt=vt.unregisterPath,xt=vt.refreshOverflowKeys,kt=vt.isSubPathKey,St=vt.getKeyPath,Et=vt.getKeys,Tt=vt.getSubPathKeys,Ct=m.useMemo((function(){return{registerPath:bt,unregisterPath:wt}}),[bt,wt]),Lt=m.useMemo((function(){return{isSubPathKey:kt}}),[kt]);m.useEffect((function(){xt(yt?We:Re.slice(gt+1).map((function(e){return e.key})))}),[gt,yt]);var At=(0,d.Z)(q||H&&(null===(n=Re[0])||void 0===n?void 0:n.key),{value:q}),Dt=(0,o.Z)(At,2),Mt=Dt[0],Rt=Dt[1],It=Q((function(e){Rt(e)})),Pt=Q((function(){Rt(void 0)}));(0,m.useImperativeHandle)(t,(function(){return{list:$e.current,focus:function(e){var t,n,i=Et(),r=j(i,Ke),s=r.elements,a=r.key2element,o=r.element2key,l=G($e.current,s),c=null!=Mt?Mt:l[0]?o.get(l[0]):null===(t=Re.find((function(e){return!e.props.disabled})))||void 0===t?void 0:t.key,u=a.get(c);c&&u&&(null==u||null===(n=u.focus)||void 0===n||n.call(u,e))}}}));var Ot=(0,d.Z)(re||[],{value:se,postState:function(e){return Array.isArray(e)?e:null==e?We:[e]}}),Ft=(0,o.Z)(Ot,2),Nt=Ft[0],Bt=Ft[1],$t=Q((function(e){null==ke||ke(de(e)),function(e){if(Y){var t,n=e.key,i=Nt.includes(n);t=ie?i?Nt.filter((function(e){return e!==n})):[].concat((0,a.Z)(Nt),[n]):[n],Bt(t);var r=(0,s.Z)((0,s.Z)({},e),{},{selectedKeys:t});i?null==oe||oe(r):null==ae||ae(r)}!ie&&qe.length&&"inline"!==lt&&Ze(We)}(e)})),Kt=Q((function(e,t){var n=qe.filter((function(t){return t!==e}));if(t)n.push(e);else if("inline"!==lt){var i=Tt(e);n=n.filter((function(e){return!i.has(e)}))}(0,p.Z)(qe,n,!0)||Ze(n,!0)})),Ut=W(lt,Mt,Ue,Ke,$e,Et,St,Rt,(function(e,t){var n=null!=t?t:!qe.includes(e);Kt(e,n)}),Ee);m.useEffect((function(){Ne(!0)}),[]);var zt=m.useMemo((function(){return{_internalRenderMenuItem:Te,_internalRenderSubMenuItem:Ce}}),[Te,Ce]),Vt="horizontal"!==lt||F?Re:Re.map((function(e,t){return m.createElement(k,{key:e.key,overflowDisabled:t>gt},e)})),qt=m.createElement(h.Z,(0,i.Z)({id:M,ref:$e,prefixCls:"".concat(y,"-overflow"),component:"ul",itemComponent:ve,className:u()(y,"".concat(y,"-root"),"".concat(y,"-").concat(lt),w,(0,r.Z)((0,r.Z)({},"".concat(y,"-inline-collapsed"),dt),"".concat(y,"-rtl"),Ue),v),dir:L,style:b,role:"menu",tabIndex:S,data:Vt,renderRawItem:function(e){return e},renderRawRest:function(e){var t=e.length,n=t?Re.slice(-t):null;return m.createElement(Be,{eventKey:X,title:be,disabled:yt,internalPopupClose:0===t,popupClassName:we},n)},maxCount:"horizontal"!==lt||F?h.Z.INVALIDATE:h.Z.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function(e){_t(e)},onKeyDown:Ut},Ae));return m.createElement(D.Provider,{value:zt},m.createElement(_.Provider,{value:Ke},m.createElement(k,{prefixCls:y,rootClassName:v,mode:lt,openKeys:qe,rtl:Ue,disabled:O,motion:Fe?ue:null,defaultMotions:Fe?he:null,activeKey:Mt,onActive:It,onInactive:Pt,selectedKeys:Nt,inlineIndent:ce,subMenuOpenDelay:B,subMenuCloseDelay:K,forceSubMenuRender:U,builtinPlacements:me,triggerSubMenuAction:fe,getPopupContainer:xe,itemIcon:ge,expandIcon:_e,onItemClick:$t,onOpenChange:Kt},m.createElement(A.Provider,{value:Lt},qt),m.createElement("div",{style:{display:"none"},"aria-hidden":!0},m.createElement(E.Provider,{value:Ct},Ie)))))})),Ye=Ze;Ye.Item=ve,Ye.SubMenu=Be,Ye.ItemGroup=Ve,Ye.Divider=Ke;var Xe=Ye},83836:function(e,t,n){"use strict";n.d(t,{Z:function(){return O}});var i=n(54476),r=n(33885),s=n(42978),a=n(75931),o=n(59301),l=n(92310),c=n.n(l),u=n(29301),h=n(34280),d=["prefixCls","invalidate","item","renderItem","responsive","responsiveDisabled","registerSize","itemKey","className","style","children","display","order","component"],p=void 0;function f(e,t){var n=e.prefixCls,s=e.invalidate,l=e.item,h=e.renderItem,f=e.responsive,m=e.responsiveDisabled,g=e.registerSize,_=e.itemKey,y=e.className,v=e.style,b=e.children,w=e.display,x=e.order,k=e.component,S=void 0===k?"div":k,E=(0,a.Z)(e,d),T=f&&!w;function C(e){g(_,e)}o.useEffect((function(){return function(){C(null)}}),[]);var L,A=h&&l!==p?h(l,{index:x}):b;s||(L={opacity:T?0:1,height:T?0:p,overflowY:T?"hidden":p,order:f?x:p,pointerEvents:T?"none":p,position:T?"absolute":p});var D={};T&&(D["aria-hidden"]=!0);var M=o.createElement(S,(0,i.Z)({className:c()(!s&&n,y),style:(0,r.Z)((0,r.Z)({},L),v)},D,E,{ref:t}),A);return f&&(M=o.createElement(u.Z,{onResize:function(e){C(e.offsetWidth)},disabled:m},M)),M}var m=o.forwardRef(f);m.displayName="Item";var g=m,_=n(6089),y=n(4676),v=n(16089);function b(){var e=o.useRef(null);return function(t){e.current||(e.current=[],function(e){if("undefined"==typeof MessageChannel)(0,v.Z)(e);else{var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(void 0)}}((function(){(0,y.unstable_batchedUpdates)((function(){e.current.forEach((function(e){e()})),e.current=null}))}))),e.current.push(t)}}function w(e,t){var n=o.useState(t),i=(0,s.Z)(n,2),r=i[0],a=i[1];return[r,(0,_.Z)((function(t){e((function(){a(t)}))}))]}var x=o.createContext(null),k=["component"],S=["className"],E=["className"],T=function(e,t){var n=o.useContext(x);if(!n){var r=e.component,s=void 0===r?"div":r,l=(0,a.Z)(e,k);return o.createElement(s,(0,i.Z)({},l,{ref:t}))}var u=n.className,h=(0,a.Z)(n,S),d=e.className,p=(0,a.Z)(e,E);return o.createElement(x.Provider,{value:null},o.createElement(g,(0,i.Z)({ref:t,className:c()(u,d)},h,p)))},C=o.forwardRef(T);C.displayName="RawItem";var L=C,A=["prefixCls","data","renderItem","renderRawItem","itemKey","itemWidth","ssr","style","className","maxCount","renderRest","renderRawRest","prefix","suffix","component","itemComponent","onVisibleChange"],D="responsive",M="invalidate";function R(e){return"+ ".concat(e.length," ...")}function I(e,t){var n=e.prefixCls,l=void 0===n?"rc-overflow":n,d=e.data,p=void 0===d?[]:d,f=e.renderItem,m=e.renderRawItem,_=e.itemKey,y=e.itemWidth,v=void 0===y?10:y,k=e.ssr,S=e.style,E=e.className,T=e.maxCount,C=e.renderRest,L=e.renderRawRest,I=e.prefix,P=e.suffix,O=e.component,F=void 0===O?"div":O,N=e.itemComponent,B=e.onVisibleChange,$=(0,a.Z)(e,A),K="full"===k,U=b(),z=w(U,null),V=(0,s.Z)(z,2),q=V[0],G=V[1],H=q||0,j=w(U,new Map),W=(0,s.Z)(j,2),Z=W[0],Y=W[1],X=w(U,0),J=(0,s.Z)(X,2),Q=J[0],ee=J[1],te=w(U,0),ne=(0,s.Z)(te,2),ie=ne[0],re=ne[1],se=w(U,0),ae=(0,s.Z)(se,2),oe=ae[0],le=ae[1],ce=w(U,0),ue=(0,s.Z)(ce,2),he=ue[0],de=ue[1],pe=(0,o.useState)(null),fe=(0,s.Z)(pe,2),me=fe[0],ge=fe[1],_e=(0,o.useState)(null),ye=(0,s.Z)(_e,2),ve=ye[0],be=ye[1],we=o.useMemo((function(){return null===ve&&K?Number.MAX_SAFE_INTEGER:ve||0}),[ve,q]),xe=(0,o.useState)(!1),ke=(0,s.Z)(xe,2),Se=ke[0],Ee=ke[1],Te="".concat(l,"-item"),Ce=Math.max(Q,ie),Le=T===D,Ae=p.length&&Le,De=T===M,Me=Ae||"number"==typeof T&&p.length>T,Re=(0,o.useMemo)((function(){var e=p;return Ae?e=null===q&&K?p:p.slice(0,Math.min(p.length,H/v)):"number"==typeof T&&(e=p.slice(0,T)),e}),[p,v,q,T,Ae]),Ie=(0,o.useMemo)((function(){return Ae?p.slice(we+1):p.slice(Re.length)}),[p,Re,Ae,we]),Pe=(0,o.useCallback)((function(e,t){var n;return"function"==typeof _?_(e):null!==(n=_&&(null==e?void 0:e[_]))&&void 0!==n?n:t}),[_]),Oe=(0,o.useCallback)(f||function(e){return e},[f]);function Fe(e,t,n){(ve!==e||void 0!==t&&t!==me)&&(be(e),n||(Ee(e<p.length-1),null==B||B(e)),void 0!==t&&ge(t))}function Ne(e,t){Y((function(n){var i=new Map(n);return null===t?i.delete(e):i.set(e,t),i}))}function Be(e){return Z.get(Pe(Re[e],e))}(0,h.Z)((function(){if(H&&"number"==typeof Ce&&Re){var e=oe+he,t=Re.length,n=t-1;if(!t)return void Fe(0,null);for(var i=0;i<t;i+=1){var r=Be(i);if(K&&(r=r||0),void 0===r){Fe(i-1,void 0,!0);break}if(e+=r,0===n&&e<=H||i===n-1&&e+Be(n)<=H){Fe(n,null);break}if(e+Ce>H){Fe(i-1,e-r-he+ie);break}}P&&Be(0)+he>H&&ge(null)}}),[H,Z,ie,oe,he,Pe,Re]);var $e=Se&&!!Ie.length,Ke={};null!==me&&Ae&&(Ke={position:"absolute",left:me,top:0});var Ue={prefixCls:Te,responsive:Ae,component:N,invalidate:De},ze=m?function(e,t){var n=Pe(e,t);return o.createElement(x.Provider,{key:n,value:(0,r.Z)((0,r.Z)({},Ue),{},{order:t,item:e,itemKey:n,registerSize:Ne,display:t<=we})},m(e,t))}:function(e,t){var n=Pe(e,t);return o.createElement(g,(0,i.Z)({},Ue,{order:t,key:n,item:e,renderItem:Oe,itemKey:n,registerSize:Ne,display:t<=we}))},Ve={order:$e?we:Number.MAX_SAFE_INTEGER,className:"".concat(Te,"-rest"),registerSize:function(e,t){re(t),ee(ie)},display:$e},qe=C||R,Ge=L?o.createElement(x.Provider,{value:(0,r.Z)((0,r.Z)({},Ue),Ve)},L(Ie)):o.createElement(g,(0,i.Z)({},Ue,Ve),"function"==typeof qe?qe(Ie):qe),He=o.createElement(F,(0,i.Z)({className:c()(!De&&l,E),style:S,ref:t},$),I&&o.createElement(g,(0,i.Z)({},Ue,{responsive:Le,responsiveDisabled:!Ae,order:-1,className:"".concat(Te,"-prefix"),registerSize:function(e,t){le(t)},display:!0}),I),Re.map(ze),Me?Ge:null,P&&o.createElement(g,(0,i.Z)({},Ue,{responsive:Le,responsiveDisabled:!Ae,order:we,className:"".concat(Te,"-suffix"),registerSize:function(e,t){de(t)},display:!0,style:Ke}),P));return Le?o.createElement(u.Z,{onResize:function(e,t){G(t.clientWidth)},disabled:!Ae},He):He}var P=o.forwardRef(I);P.displayName="Overflow",P.Item=L,P.RESPONSIVE=D,P.INVALIDATE=M;var O=P},29301:function(e,t,n){"use strict";n.d(t,{Z:function(){return k}});var i=n(54476),r=n(59301),s=n(11592),a=(n(48736),n(33885)),o=n(76190),l=n(76846),c=n(8654),u=r.createContext(null);var h=n(76374),d=new Map;var p=new h.Z((function(e){e.forEach((function(e){var t,n=e.target;null===(t=d.get(n))||void 0===t||t.forEach((function(e){return e(n)}))}))}));var f=n(67732),m=n(83652),g=n(42403),_=n(158),y=function(e){(0,g.Z)(n,e);var t=(0,_.Z)(n);function n(){return(0,f.Z)(this,n),t.apply(this,arguments)}return(0,m.Z)(n,[{key:"render",value:function(){return this.props.children}}]),n}(r.Component);function v(e,t){var n=e.children,i=e.disabled,s=r.useRef(null),h=r.useRef(null),f=r.useContext(u),m="function"==typeof n,g=m?n(s):n,_=r.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),v=!m&&r.isValidElement(g)&&(0,c.Yr)(g),b=v?(0,c.C4)(g):null,w=(0,c.x1)(b,s),x=function(){var e;return(0,l.ZP)(s.current)||(s.current&&"object"===(0,o.Z)(s.current)?(0,l.ZP)(null===(e=s.current)||void 0===e?void 0:e.nativeElement):null)||(0,l.ZP)(h.current)};r.useImperativeHandle(t,(function(){return x()}));var k=r.useRef(e);k.current=e;var S=r.useCallback((function(e){var t=k.current,n=t.onResize,i=t.data,r=e.getBoundingClientRect(),s=r.width,o=r.height,l=e.offsetWidth,c=e.offsetHeight,u=Math.floor(s),h=Math.floor(o);if(_.current.width!==u||_.current.height!==h||_.current.offsetWidth!==l||_.current.offsetHeight!==c){var d={width:u,height:h,offsetWidth:l,offsetHeight:c};_.current=d;var p=l===Math.round(s)?s:l,m=c===Math.round(o)?o:c,g=(0,a.Z)((0,a.Z)({},d),{},{offsetWidth:p,offsetHeight:m});null==f||f(g,e,i),n&&Promise.resolve().then((function(){n(g,e)}))}}),[]);return r.useEffect((function(){var e,t,n=x();return n&&!i&&(e=n,t=S,d.has(e)||(d.set(e,new Set),p.observe(e)),d.get(e).add(t)),function(){return function(e,t){d.has(e)&&(d.get(e).delete(t),d.get(e).size||(p.unobserve(e),d.delete(e)))}(n,S)}}),[s.current,i]),r.createElement(y,{ref:h},v?r.cloneElement(g,{ref:w}):g)}var b=r.forwardRef(v);function w(e,t){var n=e.children;return("function"==typeof n?[n]:(0,s.Z)(n)).map((function(n,s){var a=(null==n?void 0:n.key)||"".concat("rc-observer-key","-").concat(s);return r.createElement(b,(0,i.Z)({},e,{key:a,ref:0===s?t:void 0}),n)}))}var x=r.forwardRef(w);x.Collection=function(e){var t=e.children,n=e.onBatchResize,i=r.useRef(0),s=r.useRef([]),a=r.useContext(u),o=r.useCallback((function(e,t,r){i.current+=1;var o=i.current;s.current.push({size:e,element:t,data:r}),Promise.resolve().then((function(){o===i.current&&(null==n||n(s.current),s.current=[])})),null==a||a(e,t,r)}),[n,a]);return r.createElement(u.Provider,{value:o},t)};var k=x},29443:function(e,t,n){"use strict";n.d(t,{Z:function(){return J}});var i=n(54476),r=n(20068),s=n(33885),a=n(42978),o=n(76190),l=n(75931),c=n(92310),u=n.n(c),h=n(18929),d=n(49658),p=n(59301),f=(0,p.createContext)(null),m=n(94480),g=n(29301),_=n(6089),y=n(8654),v=n(16089),b=function(e){var t=e.activeTabOffset,n=e.horizontal,i=e.rtl,r=e.indicator,s=void 0===r?{}:r,o=s.size,l=s.align,c=void 0===l?"center":l,u=(0,p.useState)(),h=(0,a.Z)(u,2),d=h[0],f=h[1],m=(0,p.useRef)(),g=p.useCallback((function(e){return"function"==typeof o?o(e):"number"==typeof o?o:e}),[o]);function _(){v.Z.cancel(m.current)}return(0,p.useEffect)((function(){var e={};if(t)if(n){e.width=g(t.width);var r=i?"right":"left";"start"===c&&(e[r]=t[r]),"center"===c&&(e[r]=t[r]+t.width/2,e.transform=i?"translateX(50%)":"translateX(-50%)"),"end"===c&&(e[r]=t[r]+t.width,e.transform="translateX(-100%)")}else e.height=g(t.height),"start"===c&&(e.top=t.top),"center"===c&&(e.top=t.top+t.height/2,e.transform="translateY(-50%)"),"end"===c&&(e.top=t.top+t.height,e.transform="translateY(-100%)");return _(),m.current=(0,v.Z)((function(){f(e)})),_}),[t,n,i,c,g]),{style:d}},w={width:0,height:0,left:0,top:0};function x(e,t){var n=p.useRef(e),i=p.useState({}),r=(0,a.Z)(i,2)[1];return[n.current,function(e){var i="function"==typeof e?e(n.current):e;i!==n.current&&t(i,n.current),n.current=i,r({})}]}var k=Math.pow(.995,20);var S=n(34280);function E(e){var t=(0,p.useState)(0),n=(0,a.Z)(t,2),i=n[0],r=n[1],s=(0,p.useRef)(0),o=(0,p.useRef)();return o.current=e,(0,S.o)((function(){var e;null===(e=o.current)||void 0===e||e.call(o)}),[i]),function(){s.current===i&&(s.current+=1,r(s.current))}}var T={width:0,height:0,left:0,top:0,right:0};function C(e){var t;return e instanceof Map?(t={},e.forEach((function(e,n){t[n]=e}))):t=e,JSON.stringify(t)}function L(e){return String(e).replace(/"/g,"TABS_DQ")}function A(e,t,n,i){return!(!n||i||!1===e||void 0===e&&(!1===t||null===t))}var D=p.forwardRef((function(e,t){var n=e.prefixCls,i=e.editable,r=e.locale,s=e.style;return i&&!1!==i.showAdd?p.createElement("button",{ref:t,type:"button",className:"".concat(n,"-nav-add"),style:s,"aria-label":(null==r?void 0:r.addAriaLabel)||"Add tab",onClick:function(e){i.onEdit("add",{event:e})}},i.addIcon||"+"):null}));var M=p.forwardRef((function(e,t){var n,i=e.position,r=e.prefixCls,s=e.extra;if(!s)return null;var a={};return"object"!==(0,o.Z)(s)||p.isValidElement(s)?a.right=s:a=s,"right"===i&&(n=a.right),"left"===i&&(n=a.left),n?p.createElement("div",{className:"".concat(r,"-extra-content"),ref:t},n):null})),R=n(96478),I=n(28321),P=n(10228),O=p.forwardRef((function(e,t){var n=e.prefixCls,s=e.id,o=e.tabs,l=e.locale,c=e.mobile,h=e.more,d=void 0===h?{}:h,f=e.style,m=e.className,g=e.editable,_=e.tabBarGutter,y=e.rtl,v=e.removeAriaLabel,b=e.onTabClick,w=e.getPopupContainer,x=e.popupClassName,k=(0,p.useState)(!1),S=(0,a.Z)(k,2),E=S[0],T=S[1],C=(0,p.useState)(null),L=(0,a.Z)(C,2),M=L[0],O=L[1],F=d.icon,N=void 0===F?"More":F,B="".concat(s,"-more-popup"),$="".concat(n,"-dropdown"),K=null!==M?"".concat(B,"-").concat(M):null,U=null==l?void 0:l.dropdownAriaLabel;var z=p.createElement(I.ZP,{onClick:function(e){var t=e.key,n=e.domEvent;b(t,n),T(!1)},prefixCls:"".concat($,"-menu"),id:B,tabIndex:-1,role:"listbox","aria-activedescendant":K,selectedKeys:[M],"aria-label":void 0!==U?U:"expanded dropdown"},o.map((function(e){var t=e.closable,n=e.disabled,i=e.closeIcon,r=e.key,a=e.label,o=A(t,i,g,n);return p.createElement(I.sN,{key:r,id:"".concat(B,"-").concat(r),role:"option","aria-controls":s&&"".concat(s,"-panel-").concat(r),disabled:n},p.createElement("span",null,a),o&&p.createElement("button",{type:"button","aria-label":v||"remove",tabIndex:0,className:"".concat($,"-menu-item-remove"),onClick:function(e){e.stopPropagation(),function(e,t){e.preventDefault(),e.stopPropagation(),g.onEdit("remove",{key:t,event:e})}(e,r)}},i||g.removeIcon||"×"))})));function V(e){for(var t=o.filter((function(e){return!e.disabled})),n=t.findIndex((function(e){return e.key===M}))||0,i=t.length,r=0;r<i;r+=1){var s=t[n=(n+e+i)%i];if(!s.disabled)return void O(s.key)}}(0,p.useEffect)((function(){var e=document.getElementById(K);e&&e.scrollIntoView&&e.scrollIntoView(!1)}),[M]),(0,p.useEffect)((function(){E||O(null)}),[E]);var q=(0,r.Z)({},y?"marginRight":"marginLeft",_);o.length||(q.visibility="hidden",q.order=1);var G=u()((0,r.Z)({},"".concat($,"-rtl"),y)),H=c?null:p.createElement(R.Z,(0,i.Z)({prefixCls:$,overlay:z,visible:!!o.length&&E,onVisibleChange:T,overlayClassName:u()(G,x),mouseEnterDelay:.1,mouseLeaveDelay:.1,getPopupContainer:w},d),p.createElement("button",{type:"button",className:"".concat(n,"-nav-more"),style:q,"aria-haspopup":"listbox","aria-controls":B,id:"".concat(s,"-more"),"aria-expanded":E,onKeyDown:function(e){var t=e.which;if(E)switch(t){case P.Z.UP:V(-1),e.preventDefault();break;case P.Z.DOWN:V(1),e.preventDefault();break;case P.Z.ESC:T(!1);break;case P.Z.SPACE:case P.Z.ENTER:null!==M&&b(M,e)}else[P.Z.DOWN,P.Z.SPACE,P.Z.ENTER].includes(t)&&(T(!0),e.preventDefault())}},N));return p.createElement("div",{className:u()("".concat(n,"-nav-operations"),m),style:f,ref:t},H,p.createElement(D,{prefixCls:n,locale:l,editable:g}))})),F=p.memo(O,(function(e,t){return t.tabMoving})),N=function(e){var t=e.prefixCls,n=e.id,i=e.active,s=e.focus,a=e.tab,o=a.key,l=a.label,c=a.disabled,h=a.closeIcon,d=a.icon,f=e.closable,m=e.renderWrapper,g=e.removeAriaLabel,_=e.editable,y=e.onClick,v=e.onFocus,b=e.onBlur,w=e.onKeyDown,x=e.onMouseDown,k=e.onMouseUp,S=e.style,E=e.tabCount,T=e.currentPosition,C="".concat(t,"-tab"),D=A(f,h,_,c);function M(e){c||y(e)}var R=p.useMemo((function(){return d&&"string"==typeof l?p.createElement("span",null,l):l}),[l,d]),I=p.useRef(null);p.useEffect((function(){s&&I.current&&I.current.focus()}),[s]);var P=p.createElement("div",{key:o,"data-node-key":L(o),className:u()(C,(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(C,"-with-remove"),D),"".concat(C,"-active"),i),"".concat(C,"-disabled"),c),"".concat(C,"-focus"),s)),style:S,onClick:M},p.createElement("div",{ref:I,role:"tab","aria-selected":i,id:n&&"".concat(n,"-tab-").concat(o),className:"".concat(C,"-btn"),"aria-controls":n&&"".concat(n,"-panel-").concat(o),"aria-disabled":c,tabIndex:c?null:i?0:-1,onClick:function(e){e.stopPropagation(),M(e)},onKeyDown:w,onMouseDown:x,onMouseUp:k,onFocus:v,onBlur:b},s&&p.createElement("div",{"aria-live":"polite",style:{width:0,height:0,position:"absolute",overflow:"hidden",opacity:0}},"Tab ".concat(T," of ").concat(E)),d&&p.createElement("span",{className:"".concat(C,"-icon")},d),l&&R),D&&p.createElement("button",{type:"button",role:"tab","aria-label":g||"remove",tabIndex:i?0:-1,className:"".concat(C,"-remove"),onClick:function(e){var t;e.stopPropagation(),(t=e).preventDefault(),t.stopPropagation(),_.onEdit("remove",{key:o,event:t})}},h||_.removeIcon||"×"));return m?m(P):P},B=function(e){var t=e.current||{},n=t.offsetWidth,i=void 0===n?0:n,r=t.offsetHeight,s=void 0===r?0:r;if(e.current){var a=e.current.getBoundingClientRect(),o=a.width,l=a.height;if(Math.abs(o-i)<1)return[o,l]}return[i,s]},$=function(e,t){return e[t?0:1]},K=p.forwardRef((function(e,t){var n=e.className,o=e.style,l=e.id,c=e.animated,h=e.activeKey,d=e.rtl,v=e.extra,S=e.editable,R=e.locale,I=e.tabPosition,P=e.tabBarGutter,O=e.children,K=e.onTabClick,U=e.onTabScroll,z=e.indicator,V=p.useContext(f),q=V.prefixCls,G=V.tabs,H=(0,p.useRef)(null),j=(0,p.useRef)(null),W=(0,p.useRef)(null),Z=(0,p.useRef)(null),Y=(0,p.useRef)(null),X=(0,p.useRef)(null),J=(0,p.useRef)(null),Q="top"===I||"bottom"===I,ee=x(0,(function(e,t){Q&&U&&U({direction:e>t?"left":"right"})})),te=(0,a.Z)(ee,2),ne=te[0],ie=te[1],re=x(0,(function(e,t){!Q&&U&&U({direction:e>t?"top":"bottom"})})),se=(0,a.Z)(re,2),ae=se[0],oe=se[1],le=(0,p.useState)([0,0]),ce=(0,a.Z)(le,2),ue=ce[0],he=ce[1],de=(0,p.useState)([0,0]),pe=(0,a.Z)(de,2),fe=pe[0],me=pe[1],ge=(0,p.useState)([0,0]),_e=(0,a.Z)(ge,2),ye=_e[0],ve=_e[1],be=(0,p.useState)([0,0]),we=(0,a.Z)(be,2),xe=we[0],ke=we[1],Se=function(e){var t=(0,p.useRef)([]),n=(0,p.useState)({}),i=(0,a.Z)(n,2)[1],r=(0,p.useRef)("function"==typeof e?e():e),s=E((function(){var e=r.current;t.current.forEach((function(t){e=t(e)})),t.current=[],r.current=e,i({})}));return[r.current,function(e){t.current.push(e),s()}]}(new Map),Ee=(0,a.Z)(Se,2),Te=Ee[0],Ce=Ee[1],Le=function(e,t,n){return(0,p.useMemo)((function(){for(var n,i=new Map,r=t.get(null===(n=e[0])||void 0===n?void 0:n.key)||w,a=r.left+r.width,o=0;o<e.length;o+=1){var l,c=e[o].key,u=t.get(c);u||(u=t.get(null===(l=e[o-1])||void 0===l?void 0:l.key)||w);var h=i.get(c)||(0,s.Z)({},u);h.right=a-h.left-h.width,i.set(c,h)}return i}),[e.map((function(e){return e.key})).join("_"),t,n])}(G,Te,fe[0]),Ae=$(ue,Q),De=$(fe,Q),Me=$(ye,Q),Re=$(xe,Q),Ie=Math.floor(Ae)<Math.floor(De+Me),Pe=Ie?Ae-Re:Ae-Me,Oe="".concat(q,"-nav-operations-hidden"),Fe=0,Ne=0;function Be(e){return e<Fe?Fe:e>Ne?Ne:e}Q&&d?(Fe=0,Ne=Math.max(0,De-Pe)):(Fe=Math.min(0,Pe-De),Ne=0);var $e=(0,p.useRef)(null),Ke=(0,p.useState)(),Ue=(0,a.Z)(Ke,2),ze=Ue[0],Ve=Ue[1];function qe(){Ve(Date.now())}function Ge(){$e.current&&clearTimeout($e.current)}!function(e,t){var n=(0,p.useState)(),i=(0,a.Z)(n,2),r=i[0],s=i[1],o=(0,p.useState)(0),l=(0,a.Z)(o,2),c=l[0],u=l[1],h=(0,p.useState)(0),d=(0,a.Z)(h,2),f=d[0],m=d[1],g=(0,p.useState)(),_=(0,a.Z)(g,2),y=_[0],v=_[1],b=(0,p.useRef)(),w=(0,p.useRef)(),x=(0,p.useRef)(null);x.current={onTouchStart:function(e){var t=e.touches[0],n=t.screenX,i=t.screenY;s({x:n,y:i}),window.clearInterval(b.current)},onTouchMove:function(e){if(r){var n=e.touches[0],i=n.screenX,a=n.screenY;s({x:i,y:a});var o=i-r.x,l=a-r.y;t(o,l);var h=Date.now();u(h),m(h-c),v({x:o,y:l})}},onTouchEnd:function(){if(r&&(s(null),v(null),y)){var e=y.x/f,n=y.y/f,i=Math.abs(e),a=Math.abs(n);if(Math.max(i,a)<.1)return;var o=e,l=n;b.current=window.setInterval((function(){Math.abs(o)<.01&&Math.abs(l)<.01?window.clearInterval(b.current):t(20*(o*=k),20*(l*=k))}),20)}},onWheel:function(e){var n=e.deltaX,i=e.deltaY,r=0,s=Math.abs(n),a=Math.abs(i);s===a?r="x"===w.current?n:i:s>a?(r=n,w.current="x"):(r=i,w.current="y"),t(-r,-r)&&e.preventDefault()}},p.useEffect((function(){function t(e){x.current.onTouchMove(e)}function n(e){x.current.onTouchEnd(e)}return document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",n,{passive:!0}),e.current.addEventListener("touchstart",(function(e){x.current.onTouchStart(e)}),{passive:!0}),e.current.addEventListener("wheel",(function(e){x.current.onWheel(e)}),{passive:!1}),function(){document.removeEventListener("touchmove",t),document.removeEventListener("touchend",n)}}),[])}(Z,(function(e,t){function n(e,t){e((function(e){return Be(e+t)}))}return!!Ie&&(Q?n(ie,e):n(oe,t),Ge(),qe(),!0)})),(0,p.useEffect)((function(){return Ge(),ze&&($e.current=setTimeout((function(){Ve(0)}),100)),Ge}),[ze]);var He=function(e,t,n,i,r,s,a){var o,l,c,u=a.tabs,h=a.tabPosition,d=a.rtl;return["top","bottom"].includes(h)?(o="width",l=d?"right":"left",c=Math.abs(n)):(o="height",l="top",c=-n),(0,p.useMemo)((function(){if(!u.length)return[0,0];for(var n=u.length,i=n,r=0;r<n;r+=1){var s=e.get(u[r].key)||T;if(Math.floor(s[l]+s[o])>Math.floor(c+t)){i=r-1;break}}for(var a=0,h=n-1;h>=0;h-=1)if((e.get(u[h].key)||T)[l]<c){a=h+1;break}return a>=i?[0,0]:[a,i]}),[e,t,i,r,s,c,h,u.map((function(e){return e.key})).join("_"),d])}(Le,Pe,Q?ne:ae,De,Me,Re,(0,s.Z)((0,s.Z)({},e),{},{tabs:G})),je=(0,a.Z)(He,2),We=je[0],Ze=je[1],Ye=(0,_.Z)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h,t=Le.get(e)||{width:0,height:0,left:0,right:0,top:0};if(Q){var n=ne;d?t.right<ne?n=t.right:t.right+t.width>ne+Pe&&(n=t.right+t.width-Pe):t.left<-ne?n=-t.left:t.left+t.width>-ne+Pe&&(n=-(t.left+t.width-Pe)),oe(0),ie(Be(n))}else{var i=ae;t.top<-ae?i=-t.top:t.top+t.height>-ae+Pe&&(i=-(t.top+t.height-Pe)),ie(0),oe(Be(i))}})),Xe=(0,p.useState)(),Je=(0,a.Z)(Xe,2),Qe=Je[0],et=Je[1],tt=(0,p.useState)(!1),nt=(0,a.Z)(tt,2),it=nt[0],rt=nt[1],st=G.filter((function(e){return!e.disabled})).map((function(e){return e.key})),at=function(e){var t=st.indexOf(Qe||h),n=st.length,i=st[(t+e+n)%n];et(i)},ot=function(e){var t=e.code,n=d&&Q,i=st[0],r=st[st.length-1];switch(t){case"ArrowLeft":Q&&at(n?1:-1);break;case"ArrowRight":Q&&at(n?-1:1);break;case"ArrowUp":e.preventDefault(),Q||at(-1);break;case"ArrowDown":e.preventDefault(),Q||at(1);break;case"Home":e.preventDefault(),et(i);break;case"End":e.preventDefault(),et(r);break;case"Enter":case"Space":e.preventDefault(),K(h,e);break;case"Backspace":case"Delete":var s=st.indexOf(Qe),a=G.find((function(e){return e.key===Qe}));A(null==a?void 0:a.closable,null==a?void 0:a.closeIcon,S,null==a?void 0:a.disabled)&&(e.preventDefault(),e.stopPropagation(),S.onEdit("remove",{key:Qe,event:e}),s===st.length-1?at(-1):at(1))}},lt={};Q?lt[d?"marginRight":"marginLeft"]=P:lt.marginTop=P;var ct=G.map((function(e,t){var n=e.key;return p.createElement(N,{id:l,prefixCls:q,key:n,tab:e,style:0===t?void 0:lt,closable:e.closable,editable:S,active:n===h,focus:n===Qe,renderWrapper:O,removeAriaLabel:null==R?void 0:R.removeAriaLabel,tabCount:st.length,currentPosition:t+1,onClick:function(e){K(n,e)},onKeyDown:ot,onFocus:function(){it||et(n),Ye(n),qe(),Z.current&&(d||(Z.current.scrollLeft=0),Z.current.scrollTop=0)},onBlur:function(){et(void 0)},onMouseDown:function(){rt(!0)},onMouseUp:function(){rt(!1)}})})),ut=function(){return Ce((function(){var e,t=new Map,n=null===(e=Y.current)||void 0===e?void 0:e.getBoundingClientRect();return G.forEach((function(e){var i,r=e.key,s=null===(i=Y.current)||void 0===i?void 0:i.querySelector('[data-node-key="'.concat(L(r),'"]'));if(s){var o=function(e,t){var n=e.offsetWidth,i=e.offsetHeight,r=e.offsetTop,s=e.offsetLeft,a=e.getBoundingClientRect(),o=a.width,l=a.height,c=a.left,u=a.top;return Math.abs(o-n)<1?[o,l,c-t.left,u-t.top]:[n,i,s,r]}(s,n),l=(0,a.Z)(o,4),c=l[0],u=l[1],h=l[2],d=l[3];t.set(r,{width:c,height:u,left:h,top:d})}})),t}))};(0,p.useEffect)((function(){ut()}),[G.map((function(e){return e.key})).join("_")]);var ht=E((function(){var e=B(H),t=B(j),n=B(W);he([e[0]-t[0]-n[0],e[1]-t[1]-n[1]]);var i=B(J);ve(i);var r=B(X);ke(r);var s=B(Y);me([s[0]-i[0],s[1]-i[1]]),ut()})),dt=G.slice(0,We),pt=G.slice(Ze+1),ft=[].concat((0,m.Z)(dt),(0,m.Z)(pt)),mt=Le.get(h),gt=b({activeTabOffset:mt,horizontal:Q,indicator:z,rtl:d}).style;(0,p.useEffect)((function(){Ye()}),[h,Fe,Ne,C(mt),C(Le),Q]),(0,p.useEffect)((function(){ht()}),[d]);var _t,yt,vt,bt,wt=!!ft.length,xt="".concat(q,"-nav-wrap");return Q?d?(yt=ne>0,_t=ne!==Ne):(_t=ne<0,yt=ne!==Fe):(vt=ae<0,bt=ae!==Fe),p.createElement(g.Z,{onResize:ht},p.createElement("div",{ref:(0,y.x1)(t,H),role:"tablist","aria-orientation":Q?"horizontal":"vertical",className:u()("".concat(q,"-nav"),n),style:o,onKeyDown:function(){qe()}},p.createElement(M,{ref:j,position:"left",extra:v,prefixCls:q}),p.createElement(g.Z,{onResize:ht},p.createElement("div",{className:u()(xt,(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(xt,"-ping-left"),_t),"".concat(xt,"-ping-right"),yt),"".concat(xt,"-ping-top"),vt),"".concat(xt,"-ping-bottom"),bt)),ref:Z},p.createElement(g.Z,{onResize:ht},p.createElement("div",{ref:Y,className:"".concat(q,"-nav-list"),style:{transform:"translate(".concat(ne,"px, ").concat(ae,"px)"),transition:ze?"none":void 0}},ct,p.createElement(D,{ref:J,prefixCls:q,locale:R,editable:S,style:(0,s.Z)((0,s.Z)({},0===ct.length?void 0:lt),{},{visibility:wt?"hidden":null})}),p.createElement("div",{className:u()("".concat(q,"-ink-bar"),(0,r.Z)({},"".concat(q,"-ink-bar-animated"),c.inkBar)),style:gt}))))),p.createElement(F,(0,i.Z)({},e,{removeAriaLabel:null==R?void 0:R.removeAriaLabel,ref:X,prefixCls:q,tabs:ft,className:!wt&&Oe,tabMoving:!!ze})),p.createElement(M,{ref:W,position:"right",extra:v,prefixCls:q})))})),U=K;var z=p.forwardRef((function(e,t){var n=e.prefixCls,i=e.className,r=e.style,s=e.id,a=e.active,o=e.tabKey,l=e.children;return p.createElement("div",{id:s&&"".concat(s,"-panel-").concat(o),role:"tabpanel",tabIndex:a?0:-1,"aria-labelledby":s&&"".concat(s,"-tab-").concat(o),"aria-hidden":!a,style:r,className:u()(n,a&&"".concat(n,"-active"),i),ref:t},l)})),V=["renderTabBar"],q=["label","key"];var G=function(e){var t=e.renderTabBar,n=(0,l.Z)(e,V),r=p.useContext(f).tabs;return t?t((0,s.Z)((0,s.Z)({},n),{},{panes:r.map((function(e){var t=e.label,n=e.key,r=(0,l.Z)(e,q);return p.createElement(z,(0,i.Z)({tab:t,key:n,tabKey:n},r))}))}),U):p.createElement(U,n)},H=n(77900),j=["key","forceRender","style","className","destroyInactiveTabPane"],W=function(e){var t=e.id,n=e.activeKey,a=e.animated,o=e.tabPosition,c=e.destroyInactiveTabPane,h=p.useContext(f),d=h.prefixCls,m=h.tabs,g=a.tabPane,_="".concat(d,"-tabpane");return p.createElement("div",{className:u()("".concat(d,"-content-holder"))},p.createElement("div",{className:u()("".concat(d,"-content"),"".concat(d,"-content-").concat(o),(0,r.Z)({},"".concat(d,"-content-animated"),g))},m.map((function(e){var r=e.key,o=e.forceRender,h=e.style,d=e.className,f=e.destroyInactiveTabPane,m=(0,l.Z)(e,j),y=r===n;return p.createElement(H.default,(0,i.Z)({key:r,visible:y,forceRender:o,removeOnLeave:!(!c&&!f),leavedClassName:"".concat(_,"-hidden")},a.tabPaneMotion),(function(e,n){var a=e.style,o=e.className;return p.createElement(z,(0,i.Z)({},m,{prefixCls:_,id:t,tabKey:r,animated:g,active:y,style:(0,s.Z)((0,s.Z)({},h),a),className:u()(d,o),ref:n}))}))}))))};n(48736);var Z=["id","prefixCls","className","items","direction","activeKey","defaultActiveKey","editable","animated","tabPosition","tabBarGutter","tabBarStyle","tabBarExtraContent","locale","more","destroyInactiveTabPane","renderTabBar","onChange","onTabClick","onTabScroll","getPopupContainer","popupClassName","indicator"],Y=0,X=p.forwardRef((function(e,t){var n=e.id,c=e.prefixCls,m=void 0===c?"rc-tabs":c,g=e.className,_=e.items,y=e.direction,v=e.activeKey,b=e.defaultActiveKey,w=e.editable,x=e.animated,k=e.tabPosition,S=void 0===k?"top":k,E=e.tabBarGutter,T=e.tabBarStyle,C=e.tabBarExtraContent,L=e.locale,A=e.more,D=e.destroyInactiveTabPane,M=e.renderTabBar,R=e.onChange,I=e.onTabClick,P=e.onTabScroll,O=e.getPopupContainer,F=e.popupClassName,N=e.indicator,B=(0,l.Z)(e,Z),$=p.useMemo((function(){return(_||[]).filter((function(e){return e&&"object"===(0,o.Z)(e)&&"key"in e}))}),[_]),K="rtl"===y,U=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{inkBar:!0,tabPane:!1};return(e=!1===t?{inkBar:!1,tabPane:!1}:!0===t?{inkBar:!0,tabPane:!1}:(0,s.Z)({inkBar:!0},"object"===(0,o.Z)(t)?t:{})).tabPaneMotion&&void 0===e.tabPane&&(e.tabPane=!0),!e.tabPaneMotion&&e.tabPane&&(e.tabPane=!1),e}(x),z=(0,p.useState)(!1),V=(0,a.Z)(z,2),q=V[0],H=V[1];(0,p.useEffect)((function(){H((0,d.Z)())}),[]);var j=(0,h.Z)((function(){var e;return null===(e=$[0])||void 0===e?void 0:e.key}),{value:v,defaultValue:b}),X=(0,a.Z)(j,2),J=X[0],Q=X[1],ee=(0,p.useState)((function(){return $.findIndex((function(e){return e.key===J}))})),te=(0,a.Z)(ee,2),ne=te[0],ie=te[1];(0,p.useEffect)((function(){var e,t=$.findIndex((function(e){return e.key===J}));-1===t&&(t=Math.max(0,Math.min(ne,$.length-1)),Q(null===(e=$[t])||void 0===e?void 0:e.key));ie(t)}),[$.map((function(e){return e.key})).join("_"),J,ne]);var re=(0,h.Z)(null,{value:n}),se=(0,a.Z)(re,2),ae=se[0],oe=se[1];(0,p.useEffect)((function(){n||(oe("rc-tabs-".concat(Y)),Y+=1)}),[]);var le={id:ae,activeKey:J,animated:U,tabPosition:S,rtl:K,mobile:q},ce=(0,s.Z)((0,s.Z)({},le),{},{editable:w,locale:L,more:A,tabBarGutter:E,onTabClick:function(e,t){null==I||I(e,t);var n=e!==J;Q(e),n&&(null==R||R(e))},onTabScroll:P,extra:C,style:T,panes:null,getPopupContainer:O,popupClassName:F,indicator:N});return p.createElement(f.Provider,{value:{tabs:$,prefixCls:m}},p.createElement("div",(0,i.Z)({ref:t,id:n,className:u()(m,"".concat(m,"-").concat(S),(0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(m,"-mobile"),q),"".concat(m,"-editable"),w),"".concat(m,"-rtl"),K),g)},B),p.createElement(G,(0,i.Z)({},ce,{renderTabBar:M})),p.createElement(W,(0,i.Z)({destroyInactiveTabPane:D},le,{animated:U}))))}));var J=X},29125:function(e,t,n){"use strict";n.d(t,{G:function(){return a},Z:function(){return y}});var i=n(92310),r=n.n(i),s=n(59301);function a(e){var t=e.children,n=e.prefixCls,i=e.id,a=e.overlayInnerStyle,o=e.bodyClassName,l=e.className,c=e.style;return s.createElement("div",{className:r()("".concat(n,"-content"),l),style:c},s.createElement("div",{className:r()("".concat(n,"-inner"),o),id:i,role:"tooltip",style:a},"function"==typeof t?t():t))}var o=n(54476),l=n(33885),c=n(75931),u=n(65030),h={shiftX:64,adjustY:1},d={adjustX:1,shiftY:!0},p=[0,0],f={left:{points:["cr","cl"],overflow:d,offset:[-4,0],targetOffset:p},right:{points:["cl","cr"],overflow:d,offset:[4,0],targetOffset:p},top:{points:["bc","tc"],overflow:h,offset:[0,-4],targetOffset:p},bottom:{points:["tc","bc"],overflow:h,offset:[0,4],targetOffset:p},topLeft:{points:["bl","tl"],overflow:h,offset:[0,-4],targetOffset:p},leftTop:{points:["tr","tl"],overflow:d,offset:[-4,0],targetOffset:p},topRight:{points:["br","tr"],overflow:h,offset:[0,-4],targetOffset:p},rightTop:{points:["tl","tr"],overflow:d,offset:[4,0],targetOffset:p},bottomRight:{points:["tr","br"],overflow:h,offset:[0,4],targetOffset:p},rightBottom:{points:["bl","br"],overflow:d,offset:[4,0],targetOffset:p},bottomLeft:{points:["tl","bl"],overflow:h,offset:[0,4],targetOffset:p},leftBottom:{points:["br","bl"],overflow:d,offset:[-4,0],targetOffset:p}},m=n(80402),g=["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","motion","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle","arrowContent","overlay","id","showArrow","classNames","styles"],_=function(e,t){var n=e.overlayClassName,i=e.trigger,h=void 0===i?["hover"]:i,d=e.mouseEnterDelay,p=void 0===d?0:d,_=e.mouseLeaveDelay,y=void 0===_?.1:_,v=e.overlayStyle,b=e.prefixCls,w=void 0===b?"rc-tooltip":b,x=e.children,k=e.onVisibleChange,S=e.afterVisibleChange,E=e.transitionName,T=e.animation,C=e.motion,L=e.placement,A=void 0===L?"right":L,D=e.align,M=void 0===D?{}:D,R=e.destroyTooltipOnHide,I=void 0!==R&&R,P=e.defaultVisible,O=e.getTooltipContainer,F=e.overlayInnerStyle,N=(e.arrowContent,e.overlay),B=e.id,$=e.showArrow,K=void 0===$||$,U=e.classNames,z=e.styles,V=(0,c.Z)(e,g),q=(0,m.Z)(B),G=(0,s.useRef)(null);(0,s.useImperativeHandle)(t,(function(){return G.current}));var H=(0,l.Z)({},V);"visible"in e&&(H.popupVisible=e.visible);var j,W,Z;return s.createElement(u.Z,(0,o.Z)({popupClassName:r()(n,null==U?void 0:U.root),prefixCls:w,popup:function(){return s.createElement(a,{key:"content",prefixCls:w,id:q,bodyClassName:null==U?void 0:U.body,overlayInnerStyle:(0,l.Z)((0,l.Z)({},F),null==z?void 0:z.body)},N)},action:h,builtinPlacements:f,popupPlacement:A,ref:G,popupAlign:M,getPopupContainer:O,onPopupVisibleChange:k,afterPopupVisibleChange:S,popupTransitionName:E,popupAnimation:T,popupMotion:C,defaultPopupVisible:P,autoDestroy:I,mouseLeaveDelay:y,popupStyle:(0,l.Z)((0,l.Z)({},v),null==z?void 0:z.root),mouseEnterDelay:p,arrow:K},H),(j=s.Children.only(x),W=(null==j?void 0:j.props)||{},Z=(0,l.Z)((0,l.Z)({},W),{},{"aria-describedby":N?q:null}),s.cloneElement(x,Z)))},y=(0,s.forwardRef)(_)},49658:function(e,t){"use strict";t.Z=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return!1;var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(null==e?void 0:e.substr(0,4))}},83145:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CopyToClipboard=void 0;var i=s(n(59301)),r=s(n(25769));function s(e){return e&&e.__esModule?e:{default:e}}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function l(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},s=Object.keys(e);for(i=0;i<s.length;i++)n=s[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)n=s[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?p(e):t}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){return f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},f(e,t)}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var g=function(e){function t(){var e,n;c(this,t);for(var s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];return m(p(n=h(this,(e=d(t)).call.apply(e,[this].concat(a)))),"onClick",(function(e){var t=n.props,s=t.text,a=t.onCopy,o=t.children,l=t.options,c=i.default.Children.only(o),u=(0,r.default)(s,l);a&&a(s,u),c&&c.props&&"function"==typeof c.props.onClick&&c.props.onClick(e)})),n}var n,s,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(t,e),n=t,s=[{key:"render",value:function(){var e=this.props,t=(e.text,e.onCopy,e.options,e.children),n=l(e,["text","onCopy","options","children"]),r=i.default.Children.only(t);return i.default.cloneElement(r,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(n,!0).forEach((function(t){m(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},n,{onClick:this.onClick}))}}],s&&u(n.prototype,s),a&&u(n,a),t}(i.default.PureComponent);t.CopyToClipboard=g,m(g,"defaultProps",{onCopy:void 0,options:void 0})},56102:function(e,t,n){"use strict";var i=n(83145).CopyToClipboard;i.CopyToClipboard=i,e.exports=i},76374:function(e,t,n){"use strict";var i=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some((function(e,i){return e[0]===t&&(n=i,!0)})),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),i=this.__entries__[n];return i&&i[1]},t.prototype.set=function(t,n){var i=e(this.__entries__,t);~i?this.__entries__[i][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,i=e(n,t);~i&&n.splice(i,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,i=this.__entries__;n<i.length;n++){var r=i[n];e.call(t,r[1],r[0])}},t}()}(),r="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,s=void 0!==n.g&&n.g.Math===Math?n.g:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),a="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(s):function(e){return setTimeout((function(){return e(Date.now())}),1e3/60)};var o=["top","right","bottom","left","width","height","size","weight"],l="undefined"!=typeof MutationObserver,c=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(e,t){var n=!1,i=!1,r=0;function s(){n&&(n=!1,e()),i&&l()}function o(){a(s)}function l(){var e=Date.now();if(n){if(e-r<2)return;i=!0}else n=!0,i=!1,setTimeout(o,t);r=e}return l}(this.refresh.bind(this),20)}return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var e=this.observers_.filter((function(e){return e.gatherActive(),e.hasActive()}));return e.forEach((function(e){return e.broadcastActive()})),e.length>0},e.prototype.connect_=function(){r&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),l?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){r&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;o.some((function(e){return!!~n.indexOf(e)}))&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),u=function(e,t){for(var n=0,i=Object.keys(t);n<i.length;n++){var r=i[n];Object.defineProperty(e,r,{value:t[r],enumerable:!1,writable:!1,configurable:!0})}return e},h=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||s},d=y(0,0,0,0);function p(e){return parseFloat(e)||0}function f(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce((function(t,n){return t+p(e["border-"+n+"-width"])}),0)}function m(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return d;var i=h(e).getComputedStyle(e),r=function(e){for(var t={},n=0,i=["top","right","bottom","left"];n<i.length;n++){var r=i[n],s=e["padding-"+r];t[r]=p(s)}return t}(i),s=r.left+r.right,a=r.top+r.bottom,o=p(i.width),l=p(i.height);if("border-box"===i.boxSizing&&(Math.round(o+s)!==t&&(o-=f(i,"left","right")+s),Math.round(l+a)!==n&&(l-=f(i,"top","bottom")+a)),!function(e){return e===h(e).document.documentElement}(e)){var c=Math.round(o+s)-t,u=Math.round(l+a)-n;1!==Math.abs(c)&&(o-=c),1!==Math.abs(u)&&(l-=u)}return y(r.left,r.top,o,l)}var g="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof h(e).SVGGraphicsElement}:function(e){return e instanceof h(e).SVGElement&&"function"==typeof e.getBBox};function _(e){return r?g(e)?function(e){var t=e.getBBox();return y(0,0,t.width,t.height)}(e):m(e):d}function y(e,t,n,i){return{x:e,y:t,width:n,height:i}}var v=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=y(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=_(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),b=function(e,t){var n,i,r,s,a,o,l,c=(i=(n=t).x,r=n.y,s=n.width,a=n.height,o="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,l=Object.create(o.prototype),u(l,{x:i,y:r,width:s,height:a,top:r,right:i+s,bottom:a+r,left:i}),l);u(this,{target:e,contentRect:c})},w=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new i,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof h(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new v(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof h(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach((function(t){t.isActive()&&e.activeObservations_.push(t)}))},e.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map((function(e){return new b(e.target,e.broadcastRect())}));this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),x="undefined"!=typeof WeakMap?new WeakMap:new i,k=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=c.getInstance(),i=new w(t,n,this);x.set(this,i)};["observe","unobserve","disconnect"].forEach((function(e){k.prototype[e]=function(){var t;return(t=x.get(this))[e].apply(t,arguments)}}));var S=void 0!==s.ResizeObserver?s.ResizeObserver:k;t.Z=S},98040:function(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}}},80360:function(e,t,n){"use strict";n.d(t,{ZP:function(){return fl}});const i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},r=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=s},s=Number.MAX_SAFE_INTEGER||9007199254740991;let a=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),o=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),l=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var c="manifest",u="level",h="audioTrack",d="subtitleTrack",p="main",f="audio",m="subtitle";class g{constructor(e,t=0,n=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=n}sample(e,t){const n=Math.pow(this.alpha_,e);this.estimate_=t*(1-n)+n*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class _{constructor(e,t,n,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new g(e),this.fast_=new g(t),this.defaultTTFB_=i,this.ttfb_=new g(e)}update(e,t){const{slow_:n,fast_:i,ttfb_:r}=this;n.halfLife!==e&&(this.slow_=new g(e,n.getEstimate(),n.getTotalWeight())),i.halfLife!==t&&(this.fast_=new g(t,i.getEstimate(),i.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new g(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){const n=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/n;this.fast_.sample(n,i),this.slow_.sample(n,i)}sampleTTFB(e){const t=e/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(n,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},v.apply(null,arguments)}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){y(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class x{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const n=`[${e}]:`;this.trace=k,this.debug=t.debug.bind(null,n),this.log=t.log.bind(null,n),this.warn=t.warn.bind(null,n),this.info=t.info.bind(null,n),this.error=t.error.bind(null,n)}}const k=function(){},S={trace:k,debug:k,log:k,warn:k,info:k,error:k};function E(){return v({},S)}function T(e,t,n){return t[e]?t[e].bind(t):function(e,t){const n=self.console[e];return n?n.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):k}(e,n)}const C=E();const L=C;function A(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function D(e,t){const n=Object.keys(e),i=Object.keys(t),r=n.length,s=i.length;return!r||!s||r===s&&!n.some((e=>-1===i.indexOf(e)))}function M(e,t=!1){if("undefined"!=typeof TextDecoder){const n=new TextDecoder("utf-8").decode(e);if(t){const e=n.indexOf("\0");return-1!==e?n.substring(0,e):n}return n.replace(/\0/g,"")}const n=e.length;let i,r,s,a="",o=0;for(;o<n;){if(i=e[o++],0===i&&t)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=e[o++],a+=String.fromCharCode((31&i)<<6|63&r);break;case 14:r=e[o++],s=e[o++],a+=String.fromCharCode((15&i)<<12|(63&r)<<6|(63&s)<<0)}}return a}function R(e){let t="";for(let n=0;n<e.length;n++){let i=e[n].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function I(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function P(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O,F={exports:{}};var N,B,$,K,U,z=(O||(O=1,N=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,B=/^(?=([^\/?#]*))\1([^]*)$/,$=/(?:\/|^)\.(?=\/)/g,K=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,F.exports=U={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var i=U.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=U.normalizePath(i.path),U.buildURLFromParts(i)}var r=U.parseURL(t);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return n.alwaysNormalize?(r.path=U.normalizePath(r.path),U.buildURLFromParts(r)):t;var s=U.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=B.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(o.netLoc=s.netLoc,"/"!==r.path[0]))if(r.path){var l=s.path,c=l.substring(0,l.lastIndexOf("/")+1)+r.path;o.path=U.normalizePath(c)}else o.path=s.path,r.params||(o.params=s.params,r.query||(o.query=s.query));return null===o.path&&(o.path=n.alwaysNormalize?U.normalizePath(r.path):r.path),U.buildURLFromParts(o)},parseURL:function(e){var t=N.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace($,"");e.length!==(e=e.replace(K,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}),F.exports);class V{constructor(){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}}}var q="audio",G="video",H="audiovideo";class j{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const n=X(e,t);n&&(n.enumerable=!0,Object.defineProperty(e,t,n))}(this,"stats")}setByteRange(e,t){const n=e.split("@",2);let i;i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[q]:null,[G]:null,[H]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new V),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=z.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[q]=null,e[G]=null,e[H]=null}}function W(e){return"initSegment"!==e.sn}class Z extends j{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(i(e)&&i(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const n=this._decryptdata=t[e[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=i(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),n=e.length;if(n>1||1===n&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){i(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return W(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var n;const i=t[e];!i||null!=(n=this._decryptdata)&&n.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,n,i,r,s=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,n),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,r)):a[e]={startPTS:t,endPTS:n,startDTS:i,endDTS:r,partial:s}}}class Y extends j{constructor(e,t,n,i,r){super(n),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function X(e,t){const n=Object.getPrototypeOf(e);if(n){const e=Object.getOwnPropertyDescriptor(n,t);return e||X(n,t)}}const J=Math.pow(2,32)-1,Q=[].push,ee={video:1,audio:2,id3:3,text:4};function te(e){return String.fromCharCode.apply(null,e)}function ne(e,t){const n=e[t]<<8|e[t+1];return n<0?65536+n:n}function ie(e,t){const n=se(e,t);return n<0?4294967296+n:n}function re(e,t){let n=ie(e,t);return n*=Math.pow(2,32),n+=ie(e,t+4),n}function se(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function ae(e,t){const n=[];if(!t.length)return n;const i=e.byteLength;for(let r=0;r<i;){const s=ie(e,r),a=s>1?r+s:i;if(te(e.subarray(r+4,r+8))===t[0])if(1===t.length)n.push(e.subarray(r+8,a));else{const i=ae(e.subarray(r+8,a),t.slice(1));i.length&&Q.apply(n,i)}r=a}return n}function oe(e){const t=[],n=e[0];let i=8;const r=ie(e,i);i+=4;let s=0,a=0;0===n?(s=ie(e,i),a=ie(e,i+4),i+=8):(s=re(e,i),a=re(e,i+8),i+=16),i+=2;let o=e.length+a;const l=ne(e,i);i+=2;for(let n=0;n<l;n++){let n=i;const s=ie(e,n);n+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return L.warn("SIDX has hierarchical references (not supported)"),null;const l=ie(e,n);n+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/r,start:o,end:o+a-1}}),o+=a,n+=4,i=n}return{earliestPresentationTime:s,timescale:r,version:n,referencesCount:l,references:t}}function le(e){const t=[],n=ae(e,["moov","trak"]);for(let e=0;e<n.length;e++){const i=n[e],r=ae(i,["tkhd"])[0];if(r){let e=r[0];const n=ie(r,0===e?12:20),s=ae(i,["mdia","mdhd"])[0];if(s){e=s[0];const r=ie(s,0===e?12:20),a=ae(i,["mdia","hdlr"])[0];if(a){const e=te(a.subarray(8,12)),s={soun:q,vide:G}[e],o=ce(ae(i,["mdia","minf","stbl","stsd"])[0]);s?(t[n]={timescale:r,type:s,stsd:o},t[s]=w({timescale:r,id:n},o)):t[n]={timescale:r,type:e,stsd:o}}}}}return ae(e,["moov","mvex","trex"]).forEach((e=>{const n=ie(e,4),i=t[n];i&&(i.default={duration:ie(e,12),flags:ie(e,20)})})),t}function ce(e){const t=e.subarray(8),n=t.subarray(86),i=te(t.subarray(4,8));let r,s=i;const a="enca"===i||"encv"===i;if(a){const e=ae(t,[i])[0];ae(e.subarray("enca"===i?28:78),["sinf"]).forEach((e=>{const t=ae(e,["schm"])[0];if(t){const n=te(t.subarray(4,8));if("cbcs"===n||"cenc"===n){const t=ae(e,["frma"])[0];t&&(s=te(t))}}}))}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=ae(n,["avcC"])[0];e&&e.length>3&&(s+="."+de(e[1])+de(e[2])+de(e[3]),r=ue("avc1"===o?"dva1":"dvav",n));break}case"mp4a":{const e=ae(t,[i])[0],n=ae(e.subarray(28),["esds"])[0];if(n&&n.length>7){let e=4;if(3!==n[e++])break;e=he(n,e),e+=2;const t=n[e++];if(128&t&&(e+=2),64&t&&(e+=n[e++]),4!==n[e++])break;e=he(n,e);const i=n[e++];if(64!==i)break;if(s+="."+de(i),e+=12,5!==n[e++])break;e=he(n,e);const r=n[e++];let a=(248&r)>>3;31===a&&(a+=1+((7&r)<<3)+((224&n[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=ae(n,["hvcC"])[0];if(e&&e.length>12){const t=e[1],n=["","A","B","C"][t>>6],i=31&t,r=ie(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);s+="."+n+i,s+="."+function(e){let t=0;for(let n=0;n<32;n++)t|=(e>>n&1)<<31-n;return t>>>0}(r).toString(16).toUpperCase(),s+="."+a+o;let c="";for(let e=l.length;e--;){const t=l[e];if(t||c){c="."+t.toString(16).toUpperCase()+c}}s+=c}r=ue("hev1"==o?"dvhe":"dvh1",n);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=ue(s,n)||s;break;case"vp09":{const e=ae(n,["vpcC"])[0];if(e&&e.length>6){const t=e[4],n=e[5],i=e[6]>>4&15;s+="."+pe(t)+"."+pe(n)+"."+pe(i)}break}case"av01":{const e=ae(n,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,c=2===t&&o?l?12:10:o?10:8,u=(16&e[2])>>4,h=(8&e[2])>>3,d=(4&e[2])>>2,p=3&e[2],f=1,m=1,g=1,_=0;s+="."+t+"."+pe(i)+a+"."+pe(c)+"."+u+"."+h+d+p+"."+pe(f)+"."+pe(m)+"."+pe(g)+"."+_,r=ue("dav1",n)}break}}return{codec:s,encrypted:a,supplemental:r}}function ue(e,t){const n=ae(t,["dvvC"]),i=n.length?n[0]:ae(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return e+"."+pe(t)+"."+pe(n)}}function he(e,t){const n=t+5;for(;128&e[t++]&&t<n;);return t}function de(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function pe(e){return(e<10?"0":"")+e}function fe(e,t){ae(e,["moov","trak"]).forEach((e=>{const n=ae(e,["mdia","minf","stbl","stsd"])[0];if(!n)return;const i=n.subarray(8);let r=ae(i,["enca"]);const s=r.length>0;s||(r=ae(i,["encv"])),r.forEach((e=>{ae(s?e.subarray(28):e.subarray(78),["sinf"]).forEach((e=>{const n=me(e);n&&t(n,s)}))}))}))}function me(e){const t=ae(e,["schm"])[0];if(t){const n=te(t.subarray(4,8));if("cbcs"===n||"cenc"===n){const t=ae(e,["schi","tenc"])[0];if(t)return t}}}function ge(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function _e(e,t){const n=[],i=t.samples,r=t.timescale,s=t.id;let a=!1;return ae(i,["moof"]).map((o=>{const l=o.byteOffset-8;ae(o,["traf"]).map((o=>{const c=ae(o,["tfdt"]).map((e=>{const t=e[0];let n=ie(e,4);return 1===t&&(n*=Math.pow(2,32),n+=ie(e,8)),n/r}))[0];return void 0!==c&&(e=c),ae(o,["tfhd"]).map((c=>{const u=ie(c,4),h=16777215&ie(c,0);let d=0;const p=0!=(16&h);let f=0;const m=0!=(32&h);let g=8;u===s&&(0!=(1&h)&&(g+=8),0!=(2&h)&&(g+=4),0!=(8&h)&&(d=ie(c,g),g+=4),p&&(f=ie(c,g),g+=4),m&&(g+=4),"video"===t.type&&(a=ye(t.codec)),ae(o,["trun"]).map((s=>{const o=s[0],c=16777215&ie(s,0),u=0!=(1&c);let h=0;const p=0!=(4&c),m=0!=(256&c);let g=0;const _=0!=(512&c);let y=0;const v=0!=(1024&c),b=0!=(2048&c);let w=0;const x=ie(s,4);let k=8;u&&(h=ie(s,k),k+=4),p&&(k+=4);let S=h+l;for(let l=0;l<x;l++){if(m?(g=ie(s,k),k+=4):g=d,_?(y=ie(s,k),k+=4):y=f,v&&(k+=4),b&&(w=0===o?ie(s,k):se(s,k),k+=4),t.type===G){let t=0;for(;t<y;){const s=ie(i,S);if(S+=4,ve(a,i[S])){be(i.subarray(S,S+s),a?2:1,e+w/r,n)}S+=s,t+=s+4}}e+=g/r}})))}))}))})),n}function ye(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function ve(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function be(e,t,n,i){const r=we(e);let s=0;s+=t;let a=0,o=0,l=0;for(;s<r.length;){a=0;do{if(s>=r.length)break;l=r[s++],a+=l}while(255===l);o=0;do{if(s>=r.length)break;l=r[s++],o+=l}while(255===l);const e=r.length-s;let t=s;if(o<e)s+=o;else if(o>e){L.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===r[t++]){const e=ne(r,t);if(t+=2,49===e){const e=ie(r,t);if(t+=4,1195456820===e){const e=r[t++];if(3===e){const s=r[t++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let e=1;e<l;e++)c[e]=r[t++]}i.push({type:e,payloadType:a,pts:n,bytes:c})}}}}}else if(5===a&&o>16){const e=[];for(let n=0;n<16;n++){const i=r[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==n&&5!==n&&7!==n&&9!==n||e.push("-")}const s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=r[t++];i.push({payloadType:a,pts:n,uuid:e.join(""),userData:M(l),userDataBytes:l})}}}function we(e){const t=e.byteLength,n=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(n.push(i+2),i+=2):i++;if(0===n.length)return e;const r=t-n.length,s=new Uint8Array(r);let a=0;for(i=0;i<r;a++,i++)a===n[0]&&(a++,n.shift()),s[i]=e[a];return s}function xe(e,t,n){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,r,s;i=0,r=new Uint8Array,s=new Uint8Array;const a=new Uint8Array(4);return n.byteLength>0&&new DataView(a.buffer).setUint32(0,n.byteLength,!1),function(e,...t){const n=t.length;let i=8,r=n;for(;r--;)i+=t[r].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),r=0,i=8;r<n;r++)s.set(t[r],i),i+=t[r].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,r,a,n)}function ke(e){const t=e.getUint32(0),n=e.byteOffset,i=e.byteLength;if(i<t)return{offset:n,size:i};if(1886614376!==e.getUint32(4))return{offset:n,size:t};const r=e.getUint32(8)>>>24;if(0!==r&&1!==r)return{offset:n,size:t};const s=e.buffer,a=R(new Uint8Array(s,n+12,16));let o=null,l=null,c=0;if(0===r)c=28;else{const r=e.getUint32(28);if(!r||i<32+16*r)return{offset:n,size:t};o=[];for(let e=0;e<r;e++)o.push(new Uint8Array(s,n+32+16*e,16));c=32+16*r}if(!c)return{offset:n,size:t};const u=e.getUint32(c);return t-32<u?{offset:n,size:t}:(l=new Uint8Array(s,n+c+4,u),{version:r,systemId:a,kids:o,data:l,offset:n,size:t})}const Se=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Ee={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Te(e,t){const n=Ee[t];return!!n&&!!n[e.slice(0,4)]}function Ce(e,t,n=!0){return!e.split(",").some((e=>!Le(e,t,n)))}function Le(e,t,n=!0){var i;const r=A(n);return null!=(i=null==r?void 0:r.isTypeSupported(Ae(e,t)))&&i}function Ae(e,t){return`${t}/mp4;codecs=${e}`}function De(e){if(e){const t=e.substring(0,4);return Ee.video[t]}return 2}function Me(e){const t=Se();return e.split(",").reduce(((e,n)=>{const i=t&&ye(n)?9:Ee.video[n];return i?(2*i+e)/(e?3:2):(Ee.audio[n]+e)/(e?2:1)}),0)}const Re={};const Ie=/flac|opus|mp4a\.40\.34/i;function Pe(e,t=!0){return e.replace(Ie,(e=>function(e,t=!0){if(Re[e])return Re[e];const n={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let r=0;r<n.length;r++){var i;if(Le(n[r],"audio",t))return Re[e]=n[r],n[r];if("mp3"===n[r]&&null!=(i=A(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)))}function Oe(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(Fe(e,"audio")||Fe(e,"video")))return e;if(t){const n=t.split(",");if(n.length>1){if(e)for(let t=n.length;t--;)if(n[t].substring(0,4)===e.substring(0,4))return n[t];return n[0]}}return t||e}function Fe(e,t){return Te(e,t)&&Le(e,t)}function Ne(e){if(e.startsWith("av01.")){const t=e.split("."),n=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=n[e-4];return t.join(".")}return e}function Be(e){const t=A(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function $e(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Ke={supported:!1,smooth:!1,powerEfficient:!1},Ue={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ze(e,t){return{supported:!1,configurations:t,decodingInfoResults:[Ke],error:e}}function Ve(e,t,n,r,s,a){const o=e.videoCodec,l=e.audioCodec?e.audioGroups:null,c=null==a?void 0:a.audioCodec,u=null==a?void 0:a.channels,h=u?parseInt(u):c?1/0:2;let d=null;if(null!=l&&l.length)try{d=1===l.length&&l[0]?t.groups[l[0]].channels:l.reduce(((e,n)=>{if(n){const i=t.groups[n];if(!i)throw new Error(`Audio track group ${n} not found`);Object.keys(i.channels).forEach((t=>{e[t]=(e[t]||0)+i.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some((e=>ye(e)))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==n||e.bitrate>Math.max(s,8e6))||!!d&&i(h)&&Object.keys(d).some((e=>parseInt(e)>h))}function qe(e,t,n,i={}){const r=e.videoCodec;if(!r&&!e.audioCodec||!n)return Promise.resolve(Ue);const s=[],a=function(e){var t;const n=null==(t=e.videoCodec)?void 0:t.split(","),i=He(e),r=e.width||640,s=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return n?n.map((e=>{const t={contentType:Ae(Ne(e),"video"),width:r,height:s,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t})):[]}(e),o=a.length,l=function(e,t,n){var i;const r=null==(i=e.audioCodec)?void 0:i.split(","),s=He(e);if(r&&e.audioGroups)return e.audioGroups.reduce(((e,i)=>{var a;const o=i?null==(a=t.groups[i])?void 0:a.tracks:null;return o?o.reduce(((e,t)=>{if(t.groupId===i){const i=parseFloat(t.channels||"");r.forEach((t=>{const r={contentType:Ae(t,"audio"),bitrate:n?Ge(t,s):s};i&&(r.channels=""+i),e.push(r)}))}return e}),e):e}),[]);return[]}(e,t,o>0),c=l.length;for(let e=o||1*c||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),c){t.audio=l[e%c];const n=t.audio.bitrate;t.video&&n&&(t.video.bitrate-=n)}s.push(t)}if(r){const e=navigator.userAgent;if(r.split(",").some((e=>ye(e)))&&Se())return Promise.resolve(ze(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),s))}return Promise.all(s.map((e=>{const t=function(e){let t="";const{audio:n,video:i}=e;if(i){t+=`${$e(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(n){t+=`${i?"_":""}${$e(n.contentType)}_c${n.channels}`}return t}(e);return i[t]||(i[t]=n.decodingInfo(e))}))).then((e=>({supported:!e.some((e=>!e.supported)),configurations:s,decodingInfoResults:e}))).catch((e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e})))}function Ge(e,t){if(t<=1)return 1;let n=128e3;return"ec-3"===e?n=768e3:"ac-3"===e&&(n=64e4),Math.min(t/2,n)}function He(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const je=["NONE","TYPE-0","TYPE-1",null];const We=["SDR","PQ","HLG"];var Ze="",Ye="YES",Xe="v2";function Je(e){const{canSkipUntil:t,canSkipDateRanges:n,age:i}=e;return t&&i<t/2?n?Xe:Ye:Ze}class Qe{constructor(e,t,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=n}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class et{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((e=>!!e)).map((e=>e.substring(0,4))).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const n=null==(t=e.supplemental)?void 0:t.videoCodec;n&&n!==e.videoCodec&&(this.codecSet+=`,${n.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return tt(this._audioGroups,e)}hasSubtitleGroup(e){return tt(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function tt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function nt(e,t){let n=!1,i=[];if(e&&(n="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||We.slice(0);const e="SDR"!==i.join("")&&!t.videoCodec;n=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),n||(i=["SDR"])}return{preferHDR:n,allowedVideoRanges:i}}const it=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(n,i)=>{if(e&&(i=e(n,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function rt(e,t){L.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function st(e){return e.reduce(((e,t)=>{let n=e.groups[t.groupId];n||(n=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),n.tracks.push(t);const i=t.channels||"2";return n.channels[i]=(n.channels[i]||0)+1,n.hasDefault=n.hasDefault||t.default,n.hasAutoSelect=n.hasAutoSelect||t.autoselect,n.hasDefault&&(e.hasDefaultAudio=!0),n.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function at(e){if(!e)return e;const{lang:t,assocLang:n,characteristics:i,channels:r,audioCodec:s}=e;return{lang:t,assocLang:n,characteristics:i,channels:r,audioCodec:s}}function ot(e,t,n){if("attrs"in e){const n=t.indexOf(e);if(-1!==n)return n}for(let i=0;i<t.length;i++){if(lt(e,t[i],n))return i}return-1}function lt(e,t,n){const{groupId:i,name:r,lang:s,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===r||t.name===r)&&(void 0===s||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===s||t.assocLang===a)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const n=e.split(","),i=t.split(",");return n.length===i.length&&!n.some((e=>-1===i.indexOf(e)))}(e.characteristics||"",t.characteristics))&&(void 0===n||n(e,t))}function ct(e,t){const{audioCodec:n,channels:i}=e;return!(void 0!==n&&(t.audioCodec||"").substring(0,4)!==n.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function ut(e,t,n){for(let i=t;i>-1;i--)if(n(e[i]))return i;for(let i=t+1;i<e.length;i++)if(n(e[i]))return i;return-1}function ht(e,t){var n;return!!e&&e!==(null==(n=t.loadLevelObj)?void 0:n.uri)}const dt=function(e,t){let n=0,i=e.length-1,r=null,s=null;for(;n<=i;){r=(n+i)/2|0,s=e[r];const a=t(s);if(a>0)n=r+1;else{if(!(a<0))return s;i=r-1}}return null};function pt(e,t,n=0,i=0,r=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-n;i>0&&i<15e-7&&(n+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===n&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===ft(n,i,s)||function(e,t,n){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce(((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e)),n);return e.start<=i}return!1}(s,e,Math.min(r,i))))return s;const a=dt(t,ft.bind(null,n,i));return!a||a===e&&s?s:a}function ft(e=0,t=0,n){if(n.start<=e&&n.start+n.duration>e)return 0;const i=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-i<=e?1:n.start-i>e&&n.start?-1:0}function mt(e,t,n){const i=1e3*Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-i>e}function gt(e,t,n){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:r}=e;let s;return r&&(i=i.concat(r)),dt(i,(e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=n?1:e.start>n?-1:0))),s||null}return null}function _t(e){switch(e.details){case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_TIMEOUT:case o.LEVEL_LOAD_TIMEOUT:case o.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function yt(e){return e.details.startsWith("key")}function vt(e){return yt(e)&&!!e.frag&&!e.frag.decryptdata}function bt(e,t){const n=_t(t);return e.default[(n?"timeout":"error")+"Retry"]}function wt(e,t){const n="linear"===e.backoff?1:Math.pow(2,t);return Math.min(n*e.retryDelayMs,e.maxRetryDelayMs)}function xt(e){return w(w({},e),{errorRetry:null,timeoutRetry:null})}function kt(e,t,n,i){if(!e)return!1;const r=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return St(e)||!!e&&(e<400||e>499)}(r)||!!n);return e.shouldRetry?e.shouldRetry(e,t,n,i,s):s}function St(e){return 0===e&&!1===navigator.onLine}var Et=0,Tt=2,Ct=3,Lt=5,At=0,Dt=1,Mt=2,Rt=4;function It(e){const t={action:Et,flags:At};return e&&(t.resolved=!0),t}var Pt="NOT_LOADED",Ot="APPENDING",Ft="PARTIAL",Nt="OK";class Bt{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.BUFFER_APPENDED,this.onBufferAppended,this),e.on(l.FRAG_BUFFERED,this.onFragBuffered,this),e.on(l.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.BUFFER_APPENDED,this.onBufferAppended,this),e.off(l.FRAG_BUFFERED,this.onFragBuffered,this),e.off(l.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const n=this.activePartLists[t];if(n)for(let t=n.length;t--;){const i=n[t];if(!i)break;if(i.start<=e&&e<=i.end&&i.loaded)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,n){const{fragments:i}=this,r=Object.keys(i);for(let s=r.length;s--;){const a=i[r[s]];if((null==a?void 0:a.body.type)===t&&(!n||a.buffered)){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,n,i,r){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((i=>{const a=this.fragments[i];if(!a)return;if(s>=a.body.sn)return;if(!a.buffered&&(!a.loaded||r))return void(a.body.type===n&&this.removeFragment(a.body));const o=a.range[e];o&&(0!==o.time.length?o.time.some((e=>{const n=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return n&&this.removeFragment(a.body),n})):this.removeFragment(a.body))}))}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const n=e.frag,i=Kt(n),r=this.fragments[i];if(!r||r.buffered&&n.gap)return;const s=!n.relurl;if(Object.keys(t).forEach((i=>{const a=n.elementaryStreams[i];if(!a)return;const o=t[i],l=s||!0===a.partial;r.range[i]=this.getBufferedTimes(n,e.part,l,o)})),r.loaded=null,Object.keys(r.range).length){r.buffered=!0;(r.body.endList=n.endList||r.body.endList)&&(this.endListFragments[r.body.type]=r),$t(r)||this.removeParts(n.sn-1,n.type)}else this.removeFragment(r.body)}removeParts(e,t){const n=this.activePartLists[t];n&&(this.activePartLists[t]=Ut(n,(t=>t.fragment.sn>=e)))}fragBuffered(e,t){const n=Kt(e);let i=this.fragments[n];!i&&t&&(i=this.fragments[n]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,n,i){const r={time:[],partial:n},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,n=i.end(e)+this.bufferPadding;if(l>=t&&o<=n){r.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<n&&a>t){const t=Math.max(s,i.start(e)),n=Math.min(a,i.end(e));n>t&&(r.partial=!0,r.time.push({startPTS:t,endPTS:n}))}else if(a<=t)break}return r}getPartialFragment(e){let t,n,i,r=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&$t(c)&&(n=c.body.start-a,i=c.body.end+a,e>=n&&e<=i&&(t=Math.min(e-n,i-e),s<=t&&(r=c.body,s=t)))})),r}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||$t(t))}getState(e){const t=Kt(e),n=this.fragments[t];return n?n.buffered?$t(n)?Ft:Nt:Ot:Pt}isTimeBuffered(e,t,n){let i,r;for(let s=0;s<n.length;s++){if(i=n.start(s)-this.bufferPadding,r=n.end(s)+this.bufferPadding,e>=i&&t<=r)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const n=t.frag,i=t.part?null:t,r=Kt(n);this.fragments[r]={body:n,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:n,part:i,timeRanges:r,type:s}=t;if("initSegment"===n.sn)return;const a=n.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=r;const o=r[s];this.detectEvictedFragments(s,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Kt(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,n=Object.keys(t);if(!e)return n.length>0;for(let i=n.length;i--;){const r=t[n[i]];if((null==r?void 0:r.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,n,i,r){i&&!this.hasGaps||Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==n||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||r)&&this.removeFragment(o)}))}removeFragment(e){const t=Kt(e);e.clearElementaryStreamInfo();const n=this.activePartLists[e.type];if(n){const t=e.sn;this.activePartLists[e.type]=Ut(n,(e=>e.fragment.sn!==t))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach((e=>e.clearElementaryStreamInfo()))}}function $t(e){var t,n,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(n=e.range.audio)&&n.partial||null!=(i=e.range.audiovideo)&&i.partial)}function Kt(e){return`${e.type}_${e.level}_${e.sn}`}function Ut(e,t){return e.filter((e=>{const n=t(e);return n||e.clearElementaryStreamInfo(),n}))}var zt=0,Vt=1;class qt{constructor(e,t,n){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=n}decrypt(e,t){switch(this.aesMode){case zt:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Vt:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Gt{constructor(){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()}uint8ArrayToUint32Array_(e){const t=new DataView(e),n=new Uint32Array(4);for(let e=0;e<4;e++)n[e]=t.getUint32(4*e);return n}initTable(){const e=this.sBox,t=this.invSBox,n=this.subMix,i=n[0],r=n[1],s=n[2],a=n[3],o=this.invSubMix,l=o[0],c=o[1],u=o[2],h=o[3],d=new Uint32Array(256);let p=0,f=0,m=0;for(m=0;m<256;m++)d[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let n=f^f<<1^f<<2^f<<3^f<<4;n=n>>>8^255&n^99,e[p]=n,t[n]=p;const o=d[p],m=d[o],g=d[m];let _=257*d[n]^16843008*n;i[p]=_<<24|_>>>8,r[p]=_<<16|_>>>16,s[p]=_<<8|_>>>24,a[p]=_,_=16843009*g^65537*m^257*o^16843008*p,l[n]=_<<24|_>>>8,c[n]=_<<16|_>>>16,u[n]=_<<8|_>>>24,h[n]=_,p?(p=o^d[d[d[g^o]]],f^=d[d[f]]):p=f=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let n=!0,i=0;for(;i<t.length&&n;)n=t[i]===this.key[i],i++;if(n)return;this.key=t;const r=this.keySize=t.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const s=this.ksRows=4*(r+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),c=this.invKeySchedule=new Uint32Array(s),u=this.sBox,h=this.rcon,d=this.invSubMix,p=d[0],f=d[1],m=d[2],g=d[3];let _,y;for(a=0;a<s;a++)a<r?_=l[a]=t[a]:(y=_,a%r==0?(y=y<<8|y>>>24,y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[255&y],y^=h[a/r|0]<<24):r>6&&a%r==4&&(y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[255&y]),l[a]=_=(l[a-r]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:p[u[y>>>24]]^f[u[y>>>16&255]]^m[u[y>>>8&255]]^g[u[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,n){const i=this.keySize+6,r=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],u=a[3],h=this.uint8ArrayToUint32Array_(n);let d=h[0],p=h[1],f=h[2],m=h[3];const g=new Int32Array(e),_=new Int32Array(g.length);let y,v,b,w,x,k,S,E,T,C,L,A,D,M;const R=this.networkToHostOrderSwap;for(;t<g.length;){for(T=R(g[t]),C=R(g[t+1]),L=R(g[t+2]),A=R(g[t+3]),x=T^r[0],k=A^r[1],S=L^r[2],E=C^r[3],D=4,M=1;M<i;M++)y=o[x>>>24]^l[k>>16&255]^c[S>>8&255]^u[255&E]^r[D],v=o[k>>>24]^l[S>>16&255]^c[E>>8&255]^u[255&x]^r[D+1],b=o[S>>>24]^l[E>>16&255]^c[x>>8&255]^u[255&k]^r[D+2],w=o[E>>>24]^l[x>>16&255]^c[k>>8&255]^u[255&S]^r[D+3],x=y,k=v,S=b,E=w,D+=4;y=s[x>>>24]<<24^s[k>>16&255]<<16^s[S>>8&255]<<8^s[255&E]^r[D],v=s[k>>>24]<<24^s[S>>16&255]<<16^s[E>>8&255]<<8^s[255&x]^r[D+1],b=s[S>>>24]<<24^s[E>>16&255]<<16^s[x>>8&255]<<8^s[255&k]^r[D+2],w=s[E>>>24]<<24^s[x>>16&255]<<16^s[k>>8&255]<<8^s[255&S]^r[D+3],_[t]=R(y^d),_[t+1]=R(w^p),_[t+2]=R(b^f),_[t+3]=R(v^m),d=T,p=C,f=L,m=A,t+=4}return _.buffer}}class Ht{constructor(e,t,n){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=n}expandKey(){const e=function(e){switch(e){case zt:return"AES-CBC";case Vt:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class jt{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,n=t&&new DataView(e.buffer).getUint8(t-1);return n?e.slice(0,t-n):e}(n):n}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,n,i){return this.useSoftware?new Promise(((r,s)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,n,i);const o=this.flush();o?r(o.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,n,i)}softwareDecrypt(e,t,n,i){const{currentIV:r,currentResult:s,remainderData:a}=this;if(i!==zt||16!==t.byteLength)return L.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=ge(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;r&&(n=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Gt),l.expandKey(t);const c=s;return this.currentResult=l.decrypt(o.buffer,0,n),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,n,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,n,i));this.key=t,this.fastAesKey=new Ht(this.subtle,t,i)}return this.fastAesKey.expandKey().then((t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new qt(this.subtle,new Uint8Array(n),i).decrypt(e.buffer,t)})).catch((r=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,n,i))))}onWebCryptoError(e,t,n,i){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,n,i);const r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const n=e.length-e.length%16;return n!==e.length&&(t=e.slice(0,n),this.remainderData=e.slice(n)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Wt=Math.pow(2,17);class Zt{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const n=e.url;if(!n)return Promise.reject(new Jt({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,r=i.fLoader,s=i.loader;return new Promise(((l,c)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some((e=>"GAP"===e[0])))return void c(Xt(e));e.gap=!1}const u=this.loader=r?new r(i):new s(i),h=Yt(e);e.loader=u;const d=xt(i.fragLoadPolicy.default),p={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Wt};e.stats=u.stats;const f={onSuccess:(t,n,i,r)=>{this.resetLoader(e,u);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),l({frag:e,part:null,payload:s,networkDetails:r})},onError:(t,i,r,s)=>{this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:w({url:n,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:s}))},onAbort:(t,n,i)=>{this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,n,i)=>{this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:i,stats:t}))}};t&&(f.onProgress=(n,i,r,s)=>t({frag:e,part:null,payload:r,networkDetails:s})),u.load(h,p,f)}))}loadPart(e,t,n){this.abort();const i=this.config,r=i.fLoader,s=i.loader;return new Promise(((l,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void c(Xt(e,t));const u=this.loader=r?new r(i):new s(i),h=Yt(e,t);e.loader=u;const d=xt(i.fragLoadPolicy.default),p={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Wt};t.stats=u.stats,u.load(h,p,{onSuccess:(i,r,s,a)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);const o={frag:e,part:t,payload:i.data,networkDetails:a};n(o),l(o)},onError:(n,i,r,s)=>{this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:w({url:h.url,data:void 0},n),error:new Error(`HTTP Error ${n.code} ${n.text}`),networkDetails:r,stats:s}))},onAbort:(n,i,r)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:r,stats:n}))},onTimeout:(n,i,r)=>{this.resetLoader(e,u),c(new Jt({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:r,stats:n}))}})}))}updateStatsFromPart(e,t){const n=e.stats,i=t.stats,r=i.total;if(n.loaded+=i.loaded,r){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(n.loaded/r),i),a=(i-s)*Math.round(n.loaded/s);n.total=n.loaded+a}else n.total=Math.max(n.loaded,n.total);const s=n.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Yt(e,t=null){const n=t||e,r={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,a=n.byteRangeEndOffset;if(i(s)&&i(a)){var o;let t=s,n=a;if("initSegment"===e.sn&&("AES-128"===(l=null==(o=e.decryptdata)?void 0:o.method)||"AES-256"===l)){const e=a-s;e%16&&(n=a+(16-e%16)),0!==s&&(r.resetIV=!0,t=s-16)}r.rangeStart=t,r.rangeEnd=n}var l;return r}function Xt(e,t){const n=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:a.MEDIA_ERROR,details:o.FRAG_GAP,fatal:!1,frag:e,error:n,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Jt(i)}class Jt extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Qt extends x{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class en{constructor(e,t,n,i=0,r=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=n,this.size=i,this.part=r,this.partial=s}}const tn={length:0,start:()=>0,end:()=>0};class nn{static isBuffered(e,t){if(e){const n=nn.getBuffered(e);for(let e=n.length;e--;)if(t>=n.start(e)&&t<=n.end(e))return!0}return!1}static bufferedRanges(e){if(e){const t=nn.getBuffered(e);return nn.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}static bufferInfo(e,t,n){if(e){const i=nn.bufferedRanges(e);if(i.length)return nn.bufferedInfo(i,t,n)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,n){t=Math.max(0,t),e.length>1&&e.sort(((e,t)=>e.start-t.start||t.end-e.end));let i=-1,r=[];if(n)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(i=s);const a=r.length;if(a){const t=r[a-1].end;e[s].start-t<n?e[s].end>t&&(r[a-1].end=e[s].end):r.push(e[s])}else r.push(e[s])}else r=e;let s,a=0,o=t,l=t;for(let e=0;e<r.length;e++){const c=r[e].start,u=r[e].end;if(-1===i&&t>=c&&t<=u&&(i=e),t+n>=c&&t<u)o=c,l=u,a=l-t;else if(t+n<c){s=c;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||tn}catch(e){return L.log("failed to get media.buffered",e),tn}}}const rn=/\{\$([a-zA-Z0-9-_]+)\}/g;function sn(e){return rn.test(e)}function an(e,t){if(null!==e.variableList||e.hasVariableRefs){const n=e.variableList;return t.replace(rn,(t=>{const i=t.substring(2,t.length-1),r=null==n?void 0:n[i];return void 0===r?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):r}))}return t}function on(e,t,n){let i,r,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(n).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${n}"`);r=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,r=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=r||""}function ln(e,t,n){const i=t.IMPORT;if(n&&i in n){let t=e.variableList;t||(e.variableList=t={}),t[i]=n[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const cn=/^(\d+)x(\d+)$/,un=/(.+?)=(".*?"|.*?)(?:,|$)/g;class hn{constructor(e,t){"string"==typeof e&&(e=hn.parseAttrList(e,t)),v(this,e)}get clientAttrs(){return Object.keys(this).filter((e=>"X-"===e.substring(0,2)))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const n=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)n[e]=parseInt(t.slice(2*e,2*e+2),16);return n}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const n=this[e];return n?parseFloat(n):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const n=this[e];return(n?n.split(/[ ,]+/):[]).reduce(((e,t)=>(e[t.toLowerCase()]=!0,e)),t)}bool(e){return"YES"===this[e]}decimalResolution(e){const t=cn.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let n;const i={};for(un.lastIndex=0;null!==(n=un.exec(e));){const r=n[1].trim();let s=n[2];const a=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1;let o=!1;if(a)s=s.slice(1,-1);else switch(r){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))s=an(t,s);else if(!o&&!a)switch(r){case"CLOSED-CAPTIONS":if("NONE"===s)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":L.warn(`${e}: attribute ${r} is missing quotes`)}i[r]=s}return i}}function dn(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class pn{constructor(e,t,n=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(r=null==t?void 0:t.tagOrder)?r:n,t){const n=t.attr;for(const t in n)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t]){L.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=v(new hn({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);i(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return null===e||null===e.programDateTime?(L.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(i(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&i(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class fn{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,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.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,n=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!n||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some((t=>{let n=t.decryptdata;return n||(t.setKeyFormat(e.keyFormat),n=t.decryptdata),!!n&&e.matches(n)}))}get hasProgramDateTime(){return!!this.fragments.length&&i(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(-1!==t){for(let n=e.length;n--;)if(e[n].index>t)return e[n].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function mn(e,t){return e.length===t.length&&!e.some(((e,n)=>e!==t[n]))}function gn(e,t){return!e&&!t||!(!e||!t)&&mn(e,t)}function _n(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function yn(e){switch(e){case"AES-128":case"AES-256":return zt;case"AES-256-CTR":return Vt;default:throw new Error(`invalid full segment method ${e}`)}}function vn(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}function bn(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(e=>e.charCodeAt(0)))}function wn(e){const t=function(e,t,n){const i=e[t];e[t]=e[n],e[n]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function xn(e){const t=e.split(":");let n=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],r=i[1];t?(e.splice(-1,1),n=vn(r)):n=function(e){const t=bn(e).subarray(0,16),n=new Uint8Array(16);return n.set(t,16-t.length),n}(r)}}return n}const kn="undefined"!=typeof self?self:void 0;var Sn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},En="org.w3.clearkey",Tn="com.apple.streamingkeydelivery",Cn="com.microsoft.playready",Ln="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function An(e){switch(e){case Tn:return Sn.FAIRPLAY;case Cn:return Sn.PLAYREADY;case Ln:return Sn.WIDEVINE;case En:return Sn.CLEARKEY}}function Dn(e){switch(e){case Sn.FAIRPLAY:return Tn;case Sn.PLAYREADY:return Cn;case Sn.WIDEVINE:return Ln;case Sn.CLEARKEY:return En}}function Mn(e){const{drmSystems:t,widevineLicenseUrl:n}=e,i=t?[Sn.FAIRPLAY,Sn.WIDEVINE,Sn.PLAYREADY,Sn.CLEARKEY].filter((e=>!!t[e])):[];return!i[Sn.WIDEVINE]&&n&&i.push(Sn.WIDEVINE),i}const Rn=null!=kn&&null!=(In=kn.navigator)&&In.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var In;function Pn(e){const t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(t)),i=n.substring(n.indexOf("<"),n.length),r=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(r){const e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){const t=vn(e).subarray(0,16);return wn(t),t}}return null}let On={};class Fn{static clearKeyUriToKeyIdMap(){On={}}static setKeyIdForUri(e,t){On[e]=t}constructor(e,t,n,i=[1],r=null,s){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=n,this.keyFormatVersions=i,this.iv=r,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!_n(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(I(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&mn(e.keyFormatVersions,this.keyFormatVersions)&&gn(e.iv,this.iv)&&gn(e.keyId,this.keyId)}isSupported(){if(this.method){if(_n(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Tn:case Ln:case Cn:case En:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(_n(this.method)){let t=this.iv;t||("number"!=typeof e&&(L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){const t=new Uint8Array(16);for(let n=12;n<16;n++)t[n]=e>>8*(15-n)&255;return t}(e));return new Fn(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=On[this.uri];if(e&&!mn(this.keyId,e)&&Fn.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const n=xn(this.uri);if(n)switch(this.keyFormat){case Ln:if(this.pssh=n,!this.keyId){const e=function(e){const t=[];if(e instanceof ArrayBuffer){const n=e.byteLength;let i=0;for(;i+32<n;){const n=ke(new DataView(e,i));t.push(n),i+=n.size}}return t}(n.buffer);if(e.length){var i;const t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=Nn(t));break;case Cn:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=xe(e,0,n),this.keyId=Pn(n);break}default:{let e=n.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e;e=function(e){const t=null==e?void 0:e[Ln];if(t)return t.keyId;return null}(t),e||(e=Nn(t),e||(e=On[this.uri])),e&&(this.keyId=e,Fn.setKeyIdForUri(this.uri,e))}return this}}function Nn(e){const t=null==e?void 0:e[Cn];if(t){const e=xn(t.uri);if(e)return Pn(e)}return null}const Bn=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,$n=/#EXT-X-MEDIA:(.*)/g,Kn=/^#EXT(?:INF|-X-TARGETDURATION):/m,Un=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),zn=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Vn{static findGroup(e,t){for(let n=0;n<e.length;n++){const i=e[n];if(i.id===t)return i}}static resolve(e,t){return z.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Kn.test(e)}static parseMasterPlaylist(e,t){const n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:sn(e)},i=[];if(Bn.lastIndex=0,!e.startsWith("#EXTM3U"))return n.playlistParsingError=new Error("no EXTM3U delimiter"),n;let r;for(;null!=(r=Bn.exec(e));)if(r[1]){var s;const e=new hn(r[1],n),a=an(n,r[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Vn.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),Wn(e.CODECS,o);const c=e["SUPPLEMENTAL-CODECS"];c&&(o.supplemental={},Wn(c,o.supplemental)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),n.levels.push(o)}else if(r[3]){const e=r[3],i=r[4];switch(e){case"SESSION-DATA":{const e=new hn(i,n),t=e["DATA-ID"];t&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[t]=e);break}case"SESSION-KEY":{const e=Hn(i,t,n);e.encrypted&&e.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(e)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":on(n,new hn(i,n),t);break;case"CONTENT-STEERING":{const e=new hn(i,n);n.contentSteering={uri:Vn.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":n.startTimeOffset=jn(i)}}const a=i.length>0&&i.length<n.levels.length;return n.levels=a?i:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,n){let i;const r={},s=n.levels,a={AUDIO:s.map((e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec}))),SUBTITLES:s.map((e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for($n.lastIndex=0;null!==(i=$n.exec(e));){const e=new hn(i[1],n),s=e.TYPE;if(s){const n=a[s],i=r[s]||[];r[s]=i;const l=e.LANGUAGE,c=e["ASSOC-LANGUAGE"],u=e.CHANNELS,h=e.CHARACTERISTICS,d=e["INSTREAM-ID"],p={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?Vn.resolve(e.URI,t):""};if(c&&(p.assocLang=c),u&&(p.channels=u),h&&(p.characteristics=h),d&&(p.instreamId=d),null!=n&&n.length){const e=Vn.findGroup(n,p.groupId)||n[0];Zn(p,e,"audioCodec"),Zn(p,e,"textCodec")}i.push(p)}}return r}static parseLevelPlaylist(e,t,n,r,s,a){var o;const l={url:t},c=new fn(t),u=c.fragments,h=[];let d,p,f,m,g=null,_=0,y=0,b=0,w=0,x=0,k=null,S=new Z(r,l),E=-1,T=!1,C=null;if(Un.lastIndex=0,c.m3u8=e,c.hasVariableRefs=sn(e),"#EXTM3U"!==(null==(o=Un.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(d=Un.exec(e));){T&&(T=!1,S=new Z(r,l),S.playlistOffset=b,S.setStart(b),S.sn=_,S.cc=w,x&&(S.bitrate=x),S.level=n,g&&(S.initSegment=g,g.rawProgramDateTime&&(S.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),C&&(S.setByteRange(C),C=null)));const e=d[1];if(e){S.duration=parseFloat(e);const t=(" "+d[2]).slice(1);S.title=t||null,S.tagList.push(t?["INF",e,t]:["INF",e])}else if(d[3]){if(i(S.duration)){S.playlistOffset=b,S.setStart(b),f&&Jn(S,f,c),S.sn=_,S.level=n,S.cc=w,u.push(S);const e=(" "+d[3]).slice(1);S.relurl=an(c,e),Yn(S,k,h),k=S,b+=S.duration,_++,y=0,T=!0}}else{if(d=d[0].match(zn),!d){L.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<d.length&&void 0===d[p];p++);const e=(" "+d[p]).slice(1),s=(" "+d[p+1]).slice(1),o=d[p+2]?(" "+d[p+2]).slice(1):null;switch(e){case"BYTERANGE":k?S.setByteRange(s,k):S.setByteRange(s);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=s,S.tagList.push(["PROGRAM-DATE-TIME",s]),-1===E&&(E=u.length);break;case"PLAYLIST-TYPE":c.type&&Qn(c,e,d),c.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?Qn(c,e,d):u.length>0&&ei(c,e,d),_=c.startSN=parseInt(s);break;case"SKIP":{c.skippedSegments&&Qn(c,e,d);const t=new hn(s,c),n=t.decimalInteger("SKIPPED-SEGMENTS");if(i(n)){c.skippedSegments+=n;for(let e=n;e--;)u.push(null);_+=n}const r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(r.split("\t")));break}case"TARGETDURATION":0!==c.targetduration&&Qn(c,e,d),c.targetduration=Math.max(parseInt(s),1);break;case"VERSION":null!==c.version&&Qn(c,e,d),c.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||Qn(c,e,d),c.live=!1;break;case"#":(s||o)&&S.tagList.push(o?[s,o]:[s]);break;case"DISCONTINUITY":w++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([e]);break;case"BITRATE":S.tagList.push([e,s]),x=1e3*parseInt(s),i(x)?S.bitrate=x:x=0;break;case"DATERANGE":{const e=new hn(s,c),t=new pn(e,c.dateRanges[e.ID],c.dateRangeTagCount);c.dateRangeTagCount++,t.isValid||c.skippedSegments?c.dateRanges[t.id]=t:L.warn(`Ignoring invalid DATERANGE tag: "${s}"`),S.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const e=new hn(s,c);"IMPORT"in e?ln(c,e,a):on(c,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?Qn(c,e,d):u.length>0&&ei(c,e,d),c.startCC=w=parseInt(s);break;case"KEY":{const e=Hn(s,t,c);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={});const t=f[e.keyFormat];null!=t&&t.matches(e)||(t&&(f=v({},f)),f[e.keyFormat]=e)}else L.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${s}"`);break}case"START":c.startTimeOffset=jn(s);break;case"MAP":{const e=new hn(s,c);if(S.duration){const t=new Z(r,l);Xn(t,e,n,f),g=t,S.initSegment=g,g.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=g.rawProgramDateTime)}else{const t=S.byteRangeEndOffset;if(t){const e=S.byteRangeStartOffset;C=`${t-e}@${e}`}else C=null;Xn(S,e,n,f),g=S,T=!0}g.cc=w;break}case"SERVER-CONTROL":m&&Qn(c,e,d),m=new hn(s),c.canBlockReload=m.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=m.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&m.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=m.optionalFloat("PART-HOLD-BACK",0),c.holdBack=m.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{c.partTarget&&Qn(c,e,d);const t=new hn(s);c.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=c.partList;e||(e=c.partList=[]);const t=y>0?e[e.length-1]:void 0,n=y++,i=new hn(s,c),r=new Y(i,S,l,n,t);e.push(r),S.duration+=r.duration;break}case"PRELOAD-HINT":{const e=new hn(s,c);c.preloadHint=e;break}case"RENDITION-REPORT":{const e=new hn(s,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(e);break}default:L.warn(`line parsed but not handled: ${d}`)}}}k&&!k.relurl?(u.pop(),b-=k.duration,c.partList&&(c.fragmentHint=k)):c.partList&&(Yn(S,k,h),S.cc=w,c.fragmentHint=S,f&&Jn(S,f,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));const A=u.length,D=u[0],M=u[A-1];if(b+=c.skippedSegments*c.targetduration,b>0&&A&&M){c.averagetargetduration=b/A;const e=M.sn;c.endSN="initSegment"!==e?e:0,c.live||(M.endList=!0),E>0&&(!function(e,t){let n=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=n.programDateTime-1e3*t.duration,n=t}}(u,E),D&&h.unshift(D))}return c.fragmentHint&&(b+=c.fragmentHint.duration),c.totalduration=b,h.length&&c.dateRangeTagCount&&D&&qn(h,c),c.endCC=w,c}}function qn(e,t){let n=e.length;if(!n){if(!t.hasProgramDateTime)return;{const i=t.fragments[t.fragments.length-1];e.push(i),n++}}const i=e[n-1],r=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let o=s.length;o--;){const l=t.dateRanges[s[o]],c=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=n;i--;){var a;if((null==(a=e[i])?void 0:a.sn)<t.startSN)break;const n=Gn(t,c,e,i,r);if(-1!==n){l.tagAnchor=t.fragments[n].ref;break}}}}function Gn(e,t,n,i,r){const s=n[i];if(s){const o=s.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=n[i+1])?void 0:a.start)||r)-s.start)){const r=n[i].sn-e.startSN;if(r<0)return-1;const s=e.fragments;if(s.length>n.length){for(let a=(n[i+1]||s[s.length-1]).sn-e.startSN;a>r;a--){const e=s[a].programDateTime;if(t>=e&&t<e+1e3*s[a].duration)return a}}return r}}}return-1}function Hn(e,t,n){var i,r;const s=new hn(e,n),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,u=null!=(r=s.KEYFORMAT)?r:"identity";o&&s.IV&&!l&&L.error(`Invalid IV: ${s.IV}`);const h=o?Vn.resolve(o,t):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Fn(a,h,u,d,l,s.KEYID)}function jn(e){const t=new hn(e).decimalFloatingPoint("TIME-OFFSET");return i(t)?t:null}function Wn(e,t){let n=(e||"").split(/[ ,]+/).filter((e=>e));["video","audio","text"].forEach((e=>{const i=n.filter((t=>Te(t,e)));i.length&&(t[`${e}Codec`]=i.map((e=>e.split("/")[0])).join(","),n=n.filter((e=>-1===i.indexOf(e))))})),t.unknownCodecs=n}function Zn(e,t,n){const i=t[n];i&&(e[n]=i)}function Yn(e,t,n){e.rawProgramDateTime?n.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Xn(e,t,n,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=n,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Jn(e,t,n){e.levelkeys=t;const{encryptedFragments:i}=n;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((e=>t[e].isCommonEncryption))||i.push(e)}function Qn(e,t,n){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${n[0]})`)}function ei(e,t,n){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${n[0]})`)}function ti(e,t){const n=t.startPTS;if(i(n)){let i,r=0;t.sn>e.sn?(r=n-e.start,i=e):(r=e.start-n,i=t),i.duration!==r&&i.setDuration(r)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function ni(e,t,n,r,s,a,o){r-n<=0&&(o.warn("Fragment should have a positive duration",t),r=n+t.duration,a=s+t.duration);let l=n,c=r;const u=t.startPTS,h=t.endPTS;if(i(u)){const d=Math.abs(u-n);e&&d>e.totalduration?o.warn(`media timestamps and playlist times differ by ${d}s for level ${t.level} ${e.url}`):i(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,l=Math.max(n,u),n=Math.min(n,u),s=void 0!==t.startDTS?Math.min(s,t.startDTS):s,c=Math.min(r,h),r=Math.max(r,h),a=void 0!==t.endDTS?Math.max(a,t.endDTS):a}const d=n-t.start;0!==t.start&&t.setStart(n),t.setDuration(r-t.start),t.startPTS=n,t.maxStartPTS=l,t.startDTS=s,t.endPTS=r,t.minEndPTS=c,t.endDTS=a;const p=t.sn;if(!e||p<e.startSN||p>e.endSN)return 0;let f;const m=p-e.startSN,g=e.fragments;for(g[m]=t,f=m;f>0;f--)ti(g[f],g[f-1]);for(f=m;f<g.length-1;f++)ti(g[f],g[f+1]);return e.fragmentHint&&ti(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,d}function ii(e,t,n){if(e===t)return;let r=null;const s=e.fragments;for(let e=s.length-1;e>=0;e--){const t=s[e].initSegment;if(t){r=t;break}}let a;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,n){const i=t.skippedSegments,r=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let c=r;c<=s;c++){const r=l[a+c];let s=o[c];if(i&&!s&&r&&(s=t.fragments[c]=r),r&&s){n(r,s,c,o);const i=r.relurl,a=s.relurl;if(i&&di(i,a))return void(t.playlistParsingError=ri(`media sequence mismatch ${s.sn}:`,e,t,r,s));if(r.cc!==s.cc)return void(t.playlistParsingError=ri(`discontinuity sequence mismatch (${r.cc}!=${s.cc})`,e,t,r,s))}}}(e,t,((e,n,s,o)=>{if((!t.startCC||t.skippedSegments)&&n.cc!==e.cc){const i=e.cc-n.cc;for(let e=s;e<o.length;e++)o[e].cc+=i;t.endCC=o[o.length-1].cc}i(e.startPTS)&&i(e.endPTS)&&(n.setStart(n.startPTS=e.startPTS),n.startDTS=e.startDTS,n.maxStartPTS=e.maxStartPTS,n.endPTS=e.endPTS,n.endDTS=e.endDTS,n.minEndPTS=e.minEndPTS,n.setDuration(e.endPTS-e.startPTS),n.duration&&(a=n),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(n.elementaryStreams=e.elementaryStreams),n.loader=e.loader,e.hasStats&&(n.stats=e.stats),e.initSegment&&(n.initSegment=e.initSegment,r=e.initSegment)}));const o=t.fragments,l=t.fragmentHint?o.concat(t.fragmentHint):o;if(r&&l.forEach((e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments){if(t.deltaUpdateFailed=o.some((e=>!e)),t.deltaUpdateFailed){n.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)o.shift();t.startSN=o[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,n){const{dateRanges:i,recentlyRemovedDateranges:r}=t,s=v({},e);r&&r.forEach((e=>{delete s[e]}));const a=Object.keys(s).length;if(!a)return i;return Object.keys(i).forEach((e=>{const t=s[e],r=new pn(i[e].attr,t);r.isValid?(s[e]=r,t||(r.tagOrder+=a)):n.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${it(i[e].attr)}"`)})),s}(e.dateRanges,t,n));const i=e.fragments.filter((e=>e.rawProgramDateTime));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<l.length;e++)null===l[e].programDateTime&&Yn(l[e],l[e-1],i);qn(i,t)}t.endCC=o[o.length-1].cc}if(!t.startCC){var c;const n=li(e,t.startSN-1);t.startCC=null!=(c=null==n?void 0:n.cc)?c:o[0].cc}!function(e,t,n){if(e&&t){let i=0;for(let r=0,s=e.length;r<=s;r++){const s=e[r],a=t[r+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?n(s,a):i--}}}(e.partList,t.partList,((e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),a?ni(t,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS,n):si(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const u=t.advancedDateTime;if(t.advanced&&u){const e=t.edge;t.driftStart||(t.driftStartTime=u,t.driftStart=e),t.driftEndTime=u,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function ri(e,t,n,i,r){return new Error(`${e} ${r.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${n.startSN}\n${n.m3u8}`)}function si(e,t,n=!0){const i=t.startSN+t.skippedSegments-e.startSN,r=e.fragments,s=i>=0;let a=0;if(s&&i<r.length)a=r[i].start;else if(s&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(s&&n)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}ai(t,a)}function ai(e,t){if(t){const n=e.fragments;for(let i=e.skippedSegments;i<n.length;i++)n[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function oi(e,t=1/0){let n=1e3*e.targetduration;if(e.updated){const i=e.fragments,r=4;if(i.length&&n*r>t){const e=1e3*i[i.length-1].duration;e<n&&(n=e)}}else n/=2;return Math.round(n)}function li(e,t,n){if(!e)return null;let i=e.fragments[t-e.startSN];return i||(i=e.fragmentHint,i&&i.sn===t?i:t<e.startSN&&n&&n.sn===t?n:null)}function ci(e,t,n){return e?ui(e.partList,t,n):null}function ui(e,t,n){if(e)for(let i=e.length;i--;){const r=e[i];if(r.index===n&&r.fragment.sn===t)return r}return null}function hi(e){e.forEach(((e,t)=>{var n;null==(n=e.details)||n.fragments.forEach((e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function di(e,t){return!(e===t||!t)&&pi(e)!==pi(t)}function pi(e){return e.replace(/\?[^?]*$/,"")}function fi(e,t){for(let i=0,r=e.length;i<r;i++){var n;if((null==(n=e[i])?void 0:n.cc)===t)return e[i]}return null}function mi(e,t){const n=e.start+t;e.startPTS=n,e.setStart(n),e.endPTS=n+e.duration}function gi(e,t){const n=t.fragments;for(let t=0,i=n.length;t<i;t++)mi(n[t],e);t.fragmentHint&&mi(t.fragmentHint,e),t.alignedSliding=!0}function _i(e,t){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;const n=Math.min(t.endCC,e.endCC),i=fi(t.fragments,n),r=fi(e.fragments,n);if(!i||!r)return;L.log(`Aligning playlist at start of dicontinuity sequence ${n}`);gi(i.start-r.start,e)}function yi(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const n=e.fragments,i=t.fragments;if(!n.length||!i.length)return;let r,s;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(r=fi(i,a),s=fi(n,a)),r&&s||(r=i[Math.floor(i.length/2)],s=fi(n,r.cc)||n[Math.floor(n.length/2)]);const o=r.programDateTime,l=s.programDateTime;if(!o||!l)return;gi((l-o)/1e3-(s.start-r.start),e)}function vi(e,t,n){bi(e,t,n),e.addEventListener(t,n)}function bi(e,t,n){e.removeEventListener(t,n)}const wi=function(e){let t="";const n=e.length;for(let i=0;i<n;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},xi="STOPPED",ki="IDLE",Si="KEY_LOADING",Ei="FRAG_LOADING",Ti="FRAG_LOADING_WAITING_RETRY",Ci="WAITING_TRACK",Li="PARSING",Ai="PARSED",Di="ENDED",Mi="ERROR",Ri="WAITING_INIT_PTS",Ii="WAITING_LEVEL";class Pi extends Qt{constructor(e,t,n,r,s){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=xi,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:e,fragCurrent:t,media:n,mediaBuffer:r,state:s}=this,a=n?n.currentTime:0,o=nn.bufferInfo(r||n,a,e.maxBufferHole),l=!o.len;if(this.log(`Media seeking to ${i(a)?a.toFixed(3):a}, state: ${s}, ${l?"out of":"in"} buffer`),this.state===Di)this.resetLoadingState();else if(t){const n=e.maxFragLookUpTolerance,i=t.start-n,r=t.start+t.duration+n;if(l||r<o.start||i>o.end){const e=a>r;(a<i||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(n){this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0);if(a>this.lastCurrentTime&&(this.lastCurrentTime=a),!this.loadingParts){const e=Math.max(o.end,a),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${a.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${a} for seek without enough to start`),this.nextLoadPosition=a,l&&(this.startPosition=a)),l&&this.state===ki&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=s,this.hls=e,this.fragmentLoader=new Zt(e.config),this.keyLoader=n,this.fragmentTracker=t,this.config=e.config,this.decrypter=new jt(e.config)}registerListeners(){const{hls:e}=this;e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(l.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===xi)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=xi}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return-1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const n=e.end||0,i=this.config.timelineOffset||0;if(n<=i)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=nn.bufferedInfo(r,e.start,0));const s=e.nextStart;if(s&&s>i&&s<t.edge)return!1;if(this.media.currentTime<e.start)return!1;const a=t.partList;if(null!=a&&a.length){const e=a[a.length-1];return nn.isBuffered(this.media,e.start+e.duration/2)}const o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){const n=this.media=this.mediaBuffer=t.media;vi(n,"seeking",this.onMediaSeeking),vi(n,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===xi&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const n=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),bi(i,"seeking",this.onMediaSeeking),bi(i,"ended",this.onMediaEnded),this.keyLoader&&!n&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,n)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=xi,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,n){this.startFragRequested=!0,this._loadFragForPlayback(e,t,n)}_loadFragForPlayback(e,t,n){this._doFragLoad(e,t,n,(e=>{const t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)})).then((e=>{if(!e)return;const t=this.state,n=e.frag;this.fragContextChanged(n)?(t===Ei||!this.fragCurrent&&t===Li)&&(this.fragmentTracker.removeFragment(n),this.state=ki):("payload"in e&&(this.log(`Loaded ${n.type} sn: ${n.sn} of ${this.playlistLabel()} ${n.level}`),this.hls.trigger(l.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((t=>{this.state!==xi&&this.state!==Mi&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))}))}clearTrackerIfNeeded(e){var t;const{fragmentTracker:n}=this;if(n.getState(e)===Ot){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),r=Math.max(e.duration,i?i.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&n.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?n.removeAllFragments():n.hasParts(e.type)&&(n.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),n.getState(e)===Ft&&n.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,n=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:n};this.hls.trigger(l.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then((e=>{const t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e})).then((e=>{const{hls:t}=this,{frag:n,payload:i}=e,r=n.decryptdata;if(i&&i.byteLength>0&&null!=r&&r.key&&r.iv&&_n(r.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,yn(r.method)).catch((e=>{throw t.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:n}),e})).then((i=>{const r=self.performance.now();return t.trigger(l.FRAG_DECRYPTED,{frag:n,payload:i,stats:{tstart:s,tdecrypt:r}}),e.payload=i,this.completeInitSegmentLoad(e)}))}return this.completeInitSegmentLoad(e)})).catch((t=>{this.state!==xi&&this.state!==Mi&&(this.warn(t),this.resetFragmentLoading(e))}))}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const n=e.frag.stats;this.state!==xi&&(this.state=ki),e.frag.data=new Uint8Array(e.payload),n.parsing.start=n.buffering.start=self.performance.now(),n.parsing.end=n.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var n,i;const r=e.tracks;if(r&&!t.encrypted&&(null!=(n=r.audio)&&n.encrypted||null!=(i=r.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const e=this.media,n=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(n.message),!e||e.mediaKeys?!1:(this.hls.trigger(l.ERROR,{type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_KEYS,fatal:!1,error:n,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const n=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${n?wi(nn.getBuffered(n)):"(detached)"})`),W(e)){var i;if(e.type!==m){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return void(this.state=ki)}const t=null==(i=this.levels)?void 0:i[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=ki}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:n,part:i,partsLoaded:r}=e,s=!r||0===r.length||r.some((e=>!e)),a=new en(n.level,n.sn,n.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,n=null,r){var s;this.fragCurrent=e;const a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key)e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Si,this.fragCurrent=e,o=this.keyLoader.load(e).then((e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(l.KEY_LOADED,e),this.state===Si&&(this.state=ki),e})),this.hls.trigger(l.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const c=this.fragPrevious;if(W(e)&&(!c||e.sn!==c.sn)){const n=this.shouldLoadParts(t.details,e.end);n!==this.loadingParts&&(this.log(`LL-Part loading ${n?"ON":"OFF"} loading sn ${null==c?void 0:c.sn}->${e.sn}`),this.loadingParts=n)}if(n=Math.max(e.start,n||0),this.loadingParts&&W(e)){const i=a.partList;if(i&&r){n>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);const s=this.getNextPart(i,e,n);if(s>-1){const c=i[s];let u;return e=this.fragCurrent=c.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${c.index} (${s}/${i.length-1}) of ${this.fragInfo(e,!1,c)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(n.toFixed(3))}`),this.nextLoadPosition=c.start+c.duration,this.state=Ei,u=o?o.then((n=>!n||this.fragContextChanged(n.frag)?null:this.doFragPartsLoad(e,c,t,r))).catch((e=>this.handleFragLoadError(e))):this.doFragPartsLoad(e,c,t,r).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(l.FRAG_LOADING,{frag:e,part:c,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):u}if(!e.url||this.loadedEndOfParts(i,n))return Promise.resolve(null)}}var u;if(W(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${n.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(u=a.partList)?void 0:u.filter((e=>e.loaded)).map((e=>`[${e.start}-${e.end}]`))}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(n.toFixed(3))}`),i(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Ei;const h=this.config.progressive;let d;return d=h&&o?o.then((t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,r))).catch((e=>this.handleFragLoadError(e))):Promise.all([this.fragmentLoader.load(e,h?r:void 0),o]).then((([e])=>(!h&&r&&r(e),e))).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(l.FRAG_LOADING,{frag:e,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,n,i){return new Promise(((r,s)=>{var a;const o=[],c=null==(a=n.details)?void 0:a.partList,u=t=>{this.fragmentLoader.loadPart(e,t,i).then((i=>{o[t.index]=i;const s=i.part;this.hls.trigger(l.FRAG_LOADED,i);const a=ci(n.details,e.sn,t.index+1)||ui(c,e.sn,t.index+1);if(!a)return r({frag:e,part:s,partsLoaded:o});u(a)})).catch(s)};u(t)}))}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===o.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===a.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(l.ERROR,t)}else this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Li)return void(this.fragCurrent||this.state===xi||this.state===Mi||(this.state=ki));const{frag:n,part:i,level:r}=t,s=self.performance.now();n.stats.parsing.end=s,i&&(i.stats.parsing.end=s);const a=this.getLevelDetails(),o=a&&n.sn>a.endSN||this.shouldLoadParts(a,n.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${n.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(n,i,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var n;const r=e.partList[0];if(r.fragment.type===m)return!1;if(t>=r.end+((null==(n=e.fragmentHint)?void 0:n.duration)||0)){var i;if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:n}=this,{level:i,sn:r,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=s>-1?ci(o,r,s):null,c=l?l.fragment:li(o,r,n);return c?(n&&n!==c&&(c.stats=n.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,n,i,r){if(this.state!==Li)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=ge(s,a)),!o.length)return;const c=this.initPTS[t.cc],u=c?-c.baseTime/c.timescale:void 0,h={type:e.type,frag:t,part:n,chunkMeta:i,offset:u,parent:t.type,data:o};if(this.hls.trigger(l.BUFFER_APPENDING,h),e.dropped&&e.independent&&!n){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!nn.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const n=t.currentTime,i=nn.bufferInfo(t,n,0),r=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),a=Math.max(Math.min(e.start-s,i.end-s),n+s);e.start-a>s&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var n;const r=this.getLoadPosition();if(!i(r))return null;const s=this.lastCurrentTime>r||null!=(n=this.media)&&n.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,s)}getFwdBufferInfoAtPos(e,t,n,i){const r=nn.bufferInfo(e,t,i);if(0===r.len&&void 0!==r.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,n);if(s&&(r.nextStart<=s.end||s.gap)){const n=Math.max(Math.min(r.nextStart,s.end)-t,i);return nn.bufferInfo(e,t,n)}}return r}getMaxBufferLength(e){const{config:t}=this;let n;return n=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(n,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const n=this.config,i=Math.max(Math.min(e-t,n.maxBufferLength),t),r=Math.max(e-3*t,n.maxMaxBufferLength/2,i);return r>=i&&(n.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0)}getAppendedFrag(e,t=p){const n=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return n&&"fragment"in n?n.fragment:n}getNextFragment(e,t){const n=t.fragments,i=n.length;if(!i)return null;const{config:r}=this,s=n[0].start,a=r.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const n=r.initialLiveManifestSize;if(i<n)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${n})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);const n=this.hls.startPosition,i=this.hls.liveSyncPosition,r=o?(-1!==n&&n>=s?n:i)||o.start:e;this.log(`Setting startPosition to ${r} to match start frag at live edge. mainStart: ${n} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=r}}else e<=s&&(o=n[0]);if(!o){const n=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,n,t)}let c=this.filterReplacedPrimary(o,t);if(!c&&o){const e=o.sn-t.startSN;c=this.filterReplacedPrimary(n[e+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const n=this.fragmentTracker.getState(e);return(n===Nt||n===Ft&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,n,i,r){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t),s&&!s.gap&&n.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,n.nextStart,i,0);if(null!==e&&n.len+e.len>=r){const e=s.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,s}get primaryPrefetch(){if(Oi(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(Oi(this.config)&&e.type!==m){const n=this.hls.interstitialsManager,i=null==n?void 0:n.bufferingItem;if(i){const n=i.event;if(n){if(n.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}const r=null==n?void 0:n.playerQueue;if(r)for(let t=r.length;t--;){const n=r[t].interstitial;if(n.appendInPlace&&e.start>=n.startTime&&e.end<=n.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,n){let i=-1,r=!1,s=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(s=s&&!o.independent,i>-1&&n<o.start)break;const l=o.loaded;l?i=-1:(r||(o.independent||s)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${n} but next unloaded part starts at ${o.start}`),i=a),r=l}return i}loadedEndOfParts(e,t){let n;for(let i=e.length;i--;){if(n=e[i],!n.loaded)return!1;if(t>n.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,n=this.fragPrevious;let r=null;if(n){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`),r=function(e,t,n){if(null===t||!Array.isArray(e)||!e.length||!i(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let i=0;i<e.length;++i){const r=e[i];if(mt(t,n,r))return r}return null}(t,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const i=n.sn+1;if(i>=e.startSN&&i<=e.endSN){const s=t[i-e.startSN];n.cc===s.cc&&(r=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=gt(e,n.cc,n.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(r=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,n){const{config:i}=this;let{fragPrevious:r}=this,{fragments:s,endSN:a}=n;const{fragmentHint:o}=n,{maxFragLookUpTolerance:l}=i,c=n.partList,u=!!(this.loadingParts&&null!=c&&c.length&&o);let h;if(u&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var d;h=pt(r,s,e,e<this.lastCurrentTime||e>t-l||null!=(d=this.media)&&d.paused||!this.startFragRequested?0:l)}else h=s[s.length-1];if(h){const e=h.sn-n.startSN,t=this.fragmentTracker.getState(h);if((t===Nt||t===Ft&&h.gap)&&(r=h),r&&h.sn===r.sn&&(!u||c[0].fragment.sn>h.sn||!n.live)){if(h.level===r.level){const t=s[e+1];h=h.sn<a&&this.fragmentTracker.getState(t)!==Nt?t:null}}}return h}alignPlaylists(e,t,n){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const s=e.fragmentStart,a=!t,o=e.alignedSliding&&i(s);if(a||!o&&!s){!function(e,t){e&&(_i(t,e),t.alignedSliding||yi(t,e),t.alignedSliding||t.skippedSegments||si(e,t,!1))}(n,e);const i=e.fragmentStart;return this.log(`Live playlist sliding: ${i.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),i}return s}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let n=this.startPosition;n<t&&(n=-1);const r=this.timelineOffset;if(-1===n){const s=null!==this.startTimeOffset,a=s?this.startTimeOffset:e.startTimeOffset;null!==a&&i(a)?(n=t+a,a<0&&(n+=e.edge),n=Math.min(Math.max(t,n),t+e.totalduration),this.log(`Setting startPosition to ${n} for start time offset ${a} found in ${s?"multivariant":"media"} playlist`),this.startPosition=n):e.live?(n=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${n}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=n=0),this.lastCurrentTime=n+r}this.nextLoadPosition=n+r}getLoadPosition(){var e;const{media:t}=this;let n=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?n=t.currentTime:this.nextLoadPosition>=0&&(n=this.nextLoadPosition),n}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&W(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Ti)||(this.state=ki)}onFragmentOrKeyLoadError(e,t){var n;if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var r;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`);const s=t.details===o.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=Mi);const{action:l,flags:c,retryCount:u=0,retryConfig:h}=a,d=!!h,p=d&&l===Lt,f=d&&!a.resolved&&c===Dt,m=null==(n=this.hls.latestLevelDetails)?void 0:n.live;if(!p&&f&&W(i)&&!i.endList&&m&&!vt(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((p||f)&&u<h.maxNumRetry){var g;const n=St(null==(g=t.response)?void 0:g.code),r=wt(h,u);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+r,this.state=Ti,a.resolved=!0,n)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${u+1}/${h.maxNumRetry} in ${r}ms`)}else if(h){if(this.resetFragmentErrors(e),!(u<h.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${u})`);s||l===Ct||(a.resolved=!0)}else this.state=l===Tt?Ii:Mi;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,n=t===1/0;(!t||e>=t||n&&!St(0))&&(n&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=ki)}reduceLengthAndFlushBuffer(e){if(this.state===Li||this.state===Ai){const t=e.frag,n=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,n),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const s=!r;return s&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${n} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===f&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==xi&&(this.state=ki)}afterBufferFlushed(e,t,n){if(!e)return;const i=nn.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,n),this.state===Di&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==xi&&(this.state=ki)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,n,i){const r=n.details;if(!r)return void this.warn("level.details undefined");var s;if(!Object.keys(e.elementaryStreams).reduce(((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const c=i?0:ni(r,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(l.LEVEL_PTS_UPDATED,{details:r,level:n,drift:c,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t}),!1)&&(0===n.fragmentError&&this.treatAsGap(e,n),null===(null==(s=this.transmuxer)?void 0:s.error))){const t=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${n.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Ai,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(l.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===p?"level":"track"}fragInfo(e,t=!0,n){var i,r;return`${this.playlistLabel()} ${e.level} (${n?"part":"frag"}:[${(null!=(i=t&&!n?e.startPTS:(n||e).start)?i:NaN).toFixed(3)}-${(null!=(r=t&&!n?e.endPTS:(n||e).end)?r:NaN).toFixed(3)}]${n&&"main"===e.type?"INDEPENDENT="+(n.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Oi(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class Fi{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let n;return e.length?(n=1===e.length?e[0]:function(e,t){const n=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];n.set(r,i),i+=r.length}return n}(e,t),this.reset(),n):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var Ni,Bi={exports:{}};var $i=(Ni||(Ni=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,i,s,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new r(i,s||e,a),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),o.prototype.eventNames=function(){var e,i,r=[];if(0===this._eventsCount)return r;for(i in e=this._events)t.call(e,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},o.prototype.listeners=function(e){var t=n?n+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,a=new Array(s);r<s;r++)a[r]=i[r].fn;return a},o.prototype.listenerCount=function(e){var t=n?n+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,r,s,a){var o=n?n+e:e;if(!this._events[o])return!1;var l,c,u=this._events[o],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,i),!0;case 4:return u.fn.call(u.context,t,i,r),!0;case 5:return u.fn.call(u.context,t,i,r,s),!0;case 6:return u.fn.call(u.context,t,i,r,s,a),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var d,p=u.length;for(c=0;c<p;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,i);break;case 4:u[c].fn.call(u[c].context,t,i,r);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];u[c].fn.apply(u[c].context,l)}}return!0},o.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},o.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},o.prototype.removeListener=function(e,t,i,r){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||r&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,c=[],u=o.length;l<u;l++)(o[l].fn!==t||r&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,e.exports=o}(Bi)),Bi.exports),Ki=P($i);const Ui="1.6.13",zi={};function Vi(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function qi(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Gi(e,t){let n=0;return n=(127&e[t])<<21,n|=(127&e[t+1])<<14,n|=(127&e[t+2])<<7,n|=127&e[t+3],n}function Hi(e,t){const n=t;let i=0;for(;qi(e,t);){i+=10;i+=Gi(e,t+6),Vi(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(n,n+i)}function ji(e,t){return 255===e[t]&&240==(246&e[t+1])}function Wi(e,t){return 1&e[t+1]?7:9}function Zi(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Yi(e,t){return t+1<e.length&&ji(e,t)}function Xi(e,t){if(Yi(e,t)){const n=Wi(e,t);if(t+n>=e.length)return!1;const i=Zi(e,t);if(i<=n)return!1;const r=t+i;return r===e.length||Yi(e,r)}return!1}function Ji(e,t,n,i,r){if(!e.samplerate){const s=function(e,t,n,i){const r=t[n+2],s=r>>2&15;if(s>12){const t=new Error(`invalid ADTS sampling index:${s}`);return void e.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const c=1+(r>>6&3),u=t[n+3]>>6&3|(1&r)<<2,h="mp4a.40."+c,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let p=s;5!==c&&29!==c||(p-=3);const f=[c<<3|(14&p)>>1,(1&p)<<7|u<<3];return L.log(`manifest codec:${i}, parsed codec:${h}, channels:${u}, rate:${d} (ADTS object type:${c} sampling index:${s})`),{config:f,samplerate:d,channelCount:u,codec:h,parsedCodec:h,manifestCodec:i}}(t,n,i,r);if(!s)return;v(e,s)}}function Qi(e){return 9216e4/e}function er(e,t,n,i,r){const s=i+r*Qi(e.samplerate),a=function(e,t){const n=Wi(e,t);if(t+n<=e.length){const i=Zi(e,t)-n;if(i>0)return{headerLength:n,frameLength:i}}}(t,n);let o;if(a){const{frameLength:i,headerLength:r}=a,l=r+i,c=Math.max(0,n+l-t.length);c?(o=new Uint8Array(l-r),o.set(t.subarray(n+r,t.length),0)):o=t.subarray(n+r,n+l);const u={unit:o,pts:s};return c||e.samples.push(u),{sample:u,length:l,missing:c}}const l=t.length-n;o=new Uint8Array(l),o.set(t.subarray(n,t.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}function tr(e,t){return qi(e,t)&&Gi(e,t+6)+10<=e.length-t}function nr(e,t=0,n=1/0){return function(e,t,n,i){const r=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let s=1;"BYTES_PER_ELEMENT"in i&&(s=i.BYTES_PER_ELEMENT);const a=(h=e,h&&h.buffer instanceof ArrayBuffer&&void 0!==h.byteLength&&void 0!==h.byteOffset?e.byteOffset:0),o=(a+e.byteLength)/s,l=(a+t)/s,c=Math.floor(Math.max(0,Math.min(l,o))),u=Math.floor(Math.min(c+Math.max(n,0),o));var h;return new i(r,c,u-c)}(e,t,n,Uint8Array)}function ir(e){const t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");const n=e.data.subarray(1).indexOf(0);if(-1===n)return;const i=M(nr(e.data,1,n)),r=e.data[2+n],s=e.data.subarray(3+n).indexOf(0);if(-1===s)return;const a=M(nr(e.data,3+n,s));let o;return o="--\x3e"===i?M(nr(e.data,4+n+s)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+n+s)),t.mimeType=i,t.pictureType=r,t.description=a,t.data=o,t}function rr(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=M(e.data,!0),n=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:n.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1;const n=M(e.data.subarray(t),!0);t+=n.length+1;const i=M(e.data.subarray(t));return{key:e.type,info:n,data:i}}const t=M(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?ir(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const n=M(e.data.subarray(t),!0);t+=n.length+1;const i=M(e.data.subarray(t));return{key:e.type,info:n,data:i}}const t=M(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function sr(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),n=Gi(e,4);return{type:t,size:n,data:e.subarray(10,10+n)}}function ar(e){let t=0;const n=[];for(;qi(e,t);){const i=Gi(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const r=t+i;for(;t+10<r;){const i=sr(e.subarray(t)),r=rr(i);r&&n.push(r),t+=i.size+10}Vi(e,t)&&(t+=10)}return n}function or(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function lr(e){if(8===e.data.byteLength){const t=new Uint8Array(e.data),n=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,n&&(i+=47721858.84),Math.round(i)}}function cr(e){const t=ar(e);for(let e=0;e<t.length;e++){const n=t[e];if(or(n))return lr(n)}}let ur=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function hr(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class dr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,n,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,n){}demux(e,t){this.cachedData&&(e=ge(this.cachedData,e),this.cachedData=null);let n,r=Hi(e,0),s=r?r.length:0;const a=this._audioTrack,o=this._id3Track,l=r?cr(r):void 0,c=e.length;for((null===this.basePTS||0===this.frameIndex&&i(l))&&(this.basePTS=pr(l,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ur.audioId3,duration:Number.POSITIVE_INFINITY});s<c;){if(this.canParse(e,s)){const t=this.appendFrame(a,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,n=s):s=c}else tr(e,s)?(r=Hi(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ur.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===c&&n!==c){const t=e.slice(n);this.cachedData?this.cachedData=ge(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:hr(),id3Track:o,textTrack:hr()}}demuxSampleAes(e,t,n){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:hr(),id3Track:this._id3Track,textTrack:hr()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const pr=(e,t,n)=>{if(i(e))return 90*e;return 9e4*t+(n?9e4*n.baseTime/n.timescale:0)};let fr=null;const mr=[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],gr=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_r=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],yr=[0,1,1,4];function vr(e,t,n,i,r){if(n+24>t.length)return;const s=br(t,n);if(s&&n+s.frameLength<=t.length){const a=i+r*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:t.subarray(n,n+s.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function br(e,t){const n=e[t+1]>>3&3,i=e[t+1]>>1&3,r=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==n&&0!==r&&15!==r&&3!==s){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*mr[14*(3===n?3-i:3===i?3:4)+r-1],c=gr[3*(3===n?0:2===n?1:2)+s],u=3===o?1:2,h=_r[n][i],d=yr[i],p=8*h*d,f=Math.floor(h*l/c+a)*d;if(null===fr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fr=e?parseInt(e[1]):0}return!!fr&&fr<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:f,samplesPerFrame:p}}}function wr(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function xr(e,t){return t+1<e.length&&wr(e,t)}function kr(e,t){if(t+1<e.length&&wr(e,t)){const n=4,i=br(e,t);let r=n;null!=i&&i.frameLength&&(r=i.frameLength);const s=t+r;return s===e.length||xr(e,s)}return!1}const Sr=(e,t)=>{let n=0,i=5;t+=i;const r=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;s[0]=4278190080>>>24+l<<l,r[0]=(a[0]&s[0])>>l,n=n?n<<o|r[0]:r[0],t+=1,i-=o}return n};class Er extends dr{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,n){const i=Tr(e,t,n,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=Hi(e,0);if(!t)return!1;const n=t.length;return 11===e[n]&&119===e[n+1]&&void 0!==cr(t)&&Sr(e,n)<16}}function Tr(e,t,n,i,r){if(n+8>t.length)return-1;if(11!==t[n]||119!==t[n+1])return-1;const s=t[n+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&t[n+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(n+l>t.length)return-1;const c=t[n+6]>>5;let u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));const h=(t[n+6]<<8|t[n+7])>>12-u&1,d=[2,1,2,3,3,4,4,5][c]+h,p=t[n+5]>>3,f=7&t[n+5],m=new Uint8Array([s<<6|p<<1|f>>2,(3&f)<<6|c<<3|h<<2|o>>4,o<<4&224]),g=i+r*(1536/a*9e4),_=t.subarray(n,n+l);return e.config=m,e.channelCount=d,e.samplerate=a,e.samples.push({unit:_,pts:g}),l}const Cr=/\/emsg[-/]ID3/i;function Lr(e,t){return i(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class Ar{constructor(e,t,n){this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new jt(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,zt)}decryptAacSample(e,t,n){const i=e[t].unit;if(i.length<=16)return;const r=i.subarray(16,i.length-i.length%16),s=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(s).then((r=>{const s=new Uint8Array(r);i.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,n)})).catch(n)}decryptAacSamples(e,t,n){for(;;t++){if(t>=e.length)return void n();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,n),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,n=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)n.set(e.subarray(t,t+16),i);return n}getAvcDecryptedUnit(e,t){const n=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(n.subarray(i,i+16),t);return e}decryptAvcSample(e,t,n,i,r){const s=we(r.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then((a=>{r.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,n+1,i)})).catch(i)}decryptAvcSamples(e,t,n,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,n=0){if(t>=e.length)return void i();const r=e[t].units;for(;!(n>=r.length);n++){const s=r[n];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,n,i,s),this.decrypter.isSync())))return}}}}class Dr{constructor(){this.VideoSample=null}createVideoSample(e,t,n){return{key:e,frame:!1,pts:t,dts:n,units:[],length:0}}getLastNalUnit(e){var t;let n,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;n=e[e.length-1]}return n}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const n=t.samples,i=n.length;if(!i)return void t.dropped++;{const t=n[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,n){const i=t.byteLength;let r=e.naluState||0;const s=r,a=[];let o,l,c,u=0,h=-1,d=0;for(-1===r&&(h=0,d=this.getNALuType(t,0),r=0,u=1);u<i;)if(o=t[u++],r)if(1!==r)if(o)if(1===o){if(l=u-r-1,h>=0){const e={data:t.subarray(h,l),type:d};a.push(e)}else{const n=this.getLastNalUnit(e.samples);n&&(s&&u<=4-s&&n.state&&(n.data=n.data.subarray(0,n.data.byteLength-s)),l>0&&(n.data=ge(n.data,t.subarray(0,l)),n.state=0))}u<i?(c=this.getNALuType(t,u),h=u,d=c,r=0):r=-1}else r=0;else r=3;else r=o?0:2;else r=o?0:1;if(h>=0&&r>=0){const e={data:t.subarray(h,i),type:d,state:r};a.push(e)}if(0===a.length){const n=this.getLastNalUnit(e.samples);n&&(n.data=ge(n.data,t))}return e.naluState=r,a}}class Mr{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,n=e.byteLength-t,i=new Uint8Array(4),r=Math.min(4,t);if(0===r)throw new Error("no bytes available");i.set(e.subarray(n,n+r)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const n=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?n<<t|this.readBits(t):n}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Rr extends Dr{parsePES(e,t,n,i){const r=this.parseNALu(e,n.data,i);let s,a=this.VideoSample,o=!1;n.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),r.forEach((i=>{var r,l;switch(i.type){case 1:{let t=!1;s=!0;const r=i.data;if(o&&r.length>4){const e=this.readSliceType(r);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var c;if(t)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),a.frame=!0,a.key=t;break}case 5:s=!0,null!=(r=a)&&r.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),a.key=!0,a.frame=!0;break;case 6:s=!0,be(i.data,1,n.pts,t.samples);break;case 7:{var u,h;s=!0,o=!0;const t=i.data,n=this.readSPS(t);if(!e.sps||e.width!==n.width||e.height!==n.height||(null==(u=e.pixelRatio)?void 0:u[0])!==n.pixelRatio[0]||(null==(h=e.pixelRatio)?void 0:h[1])!==n.pixelRatio[1]){e.width=n.width,e.height=n.height,e.pixelRatio=n.pixelRatio,e.sps=[t];const i=t.subarray(1,4);let r="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),r+=t}e.codec=r}break}case 8:s=!0,e.pps=[i.data];break;case 9:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts));break;case 12:s=!0;break;default:s=!1}if(a&&s){a.units.push(i)}})),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){const t=new Mr(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let n,i=8,r=8;for(let s=0;s<e;s++)0!==r&&(n=t.readEG(),r=(i+n+256)%256),i=0===r?i:r}readSPS(e){const t=new Mr(e);let n,i,r,s=0,a=0,o=0,l=0;const c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),d=t.readBoolean.bind(t),p=t.skipBits.bind(t),f=t.skipEG.bind(t),m=t.skipUEG.bind(t),g=this.skipScalingList.bind(this);c();const _=c();if(u(5),p(3),c(),m(),100===_||110===_||122===_||244===_||44===_||83===_||86===_||118===_||128===_){const e=h();if(3===e&&p(1),m(),m(),p(1),d())for(i=3!==e?8:12,r=0;r<i;r++)d()&&g(r<6?16:64,t)}m();const y=h();if(0===y)h();else if(1===y)for(p(1),f(),f(),n=h(),r=0;r<n;r++)f();m(),p(1);const v=h(),b=h(),w=u(1);0===w&&p(1),p(1),d()&&(s=h(),a=h(),o=h(),l=h());let x=[1,1];if(d()&&d()){switch(c()){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:x=[c()<<8|c(),c()<<8|c()]}}return{width:Math.ceil(16*(v+1)-2*s-2*a),height:(2-w)*(b+1)*16-(w?2:4)*(o+l),pixelRatio:x}}}class Ir extends Dr{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,n,i){const r=this.parseNALu(e,n.data,i);let s,a=this.VideoSample,o=!1;n.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),r.forEach((i=>{var r,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),a.frame=!0,s=!0;break;case 16:case 17:case 18:case 21:var c;if(s=!0,o)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:s=!0,null!=(r=a)&&r.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),a.key=!0,a.frame=!0;break;case 39:s=!0,be(i.data,2,n.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=v(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(s=!0,o=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const t=this.readSPS(i.data);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(const n in t.params)e.params[n]=t.params[n]}this.pushParameterSet(e.sps,i.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),a.key=!0;break;case 34:if(s=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];const t=this.readPPS(i.data);for(const n in t)e.params[n]=t[n]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts));break;default:s=!1}if(a&&s){a.units.push(i)}})),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,n){(n&&n[0]===this.initVPS||!n&&!e.length)&&e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let n=0;for(let i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[n]=e[i],n++);return new Uint8Array(t.buffer,0,n)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new Mr(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);return{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){const t=new Mr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const n=t.readBits(3);t.readBoolean();const i=t.readBits(2),r=t.readBoolean(),s=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),d=t.readUByte(),p=t.readUByte(),f=t.readUByte(),m=t.readUByte(),g=t.readUByte(),_=[],y=[];for(let e=0;e<n;e++)_.push(t.readBoolean()),y.push(t.readBoolean());if(n>0)for(let e=n;e<8;e++)t.readBits(2);for(let e=0;e<n;e++)_[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();const v=t.readUEG();3==v&&t.skipBits(1);const b=t.readUEG(),w=t.readUEG(),x=t.readBoolean();let k=0,S=0,E=0,T=0;x&&(k+=t.readUEG(),S+=t.readUEG(),E+=t.readUEG(),T+=t.readUEG());const C=t.readUEG(),L=t.readUEG(),A=t.readUEG();for(let e=t.readBoolean()?0:n;e<=n;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.readBoolean()){if(t.readBoolean())for(let e=0;e<4;e++)for(let n=0;n<(3===e?2:6);n++){if(t.readBoolean()){const n=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<n;e++)t.readEG()}else t.readUEG()}}t.readBoolean(),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const D=t.readUEG();let M=0;for(let e=0;e<D;e++){let n=!1;if(0!==e&&(n=t.readBoolean()),n){e===D&&t.readUEG(),t.readBoolean(),t.readUEG();let n=0;for(let e=0;e<=M;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&n++}M=n}else{const e=t.readUEG(),n=t.readUEG();M=e+n;for(let n=0;n<e;n++)t.readUEG(),t.readBoolean();for(let e=0;e<n;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const e=t.readUEG();for(let n=0;n<e;n++){for(let e=0;e<A+4;e++)t.readBits(1);t.readBits(1)}}let R=0,I=1,P=1,O=!0,F=1,N=0;t.readBoolean(),t.readBoolean();let B=!1;if(t.readBoolean()){if(t.readBoolean()){const e=t.readUByte();e>0&&e<16?(I=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],P=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(I=t.readBits(16),P=t.readBits(16))}t.readBoolean()&&t.readBoolean();if(t.readBoolean()){t.readBits(3),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())}t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),B=t.readBoolean(),B&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG());if(t.readBoolean()){F=t.readBits(32),N=t.readBits(32);t.readBoolean()&&t.readUEG();if(t.readBoolean()){const e=t.readBoolean(),i=t.readBoolean();let r=!1;(e||i)&&(r=t.readBoolean(),r&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),r&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let s=0;s<=n;s++){O=t.readBoolean();let n=!1;O||t.readBoolean()?t.readEG():n=t.readBoolean();const s=n?1:t.readUEG()+1;if(e)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),r&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),r&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),R=t.readUEG())}let $=b,K=w;if(x){let e=1,t=1;1===v?e=t=2:2==v&&(e=2),$=b-e*S-e*k,K=w-t*T-t*E}const U=i?["A","B","C"][i]:"",z=a<<24|o<<16|l<<8|c;let V=0;for(let e=0;e<32;e++)V=(V|(z>>e&1)<<31-e)>>>0;let q=V.toString(16);1===s&&"2"===q&&(q="6");return{codecString:`hvc1.${U}${s}.${q}.${r?"H":"L"}${g}.B0`,params:{general_tier_flag:r,general_profile_idc:s,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[u,h,d,p,f,m],general_level_idc:g,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:R,chroma_format_idc:v,frame_rate:{fixed:O,fps:N/F}},width:$,height:K,pixelRatio:[I,P]}}readPPS(e){const t=new Mr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2);t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const n=t.readBoolean(),i=t.readBoolean();let r=1;return i&&n?r=0:i?r=3:n&&(r=2),{parallelismType:r}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Pr=188;class Or{constructor(e,t,n,i){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=n,this.logger=i,this.videoParser=null}static probe(e,t){const n=Or.syncOffset(e);return n>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${n}`),-1!==n}static syncOffset(e){const t=e.length;let n=Math.min(940,t-Pr)+1,i=0;for(;i<n;){let r=!1,s=-1,a=0;for(let o=i;o<t;o+=Pr){if(71!==e[o]||t-o!==Pr&&71!==e[o+Pr]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(n=Math.min(s+18612,e.length-Pr)+1)),r||(r=0===Fr(e,o)),r&&a>1&&(0===s&&a>2||o+Pr>n))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:ee[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,n,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Or.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=Or.createTrack("audio",i),this._id3Track=Or.createTrack("id3"),this._txtTrack=Or.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:n}=this;e&&(e.pesData=null),t&&(t.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,n=!1,i=!1){let r;n||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,u=s.pesData,h=a.pid,d=o.pid,p=a.pesData,f=o.pesData,m=null,g=this.pmtParsed,_=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=ge(this.remainderData,e)).length,this.remainderData=null),y<Pr&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const v=Math.max(0,Or.syncOffset(e));y-=(y-v)%Pr,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let b=0;for(let t=v;t<y;t+=Pr)if(71===e[t]){const i=!!(64&e[t+1]),y=Fr(e,t);let b;if((48&e[t+3])>>4>1){if(b=t+5+e[t+4],b===t+Pr)continue}else b=t+4;switch(y){case c:i&&(u&&(r=Ur(u,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,r,!1)),u={data:[],size:0}),u&&(u.data.push(e.subarray(b,t+Pr)),u.size+=t+Pr-b);break;case h:if(i){if(p&&(r=Ur(p,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r);break;case"ac3":this.parseAC3PES(a,r)}p={data:[],size:0}}p&&(p.data.push(e.subarray(b,t+Pr)),p.size+=t+Pr-b);break;case d:i&&(f&&(r=Ur(f,this.logger))&&this.parseID3PES(o,r),f={data:[],size:0}),f&&(f.data.push(e.subarray(b,t+Pr)),f.size+=t+Pr-b);break;case 0:i&&(b+=e[b]+1),_=this._pmtId=Nr(e,b);break;case _:{i&&(b+=e[b]+1);const r=Br(e,b,this.typeSupported,n,this.observer,this.logger);c=r.videoPid,c>0&&(s.pid=c,s.segmentCodec=r.segmentVideoCodec),h=r.audioPid,h>0&&(a.pid=h,a.segmentCodec=r.segmentAudioCodec),d=r.id3Pid,d>0&&(o.pid=d),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${v} to parse all TS packets.`),m=null,t=v-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=y}}else b++;b>0&&$r(this.observer,new Error(`Found ${b} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=u,a.pesData=p,o.pesData=f;const w={audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(w),w}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:n,id3Track:i,textTrack:r}=e,s=n.pesData,a=t.pesData,o=i.pesData;let l;if(s&&(l=Ur(s,this.logger))?(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(n,r,l,!0),n.pesData=null)):n.pesData=s,a&&(l=Ur(a,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=Ur(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,n){const i=this.demux(e,n,!0,!this.config.progressive),r=this.sampleAes=new Ar(this.observer,this.config,t);return this.decrypt(i,r)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new Rr:"hevc"===e&&(this.videoParser=new Ir))}decrypt(e,t){return new Promise((n=>{const{audioTrack:i,videoTrack:r}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,(()=>{n(e)})):n(e)})):r.samples&&t.decryptAvcSamples(r.samples,0,0,(()=>{n(e)}))}))}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let n=0;const i=this.aacOverFlow;let r,s,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,r=i.sample.unit.byteLength;if(-1===t)o=ge(i.sample.unit,o);else{const s=r-t;i.sample.unit.set(o.subarray(0,t),s),e.samples.push(i.sample),n=i.missing}}for(r=n,s=o.length;r<s-1&&!Yi(o,r);r++);if(r!==n){let e;const t=r<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",$r(this.observer,new Error(e),t,this.logger),!t)return}if(Ji(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=Qi(e.samplerate);a=i.sample.pts+t}}let l,c=0;for(;r<s;){if(l=er(e,o,r,a,c),r+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;r<s-1&&!Yi(o,r);r++);}}parseMPEGPES(e,t){const n=t.data,i=n.length;let r=0,s=0;const a=t.pts;if(void 0!==a)for(;s<i;)if(xr(n,s)){const t=vr(e,n,s,a,r);if(!t)break;s+=t.length,r++}else s++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const n=t.data,i=t.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const r=n.length;let s,a=0,o=0;for(;o<r&&(s=Tr(e,n,o,i,a++))>0;)o+=s}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const n=v({},t,{type:this._videoTrack?ur.emsg:ur.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(n)}}function Fr(e,t){return((31&e[t+1])<<8)+e[t+2]}function Nr(e,t){return(31&e[t+10])<<8|e[t+11]}function Br(e,t,n,i,r,s){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=Fr(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Kr("ADTS AAC",s);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Kr("H.264",s);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:n.mpeg||n.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Kr("AC-3",s);break}case 129:n.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,r=l;for(;r>2;){if(106===e[i])!0!==n.ac3?s.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,r-=t}}break;case 194:case 135:return $r(r,new Error("Unsupported EC-3 in M2TS found"),void 0,s),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=l+5}return a}function $r(e,t,n,i){i.warn(`parsing error: ${t.message}`),e.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,levelRetry:n,error:t,reason:t.message})}function Kr(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function Ur(e,t){let n,i,r,s,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=ge(l[0],l[1]),l.splice(1,1);n=l[0];if(1===(n[0]<<16)+(n[1]<<8)+n[2]){if(i=(n[4]<<8)+n[5],i&&i>e.size-6)return null;const c=n[7];192&c&&(s=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&c?(a=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2,s-a>54e5&&(t.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a)):a=s),r=n[8];let u=r+9;if(e.size<=u)return null;e.size-=u;const h=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){n=l[e];let t=n.byteLength;if(u){if(u>t){u-=t;continue}n=n.subarray(u),t-=u,u=0}h.set(n,o),o+=t}return i&&(i-=r+3),{data:h,pts:s,dts:a,len:i}}return null}class zr{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)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])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)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])}}}const Vr=Math.pow(2,32)-1;class qr{static init(){let e;for(e in qr.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},qr.types)qr.types.hasOwnProperty(e)&&(qr.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);qr.HDLR_TYPES={video:t,audio:n};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);qr.STTS=qr.STSC=qr.STCO=r,qr.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),qr.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),qr.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),qr.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);qr.FTYP=qr.box(qr.types.ftyp,s,o,s,a),qr.DINF=qr.box(qr.types.dinf,qr.box(qr.types.dref,i))}static box(e,...t){let n=8,i=t.length;const r=i;for(;i--;)n+=t[i].byteLength;const s=new Uint8Array(n);for(s[0]=n>>24&255,s[1]=n>>16&255,s[2]=n>>8&255,s[3]=255&n,s.set(e,4),i=0,n=8;i<r;i++)s.set(t[i],n),n+=t[i].byteLength;return s}static hdlr(e){return qr.box(qr.types.hdlr,qr.HDLR_TYPES[e])}static mdat(e){return qr.box(qr.types.mdat,e)}static mdhd(e,t){t*=e;const n=Math.floor(t/(Vr+1)),i=Math.floor(t%(Vr+1));return qr.box(qr.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return qr.box(qr.types.mdia,qr.mdhd(e.timescale||0,e.duration||0),qr.hdlr(e.type),qr.minf(e))}static mfhd(e){return qr.box(qr.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?qr.box(qr.types.minf,qr.box(qr.types.smhd,qr.SMHD),qr.DINF,qr.stbl(e)):qr.box(qr.types.minf,qr.box(qr.types.vmhd,qr.VMHD),qr.DINF,qr.stbl(e))}static moof(e,t,n){return qr.box(qr.types.moof,qr.mfhd(e),qr.traf(n,t))}static moov(e){let t=e.length;const n=[];for(;t--;)n[t]=qr.trak(e[t]);return qr.box.apply(null,[qr.types.moov,qr.mvhd(e[0].timescale||0,e[0].duration||0)].concat(n).concat(qr.mvex(e)))}static mvex(e){let t=e.length;const n=[];for(;t--;)n[t]=qr.trex(e[t]);return qr.box.apply(null,[qr.types.mvex,...n])}static mvhd(e,t){t*=e;const n=Math.floor(t/(Vr+1)),i=Math.floor(t%(Vr+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,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 qr.box(qr.types.mvhd,r)}static sdtp(e){const t=e.samples||[],n=new Uint8Array(4+t.length);let i,r;for(i=0;i<t.length;i++)r=t[i].flags,n[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return qr.box(qr.types.sdtp,n)}static stbl(e){return qr.box(qr.types.stbl,qr.stsd(e),qr.box(qr.types.stts,qr.STTS),qr.box(qr.types.stsc,qr.STSC),qr.box(qr.types.stsz,qr.STSZ),qr.box(qr.types.stco,qr.STCO))}static avc1(e){let t,n,i,r=[],s=[];for(t=0;t<e.sps.length;t++)n=e.sps[t],i=n.byteLength,r.push(i>>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(n));for(t=0;t<e.pps.length;t++)n=e.pps[t],i=n.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(n));const a=qr.box(qr.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return qr.box(qr.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,o>>8&255,255&o,l>>8&255,255&l,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]),a,qr.box(qr.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),qr.box(qr.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return qr.box(qr.types.mp4a,qr.audioStsd(e),qr.box(qr.types.esds,qr.esds(e)))}static mp3(e){return qr.box(qr.types[".mp3"],qr.audioStsd(e))}static ac3(e){return qr.box(qr.types["ac-3"],qr.audioStsd(e),qr.box(qr.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return qr.box(qr.types.stsd,qr.STSD,qr.mp4a(e));if("ac3"===t&&e.config)return qr.box(qr.types.stsd,qr.STSD,qr.ac3(e));if("mp3"===t&&"mp3"===e.codec)return qr.box(qr.types.stsd,qr.STSD,qr.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return qr.box(qr.types.stsd,qr.STSD,qr.avc1(e));if("hevc"===t&&e.vps)return qr.box(qr.types.stsd,qr.STSD,qr.hvc1(e))}throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,n=(e.duration||0)*(e.timescale||0),i=e.width||0,r=e.height||0,s=Math.floor(n/(Vr+1)),a=Math.floor(n%(Vr+1));return qr.box(qr.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a,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,i>>8&255,255&i,0,0,r>>8&255,255&r,0,0]))}static traf(e,t){const n=qr.sdtp(e),i=e.id,r=Math.floor(t/(Vr+1)),s=Math.floor(t%(Vr+1));return qr.box(qr.types.traf,qr.box(qr.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),qr.box(qr.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s])),qr.trun(e,n.length+16+20+8+16+8+8),n)}static trak(e){return e.duration=e.duration||4294967295,qr.box(qr.types.trak,qr.tkhd(e),qr.mdia(e))}static trex(e){const t=e.id;return qr.box(qr.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const n=e.samples||[],i=n.length,r=12+16*i,s=new Uint8Array(r);let a,o,l,c,u,h;for(t+=8+r,s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=n[a],l=o.duration,c=o.size,u=o.flags,h=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*a);return qr.box(qr.types.trun,s)}static initSegment(e){qr.types||qr.init();const t=qr.moov(e);return ge(qr.FTYP,t)}static hvc1(e){const t=e.params,n=[e.vps,e.sps,e.pps],i=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),n.length]);let r=i.length;for(let e=0;e<n.length;e+=1){r+=3;for(let t=0;t<n[e].length;t+=1)r+=2+n[e][t].length}const s=new Uint8Array(r);s.set(i,0),r=i.length;const a=n.length-1;for(let e=0;e<n.length;e+=1){s.set(new Uint8Array([32+e|(e===a?128:0),0,n[e].length]),r),r+=3;for(let t=0;t<n[e].length;t+=1)s.set(new Uint8Array([n[e][t].length>>8,255&n[e][t].length]),r),r+=2,s.set(n[e][t],r),r+=n[e][t].length}const o=qr.box(qr.types.hvcC,s),l=e.width,c=e.height,u=e.pixelRatio[0],h=e.pixelRatio[1];return qr.box(qr.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,qr.box(qr.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),qr.box(qr.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))}}qr.types=void 0,qr.HDLR_TYPES=void 0,qr.STTS=void 0,qr.STSC=void 0,qr.STCO=void 0,qr.STSZ=void 0,qr.VMHD=void 0,qr.SMHD=void 0,qr.STSD=void 0,qr.FTYP=void 0,qr.DINF=void 0;function Gr(e,t,n=1,i=!1){const r=e*t*n;return i?Math.round(r):r}function Hr(e,t=!1){return Gr(e,1e3,1/9e4,t)}function jr(e){const{baseTime:t,timescale:n,trackId:i}=e;return`${t/n} (${t}/${n}) trackId: ${i}`}let Wr,Zr=null,Yr=null;function Xr(e,t,n,i){return{duration:t,size:n,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class Jr extends x{constructor(e,t,n,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=n,this.ISGenerated=!1,null===Zr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zr=e?parseInt(e[1]):0}if(null===Yr){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Yr=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?jr(t):t} > ${e?jr(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const n=e[0].pts,i=e.reduce(((e,i)=>{let r=i.pts,s=r-e;return s<-4294967296&&(t=!0,r=Qr(r,n),s=r-e),s>0?e:r}),n);return t&&this.debug("PTS rollover detected"),i}remux(e,t,n,i,r,s,a,o){let l,c,u,h,d,p,m=r,g=r;const _=e.pid>-1,y=t.pid>-1,v=t.samples.length,b=e.samples.length>0,w=a&&v>0||v>1;if((!_||b)&&(!y||w)||this.ISGenerated||a){if(this.ISGenerated){var x,k,S,E;const e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(x=t.pixelRatio)?void 0:x[0])!==(null==(k=e.pixelRatio)?void 0:k[0])||(null==(S=t.pixelRatio)?void 0:S[1])!==(null==(E=e.pixelRatio)?void 0:E[1]))||!e&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,r,s));const n=this.isVideoContiguous;let i,a=-1;if(w&&(a=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!n&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,a>0){this.warn(`Dropped ${a} out of ${v} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else-1===a&&(this.warn(`No keyframe found out of ${v} video samples`),p=!1);if(this.ISGenerated){if(b&&w){const n=this.getVideoStartPts(t.samples),i=(Qr(e.samples[0].pts,n)-n)/t.inputTimeScale;m+=Math.max(0,i),g+=Math.max(0,-i)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,r,s)),c=this.remuxAudio(e,m,this.isAudioContiguous,s,y||w||o===f?g:void 0),w){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,r,s)),l=this.remuxVideo(t,g,n,i)}}else w&&(l=this.remuxVideo(t,g,n,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(d=es(n,r,this._initPTS,this._initDTS)),i.samples.length&&(h=ts(i,r,this._initPTS))),{audio:c,video:l,initSegment:u,independent:p,text:h,id3:d}}computeInitPts(e,t,n,i){const r=Math.round(n*t);let s=Qr(e,r);if(s<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-s)/t} ${i}`);s<r+t;)s+=8589934592;return s-r}generateIS(e,t,n,i){const r=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let c,u,h,d=!l||i,p="audio/mp4",f=-1;if(d&&(c=u=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(p="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}o.audio={id:"audio",container:p,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):qr.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(f=e.id,h=e.inputTimeScale,l&&h===l.timescale?d=!1:c=u=this.computeInitPts(r[0].pts,h,n,"audio"))}if(t.sps&&t.pps&&s.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:qr.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(f=t.id,h=t.inputTimeScale,l&&h===l.timescale)d=!1;else{const e=this.getVideoStartPts(s),t=Qr(s[0].dts,e),i=this.computeInitPts(t,h,n,"video"),r=this.computeInitPts(e,h,n,"video");u=Math.min(u,i),c=Math.min(c,r)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,d?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${n} ${c/h} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${c/h} (${c}/${h}) trackId: ${f}`),this._initPTS={baseTime:c,timescale:h,trackId:f},this._initDTS={baseTime:u,timescale:h,trackId:f}):c=h=void 0,{tracks:o,initPTS:c,timescale:h,trackId:f}}remuxVideo(e,t,n,i){const r=e.inputTimeScale,s=e.samples,c=[],u=s.length,h=this._initPTS,d=h.baseTime*r/h.timescale;let p,f,m=this.nextVideoTs,g=8,_=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,w=!1;if(!n||null===m){const e=d+t*r,i=s[0].pts-Qr(s[0].dts,s[0].pts);Zr&&null!==m&&Math.abs(e-i-(m+d))<15e3?n=!0:m=e-i-d}const x=m+d;for(let e=0;e<u;e++){const t=s[e];t.pts=Qr(t.pts,x),t.dts=Qr(t.dts,x),t.dts<s[e>0?e-1:e].dts&&(w=!0)}w&&s.sort((function(e,t){const n=e.dts-t.dts,i=e.pts-t.pts;return n||i})),p=s[0].dts,f=s[s.length-1].dts;const k=f-p,S=k?Math.round(k/(u-1)):_||e.inputTimeScale/30;if(n){const n=p-x,i=n>S,r=n<-1;if((i||r)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Hr(n,!0)} ms (${n}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Hr(-n,!0)} ms (${n}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!r||x>=s[0].pts||Zr)){p=x;const e=s[0].pts-n;if(i)s[0].dts=p,s[0].pts=e;else{let t=!0;for(let i=0;i<s.length&&!(s[i].dts>e&&t);i++){const e=s[i].pts;if(s[i].dts-=n,s[i].pts-=n,i<s.length-1){const n=s[i+1].pts;t=n<=s[i].pts==n<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${Hr(e,!0)}/${Hr(p,!0)}, delta: ${Hr(n,!0)} ms`)}}p=Math.max(0,p);let E=0,T=0,C=p;for(let e=0;e<u;e++){const t=s[e],n=t.units,i=n.length;let r=0;for(let e=0;e<i;e++)r+=n[e].data.length;T+=r,E+=i,t.length=r,t.dts<C?(t.dts=C,C+=S/4|0||1):C=t.dts,y=Math.min(t.pts,y),b=Math.max(t.pts,b)}f=s[u-1].dts;const L=T+4*E+8;let A;try{A=new Uint8Array(L)}catch(e){return void this.observer.emit(l.ERROR,l.ERROR,{type:a.MUX_ERROR,details:o.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating video mdat ${L}`})}const D=new DataView(A.buffer);D.setUint32(0,L),A.set(qr.types.mdat,4);let M=!1,R=Number.POSITIVE_INFINITY,I=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY;for(let e=0;e<u;e++){const t=s[e],n=t.units;let a,o=0;for(let e=0,t=n.length;e<t;e++){const t=n[e],i=t.data,r=t.data.byteLength;D.setUint32(g,r),g+=4,A.set(i,g),g+=r,o+=4+r}if(e<u-1)_=s[e+1].dts-t.dts,a=s[e+1].pts-t.pts;else{const n=this.config,o=e>0?t.dts-s[e-1].dts:S;if(a=e>0?t.pts-s[e-1].pts:S,n.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(n.maxBufferHole*r),s=(i?y+i*r:this.nextAudioTs+d)-t.pts;s>e?(_=s-o,_<0?_=o:M=!0,this.log(`It is approximately ${s/90} ms to the next segment; using duration ${_/90} ms for the last video frame.`)):_=o}else _=o}const l=Math.round(t.pts-t.dts);R=Math.min(R,_),P=Math.max(P,_),I=Math.min(I,a),O=Math.max(O,a),c.push(Xr(t.key,_,o,l))}if(c.length)if(Zr){if(Zr<70){const e=c[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Yr&&O-I<P-R&&S/P<.025&&0===c[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=p;for(let t=0,n=c.length;t<n;t++){const i=e+c[t].duration,r=e+c[t].cts;if(t<n-1){const e=i+c[t+1].cts;c[t].duration=e-r}else c[t].duration=t?c[t-1].duration:S;c[t].cts=0,e=i}}_=M||!_?S:_;const F=f+_;this.nextVideoTs=m=F-d,this.videoSampleDuration=_,this.isVideoContiguous=!0;const N={data1:qr.moof(e.sequenceNumber++,p,v(e,{samples:c})),data2:A,startPTS:(y-d)/r,endPTS:(b+_-d)/r,startDTS:(p-d)/r,endDTS:m/r,type:"video",hasAudio:!1,hasVideo:!0,nb:c.length,dropped:e.dropped};return e.samples=[],e.dropped=0,N}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,n,i,r){const s=e.inputTimeScale,c=s/(e.samplerate?e.samplerate:s),u=this.getSamplesPerFrame(e),h=u*c,d=this._initPTS,p="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],m=void 0!==r;let g=e.samples,_=p?0:8,y=this.nextAudioTs||-1;const b=d.baseTime*s/d.timescale,w=b+t*s;if(this.isAudioContiguous=n=n||g.length&&y>0&&(i&&Math.abs(w-(y+b))<9e3||Math.abs(Qr(g[0].pts,w)-(y+b))<20*h),g.forEach((function(e){e.pts=Qr(e.pts,w)})),!n||y<0){const e=g.length;if(g=g.filter((e=>e.pts>=0)),e!==g.length&&this.warn(`Removed ${g.length-e} of ${e} samples (initPTS ${b} / ${s})`),!g.length)return;y=0===r?0:i&&!m?Math.max(0,w-b):g[0].pts-b}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let n=0,i=y+b;n<g.length;n++){const r=g[n],a=r.pts,o=a-i,l=Math.abs(1e3*o/s);if(o<=-t*h&&m)0===n&&(this.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=y=a-b,i=a);else if(o>=t*h&&l<1e4&&m){let t=Math.round(o/h);for(i=a-t*h;i<0&&t&&h;)t--,i+=h;0===n&&(this.nextAudioTs=y=i-b),this.warn(`Injecting ${t} audio frames @ ${((i-b)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s<t;s++){let t=zr.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=r.unit.subarray()),g.splice(n,0,{unit:t,pts:i}),i+=h,n++}}r.pts=i,i+=h}}let x,k=null,S=null,E=0,T=g.length;for(;T--;)E+=g[T].unit.byteLength;for(let t=0,i=g.length;t<i;t++){const i=g[t],r=i.unit;let s=i.pts;if(null!==S){f[t-1].duration=Math.round((s-S)/c)}else{if(n&&"aac"===e.segmentCodec&&(s=y+b),k=s,!(E>0))return;E+=_;try{x=new Uint8Array(E)}catch(e){return void this.observer.emit(l.ERROR,l.ERROR,{type:a.MUX_ERROR,details:o.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:E,reason:`fail allocating audio mdat ${E}`})}if(!p){new DataView(x.buffer).setUint32(0,E),x.set(qr.types.mdat,4)}}x.set(r,_);const h=r.byteLength;_+=h,f.push(Xr(!0,u,h,0)),S=s}const C=f.length;if(!C)return;const L=f[f.length-1];y=S-b,this.nextAudioTs=y+c*L.duration;const A=p?new Uint8Array(0):qr.moof(e.sequenceNumber++,k/c,v({},e,{samples:f}));e.samples=[];const D=(k-b)/s,M=y/s,R={data1:A,data2:x,startPTS:D,endPTS:M,startDTS:D,endDTS:M,type:"audio",hasAudio:!0,hasVideo:!1,nb:C};return this.isAudioContiguous=!0,R}}function Qr(e,t){let n;if(null===t)return e;for(n=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=n;return e}function es(e,t,n,i){const r=e.samples.length;if(!r)return;const s=e.inputTimeScale;for(let a=0;a<r;a++){const r=e.samples[a];r.pts=Qr(r.pts-n.baseTime*s/n.timescale,t*s)/s,r.dts=Qr(r.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function ts(e,t,n){const i=e.samples.length;if(!i)return;const r=e.inputTimeScale;for(let s=0;s<i;s++){const i=e.samples[s];i.pts=Qr(i.pts-n.baseTime*r/n.timescale,t*r)/r}e.samples.sort(((e,t)=>e.pts-t.pts));const s=e.samples;return e.samples=[],{samples:s}}function ns(e,t,n=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(n?e.duration:0))/e.timescale:t}function is(e,t,n){const i=e.codec;if(i&&i.length>4)return i;if(t===q){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return Pe(i,!1)}return n.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return n.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{Wr=self.performance.now.bind(self.performance)}catch(e){Wr=Date.now}const rs=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,n,i){const r=this.videoTrack=hr("video",1),s=this.audioTrack=hr("audio",1),a=this.txtTrack=hr("text",1);if(this.id3Track=hr("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=le(e);if(o.video){const{id:e,timescale:t,codec:n,supplemental:i}=o.video;r.id=e,r.timescale=a.timescale=t,r.codec=n,r.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:n}=o.audio;s.id=e,s.timescale=t,s.codec=n}a.id=ee.text,r.sampleDuration=0,r.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let n=0;n<t;){const i=ie(e,n);if(i>8&&109===e[n+4]&&111===e[n+5]&&111===e[n+6]&&102===e[n+7])return!0;n=i>1?n+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let n=e;const i=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(n=ge(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},n=ae(e,["moof"]);if(n.length<2)return t.remainder=e,t;const i=n[n.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(n);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=n;const s=this.extractID3Track(i,t);return r.samples=_e(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,n=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return n.samples=_e(e,t),{videoTrack:t,audioTrack:hr(),id3Track:i,textTrack:hr()}}extractID3Track(e,t){const n=this.id3Track;if(e.samples.length){const i=ae(e.samples,["emsg"]);i&&i.forEach((e=>{const i=function(e){const t=e[0];let n="",i="",s=0,a=0,o=0,l=0,c=0,u=0;if(0===t){for(;"\0"!==te(e.subarray(u,u+1));)n+=te(e.subarray(u,u+1)),u+=1;for(n+=te(e.subarray(u,u+1)),u+=1;"\0"!==te(e.subarray(u,u+1));)i+=te(e.subarray(u,u+1)),u+=1;i+=te(e.subarray(u,u+1)),u+=1,s=ie(e,12),a=ie(e,16),l=ie(e,20),c=ie(e,24),u=28}else if(1===t){u+=4,s=ie(e,u),u+=4;const t=ie(e,u);u+=4;const a=ie(e,u);for(u+=4,o=2**32*t+a,r(o)||(o=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=ie(e,u),u+=4,c=ie(e,u),u+=4;"\0"!==te(e.subarray(u,u+1));)n+=te(e.subarray(u,u+1)),u+=1;for(n+=te(e.subarray(u,u+1)),u+=1;"\0"!==te(e.subarray(u,u+1));)i+=te(e.subarray(u,u+1)),u+=1;i+=te(e.subarray(u,u+1)),u+=1}return{schemeIdUri:n,value:i,timeScale:s,presentationTime:o,presentationTimeDelta:a,eventDuration:l,id:c,payload:e.subarray(u,e.byteLength)}}(e);if(Cr.test(i.schemeIdUri)){const e=Lr(i,t);let r=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const s=i.payload;n.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:ur.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=Lr(i,t);n.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:ur.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return n}demuxSampleAes(e,t,n){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends x{constructor(e,t,n,i){super("passthrough-remuxer",i),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,n,i){this.audioCodec=t,this.videoCodec=n,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:n,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:r,video:s}=this.initData=le(e);if(t)!function(e,t){if(!e||!t)return;const n=t.keyId;n&&t.isCommonEncryption&&fe(e,((e,t)=>{const i=e.subarray(8,24);i.some((e=>0!==e))||(L.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${R(i)} -> ${R(n)}`),e.set(n,8))}))}(e,t);else{const e=r||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}r&&(n=is(r,q,this)),s&&(i=is(s,G,this));const a={};r&&s?a.audiovideo={container:"video/mp4",codec:n+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:r?a.audio={container:"audio/mp4",codec:n,encrypted:r.encrypted,initSegment:e,id:"audio"}:s?a.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,n,r,s,a){var o,l;let{initPTS:c,lastEndTime:u}=this;const h={audio:void 0,video:void 0,text:r,id3:n,initSegment:void 0};i(u)||(u=this.lastEndTime=s||0);const d=t.samples;if(!d.length)return h;const p={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(o=f)&&o.length||(this.generateInitSegment(d),f=this.initData),null==(l=f)||!l.length)return this.warn("Failed to generate initSegment."),h;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);const m=function(e,t,n){const r={},s=ae(e,["moof","traf"]);for(let e=0;e<s.length;e++){const a=s[e],o=ae(a,["tfhd"])[0],l=ie(o,4),c=t[l];if(!c)continue;r[l]||(r[l]={start:NaN,duration:0,sampleCount:0,timescale:c.timescale,type:c.type});const u=r[l],h=ae(a,["tfdt"])[0];if(h){const e=h[0];let t=ie(h,4);1===e&&(t===J?n.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=J+1,t+=ie(h,8))),i(t)&&(!i(u.start)||t<u.start)&&(u.start=t)}const d=c.default,p=ie(o,0)|(null==d?void 0:d.flags);let f=(null==d?void 0:d.duration)||0;8&p&&(f=ie(o,2&p?12:8));const m=ae(a,["trun"]);let g=u.start||0,_=0,y=f;for(let e=0;e<m.length;e++){const t=m[e],n=ie(t,4),i=u.sampleCount;u.sampleCount+=n;const r=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],c=8&t[2];let h=8,d=n;for(r&&(h+=4),s&&n&&(1&t[h+1]||void 0!==u.keyFrameIndex||(u.keyFrameIndex=i),h+=4,a?(y=ie(t,h),h+=4):y=f,o&&(h+=4),c&&(h+=4),g+=y,_+=y,d--);d--;)a?(y=ie(t,h),h+=4):y=f,o&&(h+=4),l&&(1&t[h+1]||void 0===u.keyFrameIndex&&(u.keyFrameIndex=u.sampleCount-(d+1),u.keyFrameStart=g),h+=4),c&&(h+=4),g+=y,_+=y;!_&&f&&(_+=f*n)}u.duration+=_}if(!Object.keys(r).some((e=>r[e].duration))){let t=1/0,n=0;const s=ae(e,["sidx"]);for(let e=0;e<s.length;e++){const i=oe(s[e]);if(null!=i&&i.references){t=Math.min(t,i.earliestPresentationTime/i.timescale);const e=i.references.reduce(((e,t)=>e+t.info.duration||0),0);n=Math.max(n,e+i.earliestPresentationTime/i.timescale)}}n&&i(n)&&Object.keys(r).forEach((e=>{r[e].duration||(r[e].duration=n*r[e].timescale-r[e].start)}))}return r}(d,f,this),g=f.audio?m[f.audio.id]:null,_=f.video?m[f.video.id]:null,y=ns(_,1/0),v=ns(g,1/0),b=ns(_,0,!0),w=ns(g,0,!0);let x=s,k=0;const S=g&&(!_||!c&&v<y||c&&c.trackId===f.audio.id),E=S?g:_;if(E){const e=E.timescale,t=E.start-s*e,n=S?f.audio.id:f.video.id;x=E.start/e,k=S?w-v:b-y,!a&&c||!function(e,t,n,i){if(null===e)return!0;const r=Math.max(i,1),s=t-e.baseTime/e.timescale;return Math.abs(s-n)>r}(c,x,s,k)&&e===c.timescale||(c&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${s} ${t/e} != initPTS: ${c.baseTime/c.timescale} (${c.baseTime}/${c.timescale}) trackId: ${c.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${x-s} (${t}/${e}) trackId: ${n}`),c=null,p.initPTS=t,p.timescale=e,p.trackId=n)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${s}`);c?(p.initPTS=c.baseTime,p.timescale=c.timescale,p.trackId=c.trackId):(p.timescale&&void 0!==p.trackId&&void 0!==p.initPTS||(this.warn("Could not set initPTS"),p.initPTS=x,p.timescale=1,p.trackId=-1),this.initPTS=c={baseTime:p.initPTS,timescale:p.timescale,trackId:p.trackId});const T=x-c.baseTime/c.timescale,C=T+k;k>0?this.lastEndTime=C:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const L=!!f.audio,A=!!f.video;let D="";L&&(D+="audio"),A&&(D+="video");const M={data1:d,startPTS:T,startDTS:T,endPTS:C,endDTS:C,type:D,hasAudio:L,hasVideo:A,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};h.audio=L&&!A?M:void 0,h.video=A?M:void 0;const R=null==_?void 0:_.sampleCount;if(R){const e=_.keyFrameIndex,t=-1!==e;M.nb=R,M.dropped=0===e||this.isVideoContiguous?0:t?e:R,M.independent=t,M.firstKeyFrame=e,t&&_.keyFrameStart&&(M.firstKeyFramePTS=(_.keyFrameStart-c.baseTime)/c.timescale),this.isVideoContiguous||(h.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),M.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${R} dropped: ${M.dropped} start: ${M.firstKeyFramePTS||"NA"}`)}return h.initSegment=p,h.id3=es(n,s,c,c),r.samples.length&&(h.text=ts(r,s,c)),h}}},{demux:Or,remux:Jr},{demux:class extends dr{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const n=Hi(e,0);let i=(null==n?void 0:n.length)||0;if(kr(e,i))return!1;for(let n=e.length;i<n;i++)if(Xi(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&ji(e,t)&&Zi(e,t)<=e.length-t}(e,t)}appendFrame(e,t,n){Ji(e,this.observer,t,n,e.manifestCodec);const i=er(e,t,n,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Jr},{demux:class extends dr{resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Hi(e,0);let n=(null==t?void 0:t.length)||0;if(t&&11===e[n]&&119===e[n+1]&&void 0!==cr(t)&&Sr(e,n)<=16)return!1;for(let t=e.length;n<t;n++)if(kr(e,n))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return wr(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,n){if(null!==this.basePTS)return vr(e,t,n,this.basePTS,this.frameIndex)}},remux:Jr}];rs.splice(2,0,{demux:Er,remux:Jr});class ss{constructor(e,t,n,i,r,s){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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.observer=e,this.typeSupported=t,this.config=n,this.id=r,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,n,i){const r=n.transmuxing;r.executeStart=Wr();let s=new Uint8Array(e);const{currentTransmuxState:c,transmuxConfig:u}=this;i&&(this.currentTransmuxState=i);const{contiguous:h,discontinuity:d,trackSwitch:p,accurateTimeOffset:f,timeOffset:m,initSegmentChange:g}=i||c,{audioCodec:_,videoCodec:y,defaultInitPts:v,duration:b,initSegmentData:w}=u,x=function(e,t){let n=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(n=t);return n}(s,t);if(x&&_n(x.method)){const e=this.getDecrypter(),t=yn(x.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(s,x.key.buffer,x.iv.buffer,t).then((e=>{const t=this.push(e,null,n);return this.decryptionPromise=null,t})),this.decryptionPromise;{let i=e.softwareDecrypt(s,x.key.buffer,x.iv.buffer,t);if(n.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return r.executeEnd=Wr(),as(n);s=new Uint8Array(i)}}const k=this.needsProbing(d,p);if(k){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),r.executeEnd=Wr(),as(n)}(d||p||g||k)&&this.resetInitSegment(w,_,y,b,t),(d||g||k)&&this.resetInitialTimestamp(v),h||this.resetContiguity();const S=this.transmux(s,x,m,f,n);this.asyncResult=os(S);const E=this.currentTransmuxState;return E.contiguous=!0,E.discontinuity=!1,E.trackSwitch=!1,r.executeEnd=Wr(),S}flush(e){const t=e.transmuxing;t.executeStart=Wr();const{decrypter:n,currentTransmuxState:i,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then((()=>this.flush(e)));const s=[],{timeOffset:a}=i;if(n){const t=n.flush();t&&s.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=Wr();const n=[as(e)];return this.asyncResult?Promise.resolve(n):n}const c=o.flush(a);return os(c)?(this.asyncResult=!0,c.then((t=>(this.flushRemux(s,t,e),s)))):(this.flushRemux(s,c,e),this.asyncResult?Promise.resolve(s):s)}flushRemux(e,t,n){const{audioTrack:i,videoTrack:r,id3Track:s,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${n.sn}${n.part>-1?" part: "+n.part:""} of ${this.id===p?"level":"track"} ${n.level}`);const c=this.remuxer.remux(i,r,s,a,l,o,!0,this.id);e.push({remuxResult:c,chunkMeta:n}),n.transmuxing.executeEnd=Wr()}resetInitialTimestamp(e){const{demuxer:t,remuxer:n}=this;t&&n&&(t.resetTimeStamp(e),n.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,n,i,r){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,n,i),a.resetInitSegment(e,t,n,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,n,i,r){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,n,i,r):this.transmuxUnencrypted(e,n,i,r),s}transmuxUnencrypted(e,t,n,i){const{audioTrack:r,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,s,a,o,t,n,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,n,i,r){return this.demuxer.demuxSampleAes(e,t,n).then((e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,n,i,!1,this.id),chunkMeta:r})))}configureTransmuxer(e){const{config:t,observer:n,typeSupported:i}=this;let r;for(let t=0,n=rs.length;t<n;t++){var s;if(null!=(s=rs[t].demux)&&s.probe(e,this.logger)){r=rs[t];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=r.remux,c=r.demux;o&&o instanceof l||(this.remuxer=new l(n,t,i,this.logger)),a&&a instanceof c||(this.demuxer=new c(n,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new jt(this.config)),e}}const as=e=>({remuxResult:{},chunkMeta:e});function os(e){return"then"in e&&e.then instanceof Function}class ls{constructor(e,t,n,i,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=n,this.duration=i,this.defaultInitPts=r||null}}class cs{constructor(e,t,n,i,r,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=n,this.trackSwitch=i,this.timeOffset=r,this.initSegmentChange=s}}let us=0;class hs{constructor(e,t,n,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=us++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{const t=e.data,n=this.hls;if(n&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":n.logger[t.data.logType]&&n.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,n.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;const t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=n,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===l.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Ki,this.observer.on(l.FRAG_DECRYPTED,s),this.observer.on(l.ERROR,s);const c=Be(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const n=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(n.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=function(e){const t=zi[e];if(t)return t.clientCount++,t;const n=new self.URL(e,self.location.href).href,i={worker:new self.Worker(n),scriptURL:n,clientCount:1};return zi[e]=i,i}(r.workerPath)):(n.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=zi[Ui];if(e)return e.clientCount++,e;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),n=self.URL.createObjectURL(t),i={worker:new self.Worker(n),objectURL:n,clientCount:1};return zi[Ui]=i,i}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:c,id:t,config:it(r)})}catch(i){n.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new ss(this.observer,c,r,"",t,e.logger)}return}}this.transmuxer=new ss(this.observer,c,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=us++;const t=this.hls.config,n=Be(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:n,id:this.id,config:it(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){const t=zi[e||Ui];if(t&&1==t.clientCount--){const{worker:n,objectURL:i}=t;delete zi[e||Ui],i&&self.URL.revokeObjectURL(i),n.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,n,i,r,s,a,o,l,c){var u,h;l.transmuxing.start=self.performance.now();const{instanceNo:d,transmuxer:f}=this,m=s?s.start:r.start,g=r.decryptdata,_=this.frag,y=!(_&&r.cc===_.cc),v=!(_&&l.level===_.level),b=_?l.sn-_.sn:-1,w=this.part?l.part-this.part.index:-1,x=0===b&&l.id>1&&l.id===(null==_?void 0:_.stats.chunkCount),k=!v&&(1===b||0===b&&(1===w||x&&w<=0)),S=self.performance.now();(v||b||0===r.stats.parsing.start)&&(r.stats.parsing.start=S),!s||!w&&k||(s.stats.parsing.start=S);const E=!(_&&(null==(u=r.initSegment)?void 0:u.url)===(null==(h=_.initSegment)?void 0:h.url)),T=new cs(y,k,o,v,m,E);if(!k||y||E){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===p?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${y}\n trackSwitch: ${v}\n contiguous: ${k}\n accurateTimeOffset: ${o}\n timeOffset: ${m}\n initSegmentChange: ${E}`);const e=new ls(n,i,t,a,c);this.configureTransmuxer(e)}if(this.frag=r,this.part=s,this.workerContext)this.workerContext.worker.postMessage({instanceNo:d,cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:T},e instanceof ArrayBuffer?[e]:[]);else if(f){const t=f.push(e,g,l,T);os(t)?t.then((e=>{this.handleTransmuxComplete(e)})).catch((e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:n}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(n){const t=n.flush(e);os(t)?t.then((t=>{this.handleFlushResult(t,e)})).catch((t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")})):this.handleFlushResult(t,e)}}transmuxerError(e,t,n){this.hls&&(this.error=e,this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:n}))}handleFlushResult(e,t){e.forEach((e=>{this.handleTransmuxComplete(e)})),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:n}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):n&&n.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class ds extends x{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,n){const i=null==t?void 0:t.renditionReports;if(i){let r=-1;for(let n=0;n<i.length;n++){const s=i[n];let a;try{a=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=s.URI||""}if(a===e){r=n;break}a===e.substring(0,a.length)&&(r=n)}if(-1!==r){const e=i[r],s=parseInt(e["LAST-MSN"])||t.lastPartSn;let a=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=n&&Je(n);return new Qe(s,a>=0?a:void 0,o)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,n){const{details:i,stats:r}=t,s=self.performance.now(),c=r.loading.first?Math.max(0,s-r.loading.first):0;i.advancedDateTime=Date.now()-c;const u=this.hls.config.timelineOffset;if(u!==i.appliedTimelineOffset){const e=Math.max(u||0,0);i.appliedTimelineOffset=e,i.fragments.forEach((t=>{t.setStart(t.playlistOffset+e)}))}if(i.live||null!=n&&n.live){const u="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(n),n&&i.fragments.length>0){ii(n,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const n=this.hls;if(!n.config.ignorePlaylistParsingErrors){var h;const{networkDetails:s}=t;return void n.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(h=i.fragments[0])?void 0:h.type,networkDetails:s,stats:r})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=r.loading.start);const d=this.hls.mainForwardBufferInfo,p=d?d.end-d.len:0,f=oi(i,1e3*(i.edge-p));if(i.requestScheduled+f<s?i.requestScheduled=s:i.requestScheduled+=f,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;let m,g,_;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,r=i.lastPartSn,a=i.endSN,o=i.lastPartIndex,l=r===a;-1!==o?l?(g=a+1,_=e?0:o):(g=r,_=e?o+1:i.maxPartIndex):g=a+1;const c=i.age,h=c+i.ageHeader;let d=Math.min(h-i.partTarget,1.5*i.targetduration);if(d>0){if(h>3*i.targetduration)this.log(`Playlist last advanced ${c.toFixed(2)}s ago. Omitting segment and part directives.`),g=void 0,_=void 0;else if(null!=n&&n.tuneInGoal&&h-i.partTarget>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${d} with playlist age: ${i.age}`),d=0;else{const e=Math.floor(d/i.targetduration);if(g+=e,void 0!==_){_+=Math.round(d%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${c.toFixed(2)}s goal: ${d} skip sn ${e} to part ${_}`)}i.tuneInGoal=d}if(m=this.getDeliveryDirectives(i,t.deliveryDirectives,g,_),e||!l)return i.requestScheduled=s,void this.loadingPlaylist(u,m)}else(i.canBlockReload||i.canSkipUntil)&&(m=this.getDeliveryDirectives(i,t.deliveryDirectives,g,_));m&&void 0!==g&&i.canBlockReload&&(i.requestScheduled=r.loading.first+Math.max(f-2*c,f/2)),this.scheduleLoading(u,m,i)}else this.clearTimer()}scheduleLoading(e,t,n){const i=n||e.details;if(!i)return void this.loadingPlaylist(e,t);const r=self.performance.now(),s=i.requestScheduled;if(r>=s)return void this.loadingPlaylist(e,t);const a=s-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout((()=>this.loadingPlaylist(e,t)),a)}getDeliveryDirectives(e,t,n,i){let r=Je(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(n=t.msn,i=t.part,r=Ze),new Qe(n,i,r)}checkRetry(e){const t=e.details,n=_t(e),i=e.errorAction,{action:r,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(r===Lt||!i.resolved&&r===Tt);if(o){var l;if(s>=a.maxNumRetry)return!1;if(n&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=wt(a,s);this.clearTimer(),this.timer=self.setTimeout((()=>this.loadPlaylist()),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function ps(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!fs(e[n].attrs,t[n].attrs))return!1;return!0}function fs(e,t,n){const i=e["STABLE-RENDITION-ID"];return i&&!n?i===t["STABLE-RENDITION-ID"]:!(n||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((n=>e[n]!==t[n]))}function ms(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class gs{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,n){if(null===this.queues||null===this.tracks)return;const i=this.queues[t];i.push(e),1!==i.length||n||this.executeNext(t)}appendBlocker(e){return new Promise((t=>{const n={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(n,e)}))}prependBlocker(e){return new Promise((t=>{if(this.queues){const n={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(n)}}))}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach((e=>{var t;const n=null==(t=e[0])?void 0:t.label;"async-blocker"!==n&&"async-blocker-prepend"!==n||(e[0].execute(),e.splice(0,1))}))}unblockAudio(e){if(null===this.queues)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){var n;if(i.onError(t),null===this.queues||null===this.tracks)return;const r=null==(n=this.tracks[e])?void 0:n.buffer;null!=r&&r.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(e){var t,n;return null!=(t=this.queues)&&t[e]||null!=(n=this.tracks)&&n[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const n=null==(t=this.tracks)?void 0:t[e],i=null==n?void 0:n.buffer;return i?`SourceBuffer${i.updating?" updating":""}${n.ended?" ended":""}${n.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map((e=>e.label)).join(", "))||""}}const _s=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,ys="HlsJsTrackRemovedError";class vs extends Error{constructor(e){super(e),this.name=ys}}function bs(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach((t=>{e.removeChild(t)}))}function ws(e){return"audio"===e?1:0}class xs{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(l.BUFFER_CODECS,this.onBufferCodecs,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(l.BUFFER_CODECS,this.onBufferCodecs,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const n=this.hls.levels[t.droppedLevel];this.isLevelAllowed(n)&&this.restrictedLevels.push({bitrate:n.bitrate,height:n.height,width:n.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const n=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,n.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&i(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,n=this.getMaxLevel(e.length-1);n!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${n}: ${e[n].height}p@${e[n].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=n,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const n=t.filter(((t,n)=>this.isLevelAllowed(t)&&n<=e));return this.clientRect=null,xs.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const n=e.getBoundingClientRect();t.width=n.width,t.height=n.height,t.width||t.height||(t.width=n.right-n.left||e.width||0,t.height=n.bottom-n.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some((t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height))}static getMaxLevelByMediaSize(e,t,n){if(null==e||!e.length)return-1;let i=e.length-1;const r=Math.max(t,n);for(let t=0;t<e.length;t+=1){const n=e[t];if((n.width>=r||n.height>=r)&&(s=n,!(a=e[t+1])||s.width!==a.width||s.height!==a.height)){i=t;break}}var s,a;return i}}const ks={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Ss={HLS:"h"};class Es{constructor(e,t){Array.isArray(e)&&(e=e.map((e=>e instanceof Es?e:new Es(e)))),this.value=e,this.params=t}}function Ts(e,t,n,i){return new Error(`failed to ${e} "${r=t,Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":"object"==typeof r?JSON.stringify(r):String(r)}" as ${n}`,{cause:i});var r}function Cs(e,t,n){return Ts("serialize",e,t,n)}class Ls{constructor(e){this.description=e}}const As="Bare Item";function Ds(e){if(!1===ArrayBuffer.isView(e))throw Cs(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function Ms(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw Cs(e,"Integer");return e.toString()}function Rs(e,t){if(e<0)return-Rs(-e,t);const n=Math.pow(10,t);if(Math.abs(e*n%1-.5)<Number.EPSILON){const t=Math.floor(e*n);return(t%2==0?t:t+1)/n}return Math.round(e*n)/n}function Is(e){const t=Rs(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Cs(e,"Decimal");const n=t.toString();return n.includes(".")?n:`${n}.0`}const Ps=/[\x00-\x1f\x7f]+/;function Os(e){const t=(n=e).description||n.toString().slice(7,-1);var n;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Cs(t,"Token");return t}function Fs(e){switch(typeof e){case"number":if(!i(e))throw Cs(e,As);return Number.isInteger(e)?Ms(e):Is(e);case"string":return function(e){if(Ps.test(e))throw Cs(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return Os(e);case"boolean":return function(e){if("boolean"!=typeof e)throw Cs(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${Ms(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return Ds(e);if(e instanceof Ls)return Os(e);default:throw Cs(e,As)}}function Ns(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Cs(e,"Key");return e}function Bs(e){return null==e?"":Object.entries(e).map((([e,t])=>!0===t?`;${Ns(e)}`:`;${Ns(e)}=${Fs(t)}`)).join("")}function $s(e){return e instanceof Es?`${Fs(e.value)}${Bs(e.params)}`:Fs(e)}function Ks(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw Cs(e,"Dict");const n=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(n).map((([e,t])=>{t instanceof Es==!1&&(t=new Es(t));let n=Ns(e);var i;return!0===t.value?n+=Bs(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map($s).join(" ")})${Bs(i.params)}`:n+=$s(t)),n})).join(`,${i}`)}function Us(e,t){return Ks(e,t)}const zs="CMCD-Object",Vs="CMCD-Request",qs="CMCD-Session",Gs="CMCD-Status",Hs={br:zs,ab:zs,d:zs,ot:zs,tb:zs,tpb:zs,lb:zs,tab:zs,lab:zs,url:zs,pb:Vs,bl:Vs,tbl:Vs,dl:Vs,ltc:Vs,mtp:Vs,nor:Vs,nrr:Vs,rc:Vs,sn:Vs,sta:Vs,su:Vs,ttfb:Vs,ttfbb:Vs,ttlb:Vs,cmsdd:Vs,cmsds:Vs,smrt:Vs,df:Vs,cs:Vs,ts:Vs,cid:qs,pr:qs,sf:qs,sid:qs,st:qs,v:qs,msd:qs,bs:Gs,bsd:Gs,cdn:Gs,rtp:Gs,bg:Gs,pt:Gs,ec:Gs,e:Gs},js=Vs;function Ws(e,t){const n={};if(!e)return n;const i=Object.keys(e),r=t?(s=t,Object.keys(s).reduce(((e,t)=>{var n;return null===(n=s[t])||void 0===n||n.forEach((n=>e[n]=t)),e}),{})):{};var s;return i.reduce(((t,n)=>{var i;const s=Hs[n]||r[n]||js;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[n]=e[n],t}),n)}const Zs="event";const Ys=e=>Math.round(e),Xs=(e,t)=>Array.isArray(e)?e.map((e=>Xs(e,t))):e instanceof Es&&"string"==typeof e.value?new Es(Xs(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){const n=new URL(e),i=new URL(t);if(n.origin!==i.origin)return e;const r=n.pathname.split("/").slice(1),s=i.pathname.split("/").slice(1,-1);for(;r[0]===s[0];)r.shift(),s.shift();for(;s.length;)s.shift(),r.unshift("..");return r.join("/")+n.search+n.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),Js=e=>100*Ys(e/100),Qs={br:Ys,d:Ys,bl:Js,dl:Js,mtp:Js,nor:(e,t)=>{let n=e;return t.version>=2&&(e instanceof Es&&"string"==typeof e.value?n=new Es([e]):"string"==typeof e&&(n=[e])),Xs(n,t)},rtp:Js,tb:Ys},ea="request",ta="response",na=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],ia=["e"],ra=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function sa(e){return ra.test(e)}const aa=["d","dl","nor","ot","rtp","su"];const oa=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const la=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function ca(e){return la.includes(e)||sa(e)}const ua={[ta]:function(e){return na.includes(e)||aa.includes(e)||oa.includes(e)||sa(e)},[Zs]:function(e){return na.includes(e)||ia.includes(e)||sa(e)},[ea]:function(e){return na.includes(e)||aa.includes(e)||sa(e)}};function ha(e,t={}){const n={};if(null==e||"object"!=typeof e)return n;const r=t.version||e.v||1,s=t.reportingMode||ea,a=1===r?ca:ua[s];let o=Object.keys(e).filter(a);const l=t.filter;"function"==typeof l&&(o=o.filter(l));const c=s===ta||s===Zs;c&&!o.includes("ts")&&o.push("ts"),r>1&&!o.includes("v")&&o.push("v");const u=v({},Qs,t.formatters),h={version:r,reportingMode:s,baseUrl:t.baseUrl};return o.sort().forEach((t=>{let s=e[t];const a=u[t];if("function"==typeof a&&(s=a(s,h)),"v"===t){if(1===r)return;s=r}"pr"==t&&1===s||(c&&"ts"===t&&!i(s)&&(s=Date.now()),function(e){return"number"==typeof e?i(e):null!=e&&""!==e&&!1!==e}(s)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof s&&(s=new Ls(s)),n[t]=s))})),n}function da(e,t,n){return v(e,function(e,t={}){const n={};if(!e)return n;const i=Ws(ha(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce(((e,[t,n])=>{const i=Us(n,{whitespace:!1});return i&&(e[t]=i),e}),n)}(t,n))}function pa(e,t={}){if(!e)return"";const n=function(e,t={}){return e?Us(ha(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(n)}const fa=/CMCD=[^&#]+/;function ma(e,t,n){const i=function(e,t={}){return e?`CMCD=${pa(e,t)}`:""}(t,n);if(!i)return e;if(fa.test(e))return e.replace(fa,i);const r=e.includes("?")?"&":"?";return`${e}${r}${i}`}function ga(e,t,n,i){e&&Object.keys(t).forEach((r=>{const s=e.filter((e=>e.groupId===r)).map((e=>{const s=v({},e);return s.details=void 0,s.attrs=new hn(s.attrs),s.url=s.attrs.URI=_a(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),s.groupId=s.attrs["GROUP-ID"]=t[r],s.attrs["PATHWAY-ID"]=i,s}));e.push(...s)}))}function _a(e,t,n,i){const{HOST:r,PARAMS:s,[n]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return r&&!o&&(l.host=r),s&&Object.keys(s).sort().forEach((e=>{e&&l.searchParams.set(e,s[e])})),l.href}class ya extends x{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=ya.CDMCleanupPromise?[ya.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{const{initDataType:t,initData:n}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null!==n){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=Mn(this.config));const t=e.map(Dn).filter((e=>!!e));this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then((r=>{const s=An(r);if("sinf"!==t||s!==Sn.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=te(new Uint8Array(n)),t=me(vn(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}const o=R(a),{keyIdToKeySessionPromise:l,mediaKeySessions:c}=this;let u=l[o];for(let e=0;e<c.length;e++){const i=c[e],r=i.decryptdata;if(!r.keyId)continue;const s=R(r.keyId);if(mn(a,r.keyId)||-1!==r.uri.replace(/-/g,"").indexOf(o)){if(u=l[s],!u)continue;if(r.pssh)break;delete l[s],r.pssh=new Uint8Array(n),r.keyId=a,u=l[o]=u.then((()=>this.generateRequestWithPreferredKeySession(i,t,n,"encrypted-event-key-match"))),u.catch((e=>this.handleError(e)));break}}u||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${c.length}.`))})).catch((e=>this.handleError(e)))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(l.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(l.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:n}=this.config,i=null==t?void 0:t[e];return i?i.licenseUrl:e===Sn.WIDEVINE&&n?n:void 0}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,n=null==t?void 0:t[e];if(n)return n.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,n=(e,t,n)=>!!e&&n.indexOf(e)===t,i=t.map((e=>e.audioCodec)).filter(n),r=t.map((e=>e.videoCodec)).filter(n);return i.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((t,n)=>{const s=e=>{const l=e.shift();this.getMediaKeysPromise(l,i,r).then((e=>t({keySystem:l,mediaKeys:e}))).catch((t=>{e.length?s(e):n(t instanceof wa?t:new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))};s(e)}))}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:n}=this.config;if("function"!=typeof n){let e=`Configured requestMediaKeySystemAccess is not a function ${n}`;return null===Rn&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return n(e,t)}getMediaKeysPromise(e,t,n){var i;const r=function(e,t,n,i){let r;switch(e){case Sn.FAIRPLAY:r=["cenc","sinf"];break;case Sn.WIDEVINE:case Sn.PLAYREADY:r=["cenc"];break;case Sn.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,n,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map((e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}))),videoCapabilities:n.map((e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null})))}]}(r,t,n,i)}(e,t,n,this.config.drmSystemOptions||{});let s=this.keySystemAccessPromises[e],a=null==(i=s)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${it(r)}`),a=this.requestMediaKeySystemAccess(e,r);const t=s=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch((t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)})),a.then((n=>{this.log(`Access for key-system "${n.keySystem}" obtained`);const i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const r=t.mediaKeys=n.createMediaKeys().then((n=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,i.then((t=>t?this.setMediaKeysServerCertificate(n,e,t):n)))));return r.catch((t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)})),r}))}return a.then((()=>s.mediaKeys))}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:n}){this.log(`Creating key-system session "${t}" keyId: ${R(e.keyId||[])} keyUri: ${e.uri}`);const i=n.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:n,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const n=this.createMediaKeySessionContext(e),i=va(t),r="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(n,r,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const n=e.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyId ${R(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),n.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map((e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys}))).filter((({hasMediaKeys:e})=>!!e)).map((({keySystem:e})=>Dn(e))).filter((e=>!!e))}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then((({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t)))}selectKeySystem(e){return new Promise(((t,n)=>{this.getKeySystemSelectionPromise(e).then((({keySystem:e})=>{const i=Dn(e);i?t(i):n(new Error(`Unable to find format for key-system "${e}"`))})).catch(n)}))}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=Mn(this.config),n=e.map(An).filter((e=>!!e&&-1!==t.indexOf(e)));return this.selectKeySystem(n)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let n=0;n<t.length;n++){const i=ba(e,t[n]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,n=va(t),i=this.bannedKeyIds[n];if(i||"internal-error"===this.getKeyStatus(t)){const n=xa(i||"internal-error",t);return this.handleError(n,e.frag),Promise.reject(n)}const r=`(keyId: ${n} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const s=this.keyIdToKeySessionPromise[n];if(!s){const i=this.getKeySystemForKeyPromise(t).then((({keySystem:n,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(n,i).then((()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:n,mediaKeys:i,decryptdata:t}))))))).then((e=>{const n=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",n,"playlist-key")}));return i.catch((t=>this.handleError(t,e.frag))),this.keyIdToKeySessionPromise[n]=i,i}return s.catch((n=>{if(n instanceof wa){const i=w({},n.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const r=new wa(i,n.message);this.handleError(r,e.frag)}})),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof wa){t&&(e.data.frag=t);const n=e.data.decryptdata;this.error(`${e.message}${n?` (${R(n.keyId||[])})`:""}`),this.hls.trigger(l.ERROR,e.data)}else this.error(e.message),this.hls.trigger(l.ERROR,{type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=va(e),n=this.keyIdToKeySessionPromise[t];if(!n){const t=An(e.keyFormat),n=t?[t]:Mn(this.config);return this.attemptKeySystemAccess(n)}return n}getKeySystemSelectionPromise(e){if(e.length||(e=Mn(this.config)),0===e.length)throw new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${it({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaKeys===t)return Promise.resolve();const n=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(n).then((()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then((()=>{this.log(`Media-keys set for "${e}"`),n.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((e=>-1===n.indexOf(e)))}))}generateRequestWithPreferredKeySession(e,t,n,i){var r;const s=null==(r=this.config.drmSystems)||null==(r=r[e.keySystem])?void 0:r.generateRequest;if(s)try{const i=s.call(this.hls,t,n,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,n=i.initData?i.initData:null,e.decryptdata.pssh=n?new Uint8Array(n):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===n)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const l=va(e.decryptdata),c=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${l} URI: ${c} (init data type: ${t} length: ${n.byteLength})`);const u=new Ki,h=e._onmessage=t=>{const n=e.mediaKeysSession;if(!n)return void u.emit("error",new Error("invalid state"));const{messageType:i,message:r}=t;this.log(`"${i}" message event for session "${n.sessionId}" message size: ${r.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,r).catch((e=>{u.eventNames().length?u.emit("error",e):this.handleError(e)})):"license-release"===i?e.keySystem===Sn.FAIRPLAY&&this.updateKeySession(e,bn("acknowledged")).then((()=>this.removeSession(e))).catch((e=>this.handleError(e))):this.warn(`unhandled media key message type "${i}"`)},d=(e,t)=>{let n;t.keyStatus=e,e.startsWith("usable")?u.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?n=xa(e,t.decryptdata):"expired"===e?n=new Error(`key expired (keyId: ${l})`):"released"===e?n=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${l})`),n&&(u.eventNames().length?u.emit("error",n):this.handleError(n))},p=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void u.emit("error",new Error("invalid state"));const n=this.getKeyStatuses(e);if(!Object.keys(n).some((e=>"status-pending"!==n[e])))return;if("expired"===n[l])return this.log(`Expired key ${it(n)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=n[l];if(i)d(i,e);else{var r;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(r=e.keyStatusTimeouts)[l]||(r[l]=self.setTimeout((()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const n=this.getKeyStatus(e.decryptdata);if(n&&"status-pending"!==n)return this.log(`No status for keyId ${l} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${n} from other session.`),d(n,e);this.log(`key status for ${l} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",d(i,e)}),t)),this.log(`No status for keyId ${l} (${it(n)}).`)}};vi(e.mediaKeysSession,"message",h),vi(e.mediaKeysSession,"keystatuseschange",p);const f=new Promise(((e,t)=>{u.on("error",t),u.on("resolved",e)}));return e.mediaKeysSession.generateRequest(t,n).then((()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${l} URI: ${c}`)})).catch((t=>{throw new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)})).then((()=>f)).catch((t=>(u.removeAllListeners(),this.removeSession(e).then((()=>{throw t}))))).then((()=>(u.removeAllListeners(),e)))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach(((n,i)=>{if("string"==typeof i&&"object"==typeof n){const e=i;i=n,n=e}const r="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);e.keySystem===Sn.PLAYREADY&&16===r.length&&wn(r);const s=R(r);"internal-error"===n&&(this.bannedKeyIds[s]=n),this.log(`key status change "${n}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=n})),t}fetchServerCertificate(e){const t=this.config,n=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise(((r,s)=>{const l={responseType:"arraybuffer",url:i},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,n,i)=>{r(e.data)},onError:(t,n,r,c)=>{s(new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:w({url:l.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,n,r)=>{s(new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,n)=>{s(new Error("aborted"))}};n.load(l,u,h)}))):Promise.resolve()}setMediaKeysServerCertificate(e,t,n){return new Promise(((i,r)=>{e.setServerCertificate(n).then((r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${n.byteLength}) on "${t}"`),i(e)})).catch((e=>{r(new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then((t=>this.updateKeySession(e,new Uint8Array(t)).catch((t=>{throw new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))))}unpackPlayReadyKeyMessage(e,t){const n=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!n.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(n,"application/xml"),r=i.querySelectorAll("HttpHeader");if(r.length>0){let t;for(let n=0,i=r.length;n<i;n++){var s,a;t=r[n];const i=null==(s=t.querySelector("name"))?void 0:s.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return bn(atob(l))}setupLicenseXHR(e,t,n,i){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>{if(!n.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,n,i)})).catch((s=>{if(!n.decryptdata)throw s;return e.open("POST",t,!0),r.call(this.hls,e,t,n,i)})).then((n=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:n||i}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const n=this.config.keyLoadPolicy.default;return new Promise(((i,r)=>{const s=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${s}`);const l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(4===l.readyState)if(200===l.status){this._requestLicenseFailureCount=0;let t=l.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const n=this.config.licenseResponseCallback;if(n)try{t=n.call(this.hls,l,s,e)}catch(e){this.error(e)}i(t)}else{const c=n.errorRetry,u=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>u||l.status>=400&&l.status<500)r(new wa({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:l,response:{url:s,data:void 0,code:l.status,text:l.statusText}},`License Request XHR failed (${s}). Status: ${l.status} (${l.statusText})`));else{const n=u-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${n} attempts left`),this.requestLicense(e,t).then(i,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=l,this.setupLicenseXHR(l,s,e,t).then((({xhr:t,licenseChallenge:n})=>{e.keySystem==Sn.PLAYREADY&&(n=this.unpackPlayReadyKeyMessage(t,n)),t.send(n)})).catch(r)}))}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const n=t.media;this.media=n,vi(n,"encrypted",this.onMediaEncrypted),vi(n,"waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media;e&&(bi(e,"encrypted",this.onMediaEncrypted),bi(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={},!this.mediaKeys&&!this.mediaKeySessions.length)return;const t=this.media,n=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Fn.clearKeyUriToKeyIdMap();const i=n.length;ya.CDMCleanupPromise=Promise.all(n.map((e=>this.removeSession(e))).concat((null==t||null==(e=t.setMediaKeys(null))?void 0:e.catch((e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})})))||Promise.resolve())).catch((e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})})).then((()=>{i&&this.log("finished closing key sessions and clearing media keys")}))}onManifestLoading(){this.keyFormatPromise=null,this.bannedKeyIds={}}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce(((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e)),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:n,decryptdata:i}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${R((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach((e=>self.clearTimeout(s[e])));const{drmSystemOptions:c}=this.config,u=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some((e=>"persistent-license"===e))))}(c)?new Promise(((e,n)=>{self.setTimeout((()=>n(new Error("MediaKeySession.remove() timeout"))),8e3),t.remove().then(e).catch(n)})):Promise.resolve();return u.catch((e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})})).then((()=>t.close())).catch((e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})}))}return Promise.resolve()}}function va(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return R(e.keyId)}function ba(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}ya.CDMCleanupPromise=void 0;class wa extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function xa(e,t){const n="output-restricted"===e,i=n?o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:o.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new wa({type:a.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},n?"HDCP level output restricted":`key status changed to "${e}"`)}function ka(e,t){let n;try{n=new Event("addtrack")}catch(e){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=e,t.dispatchEvent(n)}function Sa(e,t){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(n){L.debug(`[texttrack-utils]: ${n}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===n&&(e.mode=n)}function Ea(e,t){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues)for(let n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===n&&(e.mode=n)}function Ta(e,t,n,i){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&e.cues.length>0){const r=function(e,t,n){const i=[],r=function(e,t){if(t<=e[0].startTime)return 0;const n=e.length-1;if(t>e[n].endTime)return-1;let i,r=0,s=n;for(;r<=s;)if(i=Math.floor((s+r)/2),t<e[i].startTime)s=i-1;else{if(!(t>e[i].startTime&&r<n))return i;r=i+1}return e[r].startTime-t<t-e[s].startTime?r:s}(e,t);if(r>-1)for(let s=r,a=e.length;s<a;s++){const r=e[s];if(r.startTime>=t&&r.endTime<=n)i.push(r);else if(r.startTime>n)return i}return i}(e.cues,t,n);for(let t=0;t<r.length;t++)i&&!i(r[t])||e.removeCue(r[t])}"disabled"===r&&(e.mode=r)}function Ca(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[n])}return t}function La(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return(t>>>0).toString()}const Aa=.025;let Da=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function Ma(e,t,n){return`${e.identifier}-${n+1}-${La(t)}`}class Ra{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const n=this.playoutLimit;if(e<=0||isNaN(n))return!1;if(0===n)return!0;return((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>n}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Ia(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime;return t-Ia(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=i(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Ia(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Aa))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return t=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?Da.Range:Da.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}function Ia(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<Aa)?t.start:t.start+t.duration}function Pa(e,t,n){const i=new self.URL(e,n);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function Oa(e,t){for(;null!=(n=e.assetList[++t])&&n.error;)var n;return t}function Fa(e){const t=e.timelineStart,n=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+n).toFixed(2)}]`}class Na{constructor(e,t,n,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(l.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=n,this.assetItem=i;const s=()=>{this.hasDetails=!0};r.once(l.LEVEL_LOADED,s),r.once(l.AUDIO_TRACK_LOADED,s),r.once(l.SUBTITLE_TRACK_LOADED,s),r.on(l.MEDIA_ATTACHING,((e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(l.BUFFER_APPENDED,(()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(l.BUFFERED_TO_END,void 0))})))}))}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Pa(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;const n=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,r=nn.bufferInfo(e,i,0);return this.getAssetTime(r.end)>=n-.02}reachedPlayout(e){const t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=nn.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const n=t-this.startOffset;if(n>0&&n<e)return n}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const n=e-t;if(Math.abs(n)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,n=this.duration;return Math.min(Math.max(0,e-t),n)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,n){var i;null==(i=this.hls)||i.on(e,t)}once(e,t,n){var i;null==(i=this.hls)||i.once(e,t)}off(e,t,n){var i;null==(i=this.hls)||i.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${Fa(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class Ba extends x{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach((e=>e.reset())),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce(((n,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,n+1):n),0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let n=-1;e.nextEvent?n=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(n=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[n]||(void 0===t&&(t=e.start),n=this.findItemIndexAtTime(t));n>=0&&null!=(r=i[n])&&r.event;){var r;n--}return n}findItemIndexAtTime(e,t){const n=this.items;if(n)for(let i=0;i<n.length;i++){let r=n[i];if(t&&"primary"!==t&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return i}return-1}findJumpRestrictedIndex(e,t){const n=this.items;if(n)for(let i=e;i<=t&&n[i];i++){const e=n[i].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var n;if((null==(n=t[i].event)?void 0:n.identifier)===e)return i}return-1}findAssetIndex(e,t){const n=e.assetList,i=n.length;if(i>1)for(let e=0;e<i;e++){const r=n[e];if(!r.error){const n=r.timelineStart;if(t===n||t>n&&(t<n+(r.duration||0)||e===i-1))return e}}return 0}get assetIdAtEnd(){var e;const t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){const e=t.assetList,n=e[e.length-1];if(n)return n.identifier}return null}parseInterstitialDateRanges(e,t){const n=e.main.details,{dateRanges:i}=n,r=this.events,s=this.parseDateRanges(i,{url:n.url},t),a=Object.keys(i),o=r?r.filter((e=>!a.includes(e.identifier))):[];s.length&&s.sort(((e,t)=>{const n=e.cue.pre,i=e.cue.post,r=t.cue.pre,s=t.cue.post;if(n&&!r)return-1;if(r&&!n)return 1;if(i&&!s)return 1;if(s&&!i)return-1;if(!(n||r||i||s)){const n=e.startTime,i=t.startTime;if(n!==i)return n-i}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=s,o.forEach((e=>{this.removeEvent(e)})),this.updateSchedule(e,o)}updateSchedule(e,t=[],n=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const r=this.items,s=this.parseSchedule(i,e);(n||t.length||(null==r?void 0:r.length)!==s.length||s.some(((e,t)=>Math.abs(e.playout.start-r[t].playout.start)>.005||Math.abs(e.playout.end-r[t].playout.end)>.005)))&&(this.items=s,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,n){const i=[],r=Object.keys(e);for(let s=0;s<r.length;s++){const a=r[s],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new Ra(o,t),this.eventMap[a]=e,!1===n&&(e.appendInPlace=n)),i.push(e)}}return i}parseSchedule(e,t){const n=[],i=t.main.details,r=i.live?1/0:i.edge;let s=0;if((e=e.filter((e=>!(e.error||e.cue.once&&e.hasPlayed)))).length){this.resolveOffsets(e,t);let i=0,o=0;if(e.forEach(((t,a)=>{const l=t.cue.pre,c=t.cue.post,u=e[a-1]||null,h=t.appendInPlace,d=c?r:t.startOffset,p=t.duration,f=t.timelineOccupancy===Da.Range?p:0,m=t.resumptionOffset,g=(null==u?void 0:u.startTime)===d,_=d+t.cumulativeDuration;let y=h?_+p:d+m;if(l||!c&&d<=0){const e=o;o+=f,t.timelineStart=_;const i=s;s+=p,n.push({event:t,start:_,end:y,playout:{start:i,end:s},integrated:{start:e,end:o}})}else{if(!(d<=r))return;{if(!g){const r=d-i;if(r>.033){const l=i,c=o;o+=r;const u=s;s+=r;const h={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+r,playout:{start:u,end:s},integrated:{start:c,end:o}};n.push(h)}else r>0&&u&&(u.cumulativeDuration+=r,n[n.length-1].end=d)}c&&(y=_),t.timelineStart=_;const r=o;o+=f;const l=s;s+=p,n.push({event:t,start:_,end:y,playout:{start:l,end:s},integrated:{start:r,end:o}})}}const v=t.resumeTime;i=c||v>r?r:v})),i<r){var a;const e=i,t=o,l=r-i;o+=l;const c=s;s+=l,n.push({previousEvent:(null==(a=n[n.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:c,end:s},integrated:{start:t,end:o}})}this.setDurations(r,s,o)}else{const e=0;n.push({previousEvent:null,nextEvent:null,start:e,end:r,playout:{start:e,end:r},integrated:{start:e,end:r}}),this.setDurations(r,r,r)}return n}setDurations(e,t,n){this.durations={primary:e,playout:t,integrated:n}}resolveOffsets(e,t){const n=t.main.details,r=n.live?1/0:n.edge;let s=0,a=-1;e.forEach(((o,l)=>{const c=o.cue.pre,u=o.cue.post,h=c?0:u?r:o.startTime;this.updateAssetDurations(o);if(a===h?o.cumulativeDuration=s:(s=0,a=h),!u&&o.snapOptions.in&&(o.resumeAnchor=pt(null,n.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted){this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)}if(!o.appendInPlace&&l+1<e.length){e[l+1].startTime-e[l].resumeTime<.033&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`))}const d=i(o.resumeOffset)?o.resumeOffset:o.duration;s+=d}))}primaryCanResumeInPlaceAt(e,t){const n=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(n-i)>Aa)return this.log(`"${e.identifier}" resumption ${n} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some((i=>{const r=t[i].details,s=r.edge;if(n>=s)return this.log(`"${e.identifier}" resumption ${n} past ${i} playlist end ${s}`),!1;const a=pt(null,r.fragments,n);if(!a)return this.log(`"${e.identifier}" resumption ${n} does not align with any fragments in ${i} playlist (${r.fragStart}-${r.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-n)<Aa+o||Math.abs(a.end-n)<Aa+o)&&(this.log(`"${e.identifier}" resumption ${n} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),!0)}))}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let n=0,i=!1,r=!1;for(let s=0;s<e.assetList.length;s++){const a=e.assetList[s],o=t+n;a.startOffset=n,a.timelineStart=o,i||(i=null===a.duration),r||(r=!!a.error);n+=a.error?0:a.duration||0}e.duration=i&&!r?Math.max(n,e.duration):n}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function $a(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class Ka{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const n=e.assetListUrl;let i;try{i=Pa(n,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,o.ASSET_LIST_LOAD_ERROR,t,n);return void this.hls.trigger(l.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,s=new(0,r.loader)(r),a={responseType:"json",url:i.href},c=r.interstitialAssetListLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(t,n,i,r)=>{const s=t.data,a=null==s?void 0:s.ASSETS;if(Array.isArray(a))e.assetListResponse=s,this.hls.trigger(l.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:r});else{const t=this.assignAssetListError(e,o.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,n,r);this.hls.trigger(l.ERROR,t)}},onError:(t,n,i,r)=>{const s=this.assignAssetListError(e,o.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${n.url})`),n.url,r,i);this.hls.trigger(l.ERROR,s)},onTimeout:(t,n,i)=>{const r=this.assignAssetListError(e,o.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${n.url})`),n.url,t,i);this.hls.trigger(l.ERROR,r)}};return s.load(a,u,h),this.hls.trigger(l.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,n,i,r,s){return e.error=n,{type:a.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:n,networkDetails:s,stats:r}}}function Ua(e){null==e||e.play().catch((()=>{}))}function za(e,t){return`[${e}] Advancing timeline position to ${t}`}class Va{constructor(e){this.buffered=void 0;const t=(t,n,i)=>{if((n>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${i})`);return e[n][t]};this.buffered={get length(){return e.length},end(n){return t("end",n,e.length)},start(n){return t("start",n,e.length)}}}}const qa={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},Ga=e=>String.fromCharCode(qa[e]||e),Ha=15,ja=100,Wa={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Za={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ya={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Xa={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ja=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Qa{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const n="function"==typeof t?t():t;L.log(`${this.time} [${e}] ${n}`)}}}const eo=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].toString(16));return t};class to{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let n=0;n<t.length;n++){const i=t[n];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class no{constructor(){this.uchar=" ",this.penState=new to}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class io{constructor(e){this.chars=[],this.pos=0,this.currPenState=new to,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<ja;e++)this.chars.push(new no);this.logger=e}equals(e){for(let t=0;t<ja;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ja;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ja;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ja&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ja)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Ga(e);this.pos>=ja?this.logger.log(0,(()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<ja;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let n=0;n<ja;n++){const i=this.chars[n].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class ro{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ha;t++)this.rows.push(new io(e));this.logger=e}reset(){for(let e=0;e<Ha;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let n=0;n<Ha;n++)if(!this.rows[n].equals(e.rows[n])){t=!1;break}return t}copy(e){for(let t=0;t<Ha;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Ha;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,(()=>"pacData = "+it(e)));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<Ha;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){const i=n.rows[e].cueStartTime,r=this.logger.time;if(null!==i&&null!==r&&i<r)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(n.rows[e+i])}}this.currRow=t;const n=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);n.setCursor(e.indent),e.color=n.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,(()=>"bkgData = "+it(e))),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let n="",i=-1;for(let n=0;n<Ha;n++){const r=this.rows[n].getTextString();r&&(i=n+1,e?t.push("Row "+i+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(n=e?"["+t.join(" | ")+"]":t.join("\n")),n}getTextAndFormat(){return this.rows}}class so{constructor(e,t,n){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ro(n),this.nonDisplayedMemory=new ro(n),this.lastOutputScreen=new ro(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(()=>"MODE="+e)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>t+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const n=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[n]}this.logger.log(2,"MIDROW: "+it(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class ao{constructor(e,t,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new Qa;this.channels=[null,new so(e,t,i),new so(e+1,n,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const n=127&t[e],i=127&t[e+1];let r=!1,s=null;if(0===n&&0===i)continue;this.logger.log(3,(()=>"["+eo([t[e],t[e+1]])+"] -> ("+eo([n,i])+")"));const a=this.cmdHistory;if(n>=16&&n<=31){if(lo(n,i,a)){oo(null,null,a),this.logger.log(3,(()=>"Repeated command ("+eo([n,i])+") is dropped"));continue}oo(n,i,this.cmdHistory),r=this.parseCmd(n,i),r||(r=this.parseMidrow(n,i)),r||(r=this.parsePAC(n,i)),r||(r=this.parseBackgroundAttributes(n,i))}else oo(null,null,a);if(!r&&(s=this.parseChars(n,i),s)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(2,(()=>"Couldn't parse cleaned data "+eo([n,i])+" orig: "+eo([t[e],t[e+1]])))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;const n=20===e||21===e||23===e?1:2,i=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let n=0;if((17===e||25===e)&&t>=32&&t<=47){if(n=17===e?1:2,n!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[n];return!!i&&(i.ccMIDROW(t),this.logger.log(3,(()=>"MIDROW ("+eo([e,t])+")")),!0)}return!1}parsePAC(e,t){let n;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;n=t>=64&&t<=95?1===i?Wa[e]:Ya[e]:1===i?Za[e]:Xa[e];const r=this.channels[i];return!!r&&(r.setPAC(this.interpretPAC(n,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let n;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return n=t>95?t-96:t-64,i.underline=1==(1&n),n<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((n-16)/2),i}parseChars(e,t){let n,i=null,r=null;if(e>=25?(n=2,r=e-8):(n=1,r=e),r>=17&&r<=19){let e;e=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,(()=>"Special char '"+Ga(e)+"' in channel "+n)),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,(()=>"Char codes = "+eo(i).join(","))),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let n;const i={};16===e||24===e?(n=Math.floor((t-32)/2),i.background=Ja[n],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const r=e<=23?1:2;return this.channels[r].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}oo(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const n=this.channels[t];n&&n.cueSplitAtTime(e)}}}function oo(e,t,n){n.a=e,n.b=t}function lo(e,t,n){return n.a===e&&n.b===t}var co=function(){if(null!=kn&&kn.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function n(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const n=t.toLowerCase();return!!~e.indexOf(n)&&n}function i(e){return n(t,e)}function r(e,...t){let n=1;for(;n<arguments.length;n++){const t=arguments[n];for(const n in t)e[n]=t[n]}return e}function s(t,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",u=!1,h=t,d=s,p=a,f=null,m="",g=!0,_="auto",y="start",v=50,b="middle",w=50,x="middle";Object.defineProperty(o,"id",r({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(o,"pauseOnExit",r({},l,{get:function(){return u},set:function(e){u=!!e}})),Object.defineProperty(o,"startTime",r({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",r({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",r({},l,{get:function(){return p},set:function(e){p=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",r({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",r({},l,{get:function(){return m},set:function(t){const i=function(t){return n(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",r({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",r({},l,{get:function(){return _},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",r({},l,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",r({},l,{get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},l,{get:function(){return b},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},l,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},l,{get:function(){return x},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");x=t,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class uo{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function ho(e){function t(e,t,n,i){return 3600*(0|e)+60*(0|t)+(0|n)+parseFloat(i||0)}const n=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?t(n[2],n[3],0,n[4]):t(n[1],n[2],n[3],n[4]):null}class po{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,n){for(let i=0;i<n.length;++i)if(t===n[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const n=parseFloat(t);if(n>=0&&n<=100)return this.set(e,n),!0}return!1}}function fo(e,t,n,i){const r=i?e.split(i):[e];for(const e in r){if("string"!=typeof r[e])continue;const i=r[e].split(n);if(2!==i.length)continue;t(i[0],i[1])}}const mo=new co(0,0,""),go="middle"===mo.align?"middle":"center";function _o(e,t,n){const i=e;function r(){const t=ho(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=r(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=r(),s(),function(e,t){const i=new po;fo(e,(function(e,t){let r;switch(e){case"region":for(let r=n.length-1;r>=0;r--)if(n[r].id===t){i.set(e,n[r].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":r=t.split(","),i.integer(e,r[0]),i.percent(e,r[0])&&i.set("snapToLines",!1),i.alt(e,r[0],["auto"]),2===r.length&&i.alt("lineAlign",r[1],["start",go,"end"]);break;case"position":r=t.split(","),i.percent(e,r[0]),2===r.length&&i.alt("positionAlign",r[1],["start",go,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",go,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let r=i.get("line","auto");"auto"===r&&-1===mo.line&&(r=-1),t.line=r,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",go);let s=i.get("position","auto");"auto"===s&&50===mo.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function yo(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class vo{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new uo,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function n(){let e=t.buffer,n=0;for(e=yo(e);n<e.length&&"\r"!==e[n]&&"\n"!==e[n];)++n;const i=e.slice(0,n);return"\r"===e[n]&&++n,"\n"===e[n]&&++n,t.buffer=e.slice(n),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=n();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let i=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(i?i=!1:e=n(),t.state){case"HEADER":/:/.test(e)?fo(e,(function(e,t){}),/:/):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new co(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{_o(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const n=-1!==e.indexOf("--\x3e");if(!e||n&&(i=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const bo=/\r\n|\n\r|\n|\r/g,wo=function(e,t,n=0){return e.slice(n,n+t.length)===t};function xo(e,t,n){return La(e.toString())+La(t.toString())+La(n)}function ko(e,t,n,r,s,a,o){const l=new vo,c=M(new Uint8Array(e)).trim().replace(bo,"\n").split("\n"),u=[],h=t?function(e,t=1){return Gr(e,9e4,1/t)}(t.baseTime,t.timescale):0;let d,p="00:00.000",f=0,m=0,g=!0;l.oncue=function(e){const i=n[r];let a=n.ccOffset;const o=(f-h)/9e4;if(null!=i&&i.new&&(void 0!==m?a=n.ccOffset=i.start:function(e,t,n){let i=e[t],r=e[i.prevCC];if(!r||!r.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=r)&&s.new;){var s;e.ccOffset+=i.start-r.start,i.new=!1,i=r,r=e[i.prevCC]}e.presentationOffset=n}(n,r,o)),o){if(!t)return void(d=new Error("Missing initPTS for VTT MPEGTS"));a=o-n.presentationOffset}const l=e.endTime-e.startTime,c=Qr(9e4*(e.startTime+a-m),9e4*s)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+l,0);const p=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=xo(e.startTime,e.endTime,p)),e.endTime>0&&u.push(e)},l.onparsingerror=function(e){d=e},l.onflush=function(){d?o(d):a(u)},c.forEach((e=>{if(g){if(wo(e,"X-TIMESTAMP-MAP=")){g=!1,e.slice(16).split(",").forEach((e=>{wo(e,"LOCAL:")?p=e.slice(6):wo(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))}));try{m=function(e){let t=parseInt(e.slice(-3));const n=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(i(t)&&i(n)&&i(r)&&i(s)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*n,t+=6e4*r,t+=36e5*s,t}(p)/1e3}catch(e){d=e}return}""===e&&(g=!1)}l.parse(e+"\n")})),l.flush()}const So="stpp.ttml.im1t",Eo=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,To=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Co={left:"start",center:"center",right:"end",start:"start",end:"end"};function Lo(e,t,n,i){const r=ae(new Uint8Array(e),["mdat"]);if(0===r.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=r.map((e=>M(e))),a=function(e,t,n=1,i=!1){return Gr(e,t,1/n,i)}(t.baseTime,1,t.timescale);try{s.forEach((e=>n(function(e,t){const n=(new DOMParser).parseFromString(e,"text/xml"),i=n.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce(((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||r[t],e)),{}),a="preserve"!==i.getAttribute("xml:space"),o=Do(Ao(i,"styling","style")),l=Do(Ao(i,"layout","region")),c=Ao(i,"body","[begin]");return[].map.call(c,(e=>{const n=Mo(e,a);if(!n||!e.hasAttribute("begin"))return null;const i=Po(e.getAttribute("begin"),s),r=Po(e.getAttribute("dur"),s);let c=Po(e.getAttribute("end"),s);if(null===i)throw Io(e);if(null===c){if(null===r)throw Io(e);c=i+r}const u=new co(i-t,c-t,n);u.id=xo(u.startTime,u.endTime,u.text);const h=function(e,t,n){const i="http://www.w3.org/ns/ttml#styling";let r=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&n.hasOwnProperty(a)&&(r=n[a]);return s.reduce(((n,s)=>{const a=Ro(t,i,s)||Ro(e,i,s)||Ro(r,i,s);return a&&(n[s]=a),n}),{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:d}=h;if(d){const e=Co[d];e&&(u.lineAlign=e),u.align=d}return v(u,h),u})).filter((e=>null!==e))}(e,a))))}catch(e){i(e)}}function Ao(e,t,n){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(n)):[]}function Do(e){return e.reduce(((e,t)=>{const n=t.getAttribute("xml:id");return n&&(e[n]=t),e}),{})}function Mo(e,t){return[].slice.call(e.childNodes).reduce(((e,n,i)=>{var r;return"br"===n.nodeName&&i?e+"\n":null!=(r=n.childNodes)&&r.length?Mo(n,t):t?e+n.textContent.trim().replace(/\s+/g," "):e+n.textContent}),"")}function Ro(e,t,n){return e&&e.hasAttributeNS(t,n)?e.getAttributeNS(t,n):null}function Io(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Po(e,t){if(!e)return null;let n=ho(e);return null===n&&(Eo.test(e)?n=function(e,t){const n=Eo.exec(e),i=(0|n[4])+(0|n[5])/t.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+i/t.frameRate}(e,t):To.test(e)&&(n=function(e,t){const n=To.exec(e),i=Number(n[1]);switch(n[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),n}class Oo{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,n){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function Fo(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function No(e,t){return!!e&&e.kind===Fo(t)&&ms(t,e)}const Bo=/\s/,$o={newCue(e,t,n,i){const r=[];let s,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let d=0;d<i.rows.length;d++)if(s=i.rows[d],o=!0,l=0,c="",!s.isEmpty()){var h;for(let e=0;e<s.chars.length;e++)Bo.test(s.chars[e].uchar)&&o?l++:(c+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===n&&(n+=1e-4),l>=16?l--:l++;const i=yo(c.trim()),p=xo(t,n,i);null!=e&&null!=(h=e.cues)&&h.getCueById(p)||(a=new u(t,n,i),a.id=p,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(a))}return e&&r.length&&(r.sort(((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line)),r.forEach((t=>Sa(e,t)))),r}};const Ko=/(\d+)-(\d+)\/(\d+)/;class Uo{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||zo,this.controller=new self.AbortController,this.stats=new V}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,n){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const s=function(e,t){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(v({},e.headers))};e.rangeEnd&&n.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return n}(e,this.controller.signal),a="arraybuffer"===e.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=n,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=l&&i(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))}),t.timeout);(os(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((n=>{var s;this.response=this.loader=n;const o=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))}),c-(o-r.loading.start)),!n.ok){const{status:e,statusText:t}=n;throw new Vo(t||"fetch, bad network response",e,n)}r.loading.first=o,r.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=Ko.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(i(e))return e}const n=e.get("Content-Length");if(n)return parseInt(n)}(n.headers)||r.total;const l=null==(s=this.callbacks)?void 0:s.onProgress;return l&&i(t.highWaterMark)?this.loadProgressively(n,r,e,t.highWaterMark,l):a?n.arrayBuffer():"json"===e.responseType?n.json():n.text()})).then((n=>{var s,a;const l=this.response;if(!l)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const c=n[o];c&&(r.loaded=r.total=c);const u={url:l.url,data:n,code:l.status},h=null==(s=this.callbacks)?void 0:s.onProgress;h&&!i(t.highWaterMark)&&h(r,e,n,l),null==(a=this.callbacks)||a.onSuccess(u,r,e,l)})).catch((t=>{var n;if(self.clearTimeout(this.requestTimeout),r.aborted)return;const i=t&&t.code||0,s=t?t.message:null;null==(n=this.callbacks)||n.onError({code:i,text:s},e,t?t.details:null,r)}))}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,n,i=0,r){const s=new Fi,a=e.body.getReader(),o=()=>a.read().then((a=>{if(a.done)return s.dataLength&&r(t,n,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return t.loaded+=c,c<i||s.dataLength?(s.push(l),s.dataLength>=i&&r(t,n,s.flush().buffer,e)):r(t,n,l.buffer,e),o()})).catch((()=>Promise.reject()));return o()}}function zo(e,t){return new self.Request(e.url,t)}class Vo extends Error{constructor(e,t,n){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=n}}const qo=/^age:\s*[\d.]+\s*$/im;class Go{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new V,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=n,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const n=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(this.loader===n&&!this.stats.aborted)return r(n,t.url)})).catch((e=>{if(this.loader===n&&!this.stats.aborted)return n.open("GET",t.url,!0),r(n,t.url)})).then((()=>{this.loader!==n||this.stats.aborted||this.openAndSendXhr(n,t,e)})).catch((e=>{var r;null==(r=this.callbacks)||r.onError({code:n.status,text:e.message},t,n,i)})):this.openAndSendXhr(n,t,e)}openAndSendXhr(e,t,n){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:a}=n.loadPolicy;if(r)for(const t in r)e.setRequestHeader(t,r[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),n.timeout=s&&i(s)?s:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:n}=this;if(!e||!t)return;const i=t.readyState,r=this.config;if(!n.aborted&&i>=2&&(0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(n.loading.first-n.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,l="text"===t.responseType?t.responseText:null;if(i>=200&&i<300){const r=null!=l?l:t.response;if(null!=r){var s,a;n.loading.end=Math.max(self.performance.now(),n.loading.first);const o="arraybuffer"===t.responseType?r.byteLength:r.length;n.loaded=n.total=o,n.bwEstimate=8e3*n.total/(n.loading.end-n.loading.first);const l=null==(s=this.callbacks)?void 0:s.onProgress;l&&l(n,e,r,t);const c={url:t.responseURL,data:r,code:i};return void(null==(a=this.callbacks)||a.onSuccess(c,n,e,t))}}const c=r.loadPolicy.errorRetry;var o;if(kt(c,n.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(c);else L.error(`${i} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:i,text:t.statusText},e,t,n)}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(kt(e,this.stats.retry,!0))this.retry(e);else{var t;L.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:n}=this;this.retryDelay=wt(e,n.retry),n.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${n.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&qo.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Ho=w(w({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Go,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends x{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;const{fragCurrent:n,partCurrent:r,hls:s}=this,{autoLevelEnabled:a,media:o}=s;if(!n||!o)return;const c=performance.now(),u=r?r.stats:n.stats,h=r?r.duration:n.duration,d=c-u.loading.start,p=s.minAutoLevel,f=n.level,m=this._nextAutoLevel;if(u.aborted||u.loaded&&u.loaded===u.total||f<=p)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!a)return;const g=m>-1&&m!==f,_=!!e||g;if(!_&&(o.paused||!o.playbackRate||!o.readyState))return;const y=s.mainForwardBufferInfo;if(!_&&null===y)return;const v=this.bwEstimator.getEstimateTTFB(),b=Math.abs(o.playbackRate);if(d<=Math.max(v,h/(2*b)*1e3))return;const w=y?y.len/b:0,x=u.loading.first?u.loading.first-u.loading.start:-1,k=u.loaded&&x>-1,S=this.getBwEstimate(),E=s.levels,T=E[f],C=Math.max(u.loaded,Math.round(h*(n.bitrate||T.averageBitrate)/8));let L=k?d-x:d;L<1&&k&&(L=Math.min(d,8*u.loaded/S));const A=k?1e3*u.loaded/L:0,D=v/1e3,M=A?(C-u.loaded)/A:8*C/S+D;if(M<=w)return;const R=A?8*A:S,I=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),P=this.hls.config.abrBandWidthUpFactor;let O,F=Number.POSITIVE_INFINITY;for(O=f-1;O>p;O--){const e=E[O].maxBitrate,t=!E[O].details||I;if(F=this.getTimeToLoadFrag(D,R,h*e,t),F<Math.min(w,h+D))break}if(F>=M)return;if(F>10*h)return;k?this.bwEstimator.sample(d-Math.min(v,x),u.loaded):this.bwEstimator.sampleTTFB(d);const N=E[O].maxBitrate;this.getBwEstimate()*P>N&&this.resetEstimator(N);const B=this.findBestLevel(N,p,O,0,w,1,1);B>-1&&(O=B),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${n.duration.toFixed(3)}\n Time to underbuffer: ${w.toFixed(3)} s\n Estimated load time for current fragment: ${M.toFixed(3)} s\n Estimated load time for down switch fragment: ${F.toFixed(3)} s\n TTFB estimate: ${0|x} ms\n Current BW estimate: ${i(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${O} @ ${0|N} bps`),s.nextLoadLevel=s.nextAutoLevel=O,this.clearTimer();const $=()=>{if(this.clearTimer(),this.fragCurrent===n&&this.hls.loadLevel===O&&O>0){const e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${O>0?"and switching down":""}\n Fragment duration: ${n.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),n.abortRequests(),this.fragCurrent=this.partCurrent=null,O>p){let t=this.findBestLevel(this.hls.levels[p].bitrate,p,O,0,e,1,1);-1===t&&(t=p),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};g||M>2*F?$():this.timer=self.setInterval($,1e3*F),s.trigger(l.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:r,stats:u})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new _(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.FRAG_LOADING,this.onFragLoading,this),e.on(l.FRAG_LOADED,this.onFragLoaded,this),e.on(l.FRAG_BUFFERED,this.onFragBuffered,this),e.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(l.LEVEL_LOADED,this.onLevelLoaded,this),e.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.FRAG_LOADING,this.onFragLoading,this),e.off(l.FRAG_LOADED,this.onFragLoaded,this),e.off(l.FRAG_BUFFERED,this.onFragBuffered,this),e.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(l.LEVEL_LOADED,this.onLevelLoaded,this),e.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(l.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const n=t.frag;if(!this.ignoreFragment(n)){var i;if(!n.bitrateTest)this.fragCurrent=n,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case o.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:n,partCurrent:i}=this;if(e&&n&&e.sn===n.sn&&e.level===n.level){const t=performance.now(),n=i?i.stats:e.stats,r=t-n.loading.start,s=n.loading.first?n.loading.first-n.loading.start:-1;if(n.loaded&&s>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(e,s),n.loaded)}else this.bwEstimator.sampleTTFB(r)}break}}}getTimeToLoadFrag(e,t,n,i){return e+n/t+(i?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const n=this.hls.config,{loading:r}=t.stats,s=r.end-r.first;i(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:n}){const i=n?n.stats:t.stats;if(t.type===p&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=n?n.duration:t.duration,r=this.hls.levels[t.level],s=(r.loaded?r.loaded.bytes:0)+i.loaded,a=(r.loaded?r.loaded.duration:0)+e;r.loaded={bytes:s,duration:a},r.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:n,id:t.type};this.onFragBuffered(l.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:n,part:i}=t,r=null!=i&&i.stats.loaded?i.stats:n.stats;if(r.aborted)return;if(this.ignoreFragment(n))return;const s=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,r.loaded),r.bwEstimate=this.getBwEstimate(),n.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==p||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,n=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,r=this.findBestLevel(n,t,e,0,i,1,1);if(r>-1)return r;const s=this.hls.firstLevel,a=Math.min(Math.max(s,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${s} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),n=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&n&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&n?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:n}=this;if(n.levels.length<=1)return n.loadLevel;const{maxAutoLevel:i,config:r,minAutoLevel:s}=n,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=r.abrBandWidthFactor,u=r.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,c,u);if(e>=0)return this.rebufferNotice=-1,e}let h=a?Math.min(a,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){h=(a?Math.min(a,r.maxLoadingDelay):r.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1}}const d=this.findBestLevel(o,s,i,l,h,c,u);if(this.rebufferNotice!==d&&(this.rebufferNotice=d,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${d}`)),d>-1)return d;const p=n.levels[s],f=n.loadLevelObj;return f&&(null==p?void 0:p.bitrate)<f.bitrate?s:n.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const n=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/n}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,n,r,s,a,o){var l;const c=r+s,u=this.lastLoadedFragLevel,h=-1===u?this.hls.firstLevel:u,{fragCurrent:d,partCurrent:p}=this,{levels:f,allAudioTracks:m,loadLevel:g,config:_}=this.hls;if(1===f.length)return 0;const y=f[h],v=!(null==(l=this.hls.latestLevelDetails)||!l.live),b=-1===g||-1===u;let w,x="SDR",k=(null==y?void 0:y.frameRate)||0;const{audioPreference:S,videoPreference:E}=_,T=this.audioTracksByGroup||(this.audioTracksByGroup=st(m));let C=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;const r=this.codecTiers||(this.codecTiers=function(e,t,n,i){return e.slice(n,i+1).reduce(((e,n,i)=>{if(!n.codecSet)return e;const r=n.audioGroups;let s=e[n.codecSet];s||(e[n.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,n.bitrate);const a=Math.min(n.height,n.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,n.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,n.score),s.fragmentError+=n.fragmentError,s.videoRanges[n.videoRange]=(s.videoRanges[n.videoRange]||0)+1,r&&r.forEach((e=>{if(!e)return;const n=t.groups[e];n&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?n.hasDefault:n.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(n.channels).forEach((e=>{s.channels[e]=(s.channels[e]||0)+n.channels[e]})))})),e}),{})}(f,T,t,n)),s=function(e,t,n,r,s){const a=Object.keys(e),o=null==r?void 0:r.channels,l=null==r?void 0:r.audioCodec,c=null==s?void 0:s.videoCodec,u=o&&2===parseInt(o);let h=!1,d=!1,p=1/0,f=1/0,m=1/0,g=1/0,_=0,y=[];const{preferHDR:v,allowedVideoRanges:b}=nt(t,s);for(let t=a.length;t--;){const n=e[a[t]];h||(h=n.channels[2]>0),p=Math.min(p,n.minHeight),f=Math.min(f,n.minFramerate),m=Math.min(m,n.minBitrate),b.filter((e=>n.videoRanges[e]>0)).length>0&&(d=!0)}p=i(p)?p:0,f=i(f)?f:0;const w=Math.max(1080,p),x=Math.max(30,f);m=i(m)?m:n,n=Math.max(m,n),d||(t=void 0);const k=a.length>1;return{codecSet:a.reduce(((t,i)=>{const r=e[i];if(i===t)return t;if(y=d?b.filter((e=>r.videoRanges[e]>0)):[],k){if(r.minBitrate>n)return rt(i,`min bitrate of ${r.minBitrate} > current estimate of ${n}`),t;if(!r.hasDefaultAudio)return rt(i,"no renditions with default or auto-select sound found"),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return rt(i,`audio codec preference "${l}" not found`),t;if(o&&!u){if(!r.channels[o])return rt(i,`no renditions with ${o} channel sound found (channels options: ${Object.keys(r.channels)})`),t}else if((!l||u)&&h&&0===r.channels[2])return rt(i,"no renditions with stereo sound found"),t;if(r.minHeight>w)return rt(i,`min resolution of ${r.minHeight} > maximum of ${w}`),t;if(r.minFramerate>x)return rt(i,`min framerate of ${r.minFramerate} > maximum of ${x}`),t;if(!y.some((e=>r.videoRanges[e]>0)))return rt(i,`no variants with VIDEO-RANGE of ${it(y)} found`),t;if(c&&i.indexOf(c.substring(0,4))%5!=0)return rt(i,`video codec preference "${c}" not found`),t;if(r.maxScore<_)return rt(i,`max score of ${r.maxScore} < selected max of ${_}`),t}return t&&(Me(i)>=Me(t)||r.fragmentError>e[t].fragmentError)?t:(g=r.minIndex,_=r.maxScore,i)}),void 0),videoRanges:y,preferHDR:v,minFramerate:f,minBitrate:m,minIndex:g}}(r,x,e,S,E),{codecSet:a,videoRanges:o,minFramerate:l,minBitrate:c,minIndex:u,preferHDR:h}=s;C=u,w=a,x=h?o[o.length-1]:o[0],k=l,e=Math.max(e,c),this.log(`picked start tier ${it(s)}`)}else w=null==y?void 0:y.codecSet,x=null==y?void 0:y.videoRange;const L=p?p.duration:d?d.duration:0,A=this.bwEstimator.getEstimateTTFB()/1e3,D=[];for(let l=n;l>=t;l--){var M;const t=f[l],d=l>h;if(!t)continue;if(_.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const n=navigator.mediaCapabilities;"function"==typeof(null==n?void 0:n.decodingInfo)&&Ve(t,T,x,k,e,S)?(t.supportedPromise=qe(t,T,n,this.supportedCache),t.supportedPromise.then((e=>{if(!this.hls)return;t.supportedResult=e;const n=this.hls.levels,i=n.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${it(e)}`):e.supported?e.decodingInfoResults.some((e=>!1===e.smooth||!1===e.powerEfficient))&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${it(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${it(e)}`),i>-1&&n.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))})).catch((e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)}))):t.supportedResult=Ue}if((w&&t.codecSet!==w||x&&t.videoRange!==x||d&&k>t.frameRate||!d&&k>0&&k<t.frameRate||null!=(M=t.supportedResult)&&null!=(M=M.decodingInfoResults)&&M.some((e=>!1===e.smooth)))&&(!b||l!==C)){D.push(l);continue}const m=t.details,y=(p?null==m?void 0:m.partTarget:null==m?void 0:m.averagetargetduration)||L;let E;E=d?o*e:a*e;const R=L&&r>=2*L&&0===s?t.averageBitrate:t.maxBitrate,I=this.getTimeToLoadFrag(A,E,R*y,void 0===m);if(E>=R&&(l===u||0===t.loadError&&0===t.fragmentError)&&(I<=A||!i(I)||v&&!this.bitrateTestDelay||I<c)){const e=this.forcedAutoLevel;return l===g||-1!==e&&e===g||(D.length&&this.trace(`Skipped level(s) ${D.join(",")} of ${n} max with CODECS and VIDEO-RANGE:"${f[D[0]].codecs}" ${f[D[0]].videoRange}; not compatible with "${w}" ${x}`),this.info(`switch candidate:${h}->${l} adjustedbw(${Math.round(E)})-bitrate=${Math.round(E-R)} ttfb:${A.toFixed(1)} avgDuration:${y.toFixed(1)} maxFetchDuration:${c.toFixed(1)} fetchDuration:${I.toFixed(1)} firstSelection:${b} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),b&&(this.firstSelection=l),l}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:n}=this.hls;return Math.min(Math.max(e,n),t)}},bufferController:class extends x{constructor(e,t){var n;super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{const{media:t,mediaSource:n}=this;e&&this.log("Media source opened"),t&&n&&(n.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(l.MEDIA_ATTACHED,{media:t,mediaSource:n}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=(n=A(e.config.preferManagedMediaSource),"undefined"!=typeof self&&n===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.BUFFER_RESET,this.onBufferReset,this),e.on(l.BUFFER_APPENDING,this.onBufferAppending,this),e.on(l.BUFFER_CODECS,this.onBufferCodecs,this),e.on(l.BUFFER_EOS,this.onBufferEos,this),e.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(l.FRAG_PARSED,this.onFragParsed,this),e.on(l.FRAG_CHANGED,this.onFragChanged,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.BUFFER_RESET,this.onBufferReset,this),e.off(l.BUFFER_APPENDING,this.onBufferAppending,this),e.off(l.BUFFER_CODECS,this.onBufferCodecs,this),e.off(l.BUFFER_EOS,this.onBufferEos,this),e.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(l.FRAG_PARSED,this.onFragParsed,this),e.off(l.FRAG_CHANGED,this.onFragChanged,this),e.off(l.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const n={};if(this.operationQueue){const e=this.isUpdating();e||this.operationQueue.removeBlockers();const t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?v(n,i.tracks):this.sourceBuffers.forEach((e=>{const[t]=e;t&&(n[t]=v({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null})),{media:e,mediaSource:t,tracks:n}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var n;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(n=this.transferData)&&n.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const n=this.media=t.media;this.transferData=this.overrides=void 0;const i=A(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const r=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(r),e)this._objectUrl=n.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{n.removeAttribute("src");const t=self.ManagedMediaSource;n.disableRemotePlayback=n.disableRemotePlayback||t&&r instanceof t,bs(n),function(e,t){const n=self.document.createElement("source");n.type="video/mp4",n.src=t,e.appendChild(n)}(n,e),n.load()}catch(t){n.src=e}else n.src=e}n.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,n;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(n=e.constructor)?void 0:n.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const n=this.tracks,i=t.tracks,r=i?Object.keys(i):null,s=r?r.length:0,a=()=>{Promise.resolve().then((()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()}))};if(i&&r&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${it(n,((e,t)=>"initSegment"===e?void 0:t))};\ntransfer tracks: ${it(i,((e,t)=>"initSegment"===e?void 0:t))}}`),!D(i,n)){t.mediaSource=null,t.tracks=void 0;const r=e.currentTime,s=this.details,a=Math.max(r,(null==s?void 0:s.fragments[0].start)||0);return a-r>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${r} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(n)}") start time: ${a} currentTime: ${r}`),this.onMediaDetaching(l.MEDIA_DETACHING,{}),this.onMediaAttaching(l.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,r.forEach((e=>{const t=e,n=i[t];if(n){const e=n.buffer;if(e){const i=this.fragmentTracker,r=n.id;if(i.hasFragments(r)||i.hasParts(r)){const n=nn.getBuffered(e);i.detectEvictedFragments(t,n,r,null,!0)}const s=ws(t),a=[t,e];this.sourceBuffers[s]=a,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,n)}}})),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var e;const t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){const n=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:r,_objectUrl:s}=this;if(r){if(this.log("media source "+(n?"transferring":"detaching")),n)this.sourceBuffers.forEach((([e])=>{e&&this.removeBuffer(e)})),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const e="open"===r.readyState;try{const t=r.sourceBuffers;for(let n=t.length;n--;)e&&t[n].abort(),r.removeSourceBuffer(t[n]);e&&r.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),n||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(i.removeAttribute("src"),this.appendSource&&bs(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(l.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach((([e])=>{e&&this.resetBuffer(e)})),this.initTracks()}resetBuffer(e){var t;const n=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),n)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(n)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[ws(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new gs(this.tracks)}onBufferCodecs(e,t){var n;const i=this.tracks,r=Object.keys(t);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);const s="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!s&&this.sourceBufferCount&&this.media&&r.some((e=>!i[e]));s||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${r}" SourceBuffers`):(r.forEach((e=>{var n,r;const s=t[e],{id:a,codec:o,levelCodec:l,container:c,metadata:u,supplemental:h}=s;let d=i[e];const p=null==(n=this.transferData)||null==(n=n.tracks)?void 0:n[e],f=null!=p&&p.buffer?p:d,m=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),g=null==f?void 0:f.levelCodec;d||(d=i[e]={buffer:void 0,listeners:[],codec:o,supplemental:h,container:c,levelCodec:l,metadata:u,id:a});const _=Oe(m,g),y=null==_?void 0:_.replace(_s,"$1");let v=Oe(o,l);const b=null==(r=v)?void 0:r.replace(_s,"$1");v&&_&&y!==b&&("audio"===e.slice(0,5)&&(v=Pe(v,this.appendSource)),this.log(`switching codec ${m} to ${v}`),v!==(d.pendingCodec||d.codec)&&(d.pendingCodec=v),d.container=c,this.appendChangeType(e,c,v))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(n=t.audio)?void 0:n.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce(((e,t)=>{const n=this.tracks[t];return e[t]={id:n.id,container:n.container,codec:n.codec,levelCodec:n.levelCodec},e}),{})}appendChangeType(e,t,n){const i=`${t};codecs=${n}`,r={label:`change-type=${i}`,execute:()=>{const r=this.tracks[e];if(r){const s=r.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),s.changeType(i),r.codec=n,r.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const n=e.start,i=n+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(n,p))?void 0:t.gap))return;const r={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&nn.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,p))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:r,frag:e},this.append(r,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:n}=this,{data:r,type:s,parent:c,frag:u,part:h,chunkMeta:d,offset:f}=t,m=d.buffering[s],{sn:g,cc:_}=u,y=self.performance.now();m.start=y;const v=u.stats.buffering,b=h?h.stats.buffering:null;0===v.start&&(v.start=y),b&&0===b.start&&(b.start=y);const w=n.audio;let x=!1;"audio"===s&&"audio/mpeg"===(null==w?void 0:w.container)&&(x=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const k=n.video,S=null==k?void 0:k.buffer;if(S&&"initSegment"!==g){const e=h||u,t=this.blockedAudioAppend;if("audio"!==s||"main"===c||this.blockedAudioAppend||k.ending||k.ended){if("video"===s){const n=e.end;if(t){const e=t.frag.start;(n>e||n<this.lastVideoAppendEnd||nn.isBuffered(S,e))&&this.unblockAudio()}this.lastVideoAppendEnd=n}}else{const t=e.start+.05*e.duration,n=S.buffered,i=this.currentOp("video");n.length||i?!i&&!nn.isBuffered(S,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(h||u).start,T={label:`append-${s}`,execute:()=>{var e;m.executeStart=self.performance.now();const t=null==(e=this.tracks[s])?void 0:e.buffer;t&&(x?this.updateTimestampOffset(t,E,.1,s,g,_):void 0!==f&&i(f)&&this.updateTimestampOffset(t,f,1e-6,s,g,_)),this.appendExecutor(r,s)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();m.executeEnd=m.end=e,0===v.first&&(v.first=e),b&&0===b.first&&(b.first=e);const t={};this.sourceBuffers.forEach((([e,n])=>{e&&(t[e]=nn.getBuffered(n))})),this.appendErrors[s]=0,"audio"===s||"video"===s?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(l.BUFFER_APPENDED,{type:s,frag:u,part:h,chunkMeta:d,parent:u.type,timeRanges:t})},onError:e=>{var t;const n={type:a.MEDIA_ERROR,parent:u.type,details:o.BUFFER_APPEND_ERROR,sourceBufferName:s,frag:u,part:h,chunkMeta:d,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)n.details=o.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)n.errorAction=It(!0);else if(e.name===ys&&0===this.sourceBufferCount)n.errorAction=It(!0);else{const e=++this.appendErrors[s];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${s}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(n.fatal=!0)}this.hls.trigger(l.ERROR,n)}};this.log(`queuing "${s}" append sn: ${g}${h?" p: "+h.index:""} of ${u.type===p?"level":"track"} ${u.level} cc: ${_}`),this.append(T,s,this.isPending(this.tracks[s]))}getFlushOp(e,t,n){return this.log(`queuing "${e}" remove ${t}-${n}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,n)},onStart:()=>{},onComplete:()=>{this.hls.trigger(l.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${n} from "${e}" SourceBuffer`,i)}}}onBufferFlushing(e,t){const{type:n,startOffset:i,endOffset:r}=t;n?this.append(this.getFlushOp(n,i,r),n):this.sourceBuffers.forEach((([e])=>{e&&this.append(this.getFlushOp(e,i,r),e)}))}onFragParsed(e,t){const{frag:n,part:i}=t,r=[],s=i?i.elementaryStreams:n.elementaryStreams;s[H]?r.push("audiovideo"):(s[q]&&r.push("audio"),s[G]&&r.push("video"));0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${n.type} level: ${n.level} sn: ${n.sn}`),this.blockBuffers((()=>{const e=self.performance.now();n.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:n.stats;this.hls.trigger(l.FRAG_BUFFERED,{frag:n,part:i,stats:t,id:n.type})}),r).catch((e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)}))}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some((([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1}))}onBufferEos(e,t){var n;this.sourceBuffers.forEach((([e])=>{if(e){const n=this.tracks[e];t.type&&t.type!==e||(n.ending=!0,n.ended||(n.ended=!0,this.log(`${e} buffer reached EOS`)))}}));const i=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some((([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)}))?i?(this.log("Queueing EOS"),this.blockUntilOpen((()=>{this.tracksEnded();const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(l.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)}))):(this.tracksEnded(),this.hls.trigger(l.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach((([e])=>{if(null!==e){const t=this.tracks[e];t&&(t.ending=!1)}}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen((()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)}))}onError(e,t){if(t.details===o.BUFFER_APPEND_ERROR&&t.frag){var n;const e=null==(n=t.errorAction)?void 0:n.nextAutoLevel;i(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:n}=this;if(!n||null===t)return;if(!this.sourceBufferCount)return;const r=e.config,s=n.currentTime,a=t.levelTargetDuration,o=t.live&&null!==r.liveBackBufferLength?r.liveBackBufferLength:r.backBufferLength;if(i(o)&&o>=0){const e=Math.max(o,a),t=Math.floor(s/a)*a-e;this.flushBackBuffer(s,a,t)}const l=r.frontBufferFlushThreshold;if(i(l)&&l>0){const e=Math.max(r.maxBufferLength,l),t=Math.max(e,a),n=Math.floor(s/a)*a+t;this.flushFrontBuffer(s,a,n)}}flushBackBuffer(e,t,n){this.sourceBuffers.forEach((([e,t])=>{if(t){const r=nn.getBuffered(t);if(r.length>0&&n>r.start(0)){var i;this.hls.trigger(l.BACK_BUFFER_REACHED,{bufferEnd:n});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(l.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:e})}}}))}flushFrontBuffer(e,t,n){this.sourceBuffers.forEach((([t,i])=>{if(i){const r=nn.getBuffered(i),s=r.length;if(s<2)return;const a=r.start(s-1),o=r.end(s-1);if(n>a||e>=a&&e<=o)return;this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:t})}}))}getDurationAndRange(){var e;const{details:t,mediaSource:n}=this;if(!t||!this.media||"open"!==(null==n?void 0:n.readyState))return null;const r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&n.setLiveSeekableRange){const e=Math.max(0,t.fragmentStart);return{duration:1/0,start:e,end:Math.max(e,r)}}return{duration:1/0}}const s=null==(e=this.overrides)?void 0:e.duration;if(s)return i(s)?{duration:s}:null;const a=this.media.duration;return r>(i(n.duration)?n.duration:0)&&r>a||!i(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:n}){const r=this.mediaSource;this.media&&r&&"open"===r.readyState&&(r.duration!==e&&(i(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),void 0!==t&&void 0!==n&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${n}.`),r.setLiveSeekableRange(t,n)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:n}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${it(n)}`),this.tracksReady){var i;const e=null==(i=this.transferData)?void 0:i.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach((([t,n])=>{if(t){const i=this.tracks[t];e[t]={buffer:n,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}})),this.hls.trigger(l.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach((([e])=>{this.executeNext(e)}))}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:n}=this;if(!n)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const s=r,c=e[s];if(this.isPending(c)){const e=this.getTrackCodec(c,s),r=`${c.container};codecs=${e}`;c.codec=e,this.log(`creating sourceBuffer(${r})${this.currentOp(s)?" Queued":""} ${it(c)}`);try{const e=n.addSourceBuffer(r),i=ws(s),a=[s,e];t[i]=a,c.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[s],void this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:r,parent:c.id})}this.trackSourceBuffer(s,c)}}this.bufferCreated()}getTrackCodec(e,t){const n=e.supplemental;let i=e.codec;n&&("video"===t||"audiovideo"===t)&&Ce(n,"video")&&(i=function(e,t){const n=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)Te(t[e],"video")||n.push(t[e])}return t&&n.push(t),n.join(",")}(i,n));const r=Oe(i,e.levelCodec);return r?"audio"===t.slice(0,5)?Pe(r,this.appendSource):r:""}trackSourceBuffer(e,t){const n=t.buffer;if(!n)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:n,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",((e,t)=>{const n=t.removedRanges;null!=n&&n.length&&this.hls.trigger(l.BUFFER_FLUSHED,{type:e})}))}get mediaSrc(){var e,t;const n=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==n?void 0:n.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const n=this.currentOp(e);n&&(n.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var n;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(n=this.mediaSource)?void 0:n.readyState}`);this.error(`${i}`,t),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const r=this.currentOp(e);r&&r.onError(i)}updateTimestampOffset(e,t,n,i,r,s){const a=t-e.timestampOffset;Math.abs(a)>=n&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,n){const{media:r,mediaSource:s}=this,a=this.tracks[e],o=null==a?void 0:a.buffer;if(!r||!s||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const l=i(r.duration)?r.duration:1/0,c=i(s.duration)?s.duration:1/0,u=Math.max(0,t),h=Math.min(n,l,c);h>u&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${u},${h}] from the ${e} SourceBuffer`),o.remove(u,h)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const n=this.tracks[t],i=null==n?void 0:n.buffer;if(!i)throw new vs(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);n.ending=!1,n.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch((e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)}));else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some((([e,t])=>e&&t.updating))}isQueued(){return this.sourceBuffers.some((([e])=>e&&!!this.currentOp(e)))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:n}=this,i=t.map((e=>this.appendBlocker(e)));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then((t=>{n===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))}))}stepOperationQueue(e){e.forEach((e=>{var t;const n=null==(t=this.tracks[e])?void 0:t.buffer;n&&!n.updating&&this.shiftAndExecuteNext(e)}))}append(e,t,n){this.operationQueue&&this.operationQueue.append(e,t,n)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce(((e,t)=>e+(this.isPending(this.tracks[t])?1:0)),0)}get sourceBufferCount(){return this.sourceBuffers.reduce(((e,[t])=>e+(t?1:0)),0)}get sourceBufferTypes(){return this.sourceBuffers.map((([e])=>e)).filter((e=>!!e))}addBufferListener(e,t,n){const i=this.tracks[e];if(!i)return;const r=i.buffer;if(!r)return;const s=n.bind(this,e);i.listeners.push({event:t,listener:s}),r.addEventListener(t,s)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const n=t.buffer;n&&(t.listeners.forEach((e=>{n.removeEventListener(e.event,e.listener)})),t.listeners.length=0)}},capLevelController:xs,errorController:class extends x{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(l.ERROR,this.onError,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(l.ERROR,this.onError,this),e.off(l.ERROR,this.onErrorOut,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===p?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,n=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===n?t.loadLevel:n}variantHasKey(e,t){if(e){var n;if(null!=(n=e.details)&&n.hasKey(t))return!0;const i=e.audioGroups;if(i){return this.hls.allAudioTracks.filter((e=>i.indexOf(e.groupId)>=0)).some((e=>{var n;return null==(n=e.details)?void 0:n.hasKey(t)}))}}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var n;if(t.fatal)return;const i=this.hls,r=t.context;switch(t.details){case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case o.FRAG_PARSING_ERROR:if(null!=(n=t.frag)&&n.gap)return void(t.errorAction=It());case o.FRAG_GAP:case o.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Tt);case o.LEVEL_EMPTY_ERROR:case o.LEVEL_PARSING_ERROR:{var s;const e=t.parent===p?t.level:i.loadLevel;t.details===o.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==r?void 0:r.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level)));case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.SUBTITLE_LOAD_ERROR:case o.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const e=i.loadLevelObj;if(e&&(r.type===h&&e.hasAudioGroup(r.groupId)||r.type===d&&e.hasSubtitleGroup(r.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Tt,void(t.errorAction.flags=Dt)}return;case o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Tt,flags:Mt});case o.KEY_SYSTEM_SESSION_UPDATE_FAILED:case o.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case o.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Tt,flags:Rt});case o.BUFFER_ADD_CODEC_ERROR:case o.REMUX_ALLOC_ERROR:case o.BUFFER_APPEND_ERROR:var l;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(l=t.level)?l:i.loadLevel);return;case o.INTERNAL_EXCEPTION:case o.BUFFER_APPENDING_ERROR:case o.BUFFER_FULL_ERROR:case o.LEVEL_SWITCH_ERROR:case o.BUFFER_STALLED_ERROR:case o.BUFFER_SEEK_OVER_HOLE:case o.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=It())}t.type===a.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=It())}getPlaylistRetryOrSwitchAction(e,t){const n=bt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(kt(n,i,_t(e),e.response))return{action:Lt,flags:At,retryConfig:n,retryCount:i};const r=this.getLevelSwitchAction(e,t);return n&&(r.retryConfig=n,r.retryCount=i),r}getFragRetryOrSwitchAction(e){const t=this.hls,n=this.getVariantLevelIndex(e.frag),i=t.levels[n],{fragLoadPolicy:r,keyLoadPolicy:s}=t.config,a=bt(yt(e)?s:r,e),l=t.levels.reduce(((e,t)=>e+t.fragmentError),0);if(i&&(e.details!==o.FRAG_GAP&&i.fragmentError++,!vt(e))){if(kt(a,l,_t(e),e.response))return{action:Lt,flags:At,retryConfig:a,retryCount:l}}const c=this.getLevelSwitchAction(e,n);return a&&(c.retryConfig=a,c.retryCount=l),c}getLevelSwitchAction(e,t){const n=this.hls;null==t&&(t=n.loadLevel);const i=this.hls.levels[t];if(i){var r,s;const t=e.details;i.loadError++,t===o.BUFFER_APPEND_ERROR&&i.fragmentError++;let c=-1;const{levels:u,loadLevel:g,minAutoLevel:_,maxAutoLevel:y}=n;n.autoLevelEnabled||n.config.preserveManualLevelOnError||(n.loadLevel=-1);const v=null==(r=e.frag)?void 0:r.type,b=(v===f&&t===o.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===o.BUFFER_ADD_CODEC_ERROR||t===o.BUFFER_APPEND_ERROR))&&u.some((({audioCodec:e})=>i.audioCodec!==e)),w="video"===e.sourceBufferName&&(t===o.BUFFER_ADD_CODEC_ERROR||t===o.BUFFER_APPEND_ERROR)&&u.some((({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t)),{type:x,groupId:k}=null!=(s=e.context)?s:{};for(let n=u.length;n--;){const r=(n+g)%u.length;if(r!==g&&r>=_&&r<=y&&0===u[r].loadError){var a,l;const n=u[r];if(t===o.FRAG_GAP&&v===p&&e.frag){const t=u[r].details;if(t){const n=pt(e.frag,t.fragments,e.frag.start);if(null!=n&&n.gap)continue}}else{if(x===h&&n.hasAudioGroup(k)||x===d&&n.hasSubtitleGroup(k))continue;if(v===f&&null!=(a=i.audioGroups)&&a.some((e=>n.hasAudioGroup(e)))||v===m&&null!=(l=i.subtitleGroups)&&l.some((e=>n.hasSubtitleGroup(e)))||b&&i.audioCodec===n.audioCodec||w&&i.codecSet===n.codecSet||!b&&i.codecSet!==n.codecSet)continue}c=r;break}}if(c>-1&&n.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:Tt,flags:At,nextAutoLevel:c}}return{action:Tt,flags:Dt}}onErrorOut(e,t){var n;switch(null==(n=t.errorAction)?void 0:n.action){case Et:break;case Tt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===o.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,n=e.errorAction;if(!n)return;const{flags:i}=n,r=n.nextAutoLevel;switch(i){case At:this.switchLevel(e,r);break;case Mt:{const i=this.getVariantLevelIndex(e.frag),r=t.levels[i],s=null==r?void 0:r.attrs["HDCP-LEVEL"];if(n.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=je[je.indexOf(s)-1],n.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Rt:{const t=e.decryptdata;if(t){const i=this.hls.levels,r=i.length;for(let n=r;n--;){var s,a;if(this.variantHasKey(i[n],t))this.log(`Banned key found in level ${n} (${i[n].bitrate}bps) or audio group "${null==(s=i[n].audioGroups)?void 0:s.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${R(t.keyId||[])}`),i[n].fragmentError++,i[n].loadError++,this.log(`Removing level ${n} with key error (${e.error})`),this.hls.removeLevel(n)}const o=e.frag;if(this.hls.levels.length<r)n.resolved=!0;else if(o&&o.type!==p){const e=o.decryptdata;e&&!t.matches(e)&&(n.resolved=!0)}}break}}n.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===o.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=$e(e.mimeType),n=this.hls.levels;for(let i=n.length;i--;)n[i][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${i} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const n=this.hls.config;if(n.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,n){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,r=n-this.lastDroppedFrames,s=t-this.lastDecodedFrames,a=1e3*r/e,o=this.hls;if(o.trigger(l.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:n}),a>0&&r>o.config.fpsDroppedMonitoringThreshold*s){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(l.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=n,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Rn,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:$o,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Pi{constructor(e,t,n){super(e,t,n,"subtitle-stream-controller",m),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(l.LEVEL_LOADED,this.onLevelLoaded,this),e.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(l.LEVEL_LOADED,this.onLevelLoaded,this),e.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=ki,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:n,success:i}=t;if(this.fragContextChanged(n)||(W(n)&&(this.fragPrevious=n),this.state=ki),!i)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let s;const a=n.start;for(let e=0;e<r.length;e++)if(a>=r[e].start&&a<=r[e].end){s=r[e];break}const o=n.start+n.duration;s?s.end=o:(s={start:a,end:o},r.push(s)),this.fragmentTracker.fragBuffered(n),this.fragBufferedComplete(n,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:n,endOffset:i}=t;if(0===n&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach((t=>{for(let n=0;n<t.length;)if(t[n].end<=e)t.shift();else{if(!(t[n].start<e))break;t[n].start=e,n++}})),this.fragmentTracker.removeFragmentsInRange(n,e,m)}}onError(e,t){const n=t.frag;(null==n?void 0:n.type)===m&&(t.details===o.FRAG_GAP&&this.fragmentTracker.fragBuffered(n,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==xi&&(this.state=ki))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&ps(this.levels,t)?this.levels=t.map((e=>new et(e))):(this.tracksBuffered=[],this.levels=t.map((e=>{const t=new et(e);return this.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,m),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var n;if(this.currentTrackId=t.id,null==(n=this.levels)||!n.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==xi&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var n;const{currentTrackId:i,levels:r}=this,{details:s,id:a}=t;if(!r)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=r[a];if(a>=r.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(s.live||null!=(n=o.details)&&n.live){if(s.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var u;if(o.details)c=this.alignPlaylists(s,o.details,null==(u=this.levelLastLoaded)?void 0:u.details),0===c&&t&&(c=t.start,ai(s,c));else s.hasProgramDateTime&&e.hasProgramDateTime?(yi(s,e),c=s.fragmentStart):t&&(c=t.start,ai(s,c));e&&!this.startFragRequested&&this.setStartPosition(e,c)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger(l.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===ki)){pt(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:n}=e,i=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&n&&n.byteLength>0&&null!=i&&i.key&&i.iv&&_n(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer,yn(i.method)).catch((e=>{throw r.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((n=>{const i=performance.now();r.trigger(l.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:e,tdecrypt:i}})})).catch((e=>{this.warn(`${e.name}: ${e.message}`),this.state=ki}))}}doTick(){if(this.media){if(this.state===ki){const{currentTrackId:e,levels:t}=this,n=null==t?void 0:t[e];if(!n||!t.length||!n.details)return;if(this.waitForLive(n))return;const{config:i}=this,r=this.getLoadPosition(),s=nn.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,i.maxBufferHole),{end:a,len:o}=s,l=n.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,u=c.length,h=l.edge;let d=null;const p=this.fragPrevious;if(a<h){const e=i.maxFragLookUpTolerance,t=a>h-e?0:e;d=pt(p,c,Math.max(c[0].start,a),t),!d&&p&&p.start<c[0].start&&(d=c[0])}else d=c[u-1];if(d=this.filterReplacedPrimary(d,n.details),!d)return;const f=c[d.sn-l.startSN-1];if(f&&f.cc===d.cc&&this.fragmentTracker.getState(f)===Pt&&(d=f),this.fragmentTracker.getState(d)===Pt){const e=this.mapToInitFragWhenRequired(d);e&&this.loadFragment(e,n,a)}}}else this.state=ki}loadFragment(e,t,n){W(e)?super.loadFragment(e,t,n):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new Va(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends ds{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=Ca(this.media.textTracks);for(let n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}const n=this.findTrackForTextTrack(e);this.subtitleTrack!==n&&this.setSubtitleTrack(n)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.LEVEL_LOADING,this.onLevelLoading,this),e.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.LEVEL_LOADING,this.onLevelLoading,this),e.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(l.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const n=this.media;if(!n)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||n.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;Ca(n.textTracks).forEach((e=>{Ea(e)}))}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:n,groupId:i,details:r}=t,s=this.tracksInGroup[n];if(!s||s.groupId!==i)return void this.warn(`Subtitle track with id:${n} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Subtitle track ${n} "${s.name}" lang:${s.lang} group:${i} loaded [${r.startSN}-${r.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const n=t.subtitleGroups||null,i=this.groupIds;let r=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some((e=>-1===(null==i?void 0:i.indexOf(e))))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!n||-1!==n.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!r&&t){this.selectDefaultTrack=!1;const n=ot(t,e);if(n>-1)r=e[n];else{const e=ot(t,this.tracks);r=this.tracks[e]}}let i=this.findTrackId(r);-1===i&&r&&(i=this.findTrackId(null));const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==n?void 0:n.join(",")}" group-id`),this.hls.trigger(l.SUBTITLE_TRACKS_UPDATED,s),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(e){const t=this.tracksInGroup,n=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const r=t[i];if((!n||r.default)&&(n||e)&&(!e||lt(r,e)))return i}if(e){for(let n=0;n<t.length;n++){const i=t[n];if(fs(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const i=t[n];if(fs(e.attrs,i.attrs,["LANGUAGE"]))return n}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let n=0;n<t.length;n++){if(ms(t[n],e))return n}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==d||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const n=this.currentTrack;if(n&<(e,n))return n;const i=ot(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(n)return null;{const n=ot(e,t);if(n>-1)return t[n]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const n=e.id,i=e.groupId,r=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading subtitle ${n} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type?" "+s.type||0:""):""} ${r}`),this.hls.trigger(l.SUBTITLE_TRACK_LOADING,{url:r,id:n,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ca(e.textTracks),n=this.currentTrack;let i;if(n&&(i=t.filter((e=>ms(n,e)))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(t).forEach((e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")})),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!i(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;const n=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r)return void this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:e});const s=!!r.details&&!r.details.live;if(e===this.trackId&&r===n&&s)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:c,type:u,url:h}=r;this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:c,type:u,url:h});const d=this.switchParams(r.url,null==n?void 0:n.details,r.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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}},e.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(l.FRAG_LOADING,this.onFragLoading,this),e.on(l.FRAG_LOADED,this.onFragLoaded,this),e.on(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(l.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(l.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(l.FRAG_LOADING,this.onFragLoading,this),e.off(l.FRAG_LOADED,this.onFragLoaded,this),e.off(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(l.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(l.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Oo(this,"textTrack1"),t=new Oo(this,"textTrack2"),n=new Oo(this,"textTrack3"),i=new Oo(this,"textTrack4");this.cea608Parser1=new ao(1,e,t),this.cea608Parser2=new ao(3,n,i)}addCues(e,t,n,i,r){let s=!1;for(let e=r.length;e--;){const i=r[e],l=(a=i[0],o=i[1],c=t,u=n,Math.min(o,u)-Math.max(a,c));if(l>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],n),s=!0,l/(n-t)>.5))return}var a,o,c,u;if(s||r.push([t,n]),this.config.renderTextTracksNatively){const r=this.captionsTracks[e];this.Cues.newCue(r,t,n,i)}else{const r=this.Cues.newCue(null,t,n,i);this.hls.trigger(l.CUES_PARSED,{type:"captions",cues:r,track:e})}}onInitPtsFound(e,{frag:t,id:n,initPTS:i,timescale:r,trackId:s}){const{unparsedVttFrags:a}=this;n===p&&(this.initPTS[t.cc]={baseTime:i,timescale:r,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach((e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(l.FRAG_LOADED,e):this.hls.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})})))}getExistingTrack(e,t){const{media:n}=this;if(n)for(let i=0;i<n.textTracks.length;i++){const r=n.textTracks[i];if(No(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:n,media:i}=this,{label:r,languageCode:s}=t[e],a=this.getExistingTrack(r,s);if(a)n[e]=a,Ea(n[e]),ka(n[e],i);else{const t=this.createTextTrack("captions",r,s);t&&(t[e]=!0,n[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const n={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(l.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,n){const i=this.media;if(i)return i.addTextTrack(e,t,n)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const n=!!t.transferMedia;if(this.media=null,n)return;const{captionsTracks:i}=this;Object.keys(i).forEach((e=>{Ea(i[e]),delete i[e]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Ea(t[e])}onSubtitleTracksUpdated(e,t){const n=t.subtitleTracks||[],i=n.some((e=>e.textCodec===So));if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(ps(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){const e=this.media,t=e?Ca(e.textTracks):null;if(this.tracks.forEach(((e,n)=>{let i;if(t){let n=null;for(let i=0;i<t.length;i++)if(t[i]&&No(t[i],e)){n=t[i],t[i]=null;break}n&&(i=n)}if(i)Ea(i);else{const t=Fo(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)})),null!=t&&t.length){const e=t.filter((e=>null!==e)).map((e=>e.label));e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map((e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e})));this.hls.trigger(l.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const n=`textTrack${t[1]}`,i=this.captionsProperties[n];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)}))}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===p){var n,i;const{cea608Parser1:e,cea608Parser2:r,lastSn:s}=this,{cc:a,sn:o}=t.frag,l=null!=(n=null==(i=t.part)?void 0:i.index)?n:-1;e&&r&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),r.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:n,payload:i}=t;if(n.type===m)if(i.byteLength){const e=n.decryptdata,r="stats"in t;if(null==e||!e.encrypted||r){const e=this.tracks[n.level],r=this.vttCCs;r[n.cc]||(r[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),e&&e.textCodec===So?this._parseIMSC1(n,i):this._parseVTTs(t)}}else this.hls.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const n=this.hls;Lo(t,this.initPTS[e.cc],(t=>{this._appendCues(t,e.level),n.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(t=>{n.logger.log(`Failed to parse IMSC1: ${t}`),n.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}_parseVTTs(e){var t;const{frag:n,payload:i}=e,{initPTS:r,unparsedVttFrags:s}=this,a=r.length-1;if(!r[n.cc]&&-1===a)return void s.push(e);const o=this.hls;ko(null!=(t=n.initSegment)&&t.data?ge(n.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(e=>{this._appendCues(e,n.level),o.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(t=>{const r="Missing initPTS for VTT MPEGTS"===t.message;r?s.push(e):this._fallbackToIMSC1(n,i),o.logger.log(`Failed to parse VTT cue: ${t}`),r&&a>n.cc||o.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})}))}_fallbackToIMSC1(e,t){const n=this.tracks[e.level];n.textCodec||Lo(t,this.initPTS[e.cc],(()=>{n.textCodec=So,this._parseIMSC1(e,t)}),(()=>{n.textCodec="wvtt"}))}_appendCues(e,t){const n=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach((e=>Sa(n,e)))}else{const i=this.tracks[t];if(!i)return;const r=i.default?"default":"subtitles"+t;n.trigger(l.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:n}=t;n.type===m&&this.onFragLoaded(l.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:n,samples:i}=t;if(n.type!==p||"NONE"!==this.closedCaptionsForLevel(n))for(let e=0;e<i.length;e++){const t=i[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();const n=this.extractCea608Data(t);this.cea608Parser1.addData(i[e].pts,n[0]),this.cea608Parser2.addData(i[e].pts,n[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:n,endOffsetSubtitles:i,type:r}){const{media:s}=this;if(s&&!(s.currentTime<n)){if(!r||"video"===r){const{captionsTracks:e}=this;Object.keys(e).forEach((i=>Ta(e[i],t,n)))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach((n=>Ta(e[n],t,i)))}}}extractCea608Data(e){const t=[[],[]],n=31&e[0];let i=2;for(let r=0;r<n;r++){const n=e[i++],r=127&e[i++],s=127&e[i++];if(0===r&&0===s)continue;if(0!=(4&n)){const e=3&n;0!==e&&1!==e||(t[e].push(r),t[e].push(s))}}return t}},audioStreamController:class extends Pi{constructor(e,t,n){super(e,t,n,"audio-stream-controller",f),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(l.LEVEL_LOADED,this.onLevelLoaded,this),e.on(l.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(l.BUFFER_RESET,this.onBufferReset,this),e.on(l.BUFFER_CREATED,this.onBufferCreated,this),e.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(l.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(l.FRAG_LOADING,this.onFragLoading,this),e.on(l.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(l.LEVEL_LOADED,this.onLevelLoaded,this),e.off(l.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(l.BUFFER_RESET,this.onBufferReset,this),e.off(l.BUFFER_CREATED,this.onBufferCreated,this),e.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(l.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(l.FRAG_LOADING,this.onFragLoading,this),e.off(l.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:n,initPTS:i,timescale:r,trackId:s}){if(n===p){const e=t.cc,n=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:r,trackId:s},this.log(`InitPTS for cc: ${e} found from main: ${i/r} (${i}/${r}) trackId: ${s}`),this.mainAnchor=t,this.state===Ri){const n=this.waitingData;(!n&&!this.loadingParts||n&&n.frag.cc!==e)&&this.syncWithAnchor(t,null==n?void 0:n.frag)}else!this.hls.hasEnoughToStart&&n&&n.cc!==e?(n.abortRequests(),this.syncWithAnchor(t,n)):this.state===ki&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var n;const i=(null==(n=this.mainFragLoading)?void 0:n.frag)||null;if(t&&(null==i?void 0:i.cc)===t.cc)return;const r=(i||e).cc,s=gt(this.getLevelDetails(),r,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===ki&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=xi);const n=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),n>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${n.toFixed(3)}`),e=n,this.state=ki):this.state=Ci,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case ki:this.doTickIdle();break;case Ci:{const{levels:e,trackId:t}=this,n=null==e?void 0:e[t],i=null==n?void 0:n.details;if(i&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(i))break;this.state=Ri}break}case Ti:this.checkRetryDate();break;case Ri:{const e=this.waitingData;if(e){const{frag:t,part:n,cache:i,complete:r}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=Ei;const e={frag:t,part:n,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),r&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=ki}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:n,media:i,trackId:r}=this,s=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||null==n||!n[r])return;const a=n[r],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=Ci,void(this.startFragRequested=!1);const c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,q,f));const u=this.getFwdBufferInfo(c,f);if(null===u)return;if(!this.switchingTrack&&this._streamEnded(u,o))return t.trigger(l.BUFFER_EOS,{type:"audio"}),void(this.state=Di);const h=u.len,d=t.maxBufferLength,m=o.fragments,g=m[0].start,_=this.getLoadPosition(),y=this.flushing?_:u.end;if(this.switchingTrack&&i){const e=_;o.PTSKnown&&e<g&&(u.end>g||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}if(h>=d&&!this.switchingTrack&&y<m[m.length-1].start)return;let v=this.getNextFragment(y,o);if(v&&this.isLoopLoading(v,y)&&(v=this.getNextFragmentLoopLoading(v,o,u,p,d)),!v)return void(this.bufferFlushed=!0);let b=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&b&&W(v)&&!v.endList&&(!o.live||!this.loadingParts&&y<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(b)===Nt&&(this.mainFragLoading=b=null),b&&W(b))){if(v.start>b.end){const e=this.fragmentTracker.getFragAtPos(y,p);e&&e.end>b.end&&(b=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(v.start>b.end)return}this.loadFragment(v,a,y)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map((e=>new et(e)))}onAudioTrackSwitching(e,t){const n=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),n?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==xi&&(this.setInterval(100),this.state=ki,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const n=this.cachedTrackLoadedData;n&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(l.AUDIO_TRACK_LOADED,n))}onAudioTrackLoaded(e,t){var n;const{levels:i}=this,{details:r,id:s,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${s} "${o.name}" of "${a}"`);const c=this.mainDetails;if(!c||r.endCC>c.endCC||c.expired)return this.cachedTrackLoadedData=t,void(this.state!==xi&&(this.state=Ci));this.cachedTrackLoadedData=null,this.log(`Audio track ${s} "${o.name}" of "${a}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const u=i[s];let h=0;if(r.live||null!=(n=u.details)&&n.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;var d;if(u.details)h=this.alignPlaylists(r,u.details,null==(d=this.levelLastLoaded)?void 0:d.details);r.alignedSliding||(_i(r,c),r.alignedSliding||yi(r,c),h=r.fragmentStart)}u.details=r,this.levelLastLoaded=u,this.startFragRequested||this.setStartPosition(c,h),this.hls.trigger(l.AUDIO_TRACK_UPDATED,{details:r,id:s,groupId:t.groupId}),this.state!==Ci||this.waitForCdnTuneIn(r)||(this.state=ki),this.tick()}_handleFragmentLoadProgress(e){var t;const n=e.frag,{part:i,payload:r}=e,{config:s,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(n.start);const u=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new hs(this.hls,f,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[n.cc],p=null==(t=n.initSegment)?void 0:t.data;if(void 0!==d){const e=!1,t=i?i.index:-1,s=-1!==t,a=new en(n.level,n.sn,n.stats.chunkCount,r.byteLength,t,s);h.push(r,p,u,"",n,i,c.totalduration,e,a,d)}else{this.log(`Unknown video PTS for cc ${n.cc}, waiting for video PTS before demuxing audio frag ${n.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:n,part:i,cache:new Fi,complete:!1};e.push(new Uint8Array(r)),this.state!==xi&&(this.state=Ri)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const n=t.tracks.audio;n&&(this.mediaBuffer=n.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===p&&W(t.frag)&&(this.mainFragLoading=t,this.state===ki&&this.tick())}onFragBuffered(e,t){const{frag:n,part:i}=t;if(n.type===f)if(this.fragContextChanged(n))this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(W(n)){this.fragPrevious=n;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(l.AUDIO_TRACK_SWITCHED,w({},e)))}this.fragBufferedComplete(n,i),this.media&&this.tick()}else this.audioOnly||n.type!==p||n.elementaryStreams.video||n.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var n;if(t.fatal)this.state=Mi;else switch(t.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(f,t);break;case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Ci||(null==(n=t.context)?void 0:n.type)!==h||(this.state=ki);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==G&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==G){this.flushing=!1,this.bufferFlushed=!0,this.state===Di&&(this.state=ki);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,f),this.tick())}}_handleTransmuxComplete(e){var t;const n="audio",{hls:i}=this,{remuxResult:r,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:c,level:u}=a,{details:h}=u,{audio:d,text:p,id3:f,initSegment:m}=r;if(!this.fragContextChanged(o)&&h){if(this.state=Li,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=m&&m.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(m,o))return;this._bufferInitSegment(u,m.tracks,e,s),i.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:n,tracks:m.tracks})}if(d){const{startPTS:e,endPTS:t,startDTS:n,endDTS:i}=d;c&&(c.elementaryStreams[q]={startPTS:e,endPTS:t,startDTS:n,endDTS:i}),o.setElementaryStreamInfo(q,e,t,n,i),this.bufferFragmentData(d,o,c,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=v({id:n,frag:o,details:h},f);i.trigger(l.FRAG_PARSING_METADATA,e)}if(p){const e=v({id:n,frag:o,details:h},p);i.trigger(l.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,n,i){if(this.state!==Li)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const r=t.audio;r.id=f;const s=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${s}/${r.codec}]`),s&&1===s.split(",").length&&(r.levelCodec=s),this.hls.trigger(l.BUFFER_CODECS,t);const a=r.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:n,part:null,chunkMeta:i,parent:n.type,data:a};this.hls.trigger(l.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,n){const i=this.fragmentTracker.getState(e);var r;if(this.switchingTrack||i===Pt||i===Ft)if(W(e))if(null!=(r=t.details)&&r.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Ri;const n=this.mainDetails;n&&n.fragmentStart!==t.details.fragmentStart&&yi(t.details,n)}else super.loadFragment(e,t,n);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:n,assocLang:i,characteristics:r,audioCodec:s,channels:a}=this.bufferedTrack;lt({name:t,lang:n,assocLang:i,characteristics:r,audioCodec:s,channels:a},e,ct)||(ht(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(l.AUDIO_TRACK_SWITCHED,w({},e))}},audioTrackController:class extends ds{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.LEVEL_LOADING,this.onLevelLoading,this),e.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.LEVEL_LOADING,this.onLevelLoading,this),e.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(l.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:n,groupId:i,details:r}=t,s=this.tracksInGroup[n];if(!s||s.groupId!==i)return void this.warn(`Audio track with id:${n} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Audio track ${n} "${s.name}" lang:${s.lang} group:${i} loaded [${r.startSN}-${r.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const n=t.audioGroups||null,i=this.groupIds;let r=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some((e=>-1===(null==i?void 0:i.indexOf(e))))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!n||-1!==n.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!r&&t){const n=ot(t,e,ct);if(n>-1)r=e[n];else{const e=ot(t,this.tracks);r=this.tracks[e]}}let i=this.findTrackId(r);-1===i&&r&&(i=this.findTrackId(null));const c={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==n?void 0:n.join(",")}`),this.hls.trigger(l.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(-1!==i&&-1===u)this.setAudioTrack(i);else if(e.length&&-1===u){var s;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==h||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const n=this.allAudioTracks;if(this.selectDefaultTrack=!1,n.length){const i=this.currentTrack;if(i&<(e,i,ct))return i;const r=ot(e,this.tracksInGroup,ct);if(r>-1){const e=this.tracksInGroup[r];return this.setAudioTrack(r),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const r=function(e,t,n,i,r){const s=t[i],a=t.reduce(((e,t,n)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(n),e}),{})[s.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,c=s.codecSet.substring(0,4),u=ut(t,i,(t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;const i=t.audioGroups,s=n.filter((e=>!i||-1!==i.indexOf(e.groupId)));return ot(e,s,r)>-1}));return u>-1?u:ut(t,i,(t=>{const i=t.audioGroups,s=n.filter((e=>!i||-1!==i.indexOf(e.groupId)));return ot(e,s,r)>-1}))}(e,t.levels,n,i,ct);if(-1===r)return null;t.nextLoadLevel=r}if(e.channels||e.audioCodec){const t=ot(e,n);if(t>-1)return n[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;const n=this.currentTrack,i=t[e],r=i.details&&!i.details.live;if(e===this.trackId&&i===n&&r)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(l.AUDIO_TRACK_SWITCHING,w({},i)),r)return;const s=this.switchParams(i.url,null==n?void 0:n.details,i.details);this.loadPlaylist(s)}findTrackId(e){const t=this.tracksInGroup;for(let n=0;n<t.length;n++){const i=t[n];if((!this.selectDefaultTrack||i.default)&&(!e||lt(e,i,ct)))return n}if(e){const{name:n,lang:i,assocLang:r,characteristics:s,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if(lt({name:n,lang:i,assocLang:r,characteristics:s,audioCodec:a,channels:o},t[e],ct))return e}for(let n=0;n<t.length;n++){const i=t[n];if(fs(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const i=t[n];if(fs(e.attrs,i.attrs,["LANGUAGE"]))return n}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&ht(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const n=e.id,i=e.groupId,r=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading audio-track ${n} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type?" "+s.type||0:""):""} ${r}`),this.hls.trigger(l.AUDIO_TRACK_LOADING,{url:r,id:n,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:ya,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:ks.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const{frag:t,part:n}=e,i=this.hls.levels[t.level],r=this.getObjectType(t),s={d:1e3*(n||t).duration,ot:r};r!==ks.VIDEO&&r!==ks.AUDIO&&r!=ks.MUXED||(s.br=i.bitrate/1e3,s.tb=this.getTopBandwidth(r)/1e3,s.bl=this.getBufferLength(r));const a=n?this.getNextPart(n):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(s.nor=a.url),this.apply(e,s)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:n}=t;null!=n&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||e.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHED,this.onMediaDetached,this),e.on(l.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHED,this.onMediaDetached,this),e.off(l.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var n,i;this.audioBuffer=null==(n=t.tracks.audio)?void 0:n.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:Ss.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){v(t,this.createData());const n=t.ot===ks.INIT||t.ot===ks.VIDEO||t.ot===ks.MUXED;this.starved&&n&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce(((e,n)=>(i.includes(n)&&(e[n]=t[n]),e)),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),da(e.headers,t,r)):e.url=ma(e.url,t,r)}getNextFrag(e){var t;const n=null==(t=this.hls.levels[e.level])?void 0:t.details;if(n){const t=e.sn-n.startSN;return n.fragments[t+1]}}getNextPart(e){var t;const{index:n,fragment:i}=e,r=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(r){const{sn:e}=i;for(let t=r.length-1;t>=0;t--){const i=r[t];if(i.index===n&&i.fragment.sn===e)return r[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?ks.TIMED_TEXT:"initSegment"===e.sn?ks.INIT:"audio"===t?ks.AUDIO:"main"===t?this.hls.audioTracks.length?ks.VIDEO:ks.MUXED:void 0}getTopBandwidth(e){let t,n=0;const i=this.hls;if(e===ks.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,n=e>-1?e+1:i.levels.length;t=i.levels.slice(0,n)}return t.forEach((e=>{e.bitrate>n&&(n=e.bitrate)})),n>0?n:NaN}getBufferLength(e){const t=this.media,n=e===ks.AUDIO?this.audioBuffer:this.videoBuffer;if(!n||!t)return NaN;return 1e3*nn.bufferInfo(n,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,n=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new n(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,n,i){t(e),this.loader.load(e,n,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,n=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new n(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,n,i){t(e),this.loader.load(e,n,i)}}}},contentSteeringController:class extends x{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce(((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e)),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter((t=>t!==e)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:n}=t;null!==n&&(this.pathwayId=n.pathwayId,this.uri=n.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:n}=t;if((null==n?void 0:n.action)===Tt&&n.flags===Dt){const e=this.levels;let i=this._pathwayPriority,r=this.pathwayId;if(t.context){const{groupId:n,pathwayId:i,type:s}=t.context;n&&e?r=this.getPathwayForGroupId(n,s,r):i&&(r=i)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),n.resolved=this.pathwayId!==r),t.details!==o.BUFFER_APPEND_ERROR||t.fatal?n.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${e?e.length:e} priorities: ${it(i)} penalized: ${it(this.penalizedPathways)}`):n.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const n=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${n}"`),t=this.getLevelsForPathway(n),this.pathwayId=n}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter((t=>e===t.pathwayId))}updatePathwayPriority(e){let t;this._pathwayPriority=e;const n=this.penalizedPathways,i=performance.now();Object.keys(n).forEach((e=>{i-n[e]>3e5&&delete n[e]}));for(let i=0;i<e.length;i++){const r=e[i];if(r in n)continue;if(r===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(t=this.getLevelsForPathway(r),t.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,hi(t),this.hls.trigger(l.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=s);break}}}getPathwayForGroupId(e,t,n){const i=this.getLevelsForPathway(n).concat(this.levels||[]);for(let n=0;n<i.length;n++)if(t===h&&i[n].hasAudioGroup(e)||t===d&&i[n].hasSubtitleGroup(e))return i[n].pathwayId;return n}clonePathways(e){const t=this.levels;if(!t)return;const n={},i={};e.forEach((e=>{const{ID:r,"BASE-ID":s,"URI-REPLACEMENT":a}=e;if(t.some((e=>e.pathwayId===r)))return;const o=this.getLevelsForPathway(s).map((e=>{const t=new hn(e.attrs);t["PATHWAY-ID"]=r;const s=t.AUDIO&&`${t.AUDIO}_clone_${r}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${r}`;s&&(n[t.AUDIO]=s,t.AUDIO=s),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=_a(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new et({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)c.addGroupId("audio",`${e.audioGroups[t]}_clone_${r}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)c.addGroupId("text",`${e.subtitleGroups[t]}_clone_${r}`);return c}));t.push(...o),ga(this.audioTracks,n,a,r),ga(this.subtitleTracks,i,a,r)}))}loadSteeringManifest(e){const t=this.hls.config,n=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new n(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const r={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(e,t,n,r)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==(null==s?void 0:s.VERSION))return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":c}=s;if(a)try{this.uri=new self.URL(a,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||n.url),o&&this.clonePathways(o);const u={steeringManifest:s,url:i.toString()};this.hls.trigger(l.STEERING_MANIFEST_LOADED,u),c&&this.updatePathwayPriority(c)},onError:(e,t,n,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let r=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,r);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(r=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,n)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(r,o,c)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var t;const n=null==(t=this.hls)?void 0:t.media;!n||n.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)}),t)}},interstitialsController:class extends x{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;const t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;const n=t<=-.01;this.timelinePos=e,this.bufferedPos=e;const i=this.playingItem;if(!i)return void this.checkBuffer();if(n){this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0)}if(this.checkBuffer(),n&&e<i.start||e>=i.end){var r;const t=this.findItemIndex(i);let s=this.schedule.findItemIndexAtTime(e);if(-1===s&&(s=t+(n?-1:1),this.log(`seeked ${n?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${s})`)),!this.isInterstitial(i)&&null!=(r=this.media)&&r.paused&&(this.shouldPlay=!1),!n&&s>t){const e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(s)}const s=this.playingAsset;if(!s){if(this.playingLastItem&&this.isInterstitial(i)){const t=i.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}const a=s.timelineStart,o=s.duration||0;var l;(n&&e<a||e>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearInterstitial(i.event,i),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,s))},this.onTimeupdate=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();const t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}const n=this.playingAsset;if(!n)return;e>=n.timelineStart+(n.duration||0)&&this.setScheduleToAssetAtTime(e,n)},this.onScheduleUpdate=(e,t)=>{const n=this.schedule;if(!n)return;const i=this.playingItem,r=n.events||[],s=n.items||[],a=n.durations,o=e.map((e=>e.identifier)),c=!(!r.length&&!o.length);(c||t)&&this.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${s.map((e=>$a(e)))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let u=null,h=null;i&&(u=this.updateItem(i,this.timelinePos),this.itemsMatch(i,u)?this.playingItem=u:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const d=this.bufferingItem;if(d&&(h=this.updateItem(d,this.bufferedPos),this.itemsMatch(d,h)?this.bufferingItem=h:d.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(d.event,null))),e.forEach((e=>{e.assetList.forEach((e=>{this.clearAssetPlayer(e.identifier,null)}))})),this.playerQueue.forEach((e=>{if(e.interstitial.appendInPlace){const t=e.assetItem.timelineStart,n=e.timelineOffset-t;if(n)try{e.timelineOffset=t}catch(i){Math.abs(n)>Aa&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}})),c||t){if(this.hls.trigger(l.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:s.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(u,i),d&&h!==u&&this.trimInPlace(h,d),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Ka(e),this.schedule=new Ba(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(l.BUFFER_APPENDED,this.onBufferAppended,this),e.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(l.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(l.MEDIA_ENDED,this.onMediaEnded,this),e.on(l.ERROR,this.onError,this),e.on(l.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(l.BUFFER_CODECS,this.onBufferCodecs,this),e.off(l.BUFFER_APPENDED,this.onBufferAppended,this),e.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(l.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(l.MEDIA_ENDED,this.onMediaEnded,this),e.off(l.ERROR,this.onError,this),e.off(l.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){bi(e,"play",this.onPlay),bi(e,"pause",this.onPause),bi(e,"seeking",this.onSeeking),bi(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const n=this.media=t.media;vi(n,"seeking",this.onSeeking),vi(n,"timeupdate",this.onTimeupdate),vi(n,"play",this.onPlay),vi(n,"pause",this.onPause)}onMediaAttached(e,t){const n=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===n)this.checkStart();else if(!i){this.clearScheduleState();const e=this.findItemIndex(n);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const n=!!t.transferMedia,i=this.media;if(this.media=null,!n&&(i&&this.removeMediaListeners(i),this.detachedData)){const e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,n=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,s,a,o)=>{if(t){let l=t[i].start;const c=t.event;if(c){if("playout"===i||c.timelineOccupancy!==Da.Point){const e=n(s);(null==e?void 0:e.interstitial)===c&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?r():e[a])-t.start}return l}return 0},r=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=t=>{var n,i;return null!=(n=e.primaryDetails)&&n.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},a=(t,r)=>{var s,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(s=o.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${r}"`);const l=e.effectivePlayingItem,c=e.schedule.findItemIndexAtTime(t,r),u=null==(a=e.schedule.items)?void 0:a[c],h=e.getBufferingPlayer(),d=null==h?void 0:h.interstitial,p=null==d?void 0:d.appendInPlace,f=l&&e.itemsMatch(l,u);if(l&&(p||f)){const s=n(e.playingAsset),a=(null==s?void 0:s.media)||e.primaryMedia;if(a){const n="primary"===r?a.currentTime:i(l,r,e.playingAsset,"timelinePos","currentTime"),o=t-n,c=(p?n:a.currentTime)+o;if(c>=0&&(!s||p||c<=s.duration))return void(a.currentTime=c)}}if(u){let n=t;if("primary"!==r){const e=t-u[r].start;n=u.start+e}const i=!e.isInterstitial(u);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!u.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(c>s){const t=e.schedule.findJumpRestrictedIndex(s+1,c);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=n,e.checkBuffer();else{const e=u.event.assetList,n=t-(u[r]||u).start;for(let t=e.length;t--;){const i=e[t];if(i.duration&&n>=i.startOffset&&n<i.startOffset+i.duration){a=t;break}}}e.setSchedulePosition(c,a)}}else{const t=e.media||(p?null==h?void 0:h.media:null);t&&(t.currentTime=n)}}},o=()=>{const n=e.effectivePlayingItem;if(e.isInterstitial(n))return n;const i=t();return e.isInterstitial(i)?i:null},l={get bufferedEnd(){const n=t(),r=e.bufferingItem;var s;return r&&r===n&&(i(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(s=e.bufferingAsset)?void 0:s.startOffset))||0},get currentTime(){const t=o(),n=e.effectivePlayingItem;return n&&n===t?i(n,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-n.playout.start:0},set currentTime(t){const n=o(),i=e.effectivePlayingItem;i&&i===n&&a(t+i.playout.start,"playout")},get duration(){const e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;const n=null==(t=o())?void 0:t.event.assetList;return n?n.map((t=>e.getAssetPlayer(t.identifier))):[]},get playingIndex(){var t;const n=null==(t=o())?void 0:t.event;return n&&e.effectivePlayingAsset?n.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const n=t();return e.findItemIndex(n)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return r()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return s("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){a(e,"integrated")},get duration(){return s("integrated")},get seekableStart(){var t;return((t,n)=>{var i;if(0!==t&&"primary"!==n&&null!=(i=e.schedule)&&i.length){var r;const i=e.schedule.findItemIndexAtTime(t),s=null==(r=e.schedule.items)?void 0:r[i];if(s)return t+(s[n].start-s.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{const t=e.effectivePlayingItem,n=null==t?void 0:t.event;if(n&&!n.restrictions.skip){const i=e.findItemIndex(t);if(n.appendInPlace){const e=t.playout.start+t.event.duration;a(e+.001,"playout")}else e.advanceAfterAssetEnded(n,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,n=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&n)&&this.findItemIndex(t)===n.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;const n=this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&!n.event.appendInPlace)return;let r=this.media;!r&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(r=this.primaryMedia);const s=null==(t=r)?void 0:t.currentTime;return void 0!==s&&i(s)?s:void 0}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!(null==e||!e.event)}retreiveMediaSource(e,t){const n=this.getAssetPlayer(e);n&&this.transferMediaFromPlayer(n,t)}transferMediaFromPlayer(e,t){const n=e.interstitial.appendInPlace,i=e.media;if(n&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});const n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${it(n)}`),this.detachedData=n}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var n,i;if(e.media===t)return;let r=null;const s=this.hls,a=e!==s,o=a&&e.interstitial.appendInPlace,l=null==(n=this.detachedData)?void 0:n.mediaSource;let c;if(s.media)o&&(r=s.transferMedia(),this.detachedData=r),c="Primary";else if(l){const e=this.getBufferingPlayer();e?(r=e.transferMedia(),c=`${e}`):c="detached MediaSource"}else c="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${it(r)}`);else if(!this.detachedData||s.media===t){const e=this.playerQueue;e.length>1&&e.forEach((e=>{if(a&&e.interstitial.appendInPlace!==o){const t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}})),this.hls.detachMedia(),this.detachedData={media:t}}const u=r&&"mediaSource"in r&&"closed"!==(null==(i=r.mediaSource)?void 0:i.readyState),h=u&&r?r:t;this.log(`${u?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const d=this.schedule;if(h===r&&d){const t=a&&e.assetId===d.assetIdAtEnd;h.overrides={duration:d.duration,endOfStream:!a||t,cueRemoval:!a}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const n=this.timelinePos,i=this.effectivePlayingItem;if(-1===n){const n=this.hls.startPosition;if(this.log(za("checkStart",n)),this.timelinePos=n,t.length&&t[0].cue.pre){const n=e.findEventIndex(t[0].identifier);this.setSchedulePosition(n)}else if(n>=0||!this.primaryLive){const t=this.timelinePos=n>0?n:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const t=e.findItemIndex(i);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){const n=e.event,i=n.findAssetIndex(t),r=Oa(n,i);if(n.isAssetPastPlayoutLimit(r)){if(this.schedule){var s;const t=null==(s=this.schedule.items)?void 0:s[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,r)}advanceAfterAssetEnded(e,t,n){const i=Oa(e,n);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const n=this.schedule.items;if(n){const i=t+1;if(i>=n.length)return void this.setSchedulePosition(-1);const r=e.resumeTime;this.timelinePos<r&&(this.log(za("advanceAfterAssetEnded",r)),this.timelinePos=r,e.appendInPlace&&this.advanceInPlace(r),this.checkBuffer(this.bufferedPos<r)),this.setSchedulePosition(i)}}}else{if(e.appendInPlace){const t=e.assetList[i];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const n=this.schedule;if(!n)return;const i=t.parentIdentifier,r=n.getEvent(i);if(r){const t=n.findEventIndex(i),s=n.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,t,s-1)}}setSchedulePosition(e,t){var n;const i=null==(n=this.schedule)?void 0:n.items;if(!i||this.playbackDisabled)return;const r=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${r?$a(r):r}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const n=s.event,u=this.playingAsset,h=null==u?void 0:u.identifier,d=h?this.getAssetPlayer(h):null;if(d&&h&&(!this.eventItemsMatch(s,r)||void 0!==t&&h!==n.assetList[t].identifier)){var o;const t=n.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${n.assetList.length} ${Fa(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(l.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:t,event:n,schedule:i.slice(0),scheduleIndex:e,player:d}),s!==this.playingItem)return void(this.itemsMatch(s,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(n,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(h,r),!d.media||null!=(o=this.detachedData)&&o.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(s,r)&&(this.endedItem=s,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${n} ${$a(s)}`),n.hasPlayed=!0,this.hls.trigger(l.INTERSTITIAL_ENDED,{event:n,schedule:i.slice(0),scheduleIndex:e}),n.cue.once)){var c;this.updateSchedule();const e=null==(c=this.schedule)?void 0:c.items;if(r&&e){const n=this.findItemIndex(r);this.advanceSchedule(n,e,t,s,a)}return}}this.advanceSchedule(e,i,t,s,a)}advanceSchedule(e,t,n,i,r){const s=this.schedule;if(!s)return;const a=t[e]||null,o=this.primaryMedia,c=this.playerQueue;if(c.length&&c.forEach((t=>{const n=t.interstitial,i=s.findEventIndex(n.identifier);(i<e||i>e+1)&&this.clearInterstitial(n,a)})),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const r=a.event;if(void 0===n){const t=Oa(r,(n=s.findAssetIndex(r,this.timelinePos))-1);if(r.isAssetPastPlayoutLimit(t)||r.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(r,e,n);n=t}const c=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let u=this.preloadAssets(r,n);if(this.eventItemsMatch(a,c||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${$a(a)} ${r.appendInPlace?"append in place":""}`),this.hls.trigger(l.INTERSTITIAL_STARTED,{event:r,schedule:t.slice(0),scheduleIndex:e})),!r.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${r}`);if(r.assetListLoader&&(r.assetListLoader.destroy(),r.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${r}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const h=r.assetList[n];if(!h)return void this.advanceAfterAssetEnded(r,e,n||0);if(u||(u=this.getAssetPlayer(h.identifier)),null===u||u.destroyed){const e=r.assetList.length;this.warn(`asset ${n+1}/${e} player destroyed ${r}`),u=this.createAssetPlayer(r,h,n),u.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&r.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(u,n,t,e,o),this.shouldPlay&&Ua(u.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&Ua(this.hls.media)):r&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(s.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!(null==(e=this.primaryDetails)||!e.live)}resumePrimary(e,t,n){var i,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${$a(e)}`),null==(i=this.detachedData)||!i.mediaSource){let n=this.timelinePos;(n<e.start||n>=e.end)&&(n=this.getPrimaryResumption(e,t),this.log(za("resumePrimary",n)),this.timelinePos=n),this.attachPrimary(n,e)}if(!n)return;const s=null==(r=this.schedule)?void 0:r.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${$a(e)}`),this.hls.trigger(l.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const n=e.start;if(this.primaryLive){const e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(n<e.fragmentStart||n>e.edge))return this.hls.liveSyncPosition||-1}return n}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);if(null!=t&&t.hls)return t.hls.bufferedToEnd;return nn.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,n){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,i),n&&this.startLoadingPrimaryAt(e,n)),n||(this.log(za("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,n))}startLoadingPrimaryAt(e,t){var n;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(n=i.mainForwardBufferInfo)?void 0:n.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(l.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(l.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;const n=this.hls.levels[t.level];if(!n.details)return;const i=w(w({},this.mediaSelection||this.altSelection),{},{main:n});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const n=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=w(w({},this.altSelection),{},{audio:n}));const r=w(w({},i),{},{audio:n});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const n=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=w(w({},this.altSelection),{},{subtitles:n}));const r=w(w({},i),{},{subtitles:n});this.mediaSelection=r}onAudioTrackSwitching(e,t){const n=at(t);this.playerQueue.forEach((({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(n))))}onSubtitleTrackSwitch(e,t){const n=at(t);this.playerQueue.forEach((({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(n))))}onBufferCodecs(e,t){const n=t.tracks;n&&(this.requiredTracks=n)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const n=this.playingItem;if(n&&!this.itemsMatch(n,this.bufferingItem)&&!this.isInterstitial(n)){const e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){const i=t[e];if(i.cue.post){var n;const e=this.schedule.findEventIndex(i.identifier),t=null==(n=this.schedule.items)?void 0:n[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var n;const i=null==(n=this.schedule)?void 0:n.items;if(e&&i){return i[this.findItemIndex(e,t)]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach(((t,n)=>{e.event.isAssetPastPlayoutLimit(n)&&this.clearAssetPlayer(t.identifier,null)}));const n=e.end+.25,i=nn.bufferInfo(this.primaryMedia,n,0);if(i.end>n||(i.nextStart||0)>n){this.log(`trim buffered interstitial ${$a(e)} (was ${$a(t)})`);const i=!0;this.attachPrimary(n,null,i),this.flushFrontBuffer(n)}}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var n;return!!t&&(e===t||e.event.identifier===(null==(n=t.event)?void 0:n.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const n=this.mediaSelection;n&&(null==(t=this.schedule)||t.updateSchedule(n,[],e))}checkBuffer(e){var t;const n=null==(t=this.schedule)?void 0:t.items;if(!n)return;const i=nn.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,n,e)}updateBufferedPos(e,t,n){const i=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],r))return void(this.bufferedPos=e);const s=this.playingItem,a=this.findItemIndex(s);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const n=this.findItemIndex(r),i=Math.min(n+1,t.length-1),s=t[i];if((-1===o&&r&&e>=r.end||null!=(l=s.event)&&l.appendInPlace&&e+.01>=s.start)&&(o=i),this.isInterstitial(r)){const e=r.event;if(i-a>1&&!1===e.appendInPlace)return;if(0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>n&&o>a)this.bufferedToItem(s);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else n&&s&&!this.itemsMatch(s,r)&&(o===a?this.bufferedToItem(s):o===a+1&&this.bufferedToItem(t[o]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some((e=>{const n=this.getAssetPlayer(e.identifier);return!(null!=n&&n.bufferedInPlaceToEnd(t))}))}setBufferingItem(e){const t=this.bufferingItem,n=this.schedule;if(!this.itemsMatch(e,t)&&n){const{items:i,events:r}=n;if(!i||!r)return t;const s=this.isInterstitial(e),a=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const o=a?a.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${$a(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){const t=n.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach(((e,n)=>{const i=this.getAssetPlayer(e.identifier);i&&(n===t&&i.loadSource(),i.resumeBuffering())}))}else this.hls.resumeBuffering(),this.playerQueue.forEach((e=>e.pauseBuffering()));this.hls.trigger(l.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const n=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==n){this.bufferingAsset=null;const t=this.detachedData;if(t)if(t.mediaSource){const t=!0;this.attachPrimary(e.start,e,t)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}preloadPrimary(e){const t=this.findItemIndex(e),n=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(n)}bufferedToEvent(e,t){const n=e.event,i=0===n.assetList.length&&!n.assetListLoader,r=n.cue.once;if(i||!r){const e=this.preloadAssets(n,t);if(null!=e&&e.interstitial.appendInPlace){const t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){const n=e.assetUrl,i=e.assetList.length,r=0===i&&!e.assetListLoader,s=e.cue.once;if(r){const r=e.timelineStart;if(e.appendInPlace){var a;const t=this.playingItem;this.isInterstitial(t)||(null==t||null==(a=t.nextEvent)?void 0:a.identifier)!==e.identifier||this.flushFrontBuffer(r+.25)}let s,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!e.cue.pre&&!e.cue.post){const e=o-r;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${n?1:i} ${e}${s?` live-start: ${o} start-offset: ${s}`:""}`),n)return this.createAsset(e,0,0,r,e.duration,n);const l=this.assetListLoader.loadAssetList(e,s);l&&(e.assetListLoader=l)}else if(!s&&i){for(let n=t;n<i;n++){const t=e.assetList[n],i=this.getAssetPlayerQueueIndex(t.identifier);-1!==i&&!this.playerQueue[i].destroyed||t.error||this.createAssetPlayer(e,t,n)}const n=e.assetList[t];if(n){const e=this.getAssetPlayer(n.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`);Object.keys(t).forEach((t=>{this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let n=0;n<t.length;n++)if(e===t[n].assetId)return n;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t)for(let n=0;n<e.length;n++)if(e[n].media===t)return e[n];return null}createAsset(e,t,n,i,r,s){const a={parentIdentifier:e.identifier,identifier:Ma(e,s,t),duration:r,startOffset:n,timelineStart:i,uri:s};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,n){const i=this.hls,r=i.userConfig;let s=r.videoPreference;const c=i.loadLevelObj||i.levels[i.currentLevel];(s||c)&&(s=v({},s),c.videoCodec&&(s.videoCodec=c.videoCodec),c.videoRange&&(s.allowedVideoRanges=[c.videoRange]));const u=i.audioTracks[i.audioTrack],h=i.subtitleTracks[i.subtitleTrack];let d=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const n=t.duration;n&&e<n&&(d=e)}}const p=t.identifier,f=w(w({},r),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:p,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:u||r.audioPreference,subtitlePreference:h||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(f.timelineOffset=t.timelineStart));const m=f.cmcd;null!=m&&m.sessionId&&m.contentId&&(f.cmcd=v({},m,{contentId:La(t.uri)})),this.getAssetPlayer(p)&&this.warn(`Duplicate date range identifier ${e} and asset ${p}`);const g=new Na(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[n]=t;let _=!0;const y=i=>{if(i.live){var r;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=(null==(r=this.schedule)?void 0:r.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,s,n,t.message)}const s=i.edge-i.fragmentStart,l=t.duration;(_||null===l||s>l)&&(_=!1,this.log(`Interstitial asset "${p}" duration change ${l} > ${s}`),t.duration=s,this.updateSchedule())};g.on(l.LEVEL_UPDATED,((e,{details:t})=>y(t))),g.on(l.LEVEL_PTS_UPDATED,((e,{details:t})=>y(t))),g.on(l.EVENT_CUE_ENTER,(()=>this.onInterstitialCueEnter()));const b=(e,t)=>{const n=this.getAssetPlayer(p);if(n&&t.tracks){n.off(l.BUFFER_CODECS,b),n.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===n.assetItem&&e&&!n.media&&this.bufferAssetPlayer(n,e)}};g.on(l.BUFFER_CODECS,b);g.on(l.BUFFERED_TO_END,(()=>{var n;const i=this.getAssetPlayer(p);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const r=this.schedule.findEventIndex(e.identifier),s=null==(n=this.schedule.items)?void 0:n[r];this.isInterstitial(s)&&this.advanceAssetBuffering(s,t)}));const x=t=>()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;this.shouldPlay=!0;const n=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,n,t)};return g.once(l.MEDIA_ENDED,x(n)),g.once(l.PLAYOUT_LIMIT_REACHED,x(1/0)),g.on(l.ERROR,((t,i)=>{if(!this.schedule)return;const r=this.getAssetPlayer(p);if(i.details===o.BUFFER_STALLED_ERROR)return null!=r&&r.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),n,`Asset player error ${i.error} ${e}`)})),g.on(l.DESTROYING,(()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${p}`),i={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),n,t.message)})),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Fa(t)}`),this.hls.trigger(l.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:n,event:e,player:g}),g}clearInterstitial(e,t){e.assetList.forEach((e=>{this.clearAssetPlayer(e.identifier,t)})),e.reset()}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);const n=this.playerQueue[t];this.transferMediaFromPlayer(n,null),n.resetDetails()}}clearAssetPlayer(e,t){const n=this.getAssetPlayerQueueIndex(e);if(-1!==n){const e=this.playerQueue[n];this.log(`clear ${e} toSegment: ${t?$a(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(n,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,n,i,r){const{interstitial:s,assetItem:a,assetId:o}=e,c=s.assetList.length,u=this.playingAsset;this.endedAsset=null,this.playingAsset=a,u&&u.identifier===o||(u&&(this.clearAssetPlayer(u.identifier,n[i]),delete u.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${c} ${Fa(a)}`),this.hls.trigger(l.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:s,schedule:n.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var n,i;if(!this.schedule)return;const{interstitial:r,assetItem:s}=e,l=this.schedule.findEventIndex(r.identifier),c=null==(n=this.schedule.items)?void 0:n[l];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=s;const u=this.getBufferingPlayer();if(u===e)return;const h=r.appendInPlace;if(h&&!1===(null==u?void 0:u.interstitial.appendInPlace))return;const d=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(h&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!D(d,e.tracks)){const t=new Error(`Asset ${Fa(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),n={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=r.findAssetIndex(s);return void this.handleAssetItemError(n,r,l,i,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,n=this.primaryMedia;if(!t||!n)return;const i=n.currentTime,r=t.findAssetIndex(e,i),s=e.assetList[r];if(s){const a=this.getAssetPlayer(s.identifier);if(a){const o=a.currentTime||i-s.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${e} (media.currentTime: ${i})`),o&&(l/n.playbackRate<.5||a.bufferedInPlaceToEnd(n))&&a.hls){const n=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,n,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,n,i,r){if(e.details===o.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?Fa(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",c=this.getAssetPlayerQueueIndex(a),u=this.playerQueue[c]||null,h=this.schedule.items,d=v({},e,{fatal:!1,errorAction:It(!0),asset:s,assetListIndex:i,event:t,schedule:h,scheduleIndex:n,player:u});if(this.hls.trigger(l.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const p=this.playingAsset,f=this.bufferingAsset,m=new Error(r);if(s&&(this.clearAssetPlayer(a,null),s.error=m),t.assetList.some((e=>!e.error)))for(let e=i;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):p&&p.identifier===a?this.advanceAfterAssetEnded(t,n,i):f&&f.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(e){const t=e.timelineStart,n=this.effectivePlayingItem;if(n){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${$a(n)} error: ${e.error}`);let i=this.timelinePos;-1===i&&(i=this.hls.startPosition);const r=this.updateItem(n,i);if(this.itemsMatch(n,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t)),!this.schedule)return;const s=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(s)}else this.checkStart()}onAssetListLoaded(e,t){var n,i;const r=t.event,s=r.identifier,a=t.assetListResponse.ASSETS;if(null==(n=this.schedule)||!n.hasEvent(s))return;const o=r.timelineStart,l=r.duration;let c=0;a.forEach(((e,t)=>{const n=parseFloat(e.DURATION);this.createAsset(r,t,c,o+c,n,e.URI),c+=n})),r.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${r}`);const u=this.waitingItem,h=(null==u?void 0:u.event.identifier)===s;this.updateSchedule();const d=null==(i=this.bufferingItem)?void 0:i.event;if(h){var p;const e=this.schedule.findEventIndex(s),t=null==(p=this.schedule.items)?void 0:p[e];if(t){if(!this.playingItem&&this.timelinePos>t.end){if(this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return r.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${r}`),this.updateSchedule(!0),void this.primaryFallback(r)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==d?void 0:d.identifier)===s){const e=r.assetList[0];if(e){const t=this.getAssetPlayer(e.identifier);if(d.appendInPlace){const e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case o.ASSET_LIST_PARSING_ERROR:case o.ASSET_LIST_LOAD_ERROR:case o.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case o.BUFFER_STALLED_ERROR:{const e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function jo(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(jo):Object.keys(e).reduce(((t,n)=>(t[n]=jo(e[n]),t)),{}):e}function Wo(e,t){const n=e.loader;if(n!==Uo&&n!==Go)t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=Uo,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class Zo extends Qt{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;const n=this.media=t.media;vi(n,"playing",this.onMediaPlaying),vi(n,"waiting",this.onMediaWaiting),vi(n,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:n}=this;n&&(bi(n,"playing",this.onMediaPlaying),bi(n,"waiting",this.onMediaWaiting),bi(n,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var n,i;const r=null==(n=this.hls)?void 0:n.config;if(!r)return;const s=this.media;if(!s)return;const{seeking:a}=s,o=this.seeking&&!a,c=!this.seeking&&a,u=s.paused&&!a||s.ended||0===s.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!u&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(c||o)return void(o&&this.stallResolved(e));if(u)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1})));if(!nn.getBuffered(s).length)return void(this.nudgeRetry=0);const h=nn.bufferInfo(s,e,0),d=h.nextStart||0,p=this.fragmentTracker;if(a&&p&&this.hls){const t=Yo(this.hls.inFlightFragments,e),n=h.len>2,i=!d||t||d-e>2&&!p.getPartialFragment(e);if(n||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&p){if(!(h.len>0)&&!d)return;const t=Math.max(d,h.start||0)-e,n=!(null==f||!f.live)?2*f.targetduration:2,i=Jo(e,p);if(t>0&&(t<=n||i))return void(s.paused||this._trySkipBufferHole(i))}const m=r.detectStallWithCurrentTimeMs,g=self.performance.now(),_=this.waiting;let y=this.stalled;if(null===y){if(!(_>0&&g-_<m))return void(this.stalled=g);y=this.stalled=_}const v=g-y;if(!a&&(v>=m||_)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==f||!f.live)&&Math.abs(e-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(l.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media||!this.hls)return}const w=nn.bufferInfo(s,e,r.maxBufferHole);this._tryFixBufferStall(w,v,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const n=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(n)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(l.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var n;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(n=this.buffered.audio)&&n.length&&i&&i.length>1&&e>i.end(0)){const n=nn.bufferedInfo(nn.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const n=nn.timeRangesToArray(i),r=nn.bufferedInfo(n,t,0).bufferedIndex;if(r>-1&&r<n.length-1){const t=nn.bufferedInfo(n,e,0).bufferedIndex,i=n[r].end,s=n[r+1].start;if((-1===t||t>r)&&s-i<1&&e-i<2){const n=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${s} buffered index: ${t}`);this.warn(n.message),this.media.currentTime+=1e-6;let r=Jo(e,this.fragmentTracker);r&&"fragment"in r?r=r.fragment:r||(r=void 0);const c=nn.bufferInfo(this.media,e,0);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:n,reason:n.message,frag:r,buffer:c.len,bufferInfo:c})}}}}}_tryFixBufferStall(e,t,n){var i,r;const{fragmentTracker:s,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!s||!o)return;const l=null==(r=this.hls)?void 0:r.latestLevelDetails,c=Jo(n,s);if(c||null!=l&&l.live&&n<l.fragmentStart){if(this._trySkipBufferHole(c)||!this.media)return}const u=e.buffered,h=this.adjacentTraversal(e,n);(u&&u.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-n<o.maxBufferHole||h))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const n=this.fragmentTracker,i=e.nextStart;if(n&&i){const e=n.getFragAtPos(t,p),r=n.getFragAtPos(i,p);if(e&&r)return r.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:n,stallReported:i,stalled:r}=this;if(!i&&null!==r&&n&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${n.currentTime} due to low buffer (${it(e)})`);this.warn(i.message),t.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:n,media:i}=this,r=null==(t=this.hls)?void 0:t.config;if(!i||!n||!r)return 0;const s=i.currentTime,c=nn.bufferInfo(i,s,0),u=s<c.start?c.start:c.nextStart;if(u&&this.hls){const t=c.len<=r.maxBufferHole,d=c.len>0&&c.len<1&&i.readyState<3,f=u-s;if(f>0&&(t||d)){if(f>r.maxBufferHole){let t=!1;if(0===s){const e=n.getAppendedFrag(0,p);e&&u<e.end&&(t=!0)}if(!t&&e){var h;if(null==(h=this.hls.loadLevelObj)||!h.details)return 0;if(Yo(this.hls.inFlightFragments,u))return 0;let t=!1,i=e.end;for(;i<u;){const e=Jo(i,n);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(u+.05,s+.1);if(this.warn(`skipping hole, adjusting currentTime from ${s} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const n=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${t}`),i={type:a.MEDIA_ERROR,details:o.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:n,reason:n.message,buffer:c.len,bufferInfo:c};e&&("fragment"in e?i.part=e:i.frag=e),this.hls.trigger(l.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:n,nudgeRetry:i}=this,r=null==t?void 0:t.config;if(!n||!r)return 0;const s=n.currentTime;if(this.nudgeRetry++,i<r.nudgeMaxRetry){const c=s+(i+1)*r.nudgeOffset,u=new Error(`Nudging 'currentTime' from ${s} to ${c}`);this.warn(u.message),n.currentTime=c,t.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1,buffer:e.len,bufferInfo:e})}else{const n=new Error(`Playhead still not moving while enough data buffered @${s} after ${r.nudgeMaxRetry} nudges`);this.error(n.message),t.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_STALLED_ERROR,error:n,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Yo(e,t){const n=Xo(e.main);if(n&&n.start<=t)return n;const i=Xo(e.audio);return i&&i.start<=t?i:null}function Xo(e){if(!e)return null;switch(e.state){case ki:case xi:case Di:case Mi:return null}return e.frag}function Jo(e,t){return t.getAppendedFrag(e,p)||t.getPartialFragment(e)}function Qo(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function el(e,t,n,i,r){let s=new e(t,n,"");try{s.value=i,r&&(s.type=r)}catch(a){s=new e(t,n,it(r?w({type:r},i):i))}return s}const tl=(()=>{const e=Qo();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class nl{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(l.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var n;this.media=t.media,!1===(null==(n=t.overrides)?void 0:n.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var e;const t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null;!!t.transferMedia||(this.id3Track&&(this.removeCues&&Ea(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const n=e[t];if("metadata"===n.kind&&"id3"===n.label)return ka(n,this.media),n}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:n,enableID3MetadataCues:i}=this.hls.config;if(!n&&!i)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=Qo();if(s)for(let e=0;e<r.length;e++){const t=r[e].type;if(t===ur.emsg&&!n||!i)continue;const a=ar(r[e].data),o=r[e].pts;let l=o+r[e].duration;l>tl&&(l=tl);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const n=a[e];if(!or(n)){this.updateId3CueEnds(o,t);const e=el(s,o,l,n,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var n;const i=null==(n=this.id3Track)?void 0:n.cues;if(i)for(let n=i.length;n--;){const r=i[n];r.type===t&&r.startTime<e&&r.endTime===tl&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:n,type:i}){const{id3Track:r,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(r&&(a||o)){let e;e="audio"===i?e=>e.type===ur.audioId3&&o:"video"===i?e=>e.type===ur.emsg&&a:e=>e.type===ur.audioId3&&o||e.type===ur.emsg&&a,Ta(r,t,n,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:n,timelineOffset:r,enableDateRangeMetadataCues:s,interstitialsController:a}=this.hls.config;if(!s)return;const o=Qo();if(n&&r&&!a){const{fragmentStart:t,fragmentEnd:i}=e;let r=this.assetCue;r?(r.startTime=t,r.endTime=i):o&&(r=this.assetCue=el(o,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),r&&(r.id=n,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(r),r.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:l}=this,{dateRanges:c}=e,u=Object.keys(c);let h=this.dateRangeCuesAppended;var d;if(l&&t)if(null!=(d=l.cues)&&d.length){const e=Object.keys(h).filter((e=>!u.includes(e)));for(let t=e.length;t--;){var p;const n=e[t],i=null==(p=h[n])?void 0:p.cues;delete h[n],i&&Object.keys(i).forEach((e=>{const t=i[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{l.removeCue(t)}catch(e){}}}))}}else h=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==u.length&&i(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<u.length;e++){const t=u[e],n=c[t],i=n.startTime,r=h[t],s=(null==r?void 0:r.cues)||{};let l=(null==r?void 0:r.durationKnown)||!1,d=tl;const{duration:p,endDate:f}=n;if(f&&null!==p)d=i+p,l=!0;else if(n.endOnNext&&!l){const e=u.reduce(((e,t)=>{if(t!==n.id){const i=c[t];if(i.class===n.class&&i.startDate>n.startDate&&(!e||n.startDate<e.startDate))return i}return e}),null);e&&(d=e.startTime,l=!0)}const g=Object.keys(n.attr);for(let e=0;e<g.length;e++){const c=g[e];if("ID"===(m=c)||"CLASS"===m||"CUE"===m||"START-DATE"===m||"DURATION"===m||"END-DATE"===m||"END-ON-NEXT"===m)continue;const u=s[c];if(u)!l||null!=r&&r.durationKnown?Math.abs(u.startTime-i)>.01&&(u.startTime=i,u.endTime=d):u.endTime=d;else if(o){let e=n.attr[c];dn(c)&&(e=I(e));const r=el(o,i,d,{key:c,data:e},ur.dateRange);r&&(r.id=t,this.id3Track.addCue(r),s[c]=r,a&&("X-ASSET-LIST"!==c&&"X-ASSET-URL"!==c||r.addEventListener("enter",this.onEventCueEnter)))}}h[t]={cues:s,dateRange:n,durationKnown:l}}var m}}}class il{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;const n=this.computeLatency();if(null===n)return;this._latency=n;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:r}=this.config;if(!i||1===r||!t.live)return;const s=this.targetLatency;if(null===s)return;const a=n-s;if(a<Math.min(this.maxLatency,s+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,r)),n=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(t,Math.max(1,n));this.changeMediaPlaybackRate(e,i)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(null===e||null===this.hls)return null;const{holdBack:t,partHoldBack:n,targetduration:i}=e,{liveSyncDuration:r,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&n||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:s*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;const n=this.levelDetails;if(null===n)return null;const i=n.edge,r=e-t-this.edgeStalled,s=i-n.totalduration,a=i-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(s,r),a)}get drift(){const e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const n=e.buffered.length;return(n?e.buffered.end(n-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(l.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(l.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var n;t.details===o.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(n=this.levelDetails)&&n.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var n,i;e.playbackRate!==t&&(null==(n=this.hls)||n.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class rl extends ds{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(l.LEVEL_LOADED,this.onLevelLoaded,this),e.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(l.FRAG_BUFFERED,this.onFragBuffered,this),e.on(l.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(l.LEVEL_LOADED,this.onLevelLoaded,this),e.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(l.FRAG_BUFFERED,this.onFragBuffered,this),e.off(l.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach((e=>{e.loadError=0,e.fragmentError=0})),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const n=this.hls.config.preferManagedMediaSource,i=[],r={},s={};let a=!1,o=!1,l=!1;t.levels.forEach((e=>{const t=e.attrs;let{audioCodec:c,videoCodec:u}=e;c&&(e.audioCodec=c=Pe(c,n)||void 0),u&&(u=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const n=t[e].split(".");n.length>2&&"avc1"===n[0]&&(t[e]=`avc1.${parseInt(n[1]).toString(16)}${("000"+parseInt(n[2]).toString(16)).slice(-4)}`)}return t.join(",")}(u));const{width:h,height:d,unknownCodecs:p}=e,f=(null==p?void 0:p.length)||0;if(a||(a=!(!h||!d)),o||(o=!!u),l||(l=!!c),f||c&&!this.isAudioSupported(c)||u&&!this.isVideoSupported(u))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);const{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":_,"PATHWAY-ID":y,RESOLUTION:v,"VIDEO-RANGE":b}=t,w=`${`${y||"."}-`}${e.bitrate}-${v}-${g}-${m}-${b}-${_}`;if(r[w])if(r[w].uri===e.url||e.attrs["PATHWAY-ID"])r[w].addGroupId("audio",t.AUDIO),r[w].addGroupId("text",t.SUBTITLES);else{const t=s[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const n=this.createLevel(e);r[w]=n,i.push(n)}else{const t=this.createLevel(e);r[w]=t,s[w]=1,i.push(t)}})),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new et(e),n=e.supplemental;if(null!=n&&n.videoCodec&&!this.isVideoSupported(n.videoCodec)){const e=new Error(`SUPPLEMENTAL-CODECS not supported "${n.videoCodec}"`);this.log(e.message),t.supportedResult=ze(e,[])}return t}isAudioSupported(e){return Ce(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Ce(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,n,i,r){var s;let c=[],u=[],h=e;const d=(null==(s=t.stats)?void 0:s.parsing)||{};if((n||i)&&r&&(h=h.filter((({videoCodec:e,videoRange:t,width:n,height:i})=>{return(!!e||!(!n||!i))&&(!!(r=t)&&We.indexOf(r)>-1);var r}))),0===h.length)return Promise.resolve().then((()=>{if(this.hls){let e="no level with compatible codecs found in manifest",n=e;t.levels.length&&(n=`one or more CODECS in variant not supported: ${it(t.levels.map((e=>e.attrs.CODECS)).filter(((e,t,n)=>n.indexOf(e)===t)))}`,this.warn(n),e+=` (${n})`);const i=new Error(e);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:n})}})),void(d.end=performance.now());t.audioTracks&&(c=t.audioTracks.filter((e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),sl(c)),t.subtitles&&(u=t.subtitles,sl(u));const p=h.slice(0);h.sort(((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(n&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return We.indexOf(e.videoRange)-We.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const n=De(e.videoCodec),i=De(t.videoCodec);if(n!==i)return i-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const n=Me(e.codecSet),i=Me(t.codecSet);if(n!==i)return i-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));let f=p[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==p.length))for(let e=0;e<p.length;e++)if(p[e].pathwayId===h[0].pathwayId){f=p[e];break}this._levels=h;for(let e=0;e<h.length;e++)if(h[e]===f){var m;this._firstLevel=e;const t=f.bitrate,n=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${h.length} level(s) found, first bitrate: ${t}`),void 0===(null==(m=this.hls.userConfig)?void 0:m.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>n&&n===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const g=r&&!i,_=this.hls.config,y=!(!_.audioStreamController||!_.audioTrackController),v={levels:h,audioTracks:c,subtitleTracks:u,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:i,altAudio:y&&!g&&c.some((e=>!!e.url))};d.end=performance.now(),this.hls.trigger(l.MANIFEST_PARSED,v)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const n=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:n,reason:n.message}),i)return;e=Math.min(e,t.length-1)}const n=this.currentLevelIndex,i=this.currentLevel,r=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],c=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,n===e&&i&&r===c)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${c?" with Pathway "+c:""} from level ${n}${r?" with Pathway "+r:""}`);const u={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(l.LEVEL_SWITCHING,u);const h=s.details;if(!h||h.live){const e=this.switchParams(s.uri,null==i?void 0:i.details,h);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),n=e.filter((e=>-1!==t.indexOf(e)));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=n}}onError(e,t){!t.fatal&&t.context&&t.context.type===u&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===p){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return;const n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}onLevelLoaded(e,t){var n;const{level:i,details:r}=t,s=t.levelInfo;var a;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(r.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);let e=s.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const n=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],s=e.details,a=null==s?void 0:s.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${a&&s.live?" age "+a.toFixed(1)+(s.type?" "+s.type||0:""):""} ${n}`),this.hls.trigger(l.LEVEL_LOADING,{url:n,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;const n=this._levels.filter(((t,n)=>n!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((e=>e.level=-1))),!1)));hi(n),this._levels=n,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=n.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(l.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:n}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(l.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}function sl(e){const t={};e.forEach((e=>{const n=e.groupId||"";e.id=t[n]=t[n]||0,t[n]++}))}function al(){return self.SourceBuffer||self.WebKitSourceBuffer}function ol(){if(!A())return!1;const e=al();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class ll extends Pi{constructor(e,t,n){super(e,t,n,"stream-controller",p),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const e=this.media,t=e?e.currentTime:null;if(null===t||!i(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const n=this.getFwdBufferInfoAtPos(e,t,p,0);null!==n&&0!==n.len?this.tick():this.warn(`Main forward buffer length at ${t} on "seeked" event ${n?n.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(l.MANIFEST_PARSED,this.onManifestParsed,this),e.on(l.LEVEL_LOADING,this.onLevelLoading,this),e.on(l.LEVEL_LOADED,this.onLevelLoaded,this),e.on(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(l.BUFFER_CREATED,this.onBufferCreated,this),e.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(l.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(l.MANIFEST_PARSED,this.onManifestParsed,this),e.off(l.LEVEL_LOADED,this.onLevelLoaded,this),e.off(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(l.BUFFER_CREATED,this.onBufferCreated,this),e.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(l.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:n,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this._hasEnoughToStart=!!t}n>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${n.toFixed(3)}`),e=n),this.state=ki,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=xi}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ii:{const{levels:e,level:t}=this,n=null==e?void 0:e[t],i=null==n?void 0:n.details;if(i&&(!i.live||this.levelLastLoaded===n&&!this.waitForLive(n))){if(this.waitForCdnTuneIn(i))break;this.state=ki;break}if(this.hls.nextLoadLevel!==this.level){this.state=ki;break}break}case Ti:this.checkRetryDate()}this.state===ki&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:n,media:i}=this;if(null===t||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==n||!n[r])return;const s=n[r],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return 2===this.altAudio&&(e.type="video"),this.hls.trigger(l.BUFFER_EOS,e),void(this.state=Di)}if(!this.buffering)return;e.loadLevel!==r&&-1===e.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const c=s.details;if(!c||this.state===Ii||this.waitForLive(s))return this.level=r,this.state=Ii,void(this.startFragRequested=!1);const u=a.len,h=this.getMaxBufferLength(s.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const d=this.backtrackFragment?this.backtrackFragment.start:a.end;let f=this.getNextFragment(d,c);if(this.couldBacktrack&&!this.fragPrevious&&f&&W(f)&&this.fragmentTracker.getState(f)!==Nt){var m;const e=(null!=(m=this.backtrackFragment)?m:f).sn-c.startSN,t=c.fragments[e-1];t&&f.cc===t.cc&&(f=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,d)){if(!f.gap){const e=this.audioOnly&&!this.altAudio?q:G,t=(e===G?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,p)}f=this.getNextFragmentLoopLoading(f,c,a,p,h)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,s,d))}loadFragment(e,t,n){const i=this.fragmentTracker.getState(e);i===Pt||i===Ft?W(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,n):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,p)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let n;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*r.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;n=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else n=0;const s=this.getBufferedFrag(t.currentTime+n);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,n=e.duration,i=Math.max(s.end,t+Math.min(Math.max(n-this.config.maxFragLookUpTolerance,n*(this.couldBacktrack?.5:.125)),n*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Si:case Ei:case Ti:case Li:case Ai:this.state=ki}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const n=t.media;vi(n,"playing",this.onMediaPlaying),vi(n,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:n}=this;n&&(bi(n,"playing",this.onMediaPlaying),bi(n,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t);!!t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(l.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let n=!1,i=!1;for(let e=0;e<t.levels.length;e++){const r=t.levels[e].audioCodec;r&&(n=n||-1!==r.indexOf("mp4a.40.2"),i=i||-1!==r.indexOf("mp4a.40.5"))}this.audioCodecSwitch=n&&i&&!function(){var e;const t=al();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),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}onLevelLoading(e,t){const{levels:n}=this;if(!n||this.state!==ki)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=Ii)}onLevelLoaded(e,t){var n;const{levels:i,startFragRequested:r}=this,s=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${s}`);this.log(`Level ${s} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const c=t.levelInfo,u=this.fragCurrent;!u||this.state!==Ei&&this.state!==Ti||u.level!==t.level&&u.loader&&this.abortCurrentFrag();let h=0;if(a.live||null!=(n=c.details)&&n.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;h=this.alignPlaylists(a,c.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(c.details=a,this.levelLastLoaded=c,r||this.setStartPosition(a,h),this.hls.trigger(l.LEVEL_UPDATED,{details:a,level:s}),this.state===Ii){if(this.waitForCdnTuneIn(a))return;this.state=ki}r&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:n}=this;if(!n)return;const i=this.hls.liveSyncPosition,r=this.getLoadPosition(),s=e.fragmentStart,a=e.edge,o=r>=s-t.maxFragLookUpTolerance&&r<=a;if(null!==i&&n.duration>i&&(r<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&n.readyState<4||r<a-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),n.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const e=nn.bufferInfo(n,i,0);if(null==(l=e.buffered)||!l.length)return void(n.currentTime=i);if(e.start<=r)return void(n.currentTime=i);const{nextStart:t}=nn.bufferedInfo(e.buffered,r,0);t&&(n.currentTime=t)}else n.currentTime=i}}_handleFragmentLoadProgress(e){var t;const n=e.frag,{part:i,payload:r}=e,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const a=s[n.level];if(!a)return void this.warn(`Level ${n.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${n.sn} of level ${n.level} after level details were reset`),void this.fragmentTracker.removeFragment(n);const l=a.videoCodec,c=o.PTSKnown||!o.live,u=null==(t=n.initSegment)?void 0:t.data,h=this._getAudioCodec(a),d=this.transmuxer=this.transmuxer||new hs(this.hls,p,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,m=-1!==f,g=new en(n.level,n.sn,n.stats.chunkCount,r.byteLength,f,m),_=this.initPTS[n.cc];d.push(r,u,h,l,n,i,o.totalduration,c,g,_)}onAudioTrackSwitching(e,t){const n=this.hls,i=2===this.altAudio;if(ht(t.url,n))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.fragmentTracker.removeAllFragments(),n.once(l.BUFFER_FLUSHED,(()=>{this.hls&&this.hls.trigger(l.AUDIO_TRACK_SWITCHED,t)})),void n.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});n.trigger(l.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const n=ht(t.url,this.hls);if(n){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=n?2:0,this.tick()}onBufferCreated(e,t){const n=t.tracks;let i,r,s=!1;for(const e in n){const t=n[e];if("main"===t.id){if(r=e,i=t,"video"===e){const t=n[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:n,part:i}=t,r=n.type===p;if(r){if(this.fragContextChanged(n))return this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Ai&&(this.state=ki));const e=i?i.stats:n.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),W(n)&&(this.fragPrevious=n),this.fragBufferedComplete(n,i)}const s=this.media;s&&(!this._hasEnoughToStart&&nn.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var n;if(t.fatal)this.state=Mi;else switch(t.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(p,t);break;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Ii||(null==(n=t.context)?void 0:n.type)!==u||(this.state=ki);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t)){!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=ki,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==q||!this.altAudio){const e=(t===G?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,p),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let n=this.startPosition;if(n>=0&&t<n){if(e.seeking)return void this.log(`could not seek to ${n}, already seeking at ${t}`);const i=this.timelineOffset;i&&n&&(n+=i);const r=this.getLevelDetails(),s=nn.getBuffered(e),a=s.length?s.start(0):0,o=a-n,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==r?void 0:r.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),n+=o,this.startPosition=n),t<n&&(this.log(`seek to target start position ${n} from current time ${t} buffer start ${a}`),e.currentTime=n)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then((e=>{const{hls:n}=this,i=null==e?void 0:e.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=ki,this.startFragRequested=!1,this.bitrateTest=!1;const r=i.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),n.trigger(l.FRAG_LOADED,e),i.bitrateTest=!1})).catch((t=>{this.state!==xi&&this.state!==Mi&&(this.warn(t),this.resetFragmentLoading(e))}))}_handleTransmuxComplete(e){const t=this.playlistType,{hls:n}=this,{remuxResult:r,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:c,level:u}=a,{video:h,text:d,id3:p,initSegment:f}=r,{details:m}=u,g=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Li,f){const e=f.tracks;if(e){const i=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(u,e,i,s),n.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const r=f.initPTS,a=f.timescale,c=this.initPTS[o.cc];if(i(r)&&(!c||c.baseTime!==r||c.timescale!==a)){const e=f.trackId;this.initPTS[o.cc]={baseTime:r,timescale:a,trackId:e},n.trigger(l.INIT_PTS_FOUND,{frag:o,id:t,initPTS:r,timescale:a,trackId:e})}}if(h&&m){g&&"audiovideo"===h.type&&this.logMuxedErr(o);const e=m.fragments[o.sn-1-m.startSN],t=o.sn===m.startSN,n=!e||o.cc>e.cc;if(!1!==r.independent){const{startPTS:e,endPTS:i,startDTS:r,endDTS:a}=h;if(c)c.elementaryStreams[h.type]={startPTS:e,endPTS:i,startDTS:r,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===s.id&&!n&&(this.couldBacktrack=!0),h.dropped&&h.independent){const r=this.getMainFwdBufferInfo(),s=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:e;if(!t&&s<l-this.config.maxBufferHole&&!n)return void this.backtrack(o);n&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,i,o.start,a,!0)}else t&&e-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(h.type,e,i,r,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,c,s,t||n)}else{if(!t&&!n)return void this.backtrack(o);o.gap=!0}}if(g){const{startPTS:e,endPTS:t,startDTS:n,endDTS:i}=g;c&&(c.elementaryStreams[q]={startPTS:e,endPTS:t,startDTS:n,endDTS:i}),o.setElementaryStreamInfo(q,e,t,n,i),this.bufferFragmentData(g,o,c,s)}if(m&&null!=p&&p.samples.length){const e={id:t,frag:o,details:m,samples:p.samples};n.trigger(l.FRAG_PARSING_METADATA,e)}if(m&&d){const e={id:t,frag:o,details:m,samples:d.samples};n.trigger(l.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${W(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,n,i){if(this.state!==Li)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(n));const{audio:r,video:s,audiovideo:a}=t;if(r){const n=e.audioCodec;let i=Oe(r.codec,n);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=r.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==r.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),n&&n!==i&&this.log(`Swapping manifest audio codec "${n}" for "${i}"`),r.levelCodec=i,r.id=p,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${i||""}/${n||""}/${r.codec}]`),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=p;const n=s.codec;if(4===(null==n?void 0:n.length))switch(n){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${e.videoCodec||""}/${n}]${s.codec!==n?" parsed-corrected="+s.codec:""}${s.supplemental?" supplemental="+s.supplemental:""}`),delete t.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete t.video,delete t.audio);const o=Object.keys(t);if(o.length){if(this.hls.trigger(l.BUFFER_CODECS,t),!this.hls)return;o.forEach((e=>{const r=t[e].initSegment;null!=r&&r.byteLength&&this.hls.trigger(l.BUFFER_APPENDING,{type:e,data:r,frag:n,part:null,chunkMeta:i,parent:n.type})}))}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,p)}get maxBufferLength(){const{levels:e,level:t}=this,n=null==e?void 0:e[t];return n?this.getMaxBufferLength(n.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ki}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const n=e.currentTime;if(nn.isBuffered(e,n)?t=this.getAppendedFrag(n):nn.isBuffered(e,n+.1)&&(t=this.getAppendedFrag(n+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,n=t.level;e&&t.sn===e.sn&&e.level===n||(this.fragPlaying=t,this.hls.trigger(l.FRAG_CHANGED,{frag:t}),e&&e.level===n||this.hls.trigger(l.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return i(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(i(t)){const e=this.getLevelDetails(),n=this.currentFrag||(e?pt(null,e.fragments,t):null);if(n){const e=n.programDateTime;if(null!==e){const i=e+1e3*(t-n.start);return new Date(i)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class cl extends x{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const n in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[n].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=o.KEY_LOAD_ERROR,n,i,r){return new Jt({type:a.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:n,networkDetails:i})}loadClear(e,t,n){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,r=t.length;i<r;i++){const s=t[i];if(e.cc<=s.cc&&(!W(e)||!W(s)||e.sn<s.sn)||!n&&i==r-1)return this.emeController.selectKeySystemFormat(s).then((e=>{if(!this.emeController)return;s.setKeyFormat(e);const t=An(e);return t?this.emeController.getKeySystemAccess([t]):void 0}))}if(this.config.requireKeySystemAccessOnStart){const e=Mn(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then((t=>this.loadInternal(e,t))):this.loadInternal(e)}loadInternal(e,t){var n,i;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const n=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,o.KEY_LOAD_ERROR,n))}const s=r.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,o.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=ul(r);let l=this.keyIdToKeyInfo[a];if(null!=(n=l)&&n.decryptdata.key)return r.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(this.emeController&&null!=(i=l)&&i.keyLoadPromise){switch(this.emeController.getKeyStatus(l.decryptdata)){case"usable":case"usable-in-future":return l.keyLoadPromise.then((t=>{const{keyInfo:n}=t;return r.key=n.decryptdata.key,{frag:e,keyInfo:n}}))}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${r.keyId?" keyId: "+R(r.keyId):""} URI: ${r.uri} from ${e.type} ${e.level}`),l=this.keyIdToKeyInfo[a]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,o.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const n={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){const n=function(e){const t=[];return fe(e,(e=>t.push(e.subarray(8,24)))),t}(t.initSegment.data);if(n.length){const t=n[0];t.some((e=>0!==e))&&(this.log(`Using keyId found in init segment ${R(t)}`),e.decryptdata.keyId=t,Fn.setKeyIdForUri(e.decryptdata.uri,t))}}const r=this.emeController.loadKey(n);return(e.keyLoadPromise=r.then((t=>(e.mediaKeySessionContext=t,n)))).catch((n=>{throw e.keyLoadPromise=null,"data"in n&&(n.data.frag=t),n}))}return Promise.resolve(n)}loadKeyHTTP(e,t){const n=this.config,i=new(0,n.loader)(n);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise(((r,s)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(e,t,n,i)=>{const{frag:a,keyInfo:l}=n,c=ul(l.decryptdata);if(!a.decryptdata||l!==this.keyIdToKeyInfo[c])return s(this.createKeyLoadError(a,o.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));l.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,l.loader=null,r({frag:a,keyInfo:l})},onError:(e,n,i,r)=>{this.resetLoader(n),s(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,w({url:a.url,data:void 0},e)))},onTimeout:(e,n,i)=>{this.resetLoader(n),s(this.createKeyLoadError(t,o.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,n,i)=>{this.resetLoader(n),s(this.createKeyLoadError(t,o.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,c,u)}))}resetLoader(e){const{frag:t,keyInfo:n,url:i}=e,r=n.loader;t.keyLoader===r&&(t.keyLoader=null,n.loader=null);const s=ul(n.decryptdata)||i;delete this.keyIdToKeyInfo[s],r&&r.destroy()}}function ul(e){if(e.keyFormat!==Tn){const t=e.keyId;if(t)return R(t)}return e.uri}function hl(e){const{type:t}=e;switch(t){case h:return f;case d:return m;default:return p}}function dl(e,t){let n=e.url;return void 0!==n&&0!==n.indexOf("data:")||(n=t.url),n}class pl{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(l.MANIFEST_LOADING,this.onManifestLoading,this),e.on(l.LEVEL_LOADING,this.onLevelLoading,this),e.on(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(l.MANIFEST_LOADING,this.onManifestLoading,this),e.off(l.LEVEL_LOADING,this.onLevelLoading,this),e.off(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,n=t.pLoader,i=t.loader,r=new(n||i)(t);return this.loaders[e.type]=r,r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:n}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:c,url:n,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:n,level:i,pathwayId:r,url:s,deliveryDirectives:a,levelInfo:o}=t;this.load({id:n,level:i,pathwayId:r,responseType:"text",type:u,url:s,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:n,groupId:i,url:r,deliveryDirectives:s,track:a}=t;this.load({id:n,groupId:i,level:null,responseType:"text",type:h,url:r,deliveryDirectives:s,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:n,groupId:i,url:r,deliveryDirectives:s,track:a}=t;this.load({id:n,groupId:i,level:null,responseType:"text",type:d,url:r,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const n=this.loaders[u];if(n){const e=n.context;e&&!t.levels.some((t=>t===e.levelOrTrack))&&(n.abort(),delete this.loaders[u])}}load(e){var t;const n=this.hls.config;let r,s=this.getInternalLoader(e);if(s){const t=this.hls.logger,n=s.context;if(n&&n.levelOrTrack===e.levelOrTrack&&(n.url===e.url||n.deliveryDirectives&&!e.deliveryDirectives))return void(n.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${n.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}if(r=e.type===c?n.manifestLoadPolicy.default:v({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),i(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===u&&null!==e.level?t=this.hls.levels[e.level].details:e.type===h&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===d&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,n=t.targetduration;if(e&&n){const t=1e3*Math.max(3*e,.8*n);r=v({},r,{maxTimeToFirstByteMs:Math.min(t,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,r.maxTimeToFirstByteMs)})}}}const a=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,n,i)=>{const r=this.getInternalLoader(n);this.resetInternalLoader(n.type);const s=e.data;t.parsing.start=performance.now(),Vn.isMediaPlaylist(s)||n.type!==c?this.handleTrackOrLevelPlaylist(e,t,n,i||null,r):this.handleMasterPlaylist(e,t,n,i)},onError:(e,t,n,i)=>{this.handleNetworkError(t,n,!1,e,i)},onTimeout:(e,t,n)=>{this.handleNetworkError(t,n,!0,void 0,e)}};s.load(e,o,l)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:n}=this.hls;(e||n)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,n,i){const r=this.hls,s=e.data,a=dl(e,n),o=Vn.parseMasterPlaylist(s,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,n,o.playlistParsingError,i,t);const{contentSteering:c,levels:u,sessionData:h,sessionKeys:d,startTimeOffset:p,variableList:f}=o;this.variableList=f,u.forEach((e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:n}=this.hls.config;let{audioCodec:i,videoCodec:r}=e;for(let s=t.length;s--;){const a=t[s];Ce(a,"audio",n)?(e.audioCodec=i=i?`${i},${a}`:a,Ee.audio[i.substring(0,4)]=2,t.splice(s,1)):Ce(a,"video",n)&&(e.videoCodec=r=r?`${r},${a}`:a,Ee.video[r.substring(0,4)]=2,t.splice(s,1))}}}));const{AUDIO:m=[],SUBTITLES:g,"CLOSED-CAPTIONS":_}=Vn.parseMasterPlaylistMedia(s,a,o);if(m.length){m.some((e=>!e.url))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new hn({}),bitrate:0,url:""}))}r.trigger(l.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:g,captions:_,contentSteering:c,url:a,stats:t,networkDetails:i,sessionData:h,sessionKeys:d,startTimeOffset:p,variableList:f})}handleTrackOrLevelPlaylist(e,t,n,r,s){const a=this.hls,{id:o,level:u,type:h}=n,d=dl(e,n),p=i(u)?u:i(o)?o:0,f=hl(n),m=Vn.parseLevelPlaylist(e.data,d,p,f,0,this.variableList);if(h===c){const e={attrs:new hn({}),bitrate:0,details:m,name:"",url:d};m.requestScheduled=t.loading.start+oi(m,0),a.trigger(l.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),n.levelDetails=m,this.handlePlaylistLoaded(m,e,t,n,r,s)}handleManifestParsingError(e,t,n,i,r){this.hls.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.MANIFEST_PARSING_ERROR,fatal:t.type===c,url:e.url,err:n,error:n,reason:n.message,response:e,context:t,networkDetails:i,stats:r})}handleNetworkError(e,t,n=!1,i,r){let s=`A network ${n?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===u?s+=`: ${e.level} id: ${e.id}`:e.type!==h&&e.type!==d||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const p=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let f=o.UNKNOWN,m=!1;const g=this.getInternalLoader(e);switch(e.type){case c:f=n?o.MANIFEST_LOAD_TIMEOUT:o.MANIFEST_LOAD_ERROR,m=!0;break;case u:f=n?o.LEVEL_LOAD_TIMEOUT:o.LEVEL_LOAD_ERROR,m=!1;break;case h:f=n?o.AUDIO_TRACK_LOAD_TIMEOUT:o.AUDIO_TRACK_LOAD_ERROR,m=!1;break;case d:f=n?o.SUBTITLE_TRACK_LOAD_TIMEOUT:o.SUBTITLE_LOAD_ERROR,m=!1}g&&this.resetInternalLoader(e.type);const _={type:a.NETWORK_ERROR,details:f,fatal:m,url:e.url,loader:g,context:e,error:p,networkDetails:t,stats:r};if(i){const n=(null==t?void 0:t.url)||e.url;_.response=w({url:n,data:void 0},i)}this.hls.trigger(l.ERROR,_)}handlePlaylistLoaded(e,t,n,i,r,s){const f=this.hls,{type:m,level:g,levelOrTrack:_,id:y,groupId:v,deliveryDirectives:b}=i,w=dl(t,i),x=hl(i);let k="number"==typeof i.level&&x===p?g:void 0;const S=e.playlistParsingError;if(S){if(this.hls.logger.warn(`${S} ${e.url}`),!f.config.ignorePlaylistParsingErrors)return void f.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:w,error:S,reason:S.message,response:t,context:i,level:k,parent:x,networkDetails:r,stats:n});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),m){case c:case u:if(k)if(_){if(_!==f.levels[k]){const e=f.levels.indexOf(_);e>-1&&(k=e)}}else k=0;f.trigger(l.LEVEL_LOADED,{details:e,levelInfo:_||f.levels[0],level:k||0,id:y||0,stats:n,networkDetails:r,deliveryDirectives:b,withoutMultiVariant:m===c});break;case h:f.trigger(l.AUDIO_TRACK_LOADED,{details:e,track:_,id:y||0,groupId:v||"",stats:n,networkDetails:r,deliveryDirectives:b});break;case d:f.trigger(l.SUBTITLE_TRACK_LOADED,{details:e,track:_,id:y||0,groupId:v||"",stats:n,networkDetails:r,deliveryDirectives:b})}else{const s=e.playlistParsingError=new Error("No Segments found in Playlist");f.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_EMPTY_ERROR,fatal:!1,url:w,error:s,reason:s.message,response:t,context:i,level:k,parent:x,networkDetails:r,stats:n})}}}class fl{static get version(){return Ui}static isMSESupported(){return ol()}static isSupported(){return function(){if(!ol())return!1;const e=A();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((t=>e.isTypeSupported(Ae(t,"video"))))||["mp4a.40.2","fLaC"].some((t=>e.isTypeSupported(Ae(t,"audio")))))}()}static getMediaSource(){return A()}static get Events(){return l}static get MetadataSchema(){return ur}static get ErrorTypes(){return a}static get ErrorDetails(){return o}static get DefaultConfig(){return fl.defaultConfig?fl.defaultConfig:Ho}static set DefaultConfig(e){fl.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ki,this._autoLevelCapping=-1,this._maxHdcpLevel=null,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,n){const i=E();if("object"==typeof console&&!0===e||"object"==typeof e){const r=["debug","log","info","warn","error"];r.forEach((t=>{i[t]=T(t,e,n)}));try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.13`)}catch(e){return E()}r.forEach((t=>{C[t]=T(t,e)}))}else v(C,i);return i}(e.debug||!1,"Hls instance",e.assetPlayerId),n=this.config=function(e,t,n){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=jo(e),r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((e=>{const s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],o=[];r.forEach((n=>{const r=`${e}Loading${n}`,l=t[r];if(void 0!==l&&a){o.push(r);const e=i[s].default;switch(t[s]={default:e},n){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&n.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${s}": ${it(t[s])}`)})),w(w({},i),t)}(fl.DefaultConfig,e,t);this.userConfig=e,n.progressive&&Wo(n,t);const{abrController:i,bufferController:r,capLevelController:s,errorController:a,fpsController:o}=n,c=new a(this),u=this.abrController=new i(this),h=new Bt(this),d=n.interstitialsController,p=d?this.interstitialsController=new d(this,fl):null,f=this.bufferController=new r(this,h),m=this.capLevelController=new s(this),g=new o(this),_=new pl(this),y=n.contentSteeringController,b=y?new y(this):null,x=this.levelController=new rl(this,b),k=new nl(this),S=new cl(this.config,this.logger),L=this.streamController=new ll(this,h,S),A=this.gapController=new Zo(this,h);m.setStreamController(L),g.setStreamController(L);const D=[_,x,L];p&&D.splice(1,0,p),b&&D.splice(1,0,b),this.networkControllers=D;const M=[u,f,A,m,g,k,h];this.audioTrackController=this.createController(n.audioTrackController,D);const R=n.audioStreamController;R&&D.push(this.audioStreamController=new R(this,h,S)),this.subtitleTrackController=this.createController(n.subtitleTrackController,D);const I=n.subtitleStreamController;I&&D.push(this.subtititleStreamController=new I(this,h,S)),this.createController(n.timelineController,M),S.emeController=this.emeController=this.createController(n.emeController,M),this.cmcdController=this.createController(n.cmcdController,M),this.latencyController=this.createController(il,M),this.coreComponents=M,D.push(c);const P=c.onErrorOut;"function"==typeof P&&this.on(l.ERROR,P,c),this.on(l.MANIFEST_LOADED,_.onManifestLoaded,_)}createController(e,t){if(e){const n=new e(this);return t&&t.push(n),n}return null}on(e,t,n=this){this._emitter.on(e,t,n)}once(e,t,n=this){this._emitter.once(e,t,n)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,n=this,i){this._emitter.off(e,t,n,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,n){return this._emitter.emit(e,t,n)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const n=e===l.ERROR;this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:n,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(l.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach((e=>e.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((e=>e.destroy())),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const t=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,n=t?e.media:e,i=t?e:{media:n};this._media=n,this.trigger(l.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(l.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(l.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,n=this._url,i=this._url=z.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&n&&(n!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(l.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let n=0;n<this.networkControllers.length&&(this.networkControllers[n].startLoad(e,t),this.started&&this.networkControllers);n++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach((e=>{e.resumeBuffering&&e.resumeBuffering()})))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach((e=>{e.pauseBuffering&&e.pauseBuffering()})))}get inFlightFragments(){const e={[p]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[f]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[m]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)}))}}}()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return je.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const n=e.length;for(let i=0;i<n;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:n}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,n)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=n)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return qe(e,st(t),navigator.mediaCapabilities)}}fl.defaultConfig=void 0},48136:function(e,t,n){"use strict";var i=Object.defineProperty,r=Object.defineProperties,s=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e},h=(e,t)=>r(e,s(t)),d=e=>"symbol"==typeof e?e:e+"",p=(e,t)=>{var n={};for(var i in e)o.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&a)for(var i of a(e))t.indexOf(i)<0&&l.call(e,i)&&(n[i]=e[i]);return n};function f(e){return Array.isArray(e)}function m(){return"window"in globalThis&&"document"in globalThis}function g(){return"function"==typeof navigator.vibrate}function _(){var e,t;if(!m())return"other";const n=null!=(t=null==(e=navigator.userAgentData)?void 0:e.platform)?t:navigator.platform;return/^mac/i.test(n)?5===navigator.maxTouchPoints?"ios":"macos":/^win/i.test(n)?"windows":/android/i.test(navigator.userAgent)?"android":/iphone|ipod|ipad/i.test(navigator.userAgent)?"ios":/\bcros\b/i.test(navigator.userAgent)?"chromeos":"other"}function y(){return HTMLElement.prototype.hasOwnProperty("popover")}var v={strings:{en:{"keyboard.tooltip.symbols":"符号","keyboard.tooltip.greek":"希腊字母","keyboard.tooltip.numeric":"数字","keyboard.tooltip.alphabetic":"罗马字母","tooltip.cut to clipboard":"剪切到剪贴板","tooltip.copy to clipboard":"复制到剪贴板","tooltip.paste from clipboard":"粘贴","tooltip.redo":"重做","tooltip.toggle virtual keyboard":"切换虚拟键盘","tooltip.undo":"撤消","menu.insert matrix":"插入矩阵","menu.borders":"矩阵分隔符","menu.array.add row above":"在后面添加行","menu.array.add row below":"在前面添加行","menu.array.add column after":"在后面添加列r","menu.array.add column before":"在前面添加列","menu.array.delete row":"删除行","menu.array.delete rows":"删除选定行","menu.array.delete column":"删除列","menu.array.delete columns":"删除选定的列","menu.mode":"模式","menu.mode-math":"数学","menu.mode-text":"文本","menu.mode-latex":"LaTeX","tooltip.blackboard":"黑板","tooltip.bold":"粗体","tooltip.italic":"斜体","tooltip.fraktur":"Fraktur","tooltip.script":"脚本","tooltip.caligraphic":"草书","tooltip.typewriter":"打字机","tooltip.roman-upright":"罗马直立","tooltip.row-by-col":"%@ × %@","menu.font-style":"字体样式","menu.accent":"重音","menu.decoration":"装饰","menu.color":"颜色","menu.background-color":"背景","menu.evaluate":"计算","menu.simplify":"简化","menu.solve":"求解","menu.solve-for":"求解 %@","menu.cut":"剪切","menu.copy":"复制","menu.copy-as-latex":"复制为 LaTeX","menu.copy-as-ascii-math":"复制为 ASCII Math","menu.copy-as-mathml":"复制为 MathML","menu.paste":"粘贴","menu.select-all":"全选","color.red":"红色","color.orange":"橙色","color.yellow":"黄色","color.lime":"绿黄色","color.green":"绿色","color.teal":"青色","color.cyan":"蓝绿色","color.blue":"蓝色","color.indigo":"靛蓝色","color.purple":"紫色","color.magenta":"洋红色","color.black":"黑色","color.dark-grey":"深灰色","color.grey":"灰色","color.light-grey":"浅灰色","color.white":"白色"}},_locale:"",_dirty:!1,_subscribers:[],_numberFormatter:void 0,get locale(){return v._locale||(v._locale=m()?navigator.language.slice(0,5):"en-US"),v._locale},set locale(e){v._locale=e,v._numberFormatter=void 0,v.dirty=!0},get numberFormatter(){return v._numberFormatter||(v._numberFormatter=new Intl.NumberFormat(v.locale)),v._numberFormatter},merge(e,t){if("string"==typeof e&&t)v.strings[e]=u(u({},v.strings[e]),t),v.dirty=!0;else for(const t of Object.keys(e))v.merge(t,e[t])},get dirty(){return v._dirty},set dirty(e){v._dirty||v._dirty===e||(v._dirty=!0,setTimeout((()=>{v._dirty=!1,this._subscribers.forEach((e=>null==e?void 0:e()))}),0))},subscribe(e){return v._subscribers.push(e),v._subscribers.length-1},unsubscribe(e){e<0||e>=v._subscribers.length||(v._subscribers[e]=void 0)},update(e){let t=e.querySelectorAll("[data-l10n-tooltip]");for(const e of t){const t=e.getAttribute("data-l10n-tooltip");if(t){const n=b(t);n&&e.setAttribute("data-tooltip",n)}}t=e.querySelectorAll("[data-l10n-arial-label]");for(const e of t){const t=e.getAttribute("data-l10n-arial-label");if(t){const n=b(t);n&&e.setAttribute("aria-label",n)}}}};function b(e,...t){if(void 0===e)return;let n="";const i=v.locale;v.strings[i]&&(n=v.strings[i][e]);const r=i.slice(0,2);if(!n&&v.strings[r]&&(n=v.strings[r][e]),n||(n=v.strings.en[e]),!n)return;const s=/(%@|%([0-9]+)\$@)/g;let a=s.exec(n),o=0;for(;a;){if(t[o++]){let e=t[a[2]?parseInt(a[2],10)-1:o-1];"number"==typeof e&&(e=v.numberFormatter.format(e)),n=n.replace(a[1],e)}a=s.exec(n)}return n=n.replace(/%%/g,"%"),n}var w={m0:"#3F3D99",m1:"#993D71",m2:"#998B3D",m3:"#3D9956",m4:"#3D5A99",m5:"#993D90",m6:"#996D3D",m7:"#43993D",m8:"#3D7999",m9:"#843D99"},x={blue:"#0072BD",orange:"#D95319",yellow:"#EDB120",purple:"#7E2F8E",green:"#77AC30",cyan:"#4DBEEE",red:"#A2142F"},k={red:"#fbbbb6",orange:"#ffe0c2",yellow:"#fff1c2",lime:"#d0e8b9",green:"#bceac4",teal:"#b9f1f1",cyan:"#b8e5c9",blue:"#b6d9fb",indigo:"#d1c2f0",purple:"#e3baf8",magenta:"#f9c8e0",black:"#353535","dark-grey":"#8C8C8C",grey:"#D0D0D0","light-grey":"#F0F0F0",white:"#ffffff"},S={red:"#d7170b",orange:"#fe8a2b",yellow:"#ffc02b",lime:"#63b215",green:"#21ba3a",teal:"#17cfcf",cyan:"#13a7ec",blue:"#0d80f2",indigo:"#63c",purple:"#a219e6",magenta:"#eb4799",black:"#000","dark-grey":"#666",grey:"#A6A6A6","light-grey":"#d4d5d2",white:"#ffffff"},E={Red:"red",Orange:"orange",Yellow:"yellow",LimeGreen:"lime",Green:"green",TealBlue:"teal",Blue:"blue",Violet:"indigo",Purple:"purple",Magenta:"magenta",Black:"black",Gray:"grey",White:"white"},T={Apricot:"#FBB982",Aquamarine:"#00B5BE",Bittersweet:"#C04F17",Black:"#221E1F",Blue:"#2D2F92",BlueGreen:"#00B3B8",BlueViolet:"#473992",BrickRed:"#B6321C",Brown:"#792500",BurntOrange:"#F7921D",CadetBlue:"#74729A",CarnationPink:"#F282B4",Cerulean:"#00A2E3",CornflowerBlue:"#41B0E4",Cyan:"#00AEEF",Dandelion:"#FDBC42",DarkOrchid:"#A4538A",Emerald:"#00A99D",ForestGreen:"#009B55",Fuchsia:"#8C368C",Goldenrod:"#FFDF42",Gray:"#949698",Green:"#00A64F",GreenYellow:"#DFE674",JungleGreen:"#00A99A",Lavender:"#F49EC4",Limegreen:"#8DC73E",Magenta:"#EC008C",Mahogany:"#A9341F",Maroon:"#AF3235",Melon:"#F89E7B",MidnightBlue:"#006795",Mulberry:"#A93C93",NavyBlue:"#006EB8",OliveGreen:"#3C8031",Orange:"#F58137",OrangeRed:"#ED135A",Orchid:"#AF72B0",Peach:"#F7965A",Periwinkle:"#7977B8",PineGreen:"#008B72",Plum:"#92268F",ProcessBlue:"#00B0F0",Purple:"#99479B",RawSienna:"#974006",Red:"#ED1B23",RedOrange:"#F26035",RedViolet:"#A1246B",Rhodamine:"#EF559F",RoyalBlue:"#0071BC",RoyalPurple:"#613F99",RubineRed:"#ED017D",Salmon:"#F69289",SeaGreen:"#3FBC9D",Sepia:"#671800",SkyBlue:"#46C5DD",SpringGreen:"#C6DC67",Tan:"#DA9D76",TealBlue:"#00AEB3",Thistle:"#D883B7",Turquoise:"#00B4CE",Violet:"#58429B",VioletRed:"#EF58A0",White:"#FFFFFF",WildStrawberry:"#EE2967",Yellow:"#FFF200",YellowGreen:"#98CC70",YellowOrange:"#FAA21A"};function C(e){var t,n,i,r,s,a;const o=e.split("!");let l,c,u,h=255,d=255,p=255,f=-1;const m=o.length>0&&o[0].startsWith("-");m&&(o[0]=o[0].slice(1));for(let e=0;e<o.length;e++){l=h,c=d,u=p;const m=null==(t=o[e].trim().match(/^([A-Za-z\d-]+)/))?void 0:t[1],g=null==m?void 0:m.toLowerCase(),_=m&&null!=(a=null!=(s=null!=(r=null!=(i=null!=(n=S[g])?n:S[E[m]])?i:x[m])?r:T[m])?s:w[m])?a:o[e].trim();let y=_.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);if((null==y?void 0:y[1])&&y[2]&&y[3])h=Math.max(0,Math.min(255,Number.parseInt(y[1],16))),d=Math.max(0,Math.min(255,Number.parseInt(y[2],16))),p=Math.max(0,Math.min(255,Number.parseInt(y[3],16)));else if(y=_.match(/^#([\da-f]{3})$/i),null==y?void 0:y[1]){const e=Number.parseInt(y[1][0],16),t=Number.parseInt(y[1][1],16),n=Number.parseInt(y[1][2],16);h=Math.max(0,Math.min(255,16*e+e)),d=Math.max(0,Math.min(255,16*t+t)),p=Math.max(0,Math.min(255,16*n+n))}else{if(y=_.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i),!((null==y?void 0:y[1])&&y[2]&&y[3]))return;h=Math.max(0,Math.min(255,Number.parseInt(y[1]))),d=Math.max(0,Math.min(255,Number.parseInt(y[2]))),p=Math.max(0,Math.min(255,Number.parseInt(y[3])))}f>=0&&(h=(1-f)*h+f*l,d=(1-f)*d+f*c,p=(1-f)*p+f*u,f=-1),e+1<o.length&&(f=Math.max(0,Math.min(100,Number.parseInt(o[++e])))/100)}return f>=0&&(h=f*h+(1-f)*l,d=f*d+(1-f)*c,p=f*p+(1-f)*u),m&&(h=255-h,d=255-d,p=255-p),"#"+("00"+Math.round(h).toString(16)).slice(-2)+("00"+Math.round(d).toString(16)).slice(-2)+("00"+Math.round(p).toString(16)).slice(-2)}function L(e){var t,n;return e=e.trim(),null!=(n=null!=(t=k[e.toLowerCase()])?t:k[E[e]])?n:C(e)}function A(e,t,n){return n<0&&(n+=6),n>=6&&(n-=6),n<1?(t-e)*n+e:n<3?t:n<4?(t-e)*(4-n)+e:e}function D(e){return e<0?0:e>255?255:Math.round(e)}function M(e){let t=function(e){if(!e)return;if("#"!==e[0])return;let t;return(e=e.slice(1)).length<=4?(t={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(t.a=parseInt(e[3]+e[3],16)/255)):(t={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(t.a=parseInt(e[6]+e[7],16)/255)),t&&void 0===t.a&&(t.a=1),t}(e);if(!t)return e;let{h:n,s:i,l:r}=function(e){let{r:t,g:n,b:i}=e;t/=255,n/=255,i/=255;const r=Math.min(t,n,i),s=Math.max(t,n,i),a=s-r;let o,l;s===r?o=0:t===s?o=(n-i)/a:n===s?o=2+(i-t)/a:i===s&&(o=4+(t-n)/a),o=Math.min(60*o,360),o<0&&(o+=360);const c=(r+s)/2;return l=s===r?0:c<=.5?a/(s+r):a/(2-s-r),{h:o,s:l,l:c}}(t);return i+=.1,r-=.1,function(e){const{r:t,g:n,b:i}=e;let r=((1<<24)+(D(t)<<16)+(D(n)<<8)+D(i)).toString(16).slice(1);return r[0]===r[1]&&r[2]===r[3]&&r[4]===r[5]&&r[6]===r[7]&&(r=r[0]+r[2]+r[4]),"#"+r}(function(e){let[t,n,i]=[e.h,e.s,e.l];t=(t+360)%360/60,i=Math.max(0,Math.min(i,1)),n=Math.max(0,Math.min(n,1));const r=i<=.5?i*(n+1):i+n-i*n,s=2*i-r;return{r:Math.round(255*A(s,r,t+2)),g:Math.round(255*A(s,r,t)),b:Math.round(255*A(s,r,t-2))}}({h:n,s:i,l:r}))}var R={60:"\\lt",62:"\\gt",111:"o",38:"\\&",123:"\\lbrace",125:"\\rbrace",91:"\\lbrack",93:"\\rbrack",58:"\\colon",160:"~",172:"\\neg",183:"\\cdot",188:"\\frac{1}{4}",189:"\\frac{1}{2}",190:"\\frac{3}{4}",8304:"^{0}",8305:"^{i}",185:"^{1}",178:"^{2}",179:"^{3}",8224:"\\dagger",8225:"\\ddagger",8230:"\\ldots",8308:"^{4}",8309:"^{5}",8310:"^{6}",8311:"^{7}",8312:"^{8}",8313:"^{9}",8314:"^{+}",8315:"^{-}",8316:"^{=}",8319:"^{n}",8320:"_{0}",8321:"_{1}",8322:"_{2}",8323:"_{3}",8324:"_{4}",8325:"_{5}",8326:"_{6}",8327:"_{7}",8328:"_{8}",8329:"_{9}",8330:"_{+}",8331:"_{-}",8332:"_{=}",8336:"_{a}",8337:"_{e}",8338:"_{o}",8339:"_{x}",8242:"\\prime",39:"\\prime",8592:"\\gets",8594:"\\to",9651:"\\triangle",9661:"\\triangledown",8715:"\\owns",8727:"\\ast",8739:"\\vert",8741:"\\Vert",8743:"\\land",8744:"\\lor",8901:"\\cdot",8904:"\\bowtie",8800:"\\ne",8804:"\\le",8805:"\\ge",8869:"\\bot",10231:"\\biconditional",10232:"\\impliedby",10233:"\\implies",10234:"\\iff",8450:"\\mathbb{C}",8469:"\\mathbb{N}",8473:"\\mathbb{P}",8474:"\\mathbb{Q}",8477:"\\mathbb{R}",8484:"\\mathbb{Z}",8461:"\\mathbb{H}",8476:"\\Re",8465:"\\Im",42:"\\ast",11036:"\\square",9633:"\\square",8720:"\\coprod",8716:"\\not\\ni",9671:"\\diamond",8846:"\\uplus",8851:"\\sqcap",8852:"\\sqcup",8768:"\\wr",8750:"\\oint",8226:"\\textbullet",8722:"-",978:"\\Upsilon"},I={119893:8462,119965:8492,119968:8496,119969:8497,119971:8459,119972:8464,119975:8466,119976:8499,119981:8475,119994:8495,119996:8458,120004:8500,120070:8493,120075:8460,120076:8465,120085:8476,120093:8488,120122:8450,120127:8461,120133:8469,120135:8473,120136:8474,120137:8477,120145:8484},P=[{start:119808,len:26,offset:65,style:"bold"},{start:119834,len:26,offset:97,style:"bold"},{start:119860,len:26,offset:65,style:"italic"},{start:119886,len:26,offset:97,style:"italic"},{start:119912,len:26,offset:65,style:"bolditalic"},{start:119938,len:26,offset:97,style:"bolditalic"},{start:119964,len:26,offset:65,variant:"script"},{start:119990,len:26,offset:97,variant:"script"},{start:120016,len:26,offset:65,variant:"script",style:"bold"},{start:120042,len:26,offset:97,variant:"script",style:"bold"},{start:120068,len:26,offset:65,variant:"fraktur"},{start:120094,len:26,offset:97,variant:"fraktur"},{start:120172,len:26,offset:65,variant:"fraktur",style:"bold"},{start:120198,len:26,offset:97,variant:"fraktur",style:"bold"},{start:120120,len:26,offset:65,variant:"double-struck"},{start:120146,len:26,offset:97,variant:"double-struck"},{start:120224,len:26,offset:65,variant:"sans-serif"},{start:120250,len:26,offset:97,variant:"sans-serif"},{start:120276,len:26,offset:65,variant:"sans-serif",style:"bold"},{start:120302,len:26,offset:97,variant:"sans-serif",style:"bold"},{start:120328,len:26,offset:65,variant:"sans-serif",style:"italic"},{start:120354,len:26,offset:97,variant:"sans-serif",style:"italic"},{start:120380,len:26,offset:65,variant:"sans-serif",style:"bolditalic"},{start:120406,len:26,offset:97,variant:"sans-serif",style:"bolditalic"},{start:120432,len:26,offset:65,variant:"monospace"},{start:120458,len:26,offset:97,variant:"monospace"},{start:120488,len:25,offset:913,style:"bold"},{start:120514,len:25,offset:945,style:"bold"},{start:120546,len:25,offset:913,style:"italic"},{start:120572,len:25,offset:945,style:"italic"},{start:120604,len:25,offset:913,style:"bolditalic"},{start:120630,len:25,offset:945,style:"bolditalic"},{start:120662,len:25,offset:913,variant:"sans-serif",style:"bold"},{start:120688,len:25,offset:945,variant:"sans-serif",style:"bold"},{start:120720,len:25,offset:913,variant:"sans-serif",style:"bolditalic"},{start:120746,len:25,offset:945,variant:"sans-serif",style:"bolditalic"},{start:120782,len:10,offset:48,variant:"main",style:"bold"},{start:120792,len:10,offset:48,variant:"double-struck"},{start:120803,len:10,offset:48,variant:"sans-serif"},{start:120812,len:10,offset:48,variant:"sans-serif",style:"bold"},{start:120822,len:10,offset:48,variant:"monospace"}];function O(e,t,n){if(!/[A-Za-z\d]/.test(e))return e;if("up"===n&&(n=void 0),!t&&!n)return e;const i=e.codePointAt(0);if(void 0===i)return e;for(const e of P)if((!t||e.variant===t)&&(!n||e.style===n)&&i>=e.offset&&i<e.offset+e.len){const t=e.start+i-e.offset;return String.fromCodePoint(I[t]||t)}return e}function F(e){var t;if((e<119808||e>120831)&&(e<8448||e>8527))return{char:String.fromCodePoint(e)};for(const n in I)if(I[n]===e){e=null!=(t=n.codePointAt(0))?t:0;break}for(const t of P)if(e>=t.start&&e<t.start+t.len)return{char:String.fromCodePoint(e-t.start+t.offset),variant:t.variant,style:t.style};return{char:String.fromCodePoint(e)}}function N(e){return e?Array.isArray(e)?e:"object"==typeof e&&"group"in e?e.group:[]:[]}var B,$,K,U={},z=u({},R),V={},q={},G={iff:{primitive:!0,captureSelection:!0,def:"\\;⟺\\;"},nicefrac:"^{#1}\\!\\!/\\!_{#2}",phase:{def:"\\enclose{phasorangle}{#1}",args:1,captureSelection:!1},rd:"\\mathrm{d}",rD:"\\mathrm{D}",doubleStruckCapitalN:"\\mathbb{N}",doubleStruckCapitalR:"\\mathbb{R}",doubleStruckCapitalQ:"\\mathbb{Q}",doubleStruckCapitalZ:"\\mathbb{Z}",doubleStruckCapitalP:"\\mathbb{P}",scriptCapitalE:"\\mathscr{E}",scriptCapitalH:"\\mathscr{H}",scriptCapitalL:"\\mathscr{L}",gothicCapitalC:"\\mathfrak{C}",gothicCapitalH:"\\mathfrak{H}",gothicCapitalI:"\\mathfrak{I}",gothicCapitalR:"\\mathfrak{R}",imaginaryI:"\\mathrm{i}",imaginaryJ:"\\mathrm{j}",exponentialE:"\\mathrm{e}",differentialD:"\\mathrm{d}",capitalDifferentialD:"\\mathrm{D}",mathstrut:{def:"\\vphantom{(}",primitive:!0},angl:"\\enclose{actuarial}{#1}",angln:"\\enclose{actuarial}{n}",anglr:"\\enclose{actuarial}{r}",anglk:"\\enclose{actuarial}{k}",mathtools:{primitive:!0,package:{ordinarycolon:":",vcentcolon:"\\mathrel{\\mathop\\ordinarycolon}",dblcolon:'{\\mathop{\\char"2237}}',coloneqq:'{\\mathop{\\char"2254}}',Coloneqq:'{\\mathop{\\char"2237\\char"3D}}',coloneq:'{\\mathop{\\char"3A\\char"2212}}',Coloneq:'{\\mathop{\\char"2237\\char"2212}}',eqqcolon:'{\\mathop{\\char"2255}}',Eqqcolon:'{\\mathop{\\char"3D\\char"2237}}',eqcolon:'{\\mathop{\\char"2239}}',Eqcolon:'{\\mathop{\\char"2212\\char"2237}}',colonapprox:'{\\mathop{\\char"003A\\char"2248}}',Colonapprox:'{\\mathop{\\char"2237\\char"2248}}',colonsim:'{\\mathop{\\char"3A\\char"223C}}',Colonsim:'{\\mathop{\\char"2237\\char"223C}}',colondash:"\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}",Colondash:"\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}",dashcolon:"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Dashcolon:"\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}"}},ratio:"\\vcentcolon",coloncolon:"\\dblcolon",colonequals:"\\coloneq",coloncolonequals:"\\Coloneq",equalscolon:"\\eqcolon",equalscoloncolon:"\\Eqcolon",colonminus:"\\colondash",coloncolonminus:"\\Colondash",minuscolon:"\\dashcolon",minuscoloncolon:"\\Dashcolon",coloncolonapprox:"\\Colonapprox",coloncolonsim:"\\Colonsim",simcolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Simcolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}",simcoloncolon:"\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}",approxcolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}",Approxcolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}",approxcoloncolon:"\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}",notni:"\\mathrel{\\char`∌}",limsup:"\\operatorname*{lim\\,sup}",liminf:"\\operatorname*{lim\\,inf}",injlim:"\\operatorname*{inj\\,lim}",projlim:"\\operatorname*{proj\\,lim}",varlimsup:"\\operatorname*{\\overline{lim}}",varliminf:"\\operatorname*{\\underline{lim}}",varinjlim:"\\operatorname*{\\underrightarrow{lim}}",varprojlim:"\\operatorname*{\\underleftarrow{lim}}",argmin:"\\operatorname*{arg\\,min}",argmax:"\\operatorname*{arg\\,max}",plim:"\\mathop{\\operatorname{plim}}\\limits",tripledash:{def:"\\vphantom{-}\\raise{4mu}{\\mkern1.5mu\\rule{2mu}{1.5mu}\\mkern{2.25mu}\\rule{2mu}{1.5mu}\\mkern{2.25mu}\\rule{2mu}{1.5mu}\\mkern{2mu}}",expand:!0},"braket.sty":{package:{bra:{def:"\\mathinner{\\langle{#1}|}",args:1,captureSelection:!1},ket:{def:"\\mathinner{|{#1}\\rangle}",args:1,captureSelection:!1},braket:{def:"\\mathinner{\\langle{#1}\\rangle}",args:1,captureSelection:!1},set:{def:"\\mathinner{\\lbrace #1 \\rbrace}",args:1,captureSelection:!1},Bra:{def:"\\left\\langle #1\\right|",args:1,captureSelection:!1},Ket:{def:"\\left|#1\\right\\rangle",args:1,captureSelection:!1},Braket:{def:"\\left\\langle{#1}\\right\\rangle",args:1,captureSelection:!1},Set:{def:"\\left\\lbrace #1 \\right\\rbrace",args:1,captureSelection:!1}}},"amsmath.sty":{package:{varGamma:"\\mathit{\\Gamma}",varDelta:"\\mathit{\\Delta}",varTheta:"\\mathit{\\Theta}",varLambda:"\\mathit{\\Lambda}",varXi:"\\mathit{\\Xi}",varPi:"\\mathit{\\Pi}",varSigma:"\\mathit{\\Sigma}",varUpsilon:"\\mathit{\\Upsilon}",varPhi:"\\mathit{\\Phi}",varPsi:"\\mathit{\\Psi}",varOmega:"\\mathit{\\Omega}",pmod:{def:"\\quad(\\operatorname{mod}\\ #1)",args:1,expand:!1,captureSelection:!1},mod:{def:"\\quad\\operatorname{mod}\\,\\,#1",args:1,expand:!1},bmod:{def:"\\;\\mathbin{\\operatorname{mod }}",expand:!1}},primitive:!0},"texvc.sty":{package:{darr:"\\downarrow",dArr:"\\Downarrow",Darr:"\\Downarrow",lang:"\\langle",rang:"\\rangle",uarr:"\\uparrow",uArr:"\\Uparrow",Uarr:"\\Uparrow",N:"\\mathbb{N}",R:"\\mathbb{R}",Z:"\\mathbb{Z}",alef:"\\aleph",alefsym:"\\aleph",Alpha:"\\mathrm{A}",Beta:"\\mathrm{B}",bull:"\\bullet",Chi:"\\mathrm{X}",clubs:"\\clubsuit",cnums:"\\mathbb{C}",Complex:"\\mathbb{C}",Dagger:"\\ddagger",diamonds:"\\diamondsuit",empty:"\\emptyset",Epsilon:"\\mathrm{E}",Eta:"\\mathrm{H}",exist:"\\exists",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",Harr:"\\Leftrightarrow",hearts:"\\heartsuit",image:"\\Im",infin:"\\infty",Iota:"\\mathrm{I}",isin:"\\in",Kappa:"\\mathrm{K}",larr:"\\leftarrow",lArr:"\\Leftarrow",Larr:"\\Leftarrow",lrarr:"\\leftrightarrow",lrArr:"\\Leftrightarrow",Lrarr:"\\Leftrightarrow",Mu:"\\mathrm{M}",natnums:"\\mathbb{N}",Nu:"\\mathrm{N}",Omicron:"\\mathrm{O}",plusmn:"\\pm",rarr:"\\rightarrow",rArr:"\\Rightarrow",Rarr:"\\Rightarrow",real:"\\Re",reals:"\\mathbb{R}",Reals:"\\mathbb{R}",Rho:"\\mathrm{P}",sdot:"\\cdot",sect:"\\S",spades:"\\spadesuit",sub:"\\subset",sube:"\\subseteq",supe:"\\supseteq",Tau:"\\mathrm{T}",thetasym:"\\vartheta",weierp:"\\wp",Zeta:"\\mathrm{Z}"},primitive:!1}},H={" ":32,"\\!":33,"\\#":35,"\\$":36,"\\%":37,"\\&":38,"-":45,"\\textunderscore":95,"\\euro":8364,"\\maltese":10016,"\\{":123,"\\}":125,"\\textbraceleft":123,"\\textbraceright":125,"\\lbrace":123,"\\rbrace":125,"\\lbrack":91,"\\rbrack":93,"\\nobreakspace":160,"\\ldots":8230,"\\textellipsis":8230,"\\backslash":92,"`":8216,"'":8217,"``":8220,"''":8221,"\\degree":176,"\\textasciicircum":94,"\\textasciitilde":126,"\\textasteriskcentered":42,"\\textbackslash":92,"\\textbullet":8226,"\\textdollar":36,"\\textsterling":163,"\\textdagger":8224,"\\textdaggerdbl":8225,"–":8211,"—":8212,"‘":8216,"’":8217,"“":8220,"”":8221,'"':8221,"\\ss":223,"\\ae":230,"\\oe":339,"\\AE":198,"\\OE":338,"\\O":216,"\\i":305,"\\j":567,"\\aa":229,"\\AA":197},j=/[\w!@*()-=+{}\[\]\\';:?/.,~<>`|$%#&^" ]/;function W(e,t,n="mord",i){void 0!==t&&(U[e]={definitionType:"symbol",type:n,variant:i,codepoint:t},z[t]||(z[t]=e))}function Z(e,t,n){if("string"!=typeof e)for(const[i,r,s,a]of e)W(i,r,null!=s?s:t,null!=a?a:n);else for(let t=0;t<e.length;t++){const n=e.charAt(t);W(n,n.codePointAt(0))}}function Y(e,t){for(let n=e;n<=t;n++)W(String.fromCodePoint(n),n)}function X(e){let t="auto";const n=e.match(/:([^=]+)/);return n&&(t=n[1].trim()),t}function J(e){if(!e)return[];const t=[];let n=e.split("]");if(n[0].startsWith("[")){t.push({isOptional:!0,type:X(n[0].slice(1))});for(let e=1;e<=n.length;e++)t.push(...J(n[e]))}else if(n=e.split("}"),n[0].startsWith("{")){t.push({isOptional:!1,type:X(n[0].slice(1))});for(let e=1;e<=n.length;e++)t.push(...J(n[e]))}return t}function Q(e){if(!e)return"";let t="",n=!0;for(const i of e)"string"==typeof i.value?t+=i.value:n=!1;return n?t:""}function ee(e,t){"string"==typeof e&&(e=[e]);const n={tabular:!1,params:[],createAtom:t};for(const t of e)q[t]=n}function te(e,t,n){"string"==typeof e&&(e=[e]);const i={tabular:!0,params:J(t),createAtom:n};for(const t of e)q[t]=i}function ne(e,t,n){var i,r;n||(n={});const s={definitionType:"function",params:J(t),ifMode:n.ifMode,isFunction:null!=(i=n.isFunction)&&i,applyMode:n.applyMode,infix:null!=(r=n.infix)&&r,parse:n.parse,createAtom:n.createAtom,applyStyle:n.applyStyle,serialize:n.serialize,render:n.render};if("string"==typeof e)V["\\"+e]=s;else for(const t of e)V["\\"+t]=s}function ie(e){return K||(K=se(G)),e?se(u(u({},K),e)):K}function re(e,t){var n,i,r,s;if("string"==typeof e){let r=0;const s=e;return/(^|[^\\])#1/.test(s)&&(r=1),/(^|[^\\])#2/.test(s)&&(r=2),/(^|[^\\])#3/.test(s)&&(r=3),/(^|[^\\])#4/.test(s)&&(r=4),/(^|[^\\])#5/.test(s)&&(r=5),/(^|[^\\])#6/.test(s)&&(r=6),/(^|[^\\])#7/.test(s)&&(r=7),/(^|[^\\])#8/.test(s)&&(r=8),/(^|[^\\])#9/.test(s)&&(r=9),{expand:null==(n=null==t?void 0:t.expand)||n,captureSelection:null==(i=null==t?void 0:t.captureSelection)||i,args:r,def:s}}return u({expand:null==(r=null==t?void 0:t.expand)||r,captureSelection:null==(s=null==t?void 0:t.captureSelection)||s,args:0},e)}function se(e){if(!e)return{};const t={};for(const n of Object.keys(e)){const i=e[n];if(null==i)delete t[n];else if("object"==typeof i&&"package"in i)for(const e of Object.keys(i.package))t[e]=re(i.package[e],{expand:!i.primitive,captureSelection:i.captureSelection});else t[n]=re(i)}return t}function ae(e,t="math"){if(!e||0===e.length)return null;let n=null;if(e.startsWith("\\")){if(n=V[e],n)return n.ifMode&&n.ifMode!==t?null:n;"math"===t?n=U[e]:H[e]&&(n={definitionType:"symbol",type:"mord",codepoint:H[e]})}else if("math"===t){if(n=U[e],!n&&1===e.length){const t=le("math",e.codePointAt(0));return t.startsWith("\\")?h(u({},ae(t,"math")),{command:t}):null}}else H[e]?n={definitionType:"symbol",type:"mord",codepoint:H[e]}:"text"===t&&(n={definitionType:"symbol",type:"mord",codepoint:e.codePointAt(0)});return null!=n?n:null}function oe(e,t){if(!e.startsWith("\\"))return null;return t[e.slice(1)]}function le(e,t){if(void 0===t)return"";if("math"===e&&z[t])return z[t];if("text"===e){const e=Object.keys(H).find((e=>H[e]===t));return e||String.fromCodePoint(t)}return String.fromCodePoint(t)}!function(){if(!m())return!0;if(/firefox/i.test(navigator.userAgent)){const e=navigator.userAgent.match(/firefox\/(\d+)/i);if(!e)return!1;return parseInt(e[1])>=78}if(/trident/i.test(navigator.userAgent))return!1;if(/edge/i.test(navigator.userAgent)){const e=navigator.userAgent.match(/edg\/(\d+)/i);if(!e)return!1;return parseInt(e[1])>=79}return!0}()?(B=/[a-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓóŚśŹźŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/,$=/[\da-zA-ZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяĄąĆćĘꣳŃńÓóŚśŹźŻżàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒößÖẞìíòúÌÍÒÚáñÁÑ]/):(B=new RegExp("\\p{Letter}","u"),$=new RegExp("[0-9\\p{Letter}]","u"));var ce=[0,.68889,0,0,.72222],ue=[0,.68889,0,0,.66667],he=[0,.68889,0,0,.77778],de=[0,.68889,0,0,.61111],pe=[.16667,.68889,0,0,.77778],fe=[0,.68889,0,0,.55556],me=[0,0,0,0,.25],ge=[0,.825,0,0,2.33334],_e=[0,.9,0,0,2.33334],ye=[0,.68889,0,0,.54028],ve=[-.03598,.46402,0,0,.5],be=[-.13313,.36687,0,0,1],we=[.01354,.52239,0,0,1],xe=[.01354,.52239,0,0,1.11111],ke=[0,.54986,0,0,1],Se=[0,.69224,0,0,.5],Ee=[0,.43056,0,0,1],Te=[.08198,.58198,0,0,.77778],Ce=[.19444,.69224,0,0,.41667],Le=[.1808,.675,0,0,1],Ae=[.19444,.69224,0,0,.83334],De=[.13667,.63667,0,0,1],Me=[-.064,.437,0,0,1.334],Re=[.08167,.58167,0,0,.77778],Ie=[0,.69224,0,0,.72222],Pe=[0,.69224,0,0,.66667],Oe=[-.13313,.36687,0,0,.77778],Fe=[.06062,.54986,0,0,.77778],Ne=[0,.69224,0,0,.77778],Be=[.25583,.75583,0,0,.77778],$e=[.25142,.75726,0,0,.77778],Ke=[.20576,.70576,0,0,.77778],Ue=[.30274,.79383,0,0,.77778],ze=[.22958,.72958,0,0,.77778],Ve=[.1808,.675,0,0,.77778],qe=[.13667,.63667,0,0,.77778],Ge=[.13597,.63597,0,0,.77778],He=[.03517,.54986,0,0,.77778],je=[0,.675,0,0,.77778],We=[.19444,.69224,0,0,.61111],Ze=[0,.54986,0,0,.76042],Ye=[0,.54986,0,0,.66667],Xe=[.0391,.5391,0,0,.77778],Je=[.03517,.54986,0,0,1.33334],Qe=[.38569,.88569,0,0,.77778],et=[.23222,.74111,0,0,.77778],tt=[.19444,.69224,0,0,.77778],nt=[0,.37788,0,0,.5],it=[0,.54986,0,0,.72222],rt=[0,.69224,0,0,.83334],st=[.11111,.69224,0,0,.66667],at=[.26167,.75726,0,0,.77778],ot=[.48256,.98256,0,0,.77778],lt=[.28481,.79383,0,0,.77778],ct=[.08167,.58167,0,0,.22222],ut=[.08167,.58167,0,0,.38889],ht=[0,.43056,.04028,0,.66667],dt=[.41951,.91951,0,0,.77778],pt=[.24982,.74947,0,0,.38865],ft=[.08319,.58283,0,0,.75623],mt=[0,.10803,0,0,.27764],gt=[0,.47534,0,0,.50181],_t=[.18906,.47534,0,0,.50181],yt=[0,.69141,0,0,.50181],vt=[.24982,.74947,0,0,.27764],bt=[0,.69141,0,0,.21471],wt=[.25,.75,0,0,.44722],xt=[0,.64444,0,0,.575],kt=[.08556,.58556,0,0,.89444],St=[0,.69444,0,0,.89444],Et=[0,.68611,0,0,.9],Tt=[0,.68611,0,0,.86944],Ct=[.25,.75,0,0,.575],Lt=[.25,.75,0,0,.31944],At=[0,.69444,0,0,.63889],Dt=[0,.69444,0,0,.31944],Mt=[0,.44444,0,0,.63889],Rt=[0,.44444,0,0,.51111],It=[0,.69444,0,0,.575],Pt=[.13333,.63333,0,0,.89444],Ot=[0,.44444,0,0,.31944],Ft=[0,.69444,0,0,.86944],Nt=[0,.68611,0,0,.69166],Bt=[0,.68611,0,0,.83055],$t=[0,.68611,0,0,.89444],Kt=[0,.69444,0,0,.60278],Ut=[.19444,.69444,0,0,.51111],zt=[0,.69444,0,0,.83055],Vt=[-.10889,.39111,0,0,1.14999],qt=[.19444,.69444,0,0,.575],Gt=[.19444,.69444,0,0,1.14999],Ht=[.19444,.69444,0,0,.70277],jt=[.05556,.75,0,0,.575],Wt=[0,.68611,0,0,.95833],Zt=[.08556,.58556,0,0,.76666],Yt=[-.02639,.47361,0,0,.575],Xt=[0,.44444,0,0,.89444],Jt=[0,.55556,0,0,.76666],Qt=[-.10889,.39111,0,0,.89444],en=[.00222,.50222,0,0,.89444],tn=[.19667,.69667,0,0,.89444],nn=[.08556,.58556,0,0,1.14999],rn=[0,.69444,0,0,.70277],sn=[-.02778,.47222,0,0,.575],an=[.25,.75,0,0,.51111],on=[-.13889,.36111,0,0,1.14999],ln=[.19444,.69444,0,0,1.02222],cn=[.12963,.69444,0,0,.89444],un=[.19444,.69444,0,0,.44722],hn=[0,.64444,.13167,0,.59111],dn=[.19444,.64444,.13167,0,.59111],pn=[0,.68611,.17208,0,.8961],fn=[.19444,.44444,.105,0,.53222],mn=[0,.44444,.085,0,.82666],gn=[0,.69444,.06709,0,.59111],_n=[0,.69444,.12945,0,.35555],yn=[0,.69444,0,0,.94888],vn=[0,.69444,.11472,0,.59111],bn=[0,.68611,.10778,0,.88555],wn=[0,.69444,.07939,0,.62055],xn=[0,.69444,.12417,0,.30667],kn=[0,.64444,.13556,0,.51111],Sn=[.19444,.64444,.13556,0,.51111],En=[0,.68333,.16389,0,.74333],Tn=[.19444,.43056,.08847,0,.46],Cn=[0,.43056,.07514,0,.71555],Ln=[0,.69444,.06646,0,.51111],An=[0,.69444,0,0,.83129],Dn=[0,.69444,.1225,0,.51111],Mn=[0,.68333,.09403,0,.76666],Rn=[0,.68333,.11111,0,.76666],In=[0,.69444,.06961,0,.51444],Pn=[0,.69444,0,0,.27778],On=[.25,.75,0,0,.38889],Fn=[0,.64444,0,0,.5],Nn=[0,.69444,0,0,.77778],Bn=[0,.68333,0,0,.75],$n=[0,.68333,0,0,.77778],Kn=[0,.68333,0,0,.68056],Un=[0,.68333,0,0,.72222],zn=[.25,.75,0,0,.5],Vn=[.25,.75,0,0,.27778],qn=[0,.69444,0,0,.5],Gn=[0,.69444,0,0,.55556],Hn=[0,.43056,0,0,.44445],jn=[0,.43056,0,0,.5],Wn=[.19444,.43056,0,0,.55556],Zn=[0,.43056,0,0,.55556],Yn=[.08333,.58333,0,0,.77778],Xn=[0,.43056,0,0,.27778],Jn=[0,.66786,0,0,.27778],Qn=[0,.69444,0,0,.75],ei=[0,.66786,0,0,.5],ti=[0,.68333,0,0,.625],ni=[.19444,.69444,0,0,.44445],ii=[0,.69444,0,0,.72222],ri=[.19444,.69444,0,0,.5],si=[.19444,.69444,0,0,1],ai=[.011,.511,0,0,1.126],oi=[.19444,.69444,0,0,.61111],li=[.05556,.75,0,0,.5],ci=[0,.68333,0,0,.83334],ui=[.0391,.5391,0,0,.66667],hi=[-.05555,.44445,0,0,.5],di=[0,.43056,0,0,.77778],pi=[0,.55556,0,0,.66667],fi=[-.03625,.46375,0,0,.77778],mi=[-.01688,.48312,0,0,.77778],gi=[.0391,.5391,0,0,1],_i=[0,.69444,0,0,.61111],yi=[-.03472,.46528,0,0,.5],vi=[.25,.75,0,0,.44445],bi=[-.14236,.35764,0,0,1],wi=[.244,.744,0,0,.412],xi=[.19444,.69444,0,0,.88889],ki=[.12963,.69444,0,0,.77778],Si=[.19444,.69444,0,0,.38889],Ei=[.011,.511,0,0,1.638],Ti=[.19444,.69444,0,0,0],Ci=[0,.44444,0,0,.575],Li=[.19444,.44444,0,0,.575],Ai=[0,.68611,0,0,.75555],Di=[0,.69444,0,0,.66759],Mi=[0,.68611,0,0,.80555],Ri=[0,.68611,.08229,0,.98229],Ii=[0,.68611,0,0,.76666],Pi=[0,.44444,0,0,.58472],Oi=[.19444,.44444,0,0,.6118],Fi=[.19444,.43056,0,0,.5],Ni=[0,.68333,.02778,.08334,.76278],Bi=[0,.68333,.08125,.05556,.83125],$i=[0,.43056,0,.05556,.48472],Ki=[.19444,.43056,0,.08334,.51702],Ui=[.25,.75,0,0,.42778],zi=[0,.69444,0,0,.55],Vi=[0,.69444,0,0,.73334],qi=[0,.69444,0,0,.79445],Gi=[0,.69444,0,0,.51945],Hi=[0,.69444,0,0,.70278],ji=[0,.69444,0,0,.76389],Wi=[.25,.75,0,0,.34306],Zi=[0,.69444,0,0,.56111],Yi=[0,.69444,0,0,.25556],Xi=[.19444,.45833,0,0,.56111],Ji=[0,.45833,0,0,.56111],Qi=[0,.69444,0,0,.30556],er=[0,.69444,0,0,.58056],tr=[0,.69444,0,0,.67223],nr=[0,.69444,0,0,.85556],ir=[0,.69444,0,0,.55834],rr=[0,.65556,.11156,0,.5],sr=[0,.69444,.08094,0,.70834],ar=[.17014,0,0,0,.44445],or=[0,.69444,.0799,0,.5],lr=[0,.69444,0,0,.73752],cr=[0,.69444,.09205,0,.5],ur=[0,.69444,.09031,0,.77778],hr=[0,.69444,.07816,0,.27778],dr=[0,.69444,.00316,0,.5],pr=[.19444,.69444,0,0,.83334],fr=[.05556,.75,0,0,.83334],mr=[0,.75,0,0,.5],gr=[.125,.08333,0,0,.27778],_r=[0,.08333,0,0,.27778],yr=[0,.65556,0,0,.5],vr=[0,.69444,0,0,.47222],br=[0,.69444,0,0,.66667],wr=[0,.69444,0,0,.59722],xr=[0,.69444,0,0,.54167],kr=[0,.69444,0,0,.70834],Sr=[.25,.75,0,0,.28889],Er=[0,.69444,0,0,.51667],Tr=[0,.44444,0,0,.44445],Cr=[.19444,.44444,0,0,.51667],Lr=[0,.44444,0,0,.38333],Ar=[0,.44444,0,0,.51667],Dr=[0,.69444,0,0,.83334],Mr=[.35001,.85,0,0,.45834],Rr=[.35001,.85,0,0,.57778],Ir=[.35001,.85,0,0,.41667],Pr=[.35001,.85,0,0,.58334],Or=[0,.72222,0,0,.55556],Fr=[1e-5,.6,0,0,.66667],Nr=[1e-5,.6,0,0,.77778],Br=[.25001,.75,0,0,.94445],$r=[.306,.805,.19445,0,.47222],Kr=[.30612,.805,.19445,0,.47222],Ur=[.25001,.75,0,0,.83334],zr=[.35001,.85,0,0,.47222],Vr=[.25001,.75,0,0,1.11111],qr=[.65002,1.15,0,0,.59722],Gr=[.65002,1.15,0,0,.81111],Hr=[.65002,1.15,0,0,.47222],jr=[.65002,1.15,0,0,.66667],Wr=[0,.75,0,0,1],Zr=[.55001,1.05,0,0,1.27778],Yr=[.862,1.36,.44445,0,.55556],Xr=[.86225,1.36,.44445,0,.55556],Jr=[.55001,1.05,0,0,1.11111],Qr=[.65002,1.15,0,0,.52778],es=[.65002,1.15,0,0,.61111],ts=[.55001,1.05,0,0,1.51112],ns=[.95003,1.45,0,0,.73611],is=[.95003,1.45,0,0,1.04445],rs=[.95003,1.45,0,0,.52778],ss=[.95003,1.45,0,0,.75],as=[0,.75,0,0,1.44445],os=[.95003,1.45,0,0,.58334],ls=[1.25003,1.75,0,0,.79167],cs=[1.25003,1.75,0,0,1.27778],us=[1.25003,1.75,0,0,.58334],hs=[1.25003,1.75,0,0,.80556],ds=[0,.825,0,0,1.8889],ps=[1.25003,1.75,0,0,.63889],fs=[.64502,1.155,0,0,.875],ms=[1e-5,.6,0,0,.875],gs=[-99e-5,.601,0,0,.66667],_s=[.64502,1.155,0,0,.66667],ys=[1e-5,.9,0,0,.88889],vs=[.65002,1.15,0,0,.88889],bs=[.90001,0,0,0,.88889],ws=[-.00499,.605,0,0,1.05556],xs=[0,.12,0,0,.45],ks=[0,.61111,0,0,.525],Ss=[.08333,.69444,0,0,.525],Es=[-.08056,.53055,0,0,.525],Ts=[-.05556,.55556,0,0,.525],Cs=[0,.43056,0,0,.525],Ls=[.22222,.43056,0,0,.525],As=[0,0,0,0,.525],Ds={"AMS-Regular":{32:me,65:ce,66:ue,67:ce,68:ce,69:ue,70:de,71:he,72:he,73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:he,76:ue,77:[0,.68889,0,0,.94445],78:ce,79:pe,80:de,81:pe,82:ce,83:fe,84:ue,85:ce,86:ce,87:[0,.68889,0,0,1],88:ce,89:ce,90:ue,107:fe,160:me,165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:fe,295:ye,710:ge,732:_e,770:ge,771:_e,989:Re,1008:ht,8245:[0,.54986,0,0,.275],8463:ye,8487:ce,8498:fe,8502:ue,8503:[0,.68889,0,0,.44445],8504:ue,8513:[0,.68889,0,0,.63889],8592:ve,8594:ve,8602:be,8603:be,8606:we,8608:we,8610:xe,8611:xe,8619:ke,8620:ke,8621:[-.13313,.37788,0,0,1.38889],8622:be,8624:Se,8625:Se,8630:Ee,8631:Ee,8634:Te,8635:Te,8638:Ce,8639:Ce,8642:Ce,8643:Ce,8644:Le,8646:Le,8647:Le,8648:Ae,8649:Le,8650:Ae,8651:we,8652:we,8653:be,8654:be,8655:be,8666:De,8667:De,8669:[-.13313,.37788,0,0,1],8672:Me,8674:Me,8705:[0,.825,0,0,.5],8708:fe,8709:Re,8717:[0,.43056,0,0,.42917],8722:ve,8724:[.08198,.69224,0,0,.77778],8726:Re,8733:Ne,8736:Ie,8737:Ie,8738:[.03517,.52239,0,0,.72222],8739:ct,8740:[.25142,.74111,0,0,.27778],8741:ut,8742:[.25142,.74111,0,0,.5],8756:Pe,8757:Pe,8764:Oe,8765:[-.13313,.37788,0,0,.77778],8769:Oe,8770:fi,8774:Ue,8776:mi,8778:Re,8782:Fe,8783:Fe,8785:Te,8786:Te,8787:Te,8790:Ne,8791:ze,8796:[.08198,.91667,0,0,.77778],8806:Be,8807:Be,8808:$e,8809:$e,8812:[.25583,.75583,0,0,.5],8814:Ke,8815:Ke,8816:Ue,8817:Ue,8818:ze,8819:ze,8822:Ve,8823:Ve,8828:qe,8829:qe,8830:ze,8831:ze,8832:Ke,8833:Ke,8840:Ue,8841:Ue,8842:Ge,8843:Ge,8847:He,8848:He,8858:Te,8859:Te,8861:Te,8862:je,8863:je,8864:je,8865:je,8872:[0,.69224,0,0,.61111],8873:Ie,8874:[0,.69224,0,0,.88889],8876:de,8877:de,8878:ce,8879:ce,8882:He,8883:He,8884:qe,8885:qe,8888:[0,.54986,0,0,1.11111],8890:Wn,8891:We,8892:We,8901:[0,.54986,0,0,.27778],8903:Re,8905:Re,8906:Re,8907:Ne,8908:Ne,8909:[-.03598,.46402,0,0,.77778],8910:Ze,8911:Ze,8912:He,8913:He,8914:Ye,8915:Ye,8916:Pe,8918:Xe,8919:Xe,8920:Je,8921:Je,8922:Qe,8923:Qe,8926:qe,8927:qe,8928:Ue,8929:Ue,8934:et,8935:et,8936:et,8937:et,8938:Ke,8939:Ke,8940:Ue,8941:Ue,8994:tt,8995:tt,9416:[.15559,.69224,0,0,.90222],9484:Se,9488:Se,9492:nt,9496:nt,9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:je,9633:je,9650:it,9651:it,9654:He,9660:it,9661:it,9664:He,9674:st,9733:[.19444,.69224,0,0,.94445],10003:rt,10016:rt,10731:st,10846:[.19444,.75583,0,0,.61111],10877:qe,10878:qe,10885:Be,10886:Be,10887:Ge,10888:Ge,10889:at,10890:at,10891:ot,10892:ot,10901:qe,10902:qe,10933:$e,10934:$e,10935:at,10936:at,10937:at,10938:at,10949:Be,10950:Be,10955:lt,10956:lt,57350:ct,57351:ut,57352:Re,57353:ht,57356:$e,57357:$e,57358:dt,57359:Ue,57360:Ue,57361:dt,57366:$e,57367:$e,57368:$e,57369:$e,57370:Ge,57371:Ge},"Caligraphic-Regular":{32:me,65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:me},"Fraktur-Regular":{32:me,33:[0,.69141,0,0,.29574],34:bt,38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:pt,41:pt,42:[0,.62119,0,0,.27764],43:ft,44:mt,45:ft,46:mt,47:[.24982,.74947,0,0,.50181],48:gt,49:gt,50:gt,51:_t,52:_t,53:_t,54:yt,55:_t,56:yt,57:_t,58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:vt,93:vt,94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:me,8216:bt,8217:bt,58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:me,33:[0,.69444,0,0,.35],34:Kt,35:[.19444,.69444,0,0,.95833],36:jt,37:[.05556,.75,0,0,.95833],38:St,39:Dt,40:wt,41:wt,42:[0,.75,0,0,.575],43:Pt,44:[.19444,.15556,0,0,.31944],45:Lr,46:[0,.15556,0,0,.31944],47:Ct,48:xt,49:xt,50:xt,51:xt,52:xt,53:xt,54:xt,55:xt,56:xt,57:xt,58:Ot,59:[.19444,.44444,0,0,.31944],60:kt,61:Qt,62:kt,63:[0,.69444,0,0,.54305],64:St,65:Tt,66:[0,.68611,0,0,.81805],67:Bt,68:[0,.68611,0,0,.88194],69:Ai,70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:Et,73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:Nt,77:[0,.68611,0,0,1.09166],78:Et,79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:Tt,89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:Lt,92:Ct,93:Lt,94:It,95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:At,99:Rt,100:At,101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:At,105:Dt,106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:Dt,109:[0,.44444,0,0,.95833],110:Mt,111:Ci,112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:Mt,118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:Rt,123:Ct,124:Lt,125:Ct,126:[.35,.34444,0,0,.575],160:me,163:[0,.69444,0,0,.86853],168:It,172:[0,.44444,0,0,.76666],176:Ft,177:Pt,184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:Pt,216:[.04861,.73472,0,0,.89444],223:wr,230:[0,.44444,0,0,.83055],247:Pt,248:[.09722,.54167,0,0,.575],305:Ot,338:[0,.68611,0,0,1.16944],339:Xt,567:[.19444,.44444,0,0,.35139],710:It,711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:It,715:It,728:It,729:Dt,730:Ft,732:It,733:It,915:Nt,916:Wt,920:$t,923:Mi,926:Ii,928:Et,931:Bt,933:$t,934:Bt,936:$t,937:Bt,8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:Dt,8217:Dt,8220:Kt,8221:Kt,8224:Ut,8225:Ut,8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:Di,8465:zt,8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:zt,8501:rn,8592:Vt,8593:qt,8594:Vt,8595:qt,8596:Vt,8597:Ct,8598:Gt,8599:Gt,8600:Gt,8601:Gt,8636:Vt,8637:Vt,8640:Vt,8641:Vt,8656:Vt,8657:Ht,8658:Vt,8659:Ht,8660:Vt,8661:[.25,.75,0,0,.70277],8704:At,8706:[0,.69444,.06389,0,.62847],8707:At,8709:jt,8711:Wt,8712:Zt,8715:Zt,8722:Pt,8723:Pt,8725:Ct,8726:Ct,8727:sn,8728:Yt,8729:Yt,8730:[.18,.82,0,0,.95833],8733:Xt,8734:[0,.44444,0,0,1.14999],8736:Ie,8739:Lt,8741:Ct,8743:Jt,8744:Jt,8745:Jt,8746:Jt,8747:[.19444,.69444,.12778,0,.56875],8764:Qt,8768:[.19444,.69444,0,0,.31944],8771:en,8776:[.02444,.52444,0,0,.89444],8781:en,8801:en,8804:tn,8805:tn,8810:nn,8811:nn,8826:kt,8827:kt,8834:kt,8835:kt,8838:tn,8839:tn,8846:Jt,8849:tn,8850:tn,8851:Jt,8852:Jt,8853:Pt,8854:Pt,8855:Pt,8856:Pt,8857:Pt,8866:rn,8867:rn,8868:St,8869:St,8900:Yt,8901:[-.02639,.47361,0,0,.31944],8902:sn,8968:an,8969:an,8970:an,8971:an,8994:on,8995:on,9651:ln,9657:sn,9661:ln,9667:sn,9711:Gt,9824:cn,9825:cn,9826:cn,9827:cn,9837:[0,.75,0,0,.44722],9838:un,9839:un,10216:wt,10217:wt,10815:Et,10927:tn,10928:tn,57376:Ti},"Main-BoldItalic":{32:me,33:[0,.69444,.11417,0,.38611],34:wn,35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:_n,40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:hn,49:hn,50:hn,51:hn,52:dn,53:hn,54:hn,55:dn,56:hn,57:hn,58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:vn,64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:pn,73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:pn,79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:gn,95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:fn,104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:fn,114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:me,168:[0,.69444,.11473,0,.59111],176:yn,184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:mn,248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:mn,567:[.19444,.44444,.04611,0,.385],710:gn,711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:_n,730:yn,732:vn,733:vn,915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:pn,931:[0,.68611,.11431,0,.82666],933:bn,934:[0,.68611,.05632,0,.82666],936:bn,937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:_n,8217:_n,8220:[0,.69444,.16772,0,.62055],8221:wn},"Main-Italic":{32:me,33:xn,34:In,35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:xn,40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:kn,49:kn,50:kn,51:kn,52:Sn,53:kn,54:kn,55:Sn,56:kn,57:kn,58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:Dn,64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:En,73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:En,79:Mn,80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:En,86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:Ln,95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:Tn,104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:Tn,114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:me,168:[0,.66786,.10474,0,.51111],176:An,184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:Cn,248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:Cn,710:Ln,711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:An,732:[0,.66786,.11585,0,.51111],733:Dn,915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:Mn,923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:En,931:[0,.68333,.12028,0,.71555],933:Rn,934:[0,.68333,.05986,0,.71555],936:Rn,937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:xn,8217:xn,8220:[0,.69444,.1685,0,.51444],8221:In,8463:ye},"Main-Regular":{32:me,33:Pn,34:qn,35:pr,36:li,37:fr,38:Nn,39:Pn,40:On,41:On,42:mr,43:Yn,44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:zn,48:Fn,49:Fn,50:Fn,51:Fn,52:Fn,53:Fn,54:Fn,55:Fn,56:Fn,57:Fn,58:Xn,59:[.19444,.43056,0,0,.27778],60:Xe,61:Oe,62:Xe,63:vr,64:Nn,65:Bn,66:[0,.68333,0,0,.70834],67:Un,68:[0,.68333,0,0,.76389],69:Kn,70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:Bn,73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:$n,76:ti,77:[0,.68333,0,0,.91667],78:Bn,79:$n,80:Kn,81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:Un,85:Bn,86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:Bn,89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:Vn,92:zn,93:Vn,94:qn,95:[.31,.12056,.02778,0,.5],97:jn,98:Gn,99:Hn,100:Gn,101:Hn,102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:Gn,105:Jn,106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:Pn,109:[0,.43056,0,0,.83334],110:Zn,111:jn,112:Wn,113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:Zn,118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:Hn,123:zn,124:Vn,125:zn,126:[.35,.31786,0,0,.5],160:me,163:[0,.69444,0,0,.76909],167:ni,168:ei,172:[0,.43056,0,0,.66667],176:Qn,177:Yn,182:oi,184:ar,198:[0,.68333,0,0,.90278],215:Yn,216:[.04861,.73194,0,0,.77778],223:qn,230:[0,.43056,0,0,.72222],247:Yn,248:[.09722,.52778,0,0,.5],305:Xn,338:[0,.68333,0,0,1.01389],339:di,567:[.19444,.43056,0,0,.30556],710:qn,711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:qn,715:qn,728:qn,729:Jn,730:Qn,732:ei,733:qn,915:ti,916:ci,920:$n,923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:Bn,931:Un,933:$n,934:Un,936:$n,937:Un,8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:Pn,8217:Pn,8220:qn,8221:qn,8224:ni,8225:ni,8230:[0,.12,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:ye,8465:ii,8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:ii,8501:_i,8592:be,8593:ri,8594:be,8595:ri,8596:be,8597:zn,8598:si,8599:si,8600:si,8601:si,8614:[.011,.511,0,0,1],8617:ai,8618:ai,8636:be,8637:be,8640:be,8641:be,8652:[.011,.671,0,0,1],8656:be,8657:oi,8658:be,8659:oi,8660:be,8661:[.25,.75,0,0,.61111],8704:Gn,8706:[0,.69444,.05556,.08334,.5309],8707:Gn,8709:li,8711:ci,8712:ui,8715:ui,8722:Yn,8723:Yn,8725:zn,8726:zn,8727:yi,8728:hi,8729:hi,8730:[.2,.8,0,0,.83334],8733:di,8734:Ee,8736:Ie,8739:Vn,8741:zn,8743:pi,8744:pi,8745:pi,8746:pi,8747:[.19444,.69444,.11111,0,.41667],8764:Oe,8768:[.19444,.69444,0,0,.27778],8771:fi,8773:[-.022,.589,0,0,1],8776:mi,8781:fi,8784:[-.133,.67,0,0,.778],8801:fi,8804:Ge,8805:Ge,8810:gi,8811:gi,8826:Xe,8827:Xe,8834:Xe,8835:Xe,8838:Ge,8839:Ge,8846:pi,8849:Ge,8850:Ge,8851:pi,8852:pi,8853:Yn,8854:Yn,8855:Yn,8856:Yn,8857:Yn,8866:_i,8867:_i,8868:Nn,8869:Nn,8872:[.249,.75,0,0,.867],8900:hi,8901:[-.05555,.44445,0,0,.27778],8902:yi,8904:[.005,.505,0,0,.9],8942:[.03,.9,0,0,.278],8943:[-.19,.31,0,0,1.172],8945:[-.1,.82,0,0,1.282],8968:vi,8969:vi,8970:vi,8971:vi,8994:bi,8995:bi,9136:wi,9137:wi,9651:xi,9657:yi,9661:xi,9667:yi,9711:si,9824:ki,9825:ki,9826:ki,9827:ki,9837:[0,.75,0,0,.38889],9838:Si,9839:Si,10216:On,10217:On,10222:wi,10223:wi,10229:[.011,.511,0,0,1.609],10230:Ei,10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:Ei,10815:Bn,10927:Ge,10928:Ge,57376:Ti},"Math-BoldItalic":{32:me,48:Ci,49:Ci,50:Ci,51:Li,52:Li,53:Li,54:xt,55:Li,56:xt,57:Li,65:Tt,66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:Ri,73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:Ai,77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:Di,105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:Pi,112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:me,915:[0,.68611,.15972,0,.65694],916:Wt,920:[0,.68611,.03194,0,.86722],923:Mi,926:[0,.68611,.07458,0,.84125],928:Ri,931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:Ii,936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:Pi,960:[0,.44444,.03704,0,.68241],961:Oi,962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:Oi,1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:me,48:jn,49:jn,50:jn,51:Fi,52:Fi,53:Fi,54:Fn,55:Fi,56:Fn,57:Fi,65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:Bi,73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:Ni,80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:$i,112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:me,915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:Ni,923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:Bi,931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:$i,960:[0,.43056,.03588,0,.57003],961:Ki,962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:Ki,1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:me,33:[0,.69444,0,0,.36667],34:ir,35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:Qi,40:Ui,41:Ui,42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:zi,49:zi,50:zi,51:zi,52:zi,53:zi,54:zi,55:zi,56:zi,57:zi,58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:Gi,64:Vi,65:Vi,66:Vi,67:Hi,68:qi,69:[0,.69444,0,0,.64167],70:_i,71:Vi,72:qi,73:[0,.69444,0,0,.33056],74:Gi,75:ji,76:er,77:[0,.69444,0,0,.97778],78:qi,79:qi,80:Hi,81:[.10556,.69444,0,0,.79445],82:Hi,83:_i,84:Vi,85:ji,86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:Vi,89:[0,.69444,.0275,0,.73334],90:tr,91:Wi,93:Wi,94:zi,95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:Zi,99:[0,.45833,0,0,.48889],100:Zi,101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:Zi,105:Yi,106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:Yi,109:[0,.45833,0,0,.86667],110:Ji,111:[0,.45833,0,0,.55],112:Xi,113:Xi,114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:Ji,118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:me,168:zi,176:Vi,180:zi,184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:zi,711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:zi,729:Qi,730:Vi,732:zi,733:zi,915:er,916:[0,.69444,0,0,.91667],920:nr,923:tr,926:Vi,928:qi,931:qi,933:nr,934:qi,936:nr,937:qi,8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:Qi,8217:Qi,8220:ir,8221:ir},"SansSerif-Italic":{32:me,33:[0,.69444,.05733,0,.31945],34:dr,35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:hr,40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:gr,45:[0,.44444,.01946,0,.33333],46:_r,47:[.25,.75,.13164,0,.5],48:rr,49:rr,50:rr,51:rr,52:rr,53:rr,54:rr,55:rr,56:rr,57:rr,58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:br,66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:sr,73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:xr,77:[0,.69444,.08094,0,.875],78:sr,79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:or,95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:me,168:[0,.67937,.06385,0,.5],176:lr,184:ar,305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:or,711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:cr,715:qn,728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:lr,732:[0,.67659,.08826,0,.5],733:cr,915:[0,.69444,.13372,0,.54167],916:Dr,920:[0,.69444,.07555,0,.77778],923:_i,926:[0,.69444,.12816,0,.66667],928:sr,931:[0,.69444,.11983,0,.72222],933:ur,934:[0,.69444,.04603,0,.72222],936:ur,937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:hr,8217:hr,8220:[0,.69444,.14205,0,.5],8221:dr},"SansSerif-Regular":{32:me,33:[0,.69444,0,0,.31945],34:qn,35:pr,36:li,37:fr,38:[0,.69444,0,0,.75834],39:Pn,40:On,41:On,42:mr,43:Yn,44:gr,45:[0,.44444,0,0,.33333],46:_r,47:zn,48:yr,49:yr,50:yr,51:yr,52:yr,53:yr,54:yr,55:yr,56:yr,57:yr,58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:vr,64:br,65:br,66:br,67:At,68:[0,.69444,0,0,.72223],69:wr,70:[0,.69444,0,0,.56945],71:br,72:kr,73:Pn,74:vr,75:[0,.69444,0,0,.69445],76:xr,77:[0,.69444,0,0,.875],78:kr,79:[0,.69444,0,0,.73611],80:At,81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:Gn,84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:br,89:[0,.69444,.025,0,.66667],90:_i,91:Sr,93:Sr,94:qn,95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:Er,99:Tr,100:Er,101:Tr,102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:Er,105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:Ar,111:[0,.44444,0,0,.5],112:Cr,113:Cr,114:[0,.44444,.01389,0,.34167],115:Lr,116:[0,.57143,0,0,.36111],117:Ar,118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:me,168:[0,.67937,0,0,.5],176:br,184:ar,305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:qn,711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:qn,715:qn,728:qn,729:[0,.67937,0,0,.27778],730:br,732:[0,.67659,0,0,.5],733:qn,915:xr,916:Dr,920:Nn,923:_i,926:br,928:kr,931:ii,933:Nn,934:ii,936:Nn,937:ii,8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:Pn,8217:Pn,8220:qn,8221:qn},"Script-Regular":{32:me,65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:me},"Size1-Regular":{32:me,40:Mr,41:Mr,47:Rr,91:Ir,92:Rr,93:Ir,123:Pr,125:Pr,160:me,710:Or,732:Or,770:Or,771:Or,8214:[-99e-5,.601,0,0,.77778],8593:Fr,8595:Fr,8657:Nr,8659:Nr,8719:Br,8720:Br,8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:Kr,8748:$r,8749:$r,8750:Kr,8896:Ur,8897:Ur,8898:Ur,8899:Ur,8968:zr,8969:zr,8970:zr,8971:zr,9168:gs,10216:zr,10217:zr,10752:Vr,10753:Vr,10754:Vr,10756:Ur,10758:Ur},"Size2-Regular":{32:me,40:qr,41:qr,47:Gr,91:Hr,92:Gr,93:Hr,123:jr,125:jr,160:me,710:Wr,732:Wr,770:Wr,771:Wr,8719:Zr,8720:Zr,8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:Xr,8748:Yr,8749:Yr,8750:Xr,8896:Jr,8897:Jr,8898:Jr,8899:Jr,8968:Qr,8969:Qr,8970:Qr,8971:Qr,10216:es,10217:es,10752:ts,10753:ts,10754:ts,10756:Jr,10758:Jr},"Size3-Regular":{32:me,40:ns,41:ns,47:is,91:rs,92:is,93:rs,123:ss,125:ss,160:me,710:as,732:as,770:as,771:as,8730:[.95003,1.45,0,0,1],8968:os,8969:os,8970:os,8971:os,10216:ss,10217:ss},"Size4-Regular":{32:me,40:ls,41:ls,47:cs,91:us,92:cs,93:us,123:hs,125:hs,160:me,710:ds,732:ds,770:ds,771:ds,8730:[1.25003,1.75,0,0,1],8968:ps,8969:ps,8970:ps,8971:ps,9115:fs,9116:ms,9117:fs,9118:fs,9119:ms,9120:fs,9121:_s,9122:gs,9123:_s,9124:_s,9125:gs,9126:_s,9127:ys,9128:vs,9129:bs,9130:[0,.3,0,0,.88889],9131:ys,9132:vs,9133:bs,9143:[.88502,.915,0,0,1.05556],10216:hs,10217:hs,57344:ws,57345:ws,57680:xs,57681:xs,57682:xs,57683:xs},"Typewriter-Regular":{32:As,33:ks,34:ks,35:ks,36:Ss,37:Ss,38:ks,39:ks,40:Ss,41:Ss,42:[0,.52083,0,0,.525],43:Es,44:[.13889,.125,0,0,.525],45:Es,46:[0,.125,0,0,.525],47:Ss,48:ks,49:ks,50:ks,51:ks,52:ks,53:ks,54:ks,55:ks,56:ks,57:ks,58:Cs,59:[.13889,.43056,0,0,.525],60:Ts,61:[-.19549,.41562,0,0,.525],62:Ts,63:ks,64:ks,65:ks,66:ks,67:ks,68:ks,69:ks,70:ks,71:ks,72:ks,73:ks,74:ks,75:ks,76:ks,77:ks,78:ks,79:ks,80:ks,81:[.13889,.61111,0,0,.525],82:ks,83:ks,84:ks,85:ks,86:ks,87:ks,88:ks,89:ks,90:ks,91:Ss,92:Ss,93:Ss,94:ks,95:[.09514,0,0,0,.525],96:ks,97:Cs,98:ks,99:Cs,100:ks,101:Cs,102:ks,103:Ls,104:ks,105:ks,106:[.22222,.61111,0,0,.525],107:ks,108:ks,109:Cs,110:Cs,111:Cs,112:Ls,113:Ls,114:Cs,115:Cs,116:[0,.55358,0,0,.525],117:Cs,118:Cs,119:Cs,120:Cs,121:Ls,122:Cs,123:Ss,124:Ss,125:Ss,126:ks,127:ks,160:As,176:ks,184:[.19445,0,0,0,.525],305:Cs,567:Ls,711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:ks,715:ks,728:ks,730:ks,770:ks,771:ks,776:ks,915:ks,916:ks,920:ks,923:ks,926:ks,928:ks,931:ks,933:ks,934:ks,936:ks,937:ks,8216:ks,8217:ks,8242:ks,9251:[.11111,.21944,0,0,.525]}},Ms=/[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FAF]|[\uAC00-\uD7AF]/,Rs=10,Is=.25,Ps=.431,Os={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[Ps,Ps,Ps],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.5,.732,.925],num2:[.394,.384,.5],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[Is,Is,Is],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04]},Fs=[0,.5,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Ns={" ":" ","":" ","Å":"A","Ç":"C","Ð":"D","Þ":"o","å":"a","ç":"c","ð":"d","þ":"o","А":"A","Б":"B","В":"B","Г":"F","Д":"A","Е":"E","Ж":"K","З":"3","И":"N","Й":"N","К":"K","Л":"N","М":"M","Н":"H","О":"O","П":"N","Р":"P","С":"C","Т":"T","У":"y","Ф":"O","Х":"X","Ц":"U","Ч":"h","Ш":"W","Щ":"W","Ъ":"B","Ы":"X","Ь":"B","Э":"3","Ю":"X","Я":"R","а":"a","б":"b","в":"a","г":"r","д":"y","е":"e","ж":"m","з":"e","и":"n","й":"n","к":"n","л":"n","м":"m","н":"n","о":"o","п":"n","р":"p","с":"c","т":"o","у":"y","ф":"b","х":"x","ц":"n","ч":"n","ш":"w","щ":"w","ъ":"a","ы":"m","ь":"a","э":"e","ю":"m","я":"r"};function Bs(e,t){void 0===e&&(e=77);const n=Ds[t][e];if(n)return{defaultMetrics:!1,depth:n[0],height:n[1],italic:n[2],skew:n[3],width:n[4]};if(11034===e)return{defaultMetrics:!0,depth:.2,height:.8,italic:0,skew:0,width:.8};const i=String.fromCodePoint(e);if(i in Ns)e=Ns[i].codePointAt(0);else if(Ms.test(i))return e=77,{defaultMetrics:!0,depth:.2,height:.9,italic:0,skew:0,width:1};return{defaultMetrics:!0,depth:.2,height:.7,italic:0,skew:0,width:.8}}var $s={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],longrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],longleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],longleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],longrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],longleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xleftrightarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],longleftrightarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xRightleftharpoons:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],longRightleftharpoons:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xLeftrightharpoons:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716],longLeftrightharpoons:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},Ks={widehat1:[1062,239,.24],widehat2:[2364,300,.3],widehat3:[2364,360,.36],widehat4:[2364,420,.42],widecheck1:[1062,239,.24],widecheck2:[2364,300,.3],widecheck3:[2364,360,.36],widecheck4:[2364,420,.42],widetilde1:[600,260,.26],widetilde2:[1033,286,.286],widetilde3:[2339,306,.306],widetilde4:[2340,312,.34],overarc:[1061,159,.3],underarc:[1061,159,.3]},Us={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",overarc:"M529 0c179 0 524 115 524 115 5 1 9 5 9 10 0 1-1 2-1 3l-4 22c-1 5-5 9-11 9h-2s-338-93-512-92c-174 0-513 92-513 92h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13 0 0 342-115 520-115z",underarc:"m 529 160\n c -179 0 -524 -115 -524 -115\n c -5 -1 -9 -5 -9 -10\n c 0 -1 1 -2 1 -3\n l 4 -22\n c 1 -5 5 -9 11 -9\n h 2\n s 338 93 512 92\n c 174 0 513 -92 513 -92\n h 2\n c 5 0 9 4 11 9\n l 5 22\n c 1 6 -2 12 -8 13\n c 0 0 -342 115 -520 115\n z\n ",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:"M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",leftmapsto:"M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:"M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:"M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",widetilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",widetilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",widetilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",widetilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};var zs,Vs=8205,qs=[[Vs,1],[65038,2],[127995,5],[129456,4],[917536,96]],Gs=[127462,127487];function Hs(e){var t;if(void 0===zs){zs={};for(const e of qs)for(let t=e[0];t<=e[0]+e[1]-1;t++)zs[t]=!0}return null!=(t=zs[e])&&t}function js(e){return e>=Gs[0]&&e<=Gs[1]}function Ws(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const t=[],n=function(e){const t=[];for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(13===i&&10===e.charCodeAt(n+1)&&(i=10,n++),13!==i&&12!==i||(i=10),0===i&&(i=65533),i>=55296&&i<=56319){const t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(i=65536+1024*(i-55296)+(t-56320),n++)}t.push(i)}return t}(e);let i=0;for(;i<n.length;){const e=n[i++],r=n[i];if(r===Vs){const e=i-1;for(i+=2;n[i]===Vs;)i+=2;t.push(String.fromCodePoint(...n.slice(e,i-e+1)))}else if(Hs(r)){const e=i-1;for(;Hs(n[i]);)i+=n[i]===Vs?2:1;t.push(String.fromCodePoint(...n.slice(e,2*i-e-1)))}else js(e)?(i+=1,t.push(String.fromCodePoint(...n.slice(i-2,2)))):t.push(String.fromCodePoint(e))}return t}function Zs(e,t){var n,i,r,s;const a=[];let o=e.next();if(o)if("\\relax"===o);else if("\\noexpand"===o)o=e.next(),o&&a.push(o);else if("\\obeyspaces"===o)e.obeyspaces=!0;else if("\\bgroup"===o)a.push("<{>");else if("\\egroup"===o)a.push("<}>");else if("\\string"===o){if(o=e.next(),o)if(o.startsWith("\\"))for(const e of o)a.push("\\"===e?"\\backslash":e);else"<{>"===o?a.push("\\{"):"<space>"===o?a.push("~"):"<}>"===o&&a.push("\\}")}else if("\\csname"===o){for(;"<space>"===e.peek();)e.next();let r="",s=!1,l=[];do{if(0===l.length)if(/^#[\d?@]$/.test(e.peek())){const r=e.get().slice(1);l=Ys(null!=(i=null!=(n=null==t?void 0:t(r))?n:null==t?void 0:t("?"))?i:"\\placeholder{}",t),o=l[0]}else o=e.next(),l=o?[o]:[];s=0===l.length,s||"\\endcsname"!==o||(s=!0,l.shift()),s||(s="<$>"===o||"<$$>"===o||"<{>"===o||"<}>"===o||"string"==typeof o&&o.length>1&&o.startsWith("\\")),s||(r+=l.shift())}while(!s);r&&a.push("\\"+r),a.push(...l)}else if("\\endcsname"===o);else if(o.length>1&&o.startsWith("#")){const e=o.slice(1);a.push(...Ys(null!=(s=null!=(r=null==t?void 0:t(e))?r:null==t?void 0:t("?"))?s:"\\placeholder{}",t))}else a.push(o);return a}function Ys(e,t=null){const n=[];let i="";for(const t of e.toString().split(/\r?\n/)){i&&n.push(i),i=" ";const e=t.match(/((?:\\%)|[^%])*/);null!==e&&n.push(e[0])}const r=new class{constructor(e){this.obeyspaces=!1,this.pos=0,this.s=Ws(e)}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){const t="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join(""));return(null==t?void 0:t[0])?(this.pos+=t[0].length,t[0]):""}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]+/))return"<space>";if(this.obeyspaces&&this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]/))return"<space>";const e=this.get();if("\\"===e){if(!this.end()){let e=this.match(/^[a-zA-Z\*]+/);return e?this.match(/^[ \f\n\r\t\v\u00A0\u2028\u2029]*/):e=this.get(),"\\"+e}}else{if("{"===e)return"<{>";if("}"===e)return"<}>";if("^"===e){if("^"===this.peek()){this.get();const e=this.match(/^(\^(\^(\^(\^[\da-f])?[\da-f])?[\da-f])?[\da-f])?[\da-f]{2}/);if(e)return String.fromCodePoint(Number.parseInt(e.slice(e.lastIndexOf("^")+1),16))}return e}if("#"===e){if(!this.end()){let e=!1;if(/[\d?@]/.test(this.peek())&&(e=!0,this.pos+1<this.s.length)){const t=this.s[this.pos+1];e=/[^\dA-Za-z]/.test(t)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}}(function(e){var t;let n="";for(const i of e){if("{}<>[]$&#^_%:'˜".includes(i)){n+=i;continue}const e=null!=(t=i.codePointAt(0))?t:0;let r=R[e];if(r)r.startsWith("\\")?n+=r+" ":n+=r;else{const{char:t,variant:i,style:s}=F(e);switch(r=t,i){case"double-struck":r=`\\mathbb{${r}}`;break;case"fraktur":r=`\\mathfrak{${r}}`;break;case"script":r=`\\mathscr{${r}}`;break;case"sans-serif":r=`\\mathsf{${r}}`;break;case"monospace":r=`\\mathtt{${r}}`;break;case"calligraphic":r=`\\mathcal{${r}}`}switch(s){case"bold":r=`\\mathbf{${r}}`;break;case"italic":r=`\\mathit{${r}}`;break;case"bolditalic":r=`\\mathbfit{${r}}`}n+=r}}return n}(n.join(""))),s=[];do{s.push(...Zs(r,t))}while(!r.end());return s}function Xs(e){let t="";const n=[];for(const i of e)i&&(t&&/^[a-zA-Z\*]/.test(i)&&n.push(t),n.push(i),/^\\[a-zA-Z]+\*?[\"\'][^\ ]+$/.test(i)&&n.push(" "),t=/\\[a-zA-Z]+\*?$/.test(i)?" ":"");return n.join("")}function Js(e,...t){return console.assert(e.startsWith("\\")),0===t.length?e:Xs([e,...t.map((e=>`{${e}}`))])}function Qs(e){return Xs(e.map((e=>{var t;return null!=(t={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[e])?t:e})))}var ea=class e{constructor(t){e._registry[t]=this}static createAtom(t,n,i){return e._registry[t].createAtom(n,ae(n,t),i)}static serialize(t,n){var i;if(!t||0===t.length)return"";if(null!=(i=n.skipStyles)&&i){const i=[];for(const r of na(t)){const t=e._registry[r[0].mode];i.push(...t.serialize(r,n))}return Xs(i)}return Xs(function(e,t){if(0===e.length)return[];const{parent:n}=e[0],i=null==n?void 0:n.computedStyle.fontSize,r=[];for(const s of ia(e,"fontSize")){const e=s[0].computedStyle.fontSize,a=sa(s,t);a&&(!e||"auto"===e||n&&i===e?r.push(...a):r.push(["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][e],...a))}return r}(t,n))}static getFont(t,n,i){return e._registry[t].getFont(n,i)}};ea._registry={};var ta=ea;function na(e){const t=[];let n=[],i="NONE";for(const r of e)"first"!==r.type&&(r.mode!==i?(n.length>0&&t.push(n),n=[r],i=r.mode):n.push(r));return n.length>0&&t.push(n),t}function ia(e,t){const n=[];let i,r=[];for(const s of e)if("first"!==s.type&&s.style){let e;"variant"===t?(e=s.style.variant,s.style.variantStyle&&"up"!==s.style.variantStyle&&(e+="-"+s.style.variantStyle)):e=s.style[t],e===i?r.push(s):(r.length>0&&n.push(r),r=[s],i=e)}return r.length>0&&n.push(r),n}function ra(e,t){var n;const{parent:i}=e[0],r=null==i?void 0:i.computedStyle.color,s=[];for(const a of na(e)){const e=t.defaultMode;for(const o of ia(a,"color")){const a=o[0].computedStyle,l=ta._registry[o[0].mode].serialize(o,h(u({},t),{defaultMode:"text"===e?"text":"math"}));t.skipStyles||!a.color||"none"===a.color||i&&r===a.color?s.push(Xs(l)):s.push(Js("\\textcolor",null!=(n=a.verbatimColor)?n:a.color,Xs(l)))}}return s}function sa(e,t){const{parent:n}=e[0],i=null==n?void 0:n.computedStyle.backgroundColor;return ia(e,"backgroundColor").map((e=>{var r;if(e.length>0||"box"!==e[0].type){const s=e[0].computedStyle;if(s.backgroundColor&&"none"!==s.backgroundColor&&(!n||i!==s.backgroundColor))return Js("\\colorbox",null!=(r=s.verbatimBackgroundColor)?r:s.backgroundColor,Xs(ra(e,h(u({},t),{defaultMode:"text"}))))}return Xs(ra(e,t))}))}function aa(e){if(!e)return;return{mord:"ord",mbin:"bin",mop:"op",mrel:"rel",mopen:"open",mclose:"close",mpunct:"punct",minner:"inner",spacing:"ignore",latex:"latex",composition:"inner",error:"inner",placeholder:"ord",supsub:"ignore"}[e]}function oa(e){if(0===e.length)return"ord";const t=aa(e[0].type),n=aa(e[e.length-1].type);return t&&t===n?t:"ord"}function la(e,t){if("string"==typeof e)return e;if("number"==typeof e){console.assert(Number.isFinite(e));const n=Math.ceil(100*e)/100;return 0===n?"0":n.toString()+(null!=t?t:"")}return""}var ca=class e{constructor(t,n){var i,r,s,a,o;if("number"==typeof t?this.value=String.fromCodePoint(t):"string"==typeof t?this.value=t:f(t)?this.children=t.filter((e=>null!==e)):t&&t instanceof e&&(this.children=[t]),this.children)for(const e of this.children)e.parent=this;this.type=null!=(i=null==n?void 0:n.type)?i:"ignore",this.isSelected=!0===(null==n?void 0:n.isSelected),(null==n?void 0:n.caret)&&(this.caret=n.caret),this.classes=null!=(r=null==n?void 0:n.classes)?r:"",this.isTight=null!=(s=null==n?void 0:n.isTight)&&s,(null==n?void 0:n.attributes)&&(this.attributes=n.attributes);let l=null==n?void 0:n.fontFamily;(null==n?void 0:n.style)&&this.value&&(l=null!=(o=ta.getFont(null!=(a=n.mode)?a:"math",this,h(u({variant:"normal"},n.style),{letterShapeStyle:n.letterShapeStyle})))?o:void 0),l||(l="Main-Regular"),this._height=0,this._depth=0,this._width=0,this.hasExplicitWidth=!1,this.skew=0,this.italic=0,this.maxFontSize=0,this.scale=1,void 0!==(null==n?void 0:n.maxFontSize)&&(this.maxFontSize=n.maxFontSize),function(e,t){var n;if("latex"===e.type)return e.height=.9,e.depth=.2,void(e._width=1);if(e.value){e.height=-1/0,e.depth=-1/0,e._width=0,e.skew=-1/0,e.italic=-1/0;for(let n=0;n<e.value.length;n++){const i=Bs(e.value.codePointAt(n),t);e.height=Math.max(e.height,i.height),e.depth=Math.max(e.depth,i.depth),e._width+=i.width,e.skew=i.skew,e.italic=i.italic}return}if(e.children&&e.children.length>0){let t=-1/0,i=-1/0,r=0;for(const s of e.children)s.height>t&&(t=s.height),s.depth>i&&(i=s.depth),r=Math.max(r,null!=(n=s.maxFontSize)?n:0);e.height=t,e.depth=i,e._width=e.children.reduce(((e,t)=>e+t.width),0),e.maxFontSize=r}}(this,l)}set atomID(e){void 0!==e&&0!==e.length&&(this.id=e)}selected(e){if(this.isSelected!==e&&(this.isSelected=e,this.children))for(const t of this.children)t.selected(e)}setStyle(e,t,n){if(void 0===t)return;const i=la(t,n);i.length>0&&(this.cssProperties||(this.cssProperties={}),this.cssProperties[e]=i)}setTop(e){Number.isFinite(e)&&Math.abs(e)>.01&&(this.cssProperties||(this.cssProperties={}),this.cssProperties.top=la(e,"em"),this.height-=e,this.depth+=e)}get left(){var e;return(null==(e=this.cssProperties)?void 0:e["margin-left"])?Number.parseFloat(this.cssProperties["margin-left"]):0}set left(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-left"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-left"]=la(e,"em")))}set right(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-right"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-right"]=la(e,"em")))}set bottom(e){Number.isFinite(e)&&(0===e?this.cssProperties&&delete this.cssProperties["margin-bottom"]:(this.cssProperties||(this.cssProperties={}),this.cssProperties["margin-bottom"]=la(e,"em")))}get width(){return this._width*this.scale}set width(e){this._width=e,this.hasExplicitWidth=!0}set softWidth(e){}get height(){return this._height*this.scale}set height(e){this._height=e}get depth(){return this._depth*this.scale}set depth(e){this._depth=e}wrap(e){const t=e.parent;if(!t)return this;e.isPhantom&&this.setStyle("opacity",0);const n=e.color;n&&n!==t.color&&this.setStyle("color",n);let i=e.backgroundColor;this.isSelected&&(i=M(i)),i&&i!==t.backgroundColor&&(this.setStyle("background-color",i),this.setStyle("display","inline-block"));const r=e.scalingFactor;return this.scale=r,this.skew*=r,this.italic*=r,this}toMarkup(){var e,t,n,i;let r=null!=(e=this.value)?e:"";if(this.children)for(const e of this.children)r+=e.toMarkup();let s="";if(this.svgBody)s=function(e){if(Ks[e]){const[t,n,i]=Ks[e],r=`<span class="stretchy" style="height:${i}em"><svg width="100%" height="${i}em" viewBox="0 0 ${t} ${n}" preserveAspectRatio="none" ><path fill="currentcolor" d="${Us[e]}"></path></svg></span>`;return`<span style="display:inline-block;height:${Math.floor(100*i/2)/100}em;min-width:0">${r}</span>`}const[t,n,i,r]=$s[e];let s,a;const o=i/1e3;3===t.length?(s=["slice-1-of-3","slice-2-of-3","slice-3-of-3"],a=["xMinYMin","xMidYMin","xMaxYMin"]):2===t.length?(s=["slice-1-of-2","slice-2-of-2"],a=["xMinYMin","xMaxYMin"]):(s=["slice-1-of-1"],a=[r]);const l=t.map(((e,t)=>`<span class="${s[t]}" style=height:${o}em><svg width=400em height=${o}em viewBox="0 0 400000 ${i}" preserveAspectRatio="${a[t]} slice"><path fill="currentcolor" d="${Us[e]}"></path></svg></span>`)).join("");return`<span style="display:inline-block;height:${o}em;min-width:${n}em;">${l}</span>`}(this.svgBody);else if(this.svgOverlay){s='<span style="',s+="display: inline-block;",s+=`height:${Math.floor(100*(this.height+this.depth))/100}em;`,s+=`vertical-align:${Math.floor(100*this.depth)/100}em;`,s+='">',s+=r,s+="</span>",s+='<svg style="position:absolute;overflow:visible;',s+=`height:${Math.floor(100*(this.height+this.depth))/100}em;`;const e=null==(t=this.cssProperties)?void 0:t.padding;e?(s+=`top:${e};`,s+=`left:${e};`,s+=`width:calc(100% - 2 * ${e} );`):s+="top:0;left:0;width:100%;",s+="z-index:2;",s+='"',this.svgStyle&&(s+=this.svgStyle),s+=` viewBox="0 0 ${Math.floor(100*this.width)/100} ${Math.floor(100*(this.height+this.depth))/100}"`,s+=`>${this.svgOverlay}</svg>`}let a="";const o=this.classes.split(" ");o.push(null!=(n={latex:"ML__raw-latex",placeholder:"ML__placeholder",error:"ML__error"}[this.type])?n:""),"latex"===this.caret&&o.push("ML__latex-caret"),this.isSelected&&o.push("ML__selected");const l=1===o.length?o[0]:o.filter(((e,t,n)=>e.length>0&&n.indexOf(e)===t)).join(" ");if(l.length>0&&(a+=` class="${l}"`),this.id&&(a+=` data-atom-id=${this.id}`),this.cssId&&(a+=` id="${this.cssId.replace(/ /g,"-")}" `),this.attributes&&(a+=" "+Object.keys(this.attributes).map((e=>`${e}="${this.attributes[e]}"`)).join(" ")),this.htmlData){const e=this.htmlData.split(",");for(const t of e){const e=t.match(/([^=]+)=(.+$)/);if(e){const t=e[1].trim().replace(/ /g,"-");t&&(a+=` data-${t}="${e[2]}" `)}else{const e=t.trim().replace(/ /g,"-");e&&(a+=` data-${e} `)}}}const c=null!=(i=this.cssProperties)?i:{};this.hasExplicitWidth&&void 0===c.width&&(c.width=Math.ceil(100*this._width)/100+"em");const u=Object.keys(c).map((e=>`${e}:${c[e]}`));if(void 0!==this.scale&&1!==this.scale&&(r.length>0||s.length>0)&&u.push(`font-size: ${Math.ceil(1e4*this.scale)/100}%`),this.htmlStyle){const e=this.htmlStyle.split(";");let t="";for(const n of e){const e=n.match(/([^=]+):(.+$)/);if(e){const n=e[1].trim().replace(/ /g,"-");n&&(t+=`${n}:${e[2]};`)}}t&&(a+=` style="${t}"`)}u.length>0&&(a+=` style="${u.join(";")}"`);let h="";return h=a.length>0||s.length>0?`<span${a}>${r}${s}</span>`:r,"text"===this.caret?h+='<span class="ML__text-caret"></span>':"math"===this.caret&&(h+='<span class="ML__caret"></span>'),h}tryCoalesceWith(e){if(this.svgBody||!this.value)return!1;if(e.svgBody||!e.value)return!1;const t=this.children&&this.children.length>0,n=e.children&&e.children.length>0;if(t||n)return!1;if(e.cssProperties||this.cssProperties)for(const t of["border","border-left","border-right","border-right-width","left","margin","margin-left","margin-right","padding","position","width"]){if(e.cssProperties&&t in e.cssProperties)return!1;if(this.cssProperties&&t in this.cssProperties)return!1}const i=this.cssProperties?Object.keys(this.cssProperties).length:0;if(i!==(e.cssProperties?Object.keys(e.cssProperties).length:0))return!1;if(i>0)for(const t of Object.keys(this.cssProperties))if(this.cssProperties[t]!==e.cssProperties[t])return!1;const r=this.classes.trim().replace(/\s+/g," ").split(" "),s=e.classes.trim().replace(/\s+/g," ").split(" ");if(r.length!==s.length)return!1;r.sort(),s.sort();for(const[e,t]of r.entries()){if("vertical-separator"===t)return!1;if(t!==s[e])return!1}return this.value+=e.value,this.height=Math.max(this.height,e.height),this.depth=Math.max(this.depth,e.depth),this._width=this._width+e._width,this.maxFontSize=Math.max(this.maxFontSize,e.maxFontSize),this.italic=e.italic,!0}};function ua(e){if(!e||0===e.length)return[];e[0].children=ua(e[0].children);const t=[e[0]];for(let n=1;n<e.length;n++)t[t.length-1].tryCoalesceWith(e[n])||(e[n].children=ua(e[n].children),t.push(e[n]));return t}function ha(e){return e.children&&(e.children=ua(e.children)),e}function da(e,t){if(!e)return new ca(null,t);const n=new ca(null,{classes:"ML__strut",type:"ignore"});n.setStyle("height",Math.max(0,e.height),"em");const i=[n];if(0!==e.depth){const t=new ca(null,{classes:"ML__strut--bottom",type:"ignore"});t.setStyle("height",e.height+e.depth,"em"),t.setStyle("vertical-align",-e.depth,"em"),i.push(t)}return i.push(e),new ca(i,h(u({},t),{type:"lift"}))}function pa(e){const t=function(e){return $s[e]?$s[e][2]/1e3:Ks[e][2]}(e)/2,n=new ca(null,{maxFontSize:0});return n.height=t+.166,n.depth=t-.166,n.svgBody=e,n}function fa(e){var t;const[n,i]=function(e){if("individualShift"in e){const t=e.individualShift;let n=t[0];const i=[n],r=-n.shift-n.box.depth;let s=r;for(let e=1;e<t.length;e++){const r=t[e],a=-r.shift-s-r.box.depth,o=a-(n.box.height+n.box.depth);s+=a,i.push(o),i.push(r),n=r}return[i,r]}if("top"in e){let t=e.top;for(const n of e.children)t-="number"==typeof n?n:n.box.height+n.box.depth;return[e.children,t]}if("bottom"in e)return[e.children,-e.bottom];if("firstBaseline"in e){const t=e.firstBaseline[0];if("number"==typeof t)throw new Error("First child must be an element.");return[e.firstBaseline,-t.box.depth]}if("shift"in e){const t=e.children[0];if("number"==typeof t)throw new Error("First child must be an element.");return[e.children,-t.box.depth-e.shift]}return[null,0]}(e);if(!n)return[[],0,0];const r=new ca(null,{classes:"pstrut"});let s=0;for(const e of n)if("number"!=typeof e){const t=e.box;s=Math.max(s,t.maxFontSize,t.height)}s+=2,r.height=s,r.setStyle("height",s,"em");const a=[];let o=i,l=i,c=i,u=0;for(const e of n){if("number"==typeof e)c+=e;else{const n=e.box,i=null!=(t=e.classes)?t:[],o=new ca([r,n],{classes:i.join(" "),style:e.style});n.setStyle("height",n.height+n.depth,"em"),n.setStyle("display","inline-block"),o.setStyle("top",-s-c-n.depth,"em"),e.marginLeft&&o.setStyle("margin-left",e.marginLeft,"em"),e.marginRight&&o.setStyle("margin-right",e.marginRight,"em"),a.push(o),c+=n.height+n.depth,u=Math.max(u,o.width)}o=Math.min(o,c),l=Math.max(l,c)}a.forEach((e=>{e.softWidth=u}));const h=new ca(a,{classes:"vlist"});if(h.softWidth=u,h.height=l,h.setStyle("height",l,"em"),o>=0)return[[new ca(h,{classes:"vlist-r"})],l,-o];const d=new ca(new ca(null),{classes:"vlist"});d.height=-o,d.setStyle("height",-o,"em");const p=new ca(8203,{classes:"vlist-s",maxFontSize:0});return p.softWidth=0,p.height=0,p.depth=0,[[new ca([h,p],{classes:"vlist-r"}),new ca(d,{classes:"vlist-r"})],l,-o]}var ma=class extends ca{constructor(e,t){var n;const[i,r,s]=fa(e);super(1===i.length?i[0]:i,{type:null==t?void 0:t.type,classes:(null!=(n=null==t?void 0:t.classes)?n:"")+" vlist-t"+(2===i.length?" vlist-t2":"")}),this.height=r,this.depth=s,this.softWidth=i.reduce(((e,t)=>Math.max(e,t.width)),0)}};var ga=class{constructor(e,t,n){this.id=e,this.sizeDelta=t,this.cramped=n;const i={"-4":2,"-3":1,0:0}[t];this.metrics=Object.keys(Os).reduce(((e,t)=>h(u({},e),{[t]:Os[t][i]})),{})}getFontSize(e){return Math.max(1,e+this.sizeDelta)}get sup(){return ya[[0,1,0,1,2,3,2,3][this.id]]}get sub(){return ya[[0,0,0,0,2,2,2,2][this.id]]}get fracNum(){return ya[[0,1,0,1,2,3,4,5][this.id]]}get fracDen(){return ya[[0,0,0,0,2,2,4,4][this.id]]}get cramp(){return ya[[0,0,2,2,4,4,6,6][this.id]]}get isTight(){return this.sizeDelta<0}},_a={7:new ga(7,0,!1),6:new ga(6,0,!0),5:new ga(5,0,!1),4:new ga(4,0,!0),3:new ga(3,-3,!1),2:new ga(2,-3,!0),1:new ga(1,-4,!1),0:new ga(0,-4,!0)},ya=h(u({},_a),{displaystyle:_a[7],textstyle:_a[5],scriptstyle:_a[3],scriptscriptstyle:_a[1]});function va(e,t){var n;if(!e)return 0;const i={pt:1,mm:7227/2540,cm:7227/254,ex:35271/8192,px:3/4,em:Rs,bp:1.00375,dd:1238/1157,pc:12,in:72.27,mu:10/18}[null!=(n=e.unit)?n:"pt"];if(Number.isFinite(t)){const n=10**t;return Math.round(e.dimension/Rs*i*n)/n}return e.dimension*i}function ba(e,t){if(null===e)return 0;const n=va(e)/Rs;if(Number.isFinite(t)){const e=10**t;return Math.round(n*e)/e}return n}function wa(e){var t;return`${e.dimension}${null!=(t=e.unit)?t:"pt"}`}function xa(e){var t,n;if(null==e)return null;let i="";if("dimension"in e&&(i=`${e.dimension}${null!=(t=e.unit)?t:"pt"}`),"glue"in e&&(i=function(e){let t=wa(e.glue);return e.grow&&0!==e.grow.dimension&&(t+=` plus ${wa(e.grow)}`),e.shrink&&0!==e.shrink.dimension&&(t+=` minus ${wa(e.shrink)}`),t}(e)),"number"in e)if("base"in e&&"decimal"!==e.base)if("alpha"===e.base)i=`\`${String.fromCodePoint(e.number)}`;else{const t=Math.round(e.number)>>>0;"hexadecimal"===e.base?(i=Number(t).toString(16).toUpperCase(),i=t<=255?i.padStart(2,"0"):t<=65535?i.padStart(4,"0"):t<=16777215?i.padStart(6,"0"):i.padStart(8,"0"),i=`"${i}`):"octal"===e.base&&(i=Number(t).toString(8),i=t<=63?i.padStart(2,"0"):t<=30583?i.padStart(4,"0"):i.padStart(8,"0"),i=`'${i}`)}else i=Number(e.number).toString();return"register"in e&&("factor"in e&&(-1===e.factor?i="-":1!==e.factor&&(i=Number(e.factor).toString())),"global"in e&&e.global&&(i+="\\global"),i+=`\\${e.register}`),"string"in e&&(i=e.string),null!=(n=e.relax)&&n&&(i+="\\relax"),i}function ka(e,t){return null==e?null:"number"in e?h(u({},e),{number:e.number*t}):"register"in e?"factor"in e&&e.factor?h(u({},e),{factor:e.factor*t}):h(u({},e),{factor:t}):"dimension"in e?h(u({},e),{dimension:e.dimension*t}):"glue"in e?e.shrink&&e.grow?{glue:ka(e.glue,t),shrink:ka(e.shrink,t),grow:ka(e.grow,t)}:e.shrink?{glue:ka(e.glue,t),shrink:ka(e.shrink,t)}:e.grow?{glue:ka(e.glue,t),grow:ka(e.grow,t)}:{glue:ka(e.glue,t)}:null}var Sa={"p@":{dimension:1},"z@":{dimension:0},maxdimen:{dimension:16383.99999},hfuzz:{dimension:.1},vfuzz:{dimension:.1},overfullrule:{dimension:5},hsize:{dimension:6.5,unit:"in"},vsize:{dimension:8.9,unit:"in"},parindent:{dimension:20},maxdepth:{dimension:4},splitmaxdepth:{register:"maxdimen"},boxmaxdepth:{register:"maxdimen"},delimitershortfall:{dimension:5},nulldelimiterspace:{dimension:1.2,unit:"pt"},scriptspace:{dimension:.5},topskip:{dimension:10},splittopskip:{dimension:10},normalbaselineskip:{dimension:12},normallineskip:{dimension:1},normallineskiplimit:{dimension:0},jot:{dimension:3},doublerulesep:{dimension:2},arrayrulewidth:{dimension:.4},arraycolsep:{dimension:5},fboxsep:{dimension:3},fboxrule:{dimension:.4},"z@skip":{glue:{dimension:0},shrink:{dimension:0},grow:{dimension:0}},hideskip:{glue:{dimension:-1e3},grow:{dimension:1,unit:"fill"}},"@flushglue":{glue:{dimension:0},grow:{dimension:1,unit:"fill"}},parskip:{glue:{dimension:0},grow:{dimension:1}},abovedisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},abovedisplayshortskip:{glue:{dimension:0},grow:{dimension:3}},belowdisplayskip:{glue:{dimension:12},grow:{dimension:3},shrink:{dimension:9}},belowdisplayshortskip:{glue:{dimension:7},grow:{dimension:3},shrink:{dimension:4}},parfillskip:{glue:{dimension:0},grow:{dimension:1,unit:"fil"}},thinmuskip:{glue:{dimension:3,unit:"mu"}},medmuskip:{glue:{dimension:4,unit:"mu"},grow:{dimension:2,unit:"mu"},shrink:{dimension:4,unit:"mu"}},thickmuskip:{glue:{dimension:5,unit:"mu"},grow:{dimension:5,unit:"mu"}},smallskipamount:{glue:{dimension:3},grow:{dimension:1},shrink:{dimension:1}},medskipamount:{glue:{dimension:6},grow:{dimension:2},shrink:{dimension:3}},bigskipamount:{glue:{dimension:12},grow:{dimension:2},shrink:{dimension:4}},pretolerance:100,tolerance:200,hbadness:1e3,vbadness:1e3,linepenalty:10,hyphenpenalty:50,exhyphenpenalty:50,binoppenalty:700,relpenalty:500,clubpenalty:150,widowpenalty:150,displaywidowpenalty:50,brokenpenalty:100,predisplaypenalty:1e4,doublehyphendemerits:1e4,finalhyphendemerits:5e3,adjdemerits:1e4,tracinglostchars:1,uchyph:1,delimiterfactor:901,defaulthyphenchar:"\\-",defaultskewchar:-1,newlinechar:-1,showboxbreadth:5,showboxdepth:3,errorcontextlines:5,interdisplaylinepenalty:100,interfootnotelinepenalty:100,baselineSkip:1.2,arraystretch:1,month:(new Date).getMonth()+1,day:(new Date).getDate(),year:(new Date).getFullYear()};function Ea(){return u({},Sa)}function Ta(){return{registers:Ea(),smartFence:!1,renderPlaceholder:void 0,placeholderSymbol:"▢",letterShapeStyle:v.locale.startsWith("fr")?"french":"tex",minFontScale:0,colorMap:C,backgroundColorMap:L,getMacro:e=>oe(e,ie())}}var Ca=class e{constructor(t,n){var i,r,s,a,o,l,c,h,d,p,f,m,g,_,y;let v;(null==t?void 0:t.parent)?(this.parent=t.parent,v=t.parent,this.registers={}):(v=u(u({},Ta()),null!=(i=null==t?void 0:t.from)?i:{}),this.registers=v.registers),v.atomIdsSettings&&(this.atomIdsSettings=u({},v.atomIdsSettings)),this.renderPlaceholder=v.renderPlaceholder,this.isPhantom=null!=(a=null!=(s=null==t?void 0:t.isPhantom)?s:null==(r=this.parent)?void 0:r.isPhantom)&&a,this.letterShapeStyle=v.letterShapeStyle,this.minFontScale=v.minFontScale,(null==n?void 0:n.color)&&"none"!==n.color?this.color=n.color:this.color=null!=(l=null==(o=this.parent)?void 0:o.color)?l:"",(null==n?void 0:n.backgroundColor)&&"none"!==n.backgroundColor?this.backgroundColor=n.backgroundColor:this.backgroundColor=null!=(h=null==(c=this.parent)?void 0:c.backgroundColor)?h:"",(null==n?void 0:n.fontSize)&&"auto"!==n.fontSize&&n.fontSize!==(null==(d=this.parent)?void 0:d.size)?this.size=n.fontSize:this.size=null!=(f=null==(p=this.parent)?void 0:p.size)?f:5;let b=null!=(g=null==(m=this.parent)?void 0:m.mathstyle)?g:ya.displaystyle;if("string"==typeof(null==t?void 0:t.mathstyle)){if(v instanceof e)switch(t.mathstyle){case"cramp":b=b.cramp;break;case"superscript":b=b.sup;break;case"subscript":b=b.sub;break;case"numerator":b=b.fracNum;break;case"denominator":b=b.fracDen}switch(t.mathstyle){case"textstyle":b=ya.textstyle;break;case"displaystyle":b=ya.displaystyle;break;case"scriptstyle":b=ya.scriptstyle;break;case"scriptscriptstyle":b=ya.scriptscriptstyle}}this.mathstyle=b,this.smartFence=v.smartFence,this.placeholderSymbol=v.placeholderSymbol,this.colorMap=null!=(_=v.colorMap)?_:e=>e,this.backgroundColorMap=null!=(y=v.backgroundColorMap)?y:e=>e,this.getMacro=v.getMacro,console.assert(void 0!==this.parent||void 0!==this.registers)}makeID(){if(!this.atomIdsSettings)return;if(this.atomIdsSettings.overrideID)return this.atomIdsSettings.overrideID;if("number"!=typeof this.atomIdsSettings.seed)return`${Date.now().toString(36).slice(-2)}${Math.floor(1e5*Math.random()).toString(36)}`;const e=this.atomIdsSettings.seed.toString(36);return this.atomIdsSettings.seed+=1,e}scale(e){return e*this.effectiveFontSize}get scalingFactor(){return this.parent?this.effectiveFontSize/this.parent.effectiveFontSize:1}get isDisplayStyle(){return 7===this.mathstyle.id||6===this.mathstyle.id}get isCramped(){return this.mathstyle.cramped}get isTight(){return this.mathstyle.isTight}get metrics(){return this.mathstyle.metrics}get effectiveFontSize(){return Math.max(Fs[Math.max(1,this.size+this.mathstyle.sizeDelta)],this.minFontScale)}getRegister(e){var t;return(null==(t=this.registers)?void 0:t[e])?this.registers[e]:this.parent?this.parent.getRegister(e):void 0}getRegisterAsNumber(e){const t=this.getRegister(e);return"number"==typeof t?t:"string"==typeof t?Number(t):void 0}getRegisterAsGlue(e){var t;if(null==(t=this.registers)?void 0:t[e]){const t=this.registers[e];return"object"==typeof t&&"glue"in t?t:"object"==typeof t&&"dimension"in t?{glue:{dimension:t.dimension}}:"number"==typeof t?{glue:{dimension:t}}:void 0}if(this.parent)return this.parent.getRegisterAsGlue(e)}getRegisterAsEm(e,t){return ba(this.getRegisterAsDimension(e),t)}getRegisterAsDimension(e){var t;if(null==(t=this.registers)?void 0:t[e]){const t=this.registers[e];return"object"==typeof t&&"glue"in t?t.glue:"object"==typeof t&&"dimension"in t?t:"number"==typeof t?{dimension:t}:void 0}if(this.parent)return this.parent.getRegisterAsDimension(e)}setRegister(e,t){void 0!==t?this.registers[e]=t:delete this.registers[e]}evaluate(e){if(!e||!("register"in e))return e;let t=this;if("global"in e&&e.global)for(;t.parent;)t=t.parent;let n=1;"factor"in e&&1!==e.factor&&void 0!==e.factor&&(n=e.factor);const i=t.getRegister(e.register);if(void 0===i)return;if("string"==typeof i)return{string:Number(i).toString()+i};if("number"==typeof i)return{number:n*i};const r=t.evaluate(i);return void 0!==r?"string"in r?{string:Number(i).toString()+r.string}:"number"in r?{number:n*r.number}:"dimension"in r?h(u({},r),{dimension:n*r.dimension}):"glue"in r?h(u({},r),{glue:h(u({},r.glue),{dimension:n*r.glue.dimension}),shrink:r.shrink?h(u({},r.shrink),{dimension:n*r.shrink.dimension}):void 0,grow:r.grow?h(u({},r.grow),{dimension:n*r.grow.dimension}):void 0}):e:void 0}toDimension(e){const t=this.evaluate(e);return void 0===t?null:"dimension"in t?t:"glue"in t?t.glue:"number"in t?{dimension:t.number}:null}toEm(e,t){if(null===e)return 0;const n=this.toDimension(e);return null===n?0:va(n,t)/Rs}toNumber(e){if(null===e)return null;const t=this.evaluate(e);return void 0===t?null:"number"in t?t.number:"dimension"in t?t.dimension:"glue"in t?t.glue.dimension:"string"in t?Number(t.string):null}toColor(e){var t,n;if(null===e)return null;const i=this.evaluate(e);return void 0===i?null:"string"in i?null!=(n=null==(t=this.colorMap)?void 0:t.call(this,i.string))?n:i.string:null}toBackgroundColor(e){var t,n;if(null===e)return null;const i=this.evaluate(e);return void 0===i?null:"string"in i?null!=(n=null==(t=this.backgroundColorMap)?void 0:t.call(this,i.string))?n:i.string:null}},La=["body","above","below","superscript","subscript"];function Aa(e){return"string"==typeof e&&La.includes(e)}function Da(e){return void 0!==e&&Array.isArray(e)&&2===e.length}var Ma=class e{constructor(e){var t,n,i,r,s,a;this.type=e.type,"string"==typeof e.value&&(this.value=e.value),this.command=null!=(n=null!=(t=e.command)?t:this.value)?n:"",this.mode=null!=(i=e.mode)?i:"math",e.isFunction&&(this.isFunction=!0),e.limits&&(this.subsupPlacement=e.limits),this.style=u({},e.style),this.displayContainsHighlight=null!=(r=e.displayContainsHighlight)&&r,this.captureSelection=null!=(s=e.captureSelection)&&s,this.skipBoundary=null!=(a=e.skipBoundary)&&a,void 0!==e.verbatimLatex&&null!==e.verbatimLatex&&(this.verbatimLatex=e.verbatimLatex),e.args&&(this.args=e.args),e.body&&(this.body=e.body),this._changeCounter=0}static createBox(e,t,n){var i;if(!t)return null;const r=function(e){let t;const n=[];let i=[];for(const r of e)if(t||r.style){const e=r.computedStyle;t&&e.color===t.color&&e.backgroundColor===t.backgroundColor&&e.fontSize===t.fontSize?i.push(r):(i.length>0&&n.push(i),i=[r],t=e)}else i.push(r);i.length>0&&n.push(i);return n}(t),s=[];for(const t of r){const n=t[0].style,i=Ra(e,t,{style:{color:n.color,backgroundColor:n.backgroundColor,fontSize:n.fontSize}});i&&s.push(i)}if(0===s.length)return null;const a=(null!=(i=null==n?void 0:n.classes)?i:"").trim();return 1!==s.length||a||(null==n?void 0:n.type)?new ca(s,{classes:a,type:null==n?void 0:n.type}).wrap(e):s[0].wrap(e)}static serialize(e,t){return ta.serialize(e,t)}static commonAncestor(e,t){if(e===t)return e.parent;if(e.parent===t.parent)return e.parent;const n=new WeakSet;let{parent:i}=e;for(;i;)n.add(i),i=i.parent;for(i=t.parent;i;){if(n.has(i))return i;i=i.parent}console.assert(Boolean(i))}static fromJson(t){return new e("string"==typeof t?{type:"mord",value:t,mode:"math"}:t)}get latexMode(){return"math"===this.mode?"math":"text"}toJson(){const e={};if(this.type&&(e.type=this.type),"math"!==this.mode&&(e.mode=this.mode),this.command&&this.command!==this.value&&(e.command=this.command),void 0!==this.value&&(e.value=this.value),this.style&&Object.keys(this.style).length>0&&(e.style=u({},this.style)),void 0!==this.verbatimLatex&&(e.verbatimLatex=this.verbatimLatex),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.explicitSubsupPlacement&&(e.explicitSubsupPlacement=!0),this.isFunction&&(e.isFunction=!0),this.displayContainsHighlight&&(e.displayContainsHighlight=!0),this.isExtensibleSymbol&&(e.isExtensibleSymbol=!0),this.skipBoundary&&(e.skipBoundary=!0),this.captureSelection&&(e.captureSelection=!0),this.args&&(e.args=this.args.map((e=>null===e?"<null>":Array.isArray(e)&&e[0]instanceof Ma?{atoms:e.map((e=>e.toJson()))}:"object"==typeof e&&"group"in e?{group:e.group.map((e=>e.toJson()))}:e))),this._branches)for(const t of Object.keys(this._branches))this._branches[t]&&(e[t]=this._branches[t].filter((e=>"first"!==e.type)).map((e=>e.toJson())));return"mord"===e.type&&2===Object.keys(e).length&&"value"in e?e.value:e}get changeCounter(){return this.parent?this.parent.changeCounter:this._changeCounter}set isDirty(e){if(e){this.parent||this._changeCounter++,"verbatimLatex"in this&&(this.verbatimLatex=void 0),this._children=void 0;let{parent:e}=this;for(;e;)e.parent||e._changeCounter++,"verbatimLatex"in e&&(e.verbatimLatex=void 0),e._children=void 0,e=e.parent}}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);return(null==t?void 0:t.serialize)?t.serialize(this,e):this.body&&this.command?Xs([Js(this.command,this.bodyToLatex(e)),this.supsubToLatex(e)]):this.body?Xs([this.bodyToLatex(e),this.supsubToLatex(e)]):this.value&&""!==this.value?this.command:""}bodyToLatex(e){var t;return ta.serialize(this.body,h(u({},e),{defaultMode:null!=(t=e.defaultMode)?t:this.latexMode}))}aboveToLatex(e){return ta.serialize(this.above,e)}belowToLatex(e){return ta.serialize(this.below,e)}supsubToLatex(e){let t="";if(e=h(u({},e),{defaultMode:"math"}),void 0!==this.branch("subscript")){const n=ta.serialize(this.subscript,e);0===n.length?t+="_{}":1===n.length&&/^[0-9]$/.test(n)?t+=`_${n}`:t+=`_{${n}}`}if(void 0!==this.branch("superscript")){const n=ta.serialize(this.superscript,e);0===n.length?t+="^{}":1===n.length?"′"===n?t+="^\\prime ":"″"===n?t+="^\\doubleprime ":/^[0-9]$/.test(n)?t+=`^${n}`:t+=`^{${n}}`:t+=`^{${n}}`}return t}get treeDepth(){let e=1,t=this.parent;for(;t;)t=t.parent,e+=1;return e}get inCaptureSelection(){let e=this;for(;e;){if(e.captureSelection)return!0;e=e.parent}return!1}get parentPrompt(){let e=this.parent;for(;e;){if("prompt"===e.type&&!e.captureSelection)return e;e=e.parent}return null}branch(e){if(Aa(e)&&this._branches)return this._branches[e]}get branches(){if(!this._branches)return[];const e=[];for(const t of La)this._branches[t]&&e.push(t);return e}createBranch(e){return console.assert(Aa(e)),Aa(e)?(this._branches?this._branches[e]||(this._branches[e]=[this.makeFirstAtom(e)]):this._branches={[e]:[this.makeFirstAtom(e)]},this.isDirty=!0,this._branches[e]):[]}get row(){return Da(this.parentBranch)?this.parentBranch[0]:-1}get col(){return Da(this.parentBranch)?this.parentBranch[1]:-1}get body(){var e;return null==(e=this._branches)?void 0:e.body}set body(e){this.setChildren(e,"body")}get superscript(){var e;return null==(e=this._branches)?void 0:e.superscript}set superscript(e){this.setChildren(e,"superscript")}get subscript(){var e;return null==(e=this._branches)?void 0:e.subscript}set subscript(e){this.setChildren(e,"subscript")}get above(){var e;return null==(e=this._branches)?void 0:e.above}set above(e){this.setChildren(e,"above")}get below(){var e;return null==(e=this._branches)?void 0:e.below}set below(e){this.setChildren(e,"below")}get computedStyle(){var e,t;const n="string"==typeof this.style.verbatimColor,i="string"==typeof this.style.verbatimBackgroundColor,r=u(u({},null!=(t=null==(e=this.parent)?void 0:e.computedStyle)?t:{}),this.style);return delete r.variant,delete r.variantStyle,i||delete r.verbatimBackgroundColor,n||delete r.verbatimColor,r}applyStyle(e){this.isDirty=!0,this.style=u(u({},this.style),e),"none"===this.style.fontFamily&&delete this.style.fontFamily,"auto"===this.style.fontShape&&delete this.style.fontShape,"auto"===this.style.fontSeries&&delete this.style.fontSeries,"none"===this.style.color&&(delete this.style.color,delete this.style.verbatimColor),"none"===this.style.backgroundColor&&(delete this.style.backgroundColor,delete this.style.verbatimBackgroundColor),"auto"===this.style.fontSize&&delete this.style.fontSize;for(const t of this.children)t.applyStyle(e)}getInitialBaseElement(){var e,t,n;return this.hasEmptyBranch("body")?this:(console.assert("first"===(null==(e=this.body)?void 0:e[0].type)),null!=(n=null==(t=this.body[1])?void 0:t.getInitialBaseElement())?n:this)}getFinalBaseElement(){return this.hasEmptyBranch("body")?this:this.body[this.body.length-1].getFinalBaseElement()}isCharacterBox(){return"leftright"!==this.type&&"genfrac"!==this.type&&"subsup"!==this.type&&"delim"!==this.type&&"array"!==this.type&&"surd"!==this.type&&"mord"===this.getFinalBaseElement().type}hasEmptyBranch(e){const t=this.branch(e);return!t||(console.assert(t.length>0),console.assert("first"===t[0].type),1===t.length)}setChildren(e,t){var n;if(!e)return;if(console.assert(Aa(t)),!Aa(t))return;console.assert("first"!==(null==(n=e[0])?void 0:n.type));const i=[this.makeFirstAtom(t),...e];this._branches?this._branches[t]=i:this._branches={[t]:i};for(const n of e)n.parent=this,n.parentBranch=t;this.isDirty=!0}makeFirstAtom(t){const n=new e({type:"first",mode:this.mode});return n.parent=this,n.parentBranch=t,n}addChild(e,t){console.assert("first"!==e.type),this.createBranch(t).push(e),this.isDirty=!0,e.parent=this,e.parentBranch=t}addChildBefore(e,t){console.assert(void 0!==t.parentBranch);const n=this.createBranch(t.parentBranch);n.splice(n.indexOf(t),0,e),this.isDirty=!0,e.parent=this,e.parentBranch=t.parentBranch}addChildAfter(e,t){console.assert(void 0!==t.parentBranch);const n=this.createBranch(t.parentBranch);n.splice(n.indexOf(t)+1,0,e),this.isDirty=!0,e.parent=this,e.parentBranch=t.parentBranch}addChildren(e,t){const n=this.createBranch(t);for(const i of e)i.parent=this,i.parentBranch=t,n.push(i);this.isDirty=!0}addChildrenAfter(e,t){console.assert(0===e.length||"first"!==e[0].type),console.assert(void 0!==t.parentBranch);const n=this.createBranch(t.parentBranch);n.splice(n.indexOf(t)+1,0,...e),this.isDirty=!0;for(const n of e)n.parent=this,n.parentBranch=t.parentBranch;return e[e.length-1]}removeBranch(e){const t=this.branch(e);if(Aa(e)&&(this._branches[e]=void 0),!t)return[];for(const e of t)e.parent=void 0,e.parentBranch=void 0;return console.assert("first"===t[0].type),t.shift(),this.isDirty=!0,t}removeChild(e){if(console.assert(e.parent===this),"first"===e.type)return;const t=this.branch(e.parentBranch),n=t.indexOf(e);console.assert(n>=0),t.splice(n,1),this.isDirty=!0,e.parent=void 0,e.parentBranch=void 0}get siblings(){return this.parent?this.parent.branch(this.parentBranch):[]}get firstSibling(){return this.siblings[0]}get lastSibling(){const{siblings:e}=this;return e[e.length-1]}get isFirstSibling(){return this===this.firstSibling}get isLastSibling(){return this===this.lastSibling}get hasNoSiblings(){return 1===this.siblings.length}get leftSibling(){console.assert(void 0!==this.parent);const e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)-1]}get rightSibling(){console.assert(void 0!==this.parent);const e=this.parent.branch(this.parentBranch);return e[e.indexOf(this)+1]}get hasChildren(){return Boolean(this._branches&&this.children.length>0)}get firstChild(){return console.assert(this.hasChildren),this.children[0]}get lastChild(){console.assert(this.hasChildren);const{children:e}=this;return e[e.length-1]}get children(){if(this._children)return this._children;if(!this._branches)return[];const e=[];for(const t of La)if(this._branches[t])for(const n of this._branches[t])e.push(...n.children),e.push(n);return this._children=e,e}render(e){if("first"===this.type&&!e.atomIdsSettings)return null;const t=ae(this.command,this.mode);if(null==t?void 0:t.render)return t.render(this,e);const n=new Ca({parent:e},this.style);let i=this.createBox(n,{classes:this.parent?"":"ML__base"});return i?(this.subsupPlacement||!this.superscript&&!this.subscript||(i=this.attachSupsub(n,{base:i})),i.wrap(n)):null}attachSupsub(t,n){var i;const r=n.base,s=this.superscript,a=this.subscript;if(!s&&!a)return r;let o=null,l=null;const c=null!=(i=n.isCharacterBox)?i:this.isCharacterBox();let u=0;if(s){const n=new Ca({parent:t,mathstyle:"superscript"});o=e.createBox(n,s),c||(u=r.height-t.metrics.supDrop*n.scalingFactor)}let h,d=0;if(a){const n=new Ca({parent:t,mathstyle:"subscript"});l=e.createBox(n,a),c||(d=r.depth+t.metrics.subDrop*n.scalingFactor)}h=t.isDisplayStyle?t.metrics.sup1:t.isCramped?t.metrics.sup3:t.metrics.sup2;const p=.05/t.scalingFactor;let f=null;if(l&&o){u=Math.max(u,h,o.depth+.25*t.metrics.xHeight),d=Math.max(d,t.metrics.sub2);const e=t.metrics.defaultRuleThickness;if(u-o.depth-(l.height-d)<4*e){d=4*e-(u-o.depth)+l.height;const n=.8*t.metrics.xHeight-(u-o.depth);n>0&&(u+=n,d-=n)}const n=this.isExtensibleSymbol&&r.italic?-r.italic:0;f=new ma({individualShift:[{box:l,shift:d,marginLeft:n},{box:o,shift:-u}]}).wrap(t)}else l&&!o?(d=Math.max(d,t.metrics.sub1,l.height-.3448),f=new ma({shift:d,children:[{box:l,marginRight:p,marginLeft:this.isCharacterBox()?-r.italic:0}]})):!l&&o&&(u=Math.max(u,h,o.depth+.10775),f=new ma({shift:-u,children:[{box:o,marginRight:p}]}));return new ca([r,new ca(f,{caret:this.caret,isSelected:this.isSelected,classes:"msubsup"})],{type:n.type})}attachLimits(t,n){const i=this.superscript?e.createBox(new Ca({parent:t,mathstyle:"superscript"},this.style),this.superscript):null,r=this.subscript?e.createBox(new Ca({parent:t,mathstyle:"subscript"},this.style),this.subscript):null;return i||r?function(e,t){var n,i,r,s,a;const o=e.metrics,l=new ca(t.base),c=null!=(n=t.baseShift)?n:0,u=null!=(i=t.slant)?i:0;let h=0,d=0;t.above&&(h=null!=(r=t.aboveShift)?r:Math.max(o.bigOpSpacing1,o.bigOpSpacing3-t.above.depth)),t.below&&(d=null!=(s=t.belowShift)?s:Math.max(o.bigOpSpacing2,o.bigOpSpacing4-t.below.height));let p=null;if(t.below&&t.above){const n=o.bigOpSpacing5+t.below.height+t.below.depth+d+l.depth+c;p=new ma({bottom:n,children:[o.bigOpSpacing5,{box:t.below,marginLeft:-u,classes:["ML__center"]},d,{box:l,classes:["ML__center"]},h,{box:t.above,marginLeft:u,classes:["ML__center"]},o.bigOpSpacing5]}).wrap(e)}else if(t.below&&!t.above)p=new ma({top:l.height-c,children:[o.bigOpSpacing5,{box:t.below,marginLeft:-u,classes:["ML__center"]},d,{box:l,classes:["ML__center"]}]}).wrap(e);else if(!t.below&&t.above){const n=l.depth+c;p=new ma({bottom:n,children:[{box:l,classes:["ML__center"]},h,{box:t.above,marginLeft:u,classes:["ML__center"]},o.bigOpSpacing5]}).wrap(e)}else{const t=l.depth+c;p=new ma({bottom:t,children:[{box:l},o.bigOpSpacing5]}).wrap(e)}return new ca(p,{type:null!=(a=t.type)?a:"op"})}(t,h(u({},n),{above:i,below:r})):n.base.wrap(t)}bind(e,t){if(!t||e.isPhantom||""===this.value)return t;let n=this.parent;for(;n&&!n.captureSelection;)n=n.parent;return(null==n?void 0:n.captureSelection)||(this.id||(this.id=e.makeID()),t.atomID=this.id),t}createBox(t,n){var i,r,s,a;const o=null!=(i=this.value)?i:this.body,l=null!=(r=null==n?void 0:n.boxType)?r:aa(this.type);let c=null!=(s=null==n?void 0:n.classes)?s:"";"text"===this.mode&&(c+=" ML__text");const d="string"==typeof o||void 0===o?new ca(null!=o?o:null,{type:l,isSelected:this.isSelected,mode:this.mode,maxFontSize:t.scalingFactor,style:h(u({variant:"normal"},this.style),{fontSize:Math.max(1,t.size+t.mathstyle.sizeDelta)}),letterShapeStyle:t.letterShapeStyle,classes:c}):null!=(a=e.createBox(t,o,{type:l,classes:c}))?a:new ca(null);return t.isTight&&(d.isTight=!0),"math"===this.mode&&"main"!==this.style.variant||(d.italic=0),d.right=d.italic,this.bind(t,d),this.caret&&(this.superscript||this.subscript||(d.caret=this.caret)),d}isDigit(){var e;return"mord"===this.type&&this.value?/^[\d,\.]$/.test(this.value):"group"===this.type&&2===(null==(e=this.body)?void 0:e.length)&&("first"===this.body[0].type&&","===this.body[1].value)}asDigit(){var e;return"mord"===this.type&&this.value&&/^[\d,\.]$/.test(this.value)?this.value:"group"===this.type&&2===(null==(e=this.body)?void 0:e.length)&&"first"===this.body[0].type&&","===this.body[1].value?".":""}};function Ra(e,t,n){var i,r,s,a,o;if(!t||0===t.length)return null;const l=new Ca({parent:e},n.style),c=!(null==(i=l.atomIdsSettings)?void 0:i.groupNumbers);let d=[];if(1===t.length){const e=t[0],n=e.render(l);n&&(c&&e.isSelected&&n.selected(!0),d=[n])}else{let e="",n=!0;for(const i of t){(null==(r=l.atomIdsSettings)?void 0:r.groupNumbers)&&e&&(n&&i.isDigit()||!n&&Ia(i))&&(l.atomIdsSettings.overrideID=e);const t=i.render(l);l.atomIdsSettings&&(l.atomIdsSettings.overrideID=void 0),t&&((null==(s=l.atomIdsSettings)?void 0:s.groupNumbers)&&((i.isDigit()||Ia(i))&&(e&&n===i.isDigit()||(n=i.isDigit(),e=null!=(a=i.id)?a:"")),!e||(i.isDigit()||Ia(i))&&i.hasEmptyBranch("superscript")&&i.hasEmptyBranch("subscript")||(e="")),c&&i.isSelected&&t.selected(!0),d.push(t))}}if(0===d.length)return null;const p=new ca(d,h(u({isTight:l.isTight},n),{type:null!=(o=n.type)?o:"lift"}));return p.isSelected=d.every((e=>e.isSelected)),p.wrap(l)}function Ia(e){return"text"===e.mode}var Pa=class e extends Ma{constructor(e,t,n){super({type:"text",command:e,mode:"text",displayContainsHighlight:!0}),this.value=t,this.verbatimLatex=t,this.applyStyle(n)}static fromJson(t){return new e(t.command,t.value,t.style)}render(e){const t=this.createBox(e);return this.caret&&(t.caret=this.caret),t}_serialize(e){var t;return null!=(t=this.verbatimLatex)?t:le("text",this.value.codePointAt(0))}};function Oa(e,t){return e[0]===t[0]&&e[1]===t[1]?"equal":"different"}function Fa(e){let t=1/0,n=-1/0;for(const i of e.ranges)t=Math.min(t,i[0],i[1]),n=Math.max(n,i[0],i[1]);return[t,n]}function Na(e){return"number"==typeof e&&!Number.isNaN(e)}function Ba(e){return Array.isArray(e)&&2===e.length}function $a(e){return null!=e&&"object"==typeof e&&"ranges"in e&&Array.isArray(e.ranges)}function Ka(e,t,n){return n?function(e,t){if(!t)return"";if("string"==typeof t)return t;if(!e||void 0===t.after)return t.value;let n=!1,i=!1,r=!1,s=!1,a=!1,o=!1,l=!1,c=!1,u=!1,h=!1,d=!1,p=!1,f=!1,m=!1,g=!1,_=e[0],y=0;for(;(null==_?void 0:_.type)&&/^(subsup|placeholder)$/.test(_.type);)y+=1,_=e[y];return n=!_||"first"===_.type,_&&(m="text"===_.mode,i=!m&&"mord"===_.type&&B.test(_.value),r=!m&&"mord"===_.type&&/\d+$/.test(_.value),s=!m&&_.isFunction,a="genfrac"===_.type,o="surd"===_.type,l="mbin"===_.type,c="mrel"===_.type,u="mop"===_.type||"operator"===_.type||"extensible-symbol"===_.type,h="mpunct"===_.type||"minner"===_.type,d="array"===_.type,p="mopen"===_.type,f="mclose"===_.type||"leftright"===_.type,g="space"===_.type),t.after.includes("nothing")&&n||t.after.includes("letter")&&i||t.after.includes("digit")&&r||t.after.includes("function")&&s||t.after.includes("frac")&&a||t.after.includes("surd")&&o||t.after.includes("binop")&&l||t.after.includes("relop")&&c||t.after.includes("operator")&&u||t.after.includes("punct")&&h||t.after.includes("array")&&d||t.after.includes("openfence")&&p||t.after.includes("closefence")&&f||t.after.includes("text")&&m||t.after.includes("space")&&g?t.value:""}(e,n[t]):""}var Ua={"&":"\\&","%":"\\%",$:"\\$","''":"^{\\doubleprime}","'''":"^{\\prime\\prime\\prime}","''''":"^{\\prime\\prime\\prime\\prime}",alpha:"\\alpha",delta:"\\delta",Delta:"\\Delta",pi:"\\pi",Pi:"\\Pi",theta:"\\theta",Theta:"\\Theta",ii:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryI"},jj:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\imaginaryJ"},ee:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\exponentialE"},nabla:"\\nabla",grad:"\\nabla",del:"\\partial",deg:{after:"digit+space",value:"\\degree"},infty:"\\infty","∞":"\\infty",oo:{after:"nothing+digit+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\infty"},"∑":"\\sum",sum:"\\sum_{#?}^{#?}",int:"\\int_{#?}^{#?}",prod:"\\prod_{#?}^{#?}",sqrt:"\\sqrt{#?}","∆":"\\differentialD","∂":"\\differentialD",arcsin:"\\arcsin",arccos:"\\arccos",arctan:"\\arctan",arcsec:"\\arcsec",arccsc:"\\arccsc",arsinh:"\\arsinh",arcosh:"\\arcosh",artanh:"\\artanh",arcsech:"\\arcsech",arccsch:"\\arccsch",arg:"\\arg",ch:"\\ch",cosec:"\\cosec",cosh:"\\cosh",cot:"\\cot",cotg:"\\cotg",coth:"\\coth",csc:"\\csc",ctg:"\\ctg",cth:"\\cth",sec:"\\sec",sinh:"\\sinh",sh:"\\sh",tanh:"\\tanh",tg:"\\tg",th:"\\th",sin:"\\sin",cos:"\\cos",tan:"\\tan",lg:"\\lg",lb:"\\lb",log:"\\log",ln:"\\ln",exp:"\\exp",lim:"\\lim_{#?}",dx:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD x"},dy:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD y"},dt:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\differentialD t"},AA:"\\forall",EE:"\\exists","!EE":"\\nexists","&&":"\\land",xin:{after:"nothing+text+relop+punct+openfence+space",value:"x \\in"},sint:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\sin t"},in:{after:"nothing+letter+closefence",value:"\\in"},"!in":"\\notin",NN:"\\mathbb{N}",ZZ:"\\Z",QQ:"\\Q",RR:"\\R",CC:"\\C",xx:"\\times","+-":"\\pm","≠":"\\ne","!=":"\\ne","≥":"\\ge",">=":"\\ge","≤":"\\le","<=":"\\le","<<":"\\ll",">>":"\\gg","~~":"\\approx","≈":"\\approx","?=":"\\questeq","÷":"\\div","¬":"\\neg",":=":"\\coloneq","::":"\\Colon","(:":"\\langle",":)":"\\rangle",beta:"\\beta",chi:"\\chi",epsilon:"\\epsilon",varepsilon:"\\varepsilon",eta:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\eta"},gamma:"\\gamma",Gamma:"\\Gamma",iota:"\\iota",kappa:"\\kappa",lambda:"\\lambda",Lambda:"\\Lambda",mu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\mu"},nu:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\nu"},"µ":"\\mu",phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\phi"},Phi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Phi"},varphi:"\\varphi",psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\psi"},Psi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Psi"},rho:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\rho"},sigma:"\\sigma",Sigma:"\\Sigma",tau:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\tau"},vartheta:"\\vartheta",upsilon:"\\upsilon",xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space",value:"\\xi"},Xi:{after:"nothing+digit+function+frac+surd+binop+relop+punct+array+openfence+closefence+space+text",value:"\\Xi"},zeta:"\\zeta",omega:"\\omega",Omega:"\\Omega","Ω":"\\omega",forall:"\\forall",exists:"\\exists","!exists":"\\nexists",":.":"\\therefore",liminf:"\\liminf_{#?}",limsup:"\\limsup_{#?}",argmin:"\\operatorname*{arg~min}_{#?}",argmax:"\\operatorname*{arg~max}_{#?}",det:"\\det",mod:"\\bmod{#?}","(mod":"\\pmod{#?}",max:"\\max",min:"\\min",erf:"\\operatorname{erf}",erfc:"\\operatorname{erfc}",bessel:"\\operatorname{bessel}",mean:"\\operatorname{mean}",median:"\\operatorname{median}",fft:"\\operatorname{fft}",lcm:"\\operatorname{lcm}",gcd:"\\operatorname{gcd}",randomReal:"\\operatorname{randomReal}",randomInteger:"\\operatorname{randomInteger}",Re:"\\operatorname{Re}",Im:"\\operatorname{Im}",mm:{after:"nothing+digit+operator",value:"\\operatorname{mm}"},cm:{after:"nothing+digit+operator",value:"\\operatorname{cm}"},km:{after:"nothing+digit+operator",value:"\\operatorname{km}"},kg:{after:"nothing+digit+operator",value:"\\operatorname{kg}"},"...":"\\ldots","+...":"+\\cdots","-...":"-\\cdots","->...":"\\to\\cdots","--\x3e...":"\\longrightarrow\\cdots","->":"\\to","|->":"\\mapsto","--\x3e":"\\longrightarrow","<--":"\\longleftarrow","=>":"\\Rightarrow","==>":"\\Longrightarrow","<=>":"\\Leftrightarrow","<->":"\\leftrightarrow","(.)":"\\odot","(+)":"\\oplus","(/)":"\\oslash","(*)":"\\otimes","(-)":"\\ominus","||":"\\Vert","*":"\\cdot","**":"\\star","***":"\\ast","//":"\\slash","\\\\":"\\backslash",setminus:"\\backslash","|><":"\\ltimes","><|":"\\rtimes","|><|":"\\bowtie","-:":"\\div",divide:"\\div","@":"\\circ","^^":"\\wedge","^^^":"\\bigwedge",vv:"\\vee",vvv:"\\bigvee",nn:"\\cap",nnn:"\\bigcap",uu:"\\cup",uuu:"\\bigcup","-=":"\\equiv","~=":"\\cong",lt:"<","lt=":"\\leq",gt:">","gt=":"\\geq","-<":"\\prec","-lt":"\\prec","-<=":"\\preceq",">-=":"\\succeq",prop:"\\propto",diamond:"\\diamond",square:"\\square",iff:"\\iff",sub:"\\subset",sup:"\\supset",sube:"\\subseteq",supe:"\\supseteq",uarr:"\\uparrow",darr:"\\downarrow",rarr:"\\rightarrow",rArr:"\\Rightarrow",larr:"\\leftarrow",lArr:"\\Leftarrow",harr:"\\leftrightarrow",hArr:"\\Leftrightarrow",aleph:"\\aleph",and:"\\land",or:"\\lor",not:"\\neg","_|_":"\\bot",TT:"\\top","|--":"\\vdash","|==":"\\models","|__":"\\lfloor","__|":"\\rfloor","|~":"\\lceil","~|":"\\rceil",">->":"\\rightarrowtail","->>":"\\twoheadrightarrow",">->>":"\\twoheadrightarrowtail",frac:"\\frac{#?}{#?}",cbrt:"\\sqrt[3]{#?}",nthroot:"\\sqrt[#?]{#?}"};function za(e,t){var n;let i=null!=(n=null==t?void 0:t.format)?n:"auto";return"auto"===i&&([i,e]=function(e){if(e=e.trim(),e.length<=1)return["latex",e];let t;if([t,e]=ja(e),t)return["latex",e];if(e.startsWith("`")&&e.endsWith("`"))return["ascii-math",e=e.substring(1,e.length-1)];if(e.includes("\\"))return["latex",e];if(/\$.+\$/.test(e))return["latex",`\\text{${e}}`];return[void 0,e]}(e)),"ascii-math"===i?["ascii-math",Va(e=(e=(e=(e=(e=(e=e.replace(/\u2061/gu,"")).replace(/\u3016/gu,"{")).replace(/\u3017/gu,"}")).replace(/([^\\])sinx/g,"$1\\sin x")).replace(/([^\\])cosx/g,"$1\\cos x ")).replace(/\u2013/g,"-"),{inlineShortcuts:null==t?void 0:t.inlineShortcuts})]:["latex",e]}function Va(e,t){var n,i,r;if(!e)return"";let s,a=!1;const o=null!=(n=t.inlineShortcuts)?n:Ua;if(a||!e.startsWith("^")&&!e.startsWith("_")||(s=qa(e.slice(1),{inlineShortcuts:o,noWrap:!0}),e=e[0]+"{"+s.match+"}",e+=Va(s.rest,t),a=!0),!a&&(s=e.match(/^(sqrt|\u221A)(.*)/),s)){s=qa(s[2],{inlineShortcuts:o,noWrap:!0});e="\\sqrt{"+(null!=(i=s.match)?i:"\\placeholder{}")+"}",e+=Va(s.rest,t),a=!0}if(!a&&(s=e.match(/^(\\cbrt|\u221B)(.*)/),s)){s=qa(s[2],{inlineShortcuts:o,noWrap:!0});e="\\sqrt[3]{"+(null!=(r=s.match)?r:"\\placeholder{}")+"}",e+=Va(s.rest,t),a=!0}if(a||(s=e.match(/^abs(.*)/),s&&(s=qa(s[1],{inlineShortcuts:o,noWrap:!0}),e="\\left|"+s.match+"\\right|",e+=Va(s.rest,t),a=!0)),a||(s=e.match(/^["”“](.*?)["”“](.*)/),s&&(e="\\text{"+s[1]+"}",e+=Va(s[2],t),a=!0)),a||(s=e.match(/^([^a-zA-Z\(\{\[\_\^\\\s"]+)(.*)/),s&&(e=Ga(s[1],o),e+=Va(s[2],t),a=!0)),!a&&/^([fgh])[^a-zA-Z]/.test(e)&&(s=qa(e.slice(1),{inlineShortcuts:o,noWrap:!0}),e="("===e[1]?e[0]+"\\left("+s.match+"\\right)":e[0]+s.match,e+=Va(s.rest,t),a=!0),a||(s=e.match(/^([a-zA-Z]+)(.*)/),s&&(e=Ga(s[1],o),e+=Va(s[2],t),a=!0)),!a)if(s=qa(e,{inlineShortcuts:o,noWrap:!0}),s.match&&"/"===s.rest[0]){const n=qa(s.rest.slice(1),{inlineShortcuts:o,noWrap:!0});n.match&&(e="\\frac{"+s.match+"}{"+n.match+"}"+Va(n.rest,t)),a=!0}else s.match&&(e=e.startsWith("(")?"\\left("+s.match+"\\right)"+Va(s.rest,t):s.match+Va(s.rest,t),a=!0);return a||(s=e.match(/^(\s+)(.*)$/),s&&(e=" "+Va(s[2],t),a=!0)),e}function qa(e,t){let n="",i=e=e.trim(),r=e.charAt(0),s={"(":")","{":"}","[":"]"}[r];if(s){let a=1,o=1;for(;o<e.length&&a>0;)e[o]===r&&a++,e[o]===s&&a--,o++;0===a?(t.noWrap&&"("===r?n=Va(e.substring(1,o-1),t):("{"===r&&"}"===s&&(r="\\{",s="\\}"),n="\\left"+r+Va(e.substring(1,o-1),t)+"\\right"+s),i=e.slice(Math.max(0,o))):(n=e.substring(1,o),i="")}else{let r=e.match(/^([a-zA-Z]+)/);if(r){let n=Ka(null,e,t.inlineShortcuts);if(n)return n=n.replace("_{#?}",""),n=n.replace("^{#?}",""),{match:n,rest:e.slice(n.length)}}if(r=e.match(/^([a-zA-Z])/),r)return{match:r[1],rest:e.slice(1)};if(r=e.match(/^(-)?\d+(\.\d*)?/),r)return{match:r[0],rest:e.slice(r[0].length)};/^\\(left|right)/.test(e)||(r=e.match(/^(\\[a-zA-Z]+)/),r&&(i=e.slice(r[1].length),n=r[1]))}return{match:n,rest:i}}function Ga(e,t){let n=Ka(null,e,t);return n?(n=n.replace("_{#?}",""),n=n.replace("^{#?}",""),n+=" "):n=e,n}var Ha=[["\\[","\\]"],["\\(","\\)"],["$$","$$"],["$","$"],["\\begin{math}","\\end{math}"],["\\begin{displaymath}","\\end{displaymath}"],["\\begin{equation}","\\end{equation}"],["\\begin{equation*}","\\end{equation*}"]];function ja(e){const t=e.trim();for(const e of Ha)if(t.startsWith(e[0])&&t.endsWith(e[1]))return[!0,t.substring(e[0].length,t.length-e[1].length)];return[!1,e]}var Wa=(e,t,n)=>(Ha.some((e=>t.startsWith(e[0])&&t.endsWith(e[1])))||(t=`$$ ${t} $$`),t),Za=class e{constructor(t){e._modes[t]=this}static onPaste(t,n,i){var r;if(!n.contentEditable&&"none"===n.userSelect)return n.model.announce("plonk"),!1;if("string"==typeof i){const e=new DataTransfer;e.setData("text/plain",i),i=e}const s=new ClipboardEvent("paste",{clipboardData:i,cancelable:!0});return!!(null==(r=n.host)?void 0:r.dispatchEvent(s))&&e._modes[t].onPaste(n,i)}static copyToClipboard(e,t){if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");const n=e.model,i=n.selectionIsCollapsed?[0,n.lastOffset]:Fa(n.selection),r=n.getValue(i,t);navigator.clipboard.writeText(r).then((()=>{}),(()=>e.model.announce("plonk")))}static onCopy(e,t){var n;if(!t.clipboardData)return;if(!e.contentEditable&&"none"===e.userSelect)return void e.model.announce("plonk");const i=e.model,r=i.selectionIsCollapsed?[0,i.lastOffset]:Fa(i.selection);let s=i.getAtoms(r);if(s.every((e=>"text"===e.mode||!e.mode)))t.clipboardData.setData("text/plain",s.filter((e=>e instanceof Pa)).map((e=>e.value)).join(""));else if(s.every((e=>"latex"===e.mode)))t.clipboardData.setData("text/plain",i.getAtoms(r,{includeChildren:!0}).map((e=>{var t;return null!=(t=e.value)?t:""})).join(""));else{let a;a=1===s.length&&void 0!==s[0].verbatimLatex?s[0].verbatimLatex:i.getValue(r,"latex-expanded"),t.clipboardData.setData("application/x-latex",a);try{t.clipboardData.setData("text/plain",e.options.onExport(e,a,r))}catch(e){}if(1===s.length){const e=s[0];"root"!==e.type&&"group"!==e.type||(s=e.body.filter((e=>"first"!==e.type)))}try{t.clipboardData.setData("application/json+mathlive",JSON.stringify(s.map((e=>e.toJson()))))}catch(e){}if(null==(n=window[Symbol.for("io.cortexjs.compute-engine")])?void 0:n.ComputeEngine){const e=window.MathfieldElement.computeEngine;if(e)try{const n=e.jsonSerializationOptions;e.jsonSerializationOptions={metadata:["latex"]};const s=e.parse(i.getValue(r,"latex-unstyled"));e.jsonSerializationOptions=n;const a=JSON.stringify(s.json);a&&t.clipboardData.setData("application/json",a)}catch(e){}}}t.preventDefault()}static insert(t,n,i={}){var r;const s="auto"===i.mode?t.mode:null!=(r=i.mode)?r:t.mode;return e._modes[s].insert(t,n,i)}onPaste(e,t){return!1}insert(e,t,n){return!1}};Za._modes={};var Ya=Za,Xa=[{key:"left",command:"moveToPreviousChar"},{key:"right",command:"moveToNextChar"},{key:"up",command:"moveUp"},{key:"down",command:"moveDown"},{key:"shift+[ArrowLeft]",command:"extendSelectionBackward"},{key:"shift+[ArrowRight]",command:"extendSelectionForward"},{key:"shift+[ArrowUp]",command:"extendSelectionUpward"},{key:"shift+[ArrowDown]",command:"extendSelectionDownward"},{key:"[Backspace]",command:"deleteBackward"},{key:"alt+[Delete]",command:"deleteBackward"},{key:"[Delete]",command:"deleteForward"},{key:"alt+[Backspace]",command:"deleteForward"},{key:"alt+[ArrowLeft]",command:"moveToPreviousWord"},{key:"alt+[ArrowRight]",command:"moveToNextWord"},{key:"shift+alt+[ArrowLeft]",command:"extendToPreviousWord"},{key:"shift+alt+[ArrowRight]",command:"extendToNextWord"},{key:"ctrl+[ArrowLeft]",command:"moveToGroupStart"},{key:"ctrl+[ArrowRight]",command:"moveToGroupEnd"},{key:"shift+ctrl+[ArrowLeft]",command:"extendToGroupStart"},{key:"shift+ctrl+[ArrowRight]",command:"extendToGroupEnd"},{key:"[Home]",command:"moveToMathfieldStart"},{key:"cmd+[ArrowLeft]",command:"moveToMathfieldStart"},{key:"shift+[Home]",command:"extendToMathFieldStart"},{key:"shift+cmd+[ArrowLeft]",command:"extendToMathFieldStart"},{key:"[End]",command:"moveToMathfieldEnd"},{key:"cmd+[ArrowRight]",command:"moveToMathfieldEnd"},{key:"shift+[End]",command:"extendToMathFieldEnd"},{key:"shift+cmd+[ArrowRight]",command:"extendToMathFieldEnd"},{key:"[Pageup]",command:"moveToGroupStart"},{key:"[Pagedown]",command:"moveToGroupEnd"},{key:"[Tab]",command:"moveToNextGroup"},{key:"shift+[Tab]",command:"moveToPreviousGroup"},{key:"[Escape]",ifMode:"math",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"text",command:["switchMode","latex"]},{key:"[Escape]",ifMode:"latex",command:["complete","complete",{selectItem:"true"}]},{key:"\\",ifMode:"math",command:["switchMode","latex","\\"]},{key:"[IntlBackslash]",ifMode:"math",command:["switchMode","latex","\\"]},{key:"[Tab]",ifMode:"latex",command:["complete","accept-suggestion"]},{key:"[Return]",ifMode:"latex",command:"complete"},{key:"[Enter]",ifMode:"latex",command:"complete"},{key:"shift+[Escape]",ifMode:"latex",command:["complete","reject"]},{key:"[ArrowDown]",ifMode:"latex",command:"nextSuggestion"},{key:"[ArrowUp]",ifMode:"latex",command:"previousSuggestion"},{key:"ctrl+a",ifPlatform:"!macos",command:"selectAll"},{key:"cmd+a",command:"selectAll"},{key:"[Cut]",command:"cutToClipboard"},{key:"[Copy]",command:"copyToClipboard"},{key:"[Paste]",command:"pasteFromClipboard"},{key:"[Clear]",command:"deleteBackward"},{key:"[Undo]",command:"undo"},{key:"[Redo]",command:"redo"},{key:"[EraseEof]",command:"deleteToGroupEnd"},{key:"ctrl+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"cmd+x",ifPlatform:"ios",command:"cutToClipboard"},{key:"ctrl+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"cmd+c",ifPlatform:"ios",command:"copyToClipboard"},{key:"ctrl+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"cmd+v",ifPlatform:"ios",command:"pasteFromClipboard"},{key:"ctrl+z",ifPlatform:"!macos",command:"undo"},{key:"cmd+z",command:"undo"},{key:"ctrl+y",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+y",command:"redo"},{key:"shift+ctrl+z",ifPlatform:"!macos",command:"redo"},{key:"shift+cmd+z",command:"redo"},{key:"ctrl+b",ifPlatform:"macos",command:"moveToPreviousChar"},{key:"ctrl+f",ifPlatform:"macos",command:"moveToNextChar"},{key:"ctrl+p",ifPlatform:"macos",command:"moveUp"},{key:"ctrl+n",ifPlatform:"macos",command:"moveDown"},{key:"ctrl+a",ifPlatform:"macos",command:"moveToMathfieldStart"},{key:"ctrl+e",ifPlatform:"macos",command:"moveToMathfieldEnd"},{key:"shift+ctrl+b",ifPlatform:"macos",command:"extendSelectionBackward"},{key:"shift+ctrl+f",ifPlatform:"macos",command:"extendSelectionForward"},{key:"shift+ctrl+p",ifPlatform:"macos",command:"extendSelectionUpward"},{key:"shift+ctrl+n",ifPlatform:"macos",command:"extendSelectionDownward"},{key:"shift+ctrl+a",ifPlatform:"macos",command:"extendToMathFieldStart"},{key:"shift+ctrl+e",ifPlatform:"macos",command:"extendToMathFieldEnd"},{key:"alt+ctrl+b",ifPlatform:"macos",command:"moveToPreviousWord"},{key:"alt+ctrl+f",ifPlatform:"macos",command:"moveToNextWord"},{key:"shift+alt+ctrl+b",ifPlatform:"macos",command:"extendToPreviousWord"},{key:"shift+alt+ctrl+f",ifPlatform:"macos",command:"extendToNextWord"},{key:"ctrl+h",ifPlatform:"macos",command:"deleteBackward"},{key:"ctrl+d",ifPlatform:"macos",command:"deleteForward"},{key:"ctrl+l",ifPlatform:"macos",command:"scrollIntoView"},{key:"ctrl+[Digit2]",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"ctrl+[Digit5]",ifMode:"math",command:"moveToOpposite"},{key:"ctrl+[Digit6]",ifMode:"math",command:"moveToSuperscript"},{key:"ctrl+[Return]",ifMode:"math",command:"addRowAfter"},{key:"ctrl+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Return]",ifMode:"math",command:"addRowAfter"},{key:"cmd+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"alt+p",ifMode:"math",command:["insert","\\pi"]},{key:"alt+v",ifMode:"math",command:["insert","\\sqrt{#0}"]},{key:"alt+o",ifMode:"math",command:["insert","\\emptyset"]},{key:"alt+d",ifMode:"math",command:["insert","\\differentialD"]},{key:"shift+alt+o",ifMode:"math",command:["insert","\\varnothing"]},{key:"shift+alt+d",ifMode:"math",command:["insert","\\partial"]},{key:"alt+[Backslash]",ifMode:"math",command:["insert","\\backslash"]},{key:"[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+[NumpadDivide]",ifMode:"math",command:["insert","\\frac{#?}{#@}"]},{key:"shift+alt+k",command:"toggleKeystrokeCaption"},{key:"alt+[Space]",command:"toggleContextMenu"},{key:"alt+shift+[Space]",command:"toggleVirtualKeyboard"},{key:"alt+ctrl+[ArrowUp]",command:["speak","all",{withHighlighting:!1}]},{key:"alt+ctrl+[ArrowDown]",command:["speak","selection",{withHighlighting:!1}]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["switchMode","text","",""]},{key:"shift+alt+[KeyT]",ifMode:"math",command:["switchMode","text","",""]},{key:"shift+[Quote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"text",command:["switchMode","math","",""]},{key:"shift+alt+[KeyT]",ifMode:"text",command:["switchMode","math","",""]},{key:"/",ifMode:"math",command:["insert","\\frac{#@}{#?}"]},{key:"alt+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+shift+/",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","/"]},{key:"alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrack #0 \\right\\rbrack"]},{key:"ctrl+[Minus]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"moveToSubscript"},{key:"shift+alt+[BracketLeft]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\left\\lbrace #0 \\right\\rbrace"]},{key:"ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowAfter"},{key:"shift+ctrl+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"shift+cmd+;",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:"addRowBefore"},{key:"ctrl+[Backspace]",ifMode:"math",command:"removeRow"},{key:"cmd+[Backspace]",ifMode:"math",command:"removeRow"},{key:"alt+[Tab]",ifMode:"math",command:"addColumnAfter"},{key:"shift+alt+[Tab]",ifMode:"math",command:"addColumnBefore"},{key:"alt+[Enter]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Enter]",ifMode:"math",command:"addRowBefore"},{key:"alt+[Return]",ifMode:"math",command:"addRowAfter"},{key:"shift+alt+[Return]",ifMode:"math",command:"addRowBefore"},{key:"shift+[Backspace]",ifMode:"math",command:"removeColumn"},{key:"alt+[Digit5]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","$\\infty"]},{key:"alt+[Digit9]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","("]},{key:"alt+[Digit0]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert",")"]},{key:"alt+|",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","|"]},{key:"shift+[Backquote]",ifLayout:["apple.en-intl","windows.en-intl","linux.en"],ifMode:"math",command:["insert","\\~"]},{key:"[Backquote]",ifLayout:["windows.french","linux.french"],ifMode:"math",command:["insert","^2"]},{key:"[Backquote]",ifLayout:["windows.german","linux.german"],ifMode:"math",command:["insert","^"]},{key:"[IntlBackslash]",ifLayout:["apple.german"],ifMode:"math",command:["insert","^"]}],Ja={"\\sqrt":["alt+v","ctrl+[Digit2]"],"\\pi":"alt+p","\\infty":"alt+[Digit5]","\\differentialD":"alt+d","\\partial":"shift+alt+d","\\frac":"Slash","\\emptyset":"alt+o","\\varnothing":"shift+alt+o","\\~":"~"};function Qa(e){var t;return(null==(t=e.element)?void 0:t.mathfield)===e}function eo(e){const t=function(e){var t,n;return null!=(n=null!=(t=e.querySelector(".ML__caret"))?t:e.querySelector(".ML__text-caret"))?n:e.querySelector(".ML__latex-caret")}(e);if(!t)return null;const n=t.getBoundingClientRect();return{x:n.right,y:n.bottom,height:n.height}}function to(e){var t;if(!e.parent)return"root";let n=null!=(t=e.parent.id)?t:"";return n+="string"==typeof e.parentBranch?"-"+e.parentBranch:`-${e.parentBranch[0]}/${e.parentBranch[0]}`,n}function no(e,t,n){if(!t)return null;const i=e.field.getBoundingClientRect(),r=t.right-t.left,s=t.bottom-t.top,a=Math.ceil(t.left-i.left+e.field.scrollLeft*n),o=Math.ceil(t.top-i.top);return{left:a,right:a+r,top:o,bottom:o+s}}function io(e){const t=e.getBoundingClientRect(),n=parseInt(getComputedStyle(e).marginRight),i={top:t.top-1,bottom:t.bottom,left:t.left,right:t.right-1+n};if(0===e.children.length||"SVG"===e.tagName.toUpperCase())return i;for(const t of e.children)if(1===t.nodeType&&"atomId"in t.dataset&&!t.classList.contains("pstrut")){const e=io(t);i.left=Math.min(i.left,e.left),i.right=Math.max(i.right,e.right),i.top=Math.min(i.top,e.top),i.bottom=Math.max(i.bottom,e.bottom)}return i}function ro(e,t){var n,i;if(!t.id)return null;let r=null!=(i=null==(n=e.atomBoundsCache)?void 0:n.get(t.id))?i:null;if(null!==r)return r;const s=e.field.querySelector(`[data-atom-id="${t.id}"]`);return r=s?io(s):null,e.atomBoundsCache&&(r?e.atomBoundsCache.set(t.id,r):e.atomBoundsCache.delete(t.id)),null!=r?r:null}function so(e,t){return e.model.selection.ranges.reduce(((n,i)=>n.concat(...function(e,t,n){const i=new Map;for(const r of e.model.getAtoms(t,{includeChildren:!0})){if((null==n?void 0:n.excludeAtomsWithBackground)&&r.style.backgroundColor)continue;const t=e.field,s=t.offsetWidth;let a=Math.floor(t.getBoundingClientRect().width)/s;a=isNaN(a)?1:a;const o=no(e,ro(e,r),a);if(o){const e=to(r);if(i.has(e)){const t=i.get(e);i.set(e,{left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom)})}else i.set(e,o)}}return[...i.values()]}(e,i,t))),[])}function ao(e,t){return"*"===e||"none"===t||("same-origin"===t?!window.origin||e===window.origin:"function"==typeof t&&t(e))}function oo(e){let t=0,n=0;const i=e.offsetWidth,r=e.offsetHeight;for(;e instanceof HTMLElement;)t+=e.offsetTop,n+=e.offsetLeft,e=e.offsetParent;return new DOMRect(n,t,i,r)}var lo,co;function uo(e){let t="";switch(e){case"mathfield-element":t="\n :host { display: inline-block; background-color: field; color: fieldtext; border-width: 1px; border-style: solid; border-color: #acacac; border-radius: 2px; padding:4px;}\n :host([hidden]) { display: none; }\n :host([disabled]), :host([disabled]:focus), :host([disabled]:focus-within) { outline: none; opacity: .5; }\n :host(:focus), :host(:focus-within) {\n outline: Highlight auto 1px; /* For Firefox */\n outline: -webkit-focus-ring-color auto 1px;\n }\n :host([readonly]:focus), :host([readonly]:focus-within),\n :host([read-only]:focus), :host([read-only]:focus-within) {\n outline: none;\n }\n @media (hover: none) and (pointer: coarse) {\n :host(:not(:focus)) :first-child { pointer-events: none !important; }\n }";break;case"core":t=".ML__container {\n min-height: auto !important;\n --_hue: var(--hue, 212);\n --_placeholder-color: var(--placeholder-color, hsl(var(--_hue), 40%, 49%));\n --_placeholder-opacity: var(--placeholder-opacity, 0.4);\n --_text-font-family: var(--text-font-family, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif);\n}\n.ML__sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n.ML__is-inline {\n display: inline-block;\n}\n.ML__base {\n visibility: inherit;\n display: inline-block;\n position: relative;\n cursor: text;\n padding: 0;\n margin: 0;\n box-sizing: content-box;\n border: 0;\n outline: 0;\n vertical-align: baseline;\n font-weight: inherit;\n font-family: inherit;\n font-style: inherit;\n text-decoration: none;\n width: min-content;\n}\n.ML__strut,\n.ML__strut--bottom {\n display: inline-block;\n min-height: 0.5em;\n}\n.ML__small-delim {\n font-family: KaTeX_Main;\n}\n/* Text mode */\n.ML__text {\n font-family: var(--_text-font-family);\n white-space: pre;\n}\n/* Use cmr for 'math upright' */\n.ML__cmr {\n font-family: KaTeX_Main;\n font-style: normal;\n}\n.ML__mathit {\n font-family: KaTeX_Math;\n /* The KaTeX_Math font is italic by default, so the font-style below is only \n useful when a fallback font is used\n */\n font-style: italic;\n}\n.ML__mathbf {\n font-family: KaTeX_Main;\n font-weight: bold;\n}\n/* Lowercase greek symbols should stick to math font when \\mathbf is applied \n to match TeX idiosyncratic behavior */\n.lcGreek.ML__mathbf {\n font-family: KaTeX_Math;\n font-weight: normal;\n}\n.ML__mathbfit {\n font-family: KaTeX_Math;\n font-weight: bold;\n font-style: italic;\n}\n.ML__ams {\n font-family: KaTeX_AMS;\n}\n/* Blackboard */\n.ML__bb {\n font-family: KaTeX_AMS;\n}\n.ML__cal {\n font-family: KaTeX_Caligraphic;\n}\n.ML__frak {\n font-family: KaTeX_Fraktur;\n}\n.ML__tt {\n font-family: KaTeX_Typewriter;\n}\n.ML__script {\n font-family: KaTeX_Script;\n}\n.ML__sans {\n font-family: KaTeX_SansSerif;\n}\n.ML__series_ul {\n font-weight: 100;\n}\n.ML__series_el {\n font-weight: 100;\n}\n.ML__series_l {\n font-weight: 200;\n}\n.ML__series_sl {\n font-weight: 300;\n}\n.ML__series_sb {\n font-weight: 500;\n}\n.ML__bold,\n.ML__boldsymbol {\n font-weight: 700;\n}\n.ML__series_eb {\n font-weight: 800;\n}\n.ML__series_ub {\n font-weight: 900;\n}\n.ML__series_uc {\n font-stretch: ultra-condensed;\n}\n.ML__series_ec {\n font-stretch: extra-condensed;\n}\n.ML__series_c {\n font-stretch: condensed;\n}\n.ML__series_sc {\n font-stretch: semi-condensed;\n}\n.ML__series_sx {\n font-stretch: semi-expanded;\n}\n.ML__series_x {\n font-stretch: expanded;\n}\n.ML__series_ex {\n font-stretch: extra-expanded;\n}\n.ML__series_ux {\n font-stretch: ultra-expanded;\n}\n.ML__it {\n font-style: italic;\n}\n.ML__shape_ol {\n -webkit-text-stroke: 1px black;\n text-stroke: 1px black;\n color: transparent;\n}\n.ML__shape_sc {\n font-variant: small-caps;\n}\n.ML__shape_sl {\n font-style: oblique;\n}\n/* First level emphasis */\n.ML__emph {\n color: #bc2612;\n}\n/* Second level emphasis */\n.ML__emph .ML__emph {\n color: #0c7f99;\n}\n.ML__highlight {\n color: #007cb2;\n background: #edd1b0;\n}\n.ML__center {\n text-align: center;\n}\n.ML__label_padding {\n padding: 0 0.5em;\n}\n.ML__frac-line {\n width: 100%;\n min-height: 1px;\n}\n.ML__frac-line:after {\n content: '';\n display: block;\n margin-top: max(-1px, -0.04em);\n min-height: max(1px, 0.04em);\n /* Ensure the line is visible when printing even if \"turn off background images\" is on*/\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n /* There's a bug since Chrome 62 where \n sub-pixel border lines don't draw at some zoom \n levels (110%, 90%). \n Setting the min-height used to work around it, but that workaround\n broke in Chrome 84 or so.\n Setting the background (and the min-height) seems to work for now.\n */\n background: currentColor;\n box-sizing: content-box;\n /* Vuetify sets the box-sizing to inherit \n causes the fraction line to not draw at all sizes (see #26) */\n /* On some versions of Firefox on Windows, the line fails to \n draw at some zoom levels, but setting the transform triggers\n the hardware accelerated path, which works */\n transform: translate(0, 0);\n}\n.ML__sqrt {\n display: inline-block;\n}\n.ML__sqrt-sign {\n display: inline-block;\n position: relative;\n}\n.ML__sqrt-line {\n display: inline-block;\n height: max(1px, 0.04em);\n width: 100%;\n}\n.ML__sqrt-line:before {\n content: '';\n display: block;\n margin-top: min(-1px, -0.04em);\n min-height: max(1px, 0.04em);\n /* Ensure the line is visible when printing even if \"turn off background images\" is on*/\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n background: currentColor;\n /* On some versions of Firefox on Windows, the line fails to \n draw at some zoom levels, but setting the transform triggers\n the hardware accelerated path, which works */\n transform: translate(0, 0);\n}\n.ML__sqrt-line:after {\n border-bottom-width: 1px;\n content: ' ';\n display: block;\n margin-top: -0.1em;\n}\n.ML__sqrt-index {\n margin-left: 0.27777778em;\n margin-right: -0.55555556em;\n}\n.ML__delim-size1 {\n font-family: KaTeX_Size1;\n}\n.ML__delim-size2 {\n font-family: KaTeX_Size2;\n}\n.ML__delim-size3 {\n font-family: KaTeX_Size3;\n}\n.ML__delim-size4 {\n font-family: KaTeX_Size4;\n}\n.ML__delim-mult .delim-size1 > span {\n font-family: KaTeX_Size1;\n}\n.ML__delim-mult .delim-size4 > span {\n font-family: KaTeX_Size4;\n}\n.ML__accent-body > span {\n font-family: KaTeX_Main;\n width: 0;\n}\n.ML__accent-vec {\n position: relative;\n left: 0.24em;\n}\n/** The markup for a LaTeX formula, either in an editable mathfield or \n in a static display.\n*/\n.ML__latex {\n display: inline-block;\n direction: ltr;\n text-align: left;\n text-indent: 0;\n text-rendering: auto;\n font-family: KaTeX_Main, 'Times New Roman', serif;\n font-style: normal;\n font-size-adjust: none;\n font-stretch: normal;\n font-variant-caps: normal;\n letter-spacing: normal;\n line-height: 1.2;\n word-wrap: normal;\n word-spacing: normal;\n white-space: nowrap;\n text-shadow: none;\n -webkit-user-select: none;\n user-select: none;\n width: min-content;\n}\n.ML__latex .style-wrap {\n position: relative;\n}\n.ML__latex .mfrac {\n display: inline-block;\n}\n.ML__latex .left-right {\n display: inline-block;\n}\n.ML__latex .vlist-t {\n display: inline-table;\n table-layout: fixed;\n border-collapse: collapse;\n}\n.ML__latex .vlist-r {\n display: table-row;\n}\n.ML__latex .vlist {\n display: table-cell;\n vertical-align: bottom;\n position: relative;\n}\n.ML__latex .vlist > span {\n display: block;\n height: 0;\n position: relative;\n}\n.ML__latex .vlist > span > span {\n display: inline-block;\n}\n.ML__latex .vlist > span > .pstrut {\n overflow: hidden;\n width: 0;\n}\n.ML__latex .vlist-t2 {\n margin-right: -2px;\n}\n.ML__latex .vlist-s {\n display: table-cell;\n vertical-align: bottom;\n font-size: 1px;\n width: 2px;\n min-width: 2px;\n}\n.ML__latex .msubsup {\n text-align: left;\n}\n.ML__latex .negativethinspace {\n display: inline-block;\n margin-left: -0.16667em;\n height: 0.71em;\n}\n.ML__latex .thinspace {\n display: inline-block;\n width: 0.16667em;\n height: 0.71em;\n}\n.ML__latex .mediumspace {\n display: inline-block;\n width: 0.22222em;\n height: 0.71em;\n}\n.ML__latex .thickspace {\n display: inline-block;\n width: 0.27778em;\n height: 0.71em;\n}\n.ML__latex .enspace {\n display: inline-block;\n width: 0.5em;\n height: 0.71em;\n}\n.ML__latex .quad {\n display: inline-block;\n width: 1em;\n height: 0.71em;\n}\n.ML__latex .qquad {\n display: inline-block;\n width: 2em;\n height: 0.71em;\n}\n.ML__latex .llap,\n.ML__latex .rlap {\n width: 0;\n position: relative;\n display: inline-block;\n}\n.ML__latex .llap > .inner,\n.ML__latex .rlap > .inner {\n position: absolute;\n}\n.ML__latex .llap > .fix,\n.ML__latex .rlap > .fix {\n display: inline-block;\n}\n.ML__latex .llap > .inner {\n right: 0;\n}\n.ML__latex .rlap > .inner {\n left: 0;\n}\n.ML__latex .rule {\n display: inline-block;\n border: solid 0;\n position: relative;\n box-sizing: border-box;\n}\n.ML__latex .overline .overline-line,\n.ML__latex .underline .underline-line {\n width: 100%;\n}\n.ML__latex .overline .overline-line:before,\n.ML__latex .underline .underline-line:before {\n content: '';\n border-bottom-style: solid;\n border-bottom-width: max(1px, 0.04em);\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n display: block;\n}\n.ML__latex .overline .overline-line:after,\n.ML__latex .underline .underline-line:after {\n border-bottom-style: solid;\n border-bottom-width: max(1px, 0.04em);\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n content: '';\n display: block;\n margin-top: -1px;\n}\n.ML__latex .stretchy {\n display: block;\n position: absolute;\n width: 100%;\n left: 0;\n overflow: hidden;\n}\n.ML__latex .stretchy:before,\n.ML__latex .stretchy:after {\n content: '';\n}\n.ML__latex .stretchy svg {\n display: block;\n position: absolute;\n width: 100%;\n height: inherit;\n fill: currentColor;\n stroke: currentColor;\n fill-rule: nonzero;\n fill-opacity: 1;\n stroke-width: 1;\n stroke-linecap: butt;\n stroke-linejoin: miter;\n stroke-miterlimit: 4;\n stroke-dasharray: none;\n stroke-dashoffset: 0;\n stroke-opacity: 1;\n}\n.ML__latex .slice-1-of-2 {\n display: inline-flex;\n position: absolute;\n left: 0;\n width: 50.2%;\n overflow: hidden;\n}\n.ML__latex .slice-2-of-2 {\n display: inline-flex;\n position: absolute;\n right: 0;\n width: 50.2%;\n overflow: hidden;\n}\n.ML__latex .slice-1-of-3 {\n display: inline-flex;\n position: absolute;\n left: 0;\n width: 25.1%;\n overflow: hidden;\n}\n.ML__latex .slice-2-of-3 {\n display: inline-flex;\n position: absolute;\n left: 25%;\n width: 50%;\n overflow: hidden;\n}\n.ML__latex .slice-3-of-3 {\n display: inline-flex;\n position: absolute;\n right: 0;\n width: 25.1%;\n overflow: hidden;\n}\n.ML__latex .slice-1-of-1 {\n display: inline-flex;\n position: absolute;\n width: 100%;\n left: 0;\n overflow: hidden;\n}\n.ML__latex .nulldelimiter {\n display: inline-block;\n}\n.ML__latex .op-group {\n display: inline-block;\n}\n.ML__latex .op-symbol {\n position: relative;\n}\n.ML__latex .op-symbol.small-op {\n font-family: KaTeX_Size1;\n}\n.ML__latex .op-symbol.large-op {\n font-family: KaTeX_Size2;\n}\n.ML__latex .mtable .vertical-separator {\n display: inline-block;\n min-width: 1px;\n box-sizing: border-box;\n}\n.ML__latex .mtable .arraycolsep {\n display: inline-block;\n}\n.ML__latex .mtable .col-align-m > .vlist-t {\n text-align: center;\n}\n.ML__latex .mtable .col-align-c > .vlist-t {\n text-align: center;\n}\n.ML__latex .mtable .col-align-l > .vlist-t {\n text-align: left;\n}\n.ML__latex .mtable .col-align-r > .vlist-t {\n text-align: right;\n}\n.ML__error {\n display: inline-block;\n background-image: radial-gradient(ellipse at center, hsl(341, 100%, 40%), rgba(0, 0, 0, 0) 70%);\n background-color: hsla(341, 100%, 40%, 0.1);\n background-repeat: repeat-x;\n background-size: 3px 3px;\n padding-bottom: 3px;\n background-position: 0 100%;\n}\n.ML__error > .ML__error {\n background: transparent;\n padding: 0;\n}\n.ML__placeholder {\n color: var(--_placeholder-color);\n opacity: var(--_placeholder-opacity);\n padding-left: 0.4ex;\n padding-right: 0.4ex;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n.ML__notation {\n position: absolute;\n box-sizing: border-box;\n line-height: 0;\n}\n/* This class is used to implement the `\\mathtip` and `\\texttip` commands\n For UI elements, see `[data-ML__tooltip]`\n*/\n.ML__tooltip-container {\n position: relative;\n transform: scale(0);\n}\n.ML__tooltip-container .ML__tooltip-content {\n position: fixed;\n display: inline-table;\n visibility: hidden;\n z-index: 2;\n width: max-content;\n max-width: 400px;\n padding: 12px 12px;\n border-radius: 8px;\n background: #616161;\n --_selection-color: #fff;\n color: #fff;\n box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);\n opacity: 0;\n transition: opacity 0.15s cubic-bezier(0.4, 0, 1, 1);\n}\n.ML__tooltip-container .ML__tooltip-content .ML__text {\n white-space: normal;\n}\n.ML__tooltip-container .ML__tooltip-content .ML__base {\n display: contents;\n}\n.ML__tooltip-container:hover .ML__tooltip-content {\n visibility: visible;\n opacity: 1;\n font-size: 0.75em;\n transform: scale(1) translate(0, 3em);\n}\n";break;case"mathfield":t="@keyframes ML__caret-blink {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n}\n.ML__container {\n display: inline-flex;\n flex-flow: row;\n justify-content: space-between;\n align-items: flex-end;\n min-height: 39px;\n /* Need some room for the virtual keyboard toggle */\n width: 100%;\n /* Encourage browsers to consider allocating a hardware accelerated\n layer for this element. */\n isolation: isolate;\n /* Prevent the browser from trying to interpret touch gestures in the field */\n /* \"Disabling double-tap to zoom removes the need for browsers to\n delay the generation of click events when the user taps the screen.\" */\n touch-action: none;\n --_caret-color: var(--caret-color, hsl(var(--_hue), 40%, 49%));\n --_selection-color: var(--selection-color, #000);\n --_selection-background-color: var(--selection-background-color, hsl(var(--_hue), 70%, 85%));\n --_text-highlight-background-color: var(--highlight-text, hsla(var(--_hue), 40%, 50%, 0.1));\n --_contains-highlight-background-color: var(--contains-highlight-background-color, hsl(var(--_hue), 40%, 95%));\n --_smart-fence-color: var(--smart-fence-color, currentColor);\n --_smart-fence-opacity: var(--smart-fence-opacity, 0.5);\n --_latex-color: var(--latex-color, hsl(var(--_hue), 80%, 40%));\n --_correct-color: var(--correct-color, #10a000);\n --_incorrect-color: var(--incorrect-color, #a01b00);\n --_composition-background-color: var(--composition-background-color, #fff1c2);\n --_composition-text-color: var(--composition-text-color, black);\n --_composition-underline-color: var(--composition-underline-color, transparent);\n}\n/* This is the actual field content (formula) */\n.ML__content {\n display: flex;\n align-items: center;\n align-self: center;\n position: relative;\n overflow: hidden;\n padding: 2px 3px 2px 1px;\n width: 100%;\n}\n.ML__virtual-keyboard-toggle,\n.ML__menu-toggle {\n box-sizing: border-box;\n display: flex;\n align-self: center;\n align-items: center;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: center;\n width: 34px;\n height: 34px;\n padding: 0;\n margin-right: 4px;\n cursor: pointer;\n /* Avoid some weird blinking with :hover */\n border-radius: 8px;\n border: 1px solid transparent;\n transition: background 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);\n color: hsl(var(--_hue), 40%, 50%);\n fill: currentColor;\n background: transparent;\n}\n.ML__virtual-keyboard-toggle:hover,\n.ML__menu-toggle:hover {\n background: hsla(0, 0%, 70%, 0.3);\n color: #333;\n fill: currentColor;\n}\n.ML__virtual-keyboard-toggle > span,\n.ML__menu-toggle > span {\n display: flex;\n align-self: center;\n align-items: center;\n}\n/* The invisible element used to capture keyboard events. We're just trying\n really hard to make sure it doesn't show. */\n.ML__keyboard-sink {\n display: inline-block;\n resize: none;\n outline: none;\n border: none;\n /* Need these for Microsoft Edge */\n position: fixed;\n clip: rect(0 0 0 0);\n /* Need this to prevent iOS Safari from auto-zooming */\n font-size: 1em;\n font-family: KaTeX_Main;\n line-height: 0.5;\n /* On Chromium, if this is 0, no keyboard events are received */\n}\n[part=\"placeholder\"] {\n color: var(--neutral-400);\n}\n.ML__composition {\n background: var(--_composition-background-color);\n color: var(--_composition-text-color);\n text-decoration: underline var(--_composition-underline-color);\n}\n.ML__caret::after {\n content: '';\n visibility: hidden;\n width: 0;\n display: inline-block;\n height: 0.76em;\n --_caret-width: clamp(2px, 0.08em, 10px);\n border: none;\n border-radius: calc(var(--_caret-width) / 2);\n border-right: var(--_caret-width) solid var(--_caret-color);\n margin-right: calc(-1 * var(--_caret-width));\n position: relative;\n left: -0.045em;\n bottom: -0.05em;\n animation: ML__caret-blink 1.05s step-end forwards infinite;\n}\n.ML__text-caret::after {\n content: '';\n visibility: hidden;\n width: 0;\n display: inline-block;\n height: 0.76em;\n --_caret-width: clamp(2px, 0.08em, 10px);\n border: none;\n border-radius: calc(var(--_caret-width) / 2);\n border-right: var(--_caret-width) solid var(--_caret-color);\n margin-right: calc(-1 * var(--_caret-width));\n position: relative;\n left: -0.045em;\n bottom: -0.05em;\n animation: ML__caret-blink 1.05s step-end forwards infinite;\n}\n.ML__latex-caret::after {\n content: '';\n visibility: hidden;\n --_caret-width: clamp(2px, 0.08em, 10px);\n border: none;\n border-radius: calc(var(--_caret-width) / 2);\n border-right: var(--_caret-width) solid var(--_latex-color);\n margin-right: calc(-1 * var(--_caret-width));\n position: relative;\n left: -0.019em;\n animation: ML__caret-blink 1.05s step-end forwards infinite;\n}\n.ML__focused .ML__latex-caret::after,\n.ML__focused .ML__text-caret::after,\n.ML__focused .ML__caret::after {\n visibility: visible;\n}\n.ML__focused .ML__text {\n background: var(--_text-highlight-background-color);\n}\n/* When using smartFence, the anticipated closing fence is displayed\nwith this style */\n.ML__smart-fence__close {\n opacity: var(--_smart-fence-opacity);\n color: var(--_smart-fence-color);\n}\n.ML__selected,\n.ML__focused .ML__selected .ML__contains-caret,\n.ML__focused .ML__selected .ML__smart-fence__close,\n.ML__focused .ML__selected .ML__placeholder {\n color: var(--_selection-color);\n opacity: 1;\n}\n.ML__selection {\n box-sizing: border-box;\n background: var(--_selection-background-color) !important;\n}\n.ML__contains-caret.ML__close,\n.ML__contains-caret.ML__open,\n.ML__contains-caret > .ML__close,\n.ML__contains-caret > .ML__open,\n.ML__contains-caret .ML__sqrt-sign,\n.ML__contains-caret .ML__sqrt-line {\n color: var(--_caret-color);\n}\n.ML__contains-highlight {\n box-sizing: border-box;\n background: transparent;\n}\n.ML__focused .ML__contains-highlight {\n background: var(--_contains-highlight-background-color);\n}\n.ML__raw-latex {\n font-family: 'Berkeley Mono', 'IBM Plex Mono', 'Source Code Pro', Consolas, 'Roboto Mono', Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace;\n font-weight: 400;\n font-size: 0.8em;\n letter-spacing: -0.05em;\n color: var(--_latex-color);\n}\n.ML__suggestion {\n color: var(--neutral-500);\n}\n.ML__virtual-keyboard-toggle.is-visible.is-pressed:hover {\n background: hsl(var(--_hue), 25%, 35%);\n color: #fafafa;\n fill: currentColor;\n}\n.ML__virtual-keyboard-toggle:focus {\n outline: none;\n border-radius: 8px;\n border: 2px solid hsl(var(--_hue), 40%, 50%);\n}\n.ML__virtual-keyboard-toggle.is-pressed,\n.ML__virtual-keyboard-toggle.is-active:hover,\n.ML__virtual-keyboard-toggle.is-active {\n background: hsl(var(--_hue), 25%, 35%);\n color: #fafafa;\n fill: currentColor;\n}\n/* Add an attribute 'data-tooltip' to automatically show a\n tooltip over a element on hover.\n*/\n[data-tooltip] {\n position: relative;\n}\n[data-tooltip]::after {\n content: attr(data-tooltip);\n position: absolute;\n display: block;\n z-index: 2;\n pointer-events: none;\n right: auto;\n top: calc(-100% - 4px);\n width: max-content;\n max-width: 200px;\n padding: 8px 8px;\n border-radius: 4px;\n background: #616161;\n color: #fff;\n box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);\n text-align: center;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-style: normal;\n font-weight: 400;\n font-size: 13px;\n /* Phone */\n opacity: 0;\n transform: scale(0.5);\n}\n@media only screen and (max-width: 767px) {\n [data-tooltip]::after {\n padding: 8px 16px;\n font-size: 16px;\n }\n}\nmenu [data-tooltip]::after {\n left: 100%;\n top: 0%;\n}\nmenu .ML__base {\n cursor: default;\n}\n/** Don't display if we're tracking, i.e. have the pointer down */\n.tracking [data-tooltip]:hover::after {\n /* Use visibility, not display. Display will remove the after from the DOM, and the override below will not work */\n visibility: hidden;\n}\n/** But do display if tracking and inside a menu */\n.tracking menu li[data-tooltip]:hover::after,\n[data-tooltip]:hover::after {\n visibility: visible;\n opacity: 1;\n transform: scale(1);\n transition-property: opacity, scale;\n transition-duration: 0.15s;\n transition-delay: 1s;\n transition-timing-function: cubic-bezier(0.4, 0, 1, 1);\n}\n.ML__prompt {\n border-radius: 2px;\n}\n.ML__editablePromptBox {\n outline: 1px solid #acacac;\n border-radius: 2px;\n z-index: -1;\n}\n.ML__focusedPromptBox {\n outline: highlight auto 1px;\n}\n.ML__lockedPromptBox {\n background-color: rgba(142, 142, 141, 0.4);\n z-index: -1;\n}\n.ML__correctPromptBox {\n outline: 1px solid var(--_correct-color);\n box-shadow: 0 0 5px var(--_correct-color);\n}\n.ML__incorrectPromptBox {\n outline: 1px solid var(--_incorrect-color);\n box-shadow: 0 0 5px var(--_incorrect-color);\n}\n.variant-submenu {\n display: flex;\n flex-direction: column;\n padding: 8px;\n}\n.variant-submenu [part=menu-item] {\n font-size: 2rem;\n text-align: center;\n margin: 0;\n}\n.insert-matrix-submenu {\n display: grid;\n padding: 8px;\n align-content: center;\n justify-content: center;\n grid-template-columns: repeat(5, minmax(0, 1fr));\n}\n.insert-matrix-submenu [part=menu-item] {\n font-size: 21px;\n border: none;\n border-radius: 0;\n line-height: 21px;\n text-align: center;\n padding: 0;\n margin: 0;\n}\n.border-submenu [part=menu-item] {\n font-size: 2rem;\n line-height: 1.2;\n text-align: center;\n}\n.swatches-submenu {\n --_swatch-size: 2rem;\n --_columns: 4;\n display: flex;\n flex-flow: wrap;\n padding: 8px;\n max-width: calc(var(--_columns) * (var(--_swatch-size) + 18px) + 16px);\n box-sizing: border-box;\n}\n.menu-swatch {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: fit-content;\n height: fit-content;\n margin: 2px;\n padding: 0;\n background: var(--neutral-200);\n}\n.menu-swatch > .label {\n padding: 0;\n margin: 0;\n line-height: 0;\n}\n.menu-swatch > .label > span {\n display: inline-block;\n margin: 6px;\n min-width: var(--_swatch-size);\n min-height: var(--_swatch-size);\n border-radius: 50%;\n}\n.menu-swatch.active {\n background: var(--neutral-100);\n scale: 1.4;\n}\n.menu-swatch.active > .label > span {\n border-radius: 2px;\n}\n.menu-swatch .ui-checkmark,\n.menu-swatch .ui-mixedmark {\n position: absolute;\n margin: 0;\n padding: 0;\n color: white;\n}\n.menu-swatch.dark-contrast .ui-checkmark,\n.menu-swatch.dark-contrast .ui-mixedmark {\n color: #000;\n}\n";break;case"environment-popover":t="#mathlive-environment-popover.is-visible {\n visibility: visible;\n}\n#mathlive-environment-popover {\n --_environment-panel-height: var(--environment-panel-height, 70px);\n --_accent-color: var(--accent-color, #aaa);\n --_background: var(--environment-panel-background, #fff);\n --_button-background: var(--environment-panel-button-background, white);\n --_button-background-hover: var(--environment-panel-button-background-hover, #f5f5f7);\n --_button-background-active: var(--environment-panel-button-background-active, #f5f5f7);\n --_button-text: var(--environment-panel-button-text, #e3e4e8);\n position: absolute;\n width: calc(var(--_environment-panel-height) * 2);\n height: var(--_environment-panel-height);\n border-radius: 4px;\n border: 1.5px solid var(--_accent-color);\n background-color: var(--_background);\n box-shadow: 0 0 30px 0 var(--environment-shadow, rgba(0, 0, 0, 0.4));\n pointer-events: all;\n visibility: hidden;\n}\n#mathlive-environment-popover .MLEP__array-buttons {\n height: calc(var(--_environment-panel-height) * 5/4);\n width: calc(var(--_environment-panel-height) * 5/4);\n margin-left: calc(0px - var(--_environment-panel-height) * 0.16);\n margin-top: calc(0px - var(--_environment-panel-height) * 0.19);\n}\n#mathlive-environment-popover .MLEP__array-buttons .font {\n fill: white;\n}\n#mathlive-environment-popover .MLEP__array-buttons circle {\n fill: #7f7f7f;\n transition: fill 300ms;\n}\n#mathlive-environment-popover .MLEP__array-buttons .MLEP__array-insert-background {\n fill-opacity: 1;\n fill: var(--_background);\n stroke: var(--_accent-color);\n stroke-width: 3px;\n}\n#mathlive-environment-popover .MLEP__array-buttons line {\n stroke: var(--_accent-color);\n stroke-opacity: 0;\n stroke-width: 40;\n pointer-events: none;\n transition: stroke-opacity 300ms;\n stroke-linecap: round;\n}\n#mathlive-environment-popover .MLEP__array-buttons g[data-command]:hover circle {\n fill: var(--_accent-color);\n}\n#mathlive-environment-popover .MLEP__array-buttons g[data-command]:hover line {\n stroke-opacity: 1;\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls {\n height: 100%;\n width: 50%;\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options {\n width: var(--_environment-panel-height);\n height: var(--_environment-panel-height);\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n justify-content: space-around;\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg {\n pointer-events: all;\n margin-top: 2px;\n width: calc(var(--_environment-panel-height) / 3 * 28 / 24);\n height: calc(var(--_environment-panel-height) / 3 - 2px);\n border-radius: calc(var(--_environment-panel-height) / 25);\n background-color: var(--_button-background);\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg:hover {\n background-color: var(--_button-background-hover);\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg path,\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg line {\n stroke: var(--_button-text);\n stroke-width: 2;\n stroke-linecap: round;\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg rect,\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg path {\n fill-opacity: 0;\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active {\n pointer-events: none;\n background-color: var(--_button-background-active);\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active path,\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active line {\n stroke: var(--_accent-color);\n}\n#mathlive-environment-popover .MLEP__environment-delimiter-controls .MLEP__array-delimiter-options svg.active circle {\n fill: var(--_accent-color);\n}\n";break;case"suggestion-popover":t="/* The element that display info while in latex mode */\n#mathlive-suggestion-popover {\n background-color: rgba(97, 97, 97);\n color: #fff;\n text-align: center;\n border-radius: 8px;\n position: fixed;\n z-index: 1;\n display: none;\n flex-direction: column;\n justify-content: center;\n box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);\n}\n#mathlive-suggestion-popover.top-tip::after {\n content: '';\n position: absolute;\n top: -15px;\n left: calc(50% - 15px);\n width: 0;\n height: 0;\n border-left: 15px solid transparent;\n border-right: 15px solid transparent;\n border-bottom: 15px solid rgba(97, 97, 97);\n font-size: 1rem;\n}\n#mathlive-suggestion-popover.bottom-tip::after {\n content: '';\n position: absolute;\n bottom: -15px;\n left: calc(50% - 15px);\n width: 0;\n height: 0;\n border-left: 15px solid transparent;\n border-right: 15px solid transparent;\n border-top: 15px solid rgba(97, 97, 97);\n font-size: 1rem;\n}\n#mathlive-suggestion-popover.is-animated {\n transition: all 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);\n animation: ML__fade-in cubic-bezier(0, 0, 0.2, 1) 0.15s;\n}\n#mathlive-suggestion-popover.is-visible {\n display: flex;\n}\n@keyframes ML__fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n/* The wrapper class for the entire content of the popover panel */\n#mathlive-suggestion-popover ul {\n display: flex;\n flex-flow: column;\n list-style: none;\n margin: 0;\n padding: 0;\n align-items: flex-start;\n max-height: 400px;\n overflow-y: auto;\n}\n#mathlive-suggestion-popover li {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n margin: 8px;\n padding: 8px;\n width: calc(100% - 16px - 16px);\n column-gap: 1em;\n border-radius: 8px;\n cursor: pointer;\n /* Since the content can be clicked on, provide feedback on hover */\n}\n#mathlive-suggestion-popover li a {\n color: #5ea6fd;\n padding-top: 0.3em;\n margin-top: 0.4em;\n display: block;\n}\n#mathlive-suggestion-popover li a:hover {\n color: #5ea6fd;\n text-decoration: underline;\n}\n#mathlive-suggestion-popover li:hover,\n#mathlive-suggestion-popover li.is-pressed,\n#mathlive-suggestion-popover li.is-active {\n background: rgba(255, 255, 255, 0.1);\n}\n/* The command inside a popover (inside a #mathlive-suggestion-popover) */\n.ML__popover__command {\n font-size: 1.6rem;\n font-family: KaTeX_Main;\n}\n.ML__popover__current {\n background: #5ea6fd;\n color: #fff;\n}\n.ML__popover__latex {\n font-family: 'IBM Plex Mono', 'Source Code Pro', Consolas, 'Roboto Mono', Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace;\n align-self: center;\n}\n/* The keyboard shortcuts for a symbol as displayed in the popover */\n.ML__popover__keybinding {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-size: 0.8em;\n opacity: 0.7;\n}\n/* Style for the character that joins the modifiers of a keyboard shortcut \n(usually a \"+\" sign)*/\n.ML__shortcut-join {\n opacity: 0.5;\n}\n";break;case"keystroke-caption":t="/* The element that displays the keys as the user type them */\n#mathlive-keystroke-caption-panel {\n visibility: hidden;\n /*min-width: 160px;*/\n /*background-color: rgba(97, 97, 200, .95);*/\n background: var(--secondary, hsl(var(--_hue), 19%, 26%));\n border-color: var(--secondary-border, hsl(0, 0%, 91%));\n box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);\n text-align: center;\n border-radius: 6px;\n padding: 16px;\n position: absolute;\n z-index: 1;\n display: flex;\n flex-direction: row-reverse;\n justify-content: center;\n --keystroke: white;\n --on-keystroke: #555;\n --keystroke-border: #f7f7f7;\n}\n@media (prefers-color-scheme: dark) {\n body:not([theme='light']) #mathlive-keystroke-caption-panel {\n --keystroke: hsl(var(--_hue), 50%, 30%);\n --on-keystroke: hsl(0, 0%, 98%);\n --keystroke-border: hsl(var(--_hue), 50%, 25%);\n }\n}\nbody[theme='dark'] #mathlive-keystroke-caption-panel {\n --keystroke: hsl(var(--_hue), 50%, 30%);\n --on-keystroke: hsl(0, 0%, 98%);\n --keystroke-border: hsl(var(--_hue), 50%, 25%);\n}\n#mathlive-keystroke-caption-panel > span {\n min-width: 14px;\n /*height: 8px;*/\n margin: 0 8px 0 0;\n padding: 4px;\n background-color: var(--keystroke);\n color: var(--on-keystroke);\n fill: currentColor;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-size: 1em;\n border-radius: 6px;\n border: 2px solid var(--keystroke-border);\n /*box-shadow: 0 7px 14px rgba(0,0,0,0.25), 0 5px 5px rgba(0,0,0,0.22);*/\n}\n";break;case"virtual-keyboard":t=".ML__keyboard {\n --_keyboard-height: 0;\n --_keyboard-zindex: var(--keyboard-zindex, 105);\n --_accent-color: var(--keyboard-accent-color, #0c75d8);\n --_background: var(--keyboard-background, #cacfd7);\n --_border: var(--keyboard-border, #ddd);\n --_padding-horizontal: var(--keyboard-padding-horizontal, 0px);\n --_padding-top: var(--keyboard-padding-top, 5px);\n --_padding-bottom: var(--keyboard-padding-bottom, 0px);\n --_row-padding-left: var(--keyboard-row-padding-left, 0px);\n --_row-padding-right: var(--keyboard-row-padding-right, 0px);\n --_toolbar-text: var(--keyboard-toolbar-text, #2c2e2f);\n --_toolbar-text-active: var(--keyboard-toolbar-text-active, var(--_accent-color));\n --_toolbar-background: var(--keyboard-toolbar-background, transparent);\n --_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #eee);\n --_toolbar-background-selected: var(--keyboard-toolbar-background-selected, transparent);\n --_toolbar-font-size: var(--keyboard-toolbar-font-size, '135%');\n --_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #fff);\n --_keycap-background: var(--keycap-background, white);\n --_keycap-background-hover: var(--keycap-background-hover, #f5f5f7);\n --_keycap-background-active: var(--keycap-background-active, var(--_accent-color));\n --_keycap-background-pressed: var(--keycap-background-pressed, var(--_accent-color));\n --_keycap-border: var(--keycap-border, #e5e6e9);\n --_keycap-border-bottom: var(--keycap-border-bottom, #8d8f92);\n --_keycap-text: var(--keycap-text, #000);\n --_keycap-text-active: var(--keycap-text-active, #fff);\n --_keycap-text-hover: var(--keycap-text-hover, var(--_keycap-text));\n --_keycap-text-pressed: var(--keycap-text-pressed, #fff);\n --_keycap-shift-text: var(--keycap-shift-text, var(--_accent-color));\n --_keycap-primary-background: var(--keycap-primary-background, var(--_accent-color));\n --_keycap-primary-text: var(--keycap-primary-text, #ddd);\n --_keycap-primary-background-hover: var(--keycap-primary-background-hover, #0d80f2);\n --_keycap-secondary-background: var(--keycap-secondary-background, #a0a9b8);\n --_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #7d8795);\n --_keycap-secondary-text: var(--keycap-secondary-text, #060707);\n --_keycap-secondary-border: var(--keycap-secondary-border, #c5c9d0);\n --_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, #989da6);\n --_keycap-height: var(--keycap-height, 60px);\n /* Keycap width (incl. margin) */\n --_keycap-max-width: var(--keycap-max-width, 100px);\n --_keycap-gap: var(--keycap-gap, 8px);\n --_keycap-font-size: var(--keycap-font-size, clamp(16px, 4cqw, 24px));\n --_keycap-small-font-size: var(--keycap-small-font-size, calc(var(--keycap-font-size) * 0.8));\n --_keycap-extra-small-font-size: var(--keycap-extra-small-font-size, calc(var(--keycap-font-size) / 1.42));\n --_variant-panel-background: var(--variant-panel-background, #fff);\n --_variant-keycap-text: var(--variant-keycap-text, var(--_keycap-text));\n --_variant-keycap-text-active: var(--variant-keycap-text-active, var(--_keycap-text-active));\n --_variant-keycap-background-active: var(--variant-keycap-background-active, var(--_accent-color));\n --_variant-keycap-length: var(--variant-keycap-length, 70px);\n --_variant-keycap-font-size: var(--variant-keycap-font-size, 30px);\n --_variant-keycap-aside-font-size: var(--variant-keycap-aside-font-size, 12px);\n --_keycap-shift-font-size: var(--keycap-shift-font-size, 16px);\n --_keycap-shift-color: var(--keycap-shift-color, var(--_accent-color));\n --_box-placeholder-color: var(--box-placeholder-color, var(--_accent-color));\n --_box-placeholder-pressed-color: var(--box-placeholder-pressed-color, var(--keycap-text-pressed));\n}\n.is-math-mode .MLK__rows .if-text-mode,\n.is-text-mode .MLK__rows .if-math-mode {\n display: none;\n}\n.if-can-undo,\n.if-can-redo,\n.if-can-copy,\n.if-can-cut,\n.if-can-paste {\n opacity: 0.4;\n pointer-events: none;\n}\n.can-undo .if-can-undo,\n.can-redo .if-can-redo,\n.can-copy .if-can-copy,\n.can-cut .if-can-cut,\n.can-paste .if-can-paste {\n opacity: 1;\n pointer-events: all;\n}\nbody > .ML__keyboard {\n position: fixed;\n --_padding-bottom: calc(var(--keyboard-padding-bottom, 0px) + env(safe-area-inset-bottom, 0));\n}\nbody > .ML__keyboard.is-visible > .MLK__backdrop {\n box-shadow: 0 -5px 6px rgba(0, 0, 0, 0.08);\n border-top: 1px solid var(--_border);\n}\nbody > .ML__keyboard.backdrop-is-transparent.is-visible > .MLK__backdrop {\n box-shadow: none;\n border: none;\n}\nbody > .ML__keyboard.is-visible.animate > .MLK__backdrop {\n transition: 0.28s cubic-bezier(0, 0, 0.2, 1);\n transition-property: transform, opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 1, 1);\n}\n.ML__keyboard {\n position: relative;\n overflow: hidden;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n z-index: var(--_keyboard-zindex);\n box-sizing: border-box;\n outline: none;\n border: none;\n margin: 0;\n padding: 0;\n line-height: 1;\n overflow-wrap: unset;\n text-align: left;\n vertical-align: baseline;\n cursor: auto;\n white-space: pre;\n box-shadow: none;\n opacity: 1;\n transform: none;\n pointer-events: none;\n}\n.ML__keyboard :where(div) {\n box-sizing: border-box;\n outline: none;\n border: none;\n margin: 0;\n padding: 0;\n line-height: 1;\n overflow-wrap: unset;\n text-align: left;\n vertical-align: baseline;\n cursor: auto;\n white-space: pre;\n box-shadow: none;\n transform: none;\n}\n.MLK__backdrop {\n position: absolute;\n bottom: calc(-1 * var(--_keyboard-height));\n width: 100%;\n height: var(--_keyboard-height);\n box-sizing: border-box;\n padding-top: var(--_padding-top);\n padding-bottom: var(--_padding-bottom);\n padding-left: var(--_padding-horizontal);\n padding-right: var(--_padding-horizontal);\n opacity: 0;\n visibility: hidden;\n transform: translate(0, 0);\n background: var(--_background);\n}\n.backdrop-is-transparent .MLK__backdrop {\n background: transparent;\n}\n/* If a custom layout has a custom container/backdrop\n (backdrop-is-transparent), make sure to let pointer event go through. */\n.backdrop-is-transparent .MLK__plate {\n background: transparent;\n pointer-events: none;\n}\n/* If a custom layout has a custom container/backdrop, make sure to \n allow pointer events on it. */\n.backdrop-is-transparent .MLK__layer > div > div {\n pointer-events: all;\n}\n.ML__keyboard.is-visible > .MLK__backdrop {\n transform: translate(0, calc(-1 * var(--_keyboard-height)));\n opacity: 1;\n visibility: visible;\n}\n.caps-lock-indicator {\n display: none;\n width: 8px;\n height: 8px;\n background: #0cbc0c;\n box-shadow: inset 0 0 4px 0 #13ca13, 0 0 4px 0 #a9ef48;\n border-radius: 8px;\n right: 8px;\n top: 8px;\n position: absolute;\n}\n.ML__keyboard.is-caps-lock .caps-lock-indicator {\n display: block;\n}\n.ML__keyboard.is-caps-lock .shift {\n background: var(--_keycap-background-active);\n color: var(--_keycap-text-active);\n}\n.MLK__plate {\n position: absolute;\n top: var(--_padding-top);\n left: var(--_padding-horizontal);\n width: calc(100% - 2 * var(--_padding-horizontal));\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n container-type: inline-size;\n touch-action: none;\n -webkit-user-select: none;\n user-select: none;\n pointer-events: all;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-size: 16px;\n /* Size of toolbar labels */\n font-weight: 400;\n text-shadow: none;\n}\n.ML__box-placeholder {\n color: var(--_box-placeholder-color);\n}\n.MLK__tex {\n font-family: KaTeX_Main, KaTeX_Math, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;\n}\n.MLK__tex-math {\n font-family: KaTeX_Math, KaTeX_Main, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;\n font-style: italic;\n}\n.MLK__layer {\n display: none;\n outline: none;\n}\n.MLK__layer.is-visible {\n display: flex;\n flex-flow: column;\n}\n/* Keyboard layouts are made or rows of keys... */\n.MLK__rows {\n --_keycap-width: min(var(--_keycap-max-width), 10cqw);\n display: flex;\n flex-flow: column;\n align-items: center;\n border-collapse: separate;\n clear: both;\n border: 0;\n margin: 0;\n margin-bottom: var(--_keycap-gap);\n gap: var(--_keycap-gap);\n /* If the styling include, e.g., some shadows, they will be\n cut off by the overflow. In that case, set the padding to \n compensate. */\n padding-left: var(--_row-padding-left);\n padding-right: var(--_row-padding-right);\n overflow: visible;\n touch-action: none;\n}\n.MLK__rows > .MLK__row {\n display: flex;\n flex-flow: row;\n justify-content: center;\n width: 100%;\n gap: var(--_keycap-gap);\n margin: 0;\n padding: 0;\n /* For the alignment of the text on some modifiers (e.g. shift) */\n /* Extra spacing between two adjacent keys */\n}\n.MLK__rows > .MLK__row .tex {\n font-family: KaTeX_Math, KaTeX_Main, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;\n}\n.MLK__rows > .MLK__row .tex-math {\n font-family: KaTeX_Math, 'Cambria Math', 'Asana Math', OpenSymbol, Symbola, STIX, Times, serif !important;\n}\n.MLK__rows > .MLK__row .big-op {\n font-size: calc(1.25 * var(--_keycap-font-size));\n}\n.MLK__rows > .MLK__row .small {\n font-size: var(--_keycap-small-font-size);\n}\n.MLK__rows > .MLK__row .bottom {\n justify-content: flex-end;\n}\n.MLK__rows > .MLK__row .left {\n align-items: flex-start;\n padding-left: 12px;\n}\n.MLK__rows > .MLK__row .right {\n align-items: flex-end;\n padding-right: 12px;\n}\n.MLK__rows > .MLK__row .w0 {\n width: 0;\n}\n.MLK__rows > .MLK__row .w5 {\n width: calc(0.5 * var(--_keycap-width) - var(--_keycap-gap));\n}\n.MLK__rows > .MLK__row .w15 {\n width: calc(1.5 * var(--_keycap-width) - var(--_keycap-gap));\n}\n.MLK__rows > .MLK__row .w20 {\n width: calc(2 * var(--_keycap-width) - var(--_keycap-gap));\n}\n.MLK__rows > .MLK__row .w40 {\n width: calc(4 * var(--_keycap-width) - var(--_keycap-gap));\n}\n.MLK__rows > .MLK__row .w50 {\n width: calc(5 * var(--_keycap-width) - var(--_keycap-gap));\n}\n.MLK__rows > .MLK__row .MLK__keycap.w50 {\n font-size: 80%;\n padding-top: 10px;\n font-weight: 100;\n}\n.MLK__rows > .MLK__row .separator {\n background: transparent;\n border: none;\n pointer-events: none;\n}\n.MLK__rows > .MLK__row .horizontal-rule {\n height: 6px;\n margin-top: 3px;\n margin-bottom: 0;\n width: 100%;\n border-radius: 0;\n border-top: var(--_horizontal-rule);\n}\n.MLK__rows > .MLK__row .ghost {\n background: var(--_toolbar-background);\n border: none;\n color: var(--_toolbar-text);\n}\n.MLK__rows > .MLK__row .ghost:hover {\n background: var(--_toolbar-background-hover);\n}\n.MLK__rows > .MLK__row .bigfnbutton {\n font-size: var(--_keycap-extra-small-font-size);\n}\n.MLK__rows > .MLK__row .shift,\n.MLK__rows > .MLK__row .action {\n color: var(--_keycap-secondary-text);\n background: var(--_keycap-secondary-background);\n border-color: var(--_keycap-secondary-border);\n border-bottom-color: var(--_keycap-secondary-border-bottom);\n line-height: 0.8;\n font-size: min(1rem, var(--_keycap-small-font-size));\n font-weight: 600;\n padding: 8px 12px 8px 12px;\n}\n.MLK__rows > .MLK__row .shift:hover,\n.MLK__rows > .MLK__row .action:hover {\n background: var(--_keycap-secondary-background-hover);\n}\n.MLK__rows > .MLK__row .action.primary {\n background: var(--_keycap-primary-background);\n color: var(--_keycap-primary-text);\n}\n.MLK__rows > .MLK__row .action.primary:hover {\n background: var(--_keycap-primary-background-hover);\n color: var(--_keycap-primary-text);\n}\n.MLK__rows > .MLK__row .shift.selected,\n.MLK__rows > .MLK__row .action.selected {\n color: var(--_toolbar-text-active);\n}\n.MLK__rows > .MLK__row .shift.selected.is-pressed,\n.MLK__rows > .MLK__row .action.selected.is-pressed,\n.MLK__rows > .MLK__row .shift.selected.is-active,\n.MLK__rows > .MLK__row .action.selected.is-active {\n color: white;\n}\n.MLK__rows > .MLK__row .warning {\n background: #cd0030;\n color: white;\n}\n.MLK__rows > .MLK__row .warning svg.svg-glyph {\n width: 24px;\n height: 24px;\n min-height: 24px;\n}\n/** A regular keycap\n * Use the :where() pseudo-class to give it a very low specifity, \n * so that it can be overriden by custom style.\n */\n:where(.MLK__rows > .MLK__row div) {\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: space-evenly;\n width: calc(var(--_keycap-width) - var(--_keycap-gap));\n height: var(--_keycap-height);\n box-sizing: border-box;\n padding: 0;\n vertical-align: top;\n text-align: center;\n float: left;\n color: var(--_keycap-text);\n fill: currentColor;\n font-size: var(--_keycap-font-size);\n background: var(--_keycap-background);\n border: 1px solid var(--_keycap-border);\n border-bottom-color: var(--_keycap-border-bottom);\n border-radius: 6px;\n cursor: pointer;\n touch-action: none;\n /* Keys with a variants panel */\n position: relative;\n overflow: hidden;\n -webkit-user-select: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n:where(.MLK__rows > .MLK__row div):hover {\n overflow: visible;\n background: var(--_keycap-background-hover);\n}\n:where(.MLK__rows > .MLK__row div) .ML__latex {\n pointer-events: none;\n touch-action: none;\n}\n:where(.MLK__rows > .MLK__row div) svg.svg-glyph {\n margin: 8px 0;\n width: 20px;\n height: 20px;\n min-height: 20px;\n}\n:where(.MLK__rows > .MLK__row div) svg.svg-glyph-lg {\n margin: 8px 0;\n width: 24px;\n height: 24px;\n min-height: 24px;\n}\n:where(.MLK__rows > .MLK__row div).MLK__tex-math {\n font-size: 25px;\n}\n:where(.MLK__rows > .MLK__row div).is-pressed {\n background: var(--_keycap-background-pressed);\n color: var(--_keycap-text-pressed);\n --_box-placeholder-color: var(--_box-placeholder-pressed-color);\n}\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active,\n:where(.MLK__rows > .MLK__row div).action.is-active,\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed,\n:where(.MLK__rows > .MLK__row div).action.is-pressed {\n z-index: calc(var(--_keyboard-zindex) - 5);\n}\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active aside,\n:where(.MLK__rows > .MLK__row div).action.is-active aside,\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed aside,\n:where(.MLK__rows > .MLK__row div).action.is-pressed aside {\n display: none;\n}\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active .MLK__shift,\n:where(.MLK__rows > .MLK__row div).action.is-active .MLK__shift,\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed .MLK__shift,\n:where(.MLK__rows > .MLK__row div).action.is-pressed .MLK__shift {\n display: none;\n}\n:where(.MLK__rows > .MLK__row div).shift.is-pressed,\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-pressed,\n:where(.MLK__rows > .MLK__row div).action.is-pressed {\n background: var(--_keycap-background-pressed);\n color: var(--_keycap-text-pressed);\n}\n:where(.MLK__rows > .MLK__row div).shift.is-active,\n:where(.MLK__rows > .MLK__row div).MLK__keycap.is-active,\n:where(.MLK__rows > .MLK__row div).action.is-active {\n background: var(--_keycap-background-active);\n color: var(--_keycap-text-active);\n --_box-placeholder-color: var(--_box-placeholder-pressed-color);\n}\n:where(.MLK__rows > .MLK__row div) small {\n color: var(--_keycap-secondary-text);\n}\n:where(.MLK__rows > .MLK__row div) aside {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-size: 10px;\n line-height: 10px;\n color: var(--_keycap-secondary-text);\n}\n/* Add an attribute 'data-tooltip' to display a tooltip on hover.\nNote there are a different set of tooltip rules for the keyboard toggle\n(it's in a different CSS tree) */\n.ML__keyboard [data-tooltip] {\n position: relative;\n}\n.ML__keyboard [data-tooltip]::after {\n position: absolute;\n display: inline-table;\n content: attr(data-tooltip);\n top: inherit;\n bottom: 100%;\n width: max-content;\n max-width: 200px;\n padding: 8px 8px;\n background: #616161;\n color: #fff;\n text-align: center;\n z-index: 2;\n box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);\n border-radius: 2px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n font-weight: 400;\n font-size: 12px;\n transition: all 0.15s cubic-bezier(0.4, 0, 1, 1) 1s;\n opacity: 0;\n transform: scale(0.5);\n}\n.ML__keyboard [data-tooltip]:hover {\n position: relative;\n}\n.ML__keyboard [data-tooltip]:hover::after {\n opacity: 1;\n transform: scale(1);\n}\n.MLK__toolbar {\n align-self: center;\n display: flex;\n flex-flow: row;\n justify-content: space-between;\n width: 100%;\n max-width: 996px;\n min-height: 32px;\n /* Icons for undo/redo, etc. */\n}\n.MLK__toolbar svg {\n height: 20px;\n width: 20px;\n}\n.MLK__toolbar > .left {\n position: relative;\n display: flex;\n justify-content: flex-start;\n flex-flow: row;\n}\n.MLK__toolbar > .right {\n display: flex;\n justify-content: flex-end;\n flex-flow: row;\n}\n.MLK__toolbar > div > div {\n /* \"button\" in the toolbar */\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--_toolbar-text);\n fill: currentColor;\n background: var(--_toolbar-background);\n font-size: var(--_toolbar-font-size);\n padding: 4px 15px;\n cursor: pointer;\n width: max-content;\n min-width: 42px;\n min-height: 34px;\n border: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-bottom: 8px;\n padding-top: 8px;\n margin-top: 0;\n margin-bottom: 4px;\n margin-left: 4px;\n margin-right: 4px;\n border-radius: 8px;\n box-shadow: none;\n border-bottom: 2px solid transparent;\n}\n.MLK__toolbar > div > div:not(.disabled):not(.selected):hover {\n background: var(--_toolbar-background-hover);\n}\n.MLK__toolbar > div > div.disabled svg,\n.MLK__toolbar > div > div.disabled:hover svg,\n.MLK__toolbar > div > div.disabled.is-pressed svg {\n color: var(--_toolbar-text);\n opacity: 0.2;\n}\n.MLK__toolbar > div > div:hover,\n.MLK__toolbar > div > div:active,\n.MLK__toolbar > div > div.is-pressed,\n.MLK__toolbar > div > div.is-active {\n color: var(--_toolbar-text-active);\n}\n.MLK__toolbar > div > div.selected {\n color: var(--_toolbar-text-active);\n background: var(--_toolbar-background-selected);\n border-radius: 0;\n border-bottom-color: var(--_toolbar-text-active);\n padding-bottom: 4px;\n margin-bottom: 8px;\n}\n/* This is the element that displays variants on press+hold */\n.MLK__variant-panel {\n visibility: hidden;\n position: fixed;\n display: flex;\n flex-flow: row wrap-reverse;\n justify-content: center;\n align-content: center;\n margin: 0;\n padding: 0;\n bottom: auto;\n top: 0;\n box-sizing: content-box;\n transform: none;\n z-index: calc(var(--_keyboard-zindex) + 1);\n touch-action: none;\n max-width: 350px;\n background: var(--_variant-panel-background);\n text-align: center;\n border-radius: 6px;\n padding: 6px;\n box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);\n transition: none;\n}\n.MLK__variant-panel.is-visible {\n visibility: visible;\n}\n.MLK__variant-panel.compact {\n --_variant-keycap-length: var(--variant-keycap-length, 50px);\n --_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);\n --_variant-keycap-aside-font-size: var(--variant-keycap-aside-font-size, 10px);\n}\n.MLK__variant-panel .item {\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: center;\n font-size: var(--_variant-keycap-font-size);\n height: var(--_variant-keycap-length);\n width: var(--_variant-keycap-length);\n margin: 0;\n box-sizing: border-box;\n border-radius: 5px;\n border: 1px solid transparent;\n background: transparent;\n pointer-events: all;\n cursor: pointer;\n color: var(--_variant-keycap-text);\n fill: currentColor;\n}\n@media (max-height: 412px) {\n .MLK__variant-panel .item {\n --_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);\n --_variant-keycap-length: var(--variant-keycap-length, 50px);\n }\n}\n.MLK__variant-panel .item .ML__latex {\n pointer-events: none;\n}\n.MLK__variant-panel .item.is-active {\n background: var(--_variant-keycap-background-active);\n color: var(--_variant-keycap-text-active);\n}\n.MLK__variant-panel .item.is-pressed {\n background: var(--_variant-keycap-background-pressed);\n color: var(--_variant-keycap-text-pressed);\n}\n.MLK__variant-panel .item.small {\n font-size: var(--_keycap-small-font-size);\n}\n.MLK__variant-panel .item.swatch-button {\n box-sizing: border-box;\n background: #fbfbfb;\n}\n.MLK__variant-panel .item.swatch-button > span {\n display: inline-block;\n margin: 6px;\n width: calc(100% - 12px);\n height: calc(100% - 12px);\n border-radius: 50%;\n}\n.MLK__variant-panel .item.swatch-button:hover {\n background: #f0f0f0;\n}\n.MLK__variant-panel .item.swatch-button:hover > span {\n border-radius: 2px;\n}\n.MLK__variant-panel .item.box > div,\n.MLK__variant-panel .item.box > span {\n border: 1px dashed rgba(0, 0, 0, 0.24);\n}\n.MLK__variant-panel .item .warning {\n min-height: 60px;\n min-width: 60px;\n background: #cd0030;\n color: white;\n padding: 5px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 5px;\n}\n.MLK__variant-panel .item .warning.is-pressed,\n.MLK__variant-panel .item .warning.is-active {\n background: red;\n}\n.MLK__variant-panel .item .warning svg.svg-glyph {\n width: 50px;\n height: 50px;\n}\n.MLK__variant-panel .item aside {\n font-size: var(--_variant-keycap-aside-font-size);\n line-height: 12px;\n opacity: 0.78;\n padding-top: 2px;\n}\n.MLK__keycap {\n position: relative;\n}\n.MLK__shift {\n display: block;\n position: absolute;\n right: 4px;\n top: 4px;\n font-size: var(--_keycap-shift-font-size);\n color: var(--_keycap-shift-color);\n}\n.hide-shift .MLK__shift {\n display: none;\n}\n@media (max-width: 414px) {\n .MLK__variant-panel {\n max-width: 350px;\n --_variant-keycap-font-size: var(--variant-keycap-font-size, 24px);\n --_variant-keycap-length: var(--variant-keycap-length, 50px);\n }\n}\n/* @xs breakpoint: iPhone 5 */\n@container (max-width: 414px) {\n .MLK__rows {\n --_keycap-gap: max(var(--_keycap-gap, 2px), 2px);\n --_keycap-height: max(var(--_keycap-height), 42px);\n --_keycap-width: min(min(var(--_keycap-max-width), 10cqw), 62px);\n }\n .MLK__toolbar > div > div {\n font-size: 100%;\n margin-left: 2px;\n margin-right: 2px;\n }\n .MLK__rows .shift,\n .MLK__rows .action {\n font-size: 65%;\n }\n .MLK__rows .warning svg.svg-glyph {\n width: 14px;\n height: 14px;\n min-height: 14px;\n }\n}\n@container (max-width: 744px) {\n .MLK__rows {\n --_keycap-gap: max(var(--keycap-gap, 2px), 2px);\n --_keycap-height: max(var(--keycap-height, 52px), 52px);\n --_keycap-width: min(min(var(--_keycap-max-width), 10cqw), 62px);\n }\n .MLK__toolbar > div > div {\n padding-left: 0;\n padding-right: 0;\n }\n .MLK__tooltip::after {\n padding: 8px 16px;\n font-size: 16px;\n }\n .MLK__rows > .MLK__row > div.fnbutton {\n font-size: 16px;\n }\n .MLK__rows > .MLK__row > div.bigfnbutton {\n font-size: calc(var(--_keycap-extra-small-font-size) / 1.55);\n }\n .MLK__rows > .MLK__row > div.small {\n font-size: 13px;\n }\n .MLK__rows > .MLK__row > div > aside {\n display: none;\n }\n .MLK__shift {\n display: none;\n }\n}\n/* Medium breakpoint: larger phones */\n@container (max-width: 768px) {\n .MLK__rows {\n --_keycap-height: max(var(--keycap-height, 42px), 42px);\n }\n .MLK__rows > .MLK__row > div > small {\n font-size: 14px;\n }\n}\n@media (max-height: 768px) {\n .MLK__rows {\n --_keycap-height: max(var(--keycap-height, 42px), 42px);\n }\n .MLK__rows > .MLK__row > div > small {\n font-size: 14px;\n }\n}\n@container (max-width: 1444px) {\n .MLK__rows .if-wide {\n display: none;\n }\n}\n@media (prefers-color-scheme: dark) {\n .ML__keyboard {\n --_accent-color: var(--keyboard-accent-color, #0b5c9c);\n --_background: var(--keyboard-background, #151515);\n --_border: var(--keyboard-border, transparent);\n --_toolbar-text: var(--keyboard-toolbar-text, #e3e4e8);\n --_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #303030);\n --keyboard-toolbar-background-hover: #303030;\n --_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #303030);\n --_keycap-background: var(--keycap-background, #1f2022);\n --_keycap-background-hover: var(--keycap-background-hover, #2f3032);\n --_keycap-border: var(--_keycap-border, transparent);\n --_keycap-border-bottom: var(--_keycap-border-bottom, transparent);\n --_keycap-text: var(--keycap-text, #e3e4e8);\n --_keycap-secondary-background: var(--keycap-secondary-background, #3d4144);\n --_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #4d5154);\n --_keycap-secondary-text: var(--keycap-secondary-text, #e7ebee);\n --keycap-secondary-border: transparent;\n --keycap-secondary-border-bottom: transparent;\n --_keycap-secondary-border: var(--keycap-secondary-border, transparent);\n --_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, transparent);\n --_variant-panel-background: var(--variant-panel-background, #303030);\n --_variant-keycap-text-active: var(--variant-keycap-text-active, #fff);\n }\n}\n/* Same as the media query, but with a class */\n[theme='dark'] .ML__keyboard {\n --_accent-color: var(--keyboard-accent-color, #0b5c9c);\n --_background: var(--keyboard-background, #151515);\n --_border: var(--keyboard-border, transparent);\n --_toolbar-text: var(--keyboard-toolbar-text, #e3e4e8);\n --_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #303030);\n --keyboard-toolbar-background-hover: #303030;\n --_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #303030);\n --_keycap-background: var(--keycap-background, #1f2022);\n --_keycap-background-hover: var(--keycap-background-hover, #2f3032);\n --_keycap-border: var(--_keycap-border, transparent);\n --_keycap-border-bottom: var(--_keycap-border-bottom, transparent);\n --_keycap-text: var(--keycap-text, #e3e4e8);\n --_keycap-secondary-background: var(--keycap-secondary-background, #3d4144);\n --_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #4d5154);\n --_keycap-secondary-text: var(--keycap-secondary-text, #e7ebee);\n --keycap-secondary-border: transparent;\n --keycap-secondary-border-bottom: transparent;\n --_keycap-secondary-border: var(--keycap-secondary-border, transparent);\n --_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, transparent);\n --_variant-panel-background: var(--variant-panel-background, #303030);\n --_variant-keycap-text-active: var(--variant-keycap-text-active, #fff);\n}\n[theme='light'] .ML__keyboard {\n --_accent-color: var(--keyboard-accent-color, #0c75d8);\n --_background: var(--keyboard-background, #cacfd7);\n --_border: var(--keyboard-border, #ddd);\n --_toolbar-text: var(--keyboard-toolbar-text, #2c2e2f);\n --_toolbar-background: var(--keyboard-toolbar-background, transparent);\n --_toolbar-background-hover: var(--keyboard-toolbar-background-hover, #eee);\n --_toolbar-background-selected: var(--keyboard-toolbar-background-selected, transparent);\n --_horizontal-rule: var(--keyboard-horizontal-rule, 1px solid #fff);\n --_keycap-background: var(--keycap-background, white);\n --_keycap-background-hover: var(--keycap-background-hover, #f5f5f7);\n --_keycap-background-active: var(--keycap-background-active, var(--_accent-color));\n --_keycap-background-pressed: var(--keycap-background-pressed, var(--_accent-color));\n --_keycap-border: var(--_keycap-border, #e5e6e9);\n --_keycap-border-bottom: var(--_keycap-border-bottom, #8d8f92);\n --_keycap-text: var(--keycap-text, #000);\n --_keycap-text-active: var(--keycap-text-active, #fff);\n --_keycap-text-hover: var(--keycap-text-hover, var(--_keycap-text));\n --_keycap-text-pressed: var(--keycap-text-pressed, #fff);\n --_keycap-shift-text: var(--keycap-shift-text, var(--_accent-color));\n --_keycap-secondary-background: var(--keycap-secondary-background, #a0a9b8);\n --_keycap-secondary-background-hover: var(--keycap-secondary-background-hover, #7d8795);\n --_keycap-secondary-text: var(--keycap-secondary-text, #060707);\n --_keycap-secondary-border: var(--keycap-secondary-border, #c5c9d0);\n --_keycap-secondary-border-bottom: var(--keycap-secondary-border-bottom, #989da6);\n --_variant-panel-background: var(--variant-panel-background, #fff);\n --_variant-keycap-text: var(--variant-keycap-textvar, var(--_keycap-text));\n --_variant-keycap-text-active: var(--variant-keycap-text-active, var(--_keycap-text-active));\n --_variant-keycap-background-active: var(--variant-keycap-background-active, var(--_accent-color));\n}\n";break;case"ui":t=":host {\n --primary-color: #5898ff;\n --primary-color-dimmed: #c0c0f0;\n --primary-color-dark: var(--blue-500);\n --primary-color-light: var(--blue-100);\n --primary-color-reverse: #ffffff;\n --secondary-color: #ff8a65;\n --secondary-color-dimmed: #f0d5c5;\n --secondary-color-dark: var(--orange-500);\n --secondary-color-light: var(--orange-100);\n --secondary-color-reverse: #ffffff;\n --link-color: #5898ff;\n --link-color-dimmed: #c5c5c5;\n --link-color-dark: #121212;\n --link-color-light: #e2e2e2;\n --link-color-reverse: #ffffff;\n --semantic-blue: var(--blue-700);\n --semantic-red: var(--red-400);\n --semantic-orange: var(--orange-400);\n --semantic-green: var(--green-700);\n --neutral-100: #f5f5f5;\n --neutral-200: #eeeeee;\n --neutral-300: #e0e0e0;\n --neutral-400: #bdbdbd;\n --neutral-500: #9e9e9e;\n --neutral-600: #757575;\n --neutral-700: #616161;\n --neutral-800: #424242;\n --neutral-900: #212121;\n --red-25: #fff8f7;\n --red-50: #fff1ef;\n --red-100: #ffeae6;\n --red-200: #ffcac1;\n --red-300: #ffa495;\n --red-400: #ff7865;\n --red-500: #f21c0d;\n --red-600: #e50018;\n --red-700: #d30024;\n --red-800: #bd002c;\n --red-900: #a1002f;\n --orange-25: #fffbf8;\n --orange-50: #fff7f1;\n --orange-100: #fff3ea;\n --orange-200: #ffe1c9;\n --orange-300: #ffcca2;\n --orange-400: #ffb677;\n --orange-500: #fe9310;\n --orange-600: #f58700;\n --orange-700: #ea7c00;\n --orange-800: #dc6d00;\n --orange-900: #ca5b00;\n --brown-25: #fff8ef;\n --brown-50: #fff1df;\n --brown-100: #ffe9ce;\n --brown-200: #ebcca6;\n --brown-300: #cdaf8a;\n --brown-400: #af936f;\n --brown-500: #856a47;\n --brown-600: #7f5e34;\n --brown-700: #78511f;\n --brown-800: #6e4200;\n --brown-900: #593200;\n --yellow-25: #fffdf9;\n --yellow-50: #fffcf2;\n --yellow-100: #fffaec;\n --yellow-200: #fff2ce;\n --yellow-300: #ffe8ab;\n --yellow-400: #ffdf85;\n --yellow-500: #ffcf33;\n --yellow-600: #f1c000;\n --yellow-700: #dfb200;\n --yellow-800: #c9a000;\n --yellow-900: #ad8a00;\n --lime-25: #f4ffee;\n --lime-50: #e9ffdd;\n --lime-100: #ddffca;\n --lime-200: #a8fb6f;\n --lime-300: #94e659;\n --lime-400: #80d142;\n --lime-500: #63b215;\n --lime-600: #45a000;\n --lime-700: #268e00;\n --lime-800: #007417;\n --lime-900: #005321;\n --green-25: #f5fff5;\n --green-50: #ebffea;\n --green-100: #e0ffdf;\n --green-200: #a7ffa7;\n --green-300: #5afa65;\n --green-400: #45e953;\n --green-500: #17cf36;\n --green-600: #00b944;\n --green-700: #00a34a;\n --green-800: #008749;\n --green-900: #00653e;\n --teal-25: #f3ffff;\n --teal-50: #e6fffe;\n --teal-100: #d9fffe;\n --teal-200: #8dfffe;\n --teal-300: #57f4f4;\n --teal-400: #43e5e5;\n --teal-500: #17cfcf;\n --teal-600: #00c2c0;\n --teal-700: #00b5b1;\n --teal-800: #00a49e;\n --teal-900: #009087;\n --cyan-25: #f7fcff;\n --cyan-50: #eff8ff;\n --cyan-100: #e7f5ff;\n --cyan-200: #c2e6ff;\n --cyan-300: #95d5ff;\n --cyan-400: #61c4ff;\n --cyan-500: #13a7ec;\n --cyan-600: #069eda;\n --cyan-700: #0095c9;\n --cyan-800: #0088b2;\n --cyan-900: #0a7897;\n --blue-25: #f7faff;\n --blue-50: #eef5ff;\n --blue-100: #e5f1ff;\n --blue-200: #bfdbff;\n --blue-300: #92c2ff;\n --blue-400: #63a8ff;\n --blue-500: #0d80f2;\n --blue-600: #0077db;\n --blue-700: #006dc4;\n --blue-800: #0060a7;\n --blue-900: #005086;\n --indigo-25: #f8f7ff;\n --indigo-50: #f1efff;\n --indigo-100: #eae7ff;\n --indigo-200: #ccc3ff;\n --indigo-300: #ac99ff;\n --indigo-400: #916aff;\n --indigo-500: #63c;\n --indigo-600: #5a21b2;\n --indigo-700: #4e0b99;\n --indigo-800: #3b0071;\n --indigo-900: #220040;\n --purple-25: #fbf7ff;\n --purple-50: #f8f0ff;\n --purple-100: #f4e8ff;\n --purple-200: #e4c4ff;\n --purple-300: #d49aff;\n --purple-400: #c36aff;\n --purple-500: #a219e6;\n --purple-600: #9000c4;\n --purple-700: #7c009f;\n --purple-800: #600073;\n --purple-900: #3d0043;\n --magenta-25: #fff8fb;\n --magenta-50: #fff2f6;\n --magenta-100: #ffebf2;\n --magenta-200: #ffcddf;\n --magenta-300: #ffa8cb;\n --magenta-400: #ff7fb7;\n --magenta-500: #eb4799;\n --magenta-600: #da3689;\n --magenta-700: #c82179;\n --magenta-800: #b00065;\n --magenta-900: #8a004c;\n}\n@media (prefers-color-scheme: dark) {\n :host {\n --semantic-blue: var(--blue-700);\n --semantic-red: var(--red-400);\n --semantic-orange: var(--orange-400);\n --semantic-green: var(--green-700);\n --semantic-bg-blue: var(--blue-25);\n --semantic-bg-red: var(--red-25);\n --semantic-bg-orange: var(--orange-25);\n --semantic-bg-green: var(--green-25);\n --neutral-100: #121212;\n --neutral-200: #424242;\n --neutral-300: #616161;\n --neutral-400: #757575;\n --neutral-500: #9e9e9e;\n --neutral-600: #bdbdbd;\n --neutral-700: #e0e0e0;\n --neutral-800: #eeeeee;\n --neutral-900: #f5f5f5;\n }\n}\n:host([theme='dark']) {\n --semantic-blue: var(--blue-700);\n --semantic-red: var(--red-400);\n --semantic-orange: var(--orange-400);\n --semantic-green: var(--green-700);\n --semantic-bg-blue: var(--blue-25);\n --semantic-bg-red: var(--red-25);\n --semantic-bg-orange: var(--orange-25);\n --semantic-bg-green: var(--green-25);\n --neutral-100: #121212;\n --neutral-200: #424242;\n --neutral-300: #616161;\n --neutral-400: #757575;\n --neutral-500: #9e9e9e;\n --neutral-600: #bdbdbd;\n --neutral-700: #e0e0e0;\n --neutral-800: #eeeeee;\n --neutral-900: #f5f5f5;\n}\n/* @media (prefers-color-scheme: dark) {\n :host {\n --label-color: #fff;\n --active-label-color: #000;\n --menu-bg: #525252;\n --active-bg: #5898ff;\n --active-bg-dimmed: #5c5c5c;\n }\n} */\n:host {\n --ui-font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,\n 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji',\n 'Segoe UI Emoji', 'Segoe UI Symbol';\n --ui-font-size: 14px;\n --ui-line-height: 1.5;\n --ui-letter-spacing: 0.007em;\n --mono-font-family: 'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono',\n 'Source Code Pro', Menlo, Monaco, 'Courier New', monospace;\n --ui-layer-1: var(--neutral-100);\n --ui-layer-2: var(--neutral-200);\n --ui-layer-3: var(--neutral-300);\n --ui-layer-4: var(--neutral-400);\n --ui-layer-5: var(--neutral-500);\n --ui-layer-6: var(--neutral-600);\n --ui-border-color: var(--primary-color);\n --ui-border-radius: 4px;\n --ui-text: var(--neutral-900);\n --ui-text-secondary: var(--neutral-700);\n --ui-text-placeholder: var(--neutral-500);\n --ui-text-muted: var(--neutral-300);\n /** A field is a UI element in which a user can type data, for\n * example an input or textarea element.\n */\n --ui-field-bg: var(--neutral-100);\n --ui-field-bg-hover: var(--neutral-100);\n --ui-field-bg-disabled: var(--neutral-300);\n --ui-field-bg-invalid: var(--red-100);\n --ui-field-bg-focus: var(--neutral-100);\n --ui-field-border: 0.5px solid var(--border-color);\n --ui-field-border-hover: 0.5px solid var(--border-color);\n --ui-field-border-disabled: 0.5px solid var(--border-color);\n --ui-field-border-invalid: 0.5px solid var(--border-color);\n --ui-field-border-focus: 0.5px solid var(--border-color);\n --ui-menu-bg: var(--neutral-100);\n --ui-menu-text: var(--neutral-900);\n --ui-menu-bg-hover: var(--neutral-200);\n --ui-menu-text-hover: var(--neutral-900);\n /** The `active` state is used for the state of menu items\n * when they are selected.\n */\n --ui-menu-bg-active: var(--primary-color);\n --ui-menu-text-active: var(--primary-color-reverse);\n /** The `active-muted` set is used for the state of\n * submenus when they are open.\n */\n --ui-menu-bg-active-muted: var(--neutral-300);\n --ui-menu-text-active-muted: var(--neutral-900);\n /* --ui-menu-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.302),\n0 2px 6px 2px rgba(60, 64, 67, 0.149); */\n --ui-menu-shadow: 0 0 2px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 0, 0, 0.2);\n --ui-menu-divider: 0.5px solid #c7c7c7;\n /* var(--neutral-300); */\n --ui-menu-z-index: 10000;\n --page-bg: var(--neutral-100);\n --content-bg: var(--neutral-200);\n}\n@media (prefers-color-scheme: dark) {\n :host {\n --ui-menu-bg: var(--neutral-200);\n }\n}\n:host([theme='dark']) {\n --ui-menu-bg: var(--neutral-200);\n}\n/* PingFang SC is a macOS font. Microsoft Yahei is a Windows font. \n Noto is a Linux/Android font.\n*/\n:lang(zh-cn),\n:lang(zh-sg),\n:lang(zh-my),\n:lang(zh) {\n --ui-font-family: -apple-system, system-ui, 'PingFang SC', 'Hiragino Sans GB',\n 'Noto Sans CJK SC', 'Noto Sans SC', 'Noto Sans', 'Microsoft Yahei UI',\n 'Microsoft YaHei New', 'Microsoft Yahei', '微软雅黑', SimSun, '宋体',\n STXihei, '华文细黑', sans-serif;\n}\n:lang(zh-tw),\n:lang(zh-hk),\n:lang(zh-mo) {\n --ui-font-family: -apple-system, system-ui, 'Noto Sans',\n 'Microsoft JhengHei UI', 'Microsoft JhengHei', '微軟正黑體', '新細明體',\n 'PMingLiU', '細明體', 'MingLiU', sans-serif;\n}\n:lang(ja),\n:lang(ja-jp),\n:lang(ja-jp-mac) {\n --ui-font-family: -apple-system, system-ui, 'Hiragino Sans',\n 'Hiragino Kaku Gothic ProN', 'Noto Sans CJK JP', 'Noto Sans JP', 'Noto Sans',\n '游ゴシック', '游ゴシック体', YuGothic, 'Yu Gothic', 'メイリオ', Meiryo,\n 'MS Pゴシック', 'MS PGothic', sans-serif;\n}\n:lang(ko),\n:lang(ko-kr),\n:lang(ko-kr-std) {\n --ui-font-family: -apple-system, system-ui, 'Noto Sans CJK KR', 'Noto Sans KR',\n 'Noto Sans', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo',\n '애플 SD 산돌고딕 Neo', 'Apple SD 산돌고딕 Neo', '돋움', Dotum, sans-serif;\n}\n:lang(ko-kr-apple) {\n --ui-font-family: -apple-system, system-ui, 'Noto Sans CJK KR', 'Noto Sans KR',\n 'Noto Sans', 'Apple SD Gothic Neo', '애플 SD 산돌고딕 Neo',\n 'Apple SD 산돌고딕 Neo', '돋움', Dotum, sans-serif;\n}\n:lang(zh-cn),\n:lang(zh-sg),\n:lang(zh-my),\n:lang(zh),\n:lang(zh-tw),\n:lang(zh-hk),\n:lang(zh-mo),\n:lang(ja),\n:lang(ja-jp),\n:lang(ja-jp-mac),\n:lang(ko),\n:lang(ko-kr),\n:lang(ko-kr-std),\n:lang(ko-kr-apple) {\n --ui-font-size: 1rem;\n --ui-line-height: 1.7;\n --ui-letter-spacing: 0;\n}\n:dir(rtl) {\n --ui-line-height: auto;\n --ui-letter-spacing: 0;\n}\n";break;case"menu":t=".ui-menu *,\n.ui-menu ::before,\n.ui-menu ::after {\n box-sizing: border-box;\n}\n.ui-menu {\n display: none;\n color-scheme: light dark;\n -webkit-user-select: none;\n /* Important: Safari iOS doesn't respect user-select */\n user-select: none;\n cursor: default;\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: rgba(0 0 0 0);\n --active-label-color: #fff;\n /* ui-menu-text-active */\n --label-color: #121212;\n /* ui-menu-text */\n --menu-bg: #e2e2e2;\n /* ui-menu-background */\n --active-bg: #5898ff;\n /* ui-menu-background-active */\n --active-bg-dimmed: #c5c5c5;\n /* ui-menu-background-active-muted */\n}\n/** Use the :where pseudo selector to make the specificity of the\n * selector 0, so that it can be overridden by the user.\n */\n:where(.ui-menu-container) {\n position: absolute;\n overflow: visible;\n width: auto;\n height: auto;\n z-index: 10000;\n border-radius: 8px;\n background: var(--ui-menu-bg);\n box-shadow: var(--ui-menu-shadow);\n list-style: none;\n padding: 6px 0 6px 0;\n margin: 0;\n user-select: none;\n cursor: default;\n color: var(--ui-menu-text);\n font-weight: normal;\n font-style: normal;\n text-shadow: none;\n text-transform: none;\n letter-spacing: 0;\n outline: none;\n opacity: 1;\n /* The [popover] elements have a 1px solid black border. Ugh. */\n border: none;\n width: fit-content;\n height: fit-content;\n}\n:where(.ui-menu-container > li) {\n display: flex;\n flex-flow: row;\n align-items: center;\n padding: 1px 7px 1px 7px;\n margin-top: 0;\n margin-left: 6px;\n margin-right: 6px;\n border-radius: 4px;\n white-space: nowrap;\n position: relative;\n outline: none;\n fill: currentColor;\n user-select: none;\n cursor: default;\n text-align: left;\n color: inherit;\n font-family: var(--ui-font-family);\n font-size: var(--ui-font-size);\n line-height: var(--ui-line-height);\n letter-spacing: var(--ui-letter-spacing);\n}\n:where(.ui-menu-container > li > .label) {\n appearance: none;\n background: none;\n outline: none;\n width: 100%;\n margin: 0;\n padding: 1px 2px 1px 1px;\n overflow: visible;\n border: 1px solid transparent;\n white-space: nowrap;\n text-align: start;\n}\n:where(.ui-menu-container > li:has(.heading)) {\n margin-top: 0.5em;\n}\n:where(.ui-menu-container > li > .label.heading) {\n font-weight: bold;\n opacity: 0.4;\n}\n:where(.ui-menu-container > li.indent > .label) {\n margin-inline-start: 12px;\n}\n:where(.ui-menu-container > li > .label.indent) {\n margin-inline-start: 12px;\n}\n:where(.ui-menu-container > li[role='divider']) {\n border-bottom: 1px solid var(--ui-menu-divider);\n border-radius: 0;\n padding: 0;\n margin-left: 15px;\n margin-right: 15px;\n padding-top: 5px;\n margin-bottom: 5px;\n width: calc(100% - 30px);\n /** 100% - (margin-left + margin-right) */\n}\n:where(.ui-menu-container > li[aria-disabled='true']) {\n opacity: 0.5;\n}\n:where(.ui-menu-container > li.active) {\n background: var(--ui-menu-bg-active);\n background: -apple-system-control-accent;\n color: var(--ui-menu-text-active);\n}\n:where(.ui-menu-container > li.active.is-submenu-open) {\n background: var(--ui-menu-bg-active-muted);\n color: inherit;\n}\n:where(.ui-menu-container > li[aria-haspopup='true'] > .label) {\n padding-inline-end: 0;\n}\n:where(.ui-menu-container > li[aria-haspopup='true'].active::after) {\n color: var(--ui-menu-text-active);\n}\n/** Keyboard shortcut */\n:where(.ui-menu-container > li > kbd) {\n font-family: var(--ui-font-family);\n margin-inline-start: 12px;\n opacity: 0.4;\n}\n:where(.ui-menu-container > li.active > kbd) {\n opacity: 0.85;\n}\n.ui-trailing-chevron {\n display: flex;\n margin-inline-start: 24px;\n width: 10px;\n height: 10px;\n margin-bottom: 4px;\n}\n.ui-trailing-chevron:dir(rtl) {\n transform: scaleX(-1);\n}\n.ui-checkmark {\n display: flex;\n margin-inline-end: -11px;\n margin-inline-start: -4px;\n margin-top: 2px;\n width: 16px;\n height: 16px;\n}\n.ui-mixedmark {\n display: flex;\n margin-inline-end: -11px;\n margin-inline-start: -4px;\n margin-top: 2px;\n width: 16px;\n height: 16px;\n}\n"}return t}function ho(e){return lo||(lo={}),lo[e]||(lo[e]=new CSSStyleSheet,lo[e].replaceSync(uo(e))),lo[e]}function po(e){var t;if(!("adoptedStyleSheets"in document)){if(window.document.getElementById(`mathlive-style-${e}`))return;const t=window.document.createElement("style");return t.id=`mathlive-style-${e}`,t.append(window.document.createTextNode(uo(e))),void window.document.head.appendChild(t)}if(co||(co={}),0!==(null!=(t=co[e])?t:0))co[e]+=1;else{const t=ho(e);document.adoptedStyleSheets=[...document.adoptedStyleSheets,t],co[e]=1}}function fo(e){if("adoptedStyleSheets"in document&&(null==co?void 0:co[e])&&(co[e]-=1,co[e]<=0)){const t=lo[e];document.adoptedStyleSheets=document.adoptedStyleSheets.filter((e=>e!==t))}}var mo=class e extends Ma{constructor(e){var t;super(h(u({},e),{type:"accent",body:null!=(t=e.body)?t:void 0})),e.accentChar?this.accent=e.accentChar:this.svgAccent=null==e?void 0:e.svgAccent,this.skipBoundary=!0,this.captureSelection=!0}static fromJson(t){return new e(t)}toJson(){return h(u({},super.toJson()),{accentChar:this.accent,svgAccent:this.svgAccent})}render(e){var t;const n=new Ca({parent:e,mathstyle:"cramp"},this.style),i=null!=(t=Ma.createBox(n,this.body))?t:new ca("▢",{style:this.style});let r=0;!this.hasEmptyBranch("body")&&2===this.body.length&&this.body[1].isCharacterBox()&&(r=i.skew);let s,a=Math.min(i.height,Ps);if(this.svgAccent)s=pa(this.svgAccent),a=n.metrics.bigOpSpacing1-a;else if(this.accent){const e=new ca(this.accent,{fontFamily:"Main-Regular"});e.italic=0;const t=8407===this.accent?" ML__accent-vec":"";s=new ca(new ca(e),{classes:"ML__accent-body"+t})}s=new ma({shift:0,children:[{box:new ca(i)},-a,{box:s,marginLeft:i.left+2*r,classes:["ML__center"]}]});const o=new ca(s,{type:"lift"});return this.caret&&(o.caret=this.caret),this.bind(n,o.wrap(n)),this.attachSupsub(n,{base:o})}},go={"(":")","{":"}","[":"]","|":"|","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\{":"\\}","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache"},_o=Object.fromEntries(Object.entries(go).map((([e,t])=>[t,e])));function yo(e){var t;return null!=(t={"[":91,"]":93,"(":40,")":41,"\\mid":8739,"|":8739,"∣":8739,"∥":8741,"\\|":8739,"\\{":123,"\\}":125,"\\lbrace":123,"\\rbrace":125,"\\lparen":40,"\\rparen":41,"\\lbrack":91,"\\rbrack":93,"\\vert":8739,"\\lvert":8739,"\\mvert":8739,"\\rvert":8739,"\\Vert":8741,"\\lVert":8741,"\\mVert":8741,"\\rVert":8741,"\\parallel":8741,"\\shortparallel":8741,"\\langle":10216,"\\rangle":10217,"\\lfloor":8970,"\\rfloor":8971,"\\lceil":8968,"\\rceil":8969,"\\ulcorner":9484,"\\urcorner":9488,"\\llcorner":9492,"\\lrcorner":9496,"\\lgroup":10222,"\\rgroup":10223,"\\lmoustache":9136,"\\rmoustache":9137,"\\surd":8730}[e])?t:e.codePointAt(0)}function vo(e,t,n,i,r){var s,a;const o=new Ca({parent:i,mathstyle:"textstyle"},null==r?void 0:r.style),l=new ca(yo(e),{fontFamily:`Size${t}-Regular`,isSelected:r.isSelected,classes:(null!=(s=r.classes)?s:"")+` ML__delim-size${t}`,type:null!=(a=r.type)?a:"ignore"}).wrap(o);return n&&l.setTop((1-o.scalingFactor)*Is),l}function bo(e,t,n,i,r){var s;let a,o,l,c;a=l=c=yo(e),o=null;let d="Size1-Regular";"\\vert"===e||"\\lvert"===e||"\\rvert"===e||"\\mvert"===e||"\\mid"===e?l=a=c=8739:"\\Vert"===e||"\\lVert"===e||"\\rVert"===e||"\\mVert"===e||"\\|"===e?l=a=c=8741:"\\uparrow"===e?l=c=9168:"\\Uparrow"===e?l=c=8214:"\\downarrow"===e?a=l=9168:"\\Downarrow"===e?a=l=8214:"\\updownarrow"===e?(a=8593,l=9168,c=8595):"\\Updownarrow"===e?(a=8657,l=8214,c=8659):"["===e||"\\lbrack"===e?(a=9121,l=9122,c=9123,d="Size4-Regular"):"]"===e||"\\rbrack"===e?(a=9124,l=9125,c=9126,d="Size4-Regular"):"\\lfloor"===e||"⌊"===e?(l=a=9122,c=9123,d="Size4-Regular"):"\\lceil"===e||"⌈"===e?(a=9121,l=c=9122,d="Size4-Regular"):"\\rfloor"===e||"⌋"===e?(l=a=9125,c=9126,d="Size4-Regular"):"\\rceil"===e||"⌉"===e?(a=9124,l=c=9125,d="Size4-Regular"):"("===e||"\\lparen"===e?(a=9115,l=9116,c=9117,d="Size4-Regular"):")"===e||"\\rparen"===e?(a=9118,l=9119,c=9120,d="Size4-Regular"):"\\{"===e||"\\lbrace"===e?(a=9127,o=9128,c=9129,l=9130,d="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(a=9131,o=9132,c=9133,l=9130,d="Size4-Regular"):"\\lgroup"===e||"⟮"===e?(a=9127,c=9129,l=9130,d="Size4-Regular"):"\\rgroup"===e||"⟯"===e?(a=9131,c=9133,l=9130,d="Size4-Regular"):"\\lmoustache"===e||"⎰"===e?(a=9127,c=9133,l=9130,d="Size4-Regular"):"\\rmoustache"===e||"⎱"===e?(a=9131,c=9129,l=9130,d="Size4-Regular"):"\\surd"===e?(a=57345,c=9143,l=57344,d="Size4-Regular"):"\\ulcorner"===e?(a=9484,l=c=32):"\\urcorner"===e?(a=9488,l=c=32):"\\llcorner"===e?(c=9492,l=a=32):"\\lrcorner"===e&&(a=9496,l=a=32);const p=Bs(a,d),f=p.height+p.depth,m=Bs(l,d),g=m.height+m.depth,_=Bs(c,d),y=_.height+_.depth;let v=0,b=1;if(null!==o){const e=Bs(o,d);v=e.height+e.depth,b=2}const w=f+y+v,x=Math.max(0,Math.ceil((t-w)/(b*g))),k=w+x*b*g;let S=Is;n&&(S*=i.scalingFactor);const E=k/2-S,T=[];T.push({box:new ca(c,{fontFamily:d})}),T.push(-.008);const C=new ca(l,{fontFamily:d});if(null===o)for(let e=0;e<x;e++)T.push({box:C});else{for(let e=0;e<x;e++)T.push({box:C});T.push(-.008),T.push({box:new ca(o,{fontFamily:d})}),T.push(-.008);for(let e=0;e<x;e++)T.push({box:C})}T.push(-.008),T.push({box:new ca(a,{fontFamily:d})});let L="";"Size1-Regular"===d?L=" delim-size1":"Size4-Regular"===d&&(L=" delim-size4");const A=new ma({bottom:E,children:T},{classes:L});return new ca(A,h(u({},null!=r?r:{}),{classes:(null!=(s=null==r?void 0:r.classes)?s:"")+" ML__delim-mult"}))}var wo=new Set(["(",")","\\lparen","\\rparen","[","]","\\lbrack","\\rbrack","\\{","\\}","\\lbrace","\\rbrace","\\lfloor","\\rfloor","\\lceil","\\rceil","\\surd","⌊","⌋","⌈","⌉"]),xo=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\mvert","\\mid","\\lgroup","\\rgroup","\\lmoustache","\\rmoustache","⟮","⟯","⎰","⎱"]),ko=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),So=[0,1.2,1.8,2.4,3];var Eo=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],To=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"stack"}],Co=[{type:"small",mathstyle:"scriptscriptstyle"},{type:"small",mathstyle:"scriptstyle"},{type:"small",mathstyle:"textstyle"},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}];function Lo(e,t,n,i,r,s){if(!t||0===t.length||"."===t)return Do(r);let a;"<"===t||"\\lt"===t?t="\\langle":">"!==t&&"\\gt"!==t||(t="\\rangle"),a=ko.has(t)?Eo:wo.has(t)?Co:To;const o=function(e,t,n,i){for(let s={"-4":0,"-3":1,0:2}[i.mathstyle.sizeDelta];s<n.length&&"stack"!==n[s].type;s++){const a=Bs(e,"small"===(r=n[s]).type?"Main-Regular":"large"===r.type?"Size"+r.size+"-Regular":(console.assert("stack"===r.type),"Size4-Regular"));if(a.defaultMetrics)return{type:"small",mathstyle:"scriptstyle"};let o=a.height+a.depth;if("small"===n[s].type&&("scriptscriptstyle"===n[s].mathstyle?o*=Math.max(Fs[Math.max(1,i.size-2)],i.minFontScale):"scriptstyle"===n[s].mathstyle&&(o*=Math.max(Fs[Math.max(1,i.size-1)],i.minFontScale))),o>t)return n[s]}var r;return n[n.length-1]}(yo(t),n,a,r),l=new Ca({parent:r,mathstyle:o.mathstyle},null==s?void 0:s.style);return"small"===o.type?function(e,t,n,i){var r;const s=new ca(yo(e),{fontFamily:"Main-Regular",isSelected:i.isSelected,classes:"ML__small-delim "+(null!=(r=i.classes)?r:"")}).wrap(t);return n&&s.setTop((1-t.scalingFactor)*Is),s}(t,l,i,h(u({},s),{type:e})):"large"===o.type?vo(t,o.size,i,l,h(u({},s),{type:e})):(console.assert("stack"===o.type),bo(t,n,i,l,h(u({},s),{type:e})))}function Ao(e,t,n,i,r,s){if("."===t)return Do(r,null==s?void 0:s.classes);const a=Is*r.scalingFactor,o=Math.max(n-a,i+a);return Lo(e,t,Math.max(o/500*901,2*o-.5),!0,r,s)}function Do(e,t){const n=new ca(null,{classes:" nulldelimiter "+(null!=t?t:""),type:"ignore"});return n.width=e.getRegisterAsEm("nulldelimiterspace"),n.wrap(new Ca({parent:e,mathstyle:"textstyle"}))}var Mo=class e extends Ma{constructor(e){var t;super({type:"placeholder",command:"\\placeholder",mode:null!=(t=null==e?void 0:e.mode)?t:"math",style:null==e?void 0:e.style}),this.captureSelection=!0}static fromJson(t){return new e(t)}toJson(){return super.toJson()}render(e){let t;return this.value=e.placeholderSymbol,t="function"==typeof e.renderPlaceholder?e.renderPlaceholder(e):this.createBox(e),this.caret&&(t.classes+=" ML__placeholder-selected"),t}_serialize(e){return e.skipPlaceholders?"":"\\placeholder{}"}},Ro=["matrix","matrix*","pmatrix","pmatrix*","bmatrix","bmatrix*","Bmatrix","Bmatrix*","vmatrix","vmatrix*","Vmatrix","Vmatrix*"],Io=["cases","dcases","rcases"],Po=["align","align*","aligned","gather","gathered","split"],Oo=["array","subequations","eqnarray"];function Fo(e){return Ro.includes(e)}var No=class e extends Ma{constructor(e,t,n,i={}){var r;super({type:"array"}),this.environmentName=e,this.rowGaps=n,i.mathstyleName&&(this.mathstyleName=i.mathstyleName),i.columns&&(0===i.columns.length?this.colFormat=[{align:"l"}]:this.colFormat=i.columns),this.colFormat||(this.colFormat=[{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"},{align:"l"}]),this.array=function(e,t,n){let i=0;for(const e of n)"align"in e&&(i+=1);let r=0;const s=[];for(const n of t){let t=0;for(r=Math.max(r,Math.min(n.length,i));t<n.length;){const r=[],a=Math.min(n.length,t+i);for(;t<a;){const i=n[t];0===i.length?r.push([new Ma({type:"first",mode:e.mode})]):"first"!==i[0].type?r.push([new Ma({type:"first",mode:e.mode}),...i]):(console.assert(!i.slice(1).some((e=>"first"===e.type))),r.push(i)),t+=1}s.push(r)}}s.length>0&&1===s[s.length-1].length&&1===s[s.length-1][0].length&&"first"===s[s.length-1][0][0].type&&s.pop();const a=[];for(const t of s){if(t.length!==r)for(let n=t.length;n<r;n++)t.push([new Ma({type:"first",mode:e.mode}),new Mo]);a.push(t)}let o=0,l=0;for(const t of a){l=0;for(const n of t){for(const t of n)t.parent=e,t.parentBranch=[o,l];l+=1}o+=1}return e.isDirty=!0,a}(this,t,this.colFormat),i.leftDelim&&(this.leftDelim=i.leftDelim),i.rightDelim&&(this.rightDelim=i.rightDelim),void 0!==i.arraycolsep&&(this.arraycolsep=i.arraycolsep),this.colSeparationType=i.colSeparationType,void 0!==i.arraystretch&&(this.arraystretch=i.arraystretch),this.minColumns=null!=(r=i.minColumns)?r:1}static fromJson(t){return new e(t.environmentName,t.array,t.rowGaps,t)}toJson(){const e=h(u({},super.toJson()),{environmentName:this.environmentName,array:this.array.map((e=>e.map((e=>e.map((e=>e.toJson())))))),rowGaps:this.rowGaps,columns:this.colFormat,colSeparationType:this.colSeparationType});return void 0!==this.arraystretch&&(e.arraystretch=this.arraystretch),void 0!==this.arraycolsep&&(e.arraycolsep=this.arraycolsep),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),e}branch(e){var t;if(Da(e))return null!=(t=this.array[e[0]][e[1]])?t:void 0}createBranch(e){var t;return Da(e)?(this.isDirty=!0,null!=(t=this.branch(e))?t:[]):[]}get rowCount(){return this.array.length}get colCount(){return this.array[0].length}get maxColumns(){return this.colFormat.filter((e=>Boolean(e.align))).length}removeBranch(e){if(Aa(e))return super.removeBranch(e);const t=this.branch(e);return this.array[e[0]][e[1]]=void 0,t.forEach((e=>{e.parent=void 0,e.parentBranch=void 0})),console.assert("first"===t[0].type),t.shift(),this.isDirty=!0,t}get hasChildren(){return this.children.length>0}get children(){const e=[];for(const t of this.array)for(const n of t)if(n)for(const t of n)e.push(...t.children),e.push(t);return[...e,...super.children]}render(e){var t,n,i,r,s,a;const o=new Ca({parent:e,mathstyle:this.mathstyleName},this.style),l=o.getRegisterAsEm("arrayrulewidth"),c=o.getRegisterAsEm("arraycolsep"),u=o.getRegisterAsEm("doublerulesep"),h=null!=(n=null!=(t=this.arraystretch)?t:o.getRegisterAsNumber("arraystretch"))?n:1;let d="number"==typeof this.arraycolsep?this.arraycolsep:c;if("small"===this.colSeparationType){d=new Ca({parent:e,mathstyle:"scriptstyle"}).scalingFactor/e.scalingFactor*.2778}const p=1.2*h,f=.7*p,m=.3*p;let g=0;const _=[];let y=0;const v=this.array.length;for(let e=0;e<v;++e){const t=this.array[e];y=Math.max(y,t.length);const n=new Ca({parent:o,mathstyle:this.mathstyleName},this.style);let s=f/n.scalingFactor,a=m/n.scalingFactor;const l={cells:[],height:0,depth:0,pos:0};for(const e of t){const t=null!=(i=Ma.createBox(n,e,{type:"ignore"}))?i:new ca(null,{type:"ignore"});a=Math.max(a,t.depth),s=Math.max(s,t.height),l.cells.push(t)}let c=null!=(r=ba(this.rowGaps[e]))?r:0;c>0&&(c+=m,a=Math.max(a,c),c=0),e<v-1&&!Fo(this.environmentName)&&"cases"!==this.environmentName&&"array"!==this.environmentName&&(a+=o.getRegisterAsEm("jot")),l.height=s,l.depth=a,g+=s,l.pos=g,g+=a+c,_.push(l)}const b=g/2+Is,w=[];for(let e=0;e<y;e++){const t=[];for(const n of _){const i=n.cells[e];i.depth=n.depth,i.height=n.height,t.push({box:i,shift:n.pos-b})}t.length>0&&w.push(new ma({individualShift:t}))}const x=[];let k=!1,S=!1,E=0,T=!this.leftDelim;const{colFormat:C}=this;for(const t of C){if("align"in t&&E>=w.length)break;if("align"in t)k?x.push($o(2*d)):(S||T)&&x.push($o(d)),x.push(new ca(w[E],{classes:"col-align-"+t.align})),E++,k=!0,S=!1,T=!1;else if("gap"in t){if("number"==typeof t.gap)x.push($o(t.gap));else{const n=Ko(e,_,b,t.gap);n&&x.push(n)}k=!1,S=!1,T=!1}else if("separator"in t){const e=new ca(null,{classes:"vertical-separator"});e.height=g,e.setStyle("height",g,"em"),e.setStyle("border-right",`${l}em ${t.separator} currentColor`),e.setStyle("vertical-align",-(g-b),"em");let n=0;S?n=u-l:k&&(n=d-l),e.left=n,x.push(e),k=!1,S=!0,T=!1}}k&&!this.rightDelim&&x.push($o(d));const L=new ca(x,{classes:"mtable"});if(!(this.leftDelim&&"."!==this.leftDelim||this.rightDelim&&"."!==this.rightDelim))return this.caret&&(L.caret=this.caret),this.bind(e,L);const A=L.height,D=L.depth,M=this.bind(e,new ca([this.bind(e,Ao("open",null!=(s=this.leftDelim)?s:".",A,D,o,{isSelected:this.isSelected})),L,this.bind(e,Ao("close",null!=(a=this.rightDelim)?a:".",A,D,o,{isSelected:this.isSelected}))],{type:"ord"}));return M?(M.setStyle("display","inline-block"),this.caret&&(M.caret=this.caret),this.bind(e,this.attachSupsub(e,{base:M}))):null}_serialize(e){var t;const n=[];if("lines"===this.environmentName?n.push("{\\displaylines"):n.push(`\\begin{${this.environmentName}}`),"array"===this.environmentName){if(n.push("{"),void 0!==this.colFormat)for(const e of this.colFormat)"align"in e&&"string"==typeof e.align?n.push(e.align):"separator"in e&&"solid"===e.separator?n.push("|"):"separator"in e&&"dashed"===e.separator&&n.push(":");n.push("}")}for(let i=0;i<this.array.length;i++){for(let t=0;t<this.array[i].length;t++)t>0&&n.push(" & "),n.push(Ma.serialize(this.array[i][t],e));if(i<this.array.length-1){const e=this.rowGaps[i];(null==e?void 0:e.dimension)?n.push(`\\\\[${e.dimension} ${null!=(t=e.unit)?t:"pt"}] `):n.push("\\\\ ")}}return"lines"===this.environmentName?n.push("}"):n.push(`\\end{${this.environmentName}}`),Xs(n)}getCell(e,t){return this.array[e][t]}setCell(e,t,n){console.assert("array"===this.type&&Array.isArray(this.array)&&void 0!==this.array[e][t]);for(const n of this.array[e][t])n.parent=void 0,n.parentBranch=void 0;let i=n;0!==n.length&&"first"===n[0].type||(i=[new Ma({type:"first",mode:this.mode}),...n]),this.array[e][t]=i;for(const n of i)n.parent=this,n.parentBranch=[e,t];this.isDirty=!0}addRowBefore(e){console.assert("array"===this.type&&Array.isArray(this.array));const t=[];for(let e=0;e<this.colCount;e++)t.push(Bo(this));this.array.splice(e,0,t);for(let t=e;t<this.rowCount;t++)for(let e=0;e<this.colCount;e++){const n=this.array[t][e];if(n)for(const i of n)i.parentBranch=[t,e]}this.isDirty=!0}addRowAfter(e){console.assert("array"===this.type&&Array.isArray(this.array));const t=[];for(let e=0;e<this.colCount;e++)t.push(Bo(this));this.array.splice(e+1,0,t);for(let t=e+1;t<this.rowCount;t++)for(let e=0;e<this.colCount;e++){const n=this.array[t][e];if(n)for(const i of n)i.parentBranch=[t,e]}this.isDirty=!0}removeRow(e){console.assert("array"===this.type&&Array.isArray(this.array)&&this.rowCount>e);const t=this.array.splice(e,1);for(const e of t)for(const t of e)if(t)for(const e of t)e.parent=void 0,e.parentBranch=void 0;for(let t=e;t<this.rowCount;t++)for(let e=0;e<this.colCount;e++){const n=this.array[t][e];if(n)for(const i of n)i.parentBranch=[t,e]}this.isDirty=!0}addColumnBefore(e){console.assert("array"===this.type&&Array.isArray(this.array));for(const t of this.array)t.splice(e,0,Bo(this));for(let t=0;t<this.rowCount;t++)for(let n=e;n<this.colCount;n++){const e=this.array[t][n];if(e)for(const i of e)i.parentBranch=[t,n]}this.isDirty=!0}addColumnAfter(e){console.assert("array"===this.type&&Array.isArray(this.array));for(const t of this.array)t.splice(e+1,0,Bo(this));for(let t=0;t<this.rowCount;t++)for(let n=e+1;n<this.colCount;n++){const e=this.array[t][n];if(e)for(const i of e)i.parentBranch=[t,n]}this.isDirty=!0}addColumn(){this.addColumnAfter(this.colCount-1)}removeColumn(e){console.assert("array"===this.type&&Array.isArray(this.array)&&this.colCount>e);for(const t of this.array){const n=t.splice(e,1);for(const e of n)if(e)for(const t of e)t.parent=void 0,t.parentBranch=void 0}for(let t=0;t<this.rowCount;t++)for(let n=e;n<this.colCount;n++){const e=this.array[t][n];if(e)for(const i of e)i.parentBranch=[t,n]}this.isDirty=!0}get cells(){const e=[];for(const t of this.array)for(const n of t)n&&e.push(n.filter((e=>"first"!==e.type)));return e}};function Bo(e){const t=new Ma({type:"first",mode:e.mode});t.parent=e;const n=new Mo;return n.parent=e,[t,n]}function $o(e){const t=new ca(null,{classes:"arraycolsep"});return t.width=e,t}function Ko(e,t,n,i){if(!i)return null;const r=[];for(const s of t){const t=Ma.createBox(e,i,{type:"ignore"});t&&(t.depth=s.depth,t.height=s.height,r.push({box:t,shift:s.pos-n}))}return new ma({individualShift:r}).wrap(e)}var Uo=class e extends Ma{constructor(e){super({mode:e.mode,command:e.command,style:e.style,body:e.body,type:"box"}),this.framecolor=e.framecolor,this.backgroundcolor=e.backgroundcolor,this.padding=e.padding,this.offset=e.offset,this.border=e.border}static fromJson(t){return new e(t)}toJson(){return h(u({},super.toJson()),{framecolor:this.framecolor,backgroundcolor:this.backgroundcolor,padding:this.padding,offset:this.offset,border:this.border})}render(e){var t,n,i,r;const s=Ma.createBox(e,this.body,{type:"lift"});if(!s)return null;const a=e.toEm(null!=(t=this.offset)?t:{dimension:0});s.depth+=a,s.setStyle("display","inline-block"),s.setStyle("position","relative"),s.setStyle("height",Math.floor(100*s.height+s.depth)/100,"em"),s.setStyle("vertical-align",-Math.floor(100*s.height)/100,"em");const o=new Ca({parent:e},this.style),l=o.toEm(null!=(n=this.padding)?n:{register:"fboxsep"}),c=new ca(null,{classes:"ML__box"});c.height=s.height+l,c.depth=s.depth+l,c.setStyle("box-sizing","border-box"),c.setStyle("position","absolute"),c.setStyle("top",.3-l,"em"),c.setStyle("left",0),c.setStyle("height",c.height+c.depth,"em"),c.setStyle("width","100%"),this.backgroundcolor&&c.setStyle("background-color",null!=(i=o.toColor(this.backgroundcolor))?i:"transparent"),this.framecolor&&c.setStyle("border",`${o.getRegisterAsEm("fboxrule",2)}em solid ${null!=(r=o.toColor(this.framecolor))?r:"black"}`),this.border&&c.setStyle("border",this.border);const u=new ca([c,s],{type:"lift"});return u.setStyle("display","inline-block"),u.setStyle("position","relative"),u.setStyle("line-height",0),u.height=s.height+l+(a>0?a:0),u.depth=s.depth+l+(a<0?-a:0),u.setStyle("padding-left",l,"em"),u.setStyle("padding-right",l,"em"),u.setStyle("height",Math.floor(100*(s.height+s.depth+2*l+Math.abs(a)))/100,"em"),u.setStyle("margin-top",-l,"em"),u.setStyle("top",Math.floor(100*(s.depth-s.height+2*l-a))/100,"em"),u.setStyle("vertical-align",Math.floor(100*(s.depth+2*l))/100,"em"),this.caret&&(u.caret=this.caret),this.attachSupsub(e,{base:u})}_serialize(e){return e.skipStyles?Xs([this.bodyToLatex(e),this.supsubToLatex(e)]):super._serialize(e)}},zo=class e extends Ma{constructor(e,t){var n;super({type:"composition",mode:null!=(n=null==t?void 0:t.mode)?n:"math",value:e})}static fromJson(t){return new e(t.value,t)}toJson(){return super.toJson()}get computedStyle(){return{}}render(e){const t=new ca(this.value,{classes:"ML__composition",type:"composition"});return this.bind(e,t),this.caret&&(t.caret=this.caret),t}_serialize(e){return""}},Vo=class e extends Ma{constructor(e){super({type:"error",value:e,command:e,mode:"math"}),this.verbatimLatex=e}static fromJson(t){return new e(t.command)}toJson(){return super.toJson()}render(e){const t=this.createBox(e,{classes:"ML__error"});return this.caret&&(t.caret=this.caret),t}},qo=class e extends Ma{constructor(e,t,n){super({type:"group",mode:t,style:n}),this.body=e,this.boxType=e.length>1?"ord":"ignore",this.skipBoundary=!0,this.displayContainsHighlight=!1,e&&1===e.length&&","===e[0].command&&(this.captureSelection=!0)}static fromJson(t){return new e(t.body,t.mode,t.style)}render(e){const t=Ma.createBox(e,this.body,{type:this.boxType});return t?(this.caret&&(t.caret=this.caret),this.bind(e,t)):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);return(null==t?void 0:t.serialize)?t.serialize(this,e):`{${this.bodyToLatex(e)}}`}},Go=class e extends Ma{constructor(e,t,n){super({type:"leftright",style:n.style,displayContainsHighlight:!0}),this.variant=e,this.body=t,this.leftDelim=n.leftDelim,this.rightDelim=n.rightDelim}static fromJson(t){var n;return new e(null!=(n=t.variant)?n:"",t.body,t)}toJson(){const e=super.toJson();return this.variant&&(e.variant=this.variant),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),e}_serialize(e){var t,n;const i=this.matchingRightDelim();return"left...right"===this.variant?Xs(["\\left",null!=(t=this.leftDelim)?t:".",this.bodyToLatex(e),"\\right",i]):"mleft...mright"===this.variant?Xs(["\\mleft",null!=(n=this.leftDelim)?n:".",this.bodyToLatex(e),"\\mright",i]):Xs([this.leftDelim&&"."!==this.leftDelim?this.leftDelim:"",this.bodyToLatex(e),i])}matchingRightDelim(){var e,t;if(this.rightDelim&&"?"!==this.rightDelim)return this.rightDelim;const n=null!=(e=this.leftDelim)?e:".";return null!=(t=go[n])?t:n}render(e){var t,n;const i=new Ca({parent:e},this.style);console.assert(void 0!==this.body);const r=new Ca({parent:e,mathstyle:"textstyle"},this.style),s=null!=(t=Ma.createBox(i,this.body,{type:"inner"}))?t:new ca(null,{type:"inner"}),a=s.height/r.scalingFactor,o=s.depth/r.scalingFactor,l=[];if(this.leftDelim&&l.push(this.bind(r,Ao("open",this.leftDelim,a,o,r,{isSelected:this.isSelected,classes:"ML__open"+(this.containsCaret?" ML__contains-caret":""),mode:this.mode,style:this.style}))),s&&(Ho(s.children,this,i,a,o),l.push(s)),this.rightDelim){let e=this.containsCaret?" ML__contains-caret":"",t=this.rightDelim;"?"===t&&(i.smartFence?(t=this.matchingRightDelim(),e+=" ML__smart-fence__close"):t="."),l.push(this.bind(r,Ao("close",t,a,o,r,{isSelected:this.isSelected,classes:e+" ML__close",mode:this.mode,style:this.style})))}let c="mleft...mright"===this.variant;const u=this.leftSibling;u&&(!c&&u.isFunction&&(c=!0),!c&&"subsup"===u.type&&(null==(n=u.leftSibling)?void 0:n.isFunction)&&(c=!0));const h=new ca(l,{type:c?"close":"inner",classes:"left-right"});return h.setStyle("margin-top",-s.depth+"em"),h.setStyle("height",`${s.height+s.depth}em`),this.caret&&(h.caret=this.caret),this.bind(i,h.wrap(i))}};function Ho(e,t,n,i,r){if(e)for(let s=0;s<e.length;s++){const a=e[s];"middle"===a.type?(e[s]=t.bind(n,Ao("inner",a.value,i,r,n,{isSelected:t.isSelected})),e[s].caret=a.caret,e[s].isSelected=a.isSelected,e[s].cssId=a.cssId,e[s].htmlData=a.htmlData,e[s].htmlStyle=a.htmlStyle,e[s].attributes=a.attributes,e[s].cssProperties=a.cssProperties):a.children&&Ho(a.children,t,n,i,r)}}var jo=class e extends Ma{constructor(e,t){var n;super({type:"macro",command:e,style:t.style}),this.body=t.body,void 0===t.captureSelection?t.args?this.captureSelection=!1:this.captureSelection=!0:this.captureSelection=t.captureSelection,this.macroArgs=t.args,this.expand=null!=(n=t.expand)&&n}static fromJson(t){return new e(t.command,t)}toJson(){const e=super.toJson();return this.expand&&(e.expand=!0),void 0!==this.captureSelection&&(e.captureSelection=this.captureSelection),this.macroArgs&&(e.args=this.macroArgs),e}_serialize(e){var t;return e.expandMacro&&this.expand?this.bodyToLatex(e):this.command+(null!=(t=this.macroArgs)?t:"")}render(e){const t=Ma.createBox(e,this.body);return t?(this.caret&&(t.caret=this.caret),this.bind(e,t)):null}},Wo=class e extends Ma{constructor(){super({type:"macro-argument"})}static fromJson(t){return new e}toJson(){return super.toJson()}_serialize(e){return""}render(e){return null}},Zo=class e extends Ma{constructor(e,t,n=!1,i,r){var s;super({type:"prompt",mode:null!=(s=null==r?void 0:r.mode)?s:"math",style:null==r?void 0:r.style,command:"\\placeholder"}),this.body=i,this.correctness=t,this.placeholderId=e,this.locked=n,this.captureSelection=this.locked}static fromJson(t){return new e(t.placeholderId,t.correctness,t.locked,t.body,t)}toJson(){const e=super.toJson();return this.placeholderId&&(e.placeholderId=this.placeholderId),this.body||delete e.body,this.body&&(e.body=this.body.filter((e=>"first"!==e.type)).map((e=>e.toJson()))),this.correctness&&(e.correctness=this.correctness),e.locked=this.locked,e}render(e){const t=new Ca({parent:e}),n=t.getRegisterAsEm("fboxsep"),i=n,r=n,s=Ma.createBox(e,this.body);if(!s)return null;s.height||(s.height=t.metrics.xHeight),s.setStyle("vertical-align",-s.height,"em"),"correct"===this.correctness?s.setStyle("color","var(--correct-color, var(--ML__correct-color))"):"incorrect"===this.correctness&&s.setStyle("color","var(--incorrect-color, var(--ML__incorrect-color))");const a=new ca(s,{type:"ord"});a.setStyle("display","inline-block"),a.setStyle("height",s.height+s.depth,"em"),a.setStyle("vertical-align",-r,"em");let o="ML__prompt ";this.locked?o+=" ML__lockedPromptBox ":o+=" ML__editablePromptBox ","correct"===this.correctness?o+=" ML__correctPromptBox ":"incorrect"===this.correctness&&(o+=" ML__incorrectPromptBox "),this.containsCaret&&(o+=" ML__focusedPromptBox ");const l=new ca(null,{classes:o,attributes:{part:"prompt"}});l.height=a.height+r,l.depth=a.depth+r,l.width=a.width+2*i,l.setStyle("box-sizing","border-box"),l.setStyle("position","absolute"),l.setStyle("height",a.height+a.depth+2*r,"em"),0===i&&l.setStyle("width","100%"),0!==i&&(l.setStyle("width",`calc(100% + ${2*i}em)`),l.setStyle("top",n,"em"),l.setStyle("left",-i,"em")),this.body&&1!==this.body.length||(l.width=3*i,l.setStyle("width",`calc(100% + ${3*i}em)`),l.setStyle("left",-1.5*i,"em"));let c="";"incorrect"===this.correctness&&(c+='<line x1="3%" y1="97%" x2="97%" y2="3%" stroke-width="0.5" stroke="var(--incorrect-color, var(--ML__incorrect-color))" stroke-linecap="round" />'),c&&(l.svgOverlay=c);const u=new ca([l,a],{classes:"ML__prompt-atom"});return u.setStyle("position","relative"),u.setStyle("display","inline-block"),u.setStyle("line-height",0),u.height=a.height+r+.2,u.depth=a.depth+r,u.left=i,u.right=i,u.setStyle("height",a.height+r,"em"),u.setStyle("top",a.depth-a.height,"em"),u.setStyle("vertical-align",a.depth+r,"em"),u.setStyle("margin-left",.5,"em"),u.setStyle("margin-right",.5,"em"),this.caret&&(u.caret=this.caret),this.bind(t,this.attachSupsub(e,{base:u}))}_serialize(e){var t;const n=null!=(t=this.bodyToLatex(e))?t:"";if(e.skipPlaceholders)return n;let i="\\placeholder";return this.placeholderId&&(i+=`[${this.placeholderId}]`),"correct"===this.correctness?i+="[correct]":"incorrect"===this.correctness&&(i+="[incorrect]"),this.locked&&(i+="[locked]"),Js(i,n)}},Yo=class e extends Ma{constructor(e){super({type:"subsup",style:null==e?void 0:e.style}),this.subsupPlacement="auto"}static fromJson(t){const n=new e(t);for(const e of La)t[e]&&n.setChildren(t[e],e);return n}render(e){var t;const n=new Ca({parent:e,isPhantom:!0}),i=this.leftSibling,r=null!=(t=i.render(n))?t:new ca(null),s=new ca(null);return s.height=r.height,s.depth=r.depth,this.attachSupsub(e,{base:s,isCharacterBox:i.isCharacterBox(),type:"ignore"})}_serialize(e){return this.supsubToLatex(e)}};function Xo(e){return!!e&&!/^(<$$>|<$>|<space>|<{>|<}>|#[0-9\?]|\\.+)$/.test(e)}var Jo=class{constructor(e,t,n){var i,r,s,a;this.errors=[],this.index=0,this.endCount=0,null!=n||(n={}),this.tokens=e,this.context=t instanceof Ca&&!(null==n?void 0:n.parseMode)&&!n.mathstyle?t:new Ca({from:t,mathstyle:n.mathstyle},n.style),this.args=null!=(i=n.args)?i:void 0,this.smartFence=this.context.smartFence,this.parsingContext={parent:void 0,mathlist:[],style:null!=(r=n.style)?r:{},parseMode:null!=(s=n.parseMode)?s:"math",mathstyle:null!=(a=n.mathstyle)?a:"displaystyle",tabular:!1}}beginContext(e){var t,n,i;const r=this.parsingContext,s={parent:r,mathlist:[],style:u({},r.style),parseMode:null!=(t=null==e?void 0:e.mode)?t:r.parseMode,mathstyle:null!=(n=null==e?void 0:e.mathstyle)?n:r.mathstyle,tabular:null!=(i=null==e?void 0:e.tabular)&&i};this.parsingContext=s}endContext(){this.parsingContext=this.parsingContext.parent}onError(e){this.errors.push(u({before:Qs(this.tokens.slice(this.index,this.index+10)),after:Qs(this.tokens.slice(Math.max(0,this.index-10),this.index))},e))}get mathlist(){return this.parsingContext.mathlist}set mathlist(e){this.parsingContext.mathlist=e}get parseMode(){return this.parsingContext.parseMode}set parseMode(e){this.parsingContext.parseMode=e}get tabularMode(){return this.parsingContext.tabular}get style(){let e=this.parsingContext;for(;e;){if(e.style)return u({},e.style);e=e.parent}return{}}set style(e){this.parsingContext.style=e}end(){return this.endCount++,this.index>=this.tokens.length||this.endCount>1e3}next(){this.index+=1}get(){return this.endCount=0,this.index<this.tokens.length?this.tokens[this.index++]:""}peek(){return this.tokens[this.index]}match(e){return this.tokens[this.index]===e&&(this.index++,!0)}lastSubsupAtom(){let e;if(this.mathlist.length>0){if(e=this.mathlist[this.mathlist.length-1],"subsup"===e.type)return e;if(void 0!==e.subsupPlacement)return e}return e=new Yo({style:this.style}),this.mathlist.push(e),e}hasPattern(e){return e.test(this.tokens[this.index])}hasInfixCommand(){var e;const{index:t}=this;if(t<this.tokens.length&&this.tokens[t].startsWith("\\")){const n=ae(this.tokens[t],this.parseMode);return!(!n||"symbol"===n.definitionType)&&(!(n.ifMode&&!n.ifMode.includes(this.parseMode))&&(null!=(e=n.infix)&&e))}return!1}matchColumnSeparator(){if(!this.tabularMode)return!1;return"&"===this.peek()&&(this.index++,!0)}matchRowSeparator(){if(!this.tabularMode)return!1;const e=this.peek();return("\\\\"===e||"\\cr"===e||"\\tabularnewline"===e)&&(this.index++,!0)}placeholder(){var e;const t=null==(e=this.args)?void 0:e.call(this,"?");return t?Qo(t,{parseMode:this.parseMode,mathstyle:"textstyle"}):[new Mo({mode:this.parseMode,style:this.style})]}skipWhitespace(){for(;this.match("<space>"););}skipUntilToken(e){let t=this.tokens[this.index];for(;t&&t!==e;)t=this.tokens[++this.index];t===e&&this.index++}skipFiller(){for(;this.match("\\relax")||this.match("<space>"););}matchKeyword(e){const t=this.index;let n=this.end(),i="";for(;!n;){const t=this.get();Xo(t)?(i+=t,n=this.end()||i.length>=e.length):n=!0}const r=e.toUpperCase()===i.toUpperCase();return r||(this.index=t),r}scanString(){let e="";for(;!this.end();){const t=this.peek();if("]"===t)return e;if("<space>"===t)e+=" ";else if(t.startsWith("\\"))this.onError({code:"unexpected-command-in-string"}),e+=t.substring(1);else{if(!Xo(t))return e;e+=t}this.next()}return e}scanBalancedString(){let e="",t=this.end(),n=1;for(;!t;){const i=this.get();"<space>"===i?e+=" ":"<{>"===i?(e+="{",n+=1):"<}>"===i?(n-=1,n>0?e+="}":this.index-=1):e+="<$>"===i?"$":"<$$>"===i?"$$":i,t=0===n||this.end()}return e}scanLiteralGroup(){var e;if(!this.match("<{>"))return"";let t="",n=1;for(;n>0&&!this.end();){const i=this.get();"<}>"===i?(n-=1,n>0&&(t+="}")):"<{>"===i?(n+=1,t+="{"):(/\\[a-zA-Z]+$/.test(t)&&/^[a-zA-Z]/.test(i)&&(t+=" "),t+=null!=(e={"<space>":" ","<$$>":"$$","<$>":"$"}[i])?e:i)}return t}scanNumber(e=!0){var t,n;let i=!1,r=this.peek();for(;"<space>"===r||"+"===r||"-"===r;)this.get(),"-"===r&&(i=!i),r=this.peek();e=Boolean(e);let s=10,a=/\d/;if(this.match("'"))s=8,a=/[0-7]/,e=!0;else if(this.match('"'))s=16,a=/[\dA-F]/,e=!0;else if(this.match("x"))s=16,a=/[\dA-Fa-f]/,e=!0;else if(this.match("`"))return r=this.get(),r?2===r.length&&r.startsWith("\\")?{number:(i?-1:1)*(null!=(t=r.codePointAt(1))?t:0),base:"alpha"}:{number:(i?-1:1)*(null!=(n=r.codePointAt(0))?n:0),base:"alpha"}:null;let o="";for(;this.hasPattern(a);)o+=this.get();if(!e&&(this.match(".")||this.match(",")))for(o+=".";this.hasPattern(a);)o+=this.get();const l=e?Number.parseInt(o,s):Number.parseFloat(o);return Number.isNaN(l)?null:{number:i?-l:l,base:16===s?"hexadecimal":8===s?"octal":"decimal"}}scanRegister(){var e;const t=this.index,n=this.scanNumber(!1);if(this.skipWhitespace(),this.match("\\relax"))return n;let i=!1;if(null===n)for(;;){const e=this.peek();if("-"===e)i=!i;else if("+"!==e)break;this.next(),this.skipWhitespace()}if(this.match("\\global")){this.skipWhitespace();const e=this.get();return e.startsWith("\\")?n?{register:e,global:!0,factor:(i?-1:1)*n.number}:i?{register:e,global:!0,factor:-1}:{register:e,global:!0}:(this.index=t,null)}let r=this.get();return(null==r?void 0:r.startsWith("\\"))?(r=r.substring(1),this.context.registers[r]?i&&null===n?{register:r}:{register:r,factor:(i?-1:1)*(null!=(e=null==n?void 0:n.number)?e:1)}:(this.index=t,null)):(this.index=t,null)}scanValue(){const e=this.scanRegister();if(e)return e;const t=this.index,n=this.scanGlueOrDimen();if(n&&("unit"in n||"glue"in n&&"unit"in n.glue))return n;this.index=t;const i=this.scanNumber();if(i)return i;if(this.end()||!Xo(this.peek()))return null;const r=this.scanString();return r.length>0?{string:r}:null}scanDimen(){const e=this.scanNumber(!1);if(null===e)return null;const t=e.number;let n;return this.skipWhitespace(),this.matchKeyword("true"),this.skipWhitespace(),this.matchKeyword("pt")?n="pt":this.matchKeyword("mm")?n="mm":this.matchKeyword("cm")?n="cm":this.matchKeyword("ex")?n="ex":this.matchKeyword("px")?n="px":this.matchKeyword("em")?n="em":this.matchKeyword("bp")?n="bp":this.matchKeyword("dd")?n="dd":this.matchKeyword("pc")?n="pc":this.matchKeyword("in")?n="in":this.matchKeyword("mu")&&(n="mu"),n?{dimension:t,unit:n}:{dimension:t}}scanGlueOrDimen(){const e=this.scanDimen();if(null===e)return null;if(this.skipWhitespace(),this.match("\\relax"))return e;const t={glue:e};if(this.matchKeyword("plus")){const e=this.scanDimen();if(!e)return t;t.grow=e}if(this.skipWhitespace(),this.match("\\relax"))return t;if(this.skipWhitespace(),this.matchKeyword("minus")){const e=this.scanDimen();if(!e)return t;t.shrink=e}return t.grow||t.shrink?t:e}scanColspec(){this.skipWhitespace();const e=[];for(;!this.end()&&"<}>"!==this.peek()&&"]"!==this.peek();){const t=this.get();"c"===t||"r"===t||"l"===t?e.push({align:t}):"|"===t?e.push({separator:"solid"}):":"===t?e.push({separator:"dashed"}):"@"===t&&(this.match("<{>")&&(this.beginContext({mode:"math"}),e.push({gap:this.scan((e=>"<}>"===e))}),this.endContext()),this.match("<}>")||this.onError({code:"unbalanced-braces"}))}return e}scanModeSet(){let e;if(this.match("\\(")&&(e="textstyle"),!e&&this.match("\\[")&&(e="displaystyle"),!e)return null;this.beginContext({mode:"math",mathstyle:e});const t=this.scan((t=>t===("displaystyle"===e?"\\]":"\\)")));return this.match("displaystyle"===e?"\\]":"\\)")||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),t}scanModeShift(){let e="";if(this.match("<$>")&&(e="<$>"),!e&&this.match("<$$>")&&(e="<$$>"),!e)return null;this.beginContext({mode:"math",mathstyle:"textstyle"});const t=this.scan((t=>t===e));return this.match(e)||this.onError({code:"unbalanced-mode-shift"}),this.endContext(),t}scanEnvironment(){if(!this.match("\\begin"))return null;const e=this.scanArgument("string");if(!e)return null;const t=null!=(n=q[e])?n:null;var n;if(!t)return this.onError({code:"unknown-environment",arg:e}),null;const i=[];if(t.params)for(const n of t.params)if(n.isOptional)i.push(this.scanOptionalArgument(n.type));else{const t=this.scanArgument(n.type);t||this.onError({code:"missing-argument",arg:e}),i.push(t)}this.beginContext({tabular:t.tabular});const r=[],s=[];let a=[],o=!1;do{if(this.end()&&(this.onError({code:"unbalanced-environment",arg:e}),o=!0),!o&&this.match("\\end")&&(this.scanArgument("string")!==e&&this.onError({code:"unbalanced-environment",arg:e}),o=!0),!o)if(this.matchColumnSeparator())a.push(this.mathlist),this.mathlist=[];else if(this.matchRowSeparator()){a.push(this.mathlist),this.mathlist=[];let e=null;this.skipWhitespace(),this.match("[")&&(e=this.scanDimen(),this.skipWhitespace(),this.match("]")),s.push(null!=e?e:{dimension:0}),r.push(a),a=[]}else this.mathlist.push(...this.scan((e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline"].includes(e))))}while(!o);return a.push(this.mathlist),a.length>0&&r.push(a),this.endContext(),t.createAtom(e,r,s,i)}scanExpression(){const e=this.mathlist;if(this.mathlist=[],this.parseExpression()){const t=this.mathlist;return this.mathlist=e,t}return this.mathlist=e,null}scan(e){this.beginContext(),e||(e=e=>"<}>"===e);let t,n="",i=null,r=[],s=null;for(;!this.end()&&!e(this.peek());)this.hasInfixCommand()&&!n?(n=this.get(),i=ae(n,"math"),i&&(r=this.scanArguments(i)[1]),s=this.mathlist,this.mathlist=[]):this.parseExpression();return n?(console.assert(Boolean(i)),r.unshift(this.mathlist),s&&r.unshift(s),t=[i.createAtom({command:n,args:r,style:this.style,mode:this.parseMode})]):t=this.mathlist,this.endContext(),t}scanGroup(){const e=this.index;if(!this.match("<{>"))return null;const t=this.scan((e=>"<}>"===e));this.match("<}>")||this.onError({code:"unbalanced-braces"});const n=new qo(t,this.parseMode,this.style);return n.verbatimLatex=Qs(this.tokens.slice(e,this.index)),n}scanSmartFence(){if(this.skipWhitespace(),!this.match("("))return null;this.beginContext();let e=1;for(;!this.end()&&0!==e;)this.match("(")&&(e+=1),this.match(")")&&(e-=1),0!==e&&this.parseExpression();const t=new Go("",this.mathlist,{leftDelim:"(",rightDelim:0===e?")":"?"});return this.endContext(),t}scanDelim(){this.skipWhitespace();const e=this.peek();if(!e)return this.onError({code:"unexpected-end-of-string"}),null;if(!Xo(e)&&!e.startsWith("\\"))return null;this.next();const t=ae(e,"math");return t?"function"===t.definitionType&&t.ifMode&&!t.ifMode.includes(this.parseMode)?(this.onError({code:"unexpected-delimiter",arg:e}),null):"symbol"!==t.definitionType||"mopen"!==t.type&&"mclose"!==t.type?/^(\.|\?|\||<|>|\\vert|\\Vert|\\\||\\surd|\\uparrow|\\downarrow|\\Uparrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\mid|\\mvert|\\mVert)$/.test(e)?e:(this.onError({code:"unexpected-delimiter",arg:e}),null):e:(this.onError({code:"unknown-command",arg:e}),null)}scanLeftRight(){var e;if(this.match("\\right"))return this.onError({code:"unbalanced-braces"}),new Vo("\\right");if(this.match("\\mright"))return this.onError({code:"unbalanced-braces"}),new Vo("\\mright");let t="\\right";if(!this.match("\\left")){if(!this.match("\\mleft"))return null;t="\\mright"}const n=this.scanDelim();if(!n)return this.onError({code:"unexpected-delimiter"}),new Vo("\\right"===t?"\\left":"\\mleft");for(this.beginContext();!this.end()&&!this.match(t);)this.parseExpression();const i=this.mathlist;this.endContext();const r=null!=(e=this.scanDelim())?e:".";return new Go("\\right"===t?"left...right":"mleft...mright",i,{leftDelim:n,rightDelim:r,style:this.style})}parseSupSub(){if("math"!==this.parseMode)return!1;let e=this.peek();if("^"!==e&&"_"!==e&&"'"!==e)return!1;const t=this.lastSubsupAtom();for(;"^"===e||"_"===e||"'"===e;)this.match("'")?this.match("'")?t.addChild(new Ma({type:"mord",command:"\\doubleprime",mode:"math",value:"′′"}),"superscript"):t.addChild(new Ma({type:"mord",command:"\\prime",mode:"math",value:"′"}),"superscript"):(this.match("^")||this.match("_"))&&t.addChildren(N(this.scanArgument("expression")),"_"===e?"subscript":"superscript"),e=this.peek();return!0}parseLimits(){if("math"!==this.parseMode)return!1;const e=this.match("\\limits"),t=!e&&this.match("\\nolimits"),n=!t&&!e&&this.match("\\displaylimits");if(!e&&!t&&!n)return!1;const i=this.mathlist.length>0?this.mathlist[this.mathlist.length-1]:null;return null!==i&&(i.explicitSubsupPlacement=!0,e&&(i.subsupPlacement="over-under"),t&&(i.subsupPlacement="adjacent"),n&&(i.subsupPlacement="auto"),!0)}scanArguments(e){if(!(null==e?void 0:e.params))return[void 0,[]];let t;const n=[];let i=e.infix?2:0;for(;i<e.params.length;){const r=e.params[i];"rest"===r.type?n.push(this.scan((e=>["<}>","&","\\end","\\cr","\\\\","\\tabularnewline","\\right"].includes(e)))):r.isOptional?n.push(this.scanOptionalArgument(r.type)):r.type.endsWith("*")?t=r.type.slice(0,-1):n.push(this.scanArgument(r.type)),i+=1}return[t,n]}scanSymbolOrLiteral(){const e=this.peek();if(!e)return null;let t;if(this.next(),Xo(e)){const t=ta.createAtom(this.parseMode,e,u({},this.style));return t?[t]:null}if(t=this.scanMacro(e),t)return[t];if(e.startsWith("\\")){const n=ae(e,this.parseMode);if(!n)return this.onError({code:"unknown-command",arg:e}),[new Vo(e)];if("symbol"===n.definitionType){const i=u({},this.style);n.variant&&(i.variant=n.variant),t=new Ma({type:n.type,command:e,style:i,value:String.fromCodePoint(n.codepoint),mode:this.parseMode,verbatimLatex:e})}else{if(n.applyMode||n.applyStyle||n.infix)return this.onError({code:"invalid-command",arg:e}),[new Vo(e)];n.createAtom&&(t=n.createAtom({command:e,args:[],style:this.style,mode:this.parseMode}))}}return t?[t]:null}scanArgument(e){var t;this.skipFiller();const n=this.parseMode;if("auto"===e&&(e=n),!this.match("<{>")){if("string"===e)return this.scanString();if("value"===e)return this.scanValue();if("delim"===e)return null!=(t=this.scanDelim())?t:".";if("expression"===e)return this.scanExpression();if("math"===e){e!==n&&this.beginContext({mode:"math"});const t=this.scanSymbolOrLiteral();return e!==n&&this.endContext(),t}if("text"===e){e!==n&&this.beginContext({mode:"text"});const t=this.scanSymbolOrLiteral();return e!==n&&this.endContext(),t}return"balanced-string"===e||console.assert(!1),null}if("text"===e){this.beginContext({mode:"text"});do{this.mathlist.push(...this.scan())}while(!this.match("<}>")&&!this.end());const e=this.mathlist;return this.endContext(),{group:e}}if("math"===e){this.beginContext({mode:"math"});do{this.mathlist.push(...this.scan())}while(!this.match("<}>")&&!this.end());const e=this.mathlist;return this.endContext(),{group:e}}let i=null;if("expression"===e){this.beginContext({mode:"math"});do{this.mathlist.push(...this.scan())}while(!this.match("<}>")&&!this.end());const e=this.mathlist;return this.endContext(),{group:e}}return"string"===e?i=this.scanString():"balanced-string"===e?i=this.scanBalancedString():"colspec"===e?i=this.scanColspec():"value"===e&&(i=this.scanValue()),this.skipUntilToken("<}>"),i}scanOptionalArgument(e){if(e="auto"===e?this.parseMode:e,this.skipFiller(),!this.match("["))return null;let t=null;for(;!this.end()&&!this.match("]");)if("string"===e)t=this.scanString();else if("value"===e)t=this.scanValue();else if("colspec"===e)t=this.scanColspec();else if("bbox"===e){const e={},n=this.scanString().toLowerCase().trim().split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);for(const t of n){const n=t.match(/^\s*([\d.]+)\s*([a-z]{2})/);if(n)e.padding={dimension:parseInt(n[1]),unit:n[2]};else{const n=t.match(/^\s*border\s*:\s*(.*)/);n?e.border=n[1]:e.backgroundcolor={string:t}}}t=e}else"math"===e&&(this.beginContext({mode:"math"}),t=this.mathlist.concat(this.scan((e=>"]"===e))),this.endContext());return t}scanSymbolOrCommand(e){var t,n,i;if("\\placeholder"===e){const e=this.scanOptionalArgument("string"),t=this.scanOptionalArgument("math"),n=Ma.serialize(t,{defaultMode:"math"});let i,r=[];i||"correct"!==n?i||"incorrect"!==n?""!==n&&(r=t):i="incorrect":i="correct";const s="locked"===this.scanOptionalArgument("string"),a=this.scanArgument("auto");let o;return o=a&&Array.isArray(a)&&a.length>0?a:a&&"object"==typeof a&&"group"in a?a.group:r,e?[new Zo(e,i,s,null!=o?o:r,{mode:this.parseMode,style:this.style})]:[new Mo({mode:this.parseMode,style:this.style})]}if("\\renewcommand"===e||"\\newcommand"===e||"\\providecommand"===e||"\\def"===e){const t=this.index,n=this.scanLiteralGroup()||this.next();if(!n)return null;if(this.context.registers[n.substring(1)]){const i=this.scanArgument("string");null!==i&&(this.context.registers[n.substring(1)]=i);const r=Xs([e,Qs(this.tokens.slice(t,this.index))]);return[new Ma({type:"text",value:"",verbatimLatex:r})]}}let r=this.scanMacro(e);if(r)return[r];const s=ae(e,this.parseMode);if(!s)return"text"===this.parseMode?(/[a-zA-Z]/.test(null!=(t=this.peek())?t:"")&&(e+=" "),[...e].map((e=>new Ma({type:"text",value:e,mode:"text",style:this.style})))):(this.onError({code:"unknown-command",arg:e}),[new Vo(e)]);const a=this.index;if("symbol"===s.definitionType){const t=u({},this.style);s.variant&&(t.variant=s.variant),r=new Ma({type:s.type,command:e,style:t,value:String.fromCodePoint(s.codepoint),mode:this.parseMode})}else{if(s.ifMode&&!s.ifMode.includes(this.parseMode))return[];const t=this.parseMode;let a;s.applyMode&&(this.parseMode=s.applyMode);let o=[];if(s.parse?o=s.parse(this):[a,o]=this.scanArguments(s),this.parseMode=t,s.applyMode&&!s.applyStyle&&!s.createAtom)return N(o[0]);if(s.infix)return this.onError({code:"too-many-infix-commands",arg:e}),null;if("function"==typeof s.createAtom)r=s.createAtom({command:e,args:o,style:this.style,mode:this.parseMode}),a&&(r.body=N(this.scanArgument(a)));else if("function"==typeof s.applyStyle){const t=u(u({},this.style),s.applyStyle(e,o,this.context)),n=this.parseMode;if(s.applyMode&&(this.parseMode=s.applyMode),a){const e=this.style;this.style=t;const i=this.scanArgument(a);return this.style=e,this.parseMode=n,N(i)}this.style=t}else r=new Ma({type:"mord",command:null!=(n=s.command)?n:e,style:u({},this.style),value:e,mode:null!=(i=s.applyMode)?i:this.parseMode})}if(!r)return null;if(r instanceof Ma&&void 0===r.verbatimLatex&&!/^\\(llap|rlap|class|cssId|htmlData)$/.test(e)){const t=Xs([e,Qs(this.tokens.slice(a,this.index))]);t&&(r.verbatimLatex=t)}if(null===r.verbatimLatex&&(r.verbatimLatex=void 0),r.isFunction&&this.smartFence){const e=this.scanSmartFence();if(e)return[r,e]}return[r]}scanSymbolCommandOrLiteral(){const e=this.get();if(!e)return null;if(Xo(e)){const t=ta.createAtom(this.parseMode,e,u({},this.style));if(!t)return null;if(t.isFunction&&this.smartFence){const e=this.scanSmartFence();if(e)return[t,e]}return[t]}return e.startsWith("\\")?this.scanSymbolOrCommand(e):"<space>"===e?"text"===this.parseMode?[new Pa(" "," ",this.style)]:null:("<}>"===e?this.onError({latex:"",code:"unbalanced-braces"}):this.onError({latex:"",code:"unexpected-token",arg:e}),null)}scanMacro(e){var t;const n=this.context.getMacro(e);if(!n)return null;const i=this.index,r=n.args,s={"?":null==(t=this.args)?void 0:t.call(this,"?")};for(let e=1;e<=r;e++){let t=this.scanLiteralGroup();if(!t){const e=this.index;this.scanExpression(),t=Qs(this.tokens.slice(e,this.index))}s[e]=t}return new jo(e,{expand:n.expand,captureSelection:n.captureSelection,args:i===this.index?null:Qs(this.tokens.slice(i,this.index)),style:this.parsingContext.style,body:Qo(n.def,{context:this.context,parseMode:this.parseMode,args:e=>s[e],mathstyle:this.parsingContext.mathstyle,style:this.parsingContext.style})})}parseExpression(){var e,t,n,i;let r=null!=(i=null!=(n=null!=(t=null!=(e=this.scanEnvironment())?e:this.scanModeShift())?t:this.scanModeSet())?n:this.scanGroup())?i:this.scanLeftRight();if(null===r){if(this.parseSupSub())return!0;if(this.parseLimits())return!0;r=this.scanSymbolCommandOrLiteral()}return!!r&&(Array.isArray(r)?this.mathlist.push(...r):this.mathlist.push(r),!0)}};function Qo(e,t){var n,i,r,s;const a=null!=(n=null==t?void 0:t.args)?n:void 0,o=new Jo(Ys(e,a),null==t?void 0:t.context,{args:a,mathstyle:null!=(i=null==t?void 0:t.mathstyle)?i:"displaystyle",parseMode:null!=(r=null==t?void 0:t.parseMode)?r:"math",style:null!=(s=null==t?void 0:t.style)?s:{}}),l=[];for(;!o.end();)l.push(...o.scan((()=>!1)));return l}function el(e,t){var n;const i=new Jo(Ys(e,null),null==t?void 0:t.context,{mathstyle:"displaystyle",parseMode:null!=(n=null==t?void 0:t.parseMode)?n:"math"});for(;!i.end();)i.scan();return i.errors}var tl=class e extends Ma{constructor(e,t){super({type:"chem"},{command:e,mode:"math"});const n=il.go(nl.go(t,"\\pu"===e?"pu":"ce"),!1);this.body=Qo(n),this._verbatimLatex=e+"{"+t+"}",this.arg=t,this.captureSelection=!0}static fromJson(t){return new e(t.command,t.arg)}set verbatimLatex(e){}get verbatimLatex(){return this._verbatimLatex}toJson(){return h(u({},super.toJson()),{arg:this.arg})}render(e){const t=Ma.createBox(e,this.body,{type:"inner"});return this.caret&&(t.caret=this.caret),this.bind(e,t)}_serialize(e){return console.assert(void 0!==this.verbatimLatex),this.verbatimLatex}};ne(["ce","pu"],"{chemformula:balanced-string}",{createAtom:e=>{var t;return new tl(e.command,null!=(t=e.args[0])?t:"")}});var nl={go:function(e,t){if(!e)return[];void 0===t&&(t="ce");var n,i="0",r={};r.parenthesisLevel=0,e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var s=10,a=[];;){n!==e?(s=10,n=e):s--;var o=nl.stateMachines[t],l=o.transitions[i]||o.transitions["*"];e:for(var c=0;c<l.length;c++){var u=nl.patterns.match_(l[c].pattern,e);if(u){for(var h=l[c].task,d=0;d<h.action_.length;d++){var p;if(o.actions[h.action_[d].type_])p=o.actions[h.action_[d].type_](r,u.match_,h.action_[d].option);else{if(!nl.actions[h.action_[d].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+h.action_[d].type_+")"];p=nl.actions[h.action_[d].type_](r,u.match_,h.action_[d].option)}nl.concatArray(a,p)}if(i=h.nextState||i,!(e.length>0))return a;if(h.revisit||(e=u.remainder),!h.toContinue)break e}}if(s<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if("[object Array]"===Object.prototype.toString.call(t))for(var n=0;n<t.length;n++)e.push(t[n]);else e.push(t)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return t&&t[0]?{match_:t.slice(1),remainder:e.substr(t[0].length)}:null},"(-)(9)^(-9)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return t&&t[0]?{match_:t.slice(1),remainder:e.substr(t[0].length)}:null},"state of aggregation $":function(e){var t=nl.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))return t;var n=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return n?{match_:n[0],remainder:e.substr(n[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(e){return nl.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return nl.patterns.findObserveGroups(e,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return nl.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(e){return nl.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(e){return nl.patterns.findObserveGroups(e,"_{","","","}")},"_($...$)":function(e){return nl.patterns.findObserveGroups(e,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(e){return nl.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(e){return nl.patterns.findObserveGroups(e,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(e){return nl.patterns.findObserveGroups(e,"","{","}","")},"{(...)}":function(e){return nl.patterns.findObserveGroups(e,"{","","","}")},"$...$":function(e){return nl.patterns.findObserveGroups(e,"","$","$","")},"${(...)}$":function(e){return nl.patterns.findObserveGroups(e,"${","","","}$")},"$(...)$":function(e){return nl.patterns.findObserveGroups(e,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return nl.patterns.findObserveGroups(e,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return nl.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(e){return nl.patterns.findObserveGroups(e,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(e){return nl.patterns.findObserveGroups(e,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(e){return nl.patterns.findObserveGroups(e,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(e){return nl.patterns.findObserveGroups(e,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(e){return nl.patterns.findObserveGroups(e,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){var t;if(t=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:t[0],remainder:e.substr(t[0].length)};var n=nl.patterns.findObserveGroups(e,"","$","$","");return n&&(t=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:t[0],remainder:e.substr(t[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var t=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return t?{match_:t[0],remainder:e.substr(t[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,t,n,i,r,s,a,o,l,c){var u=function(e,t){if("string"==typeof t)return 0!==e.indexOf(t)?null:t;var n=e.match(t);return n?n[0]:null},h=u(e,t);if(null===h)return null;if(e=e.substr(h.length),null===(h=u(e,n)))return null;var d=function(e,t,n){for(var i=0;t<e.length;){var r=e.charAt(t),s=u(e.substr(t),n);if(null!==s&&0===i)return{endMatchBegin:t,endMatchEnd:t+s.length};if("{"===r)i++;else if("}"===r){if(0===i)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];i--}t++}return null}(e,h.length,i||r);if(null===d)return null;var p=e.substring(0,i?d.endMatchEnd:d.endMatchBegin);if(s||a){var f=this.findObserveGroups(e.substr(d.endMatchEnd),s,a,o,l);if(null===f)return null;var m=[p,f.match_];return{match_:c?m.join(""):m,remainder:f.remainder}}return{match_:p,remainder:e.substr(d.endMatchEnd)}},match_:function(e,t){var n=nl.patterns.patterns[e];if(void 0===n)throw["MhchemBugP","mhchem bug P. Please report. ("+e+")"];if("function"==typeof n)return nl.patterns.patterns[e](t);var i=t.match(n);return i?{match_:i[2]?[i[1],i[2]]:i[1]?i[1]:i[0],remainder:t.substr(i[0].length)}:null}},actions:{"a=":function(e,t){e.a=(e.a||"")+t},"b=":function(e,t){e.b=(e.b||"")+t},"p=":function(e,t){e.p=(e.p||"")+t},"o=":function(e,t){e.o=(e.o||"")+t},"q=":function(e,t){e.q=(e.q||"")+t},"d=":function(e,t){e.d=(e.d||"")+t},"rm=":function(e,t){e.rm=(e.rm||"")+t},"text=":function(e,t){e.text_=(e.text_||"")+t},insert:function(e,t,n){return{type_:n}},"insert+p1":function(e,t,n){return{type_:n,p1:t}},"insert+p1+p2":function(e,t,n){return{type_:n,p1:t[0],p2:t[1]}},copy:function(e,t){return t},rm:function(e,t){return{type_:"rm",p1:t||""}},text:function(e,t){return nl.go(t,"text")},"{text}":function(e,t){var n=["{"];return nl.concatArray(n,nl.go(t,"text")),n.push("}"),n},"tex-math":function(e,t){return nl.go(t,"tex-math")},"tex-math tight":function(e,t){return nl.go(t,"tex-math tight")},bond:function(e,t,n){return{type_:"bond",kind_:n||t}},"color0-output":function(e,t){return{type_:"color0",color:t[0]}},ce:function(e,t){return nl.go(t)},"1/2":function(e,t){var n=[];t.match(/^[+\-]/)&&(n.push(t.substr(0,1)),t=t.substr(1));var i=t.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return i[1]=i[1].replace(/\$/g,""),n.push({type_:"frac",p1:i[1],p2:i[2]}),i[3]&&(i[3]=i[3].replace(/\$/g,""),n.push({type_:"tex-math",p1:i[3]})),n},"9,9":function(e,t){return nl.go(t,"9,9")}},createTransitions:function(e){var t,n,i,r,s={};for(t in e)for(n in e[t])for(i=n.split("|"),e[t][n].stateArray=i,r=0;r<i.length;r++)s[i[r]]=[];for(t in e)for(n in e[t])for(i=e[t][n].stateArray||[],r=0;r<i.length;r++){var a=e[t][n];if(a.action_){a.action_=[].concat(a.action_);for(var o=0;o<a.action_.length;o++)"string"==typeof a.action_[o]&&(a.action_[o]={type_:a.action_[o]})}else a.action_=[];for(var l=t.split("|"),c=0;c<l.length;c++)if("*"===i[r])for(var u in s)s[u].push({pattern:l[c],task:a});else s[i[r]].push({pattern:l[c],task:a})}return s},stateMachines:{}};nl.stateMachines={ce:{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(e,t){var n;if((e.d||"").match(/^[0-9]+$/)){var i=e.d;e.d=void 0,n=this.output(e),e.b=i}else n=this.output(e);return nl.actions["o="](e,t),n},"d= kv":function(e,t){e.d=t,e.dType="kv"},"charge or bond":function(e,t){if(e.beginsWithBond){var n=[];return nl.concatArray(n,this.output(e)),nl.concatArray(n,nl.actions.bond(e,t,"-")),n}e.d=t},"- after o/d":function(e,t,n){var i=nl.patterns.match_("orbital",e.o||""),r=nl.patterns.match_("one lowercase greek letter $",e.o||""),s=nl.patterns.match_("one lowercase latin letter $",e.o||""),a=nl.patterns.match_("$one lowercase latin letter$ $",e.o||""),o="-"===t&&(i&&""===i.remainder||r||s||a);!o||e.a||e.b||e.p||e.d||e.q||i||!s||(e.o="$"+e.o+"$");var l=[];return o?(nl.concatArray(l,this.output(e)),l.push({type_:"hyphen"})):(i=nl.patterns.match_("digits",e.d||""),n&&i&&""===i.remainder?(nl.concatArray(l,nl.actions["d="](e,t)),nl.concatArray(l,this.output(e))):(nl.concatArray(l,this.output(e)),nl.concatArray(l,nl.actions.bond(e,t,"-")))),l},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,t){return{type_:"state of aggregation",p1:nl.go(t,"o")}},comma:function(e,t){var n=t.replace(/\s*$/,"");return n!==t&&0===e.parenthesisLevel?{type_:"comma enumeration L",p1:n}:{type_:"comma enumeration M",p1:n}},output:function(e,t,n){var i,r,s;e.r?(r="M"===e.rdt?nl.go(e.rd,"tex-math"):"T"===e.rdt?[{type_:"text",p1:e.rd||""}]:nl.go(e.rd),s="M"===e.rqt?nl.go(e.rq,"tex-math"):"T"===e.rqt?[{type_:"text",p1:e.rq||""}]:nl.go(e.rq),i={type_:"arrow",r:e.r,rd:r,rq:s}):(i=[],(e.a||e.b||e.p||e.o||e.q||e.d||n)&&(e.sb&&i.push({type_:"entitySkip"}),e.o||e.q||e.d||e.b||e.p||2===n?e.o||e.q||e.d||!e.b&&!e.p?e.o&&"kv"===e.dType&&nl.patterns.match_("d-oxidation$",e.d||"")?e.dType="oxidation":e.o&&"kv"===e.dType&&!e.q&&(e.dType=void 0):(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):(e.o=e.a,e.a=void 0),i.push({type_:"chemfive",a:nl.go(e.a,"a"),b:nl.go(e.b,"bd"),p:nl.go(e.p,"pq"),o:nl.go(e.o,"o"),q:nl.go(e.q,"pq"),d:nl.go(e.d,"oxidation"===e.dType?"oxidation":"bd"),dType:e.dType})));for(var a in e)"parenthesisLevel"!==a&&"beginsWithBond"!==a&&delete e[a];return i},"oxidation-output":function(e,t){var n=["{"];return nl.concatArray(n,nl.go(t,"oxidation")),n.push("}"),n},"frac-output":function(e,t){return{type_:"frac-ce",p1:nl.go(t[0]),p2:nl.go(t[1])}},"overset-output":function(e,t){return{type_:"overset",p1:nl.go(t[0]),p2:nl.go(t[1])}},"underset-output":function(e,t){return{type_:"underset",p1:nl.go(t[0]),p2:nl.go(t[1])}},"underbrace-output":function(e,t){return{type_:"underbrace",p1:nl.go(t[0]),p2:nl.go(t[1])}},"color-output":function(e,t){return{type_:"color",color1:t[0],color2:nl.go(t[1])}},"r=":function(e,t){e.r=t},"rdt=":function(e,t){e.rdt=t},"rd=":function(e,t){e.rd=t},"rqt=":function(e,t){e.rqt=t},"rq=":function(e,t){e.rq=t},operator:function(e,t,n){return{type_:"operator",kind_:n||t}}}},a:{transitions:nl.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:nl.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(e){if(e.text_){var t={type_:"text",p1:e.text_};for(var n in e)delete e[n];return t}}}},pq:{transitions:nl.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(e,t){return{type_:"state of aggregation subscript",p1:nl.go(t,"o")}},"color-output":function(e,t){return{type_:"color",color1:t[0],color2:nl.go(t[1],"pq")}}}},bd:{transitions:nl.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(e,t){return{type_:"color",color1:t[0],color2:nl.go(t[1],"bd")}}}},oxidation:{transitions:nl.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(e,t){return{type_:"roman numeral",p1:t||""}}}},"tex-math":{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(e){if(e.o){var t={type_:"tex-math",p1:e.o};for(var n in e)delete e[n];return t}}}},"tex-math tight":{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(e,t){e.o=(e.o||"")+"{"+t+"}"},output:function(e){if(e.o){var t={type_:"tex-math",p1:e.o};for(var n in e)delete e[n];return t}}}},"9,9":{transitions:nl.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(e,t){var n=[];return"+-"===t[0]||"+/-"===t[0]?n.push("\\pm "):t[0]&&n.push(t[0]),t[1]&&(nl.concatArray(n,nl.go(t[1],"pu-9,9")),t[2]&&(t[2].match(/[,.]/)?nl.concatArray(n,nl.go(t[2],"pu-9,9")):n.push(t[2])),(t[3]||t[4])&&("e"===t[3]||"*"===t[4]?n.push({type_:"cdot"}):n.push({type_:"times"}))),t[5]&&n.push("10^{"+t[5]+"}"),n},"number^":function(e,t){var n=[];return"+-"===t[0]||"+/-"===t[0]?n.push("\\pm "):t[0]&&n.push(t[0]),nl.concatArray(n,nl.go(t[1],"pu-9,9")),n.push("^{"+t[2]+"}"),n},operator:function(e,t,n){return{type_:"operator",kind_:n||t}},space:function(){return{type_:"pu-space-1"}},output:function(e){var t,n=nl.patterns.match_("{(...)}",e.d||"");n&&""===n.remainder&&(e.d=n.match_);var i=nl.patterns.match_("{(...)}",e.q||"");if(i&&""===i.remainder&&(e.q=i.match_),e.d&&(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.d=e.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var r={d:nl.go(e.d,"pu"),q:nl.go(e.q,"pu")};"//"===e.o?t={type_:"pu-frac",p1:r.d,p2:r.q}:(t=r.d,r.d.length>1||r.q.length>1?t.push({type_:" / "}):t.push({type_:"/"}),nl.concatArray(t,r.q))}else t=nl.go(e.d,"pu-2");for(var s in e)delete e[s];return t}}},"pu-2":{transitions:nl.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(e,t){e.rm+="^{"+t+"}"},space:function(){return{type_:"pu-space-2"}},output:function(e){var t=[];if(e.rm){var n=nl.patterns.match_("{(...)}",e.rm||"");t=n&&""===n.remainder?nl.go(n.match_,"pu"):{type_:"rm",p1:e.rm}}for(var i in e)delete e[i];return t}}},"pu-9,9":{transitions:nl.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(e){var t=[];if(e.text_=e.text_||"",e.text_.length>4){var n=e.text_.length%3;0===n&&(n=3);for(var i=e.text_.length-3;i>0;i-=3)t.push(e.text_.substr(i,3)),t.push({type_:"1000 separator"});t.push(e.text_.substr(0,n)),t.reverse()}else t.push(e.text_);for(var r in e)delete e[r];return t},"output-o":function(e){var t=[];if(e.text_=e.text_||"",e.text_.length>4){for(var n=e.text_.length-3,i=0;i<n;i+=3)t.push(e.text_.substr(i,3)),t.push({type_:"1000 separator"});t.push(e.text_.substr(i))}else t.push(e.text_);for(var r in e)delete e[r];return t}}}};var il={go:function(e,t){if(!e)return"";for(var n="",i=!1,r=0;r<e.length;r++){var s=e[r];"string"==typeof s?n+=s:(n+=il._go2(s),"1st-level escape"===s.type_&&(i=!0))}return t||i||!n||(n="{"+n+"}"),n},_goInner:function(e){return e?il.go(e,!0):e},_go2:function(e){var t;switch(e.type_){case"chemfive":t="";var n={a:il._goInner(e.a),b:il._goInner(e.b),p:il._goInner(e.p),o:il._goInner(e.o),q:il._goInner(e.q),d:il._goInner(e.d)};n.a&&(n.a.match(/^[+\-]/)&&(n.a="{"+n.a+"}"),t+=n.a+"\\,"),(n.b||n.p)&&(t+="{\\vphantom{X}}",t+="^{\\hphantom{"+(n.b||"")+"}}_{\\hphantom{"+(n.p||"")+"}}",t+="{\\vphantom{X}}",t+="^{\\smash[t]{\\vphantom{2}}\\llap{"+(n.b||"")+"}}",t+="_{\\vphantom{2}\\llap{\\smash[t]{"+(n.p||"")+"}}}"),n.o&&(n.o.match(/^[+\-]/)&&(n.o="{"+n.o+"}"),t+=n.o),"kv"===e.dType?((n.d||n.q)&&(t+="{\\vphantom{X}}"),n.d&&(t+="^{"+n.d+"}"),n.q&&(t+="_{\\smash[t]{"+n.q+"}}")):"oxidation"===e.dType?(n.d&&(t+="{\\vphantom{X}}",t+="^{"+n.d+"}"),n.q&&(t+="{\\vphantom{X}}",t+="_{\\smash[t]{"+n.q+"}}")):(n.q&&(t+="{\\vphantom{X}}",t+="_{\\smash[t]{"+n.q+"}}"),n.d&&(t+="{\\vphantom{X}}",t+="^{"+n.d+"}"));break;case"rm":case"roman numeral":t="\\mathrm{"+e.p1+"}";break;case"text":e.p1.match(/[\^_]/)?(e.p1=e.p1.replace(" ","~").replace("-","\\text{-}"),t="\\mathrm{"+e.p1+"}"):t="\\text{"+e.p1+"}";break;case"state of aggregation":t="\\mskip2mu "+il._goInner(e.p1);break;case"state of aggregation subscript":t="\\mskip1mu "+il._goInner(e.p1);break;case"bond":if(!(t=il._getBond(e.kind_)))throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+e.kind_+")"];break;case"frac":var i="\\frac{"+e.p1+"}{"+e.p2+"}";t="\\mathchoice{\\textstyle"+i+"}{"+i+"}{"+i+"}{"+i+"}";break;case"pu-frac":var r="\\frac{"+il._goInner(e.p1)+"}{"+il._goInner(e.p2)+"}";t="\\mathchoice{\\textstyle"+r+"}{"+r+"}{"+r+"}{"+r+"}";break;case"tex-math":case"1st-level escape":t=e.p1+" ";break;case"frac-ce":t="\\frac{"+il._goInner(e.p1)+"}{"+il._goInner(e.p2)+"}";break;case"overset":t="\\overset{"+il._goInner(e.p1)+"}{"+il._goInner(e.p2)+"}";break;case"underset":t="\\underset{"+il._goInner(e.p1)+"}{"+il._goInner(e.p2)+"}";break;case"underbrace":t="\\underbrace{"+il._goInner(e.p1)+"}_{"+il._goInner(e.p2)+"}";break;case"color":t="{\\color{"+e.color1+"}{"+il._goInner(e.color2)+"}}";break;case"color0":t="\\color{"+e.color+"}";break;case"arrow":var s={rd:il._goInner(e.rd),rq:il._goInner(e.rq)},a=il._getArrow(e.r);s.rd||s.rq?"<=>"===e.r||"<=>>"===e.r||"<<=>"===e.r||"<--\x3e"===e.r?(a="\\long"+a,s.rd&&(a="\\overset{"+s.rd+"}{"+a+"}"),s.rq&&(a="<--\x3e"===e.r?"\\underset{\\lower2mu{"+s.rq+"}}{"+a+"}":"\\underset{\\lower6mu{"+s.rq+"}}{"+a+"}"),a=" {}\\mathrel{"+a+"}{} "):(s.rq&&(a+="[{"+s.rq+"}]"),a=" {}\\mathrel{\\x"+(a+="{"+s.rd+"}")+"}{} "):a=" {}\\mathrel{\\long"+a+"}{} ",t=a;break;case"operator":t=il._getOperator(e.kind_);break;case"space":t=" ";break;case"entitySkip":case"pu-space-1":t="~";break;case"pu-space-2":t="\\mkern3mu ";break;case"1000 separator":t="\\mkern2mu ";break;case"commaDecimal":t="{,}";break;case"comma enumeration L":t="{"+e.p1+"}\\mkern6mu ";break;case"comma enumeration M":t="{"+e.p1+"}\\mkern3mu ";break;case"comma enumeration S":t="{"+e.p1+"}\\mkern1mu ";break;case"hyphen":t="\\text{-}";break;case"addition compound":t="\\,{\\cdot}\\,";break;case"electron dot":t="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":t="{\\times}";break;case"prime":t="\\prime ";break;case"cdot":t="\\cdot ";break;case"tight cdot":t="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":t="\\times ";break;case"circa":t="{\\sim}";break;case"^":t="uparrow";break;case"v":t="downarrow";break;case"ellipsis":t="\\ldots ";break;case"/":t="/";break;case" / ":t="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return t},_getArrow:function(e){switch(e){case"->":case"→":case"⟶":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"leftrightarrows";case"<=>":case"⇌":return"rightleftharpoons";case"<=>>":return"Rightleftharpoons";case"<<=>":return"Leftrightharpoons";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(e){switch(e){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}";case"~=":case"~--":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}";case"-~-":return"{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(e){switch(e){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};var rl=class e extends Ma{constructor(e){super(h(u({},e),{type:"delim"})),this.value=e.delim,this.size=e.size}static fromJson(t){return new e(t)}toJson(){return h(u({},super.toJson()),{delim:this.value,size:this.size})}render(e){return new ca(this.value,{type:"middle"})}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);return(null==t?void 0:t.serialize)?t.serialize(this,e):Js(this.command,this.value)}},sl=class e extends Ma{constructor(e){super(h(u({},e),{type:"sizeddelim",value:e.delim})),this.delimType=e.delimType,this.size=e.size}static fromJson(t){return new e(t)}toJson(){return h(u({},super.toJson()),{delim:this.value,size:this.size,delimType:this.delimType})}render(e){let t=function(e,t,n,i){return void 0===e||"."===e?Do(n,i.classes):("<"===e||"\\lt"===e||"⟨"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"⟩"!==e||(e="\\rangle"),wo.has(e)||ko.has(e)?vo(e,t,!1,n,i):xo.has(e)?bo(e,So[t],!1,n,i):(console.assert(!1,"Unknown delimiter '"+e+"'"),null))}(this.value,this.size,e,{classes:{open:"mopen",close:"mclose"}[this.delimType],type:this.delimType,isSelected:this.isSelected});return t?(t=this.bind(e,t),this.caret&&(t.caret=this.caret),t):null}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);return(null==t?void 0:t.serialize)?t.serialize(this,e):Js(this.command,this.value)}},al=class e extends Ma{constructor(e,t,n,i){var r,s;super({type:"enclose",command:e,style:i.style}),this.body=t,this.backgroundcolor=i.backgroundcolor,n.updiagonalarrow&&(n.updiagonalstrike=!1),n.box&&(n.left=!1,n.right=!1,n.bottom=!1,n.top=!1),this.notation=n,this.shadow=null!=(r=i.shadow)?r:"none",this.strokeWidth=null!=(s=i.strokeWidth)?s:"0.06em",this.strokeWidth||(this.strokeWidth="0.06em"),this.strokeStyle=i.strokeStyle,this.svgStrokeStyle=i.svgStrokeStyle,this.strokeColor=i.strokeColor,this.borderStyle=i.borderStyle,this.padding=i.padding,this.captureSelection=!1}static fromJson(t){return new e(t.command,t.body,t.notation,t)}toJson(){return h(u({},super.toJson()),{notation:this.notation,shadow:this.shadow,strokeWidth:this.strokeWidth,strokeStyle:this.strokeStyle,svgStrokeStyle:this.svgStrokeStyle,strokeColor:this.strokeColor,borderStyle:this.borderStyle,padding:this.padding})}_serialize(e){var t;if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const n=ae(this.command,this.mode);if(null==n?void 0:n.serialize)return n.serialize(this,e);let i=null!=(t=this.command)?t:"";if("\\enclose"===this.command){i+="{"+Object.keys(this.notation).join(" ")+"}";let e="",t="";this.backgroundcolor&&"transparent"!==this.backgroundcolor&&(e+=t+'mathbackground="'+this.backgroundcolor+'"',t=","),this.shadow&&"auto"!==this.shadow&&(e+=t+'shadow="'+this.shadow+'"',t=","),this.strokeWidth||"solid"!==this.strokeStyle?(e+=t+this.borderStyle,t=","):this.strokeColor&&"currentColor"!==this.strokeColor&&(e+=t+'mathcolor="'+this.strokeColor+'"',t=","),e&&(i+=`[${e}]`)}return Js(i,this.bodyToLatex(e))}render(e){const t=new Ca({parent:e},this.style),n=Ma.createBox(t,this.body);if(!n)return null;const i=function(e){if(!e)return"1px";const t=e.match(/([0-9][a-zA-Z\%]+)/);return null===t?"1px":t[1]}(this.borderStyle),r=t.toEm(this.padding&&"auto"!==this.padding?{string:this.padding}:{register:"fboxsep"});n.setStyle("position","relative"),n.setStyle("display","inline-block"),n.setStyle("top",r,"em"),n.setStyle("height",n.height+n.depth,"em"),n.setStyle("width",n.width,"em");const s=new ca(null,{classes:"ML__notation"});let a=n.height+n.depth+2*r;const o=n.width+2*r;let l="";if(this.notation.horizontalstrike&&(l+=this.line(3,50,97,50)),this.notation.verticalstrike&&(l+=this.line(50,3,50,97)),this.notation.updiagonalstrike&&(l+=this.line(3,97,97,3)),this.notation.downdiagonalstrike&&(l+=this.line(3,3,97,97)),this.notation.updiagonalarrow){l+=this.line(r.toString(),(r+n.depth+n.height).toString(),(r+n.width).toString(),r.toString());const e=1,t=.03*Math.sqrt(o*o+a*a)*e,i=n.width*t,s=(n.depth+n.height)*t,c=r+n.width;let u=r;u+s-.4*i<0&&(u=.4*i-s),l+='<polygon points="',l+=`${c},${u} ${c-i-.4*s},${u+s-.4*i} `,l+=`${c-.7*i},${u+.7*s} ${c-i+.4*s},${u+s+.4*i} `,l+=`${c},${u}`,l+=`" stroke='none' fill="${this.strokeColor}"`,l+="/>"}let c=0;if(this.notation.phasorangle){const e=ll(t),i=(n.height+n.depth+2*e+r).toString(),s=(n.height+n.depth)/2;l+=this.line(r.toString(),i,(r+s+n.width).toString(),i),l+=this.line(r.toString(),i,(r+s).toString(),(r-e).toString()),a+=e,c=s,n.left+=a/2-r}if(this.notation.longdiv){const e=ll(t);a+=e,l+=this.line(r.toString(),r.toString(),(r+n.width).toString(),r.toString());const i=.3;c=i+e,n.left+=i+e,n.setTop(r+e),l+='<path d="',l+=`M ${r} ${r} a${i} ${(n.depth+n.height+2*e)/2}, 0, 1, 1, 0 ${n.depth+n.height+2*e} "`,l+=` stroke-width="${u=t,(Math.floor(100*u.metrics.sqrtRuleThickness/u.scalingFactor)/100/10).toString()+"em"}" stroke="${this.strokeColor}" fill="none"`,l+="/>"}var u;if(s.width=n.width+2*r+c,s.height=n.height+r,s.depth=n.depth+r,s.setStyle("box-sizing","border-box"),s.setStyle("left",`calc(-${i} / 2 )`),s.setStyle("height",Math.floor(100*a)/100+"em"),s.setStyle("top",`calc(${i} / 2 )`),this.backgroundcolor&&s.setStyle("background-color",this.backgroundcolor),this.notation.box&&s.setStyle("border","1px solid red"),this.notation.actuarial&&(s.setStyle("border-top",this.borderStyle),s.setStyle("border-right",this.borderStyle)),this.notation.madruwb&&(s.setStyle("border-bottom",this.borderStyle),s.setStyle("border-right",this.borderStyle)),this.notation.roundedbox&&(s.setStyle("border-radius","8px"),s.setStyle("border",this.borderStyle)),this.notation.circle&&(s.setStyle("border-radius","50%"),s.setStyle("border",this.borderStyle)),this.notation.top&&s.setStyle("border-top",this.borderStyle),this.notation.left&&s.setStyle("border-left",this.borderStyle),this.notation.right&&s.setStyle("border-right",this.borderStyle),this.notation.bottom&&s.setStyle("border-bottom",this.borderStyle),l){let e="";"auto"===this.shadow&&(e+="filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .7)) drop-shadow(1px 1px 2px #333)"),"none"!==this.shadow&&(e+=`filter: drop-shadow(${this.shadow})`),e+=` stroke-width="${this.strokeWidth}" stroke="${this.strokeColor}"`,e+=' stroke-linecap="round"',this.svgStrokeStyle&&(e+=` stroke-dasharray="${this.svgStrokeStyle}"`),s.svgStyle=e,s.svgOverlay=l}const h=new ca([s,n]);return h.setStyle("position","relative"),h.setStyle("vertical-align",r,"em"),h.setStyle("height",Math.floor(100*(n.height+n.depth+2*r))/100+"em"),h.setStyle("display","inline-block"),h.height=s.height,h.depth=s.depth,h.width=s.width-2*r,h.left=r,h.right=r,this.caret&&(h.caret=this.caret),h.wrap(t)}line(e,t,n,i){return`<line x1="${ol(e)}" y1="${ol(t)}" x2="${ol(n)}" y2="${ol(i)}" vector-effect="non-scaling-stroke"></line>`}};function ol(e){return"number"==typeof e?Math.floor(100*e)/100+"%":e}function ll(e){const t=e.isDisplayStyle?Ps:e.metrics.defaultRuleThickness;return e.metrics.defaultRuleThickness+e.scalingFactor*t/4}var cl=class e extends Ma{constructor(e,t,n){var i,r;super(h(u({},n),{type:"genfrac",displayContainsHighlight:!0})),this.above=e,this.below=t,this.hasBarLine=null==(i=null==n?void 0:n.hasBarLine)||i,this.continuousFraction=null!=(r=null==n?void 0:n.continuousFraction)&&r,this.numerPrefix=null==n?void 0:n.numerPrefix,this.denomPrefix=null==n?void 0:n.denomPrefix,this.mathstyleName=null==n?void 0:n.mathstyleName,this.leftDelim=null==n?void 0:n.leftDelim,this.rightDelim=null==n?void 0:n.rightDelim,this.fractionNavigationOrder=null==n?void 0:n.fractionNavigationOrder}static fromJson(t){return new e(t.above,t.below,t)}toJson(){const e={};return this.continuousFraction&&(e.continuousFraction=!0),this.numerPrefix&&(e.numerPrefix=this.numerPrefix),this.denomPrefix&&(e.denomPrefix=this.denomPrefix),this.leftDelim&&(e.leftDelim=this.leftDelim),this.rightDelim&&(e.rightDelim=this.rightDelim),this.hasBarLine||(e.hasBarLine=!1),this.mathstyleName&&(e.mathstyleName=this.mathstyleName),this.fractionNavigationOrder&&(e.fractionNavigationOrder=this.fractionNavigationOrder),u(u({},super.toJson()),e)}get children(){if(this._children)return this._children;const e=[];if("denominator-numerator"===this.fractionNavigationOrder){for(const t of this.below)e.push(...t.children),e.push(t);for(const t of this.above)e.push(...t.children),e.push(t)}else{for(const t of this.above)e.push(...t.children),e.push(t);for(const t of this.below)e.push(...t.children),e.push(t)}return this._children=e,e}render(e){var t,n;const i=new Ca({parent:e,mathstyle:this.mathstyleName},this.style),r=i.metrics,s=new Ca({parent:i,mathstyle:this.continuousFraction?"":"numerator"},this.style),a=this.numerPrefix?new ca([new ca(this.numerPrefix),Ma.createBox(s,this.above)],{isTight:s.isTight,type:"ignore"}):null!=(t=Ma.createBox(s,this.above,{type:"ignore"}))?t:new ca(null,{type:"ignore"}),o=new Ca({parent:i,mathstyle:this.continuousFraction?"":"denominator"},this.style),l=this.denomPrefix?new ca([new ca(this.denomPrefix),Ma.createBox(o,this.below,{type:"ignore"})]):null!=(n=Ma.createBox(o,this.below,{type:"ignore"}))?n:new ca(null,{type:"ignore"}),c=this.hasBarLine?r.defaultRuleThickness:0;let u,h,d=0;i.isDisplayStyle?(u=s.metrics.num1,d=c>0?3*c:7*c,h=o.metrics.denom1):(c>0?(u=s.metrics.num2,d=c):(u=s.metrics.num3,d=3*r.defaultRuleThickness),h=o.metrics.denom2);const p=[];this.isSelected&&p.push("ML__selected");const f=a.depth,m=l.height;let g;if(c<=0){const e=u-f-(m-h);e<d&&(u+=(d-e)/2,h+=(d-e)/2),g=new ma({individualShift:[{box:a,shift:-u,classes:[...p,"ML__center"]},{box:l,shift:h,classes:[...p,"ML__center"]}]}).wrap(i)}else{const e=new ca(null,{classes:"ML__frac-line",mode:this.mode,style:this.style});e.softWidth=Math.max(a.width,l.width),e.height=c/2,e.depth=c/2;const t=Is+c/2;u<d+f+t&&(u=d+f+t);const n=Is-c/2;h<d+m-n&&(h=d+m-n),g=new ma({individualShift:[{box:l,shift:h,classes:[...p,"ML__center"]},{box:e,shift:-n,classes:p},{box:a,shift:-u,classes:[...p,"ML__center"]}]}).wrap(i)}const _=i.isDisplayStyle?r.delim1:r.delim2,y=this.leftDelim?this.bind(e,Lo("open",this.leftDelim,_,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):Do(i,"open");let v=null;v=this.continuousFraction?new ca(null,{type:"close"}):this.rightDelim?this.bind(e,Lo("close",this.rightDelim,_,!0,e,{style:this.style,mode:this.mode,isSelected:this.isSelected})):Do(i,"close");const b=new ca([y,g,v],{isTight:i.isTight,type:"inner",classes:"mfrac"}),w=this.bind(e,b);return this.caret&&(w.caret=this.caret),this.attachSupsub(e,{base:w})}},ul=class e extends Ma{constructor(e,t){var n;super({type:"latex",value:e,mode:"latex"}),this.isSuggestion=null!=(n=null==t?void 0:t.isSuggestion)&&n,this.isError=!1}static fromJson(t){const n=new e(t.value);return t.isSuggestion&&(n.isSuggestion=!0),t.isError&&(n.isError=!0),n}toJson(){const e={};return this.isSuggestion&&(e.isSuggestion=!0),this.isError&&(e.isError=!0),u({type:"latex",value:this.value},e)}get computedStyle(){return{}}render(e){const t=new ca(this.value,{classes:this.isSuggestion?"ML__suggestion":this.isError?"ML__error":"",type:"latex",maxFontSize:1});return t?(this.caret&&(t.caret=this.caret),this.bind(e,t)):null}},hl=class e extends Ma{constructor(e){super({type:"latexgroup",mode:"latex"}),this.body=[...e].map((e=>new ul(e))),this.skipBoundary=!1}static fromJson(t){return new e("")}toJson(){return super.toJson()}render(e){const t=Ma.createBox(e,this.body);return t?(this.caret&&(t.caret=this.caret),this.bind(e,t)):null}_serialize(e){var t,n;return null!=(n=null==(t=this.body)?void 0:t.map((e=>e.value)).join(""))?n:""}},dl=class e extends Ma{constructor(e,t){super(h(u({},t),{type:"extensible-symbol",isFunction:null==t?void 0:t.isFunction})),this.value=e,this.variant=null==t?void 0:t.variant,this.subsupPlacement=null==t?void 0:t.limits}static fromJson(t){return new e(t.symbol,t)}toJson(){const e=super.toJson();return this.variant&&(e.variant=this.variant),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.isExtensibleSymbol&&(e.isExtensibleSymbol=!0),this.value&&(e.symbol=this.value),e}render(e){var t;const n=e.isDisplayStyle&&"\\smallint"!==this.value,i=new ca(this.value,{fontFamily:n?"Size2-Regular":"Size1-Regular",classes:"op-symbol "+(n?"large-op":"small-op"),type:"op",maxFontSize:e.scalingFactor,isSelected:this.isSelected});if(!i)return null;i.right=i.italic;const r=(i.height-i.depth)/2-Is*e.scalingFactor,s=i.italic;i.setTop(r);let a=i;if(this.superscript||this.subscript){const n=null!=(t=this.subsupPlacement)?t:"auto";a="over-under"===n||"auto"===n&&e.isDisplayStyle?this.attachLimits(e,{base:i,baseShift:r,slant:s}):this.attachSupsub(e,{base:i})}return new ca(this.bind(e,a),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);if(null==t?void 0:t.serialize)return t.serialize(this,e);const n=[];return n.push(this.command),this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&n.push("\\limits"),"adjacent"===this.subsupPlacement&&n.push("\\nolimits"),"auto"===this.subsupPlacement&&n.push("\\displaylimits")),n.push(this.supsubToLatex(e)),Xs(n)}},pl=class e extends Ma{constructor(e){const t=e.body;super(h(u({},e),{type:"overlap",body:"string"==typeof t?[new Ma({value:t})]:t,style:null==e?void 0:e.style})),this.skipBoundary=!0,this.align=null==e?void 0:e.align,this.boxType=null==e?void 0:e.boxType}static fromJson(t){return new e(t)}toJson(){const e={};return this.align&&(e.align=this.align),this.boxType&&(e.boxType=this.boxType),u(u({},super.toJson()),e)}render(e){const t=Ma.createBox(e,this.body,{classes:"inner"});return t?(this.caret&&(t.caret=this.caret),this.bind(e,new ca([t,new ca(null,{classes:"fix"})],{classes:"right"===this.align?"rlap":"llap",type:this.boxType}))):null}},fl=class e extends Ma{constructor(e){var t,n,i,r;super({type:"overunder",command:e.command,style:e.style,mode:e.mode,body:e.body,skipBoundary:null==(t=e.skipBoundary)||t}),this.subsupPlacement=e.supsubPlacement,this.svgAbove=e.svgAbove,this.svgBelow=e.svgBelow,this.svgBody=e.svgBody,this.above=e.above,this.below=e.below,this.boxType=null!=(n=e.boxType)?n:"ord",this.paddedBody=null!=(i=e.paddedBody)&&i,this.paddedLabels=null!=(r=e.paddedLabels)&&r}static fromJson(t){return new e(t)}toJson(){const e=super.toJson();return this.skipBoundary||(e.skipBoundary=!1),this.subsupPlacement&&(e.subsupPlacement=this.subsupPlacement),this.svgAbove&&(e.svgAbove=this.svgAbove),this.svgBelow&&(e.svgBelow=this.svgBelow),this.svgBody&&(e.svgBody=this.svgBody),"ord"!==this.boxType&&(e.boxType=this.boxType),this.paddedBody&&(e.paddedBody=!0),this.paddedLabels&&(e.paddedLabels=!0),e}render(e){let t=this.svgBody?pa(this.svgBody):Ma.createBox(e,this.body,{type:"ignore"});const n=new Ca({parent:e,mathstyle:"scriptstyle"},this.style);let i=null;this.svgAbove?i=pa(this.svgAbove):this.above&&(i=Ma.createBox(n,this.above,{type:"ignore"}));let r=null;this.svgBelow?r=pa(this.svgBelow):this.below&&(r=Ma.createBox(n,this.below,{type:"ignore"})),this.paddedBody&&(t=new ca([Do(e,"open"),t,Do(e,"close")],{type:"ignore"}));let s=function(e,t){if(!t.base)return null;if(!t.above&&!t.below){const e=new ca(t.base,{type:t.type});return e.setStyle("position","relative"),e}let n=0;t.above&&(n=e.metrics.bigOpSpacing5);let i=null;const r=t.base,s=0,a=["ML__center"];t.paddedAboveBelow&&a.push("ML__label_padding");if(t.below&&t.above){const o=e.metrics.bigOpSpacing5+t.below.height+t.below.depth+r.depth+s;i=new ma({bottom:o,children:[e.metrics.bigOpSpacing5,{box:t.below,classes:a},{box:r,classes:["ML__center"]},n,{box:t.above,classes:a},e.metrics.bigOpSpacing5]})}else t.below?i=new ma({top:r.height-s,children:[e.metrics.bigOpSpacing5,{box:t.below,classes:a},{box:r,classes:["ML__center"]}]}):t.above&&(i=new ma({bottom:r.depth+s,children:[{box:r,classes:["ML__center"]},n,{box:t.above,classes:a},e.metrics.bigOpSpacing5]}));return new ca(i,{type:t.type})}(e,{base:t,above:i,below:r,type:"bin"===this.boxType||"rel"===this.boxType?this.boxType:"ord",paddedAboveBelow:this.paddedLabels});return s?(s="over-under"===this.subsupPlacement?this.attachLimits(e,{base:s,type:s.type}):this.attachSupsub(e,{base:s}),this.caret&&(s.caret=this.caret),this.bind(e,s)):null}};var ml=class e extends Ma{constructor(e){var t,n,i,r;super(h(u({},e),{type:"phantom"})),this.captureSelection=!0,this.isInvisible=null!=(t=e.isInvisible)&&t,this.smashDepth=null!=(n=e.smashDepth)&&n,this.smashHeight=null!=(i=e.smashHeight)&&i,this.smashWidth=null!=(r=e.smashWidth)&&r}static fromJson(t){return new e(t)}toJson(){const e={};return this.isInvisible&&(e.isInvisible=!0),this.smashDepth&&(e.smashDepth=!0),this.smashHeight&&(e.smashHeight=!0),this.smashWidth&&(e.smashWidth=!0),u(u({},super.toJson()),e)}render(e){const t=new Ca({parent:e,isPhantom:!0});if(!this.smashDepth&&!this.smashHeight&&!this.smashWidth)return console.assert(this.isInvisible),Ma.createBox(t,this.body,{classes:"inner"});const n=Ma.createBox(this.isInvisible?t:e,this.body);if(!n)return null;if(this.smashWidth){const t=new ca(null,{classes:"fix"});return new ca([n,t],{classes:"rlap"}).wrap(e)}if(!this.smashHeight&&!this.smashDepth)return n;if(this.smashHeight&&(n.height=0),this.smashDepth&&(n.depth=0),n.children)for(const e of n.children)this.smashHeight&&(e.height=0),this.smashDepth&&(e.depth=0);return new ma({firstBaseline:[{box:n}]},{type:n.type}).wrap(e)}},gl=class e extends Ma{constructor(e){var t;super(u({type:"spacing"},e)),this.width=null==e?void 0:e.width,this._braced=null!=(t=null==e?void 0:e.braced)&&t}static fromJson(t){return new e(t)}toJson(){const e=super.toJson();return void 0!==this.width&&(e.width=this.width),this._braced&&(e.braced=!0),e}render(e){var t;if("space"===this.command)return new ca("math"===this.mode?null:" ");let n;if(void 0!==this.width)n=new ca(null,{classes:"mspace"}),n.left=e.toEm(this.width);else{const e=null!=(t={"\\qquad":"qquad","\\quad":"quad","\\enspace":"enspace","\\;":"thickspace","\\:":"mediumspace","\\>":"mediumspace","\\,":"thinspace","\\!":"negativethinspace"}[this.command])?t:"mediumspace";n=new ca(null,{classes:e})}return n=this.bind(e,n),this.caret&&(n.caret=this.caret),n}_serialize(e){var t;if(!e.expandMacro&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const n=ae(this.command,this.mode);if(null==n?void 0:n.serialize)return n.serialize(this,e);const i=null!=(t=this.command)?t:"";return void 0===this.width?i:this._braced&&!("register"in this.width)?`${i}{${xa(this.width)}}`:`${i}${xa(this.width)}`}},_l=class e extends Ma{constructor(e){var t;super(h(u({},e),{type:"surd",mode:null!=(t=e.mode)?t:"math",style:e.style,displayContainsHighlight:!0,body:e.body})),this.above=e.index}static fromJson(t){return new e(h(u({},t),{index:t.above}))}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);if(null==t?void 0:t.serialize)return t.serialize(this,e);const n=this.command,i=this.bodyToLatex(e);return this.above&&!this.hasEmptyBranch("above")?Js(`${n}[${this.aboveToLatex(e)}]`,i):/^[0-9]$/.test(i)?`${n}${i}`:Js(n,i)}get children(){if(this._children)return this._children;const e=[];if(this.above)for(const t of this.above)e.push(...t.children),e.push(t);if(this.body)for(const t of this.body)e.push(...t.children),e.push(t);return this._children=e,e}render(e){var t;const n=new Ca({parent:e,mathstyle:"cramp"},this.style),i=null!=(t=Ma.createBox(n,this.body,{type:"inner"}))?t:new ca(null),r=n.scalingFactor,s=n.metrics.defaultRuleThickness/r,a=e.isDisplayStyle?Ps:s,o=new ca(null,{classes:"ML__sqrt-line",style:this.style});o.height=s,o.softWidth=i.width;let l=r*(s+a/4);const c=Math.max(2*r*a,i.height+i.depth)+l+s,u=new Ca({parent:e},this.style),h=this.bind(u,new ca(Lo("inner","\\surd",c,!1,u,{isSelected:this.isSelected}),{isSelected:this.isSelected,classes:"ML__sqrt-sign",style:this.style}));if(!h)return null;const d=h.height+h.depth-s;d>i.height+i.depth+l&&(l=(l+d-(i.height+i.depth))/2),h.setTop(h.height-i.height-l);const p=this.bind(e,new ma({firstBaseline:[{box:new ca(i)},l-2*s,{box:o},s]})),f=Ma.createBox(new Ca({parent:e,mathstyle:"scriptscriptstyle"}),this.above,{type:"ignore"});if(!f){const t=new ca([h,p],{classes:this.containsCaret?"ML__contains-caret":"",type:"inner"});return t.setStyle("display","inline-block"),t.setStyle("height",t.height+t.depth,"em"),this.caret&&(t.caret=this.caret),this.bind(e,t)}const m=new ma({shift:-.6*(Math.max(h.height,p.height)-Math.max(h.depth,p.depth)),children:[{box:f}]}),g=new ca([new ca(m,{classes:"ML__sqrt-index",type:"ignore"}),h,p],{type:"inner",classes:this.containsCaret?"ML__contains-caret":""});return g.height=h.height,g.depth=h.depth,this.caret&&(g.caret=this.caret),this.bind(e,g)}},yl=class extends ca{constructor(e){super(null,{type:"skip"}),this._width=e}toMarkup(){return`<span style="display:inline-block;width:${Math.ceil(100*this.width)/100}em"></span>`}};function vl(e,t){if(!e.parent)return;const n=e.parent.children,i=n.indexOf(e);let r=i-1;for(;r>=0&&"ignore"===n[r].type;)r-=1;r<0&&e.parent.parent&&"lift"===e.parent.type?vl(e.parent,t):i>0&&"skip"===n[i-1].type?n[i-1].width+=t:n.splice(i,0,new yl(t))}var bl={ord:{op:3,bin:4,rel:5,inner:3},op:{ord:3,op:3,rel:5,inner:3},bin:{ord:4,op:4,open:4,inner:4},rel:{ord:5,op:5,open:5,inner:5},close:{op:3,bin:4,rel:5,inner:3},punct:{ord:3,op:3,rel:3,open:3,punct:3,inner:3},inner:{ord:3,op:3,bin:4,rel:5,open:3,punct:3,inner:3}},wl={ord:{op:3},op:{ord:3,op:3},close:{op:3},inner:{op:3}};function xl(e,t){if(!e.children)return e;const n=e.children;!function(e){kl(e,((e,t)=>{"bin"!==t.type||e&&!/^(middle|bin|op|rel|open|punct)$/.test(e.type)||(t.type="ord"),"bin"===(null==e?void 0:e.type)&&/^(rel|close|punct)$/.test(t.type)&&(e.type="ord"),"ignore"!==t.type&&(e=t)}))}(n);const i=t.getRegisterAsEm("thinmuskip"),r=t.getRegisterAsEm("medmuskip"),s=t.getRegisterAsEm("thickmuskip");return kl(n,((e,t)=>{var n,a,o;if(!e)return;const l=e.type,c=t.isTight?null!=(n=wl[l])?n:null:null!=(a=bl[l])?a:null,u=null!=(o=null==c?void 0:c[t.type])?o:null;3===u&&vl(t,i),4===u&&vl(t,r),5===u&&vl(t,s)})),e}function kl(e,t,n){if(!e)return n;e=[...e];for(const i of e)"lift"===i.type?n=kl(i.children,t,n):"ignore"===i.type?kl(i.children,t):(t(n,i),kl(i.children,t),n=i);return n}var Sl=class e extends Ma{constructor(e){super({type:"tooltip",command:e.command,mode:e.mode,style:e.style,body:e.body,displayContainsHighlight:!0}),this.tooltip=new Ma({type:"root",mode:e.content,body:e.tooltip,style:{}}),this.skipBoundary=!0,this.captureSelection=!1}static fromJson(t){return new e(h(u({},t),{tooltip:Tl(t.tooltip)}))}toJson(){var e;const t=null==(e=this.tooltip.body)?void 0:e.filter((e=>"first"!==e.type)).map((e=>e.toJson()));return h(u({},super.toJson()),{tooltip:t})}render(e){const t=Ma.createBox(new Ca,this.body);if(!t)return null;const n=new Ca({parent:e,mathstyle:"displaystyle"},{fontSize:5}),i=ha(xl(new ca(this.tooltip.render(n),{classes:"ML__tooltip-content"}),n)),r=new ca([i,t],{classes:"ML__tooltip-container"});return this.caret&&(r.caret=this.caret),this.bind(e,r)}},El=class e extends Ma{constructor(e,t){super(h(u({},t),{type:"operator",isFunction:null==t?void 0:t.isFunction})),this.value=e,this.variant=null==t?void 0:t.variant,this.variantStyle=null==t?void 0:t.variantStyle,this.subsupPlacement=null==t?void 0:t.limits}static fromJson(t){return new e(t.symbol,t)}toJson(){const e=super.toJson();return this.variant&&(e.variant=this.variant),this.variantStyle&&(e.variantStyle=this.variantStyle),this.subsupPlacement&&(e.limits=this.subsupPlacement),this.value&&(e.symbol=this.value),e}render(e){var t;const n=new ca(this.value,{type:"op",mode:"math",maxFontSize:e.scalingFactor,style:{variant:this.variant,variantStyle:this.variantStyle},isSelected:this.isSelected,letterShapeStyle:e.letterShapeStyle});let i=n;if(this.superscript||this.subscript){const r=null!=(t=this.subsupPlacement)?t:"auto";i="over-under"===r||"auto"===r&&e.isDisplayStyle?this.attachLimits(e,{base:n}):this.attachSupsub(e,{base:n})}return new ca(this.bind(e,i),{type:"op",caret:this.caret,isSelected:this.isSelected,classes:"op-group"}).wrap(e)}_serialize(e){if(!(e.expandMacro||e.skipStyles||e.skipPlaceholders)&&"string"==typeof this.verbatimLatex)return this.verbatimLatex;const t=ae(this.command,this.mode);if(null==t?void 0:t.serialize)return t.serialize(this,e);const n=[this.command];return this.explicitSubsupPlacement&&("over-under"===this.subsupPlacement&&n.push("\\limits"),"adjacent"===this.subsupPlacement&&n.push("\\nolimits"),"auto"===this.subsupPlacement&&n.push("\\displaylimits")),n.push(this.supsubToLatex(e)),Xs(n)}};function Tl(e){if(f(e))return e.map((e=>Tl(e)));if("string"==typeof e)return Ma.fromJson(e);e=u({},e);for(const t of La)e[t]&&(e[t]=Tl(e[t]));e.args&&(e.args=function(e){return e&&Array.isArray(e)?e.map((e=>"<null>"===e?null:"object"==typeof e&&"group"in e?{group:e.group.map((e=>Tl(e)))}:"object"==typeof e&&"atoms"in e?e.atoms.map((e=>Tl(e))):e)):void 0}(e.args)),e.array&&(e.array=Tl(e.array));const t=e.type;let n;"accent"===t&&(n=mo.fromJson(e)),"array"===t&&(n=No.fromJson(e)),"box"===t&&(n=Uo.fromJson(e)),"chem"===t&&(n=tl.fromJson(e)),"composition"===t&&(n=zo.fromJson(e)),"delim"===t&&(n=rl.fromJson(e)),"enclose"===t&&(n=al.fromJson(e)),"error"===t&&(n=Vo.fromJson(e)),"extensible-symbol"===t&&(n=dl.fromJson(e)),"genfrac"===t&&(n=cl.fromJson(e)),"group"===t&&(n=qo.fromJson(e)),"latex"===t&&(n=ul.fromJson(e)),"latexgroup"===t&&(n=hl.fromJson(e)),"leftright"===t&&(n=Go.fromJson(e)),"macro"===t&&(n=jo.fromJson(e)),"macro-argument"===t&&(n=Wo.fromJson(e)),"operator"===t&&(n=El.fromJson(e)),"overlap"===t&&(n=pl.fromJson(e)),"overunder"===t&&(n=fl.fromJson(e)),"placeholder"===t&&(n=Mo.fromJson(e)),"prompt"===t&&(n=Zo.fromJson(e)),"phantom"===t&&(n=ml.fromJson(e)),"sizeddelim"===t&&(n=sl.fromJson(e)),"spacing"===t&&(n=gl.fromJson(e)),"subsup"===t&&(n=Yo.fromJson(e)),"surd"===t&&(n=_l.fromJson(e)),"text"===t&&(n=Pa.fromJson(e)),"tooltip"===t&&(n=Sl.fromJson(e)),n||(console.assert(!t||["first","mbin","mrel","mclose","minner","mop","mopen","mord","mpunct","root","space"].includes(t),`MathLive 0.98.5: an unexpected atom type "${t}" was encountered. Add new atom constructors to \`fromJson()\` in "atom.ts"`),n=Ma.fromJson(e));for(const t of La)e[t]&&n.setChildren(e[t],t);return void 0!==e.verbatimLatex&&(n.verbatimLatex=e.verbatimLatex),e.subsupPlacement&&(n.subsupPlacement=e.subsupPlacement),e.explicitSubsupPlacement&&(n.explicitSubsupPlacement=!0),e.isFunction&&(n.isFunction=!0),e.isExtensibleSymbol&&(n.isExtensibleSymbol=!0),e.skipBoundary&&(n.skipBoundary=!0),e.captureSelection&&(n.captureSelection=!0),n}var Cl={main:["Main-Regular","ML__cmr"],"main-italic":["Main-Italic","ML__cmr ML__it"],"main-bold":["Main-Bold","ML__cmr ML__bold"],"main-bolditalic":["Main-BoldItalic","ML__cmr ML__bold ML__it"],normal:["Main-Regular","ML__cmr"],"normal-bold":["Main-Bold","ML__mathbf"],"normal-italic":["Math-Italic","ML__mathit"],"normal-bolditalic":["Math-BoldItalic","ML__mathbfit"],ams:["AMS-Regular","ML__ams"],"ams-bold":["AMS-Regular","ML__ams"],"ams-italic":["AMS-Regular","ML__ams"],"ams-bolditalic":["AMS-Regular","ML__ams"],"sans-serif":["SansSerif-Regular","ML__sans"],"sans-serif-bold":["SansSerif-Regular","ML__sans ML__bold"],"sans-serif-italic":["SansSerif-Regular","ML__sans"],"sans-serif-bolditalic":["SansSerif-Regular","ML__sans"],calligraphic:["Caligraphic-Regular","ML__cal"],"calligraphic-bold":["Caligraphic-Regular","ML__cal ML__bold"],"calligraphic-italic":["Caligraphic-Regular","ML__cal ML__it"],"calligraphic-bolditalic":["Caligraphic-Regular","ML__cal ML__bold ML__it"],script:["Script-Regular","ML__script"],"script-bold":["Script-Regular","ML__script ML__bold"],"script-italic":["Script-Regular","ML__script ML__it"],"script-bolditalic":["Script-Regular","ML__script ML__bold ML__it"],fraktur:["Fraktur-Regular","ML__frak"],"fraktur-bold":["Fraktur-Regular","ML__frak"],"fraktur-italic":["Fraktur-Regular","ML__frak"],"fraktur-bolditalic":["Fraktur-Regular","ML__frak"],monospace:["Typewriter-Regular","ML__tt"],"monospace-bold":["Typewriter-Regular","ML__tt ML__bold"],"monospace-italic":["Typewriter-Regular","ML__tt ML__it"],"monospace-bolditalic":["Typewriter-Regular","ML__tt ML__bold ML__it"],"double-struck":["AMS-Regular","ML__bb"],"double-struck-bold":["AMS-Regular","ML__bb"],"double-struck-italic":["AMS-Regular","ML__bb"],"double-struck-bolditalic":["AMS-Regular","ML__bb"]},Ll={"double-struck":/^[A-Z ]$/,script:/^[A-Z ]$/,calligraphic:/^[\dA-Z ]$/,fraktur:/^[\dA-Za-z ]$|^[!"#$%&'()*+,\-./:;=?[]^’‘]$/,monospace:/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/,"sans-serif":/^[\dA-Za-z ]$|^[!"&'()*+,\-./:;=?@[\]^_~\u0131\u0237\u0393\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A8\u03A9]$/},Al=/^[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5]$/,Dl=[/^[a-z]$/,/^[A-Z]$/,Al,/^[\u0393|\u0394\u0398\u039B\u039E\u03A0\u03A3\u03A5\u03A6\u03A8\u03A9]$/],Ml={iso:["it","it","it","it"],tex:["it","it","it","up"],french:["it","up","up","up"],upright:["up","up","up","up"]};function Rl(e){if(!e)return"";const{style:t}=e;if(void 0===t.variant)return"";let n=t.variant;return!["calligraphic","fraktur","double-struck","script","monospace","sans-serif"].includes(t.variant)&&t.variantStyle&&"up"!==t.variantStyle&&(n+="-"+t.variantStyle),n}function Il(e,t){return ia(e,"fontSeries").map((e=>{const n=function(e,t){return ia(e,"fontShape").map((e=>{const n=function(e,t){return e.map((e=>e._serialize(t)))}(e,t),{fontShape:i}=e[0].style;let r="";return"it"===i&&(r="\\textit"),"sl"===i&&(r="\\textsl"),"sc"===i&&(r="\\textsc"),"n"===i&&(r="\\textup"),!r&&i?`{${Js("\\fontshape",i)}${Xs(n)}}`:r?Js(r,Xs(n)):Xs(n)}))}(e,t),{fontSeries:i}=e[0].style;let r="";return"b"===i&&(r="\\textbf"),"l"===i&&(r="\\textlf"),"m"===i&&(r="\\textmd"),i&&!r?`{${Js("\\fontseries",i)}${Xs(n)}}`:r?Js(r,Xs(n)):Xs(n)}))}function Pl(e,t,n){return ia(e,"fontFamily").map((e=>{var i,r;const s=function(e,t){return ia(e,"fontSize").map((e=>{var n,i;const r=Il(e,t),s=null!=(i=["","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"][null!=(n=e[0].style.fontSize)?n:""])?i:"";return s?`${s} ${Xs(r)}`:Xs(r)}))}(e,t),a=null!=(r={roman:"textrm",monospace:"texttt","sans-serif":"textsf"}[null!=(i=e[0].style.fontFamily)?i:""])?r:"";return a?`\\${a}{${Xs(s)}}`:e[0].style.fontFamily?`{\\fontfamily{${e[0].style.fontFamily}} ${Xs(s)}}`:n?`\\text{${Xs(s)}}`:Xs(s)}))}new class extends ta{constructor(){super("math")}createAtom(e,t,n){var i,r,s,a;if(null===t)return new Ma({type:"mord",mode:"math",command:e,value:e,style:n});const o=window.MathfieldElement.isFunction(null!=(i=t.command)?i:e);if("symbol"===t.definitionType){const i=new Ma({type:null!=(r=t.type)?r:"mord",mode:"math",command:null!=(s=t.command)?s:e,value:String.fromCodePoint(t.codepoint),style:n});return o&&(i.isFunction=!0),e.startsWith("\\")&&(i.verbatimLatex=e),i}const l=new Ma({type:"mord",mode:"math",command:null!=(a=t.command)?a:e,value:e,style:n});return o&&(l.isFunction=!0),e.startsWith("\\")&&(l.verbatimLatex=e),l}serialize(e,t){const n=function(e,t){const{parent:n}=e[0],i=Rl(n);return ia(e,"variant").map((e=>{const n=Rl(e[0]);let r="";n&&n!==i&&(r={calligraphic:"\\mathcal",fraktur:"\\mathfrak","double-struck":"\\mathbb",script:"\\mathscr",monospace:"\\mathtt","sans-serif":"\\mathsf",normal:"\\mathrm","normal-italic":"\\mathnormal","normal-bold":"\\mathbf","normal-bolditalic":"\\mathbfit",ams:"","ams-italic":"\\mathit","ams-bold":"\\mathbf","ams-bolditalic":"\\mathbfit",main:"","main-italic":"\\mathit","main-bold":"\\mathbf","main-bolditalic":"\\mathbfit"}[n],console.assert(void 0!==r));const s=Xs(e.map((e=>e._serialize(t))));return r?Js(r,s):s}))}(e,h(u({},t),{defaultMode:"math"}));return 0===n.length||"text"!==t.defaultMode?n:["$ ",...n," $"]}getFont(e,t){console.assert(void 0!==t.variant);let{variant:n}=t,{variantStyle:i}=t;"normal"===n&&!i&&/[\u00A3\u0131\u0237]/.test(e.value)&&(n="main",i="italic"),"normal"!==n||i||1!==e.value.length||Dl.forEach(((n,r)=>{var s;n.test(e.value)&&"it"===Ml[null!=(s=t.letterShapeStyle)?s:"tex"][r]&&(i="italic")})),"up"===i&&(i=void 0);const r=i?n+"-"+i:n;console.assert(void 0!==Cl[r]);const[s,a]=Cl[r];return Ll[n]&&!Ll[n].test(e.value)?(e.value=O(e.value,n,i),null):(Al.test(e.value)&&(e.classes+=" lcGreek"),a&&(e.classes+=" "+a),s)}};var Ol={roman:"","sans-serif":"ML__sans",monospace:"ML__tt"};new class extends ta{constructor(){super("text")}createAtom(e,t,n){return t&&"symbol"===t.definitionType?new Pa(e,String.fromCodePoint(t.codepoint),null!=n?n:{}):null}serialize(e,t){return Pl(e,h(u({},t),{defaultMode:"text"}),"text"!==t.defaultMode)}getFont(e,t){var n,i,r,s,a;const{fontFamily:o}=t;if(Ol[o]?e.classes+=" "+Ol[o]:o&&e.setStyle("font-family",o),t.fontShape&&(e.classes+=" ",e.classes+=null!=(n={it:"ML__it",sl:"ML__shape_sl",sc:"ML__shape_sc",ol:"ML__shape_ol"}[t.fontShape])?n:""),t.fontSeries){const n=t.fontSeries.match(/(.?[lbm])?(.?[cx])?/);n&&(e.classes+=" ",e.classes+=null!=(r={ul:"ML__series_ul",el:"ML__series_el",l:"ML__series_l",sl:"ML__series_sl",m:"",sb:"ML__series_sb",b:"ML__bold",eb:"ML__series_eb",ub:"ML__series_ub"}[null!=(i=n[1])?i:""])?r:"",e.classes+=" ",e.classes+=null!=(a={uc:"ML__series_uc",ec:"ML__series_ec",c:"ML__series_c",sc:"ML__series_sc",n:"",sx:"ML__series_sx",x:"ML__series_x",ex:"ML__series_ex",ux:"ML__series_ux"}[null!=(s=n[2])?s:""])?a:"")}return"Main-Regular"}};new class extends ta{constructor(){super("latex")}createAtom(e){return new ul(e)}serialize(e,t){return e.filter((e=>e instanceof ul&&!e.isSuggestion)).map((e=>e.value))}getFont(){return null}};var Fl={id:"apple.en-intl",displayName:"English (international)",virtualLayout:"qwerty",platform:"apple",locale:"en",score:0,mapping:{KeyA:["a","A","å","Å"],KeyB:["b","B","∫","ı"],KeyC:["c","C","ç","Ç"],KeyD:["d","D","∂","Î"],KeyE:["e","E","´","´"],KeyF:["f","F","ƒ","Ï"],KeyG:["g","G","©","˝"],KeyH:["h","H","˙","Ó"],KeyI:["i","I","ˆ","ˆ"],KeyJ:["j","J","∆","Ô"],KeyK:["k","K","˚",""],KeyL:["l","L","¬","Ò"],KeyM:["m","M","µ","Â"],KeyN:["n","N","˜","˜"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","π","∏"],KeyQ:["q","Q","œ","Œ"],KeyR:["r","R","®","‰"],KeyS:["s","S","ß","Í"],KeyT:["t","T","†","ˇ"],KeyU:["u","U","¨","¨"],KeyV:["v","V","√","◊"],KeyW:["w","W","∑","„"],KeyX:["x","X","≈","˛"],KeyY:["y","Y","¥","Á"],KeyZ:["z","Z","Ω","¸"],Digit1:["1","!","¡","⁄"],Digit2:["2","@","™","€"],Digit3:["3","#","£","‹"],Digit4:["4","$","¢","›"],Digit5:["5","%","∞","fi"],Digit6:["6","^","§","fl"],Digit7:["7","&","¶","‡"],Digit8:["8","*","•","°"],Digit9:["9","(","ª","·"],Digit0:["0",")","º","‚"],Space:[" "," "," "," "],Minus:["-","_","–","—"],Equal:["=","+","≠","±"],BracketLeft:["[","{","“","”"],BracketRight:["]","}","‘","’"],Backslash:["\\","|","«","»"],Semicolon:[";",":","…","Ú"],Quote:["'",'"',"æ","Æ"],Backquote:["`","˜","`","`"],Comma:[",","<","≤","¯"],Period:[".",">","≥","˘"],Slash:["/","?","÷","¿"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["§","±","§","±"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}},Nl={id:"windows.en-intl",displayName:"English (international)",platform:"windows",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","á","Á"],KeyB:["b","B","",""],KeyC:["c","C","©","¢"],KeyD:["d","D","ð","Ð"],KeyE:["e","E","é","É"],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","í","Í"],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","ø","Ø"],KeyM:["m","M","µ",""],KeyN:["n","N","ñ","Ñ"],KeyO:["o","O","ó","Ó"],KeyP:["p","P","ö","Ö"],KeyQ:["q","Q","ä","Ä"],KeyR:["r","R","®",""],KeyS:["s","S","ß","§"],KeyT:["t","T","þ","Þ"],KeyU:["u","U","ú","Ú"],KeyV:["v","V","",""],KeyW:["w","W","å","Å"],KeyX:["x","X","",""],KeyY:["y","Y","ü","Ü"],KeyZ:["z","Z","æ","Æ"],Digit1:["1","!","¡","¹"],Digit2:["2","@","²",""],Digit3:["3","#","³",""],Digit4:["4","$","¤","£"],Digit5:["5","%","€",""],Digit6:["6","^","¼",""],Digit7:["7","&","½",""],Digit8:["8","*","¾",""],Digit9:["9","(","‘",""],Digit0:["0",")","’",""],Space:[" "," ","",""],Minus:["-","_","¥",""],Equal:["=","+","×","÷"],BracketLeft:["[","{","«",""],BracketRight:["]","}","»",""],Backslash:["\\","|","¬","¦"],Semicolon:[";",":","¶","°"],Quote:["'",'"',"´","¨"],Backquote:["`","~","",""],Comma:[",","<","ç","Ç"],Period:[".",">","",""],Slash:["/","?","¿",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["\\","|","",""]}},Bl={id:"linux.en",displayName:"English",platform:"linux",virtualLayout:"qwerty",locale:"en",score:0,mapping:{KeyA:["a","A","a","A"],KeyB:["b","B","b","B"],KeyC:["c","C","c","C"],KeyD:["d","D","d","D"],KeyE:["e","E","e","E"],KeyF:["f","F","f","F"],KeyG:["g","G","g","G"],KeyH:["h","H","h","H"],KeyI:["i","I","i","I"],KeyJ:["j","J","j","J"],KeyK:["k","K","k","K"],KeyL:["l","L","l","L"],KeyM:["m","M","m","M"],KeyN:["n","N","n","N"],KeyO:["o","O","o","O"],KeyP:["p","P","p","P"],KeyQ:["q","Q","q","Q"],KeyR:["r","R","r","R"],KeyS:["s","S","s","S"],KeyT:["t","T","t","T"],KeyU:["u","U","u","U"],KeyV:["v","V","v","V"],KeyW:["w","W","w","W"],KeyX:["x","X","x","X"],KeyY:["y","Y","y","Y"],KeyZ:["z","Z","z","Z"],Digit1:["1","!","1","!"],Digit2:["2","@","2","@"],Digit3:["3","#","3","#"],Digit4:["4","$","4","$"],Digit5:["5","%","5","%"],Digit6:["6","^","6","^"],Digit7:["7","&","7","&"],Digit8:["8","*","8","*"],Digit9:["9","(","9","("],Digit0:["0",")","0",")"],Space:[" "," "," "," "],Minus:["-","_","-","_"],Equal:["=","+","=","+"],BracketLeft:["[","{","[","{"],BracketRight:["]","}","]","}"],Backslash:["\\","|","\\","|"],Semicolon:[";",":",";",":"],Quote:["'",'"',"'",'"'],Backquote:["`","~","`","~"],Comma:[",","<",",","<"],Period:[".",">",".",">"],Slash:["/","?","/","?"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","¦"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}};function $l(e){const t=e.split("+"),n={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:t.pop()};return t.includes("shift")&&(n.shift=!0),t.includes("alt")&&(n.alt=!0),t.includes("ctrl")&&(n.ctrl=!0),t.includes("cmd")&&(n.cmd=!0),t.includes("win")&&(n.win=!0),t.includes("meta")&&(n.meta=!0),n}function Kl(e){let t="";return e.shift&&(t+="shift+"),e.alt&&(t+="alt+"),e.ctrl&&(t+="ctrl+"),e.cmd&&(t+="cmd+"),e.win&&(t+="win+"),e.meta&&(t+="meta+"),t+e.key}var Ul,zl={enter:"[Enter]",escape:"[Escape]",backspace:"[Backspace]",tab:"[Tab]",space:"[Space]",pausebreak:"[Pause]",insert:"[Insert]",home:"[Home]",pageup:"[PageUp]",delete:"[Delete]",end:"[End]",pagedown:"[PageDown]",right:"[ArrowRight]",left:"[ArrowLeft]",down:"[ArrowDown]",up:"[ArrowUp]",numpad0:"[Numpad0]",numpad1:"[Numpad1]",numpad2:"[Numpad2]",numpad3:"[Numpad3]",numpad4:"[Numpad4]",numpad5:"[Numpad5]",numpad6:"[Numpad6]",numpad7:"[Numpad7]",numpad8:"[Numpad8]",numpad9:"[Numpad9]",numpad_divide:"[NumpadDivide]",numpad_multiply:"[NumpadMultiply]",numpad_subtract:"[NumpadSubtract]",numpad_add:"[NumpadAdd]",numpad_decimal:"[NumpadDecimal]",numpad_separator:"[NumpadComma]",capslock:"[Capslock]",f1:"[F1]",f2:"[F2]",f3:"[F3]",f4:"[F4]",f5:"[F5]",f6:"[F6]",f7:"[F7]",f8:"[F8]",f9:"[F9]",f10:"[F10]",f11:"[F11]",f12:"[F12]",f13:"[F13]",f14:"[F14]",f15:"[F15]",f16:"[F16]",f17:"[F17]",f18:"[F18]",f19:"[F19]"},Vl=[];function ql(){switch(_()){case"macos":case"ios":return"apple";case"windows":return"windows"}return"linux"}function Gl(e){e.platform&&e.platform!==ql()||Vl.push(e)}function Hl(){return null!=Ul?Ul:Vl[0]}switch(ql()){case"apple":Gl(Fl),Gl({id:"apple.french",locale:"fr",displayName:"French",platform:"apple",virtualLayout:"azerty",score:0,mapping:{KeyA:["q","Q","‡","Ω"],KeyB:["b","B","ß","∫"],KeyC:["c","C","©","¢"],KeyD:["d","D","∂","∆"],KeyE:["e","E","ê","Ê"],KeyF:["f","F","ƒ","·"],KeyG:["g","G","fi","fl"],KeyH:["h","H","Ì","Î"],KeyI:["i","I","î","ï"],KeyJ:["j","J","Ï","Í"],KeyK:["k","K","È","Ë"],KeyL:["l","L","¬","|"],KeyM:[",","?","∞","¿"],KeyN:["n","N","~","ı"],KeyO:["o","O","œ","Œ"],KeyP:["p","P","π","∏"],KeyQ:["a","A","æ","Æ"],KeyR:["r","R","®","‚"],KeyS:["s","S","Ò","∑"],KeyT:["t","T","†","™"],KeyU:["u","U","º","ª"],KeyV:["v","V","◊","√"],KeyW:["z","Z","Â","Å"],KeyX:["x","X","≈","⁄"],KeyY:["y","Y","Ú","Ÿ"],KeyZ:["w","W","‹","›"],Digit1:["&","1","","´"],Digit2:["é","2","ë","„"],Digit3:['"',"3","“","”"],Digit4:["'","4","‘","’"],Digit5:["(","5","{","["],Digit6:["§","6","¶","å"],Digit7:["è","7","«","»"],Digit8:["!","8","¡","Û"],Digit9:["ç","9","Ç","Á"],Digit0:["à","0","ø","Ø"],Space:[" "," "," "," "],Minus:[")","°","}","]"],Equal:["-","_","—","–"],BracketLeft:["^","¨","ô","Ô"],BracketRight:["$","*","€","¥"],Backslash:["`","£","@","#"],Semicolon:["m","M","µ","Ó"],Quote:["ù","%","Ù","‰"],Backquote:["<",">","≤","≥"],Comma:[";",".","…","•"],Period:[":","/","÷","\\"],Slash:["=","+","≠","±"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",".",",","."],IntlBackslash:["@","#","•","Ÿ"],NumpadEqual:["=","=","=","="]}}),Gl({id:"apple.spanish",locale:"es",displayName:"Spanish ISO",platform:"apple",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","å","Å"],KeyB:["b","B","ß",""],KeyC:["c","C","©"," "],KeyD:["d","D","∂","∆"],KeyE:["e","E","€","€"],KeyF:["f","F","ƒ","fi"],KeyG:["g","G","","fl"],KeyH:["h","H","™"," "],KeyI:["i","I"," "," "],KeyJ:["j","J","¶","¯"],KeyK:["k","K","§","ˇ"],KeyL:["l","L"," ","˘"],KeyM:["m","M","µ","˚"],KeyN:["n","N"," ","˙"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","π","∏"],KeyQ:["q","Q","œ","Œ"],KeyR:["r","R","®"," "],KeyS:["s","S","∫"," "],KeyT:["t","T","†","‡"],KeyU:["u","U"," "," "],KeyV:["v","V","√","◊"],KeyW:["w","W","æ","Æ"],KeyX:["x","X","∑","›"],KeyY:["y","Y","¥"," "],KeyZ:["z","Z","Ω","‹"],Digit1:["1","!","|","ı"],Digit2:["2",'"',"@","˝"],Digit3:["3","·","#","•"],Digit4:["4","$","¢","£"],Digit5:["5","%","∞","‰"],Digit6:["6","&","¬"," "],Digit7:["7","/","÷","⁄"],Digit8:["8","(","“","‘"],Digit9:["9",")","”","’"],Digit0:["0","=","≠","≈"],Space:[" "," "," "," "],Minus:["'","?","´","¸"],Equal:["¡","¿","‚","˛"],BracketLeft:["`","^","[","ˆ"],BracketRight:["+","*","]","±"],Backslash:["ç","Ç","}","»"],Semicolon:["ñ","Ñ","~","˜"],Quote:["´","¨","{","«"],Backquote:["<",">","≤","≥"],Comma:[",",";","„",""],Period:[".",":","…","…"],Slash:["-","_","–","—"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[",",",",",",","],IntlBackslash:["º","ª","\\","°"]}}),Gl({id:"apple.german",locale:"de",displayName:"German",virtualLayout:"qwertz",platform:"apple",score:0,mapping:{KeyA:["a","A","å","Å"],KeyB:["b","B","∫","‹"],KeyC:["c","C","ç","Ç"],KeyD:["d","D","∂","™"],KeyE:["e","E","€","‰"],KeyF:["f","F","ƒ","Ï"],KeyG:["g","G","©","Ì"],KeyH:["h","H","ª","Ó"],KeyI:["i","I","⁄","Û"],KeyJ:["j","J","º","ı"],KeyK:["k","K","∆","ˆ"],KeyL:["l","L","@","fl"],KeyM:["m","M","µ","˘"],KeyN:["n","N","~","›"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","π","∏"],KeyQ:["q","Q","«","»"],KeyR:["r","R","®","¸"],KeyS:["s","S","‚","Í"],KeyT:["t","T","†","˝"],KeyU:["u","U","¨","Á"],KeyV:["v","V","√","◊"],KeyW:["w","W","∑","„"],KeyX:["x","X","≈","Ù"],KeyY:["z","Z","Ω","ˇ"],KeyZ:["y","Y","¥","‡"],Digit1:["1","!","¡","¬"],Digit2:["2",'"',"“","”"],Digit3:["3","§","¶","#"],Digit4:["4","$","¢","£"],Digit5:["5","%","[","fi"],Digit6:["6","&","]","^"],Digit7:["7","/","|","\\"],Digit8:["8","(","{","˜"],Digit9:["9",")","}","·"],Digit0:["0","=","≠","¯"],Space:[" "," "," "," "],Minus:["ß","?","¿","˙"],Equal:["´","`","'","˚"],BracketLeft:["ü","Ü","•","°"],BracketRight:["+","*","±",""],Backslash:["#","'","‘","’"],Semicolon:["ö","Ö","œ","Œ"],Quote:["ä","Ä","æ","Æ"],Backquote:["<",">","≤","≥"],Comma:[",",";","∞","˛"],Period:[".",":","…","÷"],Slash:["-","_","–","—"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:[",",",",".","."],IntlBackslash:["^","°","„","“"],NumpadEqual:["=","=","=","="]}});break;case"windows":Gl(Nl),Gl({id:"windows.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"windows",score:0,mapping:{KeyA:["q","Q","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","€",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:[",","?","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["a","A","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["z","Z","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["w","W","",""],Digit1:["&","1","",""],Digit2:["é","2","~",""],Digit3:['"',"3","#",""],Digit4:["'","4","{",""],Digit5:["(","5","[",""],Digit6:["-","6","|",""],Digit7:["è","7","`",""],Digit8:["_","8","\\",""],Digit9:["ç","9","^",""],Digit0:["à","0","@",""],Space:[" "," ","",""],Minus:[")","°","]",""],Equal:["=","+","}",""],BracketLeft:["^","¨","",""],BracketRight:["$","£","¤",""],Backslash:["*","µ","",""],Semicolon:["m","M","",""],Quote:["ù","%","",""],Backquote:["²","","",""],Comma:[";",".","",""],Period:[":","/","",""],Slash:["!","§","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}}),Gl({id:"windows.spanish",locale:"es",displayName:"Spanish",platform:"windows",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","€",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["y","Y","",""],KeyZ:["z","Z","",""],Digit1:["1","!","|",""],Digit2:["2",'"',"@",""],Digit3:["3","·","#",""],Digit4:["4","$","~",""],Digit5:["5","%","€",""],Digit6:["6","&","¬",""],Digit7:["7","/","",""],Digit8:["8","(","",""],Digit9:["9",")","",""],Digit0:["0","=","",""],Space:[" "," ","",""],Minus:["'","?","",""],Equal:["¡","¿","",""],BracketLeft:["`","^","[",""],BracketRight:["+","*","]",""],Backslash:["ç","Ç","}",""],Semicolon:["ñ","Ñ","",""],Quote:["´","¨","{",""],Backquote:["º","ª","\\",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","",""]}}),Gl({id:"windows.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","",""],KeyB:["b","B","",""],KeyC:["c","C","",""],KeyD:["d","D","",""],KeyE:["e","E","€",""],KeyF:["f","F","",""],KeyG:["g","G","",""],KeyH:["h","H","",""],KeyI:["i","I","",""],KeyJ:["j","J","",""],KeyK:["k","K","",""],KeyL:["l","L","",""],KeyM:["m","M","µ",""],KeyN:["n","N","",""],KeyO:["o","O","",""],KeyP:["p","P","",""],KeyQ:["q","Q","@",""],KeyR:["r","R","",""],KeyS:["s","S","",""],KeyT:["t","T","",""],KeyU:["u","U","",""],KeyV:["v","V","",""],KeyW:["w","W","",""],KeyX:["x","X","",""],KeyY:["z","Z","",""],KeyZ:["y","Y","",""],Digit1:["1","!","",""],Digit2:["2",'"',"²",""],Digit3:["3","§","³",""],Digit4:["4","$","",""],Digit5:["5","%","",""],Digit6:["6","&","",""],Digit7:["7","/","{",""],Digit8:["8","(","[",""],Digit9:["9",")","]",""],Digit0:["0","=","}",""],Space:[" "," ","",""],Minus:["ß","?","\\","ẞ"],Equal:["´","`","",""],BracketLeft:["ü","Ü","",""],BracketRight:["+","*","~",""],Backslash:["#","'","",""],Semicolon:["ö","Ö","",""],Quote:["ä","Ä","",""],Backquote:["^","°","",""],Comma:[",",";","",""],Period:[".",":","",""],Slash:["-","_","",""],NumpadDivide:["/","/","",""],NumpadMultiply:["*","*","",""],NumpadSubtract:["-","-","",""],NumpadAdd:["+","+","",""],IntlBackslash:["<",">","|",""]}});break;case"linux":Gl(Bl),Gl({id:"linux.french",locale:"fr",displayName:"French",virtualLayout:"azerty",platform:"linux",score:0,mapping:{KeyA:["q","Q","@","Ω"],KeyB:["b","B","”","’"],KeyC:["c","C","¢","©"],KeyD:["d","D","ð","Ð"],KeyE:["e","E","€","¢"],KeyF:["f","F","đ","ª"],KeyG:["g","G","ŋ","Ŋ"],KeyH:["h","H","ħ","Ħ"],KeyI:["i","I","→","ı"],KeyJ:["j","J","̉","̛"],KeyK:["k","K","ĸ","&"],KeyL:["l","L","ł","Ł"],KeyM:[",","?","́","̋"],KeyN:["n","N","n","N"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","þ","Þ"],KeyQ:["a","A","æ","Æ"],KeyR:["r","R","¶","®"],KeyS:["s","S","ß","§"],KeyT:["t","T","ŧ","Ŧ"],KeyU:["u","U","↓","↑"],KeyV:["v","V","“","‘"],KeyW:["z","Z","«","<"],KeyX:["x","X","»",">"],KeyY:["y","Y","←","¥"],KeyZ:["w","W","ł","Ł"],Digit1:["&","1","¹","¡"],Digit2:["é","2","~","⅛"],Digit3:['"',"3","#","£"],Digit4:["'","4","{","$"],Digit5:["(","5","[","⅜"],Digit6:["-","6","|","⅝"],Digit7:["è","7","`","⅞"],Digit8:["_","8","\\","™"],Digit9:["ç","9","^","±"],Digit0:["à","0","@","°"],Enter:["\r","\r","\r","\r"],Escape:["","","",""],Backspace:["\b","\b","\b","\b"],Tab:["\t","","\t",""],Space:[" "," "," "," "],Minus:[")","°","]","¿"],Equal:["=","+","}","̨"],BracketLeft:["̂","̈","̈","̊"],BracketRight:["$","£","¤","̄"],Backslash:["*","µ","̀","̆"],Semicolon:["m","M","µ","º"],Quote:["ù","%","̂","̌"],Backquote:["²","~","¬","¬"],Comma:[";",".","─","×"],Period:[":","/","·","÷"],Slash:["!","§","̣","̇"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","¦"]}}),Gl({id:"linux.spanish",locale:"es",displayName:"Spanish",platform:"linux",virtualLayout:"qwerty",score:0,mapping:{KeyA:["a","A","æ","Æ"],KeyB:["b","B","”","’"],KeyC:["c","C","¢","©"],KeyD:["d","D","ð","Ð"],KeyE:["e","E","€","¢"],KeyF:["f","F","đ","ª"],KeyG:["g","G","ŋ","Ŋ"],KeyH:["h","H","ħ","Ħ"],KeyI:["i","I","→","ı"],KeyJ:["j","J","̉","̛"],KeyK:["k","K","ĸ","&"],KeyL:["l","L","ł","Ł"],KeyM:["m","M","µ","º"],KeyN:["n","N","n","N"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","þ","Þ"],KeyQ:["q","Q","@","Ω"],KeyR:["r","R","¶","®"],KeyS:["s","S","ß","§"],KeyT:["t","T","ŧ","Ŧ"],KeyU:["u","U","↓","↑"],KeyV:["v","V","“","‘"],KeyW:["w","W","ł","Ł"],KeyX:["x","X","»",">"],KeyY:["y","Y","←","¥"],KeyZ:["z","Z","«","<"],Digit1:["1","!","|","¡"],Digit2:["2",'"',"@","⅛"],Digit3:["3","·","#","£"],Digit4:["4","$","~","$"],Digit5:["5","%","½","⅜"],Digit6:["6","&","¬","⅝"],Digit7:["7","/","{","⅞"],Digit8:["8","(","[","™"],Digit9:["9",")","]","±"],Digit0:["0","=","}","°"],Enter:["\r","\r","\r","\r"],Escape:["","","",""],Backspace:["\b","\b","\b","\b"],Tab:["\t","","\t",""],Space:[" "," "," "," "],Minus:["'","?","\\","¿"],Equal:["¡","¿","̃","~"],BracketLeft:["̀","̂","[","̊"],BracketRight:["+","*","]","̄"],Backslash:["ç","Ç","}","̆"],Semicolon:["ñ","Ñ","~","̋"],Quote:["́","̈","{","{"],Backquote:["º","ª","\\","\\"],Comma:[",",";","─","×"],Period:[".",":","·","÷"],Slash:["-","_","̣","̇"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],NumpadEnter:["\r","\r","\r","\r"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",".","","."],IntlBackslash:["<",">","|","¦"],NumpadEqual:["=","=","=","="],NumpadComma:[".",".",".","."],NumpadParenLeft:["(","(","(","("],NumpadParenRight:[")",")",")",")"]}}),Gl({id:"linux.german",locale:"de",displayName:"German",platform:"windows",virtualLayout:"qwertz",score:0,mapping:{KeyA:["a","A","æ","Æ"],KeyB:["b","B","“","‘"],KeyC:["c","C","¢","©"],KeyD:["d","D","ð","Ð"],KeyE:["e","E","€","€"],KeyF:["f","F","đ","ª"],KeyG:["g","G","ŋ","Ŋ"],KeyH:["h","H","ħ","Ħ"],KeyI:["i","I","→","ı"],KeyJ:["j","J","̣","̇"],KeyK:["k","K","ĸ","&"],KeyL:["l","L","ł","Ł"],KeyM:["m","M","µ","º"],KeyN:["n","N","”","’"],KeyO:["o","O","ø","Ø"],KeyP:["p","P","þ","Þ"],KeyQ:["q","Q","@","Ω"],KeyR:["r","R","¶","®"],KeyS:["s","S","ſ","ẞ"],KeyT:["t","T","ŧ","Ŧ"],KeyU:["u","U","↓","↑"],KeyV:["v","V","„","‚"],KeyW:["w","W","ł","Ł"],KeyX:["x","X","«","‹"],KeyY:["z","Z","←","¥"],KeyZ:["y","Y","»","›"],Digit1:["1","!","¹","¡"],Digit2:["2",'"',"²","⅛"],Digit3:["3","§","³","£"],Digit4:["4","$","¼","¤"],Digit5:["5","%","½","⅜"],Digit6:["6","&","¬","⅝"],Digit7:["7","/","{","⅞"],Digit8:["8","(","[","™"],Digit9:["9",")","]","±"],Digit0:["0","=","}","°"],Enter:["\r","\r","\r","\r"],Escape:["","","",""],Backspace:["\b","\b","\b","\b"],Tab:["\t","","\t",""],Space:[" "," "," "," "],Minus:["ß","?","\\","¿"],Equal:["́","̀","̧","̨"],BracketLeft:["ü","Ü","̈","̊"],BracketRight:["+","*","~","¯"],Backslash:["#","'","’","̆"],Semicolon:["ö","Ö","̋","̣"],Quote:["ä","Ä","̂","̌"],Backquote:["̂","°","′","″"],Comma:[",",";","·","×"],Period:[".",":","…","÷"],Slash:["-","_","–","—"],PrintScreen:["","","",""],PageUp:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["","1","","1"],Numpad2:["","2","","2"],Numpad3:["","3","","3"],Numpad4:["","4","","4"],Numpad5:["","5","","5"],Numpad6:["","6","","6"],Numpad7:["","7","","7"],Numpad8:["","8","","8"],Numpad9:["","9","","9"],Numpad0:["","0","","0"],NumpadDecimal:["",",","",","],IntlBackslash:["<",">","|","̱"],AltRight:["\r","\r","\r","\r"],MetaRight:[".",".",".","."]}})}function jl(e){var t;const n=/macos|ios/.test(_()),i=e.split("+");let r="";for(const e of i)r&&(r+=n?" ":'<span class="ML__shortcut-join">+</span>'),e.startsWith("[Key")?r+=e.slice(4,5):e.startsWith("Key")?r+=e.slice(3,4):e.startsWith("[Digit")?r+=e.slice(6,7):e.startsWith("Digit")?r+=e.slice(5,6):r+=null!=(t={cmd:"⌘",meta:n?"⌘":"Ctrl",shift:n?"⇧":"Shift",alt:n?"⌥":"Alt",ctrl:n?"⌃":"Ctrl","\n":n?"⏎":"Return","[return]":n?"⏎":"Return","[enter]":n?"⌤":"Enter","[tab]":n?"⇥":"Tab","[escape]":"Esc","[backspace]":n?"⌫":"Backspace","[delete]":n?"⌦":"Del","[pageup]":n?"⇞":"Page Up","[pagedown]":n?"⇟":"Page Down","[home]":n?"⤒":"Home","[end]":n?"⤓":"End","[space]":"Space","[equal]":"=","[minus]":"-","[comma]":",","[slash]":"/","[backslash]":"\\","[bracketleft]":"[","[bracketright]":"]",semicolon:";",period:".",comma:",",minus:"-",equal:"=",quote:"'",backslash:"\\",intlbackslash:"\\",backquote:"`",slash:"/",numpadmultiply:"* 🔢",numpaddivide:"/ 🔢",numpadsubtract:"- 🔢",numpadadd:"+ 🔢",numpaddecimal:". 🔢",numpadcomma:", 🔢",help:"help",left:"⇠",up:"⇡",right:"⇢",down:"⇣","[arrowleft]":"⇠","[arrowup]":"⇡","[arrowright]":"⇢","[arrowdown]":"⇣"}[e.toLowerCase()])?t:e.toUpperCase();return r}function Wl(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return{x:e.clientX,y:e.clientY};if(e instanceof TouchEvent){const t=[...e.touches].reduce(((e,t)=>({x:e.x+t.clientX,y:e.y+t.clientY})),{x:0,y:0}),n=e.touches.length;return{x:t.x/n,y:t.y/n}}}function Zl(e){const t={alt:!1,control:!1,shift:!1,meta:!1};return(e instanceof MouseEvent||e instanceof PointerEvent||e instanceof TouchEvent||e instanceof KeyboardEvent)&&(e.altKey&&(t.alt=!0),e.ctrlKey&&(t.control=!0),e.metaKey&&(t.meta=!0),e.shiftKey&&(t.shift=!0)),t}Gl({id:"dvorak",locale:"en",displayName:"Dvorak",virtualLayout:"dvorak",platform:"",score:0,mapping:{KeyA:["a","A","å","Å"],KeyB:["x","X","≈","˛"],KeyC:["j","J","∆","Ô"],KeyD:["e","E","´","´"],KeyE:[".",">","≥","˘"],KeyF:["u","U","¨","¨"],KeyG:["i","I","ˆ","ˆ"],KeyH:["d","D","∂","Î"],KeyI:["c","C","ç","Ç"],KeyJ:["h","H","˙","Ó"],KeyK:["t","T","†","ˇ"],KeyL:["n","N","˜","˜"],KeyM:["m","M","µ","Â"],KeyN:["b","B","∫","ı"],KeyO:["r","R","®","‰"],KeyP:["l","L","¬","Ò"],KeyQ:["'",'"',"æ","Æ"],KeyR:["p","P","π","∏"],KeyS:["o","O","ø","Ø"],KeyT:["y","Y","¥","Á"],KeyU:["g","G","©","˝"],KeyV:["k","K","˚",""],KeyW:[",","<","≤","¯"],KeyX:["q","Q","œ","Œ"],KeyY:["f","F","ƒ","Ï"],KeyZ:[";",":","…","Ú"],Digit1:["1","!","¡","⁄"],Digit2:["2","@","™","€"],Digit3:["3","#","£","‹"],Digit4:["4","$","¢","›"],Digit5:["5","%","∞","fi"],Digit6:["6","^","§","fl"],Digit7:["7","&","¶","‡"],Digit8:["8","*","•","°"],Digit9:["9","(","ª","·"],Digit0:["0",")","º","‚"],Space:[" "," "," "," "],Minus:["[","{","“","”"],Equal:["]","}","‘","’"],BracketLeft:["/","?","÷","¿"],BracketRight:["=","+","≠","±"],Backslash:["\\","|","«","»"],Semicolon:["s","S","ß","Í"],Quote:["-","_","–","—"],Backquote:["`","~","`","`"],Comma:["w","W","∑","„"],Period:["v","V","√","◊"],Slash:["z","Z","Ω","¸"],NumpadDivide:["/","/","/","/"],NumpadMultiply:["*","*","*","*"],NumpadSubtract:["-","-","-","-"],NumpadAdd:["+","+","+","+"],Numpad1:["1","1","1","1"],Numpad2:["2","2","2","2"],Numpad3:["3","3","3","3"],Numpad4:["4","4","4","4"],Numpad5:["5","5","5","5"],Numpad6:["6","6","6","6"],Numpad7:["7","7","7","7"],Numpad8:["8","8","8","8"],Numpad9:["9","9","9","9"],Numpad0:["0","0","0","0"],NumpadDecimal:[".",".",".","."],IntlBackslash:["§","±","§","±"],NumpadEqual:["=","=","=","="],AudioVolumeUp:["","=","","="]}});var Yl=new Set(["Backquote","Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Minus","Equal","IntlYen","KeyQ","KeyW","KeyE","KeyR","KeyT","KeyY","KeyU","KeyI","KeyO","KeyP","BracketLeft","BracketRight","Backslash","KeyA","KeyS","KeyD","KeyF","KeyG","KeyH","KeyJ","KeyK","KeyL","Semicolon","Quote","IntlBackslash","KeyZ","KeyX","KeyC","KeyV","KeyB","KeyN","KeyM","Comma","Period","Slash","IntlRo","Space","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadAdd","NumpadComma","NumpadDecimal","NumpadDivide","NumpadEqual","NumpadHash","NumpadMultiply","NumpadParenLeft","NumpadParenRight","NumpadStar","NumpadSubstract"]);function Xl(e){return!e.ctrlKey&&!e.metaKey&&(!["Dead","Process"].includes(e.key)&&(""===e.code||Yl.has(e.code)))}function Jl(){var e;let t=document.activeElement;for(;null==(e=null==t?void 0:t.shadowRoot)?void 0:e.activeElement;)t=t.shadowRoot.activeElement;return t}var Ql=class e{static get scrim(){return e._scrim||(e._scrim=new e),e._scrim}static open(t){e.scrim.open(t)}static close(){e.scrim.close()}static get state(){return e.scrim.state}static get element(){return e.scrim.element}constructor(e){var t,n;this.lightDismiss=null==(t=null==e?void 0:e.lightDismiss)||t,this.translucent=null!=(n=null==e?void 0:e.translucent)&&n,this.state="closed"}get element(){if(this._element)return this._element;const e=document.createElement("div");return e.setAttribute("role","presentation"),e.style.position="fixed",e.style.contain="content",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.zIndex="var(--scrim-zindex, 10099)",e.style.outline="none",this.translucent?(e.style.background="rgba(255, 255, 255, .2)",e.style.backdropFilter="contrast(40%)"):e.style.background="transparent",this._element=e,e}open(e){var t;if("closed"!==this.state)return;this.state="opening",this.onDismiss=null==e?void 0:e.onDismiss,this.savedActiveElement=Jl();const{element:n}=this;(null!=(t=null==e?void 0:e.root)?t:document.body).appendChild(n),n.addEventListener("click",this),document.addEventListener("touchmove",this,!1),document.addEventListener("scroll",this,!1);const i=window.innerWidth-document.documentElement.clientWidth;this.savedMarginRight=document.body.style.marginRight,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden";const r=Number.parseFloat(getComputedStyle(document.body).marginRight);document.body.style.marginRight=`${r+i}px`,(null==e?void 0:e.child)&&n.append(e.child),this.state="open"}close(){var e,t,n,i;if("open"!==this.state)return void console.assert(null!==this.element.parentElement);this.state="closing","function"==typeof this.onDismiss&&this.onDismiss(),this.onDismiss=void 0;const{element:r}=this;r.removeEventListener("click",this),document.removeEventListener("touchmove",this,!1),document.removeEventListener("scroll",this,!1),r.remove(),document.body.style.overflow=null!=(e=this.savedOverflow)?e:"",document.body.style.marginRight=null!=(t=this.savedMarginRight)?t:"",Jl()!==this.savedActiveElement&&(null==(i=null==(n=this.savedActiveElement)?void 0:n.focus)||i.call(n)),r.innerHTML="",this.state="closed"}handleEvent(e){this.lightDismiss&&(e.target===this._element&&"click"===e.type?(this.close(),e.preventDefault(),e.stopPropagation()):e.target!==document||"touchmove"!==e.type&&"scroll"!==e.type||(this.close(),e.preventDefault(),e.stopPropagation()))}};function ec(e){var t;if(!e||!Xl(e))return"";let n;return"Unidentified"===e.key&&e.target&&(n=e.target.value),n=null!=(t=null!=n?n:e.key)?t:e.code,/^(Dead|Return|Enter|Tab|Escape|Delete|PageUp|PageDown|Home|End|Help|ArrowLeft|ArrowRight|ArrowUp|ArrowDown)$/.test(n)&&(n=""),n}function tc(e){const t=[];return(e=function(e){if(e.code)return e;const t=Object.entries(Hl().mapping);let n=!1,i=!1,r="";for(let s=0;s<4;s++){for(const[a,o]of t)if(o[s]===e.key){r=a,3===s?(n=!0,i=!0):2===s?n=!0:1===s&&(i=!0);break}if(r)break}return new KeyboardEvent(e.type,h(u({},e),{altKey:n,shiftKey:i,code:r}))}(e)).ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),0===t.length?`[${e.code}]`:(t.push(`[${e.code}]`),t.join("+"))}function nc(e){let t=e;return f(t)&&(t=t.length>0?t[0]+"("+t.slice(1).join("")+")":""),t}function ic(e,t){let n=[];if("string"==typeof t){const e=Ja[t];f(e)?n=e.slice():e&&n.push(e)}const i=nc(t),r=new RegExp("^"+i.replace("\\","\\\\").replace("|","\\|").replace("*","\\*").replace("$","\\$").replace("^","\\^")+"([^*a-zA-Z]|$)");for(const t of e)r.test(nc(t.command))&&n.push(t.key);return n.map(jl)}function rc(e,t){if(e.ifPlatform&&!/^!?(macos|windows|android|ios|chromeos|other)$/.test(e.ifPlatform))throw new Error(`Unexpected platform "${e.ifPlatform}" for keybinding ${e.key}`);if(void 0!==e.ifLayout&&(0===t.score||!e.ifLayout.includes(t.id)))return;const n=$l(e.key);let i=e.ifPlatform;if(n.cmd){if(i&&"macos"!==i&&"ios"!==i)throw new Error('Unexpected "cmd" modifier with platform "'+i+'"\n"cmd" modifier can only be used with macOS or iOS platform.');i||(i="ios"===_()?"ios":"macos"),n.win=!1,n.cmd=!1,n.meta=!0}if(n.win){if(i&&"windows"!==i)throw new Error('Unexpected "win" modifier with platform "'+i+'"\n"win" modifier can only be used with Windows platform.');i="windows",n.win=!1,n.cmd=!1,n.meta=!0}if(i&&!function(e){if(m()){const t=_(),n=e.startsWith("!"),i=e.endsWith(t);if(n&&!i)return!0;if(!n&&i)return!0}return"!other"!==e&&"other"===e}(i))return;if(/^\[.+\]$/.test(n.key))return h(u({},e),{key:Kl(n)});const r=function(e,t){var n;const i={shift:!1,alt:!1,cmd:!1,win:!1,meta:!1,ctrl:!1,key:""};if(!e)return i;for(const[n,r]of Object.entries(t.mapping)){if(r[0]===e)return i.key=`[${n}]`,i;if(r[1]===e)return i.shift=!0,i.key=`[${n}]`,i;if(r[2]===e)return i.alt=!0,i.key=`[${n}]`,i;if(r[3]===e)return i.shift=!0,i.alt=!0,i.key=`[${n}]`,i}return i.key=null!=(n=zl[e])?n:"",i}(n.key,t);if(!r)return h(u({},e),{key:Kl(n)});if(r.shift&&n.shift||r.alt&&n.alt)throw new Error(`The keybinding ${e.key} (${sc(e.command)}) is conflicting with the key combination ${Kl(r)} using the ${t.displayName} keyboard layout`);return r.shift=r.shift||n.shift,r.alt=r.alt||n.alt,r.meta=n.meta,r.ctrl=n.ctrl,h(u({},e),{key:Kl(r)})}function sc(e){if(Array.isArray(e)){const t=[...e];return t.shift()+"("+t.map((e=>"string"==typeof e?`"${e}"`:e.toString())).join(", ")+")"}return e}function ac(e){var t,n;const i=e.atoms.find((e=>"latexgroup"===e.type));return i&&null!=(n=null==(t=i.body)?void 0:t.filter((e=>"latex"===e.type)))?n:[]}function oc(e,t){var n;let i=0,r=!1;const s=Number.isFinite(null==t?void 0:t.before)?null!=(n=null==t?void 0:t.before)?n:0:e.lastOffset;for(;i<=s&&!r;){const t=e.at(i);r=t instanceof ul&&t.isSuggestion,r||i++}if(!r)return[void 0,void 0];let a=i,o=!1;for(;a<=s&&!o;){const t=e.at(a);o=!(t instanceof ul&&t.isSuggestion),o||a++}return[i-1,a-1]}function lc(e){const t=ac(e.model).filter((e=>e.isSuggestion));if(0!==t.length){e.model.position=e.model.offsetOf(t[0].leftSibling);for(const e of t)e.parent.removeChild(e)}}function cc(e,t){var n;const{model:i}=e;lc(e);for(const e of ac(i))e.isError=!1;if(!i.selectionIsCollapsed||"off"===e.options.popoverPolicy)return void _c(e);const r=[];let s=i.at(i.position);for(;s&&s instanceof ul&&/^[a-zA-Z\*]$/.test(s.value);)s=s.leftSibling;if(s&&s instanceof ul&&"\\"===s.value)for(r.push(s),s=s.rightSibling;s&&s instanceof ul&&/^[a-zA-Z\*]$/.test(s.value);)r.push(s),s=s.rightSibling;const a=r.map((e=>e.value)).join(""),o=function(e,t){var n,i;if(0===t.length||"\\"===t||!t.startsWith("\\"))return[];const r=[];for(const e in V)e.startsWith(t)&&!V[e].infix&&r.push({match:e,frequency:null!=(n=V[e].frequency)?n:0});for(const e in U)e.startsWith(t)&&r.push({match:e,frequency:null!=(i=U[e].frequency)?i:0});const s=t.substring(1);for(const t of Object.keys(e.options.macros))t.startsWith(s)&&r.push({match:"\\"+t,frequency:0});return r.sort(((e,t)=>{var n,i;return e.frequency===t.frequency?e.match.length===t.match.length?e.match<t.match?-1:1:e.match.length-t.match.length:(null!=(n=t.frequency)?n:0)-(null!=(i=e.frequency)?i:0)})),r.map((e=>e.match))}(e,a);if(0===o.length){if(/^\\[a-zA-Z\*]+$/.test(a))for(const e of r)e.isError=!0;return void _c(e)}const l=null!=(n=null==t?void 0:t.atIndex)?n:0;e.suggestionIndex=l<0?o.length-1:l%o.length;const c=o[e.suggestionIndex];if(c!==a){const t=r[r.length-1];t.parent.addChildrenAfter([...c.slice(a.length-c.length)].map((e=>new ul(e,{isSuggestion:!0}))),t),Lc(e,{interactive:!0})}!function(e,t){var n;if(0===t.length)return void _c(e);let i="";for(const[n,r]of t.entries()){const t=r,s=fc(e,r),a=ic(e.keybindings,t).join("<br>");i+=`<li role="button" data-command="${t}" ${n===e.suggestionIndex?"class=ML__popover__current":""}><span class="ML__popover__latex">${t}</span><span class="ML__popover__command">${s}</span>`,a&&(i+=`<span class="ML__popover__keybinding">${a}</span>`),i+="</li>"}const r=function(e,t){let n=document.getElementById("mathlive-suggestion-popover");n||(n=dc("mathlive-suggestion-popover"),po("suggestion-popover"),po("core"),n.addEventListener("pointerdown",(e=>e.preventDefault())),n.addEventListener("click",(t=>{let n=t.target;for(;n&&!n.dataset.command;)n=n.parentElement;n&&(hc(e,"reject"),Ya.insert(e.model,n.dataset.command,{selectionMode:"placeholder",format:"latex",mode:"math"}),e.dirty=!0,e.focus())})));return n.innerHTML=window.MathfieldElement.createHTML(t),n}(e,`<ul>${i}</ul>`);mc()&&(null==(n=r.querySelector(".ML__popover__current"))||n.scrollIntoView({block:"nearest",inline:"nearest"}));setTimeout((()=>{var t;r&&!mc()&&(r.classList.add("is-visible"),gc(e),null==(t=r.querySelector(".ML__popover__current"))||t.scrollIntoView({block:"nearest",inline:"nearest"}))}),32)}(e,o)}function uc(e){const[t,n]=oc(e,{before:e.position});if(void 0===t||void 0===n)return!1;let i=!1;return e.getAtoms([t,n]).forEach((e=>{e.isSuggestion&&(e.isSuggestion=!1,i=!0)})),i}function hc(e,t="accept",n){var i,r;_c(e);const s=e.model.atoms.find((e=>"latexgroup"===e.type));if(!s)return!1;if("accept-suggestion"===t||"accept-all"===t){const n=ac(e.model).filter((e=>e.isSuggestion));if(0!==n.length){for(const e of n)e.isSuggestion=!1;e.model.position=e.model.offsetOf(n[n.length-1])}if("accept-suggestion"===t)return 0!==n.length}const a=ac(e.model).filter((e=>!e.isSuggestion)).map((e=>e.value)).join(""),o=s.leftSibling;return s.parent.removeChild(s),e.model.position=e.model.offsetOf(o),e.switchMode(null!=(i=null==n?void 0:n.mode)?i:"math"),"reject"===t||(Ya.insert(e.model,a,{selectionMode:null!=(r=null==n?void 0:n.selectItem)&&r?"item":"placeholder",format:"latex",mode:"math"}),e.snapshot(),e.model.announce("replacement"),e.switchMode("math")),!0}function dc(e){var t;let n=document.getElementById(e);return n?n.dataset.refcount=Number(Number.parseInt(null!=(t=n.dataset.refcount)?t:"0")+1).toString():(n=document.createElement("div"),n.setAttribute("aria-hidden","true"),n.dataset.refcount="1",n.id=e,document.body.append(n)),n}function pc(e){var t;const n=document.getElementById(e);if(!n)return;const i=Number.parseInt(null!=(t=n.getAttribute("data-refcount"))?t:"0");i<=1?n.remove():n.dataset.refcount=Number(i-1).toString()}function fc(e,t){const n=new Ca({from:e.context}),i=new Ma({mode:"math",type:"root",body:Qo(t,{context:n})});return da(ha(xl(new ca(i.render(n),{classes:"ML__base"}),n)),{classes:"ML__latex"}).toMarkup()}function mc(){const e=document.getElementById("mathlive-suggestion-popover");return!!e&&e.classList.contains("is-visible")}function gc(e,t){var n;if(!e.element||e.element.mathfield!==e)return;if(!mc())return;if("latex"!==(null==(n=e.model.at(e.model.position))?void 0:n.type))return void _c(e);if(null==t?void 0:t.deferred)return void setTimeout((()=>gc(e)),32);const i=eo(e.field);if(!i)return;const r=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a=window.innerWidth-document.documentElement.clientWidth,o=window.innerHeight-document.documentElement.clientHeight,l=window.mathVirtualKeyboard.boundingRect.height,c=document.getElementById("mathlive-suggestion-popover");i.x+c.offsetWidth/2>s-a?c.style.left=s-c.offsetWidth-a+"px":i.x-c.offsetWidth/2<0?c.style.left="0":c.style.left=i.x-c.offsetWidth/2+"px";const u=i.y-i.height;r-o-l-i.y<u?(c.classList.add("ML__popover--reverse-direction"),c.classList.remove("top-tip"),c.classList.add("bottom-tip"),c.style.top=i.y-i.height-c.offsetHeight-15+"px"):(c.classList.remove("ML__popover--reverse-direction"),c.classList.add("top-tip"),c.classList.remove("bottom-tip"),c.style.top=`${i.y+15}px`)}function _c(e){e.suggestionIndex=0;const t=document.getElementById("mathlive-suggestion-popover");t&&(t.classList.remove("is-visible"),t.innerHTML="")}new class extends Ya{constructor(){super("latex")}createAtom(e){return new ul(e)}onPaste(e,t){if(!t)return!1;const n="string"==typeof t?t:t.getData("application/x-latex")||t.getData("text/plain");return!(!n||!e.model.contentWillChange({inputType:"insertFromPaste",data:n}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,n)&&(e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),Tc(e)),e.startRecording(),!0)}insert(e,t,n){if(!e.contentWillChange({data:t,inputType:"insertText"}))return!1;n||(n={}),n.insertionMode||(n.insertionMode="replaceSelection"),n.selectionMode||(n.selectionMode="placeholder");const{silenceNotifications:i}=e;n.silenceNotifications&&(e.silenceNotifications=!0);const r=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==n.insertionMode||e.selectionIsCollapsed?"replaceAll"===n.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===n.insertionMode?e.collapseSelection("backward"):"insertAfter"===n.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(Fa(e.selection));const s=[];for(const e of t)j.test(e)&&s.push(new ul(e));let a=e.at(e.position);if(a instanceof hl&&(a=a.lastChild),!(a.parent instanceof hl)){const e=new hl("");a.parent.addChildAfter(e,a),a=e.firstChild}const o=a.parent.addChildrenAfter(s,a);return e.silenceNotifications=r,"before"===n.selectionMode||("item"===n.selectionMode?e.setSelection(e.anchor,e.offsetOf(o)):o&&(e.position=e.offsetOf(o))),e.contentDidChange({data:t,inputType:"insertText"}),e.silenceNotifications=i,!0}};var yc,vc,bc=null,wc=(null==(vc=null==(yc=null==globalThis?void 0:globalThis.document)?void 0:yc.currentScript)?void 0:vc.src)||function(){const e=String((new Error).stack).replace(/^Error.*\n/,"").split("\n");if(0===e.length)return console.error(`Can't use relative paths to specify assets location because the sourcefile location could not be determined (unexpected stack trace format "${(new Error).stack}").`),"";let t=e[1],n=t.match(/http.*\.ts[\?:]/);return n&&(t=e[2]),n=t.match(/(https?:.*):[0-9]+:[0-9]+/),n||(n=t.match(/at (.*(\.ts))[\?:]/),n||(n=t.match(/at (.*(\.mjs|\.js))[\?:]/))),n?n[1]:(console.error(e),console.error(`Can't use relative paths to specify assets location because the source file location could not be determined (unexpected location "${t}").`),"")}();async function xc(e){if(/^(?:[a-z+]+:)?\/\//i.test(e))return new URL(e).href;if(null===bc)try{const e=await fetch(wc,{method:"HEAD"});200===e.status&&(bc=e.url)}catch(t){console.error(`Invalid URL "${e}" (relative to "${wc}")`)}return new URL(e,null!=bc?bc:wc).href}var kc="not-loaded";async function Sc(){var e;if("not-loaded"!==kc)return;kc="loading";if(null!=(e=getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts"))&&e)kc="ready";else if(document.body.classList.remove("ML__fonts-did-not-load"),"fonts"in document){const e=["KaTeX_Main","KaTeX_Math","KaTeX_AMS","KaTeX_Caligraphic","KaTeX_Fraktur","KaTeX_SansSerif","KaTeX_Script","KaTeX_Typewriter","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"],t=Array.from(document.fonts).map((e=>e.family));if(e.every((e=>t.includes(e))))return void(kc="ready");if(!window.MathfieldElement.fontsDirectory)return void(kc="not-loaded");const n=await xc(window.MathfieldElement.fontsDirectory);if(!n)return document.body.classList.add("ML__fonts-did-not-load"),void(kc="error");const i=[["KaTeX_Main-Regular"],["KaTeX_Main-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_Main-Bold",{weight:"bold"}],["KaTeX_Main-Italic",{style:"italic"}],["KaTeX_Math-Italic",{style:"italic"}],["KaTeX_Math-BoldItalic",{style:"italic",weight:"bold"}],["KaTeX_AMS-Regular"],["KaTeX_Caligraphic-Regular"],["KaTeX_Caligraphic-Bold",{weight:"bold"}],["KaTeX_Fraktur-Regular"],["KaTeX_Fraktur-Bold",{weight:"bold"}],["KaTeX_SansSerif-Regular"],["KaTeX_SansSerif-Bold",{weight:"bold"}],["KaTeX_SansSerif-Italic",{style:"italic"}],["KaTeX_Script-Regular"],["KaTeX_Typewriter-Regular"],["KaTeX_Size1-Regular"],["KaTeX_Size2-Regular"],["KaTeX_Size3-Regular"],["KaTeX_Size4-Regular"]].map((e=>function(e,t,n={}){return new FontFace(e,`url(${t}.woff2) format('woff2')`,n)}(e[0].replace(/-[a-zA-Z]+$/,""),`${n}/${e[0]}`,e[1])));try{return(await Promise.all(i.map((e=>{try{return e.load()}catch(e){}})))).forEach((e=>document.fonts.add(e))),void(kc="ready")}catch(e){console.error(`MathLive 0.98.5: The math fonts could not be loaded from "${n}"`,{cause:e}),document.body.classList.add("ML__fonts-did-not-load")}kc="error"}}function Ec(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Tc(e,t){e&&(e.dirty||(e.dirty=!0,requestAnimationFrame((()=>{Qa(e)&&e.dirty&&(e.atomBoundsCache=new Map,Lc(e,t),e.atomBoundsCache=void 0)}))))}function Cc(e,t){const{model:n}=e;n.root.caret=void 0,n.root.isSelected=!1,n.root.containsCaret=!0;for(const e of n.atoms)e.caret=void 0,e.isSelected=!1,e.containsCaret=!1;if(n.selectionIsCollapsed){const t=n.at(n.position);t.caret=e.model.mode;let i=t.parent;for(;i;)i.containsCaret=!0,i=i.parent}else{const e=n.getAtoms(n.selection,{includeChildren:!0});for(const t of e)t.isSelected=!0}const i=function(e,t){var n;t=null!=t?t:{};const i=new Ca({from:h(u({},e.context),{atomIdsSettings:{seed:t.forHighlighting?Ec(Ma.serialize([e.model.root],{expandMacro:!1,defaultMode:e.options.defaultMode})):"random",groupNumbers:null!=(n=t.forHighlighting)&&n},letterShapeStyle:e.options.letterShapeStyle}),mathstyle:"inline-math"===e.options.defaultMode?"textstyle":"displaystyle"});return da(xl(e.model.root.render(i),i),{classes:e.hasEditablePrompts?"ML__latex ML__prompting":"ML__latex",attributes:{translate:"no","aria-hidden":"true"}})}(e,t);return i.toMarkup()}function Lc(e,t){if(!Qa(e))return;null!=t||(t={});const n=e.element.querySelector("[part=virtual-keyboard-toggle]");n&&(n.style.display=e.hasEditableContent?"":"none");const i=e.field;if(!i)return;const r=e.isSelectionEditable&&e.hasFocus(),s=i.classList.contains("ML__focused");s&&!r?i.classList.remove("ML__focused"):!s&&r&&i.classList.add("ML__focused");let a=Cc(e,t);const o=e.element.querySelector("[part=menu-toggle]");if(o&&(e.model.atoms.length<=1||e.disabled||e.readOnly&&!e.hasEditableContent||"none"===e.userSelect?o.style.display="none":o.style.display=""),e.model.atoms.length<=1){const t=e.options.contentPlaceholder;t&&(a+=`<span part=placeholder class="ML__content-placeholder">${bd(t)}</span>`)}i.innerHTML=window.MathfieldElement.createHTML(a),Ac(e,t.interactive),e.dirty=!1}function Ac(e,t){const n=e.field;if(!n)return;for(const e of n.querySelectorAll(".ML__selection, .ML__contains-highlight"))e.remove();null!=t&&t||"error"===kc||"ready"===kc||setTimeout((()=>{"ready"===kc?Ac(e):setTimeout((()=>Ac(e)),128)}),32);const i=e.model,r=n.offsetWidth,s=n.getBoundingClientRect().width;let a=Math.floor(s)/r;if(a=isNaN(a)?1:a,i.selectionIsCollapsed){gc(e,{deferred:!0});let t=i.at(i.position);for(;t&&"prompt"!==t.type&&(!t.containsCaret||!t.displayContainsHighlight);)t=t.parent;if((null==t?void 0:t.containsCaret)&&t.displayContainsHighlight){const i=no(e,ro(e,t),a);if(i){i.left/=a,i.right/=a,i.top/=a,i.bottom/=a;const e=document.createElement("div");e.classList.add("ML__contains-highlight"),e.style.position="absolute",e.style.left=`${i.left+1}px`,e.style.top=`${Math.ceil(i.top)}px`,e.style.width=`${Math.ceil(i.right-i.left)}px`,e.style.height=`${Math.ceil(i.bottom-i.top)}px`,n.insertBefore(e,n.childNodes[0])}}}else for(const t of function(e){let t=[];for(const n of e){let e=!1;for(const i of t)if(n.left===i.left&&n.right===i.right&&n.top===i.top&&n.bottom===i.bottom){e=!0;break}e||t.push(n)}e=t,t=[];for(const n of e){let i=0;for(const t of e)if(n.left>=t.left&&n.right<=t.right&&n.top>=t.top&&n.bottom<=t.bottom&&(i+=1,i>1))break;1===i&&t.push(n)}return t}(so(e,{excludeAtomsWithBackground:!0}))){t.left/=a,t.right/=a,t.top/=a,t.bottom/=a;const e=document.createElement("div");e.classList.add("ML__selection"),e.style.position="absolute",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${Math.ceil(t.right-t.left)}px`,e.style.height=`${Math.ceil(t.bottom-t.top-1)}px`,n.insertBefore(e,n.childNodes[0])}}var Dc;function Mc(e,t){t=u({target:"mathfield",canUndo:!1,audioFeedback:void 0,changeContent:!1,changeSelection:!1},null!=t?t:{}),Dc||(Dc={});for(const n of Object.keys(e))console.assert(!Dc[n],"Selector already defined: ",n),Dc[n]=h(u({},t),{fn:e[n]})}function Rc(e){let t;if(Array.isArray(e)){if("performWithFeedback"===e[0])return Rc(e[1]);t=e[0]}else t=e;return t=t.replace(/-\w/g,(e=>e[1].toUpperCase())),Dc[t]}function Ic(e){var t;return null==(t=Rc(e))?void 0:t.target}Mc({performWithFeedback:(e,t)=>function(e,t){var n;if(!e)return!1;e.focus(),dp.keypressVibration&&g()&&navigator.vibrate(3);const i=Rc(t);window.MathfieldElement.playSound(null!=(n=null==i?void 0:i.audioFeedback)?n:"keypress");const r=e.executeCommand(t);return e.scrollIntoView(),r}(e,t)}),Mc({complete:hc},{target:"mathfield",audioFeedback:"return",canUndo:!0,changeContent:!0,changeSelection:!0}),Mc({nextSuggestion:function(e){return cc(e,{atIndex:e.suggestionIndex+1}),!1},previousSuggestion:function(e){return cc(e,{atIndex:e.suggestionIndex-1}),!1}},{target:"mathfield",audioFeedback:"keypress",changeSelection:!0});var Pc="mathlive#virtual-keyboard-message";function Oc(e){var t;if("message"!==e.type)return!1;return(null==(t=e.data)?void 0:t.type)===Pc}var Fc,Nc=class e{constructor(){this.targetOrigin=window.origin,this.originValidator="none",this._boundingRect=new DOMRect(0,0,0,0),this._isShifted=!1,window.addEventListener("message",this),this.sendMessage("proxy-created"),this.listeners={}}static get singleton(){return this._singleton||(this._singleton=new e),this._singleton}set alphabeticLayout(e){this.sendMessage("update-setting",{alphabeticLayout:e})}set layouts(e){this.sendMessage("update-setting",{layouts:e})}get normalizedLayouts(){return[]}set editToolbar(e){this.sendMessage("update-setting",{editToolbar:e})}set actionKeycap(e){this.sendMessage("update-setting",{actionKeycap:e})}set shiftKeycap(e){this.sendMessage("update-setting",{shiftKeycap:e})}set backspaceKeycap(e){this.sendMessage("update-setting",{backspaceKeycap:e})}set tabKeycap(e){this.sendMessage("update-setting",{tabKeycap:e})}set container(e){throw new Error("Container inside an iframe cannot be changed")}show(e){this.sendMessage("show",e)}hide(e){this.sendMessage("hide",e)}get isShifted(){return this._isShifted}get visible(){return this._boundingRect.height>0}set visible(e){e?this.show():this.hide()}get boundingRect(){return this._boundingRect}executeCommand(e){return this.sendMessage("execute-command",{command:e}),!0}updateToolbar(e){this.sendMessage("update-toolbar",e)}update(e){this.sendMessage("update-setting",e)}connect(){this.sendMessage("connect")}disconnect(){this.sendMessage("disconnect")}addEventListener(e,t,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(t)||this.listeners[e].add(t)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach((t=>{"function"==typeof t?t(e):null==t||t.handleEvent(e)})),!e.defaultPrevented)}removeEventListener(e,t,n){this.listeners[e]&&this.listeners[e].delete(t)}handleEvent(e){if(Oc(e)){if(!ao(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");this.handleMessage(e.data)}}handleMessage(e){const{action:t}=e;if("execute-command"!==t)return"synchronize-proxy"===t?(this._boundingRect=e.boundingRect,void(this._isShifted=e.isShifted)):"geometry-changed"===t?(this._boundingRect=e.boundingRect,void this.dispatchEvent(new Event("geometrychange"))):void 0;{const{command:t}=e;"virtual-keyboard"===Ic(t)&&this.executeCommand(t)}}sendMessage(e,t={}){if(!window.top)throw new DOMException("A frame does not have access to the top window and can‘t communicate with the keyboard. Review virtualKeyboardTargetOrigin and originValidator on mathfields embedded in an iframe","SecurityError");window.top.postMessage(u({type:Pc,action:e},t),this.targetOrigin)}},Bc={numeric:{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",rows:[[{latex:"x",shift:"y",variants:["y","z","t","r","x^2","x^n","x^{#?}","x_n","x_i","x_{#?}",{latex:"f(#?)",class:"small"},{latex:"g(#?)",class:"small"}]},{latex:"n",shift:"a",variants:["i","j","p","k","a","u"]},"[separator-5]","[7]","[8]","[9]","[/]","[separator-5]",{latex:"\\exponentialE",shift:"\\ln",variants:["\\exp","\\times 10^{#?}","\\ln","\\log_{10}","\\log"]},{latex:"\\imaginaryI",variants:["\\Re","\\Im","\\imaginaryJ","\\Vert #0 \\Vert"]},{latex:"\\pi",shift:"\\sin",variants:["\\prod",{latex:"\\theta",aside:"theta"},{latex:"\\rho",aside:"rho"},{latex:"\\tau",aside:"tau"},"\\sin","\\cos","\\tan"]}],[{label:"<",latex:"<",class:"hide-shift",shift:{latex:"\\le",label:"≤"}},{label:">",latex:">",class:"hide-shift",shift:{latex:"\\ge",label:"≥"}},"[separator-5]","[4]","[5]","[6]","[*]","[separator-5]",{class:"hide-shift",latex:"#@^2}",shift:"#@^{\\prime}}"},{latex:"#@^{#0}}",class:"hide-shift",shift:"#@_{#?}"},{class:"hide-shift",latex:"\\sqrt{#0}",shift:{latex:"\\sqrt[#0]{#?}}"}}],["[(]","[)]","[separator-5]","[1]","[2]","[3]","[-]","[separator-5]",{latex:"\\int^{\\infty}_{0}\\!#?\\,\\mathrm{d}x",class:"small hide-shift",shift:"\\int",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{class:"hide-shift",latex:"\\forall",shift:"\\exists"},{label:"[backspace]",width:1}],[{label:"[shift]",width:2},"[separator-5]","[0]","[.]","[=]","[+]","[separator-5]","[left]","[right]",{label:"[action]",width:1}]]},greek:{label:"αβγ",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.greek",rows:[[{label:"<i>φ</i>",class:"MLK__tex hide-shift",insert:"\\varphi",aside:"phi var.",shift:"\\Phi"},{label:"<i>ς</i>",class:"MLK__tex hide-shift",insert:"\\varsigma",aside:"sigma var.",shift:"\\Sigma"},{label:"<i>ϵ</i>",class:"MLK__tex hide-shift",insert:"\\epsilon",aside:"espilon",shift:'\\char"0190'},{label:"<i>ρ</i>",class:"MLK__tex hide-shift",insert:"\\rho",aside:"rho",shift:'\\char"3A1'},{label:"<i>τ</i>",class:"MLK__tex hide-shift",insert:"\\tau",aside:"tau",shift:'\\char"3A4'},{label:"<i>υ</i>",class:"MLK__tex hide-shift",insert:"\\upsilon",aside:"upsilon",shift:"\\Upsilon"},{label:"<i>θ</i>",class:"MLK__tex hide-shift",insert:"\\theta",aside:"theta",shift:"\\Theta"},{label:"<i>ι</i>",class:"MLK__tex hide-shift",insert:"\\iota",aside:"iota",shift:'\\char"399'},{label:"<i>ο</i>",class:"MLK__tex hide-shift",insert:"\\omicron",aside:"omicron",shift:'\\char"39F'},{label:"<i>π</i>",class:"MLK__tex hide-shift",insert:"\\pi",aside:"pi",shift:"\\Pi"}],["[separator-5]",{label:"<i>α</i>",class:"MLK__tex hide-shift",insert:"\\alpha",aside:"alpha",shift:'\\char"391'},{label:"<i>σ</i>",class:"MLK__tex hide-shift",insert:"\\sigma",aside:"sigma",shift:"\\Sigma"},{label:"<i>δ</i>",class:"MLK__tex hide-shift",insert:"\\delta",aside:"delta",shift:"\\Delta"},{latex:"\\phi",class:"MLK__tex hide-shift",insert:"\\phi",aside:"phi",shift:"\\Phi"},{label:"<i>γ</i>",class:"MLK__tex hide-shift",insert:"\\gamma",aside:"gamma",shift:"\\Gamma"},{label:"<i>η</i>",class:"MLK__tex hide-shift",insert:"\\eta",aside:"eta",shift:'\\char"397'},{label:"<i>ξ</i>",class:"MLK__tex hide-shift",insert:"\\xi",aside:"xi",shift:"\\Xi"},{label:"<i>κ</i>",class:"MLK__tex hide-shift",insert:"\\kappa",aside:"kappa",shift:"\\Kappa"},{label:"<i>λ</i>",class:"MLK__tex hide-shift",insert:"\\lambda",aside:"lambda",shift:"\\Lambda"},"[separator-5]"],["[shift]",{label:"<i>ζ</i>",class:"MLK__tex hide-shift",insert:"\\zeta",aside:"zeta",shift:'\\char"396'},{label:"<i>χ</i>",class:"MLK__tex hide-shift",insert:"\\chi",aside:"chi",shift:'\\char"3A7'},{label:"<i>ψ</i>",class:"MLK__tex hide-shift",insert:"\\psi",aside:"zeta",shift:"\\Psi"},{label:"<i>ω</i>",class:"MLK__tex hide-shift",insert:"\\omega",aside:"omega",shift:"\\Omega"},{label:"<i>β</i>",class:"MLK__tex hide-shift",insert:"\\beta",aside:"beta",shift:'\\char"392'},{label:"<i>ν</i>",class:"MLK__tex hide-shift",insert:"\\nu",aside:"nu",shift:'\\char"39D'},{label:"<i>μ</i>",class:"MLK__tex hide-shift",insert:"\\mu",aside:"mu",shift:'\\char"39C'},"[backspace]"],["[separator]",{label:"<i>ε</i>",class:"MLK__tex",insert:"\\varepsilon",aside:"espilon var."},{label:"<i>ϑ</i>",class:"MLK__tex",insert:"\\vartheta",aside:"theta var."},{label:"<i>ϰ</i>",class:"MLK__tex",insert:"\\varkappa",aside:"kappa var."},{label:"<i>ϖ</i>",class:"MLK__tex",insert:"\\varpi",aside:"pi var."},{label:"<i>ϱ</i>",class:"MLK__tex",insert:"\\varrho",aside:"rho var."},"[left]","[right]","[action]"]]},symbols:{label:"∞≠∈",labelClass:"MLK__tex",tooltip:"keyboard.tooltip.symbols",rows:[[{latex:"\\sin",shift:"\\sin^{-1}",variants:[{class:"small",latex:"\\sinh"},{class:"small",latex:"\\sin^{-1}"},{class:"small",latex:"\\arsinh"}]},"\\ln",{latex:"\\mathrm{abs}",insert:"\\mathrm{abs}\\left(#0\\right)"},{latex:"\\rarr",shift:"\\rArr",variants:[{latex:"\\implies",aside:"implies"},{latex:"\\to",aside:"to"},"\\dashv",{latex:"\\roundimplies",aside:"round implies"}]},{latex:"\\exists",variants:["\\nexists"],shift:"\\nexists"},{latex:"\\in",shift:"\\notin",variants:["\\notin","\\owns"]},"\\cup",{latex:"\\overrightarrow{#@}",shift:"\\overleftarrow{#@}",variants:["\\overleftarrow{#@}","\\bar{#@}","\\vec{#@}","\\hat{#@}","\\check{#@}","\\dot{#@}","\\ddot{#@}","\\mathring{#@}","\\breve{#@}","\\acute{#@}","\\tilde{#@}","\\grave{#@}"]},{class:"small",latex:"\\lim_{#?}",shift:"\\lim_{x\\to\\infty}",variants:[{class:"small",latex:"\\liminf_{#?}"},{class:"small",latex:"\\limsup_{#?}"}]},"\\exponentialE"],[{latex:"\\cos",shift:"\\cos^{-1}",variants:[{class:"small",latex:"\\cosh"},{class:"small",latex:"\\cos^{-1}"},{class:"small",latex:"\\arcosh"}]},{latex:"\\log",shift:"\\log_{10}",variants:["\\log_{#0}","\\log_{10}"]},"\\left\\vert#0\\right\\vert",{latex:"\\larr",shift:"\\lArr",variants:[{latex:"\\impliedby",aside:"implied by"},{latex:"\\gets",aside:"gets"},"\\lArr","\\vdash",{latex:"\\models",aside:"models"}]},{latex:"\\forall",shift:"\\lnot",variants:[{latex:"\\land",aside:"and"},{latex:"\\lor",aside:"or"},{latex:"\\oplus",aside:"xor"},{latex:"\\lnot",aside:"not"},{latex:"\\downarrow",aside:"nor"},{latex:"\\uparrow",aside:"nand"},{latex:"\\curlywedge",aside:"nor"},{latex:"\\bar\\curlywedge",aside:"nand"}]},{latex:"\\ni",shift:"\\not\\owns"},"\\cap",{latex:"\\overline{#@}",shift:"\\underline{#@}",variants:["\\overbrace{#@}","\\overlinesegment{#@}","\\overleftrightarrow{#@}","\\overrightarrow{#@}","\\overleftarrow{#@}","\\overgroup{#@}","\\underbrace{#@}","\\underlinesegment{#@}","\\underleftrightarrow{#@}","\\underrightarrow{#@}","\\underleftarrow{#@}","\\undergroup{#@}"]},{class:"hide-shift",latex:"\\int",shift:"\\iint",variants:[{latex:"\\int_{#?}^{#?}",class:"small"},{latex:"\\int",class:"small"},{latex:"\\smallint",class:"small"},{latex:"\\iint",class:"small"},{latex:"\\iiint",class:"small"},{latex:"\\oint",class:"small"},"\\intop","\\iiint","\\oiint","\\oiiint","\\intclockwise","\\varointclockwise","\\ointctrclockwise","\\intctrclockwise"]},{latex:"\\pi",shift:"\\tau",variants:["\\tau"]}],[{latex:"\\tan",shift:"\\tan^{-1}",variants:[{class:"small",latex:"\\tanh"},{class:"small",latex:"\\tan^{-1}"},{class:"small",latex:"\\artanh"},{class:"small",latex:"\\arctan"},{class:"small",latex:"\\arctg"},{class:"small",latex:"\\tg"}]},{latex:"\\exp",insert:"\\exp\\left(#0\\right)",variants:["\\exponentialE^{#0}"]},"\\left\\Vert#0\\right\\Vert",{latex:"\\lrArr",shift:"\\leftrightarrow",variants:[{latex:"\\iff",aside:"if and only if"},"\\leftrightarrow","\\leftrightarrows","\\Leftrightarrow",{latex:"^\\biconditional",aside:"biconditional"}]},{latex:"\\vert",shift:"!"},{latex:"#@^{\\complement}",aside:"complement",variants:[{latex:"\\setminus",aside:"set minus"},{latex:"\\smallsetminus",aside:"small set minus"}]},{latex:"\\subset",shift:"\\subseteq",variants:["\\subset","\\subseteq","\\subsetneq","\\varsubsetneq","\\subsetneqq","\\nsubset","\\nsubseteq","\\supset","\\supseteq","\\supsetneq","\\supsetneqq","\\nsupset","\\nsupseteq"]},{latex:"#@^{\\prime}",shift:"#@^{\\doubleprime}",variants:["#@^{\\doubleprime}","#@\\degree"]},{latex:"\\mathrm{d}",shift:"\\partial",variants:["\\mathrm{d}x",{latex:"\\dfrac{\\mathrm{d}}{\\mathrm{d} x}",class:"small"},{latex:"\\frac{\\partial}{\\partial x}",class:"small"},"\\partial"]},{latex:"\\infty",variants:["\\aleph_0","\\aleph_1","\\omega","\\mathfrak{m}"]}],[{label:"[shift]",width:2},{class:"box",latex:",",shift:";",variants:[";","?"]},{class:"box",latex:"\\colon",shift:"\\Colon",variants:[{latex:"\\Colon",aside:"such that",class:"box"},{latex:":",aside:"ratio",class:"box"},{latex:"\\vdots",aside:"",class:"box"},{latex:"\\ddots",aside:"",class:"box"},{latex:"\\ldotp",aside:"low dot",class:"box"},{latex:"\\cdotp",aside:"center dot",class:"box"},{latex:"\\ldots",aside:"low ellipsis",class:"box"},{latex:"\\cdots",aside:"center ellipsis",class:"box"},{latex:"\\therefore",aside:"therefore",class:"box"},{latex:"\\because",aside:"because",class:"box"}]},{class:"box",latex:"\\cdot",aside:"centered dot",shift:"\\ast",variants:["\\circ","\\bigcirc","\\bullet","\\odot","\\oslash","\\circledcirc","\\ast","\\star","\\times","\\doteq","\\doteqdot"]},"[separator]","[left]","[right]",{label:"[backspace]",width:1,class:"action hide-shift"},{label:"[action]",width:1}]]},compact:{label:"compact",rows:[["[+]","[-]","[*]","[/]","[=]","[.]","[(]","[)]","\\sqrt{#0}","#@^{#?}"],["[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[0]"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]},minimalist:{label:"minimalist",layers:[{style:"\n .minimalist-backdrop {\n display: flex;\n justify-content: center;\n } \n .minimalist-container {\n --keycap-height: 40px;\n --keycap-max-width: 53px;\n --keycap-small-font-size: 12px;\n background: var(--keyboard-background);\n padding: 20px;\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n border: 1px solid var(--keyboard-border);\n box-shadow: 0 0 32px rgb(0 0 0 / 30%);\n } \n ",backdrop:"minimalist-backdrop",container:"minimalist-container",rows:[["+","-","\\times",{latex:"\\frac{#@}{#0}",class:"small"},"=","[.]","(",")",{latex:"\\sqrt{#0}",class:"small"},{latex:"#@^{#?}",class:"small"}],["1","2","3","4","5","6","7","8","9","0"],["[hr]"],["[undo]","[redo]","[separator]","[separator]","[separator]","[left]","[right]",{label:"[backspace]",class:"action hide-shift"},"[hide-keyboard]"]]}]},"numeric-only":{label:"123",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.numeric",id:"numeric-only",rows:[["7","8","9","[separator]",{label:"[backspace]",width:2}],["4","5","6","[separator]","[separator]","[separator]"],["1","2","3","[separator]","[separator]","[separator]"],["0",{label:"[.]",variants:[]},"-","[separator]","[left]","[right]"]]}},$c={0:["\\varnothing","\\infty"],1:["\\frac{1}{#@}","#@^{-1}","\\times 10^{#?}","\\phi","\\imaginaryI"],2:["\\frac{1}{2}","#@^2","\\sqrt2","\\exponentialE"],3:["\\frac{1}{3}","#@^3","\\sqrt3","\\pi"],4:["\\frac{1}{4}","#@^4"],5:["\\frac{1}{5}","#@^5","\\sqrt5"],6:["\\frac{1}{6}","#@^6"],7:["\\frac{1}{7}","#@^7"],8:["\\frac{1}{8}","#@^8"],9:["\\frac{1}{9}","#@^9"],".":[".",",",";","\\colon"],",":["{,}",".",";","\\colon"],a:[{latex:"\\aleph",aside:"aleph"},{latex:"\\forall",aside:"for all"},"à","á","â","ä","æ"],b:[{latex:"\\beth",aside:"beth"}],c:[{latex:"\\C",aside:"set of complex numbers"},"ç"],d:[{latex:"\\daleth",aside:"daleth"}],e:[{latex:"\\exponentialE",aside:"exponential e"},{latex:"\\exists",aside:"there is"},{latex:"\\nexists",aside:"there isn’t"},"è","é","ê","ë"],g:[{latex:"\\gimel",aside:"gimel"}],h:[{latex:"\\hbar",aside:"h bar"},{latex:"\\hslash",aside:"h slash"}],i:[{latex:"\\imaginaryI",aside:"imaginary i"},"ì","í","î","ï"],j:[{latex:"\\imaginaryJ",aside:"imaginary j"}],l:[{latex:"\\ell",aside:"ell"}],n:[{latex:"\\mathbb{N}",aside:"set of natural numbers"},"ñ"],o:["ø","œ","ò","ó","ô","ö","œ"],p:[{latex:"\\mathbb{P}",aside:"set of primes"}],q:[{latex:"\\mathbb{Q}",aside:"set of rational numbers"}],r:[{latex:"\\mathbb{R}",aside:"set of real numbers"}],u:["ù","ú","û","ü"],z:[{latex:"\\mathbb{Z}",aside:"set of integers"}],y:["ý","ÿ"],space:[{latex:'\\char"203A\\!\\char"2039',insert:"\\!",aside:"negative thin space<br>⁻³⧸₁₈ em"},{latex:'\\char"203A\\,\\char"2039',insert:"\\,",aside:"thin space<br>³⧸₁₈ em"},{latex:'\\char"203A\\:\\char"2039',insert:"\\:",aside:"medium space<br>⁴⧸₁₈ em"},{latex:'\\char"203A\\;\\char"2039',insert:"\\;",aside:"thick space<br>⁵⧸₁₈ em"},{latex:'\\char"203A\\ \\char"2039',insert:"\\ ",aside:"⅓ em"},{latex:'\\char"203A\\enspace\\char"2039',insert:"\\enspace",aside:"½ em"},{latex:'\\char"203A\\quad\\char"2039',insert:"\\quad",aside:"1 em"},{latex:'\\char"203A\\qquad\\char"2039',insert:"\\qquad",aside:"2 em"}]};function Kc(e,t){var n,i,r;const s=lu.singleton;if(!s)return;const a=au(e),o=null!=(i=null==(n=s.getKeycap(null==a?void 0:a.id))?void 0:n.variants)?i:"";if("string"==typeof o&&!zc(o)||Array.isArray(o)&&0===o.length)return void(null==t||t());const l={};let c="";for(const e of function(e){var t;if("string"!=typeof e)return e;$c[e]||($c[e]=null!=(t=function(e){if("foreground-color"===e){const e=[];for(const t of Object.keys(S))e.push({class:"swatch-button",label:'<span style="border: 3px solid '+S[t]+'"></span>',command:["applyStyle",{color:t}]});return e}if("background-color"===e){const e=[];for(const t of Object.keys(k))e.push({class:"swatch-button",label:'<span style="background:'+k[t]+'"></span>',command:["applyStyle",{backgroundColor:t}]});return e}return}(e))?t:[]);return $c[e]}(o)){const t=tu(e),n=Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36);l[n]=t;const[i,r]=Jc(t);c+=`<div id=${n} class="item ${r}">${i}</div>`}const u=document.createElement("div");u.setAttribute("aria-hidden","true"),u.className="MLK__variant-panel",u.style.height="auto";const h=Object.keys(l).length;let d=5;1===h?d=1:2===h||4===h?d=2:3===h||5===h||6===h?d=3:h>=7&&h<14&&(d=4),u.style.width=`calc(var(--variant-keycap-length) * ${d} + 12px)`,u.innerHTML=dp.createHTML(c),Ql.open({root:null==(r=null==s?void 0:s.container)?void 0:r.querySelector(".ML__keyboard"),child:u}),Fc=new AbortController;const{signal:p}=Fc,f=null==e?void 0:e.getBoundingClientRect();if(f){f.top-u.clientHeight<0&&(u.style.width="auto",h<=6?u.style.height="56px":h<=12?u.style.height="108px":h<=18?u.style.height="205px":u.classList.add("compact"));const e=Math.max(0,Math.min(window.innerWidth-u.offsetWidth,(f.left+f.right-u.offsetWidth)/2)),n=f.top-u.clientHeight+5;u.style.transform=`translate(${e}px, ${n}px)`,u.classList.add("is-visible"),requestAnimationFrame((()=>{u.addEventListener("pointerup",(e=>{const n=au(e.target);(null==n?void 0:n.id)&&l[n.id]&&(ru(l[n.id]),Uc(),null==t||t(),e.preventDefault())}),{capture:!0,passive:!1,signal:p}),u.addEventListener("pointerenter",(e=>{const t=au(e.target);(null==t?void 0:t.id)&&l[t.id]&&t.classList.add("is-active")}),{capture:!0,signal:p}),u.addEventListener("pointerleave",(e=>{const t=au(e.target);(null==t?void 0:t.id)&&l[t.id]&&t.classList.remove("is-active")}),{capture:!0,signal:p}),window.addEventListener("pointercancel",(()=>{Uc(),null==t||t()}),{signal:p}),window.addEventListener("pointerup",(()=>{Uc(),null==t||t()}),{signal:p})}))}}function Uc(){null==Fc||Fc.abort(),Fc=null,"open"===Ql.state&&Ql.close()}function zc(e){return void 0!==$c[e]}function Vc(e){return Object.keys(e).map((t=>`${t} {${function(e){return"string"==typeof e?e:Object.entries(e).map((([e,t])=>`${e}:${t} !important`)).join(";")}(e[t])}}`)).join("")}function qc(e){if(!e)return"";const t=new Ca,n=new Ma({mode:"math",type:"root",body:Qo(e,{context:t,args:e=>"@"===e?"{\\class{ML__box-placeholder}{\\blacksquare}}":"\\placeholder{}"})});return da(ha(xl(new ca(n.render(t),{classes:"ML__base"}),t)),{classes:"ML__latex"}).toMarkup()}function Gc(e){if(Array.isArray(e))return e.map((e=>Gc(e))).flat();const t="string"==typeof e?{markup:e}:e;return"rows"in t&&Array.isArray(t.rows)&&(t.rows=t.rows.map((e=>e.map((e=>tu(e)))))),null!=t.id||(t.id="ML__layer_"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36)),[t]}function Hc(e){if("alphabetic"===e)return function(){var e,t;let n=window.mathVirtualKeyboard.alphabeticLayout;if("auto"===n){const t=Hl();t&&(n=t.virtualLayout),n&&"auto"!==n||(n=null!=(e={fr:"azerty",be:"azerty",al:"qwertz",ba:"qwertz",cz:"qwertz",de:"qwertz",hu:"qwertz",sk:"qwertz",ch:"qwertz"}[v.locale.slice(0,2)])?e:"qwerty")}const i={qwerty:["qwertyuiop"," asdfghjkl ","^zxcvbnm~"],azerty:["azertyuiop","qsdfghjklm","^ wxcvbn ~"],qwertz:["qwertzuiop"," asdfghjkl ","^yxcvbnm~"],dvorak:["^ pyfgcrl ","aoeuidhtns","qjkxbmwvz~"],colemak:[" qwfpgjluy ","arstdhneio","^zxcvbkm~"]},r=null!=(t=i[n])?t:i.qwerty,s="azerty"===n?[[{label:"1",variants:"1"},{label:"2",shift:{latex:"é"},variants:"2"},{label:"3",shift:{latex:"ù"},variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{label:"(",latex:"("},variants:"5"},{label:"6",shift:{label:")",latex:")"},variants:"6"},{label:"7",shift:{latex:"è"},variants:"7"},{label:"8",shift:{latex:"ê"},variants:"8"},{label:"9",shift:{latex:"ç"},variants:"9"},{label:"0",shift:{latex:"à"},variants:"0"}]]:[[{label:"1",variants:"1"},{label:"2",variants:"2"},{label:"3",variants:"3"},{label:"4",variants:"4"},{label:"5",shift:{latex:"\\frac{#@}{#?}"},variants:"5"},{label:"6",shift:{latex:"#@^#?"},variants:"6"},{label:"7",variants:"7"},{label:"8",shift:{latex:"\\times"},variants:"8"},{label:"9",shift:{label:"(",latex:"("},variants:"9"},{label:"0",shift:{label:")",latex:")"},variants:"0"}]];for(const e of r){const t=[];for(const i of e)/[a-z]/.test(i)?t.push({label:i,class:"hide-shift",shift:{label:i.toUpperCase()},variants:zc(i)?i:void 0}):"~"===i?"dvorak"!==n?t.push("[backspace]"):t.push({label:"[backspace]",width:1}):"^"===i?t.push("[shift]"):" "===i&&t.push("[separator-5]");s.push(t)}return s.push(["[-]","[+]","[=]",{label:" ",width:1.5},{label:",",shift:";",variants:".",class:"hide-shift"},"[.]","[left]","[right]",{label:"[action]",width:1.5}]),{label:"abc",labelClass:"MLK__tex-math",tooltip:"keyboard.tooltip.alphabetic",layers:Gc({rows:s})}}();if("string"==typeof e)return console.assert(void 0!==Bc[e],`MathLive 0.98.5: unknown keyboard layout "${e}"`),Hc(Bc[e]);let t;if("rows"in e&&Array.isArray(e.rows)){console.assert(!("layers"in e||"markup"in e),'MathLive 0.98.5: when providing a "rows" property, "layers" and "markup" are ignored');const n=e,{rows:i}=n,r=p(n,["rows"]);t=h(u({},r),{layers:Gc({rows:e.rows})})}else if("markup"in e&&"string"==typeof e.markup){const n=e,{markup:i}=n,r=p(n,["markup"]);t=h(u({},r),{layers:Gc(e.markup)})}else t=u({},e),"layers"in e?t.layers=Gc(e.layers):console.error('MathLive 0.98.5: provide either a "rows", "markup" or "layers" property');let n=!1,i=!1;for(const e of t.layers)if(e.rows)for(const t of e.rows.flat()){ou(t)&&(n=!0);const e=t.command;"string"==typeof e&&["undo","redo","cut","copy","paste"].includes(e)&&(i=!0)}return"displayShiftedKeycaps"in e&&void 0!==e.displayShiftedKeycaps||(t.displayShiftedKeycaps=n),"displayEditToolbar"in e&&void 0!==e.displayEditToolbar||(t.displayEditToolbar=!i),t}function jc(e,t){var n,i;let r='<div class="left">';if(e.normalizedLayouts.length>1)for(const[s,a]of e.normalizedLayouts.entries()){const e=a,o=[s===t?"selected":"layer-switch"];e.tooltip&&o.push("MLK__tooltip"),e.labelClass&&o.push(...e.labelClass.split(" ")),r+=`<div class="${o.join(" ")}"`,e.tooltip&&(r+=" data-tooltip='"+(null!=(n=b(e.tooltip))?n:e.tooltip)+"' "),s!==t&&(r+=`data-layer="${e.layers[0].id}"`),r+=`>${null!=(i=e.label)?i:"untitled"}</div>`}return r+="</div>",r}function Wc(e,t){let n="";if("none"===e.editToolbar)return"";const i=[];t.selectionIsCollapsed?i.push("undo","redo","pasteFromClipboard"):i.push("cutToClipboard","copyToClipboard","pasteFromClipboard");const r={undo:`<div class='action ${!1===t.canUndo?"disabled":""}'\n data-command='"undo"'\n data-tooltip='${b("tooltip.undo")}'>\n <svg><use xlink:href='#svg-undo' /></svg>\n </div>`,redo:`<div class='action ${!1===t.canRedo?"disabled":""}'\n data-command='"redo"'\n data-tooltip='${b("tooltip.redo")}'>\n <svg><use xlink:href='#svg-redo' /></svg>\n </div>`,cutToClipboard:`\n <div class='action'\n data-command='"cutToClipboard"'\n data-tooltip='${b("tooltip.cut to clipboard")}'>\n <svg><use xlink:href='#svg-cut' /></svg>\n </div>\n `,copyToClipboard:`\n <div class='action'\n data-command='"copyToClipboard"'\n data-tooltip='${b("tooltip.copy to clipboard")}'>\n <svg><use xlink:href='#svg-copy' /></svg>\n </div>\n `,pasteFromClipboard:`\n <div class='action'\n data-command='"pasteFromClipboard"'\n data-tooltip='${b("tooltip.paste from clipboard")}'>\n <svg><use xlink:href='#svg-paste' /></svg>\n </div>\n `};return n+=i.map((e=>r[e])).join(""),n}function Zc(e){const t=lu.singleton;if(!t)return;const n={};if(!e.id){if(e.hasAttribute("data-label")&&(n.label=e.dataset.label),e.hasAttribute("data-latex")&&(n.latex=e.dataset.latex),e.hasAttribute("data-key")&&(n.key=e.dataset.key),e.hasAttribute("data-insert")&&(n.insert=e.dataset.insert),e.hasAttribute("data-variants")&&(n.variants=e.dataset.variants),e.hasAttribute("data-aside")&&(n.aside=e.dataset.aside),e.className&&(n.class=e.className),n.label||n.latex||n.key||n.insert||(n.latex=e.innerText,n.label=e.innerHTML),e.hasAttribute("data-command"))try{n.command=JSON.parse(e.dataset.command)}catch(e){}e.id=t.registerKeycap(n)}if(!e.innerHTML){const[t,i]=Jc(n);e.innerHTML=window.MathfieldElement.createHTML(t)}}function Yc(e){e.resetKeycapRegistry(),po("virtual-keyboard"),po("core"),Sc();const t=document.createElement("div");t.className="ML__keyboard";const n=document.createElement("div");n.className="MLK__plate",n.innerHTML=window.MathfieldElement.createHTML('<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">\n\n<symbol id="svg-delete-backward" viewBox="0 0 576 512">\n <path d="M432.1 208.1L385.9 256L432.1 303C442.3 312.4 442.3 327.6 432.1 336.1C423.6 346.3 408.4 346.3 399 336.1L352 289.9L304.1 336.1C295.6 346.3 280.4 346.3 271 336.1C261.7 327.6 261.7 312.4 271 303L318.1 256L271 208.1C261.7 199.6 261.7 184.4 271 175C280.4 165.7 295.6 165.7 304.1 175L352 222.1L399 175C408.4 165.7 423.6 165.7 432.1 175C442.3 184.4 442.3 199.6 432.1 208.1V208.1zM512 64C547.3 64 576 92.65 576 128V384C576 419.3 547.3 448 512 448H205.3C188.3 448 172 441.3 160 429.3L9.372 278.6C3.371 272.6 0 264.5 0 256C0 247.5 3.372 239.4 9.372 233.4L160 82.75C172 70.74 188.3 64 205.3 64L512 64zM528 128C528 119.2 520.8 112 512 112H205.3C201 112 196.9 113.7 193.9 116.7L54.63 256L193.9 395.3C196.9 398.3 201 400 205.3 400H512C520.8 400 528 392.8 528 384V128z"/>\n</symbol>\n\n<symbol id="svg-shift" viewBox="0 0 384 512">\n <path d="M2.438 252.3C7.391 264.2 19.06 272 32 272h80v160c0 26.51 21.49 48 48 48h64C250.5 480 272 458.5 272 432v-160H352c12.94 0 24.61-7.797 29.56-19.75c4.953-11.97 2.219-25.72-6.938-34.88l-160-176C208.4 35.13 200.2 32 192 32S175.6 35.13 169.4 41.38l-160 176C.2188 226.5-2.516 240.3 2.438 252.3zM192 86.63L313.4 224H224v208H160V224H70.63L192 86.63z"/>\n</symbol>\n\n<symbol id="svg-commit" viewBox="0 0 512 512">\n <path d="M135 432.1l-128-128C2.344 300.3 0 294.2 0 288s2.344-12.28 7.031-16.97l128-128c9.375-9.375 24.56-9.375 33.94 0s9.375 24.56 0 33.94L81.94 264H464v-208C464 42.75 474.8 32 488 32S512 42.75 512 56V288c0 13.25-10.75 24-24 24H81.94l87.03 87.03c9.375 9.375 9.375 24.56 0 33.94S144.4 442.3 135 432.1z"/>\n</symbol>\n\n\n<symbol id="circle-plus" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></symbol>\n\n<symbol id="svg-command" viewBox="0 0 640 512">\n <path d="M34.495 36.465l211.051 211.05c4.686 4.686 4.686 12.284 0 16.971L34.495 475.535c-4.686 4.686-12.284 4.686-16.97 0l-7.071-7.07c-4.686-4.686-4.686-12.284 0-16.971L205.947 256 10.454 60.506c-4.686-4.686-4.686-12.284 0-16.971l7.071-7.07c4.686-4.687 12.284-4.687 16.97 0zM640 468v-10c0-6.627-5.373-12-12-12H300c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h328c6.627 0 12-5.373 12-12z"/>\n</symbol>\n\n<symbol id="svg-undo" viewBox="0 0 512 512">\n <path d="M20 8h10c6.627 0 12 5.373 12 12v110.625C85.196 57.047 165.239 7.715 256.793 8.001 393.18 8.428 504.213 120.009 504 256.396 503.786 393.181 392.834 504 256 504c-63.926 0-122.202-24.187-166.178-63.908-5.113-4.618-5.354-12.561-.482-17.433l7.069-7.069c4.503-4.503 11.749-4.714 16.482-.454C150.782 449.238 200.935 470 256 470c117.744 0 214-95.331 214-214 0-117.744-95.331-214-214-214-82.862 0-154.737 47.077-190.289 116H180c6.627 0 12 5.373 12 12v10c0 6.627-5.373 12-12 12H20c-6.627 0-12-5.373-12-12V20c0-6.627 5.373-12 12-12z"/>\n</symbol>\n<symbol id="svg-redo" viewBox="0 0 512 512">\n <path d="M492 8h-10c-6.627 0-12 5.373-12 12v110.625C426.804 57.047 346.761 7.715 255.207 8.001 118.82 8.428 7.787 120.009 8 256.396 8.214 393.181 119.166 504 256 504c63.926 0 122.202-24.187 166.178-63.908 5.113-4.618 5.354-12.561.482-17.433l-7.069-7.069c-4.503-4.503-11.749-4.714-16.482-.454C361.218 449.238 311.065 470 256 470c-117.744 0-214-95.331-214-214 0-117.744 95.331-214 214-214 82.862 0 154.737 47.077 190.289 116H332c-6.627 0-12 5.373-12 12v10c0 6.627 5.373 12 12 12h160c6.627 0 12-5.373 12-12V20c0-6.627-5.373-12-12-12z"/>\n</symbol>\n<symbol id="svg-arrow-left" viewBox="0 0 320 512">\n <path d="M206.7 464.6l-183.1-191.1C18.22 267.1 16 261.1 16 256s2.219-11.97 6.688-16.59l183.1-191.1c9.152-9.594 24.34-9.906 33.9-.7187c9.625 9.125 9.938 24.37 .7187 33.91L73.24 256l168 175.4c9.219 9.5 8.906 24.78-.7187 33.91C231 474.5 215.8 474.2 206.7 464.6z"/>\n</symbol>\n<symbol id="svg-arrow-right" viewBox="0 0 320 512">\n <path d="M113.3 47.41l183.1 191.1c4.469 4.625 6.688 10.62 6.688 16.59s-2.219 11.97-6.688 16.59l-183.1 191.1c-9.152 9.594-24.34 9.906-33.9 .7187c-9.625-9.125-9.938-24.38-.7187-33.91l168-175.4L78.71 80.6c-9.219-9.5-8.906-24.78 .7187-33.91C88.99 37.5 104.2 37.82 113.3 47.41z"/>\n</symbol>\n<symbol id="svg-tab" viewBox="0 0 448 512">\n <path d="M32 217.1c0-8.8 7.2-16 16-16h144v-93.9c0-7.1 8.6-10.7 13.6-5.7l143.5 143.1c6.3 6.3 6.3 16.4 0 22.7L205.6 410.4c-5 5-13.6 1.5-13.6-5.7v-93.9H48c-8.8 0-16-7.2-16-16v-77.7m-32 0v77.7c0 26.5 21.5 48 48 48h112v61.9c0 35.5 43 53.5 68.2 28.3l143.6-143c18.8-18.8 18.8-49.2 0-68L228.2 78.9c-25.1-25.1-68.2-7.3-68.2 28.3v61.9H48c-26.5 0-48 21.6-48 48zM436 64h-8c-6.6 0-12 5.4-12 12v360c0 6.6 5.4 12 12 12h8c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12z"/>\n</symbol>\n<symbol id="svg-paste" viewBox="0 0 512 512"><path d="M160 32c11.6 0 21.3 8.2 23.5 19.2C185 58.6 191.6 64 199.2 64H208c8.8 0 16 7.2 16 16V96H96V80c0-8.8 7.2-16 16-16h8.8c7.6 0 14.2-5.4 15.7-12.8C138.7 40.2 148.4 32 160 32zM64 64h2.7C65 69 64 74.4 64 80V96c0 17.7 14.3 32 32 32H224c17.7 0 32-14.3 32-32V80c0-5.6-1-11-2.7-16H256c17.7 0 32 14.3 32 32h32c0-35.3-28.7-64-64-64H210.6c-9-18.9-28.3-32-50.6-32s-41.6 13.1-50.6 32H64C28.7 32 0 60.7 0 96V384c0 35.3 28.7 64 64 64H192V416H64c-17.7 0-32-14.3-32-32V96c0-17.7 14.3-32 32-32zM288 480c-17.7 0-32-14.3-32-32V192c0-17.7 14.3-32 32-32h96v56c0 22.1 17.9 40 40 40h56V448c0 17.7-14.3 32-32 32H288zM416 165.3L474.7 224H424c-4.4 0-8-3.6-8-8V165.3zM448 512c35.3 0 64-28.7 64-64V235.9c0-12.7-5.1-24.9-14.1-33.9l-59.9-59.9c-9-9-21.2-14.1-33.9-14.1H288c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H448z"/></symbol>\n<symbol id="svg-cut" viewBox="0 0 512 512"><path d="M485.6 444.2L333.6 314.9C326.9 309.2 326.1 299.1 331.8 292.4C337.5 285.6 347.6 284.8 354.4 290.5L506.4 419.8C513.1 425.5 513.9 435.6 508.2 442.4C502.5 449.1 492.4 449.9 485.6 444.2zM485.7 67.76C492.5 62.07 502.5 62.94 508.2 69.69C513.9 76.45 513.1 86.55 506.3 92.24L208.5 343.1C218.3 359.7 224 379.2 224 400C224 461.9 173.9 512 112 512C50.14 512 0 461.9 0 400C0 338.1 50.14 288 112 288C141.5 288 168.4 299.4 188.4 318.1L262.2 256L188.4 193.9C168.4 212.6 141.5 224 112 224C50.14 224 0 173.9 0 112C0 50.14 50.14 0 112 0C173.9 0 224 50.14 224 112C224 132.8 218.3 152.3 208.5 168.9L287 235.1L485.7 67.76zM32 112C32 156.2 67.82 192 112 192C156.2 192 192 156.2 192 112C192 67.82 156.2 32 112 32C67.82 32 32 67.82 32 112zM112 480C156.2 480 192 444.2 192 400C192 355.8 156.2 320 112 320C67.82 320 32 355.8 32 400C32 444.2 67.82 480 112 480z"/></symbol>\n<symbol id="svg-copy" viewBox="0 0 512 512"><path d="M272 416C263.2 416 256 423.2 256 432V448c0 17.67-14.33 32-32 32H64c-17.67 0-32-14.33-32-32V192c0-17.67 14.33-32 32-32h112C184.8 160 192 152.8 192 144C192 135.2 184.8 128 176 128H63.99c-35.35 0-64 28.65-64 64l.0098 256C0 483.3 28.65 512 64 512h160c35.35 0 64-28.65 64-64v-16C288 423.2 280.8 416 272 416zM502.6 86.63l-77.25-77.25C419.4 3.371 411.2 0 402.7 0H288C252.7 0 224 28.65 224 64v256c0 35.35 28.65 64 64 64h160c35.35 0 64-28.65 64-64V109.3C512 100.8 508.6 92.63 502.6 86.63zM416 45.25L466.7 96H416V45.25zM480 320c0 17.67-14.33 32-32 32h-160c-17.67 0-32-14.33-32-32V64c0-17.67 14.33-32 32-32h96l.0026 64c0 17.67 14.33 32 32 32H480V320z"/>\n</symbol>\n<symbol id="svg-angle-double-right" viewBox="0 0 512 512"><path d="M470.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256 265.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160zm-352 160l160-160c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L210.7 256 73.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0z"/>\n</symbol>\n<symbol id="svg-angle-double-left" viewBox="0 0 512 512"><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160zm352-160l-160 160c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L301.3 256 438.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0z"/>\n</symbol>\n<symbol id="svg-trash" viewBox="0 0 448 512">\n <path d="M336 64l-33.6-44.8C293.3 7.1 279.1 0 264 0h-80c-15.1 0-29.3 7.1-38.4 19.2L112 64H24C10.7 64 0 74.7 0 88v2c0 3.3 2.7 6 6 6h26v368c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V96h26c3.3 0 6-2.7 6-6v-2c0-13.3-10.7-24-24-24h-88zM184 32h80c5 0 9.8 2.4 12.8 6.4L296 64H152l19.2-25.6c3-4 7.8-6.4 12.8-6.4zm200 432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V96h320v368zm-176-44V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm-80 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12zm160 0V156c0-6.6 5.4-12 12-12h8c6.6 0 12 5.4 12 12v264c0 6.6-5.4 12-12 12h-8c-6.6 0-12-5.4-12-12z"/>\n</symbol>\n<symbol id="svg-keyboard-down" viewBox="0 0 576 512"><path d="M64 48c-8.8 0-16 7.2-16 16V240c0 8.8 7.2 16 16 16H512c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H64zM0 64C0 28.7 28.7 0 64 0H512c35.3 0 64 28.7 64 64V240c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zM159 359c9.4-9.4 24.6-9.4 33.9 0l95 95 95-95c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L305 505c-4.5 4.5-10.6 7-17 7s-12.5-2.5-17-7L159 393c-9.4-9.4-9.4-24.6 0-33.9zm1-167c0-8.8 7.2-16 16-16H400c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V192zM120 88h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H120c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H200c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H280c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16zm64 16c0-8.8 7.2-16 16-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H360c-8.8 0-16-7.2-16-16V104zm96-16h16c8.8 0 16 7.2 16 16v16c0 8.8-7.2 16-16 16H440c-8.8 0-16-7.2-16-16V104c0-8.8 7.2-16 16-16z"/></symbol>\n</svg>'+e.normalizedLayouts.map(((t,n)=>function(e,t,n){const i=[];if(!("layers"in t))return"";for(const r of t.layers)i.push(`<div tabindex="-1" class="MLK__layer" id="${r.id}">`),(e.normalizedLayouts.length>1||t.displayEditToolbar)&&(i.push("<div class='MLK__toolbar' role='toolbar'>"),i.push(jc(e,n)),t.displayEditToolbar&&i.push('<div class="ML__edit-toolbar right"></div>'),i.push("</div>")),i.push(Xc(e,r)),i.push("</div>");return i.join("")}(e,t,n))).join(""));const i=document.createElement("div");i.className="MLK__backdrop",i.appendChild(n),t.appendChild(i),t.addEventListener("pointerdown",nu,{passive:!1});const r=t.querySelectorAll(".ML__edit-toolbar");if(r)for(const t of r)t.addEventListener("click",(t=>{var n,i;let r=t.target,s="";for(;r&&!s;)s=null!=(n=null==r?void 0:r.getAttribute("data-command"))?n:"",r=null!=(i=null==r?void 0:r.parentElement)?i:null;s&&e.executeCommand(JSON.parse(s))}));!function(e){for(const t of e)Zc(t)}(t.querySelectorAll(".MLK__keycap, .action, .fnbutton, .bigfnbutton"));const s=t.querySelectorAll(".MLK__layer");console.assert(s.length>0,"No virtual keyboards available");for(const e of s)e.addEventListener("pointerdown",(e=>e.preventDefault()));return e.currentLayer=e.latentLayer,t}function Xc(e,t){if("string"==typeof t)return t;let n="";if("string"==typeof t.style?n+=`<style>${t.style}</style>`:"object"==typeof t.style&&(n+=`<style>${Vc(t.style)}</style>`),t.backdrop&&(n+=`<div class='${t.backdrop}'>`),t.container&&(n+=`<div class='${t.container}'>`),t.rows){n+="<div class=MLK__rows>";for(const i of t.rows){n+="<div dir='ltr' class=MLK__row>";for(const t of i)if(t){const i=e.registerKeycap(t),[r,s]=Jc(t);/(^|\s)separator/.test(s)?n+=`<div class="${s}"`:n+=`<div tabindex="-1" id="${i}" class="${s}"`,t.tooltip&&(n+=` data-tooltip="${t.tooltip}"`),n+=`>${r}</div>`}n+="</div>"}n+="</div>"}else t.markup&&(n+=t.markup);return t.container&&(n+="</div>"),t.backdrop&&(n+="</div>"),n}function Jc(e,t={shifted:!1}){var n,i,r,s,a,o,l;let c="",u=null!=(n=e.class)?n:"";if(t.shifted&&ou(e)&&(u+=" is-active"),t.shifted&&"shift"in e)"string"==typeof e.shift?c=qc(e.shift):"object"==typeof e.shift&&(c=e.shift.label?e.shift.label:null!=(i=qc(e.shift.latex||e.shift.insert||"")||e.shift.key)?i:""),"object"==typeof e.shift&&(u=null!=(s=null!=(r=e.shift.class)?r:e.class)?s:"");else{if(c=e.label?e.label:null!=(a=qc(e.latex||e.insert||"")||e.key)?a:"",e.shift){let t;t="string"==typeof e.shift?qc(e.shift):e.shift.label?e.shift.label:null!=(o=qc(e.shift.latex||e.shift.insert||"")||e.shift.key)?o:"",c+=`<span class="MLK__shift">${t}</span>`}e.aside&&(c+=`<aside>${e.aside}</aside>`)}return e.layer&&!/layer-switch/.test(u)&&(u+=" layer-switch"),/(^|\s)(separator|action|shift|fnbutton|bigfnbutton)($|\s)/.test(u)||(u+=" MLK__keycap"),!/\bw[0-9]+\b/.test(u)&&e.width&&(u+=null!=(l={0:" w0",.5:" w5",1.5:" w15",2:" w20",5:" w50"}[e.width])?l:""),[c,u||"MLK__keycap"]}var Qc,eu={"[left]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-left /></svg>",command:["performWithFeedback","moveToPreviousChar"],shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-left /></svg>",command:["performWithFeedback","extendSelectionBackward"]}},"[right]":{class:"action hide-shift",label:"<svg class=svg-glyph><use xlink:href=#svg-arrow-right /></svg>",command:["performWithFeedback","moveToNextChar"],shift:{label:"<svg class=svg-glyph><use xlink:href=#svg-angle-double-right /></svg>",command:["performWithFeedback","extendSelectionForward"]}},"[up]":{class:"action hide-shift",label:"↑",command:["performWithFeedback","moveUp"],shift:{label:"↟",command:["performWithFeedback","extendSelectionUpward"]}},"[down]":{class:"action hide-shift",label:"↓",command:["performWithFeedback","moveDown"],shift:{label:"↡",command:["performWithFeedback","extendSelectionDownward"]}},"[return]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{command:["performWithFeedback","addRowAfter"]},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[action]":{class:"action hide-shift",command:["performWithFeedback","commit"],shift:{label:"<svg class=svg-glyph><use xlink:href=#circle-plus /></svg>",command:["performWithFeedback","addRowAfter"]},width:1.5,label:"<svg class=svg-glyph><use xlink:href=#svg-commit /></svg>"},"[hr]":{class:"separator horizontal-rule"},"[hide-keyboard]":{class:"action",command:["hideVirtualKeyboard"],width:1.5,label:"<svg class=svg-glyph-lg><use xlink:href=#svg-keyboard-down /></svg>"},"[.]":{variants:".",command:["performWithFeedback","insertDecimalSeparator"],shift:",",class:"big-op hide-shift",label:"."},"[,]":{variants:",",command:["performWithFeedback","insertDecimalSeparator"],shift:".",class:"big-op hide-shift",label:","},"[+]":{variants:[{latex:"\\sum_{#0}^{#0}",class:"small"},"\\oplus"],latex:"+",label:"+",class:"big-op hide-shift",shift:{latex:"\\sum",insert:"\\sum",class:"small"}},"[-]":{variants:["\\pm","\\ominus"],latex:"-",label:"−",shift:"\\pm",class:"big-op hide-shift"},"[/]":{class:"big-op hide-shift",shift:{class:"",latex:"\\frac{1}{#@}"},variants:["/","\\div","\\%","\\oslash"],latex:"\\frac{#@}{#?}",label:"÷"},"[*]":{variants:[{latex:"\\prod_{#0}^{#0}",class:"small"},"\\otimes","\\cdot"],latex:"\\cdot",label:"×",shift:{latex:"\\times"},class:"big-op hide-shift"},"[=]":{variants:["\\neq","\\equiv","\\varpropto","\\thickapprox","\\lt","\\gt","\\le","\\ge"],latex:"=",label:"=",shift:{label:"≠",latex:"\\ne"},class:"big-op hide-shift"},"[backspace]":{class:"action bottom right hide-shift",width:1.5,command:["performWithFeedback","deleteBackward"],label:"<svg class=svg-glyph><use xlink:href=#svg-delete-backward /></svg>",shift:{class:"action warning",label:"<svg class=svg-glyph><use xlink:href=#svg-trash /></svg>",command:"deleteAll"}},"[undo]":{class:"ghost if-can-undo",command:"undo",label:"<svg class=svg-glyph><use xlink:href=#svg-undo /></svg>",tooltip:"tooltip.undo"},"[redo]":{class:"ghost if-can-redo",command:"redo",label:"<svg class=svg-glyph><use xlink:href=#svg-redo /></svg>",tooltip:"tooltip.redo"},"[(]":{variants:[{latex:"\\lbrack",key:"["},"\\langle","\\lfloor","\\lceil",{latex:"\\lbrace",key:"{"}],key:"(",label:"(",shift:{label:"[",key:"["},class:"hide-shift"},"[)]":{variants:[{latex:"\\rbrack",key:"]"},"\\rangle","\\rfloor","\\rceil",{latex:"\\rbrace",key:"]"}],key:")",label:")",shift:{label:"]",latex:"\\rbrack"},class:"hide-shift"},"[0]":{variants:"0",latex:"0",label:"0",shift:"\\infty",class:"hide-shift"},"[1]":{variants:"1",latex:"1",label:"1",shift:"#@^{-1}",class:"hide-shift"},"[2]":{variants:"2",latex:"2",label:"2",shift:"#@^2",class:"hide-shift"},"[3]":{variants:"3",latex:"3",label:"3",shift:"#@^3",class:"hide-shift"},"[4]":{variants:"4",latex:"4",label:"4",shift:"#@^4",class:"hide-shift"},"[5]":{variants:"5",latex:"5",label:"5",shift:"#@^5",class:"hide-shift"},"[6]":{variants:"6",latex:"6",label:"6",shift:"#@^6",class:"hide-shift"},"[7]":{variants:"7",latex:"7",label:"7",shift:"#@^7",class:"hide-shift"},"[8]":{variants:"8",latex:"8",label:"8",shift:"#@^8",class:"hide-shift"},"[9]":{variants:"9",latex:"9",label:"9",shift:"#@^9",class:"hide-shift"},"[separator-5]":{class:"separator",width:.5},"[separator]":{class:"separator"},"[separator-10]":{class:"separator"},"[separator-15]":{class:"separator",width:1.5},"[separator-20]":{class:"separator",width:2},"[separator-50]":{class:"separator",width:5},"[shift]":{class:"shift bottom left",width:1.5,label:"<span class=caps-lock-indicator></span><svg class=svg-glyph><use xlink:href=#svg-shift /></svg>"},"[foreground-color]":{variants:"foreground-color",command:["applyStyle",{color:"red"}],label:"<span style='border-radius: 50%;width:22px;height:22px; border: 3px solid #cc2428; box-sizing: border-box'>"},"[background-color]":{variants:"background-color",command:["applyStyle",{backgroundColor:"yellow"}],label:"<span style='border-radius: 50%;width:22px;height:22px; background:#fff590; box-sizing: border-box'></span>"}};function tu(e){var t;if("string"==typeof e){if("[.]"===e&&","===window.MathfieldElement.decimalSeparator&&(e="[,]"),!eu[e])return{latex:e};e={label:e}}let n;return"label"in e&&e.label&&eu[e.label]&&(n=h(u(u({},eu[e.label]),e),{label:eu[e.label].label})),"key"in e&&e.key&&eu[e.key]&&(n=h(u(u({},eu[e.key]),e),{key:eu[e.key].key})),n?("insertDecimalSeparator"===n.command&&(n.label=null!=(t=window.MathfieldElement.decimalSeparator)?t:"."),"[action]"===e.label&&(n=u(u({},n),window.mathVirtualKeyboard.actionKeycap)),"[shift]"===e.label&&(n=u(u({},n),window.mathVirtualKeyboard.shiftKeycap)),"[backspace]"===e.label&&(n=u(u({},n),window.mathVirtualKeyboard.backspaceKeycap)),"[tab]"===e.label&&(n=u(u({},n),window.mathVirtualKeyboard.tabKeycap)),n):e}function nu(e){var t;if(0!==e.button)return;const n=lu.singleton;if(!n)return;let i=e.target;for(;i&&!i.getAttribute("data-layer");)i=i.parentElement;if(i)return n.currentLayer=null!=(t=i.getAttribute("data-layer"))?t:"",void e.preventDefault();const r=au(e.target);if(!(null==r?void 0:r.id))return;const s=n.getKeycap(r.id);if(!s)return;console.assert("pointerdown"===e.type);const a=new AbortController,o=a.signal;r.classList.add("is-pressed"),r.addEventListener("pointerenter",iu(a),{capture:!0,signal:o}),r.addEventListener("pointerleave",iu(a),{capture:!0,signal:o}),r.addEventListener("pointercancel",iu(a),{signal:o}),r.addEventListener("pointerup",iu(a),{signal:o}),ou(s)&&(r.classList.add("is-active"),n.shiftPressCount++),s.variants&&(Qc&&clearTimeout(Qc),Qc=setTimeout((()=>{r.classList.contains("is-pressed")&&(r.classList.remove("is-pressed"),r.classList.add("is-active"),e.target&&"releasePointerCapture"in e.target&&e.target.releasePointerCapture(e.pointerId),Kc(r,(()=>{a.abort(),null==r||r.classList.remove("is-active")})))}),300)),e.preventDefault()}function iu(e){return t=>{const n=au(t.target);if(!(null==n?void 0:n.id))return;const i=lu.singleton;if(!i)return;const r=i.getKeycap(n.id);if(r){if("pointerenter"===t.type&&t.target===n){t.isPrimary&&n.classList.add("is-pressed")}return"pointercancel"===t.type?(n.classList.remove("is-pressed"),ou(r)&&(i.shiftPressCount--,n.classList.toggle("is-active",i.isShifted)),void e.abort()):"pointerleave"===t.type&&t.target===n?(n.classList.remove("is-pressed"),void(ou(r)&&(i.shiftPressCount--,n.classList.toggle("is-active",i.isShifted)))):"pointerup"===t.type?(Qc&&clearTimeout(Qc),ou(r)?n.classList.toggle("is-active",i.isShifted):n.classList.contains("is-pressed")&&(n.classList.remove("is-pressed"),i.isShifted&&r.shift?"string"==typeof r.shift?i.executeCommand(["insert",r.shift,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]):ru(r.shift):ru(r),1!==i.shiftPressCount||t.shiftKey||(i.shiftPressCount=0)),e.abort(),void t.preventDefault()):void 0}}}function ru(e){var t;let n=e.command;!n&&e.insert&&(n=["insert",e.insert,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),!n&&e.key&&(n=["typedText",e.key,{focus:!0,feedback:!0,simulateKeystroke:!0}]),!n&&e.latex&&(n=["insert",e.latex,{focus:!0,feedback:!0,scrollIntoView:!0,mode:"math",format:"latex"}]),n||(n=["typedText",e.label,{focus:!0,feedback:!0,simulateKeystroke:!0}]),null==(t=lu.singleton)||t.executeCommand(n)}function su(e){if(1!==e.nodeType)return!1;const t=e.classList;return t.contains("MLK__keycap")||t.contains("shift")||t.contains("action")||t.contains("fnbutton")||t.contains("bigfnbutton")}function au(e){if(!e)return;let t=e;for(;t&&!su(t);)t=t.parentElement;return null!=t?t:void 0}function ou(e){return!!e.class&&/(^|\s)shift($|\s)/.test(e.class)}var lu=class e{constructor(){var e,t,n;this.originalContainerBottomPadding=null,this.keycapRegistry={},this._shiftPressCount=0,this.targetOrigin=window.origin,this.originValidator="none",this._alphabeticLayout="auto",this._layouts=Object.freeze(["default"]),this._editToolbar="default",this._container=null!=(t=null==(e=window.document)?void 0:e.body)?t:null,this._visible=!1,this._rebuilding=!1,this.observer=new ResizeObserver((e=>{this.adjustBoundingRect(),this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect})})),this.listeners={};try{null==(n=window.top)||n.addEventListener("message",this)}catch(e){window.addEventListener("message",this)}document.body.addEventListener("focusin",(e=>{const t=e.target;(null==t?void 0:t.isConnected)&&setTimeout((()=>{const e=cu();e&&!e.readOnly&&"auto"===e.mathVirtualKeyboardPolicy&&("matchMedia"in window?window.matchMedia("(pointer: coarse)").matches:"ontouchstart"in window||navigator.maxTouchPoints>0)&&this.show({animate:!0})}),300)})),document.addEventListener("focusout",(e=>{"manual"!==e.target.mathVirtualKeyboardPolicy&&setTimeout((()=>{cu()||this.hide()}),300)}))}get currentLayer(){var e,t,n;return null!=(n=null==(t=null==(e=this._element)?void 0:e.querySelector(".MLK__layer.is-visible"))?void 0:t.id)?n:""}set currentLayer(e){var t;if(!this._element)return void(this.latentLayer=e);let n=e?this._element.querySelector(`#${e}.MLK__layer`):null;n||(n=this._element.querySelector(".MLK__layer")),n&&(null==(t=this._element.querySelector(".MLK__layer.is-visible"))||t.classList.remove("is-visible"),n.classList.add("is-visible")),this.render()}get shiftPressCount(){return this._shiftPressCount}set shiftPressCount(e){var t;this._shiftPressCount=e>2||e<0?0:e,null==(t=this._element)||t.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.render()}get isShifted(){return this._shiftPressCount>0}resetKeycapRegistry(){this.keycapRegistry={}}registerKeycap(e){const t="ML__k"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36);return this.keycapRegistry[t]=e,t}getKeycap(e){return e?this.keycapRegistry[e]:void 0}getLayer(e){const t=this.normalizedLayouts;for(const n of t)for(const t of n.layers)if(t.id===e)return t}get alphabeticLayout(){return this._alphabeticLayout}set alphabeticLayout(e){this._alphabeticLayout=e,this.rebuild()}get actionKeycap(){return this._actionKeycap}set actionKeycap(e){this._actionKeycap="string"==typeof e?{label:e}:e}get shiftKeycap(){return this._shiftKeycap}set shiftKeycap(e){this._shiftKeycap="string"==typeof e?{label:e}:e}get backspaceKeycap(){return this._backspaceKeycap}set backspaceKeycap(e){this._backspaceKeycap="string"==typeof e?{label:e}:e}get tabKeycap(){return this._tabKeycap}set tabKeycap(e){this._tabKeycap="string"==typeof e?{label:e}:e}get layouts(){return this._layouts}set layouts(e){this.updateNormalizedLayouts(e),this.rebuild()}updateNormalizedLayouts(e){const t=Array.isArray(e)?[...e]:[e],n=t.findIndex((e=>"default"===e));n>=0&&t.splice(n,1,"numeric","symbols","alphabetic","greek"),this._layouts=Object.freeze(t),this._normalizedLayouts=t.map((e=>Hc(e)))}get normalizedLayouts(){return this._normalizedLayouts||this.updateNormalizedLayouts(this._layouts),this._normalizedLayouts}get editToolbar(){return this._editToolbar}set editToolbar(e){this._editToolbar=e,this.rebuild()}get container(){return this._container}set container(e){this._container=e,this.rebuild()}static get singleton(){if(void 0===this._singleton)try{this._singleton=new e}catch(e){this._singleton=null}return this._singleton}get style(){return this._style}addEventListener(e,t,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].has(t)||this.listeners[e].add(t)}dispatchEvent(e){return!this.listeners[e.type]||0===this.listeners[e.type].size||(this.listeners[e.type].forEach((t=>{"function"==typeof t?t(e):null==t||t.handleEvent(e)})),!e.defaultPrevented)}removeEventListener(e,t,n){this.listeners[e]&&this.listeners[e].delete(t)}get element(){return this._element}set element(e){var t;this._element!==e&&(null==(t=this._element)||t.remove(),this._element=e)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}get boundingRect(){var e;if(!this._visible)return new DOMRect;const t=null==(e=this._element)?void 0:e.getElementsByClassName("MLK__plate")[0];return t?t.getBoundingClientRect():new DOMRect}adjustBoundingRect(){var e,t;const n=this.boundingRect.height;if(this.container===document.body){null==(e=this._element)||e.style.setProperty("--_keyboard-height",`calc(${n}px + var(--_padding-top) + var(--_padding-bottom) + env(safe-area-inset-bottom, 0))`);const t=n-1;this.container.style.paddingBottom=this.originalContainerBottomPadding?`calc(${this.originalContainerBottomPadding} + ${t}px)`:`${t}px`}else null==(t=this._element)||t.style.setProperty("--_keyboard-height",`${n}px`)}rebuild(){if(this._rebuilding||!this._element)return;this._rebuilding=!0;const e=this.currentLayer;requestAnimationFrame((()=>{this._rebuilding=!1,this._element&&(this._element.remove(),this._element=void 0),this.visible&&(this.buildAndAttachElement(),this.currentLayer=e,this.render(),this.adjustBoundingRect(),this._element.classList.add("is-visible"))}))}render(){if(!this._element)return;const e=this.getLayer(this.currentLayer);this._element.classList.toggle("backdrop-is-transparent",Boolean(e&&(e.backdrop||e.container)));const t=this._element.querySelectorAll(".MLK__layer.is-visible .MLK__keycap, .MLK__layer.is-visible .action, .fnbutton, .MLK__layer.is-visible .bigfnbutton, .MLK__layer.is-visible .shift");if(t)for(const e of t){const t=this.getKeycap(e.id);if(t){const[n,i]=Jc(t,{shifted:this.isShifted});e.innerHTML=window.MathfieldElement.createHTML(n),e.className=i}}}show(e){var t;if(this._visible)return;const n=this.container;if(n&&window.mathVirtualKeyboard&&this.stateWillChange(!0)){if(this._element||(this.buildAndAttachElement(),this.adjustBoundingRect()),!this._visible){const e=this._element.getElementsByClassName("MLK__plate")[0];if(e&&this.observer.observe(e),n===window.document.body){const t=n.style.paddingBottom;this.originalContainerBottomPadding=t;const i=e.offsetHeight-1;n.style.paddingBottom=t?`calc(${t} + ${i}px)`:`${i}px`}window.addEventListener("mouseup",this),window.addEventListener("blur",this),window.addEventListener("keydown",this,{capture:!0}),window.addEventListener("keyup",this,{capture:!0}),null==(t=this._element)||t.classList.toggle("is-caps-lock",2===this.shiftPressCount),this.currentLayer=this.latentLayer}this._visible=!0,(null==e?void 0:e.animate)?requestAnimationFrame((()=>{this._element&&(this._element.classList.add("animate"),this._element.addEventListener("transitionend",(()=>{var e;return null==(e=this._element)?void 0:e.classList.remove("animate")}),{once:!0}),this._element.classList.add("is-visible"),this.stateChanged())})):(this._element.classList.add("is-visible"),this.stateChanged())}}hide(e){var t;const n=this.container;if(n&&this._visible&&this.stateWillChange(!1)){if(this._visible=!1,this._element){this.latentLayer=this.currentLayer;const e=this._element.getElementsByClassName("MLK__plate")[0];e&&this.observer.unobserve(e),window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("keydown",this,{capture:!0}),window.removeEventListener("keyup",this,{capture:!0}),window.removeEventListener("contextmenu",this,{capture:!0}),Uc(),fo("core"),fo("virtual-keyboard"),null==(t=this._element)||t.remove(),this._element=void 0,null!==this.originalContainerBottomPadding&&(n.style.paddingBottom=this.originalContainerBottomPadding)}this.stateChanged()}}get height(){var e,t;return null!=(t=null==(e=this.element)?void 0:e.offsetHeight)?t:0}buildAndAttachElement(){var e;console.assert(!this.element),this.element=Yc(this),window.addEventListener("contextmenu",this,{capture:!0}),this.element.addEventListener("contextmenu",(e=>{e.shiftKey||((e.ctrlKey||2===e.button)&&Kc(e.target),e.preventDefault(),e.stopPropagation())}),{capture:!0}),null==(e=this.container)||e.appendChild(this.element)}handleEvent(e){if(Oc(e)){if(!ao(e.origin,this.originValidator))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");"disconnect"===e.data.action?this.connectedMathfieldWindow=void 0:"update-setting"!==e.data.action&&"proxy-created"!==e.data.action&&"execute-command"!==e.data.action&&(console.assert(void 0!==e.source),this.connectedMathfieldWindow=e.source),this.handleMessage(e.data,e.source)}if(this._element)switch(e.type){case"mouseup":case"blur":document.body.style.userSelect="",this.shiftPressCount=0;break;case"contextmenu":2!==e.button&&e.preventDefault();break;case"keydown":"Shift"!==e.key||e.repeat||(this.shiftPressCount=1);break;case"keyup":("Shift"===e.key||!e.getModifierState("Shift")&&2!==this.shiftPressCount)&&(this.shiftPressCount=0)}}handleMessage(e,t){const{action:n}=e;if("execute-command"!==n){if("connect"!==n&&"show"!==n||this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},t),"disconnect"!==n&&window===window.top)if("show"!==n){if("hide"!==n)return"update-setting"===n?(e.alphabeticLayout&&(this.alphabeticLayout=e.alphabeticLayout),e.layouts&&(this.layouts=e.layouts),void(e.editToolbar&&(this.editToolbar=e.editToolbar))):void("proxy-created"!==n||this.sendMessage("synchronize-proxy",{boundingRect:this.boundingRect,alphabeticLayout:this._alphabeticLayout,layouts:this._layouts,editToolbar:this._editToolbar},t));void 0!==e.animate?this.hide({animate:e.animate}):this.hide()}else void 0!==e.animate?this.show({animate:e.animate}):this.show()}else{const{command:t}=e,n=Ic(t);if(void 0!==window.top&&"virtual-keyboard"!==n)return;this.executeCommand(t)}}sendMessage(e,t,n){if(n||(n=this.connectedMathfieldWindow),null!==this.targetOrigin&&"null"!==this.targetOrigin&&n!==window){if(n)n.postMessage(u({type:Pc,action:e},t),{targetOrigin:this.targetOrigin});else if(t.command&&this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command",{detail:t.command})),"execute-command"===e&&Array.isArray(t.command)&&"insert"===t.command[0]){const e=t.command[1].split("");for(const t of e)this.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0})),this.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0}))}}else window.dispatchEvent(new MessageEvent("message",{source:window,data:u({type:Pc,action:e},t)}))}stateWillChange(e){return this.dispatchEvent(new CustomEvent("before-virtual-keyboard-toggle",{detail:{visible:e},bubbles:!0,cancelable:!0,composed:!0}))}stateChanged(){this.dispatchEvent(new Event("virtual-keyboard-toggle")),this._visible||(this.dispatchEvent(new Event("geometrychange")),this.sendMessage("geometry-changed",{boundingRect:this.boundingRect}))}focus(){this.sendMessage("focus",{})}blur(){this.sendMessage("blur",{})}updateToolbar(e){const t=this._element;if(!t)return;t.classList.toggle("is-math-mode","math"===e.mode),t.classList.toggle("is-text-mode","text"===e.mode),t.classList.toggle("can-undo",e.canUndo),t.classList.toggle("can-redo",e.canRedo),t.classList.toggle("can-copy",!e.selectionIsCollapsed),t.classList.toggle("can-copy",!e.selectionIsCollapsed),t.classList.toggle("can-paste",!0);const n=t.querySelectorAll(".ML__edit-toolbar");if(n)for(const t of n)t.innerHTML=Wc(this,e)}update(e){this._style=e.style,this.updateToolbar(e)}connect(){this.connectedMathfieldWindow=window}disconnect(){this.connectedMathfieldWindow=void 0}executeCommand(e){let t,n=[],i=Ic(e);return f(e)?(t=e[0],"performWithFeedback"===t&&(i=Ic(e=e.slice(1))),n=e.slice(1)):t=e,t=t.replace(/-\w/g,(e=>e[1].toUpperCase())),"virtual-keyboard"===i?Dc[t].fn(void 0,...n):(this.sendMessage("execute-command",{command:e}),!1)}dispose(){window.removeEventListener("mouseup",this),window.removeEventListener("blur",this),window.removeEventListener("message",this)}};function cu(){var e,t;let n=Jl(),i=null;for(;n;){if("host"in n&&"math-field"===(null==(t=null==(e=n.host)?void 0:e.tagName)?void 0:t.toLowerCase())){i=n.host;break}n=n.parentNode}return i}if(m()&&!("mathVirtualKeyboard"in window))if(window===window.top){const e=lu.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e})}else Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>Nc.singleton,configurable:!0});function uu(e){const t={};for(const n of Object.keys(e))switch(n){case"scriptDepth":const i=e.scriptDepth;if(f(i))t.scriptDepth=[i[0],i[1]];else if("number"==typeof i)t.scriptDepth=[i,i];else{if("string"!=typeof i)throw new TypeError("Unexpected value for scriptDepth");{const[e,n]=i.split(",").map((e=>parseInt(e.trim())));t.scriptDepth=[e,n]}}break;case"mathVirtualKeyboardPolicy":let r=e.mathVirtualKeyboardPolicy.toLowerCase();if("sandboxed"===r){if(window!==window.top){const e=lu.singleton;Object.defineProperty(window,"mathVirtualKeyboard",{get:()=>e})}r="manual"}t.mathVirtualKeyboardPolicy=r;break;case"letterShapeStyle":"auto"===e.letterShapeStyle?v.locale.startsWith("fr")?t.letterShapeStyle="french":t.letterShapeStyle="tex":t.letterShapeStyle=e.letterShapeStyle;break;case"defaultMode":["text","math","inline-math"].includes(e.defaultMode)?t.defaultMode=e.defaultMode:(console.error('MathLive 0.98.5: valid values for defaultMode are "text", "math" or "inline-math"'),t.defaultMode="math");break;case"macros":t.macros=se(e.macros);break;default:f(e[n])?t[n]=[...e[n]]:"object"!=typeof e[n]||e[n]instanceof Element||"computeEngine"===n?t[n]=e[n]:t[n]=u({},e[n])}return t}function hu(e,t){let n;n="string"==typeof t?[t]:void 0===t?Object.keys(e):t;const i={};for(const t of n)null===e[t]?i[t]=null:f(e[t])?i[t]=[...e[t]]:"object"!=typeof e[t]||e[t]instanceof Element||"computeEngine"===t?i[t]=e[t]:i[t]=u({},e[t]);return"string"==typeof t?i[t]:i}function du(){return{readOnly:!1,defaultMode:"math",macros:{},registers:{},colorMap:C,backgroundColorMap:L,letterShapeStyle:v.locale.startsWith("fr")?"french":"tex",minFontScale:0,smartMode:!1,smartFence:!0,smartSuperscript:!0,scriptDepth:[1/0,1/0],removeExtraneousParentheses:!0,isImplicitFunction:e=>["\\sin","\\cos","\\tan","\\arcsin","\\arccos","\\arctan","\\arcsec","\\arccsc","\\arsinh","\\arcosh","\\artanh","\\arcsech","\\arccsch","\\arg","\\ch","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\sec","\\sinh","\\sh","\\tanh","\\tg","\\th","\\lg","\\lb","\\log","\\ln"].includes(e),mathModeSpace:"",placeholderSymbol:"▢",contentPlaceholder:"",popoverPolicy:"auto",environmentPopoverPolicy:"off",keybindings:Xa,inlineShortcuts:Ua,inlineShortcutTimeout:0,mathVirtualKeyboardPolicy:"auto",virtualKeyboardTargetOrigin:null==window?void 0:window.origin,originValidator:"none",onInlineShortcut:()=>"",onScrollIntoView:null,onExport:Wa,value:""}}function pu(e){return"inline-math"===e.defaultMode?"math":e.defaultMode}function fu(e,t){e&&t&&(f(e)?e.forEach((e=>fu(e,t))):"object"==typeof e&&(e.style.color||e.style.backgroundColor||e.style.fontFamily||e.style.fontShape||e.style.fontSeries||e.style.fontSize||e.style.variant||e.style.variantStyle||(e.applyStyle(t),fu(e.body,t),fu(e.above,t),fu(e.below,t),fu(e.subscript,t),fu(e.superscript,t))))}function mu(e,t,n,i){function r(e,t){for(const n of s)if(n.style[e]!==t)return!1;return!0}if((t=e.normalizeRange(t))[0]===t[1])return!1;const s=e.getAtoms(t,{includeChildren:!0});"toggle"===i.operation&&(n.color&&r("color",n.color)&&(n.color="none",delete n.verbatimColor),n.backgroundColor&&r("backgroundColor",n.backgroundColor)&&(n.backgroundColor="none",delete n.verbatimBackgroundColor),n.fontFamily&&r("fontFamily",n.fontFamily)&&(n.fontFamily="none"),n.fontSeries&&r("fontSeries",n.fontSeries)&&(n.fontSeries="auto"),n.fontShape&&r("fontShape",n.fontShape)&&(n.fontShape="auto"),n.fontSize&&r("fontSize",n.fontSize)&&(n.fontSize=5),n.variant&&r("variant",n.variant)&&(n.variant="normal"),n.variantStyle&&r("variantStyle",n.variantStyle)&&(n.variantStyle=""));for(const e of s)e.applyStyle(n);return!0}function gu(e,t=1){return function(e){for(const t of e)for(const e of t)if(e.length>0)return!1;return!0}(e)?Array(t).fill([[new Ma({type:"first"}),new Mo]]):e.map((e=>0===e.length?[[new Ma({type:"first"})]]:e.map((e=>0===e.length?[new Ma({type:"first"})]:("first"!==e[0].type&&e.unshift(new Ma({type:"first"})),e)))))}function _u(e,t=[[[]]],n=[],i=[]){switch(t=gu(t,["split","align","align*","aligned","eqnarray"].includes(e)?2:1),e){case"math":case"displaymath":return new No(e,t,n,{mathstyleName:"textstyle"});case"center":return new No(e,t,n,{columns:[{align:"c"}]});case"multline":case"multline*":return new No(e,t,n,{columns:[{align:"m"}],leftDelim:".",rightDelim:"."});case"split":return new No(e,t,n,{columns:[{align:"r"},{align:"l"}],minColumns:2});case"gather":case"gathered":return new No(e,t,n,{columns:[{gap:.25},{align:"c"},{gap:0}]});case"pmatrix":case"pmatrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:"(",rightDelim:")",columns:yu(i[0])});case"bmatrix":case"bmatrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:"[",rightDelim:"]",columns:yu(i[0])});case"Bmatrix":case"Bmatrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:"\\lbrace",rightDelim:"\\rbrace",columns:yu(i[0])});case"vmatrix":case"vmatrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:"\\vert",rightDelim:"\\vert",columns:yu(i[0])});case"Vmatrix":case"Vmatrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:"\\Vert",rightDelim:"\\Vert",columns:yu(i[0])});case"matrix":case"matrix*":return new No(e,t,n,{mathstyleName:"textstyle",leftDelim:".",rightDelim:".",columns:yu(null==i?void 0:i[0])});case"smallmatrix":case"smallmatrix*":return new No(e,t,n,{mathstyleName:"scriptstyle",columns:yu(null==i?void 0:i[0]),colSeparationType:"small",arraystretch:.5});case"cases":case"dcases":return new No(e,t,n,{mathstyleName:"dcases"===e?"displaystyle":"textstyle",arraystretch:1.2,leftDelim:"\\lbrace",rightDelim:".",columns:[{align:"l"},{gap:1},{align:"l"}]});case"rcases":return new No(e,t,n,{arraystretch:1.2,leftDelim:".",rightDelim:"\\rbrace",columns:[{align:"l"},{gap:1},{align:"l"}]});case"lines":return new No(e,t,n,{leftDelim:".",rightDelim:".",columns:[{align:"l"}]});case"align":case"align*":case"aligned":case"eqnarray":{let i=0;for(const e of t)i=Math.max(i,e.length);const r=[{gap:0},{align:"r"},{gap:.25},{align:"l"}];let s=2;for(;s<i;)r.push({gap:1},{align:"r"},{gap:.25},{align:"l"}),s+=2;return r.push({gap:0}),new No(e,t,n,{arraycolsep:0,columns:r,minColumns:2})}}return new No(e,t,n,{mathstyleName:"textstyle"})}function yu(e){return null!=e?e:[{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"},{align:"c"}]}function vu(e,t,n){const i=e.getCell(t,n);return!(!i||2!==i.length)&&"placeholder"===i[1].type}function bu(e,t,n,i){const r=function(e,t,n,i){const r=t.getCell(n,i);return r?[e.offsetOf(r[0]),e.offsetOf(r[r.length-1])]:-1}(e,t,n,i);"number"!=typeof r&&e.setSelection(r)}function wu(e,t,n,i,r){const s=t.getCell(n,i);s&&e.setPositionHandlingPlaceholder(e.offsetOf(s["start"===r?0:s.length-1]))}function xu(e,t){const[n,[i,r]]=function(e,t){let n=e.at(e.position);for(;n&&!(n.parent instanceof No);)n=n.parent;n&&"array"===n.type&&n.environmentName;if(!(n&&n.parent instanceof No)){const i=e.at(e.position);if(n=i,!n.parent.parent){let n,r=e.extractAtoms([e.position,e.lastOffset]),s=e.extractAtoms([0,e.position]);return 0===s.length&&(s=Cu()),0===r.length&&(r=Cu()),t.endsWith("column")?(n=_u("split",[[s,r]]),e.root=n,vu(n,0,0)?bu(e,n,0,0):vu(n,0,1)?bu(e,n,0,1):e.position=e.offsetOf(i)):(n=_u("lines",[[s],[r]]),e.root=n,vu(n,0,0)?bu(e,n,0,0):vu(n,1,0)?bu(e,n,1,0):e.position=e.offsetOf(i)),[void 0,[0,0]]}if(n.parent instanceof Go){const i=n.parent;let r=e.extractAtoms([e.position,e.offsetOf(i.lastChild)]),s=e.extractAtoms([e.offsetOf(i.firstChild),e.position]);0===s.length&&(s=Cu()),0===r.length&&(r=Cu());let a="pmatrix";const o=i.leftDelim,l=i.rightDelim;"("!==o||")"!==l&&"?"!==l?"["!==o&&"\\lbrack"!==o||"]"!==l&&"\\rbrack"!==l&&"?"!==l?"\\vert"===o&&"\\vert"===l?a="vmatrix":"\\Vert"===o&&"\\Vert"===l?a="Vmatrix":"{"!==o&&"\\lbrace"!==o||"."!==l&&"?"!==l||(a="cases"):a="bmatrix":a="pmatrix";const c=_u(a,t.endsWith("column")?[[s,r]]:[[s],[r]]);return i.parent.addChildBefore(c,i),i.parent.removeChild(i),vu(c,0,0)?bu(e,c,0,0):t.endsWith("column")?vu(c,0,1)?bu(e,c,0,1):e.position=e.offsetOf(n):vu(c,1,0)?bu(e,c,1,0):e.position=e.offsetOf(n),[void 0,[0,0]]}}return n&&n.parent instanceof No?[n.parent,n.parentBranch]:[void 0,[0,0]]}(e,t);if(n)switch(t){case"after row":n.addRowAfter(i),wu(e,n,i+1,0,"end");break;case"after column":if(n.maxColumns<=n.colCount)return void e.announce("plonk");n.addColumnAfter(r),wu(e,n,i,r+1,"end");break;case"before row":n.addRowBefore(i),wu(e,n,i,0,"start");break;case"before column":if(n.maxColumns<=n.colCount)return void e.announce("plonk");n.addColumnBefore(r),wu(e,n,i,r,"start")}}function ku(e){return!!e.contentWillChange({inputType:"insertText"})&&(xu(e,"after row"),e.contentDidChange({inputType:"insertText"}),!0)}function Su(e){return!!e.contentWillChange({inputType:"insertText"})&&(xu(e,"after column"),e.contentDidChange({inputType:"insertText"}),!0)}function Eu(e,t){if(!e.contentWillChange({}))return!1;e.mathfield.snapshot();let n=".",i=".";switch(t){case"pmatrix":case"pmatrix*":n="(",i=")";break;case"bmatrix":case"bmatrix*":n="[",i="]";break;case"Bmatrix":case"Bmatrix*":n="\\lbrace",i="\\rbrace";break;case"vmatrix":case"vmatrix*":n="\\vert",i="\\vert";break;case"Vmatrix":case"Vmatrix*":n="\\Vert",i="\\Vert";break;case"matrix":case"matrix*":n=".",i=".";break;case"cases":case"dcases":n="\\lbrace";break;case"rcases":i="\\rbrace"}const r=e.at(e.position),s="array"===r.type?r:e.parentEnvironment;return s.environmentName=t,s.leftDelim=n,s.rightDelim=i,e.contentDidChange({}),!0}function Tu(e,t){let n=e.at(e.position);for(;n&&!(Array.isArray(n.parentBranch)&&n.parent instanceof No);)n=n.parent;if(Array.isArray(null==n?void 0:n.parentBranch)&&(null==n?void 0:n.parent)instanceof No){const i=n.parent,r=n.parentBranch;let s;switch(t){case"row":if(i.rowCount>1){i.removeRow(r[0]);const t=i.getCell(Math.max(0,r[0]-1),r[1]);s=e.offsetOf(t[t.length-1])}break;case"column":if(i.colCount>i.minColumns){i.removeColumn(r[1]);const t=i.getCell(r[0],Math.max(0,r[1]-1));s=e.offsetOf(t[t.length-1])}}s&&e.setPositionHandlingPlaceholder(s)}}function Cu(){return[new Mo]}ee(["math","displaymath"],_u),ee("center",_u),ne("displaylines","",{parse:e=>{const t=[];let n=[];for(e.beginContext({tabular:!0});;){if(e.end())break;if(e.match("<}>"))break;e.matchColumnSeparator()||e.matchRowSeparator()?(t.push([n]),n=[]):n.push(...e.scan((e=>["<}>","&","\\cr","\\\\","\\tabularnewline"].includes(e))))}return e.endContext(),t.push([n]),t},createAtom:e=>new No("lines",e.args,[],{leftDelim:".",rightDelim:".",columns:[{align:"l"}]})}),te("array","{columns:colspec}",((e,t,n,i)=>new No(e,gu(t),n,{columns:i[0],mathstyleName:"textstyle"}))),te(["equation","equation*","subequations"],"",((e,t,n)=>new No(e,gu(t),n,{columns:[{align:"c"}]}))),te(["multline","multline*"],"",_u),te(["align","align*","aligned","eqnarray"],"",_u),te("split","",_u),te(["gather","gathered"],"",_u),te(["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],"[columns:colspec]",_u),te(["smallmatrix","smallmatrix*"],"[columns:colspec]",_u),te(["cases","dcases","rcases"],"",_u),Mc({addRowAfter:ku,addColumnAfter:Su,addRowBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(xu(e,"before row"),e.contentDidChange({inputType:"insertText"}),!0)},addColumnBefore:function(e){return!!e.contentWillChange({inputType:"insertText"})&&(xu(e,"before column"),e.contentDidChange({inputType:"insertText"}),!0)},removeRow:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(Tu(e,"row"),e.contentDidChange({inputType:"deleteContent"}),!0)},removeColumn:function(e){return!!e.contentWillChange({inputType:"deleteContent"})&&(Tu(e,"column"),e.contentDidChange({inputType:"deleteContent"}),!0)},setEnvironment:Eu},{target:"model",canUndo:!0,changeContent:!0,changeSelection:!0});var Lu=class e{constructor(e){this.recording=!1,this.model=e,this.reset()}reset(){this.stack=[],this.index=-1,this.lastOp=""}startRecording(){this.recording=!0}stopRecording(){this.recording=!1}canUndo(){return this.index-1>=0}canRedo(){return this.stack.length-1>this.index}stopCoalescing(e){e&&this.index>=0&&(this.stack[this.index].selection=e),this.lastOp=""}undo(){return!!this.canUndo()&&(this.model.setState(this.stack[this.index-1],{silenceNotifications:!1,type:"undo"}),this.index-=1,this.lastOp="",!0)}redo(){return!!this.canRedo()&&(this.index+=1,this.model.setState(this.stack[this.index],{silenceNotifications:!1,type:"redo"}),this.lastOp="",!0)}pop(){this.canUndo()&&(this.stack.splice(this.index,this.stack.length-this.index),this.index-=1)}snapshot(t){return!!this.recording&&(t&&t===this.lastOp&&this.pop(),this.stack.splice(this.index+1,this.stack.length-this.index-1),this.stack.push(this.model.getState()),this.index+=1,this.stack.length>e.maximumDepth&&(this.stack.shift(),this.index-=1),this.lastOp=null!=t?t:"",!0)}};Lu.maximumDepth=1e3;var Au=Lu;function Du(e,t,n){if("text"!==e.at(t).mode)return t;const i="backward"===n?-1:1;let r;if($.test(e.at(t).value)){let n,s=t;do{n="text"===e.at(s).mode&&$.test(e.at(s).value),s+=i}while(e.at(s)&&n);r=e.at(s)?s-2*i:s-i}else if(/\s/.test(e.at(t).value)){let n=t;for(;e.at(n)&&"text"===e.at(n).mode&&/\s/.test(e.at(n).value);)n+=i;if(e.at(n)){let t=!0;do{t="text"===e.at(n).mode&&!/\s/.test(e.at(n).value),n+=i}while(e.at(n)&&t);r=e.at(n)?n-2*i:n-i}else r=n-i}else{let n=t;for(;e.at(n)&&"text"===e.at(n).mode&&!/\s/.test(e.at(n).value);)n+=i;r=e.at(n)?n:n-i;let s=!0;for(;e.at(n)&&s;)s="text"===e.at(n).mode&&/\s/.test(e.at(n).value),s&&(r=n),n+=i;r=e.at(n)?n-2*i:n-i}return r-(i>0?0:1)}function Mu(e,t,n){var i,r,s,a,o,l,c;const u=e.position;null!=(i=null==n?void 0:n.extend)&&i||e.collapseSelection(t);let h=e.at(e.position);if("forward"===t&&("subsup"===h.type?(h=h.rightSibling,h||(h=e.at(e.position+1))):h=e.at(e.position+1)),!h)return e.announce("plonk"),!1;let d=e.offsetOf(h);if(h instanceof Pa)d=Du(e,d,t);else if(h instanceof ul)if(h.isSuggestion)for(console.assert("forward"===t);h&&h instanceof ul;)h.isSuggestion=!1,d=e.offsetOf(h),h=h.rightSibling;else if("forward"===t){if(h=h.rightSibling,!(h&&h instanceof ul))return e.announce("plonk"),!1;for(;h&&h instanceof ul&&/[a-zA-Z\*]/.test(h.value);)d=e.offsetOf(h),h=h.rightSibling}else{if(h=h.leftSibling,!(h&&h instanceof ul))return e.announce("plonk"),!1;for(;h&&h instanceof ul&&/[a-zA-Z\*]/.test(h.value);)d=e.offsetOf(h),h=h.leftSibling}else if("forward"===t&&"mopen"===h.type){let t=0;do{"mopen"===h.type?t+=1:"mclose"===h.type&&(t-=1),h=h.rightSibling}while(!h.isLastSibling&&0!==t);d=e.offsetOf(h.leftSibling)}else if("backward"===t&&"mclose"===h.type){let t=0;do{"mopen"===h.type?t+=1:"mclose"===h.type&&(t-=1),h=h.leftSibling}while(!h.isFirstSibling&&0!==t);d=e.offsetOf(h)}else if("backward"===t)if("first"===h.type)for(;d>0&&"first"===h.type;)d-=1,h=e.at(d);else{const t=h.type;"subsup"===h.type&&(d=e.offsetOf(e.at(d).leftSibling)),d-=1;let n=null==(r=e.at(d))?void 0:r.type;for(;d>=0&&n===t;)"subsup"===(null==(s=e.at(d))?void 0:s.type)?d=e.offsetOf(e.at(d).leftSibling):d-=1,n=e.at(d).type}else{const{type:t}=h;let n=null==(a=e.at(d))?void 0:a.type;const{lastOffset:i}=e;for(;d<=i&&(n===t||"subsup"===n);){for(;"subsup"===(null==(o=e.at(d).rightSibling)?void 0:o.type);)d=e.offsetOf(e.at(d).rightSibling);d+=1,n=null==(l=e.at(d))?void 0:l.type}d-=1}if(null!=(c=null==n?void 0:n.extend)&&c){if(!e.setSelection(e.anchor,d))return e.announce("plonk"),!1}else{if(d===e.position)return e.announce("plonk"),!1;e.position=d}return e.announce("move",u),e.mathfield.stopCoalescingUndo(),!0}function Ru(e,t,n){var i,r;if(n=null!=n?n:{extend:!1},e.mathfield.adoptStyle="backward"===t?"right":"left","forward"!==t){const[t,n]=oc(e);void 0!==t&&void 0!==n&&e.deleteAtoms([t,n])}if("upward"===t)return function(e,t){var n,i;const r=null!=(n=null==t?void 0:t.extend)&&n;r||e.collapseSelection("backward");const s=()=>{var t,n;let i=!0;return e.silenceNotifications||(i=null==(n=null==(t=e.mathfield.host)?void 0:t.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"upward"},cancelable:!0,bubbles:!0,composed:!0})))||n),e.announce(i?"plonk":"line"),i},a=e.at(e.position);let o=a;for(;o&&"below"!==o.parentBranch&&!(Array.isArray(o.parentBranch)&&o.parent instanceof No);)o=o.parent;if(Array.isArray(null==o?void 0:o.parentBranch)&&o.parent instanceof No){const t=o.parent;if(o.parentBranch[0]<1)return s();const n=o.parentBranch[0]-1,i=t.array[n][o.parentBranch[1]];if(!i.some((e=>"prompt"===e.type&&!e.captureSelection))&&e.mathfield.hasEditablePrompts)return s();Ou(e,a,i,r,"up")}else{if(!o)return s();{const t=null!=(i=o.parent.branch("above"))?i:o.parent.createBranch("above");if(!t.some((e=>"prompt"===e.type&&e.placeholderId))&&e.mathfield.hasEditablePrompts)return s();Ou(e,a,t,r,"up")}}return e.mathfield.stopCoalescingUndo(),!0}(e,n);if("downward"===t)return function(e,t){var n,i;const r=null!=(n=null==t?void 0:t.extend)&&n;r||e.collapseSelection("forward");const s=()=>{var t,n;let i=!0;return e.silenceNotifications||(i=null==(n=null==(t=e.mathfield.host)?void 0:t.dispatchEvent(new CustomEvent("move-out",{detail:{direction:"downward"},cancelable:!0,bubbles:!0,composed:!0})))||n),e.announce(i?"plonk":"line"),i},a=e.at(e.position);let o=a;for(;o&&"above"!==o.parentBranch&&!(Array.isArray(o.parentBranch)&&o.parent instanceof No);)o=o.parent;if(Array.isArray(null==o?void 0:o.parentBranch)&&o.parent instanceof No){const t=o.parent;if(o.parentBranch[0]+1>t.array.length-1)return s();const n=o.parentBranch[0]+1,i=t.array[n][o.parentBranch[1]];if(!i.some((e=>"prompt"===e.type&&!e.captureSelection))&&e.mathfield.hasEditablePrompts)return s();Ou(e,a,i,r,"down")}else{if(!o)return s();{const t=null!=(i=o.parent.branch("below"))?i:o.parent.createBranch("below");if(!t.some((e=>"prompt"===e.type))&&e.mathfield.hasEditablePrompts)return s();Ou(e,a,t,r,"down")}}return!0}(e,n);if(n.extend){let n=Iu(e,e.position,t);n<0&&(n=0),n>e.lastOffset&&(n=e.lastOffset);const i=e.setSelection(e.anchor,n);return e.mathfield.stopCoalescingUndo(),i}if(e.selectionIsPlaceholder){e.collapseSelection(t);const n=Ru(e,t);return e.mathfield.stopCoalescingUndo(),n}let s=e.position;const a=s;if(e.collapseSelection(t)?(s=e.position,Pu(e,s)||(s=Iu(e,s,t))):s=Iu(e,s,t),s<0||s>e.lastOffset){let n=!0;return e.silenceNotifications||(n=null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:t},cancelable:!0,bubbles:!0,composed:!0})))||r),n&&e.announce("plonk"),n}return e.setPositionHandlingPlaceholder(s),e.mathfield.stopCoalescingUndo(),e.announce("move",a),!0}function Iu(e,t,n){return(t+="forward"===n?1:-1)<0||t>e.lastOffset||Pu(e,t)?t:Iu(e,t,n)}function Pu(e,t){var n;const i=e.at(t);let r=i.parent;for(;r&&!r.inCaptureSelection;)r=r.parent;if(null==r?void 0:r.inCaptureSelection)return!1;if(null==(n=i.parent)?void 0:n.skipBoundary){if(!i.isFirstSibling&&i.isLastSibling)return!1;if("first"===i.type)return!1}return!(e.mathfield.hasEditablePrompts&&!i.parentPrompt)}function Ou(e,t,n,i,r){const s=e.mathfield.hasEditablePrompts,a=s?n.filter((e=>"prompt"===e.type&&!e.captureSelection)):n,o=oo(e.mathfield.getHTMLElement(t)).right,l=e.offsetOf(function(e,t,n){let i=1/0,r=0;for(;r<t.length;r++){const s=oo(e.getHTMLElement(t[r])).right,a=Math.abs(n-s);if(!(a<=i))break;i=a}return t[r-1]}(e.mathfield,a,o))-(s?1:0);if(i){const[t,n]=e.selection.ranges[0];let i;i=l<("up"===r?t:n)?{ranges:[[l,n]],direction:"backward"}:{ranges:[[t,l]],direction:"forward"},e.setSelection(i)}else e.setPositionHandlingPlaceholder(l);e.announce(`move ${r}`)}function Fu(e){const t=e.position,n=e.at(t).parent;return(null==n?void 0:n.parent)?(e.position=e.offsetOf(n),e.mathfield.stopCoalescingUndo(),e.announce("move",t),!0):(e.announce("plonk"),!1)}function Nu(e){var t;if(e.collapseSelection(),function(e){let t=0,n=e.at(e.position),i=!1;for(;n;)n.hasEmptyBranch("superscript")&&n.hasEmptyBranch("subscript")||(t+=1),n.hasEmptyBranch("superscript")?n.hasEmptyBranch("subscript")||(i=!1):i=!0,n=n.parent;return i?t:0}(e)>=e.mathfield.options.scriptDepth[1])return e.announce("plonk"),!1;let n=e.at(e.position);return void 0===n.subsupPlacement&&("subsup"!==(null==(t=n.rightSibling)?void 0:t.type)&&n.parent.addChildAfter(new Yo({style:n.computedStyle}),n),n=n.rightSibling),n.createBranch("superscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(n.superscript[0]))),!0}function Bu(e){var t;if(e.collapseSelection(),function(e){let t=0,n=e.at(e.position),i=!1;for(;n;)n.hasEmptyBranch("superscript")&&n.hasEmptyBranch("subscript")||(t+=1),n.hasEmptyBranch("superscript")?n.hasEmptyBranch("subscript")||(i=!0):i=!1,n=n.parent;return i?t:0}(e)>=e.mathfield.options.scriptDepth[0])return e.announce("plonk"),!1;let n=e.at(e.position);return void 0===n.subsupPlacement&&("subsup"!==(null==(t=e.at(e.position+1))?void 0:t.type)&&n.parent.addChildAfter(new Yo({style:e.at(e.position).computedStyle}),n),n=e.at(e.position+1)),n.createBranch("subscript"),e.setSelection(e.getSiblingsRange(e.offsetOf(n.subscript[0]))),!0}function $u(){function e(e){return!((n=e).disabled||"hidden"===n.type&&"INPUT"===n.tagName.toUpperCase()||function(e){if(!m()||e===document.activeElement||e.contains(document.activeElement))return!1;if("hidden"===getComputedStyle(e).visibility)return!0;const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n)||function(e){return"INPUT"===e.tagName.toUpperCase()&&"radio"===e.type&&!function(e){var t;if(!e.name)return!0;const n=null!=(t=e.form)?t:e.ownerDocument,i=n.querySelectorAll('input[type="radio"][name="'+e.name+'"]'),r=function(e,t){for(const n of e)if(n.checked&&n.form===t)return n;return null}(i,e.form);return!r||r===e}(e)}(e)||t(e)<0);var n}function t(e){var t;const n=Number.parseInt(null!=(t=e.getAttribute("tabindex"))?t:"NaN",10);return Number.isNaN(n)?"true"===e.contentEditable?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:n}return m()?function(n){const i=[],r=[];return[...n.querySelectorAll('input, select, textarea, a[href], button,\n [tabindex], audio[controls], video[controls],\n [contenteditable]:not([contenteditable="false"]), details>summary')].filter(e).forEach(((e,n)=>{const s=t(e);0===s?i.push(e):r.push({documentOrder:n,tabIndex:s,node:e})})),r.sort(((e,t)=>e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex)).map((e=>e.node)).concat(i)}(document.body):[]}function Ku(e,t,n="forward"){const i=e.position;if(Array.isArray(t)){const r=e.offsetOf(t[0]),s=e.offsetOf(t[t.length-1]);return"forward"===n?e.setSelection(r,s):e.setSelection(s,r),e.announce("move",i),e.mathfield.stopCoalescingUndo(),!0}return Ku(e,"forward"===n?[t.leftSibling,t]:[t,t.leftSibling])}function Uu(e,t){const n=e.position;if("number"==typeof t&&(t=e.at(t)),"prompt"===t.type)e.setSelection(e.offsetOf(t.firstChild),e.offsetOf(t.lastChild));else{const n=e.offsetOf(t);"placeholder"===t.type?e.setSelection(n-1,n):e.position=n}return e.announce("move",n),e.mathfield.stopCoalescingUndo(),!0}function zu(e,t,n=!0){var i,r;const s="forward"===t?1:-1;let a;"placeholder"===e.at(e.anchor).type&&Ru(e,t);const o=e.at(e.anchor).parentPrompt;a=o?"forward"===t?e.offsetOf(o)+1:e.offsetOf(o.leftSibling):Math.max(e.position+s,0);const l=Vu(e,a,t);if(!l||"forward"===t&&e.offsetOf(l)<a||"backward"===t&&e.offsetOf(l)>a){if(!n||!(null==(r=null==(i=e.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("move-out",{detail:{direction:t},cancelable:!0,bubbles:!0,composed:!0})))||r))return e.announce("plonk"),!1;const a=$u();if(!document.activeElement||a.length<=1)return e.announce("plonk"),!1;let o=a.indexOf(document.activeElement)+s;return o<0&&(o=a.length-1),o>=a.length&&(o=0),a[o].focus(),e.mathfield.stopCoalescingUndo(),!0}return Uu(e,l),!0}function Vu(e,t=0,n="forward"){return e.findAtom((t=>"placeholder"===t.type||"prompt"===t.type||!e.mathfield.readOnly&&t.treeDepth>2&&t.isFirstSibling&&t.isLastSibling),t,n)}function qu(e,t,n,i){if("forward"===i){let e=t.rightSibling;for(;e&&!n(e);)e=e.rightSibling;return e}let r=t.leftSibling;for(;r&&!n(r);)r=r.leftSibling;return r}function Gu(e,t,n){"function"==typeof t&&(n=t,t=1/0),void 0===t&&(t=1/0);let i=e.position,r=!1,s="";for(;!r;){const a=e.at(i);r=0===t||void 0===a||"first"===a.type||"math"!==a.mode||!(a.type&&/mord|mpunct|operator/.test(a.type)||"mop"===a.type&&/[a-zA-Z ]+/.test(a.value))||!a.hasEmptyBranch("superscript")||!a.hasEmptyBranch("subscript")||"function"==typeof n&&!n(a),r||(a.mode="text",a.command=a.value,a.verbatimLatex=void 0,s+=a.value),i-=1,t-=1}e.contentDidChange({data:s,inputType:"insertText"})}function Hu(e,t,n){"function"==typeof t&&(n=t,t=1/0),void 0===t&&(t=1/0);let i=e.position,r=!1;const s=[];for(;!r;){const a=e.at(i);r=0===t||!a||"first"===a.type||a.isFirstSibling||"text"!==a.mode||" "===a.value||"function"==typeof n&&!n(a),r||(s.push(Ma.serialize([a],{defaultMode:"math"})),a.mode="math"),i-=1,t-=1}ju(e),e.contentDidChange({data:Xs(s),inputType:"insertText"})}function ju(e){var t;let n=e.position-1;for(;n>=0&&"math"===(null==(t=e.at(n))?void 0:t.mode);)n-=1;if(!(n<0)&&"text"===e.at(n).mode&&" "===e.at(n).value&&"math"===e.at(n-1).mode){e.at(n-1).parent.removeChild(e.at(n-1));const t=e.silenceNotifications;e.silenceNotifications=!0,e.position-=1,e.silenceNotifications=t,e.contentDidChange({inputType:"deleteContent"})}}function Wu(){const e=document.getElementById("mathlive-keystroke-caption-panel");return e||(po("keystroke-caption"),po("core"),dc("mathlive-keystroke-caption-panel"))}function Zu(e,t){var n,i,r;const{model:s}=e,a=tc(t);if(t.isTrusted){!function(e){var t,n;if(!e)return;if("Unidentified"===e.key)return;if("Dead"===e.key)return;const i=e.shiftKey&&e.altKey?3:e.altKey?2:e.shiftKey?1:0;for(const r of Vl)(null==(t=r.mapping[e.code])?void 0:t[i])===e.key?r.score+=1:(null==(n=r.mapping[e.code])?void 0:n[i])&&(r.score=0);Vl.sort(((e,t)=>t.score-e.score))}(t);const n=Hl();e.keyboardLayout!==n.id&&(e.keyboardLayout=n.id,e._keybindings=void 0)}if(clearTimeout(e.inlineShortcutBufferFlushTimer),e.inlineShortcutBufferFlushTimer=0,function(e,t){if(!e.isSelectionEditable||!e.keystrokeCaptionVisible)return;const n=Wu(),i=e.element.getBoundingClientRect();n.style.left=`${i.left}px`,n.style.top=i.top-64+"px",n.innerHTML=window.MathfieldElement.createHTML("<span>"+(jl(t)||t)+"</span>"+n.innerHTML),n.style.visibility="visible",setTimeout((()=>{n.childNodes.length>0&&n.childNodes[n.childNodes.length-1].remove(),0===n.childNodes.length&&(n.style.visibility="hidden")}),3e3)}(e,a),t.isTrusted&&t.defaultPrevented)return e.flushInlineShortcutBuffer(),!1;let o,l,c="";const u=e.inlineShortcutBuffer;if(e.isSelectionEditable){if("math"===s.mode)if("[Backspace]"===a)u.pop();else if(Xl(t)){const r=ec(t),a=[...null!=(i=null==(n=u[u.length-1])?void 0:n.keystrokes)?i:[],r];u.push({state:s.getState(),keystrokes:a,leftSiblings:Xu(e)});let c=0,h="";for(;!o&&c<a.length;)l=u.length-(a.length-c),h=a.slice(c).join(""),o=Ka(u[l].leftSiblings,h,e.options.inlineShortcuts),!o&&/^[a-zA-Z][a-zA-Z0-9]+?([_\^][a-zA-Z0-9\*\+\-]+?)?$/.test(h)&&(o=e.options.onInlineShortcut(e,h)),c+=1;e.flushInlineShortcutBuffer({defer:!0})}else e.flushInlineShortcutBuffer();e.options.smartMode&&(o?e.switchMode("math"):function(e,t,n){const{model:i}=e;if("latex"===i.mode)return!1;if(!i.at(i.position).isLastSibling)return!1;if(!n||!Xl(n))return!1;const r=ec(n);if(!i.selectionIsCollapsed)return!("text"!==e.model.mode||!/[/_^]/.test(r));const s=function(e){let t="",n=e.position,i=!1;for(;!i;){const r=e.at(n);i=!(r&&("text"===r.mode||"math"===r.mode&&r.type&&/mord|mpunct/.test(r.type))),i||(t=r.value+t),n-=1}return t}(i)+r;if("text"===e.model.mode){if("Esc"===t||/[/\\]/.test(r))return!0;if(/[\^_]/.test(r))return/(^|\s)[a-zA-Z][^_]$/.test(s)&&Hu(i,1),!0;const e={")":"(","}":"{","]":"["}[r],{parent:n}=i.at(i.position);if(e&&n instanceof Go&&n.leftDelim===e)return!0;if(/(^|[^a-zA-Z])(a|I) $/.test(s))return!1;if(/[$€£₤₺¥¤฿¢₡₧₨₹₩₱]/u.test(r))return!0;if(/(^|[^a-zA-Z'’])[a-zA-Z] $/.test(s))return Hu(i,1),!1;if(/\D\.[^\d\s]$/.test(s)){Hu(i,1);const e=i.at(i.position);return e.value="⋅",e.style.variant="normal",e.command="\\cdot",e.verbatimLatex=void 0,i.contentDidChange({data:"\\cdot",inputType:"insertText"}),!0}if(/(^|\s)[a-zA-Z][^a-zA-Z]$/.test(s))return Hu(i,1),!0;if(/\.\d$/.test(s))return Hu(i,1),!0;if(/\([\d+\-.]$/.test(s))return Hu(i,1),!0;if(/\([a-z][,;]$/.test(s))return Hu(i,2),!0;if(/[\d+\-=><*|]$/.test(r))return ju(i),!0}else{if("[Space]"===t)return Gu(i,void 0,(e=>/[a-z][:,;.]$/.test(e.value))),!0;if(/[a-zA-Z]{3,}$/.test(s)&&!/(dxd|abc|xyz|uvw)$/.test(s))return Gu(i,void 0,(e=>/[a-zA-Z]/.test(e.value))),!0;if(/(^|\W)(if)$/i.test(s))return Gu(i,1),!0;if(/(\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5){3,}$/u.test(s)&&!/(αβγ)$/.test(s))return Gu(i,void 0,(e=>/(:|,|;|.|\u0393|\u0394|\u0398|\u039B|\u039E|\u03A0|\u03A3|\u03A5|\u03A6|\u03A8|\u03A9|[\u03B1-\u03C9]|\u03D1|\u03D5|\u03D6|\u03F1|\u03F5)/u.test(e.value))),!0;if("?"===r)return!0;if("."===r&&!/[\d-+]\.$/.test(s))return!0}return!1}(e,a,t)&&(e.switchMode({math:"text",text:"math"}[s.mode]),c=""))}if(!o){if(c||(c=function(e,t,n){if(0===e.length)return"";const i=Kl($l(tc(n))),r=Kl({key:n.key,shift:n.shiftKey,alt:n.altKey,ctrl:n.ctrlKey,meta:n.metaKey||n.ctrlKey&&/macos|ios/.test(_()),cmd:!1,win:!1});for(let n=e.length-1;n>=0;n--)if(!(e[n].key!==i&&e[n].key!==r||e[n].ifMode&&e[n].ifMode!==t))return e[n].command;return""}(e.keybindings,s.mode,t)),!c&&("[Enter]"===a||"[Return]"===a)){let n=!1;return s.contentWillChange({inputType:"insertLineBreak"})&&(e.host&&(n=!e.host.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),n||t.preventDefault&&(t.preventDefault(),t.stopPropagation()),s.contentDidChange({inputType:"insertLineBreak"})),n}if((!c||"[Space]"===a)&&"math"===s.mode){if("[Space]"===a){if(e.adoptStyle="none",e.flushInlineShortcutBuffer(),e.options.mathModeSpace)return Ya.insert(s,e.options.mathModeSpace,{format:"latex",mode:"math"}),e.snapshot("insert-space"),c="",e.dirty=!0,e.scrollIntoView(),t.preventDefault&&(t.preventDefault(),t.stopPropagation()),!1;const n=s.at(s.position+1),i=s.at(s.position-1);if("text"===(null==n?void 0:n.mode)||"text"===(null==i?void 0:i.mode))return Ya.insert(s," ",{mode:"text"}),e.snapshot("insert-space"),e.dirty=!0,e.scrollIntoView(),!1}(null==(r=s.at(s.position))?void 0:r.isDigit())&&","===window.MathfieldElement.decimalSeparator&&","===ec(t)&&(c="insertDecimalSeparator")}}if(!o&&!c){if(s.mathfield.smartFence){if(Qu(s,ec(t),e.effectiveStyle))return e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}else{const{parent:n}=s.at(s.position);if(n instanceof Go&&"?"===n.rightDelim&&s.at(s.position).isLastSibling&&/^[)}\]|]$/.test(a))return e.snapshot(),n.isDirty=!0,n.rightDelim=a,s.position+=1,s.selectionDidChange(),s.contentDidChange({data:ec(t),inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1;if(!s.selectionIsCollapsed){const n=ec(t);if("("===n||"{"===n||"["===n){const i={"(":"(","{":"\\lbrace","[":"\\lbrack"}[n],r={"(":")","{":"\\rbrace","[":"\\rbrack"}[n],[a,o]=Fa(s.selection);return e.snapshot(),s.position=o,Ya.insert(s,r,{format:"latex"}),s.position=a,Ya.insert(s,i,{format:"latex"}),s.setSelection(a+1,o+1),s.contentDidChange({data:n,inputType:"insertText"}),e.snapshot("insert-fence"),e.dirty=!0,e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}}}return!0}const h=s.at(Math.max(s.position,s.anchor)),{parent:d}=h;if("moveAfterParent"===c&&"leftright"===(null==d?void 0:d.type)&&h.isLastSibling&&e.options.smartFence&&Qu(s,".",e.defaultStyle)&&(c="",Tc(e)),e.keyboardDelegate.cancelComposition(),c)e.executeCommand(c);else if(o){const t=e.effectiveStyle;s.setState(u[l].state);const n=u[u.length-1].keystrokes;for(const e of n)Ya.insert(s,e,{silenceNotifications:!0,style:t});e.snapshot("insert-shortcut"),s.setState(u[l].state),s.deferNotifications({content:!0,selection:!0,data:o,type:"insertText"},(()=>(Ya.insert(s,o,{format:"latex",style:t}),ju(e.model),o.endsWith(" ")&&(e.switchMode("text"),Ya.insert(s," ",{style:t,mode:"text"})),e.snapshot(),s.selectionIsCollapsed||e.flushInlineShortcutBuffer(),!0))),e.dirty=!0,s.announce("replacement")}return e.scrollIntoView(),t.preventDefault&&t.preventDefault(),!1}function Yu(e,t,n){const{model:i}=e;if(!e.isSelectionEditable)return void i.announce("plonk");null!=n||(n={}),n.focus&&e.focus(),n.feedback&&window.MathfieldElement.playSound("keypress"),"string"==typeof n.mode&&(e.switchMode(n.mode),e.snapshot());let r=Ws(t);const s=window.mathVirtualKeyboard;if((null==s?void 0:s.isShifted)&&(r="string"==typeof r?r.toUpperCase():r.map((e=>e.toUpperCase()))),n.simulateKeystroke){let t=!0;for(const n of r)Zu(e,new KeyboardEvent("keypress",{key:n}))&&(t=!1);if(t)return}const a=i.at(i.position),o=u(u({},a.computedStyle),e.defaultStyle);if(i.selectionIsCollapsed||(i.deleteAtoms(Fa(i.selection)),e.snapshot("delete")),"latex"===i.mode)i.deferNotifications({content:!0,selection:!0,data:t,type:"insertText"},(()=>{lc(e);for(const e of r)Ya.insert(i,e);e.snapshot("insert-latex"),cc(e)}));else if("text"===i.mode){for(const e of r)Ya.insert(i,e,{style:o});e.snapshot("insert-text")}else if("math"===i.mode)for(const t of r)Ju(e,t,o,a);e.dirty=!0,e.scrollIntoView()}function Xu(e){const t=e.model,n=[];let i=t.at(Math.min(t.position,t.anchor));for(;"first"!==i.type;)n.push(i),i=i.leftSibling;return n}function Ju(e,t,n,i){const r=e.model;let s={"^":"moveToSuperscript",_:"moveToSubscript"," ":"moveAfterParent"}[t];if(" "===t&&e.options.mathModeSpace&&(s=["insert",e.options.mathModeSpace]),s)e.executeCommand(s);else{if(/\d/.test(t)&&e.options.smartSuperscript&&"superscript"===i.parentBranch&&"mop"!==i.parent.type&&"operator"!==i.parent.type&&"extensible-symbol"!==i.parent.type&&i.hasNoSiblings)return function(e){e.selectionIsCollapsed||(e.deleteAtoms(Fa(e.selection)),e.mathfield.snapshot("delete"))}(r),Ya.insert(r,t,{style:n}),e.snapshot(),Fu(r),void e.snapshot();if(/[a-zA-Z0-9]/.test(t)&&"none"!==e.adoptStyle){const t="left"===e.adoptStyle?i:i.parent?i.rightSibling:null;"mord"===(null==t?void 0:t.type)&&/[a-zA-Z0-9]/.test(t.value)&&(n=u({},n),t.style.variant&&(n.variant=t.style.variant),t.style.variantStyle&&(n.variantStyle=t.style.variantStyle))}Ya.insert(r,t,{style:n}),e.snapshot(`insert-${r.at(r.position).type}`)}}function Qu(e,t,n){if(!t)return!1;if("math"!==e.mode)return!1;const i=e.at(e.position),{parent:r}=i,s={"(":"(",")":")","{":"\\lbrace","}":"\\rbrace","[":"\\lbrack","]":"\\rbrack","|":"|"}[t];if(!s)return!1;const a=_o[s],o=go[s];if(!e.selectionIsCollapsed){e.mathfield.snapshot();const[t,n]=Fa(e.selection),i=e.extractAtoms([t,n]),a=r.addChildrenAfter([new Go("left...right",i,{leftDelim:s,rightDelim:o})],e.at(t));return e.setSelection(e.offsetOf(a.firstChild),e.offsetOf(a.lastChild)),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:s,inputType:"insertText"}),!0}if("|"===s){const t=r instanceof Go?r.leftDelim+r.rightDelim:"";if("\\lbrace\\rbrace"===t||"\\{\\}"===t||"\\lbrace?"===t)return e.mathfield.snapshot(),Ya.insert(e,"\\,\\middle\\vert\\,",{format:"latex",style:n}),e.mathfield.snapshot("insert-fence"),e.contentDidChange({data:s,inputType:"insertText"}),!0}if(o){if(r instanceof Go&&r.firstChild===i&&("?"===r.leftDelim||"."===r.leftDelim))return r.leftDelim=s,r.isDirty=!0,e.mathfield.snapshot(),e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(!(r instanceof Go)){let t=i;for(;t&&("mclose"!==t.type||t.value!==o);)t=t.rightSibling;if(t){e.mathfield.snapshot();const n=e.extractAtoms([e.offsetOf(i),e.offsetOf(t)]);return n.pop(),r.addChildrenAfter([new Go("left...right",n,{leftDelim:s,rightDelim:o})],i),e.position=e.offsetOf(r.firstChild)+1,e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}}const t=e.offsetOf(i.lastSibling);let a;for(a=e.position;a<=t;a++){const t=e.at(a);if(t instanceof Go&&("?"===t.leftDelim||"."===t.leftDelim)&&th(s,t.rightDelim))break}const l=e.at(a);if(a<=t&&l instanceof Go){l.leftDelim=s,e.mathfield.snapshot();let t=e.extractAtoms([e.position,a-1]);return t=t.filter((e=>"first"!==e.type)),l.addChildren(t,l.parentBranch),e.position+=1,e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(r instanceof Go&&("?"===r.leftDelim||"."===r.leftDelim)&&th(s,r.rightDelim)){r.isDirty=!0,r.leftDelim=s,e.mathfield.snapshot();const t=e.extractAtoms([e.offsetOf(i.firstSibling),e.position]);for(const e of t)r.parent.addChildBefore(e,r);return e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}if(!(r instanceof Go&&"|"===r.leftDelim)){if(e.mathfield.snapshot(),Ya.insert(e,`\\left${s}\\right?`,{format:"latex",style:n}),"first"!==i.lastSibling.type){const t=e.offsetOf(i.lastSibling),n=e.extractAtoms([e.position,t]);e.at(e.position).body=n,e.position-=1}return e.mathfield.snapshot("insert-fence"),!0}}if(a){let t=i;for(;t;){if("mopen"===t.type&&t.value===a){e.mathfield.snapshot();const n=t.leftSibling,o=e.extractAtoms([e.offsetOf(t.leftSibling),e.offsetOf(i)]);o.shift();const l=new Go("left...right",o,{leftDelim:a,rightDelim:s});return r.addChildrenAfter([l],n),e.position=e.offsetOf(l),e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0}t=t.leftSibling}if(r instanceof Go&&i.isLastSibling&&eh(r.leftDelim,s))return e.mathfield.snapshot(),r.isDirty=!0,r.rightDelim=s,e.position+=1,e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const o=e.offsetOf(i.firstSibling);let l;for(l=e.position;l>=o;l--){const t=e.at(l);if(t instanceof Go&&("?"===t.rightDelim||"."===t.rightDelim)&&eh(t.leftDelim,s))break}const c=e.at(l);if(l>=o&&c instanceof Go)return e.mathfield.snapshot(),c.rightDelim=s,c.addChildren(e.extractAtoms([l,e.position]),c.parentBranch),e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;if(r instanceof Go&&("?"===r.rightDelim||"."===r.rightDelim)&&eh(r.leftDelim,s))return e.mathfield.snapshot(),r.isDirty=!0,r.rightDelim=s,r.parent.addChildren(e.extractAtoms([e.position,e.offsetOf(i.lastSibling)]),r.parentBranch),e.position=e.offsetOf(r),e.contentDidChange({data:s,inputType:"insertText"}),e.mathfield.snapshot("insert-fence"),!0;const u=r.parent;return!(!(u instanceof Go)||"?"!==u.rightDelim&&"."!==u.rightDelim||!e.at(e.position).isLastSibling)&&(e.position=e.offsetOf(u),Qu(e,s,n))}return!1}function eh(e,t){return!e||(["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e)?[")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(t):go[e]===t)}function th(e,t){return!t||([")","\\rparen","}","\\}","\\rbrace","]","\\rbrack"].includes(t)?["(","\\lparen","{","\\{","\\lbrace","[","\\lbrack"].includes(e):_o[t]===e)}function nh(e,t){var n,i,r,s,a,o,l,c,u,h;const d={};if("string"==typeof t.color){const s=null!=(i=e.colorMap(null!=(n=t.color)?n:t.verbatimColor))?i:"none";s!==t.color&&(d.verbatimColor=null!=(r=t.verbatimColor)?r:t.color),d.color=s}if("string"==typeof t.backgroundColor){const n=null!=(a=e.backgroundColorMap(null!=(s=t.backgroundColor)?s:t.verbatimBackgroundColor))?a:"none";n!==t.backgroundColor&&(d.verbatimBackgroundColor=null!=(o=t.verbatimBackgroundColor)?o:t.backgroundColor),d.backgroundColor=n}"string"==typeof t.fontFamily&&(d.fontFamily=t.fontFamily),"string"==typeof t.series&&(d.fontSeries=t.series),"string"==typeof t.fontSeries&&(d.fontSeries=t.fontSeries.toLowerCase()),d.fontSeries&&(d.fontSeries=null!=(l={bold:"b",medium:"m",normal:"m"}[d.fontSeries])?l:d.fontSeries),"string"==typeof t.shape&&(d.fontShape=t.shape),"string"==typeof t.fontShape&&(d.fontShape=t.fontShape.toLowerCase()),d.fontShape&&(d.fontShape=null!=(c={italic:"it",up:"n",upright:"n",normal:"n"}[d.fontShape])?c:d.fontShape),t.variant&&(d.variant=t.variant.toLowerCase()),t.variantStyle&&(d.variantStyle=t.variantStyle.toLowerCase());const p=null!=(u=t.size)?u:t.fontSize;return"number"==typeof p?d.fontSize=Math.max(1,Math.min(10,p)):"string"==typeof p&&(d.fontSize=null!=(h={size1:1,size2:2,size3:3,size4:4,size5:5,size6:6,size7:7,size8:8,size9:9,size10:10}[p.toLowerCase()])?h:{tiny:1,scriptsize:2,footnotesize:3,small:4,normal:5,normalsize:5,large:6,Large:7,LARGE:8,huge:9,Huge:10}[p]),d}function ih(e){let[t,n]=Fa(e.selection);if(t=rh(e,t,"backward"),n=rh(e,n,"forward"),t===n){const i=e.at(t);if("leftright"===i.type)return e.setSelection(e.offsetOf(i.firstChild)-1,n);if("first"===i.type&&("leftright"===i.parent.type||"surd"===i.parent.type))return e.setSelection(t-1,e.offsetOf(i.parent.lastChild)+1);e.setSelection(t-1,n)}else e.setSelection(t,n);return!0}function rh(e,t,n){var i,r,s;let a=e.at(t);if(!a)return t;const o="forward"===n?1:-1;if("text"===a.mode){for(;a&&"text"===a.mode&&$.test(a.value);)t+=o,a=e.at(t);return"backward"===n?t-1:t}if("latex"===a.mode){if(/[a-zA-Z\*]/.test(a.value))if("backward"===n)for(;a&&"latex"===a.mode&&"\\"!==a.value&&/[a-zA-Z]/.test(a.value);)t+=o,a=e.at(t);else for(;a&&"latex"===a.mode&&/[a-zA-Z\*]/.test(a.value);)t+=o,a=e.at(t);else{if("{"===a.value){if("forward"===n){for(;a&&"latex"===a.mode&&"}"!==a.value;)t+=o,a=e.at(t);return t}return t-1}if("}"===a.value){if("backward"===n){for(;a&&"latex"===a.mode&&"{"!==a.value;)t+=o,a=e.at(t);return t-1}return t}}return t-1}if("math"===a.mode){if(a.isDigit()){for(;null==(i=e.at(t+o))?void 0:i.isDigit();)t+=o;return"backward"===n?t-1:t}if(a.style.variant||a.style.variantStyle){let i=null==(r=e.at(t))?void 0:r.style;for(;i&&i.variant===a.style.variant&&i.variantStyle===a.style.variantStyle;)i=null==(s=e.at(t+o))?void 0:s.style,t+=o;return"backward"===n?t-1:t}return t}return t}Mc({moveToOpposite:e=>{const t=e.at(e.position),{parent:n}=t;if(!n)return e.announce("plonk"),!1;const i=t.parentBranch;let r;if("string"==typeof i&&(r={superscript:"subscript",subscript:"superscript",above:"below",below:"above"}[i]),!r){const n=t.subsupPlacement?Bu(e):Nu(e);return e.mathfield.stopCoalescingUndo(),n}n.branch(r)||n.createBranch(r);const s=e.setSelection(e.getBranchRange(e.offsetOf(n),r));return e.mathfield.stopCoalescingUndo(),s},moveBeforeParent:e=>{const{parent:t}=e.at(e.position);return t?(e.position=e.offsetOf(t),e.mathfield.stopCoalescingUndo(),!0):(e.announce("plonk"),!1)},moveAfterParent:e=>Fu(e),moveToNextChar:e=>Ru(e,"forward"),moveToPreviousChar:e=>Ru(e,"backward"),moveUp:e=>Ru(e,"upward"),moveDown:e=>Ru(e,"downward"),moveToNextWord:e=>Mu(e,"forward"),moveToPreviousWord:e=>Mu(e,"backward"),moveToGroupStart:e=>{const t=e.offsetOf(e.at(e.position).firstSibling);return t===e.position?(e.announce("plonk"),!1):(e.position=t,e.mathfield.stopCoalescingUndo(),!0)},moveToGroupEnd:e=>{const t=e.offsetOf(e.at(e.position).lastSibling);return t===e.position?(e.announce("plonk"),!1):(e.position=t,e.mathfield.stopCoalescingUndo(),!0)},moveToNextGroup:e=>{var t,n,i,r;if(e.position===e.lastOffset&&e.anchor===e.lastOffset)return zu(e,"forward");const s=e.at(e.position);if("text"===s.mode){if(e.selectionIsCollapsed){let n=s;for(;n&&"text"===n.mode;)n=n.leftSibling;let i=s;for(;"text"===(null==(t=i.rightSibling)?void 0:t.mode);)i=i.rightSibling;if(n&&i)return Ku(e,[n,i])}if("text"===s.rightSibling.mode){let t=s;for(;t&&"text"===t.mode;)t=t.rightSibling;return t?(Uu(e,null!=(n=t.leftSibling)?n:t),e.mathfield.switchMode("math"),!0):Uu(e,e.lastOffset)}}const a=e.at(e.anchor).parentPrompt,o=a?e.offsetOf(a)+1:Math.max(e.position+1,0),l=Vu(e,o,"forward");if(l)return Uu(e,l);const c=qu(e,s,(e=>"leftright"===e.type||"text"===e.type),"forward");if(c){if("text"===c.mode){let t=c;for(;t&&"text"===t.mode;)t=t.rightSibling;return Ku(e,[null!=(i=c.leftSibling)?i:c,null!=(r=t.leftSibling)?r:t])}return Ku(e,c)}const u=s.parent;if(u){if("leftright"===u.type||"surd"===u.type)return Ku(e,u);if("superscript"===s.parentBranch&&u.subscript)return Ku(e,u.subscript);if("above"===s.parentBranch&&u.below)return Ku(e,u.below);if("superscript"===s.parentBranch||"subscript"===s.parentBranch)return Uu(e,u);if("above"===s.parentBranch||"below"===s.parentBranch)return Ku(e,u)}return Uu(e,e.lastOffset)},moveToPreviousGroup:e=>{var t;if(0===e.position&&0===e.anchor)return zu(e,"backward");let n=e.at(e.position);const i=n.mode;if("text"===i){if(e.selectionIsCollapsed){let i=n;for(;i&&"text"===i.mode;)i=i.leftSibling;let r=n;for(;"text"===(null==(t=r.rightSibling)?void 0:t.mode);)r=r.rightSibling;if(i&&r)return Ku(e,[i,r])}for(;n&&"text"===n.mode;)n=n.leftSibling;return Uu(e,n?n:0)}const r=e.at(e.anchor).parentPrompt,s=r?e.offsetOf(r.leftSibling):Math.max(e.position-1,0),a=Vu(e,s,"backward");if(a)return Uu(e,a);if("math"===i){const t=qu(e,n,(e=>"leftright"===e.type||"text"===e.type),"backward");if(t){if("text"===t.mode){let n=t;for(;n&&"text"===n.mode;)n=n.leftSibling;return Ku(e,[t,n])}return Ku(e,t)}const i=n.parent;if(i){if("leftright"===i.type||"surd"===i.type)return Ku(e,i);if("subscript"===n.parentBranch&&i.superscript)return Ku(e,i.superscript);if("below"===n.parentBranch&&i.above)return Ku(e,i.above);if("superscript"===n.parentBranch||"subscript"===n.parentBranch)return Uu(e,i);if("above"===n.parentBranch||"below"===n.parentBranch)return Ku(e,i)}return Uu(e,0)}return!1},moveToMathfieldStart:e=>e.selectionIsCollapsed&&0===e.position?(e.announce("plonk"),!1):(e.position=0,e.mathfield.stopCoalescingUndo(),!0),moveToMathfieldEnd:e=>e.selectionIsCollapsed&&e.position===e.lastOffset?(e.announce("plonk"),!1):(e.position=e.lastOffset,e.mathfield.stopCoalescingUndo(),!0),moveToSuperscript:Nu,moveToSubscript:Bu},{target:"model",changeSelection:!0}),Mc({moveToNextPlaceholder:e=>zu(e,"forward"),moveToPreviousPlaceholder:e=>zu(e,"backward")},{target:"model",changeSelection:!0,audioFeedback:"return"}),Mc({undo:e=>(e.undo(),!0),redo:e=>(e.redo(),!0),scrollIntoView:e=>(e.scrollIntoView(),!0),scrollToStart:e=>(e.field.scroll(0,0),!0),scrollToEnd:e=>{const t=e.field.getBoundingClientRect();return e.field.scroll(t.left-window.scrollX,0),!0},toggleKeystrokeCaption:function(e){if(e.keystrokeCaptionVisible=!e.keystrokeCaptionVisible,e.keystrokeCaptionVisible){Wu().innerHTML=""}else{dc("mathlive-keystroke-caption-panel").style.visibility="hidden"}return!1},toggleContextMenu:e=>{const t=e.toggleContextMenu();return t||e.model.announce("plonk"),t},plonk:e=>(e.model.announce("plonk"),!0),switchMode:(e,t,n,i)=>(e.switchMode(t,n,i),!0),insert:(e,t,n)=>e.insert(t,n),typedText:(e,t,n)=>(Yu(e,t,n),!0),insertDecimalSeparator:e=>{const t=e.model;if("math"===t.mode&&","===window.MathfieldElement.decimalSeparator){if(t.at(Math.max(t.position,t.anchor)).isDigit())return e.insert("{,}",{format:"latex"}),e.snapshot("insert-mord"),!0}return e.insert("."),!0},commit:e=>{var t;return e.model.contentWillChange({inputType:"insertLineBreak"})&&(null==(t=e.host)||t.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),e.model.contentDidChange({inputType:"insertLineBreak"})),!0},insertPrompt:(e,t,n)=>{const i=e.getPrompts();let r="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),s=0;for(;i.includes(r)&&s<100;){if(99===s)return console.error("could not find a unique ID after 100 tries"),!1;r="prompt-"+Date.now().toString(36).slice(-2)+Math.floor(1e5*Math.random()).toString(36),s++}return e.insert(`\\placeholder[${null!=t?t:r}]{}`,n),!0}}),Mc({copyToClipboard:e=>(e.focus(),e.model.selectionIsCollapsed&&e.select(),"queryCommandSupported"in document&&document.queryCommandSupported("copy")?document.execCommand("copy"):e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("copy",{bubbles:!0,composed:!0})),!1)},{target:"mathfield"}),Mc({cutToClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("cut")?document.execCommand("cut"):e.element.querySelector(".ML__keyboard-sink").dispatchEvent(new ClipboardEvent("cut",{bubbles:!0,composed:!0})),!0),pasteFromClipboard:e=>(e.focus(),"queryCommandSupported"in document&&document.queryCommandSupported("paste")?(document.execCommand("paste"),!0):(navigator.clipboard.readText().then((t=>{t&&e.model.contentWillChange({inputType:"insertFromPaste",data:t})?(e.stopCoalescingUndo(),e.stopRecording(),e.insert(t,{mode:e.model.mode})&&(cc(e),e.startRecording(),e.snapshot("paste"),e.model.contentDidChange({inputType:"insertFromPaste"}),Tc(e))):e.model.announce("plonk"),e.startRecording()})),!0))},{target:"mathfield",canUndo:!0,changeContent:!0,changeSelection:!0}),Mc({applyStyle:function(e,t){e.flushInlineShortcutBuffer(),e.stopCoalescingUndo();const n=nh(e,t),{model:i}=e;return i.selectionIsCollapsed?(e.defaultStyle.fontSeries&&n.fontSeries===e.defaultStyle.fontSeries&&(n.fontSeries="auto"),n.fontShape&&n.fontShape===e.defaultStyle.fontShape&&(n.fontShape="auto"),n.color&&n.color===e.defaultStyle.color&&(n.color="none"),n.backgroundColor&&n.backgroundColor===e.defaultStyle.backgroundColor&&(n.backgroundColor="none"),n.fontSize&&n.fontSize===e.defaultStyle.fontSize&&(n.fontSize="auto"),e.defaultStyle=u(u({},e.defaultStyle),n)):e.model.deferNotifications({content:!0,type:"insertText"},(()=>{i.selection.ranges.forEach((e=>mu(i,e,n,{operation:"toggle"}))),e.snapshot("style-change")})),!0}},{target:"mathfield",canUndo:!0,changeContent:!0}),Mc({selectGroup:e=>{const t=ih(e);return t||e.announce("plonk"),t},selectAll:e=>e.setSelection(0,e.lastOffset),extendSelectionForward:e=>Ru(e,"forward",{extend:!0}),extendSelectionBackward:e=>Ru(e,"backward",{extend:!0}),extendToNextWord:e=>Mu(e,"forward",{extend:!0}),extendToPreviousWord:e=>Mu(e,"backward",{extend:!0}),extendSelectionUpward:e=>Ru(e,"upward",{extend:!0}),extendSelectionDownward:e=>Ru(e,"downward",{extend:!0}),extendToNextBoundary:e=>Mu(e,"forward",{extend:!0}),extendToPreviousBoundary:e=>Mu(e,"backward",{extend:!0}),extendToGroupStart:e=>{const t=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).firstSibling));return t||e.announce("plonk"),t},extendToGroupEnd:e=>{const t=e.setSelection(e.anchor,e.offsetOf(e.at(e.position).lastSibling));return t||e.announce("plonk"),t},extendToMathFieldStart:e=>{const t=e.setSelection(e.anchor,0);return t||e.announce("plonk"),t},extendToMathFieldEnd:e=>{const t=e.setSelection(e.anchor,e.lastOffset);return t||e.announce("plonk"),t}},{target:"model",changeSelection:!0});var sh=null,ah=0,oh=class e{static start(t,n,i,r){var s;e.element=t,null==(s=e.controller)||s.abort(),e.controller=new AbortController;const a={signal:e.controller.signal};"PointerEvent"in window?(t.addEventListener("pointermove",i,a),t.addEventListener("pointerup",r,a),t.addEventListener("pointercancel",r,a),lh(n)&&(e.pointerId=n.pointerId,t.setPointerCapture(n.pointerId))):(window.addEventListener("mousemove",i,a),window.addEventListener("blur",r,a),window.addEventListener("mouseup",r,a))}static stop(){var t;null==(t=e.controller)||t.abort(),e.controller=void 0,"number"==typeof e.pointerId&&(e.element.releasePointerCapture(e.pointerId),e.pointerId=void 0)}};function lh(e){return null!==e&&void 0!==globalThis.PointerEvent&&e instanceof PointerEvent}function ch(e,t){var n;if(t.buttons>1)return;e.atomBoundsCache=new Map;const i=e;let r,s=!1,a=!1,o="none",l=!1,c=!1;const u=t.clientX,h=t.clientY,d=Date.now(),p=i.field,f=setInterval((()=>{l?p.scroll({top:0,left:p.scrollLeft-16}):c&&p.scroll({top:0,left:p.scrollLeft+16})}),32);function m(){oh.stop(),s=!1,clearInterval(f),e.element.classList.remove("tracking"),t&&t.preventDefault()}sh&&Math.abs(sh.x-u)<5&&Math.abs(sh.y-h)<5&&Date.now()<sh.time+500?(ah+=1,sh.time=d):(sh={x:u,y:h,time:d},ah=1);const g=p.getBoundingClientRect();if(u>=g.left&&u<=g.right&&h>=g.top&&h<=g.bottom){if(e.flushInlineShortcutBuffer(),e.adoptStyle="left",r=ph(e,u,h,{bias:0}),r>=0){if(e.element.classList.add("tracking"),t.shiftKey){const t=e.model.selectionIsCollapsed;e.model.extendSelectionTo(e.model.anchor,r),o=uc(e.model)||t?"all":"selection"}else"placeholder"===e.model.at(r).type?(e.model.setSelection(r-1,r),o="selection"):"placeholder"===(null==(n=e.model.at(r).rightSibling)?void 0:n.type)?(e.model.setSelection(r,r+1),o="selection"):(e.model.position=r,o=uc(e.model)?"all":"selection");e.defaultStyle={},3===t.detail||ah>2?(m(),3!==t.detail&&3!==ah||(e.model.selection={ranges:[[0,e.model.lastOffset]]},o="all")):s||(s=!0,oh.start(p,t,(function(t){if(!i.hasFocus())return void m();const n=t.clientX,s=t.clientY,o=lh(t)&&"touch"===t.pointerType?20:5;if(Date.now()<d+500&&Math.abs(u-n)<o&&Math.abs(h-s)<o)return t.preventDefault(),void t.stopPropagation();const f=p.getBoundingClientRect();c=n>f.right,l=n<f.left;let g=r;lh(t)&&(t.isPrimary||(g=ph(i,t.clientX,t.clientY,{bias:0})));const _=ph(i,n,s,{bias:n<=u?n===u?0:-1:1});g>=0&&_>=0&&(i.model.extendSelectionTo(g,_),Tc(e)),a&&ih(i.model)}),m),2!==t.detail&&2!==ah||(a=!0,ih(e.model),o="all"))}e.hasFocus()||(o="none",e.focus({preventScroll:!0}))}else sh=null;e.stopCoalescingUndo(),"none"!==o&&(e.model.selectionIsCollapsed&&(o="all"),Tc(e)),t.preventDefault()}function uh(e,t,n){if(e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom)return 0;const i=e-(n.left+n.right)/2,r=t-(n.top+n.bottom)/2;return i*i+r*r}function hh(e,t,n,i,r){if(!n.id)return[1/0,null];if(t.has(n.id))return t.get(n.id);const s=ro(e,n);if(!s)return[1/0,null];let a=[1/0,null];if(n.hasChildren&&!n.captureSelection&&i>=s.left&&i<=s.right)for(const s of n.children){const n=hh(e,t,s,i,r);n[0]<=a[0]&&(a=n)}return a[1]||(a=[uh(i,r,s),n]),t.set(n.id,a),a}function dh(e,t,n){const[,i]=hh(e,new Map,e.model.root,t,n);return i}function ph(e,t,n,i){var r;const s=e.field.querySelector(".ML__latex").getBoundingClientRect();if(!s)return 0;if(t>s.right||n>s.bottom+8)return e.model.lastOffset;if(t<s.left||n<s.top-8)return 0;(i=null!=i?i:{}).bias=null!=(r=i.bias)?r:0;let a=dh(e,t,n);const o=[];let l=a;for(;l;)o.unshift(l),l=l.parent;for(const e of o)if(e.captureSelection){a=e;break}let c=e.model.offsetOf(a);if(c<0)return-1;if(a.leftSibling)if(0===i.bias&&"placeholder"!==a.type){const n=ro(e,a);n&&t<(n.left+n.right)/2&&(c=e.model.offsetOf(a.leftSibling))}else i.bias<0&&(c=e.model.offsetOf(a.leftSibling));return c}function fh(e,t,n,i){var r;let s,a=[];if("string"!=typeof t||"math-json"===i.format){const n=window.MathfieldElement.computeEngine;if(!n)return["math-json",[]];[s,t]=["latex",n.box(t).latex],a=Qo(t,{context:e.mathfield.context})}else"string"==typeof t&&"ascii-math"===i.format?([s,t]=za(t,{format:"ascii-math",inlineShortcuts:e.mathfield.options.inlineShortcuts}),a=Qo(t,{context:e.mathfield.context}),"latex"!==s&&e.mathfield.options.removeExtraneousParentheses&&gh(a)):("auto"===i.format||(null==(r=i.format)?void 0:r.startsWith("latex")))&&("auto"===i.format&&([s,t]=za(t,{format:"auto",inlineShortcuts:e.mathfield.options.inlineShortcuts})),"latex"===i.format&&([,t]=ja(t)),a=Qo(t,{context:e.mathfield.context,args:n}),"latex"!==i.format&&e.mathfield.options.removeExtraneousParentheses&&gh(a));return fu(a,i.style),[null!=s?s:"latex",a]}function mh(e){if(!e)return null;if(console.assert("first"===e[0].type),e.length>1)return null;const t=e[0];return t instanceof Go&&"("===t.leftDelim&&")"===t.rightDelim?t.removeBranch("body"):null}function gh(e){if(e){for(let t=0;e[t];t++){const n=e[t];if(n instanceof Go&&"("===n.leftDelim){let i=0,r=0,s=0;for(let e=0;n.body[e];e++)"genfrac"===n.body[e].type&&(i++,r=e),s++;0===s&&1===i&&(e[t]=n.body[r])}}for(const t of e){for(const e of t.branches)if(!t.hasEmptyBranch(e)){gh(t.branch(e));const n=mh(t.branch(e));n&&t.setChildren(n,e)}if(t instanceof No)for(const e of t.cells)gh(e)}}}function _h(e){return!!e.isDigit()||!(!e.type||!/^(mord|surd|subsup|leftright|mop|mclose)$/.test(e.type))&&!e.isExtensibleSymbol}new class extends Ya{constructor(){super("math")}onPaste(e,t){if(!t)return!1;if(!e.model.contentWillChange({data:"string"==typeof t?t:null,dataTransfer:"string"==typeof t?null:t,inputType:"insertFromPaste"}))return!1;let n="",i="auto",r="string"!=typeof t?t.getData("application/json+mathlive"):"";if(r)try{const t=JSON.parse(r);if(t&&Array.isArray(t)){e.snapshot();const n=Tl(t),{model:i}=e;i.selectionIsCollapsed||i.deleteAtoms(Fa(i.selection));const r=i.at(i.position);if(r.parent instanceof No){console.assert(void 0!==r.parentBranch);const e=[];let t=[];"first"===n[0].type&&n.shift(),"first"===n[n.length-1].type&&n.pop();for(const i of n)"first"===i.type&&t.length>0?(e.push(t),t=[i]):t.push(i);t.length>0&&e.push(t);let i=Number(r.parentBranch[0]),s=Number(r.parentBranch[1]);const a=r.parent.maxColumns;for(;r.parent.colCount-s<e.length&&r.parent.colCount<a;)r.parent.addColumn();r.parent.addChildrenAfter(e[0],r);for(let t=1;t<e.length;t++)s++,s>=a&&(s=0,r.parent.addRowAfter(i),i++),r.parent.setCell(i,s,e[t])}else r.parent.addChildrenAfter(n.filter((e=>"first"!==e.type)),r);return i.position=i.offsetOf(n[n.length-1]),i.contentDidChange({inputType:"insertFromPaste"}),Tc(e),!0}}catch(e){}if(r="string"!=typeof t?t.getData("application/json"):"",r&&window.MathfieldElement.computeEngine)try{const e=JSON.parse(r);if("object"==typeof e&&"latex"in e&&e.latex&&(n=e.latex),!n){const t=window.MathfieldElement.computeEngine.box(e);t&&!t.has("Error")&&(n=t.latex)}n||(i="latex")}catch(e){}if(n||"string"==typeof t||(n=t.getData("application/x-latex"),n&&(i="latex")),n||(n="string"==typeof t?t:t.getData("text/plain")),n){let t;return[t,n]=ja(n),"auto"===i&&t&&(i="latex"),e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,n,{format:i})&&(e.startRecording(),e.snapshot("paste"),Tc(e)),e.startRecording(),!0}return!1}insert(e,t,n){var i,r;const s="string"==typeof t?t:null!=(r=null==(i=window.MathfieldElement.computeEngine)?void 0:i.box(t).latex)?r:"";if(!n.silenceNotifications&&!e.contentWillChange({data:s,inputType:"insertText"}))return!1;n.insertionMode||(n.insertionMode="replaceSelection"),n.selectionMode||(n.selectionMode="placeholder"),n.format||(n.format="auto");const{silenceNotifications:a}=e;n.silenceNotifications&&(e.silenceNotifications=!0);const o=e.silenceNotifications;e.silenceNotifications=!0;const l={"?":"\\placeholder{}","@":"\\placeholder{}"};l[0]="replaceAll"===n.insertionMode?"":e.getValue(e.selection,"latex-unstyled"),"replaceSelection"!==n.insertionMode||e.selectionIsCollapsed?"replaceAll"===n.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===n.insertionMode?e.collapseSelection("backward"):"insertAfter"===n.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(Fa(e.selection)),e.at(e.position).isLastSibling||"placeholder"!==e.at(e.position+1).type?"placeholder"===e.at(e.position).type&&e.deleteAtoms([e.position-1,e.position]):e.deleteAtoms([e.position,e.position+1]);let c=-1;l[0]?l["@"]=l[0]:"string"==typeof t&&/(^|[^\\])#@/.test(t)&&(c=function(e){let t=e.at(e.position);if("text"===t.mode){for(;!t.isFirstSibling&&"text"===t.mode;)t=t.leftSibling;return e.offsetOf(t)}const n=t;let i=!1;if("mclose"===t.type){const e=_o[t.value];for(;!t.isFirstSibling&&("mopen"!==t.type||t.value!==e);)t=t.leftSibling;t.isFirstSibling||(t=t.leftSibling),i=!0}else"leftright"===t.type&&(t=t.leftSibling,i=!0);if(i)for(;!t.isFirstSibling&&(t.isFunction||_h(t));)t=t.leftSibling;else{const e=[];for(;!t.isFirstSibling&&(_h(t)||e.length>0);)"mclose"===t.type&&e.unshift(t.value),"mopen"===t.type&&e.length>0&&t.value===_o[e[0]]&&e.shift(),t=t.leftSibling}return n===t?-1:e.offsetOf(t)}(e),c>=0&&(l["@"]=e.getValue(c,e.position,"latex"))),l[0]||(l[0]=l["?"]);let u=!1;const h=e=>(u=!0,l[e]);let[d,p]=fh(e,t,h,n);if(!p)return!1;const f=1===p.length&&"genfrac"===p[0].type;f&&c>=0&&"function"==typeof e.mathfield.options.isImplicitFunction&&e.mathfield.options.isImplicitFunction(e.at(e.position).command)?(l["@"]=l["?"],u=!1,[d,p]=fh(e,t,h,n)):c>=0&&e.deleteAtoms([c,e.position]);const{parent:m}=e.at(e.position),g=m.hasEmptyBranch("body");if(f&&"latex"!==d&&e.mathfield.options.removeExtraneousParentheses&&m instanceof Go&&"("===m.leftDelim&&g){const e=m.parent,t=m.parentBranch;e.removeChild(m),e.setChildren(p,t)}const _=e.at(e.position);_.parent.addChildrenAfter(p,_),"latex"===d&&"string"==typeof t&&"root"===(null==m?void 0:m.type)&&g&&!u&&(m.verbatimLatex=t),e.silenceNotifications=o;const y=p[p.length-1];if("placeholder"===n.selectionMode){const t=p.flatMap((e=>[e,...e.children])).find((e=>"placeholder"===e.type));if(t){const n=e.offsetOf(t);e.setSelection(n-1,n),e.announce("move")}else y&&(e.position=e.offsetOf(y))}else"before"===n.selectionMode||("after"===n.selectionMode?y&&(e.position=e.offsetOf(y)):"item"===n.selectionMode&&e.setSelection(e.anchor,e.offsetOf(y)));return e.contentDidChange({data:s,inputType:"insertText"}),e.silenceNotifications=a,!0}};function yh(e){return{value:e.model.getValue(),selectionIsCollapsed:e.model.selectionIsCollapsed,canUndo:e.canUndo(),canRedo:e.canRedo(),style:e.selectionStyle,mode:e.model.mode}}new class extends Ya{constructor(){super("text")}onPaste(e,t){if(!t)return!1;const n="string"==typeof t?t:t.getData("text/plain");return!(!n||!e.model.contentWillChange({inputType:"insertFromPaste",data:n}))&&(e.stopCoalescingUndo(),e.stopRecording(),this.insert(e.model,n)&&(e.model.contentDidChange({inputType:"insertFromPaste"}),e.startRecording(),e.snapshot("paste"),Tc(e)),e.startRecording(),!0)}insert(e,t,n={}){if(!e.contentWillChange({data:t,inputType:"insertText"}))return!1;n.insertionMode||(n.insertionMode="replaceSelection"),n.selectionMode||(n.selectionMode="placeholder"),n.format||(n.format="auto");const{silenceNotifications:i}=e;n.silenceNotifications&&(e.silenceNotifications=!0);const r=e.silenceNotifications;e.silenceNotifications=!0,"replaceSelection"!==n.insertionMode||e.selectionIsCollapsed?"replaceAll"===n.insertionMode?(e.root.setChildren([],"body"),e.position=0):"insertBefore"===n.insertionMode?e.collapseSelection("backward"):"insertAfter"===n.insertionMode&&e.collapseSelection("forward"):e.deleteAtoms(Fa(e.selection));const s=(a=t,o=e.mathfield.context,Qo(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=a.replace(/\\/g,"\\textbackslash ")).replace(/#/g,"\\#")).replace(/\$/g,"\\$")).replace(/%/g,"\\%")).replace(/&/g,"\\&")).replace(/_/g,"\\_")).replace(/{/g,"\\textbraceleft ")).replace(/}/g,"\\textbraceright ")).replace(/lbrace/g,"\\textbraceleft ")).replace(/rbrace/g,"\\textbraceright ")).replace(/\^/g,"\\textasciicircum ")).replace(/~/g,"\\textasciitilde ")).replace(/£/g,"\\textsterling "),{context:o,parseMode:"text"}));var a,o;if(fu(s,n.style),!s)return!1;const l=e.at(e.position),c=l.parent.addChildrenAfter(s,l);return e.silenceNotifications=r,"before"===n.selectionMode||("item"===n.selectionMode?e.setSelection(e.anchor,e.offsetOf(c)):c&&(e.position=e.offsetOf(c))),e.contentDidChange({data:t,inputType:"insertText"}),e.silenceNotifications=i,!0}};var vh=20,bh=(e,t)=>`\n <line x1="${e+vh}" y1="${t+vh}" \n x2="${e>t?e+vh:180}" \n y2="${e<t?t+vh:180}"/>\n <svg id="plus" viewBox="0 0 40 40" x="${e}" y="${t}" width="40" height="40">\n <circle class="cls-2" cx="20" cy="20" r="20"/>\n <path class="font" d="m33.33,20c0,1.84-1.49,3.34-3.33,3.34h-6.67v6.66c0,1.84-1.49,3.34-3.33,3.34s-3.34-1.5-3.34-3.34v-6.66h-6.66c-1.84,0-3.34-1.5-3.34-3.34s1.5-3.33,3.34-3.33h6.66v-6.67c0-1.84,1.5-3.33,3.34-3.33s3.33,1.49,3.33,3.33v6.67h6.67c1.84,0,3.33,1.49,3.33,3.33Z"/>\n </svg>`,wh=(e,t)=>`\n <line x1="${e+vh}" y1="${t+vh}" \n x2="${e>t?e+vh:180}" \n y2="${e<t?t+vh:180}"/>\n <svg id="minus" viewBox="0 0 40 40" x="${e}" y="${t}" width="40" height="40">\n <circle class="cls-2" cx="20" cy="20" r="20"/>\n <path class="font" d="m33.33,20c0,1.84-1.49,3.33-3.33,3.33H10c-1.84,0-3.34-1.49-3.34-3.33s1.5-3.34,3.34-3.34h20c1.84,0,3.33,1.5,3.33,3.34Z"/>\n </svg>`,xh=(e,t,n)=>`\n <svg id="arrow" viewBox="0 0 40 40" x="${e}" y="${t}" width="40" height="40">\n <circle class="cls-2" cx="20" cy="20" r="20"/>\n <g transform="rotate(${n})" transform-origin="20 20">\n <path class="font" d="m17.7,7.23h4.6c.52,0,.94.42.94.94v13.82c0,.52.42.94.94.94h3.39c.83,0,1.25,1.01.66,1.6l-7.56,7.56c-.37.37-.96.37-1.32,0l-7.56-7.56c-.59-.59-.17-1.6.66-1.6h3.39c.52,0,.94-.42.94-.94v-13.82c0-.52.42-.94.94-.94Z"/>\n </g> \n </svg>`,kh=`\n<svg class="MLEP__array-buttons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" \nviewBox=\n"-2 -2 205 205">\n <rect \n class="MLEP__array-insert-background rows"\n x="0" \n y="52" \n height="144" \n width="48" \n rx="24"/>\n <rect \n class="MLEP__array-insert-background columns"\n x="52" \n y="0" \n height="48" \n width="144" \n rx="24"/>\n <g data-command='"moveDown"'>\n ${xh(104,152,0)}\n </g>\n <g data-command='"moveUp"'>\n ${xh(104,56,180)}\n </g>\n <g data-command='"moveToNextWord"'>\n ${xh(152,104,-90)}\n </g>\n <g data-command='"moveToPreviousWord"'>\n ${xh(56,104,90)}\n </g>\n <g>\n\n <g data-command='"addColumnBefore"'>\n ${bh(56,4)}\n </g>\n <g data-command='"removeColumn"'>\n ${wh(104,4)}\n </g>\n <g data-command='"addColumnAfter"'>\n ${bh(152,4)}\n </g>\n <g data-command='"addRowBefore"'>\n ${bh(4,56)}\n </g>\n <g data-command='"removeRow"'>\n ${wh(4,104)}\n </g>\n <g data-command='"addRowAfter"'>\n ${bh(4,152)}\n </g>\n</svg>`,Sh=e=>`\n<svg id="Bmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","Bmatrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <path class="cls-2" d="m6,4c-1.1,0-2,.9-2,2v3c0,1.66-.9,3-2,3,1.1,0,2,1.34,2,3v3c0,1.1.9,2,2,2"/>\n <path class="cls-2" d="m22,4c1.1,0,2,.9,2,2v3c0,1.66.9,3,2,3-1.1,0-2,1.34-2,3v3c0,1.1-.9,2-2,2"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/>\n</svg>`,Eh={matrix:e=>`\n<svg id="matrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","matrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/></svg>`,pmatrix:e=>`\n<svg id="pmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \ndata-command='["setEnvironment","pmatrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <path class="cls-2" d="m6,4c-3.96,4.6-3.96,11.4,0,16"/>\n <path class="cls-2" d="m22,4c3.96,4.6,3.96,11.4,0,16"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/></svg>`,bmatrix:e=>`\n<svg id="bmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","bmatrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <path class="cls-2" d="m6,4h-3v16h3"/>\n <path class="cls-2" d="m22,4h3v16h-3"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/>\n</svg>`,Bmatrix:Sh,vmatrix:e=>`\n<svg id="vmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","vmatrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/>\n <line class="cls-2" x1="4" y1="4" x2="4" y2="20"/>\n <line class="cls-2" x1="24" y1="4" x2="24" y2="20"/>\n</svg>`,Vmatrix:e=>`\n<svg id="Vmatrix" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="-3.5 -3 35 30" \n data-command='["setEnvironment","Vmatrix"]'>\n <rect class="cls-1" width="28" height="24"/>\n <circle cx="10" cy="8" r="1"/>\n <circle cx="14" cy="12" r="1"/>\n <circle cx="18" cy="16" r="1"/>\n <line class="cls-2" x1="6" y1="4" x2="6" y2="20"/>\n <line class="cls-2" x1="22" y1="4" x2="22" y2="20"/>\n <line class="cls-2" x1="2" y1="4" x2="2" y2="20"/>\n <line class="cls-2" x1="26" y1="4" x2="26" y2="20"/>\n</svg>`},Th={cases:e=>`\n<svg id="cases" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","cases"]'>\n <rect class="cls-1" width="28" height="24"/>\n <path class="cls-2" d="m10,4c-1.1,0-2,.9-2,2v3c0,1.66-.9,3-2,3,1.1,0,2,1.34,2,3v3c0,1.1.9,2,2,2"/>\n <circle cx="13" cy="8" r="1"/>\n <circle cx="13" cy="16" r="1"/>\n <circle cx="21" cy="8" r="1"/>\n <circle cx="21" cy="16" r="1"/>\n</svg>`,rcases:e=>`\n<svg id="rcases" class="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 24" \n data-command='["setEnvironment","rcases"]'>\n <rect class="cls-1" width="28" height="24"/>\n <path class="cls-2" d="m18,20c1.1,0,2-.9,2-2v-3c0-1.66.9-3,2-3-1.1,0-2-1.34-2-3v-3c0-1.1-.9-2-2-2"/>\n <circle cx="15" cy="8" r="1"/>\n <circle cx="15" cy="16" r="1"/>\n <circle cx="7" cy="8" r="1"/>\n <circle cx="7" cy="16" r="1"/>\n</svg>`,Bmatrix:Sh};function Ch(e){var t,n;const i=null==(t=e.model.parentEnvironment)?void 0:t.array;if(!i)return;let r=0;i.forEach((e=>{(!r||e.length>r)&&(r=e.length)}));let s,a=document.getElementById("mathlive-environment-popover");a||(a=dc("mathlive-environment-popover"),po("environment-popover"),po("core"),a.setAttribute("aria-hidden","true"));const o=a.querySelector(".MLEP__environment-controls");o?s=o:(s=document.createElement("div"),a.innerHTML="",a.appendChild(s)),s.className="MLEP__environment-controls",s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.boxSizing="border-box",s.innerHTML=kh;let l=[],c="";const u=e.model.parentEnvironment.environmentName;if(Fo(u)){const e=function(e){return e.replace("*","")}(u);c=Eh[e]("active");const t=Eh,{[e]:n}=t,i=p(t,[d(e)]);l=Object.values(i).map((e=>e("inactive")))}else if(function(e){return Io.includes(e)}(u)){const e=function(e){return"dcases"===e?"cases":e}(u);c=Th[e]("active");const t=Th,{[e]:n}=t,i=p(t,[d(e)]);l=Object.values(i).map((e=>e("inactive")))}else(function(e){return Po.includes(e)})(u)&&(c=Eh.matrix("active"),l=Object.values(Th).map((e=>e("inactive"))));const h=document.createElement("div");h.className="MLEP__environment-delimiter-controls",h.style.display="flex",h.style.flexDirection="column",h.innerHTML=`\n <div class='MLEP__array-delimiter-options'>\n ${c}\n ${l.join("")}\n </div>`,c&&s.appendChild(h);s.querySelectorAll("[data-command]").forEach((t=>{const n=t.dataset.command;let i=n;try{i=JSON.parse(n)}catch(e){}t.addEventListener("mousedown",(e=>e.preventDefault())),i&&t.addEventListener("click",(()=>e.executeCommand(i)))}));const f=null==(n=e.field)?void 0:n.getBoundingClientRect();f&&(a.style.top=`${window.scrollY+(f.top-a.clientHeight-15)}px`,a.style.left=`${f.left+20}px`,a.classList.add("is-visible"))}function Lh(){const e=document.getElementById("mathlive-environment-popover");null==e||e.classList.remove("is-visible")}function Ah(e){if(!e.hasFocus())return;let t=!1;if("math"===e.model.mode){const i=e.model.parentEnvironment;if((null==i?void 0:i.array)&&(n=i.environmentName,Oo.concat(Po).concat(Io).concat(Ro).includes(n))){const n=e.options.environmentPopoverPolicy;t="auto"===n||"on"===n}}var n;t?Ch(e):Lh()}function Dh(e){const t=getComputedStyle(e).direction;return"ltr"===t||"rtl"===t?t:"ltr"}function Mh(e,t,n){return"left"===t||"leading"===t&&"ltr"===n||"trailing"===t&&"rtl"===n?e.left:e.right}function Rh(e,t,n,i){return"middle"===n?e-t/2:"start"===n&&"rtl"===i||"end"===n&&"ltr"===i||"top"===n||"right"===n?Math.max(0,e-t):e}function Ih(e){return"submenu"in e}function Ph(e){return"type"in e&&"command"===e.type||"onMenuSelect"in e||"id"in e}function Oh(e){return"type"in e&&"divider"===e.type}function Fh(e){return"type"in e&&"heading"===e.type}var Nh={};function Bh(e){let t=Nh[e];if(!t){let n;switch(e){case"checkmark":n='<span aria-hidden="true" class="ui-checkmark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg>\n </span>';break;case"trailing-chevron":n='<span aria-hidden="true" class="ui-trailing-chevron"><svg focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"></path></svg></span>';break;case"mixedmark":n='<span aria-hidden="true" class="ui-mixedmark"><svg xmlns="http://www.w3.org/2000/svg" width="16" viewBox="0 0 512 512"><path fill="currentColor" d="M0 256c0-13.3 10.7-24 24-24H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H24c-13.3 0-24-10.7-24-24z"/></svg></span>'}if(n){const i=document.createElement("template");i.innerHTML=n,Nh[e]=i,t=i}}if(t){if("content"in t)return t.content.cloneNode(!0);const e=document.createElement("svg");return e.innerHTML=t.innerHTML,e}}var $h=class{constructor(e,t){var n;this._element=null,this.parentMenu=t,this._declaration=e,Ih(e)?(this.type="submenu",this.submenu=new Uh(e.submenu,{parentMenu:t,submenuClass:e.submenuClass,columnCount:e.columnCount})):this.type=null!=(n=e.type)?n:"command",this.hasCheck=Ph(e)&&void 0!==e.checked}get rootMenu(){return this.parentMenu.rootMenu}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}dispose(){var e,t;null==(e=this._abortController)||e.abort(),this._abortController=void 0,null==(t=this._element)||t.remove(),this._element=null,this.submenu&&this.submenu.dispose(),this.submenu=void 0}get menuItem(){return this._declaration}get label(){var e;return null!=(e=this._label)?e:""}set label(e){void 0===e&&(e=""),e!==this._label&&(this._label=e,this.dirty=!0)}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this.dirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.element&&(e?this.element.removeAttribute("aria-disabled"):this.element.setAttribute("aria-disabled","true")),this.dirty=!0}get checked(){return this._checked}set checked(e){this._checked=e,this.dirty=!0}get tooltip(){return this._tooltip}set tooltip(e){e!==this._tooltip&&(this._tooltip=e,this.dirty=!0)}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){e!==this._ariaLabel&&(this._ariaLabel=e,this.dirty=!0)}get active(){var e,t;return null!=(t=null==(e=this.element)?void 0:e.classList.contains("active"))&&t}set active(e){this.element&&this.element.classList.toggle("active",e)}updateState(e){var t,n,i;const r=this._declaration;if(Oh(r))return this.enabled=!1,void(this.checked=!1);Fh(r)&&(this.enabled=!1,this.checked=!1,this.visible=!0),Ph(r)&&(this.checked=Ph(r)&&null!=(t=Kh(r.checked,e))&&t),(Ph(r)||Ih(r))&&(this.enabled=null==(n=Kh(r.enabled,e))||n,this.visible=null==(i=Kh(r.visible,e))||i,this.visible&&this.enabled&&this.submenu&&(this.submenu.updateState(e),this.submenu.visible||(this.visible=!1))),(Ph(r)||Fh(r)||Ih(r))&&(this.label=Kh(r.label,e),this.tooltip=Kh(r.tooltip,e),this.ariaLabel=Kh(r.ariaLabel,e)),this._element&&this.updateElement()}set dirty(e){console.assert(!0===e),e&&this.parentMenu&&(this.parentMenu.dirty=!0)}updateElement(){if(!this.visible||!this.element)return;const e=this.element;e.textContent="",this.enabled?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true"),!0===this.checked?(e.setAttribute("aria-checked","true"),e.append(Bh("checkmark"))):"mixed"===this.checked?(e.setAttribute("aria-checked","mixed"),e.append(Bh("mixedmark"))):e.removeAttribute("aria-checked"),this.ariaLabel&&e.setAttribute("aria-label",this.ariaLabel);const t=document.createElement("span");if(t.className=this.parentMenu.hasCheck?"label indent":"label","heading"===this.type&&t.classList.add("heading"),t.innerHTML=this.label,e.append(t),this._tooltip&&e.setAttribute("data-tooltip",this._tooltip),Ph(this._declaration)&&this._declaration.keyboardShortcut){const t=document.createElement("kbd");t.innerHTML=jl(this._declaration.keyboardShortcut),e.append(t)}"submenu"===this.type&&e.append(Bh("trailing-chevron"))}get element(){if(this._element)return this._element;if(Oh(this._declaration)){const e=document.createElement("li");return e.setAttribute("part","menu-divider"),e.setAttribute("role","divider"),this._element=e,e}const e=document.createElement("li");this._element=e,(Ph(this._declaration)||Fh(this._declaration)||Ih(this._declaration))&&this._declaration.class&&(e.className=this._declaration.class),e.setAttribute("part","menu-item"),e.setAttribute("tabindex","-1"),this.hasCheck?e.setAttribute("role","menuitemcheckbox"):e.setAttribute("role","menuitem"),"submenu"===this.type&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));const t=this.abortController.signal;return e.addEventListener("pointerenter",this,{signal:t}),e.addEventListener("pointerleave",this,{signal:t}),e.addEventListener("pointerup",this,{signal:t}),e.addEventListener("click",this,{signal:t}),this._element}dispatchSelect(){if(!Ph(this._declaration))return;const e=new CustomEvent("menu-select",{cancelable:!0,bubbles:!0,detail:{modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data}});this.parentMenu.dispatchEvent(e)&&"function"==typeof this._declaration.onMenuSelect&&this._declaration.onMenuSelect({modifiers:this.rootMenu.modifiers,id:this._declaration.id,data:this._declaration.data})}handleEvent(e){var t;if(this.visible&&this.enabled){if("click"===e.type)return"modal"===this.rootMenu.state&&this.select(),e.stopPropagation(),void e.preventDefault();if("pointerenter"===e.type){const n=e;return this.rootMenu.cancelDelayedOperation(),void(this.parentMenu.isSubmenuOpen&&(null==(t=this.parentMenu.activeMenuItem)?void 0:t.movingTowardSubmenu(n))?this.rootMenu.scheduleOperation((()=>{this.parentMenu.activeMenuItem=this,this.openSubmenu()})):(this.parentMenu.activeMenuItem=this,this.openSubmenu({withDelay:!0})))}if("pointerleave"!==e.type)return"pointerup"===e.type?("modal"!==this.rootMenu.state&&this.select(),e.stopPropagation(),void e.preventDefault()):void 0;this.rootMenu.activeSubmenu===this.parentMenu&&(this.parentMenu.activeMenuItem=null)}}select(){this.rootMenu.cancelDelayedOperation(),"submenu"!==this.type?(this.active=!1,setTimeout((()=>{this.active=!0,setTimeout((()=>{this.rootMenu.hide(),this.dispatchSelect()}),80)}),80)):this.openSubmenu()}openSubmenu(e){var t;if("submenu"!==this.type||!this.element)return;if(null!=(t=null==e?void 0:e.withDelay)&&t)return void this.rootMenu.scheduleOperation((()=>this.openSubmenu()));const n=this.element.getBoundingClientRect(),i=Dh(this.element);this.submenu.show({container:this.rootMenu.element.parentNode,location:{x:Mh(n,"trailing",i),y:n.top-4},alternateLocation:{x:Mh(n,"leading",i),y:n.top-4}})}movingTowardSubmenu(e){if(!this.element)return!1;if("submenu"!==this.type)return!1;const t=this.rootMenu.lastMoveEvent;if(!t)return!1;const n=e.timeStamp-t.timeStamp;if(n>500)return!1;const i=e.clientX-t.clientX;var r,s,a;if((r=i,s=t.clientY-e.clientY,a=n,Math.hypot(r,s)/a)<=.2)return!1;let o="right";if(this.submenu.element){const e=this.submenu.element.getBoundingClientRect(),t=this.element.getBoundingClientRect();e.left<t.left+t.width/2&&(o="left")}return"right"===o?i>0:i<0}};function Kh(e,t){return void 0===e||"function"!=typeof e?e:(null!=t||(t={alt:!1,control:!1,shift:!1,meta:!1}),e(t))}var Uh=class e{constructor(e,t){var n,i;this._element=null,this._activeMenuItem=null,this._dirty=!0,this.parentMenu=null!=(n=null==t?void 0:t.parentMenu)?n:null,this._submenuClass=null==t?void 0:t.submenuClass,this.columnCount=null!=(i=null==t?void 0:t.columnCount)?i:1,this.isSubmenuOpen=!1,this.menuItems=e}get children(){return this._menuItems}set menuItems(e){const t=this.parentMenu;this.dispose(),this.parentMenu=t,e=[...e],this._menuItems=e.map((e=>e.onCreate?e.onCreate(e,this):new $h(e,this))),this.hasCheck=void 0,this.dirty=!0}dispose(){var e;this.hide(),this._element&&this._element.remove(),this._abortController&&this._abortController.abort(),null==(e=this._menuItems)||e.forEach((e=>e.dispose())),this._menuItems=[],this._activeMenuItem=null,this.parentMenu=null}handleEvent(e){if("wheel"===e.type&&this._element){const t=e;this._element.scrollBy(0,t.deltaY),e.stopPropagation()}}dispatchEvent(e){return this.rootMenu.dispatchEvent(e)}get rootMenu(){return this.parentMenu.rootMenu}updateState(e){var t,n,i;this._menuItems.forEach((t=>t.updateState(e)));const r=this.hasCheck;let s;this.hasCheck=this._menuItems.some((e=>e.visible&&e.hasCheck)),this.hasCheck!==r&&this._menuItems.forEach((t=>t.updateState(e)));let a=0;for(const e of this._menuItems)"heading"===e.type?(s&&0===a&&(s.visible=!1),s=e,a=0):"divider"===e.type&&s?(s.visible=a>0,s=void 0,a=0):s&&e.visible&&(a+=1);s&&(s.visible=a>0);let o=!0;for(const e of this._menuItems)"divider"===e.type?(e.visible=!o,o=!0):e.visible&&(o=!1);(null==(t=this.activeMenuItem)?void 0:t.visible)||(this.activeMenuItem=null),(null==(n=this.activeMenuItem)?void 0:n.enabled)||"submenu"!==(null==(i=this.activeMenuItem)?void 0:i.type)||this._activeMenuItem.submenu.hide(),this._dirty=!1}get enabled(){return this.updateIfDirty(),this._menuItems.some((e=>"divider"!==e.type&&e.visible&&e.enabled))}get visible(){return this.updateIfDirty(),this._menuItems.some((e=>"divider"!==e.type&&e.visible))}set dirty(e){console.assert(!0===e),this._dirty!==e&&e&&this.parentMenu&&(this._dirty=!0,this.parentMenu.dirty=!0)}updateIfDirty(){this._dirty&&this.updateState(this.rootMenu.modifiers)}updateElement(){var e;if(this._element){this._element.textContent="";for(const{element:e,visible:t}of this._menuItems)e&&t&&this._element.append(e);null==(e=this._element.querySelector("li:first-of-type"))||e.setAttribute("tabindex","0")}}get element(){if(this._element)return this._element;const e=document.createElement("menu");e.setAttribute("role","menu"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-orientation","vertical"),e.setAttribute("part","ui-menu-container"),this._submenuClass&&e.classList.add(this._submenuClass),e.classList.add("ui-menu-container"),this._abortController||(this._abortController=new AbortController);const t=this._abortController.signal;return e.addEventListener("focus",this,{signal:t}),e.addEventListener("wheel",this,{passive:!0,signal:t}),this._element=e,this.updateElement(),e}get activeMenuItem(){return this._activeMenuItem}set activeMenuItem(e){var t,n,i,r;if(this.rootMenu.cancelDelayedOperation(),e!==this._activeMenuItem){if(this.activeMenuItem){const e=this.activeMenuItem;e.active=!1,null==(t=e.submenu)||t.hide()}if(null!=(n=null==e?void 0:e.visible)&&!n)return void(this._activeMenuItem=null);this._activeMenuItem=e,e&&(e.active=!0)}e?null==(i=e.element)||i.focus({preventScroll:!0}):null==(r=this._element)||r.focus({preventScroll:!0})}get firstMenuItem(){this.updateIfDirty();let e=0,t=!1;const n=this._menuItems;for(;!t&&e<=n.length-1;){const i=n[e];t="divider"!==i.type&&i.visible&&i.enabled,e+=1}return t?n[e-1]:null}get lastMenuItem(){this.updateIfDirty();const e=this._menuItems;let t=e.length-1,n=!1;for(;!n&&t>=0;){const i=e[t];n="divider"!==i.type&&i.visible&&i.enabled,t-=1}return n?e[t+1]:null}nextMenuItem(e){if(0===e)return this._activeMenuItem;if(!this._activeMenuItem)return e>0?this.firstMenuItem:this.lastMenuItem;if(!this.firstMenuItem||!this.lastMenuItem||!this._activeMenuItem)return null;this.updateIfDirty();const t=this._menuItems.indexOf(this.firstMenuItem),n=this._menuItems.indexOf(this.lastMenuItem);let i=this._menuItems.indexOf(this._activeMenuItem),r=1;for(;i>=t&&i<=n;){i+=e>0?1:-1;const t=this._menuItems[i];if(!t)break;if(t.visible&&t.enabled){if(r===Math.abs(e))return this._menuItems[i];r+=1}}return e>0?this.lastMenuItem:this.firstMenuItem}getMenuItemColumn(e){this.updateIfDirty();const t=this._menuItems.filter((e=>e.visible&&e.enabled)).indexOf(e);return t<0?-1:t%this.columnCount}static get collator(){return e._collator||(e._collator=new Intl.Collator(void 0,{usage:"search",sensitivity:"base"})),e._collator}findMenuItem(t){var n;this.updateIfDirty();const i=this._menuItems.filter((e=>"divider"!==e.type&&e.visible&&e.enabled));if(0===i.length)return null;const r=Math.max(...i.map((e=>e.label.length)))-t.length;if(r<0)return null;let s=null,a=0;for(;a<r&&!s;)s=null!=(n=i.find((n=>0===e.collator.compare(t,n.label.substring(a,t.length)))))?n:null,a++;return s}show(e){return!(!this.visible||!e.container)&&(this.updateElement(),e.container.appendChild(this.element),y()&&(this.element.popover="manual",this.element.showPopover()),e.location&&function(e,t){var n,i,r;const s=null!=(n=Dh(e))?n:"ltr";e.style.position="fixed",e.style.left="",e.style.top="",e.style.right="",e.style.bottom="",e.style.height="",e.style.width="";const a=e.getBoundingClientRect(),o=Number.isFinite(t.maxHeight)?Math.min(t.maxHeight,window.innerHeight):window.innerHeight;let l=Math.min(o,null!=(i=t.height)?i:a.height),c=Rh(t.location.y,l,t.verticalPos,s);c+l>window.innerHeight-8&&(t.alternateLocation?(c=Rh(t.alternateLocation.y,l,t.verticalPos,s),c+l>window.innerHeight-8&&(c=void 0)):c=void 0),Number.isFinite(c)||(c=Math.max(8,window.innerHeight-8-l),8+l>window.innerHeight-8&&(e.style.bottom="8px")),l=Math.min(c+l,window.innerHeight-8)-c;const u=Number.isFinite(t.maxWidth)?Math.min(t.maxWidth,window.innerWidth):window.innerWidth;let h=Math.min(u,null!=(r=t.width)?r:a.width),d=Rh(t.location.x,h,t.horizontalPos,s);d+h>window.innerWidth-8&&(t.alternateLocation?(d=function(e,t,n,i){return"middle"===n?e-t/2:"start"===n&&"ltr"===i||"end"===n&&"rtl"===i||"top"===n||"right"===n?e:e-t}(t.alternateLocation.x,h,t.verticalPos,s),d+h>window.innerWidth-8&&(d=void 0)):d=void 0),Number.isFinite(d)||(d=Math.max(8,window.innerWidth-8-h),8+h>window.innerWidth-8&&(e.style.right="8px")),h=Math.min(d+h,window.innerWidth-8)-d,"rtl"===s?e.style.right=`${Math.ceil(window.innerWidth-d-h).toString()}px`:e.style.left=`${Math.ceil(d).toString()}px`,e.style.top=`${Math.ceil(c).toString()}px`,l!==a.height&&(e.style.height=`${Math.ceil(l).toString()}px`),h!==a.width&&(e.style.width=`${Math.ceil(h).toString()}px`)}(this.element,{location:e.location,alternateLocation:e.alternateLocation,verticalPos:"bottom",horizontalPos:"start"}),this.element.focus({preventScroll:!0}),this.parentMenu&&(this.parentMenu.openSubmenu=this),!0)}hide(){var e,t,n,i,r;this.openSubmenu=null,this.activeMenuItem=null,this.parentMenu&&(this.parentMenu.openSubmenu=null),y()&&(null==(e=this._element)?void 0:e.popover)&&this.element.hidePopover(),null==(n=null==(t=this.parentMenu)?void 0:t.element)||n.focus(),null==(r=null==(i=this._element)?void 0:i.parentNode)||r.removeChild(this._element)}set openSubmenu(e){var t,n,i,r;const s=null!==e;"submenu"===(null==(t=this.activeMenuItem)?void 0:t.type)&&(null==(n=this.activeMenuItem.element)||n.setAttribute("aria-expanded",s.toString())),null==(r=null==(i=this.activeMenuItem)?void 0:i.element)||r.classList.toggle("is-submenu-open",s),this.isSubmenuOpen=s}},zh=class e extends Uh{constructor(e,t){var n;super(e),this.state="closed",this.typingBufferResetTimer=0,this.hysteresisTimer=0,this._updating=!1,this._host=null!=(n=null==t?void 0:t.host)?n:null,this.isDynamic=e.some(qh),this._modifiers={shift:!1,control:!1,alt:!1,meta:!1},this.typingBuffer="",this.state="closed"}get modifiers(){return this._modifiers}set modifiers(e){var t,n;(t=this._modifiers,n=e,!t&&n||t&&!n||t&&n&&(t.alt!==n.alt||t.control!==n.control||t.shift!==n.shift||t.meta!==n.meta))&&(this._modifiers=e,this.dirty=!0)}get activeSubmenu(){let e=this;for(;e.isSubmenuOpen;)e=e.activeMenuItem.submenu;return e}set dirty(e){this._updating||(console.assert(!0===e),this._dirty!==e&&(this._dirty=!0,e&&setTimeout((()=>{this.updateState(this.modifiers),this.updateElement()}))))}updateState(e){this._updating=!0,this.modifiers=null!=e?e:this.modifiers,super.updateState(this.modifiers),this._updating=!1}handleKeyupEvent(e){this.isDynamic&&(this.modifiers=Zl(e)),e.stopImmediatePropagation()}handleKeydownEvent(e){var t,n,i;if("Tab"===e.key||"Escape"===e.key)return void this.hide();this.isDynamic&&(this.modifiers=Zl(e));let r=!0;const s=this.activeSubmenu,a=s.activeMenuItem;switch(e.key){case" ":case"Space":case"Return":case"Enter":null==a||a.select(Zl(e));break;case"ArrowRight":if("submenu"===(null==a?void 0:a.type))a.select(Zl(e)),this.activeSubmenu.activeMenuItem=this.activeSubmenu.firstMenuItem;else if(a){const e=null!=(t=s.getMenuItemColumn(a))?t:-1;if(e>=0&&e<(null!=(n=s.columnCount)?n:1)-1){const e=s.nextMenuItem(1);e&&(s.activeMenuItem=e)}}else s.activeMenuItem=s.firstMenuItem;break;case"ArrowLeft":if(s===this.rootMenu)a||(s.activeMenuItem=s.firstMenuItem);else{if((a&&null!=(i=s.getMenuItemColumn(a))?i:-1)<=0||!a){s.hide();const e=s.parentMenu.activeMenuItem;if(e){const{element:t}=e;null==t||t.focus(),null==t||t.classList.remove("is-submenu-open")}}else{const e=s.nextMenuItem(-1);e&&(s.activeMenuItem=e)}}break;case"ArrowDown":s.activeMenuItem=s.nextMenuItem(s.columnCount);break;case"ArrowUp":s.activeMenuItem=s.nextMenuItem(-s.columnCount);break;case"Home":case"PageUp":s.activeMenuItem=s.firstMenuItem;break;case"End":case"PageDown":s.activeMenuItem=s.lastMenuItem;break;case"Backspace":if(this.typingBuffer&&(this.typingBuffer=this.typingBuffer.slice(0,-1),this.typingBuffer)){clearTimeout(this.typingBufferResetTimer);const e=s.findMenuItem(this.typingBuffer);e&&(s.activeMenuItem=e),this.typingBufferResetTimer=setTimeout((()=>{this.typingBuffer=""}),500)}break;default:if(Xl(e)){isFinite(this.typingBufferResetTimer)&&clearTimeout(this.typingBufferResetTimer),this.typingBuffer+=e.key;const t=s.findMenuItem(this.typingBuffer);t&&(s.activeMenuItem=t),this.typingBufferResetTimer=setTimeout((()=>{this.typingBuffer=""}),500)}else r=!1}r&&(e.preventDefault(),e.stopPropagation())}handleEvent(e){if("keydown"===e.type)this.handleKeydownEvent(e);else if("keyup"===e.type)this.handleKeyupEvent(e);else if("pointermove"===e.type)this.lastMoveEvent=e;else if("pointerup"===e.type&&e.target===this.scrim)Number.isFinite(this.rootMenu._openTimestamp)&&Date.now()-this.rootMenu._openTimestamp<120?this.state="modal":"modal"===this.state&&this.hide();else if("contextmenu"===e.type)return e.preventDefault(),void e.stopPropagation();super.handleEvent(e)}dispatchEvent(e){return!this._host||this._host.dispatchEvent(e)}get scrim(){return Ql.element}connectScrim(e){const t=this.scrim;t.addEventListener("pointerup",this),t.addEventListener("contextmenu",this),t.addEventListener("keydown",this),t.addEventListener("keyup",this),t.addEventListener("pointermove",this),Ql.open({root:e,onDismiss:()=>this.hide()})}disconnectScrim(){const e=this.scrim;e.removeEventListener("pointerup",this),e.removeEventListener("contextmenu",this),e.removeEventListener("keydown",this),e.removeEventListener("keyup",this),e.removeEventListener("pointermove",this),"open"===Ql.state&&Ql.scrim.close()}get rootMenu(){return this}show(e){return this._onDismiss=null==e?void 0:e.onDismiss,(null==e?void 0:e.modifiers)&&(this.modifiers=e.modifiers),this.updateState(),this.connectScrim(null==e?void 0:e.target),super.show(h(u({},e),{container:this.scrim}))?(this._openTimestamp=Date.now(),this.state="open",!0):(this.disconnectScrim(),!1)}hide(){this.cancelDelayedOperation(),void 0!==this.state&&("closed"!==this.state&&(this.activeMenuItem=null,Ql.element.parentElement.focus(),super.hide(),this.state="closed",this.disconnectScrim()),this._onDismiss&&(this._onDismiss(),this._onDismiss=void 0))}scheduleOperation(t){this.cancelDelayedOperation();const n=e.SUBMENU_DELAY;n<=0?t():this.hysteresisTimer=setTimeout((()=>{this.hysteresisTimer=0,t()}),n)}cancelDelayedOperation(){this.hysteresisTimer&&(clearTimeout(this.hysteresisTimer),this.hysteresisTimer=0)}};zh.SUBMENU_DELAY=120;var Vh=zh;function qh(e){return!Oh(e)&&("function"==typeof e.label||"function"==typeof e.ariaLabel||"function"==typeof e.tooltip||(!(!Ph(e)&&!Ih(e)||"function"!=typeof e.enabled&&"function"!=typeof e.visible)||(!(!Ph(e)||"function"!=typeof e.checked)||!!Ih(e)&&e.submenu.some(qh))))}var Gh=class{};function Hh(e){return new Promise(((t,n)=>{const i=Wl(e);i||t(!1);let r=i;const s=setTimeout((()=>{var e,n;a.abort(),t((e=r,n=i,Math.hypot(n.x-e.x,n.y-e.y)<Gh.MAX_DISTANCE))}),Gh.DELAY),a=new AbortController,o=a.signal;for(const e of["pointermove","pointerup","pointercancel"])window.addEventListener(e,(e=>{if("pointerup"===e.type||"pointercancel"===e.type)clearTimeout(s),a.abort(),t(!1);else if("pointermove"===e.type){const t=Wl(e);t&&(r=t)}}),{passive:!0,signal:o})}))}async function jh(e,t,n){if("contextmenu"===e.type){const i=e;if(n.show({target:t,location:Wl(i),modifiers:Zl(i)}))return e.preventDefault(),e.stopPropagation(),!0}if("keydown"===e.type){const i=e;if("ContextMenu"===i.code||"F10"===i.code&&i.shiftKey){const r=null==t?void 0:t.getBoundingClientRect();if(r&&n.show({target:t,location:{x:Math.ceil(r.left+r.width/2),y:Math.ceil(r.top+r.height/2)},modifiers:Zl(i)}))return e.preventDefault(),e.stopPropagation(),!0}}if("pointerdown"===e.type&&"mouse"!==e.pointerType&&0===e.button){let i=e.target;for(;i&&t!==i;)i=i.parentNode;if(!i)return!1;if(!n.visible)return!1;const r=Wl(e);if(await Hh(e))return"closed"===n.state&&(n.show({target:t,location:r}),!0)}return!1}Gh.DELAY=300,Gh.MAX_DISTANCE=10;var Wh={acute:714,grave:715,dot:729,ddot:168,mathring:730,tilde:126,bar:713,breve:728,check:711,hat:94,vec:8407};ne(Object.keys(Wh),"{body:auto}",{createAtom:e=>new mo(h(u({},e),{body:N(e.args[0]),accentChar:Wh[e.command.slice(1)]}))}),ne(["widehat","widecheck","widetilde"],"{body:auto}",{createAtom:e=>{const t=Q(N(e.args[0]));return new mo(h(u({},e),{body:N(e.args[0]),svgAccent:e.command.slice(1)+(t.length>5?"4":["1","1","2","2","3","3"][t.length])}))}}),ne(["overarc","overparen","wideparen"],"{body:auto}",{createAtom:e=>new mo(h(u({},e),{body:N(e.args[0]),svgAccent:"overarc"}))}),ne(["underarc","underparen"],"{body:auto}",{createAtom:e=>new fl(h(u({},e),{body:N(e.args[0]),svgBelow:"underarc"}))}),ne("utilde","{body:auto}",{createAtom:e=>{const t=N(e.args[0]),n=Q(t),i="widetilde"+(n.length>5?"4":["1","1","2","2","3","3"][n.length]);return new fl(h(u({},e),{body:t,svgBelow:i,boxType:oa(t)}))}}),ne("^","{:string}",{createAtom:e=>{var t;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(t={a:"â",e:"ê",i:"î",o:"ô",u:"û",A:"Â",E:"Ê",I:"Î",O:"Ô",U:"Û"}[e.args[0]])?t:"^"}))}}),ne("`","{:string}",{createAtom:e=>{var t;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(t={a:"à",e:"è",i:"ì",o:"ò",u:"ù",A:"À",E:"È",I:"Ì",O:"Ò",U:"Ù"}[e.args[0]])?t:"`"}))}}),ne("'","{:string}",{createAtom:e=>{var t;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(t={a:"á",e:"é",i:"í",o:"ó",u:"ú",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú"}[e.args[0]])?t:"'"}))}}),ne('"',"{:string}",{createAtom:e=>{var t,n;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(null==(t=e.args)?void 0:t[0])?null!=(n={a:"ä",e:"ë",i:"ï",o:"ö",u:"ü",A:"Ä",E:"Ë",I:"Ë",O:"Ö",U:"Ü"}[e.args[0]])?n:'"'+e.args[0]:'"'}))}}),ne(".","{:string}",{createAtom:e=>{var t,n;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(null==(t=e.args)?void 0:t[0])?null!=(n={a:"ȧ",e:"ė",i:"̇i",o:"ȯ",u:"̇u",A:"Ȧ",E:"Ė",I:"İ",O:"Ȯ",U:"̇U"}[e.args[0]])?n:"."+e.args[0]:"."}))}}),ne("=","{:string}",{createAtom:e=>{var t,n;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:(null==(t=e.args)?void 0:t[0])?null!=(n={a:"ā",e:"ē",i:"ī",o:"ō",u:"ū",A:"Ā",E:"Ē",I:"Ī",O:"Ō",U:"Ū"}[e.args[0]])?n:"="+e.args[0]:"="}))}}),ne("~","{:string}",{createAtom:e=>{var t;return new Ma(h(u({type:"mord"},e),{isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(t={n:"ñ",N:"Ñ",a:"ã",o:"õ",A:"Ã",O:"Õ"}[e.args[0]])?t:"´"}))}}),ne("c","{:string}",{createAtom:e=>{var t;return new Ma(h(u({},e),{type:"mord",isFunction:!1,limits:"adjacent",value:e.args[0]&&null!=(t={c:"ç",C:"Ç"}[e.args[0]])?t:""}))}}),ne("enclose","{notation:string}[style:string]{body:auto}",{createAtom:e=>{var t,n;const i=e.args,r={strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",backgroundcolor:"transparent",padding:"auto",shadow:"none",svgStrokeStyle:void 0,borderStyle:void 0,style:null!=(t=e.style)?t:{}};if(i[1]){const e=i[1].split(/,(?![^(]*\)(?:(?:[^(]*\)){2})*[^"]*$)/);for(const t of e){const e=t.match(/\s*(\S+)\s+(\S+)\s+(.*)/);if(e)r.strokeWidth=e[1],r.strokeStyle=e[2],r.strokeColor=e[3];else{const e=t.match(/\s*([a-z]*)\s*=\s*"(.*)"/);e&&("mathbackground"===e[1]?r.backgroundcolor=e[2]:"mathcolor"===e[1]?r.strokeColor=e[2]:"padding"===e[1]?r.padding=e[2]:"shadow"===e[1]&&(r.shadow=e[2]))}}"dashed"===r.strokeStyle?r.svgStrokeStyle="5,5":"dotted"===r.strokeStyle&&(r.svgStrokeStyle="1,5")}r.borderStyle=`${r.strokeWidth} ${r.strokeStyle} ${r.strokeColor}`;const s={};return(null!=(n=i[0])?n:"").split(/[, ]/).filter((e=>e.length>0)).forEach((e=>{s[e.toLowerCase()]=!0})),new al(e.command,N(i[2]),s,r)}}),ne("cancel","{body:auto}",{createAtom:e=>{var t;return new al(e.command,N(e.args[0]),{updiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(t=e.style)?t:{}})}}),ne("bcancel","{body:auto}",{createAtom:e=>{var t;return new al(e.command,N(e.args[0]),{downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(t=e.style)?t:{}})}}),ne("xcancel","{body:auto}",{createAtom:e=>{var t;return new al(e.command,N(e.args[0]),{updiagonalstrike:!0,downdiagonalstrike:!0},{strokeColor:"currentColor",strokeWidth:"",strokeStyle:"solid",borderStyle:"1px solid currentColor",backgroundcolor:"transparent",padding:"auto",shadow:"none",style:null!=(t=e.style)?t:{}})}}),ne(["overrightarrow","overleftarrow","Overrightarrow","overleftharpoon","overrightharpoon","overleftrightarrow","overlinesegment","overgroup"],"{:auto}",{createAtom:e=>{var t;return new fl(h(u({},e),{body:N(null==(t=e.args)?void 0:t[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgAbove:e.command.slice(1)}))}}),ne("overbrace","{:auto}",{createAtom:e=>new fl(h(u({},e),{body:N(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgAbove:e.command.slice(1)}))}),ne(["underrightarrow","underleftarrow","underleftrightarrow","underlinesegment","undergroup"],"{:auto}",{createAtom:e=>new fl(h(u({},e),{body:N(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"rel",svgBelow:e.command.slice(1)}))}),ne(["underbrace"],"{:auto}",{createAtom:e=>new fl(h(u({},e),{body:N(e.args[0]),skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,boxType:"ord",svgBelow:e.command.slice(1)}))}),ne(["xrightarrow","longrightarrow","xleftarrow","longleftarrow","xRightarrow","xLeftarrow","xleftharpoonup","xleftharpoondown","xrightharpoonup","xrightharpoondown","xlongequal","xtwoheadleftarrow","xtwoheadrightarrow","xleftrightarrow","longleftrightarrow","xLeftrightarrow","xrightleftharpoons","longrightleftharpoons","xleftrightharpoons","xhookleftarrow","xhookrightarrow","xmapsto","xtofrom","xleftrightarrows","longleftrightarrows","xRightleftharpoons","longRightleftharpoons","xLeftrightharpoons","longLeftrightharpoons"],"[:auto]{:auto}",{createAtom:e=>{var t,n,i,r,s;return new fl(h(u({},e),{svgBody:e.command.slice(1),above:0===(null==(n=N(null==(t=e.args)?void 0:t[1]))?void 0:n.length)?void 0:N(null==(i=e.args)?void 0:i[1]),below:null!=(s=N(null==(r=e.args)?void 0:r[0]))?s:null,skipBoundary:!1,supsubPlacement:"over-under",paddedBody:!0,paddedLabels:!0,boxType:"rel"}))},serialize:(e,t)=>e.command+(e.hasEmptyBranch("below")?"":`[${e.belowToLatex(t)}]`)+`{${e.aboveToLatex(t)}}${e.supsubToLatex(t)}`}),ne(["arccos","arcsin","arctan","arctg","arcctg","arg","ch","cos","cosh","cot","cotg","coth","ctg","cth","csc","cosec","deg","dim","exp","gcd","hom","inf","ker","lb","lg","ln","log","Pr","sec","sh","sin","sinh","sup","tan","tanh","tg","th","arcsec","arccsc","arsinh","arcosh","artanh","arcsech","arccsch"],"",{isFunction:!0,ifMode:"math",createAtom:e=>new El(e.command.slice(1),h(u({},e),{limits:"adjacent",isFunction:!0,variant:"main",variantStyle:"up"}))}),ne(["liminf","limsup"],"",{ifMode:"math",createAtom:e=>new El({"\\liminf":"lim inf","\\limsup":"lim sup"}[e.command],h(u({},e),{limits:"over-under",variant:"main"}))}),ne(["lim","mod"],"",{ifMode:"math",createAtom:e=>new El(e.command.slice(1),h(u({},e),{limits:"over-under",variant:"main"}))}),ne(["det","max","min"],"",{ifMode:"math",isFunction:!0,createAtom:e=>new El(e.command.slice(1),h(u({},e),{limits:"over-under",isFunction:!0,variant:"main"}))}),ne(["ang"],"{:math}",{ifMode:"math",createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),serialize:(e,t)=>`\\ang{${e.bodyToLatex(t)}}`,render:(e,t)=>{const n=e.createBox(t),i=n.caret;n.caret=void 0;const r=new ca("°",{style:h(u({},e.style),{variant:"normal",variantStyle:"up"})});return new ca([n,r],{type:"inner",isSelected:e.isSelected,caret:i})}}),ne("sqrt","[index:auto]{radicand:expression}",{ifMode:"math",createAtom:e=>new _l(h(u({},e),{body:N(e.args[1]),index:e.args[0]?N(e.args[0]):void 0}))}),ne(["frac","dfrac","tfrac","cfrac","binom","dbinom","tbinom"],"{:expression}{:expression}",{ifMode:"math",createAtom:e=>{const t=u({},e),n=e.command,i=e.args;switch(n){case"\\dfrac":case"\\frac":case"\\tfrac":t.hasBarLine=!0;break;case"\\atopfrac":t.hasBarLine=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":t.hasBarLine=!1,t.leftDelim="(",t.rightDelim=")";break;case"\\cfrac":t.hasBarLine=!0,t.continuousFraction=!0}switch(n){case"\\dfrac":case"\\dbinom":t.mathstyleName="displaystyle";break;case"\\tfrac":case"\\tbinom":t.mathstyleName="textstyle"}return new cl(i[0]?N(i[0]):[new Mo],i[1]?N(i[1]):[new Mo],t)},serialize:(e,t)=>{const n=e.aboveToLatex(t),i=e.belowToLatex(t);return/^[0-9]$/.test(n)&&/^[0-9]$/.test(i)?`${e.command}${n}${i}`:Js(e.command,n,i)}}),ne(["brace","brack"],"",{infix:!0,createAtom:e=>new cl(N(e.args[0]),N(e.args[1]),h(u({},e),{hasBarLine:!1,leftDelim:"\\brace"===e.command?"\\lbrace":"\\lbrack",rightDelim:"\\brace"===e.command?"\\rbrace":"\\rbrack"})),serialize:(e,t)=>Xs([e.aboveToLatex(t),e.command,e.belowToLatex(t)])}),ne(["over","atop","choose"],"",{infix:!0,createAtom:e=>{let t,n;const i=e.args;return"\\choose"===e.command&&(t="(",n=")"),new cl(N(i[0]),N(i[1]),h(u({},e),{hasBarLine:"\\over"===e.command,leftDelim:t,rightDelim:n}))},serialize:(e,t)=>Xs([e.aboveToLatex(t),e.command,e.belowToLatex(t)])}),ne(["overwithdelims","atopwithdelims"],"{numer:auto}{denom:auto}{left-delim:delim}{right-delim:delim}",{infix:!0,createAtom:e=>{var t,n;const i=e.args;return new cl(N(i[0]),N(i[1]),h(u({},e),{leftDelim:null!=(t=i[2])?t:".",rightDelim:null!=(n=i[3])?n:".",hasBarLine:!1}))},serialize:(e,t)=>`${e.aboveToLatex(t)} ${e.command}${e.leftDelim}${e.rightDelim}${e.belowToLatex(t)}`}),ne("pdiff","{numerator}{denominator}",{ifMode:"math",createAtom:e=>new cl(N(e.args[0]),N(e.args[1]),h(u({},e),{hasBarLine:!0,numerPrefix:"∂",denomPrefix:"∂"}))}),ne(["sum","prod","bigcup","bigcap","coprod","bigvee","bigwedge","biguplus","bigotimes","bigoplus","bigodot","bigsqcup","intop"],"",{ifMode:"math",createAtom:e=>new dl({coprod:"∐",bigvee:"⋁",bigwedge:"⋀",biguplus:"⨄",bigcap:"⋂",bigcup:"⋃",intop:"∫",prod:"∏",sum:"∑",bigotimes:"⨂",bigoplus:"⨁",bigodot:"⨀",bigsqcup:"⨆",smallint:"∫"}[e.command.slice(1)],h(u({},e),{limits:"auto",variant:"main"}))}),ne("smallint","",{ifMode:"math",createAtom:e=>new El("∫",h(u({},e),{limits:"adjacent",variant:"main"}))});var Zh={int:"∫",iint:"∬",iiint:"∭",oint:"∮",oiint:"∯",oiiint:"∰",intclockwise:"∱",varointclockwise:"∲",ointctrclockwise:"∳",intctrclockwise:"⨑",sqcup:"⊔",sqcap:"⊓",uplus:"⊎",wr:"≀",amalg:"⨿",Cap:"⋒",Cup:"⋓",doublecap:"⋒",doublecup:"⋓"};ne(Object.keys(Zh),"",{ifMode:"math",createAtom:e=>{const t=e.command,n=Zh[t.slice(1)];return new dl(n,h(u({},e),{limits:"adjacent",variant:{"⋒":"ams","⋓":"ams"}[n]}))}}),ne(["Re","Im"],"",{ifMode:"math",createAtom:e=>new El({"\\Re":"ℜ","\\Im":"ℑ"}[e.command],h(u({},e),{limits:"adjacent",isFunction:!0,variant:"fraktur"}))}),ne("middle","{:delim}",{ifMode:"math",createAtom:e=>{var t;return new rl(h(u({},e),{delim:null!=(t=e.args[0])?t:"|",size:1}))}}),ne("the","{:value}",{createAtom:e=>new Ma(h(u({},e),{captureSelection:!0,verbatimLatex:null})),render:(e,t)=>{var n;const i=new Ca({parent:t},e.style);let r="";e.isSelected&&(r+=" ML__selected");const s=i.evaluate(e.args[0]);return new ca((null!=(n=xa(s))?n:"").split("").map((t=>new ca(t,{type:"ord",classes:r,mode:e.mode,isSelected:e.isSelected,style:u({variant:"main"},e.style)}))),{type:"lift",style:e.style,caret:e.caret,isSelected:e.isSelected,classes:r}).wrap(i)},serialize:e=>{var t;return`\\the${null!=(t=xa(e.args[0]))?t:"\\relax"}`}}),ne("mathtip","{:auto}{:math}",{createAtom:e=>new Sl(h(u({},e),{body:N(e.args[0]),tooltip:N(e.args[1]),content:"math"})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\texttip{${e.bodyToLatex(t)}}{${Ma.serialize([e.tooltip],h(u({},t),{defaultMode:"math"}))}}`}),ne("texttip","{:auto}{:text}",{createAtom:e=>new Sl(h(u({},e),{body:N(e.args[0]),tooltip:N(e.args[1]),content:"text"})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\texttip{${e.bodyToLatex(t)}}{${Ma.serialize([e.tooltip],h(u({},t),{defaultMode:"text"}))}}`}),ne("error","{:math}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),serialize:(e,t)=>`\\error{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__error"})}),ne("ensuremath","{:math}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),serialize:(e,t)=>`${e.command}{${e.bodyToLatex(h(u({},t),{defaultMode:"math"}))}}`}),ne("color","{:value}",{applyStyle:(e,t,n)=>{var i,r;return{verbatimColor:null!=(i=xa(t[0]))?i:void 0,color:n.toColor(null!=(r=t[0])?r:{string:"red"})}}}),ne("textcolor","{:value}{content:auto*}",{applyStyle:(e,t,n)=>{var i,r;return{verbatimColor:null!=(i=xa(t[0]))?i:void 0,color:n.toColor(null!=(r=t[0])?r:{string:"red"})}}}),ne("boxed","{content:math}",{createAtom:e=>new Uo(h(u({},e),{body:N(e.args[0]),framecolor:{string:"black"}}))}),ne("colorbox","{:value}{:text*}",{applyStyle:(e,t,n)=>{var i,r;return{verbatimBackgroundColor:null!=(i=xa(t[0]))?i:void 0,backgroundColor:n.toBackgroundColor(null!=(r=t[0])?r:{string:"yellow"})}}}),ne("fcolorbox","{frame-color:value}{background-color:value}{content:text}",{applyMode:"text",createAtom:e=>{var t,n;return new Uo(h(u({},e),{body:N(e.args[2]),framecolor:null!=(t=e.args[0])?t:{string:"blue"},backgroundcolor:null!=(n=e.args[1])?n:{string:"yellow"}}))},serialize:(e,t)=>{var n,i;return t.skipStyles?e.bodyToLatex(h(u({},t),{defaultMode:"text"})):Js(e.command,null!=(n=xa(e.framecolor))?n:"",null!=(i=xa(e.backgroundcolor))?i:"",e.bodyToLatex(h(u({},t),{defaultMode:"text"})))}}),ne("bbox","[:bbox]{body:auto}",{createAtom:e=>{var t;const n=e.args[0],i=N(e.args[1]);return new Uo(h(u({},e),n?{body:i,padding:n.padding,border:n.border,backgroundcolor:null!=(t=n.backgroundcolor)?t:void 0}:{body:i}))},serialize:(e,t)=>{var n,i;if(t.skipStyles)return e.bodyToLatex(t);let r=e.command;if(Number.isFinite(e.padding)||void 0!==e.border||void 0!==e.backgroundcolor){const t=[];e.padding&&t.push(null!=(n=xa(e.padding))?n:""),e.border&&t.push(`border: ${e.border}`),e.backgroundcolor&&t.push(null!=(i=xa(e.backgroundcolor))?i:""),r+=`[${t.join(",")}]`}return Js(r,e.bodyToLatex(t))}}),ne(["displaystyle","textstyle","scriptstyle","scriptscriptstyle"],"{:rest}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),render:(e,t)=>{const n=new Ca({parent:t,mathstyle:e.command.slice(1)},e.style),i=Ma.createBox(n,e.body,{type:"lift"});return e.caret&&(i.caret=e.caret),e.bind(t,i)},serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`{${Xs([e.command,e.bodyToLatex(t)])}}`}),ne(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge"],"",{applyStyle:e=>({fontSize:{"\\tiny":1,"\\scriptsize":2,"\\footnotesize":3,"\\small":4,"\\normalsize":5,"\\large":6,"\\Large":7,"\\LARGE":8,"\\huge":9,"\\Huge":10}[e]})}),ne("fontseries","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var n;return{fontSeries:null!=(n=t[0])?n:"auto"}}}),ne("fontshape","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var n;return{fontShape:null!=(n=t[0])?n:"auto"}}}),ne("fontfamily","{:string}",{ifMode:"text",applyStyle:(e,t)=>{var n;return{fontFamily:null!=(n=t[0])?n:"roman"}}}),ne("selectfont","",{ifMode:"text",applyStyle:()=>({})}),ne("bf","{:rest}",{applyStyle:()=>({fontSeries:"b",fontShape:"n",fontFamily:"roman"})}),ne(["boldsymbol","bm"],"{:math}",{applyMode:"math",createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),serialize:(e,t)=>`${e.command}{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__boldsymbol"})}),ne("bold","{:math*}",{applyMode:"math",applyStyle:()=>({variantStyle:"bold"})}),ne("bfseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),ne("mdseries","{:rest}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),ne("upshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),ne("slshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),ne("scshape","{:rest}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),ne("textbf","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"b"})}),ne("textmd","{:text*}",{applyMode:"text",applyStyle:()=>({fontSeries:"m"})}),ne("textup","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n"})}),ne("textnormal","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"n",fontSeries:"m"})}),ne("textsl","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sl"})}),ne("textit","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"it"})}),ne("textsc","{:text*}",{applyMode:"text",applyStyle:()=>({fontShape:"sc"})}),ne("textrm","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"roman"})}),ne("textsf","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"sans-serif"})}),ne("texttt","{:text*}",{applyMode:"text",applyStyle:()=>({fontFamily:"monospace"})}),ne("mathbf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"bold"})}),ne("mathit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"italic"})}),ne("mathnormal","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"italic"})}),ne("mathbfit","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"main",variantStyle:"bolditalic"})}),ne("mathrm","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"normal",variantStyle:"up"})}),ne("mathsf","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"sans-serif",variantStyle:"up"})}),ne("mathtt","{:math*}",{applyMode:"math",applyStyle:()=>({variant:"monospace",variantStyle:"up"})}),ne("it","{:rest}",{applyStyle:()=>({fontSeries:"m",fontShape:"it",fontFamily:"roman",variantStyle:"italic"})}),ne("rmfamily","",{applyStyle:()=>({fontFamily:"roman"})}),ne("sffamily","",{applyStyle:()=>({fontFamily:"sans-serif"})}),ne("ttfamily","",{applyStyle:()=>({fontFamily:"monospace"})}),ne(["Bbb","mathbb"],"{:math*}",{applyStyle:()=>({variant:"double-struck",variantStyle:"up"})}),ne(["frak","mathfrak"],"{:math*}",{applyStyle:()=>({variant:"fraktur",variantStyle:"up"})}),ne("mathcal","{:math*}",{applyStyle:()=>({variant:"calligraphic",variantStyle:"up"})}),ne("mathscr","{:math*}",{applyStyle:()=>({variant:"script",variantStyle:"up"})}),ne("mbox","{:text}",{ifMode:"math",createAtom:e=>new Ma(h(u({},e),{type:"mord",body:N(e.args[0]),mode:"math"})),serialize:(e,t)=>Js("\\mbox",e.bodyToLatex(h(u({},t),{defaultMode:"text"})))}),ne("text","{:text}",{ifMode:"math",applyMode:"text"}),ne(["class","htmlClass"],"{name:string}{content:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[1])})),serialize:(e,t)=>!e.args[0]||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`,render:(e,t)=>{var n;return e.createBox(t,{classes:null!=(n=e.args[0])?n:""})}}),ne(["cssId","htmlId"],"{id:string}{content:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[1])})),serialize:(e,t)=>{var n;return!(null==(n=e.args)?void 0:n[0])||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var n;const i=e.createBox(t);return i.cssId=null!=(n=e.args[0])?n:"",i}}),ne("htmlData","{data:string}{content:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[1])})),serialize:(e,t)=>{var n;return!(null==(n=e.args)?void 0:n[0])||t.skipStyles?e.bodyToLatex(t):`\\htmlData{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var n;const i=e.createBox(t);return i.htmlData=null!=(n=e.args[0])?n:"",i}}),ne(["style","htmlStyle"],"{data:string}{content:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[1])})),serialize:(e,t)=>{var n;return!(null==(n=e.args)?void 0:n[0])||t.skipStyles?e.bodyToLatex(t):`${e.command}{${e.args[0]}}{${e.bodyToLatex(t)}}`},render:(e,t)=>{var n;const i=e.createBox(t);return i.htmlStyle=null!=(n=e.args[0])?n:"",i}}),ne("em","{:rest}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`{\\em ${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__emph",boxType:"lift"})}),ne("emph","{:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[1])})),serialize:(e,t)=>t.skipStyles?e.bodyToLatex(t):`\\emph{${e.bodyToLatex(t)}}`,render:(e,t)=>e.createBox(t,{classes:"ML__emph",boxType:"lift"})});var Yh={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}};ne(["bigl","Bigl","biggl","Biggl","bigr","Bigr","biggr","Biggr","bigm","Bigm","biggm","Biggm","big","Big","bigg","Bigg"],"{:delim}",{createAtom:e=>{var t;return new sl(h(u({},e),{delim:null!=(t=e.args[0])?t:".",size:Yh[e.command].size,delimType:Yh[e.command].mclass}))}}),ne(["hspace","hspace*"],"{width:value}",{createAtom:e=>{var t;return new gl(h(u({},e),{width:null!=(t=e.args[0])?t:{dimension:0}}))}}),ne(["mkern","kern","mskip","hskip","mspace"],"{width:value}",{createAtom:e=>{var t;return new gl(h(u({},e),{width:null!=(t=e.args[0])?t:{dimension:0}}))}}),ne("mathchoice","{:math}{:math}{:math}{:math}",{createAtom:e=>new Ma(e),render:(e,t)=>{let n=0;const i=t.mathstyle.id;5!==i&&4!==i||(n=1),3!==i&&2!==i||(n=2),1!==i&&0!==i||(n=3);const r=N(e.args[n]);return Ma.createBox(t,r)},serialize:(e,t)=>`\\mathchoice{${Ma.serialize(e.args[0],t)}}{${Ma.serialize(e.args[1],t)}}{${Ma.serialize(e.args[2],t)}}{${Ma.serialize(e.args[3],t)}}`}),ne("mathop","{:auto}",{createAtom:e=>new Ma(h(u({},e),{type:"mop",body:N(e.args[0]),limits:"over-under",isFunction:!0,captureSelection:!0})),render:(e,t)=>{var n;let i=Ma.createBox(t,e.body);if(e.superscript||e.subscript){const r=null!=(n=e.subsupPlacement)?n:"auto";i="over-under"===r||"auto"===r&&t.isDisplayStyle?e.attachLimits(t,{base:i}):e.attachSupsub(t,{base:i})}return new ca(e.bind(t,i),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,t)=>{const n=[Js(e.command,e.bodyToLatex(t))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&n.push("\\limits"),"adjacent"===e.subsupPlacement&&n.push("\\nolimits"),"auto"===e.subsupPlacement&&n.push("\\displaylimits")),n.push(e.supsubToLatex(t)),Xs(n)}}),ne(["mathbin","mathrel","mathopen","mathclose","mathpunct","mathord","mathinner"],"{:auto}",{createAtom:e=>new Ma(h(u({},e),{type:{"\\mathbin":"mbin","\\mathrel":"mrel","\\mathopen":"mopen","\\mathclose":"mclose","\\mathpunct":"mpunct","\\mathord":"mord","\\mathinner":"minner"}[e.command],body:N(e.args[0])}))}),ne(["operatorname","operatorname*"],"{operator:math}",{createAtom:e=>{const t=N(e.args[0]).map((e=>{var t;return"first"!==e.type&&(e.type="mord",e.value=null!=(t={"∗":"*","−":"-"}[e.value])?t:e.value,e.isFunction=!1,e.style.variant||e.style.variantStyle||(e.style.variant="main",e.style.variantStyle="up")),e}));return new Ma(h(u({},e),{type:"mop",body:t,isFunction:!0,limits:"\\operatorname"===e.command?"adjacent":"over-under"}))},render:(e,t)=>{var n;let i=Ma.createBox(t,e.body);if(e.superscript||e.subscript){const r=null!=(n=e.subsupPlacement)?n:"auto";i="over-under"===r||"auto"===r&&t.isDisplayStyle?e.attachLimits(t,{base:i}):e.attachSupsub(t,{base:i})}return e.caret&&(i.caret=e.caret),new ca(e.bind(t,i),{type:"op",isSelected:e.isSelected,classes:"op-group"})},serialize:(e,t)=>{const n=[Js(e.command,e.bodyToLatex(t))];return e.explicitSubsupPlacement&&("over-under"===e.subsupPlacement&&n.push("\\limits"),"adjacent"===e.subsupPlacement&&n.push("\\nolimits"),"auto"===e.subsupPlacement&&n.push("\\displaylimits")),n.push(e.supsubToLatex(t)),Xs(n)}}),ne(["char","unicode"],"{charcode:value}",{createAtom:e=>new Ma(h(u({},e),{type:"text"===e.mode?"text":"mord"})),serialize:e=>{var t;return`${e.command}${xa(null!=(t=e.args[0])?t:{number:10067,base:"hexadecimal"})}`},render:(e,t)=>{let n=t.evaluate(e.args[0]);return n&&"number"in n||(n={number:10067,base:"hexadecimal"}),e.value=String.fromCodePoint(n.number),e.createBox(t)}}),ne("rule","[raise:value]{width:value}{thickness:value}",{createAtom:e=>new Ma(e),render:(e,t)=>{var n,i,r;const s=new Ca({parent:t,mathstyle:"textstyle"},e.style),a=s.toEm(null!=(n=e.args[0])?n:{dimension:0}),o=s.toEm(null!=(i=e.args[1])?i:{dimension:10}),l=s.toEm(null!=(r=e.args[2])?r:{dimension:10}),c=new ca(null,{classes:"rule",type:"ord"});return c.width=o,c.height=l+a,c.depth=-a,c.setStyle("border-right-width",o,"em"),c.setStyle("border-top-width",l,"em"),c.setStyle("border-color",e.style.color),c.setStyle("vertical-align",a,"em"),e.isSelected&&c.setStyle("opacity","50%"),e.bind(s,c),e.caret&&(c.caret=e.caret),c.wrap(t)},serialize:e=>`\\rule${e.args[0]?`[${xa(e.args[0])}]`:""}{${xa(e.args[1])}}{${xa(e.args[2])}}`}),ne(["overline","underline"],"{:auto}",{createAtom:e=>new Ma(h(u({},e),{body:N(e.args[0])})),render:(e,t)=>{const n=e.command.substring(1),i=new Ca({parent:t,mathstyle:"cramp"},e.style),r=Ma.createBox(i,e.body);if(!r)return null;const s=i.metrics.defaultRuleThickness/i.scalingFactor,a=new ca(null,{classes:n+"-line"});let o;return a.height=s,a.maxFontSize=1.125*s*i.scalingFactor,o=new ma("overline"===n?{shift:0,children:[{box:r},3*s,{box:a},s]}:{top:r.height,children:[s,{box:a},3*s,{box:r}]}),e.caret&&(o.caret=e.caret),new ca(o,{classes:n,type:"ignore"})}}),ne("overset","{:auto}{base:auto}",{createAtom:e=>{const t=N(e.args[1]);return new fl(h(u({},e),{above:N(e.args[0]),body:t,skipBoundary:!1,boxType:oa(t)}))},serialize:(e,t)=>Js(e.command,e.aboveToLatex(t),e.bodyToLatex(t))}),ne("underset","{:auto}{base:auto}",{createAtom:e=>{const t=N(e.args[1]);return new fl(h(u({},e),{below:N(e.args[0]),body:t,skipBoundary:!1,boxType:oa(t)}))},serialize:(e,t)=>Js(e.command,e.belowToLatex(t),e.bodyToLatex(t))}),ne("overunderset","{above:auto}{below:auto}{base:auto}",{createAtom:e=>{const t=N(e.args[2]);return new fl(h(u({},e),{above:N(e.args[0]),below:N(e.args[1]),body:t,skipBoundary:!1,boxType:oa(t)}))},serialize:(e,t)=>Js(e.command,e.belowToLatex(t),e.bodyToLatex(t))}),ne(["stackrel","stackbin"],"[below:auto]{above:auto}{base:auto}",{createAtom:e=>new fl(h(u({},e),{body:N(e.args[2]),above:N(e.args[1]),below:N(e.args[0]),skipBoundary:!1,boxType:"\\stackrel"===e.command?"rel":"bin"})),serialize:(e,t)=>Js(e.command,e.aboveToLatex(t),e.bodyToLatex(t))}),ne("smash","[:string]{:auto}",{createAtom:e=>{var t,n,i,r;return new ml(h(u({},e),{body:N(e.args[1]),smashHeight:null==(n=null==(t=e.args[0])?void 0:t.includes("t"))||n,smashDepth:null==(r=null==(i=e.args[0])?void 0:i.includes("b"))||r}))}}),ne(["vphantom"],"{:auto}",{createAtom:e=>new ml(h(u({},e),{body:N(e.args[0]),isInvisible:!0,smashWidth:!0}))}),ne(["hphantom"],"{:auto}",{createAtom:e=>new ml(h(u({},e),{body:N(e.args[0]),isInvisible:!0,smashHeight:!0,smashDepth:!0}))}),ne(["phantom"],"{:auto}",{createAtom:e=>new ml(h(u({},e),{body:N(e.args[0]),isInvisible:!0}))}),ne("not","{:math}",{createAtom:e=>{const t=N(e.args[0]);return 0===t.length?new Ma(h(u({},e),{type:"mrel",value:""})):new Ma(h(u({},e),{body:[new pl(h(u({},e),{body:"",align:"right"})),...t],captureSelection:!0}))},serialize:(e,t)=>{const n=e.args[0],i=n&&"object"==typeof n&&"group"in n;return""!==e.value?i?`\\not{${Ma.serialize(n.group,t)}}`:`\\not${Ma.serialize(n,t)}`:i?"\\not{}":"\\not"},render:(e,t)=>{if(e.value)return e.createBox(t);const n=e.args[0]&&"object"==typeof e.args[0]&&"group"in e.args[0]?"ord":oa(N(e.args[0])),i=Ma.createBox(t,e.body,{type:n});return e.caret&&(i.caret=e.caret),e.bind(t,i)}}),ne(["ne","neq"],"",{createAtom:e=>new Ma(h(u({},e),{type:"mrel",body:[new pl(h(u({},e),{body:"",align:"right",boxType:"rel"})),new Ma(h(u({},e),{value:"="}))],captureSelection:!0})),serialize:e=>e.command}),ne("rlap","{:auto}",{createAtom:e=>new pl(h(u({},e),{body:N(e.args[0]),align:"right"}))}),ne("llap","{:auto}",{createAtom:e=>new pl(h(u({},e),{body:N(e.args[0]),align:"left"}))}),ne("mathrlap","{:math}",{createAtom:e=>new pl(h(u({},e),{body:N(e.args[0]),align:"left"}))}),ne("mathllap","{:math}",{createAtom:e=>new pl(h(u({},e),{body:N(e.args[0]),align:"left"}))}),ne("raisebox","{:value}{:text}",{createAtom:e=>{var t;return new Uo(h(u({},e),{body:N(e.args[1]),padding:{dimension:0},offset:null!=(t=e.args[0])?t:{dimension:0}}))},serialize:(e,t)=>{var n;return Js("\\raisebox",null!=(n=xa(e.offset))?n:"0pt",e.bodyToLatex(t))}}),ne("raise","{:value}{:auto}",{createAtom:e=>{var t;return new Uo(h(u({},e),{body:N(e.args[1]),padding:{dimension:0},offset:null!=(t=e.args[0])?t:{dimension:0}}))},serialize:(e,t)=>{var n;return Js("\\raise",null!=(n=xa(e.offset))?n:"0pt",e.bodyToLatex(t))}}),ne("lower","{:value}{:auto}",{createAtom:e=>{var t;return new Uo(h(u({},e),{body:N(e.args[1]),padding:{dimension:0},offset:null!=(t=ka(e.args[0],-1))?t:{dimension:0}}))},serialize:(e,t)=>{var n,i;return Js("\\lower",null!=(i=xa(ka(null!=(n=e.offset)?n:{dimension:0},-1)))?i:"0pt",e.bodyToLatex(t))}}),Z("0123456789/@.?!"),Y(65,90),Y(97,122),Z([["\\forall",8704],["\\exists",8707],["\\nexists",8708,"mord","ams"],["\\mid",8739,"mrel"],["\\top",8868],["\\bot",8869]]),Z([["\\#",35],["\\&",38],["\\parallelogram",9649],["\\spadesuit",9824],["\\heartsuit",9825],["\\diamondsuit",9826],["\\clubsuit",9827],["\\flat",9837],["\\natural",9838],["\\sharp",9839]]),Z([["\\backslash",92],["\\nabla",8711],["\\partial",8706],["\\ell",8467],["\\hbar",8463],["\\Q",81,"mord","double-struck"],["\\C",67,"mord","double-struck"],["\\P",80,"mord","double-struck"],["\\pounds",163],["\\euro",8364]]),Z([["\\rightarrow",8594],["\\to",8594],["\\leftarrow",8592],["\\gets",8592],["\\Rightarrow",8658],["\\Leftarrow",8656],["\\longrightarrow",10230],["\\longleftarrow",10229],["\\Longrightarrow",10233],["\\implies",10233],["\\Longleftarrow",10232],["\\impliedby",10232],["\\longleftrightarrow",10231],["\\biconditional",10231],["\\Longleftrightarrow",10234],["\\mapsto",8614],["\\longmapsto",10236],["\\uparrow",8593],["\\downarrow",8595],["\\Uparrow",8657],["\\Downarrow",8659],["\\updownarrow",8597],["\\Updownarrow",8661],["\\hookrightarrow",8618],["\\hookleftarrow",8617],["\\rightharpoonup",8640],["\\leftharpoonup",8636],["\\rightharpoondown",8641],["\\leftharpoondown",8637],["\\searrow",8600],["\\nearrow",8599],["\\swarrow",8601],["\\nwarrow",8598],["\\originalof",8886],["\\laplace",8886],["\\imageof",8887],["\\Laplace",8887]],"mrel"),Z([["\\mapsfrom",8612,"mrel"],["\\Mapsfrom",10502,"mrel"],["\\MapsTo",10503,"mrel"],["\\Yup",8516,"mord"],["\\lightning",8623,"mrel"],["\\leftarrowtriangle",8701,"mrel"],["\\rightarrowtriangle",8702,"mrel"],["\\leftrightarrowtriangle",8703,"mrel"],["\\boxdot",8865,"mbin"],["\\bigtriangleup",9651,"mbin"],["\\bigtriangledown",9661,"mbin"],["\\boxbar",9707,"mbin"],["\\Lbag",10181,"mopen"],["\\Rbag",10182,"mclose"],["\\llbracket",10214,"mopen"],["\\rrbracket",10215,"mclose"],["\\longmapsfrom",10235,"mrel"],["\\Longmapsfrom",10237,"mrel"],["\\Longmapsto",10238,"mrel"],["\\boxslash",10692,"mbin"],["\\boxbslash",10693,"mbin"],["\\boxast",10694,"mbin"],["\\boxcircle",10695,"mbin"],["\\boxbox",10696,"mbin"],["\\fatsemi",10783,"mop"],["\\leftslice",10918,"mrel"],["\\rightslice",10919,"mrel"],["\\interleave",10996,"mbin"],["\\biginterleave",11004,"mop"],["\\sslash",11005,"mbin"],["\\talloblong",11006,"mbin"]]),Z([["\\lbrace",123,"mopen"],["\\rbrace",125,"mclose"],["\\lparen",40,"mopen"],["\\rparen",41,"mclose"],["\\langle",10216,"mopen"],["\\rangle",10217,"mclose"],["\\lfloor",8970,"mopen"],["\\rfloor",8971,"mclose"],["\\lceil",8968,"mopen"],["\\rceil",8969,"mclose"],["\\vert",8739],["\\lvert",8739,"mopen"],["\\rvert",8739,"mclose"],["\\|",8741],["\\Vert",8741],["\\mVert",8741],["\\lVert",8741,"mopen"],["\\rVert",8741,"mclose"],["\\lbrack",91,"mopen"],["\\rbrack",93,"mclose"],["\\{",123,"mopen"],["\\}",125,"mclose"],["(",40,"mopen"],[")",41,"mclose"],["[",91,"mopen"],["]",93,"mclose"],["\\ulcorner",9484,"mopen","ams"],["\\urcorner",9488,"mclose","ams"],["\\llcorner",9492,"mopen","ams"],["\\lrcorner",9496,"mclose","ams"],["\\lgroup",10222,"mopen"],["\\rgroup",10223,"mclose"],["\\lmoustache",9136,"mopen"],["\\rmoustache",9137,"mclose"]]),Z([["\\dashrightarrow",8674],["\\dashleftarrow",8672],["\\Rrightarrow",8667],["\\Lleftarrow",8666],["\\leftrightarrows",8646],["\\rightleftarrows",8644],["\\curvearrowright",8631],["\\curvearrowleft",8630],["\\rightrightarrows",8649],["\\leftleftarrows",8647],["\\upuparrows",8648],["\\downdownarrows",8650],["\\vartriangle",9651],["\\triangleq",8796],["\\vartriangleleft",8882],["\\trianglelefteq",8884],["\\ntriangleleft",8938],["\\ntrianglelefteq",8940],["\\vartriangleright",8883],["\\trianglerighteq",8885],["\\ntriangleright",8939],["\\ntrianglerighteq",8941],["\\blacktriangleleft",9664],["\\blacktriangleright",9654],["\\leftarrowtail",8610],["\\rightarrowtail",8611],["\\looparrowright",8620],["\\looparrowleft",8619],["\\twoheadleftarrow",8606],["\\twoheadrightarrow",8608],["\\twoheadrightarrowtail",10518],["\\rightleftharpoons",8652],["\\leftrightharpoons",8651],["\\Rsh",8625],["\\Lsh",8624],["\\circlearrowright",8635],["\\circlearrowleft",8634],["\\restriction",8638],["\\upharpoonright",8638],["\\upharpoonleft",8639],["\\downharpoonright",8642],["\\downharpoonleft",8643],["\\rightsquigarrow",8669],["\\leadsto",8669],["\\leftrightsquigarrow",8621],["\\multimap",8888],["\\nleftarrow",8602],["\\nrightarrow",8603],["\\nRightarrow",8655],["\\nLeftarrow",8653],["\\nleftrightarrow",8622],["\\nLeftrightarrow",8654],["\\nvrightarrow",8696],["\\nvtwoheadrightarrow",10496],["\\nvrightarrowtail",10516],["\\nvtwoheadrightarrowtail",10519],["\\shortparallel",8741],["\\nless",8814],["\\nleqslant",57360],["\\lneq",10887],["\\lneqq",8808],["\\nleqq",57361],["\\lvertneqq",57356],["\\lnsim",8934],["\\lnapprox",10889],["\\nprec",8832],["\\npreceq",8928],["\\precnsim",8936],["\\precnapprox",10937],["\\nsim",8769],["\\nshortmid",57350],["\\nmid",8740],["\\nvdash",8876],["\\nvDash",8877],["\\ngtr",8815],["\\ngeqslant",57359],["\\ngeqq",57358],["\\gneq",10888],["\\gneqq",8809],["\\gvertneqq",57357],["\\gnsim",8935],["\\gnapprox",10890],["\\nsucc",8833],["\\nsucceq",8929],["\\succnsim",8937],["\\succnapprox",10938],["\\ncong",8774],["\\nshortparallel",57351],["\\nparallel",8742],["\\nVDash",8879],["\\nsupseteqq",57368],["\\supsetneq",8843],["\\varsupsetneq",57371],["\\supsetneqq",10956],["\\varsupsetneqq",57369],["\\nVdash",8878],["\\precneqq",10933],["\\succneqq",10934],["\\nsubseteqq",57366],["\\leqslant",10877],["\\geqslant",10878],["\\gtrsim",8819],["\\approxeq",8778],["\\thickapprox",8776],["\\lessapprox",10885],["\\gtrapprox",10886],["\\precapprox",10935],["\\succapprox",10936],["\\thicksim",8764],["\\succsim",8831],["\\precsim",8830],["\\backsim",8765],["\\eqsim",8770],["\\backsimeq",8909],["\\lesssim",8818],["\\nleq",8816],["\\ngeq",8817],["\\smallsmile",8995],["\\smallfrown",8994],["\\leqq",8806],["\\eqslantless",10901],["\\lll",8920],["\\lessgtr",8822],["\\lesseqgtr",8922],["\\lesseqqgtr",10891],["\\risingdotseq",8787],["\\fallingdotseq",8786],["\\subseteqq",10949],["\\Subset",8912],["\\sqsubset",8847],["\\preccurlyeq",8828],["\\curlyeqprec",8926],["\\vDash",8872],["\\Vvdash",8874],["\\bumpeq",8783],["\\Bumpeq",8782],["\\geqq",8807],["\\eqslantgtr",10902],["\\ggg",8921],["\\gtrless",8823],["\\gtreqless",8923],["\\gtreqqless",10892],["\\supseteqq",10950],["\\Supset",8913],["\\sqsupset",8848],["\\succcurlyeq",8829],["\\curlyeqsucc",8927],["\\Vdash",8873],["\\shortmid",8739],["\\between",8812],["\\pitchfork",8916],["\\varpropto",8733],["\\backepsilon",8717],["\\llless",8920],["\\gggtr",8921],["\\doteqdot",8785],["\\Doteq",8785],["\\eqcirc",8790],["\\circeq",8791],["\\therefore",8756],["\\because",8757]],"mrel","ams"),Z([["+",43],["-",8722],["−",8722],["\\pm",177],["\\mp",8723],["*",8727],["\\times",215],["\\div",247],["\\divides",8739],["\\cdot",8901],["\\cap",8745],["\\cup",8746],["\\setminus",8726],["\\land",8743],["\\wedge",8743],["\\lor",8744],["\\vee",8744],["\\circ",8728],["\\bigcirc",9711],["\\bullet",8729],["\\oplus",8853],["\\ominus",8854],["\\otimes",8855],["\\odot",8857],["\\oslash",8856],["\\bigtriangleup",9651],["\\bigtriangledown",9661],["\\triangleleft",9667],["\\triangleright",9657],["\\And",38],["\\dagger",8224],["\\dag",8224],["\\ddag",8225],["\\ddagger",8225],["\\ast",8727],["\\star",8902],["\\bigstar",9733],["\\diamond",8900]],"mbin"),Z([["\\lhd",8882],["\\rhd",8883],["\\lessdot",8918],["\\gtrdot",8919],["\\ltimes",8905],["\\rtimes",8906],["\\leftthreetimes",8907],["\\rightthreetimes",8908],["\\intercal",8890],["\\dotplus",8724],["\\doublebarwedge",10846],["\\divideontimes",8903],["\\centerdot",8901],["\\smallsetminus",8726],["\\barwedge",8892],["\\veebar",8891],["\\nor",8891],["\\curlywedge",8911],["\\curlyvee",8910],["\\boxminus",8863],["\\boxplus",8862],["\\boxtimes",8864],["\\boxdot",8865],["\\circleddash",8861],["\\circledast",8859],["\\circledcirc",8858],["\\unlhd",8884],["\\unrhd",8885]],"mbin","ams"),Z([["\\surd",8730],["\\infty",8734],["\\prime",8242],["\\doubleprime",8243],["\\angle",8736],["`",8216],["\\$",36],["\\%",37],["\\_",95],["\\alpha",945],["\\beta",946],["\\gamma",947],["\\delta",948],["\\epsilon",1013],["\\varepsilon",949],["\\zeta",950],["\\eta",951],["\\theta",952],["\\vartheta",977],["\\iota",953],["\\kappa",954],["\\varkappa",1008,"mord","ams"],["\\lambda",955],["\\mu",956],["\\nu",957],["\\xi",958],["\\omicron",111],["\\pi",960],["\\varpi",982],["\\rho",961],["\\varrho",1009],["\\sigma",963],["\\varsigma",962],["\\tau",964],["\\phi",981],["\\varphi",966],["\\upsilon",965],["\\chi",967],["\\psi",968],["\\omega",969],["\\Gamma",915],["\\Delta",916],["\\Theta",920],["\\Lambda",923],["\\Xi",926],["\\Pi",928],["\\Sigma",931],["\\Upsilon",933],["\\Phi",934],["\\Psi",936],["\\Omega",937],["\\digamma",989,"mord","ams"],["\\emptyset",8709]]),Z([["=",61],["<",60],["\\lt",60],[">",62],["\\gt",62],["\\le",8804],["\\leq",8804],["\\ge",8805],["\\geq",8805],["\\ll",8810],["\\gg",8811],["\\coloneq",8788],["\\coloneqq",8788],["\\colonequals",8788],["\\measeq",8797],["\\eqdef",8798],["\\questeq",8799],[":",58],["\\cong",8773],["\\equiv",8801],["\\prec",8826],["\\preceq",10927],["\\succ",8827],["\\succeq",10928],["\\perp",8869],["\\propto",8733],["\\Colon",8759],["\\smile",8995],["\\frown",8994],["\\sim",8764],["\\doteq",8784],["\\bowtie",8904],["\\Join",8904],["\\asymp",8781],["\\sqsubseteq",8849],["\\sqsupseteq",8850],["\\approx",8776],["\\~",126],["\\leftrightarrow",8596],["\\Leftrightarrow",8660],["\\models",8872],["\\vdash",8866],["\\dashv",8867],["\\roundimplies",10608],["\\in",8712],["\\notin",8713],["\\ni",8715],["\\owns",8715],["\\subset",8834],["\\supset",8835],["\\subseteq",8838],["\\supseteq",8839],["\\differencedelta",8710],["\\mvert",8739],["\\parallel",8741],["\\simeq",8771]],"mrel"),Z([["\\lnot",172],["\\neg",172],["\\triangle",9651],["\\subsetneq",8842],["\\varsubsetneq",57370],["\\subsetneqq",10955],["\\varsubsetneqq",57367],["\\nsubset",8836],["\\nsupset",8837],["\\nsubseteq",8840],["\\nsupseteq",8841]],"mrel","ams"),Z([["\\wp",8472],["\\aleph",8501]]),Z([["\\blacktriangle",9650],["\\hslash",8463],["\\Finv",8498],["\\Game",8513],["\\eth",240],["\\mho",8487],["\\Bbbk",107],["\\yen",165],["\\square",9633],["\\Box",9633],["\\blacksquare",9632],["\\circledS",9416],["\\circledR",174],["\\triangledown",9661],["\\blacktriangledown",9660],["\\checkmark",10003],["\\diagup",9585],["\\measuredangle",8737],["\\sphericalangle",8738],["\\backprime",8245],["\\backdoubleprime",8246],["\\Diamond",9674],["\\lozenge",9674],["\\blacklozenge",10731],["\\varnothing",8709],["\\complement",8705],["\\maltese",10016],["\\beth",8502],["\\daleth",8504],["\\gimel",8503]],"mord","ams"),Z([["\\ ",160],["~",160]],"space"),ne(["!",",",":",";",">","enskip","enspace","quad","qquad"],"",{createAtom:e=>new gl(e)}),ne("space","",{createAtom:e=>new gl(e)}),Z([["\\colon",58],["\\cdotp",8901],["\\vdots",8942,"mord"],["\\ldotp",46],[",",44],[";",59]],"mpunct"),Z([["\\cdots",8943],["\\ddots",8945],["\\ldots",8230],["\\mathellipsis",8230]],"minner"),Z([["\\/",47],["|",8739,"mord"],["\\imath",305],["\\jmath",567],["\\degree",176],["'",8242],['"',8221]]);var Xh="<mo>⁡</mo>",Jh="<mo>⁢</mo>";function Qh(e){return e.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function ed(e,t){return e&&t.generateID?` extid="${e}"`:""}function td(e,t,n){var i,r,s,a,o,l,c,u,h,d,p;let f=!1;t=null!=t?t:e.atoms.length;let m="",g="",_=e.atoms[e.index];const y=null!=(r=null==(i=_.style)?void 0:i.variant)?r:"",v=null!=(a=null==(s=_.style)?void 0:s.variantStyle)?a:"";let b="";if(y||v){const t=O(_.value,null==(o=_.style)?void 0:o.variant,null==(l=_.style)?void 0:l.variantStyle);if(t!==_.value)return e.index+=1,m=`<mi${ed(_.id,n)}>${t}</mi>`,nd(m,e,n)||(e.mathML+=m,e.lastType="mi"),!0;b=null!=(c={upnormal:"normal",boldnormal:"bold",italicmain:"italic",bolditalicmain:"bold-italic","updouble-struck":"double-struck","double-struck":"double-struck",boldfraktur:"bold-fraktur",calligraphic:"script",upcalligraphic:"script",script:"script",boldscript:"bold-script",boldcalligraphic:"bold-script",fraktur:"fraktur","upsans-serif":"sans-serif","boldsans-serif":"bold-sans-serif","italicsans-serif":"sans-serif-italic","bolditalicsans-serif":"sans-serif-bold-italic",monospace:"monospace"}[v+y])?c:"",b=` mathvariant="${b}"`}const w={"\\exponentialE":"ⅇ","\\imaginaryI":"ⅈ","\\differentialD":"ⅆ","\\capitalDifferentialD":"ⅅ","\\alpha":"α","\\pi":"π","\\infty":"∞","\\forall":"∀","\\nexists":"∄","\\exists":"∃","\\hbar":"ℏ","\\cdotp":"⋅","\\ldots":"…","\\cdots":"⋯","\\ddots":"⋱","\\vdots":"⋮","\\ldotp":"."};if("!"===_.command)return e.index+=1,m="<mo>!</mo>",nd(m,e,n)||(e.mathML+=m,e.lastType="mo"),!0;if(w[_.command]){e.index+=1;let t=`<mi${ed(_.id,n)}${b}>${w[_.command]}</mi>`;return"mi"!==e.lastType&&"mn"!==e.lastType&&"mtext"!==e.lastType&&"fence"!==e.lastType||(t=Jh+t),nd(t,e,n)||(e.mathML+=t,e.lastType="mi"),!0}if("\\operatorname"===_.command)g=cd(_.body),e.index+=1;else if(y||v)for(;e.index<t&&("mord"===_.type||"macro"===_.type)&&!_.isDigit()&&y===(null!=(h=null==(u=_.style)?void 0:u.variant)?h:"")&&v===(null!=(p=null==(d=_.style)?void 0:d.variantStyle)?p:"");)g+=cd([_]),e.index+=1,_=e.atoms[e.index];else"mord"!==_.type&&"macro"!==_.type||_.isDigit()||(g+=cd([_]),e.index+=1);if(g.length>0){f=!0,m=`<mi${b}>${g}</mi>`;const t=e.lastType;m.endsWith(">f</mi>")||m.endsWith(">g</mi>")?(m+=Xh,e.lastType="applyfunction"):e.lastType=/^<mo>(.*)<\/mo>$/.test(m)?"mo":"mi",nd(m,e,n)||("mi"!==t&&"mn"!==t&&"mtext"!==t&&"fence"!==t||(m=Jh+m),e.mathML+=m)}return f}function nd(e,t,n){var i;let r=t.atoms[t.index-1];if(!r)return!1;if(!r.superscript&&!r.subscript){if("subsup"!==(null==(i=t.atoms[t.index])?void 0:i.type))return!1;r=t.atoms[t.index],t.index+=1}const s=t.lastType;t.lastType="";const a=od(r.superscript,n);t.lastType="";const o=od(r.subscript,n);if(t.lastType=s,!a&&!o)return!1;let l="";return a&&o?l=`<msubsup>${e}${o}${a}</msubsup>`:a?l=`<msup>${e}${a}</msup>`:o&&(l=`<msub>${e}${o}</msub>`),t.mathML+=l,t.lastType="",!0}function id(e,t,n){t=null!=t?t:e.atoms.length;const i=e.index;let r="";for(;e.index<t&&"text"===e.atoms[e.index].mode;)r+=e.atoms[e.index].value?e.atoms[e.index].value:" ",e.index+=1;return r.length>0&&(e.mathML+=`<mtext ${ed(e.atoms[i].id,n)}>${r}</mtext>`,e.lastType="mtext",!0)}function rd(e,t,n){t=null!=t?t:e.atoms.length;const i=e.index;let r="",s=function(e){let t=-1,n=e.index,i=!1,r=!1;for(;n<e.atoms.length&&!i&&!r;){const t=e.atoms[n];i=!t.isDigit(),r=!i&&void 0!==t.superscript,n++}return r&&(t=n-1),t}(e);for(s>=0&&s<t&&(t=s);e.index<t&&e.atoms[e.index].isDigit();)r+=e.atoms[e.index].asDigit(),e.index+=1;return!(r.length<=0)&&(r="<mn"+ed(e.atoms[i].id,n)+">"+r+"</mn>",s<0&&function(e){return e.index<e.atoms.length&&e.atoms[e.index].superscript&&"subsup"===e.atoms[e.index].type}(e)&&(s=e.index,e.index+=1),nd(r,e,n)||(e.mathML+=r,e.lastType="mn"),!0)}function sd(e,t,n){let i=!1;t=null!=t?t:e.atoms.length;let r="",s="";if(e.index<t&&"mopen"===e.atoms[e.index].type){let a=!1,o=0;const l=e.index;let c=-1,u=l+1;for(;u<t&&!a;)"mopen"===e.atoms[u].type?o+=1:"mclose"===e.atoms[u].type&&(o-=1),-1===o&&(a=!0,c=u),u+=1;a&&(r="<mrow>",r+=ld(e.atoms[l],n),r+=od(e.atoms,n,l+1,c),r+=ld(e.atoms[c],n),r+="</mrow>",e.index=c+1,"mi"!==e.lastType&&"mn"!==e.lastType&&"mfrac"!==e.lastType&&"fence"!==e.lastType||(e.mathML+=Jh),nd(r,e,n)&&(i=!0,e.lastType="",r=""),s="fence")}return r.length>0&&(i=!0,e.mathML+=r,e.lastType=s),i}function ad(e,t,n){let i=!1;t=null!=t?t:e.atoms.length;let r="",s="";const a=e.atoms[e.index];if(!a)return!1;const o={"\\ne":"≠","\\neq":"&neq;","\\pm":"±","\\times":"×","\\colon":":","\\vert":"|","\\Vert":"∥","\\mid":"∣","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lbrack":"[","\\rbrack":"]","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"};if(o[a.command]){e.index+=1;const t=`<mo${ed(a.id,n)}>${o[a.command]}</mo>`;return nd(t,e,n)||(e.mathML+=t,e.lastType="mo"),!0}if(e.index<t&&("mbin"===a.type||"mrel"===a.type))r+=ud(e.atoms[e.index],n),e.index+=1,s="mo";else if(e.index<t&&("mop"===a.type||"operator"===a.type||"extensible-symbol"===a.type)){if("over-under"===a.subsupPlacement&&(a.superscript||a.subscript)){const t=ld(a,n);return a.superscript&&a.subscript?(r+="<munderover>"+t,r+=od(a.subscript,n),r+=od(a.superscript,n),r+="</munderover>"):a.superscript?(r+="<mover>"+t,r+=od(a.superscript,n),r+="</mover>"):a.subscript&&(r+="<munder>"+t,r+=od(a.subscript,n),r+="</munder>"),e.mathML+=r,e.lastType="mo",e.index+=1,!0}{const t=e.atoms[e.index],i="\\operatorname"===t.value,a=i?'<mi class="MathML-Unit"'+ed(t.id,n)+">"+cd(t.value)+"</mi>":ld(t,n);r+=a,i||/^<mo>(.*)<\/mo>$/.test(a)?s=i?"mi":"mo":(r+=Xh,s="applyfunction")}"mi"!==e.lastType&&"mn"!==e.lastType||/^<mo>(.*)<\/mo>$/.test(r)||(r=Jh+r),e.index+=1}return r.length>0&&(i=!0,nd(r,e,n)||(e.mathML+=r,e.lastType=s)),i}function od(e,t,n,i){null!=t||(t={});const r={atoms:[],index:null!=n?n:0,mathML:"",lastType:""};if("number"==typeof e||"boolean"==typeof e)r.mathML=e.toString();else if("string"==typeof e)r.mathML=e;else if(e instanceof Ma)r.mathML=ud(e,t);else if(Array.isArray(e)){r.atoms=e;let n=0;for(i=i||(e?e.length:0);r.index<i;)if(id(r,i,t)||rd(r,i,t)||td(r,i,t)||ad(r,i,t)||sd(r,i,t))n+=1;else if(r.index<i){let e=ud(r.atoms[r.index],t);"mn"===r.lastType&&e.length>0&&"genfrac"===r.atoms[r.index].type&&(e="<mo>⁤</mo>"+e),"genfrac"===r.atoms[r.index].type?r.lastType="mfrac":r.lastType="",r.index+=1,nd(e,r,t)?n+=1:e.length>0&&(r.mathML+=e,n+=1)}n>1&&(r.mathML="<mrow>"+r.mathML+"</mrow>")}return r.mathML}function ld(e,t){let n="";const i=cd(e.value);return i&&(n="<mo"+ed(e.id,t)+">"+i+"</mo>"),n}function cd(e){if(!e)return"";if("string"==typeof e)return Qh(e);if(!Array.isArray(e)&&"string"==typeof e.body)return Qh(e.body);let t="";for(const n of e)"string"==typeof n.value&&(t+=n.value);return Qh(t)}function ud(e,t){var n,i,r,s,a,o,l,c,u,h,d,p,f,m,g,_,y,v,b,w,x,k;if("text"===e.mode)return`<mi${ed(e.id,t)}>${e.value}</mi>`;const S={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",longleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",longrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",longrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xleftrightarrows:"⇄",xRightleftharpoons:"⇌",longRightleftharpoons:"⇌",xLeftrightharpoons:"⇋",longLeftrightharpoons:"⇋"},E={"\\!":-3/18,"\\ ":6/18,"\\,":3/18,"\\:":4/18,"\\>":4/18,"\\;":5/18,"\\enspace":.5,"\\quad":1,"\\qquad":2,"\\enskip":.5};let T,C,L,A,D,M,R="",I="";const{command:P}=e;if("\\error"===e.command)return`<merror${ed(e.id,t)}>${od(e.body,t)}</merror>`;const O={"\\vert":"|","\\Vert":"∥","\\mid":"∣","\\lbrack":"[","\\rbrack":"]","\\{":"{","\\}":"}","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"⟨","\\rangle":"⟩","\\lfloor":"⌊","\\rfloor":"⌋","\\lceil":"⌈","\\rceil":"⌉"},F={"\\vec":"⃗","\\acute":"´","\\grave":"`","\\dot":"˙","\\ddot":"¨","\\tilde":"~","\\bar":"¯","\\breve":"˘","\\check":"ˇ","\\hat":"^"};switch(e.type){case"first":case"line":case"overlap":case"subsup":case"phantom":case"composition":case"rule":case"chem":break;case"group":case"root":R=od(e.body,t);break;case"array":if((e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(R+="<mrow>",e.leftDelim&&"."!==e.leftDelim&&(R+="<mo>"+(O[e.leftDelim]||e.leftDelim)+"</mo>")),R+="<mtable",e.colFormat){for(R+=' columnalign="',L=0;L<e.colFormat.length;L++)e.colFormat[L].align&&(R+={l:"left",c:"center",r:"right"}[e.colFormat[L].align]+" ");R+='"'}for(R+=">",C=0;C<e.array.length;C++){for(R+="<mtr>",T=0;T<e.array[C].length;T++)R+="<mtd>"+od(e.array[C][T],t)+"</mtd>";R+="</mtr>"}R+="</mtable>",(e.leftDelim&&"."!==e.leftDelim||e.rightDelim&&"."!==e.rightDelim)&&(e.rightDelim&&"."!==e.rightDelim&&(R+="<mo>"+(O[e.leftDelim]||e.rightDelim)+"</mo>"),R+="</mrow>");break;case"genfrac":(e.leftDelim||e.rightDelim)&&(R+="<mrow>"),e.leftDelim&&"."!==e.leftDelim&&(R+="<mo"+ed(e.id,t)+">"+(O[e.leftDelim]||e.leftDelim)+"</mo>"),e.hasBarLine?(R+="<mfrac>",R+=od(e.above,t)||"<mi> </mi>",R+=od(e.below,t)||"<mi> </mi>",R+="</mfrac>"):(R+="<mtable"+ed(e.id,t)+">",R+="<mtr>"+od(e.above,t)+"</mtr>",R+="<mtr>"+od(e.below,t)+"</mtr>",R+="</mtable>"),e.rightDelim&&"."!==e.rightDelim&&(R+="<mo"+ed(e.id,t)+">"+(O[e.rightDelim]||e.rightDelim)+"</mo>"),(e.leftDelim||e.rightDelim)&&(R+="</mrow>");break;case"surd":e.hasEmptyBranch("above")?(R+="<msqrt"+ed(e.id,t)+">",R+=od(e.body,t),R+="</msqrt>"):(R+="<mroot"+ed(e.id,t)+">",R+=od(e.body,t),R+=od(e.above,t),R+="</mroot>");break;case"leftright":const N=e,B=N.leftDelim;R="<mrow>",B&&"."!==B&&(R+=`<mo${ed(e.id,t)}>${null!=(n=O[B])?n:B}</mo>`),e.body&&(R+=od(e.body,t));const $=N.matchingRightDelim();$&&"."!==$&&(R+=`<mo${ed(e.id,t)}>${null!=(i=O[$])?i:$}</mo>`),R+="</mrow>";break;case"sizeddelim":case"delim":R+=`<mo${ed(e.id,t)}>${O[e.value]||e.value}</mo>`;break;case"accent":R+='<mover accent="true"'+ed(e.id,t)+">",R+=od(e.body,t),R+="<mo>"+(F[P]||e.accent)+"</mo>",R+="</mover>";break;case"overunder":D=e.above,A=e.below,(e.svgAbove||D)&&(e.svgBelow||A)?M=e.body:D&&D.length>0?(M=e.body,(null==(s=null==(r=e.body)?void 0:r[0])?void 0:s.below)?(A=e.body[0].below,M=e.body[0].body):"first"===(null==(o=null==(a=e.body)?void 0:a[0])?void 0:o.type)&&(null==(c=null==(l=e.body)?void 0:l[1])?void 0:c.below)&&(A=e.body[1].below,M=e.body[1].body)):A&&A.length>0&&(M=e.body,(null==(h=null==(u=e.body)?void 0:u[0])?void 0:h.above)?(D=e.body[0].above,M=e.body[0].body):"first"===(null==(p=null==(d=e.body)?void 0:d[0])?void 0:p.type)&&(null==(m=null==(f=e.body)?void 0:f[1])?void 0:m.above)&&(D=e.body[1].overscript,M=e.body[1].body)),(e.svgAbove||D)&&(e.svgBelow||A)?(R+=`<munderover ${ed(e.id,t)}>`,R+=null!=(g=S[e.svgBody])?g:od(M,t),R+=null!=(_=S[e.svgBelow])?_:od(A,t),R+=null!=(y=S[e.svgAbove])?y:od(D,t),R+="</munderover>"):e.svgAbove||D?(R+=`<mover ${ed(e.id,t)}>`+(null!=(v=S[e.svgBody])?v:od(M,t)),R+=null!=(b=S[e.svgAbove])?b:od(D,t),R+="</mover>"):(e.svgBelow||A)&&(R+=`<munder ${ed(e.id,t)}>`+(null!=(w=S[e.svgBody])?w:od(M,t)),R+=null!=(x=S[e.svgBelow])?x:od(A,t),R+="</munder>");break;case"placeholder":R+="?";break;case"mord":{R="string"==typeof e.value?e.value:P,"\\char"===P?R="&#x"+("000000"+e.args[0].number.toString(16)).slice(-4)+";":R.length>0&&R.startsWith("\\")&&("string"==typeof e.value&&e.value.charCodeAt(0)>255?R="&#x"+("000000"+e.value.charCodeAt(0).toString(16)).slice(-4)+";":"string"==typeof e.value?R=e.value.charAt(0):(console.error("Did not expect this"),R=""));const n=/\d/.test(R)?"mn":"mi";R=`<${n}${ed(e.id,t)}>${Qh(R)}</${n}>`;break}case"mbin":case"mrel":case"minner":R=ld(e,t);break;case"mpunct":R='<mo separator="true"'+ed(e.id,t)+">"+P+"</mo>";break;case"mop":case"operator":case"extensible-symbol":""!==e.body&&(R="<mo"+ed(e.id,t)+">",R+="\\operatorname"===P?e.body:P||e.body,R+="</mo>");break;case"box":R='<menclose notation="box"',e.backgroundcolor&&(R+=' mathbackground="'+e.backgroundcolor+'"'),R+=ed(e.id,t)+">"+od(e.body,t)+"</menclose>";break;case"spacing":R+='<mspace width="'+(null!=(k=E[P])?k:0)+'em"/>';break;case"enclose":R='<menclose notation="';for(const t in e.notation)Object.prototype.hasOwnProperty.call(e.notation,t)&&e.notation[t]&&(R+=I+t,I=" ");R+=ed(e.id,t)+'">'+od(e.body,t)+"</menclose>";break;case"prompt":R='<menclose notation="roundexbox""">'+od(e.body,t)+"</menclose>";break;case"space":R+=" ";break;case"mopen":case"mclose":R+=ld(e,t);break;case"macro":{const n=e.command+cd(e.macroArgs);n&&(R+=`<mo ${ed(e.id,t)}>${n}</mo>`)}break;case"latexgroup":case"tooltip":R+=od(e.body,t);break;case"latex":R+="<mtext"+ed(e.id,t)+">"+e.value+"</mtext>";break;case"text":R+=`<mtext ${ed(e.id,t)}x>${e.value}</mtext>`;break;default:if("\\displaystyle"===e.command)return`<mrow ${ed(e.id,t)} displaystyle="true">${od(e.body,t)}</mrow>`;if("\\textstyle"===e.command)return`<mrow ${ed(e.id,t)} displaystyle="false">${od(e.body,t)}</mrow>`;console.info("Unexpected element in conversion to MathML:",e)}return R}var hd={"\\alpha":"alpha ","\\mu":"mew ","\\sigma":"sigma ","\\pi":"pie ","\\imaginaryI":"imaginary eye ","\\imaginaryJ":"imaginary jay ","\\sum":"Summation ","\\prod":"Product ","+":"plus ","-":"minus ",";":'<break time="150ms"/> semi-colon <break time="150ms"/>',",":'<break time="150ms"/> comma <break time="150ms"/>',"|":'<break time="150ms"/>Vertical bar<break time="150ms"/>',"(":'<break time="150ms"/>Open paren. <break time="150ms"/>',")":'<break time="150ms"/> Close paren. <break time="150ms"/>',"=":"equals ","<":"is less than ","\\lt":"is less than ","<=":"is less than or equal to ","\\le":"is less than or equal to ","\\gt":"is greater than ",">":"is greater than ","\\pm":"plus or minus","\\mp":"minus or plus","\\ge":"is greater than or equal to ","\\geq":"is greater than or equal to ","\\leq":"is less than or equal to ","\\ne":"is not equal to ","\\neq":"is not equal to ","!":"factorial ","\\sin":"sine ","\\cos":"cosine ","":"","−":"minus ",":":'<break time="150ms"/> such that <break time="200ms"/> ',"\\colon":'<break time="150ms"/> such that <break time="200ms"/> ',"\\hbar":"etch bar ","\\iff":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\Longleftrightarrow":'<break time="200ms"/>if, and only if, <break time="200ms"/>',"\\land":"and ","\\lor":"or ","\\neg":"not ","\\div":"divided by ","\\forall":"for all ","\\exists":"there exists ","\\nexists":"there does not exists ","\\in":"element of ","\\N":'the set <break time="150ms"/><say-as interpret-as="character">n</say-as>',"\\C":'the set <break time="150ms"/><say-as interpret-as="character">c</say-as>',"\\Z":'the set <break time="150ms"/><say-as interpret-as="character">z</say-as>',"\\Q":'the set <break time="150ms"/><say-as interpret-as="character">q</say-as>',"\\infty":"infinity ","\\nabla":"nabla ","\\partial":"partial derivative of ","\\cdot":"times ","\\cdots":"dot dot dot ","\\Rightarrow":"implies ","\\lparen":'<break time="150ms"/>open paren<break time="150ms"/>',"\\rparen":'<break time="150ms"/>close paren<break time="150ms"/>',"\\lbrace":'<break time="150ms"/>open brace<break time="150ms"/>',"\\{":'<break time="150ms"/>open brace<break time="150ms"/>',"\\rbrace":'<break time="150ms"/>close brace<break time="150ms"/>',"\\}":'<break time="150ms"/>close brace<break time="150ms"/>',"\\langle":'<break time="150ms"/>left angle bracket<break time="150ms"/>',"\\rangle":'<break time="150ms"/>right angle bracket<break time="150ms"/>',"\\lfloor":'<break time="150ms"/>open floor<break time="150ms"/>',"\\rfloor":'<break time="150ms"/>close floor<break time="150ms"/>',"\\lceil":'<break time="150ms"/>open ceiling<break time="150ms"/>',"\\rceil":'<break time="150ms"/>close ceiling<break time="150ms"/>',"\\vert":'<break time="150ms"/>vertical bar<break time="150ms"/>',"\\mvert":'<break time="150ms"/>divides<break time="150ms"/>',"\\lvert":'<break time="150ms"/>left vertical bar<break time="150ms"/>',"\\rvert":'<break time="150ms"/>right vertical bar<break time="150ms"/>',"\\lbrack":'<break time="150ms"/> open square bracket <break time="150ms"/>',"\\rbrack":'<break time="150ms"/> close square bracket <break time="150ms"/>',mm:"millimeters",cm:"centimeters",km:"kilometers",kg:"kilograms"},dd={array:"array",matrix:"matrix",pmatrix:"parenthesis matrix",bmatrix:"square brackets matrix",Bmatrix:"braces matrix",vmatrix:"bars matrix",Vmatrix:"double bars matrix","matrix*":"matrix",smallmatrix:"small matrix"};function pd(e){let t=0;if(f(e))for(const n of e)"first"!==n.type&&(t+=1);return 1===t}function fd(e){let t="";if(f(e))for(const n of e)"first"!==n.type&&"string"==typeof n.value&&(t+=n.value);return t}function md(e,t){var n,i,r,s,a;function o(e){return"<emphasis>"+e+"</emphasis>"}if(!t)return"";let l="";if(f(t)){let i=!1,r=!1;for(let s=0;s<t.length;s++)"first"!==t[s].type&&("text"!==t[s].mode&&(r=!1),s<t.length-2&&"mopen"===t[s].type&&"mclose"===t[s+2].type&&"mord"===t[s+1].type?(l+=" of ",l+=o(md(e,t[s+1])),s+=2):"text"===t[s].mode?r?l+=null!=(n=t[s].value)?n:" ":(r=!0,l+=md("text",t[s])):t[s].isDigit()?i?l+=t[s].asDigit():(i=!0,l+=md(e,t[s])):(i=!1,l+=md(e,t[s])))}else if("text"===t.mode)t.id&&"math"===e&&(l+='<mark name="'+t.id.toString()+'"/>'),l+=t.value;else{t.id&&"math"===e&&(l+='<mark name="'+t.id.toString()+'"/>');let n="",h="",d="",p=!1;const{command:m}=t;switch(m){case"\\vec":return"vector "+md(e,t.body);case"\\acute":return md(e,t.body)+" acute";case"\\grave":return md(e,t.body)+" grave";case"\\dot":return"dot over"+md(e,t.body);case"\\ddot":return"double dot over"+md(e,t.body);case"\\mathring":return"ring over"+md(e,t.body);case"\\tilde":case"\\widetilde":return"tilde over"+md(e,t.body);case"\\bar":return md(e,t.body)+" bar";case"\\breve":return md(e,t.body)+" breve";case"\\check":case"\\widecheck":return"check over "+md(e,t.body);case"\\hat":case"\\widehat":return"hat over"+md(e,t.body);case"\\overarc":case"\\overparen":case"\\wideparen":return"arc over "+md(e,t.body);case"\\underarc":case"\\underparen":return"arc under "+md(e,t.body)}switch(t.type){case"prompt":l+=' <break time="300ms"/> '+(t.body.length>1?'start input . <break time="500ms"/> '+md(e,t.body)+'. <break time="500ms"/> end input':"blank")+'. <break time="700ms"/>'+(null!=(i=t.correctness)?i:"")+' . <break time="700ms"/> ';break;case"array":const f=t.array,g=t.environmentName;if(Object.keys(dd).includes(g)){l+=` begin ${dd[g]} `;for(let e=0;e<f.length;e++){e>0&&(l+=","),l+=` row ${e+1} `;for(let t=0;t<f[e].length;t++)t>0&&(l+=","),l+=` column ${t+1}: `,l+=md("math",f[e][t])}l+=` end ${dd[g]} `}break;case"group":"\\ne"===m?l+=" not equal ":"\\not"===m?(l+=" not ",l+=md("math",t.body)):l+=md("math",t.body);break;case"root":l+=md("math",t.body);break;case"genfrac":if(n=md("math",t.above),h=md("math",t.below),pd(t.above)&&pd(t.below)){const e={"1/2":" half ","1/3":" one third ","2/3":" two third","1/4":" one quarter ","3/4":" three quarter ","1/5":" one fifth ","2/5":" two fifths ","3/5":" three fifths ","4/5":" four fifths ","1/6":" one sixth ","5/6":" five sixths ","1/8":" one eight ","3/8":" three eights ","5/8":" five eights ","7/8":" seven eights ","1/9":" one ninth ","2/9":" two ninths ","4/9":" four ninths ","5/9":" five ninths ","7/9":" seven ninths ","8/9":" eight ninths "}[fd(t.above)+"/"+fd(t.below)];e?l=e:l+=n+" over "+h}else l+=' the fraction <break time="150ms"/>'+n+' over <break time="150ms"/>'+h+'.<break time="150ms"/> End fraction.<break time="150ms"/>';break;case"surd":if(d=md("math",t.body),t.hasEmptyBranch("above"))l+=pd(t.body)?" the square root of "+d+" , ":' the square root of <break time="200ms"/>'+d+'. <break time="200ms"/> End square root';else{let e=md("math",t.above);e=e.trim();const n=e.replace(/<mark([^/]*)\/>/g,"");l+="3"===n?' the cube root of <break time="200ms"/>'+d+'. <break time="200ms"/> End cube root':"n"===n?' the nth root of <break time="200ms"/>'+d+'. <break time="200ms"/> End root':' the root with index: <break time="200ms"/>'+e+', of <break time="200ms"/>'+d+'. <break time="200ms"/> End root'}break;case"leftright":{const e=t;l+=null!=(r=e.leftDelim?hd[e.leftDelim]:void 0)?r:e.leftDelim,l+=md("math",t.body),l+=null!=(s=e.rightDelim?hd[e.rightDelim]:void 0)?s:e.rightDelim}break;case"rule":case"overunder":case"overlap":case"space":case"spacing":break;case"macro":const _=m.replace(/^\\/g,""),y=ie()[_];y&&((null==y?void 0:y.expand)?l+=md("math",t.body):l+=`${_} `);break;case"placeholder":l+="placeholder ";break;case"delim":case"sizeddelim":case"mord":case"minner":case"mbin":case"mrel":case"mpunct":case"mopen":case"mclose":{if("\\mathbin"===m||"\\mathrel"===m||"\\mathopen"===m||"\\mathclose"===m||"\\mathpunct"===m||"\\mathord"===m||"\\mathinner"===m){l=md(e,t.body);break}let n=t.isDigit()?t.asDigit():t.value,i=t.command;if("delim"!==t.type&&"sizeddelim"!==t.type||(i=t.value,n=i),"text"===e)l+=n;else{if("mbin"===t.type&&(l+='<break time="150ms"/>'),n){const e=hd[n]||(i?hd[i.trim()]:"");if(e)l+=" "+e;else{const e=i?function(e){let t="";return e.startsWith("\\")&&(t=" "+e.replace("\\","")+" "),t}(i.trim()):"";l+=e||(u=n,window.MathfieldElement.textToSpeechMarkup?/[a-z]/.test(u)?` <say-as interpret-as="character">${u}</say-as>`:/[A-Z]/.test(u)?`capital <say-as interpret-as="character">${u.toLowerCase()}</say-as>`:u:/[a-z]/.test(u)?" '"+u.toUpperCase()+"'":/[A-Z]/.test(u)?" 'capital "+u.toUpperCase()+"'":u)}}else l+=md("math",t.body);"mbin"===t.type&&(l+='<break time="150ms"/>')}break}case"mop":case"operator":case"extensible-symbol":if(""!==t.value){const e=t.command;if("\\sum"===e)if(t.hasEmptyBranch("superscript")||t.hasEmptyBranch("subscript"))if(t.hasEmptyBranch("subscript"))l+=" the summation of";else{let e=md("math",t.subscript);e=e.trim(),l+=' the summation from <break time="200ms"/>'+e+'<break time="200ms"/> of <break time="150ms"/>',p=!0}else{let e=md("math",t.superscript);e=e.trim();let n=md("math",t.subscript);n=n.trim(),l+=' the summation from <break time="200ms"/>'+n+'<break time="200ms"/> to <break time="200ms"/>'+e+'<break time="200ms"/> of <break time="150ms"/>',p=!0}else if("\\prod"===e)if(t.hasEmptyBranch("superscript")||t.hasEmptyBranch("subscript"))if(t.hasEmptyBranch("subscript"))l+=" the product of ";else{let e=md("math",t.subscript);e=e.trim(),l+=' the product from <break time="200ms"/>'+e+'<break time="200ms"/> of <break time="150ms"/>',p=!0}else{let e=md("math",t.superscript);e=e.trim();let n=md("math",t.subscript);n=n.trim(),l+=' the product from <break time="200ms"/>'+n+'<break time="200ms"/> to <break time="200ms"/>'+e+'<break time="200ms"/> of <break time="150ms"/>',p=!0}else if("\\int"===e)if(t.hasEmptyBranch("superscript")||t.hasEmptyBranch("subscript"))l+=' the integral of <break time="200ms"/> ';else{let e=md("math",t.superscript);e=e.trim();let n=md("math",t.subscript);n=n.trim(),l+=' the integral from <break time="200ms"/>'+o(n)+'<break time="200ms"/> to <break time="200ms"/>'+o(e)+' <break time="200ms"/> of ',p=!0}else if("string"==typeof t.value){const e=null!=(a=hd[t.value])?a:t.command?hd[t.command]:void 0;l+=e||" "+t.value}else t.command&&("\\mathop"===t.command?l+=md("math",t.body):"\\operatorname"===t.command?l+=(c=t.body)?c.map((e=>e.value)).join(""):"":l+=t.command.startsWith("\\")?" "+t.command.slice(1):" "+t.command)}break;case"enclose":d=md("math",t.body),l+=" crossed out "+d+". End crossed out."}if(!p&&!t.hasEmptyBranch("superscript")){let n=md(e,t.superscript);n=n.trim();const i=n.replace(/<[^>]*>/g,"");if(pd(t.superscript)){if("math"===e){const e=function(e){if(f(e))for(const t of e)if("first"!==t.type&&t.id)return t.id.toString();return""}(t.superscript);e&&(l+='<mark name="'+e+'"/>')}"′"===i?l+=" prime ":"2"===i?l+=" squared ":"3"===i?l+=" cubed ":Number.isNaN(Number.parseInt(i))?l+=" to the "+n+"; ":l+=' to the <say-as interpret-as="ordinal">'+i+"</say-as> power; "}else Number.isNaN(Number.parseInt(i))?l+=" raised to the "+n+"; ":l+=' raised to the <say-as interpret-as="ordinal">'+i+"</say-as> power; "}if(!p&&!t.hasEmptyBranch("subscript")){let e=md("math",t.subscript);e=e.trim(),l+=pd(t.subscript)?" sub "+e:" subscript "+e+". End subscript. "}}var c,u;return l}function gd(e){var t,n;if("sre"===window.MathfieldElement.textToSpeechRules&&("sre"in window||"SRE"in window)){const i=od(e);if(i){window.MathfieldElement.textToSpeechMarkup&&(window.MathfieldElement.textToSpeechRulesOptions=null!=(t=window.MathfieldElement.textToSpeechRulesOptions)?t:{},window.MathfieldElement.textToSpeechRulesOptions=h(u({},window.MathfieldElement.textToSpeechRulesOptions),{markup:window.MathfieldElement.textToSpeechMarkup}),"ssml"===window.MathfieldElement.textToSpeechRulesOptions.markup&&(window.MathfieldElement.textToSpeechRulesOptions=h(u({},window.MathfieldElement.textToSpeechRulesOptions),{markup:"ssml_step"})),window.MathfieldElement.textToSpeechRulesOptions=h(u({},window.MathfieldElement.textToSpeechRulesOptions),{rate:window.MathfieldElement.speechEngineRate}));const e=null!=(n=window.SRE)?n:window.sre.System.getInstance();window.MathfieldElement.textToSpeechRulesOptions&&e.setupEngine(window.MathfieldElement.textToSpeechRulesOptions);let r="";try{r=e.toSpeech(i)}catch(e){console.error("MathLive 0.98.5: `SRE.toSpeech()` runtime error",e)}return r}return""}let i=md("math",e);if("ssml"===window.MathfieldElement.textToSpeechMarkup){let e="";window.MathfieldElement.speechEngineRate&&(e='<prosody rate="'+window.MathfieldElement.speechEngineRate+'">'),i='<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><amazon:auto-breaths>'+e+"<p><s>"+i+"</s></p>"+(e?"</prosody>":"")+"</amazon:auto-breaths></speak>"}else i="mac"===window.MathfieldElement.textToSpeechMarkup&&"macos"===_()?i.replace(/<mark([^/]*)\/>/g,"").replace(/<emphasis>/g,"[[emph+]]").replace(/<\/emphasis>/g,"").replace(/<break time="(\d*)ms"\/>/g,"[[slc $1]]").replace(/<say-as[^>]*>/g,"").replace(/<\/say-as>/g,""):i.replace(/<[^>]*>/g,"").replace(/\s{2,}/g," ");return i}var _d={"\\ne":"≠","\\neq":"≠","−":"-","-":"-","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\delta":"delta","\\epsilon":"epsilon","\\varepsilon":"varepsilon","\\zeta":"zeta","\\eta":"eta","\\theta":"theta","\\vartheta":"vartheta","\\iota":"iota","\\kappa":"kappa","\\lambda":"lambda","\\mu":"mu","\\nu":"nu","\\xi":"xi","\\pi":"pi","\\rho":"rho","\\sigma":"sigma","\\tau":"tau","\\upsilon":"upsilon","\\phi":"phi","\\varphi":"varphi","\\chi":"chi","\\psi":"psi","\\omega":"omega","\\Gamma":"Gamma","\\Delta":"Delta","\\Theta":"Theta","\\Lambda":"Lambda","\\Xi":"Xi","\\Pi":"Pi","\\Sigma":"Sigma","\\Phi":"Phi","\\Psi":"Psi","\\Omega":"Omega","\\exponentialE":"e","\\imaginaryI":"i","\\imaginaryJ":"j","\\!":" ","\\,":" ","\\:":" ","\\>":" ","\\;":" ","\\enskip":" ","\\enspace":" ","\\qquad":" ","\\quad":" ","\\infty":"oo"},yd={"\\pm":"+-","\\colon":":","\\vert":"|","\\Vert":"||","\\mid":"|","\\lbrack":"[","\\rbrack":"]","\\lbrace":"{","\\rbrace":"}","\\lparen":"(","\\rparen":")","\\langle":"(:","\\rangle":":)","\\sum":" sum ","\\prod":" prod ","\\bigcap":" nnn ","\\bigcup":" uuu ","\\int":" int ","\\oint":" oint ","\\ge":">=","\\le":"<=","\\ne":"!=","\\neq":"!=","\\lt":"<","\\gt":">","\\gets":"<-","\\to":"->","\\land":" and ","\\lor":" or ","\\lnot":" not ","\\forall":" AA ","\\exists":" EE ","\\in":" in ","\\notin":" !in ","\\mapsto":"|->","\\implies":"=>","\\iff":"<=>","\\cdot":"*","\\ast":"**","\\star":"***","\\times":"xx","\\div":"-:","\\ltimes":"|><","\\rtimes":"><|","\\bowtie":"|><|","\\circ":"@"};function vd(e){var t,n,i,r,s,a,o,l,c,u,h,d,p;if(!e)return"";if(f(e)){if(0===e.length)return"";if("latex"===e[0].mode)return e.map(vd).join("");if("text"===e[0].mode){let n=0,i="";for(;"text"===(null==(t=e[n])?void 0:t.mode);)i+=e[n].body?vd(e[n].body):e[n].value,n++;return`"${i}" ${vd(e.slice(n))}`}let n=0;const i=[];for(;e[n]&&"math"===e[n].mode;){let t="";for(;e[n]&&"mord"===e[n].type&&/\d/.test(e[n].value);)t+=e[n++].value;t?i.push(t):i.push(vd(e[n++]))}return i.push(vd(e.slice(n))),function(e){let t="";for(const n of e){const e=t[t.length-1];void 0!==e&&/\d/.test(e)&&/^\d/.test(n)&&(t+=" "),t+=n}return t}(i)}if("text"===e.mode)return`"${e.value}"`;let m="";const{command:g}=e;let _;if("\\placeholder"===g)return`(${vd(e.body)})`;switch(e.type){case"accent":const t={"\\vec":"vec","\\dot":"dot","\\ddot":"ddot","\\bar":"bar","\\hat":"hat","\\acute":"acute;","\\grave":"grave","\\tilde":"tilde","\\breve":"breave","\\check":"check"}[g];m=`${null!=t?t:""} ${vd(e.body)} `;break;case"first":return"";case"latexgroup":return e.body.map((e=>e.value)).join("");case"group":case"root":m=null!=(n=_d[g])?n:vd(e.body);break;case"genfrac":{const t=e;(t.leftDelim||t.rightDelim)&&(m="."!==t.leftDelim&&t.leftDelim?t.leftDelim:"{:"),t.hasBarLine?(m+="(",m+=vd(t.above),m+=")/(",m+=vd(t.below),m+=")"):(m+="("+vd(t.above)+"),",m+="("+vd(t.below)+")"),(t.leftDelim||t.rightDelim)&&(m+="."!==t.rightDelim&&t.rightDelim?t.rightDelim:"{:")}break;case"surd":m+=e.hasEmptyBranch("above")?"sqrt("+vd(e.body)+")":"root("+vd(e.above)+")("+vd(e.body)+")";break;case"latex":case"sizeddelim":case"delim":case"mopen":case"mclose":m=e.value;break;case"leftright":{const t=e,n=t.leftDelim;m+="."!==n&&n?n:"{:",m+=vd(t.body);const i=t.matchingRightDelim();m+="."!==i&&i?i:":}"}break;case"overlap":case"overunder":case"box":break;case"mord":m=null!=(r=null!=(i=_d[g])?i:g)?r:"string"==typeof e.value?e.value:"",m.startsWith("\\")&&(m+=" "),_=g?g.match(/{?\\char"([\dabcdefABCDEF]+)}?/):null,_?m=String.fromCodePoint(Number.parseInt("0x"+_[1])):m.length>0&&m.startsWith("\\")&&(m="string"==typeof e.value?e.value.charAt(0):e.command),m=function(e,t){if(!t)return e;let n=e;"double-struck"===t.variant&&(n=`bbb "${n}"`);"script"===t.variant&&(n=`cc "${n}"`);"fraktur"===t.variant&&(n=`fr "${n}"`);"sans-serif"===t.variant&&(n=`sf "${n}"`);"monospace"===t.variant&&(n=`tt "${n}"`);"bold"===t.variantStyle&&(n=`bb "${n}"`);return t.color?`color({${t.color}})(${n})`:n}(m,e.style);break;case"mbin":case"mrel":case"minner":m=null!=(a=null!=(s=_d[g])?s:yd[g])?a:e.value;break;case"mpunct":m=null!=(o=yd[g])?o:g;break;case"mop":case"operator":case"extensible-symbol":""!==e.value&&(m=yd[g]?yd[g]:"\\operatorname"===g?vd(e.body):null!=(l=e.value)?l:g,m+=" ");break;case"array":const f=e.array,y=e.environmentName,v=null!=(c={bmatrix:["[","]"],"bmatrix*":["[","]"]}[y])?c:["(",")"],b=[];for(const e of f){const t=[];for(const n of e)t.push(v[0]+vd(n)+v[1]);b.push(t.join(","))}const w=null!=(u={bmatrix:["[","]"],"bmatrix*":["[","]"],cases:["{",":}"]}[y])?u:["(",")"];m=w[0]+b.join(",")+w[1];break;case"spacing":m=null!=(h=_d[g])?h:" ";break;case"enclose":m="("+vd(e.body)+")";break;case"space":m=" ";break;case"subsup":m="";break;case"macro":m=null!=(p=null!=(d=_d[g])?d:yd[g])?p:vd(e.body)}if(!e.hasEmptyBranch("subscript")){m+="_";const t=vd(e.subscript);m+=1!==t.length?`(${t})`:t}if(!e.hasEmptyBranch("superscript")){m+="^";const t=vd(e.superscript);m+=1!==t.length?`(${t})`:t}return m}function bd(e,t){var n,i;null!=t||(t={}),t.mathstyle=null!=(n=t.mathstyle)?n:"displaystyle";const r=new Ca({from:h(u({},Ta()),{renderPlaceholder:()=>new ca(160,{maxFontSize:1}),letterShapeStyle:null!=(i=null==t?void 0:t.letterShapeStyle)?i:"tex"}),mathstyle:t.mathstyle}),s=new Ma({mode:"math",type:"root",body:Qo(e,{context:r,parseMode:"math",mathstyle:t.mathstyle})}).render(r);if(!s)return"";ha(xl(s,r));return da(s,{classes:"ML__latex"}).toMarkup()}function wd(e){if("string"==typeof e){const t=function(e){if(!e)return;if("#"!==e[0])return;let t;(e=e.slice(1)).length<=4?(t={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)},4===e.length&&(t.a=parseInt(e[3]+e[3],16)/255)):(t={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16)},8===e.length&&(t.a=parseInt(e[6]+e[7],16)/255));t&&void 0===t.a&&(t.a=1);return t}(e);if(!t)throw new Error(`Invalid color: ${e}`);return t}return"C"in e?Cd(kd(e)):"a"in e?Cd(e):e}function xd(e){return e<0?0:e>255?255:Math.round(e)}function kd(e){const[t,n,i]=[e.L,e.C,e.H],r=i*Math.PI/180,s={L:t,a:n*Math.cos(r),b:n*Math.sin(r)};return void 0!==e.alpha&&(s.alpha=e.alpha),s}function Sd(e){const[t,n,i]=[e.L,e.a,e.b],r=Math.pow(.9999999984505198*t+.39633779217376786*n+.2158037580607588*i,3),s=Math.pow(1.00000000888176*t-.10556134232365635*n-.0638541747717059*i,3),a=Math.pow(1.000000054672411*t-.0894841820949657*n-1.2914855378640917*i,3),o=-1.2684380040921763*r+2.6097574006633715*s-.3413193963102197*a,l=-.004196086541837188*r-.7034186144594493*s+1.7076147009309444*a,c=e=>{const t=Math.abs(e);return t<=.0031308?12.92*e:(Math.sign(e)||1)*(1.055*Math.pow(t,1/2.4)-.055)};return[c(4.076741661347994*r-3.307711590408193*s+.230969928729428*a),c(o),c(l)]}function Ed(e){const[t,n,i]=e;return t>=0&&t<=1&&n>=0&&n<=1&&i>=0&&i<=1}function Td(e,t){let[n,i,r]=e;return n=xd(255*n),i=xd(255*i),r=xd(255*r),void 0!==t?{r:n,g:i,b:r,alpha:t}:{r:n,g:i,b:r}}function Cd(e){let[t,n,i]=Sd(e);if(Ed([t,n,i]))return Td([t,n,i],e.alpha);const r=function(e){const[t,n,i]=[e.L,e.a,e.b],r={L:t,C:Math.sqrt(n*n+i*i),H:180*Math.atan2(i,n)/Math.PI};return void 0!==e.alpha&&(r.alpha=e.alpha),r}(e);if(r.C=0,[t,n,i]=Sd(kd(r)),!Ed([t,n,i]))return Td([t,n,i],e.alpha);let s=0,a=e.L,o=(s+a)/2;r.C=o;const l=.36/Math.pow(2,12);for(;a-s>l;)o=(s+a)/2,r.C=o,[t,n,i]=Sd(kd(r)),Ed([t,n,i])?s=o:a=o;return Td([t,n,i],e.alpha)}function Ld(e,t){const n=wd(e),i=wd(t);function r(e){return e>=.022?e:e+(.022-e)**1.414}function s(e){return(e<0?-1:1)*Math.pow(Math.abs(e),2.4)}const a=r(.2126729*s(i.r/255)+.7151522*s(i.g/255)+.072175*s(i.b/255)),o=r(.2126729*s(n.r/255)+.7151522*s(n.g/255)+.072175*s(n.b/255));let l,c,u;return Math.abs(o-a)<5e-4?c=0:o>a?(l=o**.56-a**.57,c=1.14*l):(l=o**.65-a**.62,c=1.14*l),u=Math.abs(c)<.1?0:c>0?c-.027:c+.027,100*u}function Ad(e,t,n){null!=n||(n="#fff"),null!=t||(t="#000");const i=Ld(e,n),r=Ld(e,t);return Math.abs(i)>Math.abs(r)?n:t}function Dd(e){const t=wd(e);let n=((1<<24)+(xd(t.r)<<16)+(xd(t.g)<<8)+xd(t.b)).toString(16).slice(1);return void 0!==t.alpha&&t.alpha<1&&(n+=("00"+Math.round(255*t.alpha).toString(16)).slice(-2)),n[0]===n[1]&&n[2]===n[3]&&n[4]===n[5]&&n[6]===n[7]&&(n=n[0]+n[2]+n[4]+(void 0!==t.alpha&&t.alpha<1?n[6]:"")),"#"+n}function Md(e){const t=Rd(e);let n="";for(const e of t){if("string"!=typeof e.value)return"";n+=e.value}return n}function Rd(e){const t=e.model.selection.ranges;return 1!==t.length?[]:e.model.getAtoms(t[0])}function Id(e){return[Vd(e,"double-struck","mathbb","tooltip.blackboard"),Vd(e,"fraktur","mathfrak","tooltip.fraktur"),Vd(e,"calligraphic","mathcal","tooltip.caligraphic"),qd(e,"up","mathrm","tooltip.roman-upright"),qd(e,"bold","mathbf","tooltip.bold"),qd(e,"italic","mathit","tooltip.italic")]}function Pd(e){return[{label:()=>bd(`\\vec{${Md(e)}}`),visible:()=>1===Md(e).length,onMenuSelect:()=>e.insert("\\vec{#@}",{selectionMode:"item"})},{label:()=>bd(`\\overrightarrow{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\overrightarrow{#@}",{selectionMode:"item"})},{label:()=>bd(`\\overleftarrow{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\overleftarrow{#@}",{selectionMode:"item"})},{label:()=>bd(`\\dot{${Md(e)}}`),visible:()=>1===Md(e).length,onMenuSelect:()=>e.insert("\\dot{#@}",{selectionMode:"item"})},{label:()=>bd(`\\ddot{${Md(e)}}`),visible:()=>1===Md(e).length,onMenuSelect:()=>e.insert("\\ddot{#@}",{selectionMode:"item"})},{label:()=>bd(`\\bar{${Md(e)}}`),visible:()=>1===Md(e).length,onMenuSelect:()=>e.insert("\\bar{#@}",{selectionMode:"item"})},{label:()=>bd(`\\overline{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\overline{#@}",{selectionMode:"item"})},{label:()=>bd(`\\overgroup{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\overgroup{#@}",{selectionMode:"item"})},{label:()=>bd(`\\overbrace{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\overbrace{#@}",{selectionMode:"item"})},{label:()=>bd(`\\underline{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\underline{#@}",{selectionMode:"item"})},{label:()=>bd(`\\undergroup{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\undergroup{#@}",{selectionMode:"item"})},{label:()=>bd(`\\underbrace{${Md(e)}}`),visible:()=>Md(e).length>0,onMenuSelect:()=>e.insert("\\underbrace{#@}",{selectionMode:"item"})}]}function Od(e){return[{label:()=>bd(`\\boxed{${e.getValue(e.model.selection)}}}`),onMenuSelect:()=>e.insert("\\boxed{#@}",{selectionMode:"item"})},{label:()=>bd(`\\bbox[5px, border: 2px solid red]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px solid red]{#@}",{selectionMode:"item"})},{label:()=>bd(`\\bbox[5px, border: 2px dashed black]{${e.getValue(e.model.selection)}}`),onMenuSelect:()=>e.insert("\\bbox[5px, border: 2px dashed black]{#@}",{selectionMode:"item"})}]}function Fd(e){const t=[];for(const n of Object.keys(k))t.push({class:("#000"===Dd(Ad(k[n]))?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${k[n]} "></span>`,ariaLabel:()=>{var e;return null!=(e=b(n))?e:n},checked:()=>{var t;return{some:"mixed",all:!0}[null!=(t=e.queryStyle({backgroundColor:n}))&&t]},onMenuSelect:()=>{e.applyStyle({backgroundColor:n},{operation:"toggle"}),e.adoptStyle="none"}});return t}function Nd(e){const t=[];for(const n of Object.keys(S))t.push({class:("#000"===Ad(S[n])?"dark-contrast":"light-contrast")+" menu-swatch",label:`<span style="background:${S[n]} "></span>`,ariaLabel:()=>{var e;return null!=(e=b(n))?e:n},checked:()=>{var t;return{some:"mixed",all:!0}[null!=(t=e.queryStyle({color:n}))&&t]},onMenuSelect:()=>{e.applyStyle({color:n},{operation:"toggle"}),e.adoptStyle="none"}});return t}var Bd=class extends $h{constructor(e,t,n,i){super(e,t),this.row=n,this.col=i}set active(e){const t=this.parentMenu.children;if(e)for(const e of t)e.element.classList.toggle("active",e.row<=this.row&&e.col<=this.col);else for(const e of t)e.element.classList.remove("active")}};function $d(e){const t=[];for(let n=1;n<=5;n++)for(let i=1;i<=5;i++)t.push({onCreate:(e,t)=>new Bd(e,t,n,i),label:"☐",tooltip:()=>b("tooltip.row-by-col",n,i),data:{row:n,col:i},onMenuSelect:()=>{e.insert(`\\begin{pmatrix}${Array(n).fill(Array(i).fill("#?").join(" & ")).join("\\\\")}\\end{pmatrix}`,{selectionMode:"item"})}});return t}function Kd(e){return[{label:()=>b("menu.array.add row above"),id:"add-row-above",onMenuSelect:()=>e.executeCommand("addRowBefore"),visible:()=>Ud(e)},{label:()=>b("menu.array.add row below"),id:"add-row-below",onMenuSelect:()=>e.executeCommand("addRowAfter"),visible:()=>Ud(e)},{label:()=>b("menu.array.add column before"),id:"add-column-before",onMenuSelect:()=>e.executeCommand("addColumnBefore"),visible:()=>Ud(e),enabled:()=>{const t=e.model.parentEnvironment;if(!t)return!1;const[n,i]=function(e){var t;const n=null==(t=e.model.parentEnvironment)?void 0:t.array;return n?[n.length,n.reduce(((e,t)=>Math.max(e,t.length)),0)]:[0,0]}(e);return n<t.maxColumns}},{label:()=>b("menu.array.add column after"),id:"add-column-after",onMenuSelect:()=>e.executeCommand("addColumnAfter"),visible:()=>Ud(e)},{type:"divider"},{label:()=>b("menu.array.delete row"),id:"delete-row",onMenuSelect:()=>e.executeCommand("removeRow"),visible:()=>Ud(e)},{label:()=>b("menu.array.delete column"),id:"delete-column",onMenuSelect:()=>e.executeCommand("removeColumn"),visible:()=>Ud(e)},{type:"divider"},{label:()=>b("menu.borders"),visible:()=>(function(e){return"array"===e.model.at(e.model.position).type}(e)||Ud(e))&&e.isSelectionEditable,submenu:[{label:" ⋱ ",id:"environment-no-border",onMenuSelect:()=>zd(e,"matrix")},{label:"(⋱)",id:"environment-parentheses",onMenuSelect:()=>zd(e,"pmatrix")},{label:"[⋱]",id:"environment-brackets",onMenuSelect:()=>zd(e,"bmatrix")},{label:"|⋱|",id:"environment-bar",onMenuSelect:()=>zd(e,"vmatrix")},{label:"{⋱}",id:"environment-braces",onMenuSelect:()=>zd(e,"Bmatrix")}],submenuClass:"border-submenu"},{type:"divider"},{label:()=>b("menu.insert matrix"),id:"insert-matrix",visible:()=>e.isSelectionEditable,submenu:$d(e),submenuClass:"insert-matrix-submenu",columnCount:5},{label:()=>b("menu.mode"),id:"mode",visible:()=>e.isSelectionEditable&&e.model.selectionIsCollapsed,submenu:[{label:()=>b("menu.mode-math"),id:"mode-math",onMenuSelect:()=>{hc(e,"accept-all"),e.executeCommand(["switchMode","math"])},checked:()=>"math"===e.model.mode},{label:()=>b("menu.mode-text"),id:"mode-text",onMenuSelect:()=>{hc(e,"accept-all"),e.executeCommand(["switchMode","text"])},checked:()=>"text"===e.model.mode},{label:()=>b("menu.mode-latex"),id:"mode-latex",onMenuSelect:()=>e.executeCommand(["switchMode","latex"]),checked:()=>"latex"===e.model.mode}]},{type:"divider"},{label:()=>b("menu.font-style"),id:"variant",visible:()=>e.isSelectionEditable,submenu:Id(e),submenuClass:"variant-submenu"},{label:()=>b("menu.color"),id:"color",visible:()=>e.isSelectionEditable,submenu:Nd(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>b("menu.background-color"),id:"background-color",visible:()=>e.isSelectionEditable,submenu:Fd(e),columnCount:4,submenuClass:"swatches-submenu"},{label:()=>b("menu.accent"),id:"accent",visible:()=>e.isSelectionEditable,submenu:Pd(e),submenuClass:"variant-submenu"},{label:()=>b("menu.decoration"),id:"decoration",visible:()=>e.isSelectionEditable&&Md(e).length>0,submenu:Od(e),submenuClass:"variant-submenu"},{type:"divider"},{label:()=>b("menu.evaluate"),id:"ce-evaluate",visible:()=>e.isSelectionEditable&&null!==window.MathfieldElement.computeEngine,onMenuSelect:()=>{const t=function(e){var t,n;let i;i=e.model.selectionIsCollapsed?null==(t=window.MathfieldElement.computeEngine)?void 0:t.parse(e.getValue(),{canonical:!1}):null==(n=window.MathfieldElement.computeEngine)?void 0:n.parse(e.getValue(e.model.selection),{canonical:!1});if(!i)return"";let r=i.evaluate();r.isSame(i)&&(r=i.N());return r.latex}(e);t?e.model.selectionIsCollapsed?(e.model.position=e.model.lastOffset,e.insert(`=${t}`,{insertionMode:"insertAfter",selectionMode:"item"})):e.insert(t,{insertionMode:"replaceSelection",selectionMode:"item"}):e.model.announce("plonk")}},{label:()=>b("menu.simplify"),id:"ce-simplify",visible:()=>e.isSelectionEditable&&null!==window.MathfieldElement.computeEngine,onMenuSelect:()=>{var t,n;if(e.model.selectionIsCollapsed){const n=null==(t=e.expression)?void 0:t.simplify();if(e.model.position=e.model.lastOffset,!n)return void e.model.announce("plonk");e.insert(`=${n.latex}`,{insertionMode:"insertAfter",selectionMode:"item"})}else{const t=null==(n=window.MathfieldElement.computeEngine)?void 0:n.parse(e.getValue(e.model.selection)).simplify();if(!t)return void e.model.announce("plonk");e.insert(t.latex,{insertionMode:"replaceSelection",selectionMode:"item"})}}},{label:()=>{var t;if(null===window.MathfieldElement.computeEngine)return"";const n=null==(t=e.expression)?void 0:t.unknowns[0];return n?b("menu.solve-for",bd(n)):b("menu.solve")},id:"ce-solve",visible:()=>{var t;return e.isSelectionEditable&&null!==window.MathfieldElement.computeEngine&&1===(null==(t=e.expression)?void 0:t.unknowns.length)&&"Nothing"!==e.expression.unknowns[0]},onMenuSelect:()=>{var t;const n=e.expression,i=null==n?void 0:n.unknowns[0],r=null==(t=n.solve(i))?void 0:t.map((e=>{var t;return null!=(t=e.simplify().latex)?t:""}));r?e.insert(`${i}=${1===r.length?r[0]:"\\left\\lbrace"+(null==r?void 0:r.join(", "))+"\\right\\rbrace"}`,{insertionMode:"replaceAll",selectionMode:"item"}):e.model.announce("plonk")}},{type:"divider"},{label:()=>b("menu.cut"),onMenuSelect:()=>e.executeCommand("cutToClipboard"),visible:()=>!e.options.readOnly&&e.isSelectionEditable,keyboardShortcut:"meta+X"},{label:()=>b("menu.copy"),id:"copy",submenu:[{label:()=>b("menu.copy-as-latex"),id:"copy-latex",onMenuSelect:()=>Ya.copyToClipboard(e,"latex"),keyboardShortcut:"meta+C"},{label:()=>b("menu.copy-as-ascii-math"),id:"copy-ascii-math",onMenuSelect:()=>Ya.copyToClipboard(e,"ascii-math")},{label:()=>b("menu.copy-as-mathml"),id:"copy-math-ml",onMenuSelect:()=>Ya.copyToClipboard(e,"math-ml")}]},{label:()=>b("menu.paste"),id:"paste",onMenuSelect:()=>e.executeCommand("pasteFromClipboard"),visible:()=>e.hasEditableContent,keyboardShortcut:"meta+V"},{label:()=>b("menu.select-all"),id:"select-all",keyboardShortcut:"meta+A",onMenuSelect:()=>e.executeCommand("selectAll")}]}function Ud(e){var t;return!!(null==(t=e.model.parentEnvironment)?void 0:t.array)}function zd(e,t){lc(e),e.flushInlineShortcutBuffer(),Eu(e.model,t),Tc(e)}function Vd(e,t,n,i){return{label:()=>bd(`\\${n}{${Md(e)}}`),tooltip:()=>{var e;return null!=(e=b(i))?e:i},visible:()=>function(e,t){const n=Rd(e);if(1!==n.length)return!1;const i=Ll[t];return!!i&&!!i.test(n[0].value)}(e,t),checked:()=>{var n;return{some:"mixed",all:!0}[null!=(n=e.queryStyle({variant:t}))&&n]},onMenuSelect:()=>{e.applyStyle({variant:t},{operation:"toggle"}),e.adoptStyle="none"}}}function qd(e,t,n,i){return{label:()=>bd(`\\${n}{${Md(e)}}`),tooltip:()=>{var e;return null!=(e=b(i))?e:i},visible:()=>function(e,t){return Md(e).length>0}(e),checked:()=>{var n;return{some:"mixed",all:!0}[null!=(n=e.queryStyle({variantStyle:t}))&&n]},onMenuSelect:()=>{e.applyStyle({variantStyle:t},{operation:"toggle"}),e.adoptStyle="none"}}}function Gd(e,t){return e+gd(t)}function Hd(e){var t;let n;if("prompt"===e.parent.type)"body"===e.parentBranch&&(n="prompt");else if("body"===e.parentBranch)n=e.type&&null!=(t={enclose:"cross out",leftright:"delimiter",surd:"square root",root:"math field",mop:"operator",first:"first"}[e.type])?t:"parent";else if("genfrac"===e.parent.type){if("above"===e.parentBranch)return"numerator";if("below"===e.parentBranch)return"denominator"}else"surd"===e.parent.type?"above"===e.parentBranch&&(n="index"):"superscript"===e.parentBranch?n="superscript":"subscript"===e.parentBranch&&(n="subscript");return n||console.log("unknown relationship"),null!=n?n:"parent"}function jd(e,t,n,i){let r="";if("plonk"===t)window.MathfieldElement.playSound("plonk"),e.flushInlineShortcutBuffer();else if("delete"===t)r=Gd("deleted: ",i);else if("focus"===t||t.includes("move"))r=function(e,t){if(Number.isNaN(t))return"";const n=e.at(t);if(!n)return"";if(n.treeDepth<=e.at(e.position).treeDepth)return"";let i="",r=n.parent;const s=e.at(e.position).parent;for(;r!==e.root&&r!==s;)i+=`out of ${Hd(r)};`,r=r.parent;return i}(e.model,n)+(e.model.selectionIsCollapsed?"":"selected: ")+function(e){if(!e.selectionIsCollapsed)return Gd("",e.getAtoms(e.selection));let t="";const n=e.at(e.position),i=Hd(n);n.isFirstSibling&&(t=(i?"start of "+i:"unknown")+": ");n.isLastSibling?n.isFirstSibling||(t+=i?"end of "+i:"unknown"):t+=Gd("",n);return t}(e.model);else if("replacement"===t)r=Gd("",e.model.at(e.model.position));else if("line"===t){const t=Gd("",e.model.root);e.keyboardDelegate.setAriaLabel(t)}else r=i?Gd(t+" ",i):t;if(r){const t=e.ariaLiveText.textContent.includes(" ")?" ":" ";e.ariaLiveText.textContent=r+t}}Mc({speak:(e,t,n)=>function(e,t,n){var i,r;n=null!=n?n:{withHighlighting:!1};const{model:s}=e;function a(e){let t=null;switch(e){case"all":default:t=s.root;break;case"selection":t=s.getAtoms(s.selection);break;case"left":t=s.getAtoms(s.offsetOf(s.at(s.position).leftSibling),s.position);break;case"right":t=s.getAtoms(s.position,s.offsetOf(s.at(s.position).rightSibling));break;case"group":t=s.getAtoms(s.getSiblingsRange(s.position));break;case"parent":{const{parent:e}=s.at(s.position);t=(null==e?void 0:e.parent)?e:s.root;break}}return t}function o(e){let t="";switch(e){case"all":console.log("Internal failure: speak all failed");break;case"selection":t="no selection";break;case"left":t="at start";break;case"right":t="at end";break;case"group":console.log("Internal failure: speak group failed");break;case"parent":t="no parent";break;default:console.log('unknown speak_ param value: "'+e+'"')}return t}const l=a(t);if(null===l)return null==(r=(i=window.MathfieldElement).speakHook)||r.call(i,o(t)),!1;(n.withHighlighting||"amazon"===window.MathfieldElement.speechEngine)&&(window.MathfieldElement.textToSpeechMarkup=window.sre&&"sre"===window.MathfieldElement.textToSpeechRules?"ssml_step":"ssml");const c=gd(l);m()&&n.withHighlighting?(pp().readAloudMathfield=e,Lc(e,{forHighlighting:!0}),window.MathfieldElement.readAloudHook&&window.MathfieldElement.readAloudHook(e.field,c)):window.MathfieldElement.speakHook&&window.MathfieldElement.speakHook(c);return!1}(e,t,n)},{target:"mathfield"});function Wd(e,t,n,i){const r=e.offsetOf(t);if(r<n||r>i)return!1;if(!t.hasChildren)return!0;const s=e.offsetOf(t.firstChild);if(s>=n&&s<=i){const r=e.offsetOf(t.lastChild);if(r>=n&&r<=i)return!0}return!1}function Zd(e,t,n){if(!(null==t?void 0:t.hasChildren))return!1;const[i,r]=n,s=e.offsetOf(t.firstChild),a=e.offsetOf(t.lastChild);return s>=i&&s<=r&&a>=s&&a<=r}function Yd(e,t,n,i){var r,s,a,o,l,c;const u=n.parent;if(u&&n instanceof Go){const r=!i&&"forward"===t||"body"===i&&"backward"===t;let s=r?e.offsetOf(n.firstChild):e.offsetOf(n.lastChild);return r?"?"!==n.rightDelim&&"."!==n.rightDelim?(n.leftDelim=".",n.isDirty=!0):(u.addChildrenAfter(n.removeBranch("body"),n),u.removeChild(n),s--):"?"!==n.leftDelim&&"."!==n.leftDelim?(n.rightDelim=".",n.isDirty=!0):(u.addChildrenAfter(n.removeBranch("body"),n),u.removeChild(n),s--),e.position=s,!0}if(u&&"surd"===n.type){if("forward"===t&&!i||"backward"===t&&"body"===i){const t=n.leftSibling;n.hasChildren&&u.addChildrenAfter(n.removeBranch("body"),n),u.removeChild(n),e.position=e.offsetOf(t)}else"forward"===t&&"body"===i?e.position=e.offsetOf(n):i||"backward"!==t?"above"===i&&(n.hasEmptyBranch("above")&&n.removeBranch("above"),e.position="backward"===t?e.offsetOf(n.leftSibling):e.offsetOf(n.body[0])):n.hasChildren?e.position=e.offsetOf(n.lastChild):(e.position=Math.max(0,e.offsetOf(n)-1),u.removeChild(n));return!0}if(u&&("box"===n.type||"enclose"===n.type)){const r=i&&"backward"===t||!i&&"forward"===t?n.leftSibling:n.lastChild;return u.addChildrenAfter(n.removeBranch("body"),n),u.removeChild(n),e.position=e.offsetOf(r),!0}if("genfrac"===n.type||"overunder"===n.type){if(!i)return("overunder"!==n.type||!n.hasEmptyBranch("body"))&&(("genfrac"!==n.type||!n.hasEmptyBranch("below")||!n.hasEmptyBranch("above"))&&(e.position=e.offsetOf("forward"===t?n.firstChild:n.lastChild),!0));const r="numerator-denominator"===sp.fractionNavigationOrder?"above":"below",s="above"===r?"below":"above";if(u&&("forward"===t&&i===r||"backward"===t&&i===s)){const t=n.removeBranch(r),i=n.removeBranch(s);return u.addChildrenAfter([...t,...i],n),u.removeChild(n),e.position=e.offsetOf(t.length>0?t[t.length-1]:i[0]),!0}return e.position="backward"===t?e.offsetOf(n.leftSibling):e.offsetOf(n),!0}if(n.isExtensibleSymbol||"subsup"===n.type){if(!i&&"forward"===t)return!1;if(!i){if(n.subscript||n.superscript){const i="forward"===t?null!=(a=null==(r=n.superscript)?void 0:r[0])?a:null==(s=n.subscript)?void 0:s[0]:null!=(c=null==(o=n.subscript)?void 0:o[0].lastSibling)?c:null==(l=n.superscript)?void 0:l[0].lastSibling;return i&&(e.position=e.offsetOf(i)),!0}return!1}if(!n.hasChildren&&"subsup"===n.type){const i="forward"===t?e.offsetOf(n):Math.max(0,e.offsetOf(n)-1);return n.parent.removeChild(n),e.position=i,!0}if("superscript"===i)if("backward"===t){const t=e.offsetOf(n.firstChild)-1;console.assert(t>=0),e.position=t}else n.subscript?e.position=e.offsetOf(n.subscript[0]):e.position=e.offsetOf(n);else"subscript"===i&&("backward"===t&&n.superscript?e.position=e.offsetOf(n.superscript[0].lastSibling):e.position="backward"===t?e.offsetOf(n.firstChild)-1:e.offsetOf(n));if(i&&n.hasEmptyBranch(i)&&(n.removeBranch(i),"subsup"===n.type&&!n.subscript&&!n.superscript)){const i="forward"===t?e.offsetOf(n):Math.max(0,e.offsetOf(n)-1);n.parent.removeChild(n),e.position=i}return!0}if("genfrac"===(null==u?void 0:u.type)&&!i&&"first"!==n.type){let t=e.offsetOf(n.leftSibling);return u.removeChild(n),u.hasEmptyBranch("above")&&u.hasEmptyBranch("below")?(t=e.offsetOf(u.leftSibling),u.parent.removeChild(u),e.announce("delete",void 0,[u]),e.position=t,!0):(e.announce("delete",void 0,[n]),e.position=t,!0)}if("backward"===t&&("\\ln"===(null==u?void 0:u.command)||"\\log"===(null==u?void 0:u.command))&&"body"!==n.parentBranch){const t=e.offsetOf(u.leftSibling);return u.parent.removeChild(u),e.announce("delete",void 0,[u]),e.position=t,!0}return!1}function Xd(e,t,n){const i=e.getAtoms(t);if(i.length>0&&i[0].parent){let r=i[0].parent.firstChild;"first"===r.type&&(r=r.rightSibling);const s=i[i.length-1].parent.lastChild;let a=i[0];"first"===a.type&&(a=a.rightSibling);const o=i[i.length-1];if(a===r&&o===s){const n=i[0].parent;n.parent&&"prompt"!==n.type&&(t=[e.offsetOf(n.leftSibling),e.offsetOf(n)])}if(1===i.length&&"placeholder"===i[0].type&&"genfrac"===i[0].parent.type){const t=i[0].parent,r="below"===i[0].parentBranch?"above":"below",s=e.offsetOf(t.leftSibling);return e.deferNotifications({content:!0,selection:!0,type:n},(()=>{var n,i;const a=t.removeBranch(r);if(1!==a.length||"placeholder"!==a[0].type){const i=t.parent.addChildrenAfter(a,t);null==(n=t.parent)||n.removeChild(t),e.position=e.offsetOf(i)}else null==(i=t.parent)||i.removeChild(t),e.position=Math.max(0,s)}))}}return e.deferNotifications({content:!0,selection:!0,type:n},(()=>e.deleteAtoms(t)))}Mc({deleteAll:e=>e.contentWillChange({inputType:"deleteContent"})&&Xd(e,[0,-1],"deleteContent"),deleteForward:e=>function(e){return!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentForward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentForward"},(()=>{var t,n;let i=e.at(e.position).rightSibling;if(i&&Yd(e,"forward",i))return;if(i){if(e.at(e.position).isLastSibling&&Yd(e,"forward",i.parent,i.parentBranch))return}else{if(i=e.at(e.position),i.isLastSibling&&Yd(e,"forward",i.parent,i.parentBranch))return;i=void 0}if(e.position===e.lastOffset||!i)return void e.announce("plonk");i.parent.removeChild(i);let r=null==(t=e.at(e.position))?void 0:t.rightSibling;for(;"subsup"===(null==r?void 0:r.type);)r.parent.removeChild(r),r=null==(n=e.at(e.position))?void 0:n.rightSibling;e.announce("delete",void 0,[i])})):Xd(e,Fa(e.selection),"deleteContentForward"))}(e),deleteBackward:e=>function(e){return!!e.mathfield.isSelectionEditable&&!!e.contentWillChange({inputType:"deleteContentBackward"})&&(e.selectionIsCollapsed?e.deferNotifications({content:!0,selection:!0,type:"deleteContentBackward"},(()=>{let t=e.at(e.position);if(!t||!Yd(e,"backward",t)){if(null==t?void 0:t.isFirstSibling){if(Yd(e,"backward",t.parent,t.parentBranch))return;t=null}t?(e.position=e.offsetOf(t.leftSibling),t.parent.removeChild(t),e.announce("delete",void 0,[t])):e.announce("plonk")}})):Xd(e,Fa(e.selection),"deleteContentBackward"))}(e),deleteNextWord:e=>e.contentWillChange({inputType:"deleteWordForward"})&&Xd(e,[e.anchor,Du(e,e.position,"forward")],"deleteWordForward"),deletePreviousWord:e=>e.contentWillChange({inputType:"deleteWordBackward"})&&Xd(e,[e.anchor,Du(e,e.position,"backward")],"deleteWordBackward"),deleteToGroupStart:e=>e.contentWillChange({inputType:"deleteSoftLineBackward"})&&Xd(e,[e.anchor,e.offsetOf(e.at(e.position).firstSibling)],"deleteSoftLineBackward"),deleteToGroupEnd:e=>e.contentWillChange({inputType:"deleteSoftLineForward"})&&Xd(e,[e.anchor,e.offsetOf(e.at(e.position).lastSibling)],"deleteSoftLineForward"),deleteToMathFieldStart:e=>e.contentWillChange({inputType:"deleteHardLineBackward"})&&Xd(e,[e.anchor,0],"deleteHardLineBackward"),deleteToMathFieldEnd:e=>e.contentWillChange({inputType:"deleteHardLineForward"})&&Xd(e,[e.anchor,-1],"deleteHardLineForward")},{target:"model",audioFeedback:"delete",canUndo:!0,changeContent:!0,changeSelection:!0});var Jd=`<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox="0 0 576 512" role="img" aria-label="${b("tooltip.toggle virtual keyboard")}"><path d="M528 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h480c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm16 336c0 8.823-7.177 16-16 16H48c-8.823 0-16-7.177-16-16V112c0-8.823 7.177-16 16-16h480c8.823 0 16 7.177 16 16v288zM168 268v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-336 80v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm384 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zM120 188v-24c0-6.627-5.373-12-12-12H84c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm96 0v-24c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v24c0 6.627 5.373 12 12 12h24c6.627 0 12-5.373 12-12zm-96 152v-8c0-6.627-5.373-12-12-12H180c-6.627 0-12 5.373-12 12v8c0 6.627 5.373 12 12 12h216c6.627 0 12-5.373 12-12z"/></svg>`,Qd=`<svg xmlns="http://www.w3.org/2000/svg" style="height: 18px;" viewBox="0 0 448 512" role="img" aria-label="${b("tooltip.menu")}"><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`;function ep(e){if(e&&(e.classList.remove("ML__highlight"),e.children))for(const t of e.children)ep(t)}function tp(e,t){var n;e&&(t&&(null==(n=e.dataset)?void 0:n.atomId)!==t?(e.classList.remove("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach((e=>{e instanceof HTMLElement&&tp(e,t)}))):(e.classList.add("ML__highlight"),e.children&&e.children.length>0&&[...e.children].forEach((e=>{e instanceof HTMLElement&&tp(e)}))))}m()||console.error('MathLive 0.98.5: this version of the MathLive library is for use in the browser. A subset of the API is available on the server side in the "mathlive-ssr" library. If using server side rendering (with React for example) you may want to do a dynamic import of the MathLive library inside a `useEffect()` call.');var np=new WeakMap,ip={letterShapeStyle:"mf.letterShapeStyle = ...",horizontalSpacingScale:'Removed. Use `"thinmuskip"`, `"medmuskip"`, and `"thickmuskip"` registers ',macros:"mf.macros = ...",registers:"mf.registers = ...",backgroundColorMap:"mf.backgroundColorMap = ...",colorMap:"mf.colorMap = ...",enablePopover:"mf.popoverPolicy = ...",mathModeSpace:"mf.mathModeSpace = ...",placeholderSymbol:"mf.placeholderSymbol = ...",readOnly:"mf.readOnly = ...",removeExtraneousParentheses:"mf.removeExtraneousParentheses = ...",scriptDepth:"mf.scriptDepth = ...",smartFence:"mf.smartFence = ...",smartMode:"mf.smartMode = ...",smartSuperscript:"mf.smartSuperscript = ...",inlineShortcutTimeout:"mf.inlineShortcutTimeout = ...",inlineShortcuts:"mf.inlineShortcuts = ...",keybindings:"mf.keybindings = ...",virtualKeyboardMode:"mf.mathVirtualKeyboardPolicy = ...",customVirtualKeyboardLayers:"mathVirtualKeyboard.layers = ...",customVirtualKeyboards:"mathVirtualKeyboard.layouts = ...",keypressSound:"mathVirtualKeyboard.keypressSound = ...",keypressVibration:"mathVirtualKeyboard.keypressVibration = ...",plonkSound:"mathVirtualKeyboard.plonkSound = ...",virtualKeyboardContainer:"mathVirtualKeyboard.container = ...",virtualKeyboardLayout:"mathVirtualKeyboard.alphabeticLayout = ...",virtualKeyboardTheme:"No longer supported",virtualKeyboardToggleGlyph:"No longer supported",virtualKeyboardToolbar:"mathVirtualKeyboard.editToolbar = ...",virtualKeyboards:"Use `mathVirtualKeyboard.layouts`",speechEngine:"`MathfieldElement.speechEngine`",speechEngineRate:"`MathfieldElement.speechEngineRate`",speechEngineVoice:"`MathfieldElement.speechEngineVoice`",textToSpeechMarkup:"`MathfieldElement.textToSpeechMarkup`",textToSpeechRules:"`MathfieldElement.textToSpeechRules`",textToSpeechRulesOptions:"`MathfieldElement.textToSpeechRulesOptions`",readAloudHook:"`MathfieldElement.readAloudHook`",speakHook:"`MathfieldElement.speakHook`",computeEngine:"`MathfieldElement.computeEngine`",fontsDirectory:"`MathfieldElement.fontsDirectory`",soundsDirectory:"`MathfieldElement.soundsDirectory`",createHTML:"`MathfieldElement.createHTML`",onExport:"`MathfieldElement.onExport`",onInlineShortcut:"`MathfieldElement.onInlineShortcut`",onScrollIntoView:"`MathfieldElement.onScrollIntoView`",locale:"MathfieldElement.locale = ...",strings:"MathfieldElement.strings = ...",decimalSeparator:"MathfieldElement.decimalSeparator = ...",fractionNavigationOrder:"MathfieldElement.fractionNavigationOrder = ..."},rp=class e extends HTMLElement{static get formAssociated(){return lp()}static get optionsAttributes(){return{"default-mode":"string","letter-shape-style":"string","min-font-scale":"number","popover-policy":"string","math-mode-space":"string","read-only":"boolean","remove-extraneous-parentheses":"on/off","smart-fence":"on/off","smart-mode":"on/off","smart-superscript":"on/off","inline-shortcut-timeout":"string","script-depth":"string",placeholder:"string","virtual-keyboard-target-origin":"string","math-virtual-keyboard-policy":"string"}}static get observedAttributes(){return[...Object.keys(this.optionsAttributes),"contenteditable","disabled","readonly","read-only"]}static get fontsDirectory(){return this._fontsDirectory}static set fontsDirectory(e){e!==this._fontsDirectory&&(this._fontsDirectory=e,async function(){kc="not-loaded",Sc()}())}get fontsDirectory(){throw new Error("Use MathfieldElement.fontsDirectory instead")}set fontsDirectory(e){throw new Error("Use MathfieldElement.fontsDirectory instead")}static get soundsDirectory(){return this._soundsDirectory}static set soundsDirectory(e){this._soundsDirectory=e,this.audioBuffers={}}get soundsDirectory(){throw new Error("Use MathfieldElement.soundsDirectory instead")}set soundsDirectory(e){throw new Error("Use MathfieldElement.soundsDirectory instead")}static get keypressSound(){return this._keypressSound}static set keypressSound(e){var t,n,i;this.audioBuffers={},null===e?this._keypressSound={spacebar:null,return:null,delete:null,default:null}:"string"==typeof e?this._keypressSound={spacebar:e,return:e,delete:e,default:e}:"object"==typeof e&&"default"in e&&(this._keypressSound={spacebar:null!=(t=e.spacebar)?t:e.default,return:null!=(n=e.return)?n:e.default,delete:null!=(i=e.delete)?i:e.default,default:e.default})}static get plonkSound(){return this._plonkSound}static set plonkSound(e){this.audioBuffers={},this._plonkSound=e}static get audioContext(){return this._audioContext||(this._audioContext=new AudioContext),this._audioContext}static get speechEngine(){return this._speechEngine}static set speechEngine(e){this._speechEngine=e}static get speechEngineRate(){return this._speechEngineRate}static set speechEngineRate(e){this._speechEngineRate=e}static get speechEngineVoice(){return this._speechEngineVoice}static set speechEngineVoice(e){this._speechEngineVoice=e}static get textToSpeechMarkup(){return this._textToSpeechMarkup}static set textToSpeechMarkup(e){this._textToSpeechMarkup=e}static get textToSpeechRules(){return this._textToSpeechRules}static set textToSpeechRules(e){this._textToSpeechRules=e}static get textToSpeechRulesOptions(){return this._textToSpeechRulesOptions}static set textToSpeechRulesOptions(e){this._textToSpeechRulesOptions=e}static get locale(){return v.locale}static set locale(e){"auto"===e&&(e=navigator.language.slice(0,5)),v.locale=e}get locale(){throw new Error("Use MathfieldElement.locale instead")}set locale(e){throw new Error("Use MathfieldElement.locale instead")}static get strings(){return v.strings}static set strings(e){v.merge(e)}get strings(){throw new Error("Use MathfieldElement.strings instead")}set strings(e){throw new Error("Use MathfieldElement.strings instead")}static get decimalSeparator(){return this._decimalSeparator}static set decimalSeparator(e){this._decimalSeparator=e,this._computeEngine&&(this._computeEngine.latexOptions.decimalMarker=","===this.decimalSeparator?"{,}":".")}get decimalSeparator(){throw new Error("Use MathfieldElement.decimalSeparator instead")}set decimalSeparator(e){throw new Error("Use MathfieldElement.decimalSeparator instead")}static get computeEngine(){var e,t;if(void 0===this._computeEngine){const t=null==(e=window[Symbol.for("io.cortexjs.compute-engine")])?void 0:e.ComputeEngine;if(!t)return null;this._computeEngine=new t,this._computeEngine&&","===this.decimalSeparator&&(this._computeEngine.latexOptions.decimalMarker="{,}")}return null!=(t=this._computeEngine)?t:null}static set computeEngine(e){this._computeEngine=e}get computeEngine(){throw new Error("Use MathfieldElement.computeEngine instead")}set computeEngine(e){throw new Error("Use MathfieldElement.computeEngine instead")}static get isFunction(){return"function"!=typeof this._isFunction?()=>!1:this._isFunction}static set isFunction(e){this._isFunction=e}static async loadSound(e){delete this.audioBuffers[e];let t="";switch(e){case"keypress":t=this._keypressSound.default;break;case"return":t=this._keypressSound.return;break;case"spacebar":t=this._keypressSound.spacebar;break;case"delete":t=this._keypressSound.delete;break;case"plonk":t=this.plonkSound}if("string"!=typeof t)return;t=t.trim();const n=this.soundsDirectory;if(null!=n&&"null"!==n&&"none"!==t&&"null"!==t)try{const i=await fetch(await xc(`${n}/${t}`)),r=await i.arrayBuffer(),s=await this.audioContext.decodeAudioData(r);this.audioBuffers[e]=s}catch(e){}}static async playSound(e){if("suspended"!==this.audioContext.state&&"interrupted"!==this.audioContext.state||await this.audioContext.resume(),this.audioBuffers[e]||await this.loadSound(e),!this.audioBuffers[e])return;const t=this.audioContext.createBufferSource();t.buffer=this.audioBuffers[e];const n=this.audioContext.createGain();n.gain.value=.5,t.connect(n).connect(this.audioContext.destination),t.start()}constructor(e){if(super(),e){const t=[];for(const n of Object.keys(e))if(ip[n])if(ip[n].startsWith("mf."))if(ip[n].startsWith(`mf.${n}`))t.push(`Option \`${n}\` cannot be used as a constructor option. Use ${ip[n]}`);else{const e=ip[n].match(/([a-zA-Z]+) =/);t.push(`Option \`${n}\` has been renamed \`${e[1]}\``)}else t.push(`Option \`${n}\` cannot be used as a constructor option. Use ${ip[n]}`);if(t.length>0){console.group("%cMathLive 0.98.5: %cInvalid Options","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn("Some of the options passed to `new MathfieldElement(...)` are invalid. \n See https://cortexjs.io/mathlive/changelog/ for details.");for(const e of t)console.warn(e);console.groupEnd()}}if(lp()&&(this._internals=this.attachInternals(),this._internals.role="math",this._internals.ariaLabel="math input field",this._internals.ariaMultiLine="false"),this.attachShadow({mode:"open",delegatesFocus:!0}),this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot){this.shadowRoot.adoptedStyleSheets=[ho("core"),ho("mathfield"),ho("mathfield-element"),ho("ui"),ho("menu")],this.shadowRoot.appendChild(document.createElement("span"));const e=document.createElement("slot");e.style.display="none",this.shadowRoot.appendChild(e)}else this.shadowRoot.innerHTML="<style>"+uo("core")+uo("mathfield")+uo("mathfield-element")+uo("ui")+uo("menu")+'</style><span></span><slot style="display:none"></slot>';e&&this._setOptions(e),this.shadowRoot.addEventListener("slotchange",(()=>{var e;const t=this.shadowRoot.querySelector("slot:not([name])");this.value=null!=(e=null==t?void 0:t.assignedNodes().map((e=>3===e.nodeType?e.textContent:"")).join("").trim())?e:""}))}showMenu(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.showMenu(e))&&n}get mathVirtualKeyboard(){throw new Error("The `mathVirtualKeyboard` property is not available on the MathfieldElement. Use `window.mathVirtualKeyboard` instead.")}onPointerDown(){window.addEventListener("pointerup",(e=>{var t;e.target!==this||(null==(t=this._mathfield)?void 0:t.disabled)||this.dispatchEvent(new MouseEvent("click",{altKey:e.altKey,button:e.button,buttons:e.buttons,clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,metaKey:e.metaKey,movementX:e.movementX,movementY:e.movementY,relatedTarget:e.relatedTarget,screenX:e.screenX,screenY:e.screenY,shiftKey:e.shiftKey}))}),{once:!0})}getPromptValue(e,t){var n,i;return null!=(i=null==(n=this._mathfield)?void 0:n.getPromptValue(e,t))?i:""}setPromptValue(e,t,n){var i;null==(i=this._mathfield)||i.setPromptValue(e,t,n)}getPromptRange(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.getPromptRange(e))?n:null}getPrompts(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.getPrompts(e))?n:[]}get form(){var e;return null==(e=this._internals)?void 0:e.form}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}get type(){return this.localName}get mode(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.model.mode)?t:"text"===this.defaultMode?"text":"math"}set mode(e){var t;null==(t=this._mathfield)||t.switchMode(e)}get expression(){if(this._mathfield)return window[Symbol.for("io.cortexjs.compute-engine")]?this._mathfield.expression:(console.error('MathLive 0.98.5: The CortexJS Compute Engine library is not available.\n \n Load the library, for example with:\n \n import "https://unpkg.com/@cortex-js/compute-engine?module"'),null)}set expression(t){var n,i;if(!this._mathfield)return;const r=null!=(i=null==(n=e.computeEngine)?void 0:n.box(t).latex)?i:null;null!==r&&this._mathfield.setValue(r),window[Symbol.for("io.cortexjs.compute-engine")]||console.error('MathLive 0.98.5: The CortexJS Compute Engine library is not available.\n \n Load the library, for example with:\n \n import "https://unpkg.com/@cortex-js/compute-engine?module"')}get errors(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.errors)?t:[]}_getOptions(e){return this._mathfield?hu(this._mathfield.options,e):np.has(this)?u({},hu(u(u({},du()),uu(np.get(this).options)),e)):null}getOptions(e){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOptions()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._mathfield?hu(this._mathfield.options,e):np.has(this)?hu(u(u({},du()),uu(np.get(this).options)),e):null}reflectAttributes(){const t=du(),n=this._getOptions();Object.keys(e.optionsAttributes).forEach((i=>{const r=ap(i);"on/off"===e.optionsAttributes[i]?t[r]!==n[r]?this.setAttribute(i,n[r]?"on":"off"):this.removeAttribute(i):t[r]!==n[r]&&("boolean"===e.optionsAttributes[i]?n[r]?this.setAttribute(i,""):this.removeAttribute(i):"string"!=typeof n[r]&&"number"!=typeof n[r]||this.setAttribute(i,n[r].toString()))}))}getOption(e){return console.warn("%cMathLive 0.98.5: %cDeprecated Usage%c\n `mf.getOption()` is deprecated. Read the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem","color: inherit, font-size: 1rem"),this._getOptions([e])[e]}_getOption(e){return this._getOptions([e])[e]}_setOptions(e){if(this._mathfield)this._mathfield.setOptions(e);else if(np.has(this)){const t=u(u({},np.get(this).options),e);np.set(this,h(u({},np.get(this)),{selection:{ranges:t.readOnly?[[0,0]]:[[0,-1]]},options:t}))}else np.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:e,menuItems:void 0});this.reflectAttributes()}setOptions(e){console.group("%cMathLive 0.98.5: %cDeprecated Usage","color:#12b; font-size: 1.1rem","color:#db1111; font-size: 1.1rem"),console.warn(" `mf.setOptions()` is deprecated. Set the property directly on the mathfield instead.\n See https://cortexjs.io/mathlive/changelog/ for details.");for(const t of Object.keys(e))ip[t]&&console.warn(`\`mf.setOptions({${t}:...})\` -> ${ip[t]}`);console.groupEnd(),this._setOptions(e)}executeCommand(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.executeCommand(e))&&n}getValue(e,t,n){var i,r;if(this._mathfield)return this._mathfield.model.getValue(e,t,n);if(np.has(this)){let s,a,o;if($a(e)?([s,a]=e.ranges[0],o=t):Ba(e)?([s,a]=e,o=t):Na(e)&&Na(t)?(s=e,a=t,o=n):(s=0,a=-1,o=e),(void 0===o||"latex"===o)&&0===s&&-1===a)return null!=(r=null!=(i=np.get(this).value)?i:this.textContent)?r:""}return""}setValue(e,t){if(this._mathfield&&void 0!==e)return null!=t||(t={silenceNotifications:!0,mode:"math"}),void this._mathfield.setValue(e,t);if(np.has(this)){const t=np.get(this).options;return void np.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:t,menuItems:void 0})}const n=op(this);np.set(this,{value:e,selection:{ranges:[[-1,-1]],direction:"forward"},options:n,menuItems:void 0})}hasFocus(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.hasFocus())&&t}focus(){var e;null==(e=this._mathfield)||e.focus()}blur(){var e;null==(e=this._mathfield)||e.blur()}select(){var e;null==(e=this._mathfield)||e.select()}insert(e,t){var n,i;return null!=(i=null==(n=this._mathfield)?void 0:n.insert(e,t))&&i}applyStyle(e,t){var n;return null==(n=this._mathfield)?void 0:n.applyStyle(e,t)}queryStyle(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.queryStyle(e))?n:"none"}get caretPoint(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.getCaretPoint())?t:null}set caretPoint(e){var t;e&&(null==(t=this._mathfield)||t.setCaretPoint(e.x,e.y))}setCaretPoint(e,t){var n,i;return null!=(i=null==(n=this._mathfield)?void 0:n.setCaretPoint(e,t))&&i}offsetFromPoint(e,t,n){return this._mathfield?ph(this._mathfield,e,t,n):-1}hitboxFromOffset(e){if(!this._mathfield)return null;const t=this._mathfield.model.at(e);if(!t)return null;const n=ro(this._mathfield,t);return n?new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top):null}resetUndo(){var e;null==(e=this._mathfield)||e.resetUndo()}canUndo(){return!!this._mathfield&&this._mathfield.canUndo()}canRedo(){return!!this._mathfield&&this._mathfield.canRedo()}handleEvent(e){var t,n,i,r;"closed"===Ql.state&&"closed"===(null==(n=null==(t=this._mathfield)?void 0:t.menu)?void 0:n.state)&&("pointerdown"===e.type&&this.onPointerDown(),"focus"===e.type&&(null==(i=this._mathfield)||i.focus()),"blur"===e.type&&(null==(r=this._mathfield)||r.blur()))}connectedCallback(){var t,n,i,r;const s=window.getComputedStyle(this),a=this.shadowRoot,o="none"!==s.userSelect;if(o)a.host.addEventListener("pointerdown",this,!0);else{a.querySelector("span").style.pointerEvents="none"}a.host.addEventListener("focus",this,!0),a.host.addEventListener("blur",this,!0),lp()||(this.hasAttribute("role")||this.setAttribute("role","math"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","math input field"),this.setAttribute("aria-multiline","false")),o&&!this.hasAttribute("contenteditable")&&this.setAttribute("contenteditable","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const l=a.querySelector("slot:not([name])");if(l)try{this._style=l.assignedElements().filter((e=>"style"===e.tagName.toLowerCase())).map((e=>e.textContent)).join("")}catch(e){console.error(e)}if(this._style){const e=document.createElement("style");e.textContent=this._style,a.appendChild(e)}let c="";if(c=this.hasAttribute("value")?this.getAttribute("value"):null!=(t=null==l?void 0:l.assignedNodes().map((e=>3===e.nodeType?e.textContent:"")).join("").trim())?t:"",this._mathfield=new class{constructor(e,t){var n,i,r;this.focusBlurInProgress=!1,this.options=u(h(u({},du()),{macros:ie(),registers:Ea()}),uu(t)),this.eventController=new AbortController;const s=this.eventController.signal;t.eventSink&&(this.host=t.eventSink),this.element=e,e.mathfield=this,this.blurred=!0,this.keystrokeCaptionVisible=!1,this.suggestionIndex=0,this.inlineShortcutBuffer=[],this.inlineShortcutBufferFlushTimer=0,this.defaultStyle={},this.adoptStyle="left","inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline"),this.dirty=!1;let a=null!=(i=null!=(n=t.value)?n:this.element.textContent)?i:"";a=a.trim();const o=pu(this.options),l=new Ma({type:"root",mode:o,body:Qo(a,{context:this.context})});this.model=new class{constructor(e,t,n){this.mathfield=e,this.mode=t,this.silenceNotifications=!1,this._selection={ranges:[[0,0]],direction:"none"},this._anchor=0,this._position=0,this.root=n}dispose(){this.mathfield=void 0}getState(){const e={ranges:[...this._selection.ranges]};return this.selection.direction&&"none"!==this.selection.direction&&(e.direction=this.selection.direction),{content:this.root.toJson(),selection:e,mode:this.mode}}setState(e,t){var n;const i=this.silenceNotifications;this.silenceNotifications=null==(n=null==t?void 0:t.silenceNotifications)||n;let r={};if("undo"===(null==t?void 0:t.type)&&(r={inputType:"historyUndo"}),"redo"===(null==t?void 0:t.type)&&(r={inputType:"historyRedo"}),this.contentWillChange(r)){const t=this.silenceNotifications;this.silenceNotifications=!0,this.mode=e.mode,this.root=Tl(e.content),this.selection=e.selection,this.silenceNotifications=t,this.contentDidChange(r)}this.silenceNotifications=i}get atoms(){return this.root.children}get selection(){return this._selection}set selection(e){this.setSelection(e)}setSelection(e,t){return!(!this.mathfield.contentEditable&&"none"===this.mathfield.userSelect)&&this.deferNotifications({selection:!0},(()=>{var n,i,r;const s=this.normalizeSelection(e,t);if(void 0===s)throw new TypeError("Invalid selection");if(1===s.ranges.length&&s.ranges[0][0]===s.ranges[0][1]){const e=s.ranges[0][0];return this.mathfield.dirty||(null==(n=this.at(e))?void 0:n.parentPrompt)||!this.mathfield.hasEditablePrompts?(this._anchor=e,this._position=e,void(this._selection=s)):(null==(i=this.at(e-1))?void 0:i.parentPrompt)?(this._anchor=this.normalizeOffset(e-1),this._position=this._anchor,void(this._selection=this.normalizeSelection(this._anchor))):(null==(r=this.at(e+1))?void 0:r.parentPrompt)?(this._anchor=this.normalizeOffset(e+1),this._position=this._anchor,void(this._selection=this.normalizeSelection(this._anchor))):(this._anchor=0,this._position=0,void(this._selection={ranges:[[0,0]]}))}const a=Fa(s);"backward"===s.direction?[this._position,this._anchor]=a:[this._anchor,this._position]=a;const o=this.at(a[0]+1),l=this.at(a[1]),c=Ma.commonAncestor(o,l);"array"===(null==c?void 0:c.type)&&o.parent===c&&l.parent,this._selection={ranges:[a],direction:s.direction},console.assert(this._position>=0&&this._position<=this.lastOffset)}))}setPositionHandlingPlaceholder(e){var t;const n=this.at(e);"placeholder"===(null==n?void 0:n.type)?this.setSelection(e-1,e):"placeholder"===(null==(t=null==n?void 0:n.rightSibling)?void 0:t.type)?this.setSelection(e,e+1):this.position=e,n instanceof ul&&n.isSuggestion&&(n.isSuggestion=!1),this.mathfield.stopCoalescingUndo()}get position(){return this._position}set position(e){this.setSelection(e,e)}get anchor(){return this._anchor}get selectionIsCollapsed(){return this._anchor===this._position}get selectionIsPlaceholder(){return 1===Math.abs(this._anchor-this._position)&&"placeholder"===this.at(Math.max(this._anchor,this._position)).type}collapseSelection(e="forward"){return this._anchor!==this._position&&(this.position="backward"===e?Math.min(this._anchor,this._position):Math.max(this._anchor,this._position),!0)}get lastOffset(){return this.atoms.length-1}at(e){return this.atoms[e]}offsetOf(e){return this.atoms.indexOf(e)}getSiblingsRange(e){const t=this.at(e),{parent:n}=t;if(!n)return[0,this.lastOffset];const i=t.parent.branch(t.parentBranch);return[this.offsetOf(i[0]),this.offsetOf(i[i.length-1])]}getBranchRange(e,t){const n=this.at(e).branch(t);return[this.offsetOf(n[0]),this.offsetOf(n[n.length-1])]}getAtoms(e,t,n){let i,r,s=null!=n?n:{};if($a(e)){if(s=null!=t?t:{},e.ranges.length>1)return e.ranges.reduce(((e,t)=>[...e,...this.getAtoms(t,s)]),[]);e=e.ranges[0]}if(Na(e)){if(i=e,!Na(t))return[];r=t}else[i,r]=e,s=null!=t?t:{};if(!Number.isFinite(i))return[];void 0===s.includeChildren&&(s.includeChildren=!1),i<0&&(i=this.lastOffset-i+1),r<0&&(r=this.lastOffset-r+1);const a=Math.min(i,r)+1,o=Math.max(i,r);if(!s.includeChildren&&1===a&&o===this.lastOffset)return[this.root];let l=[];for(let e=a;e<=o;e++){const t=this.atoms[e];Wd(this,t,a,o)&&l.push(t)}return s.includeChildren||(l=l.filter((e=>{let t=!1,{parent:n}=e;for(;n&&!t;)t=Wd(this,n,a,o),n=n.parent;return!t}))),l}getAllAtoms(e=0){const t=[],n=this.lastOffset;for(let i=e;i<=n;i++)t.push(this.atoms[i]);for(let n=0;n<e;n++)t.push(this.atoms[n]);return t}findAtom(e,t=0,n="forward"){let i;const r=this.lastOffset;if("forward"!==n){for(let n=t;n>=0;n--)if(i=this.atoms[n],e(i))return i;for(let n=r;n>t;n--)if(i=this.atoms[n],e(i))return i}else{for(let n=t;n<=r;n++)if(i=this.atoms[n],e(i))return i;for(let n=0;n<t;n++)if(i=this.atoms[n],e(i))return i}}extractAtoms(e){let t=this.getAtoms(e);if(1===t.length&&!t[0].parent){if("root"!==t[0].type)return t=this.root.cells.flat(),this.root=new Ma({type:"root",body:[]}),t;t=[...t[0].body],t.shift()}for(const e of t)e.parent.removeChild(e);return t}deleteAtoms(e){this.extractAtoms(e),this.position=e[0]}atomToString(e,t){const n=null!=t?t:"latex";if(n.startsWith("latex"))return Ma.serialize([e],{expandMacro:"latex-expanded"===n,skipStyles:"latex-unstyled"===n,skipPlaceholders:"latex-without-placeholders"===n,defaultMode:this.mathfield.options.defaultMode});if("math-ml"===n)return od(e);if("spoken"===n)return gd(e);if("spoken-text"===n){const t=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="";const n=gd(e);return window.MathfieldElement.textToSpeechMarkup=t,n}if("spoken-ssml"===n||"spoken-ssml-with-highlighting"===n){const t=window.MathfieldElement.textToSpeechMarkup;window.MathfieldElement.textToSpeechMarkup="ssml";const n=gd(e);return window.MathfieldElement.textToSpeechMarkup=t,n}return"ascii-math"===n?vd(e):(console.error(`MathLive 0.98.5: Unexpected format "${n}`),"")}getValue(e,t,n){if(void 0===e)return this.atomToString(this.root,"latex");if("string"==typeof e&&"math-json"!==e)return this.atomToString(this.root,e);let i,r;if(Na(e)&&Na(t)?(i=[this.normalizeRange([e,t])],r=n):Ba(e)?(i=[this.normalizeRange(e)],r=t):$a(e)?(i=e.ranges,r=t):(i=[this.normalizeRange([0,-1])],r=e),null!=r||(r="latex"),"math-json"===r){if(!window.MathfieldElement.computeEngine)return window[Symbol.for("io.cortexjs.compute-engine")]||console.error('The CortexJS Compute Engine library is not available.\nLoad the library, for example with:\nimport "https://unpkg.com/@cortex-js/compute-engine?module"'),'["Error", "compute-engine-not-available"]';const e=this.getValue({ranges:i},"latex-unstyled");try{const t=window.MathfieldElement.computeEngine.parse(e);return JSON.stringify(t.json)}catch(e){return JSON.stringify(["Error",`'${e.toString()}'`])}}if(r.startsWith("latex")){const e={expandMacro:"latex-expanded"===r,skipStyles:"latex-unstyled"===r,skipPlaceholders:"latex-without-placeholders"===r,defaultMode:this.mathfield.options.defaultMode};return Xs(i.map((t=>Ma.serialize(this.getAtoms(t),e))))}return i.map((e=>this.getAtoms(e).map((e=>this.atomToString(e,r))).join(""))).join("")}extendSelectionTo(e,t){return!(!this.mathfield.contentEditable&&"none"===this.mathfield.userSelect)&&this.deferNotifications({selection:!0},(()=>{const n=this.normalizeRange([e,t]);let[i,r]=n,{parent:s}=this.at(r);if(s&&("genfrac"===s.type||"subsup"===s.type))for(;s!==this.root&&Zd(this,s,[i,r]);)r=this.offsetOf(s),s=s.parent;for(s=this.at(i).parent;s!==this.root&&Zd(this,s,[i,r]);)i=this.offsetOf(s.leftSibling),s=s.parent;if(s=this.at(r).parent,"genfrac"===(null==s?void 0:s.type))for(;s!==this.root&&Zd(this,s,[i,r]);)r=this.offsetOf(s),console.assert(r>=0),s=s.parent;this._position=this.normalizeOffset(t),this._selection={ranges:[[i,r]],direction:"none"}}))}announce(e,t,n=[]){var i,r;(null==(r=null==(i=this.mathfield.host)?void 0:i.dispatchEvent(new CustomEvent("announce",{detail:{command:e,previousPosition:t,atoms:n},cancelable:!0,bubbles:!0,composed:!0})))||r)&&jd(this.mathfield,e,t,n)}deferNotifications(e,t){const n=this._selection,i=this._anchor,r=this._position,s=this.silenceNotifications;this.silenceNotifications=!0;const a=this.root.changeCounter;t();const o=this.root.changeCounter!==a,l=i!==this._anchor||r!==this._position||"different"===function(e,t){if(e.direction===t.direction){const n=e.ranges.length;if(t.ranges.length===n){let i=0;for(;i<n&&"equal"===Oa(e.ranges[i],t.ranges[i]);)i++;return i===n?"equal":"different"}}return"different"}(this._selection,n);return this.silenceNotifications=s,e.content&&o&&this.contentDidChange({inputType:e.type}),e.selection&&l&&this.selectionDidChange(),o||l}normalizeOffset(e){return e>0?e=Math.min(e,this.lastOffset):e<0&&(e=this.lastOffset+e+1),e}normalizeRange(e){let[t,n]=e;return t=this.normalizeOffset(t),n=this.normalizeOffset(n),t<n?[t,n]:[n,t]}normalizeSelection(e,t){var n;let i;if(Na(e)){const n=this.normalizeOffset(e);if(Na(t)){const e=this.normalizeOffset(t);i=n<=e?{ranges:[[n,e]],direction:"none"}:{ranges:[[e,n]],direction:"backward"}}else i={ranges:[[n,n]],direction:"none"}}else if(Ba(e)){const t=this.normalizeOffset(e[0]),n=this.normalizeOffset(e[1]);i=t<=n?{ranges:[[t,n]],direction:"none"}:{ranges:[[n,t]],direction:"backward"}}else $a(e)&&(i={ranges:e.ranges.map((e=>this.normalizeRange(e))),direction:null!=(n=e.direction)?n:"none"});return console.assert(void 0!==i),i}get parentEnvironment(){let e=this.at(this.position).parent;if(e){for(;e.parent&&"array"!==e.type;)e=e.parent;if("array"===e.type)return e}}get cell(){var e;let t=this.at(this.position);if(t){for(;t&&"array"!==(null==(e=t.parent)?void 0:e.type);)t=t.parent;if((null==t?void 0:t.parent)&&"array"===t.parent.type)return t.parentBranch}}contentWillChange(e={}){if(this.silenceNotifications||!this.mathfield)return!0;const t=this.silenceNotifications;this.silenceNotifications=!0;const n=this.mathfield.onContentWillChange(e);return this.silenceNotifications=t,n}contentDidChange(e){var t;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this.mathfield)),this.silenceNotifications||!this.mathfield.host||!this.mathfield)return;const n=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.host.dispatchEvent(new InputEvent("input",h(u({},e),{data:e.data?e.data:null!=(t=e.inputType)?t:"",bubbles:!0,composed:!0}))),this.silenceNotifications=n}selectionDidChange(){if(!this.mathfield)return;if(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this.mathfield)),this.silenceNotifications)return;const e=this.silenceNotifications;this.silenceNotifications=!0,this.mathfield.onSelectionDidChange(),this.silenceNotifications=e}}(this,o,l),this.undoManager=new Au(this.model);const c=[];if(c.push("<span contenteditable=true aria-multiline=false part=keyboard-sink class=ML__keyboard-sink autocapitalize=off autocomplete=off autocorrect=off spellcheck=false inputmode=none tabindex=0></span>"),c.push('<span part=container class=ML__container aria-hidden=true style="visibility:hidden">'),c.push("<span part=content class=ML__content>"),c.push(Cc(this)),c.push("</span>"),window.mathVirtualKeyboard&&(c.push(`<div part=virtual-keyboard-toggle class=ML__virtual-keyboard-toggle role=button ${this.hasEditableContent?"":'style="display:none;"'} data-l10n-tooltip="tooltip.toggle virtual keyboard">`),c.push(Jd),c.push("</div>")),c.push('<div part=menu-toggle class=ML__menu-toggle role=button data-l10n-tooltip="tooltip.menu">'),c.push(Qd),c.push("</div>"),c.push("</span>"),c.push("<span class=ML__sr-only>"),c.push("<span role=status aria-live=assertive aria-atomic=true></span>"),c.push("</span>"),this.element.innerHTML=window.MathfieldElement.createHTML(c.join("")),!this.element.children)return void console.error("%cMathLive 0.98.5: Something went wrong and the mathfield could not be created.%c\nIf you are using Vue, this may be because you are using the runtime-only build of Vue. Make sure to include `runtimeCompiler: true` in your Vue configuration. There may a warning from Vue in the log above.","color:red;font-family:system-ui;font-size:1.2rem;font-weight:bold","color:inherit;font-family:system-ui;font-size:inherit;font-weight:inherit");this._l10Subscription=v.subscribe((()=>v.update(this.element))),v.update(this.element),this.field=this.element.querySelector("[part=content]"),this.field.addEventListener("click",(e=>e.stopImmediatePropagation()),{capture:!1,signal:s}),this.field.addEventListener("wheel",this,{passive:!1,signal:s}),"PointerEvent"in window?this.field.addEventListener("pointerdown",this,{signal:s}):this.field.addEventListener("mousedown",this,{signal:s}),null==(r=this.element.querySelector("[part=virtual-keyboard-toggle]"))||r.addEventListener("click",(()=>{window.mathVirtualKeyboard.visible?window.mathVirtualKeyboard.hide():(window.mathVirtualKeyboard.show({animate:!0}),window.mathVirtualKeyboard.update(yh(this)))}),{signal:s}),this._menu=new Vh(Kd(this),{host:this.host}),this.field.addEventListener("contextmenu",this,{signal:s});const d=this.element.querySelector("[part=menu-toggle]");var p;null==d||d.addEventListener("pointerdown",(e=>{if(e.currentTarget!==d)return;if("closed"!==this._menu.state)return;this.element.classList.add("tracking");const t=d.getBoundingClientRect();this._menu.modifiers=Zl(e),this._menu.show({target:d,location:{x:t.left,y:t.bottom},onDismiss:()=>this.element.classList.remove("tracking")}),e.preventDefault(),e.stopPropagation()}),{signal:s}),(this.model.atoms.length<=1||this.disabled||this.readOnly&&!this.hasEditableContent||"none"===this.userSelect)&&(d.style.display="none"),this.ariaLiveText=this.element.querySelector("[role=status]"),this.keyboardDelegate=function(e,t,n){let i=null,r=null,s=!1,a=!1,o=!1;const l=new AbortController,c=l.signal;return e.addEventListener("keydown",(t=>{s||"Process"===t.key||"CapsLock"===t.code||/(Control|Meta|Alt|Shift)(Left|Right)/.test(t.code)?i=null:(i=t,r=null,n.onKeystroke(t)?e.textContent="":i=null)}),{capture:!0,signal:c}),e.addEventListener("keypress",(e=>{s||(i&&r&&n.onKeystroke(i),r=e)}),{capture:!0,signal:c}),e.addEventListener("compositionstart",(t=>{e.textContent="",s=!0,n.onCompositionStart(t.data)}),{capture:!0,signal:c}),e.addEventListener("compositionupdate",(e=>{s&&n.onCompositionUpdate(e.data)}),{capture:!0,signal:c}),e.addEventListener("compositionend",(t=>{e.textContent="",s&&(s=!1,n.onCompositionEnd(t.data))}),{capture:!0,signal:c}),e.addEventListener("beforeinput",(e=>e.stopImmediatePropagation()),{signal:c}),e.addEventListener("input",(t=>{var i;if(!s&&(e.textContent="","insertCompositionText"!==t.inputType)){if("insertFromPaste"===t.inputType)return t.preventDefault(),void t.stopPropagation();n.onInput(null!=(i=t.data)?i:""),t.preventDefault(),t.stopPropagation()}}),{signal:c}),e.addEventListener("paste",(t=>{e.focus({preventScroll:!0}),e.textContent="",n.onPaste(t)||t.preventDefault(),t.stopImmediatePropagation()}),{signal:c}),e.addEventListener("cut",(e=>n.onCut(e)),{capture:!0,signal:c}),e.addEventListener("copy",(e=>n.onCopy(e)),{capture:!0,signal:c}),e.addEventListener("blur",(s=>{var l,c;if((null==(c=null==(l=s.relatedTarget)?void 0:l._mathfield)?void 0:c.element)===t)return e.focus({preventScroll:!0}),s.preventDefault(),void s.stopPropagation();const u=Ql.state;return"open"===u||"opening"===u||s.relatedTarget===s.target.getRootNode().host?(s.preventDefault(),void s.stopPropagation()):void(o||a||(o=!0,i=null,r=null,n.onBlur(),o=!1))}),{capture:!0,signal:c}),e.addEventListener("focus",(e=>{o||a||(a=!0,n.onFocus(),a=!1)}),{capture:!0,signal:c}),{dispose:()=>l.abort(),cancelComposition:()=>{s&&(e.blur(),requestAnimationFrame((()=>e.focus({preventScroll:!0}))))},blur:()=>{"function"==typeof e.blur&&e.blur()},focus:()=>{a||"function"!=typeof e.focus||e.focus({preventScroll:!0})},hasFocus:()=>Jl()===e,setAriaLabel:t=>e.setAttribute("aria-label",t),setValue:t=>{var n;e.textContent=t,e.style.left="-1000px",null==(n=window.getSelection())||n.selectAllChildren(e)},moveTo:(t,n)=>{e.style.top=`${n}px`,e.style.left=`${t}px`}}}(this.element.querySelector(".ML__keyboard-sink"),this.element,this),window.addEventListener("resize",this,{signal:s}),document.addEventListener("scroll",this,{signal:s}),this.resizeObserver=new ResizeObserver((()=>Tc(this))),this.resizeObserver.observe(this.field),window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle",this,{signal:s}),Ul&&!v.locale.startsWith(Ul.locale)&&(p=v.locale,Ul=Vl.find((e=>p.startsWith(e.locale)))),"ready"!==kc&&document.fonts.ready.then((()=>Ac(this))),e.querySelector("[part=container]").style.removeProperty("visibility"),this.undoManager.startRecording(),this.undoManager.snapshot("set-value")}get defaultStyle(){return this._defaultStyle}set defaultStyle(e){this._defaultStyle=e}get effectiveStyle(){if("none"===this.adoptStyle)return this.defaultStyle;const e=this.model.at(this.model.position),t="right"===this.adoptStyle?e.rightSibling:e;if(!t)return this.defaultStyle;if("group"===t.type){const e=t.branch("body");return!e||e.length<2?{}:"right"===this.adoptStyle?e[1].computedStyle:e[e.length-1].computedStyle}return t.computedStyle}connectToVirtualKeyboard(){this.connectedToVirtualKeyboard||(this.connectedToVirtualKeyboard=!0,window.addEventListener("message",this,{signal:this.eventController.signal}),window.mathVirtualKeyboard.connect(),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this)),Ah(this))}disconnectFromVirtualKeyboard(){this.connectedToVirtualKeyboard&&(window.removeEventListener("message",this),window.mathVirtualKeyboard.disconnect(),this.connectedToVirtualKeyboard=!1,Lh())}showMenu(e){var t,n;const i=null!=(n=null!=(t=null==e?void 0:e.location)?t:eo(this.field))?n:void 0,r=null==e?void 0:e.modifiers,s=this.element.querySelector("[part=container]");return this._menu.show({target:s,location:i,modifiers:r})}get colorMap(){return e=>{var t,n,i;return null!=(i=null==(n=(t=this.options).colorMap)?void 0:n.call(t,e))?i:C(e)}}get backgroundColorMap(){return e=>{var t,n,i,r,s,a;return null!=(a=null!=(s=null==(n=(t=this.options).backgroundColorMap)?void 0:n.call(t,e))?s:null==(r=(i=this.options).colorMap)?void 0:r.call(i,e))?a:L(e)}}get smartFence(){var e;return null!=(e=this.options.smartFence)&&e}get readOnly(){var e;return null!=(e=this.options.readOnly)&&e}get disabled(){var e,t;return null!=(t=null==(e=this.host)?void 0:e.disabled)&&t}get contentEditable(){return!!this.host&&"false"!==this.host.getAttribute("contenteditable")}get userSelect(){if(!this.host)return"";const e=getComputedStyle(this.host);return e.getPropertyValue("user-select")||e.getPropertyValue("-webkit-user-select")}get hasEditableContent(){return!(this.disabled||!this.contentEditable)&&(!this.readOnly||this.hasEditablePrompts)}get hasEditablePrompts(){return this.readOnly&&!this.disabled&&this.contentEditable&&void 0!==this.model.findAtom((e=>"prompt"===e.type&&!e.locked))}get isSelectionEditable(){if(this.disabled||!this.contentEditable)return!1;if(!this.readOnly)return!0;const e=this.model.at(this.model.anchor),t=this.model.at(this.model.position),n=Ma.commonAncestor(e,t);return!("prompt"!==(null==n?void 0:n.type)&&!(null==n?void 0:n.parentPrompt))}get letterShapeStyle(){var e;return null!=(e=this.options.letterShapeStyle)?e:"tex"}get minFontScale(){return this.options.minFontScale}get selectionStyle(){if(this.model.selectionIsCollapsed)return this.effectiveStyle;const e=this.model.getAtoms(this.model.selection);if(0===e.length)return{};const t=u({},e[0].style);for(const n of e)for(const[e,i]of Object.entries(n.style))t[e]!==i&&delete t[e];return t}queryStyle(e){const t=nh(this,e);"verbatimColor"in t&&delete t.verbatimColor,"verbatimBackgroundColor"in t&&delete t.verbatimBackgroundColor;const n=Object.keys(t).length;if(0===n)return"all";if(n>1){for(const e of Object.keys(t)){const n=this.queryStyle({[e]:t[e]});if("none"===n)return"none";if("some"===n)return"some"}return"all"}const i=Object.keys(t)[0],r=t[i];if(this.model.selectionIsCollapsed)return this.effectiveStyle[i]===r?"all":"none";const s=this.model.getAtoms(this.model.selection,{includeChildren:!0});let a=s.length;if(0===a)return"none";let o=0;for(const e of s)"first"!==e.type?e.style[i]===r&&(o+=1):a-=1;return 0===o?"none":o===a?"all":"some"}get keybindings(){var e,t;if(this._keybindings)return this._keybindings;const[n,i]=function(e,t){const n=[],i=[];for(const r of e)try{const e=rc(r,t);if(!e)continue;const n=i.find((t=>t.key===e.key&&t.ifMode===e.ifMode));if(n)throw new Error(`Ambiguous key binding ${r.key} (${sc(r.command)}) matches ${n.key} (${sc(n.command)}) with the ${t.displayName} keyboard layout`);i.push(e)}catch(e){e instanceof Error&&n.push(e.message)}return[i,n]}(this.options.keybindings,null!=(e=Hl())?e:function(){switch(ql()){case"apple":return Fl;case"windows":return Nl;case"linux":return Bl}return Fl}());return(null==(t=Hl())?void 0:t.score)>0&&(this._keybindings=n,i.length>0&&console.error("MathLive 0.98.5: Invalid keybindings for current keyboard layout",i)),n}get menu(){return this._menu}setOptions(e){var t;this.options=u(u({},this.options),uu(e)),this._keybindings=void 0,"inline-math"===this.options.defaultMode?this.element.classList.add("ML__is-inline"):this.element.classList.remove("ML__is-inline");let n=this.options.defaultMode;"inline-math"===n&&(n="math"),(null==(t=this.model.root.firstChild)?void 0:t.mode)!==n&&(this.model.root.firstChild.mode=n),this.options.readOnly&&this.hasFocus()&&window.mathVirtualKeyboard.visible&&this.executeCommand("hideVirtualKeyboard");const i=Ma.serialize([this.model.root],{expandMacro:!1,defaultMode:this.options.defaultMode});("macros"in e||this.model.getValue()!==i)&&Ya.insert(this.model,i,{insertionMode:"replaceAll",selectionMode:"after",format:"latex",silenceNotifications:!0,mode:"math"}),("value"in e||"macros"in e||"registers"in e||"colorMap"in e||"backgroundColorMap"in e||"letterShapeStyle"in e||"minFontScale"in e||"readOnly"in e||"placeholderSymbol"in e)&&Tc(this)}getOptions(e){return hu(this.options,e)}getOption(e){return hu(this.options,e)}async handleEvent(e){var t;if(Qa(this))if(Oc(e)){if(!ao(e.origin,null!=(t=this.options.originValidator)?t:"none"))throw new DOMException(`Message from unknown origin (${e.origin}) cannot be handled`,"SecurityError");const{action:n}=e.data;if("execute-command"===n){const t=e.data.command;if("virtual-keyboard"===Ic(t))return;this.executeCommand(t)}else"update-state"===n||("focus"===n?this.focus({preventScroll:!0}):"blur"===n&&this.blur())}else switch(e.type){case"focus":this.onFocus();break;case"blur":this.onBlur();break;case"mousedown":"none"!==this.userSelect&&ch(this,e);break;case"pointerdown":"none"!==this.userSelect&&(ch(this,e),!1===e.shiftKey&&await jh(e,this.element.querySelector("[part=container]"),this._menu)&&oh.stop());break;case"contextmenu":"none"!==this.userSelect&&!1===e.shiftKey&&await jh(e,this.element.querySelector("[part=container]"),this._menu)&&oh.stop();break;case"virtual-keyboard-toggle":this.hasFocus()&&Ah(this);break;case"resize":case"scroll":this.geometryChangeTimer&&cancelAnimationFrame(this.geometryChangeTimer),this.geometryChangeTimer=requestAnimationFrame((()=>Qa(this)&&this.onGeometryChange()));break;case"wheel":this.onWheel(e);break;default:console.warn("Unexpected event type",e.type)}}dispose(){Qa(this)&&(v.unsubscribe(this._l10Subscription),this.keyboardDelegate.dispose(),this.keyboardDelegate=void 0,this.eventController.abort(),this.eventController=void 0,this.resizeObserver.disconnect(),window.mathVirtualKeyboard.removeEventListener("virtual-keyboard-toggle",this),this.disconnectFromVirtualKeyboard(),this.model.dispose(),delete this.element.mathfield,this.element=void 0,this.host=void 0,this.field=void 0,this.ariaLiveText=void 0,document.getElementById("mathlive-keystroke-caption-panel")&&(pc("mathlive-keystroke-caption-panel"),fo("core"),fo("keystroke-caption")),document.getElementById("mathlive-suggestion-popover")&&(pc("mathlive-suggestion-popover"),fo("suggestion-popover"),fo("core")),document.getElementById("mathlive-environment-popover")&&(pc("mathlive-environment-popover"),fo("environment-popover"),fo("core")))}flushInlineShortcutBuffer(e){if(null!=e||(e={defer:!1}),!e.defer)return this.inlineShortcutBuffer=[],clearTimeout(this.inlineShortcutBufferFlushTimer),void(this.inlineShortcutBufferFlushTimer=0);this.options.inlineShortcutTimeout>0&&(clearTimeout(this.inlineShortcutBufferFlushTimer),this.inlineShortcutBufferFlushTimer=setTimeout((()=>this.flushInlineShortcutBuffer()),this.options.inlineShortcutTimeout))}executeCommand(e){return"virtual-keyboard"===Ic(e)?(this.focus({preventScroll:!0}),window.mathVirtualKeyboard.executeCommand(e),requestAnimationFrame((()=>window.mathVirtualKeyboard.update(yh(this)))),!1):function(e,t){var n;if(!t)return!1;let i,r=[],s=!1,a=!1;f(t)?(i=t[0],r=t.slice(1)):i=t,i=i.replace(/-\w/g,(e=>e[1].toUpperCase()));const o=Dc[i],l=null==o?void 0:o.target;if("model"===l){if(!e.isSelectionEditable&&(null==o?void 0:o.changeContent))return e.model.announce("plonk"),!1;/^(delete|add)/.test(i)&&("deleteBackward"!==i&&e.flushInlineShortcutBuffer(),e.snapshot(i)),/^complete/.test(i)||lc(e),Dc[i].fn(e.model,...r),cc(e),a=!0,s=!0}else if("virtual-keyboard"===l)a=null!=(n=window.mathVirtualKeyboard.executeCommand(t))&&n,s=!0;else{if(!Dc[i])throw new Error(`Unknown command "${i}"`);if(!e.isSelectionEditable&&(null==o?void 0:o.changeContent))return e.model.announce("plonk"),!1;/^(undo|redo)/.test(i)&&e.flushInlineShortcutBuffer(),a=Dc[i].fn(e,...r),s=!0}return"virtual-keyboard"!==l&&(!e.model.selectionIsCollapsed||(null==o?void 0:o.changeSelection)&&"deleteBackward"!==t)&&(e.flushInlineShortcutBuffer(),(null==o?void 0:o.changeContent)||e.stopCoalescingUndo(),e.defaultStyle={}),a&&Tc(e),s}(this,e)}get errors(){return el(this.model.getValue(),{context:this.context})}getValue(e,t,n){return this.model.getValue(e,t,n)}setValue(e,t){var n;void 0===(t=null!=t?t:{mode:"math"}).insertionMode&&(t.insertionMode="replaceAll"),void 0!==t.format&&"auto"!==t.format||(t.format="latex"),void 0!==t.mode&&"auto"!==t.mode||(t.mode=null!=(n=function(e,t){const n=e.at(t);let i;if(n){i=n.mode;let e=n.parent;for(;!i&&e;)e&&(i=e.mode),e=e.parent}return i}(this.model,this.model.position))?n:"math");const i=this.undoManager.canUndo();Ya.insert(this.model,e,t)&&(Tc(this),i||this.undoManager.reset(),this.undoManager.snapshot("set-value"))}get expression(){const e=window.MathfieldElement.computeEngine;return e?e.box(e.parse(this.model.getValue("latex-unstyled"))):(console.error("MathLive 0.98.5: no compute engine available. Make sure the Compute Engine library is loaded."),null)}scrollIntoView(){var e;if(!this.element)return;if(this.host)if(this.options.onScrollIntoView)this.options.onScrollIntoView(this);else if(this.host.scrollIntoView({block:"nearest",inline:"nearest"}),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.container===window.document.body){const t=window.mathVirtualKeyboard.boundingRect,n=this.host.getBoundingClientRect();n.bottom>t.top&&(null==(e=window.document.scrollingElement)||e.scrollBy(0,n.bottom-t.top+8))}this.dirty&&Lc(this,{interactive:!0});const t=this.field.getBoundingClientRect();let n=null;if(this.model.selectionIsCollapsed)n=eo(this.field);else{const e=so(this);if(e.length>0){let i=-1/0,r=-1/0;for(const t of e)t.right>i&&(i=t.right),t.top<r&&(r=t.top);n={x:i+t.left-this.field.scrollLeft,y:r+t.top-this.field.scrollTop,height:0}}}if(this.host&&n){const e=this.host.getBoundingClientRect(),t=n.y;let i=this.host.scrollTop;t<e.top?i=t-e.top+this.host.scrollTop:t>e.bottom&&(i=t-e.bottom+this.host.scrollTop+n.height),this.host.scroll({top:i,left:0})}if(n){const e=n.x-window.scrollX;let i=this.field.scrollLeft;e<t.left?i=e-t.left+this.field.scrollLeft-20:e>t.right&&(i=e-t.right+this.field.scrollLeft+20),this.field.scroll({top:this.field.scrollTop,left:i})}}insert(e,t){return!("string"!=typeof e||0===e.length&&("insertBefore"===(null==t?void 0:t.insertionMode)||"insertAfter"===(null==t?void 0:t.insertionMode))||0===e.length&&this.model.selectionIsCollapsed||(this.flushInlineShortcutBuffer(),(t=null!=t?t:{mode:"math"}).focus&&this.focus(),t.feedback&&(window.MathfieldElement.keypressVibration&&g()&&navigator.vibrate(3),window.MathfieldElement.playSound("keypress")),"\\\\"===e?ku(this.model):"&"===e?Su(this.model):this.model.selectionIsCollapsed?Ya.insert(this.model,e,u({style:this.model.at(this.model.position).computedStyle},t)):Ya.insert(this.model,e,t),this.snapshot(`insert-${this.model.at(this.model.position).type}`),Tc(this),t.scrollIntoView&&this.scrollIntoView(),0))}switchMode(e,t="",n=""){var i;if(this.model.mode===e||!this.hasEditableContent||!this.contentEditable||this.disabled)return;const r=this.model.mode;if(this.model.mode=e,!(null==(i=this.host)?void 0:i.dispatchEvent(new Event("mode-change",{bubbles:!0,composed:!0,cancelable:!0}))))return void(this.model.mode=r);const s=this.model.mode,{model:a}=this;a.deferNotifications({content:Boolean(n)||Boolean(t),selection:!0,type:"insertText"},(()=>{let i=!1;if(this.flushInlineShortcutBuffer(),this.stopCoalescingUndo(),t&&"latex"!==e){const n=Qo(t,{context:this.context,parseMode:e});a.collapseSelection("forward");const r=a.at(a.position);a.position=a.offsetOf(r.parent.addChildrenAfter(n,r)),i=!0}if(this.model.mode=e,"latex"===e){let e,n=a.selectionIsCollapsed;hc(this,"accept");let i=a.at(a.position);if(n)e="\\";else{const r=Fa(a.selection);e=this.model.getValue(r,"latex");const s=this.model.extractAtoms(r);1===s.length&&"placeholder"===s[0].type&&(e=t,n=!0),i=a.at(r[0])}const r=new hl(e);i.parent.addChildAfter(r,i),n?a.position=a.offsetOf(r.lastChild):a.setSelection(a.offsetOf(r.firstChild),a.offsetOf(r.lastChild))}else ac(a).forEach((e=>{e.isError=!1}));if(n){const e=Qo(n,{context:this.context,parseMode:s});a.collapseSelection("forward");const t=a.at(a.position);a.position=a.offsetOf(t.parent.addChildrenAfter(e,t)),i=!0}return Tc(this),this.undoManager.snapshot("latex"===e?"insert-latex":"insert"),i})),this.model.mode=e,window.mathVirtualKeyboard.update(yh(this))}hasFocus(){return!this.blurred}focus(e){var t;this.hasFocus()||(this.keyboardDelegate.focus(),this.connectToVirtualKeyboard(),this.onFocus(),this.model.announce("line")),null!=(t=null==e?void 0:e.preventScroll)&&t||this.scrollIntoView()}blur(){this.disconnectFromVirtualKeyboard(),this.hasFocus()&&this.keyboardDelegate.blur()}select(){this.model.selection={ranges:[[0,this.model.lastOffset]]},this.focus()}applyStyle(e,t={}){var n,i;const r={operation:"set",silenceNotifications:!1};Ba(t)?r.range=t:("toggle"===t.operation&&(r.operation="toggle"),r.range=t.range,r.silenceNotifications=null!=(n=t.silenceNotifications)&&n);const s=nh(this,e),a=null!=(i=r.operation)?i:"set";if(void 0===r.range&&this.model.selectionIsCollapsed){if("set"===a)return void(this.defaultStyle=u(u({},this.defaultStyle),s));const e=u({},this.defaultStyle);for(const t of Object.keys(s))e[t]===s[t]?("color"===t&&delete e.verbatimColor,"backgroundColor"===t&&delete e.verbatimBackgroundColor,delete e[t]):e[t]=s[t];this.defaultStyle=e}else this.model.deferNotifications({content:!r.silenceNotifications,type:"insertText"},(()=>{if(void 0===r.range)for(const e of this.model.selection.ranges)mu(this.model,e,s,{operation:a});else mu(this.model,r.range,s,{operation:a})})),Tc(this)}toggleContextMenu(){var e;return!!this._menu.visible&&("open"===this._menu.state?(this._menu.hide(),!0):(this._menu.show({target:this.element.querySelector("[part=container]"),location:null!=(e=this.getCaretPoint())?e:void 0,onDismiss:()=>{var e;return null==(e=this.element)?void 0:e.focus()}}),!0))}getCaretPoint(){const e=eo(this.field);return e?{x:e.x,y:e.y}:null}setCaretPoint(e,t){const n=ph(this,e,t,{bias:0});if(n<0)return!1;const i=this.model.position;return this.model.position=n,this.model.announce("move",i),Tc(this),!0}getPrompt(e){const t=this.model.findAtom((t=>"prompt"===t.type&&t.placeholderId===e));return console.assert(void 0!==t,"MathLive 0.98.5: no prompts with matching ID found"),t}getPromptValue(e,t){const n=this.getPrompt(e);if(!n)return"";const i=this.model.offsetOf(n.firstChild),r=this.model.offsetOf(n.lastChild);return this.model.getValue(i,r,t)}getPrompts(e){return this.model.getAllAtoms().filter((t=>!("prompt"!==t.type||e&&(e.id&&t.placeholderId!==e.id||e.locked&&t.locked!==e.locked||"undefined"===e.correctness&&t.correctness||e.correctness&&t.correctness!==e.correctness)))).map((e=>e.placeholderId))}setPromptValue(e,t,n){if(void 0!==t){const i=this.getPrompt(e);if(!i)return void console.error(`MathLive 0.98.5: unknown prompt ${e}`);const r=this.model.getBranchRange(this.model.offsetOf(i),"body");this.model.setSelection(r),this.insert(t,h(u({},n),{insertionMode:"replaceSelection"}))}(null==n?void 0:n.silenceNotifications)&&(this.valueOnFocus=this.getValue()),Tc(this)}setPromptState(e,t,n){const i=this.getPrompt(e);i?("undefined"===t?i.correctness=void 0:"string"==typeof t&&(i.correctness=t),"boolean"==typeof n&&(i.locked=n,i.captureSelection=n),Tc(this)):console.error(`MathLive 0.98.5: unknown prompt ${e}`)}getPromptState(e){const t=this.getPrompt(e);return t?[t.correctness,t.locked]:(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[void 0,!0])}getPromptRange(e){const t=this.getPrompt(e);return t?this.model.getBranchRange(this.model.offsetOf(t),"body"):(console.error(`MathLive 0.98.5: unknown prompt ${e}`),[0,0])}canUndo(){return this.undoManager.canUndo()}canRedo(){return this.undoManager.canRedo()}popUndoStack(){this.undoManager.pop()}snapshot(e){var t;this.undoManager.snapshot(e)&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this)),null==(t=this.host)||t.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"snapshot"}})))}stopCoalescingUndo(){this.undoManager.stopCoalescing(this.model.selection)}stopRecording(){this.undoManager.stopRecording()}startRecording(){this.undoManager.startRecording()}undo(){var e;this.undoManager.undo()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this)),null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}redo(){var e;this.undoManager.redo()&&(window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this)),null==(e=this.host)||e.dispatchEvent(new CustomEvent("undo-state-change",{bubbles:!0,composed:!0,detail:{type:"undo"}})))}resetUndo(){var e;null==(e=this.undoManager)||e.reset()}onSelectionDidChange(){var e,t;const n=this.model;this.keyboardDelegate.setValue(n.getValue(this.model.selection,"latex-expanded"));{const t=n.at(n.position),i=null!=(e=t.mode)?e:pu(this.options);this.model.mode!==i&&("latex"===this.model.mode?(hc(this,"accept",{mode:i}),n.position=n.offsetOf(t)):this.switchMode(i))}null==(t=this.host)||t.dispatchEvent(new Event("selection-change",{bubbles:!0,composed:!0})),window.mathVirtualKeyboard.visible&&window.mathVirtualKeyboard.update(yh(this)),Ah(this)}onContentWillChange(e){var t,n,i;return null==(i=null==(n=this.host)?void 0:n.dispatchEvent(new InputEvent("beforeinput",h(u({},e),{data:e.data?e.data:null!=(t=e.inputType)?t:"",cancelable:!0,bubbles:!0,composed:!0}))))||i}onFocus(){!this.focusBlurInProgress&&this.blurred&&(this.focusBlurInProgress=!0,this.blurred=!1,this.keyboardDelegate.focus(),this.stopCoalescingUndo(),Lc(this,{interactive:!0}),this.valueOnFocus=this.model.getValue(),this.hasEditablePrompts&&!this.model.at(this.model.anchor).parentPrompt&&this.executeCommand("moveToNextPlaceholder"),this.focusBlurInProgress=!1)}onBlur(){var e,t,n;if(this.focusBlurInProgress||this.blurred)return;this.focusBlurInProgress=!0,this.stopCoalescingUndo(),this.blurred=!0,this.ariaLiveText.textContent="",_c(this),this.model.getValue()!==this.valueOnFocus&&(null==(e=this.host)||e.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.disconnectFromVirtualKeyboard(),null==(t=this.host)||t.dispatchEvent(new Event("blur",{bubbles:!1,composed:!0})),null==(n=this.host)||n.dispatchEvent(new UIEvent("focusout",{bubbles:!0,composed:!0})),Tc(this),this.focusBlurInProgress=!1,Lh();const i=new AbortController,r=i.signal;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&document.addEventListener("visibilitychange",(()=>{Qa(this)&&"visible"===document.visibilityState&&this.focus({preventScroll:!0})}),{once:!0,signal:r})}),{once:!0,signal:r}),setTimeout((()=>i.abort()),100)}onInput(e){Yu(this,e)}onKeystroke(e){return Zu(this,e)}onCompositionStart(e){this.model.deleteAtoms(Fa(this.model.selection));const t=eo(this.field);t&&requestAnimationFrame((()=>{Lc(this),this.keyboardDelegate.moveTo(t.x,t.y-t.height)}))}onCompositionUpdate(e){!function(e,t){const n=e.at(e.position);if("composition"===n.type)n.value=t;else{const{caret:i}=n;n.caret=void 0;const r=new zo(t,{mode:n.mode});r.caret=i,n.parent.addChildAfter(r,n),e.position+=1}}(this.model,e),Tc(this)}onCompositionEnd(e){!function(e){const t=e.at(e.position);"composition"===t.type&&(t.parent.removeChild(t),e.position-=1)}(this.model),Yu(this,e,{simulateKeystroke:!0})}onCut(e){this.isSelectionEditable?this.model.contentWillChange({inputType:"deleteByCut"})&&(this.stopCoalescingUndo(),Ya.onCopy(this,e),Xd(this.model,Fa(this.model.selection),"deleteByCut"),this.snapshot("cut"),Tc(this)):this.model.announce("plonk")}onCopy(e){Ya.onCopy(this,e)}onPaste(e){let t=this.isSelectionEditable;return t&&(t=Ya.onPaste(this.model.at(this.model.position).mode,this,e.clipboardData)),t||this.model.announce("plonk"),e.preventDefault(),e.stopPropagation(),t}onGeometryChange(){this._menu.hide(),gc(this),Ah(this)}onWheel(e){const t=5*e.deltaX;if(!Number.isFinite(t)||0===t)return;const n=this.field;t<0&&0===n.scrollLeft||t>0&&n.offsetWidth+n.scrollLeft>=n.scrollWidth||(n.scrollBy({top:0,left:t}),e.preventDefault(),e.stopPropagation())}getHTMLElement(e){let t=e;for(;!t.id&&t.hasChildren;)t=e.children[0];return this.field.querySelector(`[data-atom-id="${t.id}"]`)}get context(){var e,t;return{registers:null!=(e=this.options.registers)?e:{},smartFence:this.smartFence,letterShapeStyle:this.letterShapeStyle,minFontScale:this.minFontScale,placeholderSymbol:null!=(t=this.options.placeholderSymbol)?t:"▢",colorMap:e=>this.colorMap(e),backgroundColorMap:e=>this.backgroundColorMap(e),getMacro:e=>oe(e,this.options.macros),atomIdsSettings:{seed:"random",groupNumbers:!1}}}}(a.querySelector(":host > span"),h(u({},null!=(i=null==(n=np.get(this))?void 0:n.options)?i:op(this)),{eventSink:this,value:c})),!np.has(this)){this.upgradeProperty("disabled"),this.upgradeProperty("readonly");for(const t of Object.keys(e.optionsAttributes))this.upgradeProperty(ap(t))}if(null==(r=this._mathfield)?void 0:r.model){if(np.has(this)){const e=this._mathfield,t=np.get(this),n=t.menuItems;e.model.deferNotifications({content:!1,selection:!1},(()=>{const n=t.value;void 0!==n&&e.setValue(n),e.model.selection=t.selection,np.delete(this)})),n&&(this.menuItems=n)}window.queueMicrotask((()=>{this.isConnected&&this.dispatchEvent(new Event("mount",{cancelable:!1,bubbles:!0,composed:!0}))})),Sc()}else this._mathfield=null}disconnectedCallback(){var t,n;if(this.shadowRoot.host.removeEventListener("pointerdown",this,!0),!this._mathfield)return;window.queueMicrotask((()=>this.dispatchEvent(new Event("unmount",{cancelable:!1,bubbles:!0,composed:!0}))));const i=hu(this._mathfield.options,Object.keys(e.optionsAttributes).map((e=>ap(e))));np.set(this,{value:this._mathfield.getValue(),selection:this._mathfield.model.selection,menuItems:null!=(n=null==(t=this._mathfield.menu)?void 0:t.menuItems)?n:void 0,options:i}),this._mathfield.dispose(),this._mathfield=null}upgradeProperty(e){if(this.hasOwnProperty(e)){const t=this[e];delete this[e],"readonly"!==e&&"read-only"!==e||(e="readOnly"),this[e]=t}}attributeChangedCallback(e,t,n){if(t===n)return;const i=null!==n;switch(e){case"contenteditable":Tc(this._mathfield);break;case"disabled":this.disabled=i;break;case"read-only":case"readonly":this.readOnly=i}}get readonly(){return this.hasAttribute("readonly")||this.hasAttribute("read-only")}set readonly(e){const t=Boolean(e);t?(this.setAttribute("readonly",""),lp()?this._internals.ariaReadOnly="true":this.setAttribute("aria-readonly","true"),this.setAttribute("aria-readonly","true")):(lp()?this._internals.ariaReadOnly="false":this.removeAttribute("aria-readonly"),this.removeAttribute("readonly"),this.removeAttribute("read-only")),this._setOptions({readOnly:t})}get disabled(){return this.hasAttribute("disabled")}set disabled(e){var t;const n=Boolean(e);n?this.setAttribute("disabled",""):this.removeAttribute("disabled"),lp()?this._internals.ariaDisabled=n?"true":"false":this.setAttribute("aria-disabled",n?"true":"false"),n&&(null==(t=this._mathfield)?void 0:t.hasFocus)&&window.mathVirtualKeyboard.visible&&this._mathfield.executeCommand("hideVirtualKeyboard")}get value(){return this.getValue()}set value(e){this.setValue(e)}get defaultMode(){return this._getOption("defaultMode")}set defaultMode(e){this._setOptions({defaultMode:e})}get macros(){return this._getOption("macros")}set macros(e){this._setOptions({macros:e})}get registers(){const e=this;return new Proxy({},{get:(t,n)=>{if("string"==typeof n)return e._getOption("registers")[n]},set(t,n,i){return"string"==typeof n&&(e._setOptions({registers:h(u({},e._getOption("registers")),{[n]:i})}),!0)}})}set registers(e){this._setOptions({registers:e})}get colorMap(){return this._getOption("colorMap")}set colorMap(e){this._setOptions({colorMap:e})}get backgroundColorMap(){return this._getOption("backgroundColorMap")}set backgroundColorMap(e){this._setOptions({backgroundColorMap:e})}get letterShapeStyle(){return this._getOption("letterShapeStyle")}set letterShapeStyle(e){this._setOptions({letterShapeStyle:e})}get minFontScale(){return this._getOption("minFontScale")}set minFontScale(e){this._setOptions({minFontScale:e})}get smartMode(){return this._getOption("smartMode")}set smartMode(e){this._setOptions({smartMode:e})}get smartFence(){return this._getOption("smartFence")}set smartFence(e){this._setOptions({smartFence:e})}get smartSuperscript(){return this._getOption("smartSuperscript")}set smartSuperscript(e){this._setOptions({smartSuperscript:e})}get scriptDepth(){return this._getOption("scriptDepth")}set scriptDepth(e){this._setOptions({scriptDepth:e})}get removeExtraneousParentheses(){return this._getOption("removeExtraneousParentheses")}set removeExtraneousParentheses(e){this._setOptions({removeExtraneousParentheses:e})}get mathModeSpace(){return this._getOption("mathModeSpace")}set mathModeSpace(e){this._setOptions({mathModeSpace:e})}get placeholderSymbol(){return this._getOption("placeholderSymbol")}set placeholderSymbol(e){this._setOptions({placeholderSymbol:e})}get popoverPolicy(){return this._getOption("popoverPolicy")}set popoverPolicy(e){this._setOptions({popoverPolicy:e})}get environmentPopoverPolicy(){return this._getOption("environmentPopoverPolicy")}set environmentPopoverPolicy(e){this._setOptions({environmentPopoverPolicy:e})}get menuItems(){var e,t,n;return this._mathfield?null!=(e=this._mathfield.menu._menuItems.map((e=>e.menuItem)))?e:[]:null!=(n=null==(t=np.get(this))?void 0:t.menuItems)?n:[]}set menuItems(e){var t;if(this._mathfield){const n=null==(t=this._mathfield.element)?void 0:t.querySelector("[part=menu-toggle]");n&&(n.style.display=0===e.length?"none":""),this._mathfield.menu.menuItems=e}np.has(this)?np.set(this,h(u({},np.get(this)),{menuItems:e})):np.set(this,{value:void 0,selection:{ranges:[[0,0]]},options:op(this),menuItems:e})}get mathVirtualKeyboardPolicy(){return this._getOption("mathVirtualKeyboardPolicy")}set mathVirtualKeyboardPolicy(e){this._setOptions({mathVirtualKeyboardPolicy:e})}get inlineShortcuts(){return this._getOption("inlineShortcuts")}set inlineShortcuts(e){this._setOptions({inlineShortcuts:e})}get inlineShortcutTimeout(){return this._getOption("inlineShortcutTimeout")}set inlineShortcutTimeout(e){this._setOptions({inlineShortcutTimeout:e})}get keybindings(){return this._getOption("keybindings")}set keybindings(e){this._setOptions({keybindings:e})}get onInlineShortcut(){return this._getOption("onInlineShortcut")}set onInlineShortcut(e){this._setOptions({onInlineShortcut:e})}get onScrollIntoView(){return this._getOption("onScrollIntoView")}set onScrollIntoView(e){this._setOptions({onScrollIntoView:e})}get onExport(){return this._getOption("onExport")}set onExport(e){this._setOptions({onExport:e})}get readOnly(){return this._getOption("readOnly")}set readOnly(e){this._setOptions({readOnly:e})}get isSelectionEditable(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.isSelectionEditable)&&t}setPromptState(e,t,n){var i;null==(i=this._mathfield)||i.setPromptState(e,t,n)}getPromptState(e){var t,n;return null!=(n=null==(t=this._mathfield)?void 0:t.getPromptState(e))?n:[void 0,!0]}get virtualKeyboardTargetOrigin(){return this._getOption("virtualKeyboardTargetOrigin")}set virtualKeyboardTargetOrigin(e){this._setOptions({virtualKeyboardTargetOrigin:e})}get selection(){return this._mathfield?this._mathfield.model.selection:np.has(this)?np.get(this).selection:{ranges:[[0,0]],direction:"forward"}}set selection(e){if("number"==typeof e&&(e={ranges:[[e,e]]}),this._mathfield)return this._mathfield.model.selection=e,void Tc(this._mathfield);np.has(this)?np.set(this,h(u({},np.get(this)),{selection:e})):np.set(this,{value:void 0,selection:e,options:op(this),menuItems:void 0})}get selectionIsCollapsed(){const e=this.selection;return 1===e.ranges.length&&e.ranges[0][0]===e.ranges[0][1]}get position(){return this._mathfield?this._mathfield.model.position:np.has(this)?np.get(this).selection.ranges[0][0]:0}set position(e){this._mathfield&&(this._mathfield.model.position=e,Tc(this._mathfield)),np.has(this)?np.set(this,h(u({},np.get(this)),{selection:{ranges:[[e,e]]}})):np.set(this,{value:void 0,selection:{ranges:[[e,e]]},options:op(this),menuItems:void 0})}getOffsetDepth(e){var t,n;return this._mathfield?(null!=(n=null==(t=this._mathfield.model.at(e))?void 0:t.treeDepth)?n:2)-2:0}get lastOffset(){var e,t;return null!=(t=null==(e=this._mathfield)?void 0:e.model.lastOffset)?t:-1}};rp.version="0.98.5",rp._fontsDirectory="./fonts",rp._soundsDirectory="./sounds",rp.keypressVibration=!0,rp._keypressSound={spacebar:"keypress-spacebar.wav",return:"keypress-return.wav",delete:"keypress-delete.wav",default:"keypress-standard.wav"},rp._plonkSound="plonk.wav",rp.audioBuffers={},rp.createHTML=e=>e,rp._speechEngineRate="100%",rp._speechEngineVoice="Joanna",rp._textToSpeechMarkup="",rp._textToSpeechRules="mathlive",rp._textToSpeechRulesOptions={},rp.speakHook=function(e){var t,n;if(m())if(window.MathfieldElement.speechEngine&&"local"!==window.MathfieldElement.speechEngine)if("amazon"===window.MathfieldElement.speechEngine)if("AWS"in window){const i=new window.AWS.Polly({apiVersion:"2016-06-10"}),r={OutputFormat:"mp3",VoiceId:null!=(t=window.MathfieldElement.speechEngineVoice)?t:"Joanna",Engine:["Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew"].includes(null!=(n=window.MathfieldElement.speechEngineVoice)?n:"Joanna")?"neural":"standard",Text:e,TextType:"ssml"};i.synthesizeSpeech(r,((e,t)=>{if(e)console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${e}`);else if(null==t?void 0:t.AudioStream){const e=new Uint8Array(t.AudioStream),n=new Blob([e.buffer],{type:"audio/mpeg"}),i=URL.createObjectURL(n);new Audio(i).play().catch((e=>console.log(e)))}else console.log("polly.synthesizeSpeech():",t)}))}else console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");else"google"===window.MathfieldElement.speechEngine&&console.error("MathLive 0.98.5: The Google speech engine is not supported yet. Please come again.");else{const t=new SpeechSynthesisUtterance(e);window.speechSynthesis.speak(t)}else console.log("Speak:",e)},rp.readAloudHook=function(e,t){var n;if(!m())return;if("amazon"!==window.MathfieldElement.speechEngine)return console.error("MathLive 0.98.5: Use Amazon TTS Engine for synchronized highlighting"),void("function"==typeof window.MathfieldElement.speakHook&&window.MathfieldElement.speakHook(t));if(!window.AWS)return void console.error("MathLive 0.98.5: AWS SDK not loaded. See https://www.npmjs.com/package/aws-sdk");const i=new window.AWS.Polly({apiVersion:"2016-06-10"}),r={OutputFormat:"json",VoiceId:null!=(n=window.MathfieldElement.speechEngineVoice)?n:"Joanna",Engine:"standard",Text:t,TextType:"ssml",SpeechMarkTypes:["ssml"]};pp().readAloudElement=e,i.synthesizeSpeech(r,((e,n)=>{if(e)return void console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech()\` error: ${e}`);if(!(null==n?void 0:n.AudioStream))return void console.log("polly.synthesizeSpeech():",n);const s=new TextDecoder("utf-8").decode(new Uint8Array(n.AudioStream));pp().readAloudMarks=s.split("\n").map((e=>e?JSON.parse(e):{})),pp().readAloudTokens=[];for(const e of pp().readAloudMarks)e.value&&pp().readAloudTokens.push(e.value);pp().readAloudCurrentMark="",r.OutputFormat="mp3",r.SpeechMarkTypes=[],i.synthesizeSpeech(r,((e,n)=>{if(e)return void console.trace(`MathLive 0.98.5: \`polly.synthesizeSpeech("${t}") error:${e}`);if(!(null==n?void 0:n.AudioStream))return;const i=new Uint8Array(n.AudioStream),r=new Blob([i.buffer],{type:"audio/mpeg"}),s=URL.createObjectURL(r),a=pp();a.readAloudAudio?a.readAloudAudio.pause():(a.readAloudAudio=new Audio,a.readAloudAudio.addEventListener("ended",(()=>{const e=a.readAloudMathfield;a.readAloudStatus="ended",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),e?(Lc(e),a.readAloudElement=null,a.readAloudMathfield=null,a.readAloudTokens=[],a.readAloudMarks=[],a.readAloudCurrentMark=""):ep(a.readAloudElement)})),a.readAloudAudio.addEventListener("timeupdate",(()=>{let e="";const t=1e3*a.readAloudAudio.currentTime+100;for(const n of a.readAloudMarks)n.time<t&&(e=n.value);a.readAloudCurrentMark!==e&&(a.readAloudCurrentToken=e,e&&e===a.readAloudFinalToken?a.readAloudAudio.pause():(a.readAloudCurrentMark=e,tp(a.readAloudElement,a.readAloudCurrentMark)))}))),a.readAloudAudio.src=s,a.readAloudStatus="playing",document.body.dispatchEvent(new Event("read-aloud-status-change",{bubbles:!0,composed:!0})),a.readAloudAudio.play()}))}))},rp._decimalSeparator=".",rp.fractionNavigationOrder="numerator-denominator",rp._isFunction=e=>{var t,n;const i=window.MathfieldElement.computeEngine;return null!=(n=null==(t=null==i?void 0:i.parse(e).domain)?void 0:t.isFunction)&&n};var sp=rp;function ap(e){return e.replace(/[^a-zA-Z\d]+(.)/g,((e,t)=>t.toUpperCase()))}function op(e){const t={readOnly:!1},n=sp.optionsAttributes;return Object.keys(n).forEach((i=>{if(e.hasAttribute(i)){const r=e.getAttribute(i);"placeholder"===i?t.contentPlaceholder=null!=r?r:"":"boolean"===n[i]?t[ap(i)]=!0:"on/off"===n[i]?t[ap(i)]="on"===r||"off"!==r&&void 0:"number"===n[i]?t[ap(i)]=Number.parseFloat(null!=r?r:"0"):t[ap(i)]=r}})),t}function lp(){return!(!("ElementInternals"in window)||!HTMLElement.prototype.attachInternals)&&"role"in window.ElementInternals.prototype}var cp,up,hp,dp=sp;if(m()&&!(null==(cp=window.customElements)?void 0:cp.get("math-field"))){null!=window[up=Symbol.for("io.cortexjs.mathlive")]||(window[up]={});window[Symbol.for("io.cortexjs.mathlive")].version="0.98.5",window.MathfieldElement=sp,null==(hp=window.customElements)||hp.define("math-field",sp)}function pp(){var e;return null!=globalThis[e=Symbol.for("io.cortexjs.mathlive")]||(globalThis[e]={}),globalThis[Symbol.for("io.cortexjs.mathlive")]}Mc({switchKeyboardLayer:function(e,t){const n=lu.singleton;return!!n&&(n.show(),Uc(),n.currentLayer=t,n.render(),n.focus(),!0)},toggleVirtualKeyboard:function(){const e=window.mathVirtualKeyboard;return e.visible?e.hide({animate:!0}):e.show({animate:!0}),!1},hideVirtualKeyboard:()=>(window.mathVirtualKeyboard.hide({animate:!0}),!1),showVirtualKeyboard:()=>(window.mathVirtualKeyboard.show({animate:!0}),!1)},{target:"virtual-keyboard"})}}]); |